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
|
|---|---|---|---|---|---|---|---|---|
vijaylbais/boto
|
boto/ec2/image.py
|
57
|
16344
|
# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
# Copyright (c) 2010, Eucalyptus Systems, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
from boto.ec2.ec2object import EC2Object, TaggedEC2Object
from boto.ec2.blockdevicemapping import BlockDeviceMapping
class ProductCodes(list):
def startElement(self, name, attrs, connection):
pass
def endElement(self, name, value, connection):
if name == 'productCode':
self.append(value)
class BillingProducts(list):
def startElement(self, name, attrs, connection):
pass
def endElement(self, name, value, connection):
if name == 'billingProduct':
self.append(value)
class Image(TaggedEC2Object):
"""
Represents an EC2 Image
"""
def __init__(self, connection=None):
super(Image, self).__init__(connection)
self.id = None
self.location = None
self.state = None
self.ownerId = None # for backwards compatibility
self.owner_id = None
self.owner_alias = None
self.is_public = False
self.architecture = None
self.platform = None
self.type = None
self.kernel_id = None
self.ramdisk_id = None
self.name = None
self.description = None
self.product_codes = ProductCodes()
self.billing_products = BillingProducts()
self.block_device_mapping = None
self.root_device_type = None
self.root_device_name = None
self.virtualization_type = None
self.hypervisor = None
self.instance_lifecycle = None
self.sriov_net_support = None
def __repr__(self):
return 'Image:%s' % self.id
def startElement(self, name, attrs, connection):
retval = super(Image, self).startElement(name, attrs, connection)
if retval is not None:
return retval
if name == 'blockDeviceMapping':
self.block_device_mapping = BlockDeviceMapping()
return self.block_device_mapping
elif name == 'productCodes':
return self.product_codes
elif name == 'billingProducts':
return self.billing_products
else:
return None
def endElement(self, name, value, connection):
if name == 'imageId':
self.id = value
elif name == 'imageLocation':
self.location = value
elif name == 'imageState':
self.state = value
elif name == 'imageOwnerId':
self.ownerId = value # for backwards compatibility
self.owner_id = value
elif name == 'isPublic':
if value == 'false':
self.is_public = False
elif value == 'true':
self.is_public = True
else:
raise Exception(
'Unexpected value of isPublic %s for image %s' % (
value,
self.id
)
)
elif name == 'architecture':
self.architecture = value
elif name == 'imageType':
self.type = value
elif name == 'kernelId':
self.kernel_id = value
elif name == 'ramdiskId':
self.ramdisk_id = value
elif name == 'imageOwnerAlias':
self.owner_alias = value
elif name == 'platform':
self.platform = value
elif name == 'name':
self.name = value
elif name == 'description':
self.description = value
elif name == 'rootDeviceType':
self.root_device_type = value
elif name == 'rootDeviceName':
self.root_device_name = value
elif name == 'virtualizationType':
self.virtualization_type = value
elif name == 'hypervisor':
self.hypervisor = value
elif name == 'instanceLifecycle':
self.instance_lifecycle = value
elif name == 'sriovNetSupport':
self.sriov_net_support = value
else:
setattr(self, name, value)
def _update(self, updated):
self.__dict__.update(updated.__dict__)
def update(self, validate=False, dry_run=False):
"""
Update the image's state information by making a call to fetch
the current image attributes from the service.
:type validate: bool
:param validate: By default, if EC2 returns no data about the
image the update method returns quietly. If
the validate param is True, however, it will
raise a ValueError exception if no data is
returned from EC2.
"""
rs = self.connection.get_all_images([self.id], dry_run=dry_run)
if len(rs) > 0:
img = rs[0]
if img.id == self.id:
self._update(img)
elif validate:
raise ValueError('%s is not a valid Image ID' % self.id)
return self.state
def run(self, min_count=1, max_count=1, key_name=None,
security_groups=None, user_data=None,
addressing_type=None, instance_type='m1.small', placement=None,
kernel_id=None, ramdisk_id=None,
monitoring_enabled=False, subnet_id=None,
block_device_map=None,
disable_api_termination=False,
instance_initiated_shutdown_behavior=None,
private_ip_address=None,
placement_group=None, security_group_ids=None,
additional_info=None, instance_profile_name=None,
instance_profile_arn=None, tenancy=None, dry_run=False):
"""
Runs this instance.
:type min_count: int
:param min_count: The minimum number of instances to start
:type max_count: int
:param max_count: The maximum number of instances to start
:type key_name: string
:param key_name: The name of the key pair with which to
launch instances.
:type security_groups: list of strings
:param security_groups: The names of the security groups with which to
associate instances.
:type user_data: string
:param user_data: The Base64-encoded MIME user data to be made
available to the instance(s) in this reservation.
:type instance_type: string
:param instance_type: The type of instance to run:
* t1.micro
* m1.small
* m1.medium
* m1.large
* m1.xlarge
* m3.medium
* m3.large
* m3.xlarge
* m3.2xlarge
* c1.medium
* c1.xlarge
* m2.xlarge
* m2.2xlarge
* m2.4xlarge
* cr1.8xlarge
* hi1.4xlarge
* hs1.8xlarge
* cc1.4xlarge
* cg1.4xlarge
* cc2.8xlarge
* g2.2xlarge
* c3.large
* c3.xlarge
* c3.2xlarge
* c3.4xlarge
* c3.8xlarge
* c4.large
* c4.xlarge
* c4.2xlarge
* c4.4xlarge
* c4.8xlarge
* i2.xlarge
* i2.2xlarge
* i2.4xlarge
* i2.8xlarge
* t2.micro
* t2.small
* t2.medium
:type placement: string
:param placement: The Availability Zone to launch the instance into.
:type kernel_id: string
:param kernel_id: The ID of the kernel with which to launch the
instances.
:type ramdisk_id: string
:param ramdisk_id: The ID of the RAM disk with which to launch the
instances.
:type monitoring_enabled: bool
:param monitoring_enabled: Enable CloudWatch monitoring on
the instance.
:type subnet_id: string
:param subnet_id: The subnet ID within which to launch the instances
for VPC.
:type private_ip_address: string
:param private_ip_address: If you're using VPC, you can
optionally use this parameter to assign the instance a
specific available IP address from the subnet (e.g.,
10.0.0.25).
:type block_device_map: :class:`boto.ec2.blockdevicemapping.BlockDeviceMapping`
:param block_device_map: A BlockDeviceMapping data structure
describing the EBS volumes associated with the Image.
:type disable_api_termination: bool
:param disable_api_termination: If True, the instances will be locked
and will not be able to be terminated via the API.
:type instance_initiated_shutdown_behavior: string
:param instance_initiated_shutdown_behavior: Specifies whether the
instance stops or terminates on instance-initiated shutdown.
Valid values are:
* stop
* terminate
:type placement_group: string
:param placement_group: If specified, this is the name of the placement
group in which the instance(s) will be launched.
:type additional_info: string
:param additional_info: Specifies additional information to make
available to the instance(s).
:type security_group_ids: list of strings
:param security_group_ids: The ID of the VPC security groups with
which to associate instances.
:type instance_profile_name: string
:param instance_profile_name: The name of
the IAM Instance Profile (IIP) to associate with the instances.
:type instance_profile_arn: string
:param instance_profile_arn: The Amazon resource name (ARN) of
the IAM Instance Profile (IIP) to associate with the instances.
:type tenancy: string
:param tenancy: The tenancy of the instance you want to
launch. An instance with a tenancy of 'dedicated' runs on
single-tenant hardware and can only be launched into a
VPC. Valid values are:"default" or "dedicated".
NOTE: To use dedicated tenancy you MUST specify a VPC
subnet-ID as well.
:rtype: Reservation
:return: The :class:`boto.ec2.instance.Reservation` associated with
the request for machines
"""
return self.connection.run_instances(self.id, min_count, max_count,
key_name, security_groups,
user_data, addressing_type,
instance_type, placement,
kernel_id, ramdisk_id,
monitoring_enabled, subnet_id,
block_device_map, disable_api_termination,
instance_initiated_shutdown_behavior,
private_ip_address, placement_group,
security_group_ids=security_group_ids,
additional_info=additional_info,
instance_profile_name=instance_profile_name,
instance_profile_arn=instance_profile_arn,
tenancy=tenancy, dry_run=dry_run)
def deregister(self, delete_snapshot=False, dry_run=False):
return self.connection.deregister_image(
self.id,
delete_snapshot,
dry_run=dry_run
)
def get_launch_permissions(self, dry_run=False):
img_attrs = self.connection.get_image_attribute(
self.id,
'launchPermission',
dry_run=dry_run
)
return img_attrs.attrs
def set_launch_permissions(self, user_ids=None, group_names=None,
dry_run=False):
return self.connection.modify_image_attribute(self.id,
'launchPermission',
'add',
user_ids,
group_names,
dry_run=dry_run)
def remove_launch_permissions(self, user_ids=None, group_names=None,
dry_run=False):
return self.connection.modify_image_attribute(self.id,
'launchPermission',
'remove',
user_ids,
group_names,
dry_run=dry_run)
def reset_launch_attributes(self, dry_run=False):
return self.connection.reset_image_attribute(
self.id,
'launchPermission',
dry_run=dry_run
)
def get_kernel(self, dry_run=False):
img_attrs = self.connection.get_image_attribute(
self.id,
'kernel',
dry_run=dry_run
)
return img_attrs.kernel
def get_ramdisk(self, dry_run=False):
img_attrs = self.connection.get_image_attribute(
self.id,
'ramdisk',
dry_run=dry_run
)
return img_attrs.ramdisk
class ImageAttribute(object):
def __init__(self, parent=None):
self.name = None
self.kernel = None
self.ramdisk = None
self.attrs = {}
def startElement(self, name, attrs, connection):
if name == 'blockDeviceMapping':
self.attrs['block_device_mapping'] = BlockDeviceMapping()
return self.attrs['block_device_mapping']
else:
return None
def endElement(self, name, value, connection):
if name == 'launchPermission':
self.name = 'launch_permission'
elif name == 'group':
if 'groups' in self.attrs:
self.attrs['groups'].append(value)
else:
self.attrs['groups'] = [value]
elif name == 'userId':
if 'user_ids' in self.attrs:
self.attrs['user_ids'].append(value)
else:
self.attrs['user_ids'] = [value]
elif name == 'productCode':
if 'product_codes' in self.attrs:
self.attrs['product_codes'].append(value)
else:
self.attrs['product_codes'] = [value]
elif name == 'imageId':
self.image_id = value
elif name == 'kernel':
self.kernel = value
elif name == 'ramdisk':
self.ramdisk = value
else:
setattr(self, name, value)
class CopyImage(object):
def __init__(self, parent=None):
self._parent = parent
self.image_id = None
def startElement(self, name, attrs, connection):
pass
def endElement(self, name, value, connection):
if name == 'imageId':
self.image_id = value
|
mit
|
[
3,
1898,
334,
67,
9,
8315,
13,
6542,
603,
9414,
598,
26272,
1455,
921,
71,
26272,
14,
1308,
15,
199,
3,
1898,
334,
67,
9,
7129,
12,
662,
85,
915,
89,
541,
527,
15285,
12,
3277,
14,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
199,
504,
6055,
14,
825,
18,
14,
825,
18,
785,
492,
15352,
18,
1692,
12,
32121,
4220,
18,
1692,
199,
504,
6055,
14,
825,
18,
14,
1457,
1782,
4745,
492,
8651,
2510,
7674,
421,
199,
533,
12705,
14060,
8,
513,
304,
272,
347,
26325,
8,
277,
12,
536,
12,
3290,
12,
1950,
304,
267,
986,
339,
347,
28920,
8,
277,
12,
536,
12,
574,
12,
1950,
304,
267,
340,
536,
508,
283,
2558,
3034,
356,
288,
291,
14,
740,
8,
585,
9,
421,
199,
533,
699,
12687,
29631,
8,
513,
304,
272,
347,
26325,
8,
277,
12,
536,
12,
3290,
12,
1950,
304,
267,
986,
339,
347,
28920,
8,
277,
12,
536,
12,
574,
12,
1950,
304,
267,
340,
536,
508,
283,
19929,
5884,
356,
288,
291,
14,
740,
8,
585,
9,
421,
199,
533,
6047,
8,
26403,
4220,
18,
1692,
304,
272,
408,
272,
21591,
376,
15352,
18,
6047,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1950,
29,
403,
304,
267,
1613,
8,
3491,
12,
291,
2843,
826,
721,
2105,
9,
267,
291,
14,
344,
275,
488,
267,
291,
14,
1985,
275,
488,
267,
291,
14,
929,
275,
488,
267,
291,
14,
4597,
1304,
275,
488,
221,
327,
367,
8552,
7163,
267,
291,
14,
4597,
63,
344,
275,
488,
267,
291,
14,
4597,
63,
3620,
275,
488,
267,
291,
14,
374,
63,
3455,
275,
756,
267,
291,
14,
19134,
275,
488,
267,
291,
14,
3246,
275,
488,
267,
291,
14,
466,
275,
488,
267,
291,
14,
4989,
63,
344,
275,
488,
267,
291,
14,
26541,
63,
344,
275,
488,
267,
291,
14,
354,
275,
488,
267,
291,
14,
1802,
275,
488,
267,
291,
14,
2558,
63,
6021,
275,
12705,
14060,
342,
267,
291,
14,
19929,
63,
13336,
275,
699,
12687,
29631,
342,
267,
291,
14,
1457,
63,
1782,
63,
4745,
275,
488,
267,
291,
14,
1231,
63,
1782,
63,
466,
275,
488,
267,
291,
14,
1231,
63,
1782,
63,
354,
275,
488,
267,
291,
14,
2065,
2072,
63,
466,
275,
488,
267,
291,
14,
18237,
275,
488,
267,
291,
14,
842,
63,
28346,
275,
488,
267,
291,
14,
83,
322,
8822,
63,
846,
63,
4058,
275,
488,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
3491,
2689,
83,
7,
450,
291,
14,
344,
339,
347,
26325,
8,
277,
12,
536,
12,
3290,
12,
1950,
304,
267,
9151,
275,
1613,
8,
3491,
12,
291,
680,
30398,
8,
354,
12,
3290,
12,
1950,
9,
267,
340,
9151,
365,
440,
488,
26,
288,
372,
9151,
267,
340,
536,
508,
283,
1457,
2510,
7674,
356,
288,
291,
14,
1457,
63,
1782,
63,
4745,
275,
8651,
2510,
7674,
342,
288,
372,
291,
14,
1457,
63,
1782,
63,
4745,
267,
916,
536,
508,
283,
2558,
14060,
356,
288,
372,
291,
14,
2558,
63,
6021,
267,
916,
536,
508,
283,
19929,
29631,
356,
288,
372,
291,
14,
19929,
63,
13336,
267,
587,
26,
288,
372,
488,
339,
347,
28920,
8,
277,
12,
536,
12,
574,
12,
1950,
304,
267,
340,
536,
508,
283,
1569,
1304,
356,
288,
291,
14,
344,
275,
574,
267,
916,
536,
508,
283,
1569,
6592,
356,
288,
291,
14,
1985,
275,
574,
267,
916,
536,
508,
283,
1569,
2223,
356,
288,
291,
14,
929,
275,
574,
267,
916,
536,
508,
283,
1569,
14919,
1304,
356,
288,
291,
14,
4597,
1304,
275,
574,
327,
367,
8552,
7163,
288,
291,
14,
4597,
63,
344,
275,
574,
267,
916,
536,
508,
283,
374,
9885,
356,
288,
340,
574,
508,
283,
3910,
356,
355,
291,
14,
374,
63,
3455,
275,
756,
288,
916,
574,
508,
283,
2052,
356,
355,
291,
14,
374,
63,
3455,
275,
715,
288,
587,
26,
355,
746,
2186,
8,
490,
283,
8708,
574,
402,
365,
9885,
450,
83,
367,
1834,
450,
83,
7,
450,
334,
717,
574,
12,
717,
291,
14,
344,
490,
776,
355,
776,
267,
916,
536,
508,
283,
19134,
356,
288,
291,
14,
19134,
275,
574,
267,
916,
536,
508,
283,
1569,
804,
356,
288,
291,
14,
466,
275,
574,
267,
916,
536,
508,
283,
4989,
1304,
356,
288,
291,
14,
4989,
63,
344,
275,
574,
267,
916,
536,
508,
283,
26541,
1304,
356,
288,
291,
14,
26541,
63,
344,
275,
574,
267,
916,
536,
508,
283,
1569,
14919,
14149,
356,
288,
291,
14,
4597,
63,
3620,
275,
574,
267,
916,
536,
508,
283,
3246,
356,
288,
291,
14,
3246,
275,
574,
267,
916,
536,
508,
283,
354,
356,
288,
291,
14,
354,
275,
574,
267,
916,
536,
508,
283,
1802,
356,
288,
291,
14,
1802,
275
] |
[
1898,
334,
67,
9,
8315,
13,
6542,
603,
9414,
598,
26272,
1455,
921,
71,
26272,
14,
1308,
15,
199,
3,
1898,
334,
67,
9,
7129,
12,
662,
85,
915,
89,
541,
527,
15285,
12,
3277,
14,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
199,
504,
6055,
14,
825,
18,
14,
825,
18,
785,
492,
15352,
18,
1692,
12,
32121,
4220,
18,
1692,
199,
504,
6055,
14,
825,
18,
14,
1457,
1782,
4745,
492,
8651,
2510,
7674,
421,
199,
533,
12705,
14060,
8,
513,
304,
272,
347,
26325,
8,
277,
12,
536,
12,
3290,
12,
1950,
304,
267,
986,
339,
347,
28920,
8,
277,
12,
536,
12,
574,
12,
1950,
304,
267,
340,
536,
508,
283,
2558,
3034,
356,
288,
291,
14,
740,
8,
585,
9,
421,
199,
533,
699,
12687,
29631,
8,
513,
304,
272,
347,
26325,
8,
277,
12,
536,
12,
3290,
12,
1950,
304,
267,
986,
339,
347,
28920,
8,
277,
12,
536,
12,
574,
12,
1950,
304,
267,
340,
536,
508,
283,
19929,
5884,
356,
288,
291,
14,
740,
8,
585,
9,
421,
199,
533,
6047,
8,
26403,
4220,
18,
1692,
304,
272,
408,
272,
21591,
376,
15352,
18,
6047,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1950,
29,
403,
304,
267,
1613,
8,
3491,
12,
291,
2843,
826,
721,
2105,
9,
267,
291,
14,
344,
275,
488,
267,
291,
14,
1985,
275,
488,
267,
291,
14,
929,
275,
488,
267,
291,
14,
4597,
1304,
275,
488,
221,
327,
367,
8552,
7163,
267,
291,
14,
4597,
63,
344,
275,
488,
267,
291,
14,
4597,
63,
3620,
275,
488,
267,
291,
14,
374,
63,
3455,
275,
756,
267,
291,
14,
19134,
275,
488,
267,
291,
14,
3246,
275,
488,
267,
291,
14,
466,
275,
488,
267,
291,
14,
4989,
63,
344,
275,
488,
267,
291,
14,
26541,
63,
344,
275,
488,
267,
291,
14,
354,
275,
488,
267,
291,
14,
1802,
275,
488,
267,
291,
14,
2558,
63,
6021,
275,
12705,
14060,
342,
267,
291,
14,
19929,
63,
13336,
275,
699,
12687,
29631,
342,
267,
291,
14,
1457,
63,
1782,
63,
4745,
275,
488,
267,
291,
14,
1231,
63,
1782,
63,
466,
275,
488,
267,
291,
14,
1231,
63,
1782,
63,
354,
275,
488,
267,
291,
14,
2065,
2072,
63,
466,
275,
488,
267,
291,
14,
18237,
275,
488,
267,
291,
14,
842,
63,
28346,
275,
488,
267,
291,
14,
83,
322,
8822,
63,
846,
63,
4058,
275,
488,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
3491,
2689,
83,
7,
450,
291,
14,
344,
339,
347,
26325,
8,
277,
12,
536,
12,
3290,
12,
1950,
304,
267,
9151,
275,
1613,
8,
3491,
12,
291,
680,
30398,
8,
354,
12,
3290,
12,
1950,
9,
267,
340,
9151,
365,
440,
488,
26,
288,
372,
9151,
267,
340,
536,
508,
283,
1457,
2510,
7674,
356,
288,
291,
14,
1457,
63,
1782,
63,
4745,
275,
8651,
2510,
7674,
342,
288,
372,
291,
14,
1457,
63,
1782,
63,
4745,
267,
916,
536,
508,
283,
2558,
14060,
356,
288,
372,
291,
14,
2558,
63,
6021,
267,
916,
536,
508,
283,
19929,
29631,
356,
288,
372,
291,
14,
19929,
63,
13336,
267,
587,
26,
288,
372,
488,
339,
347,
28920,
8,
277,
12,
536,
12,
574,
12,
1950,
304,
267,
340,
536,
508,
283,
1569,
1304,
356,
288,
291,
14,
344,
275,
574,
267,
916,
536,
508,
283,
1569,
6592,
356,
288,
291,
14,
1985,
275,
574,
267,
916,
536,
508,
283,
1569,
2223,
356,
288,
291,
14,
929,
275,
574,
267,
916,
536,
508,
283,
1569,
14919,
1304,
356,
288,
291,
14,
4597,
1304,
275,
574,
327,
367,
8552,
7163,
288,
291,
14,
4597,
63,
344,
275,
574,
267,
916,
536,
508,
283,
374,
9885,
356,
288,
340,
574,
508,
283,
3910,
356,
355,
291,
14,
374,
63,
3455,
275,
756,
288,
916,
574,
508,
283,
2052,
356,
355,
291,
14,
374,
63,
3455,
275,
715,
288,
587,
26,
355,
746,
2186,
8,
490,
283,
8708,
574,
402,
365,
9885,
450,
83,
367,
1834,
450,
83,
7,
450,
334,
717,
574,
12,
717,
291,
14,
344,
490,
776,
355,
776,
267,
916,
536,
508,
283,
19134,
356,
288,
291,
14,
19134,
275,
574,
267,
916,
536,
508,
283,
1569,
804,
356,
288,
291,
14,
466,
275,
574,
267,
916,
536,
508,
283,
4989,
1304,
356,
288,
291,
14,
4989,
63,
344,
275,
574,
267,
916,
536,
508,
283,
26541,
1304,
356,
288,
291,
14,
26541,
63,
344,
275,
574,
267,
916,
536,
508,
283,
1569,
14919,
14149,
356,
288,
291,
14,
4597,
63,
3620,
275,
574,
267,
916,
536,
508,
283,
3246,
356,
288,
291,
14,
3246,
275,
574,
267,
916,
536,
508,
283,
354,
356,
288,
291,
14,
354,
275,
574,
267,
916,
536,
508,
283,
1802,
356,
288,
291,
14,
1802,
275,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
dr-robertk/opm-common
|
python/opm/tools/time_vector.py
|
5
|
11656
|
import datetime
from operator import attrgetter
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from opm.io.parser import Parser
# This is from the TimeMap.cpp implementation in opm
ecl_month = {"JAN" : 1,
"FEB" : 2,
"MAR" : 3,
"APR" : 4,
"MAI" : 5,
"MAY" : 5,
"JUN" : 6,
"JLY" : 7,
"JUL" : 7,
"AUG" : 8,
"SEP" : 9,
"OCT" : 10,
"OKT" : 10,
"NOV" : 11,
"DEC" : 12,
"DES" : 12}
inv_ecl_month = {1 : "JAN",
2 : "FEB",
3 : "MAR",
4 : "APR",
5 : "MAY",
6 : "JUN",
7 : "JUL",
8 : "AUG",
9 : "SEP",
10: "OCT",
11 : "NOV",
12 : "DEC"}
def _make_datetime(dates_record):
day = dates_record[0].get_int(0)
month = dates_record[1].get_str(0)
year = dates_record[2].get_int(0)
date_dt = datetime.datetime(year, ecl_month[month], day)
if len(dates_record) < 4:
return date_dt
else:
time_str = dates_record[3].get_str(0)
time_list = time_str.split(':')
hour = minute = second = microsecond = 0
hour = int(time_list[0])
if len(time_list)>1:
minute = int(time_list[1])
if len(time_list)>2:
sec_list = time_list[2].split('.')
second = int(sec_list[0])
if len(sec_list)>1:
ms_str = sec_list[1].strip()
npad = 6-len(ms_str)
ms_str += "".join(["0" for i in range(npad)])
microsecond = int(ms_str)
return datetime.datetime(year, ecl_month[month], day, hour, minute, second, microsecond)
class TimeStep(object):
def __init__(self, dt, keywords):
"""The TimeStep class consist of a list of keywords and a corresponding date.
Observe that the date value corresponds to a DATES / TSTEP keyword
following *after* the keywords; i.e. if the TimeStep instance contains
a WCONHIST keyword the settings in that keyword should apply *until*
the date specified is reached. See the documentation of the TimeVector
class for more details of the relationship between TimeVector and
TimeStep.
"""
self.dt = dt
self.keywords = keywords
self.tstep = None
self.is_start = False
@classmethod
def create_first(cls, dt):
ts = cls(dt, [])
ts.is_start = True
return ts
def add_keyword(self, kw):
self.keywords.append(kw)
def __len__(self):
return len(self.keywords)
def __contains__(self, arg):
for kw in self.keywords:
if arg == kw.name:
return True
return False
def __str__(self):
string = StringIO()
if not self.is_start:
day = self.dt.day
month = self.dt.month
year = self.dt.year
if not self.dt.time():
string.write("DATES\n {day} '{month}' {year}/\n/\n\n".format( day=day, month = inv_ecl_month[month], year=year))
else:
hour = self.dt.hour
minute = self.dt.minute
second = self.dt.second + self.dt.microsecond*1.0e-6
string.write("DATES\n {day} '{month}' {year} {hour:02d}:{minute:02d}:{second:2.6f} /\n/\n\n".format( day=day, month = inv_ecl_month[month], year=year, hour=hour, minute=minute, second=second))
for kw in self.keywords:
string.write(str(kw))
string.write("\n")
return string.getvalue()
class TimeVector(object):
def __init__(self, start_date, base_string = None, base_file = None):
"""The TimeVector class is a simple vector class with DATES/TSTEP blocks.
The TimeVector class is a basic building block for tools designed to
update schedule files. A schedule file consists of a list of keywords
related to the dynamic properties of the field, like opening and
closing wells, specifiying rates and so on. The temporal advancement of
the simulator is controlled by DATES and TSTEP keywords. A typical
schedule section can look like this:
--- Step 1 -----------------------
WELSPECS
'C1' 'G1' 10 10 10 'OIL' /
/
COMPDAT
'C1' 15 20 10 16 'OPEN' /
'C1' 15 21 16 16 'OPEN' /
/
WCONHIST
'C1' 'OPEN' 'ORAT' 1000 /
/
--- Step 2 ----------------------
DATES
10 'MAY' 2016 /
/
WCONHIST
'C1' 'OPEN' 'ORAT' 2000 /
/
--- Step 3 ----------------------
TSTEP
10 /
WELSPECS
'W2' 'G1' 5 5 5 'OIL' /
/
COMPDAT
'W2' 10 10 7 10 'OPEN' /
/
WCONHIST
'C1' 'OPEN' 'ORAT' 3000 /
'W2' 'OPEN' 'ORAT' 1500 /
/
--- Step 4 ----------------------
DATES
30 'MAY' 2016 /
/
As indicated above the DATES and TSTEP keywords act as delimiters in
the schedule file. In the TimeVector class the fundamental unit is
TimeStep instance which consists of a list of keywords, and a
terminating DATES or TSTEP keyword, the example above would correspond
to a TimeVector with three TimeStep instances.
Basic usage example:
#!/usr/bin/env python
from opm.tools import TimeVector
# Create vector and load history.
tv = TimeVector( start )
tv.load("history.sch")
# Load predictions from another file
tv.load("prediction.sch")
# Insert the definition of one particular well at
# a specifed date.
tv.load("extra_wll.sch", date = datetime.datetime(2018,10,1))
# Check if we have a certain timestep:
if datetime.datetime(2017,1,1) in tv:
print("We have it!")
else:
print("No such date")
# Dump the updated schedule content to a file:
with open("schedule","w") as f:
f.write(str(tv))
"""
if base_string and base_file:
raise ValueError("Can only supply one of base_string and base_file arguments")
self.start_date = datetime.datetime( start_date.year, start_date.month, start_date.day)
self.time_steps_dict = {}
self.time_steps_list = []
ts = TimeStep.create_first(self.start_date)
self._add_dates_block(ts)
start_dt = datetime.datetime(start_date.year, start_date.month, start_date.day)
if base_file:
deck = Parser().parse(base_file)
self._add_deck(deck, start_dt)
if base_string:
deck = Parser().parse_string(base_string)
self._add_deck(deck, start_dt)
def __len__(self):
"""
The number of timesteps in the vector.
"""
return len(self.time_steps_dict)
def __contains__(self, dt):
"""
Will return true if the vector contains a timestep at date dt.
"""
if isinstance(dt, datetime.date):
dt = datetime.datetime(dt.year, dt.month, dt.day)
return dt in self.time_steps_dict
def __getitem__(self, index):
"""Will look up a timestep in the vector.
The index argument can either be an integer or a datetime.date/datetime instance.
"""
if isinstance(index,int):
return self.time_steps_list[index]
else:
if not isinstance(index,datetime.datetime) and isinstance(index,datetime.date):
index = datetime.datetime(index.year, index.month, index.day)
return self.time_steps_dict[index]
def _add_dates_block(self, ts):
self.time_steps_dict[ts.dt] = ts
self.time_steps_list.append(ts)
def delete(self, dt):
del self.time_steps_dict[dt]
for (index,ts) in enumerate(self.time_steps_list):
if ts.dt == dt:
del self.time_steps_list[index]
break
def add_keywords(self, dt, keywords):
if dt < self.start_date:
raise ValueError("Invalid datetime argument: {}".format(dt))
if dt in self.time_steps_dict:
ts = self[dt]
for kw in keywords:
ts.add_keyword(kw)
else:
ts = TimeStep(dt, keywords)
self._add_dates_block(ts)
self.time_steps_list.sort( key = attrgetter("dt"))
def _add_deck(self, deck, start_date):
first_kw = deck[0]
if start_date is None:
if first_kw.name != "DATES":
raise ValueError("When loading you must *either* specify date - or file must start with DATES keyword")
dt = _make_datetime(first_kw[len(first_kw) - 1])
else:
if first_kw.name == "DATES":
raise ValueError("When loading you must *either* specify date - or file must start with DATES keyword")
dt = start_date
keywords = []
for kw in deck:
if kw.name == "DATES":
self.add_keywords(dt, keywords)
for index in range(len(kw)-1):
dt = _make_datetime(kw[index])
self.add_keywords(dt, [])
dt = _make_datetime(kw[len(kw)-1])
keywords = []
continue
#if kw.name == "TSTEP":
#raise ValueError("Must block the ranges with active TSTEP - getting a DATES in there is ERROR")
keywords.append(kw)
self.add_keywords(dt, keywords)
def load(self, filename, date = None):
"""Will parse a Schedule file and add the keywords to the current TimeVector.
You can call the load() method repeatedly, the different timesteps will
be ordered chronologically. If a timestep is already present the
keywords will be appended.
The optional date argument can be used to insert schedule file
fragments which do not have any DATES / TSTEP keywords. Assuming you
have a base file 'base.sch' and a small fragment 'well.sch' with the
WELSPECS and COMPDAT keywords to create one well, then the new well can
be added 1.st of April 2017 as this:
tv = TimeVector( start )
tv.load("base.sch")
tv.load("well.sch", date = datetime.datetime(2017, 4, 1))
"""
deck = Parser().parse(filename)
self._add_deck(deck, date)
def load_string(self, deck_string, date = None):
"""
Like load() - but load from a string literal instead of file.
"""
deck = Parser().parse_string(deck_string)
self._add_deck(deck, date)
def __str__(self):
"""Will return a string representation of the vector.
The output from this method should be valid Schedule input which can be
passed to a simulator.
"""
string = StringIO()
for ts in self:
string.write(str(ts))
return string.getvalue()
@property
def dates(self):
"""
Will return a list of all the dates in the vector.
"""
return [ x.dt for x in self.time_steps_list ]
|
gpl-3.0
|
[
646,
2197,
199,
199,
504,
4182,
492,
21829,
199,
893,
26,
272,
687,
5228,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5890,
492,
5228,
199,
199,
504,
1687,
77,
14,
2308,
14,
2087,
492,
10191,
199,
199,
3,
961,
365,
687,
314,
4703,
2956,
14,
5910,
4514,
315,
1687,
77,
199,
69,
429,
63,
4482,
275,
2420,
42,
879,
2,
520,
413,
12,
1467,
298,
5100,
34,
2,
520,
499,
12,
1467,
298,
45,
689,
2,
520,
650,
12,
1467,
298,
1282,
50,
2,
520,
841,
12,
1467,
298,
2054,
41,
2,
520,
959,
12,
1467,
298,
2054,
57,
2,
520,
959,
12,
1467,
298,
42,
1734,
2,
520,
1227,
12,
1467,
298,
42,
6084,
2,
520,
1520,
12,
1467,
298,
42,
1293,
2,
520,
1520,
12,
1467,
298,
9331,
39,
2,
520,
1695,
12,
1467,
298,
20848,
2,
520,
1749,
12,
1467,
298,
47,
1028,
2,
520,
1616,
12,
1467,
298,
3593,
52,
2,
520,
1616,
12,
1467,
298,
2826,
54,
2,
520,
4119,
12,
1467,
298,
16387,
2,
520,
3144,
12,
1467,
298,
4448,
2,
520,
3144,
93,
199,
199,
5350,
63,
69,
429,
63,
4482,
275,
469,
17,
520,
298,
42,
879,
401,
326,
499,
520,
298,
5100,
34,
401,
326,
650,
520,
298,
45,
689,
401,
326,
841,
520,
298,
1282,
50,
401,
326,
959,
520,
298,
2054,
57,
401,
326,
1227,
520,
298,
42,
1734,
401,
326,
1520,
520,
298,
42,
1293,
401,
326,
1695,
520,
298,
9331,
39,
401,
326,
1749,
520,
298,
20848,
401,
326,
1616,
26,
298,
47,
1028,
401,
326,
4119,
520,
298,
2826,
54,
401,
326,
3144,
520,
298,
16387,
3570,
199,
199,
318,
485,
1875,
63,
2083,
8,
9356,
63,
3059,
304,
272,
5382,
275,
10831,
63,
3059,
59,
16,
1055,
362,
63,
442,
8,
16,
9,
272,
5794,
275,
10831,
63,
3059,
59,
17,
1055,
362,
63,
495,
8,
16,
9,
272,
5361,
275,
10831,
63,
3059,
59,
18,
1055,
362,
63,
442,
8,
16,
9,
2286,
1434,
63,
3583,
275,
2197,
14,
2083,
8,
3403,
12,
325,
429,
63,
4482,
59,
4482,
467,
5382,
9,
272,
340,
822,
8,
9356,
63,
3059,
9,
665,
841,
26,
267,
372,
1434,
63,
3583,
272,
587,
26,
267,
900,
63,
495,
275,
10831,
63,
3059,
59,
19,
1055,
362,
63,
495,
8,
16,
9,
267,
900,
63,
513,
275,
900,
63,
495,
14,
1294,
11633,
267,
6925,
275,
12709,
275,
3499,
275,
25824,
275,
378,
267,
6925,
275,
1109,
8,
521,
63,
513,
59,
16,
566,
267,
340,
822,
8,
521,
63,
513,
13032,
17,
26,
288,
12709,
275,
1109,
8,
521,
63,
513,
59,
17,
566,
267,
340,
822,
8,
521,
63,
513,
13032,
18,
26,
288,
6513,
63,
513,
275,
900,
63,
513,
59,
18,
1055,
1294,
7563,
288,
3499,
275,
1109,
8,
3321,
63,
513,
59,
16,
566,
288,
340,
822,
8,
3321,
63,
513,
13032,
17,
26,
355,
6605,
63,
495,
275,
6513,
63,
513,
59,
17,
1055,
1913,
342,
355,
980,
350,
275,
1227,
13,
552,
8,
706,
63,
495,
9,
355,
6605,
63,
495,
847,
10587,
904,
5234,
16,
2,
367,
284,
315,
1425,
8,
1590,
350,
3948,
355,
25824,
275,
1109,
8,
706,
63,
495,
9,
398,
372,
2197,
14,
2083,
8,
3403,
12,
325,
429,
63,
4482,
59,
4482,
467,
5382,
12,
6925,
12,
12709,
12,
3499,
12,
25824,
9,
27844,
199,
533,
4703,
7801,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
4487,
12,
7681,
304,
267,
408,
1918,
4703,
7801,
1021,
17568,
402,
282,
769,
402,
7681,
436,
282,
5226,
1434,
14,
398,
17985,
4909,
626,
314,
1434,
574,
13718,
370,
282,
577,
16601,
1182,
377,
17988,
4252,
267,
2569,
627,
4399,
10,
314,
7681,
27,
284,
14,
69,
14,
340,
314,
4703,
7801,
1256,
3509,
267,
282,
644,
1864,
22802,
4252,
314,
2202,
315,
626,
4252,
1077,
4838,
627,
8111,
10,
267,
314,
1434,
2013,
365,
13075,
14,
1666,
314,
3794,
402,
314,
4703,
3646,
267,
1021,
367,
1655,
2436,
402,
314,
8931,
3382,
4703,
3646,
436,
267,
4703,
7801,
14,
398,
408,
267,
291,
14,
3583,
275,
4487,
267,
291,
14,
7511,
275,
7681,
267,
291,
14,
1086,
2852,
275,
488,
267,
291,
14,
374,
63,
928,
275,
756,
2378,
768,
3744,
272,
347,
1218,
63,
2246,
8,
1886,
12,
4487,
304,
267,
6714,
275,
843,
8,
3583,
12,
3073,
267,
6714,
14,
374,
63,
928,
275,
715,
267,
372,
6714,
339,
347,
1050,
63,
6691,
8,
277,
12,
4775,
304,
267,
291,
14,
7511,
14,
740,
8,
829,
9,
16478,
347,
636,
552,
721,
277,
304,
267,
372,
822,
8,
277,
14,
7511,
9,
339,
347,
636,
6134,
721,
277,
12,
1680,
304,
267,
367,
4775,
315,
291,
14,
7511,
26,
288,
340,
1680,
508,
4775,
14,
354,
26,
355,
372,
715,
267,
372,
756,
2378,
347,
636,
495,
721,
277,
304,
267,
1059,
275,
5228,
342,
398,
340,
440,
291,
14,
374,
63,
928,
26,
288,
5382,
275,
291,
14,
3583,
14,
2977,
288,
5794,
275,
291,
14,
3583,
14,
4482,
288,
5361,
275,
291,
14,
3583,
14,
3403,
288,
340,
440,
291,
14,
3583,
14,
521,
837,
355,
1059,
14,
952,
480,
6521,
654,
60,
78,
221,
469,
2977,
93,
5041,
4482,
6834,
469,
3403,
5995,
60,
78,
6307,
78,
60,
78,
1674,
908,
8,
5382,
29,
2977,
12,
5794,
275,
4572,
63,
69,
429,
63,
4482,
59,
4482,
467,
5361,
29,
3403,
430,
288,
587,
26,
355,
6925,
275,
291,
14,
3583,
14,
5180,
355,
12709,
275,
291,
14,
3583,
14,
10698,
355,
3499,
275,
291,
14,
3583,
14,
4375,
435,
291,
14,
3583,
14,
16627,
10,
17,
14,
16,
69,
13,
22,
355,
1059,
14,
952,
480,
6521,
654,
60,
78,
221,
469,
2977,
93,
5041,
4482,
6834,
469,
3403,
93,
469,
5180,
26,
996,
68,
16495,
10698,
26,
996,
68,
16495,
4375,
26,
18,
14,
22,
70,
93,
1182,
60,
78,
6307,
78,
60,
78,
1674,
908,
8,
5382,
29,
2977,
12,
5794,
275,
4572,
63,
69,
429,
63,
4482,
59,
4482,
467,
5361,
29,
3403,
12,
6925,
29,
5180,
12,
12709,
29,
10698,
12,
3499,
29,
4375,
430,
463,
398,
367,
4775
] |
[
2197,
199,
199,
504,
4182,
492,
21829,
199,
893,
26,
272,
687,
5228,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5890,
492,
5228,
199,
199,
504,
1687,
77,
14,
2308,
14,
2087,
492,
10191,
199,
199,
3,
961,
365,
687,
314,
4703,
2956,
14,
5910,
4514,
315,
1687,
77,
199,
69,
429,
63,
4482,
275,
2420,
42,
879,
2,
520,
413,
12,
1467,
298,
5100,
34,
2,
520,
499,
12,
1467,
298,
45,
689,
2,
520,
650,
12,
1467,
298,
1282,
50,
2,
520,
841,
12,
1467,
298,
2054,
41,
2,
520,
959,
12,
1467,
298,
2054,
57,
2,
520,
959,
12,
1467,
298,
42,
1734,
2,
520,
1227,
12,
1467,
298,
42,
6084,
2,
520,
1520,
12,
1467,
298,
42,
1293,
2,
520,
1520,
12,
1467,
298,
9331,
39,
2,
520,
1695,
12,
1467,
298,
20848,
2,
520,
1749,
12,
1467,
298,
47,
1028,
2,
520,
1616,
12,
1467,
298,
3593,
52,
2,
520,
1616,
12,
1467,
298,
2826,
54,
2,
520,
4119,
12,
1467,
298,
16387,
2,
520,
3144,
12,
1467,
298,
4448,
2,
520,
3144,
93,
199,
199,
5350,
63,
69,
429,
63,
4482,
275,
469,
17,
520,
298,
42,
879,
401,
326,
499,
520,
298,
5100,
34,
401,
326,
650,
520,
298,
45,
689,
401,
326,
841,
520,
298,
1282,
50,
401,
326,
959,
520,
298,
2054,
57,
401,
326,
1227,
520,
298,
42,
1734,
401,
326,
1520,
520,
298,
42,
1293,
401,
326,
1695,
520,
298,
9331,
39,
401,
326,
1749,
520,
298,
20848,
401,
326,
1616,
26,
298,
47,
1028,
401,
326,
4119,
520,
298,
2826,
54,
401,
326,
3144,
520,
298,
16387,
3570,
199,
199,
318,
485,
1875,
63,
2083,
8,
9356,
63,
3059,
304,
272,
5382,
275,
10831,
63,
3059,
59,
16,
1055,
362,
63,
442,
8,
16,
9,
272,
5794,
275,
10831,
63,
3059,
59,
17,
1055,
362,
63,
495,
8,
16,
9,
272,
5361,
275,
10831,
63,
3059,
59,
18,
1055,
362,
63,
442,
8,
16,
9,
2286,
1434,
63,
3583,
275,
2197,
14,
2083,
8,
3403,
12,
325,
429,
63,
4482,
59,
4482,
467,
5382,
9,
272,
340,
822,
8,
9356,
63,
3059,
9,
665,
841,
26,
267,
372,
1434,
63,
3583,
272,
587,
26,
267,
900,
63,
495,
275,
10831,
63,
3059,
59,
19,
1055,
362,
63,
495,
8,
16,
9,
267,
900,
63,
513,
275,
900,
63,
495,
14,
1294,
11633,
267,
6925,
275,
12709,
275,
3499,
275,
25824,
275,
378,
267,
6925,
275,
1109,
8,
521,
63,
513,
59,
16,
566,
267,
340,
822,
8,
521,
63,
513,
13032,
17,
26,
288,
12709,
275,
1109,
8,
521,
63,
513,
59,
17,
566,
267,
340,
822,
8,
521,
63,
513,
13032,
18,
26,
288,
6513,
63,
513,
275,
900,
63,
513,
59,
18,
1055,
1294,
7563,
288,
3499,
275,
1109,
8,
3321,
63,
513,
59,
16,
566,
288,
340,
822,
8,
3321,
63,
513,
13032,
17,
26,
355,
6605,
63,
495,
275,
6513,
63,
513,
59,
17,
1055,
1913,
342,
355,
980,
350,
275,
1227,
13,
552,
8,
706,
63,
495,
9,
355,
6605,
63,
495,
847,
10587,
904,
5234,
16,
2,
367,
284,
315,
1425,
8,
1590,
350,
3948,
355,
25824,
275,
1109,
8,
706,
63,
495,
9,
398,
372,
2197,
14,
2083,
8,
3403,
12,
325,
429,
63,
4482,
59,
4482,
467,
5382,
12,
6925,
12,
12709,
12,
3499,
12,
25824,
9,
27844,
199,
533,
4703,
7801,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
4487,
12,
7681,
304,
267,
408,
1918,
4703,
7801,
1021,
17568,
402,
282,
769,
402,
7681,
436,
282,
5226,
1434,
14,
398,
17985,
4909,
626,
314,
1434,
574,
13718,
370,
282,
577,
16601,
1182,
377,
17988,
4252,
267,
2569,
627,
4399,
10,
314,
7681,
27,
284,
14,
69,
14,
340,
314,
4703,
7801,
1256,
3509,
267,
282,
644,
1864,
22802,
4252,
314,
2202,
315,
626,
4252,
1077,
4838,
627,
8111,
10,
267,
314,
1434,
2013,
365,
13075,
14,
1666,
314,
3794,
402,
314,
4703,
3646,
267,
1021,
367,
1655,
2436,
402,
314,
8931,
3382,
4703,
3646,
436,
267,
4703,
7801,
14,
398,
408,
267,
291,
14,
3583,
275,
4487,
267,
291,
14,
7511,
275,
7681,
267,
291,
14,
1086,
2852,
275,
488,
267,
291,
14,
374,
63,
928,
275,
756,
2378,
768,
3744,
272,
347,
1218,
63,
2246,
8,
1886,
12,
4487,
304,
267,
6714,
275,
843,
8,
3583,
12,
3073,
267,
6714,
14,
374,
63,
928,
275,
715,
267,
372,
6714,
339,
347,
1050,
63,
6691,
8,
277,
12,
4775,
304,
267,
291,
14,
7511,
14,
740,
8,
829,
9,
16478,
347,
636,
552,
721,
277,
304,
267,
372,
822,
8,
277,
14,
7511,
9,
339,
347,
636,
6134,
721,
277,
12,
1680,
304,
267,
367,
4775,
315,
291,
14,
7511,
26,
288,
340,
1680,
508,
4775,
14,
354,
26,
355,
372,
715,
267,
372,
756,
2378,
347,
636,
495,
721,
277,
304,
267,
1059,
275,
5228,
342,
398,
340,
440,
291,
14,
374,
63,
928,
26,
288,
5382,
275,
291,
14,
3583,
14,
2977,
288,
5794,
275,
291,
14,
3583,
14,
4482,
288,
5361,
275,
291,
14,
3583,
14,
3403,
288,
340,
440,
291,
14,
3583,
14,
521,
837,
355,
1059,
14,
952,
480,
6521,
654,
60,
78,
221,
469,
2977,
93,
5041,
4482,
6834,
469,
3403,
5995,
60,
78,
6307,
78,
60,
78,
1674,
908,
8,
5382,
29,
2977,
12,
5794,
275,
4572,
63,
69,
429,
63,
4482,
59,
4482,
467,
5361,
29,
3403,
430,
288,
587,
26,
355,
6925,
275,
291,
14,
3583,
14,
5180,
355,
12709,
275,
291,
14,
3583,
14,
10698,
355,
3499,
275,
291,
14,
3583,
14,
4375,
435,
291,
14,
3583,
14,
16627,
10,
17,
14,
16,
69,
13,
22,
355,
1059,
14,
952,
480,
6521,
654,
60,
78,
221,
469,
2977,
93,
5041,
4482,
6834,
469,
3403,
93,
469,
5180,
26,
996,
68,
16495,
10698,
26,
996,
68,
16495,
4375,
26,
18,
14,
22,
70,
93,
1182,
60,
78,
6307,
78,
60,
78,
1674,
908,
8,
5382,
29,
2977,
12,
5794,
275,
4572,
63,
69,
429,
63,
4482,
59,
4482,
467,
5361,
29,
3403,
12,
6925,
29,
5180,
12,
12709,
29,
10698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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
powerlim2/project_free_insight
|
data_api/venv/lib/python2.7/site-packages/psycopg2/tests/test_transaction.py
|
62
|
9214
|
#!/usr/bin/env python
# test_transaction - unit test on transaction behaviour
#
# Copyright (C) 2007-2011 Federico Di Gregorio <fog@debian.org>
#
# psycopg2 is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# In addition, as a special exception, the copyright holders give
# permission to link this program with the OpenSSL library (or with
# modified versions of OpenSSL that use the same license as OpenSSL),
# and distribute linked combinations including the two.
#
# You must obey the GNU Lesser General Public License in all respects for
# all of the code used other than OpenSSL.
#
# psycopg2 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.
import threading
from testutils import unittest, ConnectingTestCase, skip_before_postgres
import psycopg2
from psycopg2.extensions import (
ISOLATION_LEVEL_SERIALIZABLE, STATUS_BEGIN, STATUS_READY)
class TransactionTests(ConnectingTestCase):
def setUp(self):
ConnectingTestCase.setUp(self)
self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
curs = self.conn.cursor()
curs.execute('''
CREATE TEMPORARY TABLE table1 (
id int PRIMARY KEY
)''')
# The constraint is set to deferrable for the commit_failed test
curs.execute('''
CREATE TEMPORARY TABLE table2 (
id int PRIMARY KEY,
table1_id int,
CONSTRAINT table2__table1_id__fk
FOREIGN KEY (table1_id) REFERENCES table1(id) DEFERRABLE)''')
curs.execute('INSERT INTO table1 VALUES (1)')
curs.execute('INSERT INTO table2 VALUES (1, 1)')
self.conn.commit()
def test_rollback(self):
# Test that rollback undoes changes
curs = self.conn.cursor()
curs.execute('INSERT INTO table2 VALUES (2, 1)')
# Rollback takes us from BEGIN state to READY state
self.assertEqual(self.conn.status, STATUS_BEGIN)
self.conn.rollback()
self.assertEqual(self.conn.status, STATUS_READY)
curs.execute('SELECT id, table1_id FROM table2 WHERE id = 2')
self.assertEqual(curs.fetchall(), [])
def test_commit(self):
# Test that commit stores changes
curs = self.conn.cursor()
curs.execute('INSERT INTO table2 VALUES (2, 1)')
# Rollback takes us from BEGIN state to READY state
self.assertEqual(self.conn.status, STATUS_BEGIN)
self.conn.commit()
self.assertEqual(self.conn.status, STATUS_READY)
# Now rollback and show that the new record is still there:
self.conn.rollback()
curs.execute('SELECT id, table1_id FROM table2 WHERE id = 2')
self.assertEqual(curs.fetchall(), [(2, 1)])
def test_failed_commit(self):
# Test that we can recover from a failed commit.
# We use a deferred constraint to cause a failure on commit.
curs = self.conn.cursor()
curs.execute('SET CONSTRAINTS table2__table1_id__fk DEFERRED')
curs.execute('INSERT INTO table2 VALUES (2, 42)')
# The commit should fail, and move the cursor back to READY state
self.assertEqual(self.conn.status, STATUS_BEGIN)
self.assertRaises(psycopg2.IntegrityError, self.conn.commit)
self.assertEqual(self.conn.status, STATUS_READY)
# The connection should be ready to use for the next transaction:
curs.execute('SELECT 1')
self.assertEqual(curs.fetchone()[0], 1)
class DeadlockSerializationTests(ConnectingTestCase):
"""Test deadlock and serialization failure errors."""
def connect(self):
conn = ConnectingTestCase.connect(self)
conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
return conn
def setUp(self):
ConnectingTestCase.setUp(self)
curs = self.conn.cursor()
# Drop table if it already exists
try:
curs.execute("DROP TABLE table1")
self.conn.commit()
except psycopg2.DatabaseError:
self.conn.rollback()
try:
curs.execute("DROP TABLE table2")
self.conn.commit()
except psycopg2.DatabaseError:
self.conn.rollback()
# Create sample data
curs.execute("""
CREATE TABLE table1 (
id int PRIMARY KEY,
name text)
""")
curs.execute("INSERT INTO table1 VALUES (1, 'hello')")
curs.execute("CREATE TABLE table2 (id int PRIMARY KEY)")
self.conn.commit()
def tearDown(self):
curs = self.conn.cursor()
curs.execute("DROP TABLE table1")
curs.execute("DROP TABLE table2")
self.conn.commit()
ConnectingTestCase.tearDown(self)
def test_deadlock(self):
self.thread1_error = self.thread2_error = None
step1 = threading.Event()
step2 = threading.Event()
def task1():
try:
conn = self.connect()
curs = conn.cursor()
curs.execute("LOCK table1 IN ACCESS EXCLUSIVE MODE")
step1.set()
step2.wait()
curs.execute("LOCK table2 IN ACCESS EXCLUSIVE MODE")
except psycopg2.DatabaseError, exc:
self.thread1_error = exc
step1.set()
conn.close()
def task2():
try:
conn = self.connect()
curs = conn.cursor()
step1.wait()
curs.execute("LOCK table2 IN ACCESS EXCLUSIVE MODE")
step2.set()
curs.execute("LOCK table1 IN ACCESS EXCLUSIVE MODE")
except psycopg2.DatabaseError, exc:
self.thread2_error = exc
step2.set()
conn.close()
# Run the threads in parallel. The "step1" and "step2" events
# ensure that the two transactions overlap.
thread1 = threading.Thread(target=task1)
thread2 = threading.Thread(target=task2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
# Exactly one of the threads should have failed with
# TransactionRollbackError:
self.assertFalse(self.thread1_error and self.thread2_error)
error = self.thread1_error or self.thread2_error
self.assertTrue(isinstance(
error, psycopg2.extensions.TransactionRollbackError))
def test_serialisation_failure(self):
self.thread1_error = self.thread2_error = None
step1 = threading.Event()
step2 = threading.Event()
def task1():
try:
conn = self.connect()
curs = conn.cursor()
curs.execute("SELECT name FROM table1 WHERE id = 1")
curs.fetchall()
step1.set()
step2.wait()
curs.execute("UPDATE table1 SET name='task1' WHERE id = 1")
conn.commit()
except psycopg2.DatabaseError, exc:
self.thread1_error = exc
step1.set()
conn.close()
def task2():
try:
conn = self.connect()
curs = conn.cursor()
step1.wait()
curs.execute("UPDATE table1 SET name='task2' WHERE id = 1")
conn.commit()
except psycopg2.DatabaseError, exc:
self.thread2_error = exc
step2.set()
conn.close()
# Run the threads in parallel. The "step1" and "step2" events
# ensure that the two transactions overlap.
thread1 = threading.Thread(target=task1)
thread2 = threading.Thread(target=task2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
# Exactly one of the threads should have failed with
# TransactionRollbackError:
self.assertFalse(self.thread1_error and self.thread2_error)
error = self.thread1_error or self.thread2_error
self.assertTrue(isinstance(
error, psycopg2.extensions.TransactionRollbackError))
class QueryCancellationTests(ConnectingTestCase):
"""Tests for query cancellation."""
def setUp(self):
ConnectingTestCase.setUp(self)
self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
@skip_before_postgres(8, 2)
def test_statement_timeout(self):
curs = self.conn.cursor()
# Set a low statement timeout, then sleep for a longer period.
curs.execute('SET statement_timeout TO 10')
self.assertRaises(psycopg2.extensions.QueryCanceledError,
curs.execute, 'SELECT pg_sleep(50)')
def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main()
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
511,
63,
5945,
446,
4137,
511,
641,
6008,
13942,
199,
3,
199,
3,
1898,
334,
35,
9,
10219,
13,
8128,
7949,
9910,
331,
3757,
29096,
269,
2308,
221,
665,
545,
71,
32,
23204,
14,
1308,
30,
199,
3,
199,
3,
15492,
18,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
199,
3,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
465,
3267,
199,
3,
701,
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,
1010,
10234,
12,
465,
282,
4539,
1919,
12,
314,
4248,
31976,
8120,
199,
3,
4983,
370,
2142,
642,
2240,
543,
314,
14296,
3555,
334,
269,
543,
199,
3,
6042,
5459,
402,
14296,
626,
675,
314,
2011,
4190,
465,
14296,
395,
199,
3,
436,
11207,
10632,
15821,
5893,
314,
2877,
14,
199,
3,
199,
3,
2047,
1471,
312,
32236,
314,
1664,
6401,
1696,
1684,
844,
315,
1006,
14021,
83,
367,
199,
3,
1006,
402,
314,
1233,
1202,
1163,
2419,
14296,
14,
199,
3,
199,
3,
15492,
18,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
199,
3,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
367,
1655,
2436,
14,
199,
199,
646,
5796,
199,
504,
511,
1208,
492,
2882,
12,
15175,
316,
1746,
12,
3372,
63,
5182,
63,
10675,
199,
199,
646,
15492,
18,
199,
504,
15492,
18,
14,
5359,
492,
334,
272,
21154,
2594,
63,
11817,
63,
19637,
5357,
2617,
12,
18460,
63,
15947,
12,
18460,
63,
22579,
9,
199,
199,
533,
18244,
2925,
8,
32000,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
15175,
316,
1746,
14,
5996,
8,
277,
9,
267,
291,
14,
1631,
14,
409,
63,
20808,
63,
1896,
8,
1311,
2228,
2594,
63,
11817,
63,
19637,
5357,
2617,
9,
267,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
18809,
14,
2526,
10505,
288,
16999,
24314,
726,
4392,
9934,
1817,
17,
334,
1598,
1305,
1109,
19770,
9301,
288,
776,
12310,
267,
327,
710,
5828,
365,
663,
370,
10133,
6842,
367,
314,
5532,
63,
4892,
511,
267,
18809,
14,
2526,
10505,
288,
16999,
24314,
726,
4392,
9934,
1817,
18,
334,
1598,
1305,
1109,
19770,
9301,
12,
1598,
1817,
17,
63,
344,
1109,
12,
1598,
30164,
1817,
18,
363,
1224,
17,
63,
344,
363,
9010,
355,
2381,
37,
3203,
9301,
334,
1224,
17,
63,
344,
9,
26901,
22243,
1817,
17,
8,
344,
9,
23566,
2666,
2617,
9,
12310,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
17,
13992,
334,
17,
5942,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
18,
13992,
334,
17,
12,
413,
5942,
267,
291,
14,
1631,
14,
3543,
342,
339,
347,
511,
63,
10437,
8,
277,
304,
267,
327,
1379,
626,
16475,
625,
9105,
4493,
267,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
18,
13992,
334,
18,
12,
413,
5942,
267,
327,
820,
14385,
894,
6181,
2739,
687,
16427,
1174,
370,
16767,
57,
1174,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
15947,
9,
267,
291,
14,
1631,
14,
10437,
342,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
22579,
9,
267,
18809,
14,
2526,
360,
4859,
1305,
12,
1817,
17,
63,
344,
4442,
1817,
18,
6038,
1305,
275,
499,
358,
267,
291,
14,
629,
8,
17255,
14,
10174,
1062,
3073,
339,
347,
511,
63,
3543,
8,
277,
304,
267,
327,
1379,
626,
5532,
14086,
4493,
267,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
18,
13992,
334,
18,
12,
413,
5942,
267,
327,
820,
14385,
894,
6181,
2739,
687,
16427,
1174,
370,
16767,
57,
1174,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
15947,
9,
267,
291,
14,
1631,
14,
3543,
342,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
22579,
9,
267,
327,
7356,
16475,
436,
2498,
626,
314,
892,
2777,
365,
5139,
2337,
26,
267,
291,
14,
1631,
14,
10437,
342,
267,
18809,
14,
2526,
360,
4859,
1305,
12,
1817,
17,
63,
344,
4442,
1817,
18,
6038,
1305,
275,
499,
358,
267,
291,
14,
629,
8,
17255,
14,
10174,
1062,
3842,
18,
12,
413,
3948,
339,
347,
511,
63,
4892,
63,
3543,
8,
277,
304,
267,
327,
1379,
626,
781,
883,
22803,
687,
282,
3405,
5532,
14,
267,
327,
2136,
675,
282,
12309,
5828,
370,
7675,
282,
5988,
641,
5532,
14,
267,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
18809,
14,
2526,
360,
3597,
30164,
51,
1817,
18,
363,
1224,
17,
63,
344,
363,
9010,
3265,
15849,
7387,
358,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
18,
13992,
334,
18,
12,
5685,
5942,
267,
327,
710,
5532,
1077,
2449,
12,
436,
4057,
314,
3920,
1771,
370,
16767,
57,
1174,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
15947,
9,
267,
291,
14,
1855,
8,
20270,
18,
14,
24823,
12,
291,
14,
1631,
14,
3543,
9,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
22579,
9,
267,
327,
710,
1950,
1077,
506,
10144,
370,
675,
367,
314,
2163,
6008,
26,
267,
18809,
14,
2526,
360,
4859,
413,
358,
267,
291,
14,
629,
8,
17255,
14,
11591,
3430,
16,
467,
413,
9,
421,
199,
533,
1487,
350,
831,
3571,
2072,
2925,
8,
32000,
1746,
304,
272,
408,
774,
12314,
831,
436,
16953,
5988,
2552,
1041,
339,
347,
4907,
8,
277,
304,
267,
2557,
275,
15175,
316,
1746,
14,
2242,
8,
277,
9,
267,
2557,
14,
409,
63,
20808,
63,
1896,
8,
1311,
2228,
2594,
63,
11817,
63,
19637,
5357,
2617,
9,
267,
372,
2557,
339,
347,
3613,
8,
277,
304,
267,
15175,
316,
1746,
14,
5996,
8,
277,
9,
398,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
327,
18110,
1817,
340,
652,
2575,
3495,
267,
862,
26,
288
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
511,
63,
5945,
446,
4137,
511,
641,
6008,
13942,
199,
3,
199,
3,
1898,
334,
35,
9,
10219,
13,
8128,
7949,
9910,
331,
3757,
29096,
269,
2308,
221,
665,
545,
71,
32,
23204,
14,
1308,
30,
199,
3,
199,
3,
15492,
18,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
199,
3,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
465,
3267,
199,
3,
701,
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,
1010,
10234,
12,
465,
282,
4539,
1919,
12,
314,
4248,
31976,
8120,
199,
3,
4983,
370,
2142,
642,
2240,
543,
314,
14296,
3555,
334,
269,
543,
199,
3,
6042,
5459,
402,
14296,
626,
675,
314,
2011,
4190,
465,
14296,
395,
199,
3,
436,
11207,
10632,
15821,
5893,
314,
2877,
14,
199,
3,
199,
3,
2047,
1471,
312,
32236,
314,
1664,
6401,
1696,
1684,
844,
315,
1006,
14021,
83,
367,
199,
3,
1006,
402,
314,
1233,
1202,
1163,
2419,
14296,
14,
199,
3,
199,
3,
15492,
18,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
199,
3,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
367,
1655,
2436,
14,
199,
199,
646,
5796,
199,
504,
511,
1208,
492,
2882,
12,
15175,
316,
1746,
12,
3372,
63,
5182,
63,
10675,
199,
199,
646,
15492,
18,
199,
504,
15492,
18,
14,
5359,
492,
334,
272,
21154,
2594,
63,
11817,
63,
19637,
5357,
2617,
12,
18460,
63,
15947,
12,
18460,
63,
22579,
9,
199,
199,
533,
18244,
2925,
8,
32000,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
15175,
316,
1746,
14,
5996,
8,
277,
9,
267,
291,
14,
1631,
14,
409,
63,
20808,
63,
1896,
8,
1311,
2228,
2594,
63,
11817,
63,
19637,
5357,
2617,
9,
267,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
18809,
14,
2526,
10505,
288,
16999,
24314,
726,
4392,
9934,
1817,
17,
334,
1598,
1305,
1109,
19770,
9301,
288,
776,
12310,
267,
327,
710,
5828,
365,
663,
370,
10133,
6842,
367,
314,
5532,
63,
4892,
511,
267,
18809,
14,
2526,
10505,
288,
16999,
24314,
726,
4392,
9934,
1817,
18,
334,
1598,
1305,
1109,
19770,
9301,
12,
1598,
1817,
17,
63,
344,
1109,
12,
1598,
30164,
1817,
18,
363,
1224,
17,
63,
344,
363,
9010,
355,
2381,
37,
3203,
9301,
334,
1224,
17,
63,
344,
9,
26901,
22243,
1817,
17,
8,
344,
9,
23566,
2666,
2617,
9,
12310,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
17,
13992,
334,
17,
5942,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
18,
13992,
334,
17,
12,
413,
5942,
267,
291,
14,
1631,
14,
3543,
342,
339,
347,
511,
63,
10437,
8,
277,
304,
267,
327,
1379,
626,
16475,
625,
9105,
4493,
267,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
18,
13992,
334,
18,
12,
413,
5942,
267,
327,
820,
14385,
894,
6181,
2739,
687,
16427,
1174,
370,
16767,
57,
1174,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
15947,
9,
267,
291,
14,
1631,
14,
10437,
342,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
22579,
9,
267,
18809,
14,
2526,
360,
4859,
1305,
12,
1817,
17,
63,
344,
4442,
1817,
18,
6038,
1305,
275,
499,
358,
267,
291,
14,
629,
8,
17255,
14,
10174,
1062,
3073,
339,
347,
511,
63,
3543,
8,
277,
304,
267,
327,
1379,
626,
5532,
14086,
4493,
267,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
18,
13992,
334,
18,
12,
413,
5942,
267,
327,
820,
14385,
894,
6181,
2739,
687,
16427,
1174,
370,
16767,
57,
1174,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
15947,
9,
267,
291,
14,
1631,
14,
3543,
342,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
22579,
9,
267,
327,
7356,
16475,
436,
2498,
626,
314,
892,
2777,
365,
5139,
2337,
26,
267,
291,
14,
1631,
14,
10437,
342,
267,
18809,
14,
2526,
360,
4859,
1305,
12,
1817,
17,
63,
344,
4442,
1817,
18,
6038,
1305,
275,
499,
358,
267,
291,
14,
629,
8,
17255,
14,
10174,
1062,
3842,
18,
12,
413,
3948,
339,
347,
511,
63,
4892,
63,
3543,
8,
277,
304,
267,
327,
1379,
626,
781,
883,
22803,
687,
282,
3405,
5532,
14,
267,
327,
2136,
675,
282,
12309,
5828,
370,
7675,
282,
5988,
641,
5532,
14,
267,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
18809,
14,
2526,
360,
3597,
30164,
51,
1817,
18,
363,
1224,
17,
63,
344,
363,
9010,
3265,
15849,
7387,
358,
267,
18809,
14,
2526,
360,
10258,
12872,
1817,
18,
13992,
334,
18,
12,
5685,
5942,
267,
327,
710,
5532,
1077,
2449,
12,
436,
4057,
314,
3920,
1771,
370,
16767,
57,
1174,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
15947,
9,
267,
291,
14,
1855,
8,
20270,
18,
14,
24823,
12,
291,
14,
1631,
14,
3543,
9,
267,
291,
14,
629,
8,
277,
14,
1631,
14,
1205,
12,
18460,
63,
22579,
9,
267,
327,
710,
1950,
1077,
506,
10144,
370,
675,
367,
314,
2163,
6008,
26,
267,
18809,
14,
2526,
360,
4859,
413,
358,
267,
291,
14,
629,
8,
17255,
14,
11591,
3430,
16,
467,
413,
9,
421,
199,
533,
1487,
350,
831,
3571,
2072,
2925,
8,
32000,
1746,
304,
272,
408,
774,
12314,
831,
436,
16953,
5988,
2552,
1041,
339,
347,
4907,
8,
277,
304,
267,
2557,
275,
15175,
316,
1746,
14,
2242,
8,
277,
9,
267,
2557,
14,
409,
63,
20808,
63,
1896,
8,
1311,
2228,
2594,
63,
11817,
63,
19637,
5357,
2617,
9,
267,
372,
2557,
339,
347,
3613,
8,
277,
304,
267,
15175,
316,
1746,
14,
5996,
8,
277,
9,
398,
18809,
275,
291,
14,
1631,
14,
3937,
342,
267,
327,
18110,
1817,
340,
652,
2575,
3495,
267,
862,
26,
288,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
herlo/d-note
|
dnote/__init__.py
|
3
|
2650
|
"""This module sets up the paths for the Flask web application."""
import os
import utils
from flask import Flask, render_template, request, redirect, url_for
from note import Note
DNOTE = Flask(__name__)
HERE = DNOTE.root_path
@DNOTE.route('/', methods=['GET'])
def index():
"""Return the index.html for the main application."""
error = request.args.get('error', None)
note = Note()
return render_template('index.html', random=note.url, error=error)
@DNOTE.route('/security/', methods=['GET'])
def security():
"""Return the index.html for the security page."""
return render_template('security.html')
@DNOTE.route('/faq/', methods=['GET'])
def faq():
"""Return the index.html for the faq page."""
return render_template('faq.html')
@DNOTE.route('/about/', methods=['GET'])
def about():
"""Return the index.html for the about page."""
return render_template('about.html')
@DNOTE.route('/post', methods=['POST'])
def show_post():
"""Return the random URL after posting the plaintext."""
new_url = request.form["new_url"]
note = Note(new_url)
note.plaintext = request.form['paste']
passphrase = request.form.get('pass', False)
token = request.form['hashcash']
if not utils.verify_hashcash(token):
return redirect(url_for('index', error='hashcash'))
if passphrase:
note.set_passphrase(passphrase)
note.encrypt()
note.duress_key()
return render_template('post.html', random=note.url,
passphrase=note.passphrase, duress=note.dkey)
else:
note.encrypt()
return render_template('post.html', random=note.url)
@DNOTE.route('/<random_url>', methods=['POST', 'GET'])
def fetch_url(random_url):
"""Return the decrypted note. Begin short destruction timer.
Keyword arguments:
random_url -- Random URL representing the encrypted note."""
note = Note(random_url)
if not note.exists():
return render_template('404.html'), 404
elif not note.decrypt() and request.method != 'POST':
return render_template('key.html', random=note.url)
elif request.method == 'POST':
passphrase = request.form['pass']
note.set_passphrase(passphrase)
if passphrase == note.dkey:
note.secure_remove()
return render_template('note.html', text=utils.duress_text())
if note.decrypt():
note.secure_remove()
return render_template('note.html', text=note.plaintext)
else:
return render_template('keyerror.html', random=note.url)
if __name__ == '__main__':
DNOTE.debug = True
DNOTE.run()
|
agpl-3.0
|
[
624,
2765,
859,
5951,
1536,
314,
3792,
367,
314,
16704,
3330,
4223,
1041,
199,
646,
747,
199,
646,
3778,
199,
504,
7209,
492,
16704,
12,
3795,
63,
1160,
12,
1056,
12,
4660,
12,
1166,
63,
509,
199,
504,
5317,
492,
3390,
199,
199,
36,
19855,
275,
16704,
3460,
354,
3368,
199,
5293,
275,
577,
19855,
14,
1231,
63,
515,
199,
199,
32,
36,
19855,
14,
4449,
10998,
3102,
2968,
2970,
1105,
199,
318,
1478,
837,
272,
408,
1767,
314,
1478,
14,
1360,
367,
314,
2446,
4223,
1041,
272,
1125,
275,
1056,
14,
589,
14,
362,
360,
705,
297,
488,
9,
272,
5317,
275,
3390,
342,
272,
372,
3795,
63,
1160,
360,
1080,
14,
1360,
297,
2196,
29,
4610,
14,
633,
12,
1125,
29,
705,
9,
199,
199,
32,
36,
19855,
14,
4449,
2336,
4416,
3678,
3102,
2968,
2970,
1105,
199,
318,
6391,
837,
272,
408,
1767,
314,
1478,
14,
1360,
367,
314,
6391,
2034,
1041,
272,
372,
3795,
63,
1160,
360,
4416,
14,
1360,
358,
199,
199,
32,
36,
19855,
14,
4449,
2336,
667,
81,
3678,
3102,
2968,
2970,
1105,
199,
318,
1433,
81,
837,
272,
408,
1767,
314,
1478,
14,
1360,
367,
314,
1433,
81,
2034,
1041,
272,
372,
3795,
63,
1160,
360,
667,
81,
14,
1360,
358,
199,
199,
32,
36,
19855,
14,
4449,
2336,
10254,
3678,
3102,
2968,
2970,
1105,
199,
318,
3595,
837,
272,
408,
1767,
314,
1478,
14,
1360,
367,
314,
3595,
2034,
1041,
272,
372,
3795,
63,
1160,
360,
10254,
14,
1360,
358,
199,
199,
32,
36,
19855,
14,
4449,
2336,
1932,
297,
3102,
2968,
4030,
1105,
199,
318,
2498,
63,
1932,
837,
272,
408,
1767,
314,
2196,
2851,
2410,
25386,
314,
18577,
1041,
272,
892,
63,
633,
275,
1056,
14,
964,
905,
1222,
63,
633,
937,
272,
5317,
275,
3390,
8,
1222,
63,
633,
9,
272,
5317,
14,
17426,
275,
1056,
14,
964,
459,
16586,
418,
339,
22432,
275,
1056,
14,
964,
14,
362,
360,
1529,
297,
756,
9,
272,
1526,
275,
1056,
14,
964,
459,
2227,
20084,
418,
339,
340,
440,
3778,
14,
4712,
63,
2227,
20084,
8,
1418,
304,
267,
372,
4660,
8,
633,
63,
509,
360,
1080,
297,
1125,
534,
2227,
20084,
1333,
339,
340,
22432,
26,
267,
5317,
14,
409,
63,
25173,
8,
25173,
9,
267,
5317,
14,
11929,
342,
267,
5317,
14,
68,
608,
385,
63,
498,
342,
267,
372,
3795,
63,
1160,
360,
1932,
14,
1360,
297,
2196,
29,
4610,
14,
633,
12,
3044,
22432,
29,
4610,
14,
25173,
12,
366,
608,
385,
29,
4610,
14,
68,
498,
9,
272,
587,
26,
267,
5317,
14,
11929,
342,
267,
372,
3795,
63,
1160,
360,
1932,
14,
1360,
297,
2196,
29,
4610,
14,
633,
9,
199,
199,
32,
36,
19855,
14,
4449,
2336,
28,
2355,
63,
633,
4206,
3102,
2968,
4030,
297,
283,
2970,
1105,
199,
318,
5267,
63,
633,
8,
2355,
63,
633,
304,
272,
408,
1767,
314,
477,
8274,
5317,
14,
25754,
3974,
477,
4742,
9715,
14,
339,
6431,
2368,
26,
272,
2196,
63,
633,
1553,
9571,
2851,
6144,
314,
14862,
5317,
1041,
339,
5317,
275,
3390,
8,
2355,
63,
633,
9,
339,
340,
440,
5317,
14,
2444,
837,
267,
372,
3795,
63,
1160,
360,
5188,
14,
1360,
659,
7901,
272,
916,
440,
5317,
14,
15682,
342,
436,
1056,
14,
765,
1137,
283,
4030,
356,
267,
372,
3795,
63,
1160,
360,
498,
14,
1360,
297,
2196,
29,
4610,
14,
633,
9,
272,
916,
1056,
14,
765,
508,
283,
4030,
356,
267,
22432,
275,
1056,
14,
964,
459,
1529,
418,
267,
5317,
14,
409,
63,
25173,
8,
25173,
9,
267,
340,
22432,
508,
5317,
14,
68,
498,
26,
288,
5317,
14,
7817,
63,
2168,
342,
288,
372,
3795,
63,
1160,
360,
4610,
14,
1360,
297,
1318,
29,
1208,
14,
68,
608,
385,
63,
505,
1012,
272,
340,
5317,
14,
15682,
837,
267,
5317,
14,
7817,
63,
2168,
342,
267,
372,
3795,
63,
1160,
360,
4610,
14,
1360,
297,
1318,
29,
4610,
14,
17426,
9,
272,
587,
26,
267,
372,
3795,
63,
1160,
360,
498,
705,
14,
1360,
297,
2196,
29,
4610,
14,
633,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
577,
19855,
14,
1757,
275,
715,
272,
577,
19855,
14,
1065,
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
] |
[
2765,
859,
5951,
1536,
314,
3792,
367,
314,
16704,
3330,
4223,
1041,
199,
646,
747,
199,
646,
3778,
199,
504,
7209,
492,
16704,
12,
3795,
63,
1160,
12,
1056,
12,
4660,
12,
1166,
63,
509,
199,
504,
5317,
492,
3390,
199,
199,
36,
19855,
275,
16704,
3460,
354,
3368,
199,
5293,
275,
577,
19855,
14,
1231,
63,
515,
199,
199,
32,
36,
19855,
14,
4449,
10998,
3102,
2968,
2970,
1105,
199,
318,
1478,
837,
272,
408,
1767,
314,
1478,
14,
1360,
367,
314,
2446,
4223,
1041,
272,
1125,
275,
1056,
14,
589,
14,
362,
360,
705,
297,
488,
9,
272,
5317,
275,
3390,
342,
272,
372,
3795,
63,
1160,
360,
1080,
14,
1360,
297,
2196,
29,
4610,
14,
633,
12,
1125,
29,
705,
9,
199,
199,
32,
36,
19855,
14,
4449,
2336,
4416,
3678,
3102,
2968,
2970,
1105,
199,
318,
6391,
837,
272,
408,
1767,
314,
1478,
14,
1360,
367,
314,
6391,
2034,
1041,
272,
372,
3795,
63,
1160,
360,
4416,
14,
1360,
358,
199,
199,
32,
36,
19855,
14,
4449,
2336,
667,
81,
3678,
3102,
2968,
2970,
1105,
199,
318,
1433,
81,
837,
272,
408,
1767,
314,
1478,
14,
1360,
367,
314,
1433,
81,
2034,
1041,
272,
372,
3795,
63,
1160,
360,
667,
81,
14,
1360,
358,
199,
199,
32,
36,
19855,
14,
4449,
2336,
10254,
3678,
3102,
2968,
2970,
1105,
199,
318,
3595,
837,
272,
408,
1767,
314,
1478,
14,
1360,
367,
314,
3595,
2034,
1041,
272,
372,
3795,
63,
1160,
360,
10254,
14,
1360,
358,
199,
199,
32,
36,
19855,
14,
4449,
2336,
1932,
297,
3102,
2968,
4030,
1105,
199,
318,
2498,
63,
1932,
837,
272,
408,
1767,
314,
2196,
2851,
2410,
25386,
314,
18577,
1041,
272,
892,
63,
633,
275,
1056,
14,
964,
905,
1222,
63,
633,
937,
272,
5317,
275,
3390,
8,
1222,
63,
633,
9,
272,
5317,
14,
17426,
275,
1056,
14,
964,
459,
16586,
418,
339,
22432,
275,
1056,
14,
964,
14,
362,
360,
1529,
297,
756,
9,
272,
1526,
275,
1056,
14,
964,
459,
2227,
20084,
418,
339,
340,
440,
3778,
14,
4712,
63,
2227,
20084,
8,
1418,
304,
267,
372,
4660,
8,
633,
63,
509,
360,
1080,
297,
1125,
534,
2227,
20084,
1333,
339,
340,
22432,
26,
267,
5317,
14,
409,
63,
25173,
8,
25173,
9,
267,
5317,
14,
11929,
342,
267,
5317,
14,
68,
608,
385,
63,
498,
342,
267,
372,
3795,
63,
1160,
360,
1932,
14,
1360,
297,
2196,
29,
4610,
14,
633,
12,
3044,
22432,
29,
4610,
14,
25173,
12,
366,
608,
385,
29,
4610,
14,
68,
498,
9,
272,
587,
26,
267,
5317,
14,
11929,
342,
267,
372,
3795,
63,
1160,
360,
1932,
14,
1360,
297,
2196,
29,
4610,
14,
633,
9,
199,
199,
32,
36,
19855,
14,
4449,
2336,
28,
2355,
63,
633,
4206,
3102,
2968,
4030,
297,
283,
2970,
1105,
199,
318,
5267,
63,
633,
8,
2355,
63,
633,
304,
272,
408,
1767,
314,
477,
8274,
5317,
14,
25754,
3974,
477,
4742,
9715,
14,
339,
6431,
2368,
26,
272,
2196,
63,
633,
1553,
9571,
2851,
6144,
314,
14862,
5317,
1041,
339,
5317,
275,
3390,
8,
2355,
63,
633,
9,
339,
340,
440,
5317,
14,
2444,
837,
267,
372,
3795,
63,
1160,
360,
5188,
14,
1360,
659,
7901,
272,
916,
440,
5317,
14,
15682,
342,
436,
1056,
14,
765,
1137,
283,
4030,
356,
267,
372,
3795,
63,
1160,
360,
498,
14,
1360,
297,
2196,
29,
4610,
14,
633,
9,
272,
916,
1056,
14,
765,
508,
283,
4030,
356,
267,
22432,
275,
1056,
14,
964,
459,
1529,
418,
267,
5317,
14,
409,
63,
25173,
8,
25173,
9,
267,
340,
22432,
508,
5317,
14,
68,
498,
26,
288,
5317,
14,
7817,
63,
2168,
342,
288,
372,
3795,
63,
1160,
360,
4610,
14,
1360,
297,
1318,
29,
1208,
14,
68,
608,
385,
63,
505,
1012,
272,
340,
5317,
14,
15682,
837,
267,
5317,
14,
7817,
63,
2168,
342,
267,
372,
3795,
63,
1160,
360,
4610,
14,
1360,
297,
1318,
29,
4610,
14,
17426,
9,
272,
587,
26,
267,
372,
3795,
63,
1160,
360,
498,
705,
14,
1360,
297,
2196,
29,
4610,
14,
633,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
577,
19855,
14,
1757,
275,
715,
272,
577,
19855,
14,
1065,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
BradleyCai/ucr-schedule-visualizer
|
scripts/target_sample.py
|
2
|
1189
|
__all__ = [
'depends',
'config_fields',
'run',
]
import random
depends = [
# Specify dependencies here. Each of these is a target
# as specified in a target_* file.
]
config_fields = {
# Settings can be passed to a target as a JSON file
# Specify the types of each field here
# If this dictionary is empty, it tells build.py to
# not load a config file
}
def run(tracker):
tracker.run_job(job_hello_world, "Printing \"hello world\"")
tracker.print_notice("Important notice here")
tracker.run_job(job_foo_bar, "Fooing bars")
tracker.print_warning("Something possibly bad happened")
def job_hello_world(tracker):
tracker.print_operation("PRINT", "Hello")
tracker.print_operation("PRINT", "World")
def job_foo_bar(tracker):
for i in range(11):
tracker.print_operation("FOO", "bar %d" % i)
if i % 3 == 0:
tracker.run_job(job_crunch_numbers, "Crunching numbers")
if random.random() < 0.2:
tracker.print_error("Oh noes!")
def job_crunch_numbers(tracker):
for i in range(random.randint(2, 7)):
tracker.print_operation("CALC", str(random.randint(-100, 100)))
|
mit
|
[
363,
452,
363,
275,
359,
272,
283,
8912,
297,
272,
283,
888,
63,
955,
297,
272,
283,
1065,
297,
199,
61,
199,
199,
646,
2196,
199,
199,
8912,
275,
359,
272,
327,
13327,
5124,
2348,
14,
7048,
402,
3520,
365,
282,
1347,
272,
327,
465,
2013,
315,
282,
1347,
15192,
570,
14,
199,
61,
199,
199,
888,
63,
955,
275,
469,
272,
327,
13303,
883,
506,
3032,
370,
282,
1347,
465,
282,
4840,
570,
272,
327,
13327,
314,
2943,
402,
1924,
901,
2348,
339,
327,
982,
642,
2600,
365,
2701,
12,
652,
26544,
1900,
14,
647,
370,
272,
327,
440,
2248,
282,
1101,
570,
199,
93,
199,
199,
318,
1255,
8,
8877,
304,
272,
15271,
14,
1065,
63,
2423,
8,
2423,
63,
5006,
63,
7617,
12,
298,
5375,
316,
8441,
5006,
6701,
60,
7230,
272,
15271,
14,
1361,
63,
20556,
480,
6295,
867,
4245,
2348,
531,
272,
15271,
14,
1065,
63,
2423,
8,
2423,
63,
1421,
63,
1700,
12,
298,
5686,
316,
29130,
531,
272,
15271,
14,
1361,
63,
3764,
480,
20641,
12570,
4875,
21056,
531,
421,
199,
318,
3906,
63,
5006,
63,
7617,
8,
8877,
304,
272,
15271,
14,
1361,
63,
5735,
480,
21754,
401,
298,
6257,
531,
272,
15271,
14,
1361,
63,
5735,
480,
21754,
401,
298,
15943,
531,
421,
199,
318,
3906,
63,
1421,
63,
1700,
8,
8877,
304,
272,
367,
284,
315,
1425,
8,
845,
304,
267,
15271,
14,
1361,
63,
5735,
480,
13046,
401,
298,
1700,
450,
68,
2,
450,
284,
9,
398,
340,
284,
450,
650,
508,
378,
26,
288,
15271,
14,
1065,
63,
2423,
8,
2423,
63,
67,
1065,
335,
63,
10548,
12,
298,
35,
1065,
335,
316,
5579,
531,
398,
340,
2196,
14,
2355,
342,
665,
378,
14,
18,
26,
288,
15271,
14,
1361,
63,
705,
480,
47,
72,
949,
397,
9124,
421,
199,
318,
3906,
63,
67,
1065,
335,
63,
10548,
8,
8877,
304,
272,
367,
284,
315,
1425,
8,
2355,
14,
8393,
8,
18,
12,
1520,
2298,
267,
15271,
14,
1361,
63,
5735,
480,
13329,
35,
401,
620,
8,
2355,
14,
8393,
2801,
1960,
12,
2948,
1724,
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
] |
[
452,
363,
275,
359,
272,
283,
8912,
297,
272,
283,
888,
63,
955,
297,
272,
283,
1065,
297,
199,
61,
199,
199,
646,
2196,
199,
199,
8912,
275,
359,
272,
327,
13327,
5124,
2348,
14,
7048,
402,
3520,
365,
282,
1347,
272,
327,
465,
2013,
315,
282,
1347,
15192,
570,
14,
199,
61,
199,
199,
888,
63,
955,
275,
469,
272,
327,
13303,
883,
506,
3032,
370,
282,
1347,
465,
282,
4840,
570,
272,
327,
13327,
314,
2943,
402,
1924,
901,
2348,
339,
327,
982,
642,
2600,
365,
2701,
12,
652,
26544,
1900,
14,
647,
370,
272,
327,
440,
2248,
282,
1101,
570,
199,
93,
199,
199,
318,
1255,
8,
8877,
304,
272,
15271,
14,
1065,
63,
2423,
8,
2423,
63,
5006,
63,
7617,
12,
298,
5375,
316,
8441,
5006,
6701,
60,
7230,
272,
15271,
14,
1361,
63,
20556,
480,
6295,
867,
4245,
2348,
531,
272,
15271,
14,
1065,
63,
2423,
8,
2423,
63,
1421,
63,
1700,
12,
298,
5686,
316,
29130,
531,
272,
15271,
14,
1361,
63,
3764,
480,
20641,
12570,
4875,
21056,
531,
421,
199,
318,
3906,
63,
5006,
63,
7617,
8,
8877,
304,
272,
15271,
14,
1361,
63,
5735,
480,
21754,
401,
298,
6257,
531,
272,
15271,
14,
1361,
63,
5735,
480,
21754,
401,
298,
15943,
531,
421,
199,
318,
3906,
63,
1421,
63,
1700,
8,
8877,
304,
272,
367,
284,
315,
1425,
8,
845,
304,
267,
15271,
14,
1361,
63,
5735,
480,
13046,
401,
298,
1700,
450,
68,
2,
450,
284,
9,
398,
340,
284,
450,
650,
508,
378,
26,
288,
15271,
14,
1065,
63,
2423,
8,
2423,
63,
67,
1065,
335,
63,
10548,
12,
298,
35,
1065,
335,
316,
5579,
531,
398,
340,
2196,
14,
2355,
342,
665,
378,
14,
18,
26,
288,
15271,
14,
1361,
63,
705,
480,
47,
72,
949,
397,
9124,
421,
199,
318,
3906,
63,
67,
1065,
335,
63,
10548,
8,
8877,
304,
272,
367,
284,
315,
1425,
8,
2355,
14,
8393,
8,
18,
12,
1520,
2298,
267,
15271,
14,
1361,
63,
5735,
480,
13329,
35,
401,
620,
8,
2355,
14,
8393,
2801,
1960,
12,
2948,
1724,
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,
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
] |
elkingtonmcb/scikit-learn
|
sklearn/setup.py
|
225
|
2856
|
import os
from os.path import join
import warnings
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import get_info, BlasNotFoundError
import numpy
libraries = []
if os.name == 'posix':
libraries.append('m')
config = Configuration('sklearn', parent_package, top_path)
config.add_subpackage('__check_build')
config.add_subpackage('svm')
config.add_subpackage('datasets')
config.add_subpackage('datasets/tests')
config.add_subpackage('feature_extraction')
config.add_subpackage('feature_extraction/tests')
config.add_subpackage('cluster')
config.add_subpackage('cluster/tests')
config.add_subpackage('covariance')
config.add_subpackage('covariance/tests')
config.add_subpackage('cross_decomposition')
config.add_subpackage('decomposition')
config.add_subpackage('decomposition/tests')
config.add_subpackage("ensemble")
config.add_subpackage("ensemble/tests")
config.add_subpackage('feature_selection')
config.add_subpackage('feature_selection/tests')
config.add_subpackage('utils')
config.add_subpackage('utils/tests')
config.add_subpackage('externals')
config.add_subpackage('mixture')
config.add_subpackage('mixture/tests')
config.add_subpackage('gaussian_process')
config.add_subpackage('gaussian_process/tests')
config.add_subpackage('neighbors')
config.add_subpackage('neural_network')
config.add_subpackage('preprocessing')
config.add_subpackage('manifold')
config.add_subpackage('metrics')
config.add_subpackage('semi_supervised')
config.add_subpackage("tree")
config.add_subpackage("tree/tests")
config.add_subpackage('metrics/tests')
config.add_subpackage('metrics/cluster')
config.add_subpackage('metrics/cluster/tests')
# add cython extension module for isotonic regression
config.add_extension(
'_isotonic',
sources=['_isotonic.c'],
include_dirs=[numpy.get_include()],
libraries=libraries,
)
# some libs needs cblas, fortran-compiled BLAS will not be sufficient
blas_info = get_info('blas_opt', 0)
if (not blas_info) or (
('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', [])):
config.add_library('cblas',
sources=[join('src', 'cblas', '*.c')])
warnings.warn(BlasNotFoundError.__doc__)
# the following packages depend on cblas, so they have to be build
# after the above.
config.add_subpackage('linear_model')
config.add_subpackage('utils')
# add the test directory
config.add_subpackage('tests')
return config
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
|
bsd-3-clause
|
[
646,
747,
199,
504,
747,
14,
515,
492,
4263,
199,
646,
3598,
421,
199,
318,
2897,
8,
1708,
63,
2491,
4581,
2746,
63,
515,
29,
403,
304,
272,
687,
2680,
14,
13350,
14,
9923,
63,
1974,
492,
11595,
272,
687,
2680,
14,
13350,
14,
2253,
63,
815,
492,
664,
63,
815,
12,
699,
12536,
10870,
272,
492,
2680,
339,
8363,
275,
942,
272,
340,
747,
14,
354,
508,
283,
9228,
356,
267,
8363,
14,
740,
360,
77,
358,
339,
1101,
275,
11595,
360,
27993,
297,
1676,
63,
2491,
12,
2746,
63,
515,
9,
339,
1101,
14,
525,
63,
954,
2491,
10714,
1074,
63,
1506,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
16820,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
12281,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
12281,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4445,
63,
24020,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4445,
63,
24020,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4201,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4201,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
15024,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
15024,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
7925,
63,
31384,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
31384,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
31384,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
480,
15628,
531,
272,
1101,
14,
525,
63,
954,
2491,
480,
15628,
15,
2219,
531,
272,
1101,
14,
525,
63,
954,
2491,
360,
4445,
63,
5592,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4445,
63,
5592,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
1208,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
1208,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
24688,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
2664,
4167,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
2664,
4167,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
22911,
63,
1412,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
22911,
63,
1412,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
11113,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
685,
4889,
63,
1200,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
21402,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
1237,
32294,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
6759,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
19290,
63,
4792,
17311,
358,
272,
1101,
14,
525,
63,
954,
2491,
480,
2350,
531,
272,
1101,
14,
525,
63,
954,
2491,
480,
2350,
15,
2219,
531,
272,
1101,
14,
525,
63,
954,
2491,
360,
6759,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
6759,
15,
4201,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
6759,
15,
4201,
15,
2219,
358,
339,
327,
1050,
29348,
3329,
859,
367,
365,
18692,
10864,
272,
1101,
14,
525,
63,
3435,
8,
267,
2513,
374,
18692,
297,
267,
5274,
2968,
63,
374,
18692,
14,
67,
995,
267,
2387,
63,
3220,
1524,
4714,
14,
362,
63,
2613,
15618,
267,
8363,
29,
10159,
12,
272,
776,
339,
327,
2005,
20314,
4839,
286,
21044,
12,
289,
14522,
13,
8427,
15979,
1179,
911,
440,
506,
19258,
272,
6826,
305,
63,
815,
275,
664,
63,
815,
360,
21044,
63,
2992,
297,
378,
9,
272,
340,
334,
1397,
6826,
305,
63,
815,
9,
503,
334,
288,
661,
2826,
63,
619,
44,
1179,
63,
4531,
297,
413,
9,
315,
6826,
305,
63,
815,
14,
362,
360,
4640,
63,
16358,
297,
3073,
304,
267,
1101,
14,
525,
63,
4342,
360,
2894,
12536,
297,
2574,
5274,
1524,
904,
360,
2164,
297,
283,
2894,
12536,
297,
11937,
67,
2023,
267,
3598,
14,
4050,
8,
34,
12536,
10870,
855,
1301,
3368,
339,
327,
314,
2569,
6117,
11687,
641,
286,
21044,
12,
880,
2985,
1172,
370,
506,
1900,
272,
327,
2410,
314,
3432,
14,
272,
1101,
14,
525,
63,
954,
2491,
360,
6676,
63,
1238,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
1208,
358,
339,
327,
1050,
314,
511,
2082,
272,
1101,
14,
525,
63,
954,
2491,
360,
2219,
358,
339,
372,
1101,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
687,
2680,
14,
13350,
14,
1018,
492,
3272,
272,
3272,
3682,
4758,
8,
2119,
63,
515,
534,
1959,
475,
807,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
747,
199,
504,
747,
14,
515,
492,
4263,
199,
646,
3598,
421,
199,
318,
2897,
8,
1708,
63,
2491,
4581,
2746,
63,
515,
29,
403,
304,
272,
687,
2680,
14,
13350,
14,
9923,
63,
1974,
492,
11595,
272,
687,
2680,
14,
13350,
14,
2253,
63,
815,
492,
664,
63,
815,
12,
699,
12536,
10870,
272,
492,
2680,
339,
8363,
275,
942,
272,
340,
747,
14,
354,
508,
283,
9228,
356,
267,
8363,
14,
740,
360,
77,
358,
339,
1101,
275,
11595,
360,
27993,
297,
1676,
63,
2491,
12,
2746,
63,
515,
9,
339,
1101,
14,
525,
63,
954,
2491,
10714,
1074,
63,
1506,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
16820,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
12281,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
12281,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4445,
63,
24020,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4445,
63,
24020,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4201,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4201,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
15024,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
15024,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
7925,
63,
31384,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
31384,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
31384,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
480,
15628,
531,
272,
1101,
14,
525,
63,
954,
2491,
480,
15628,
15,
2219,
531,
272,
1101,
14,
525,
63,
954,
2491,
360,
4445,
63,
5592,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
4445,
63,
5592,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
1208,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
1208,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
24688,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
2664,
4167,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
2664,
4167,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
22911,
63,
1412,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
22911,
63,
1412,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
11113,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
685,
4889,
63,
1200,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
21402,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
1237,
32294,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
6759,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
19290,
63,
4792,
17311,
358,
272,
1101,
14,
525,
63,
954,
2491,
480,
2350,
531,
272,
1101,
14,
525,
63,
954,
2491,
480,
2350,
15,
2219,
531,
272,
1101,
14,
525,
63,
954,
2491,
360,
6759,
15,
2219,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
6759,
15,
4201,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
6759,
15,
4201,
15,
2219,
358,
339,
327,
1050,
29348,
3329,
859,
367,
365,
18692,
10864,
272,
1101,
14,
525,
63,
3435,
8,
267,
2513,
374,
18692,
297,
267,
5274,
2968,
63,
374,
18692,
14,
67,
995,
267,
2387,
63,
3220,
1524,
4714,
14,
362,
63,
2613,
15618,
267,
8363,
29,
10159,
12,
272,
776,
339,
327,
2005,
20314,
4839,
286,
21044,
12,
289,
14522,
13,
8427,
15979,
1179,
911,
440,
506,
19258,
272,
6826,
305,
63,
815,
275,
664,
63,
815,
360,
21044,
63,
2992,
297,
378,
9,
272,
340,
334,
1397,
6826,
305,
63,
815,
9,
503,
334,
288,
661,
2826,
63,
619,
44,
1179,
63,
4531,
297,
413,
9,
315,
6826,
305,
63,
815,
14,
362,
360,
4640,
63,
16358,
297,
3073,
304,
267,
1101,
14,
525,
63,
4342,
360,
2894,
12536,
297,
2574,
5274,
1524,
904,
360,
2164,
297,
283,
2894,
12536,
297,
11937,
67,
2023,
267,
3598,
14,
4050,
8,
34,
12536,
10870,
855,
1301,
3368,
339,
327,
314,
2569,
6117,
11687,
641,
286,
21044,
12,
880,
2985,
1172,
370,
506,
1900,
272,
327,
2410,
314,
3432,
14,
272,
1101,
14,
525,
63,
954,
2491,
360,
6676,
63,
1238,
358,
272,
1101,
14,
525,
63,
954,
2491,
360,
1208,
358,
339,
327,
1050,
314,
511,
2082,
272,
1101,
14,
525,
63,
954,
2491,
360,
2219,
358,
339,
372,
1101,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
687,
2680,
14,
13350,
14,
1018,
492,
3272,
272,
3272,
3682,
4758,
8,
2119,
63,
515,
534,
1959,
475,
807,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
TzarIvan/profitpy
|
profit/lib/widgets/historicaldatadialog.py
|
18
|
2612
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2007 Troy Melhase, Yichun Wei
# Distributed under the terms of the GNU General Public License v2
# Author: Troy Melhase <troy@gci.net>
from time import localtime, strftime
from PyQt4.QtGui import QDialog
from ib.ext.Contract import Contract
from profit.lib.widgets.ui_historicaldatadialog import Ui_HistoricalDataDialog
def nextTickerId():
## TODO: make this a session value and increment it
from random import randint
return randint(1000, 2000)
class HistoricalDataDialog(QDialog, Ui_HistoricalDataDialog):
dateTypeMap = {'Strings':1, 'Integers':2, }
rthMap = {True:1, False:0, }
keywords = [
'tickerId',
'contract',
'endDateTime',
'durationStr',
'barSizeSetting',
'whatToShow',
'useRTH',
'formatDate',
]
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setupUi(self)
def historicalRequestParameters(self):
""" Returns a map suitable for a TWS historical data request.
The map keys are the same as arguments to reqHistoricalData,
and the values are read and converted where required.
"""
params = dict.fromkeys(self.keywords, '')
for name in self.keywords:
params[name] = getattr(self, name)()
return params
def tickerId(self):
## its not even a tickerId!
tid = self.tickId.value()
if tid == -1:
tid = nextTickerId()
return tid
def contract(self):
symbol = self.symbolName.text()
security = self.secType.currentText()
exchange = self.exchangeName.currentText()
contract = Contract()
contract.m_symbol = str(symbol)
contract.m_secType = str(security)
contract.m_exchange = str(exchange)
contract.m_currency = 'USD'
return contract
def endDateTime(self):
edt = self.startDate.dateTime().toPyDateTime()
fmt = "%Y%m%d %H:%M:%S" # + strftime("%Z", localtime())
return edt.strftime(fmt)
def durationStr(self):
dvalue = self.durationValue.value()
dtype = str(self.durationType.currentText())[0]
return '%s %s' % (dvalue, dtype, )
def barSizeSetting(self):
return str(self.barSize.currentText())
def whatToShow(self):
return str(self.showType.currentText()).upper()
def useRTH(self):
return self.rthMap[bool(self.rthYes.isChecked())]
def formatDate(self):
return self.dateTypeMap[str(self.dateType.currentText())]
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
10219,
377,
4813,
603,
352,
72,
482,
12,
1488,
1158,
324,
2136,
73,
199,
3,
17484,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
373,
18,
199,
3,
6529,
26,
377,
4813,
603,
352,
72,
482,
665,
1374,
89,
32,
71,
559,
14,
846,
30,
199,
199,
504,
900,
492,
2257,
521,
12,
14053,
199,
199,
504,
14084,
20,
14,
10604,
492,
1413,
5619,
199,
199,
504,
26242,
14,
832,
14,
714,
6908,
492,
1448,
6908,
199,
504,
32630,
14,
773,
14,
8583,
14,
1907,
63,
11141,
10611,
576,
7196,
492,
32471,
63,
27785,
10611,
1451,
5619,
421,
199,
318,
2163,
11763,
281,
1304,
837,
272,
925,
3254,
26,
221,
1852,
642,
282,
2351,
574,
436,
11609,
652,
272,
687,
2196,
492,
29722,
272,
372,
29722,
8,
5279,
12,
12293,
9,
421,
199,
533,
869,
631,
10611,
1451,
5619,
8,
30983,
12,
32471,
63,
27785,
10611,
1451,
5619,
304,
272,
1434,
804,
2956,
275,
791,
12672,
356,
17,
12,
283,
2674,
83,
356,
18,
12,
789,
272,
519,
273,
2956,
275,
469,
549,
26,
17,
12,
756,
26,
16,
12,
789,
272,
7681,
275,
359,
267,
283,
28572,
1304,
297,
267,
283,
14624,
297,
267,
283,
500,
3926,
297,
267,
283,
5553,
2848,
297,
267,
283,
1700,
2320,
7776,
297,
267,
283,
10058,
1378,
6824,
297,
267,
283,
1180,
50,
2080,
297,
267,
283,
908,
2506,
297,
272,
1622,
339,
347,
636,
826,
721,
277,
12,
1676,
304,
267,
1413,
5619,
855,
826,
721,
277,
12,
1676,
9,
267,
291,
14,
2758,
18203,
8,
277,
9,
339,
347,
32530,
2017,
5976,
8,
277,
304,
267,
408,
1803,
282,
2341,
11233,
367,
282,
377,
5035,
32530,
666,
1056,
14,
398,
710,
2341,
2883,
787,
314,
2011,
465,
2368,
370,
2648,
27785,
10611,
1451,
12,
267,
436,
314,
1338,
787,
1586,
436,
6702,
2382,
1415,
14,
267,
408,
267,
1862,
275,
1211,
14,
19164,
8,
277,
14,
7511,
12,
4074,
267,
367,
536,
315,
291,
14,
7511,
26,
288,
1862,
59,
354,
61,
275,
2519,
8,
277,
12,
536,
16315,
267,
372,
1862,
339,
347,
32721,
1304,
8,
277,
304,
267,
925,
2399,
440,
2755,
282,
32721,
1304,
1,
267,
11559,
275,
291,
14,
8284,
1304,
14,
585,
342,
267,
340,
11559,
508,
446,
17,
26,
288,
11559,
275,
2163,
11763,
281,
1304,
342,
267,
372,
11559,
339,
347,
16077,
8,
277,
304,
267,
5272,
275,
291,
14,
5155,
985,
14,
505,
342,
267,
6391,
275,
291,
14,
3321,
804,
14,
1818,
1872,
342,
267,
15343,
275,
291,
14,
14197,
985,
14,
1818,
1872,
342,
267,
16077,
275,
1448,
6908,
342,
267,
16077,
14,
77,
63,
5155,
275,
620,
8,
5155,
9,
267,
16077,
14,
77,
63,
3321,
804,
275,
620,
8,
4416,
9,
267,
16077,
14,
77,
63,
14197,
275,
620,
8,
14197,
9,
267,
16077,
14,
77,
63,
4968,
275,
283,
1668,
36,
7,
267,
372,
16077,
339,
347,
1284,
3926,
8,
277,
304,
267,
325,
3583,
275,
291,
14,
928,
2506,
14,
602,
1366,
1252,
475,
2713,
3926,
342,
267,
7104,
275,
2071,
57,
5,
77,
5,
68,
450,
40,
2689,
45,
2689,
51,
2,
327,
435,
14053,
3647,
58,
401,
2257,
521,
1012,
267,
372,
325,
3583,
14,
6205,
8,
5045,
9,
339,
347,
7373,
2848,
8,
277,
304,
267,
366,
585,
275,
291,
14,
5553,
1110,
14,
585,
342,
267,
2152,
275,
620,
8,
277,
14,
5553,
804,
14,
1818,
1872,
18756,
16,
61,
267,
372,
1543,
83,
450,
83,
7,
450,
334,
68,
585,
12,
2152,
12,
776,
339,
347,
4681,
2320,
7776,
8,
277,
304,
267,
372,
620,
8,
277,
14,
1700,
2320,
14,
1818,
1872,
1012,
339,
347,
4052,
1378,
6824,
8,
277,
304,
267,
372,
620,
8,
277,
14,
2384,
804,
14,
1818,
1872,
8801,
4142,
342,
339,
347,
675,
50,
2080,
8,
277,
304,
267,
372,
291,
14,
82,
273,
2956,
59,
2245,
8,
277,
14,
82,
273,
12555,
14,
25374,
24821,
339,
347,
1475,
2506,
8,
277,
304,
267,
372,
291,
14,
602,
804,
2956,
59,
495,
8,
277,
14,
602,
804,
14,
1818,
1872,
24821,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
10219,
377,
4813,
603,
352,
72,
482,
12,
1488,
1158,
324,
2136,
73,
199,
3,
17484,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
373,
18,
199,
3,
6529,
26,
377,
4813,
603,
352,
72,
482,
665,
1374,
89,
32,
71,
559,
14,
846,
30,
199,
199,
504,
900,
492,
2257,
521,
12,
14053,
199,
199,
504,
14084,
20,
14,
10604,
492,
1413,
5619,
199,
199,
504,
26242,
14,
832,
14,
714,
6908,
492,
1448,
6908,
199,
504,
32630,
14,
773,
14,
8583,
14,
1907,
63,
11141,
10611,
576,
7196,
492,
32471,
63,
27785,
10611,
1451,
5619,
421,
199,
318,
2163,
11763,
281,
1304,
837,
272,
925,
3254,
26,
221,
1852,
642,
282,
2351,
574,
436,
11609,
652,
272,
687,
2196,
492,
29722,
272,
372,
29722,
8,
5279,
12,
12293,
9,
421,
199,
533,
869,
631,
10611,
1451,
5619,
8,
30983,
12,
32471,
63,
27785,
10611,
1451,
5619,
304,
272,
1434,
804,
2956,
275,
791,
12672,
356,
17,
12,
283,
2674,
83,
356,
18,
12,
789,
272,
519,
273,
2956,
275,
469,
549,
26,
17,
12,
756,
26,
16,
12,
789,
272,
7681,
275,
359,
267,
283,
28572,
1304,
297,
267,
283,
14624,
297,
267,
283,
500,
3926,
297,
267,
283,
5553,
2848,
297,
267,
283,
1700,
2320,
7776,
297,
267,
283,
10058,
1378,
6824,
297,
267,
283,
1180,
50,
2080,
297,
267,
283,
908,
2506,
297,
272,
1622,
339,
347,
636,
826,
721,
277,
12,
1676,
304,
267,
1413,
5619,
855,
826,
721,
277,
12,
1676,
9,
267,
291,
14,
2758,
18203,
8,
277,
9,
339,
347,
32530,
2017,
5976,
8,
277,
304,
267,
408,
1803,
282,
2341,
11233,
367,
282,
377,
5035,
32530,
666,
1056,
14,
398,
710,
2341,
2883,
787,
314,
2011,
465,
2368,
370,
2648,
27785,
10611,
1451,
12,
267,
436,
314,
1338,
787,
1586,
436,
6702,
2382,
1415,
14,
267,
408,
267,
1862,
275,
1211,
14,
19164,
8,
277,
14,
7511,
12,
4074,
267,
367,
536,
315,
291,
14,
7511,
26,
288,
1862,
59,
354,
61,
275,
2519,
8,
277,
12,
536,
16315,
267,
372,
1862,
339,
347,
32721,
1304,
8,
277,
304,
267,
925,
2399,
440,
2755,
282,
32721,
1304,
1,
267,
11559,
275,
291,
14,
8284,
1304,
14,
585,
342,
267,
340,
11559,
508,
446,
17,
26,
288,
11559,
275,
2163,
11763,
281,
1304,
342,
267,
372,
11559,
339,
347,
16077,
8,
277,
304,
267,
5272,
275,
291,
14,
5155,
985,
14,
505,
342,
267,
6391,
275,
291,
14,
3321,
804,
14,
1818,
1872,
342,
267,
15343,
275,
291,
14,
14197,
985,
14,
1818,
1872,
342,
267,
16077,
275,
1448,
6908,
342,
267,
16077,
14,
77,
63,
5155,
275,
620,
8,
5155,
9,
267,
16077,
14,
77,
63,
3321,
804,
275,
620,
8,
4416,
9,
267,
16077,
14,
77,
63,
14197,
275,
620,
8,
14197,
9,
267,
16077,
14,
77,
63,
4968,
275,
283,
1668,
36,
7,
267,
372,
16077,
339,
347,
1284,
3926,
8,
277,
304,
267,
325,
3583,
275,
291,
14,
928,
2506,
14,
602,
1366,
1252,
475,
2713,
3926,
342,
267,
7104,
275,
2071,
57,
5,
77,
5,
68,
450,
40,
2689,
45,
2689,
51,
2,
327,
435,
14053,
3647,
58,
401,
2257,
521,
1012,
267,
372,
325,
3583,
14,
6205,
8,
5045,
9,
339,
347,
7373,
2848,
8,
277,
304,
267,
366,
585,
275,
291,
14,
5553,
1110,
14,
585,
342,
267,
2152,
275,
620,
8,
277,
14,
5553,
804,
14,
1818,
1872,
18756,
16,
61,
267,
372,
1543,
83,
450,
83,
7,
450,
334,
68,
585,
12,
2152,
12,
776,
339,
347,
4681,
2320,
7776,
8,
277,
304,
267,
372,
620,
8,
277,
14,
1700,
2320,
14,
1818,
1872,
1012,
339,
347,
4052,
1378,
6824,
8,
277,
304,
267,
372,
620,
8,
277,
14,
2384,
804,
14,
1818,
1872,
8801,
4142,
342,
339,
347,
675,
50,
2080,
8,
277,
304,
267,
372,
291,
14,
82,
273,
2956,
59,
2245,
8,
277,
14,
82,
273,
12555,
14,
25374,
24821,
339,
347,
1475,
2506,
8,
277,
304,
267,
372,
291,
14,
602,
804,
2956,
59,
495,
8,
277,
14,
602,
804,
14,
1818,
1872,
24821,
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,
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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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
javierwilson/err
|
errbot/bundled/rocket.py
|
8
|
65165
|
# -*- coding: utf-8 -*-
# This file is part of the Rocket Web Server
# Copyright (c) 2011 Timothy Farrell
# Import System Modules
import sys
import errno
import socket
import logging
import platform
# Define Constants
VERSION = '1.2.4'
SERVER_NAME = socket.gethostname()
SERVER_SOFTWARE = 'Rocket %s' % VERSION
HTTP_SERVER_SOFTWARE = '%s Python/%s' % (SERVER_SOFTWARE, sys.version.split(' ')[0])
BUF_SIZE = 16384
SOCKET_TIMEOUT = 1 # in secs
THREAD_STOP_CHECK_INTERVAL = 1 # in secs, How often should threads check for a server stop message?
IS_JYTHON = platform.system() == 'Java' # Handle special cases for Jython
IGNORE_ERRORS_ON_CLOSE = {errno.ECONNABORTED, errno.ECONNRESET}
DEFAULT_LISTEN_QUEUE_SIZE = 5
DEFAULT_MIN_THREADS = 10
DEFAULT_MAX_THREADS = 0
DEFAULTS = dict(LISTEN_QUEUE_SIZE = DEFAULT_LISTEN_QUEUE_SIZE,
MIN_THREADS = DEFAULT_MIN_THREADS,
MAX_THREADS = DEFAULT_MAX_THREADS)
PY3K = sys.version_info[0] > 2
class NullHandler(logging.Handler):
"""A Logging handler to prevent library errors."""
def emit(self, record):
pass
if PY3K:
def b(val):
""" Convert string/unicode/bytes literals into bytes. This allows for
the same code to run on Python 2.x and 3.x. """
if isinstance(val, str):
return val.encode()
else:
return val
def u(val, encoding="us-ascii"):
""" Convert bytes into string/unicode. This allows for the
same code to run on Python 2.x and 3.x. """
if isinstance(val, bytes):
return val.decode(encoding)
else:
return val
else:
def b(val):
""" Convert string/unicode/bytes literals into bytes. This allows for
the same code to run on Python 2.x and 3.x. """
if isinstance(val, unicode):
return val.encode()
else:
return val
def u(val, encoding="us-ascii"):
""" Convert bytes into string/unicode. This allows for the
same code to run on Python 2.x and 3.x. """
if isinstance(val, str):
return val.decode(encoding)
else:
return val
# Import Package Modules
# package imports removed in monolithic build
__all__ = ['VERSION', 'SERVER_SOFTWARE', 'HTTP_SERVER_SOFTWARE', 'BUF_SIZE',
'IS_JYTHON', 'IGNORE_ERRORS_ON_CLOSE', 'DEFAULTS', 'PY3K', 'b', 'u',
'Rocket', 'CherryPyWSGIServer', 'SERVER_NAME', 'NullHandler']
# Monolithic build...end of module: rocket/__init__.py
# Monolithic build...start of module: rocket/connection.py
# Import System Modules
import sys
import time
import socket
try:
import ssl
has_ssl = True
except ImportError:
has_ssl = False
# Import Package Modules
# package imports removed in monolithic build
# TODO - This part is still very experimental.
#from .filelike import FileLikeSocket
class Connection(object):
__slots__ = [
'setblocking',
'sendall',
'shutdown',
'makefile',
'fileno',
'client_addr',
'client_port',
'server_port',
'socket',
'start_time',
'ssl',
'secure',
'recv',
'send',
'read',
'write'
]
def __init__(self, sock_tuple, port, secure=False):
self.client_addr, self.client_port = sock_tuple[1]
self.server_port = port
self.socket = sock_tuple[0]
self.start_time = time.time()
self.ssl = has_ssl and isinstance(self.socket, ssl.SSLSocket)
self.secure = secure
if IS_JYTHON:
# In Jython we must set TCP_NODELAY here since it does not
# inherit from the listening socket.
# See: http://bugs.jython.org/issue1309
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.socket.settimeout(SOCKET_TIMEOUT)
self.sendall = self.socket.sendall
self.shutdown = self.socket.shutdown
self.fileno = self.socket.fileno
self.setblocking = self.socket.setblocking
self.recv = self.socket.recv
self.send = self.socket.send
self.makefile = self.socket.makefile
# FIXME - this is not ready for prime-time yet.
# def makefile(self, buf_size=BUF_SIZE):
# return FileLikeSocket(self, buf_size)
def close(self):
if hasattr(self.socket, '_sock'):
try:
self.socket._sock.close()
except socket.error:
info = sys.exc_info()
if info[1].args[0] != socket.EBADF:
raise info[1]
else:
pass
self.socket.close()
# Monolithic build...end of module: rocket/connection.py
# Monolithic build...start of module: rocket/filelike.py
# Import System Modules
import socket
try:
from io import StringIO
except ImportError:
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
# Import Package Modules
# package imports removed in monolithic build
class FileLikeSocket(object):
def __init__(self, conn, buf_size=BUF_SIZE):
self.conn = conn
self.buf_size = buf_size
self.buffer = StringIO()
self.content_length = None
if self.conn.socket.gettimeout() == 0.0:
self.read = self.non_blocking_read
else:
self.read = self.blocking_read
def __iter__(self):
return self
def recv(self, size):
while True:
try:
return self.conn.recv(size)
except socket.error:
exc = sys.exc_info()
e = exc[1]
# FIXME - Don't raise socket_errors_nonblocking or socket_error_eintr
if e.args[0] not in set():
raise
def next(self):
data = self.readline()
if data == '':
raise StopIteration
return data
def non_blocking_read(self, size=None):
# Shamelessly adapted from Cherrypy!
bufr = self.buffer
bufr.seek(0, 2)
if size is None:
while True:
data = self.recv(self.buf_size)
if not data:
break
bufr.write(data)
self.buffer = StringIO()
return bufr.getvalue()
else:
buf_len = self.buffer.tell()
if buf_len >= size:
bufr.seek(0)
data = bufr.read(size)
self.buffer = StringIO(bufr.read())
return data
self.buffer = StringIO()
while True:
remaining = size - buf_len
data = self.recv(remaining)
if not data:
break
n = len(data)
if n == size and not buf_len:
return data
if n == remaining:
bufr.write(data)
del data
break
bufr.write(data)
buf_len += n
del data
return bufr.getvalue()
def blocking_read(self, length=None):
if length is None:
if self.content_length is not None:
length = self.content_length
else:
length = 1
try:
data = self.conn.recv(length)
except:
data = b('')
return data
def readline(self):
data = b("")
char = self.read(1)
while char != b('\n') and char is not b(''):
line = repr(char)
data += char
char = self.read(1)
data += char
return data
def readlines(self, hint="ignored"):
return list(self)
def close(self):
self.conn = None
self.content_length = None
# Monolithic build...end of module: rocket/filelike.py
# Monolithic build...start of module: rocket/futures.py
# Import System Modules
import time
try:
from concurrent.futures import Future, ThreadPoolExecutor
from concurrent.futures.thread import _WorkItem
has_futures = True
except ImportError:
has_futures = False
class Future:
pass
class ThreadPoolExecutor:
pass
class _WorkItem:
pass
class WSGIFuture(Future):
def __init__(self, f_dict):
Future.__init__(self)
self.timeout = None
self._mem_dict = f_dict
self._lifespan = 30
self._name = None
self._start_time = time.time()
def set_running_or_notify_cancel(self):
if time.time() - self._start_time >= self._lifespan:
self.cancel()
else:
return super(WSGIFuture, self).set_running_or_notify_cancel()
def remember(self, name, lifespan=None):
self._lifespan = lifespan or self._lifespan
if name in self._mem_dict:
raise NameError('Cannot remember future by name "%s". ' % name + \
'A future already exists with that name.' )
self._name = name
self._mem_dict[name] = self
return self
def forget(self):
if self._name in self._mem_dict and self._mem_dict[self._name] is self:
del self._mem_dict[self._name]
self._name = None
class _WorkItem(object):
def __init__(self, future, fn, args, kwargs):
self.future = future
self.fn = fn
self.args = args
self.kwargs = kwargs
def run(self):
if not self.future.set_running_or_notify_cancel():
return
try:
result = self.fn(*self.args, **self.kwargs)
except BaseException:
e = sys.exc_info()[1]
self.future.set_exception(e)
else:
self.future.set_result(result)
class WSGIExecutor(ThreadPoolExecutor):
multithread = True
multiprocess = False
def __init__(self, *args, **kwargs):
ThreadPoolExecutor.__init__(self, *args, **kwargs)
self.futures = dict()
def submit(self, fn, *args, **kwargs):
if self._shutdown_lock.acquire():
if self._shutdown:
self._shutdown_lock.release()
raise RuntimeError('Cannot schedule new futures after shutdown')
f = WSGIFuture(self.futures)
w = _WorkItem(f, fn, args, kwargs)
self._work_queue.put(w)
self._adjust_thread_count()
self._shutdown_lock.release()
return f
else:
return False
class FuturesMiddleware(object):
"""Futures middleware that adds a Futures Executor to the environment"""
def __init__(self, app, threads=5):
self.app = app
self.executor = WSGIExecutor(threads)
def __call__(self, environ, start_response):
environ["wsgiorg.executor"] = self.executor
environ["wsgiorg.futures"] = self.executor.futures
return self.app(environ, start_response)
# Monolithic build...end of module: rocket/futures.py
# Monolithic build...start of module: rocket/listener.py
# Import System Modules
import os
import socket
import logging
import traceback
from threading import Thread
try:
import ssl
from ssl import SSLError
has_ssl = True
except ImportError:
has_ssl = False
class SSLError(socket.error):
pass
# Import Package Modules
# package imports removed in monolithic build
class Listener(Thread):
"""The Listener class is a class responsible for accepting connections
and queuing them to be processed by a worker thread."""
def __init__(self, interface, queue_size, active_queue, *args, **kwargs):
Thread.__init__(self, *args, **kwargs)
# Instance variables
self.active_queue = active_queue
self.interface = interface
self.addr = interface[0]
self.port = interface[1]
self.secure = len(interface) == 4 and \
os.path.exists(interface[2]) and \
os.path.exists(interface[3])
self.thread = None
self.ready = False
# Error Log
self.err_log = logging.getLogger('Rocket.Errors.Port%i' % self.port)
self.err_log.addHandler(NullHandler())
# Build the socket
listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if not listener:
self.err_log.error("Failed to get socket.")
return
if self.secure:
if not has_ssl:
self.err_log.error("ssl module required to serve HTTPS.")
return
elif not os.path.exists(interface[2]):
data = (interface[2], interface[0], interface[1])
self.err_log.error("Cannot find key file "
"'%s'. Cannot bind to %s:%s" % data)
return
elif not os.path.exists(interface[3]):
data = (interface[3], interface[0], interface[1])
self.err_log.error("Cannot find certificate file "
"'%s'. Cannot bind to %s:%s" % data)
return
# Set socket options
try:
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
except:
msg = "Cannot share socket. Using %s:%i exclusively."
self.err_log.warning(msg % (self.addr, self.port))
try:
if not IS_JYTHON:
listener.setsockopt(socket.IPPROTO_TCP,
socket.TCP_NODELAY,
1)
except:
msg = "Cannot set TCP_NODELAY, things might run a little slower"
self.err_log.warning(msg)
try:
listener.bind((self.addr, self.port))
except:
msg = "Socket %s:%i in use by other process and it won't share."
self.err_log.error(msg % (self.addr, self.port))
else:
# We want socket operations to timeout periodically so we can
# check if the server is shutting down
listener.settimeout(THREAD_STOP_CHECK_INTERVAL)
# Listen for new connections allowing queue_size number of
# connections to wait before rejecting a connection.
listener.listen(queue_size)
self.listener = listener
self.ready = True
def wrap_socket(self, sock):
try:
sock = ssl.wrap_socket(sock,
keyfile = self.interface[2],
certfile = self.interface[3],
server_side = True,
ssl_version = ssl.PROTOCOL_SSLv23)
except SSLError:
# Generally this happens when an HTTP request is received on a
# secure socket. We don't do anything because it will be detected
# by Worker and dealt with appropriately.
pass
return sock
def start(self):
if not self.ready:
self.err_log.warning('Listener started when not ready.')
return
if self.thread is not None and self.thread.isAlive():
self.err_log.warning('Listener already running.')
return
self.thread = Thread(target=self.listen, name="Port" + str(self.port))
self.thread.start()
def isAlive(self):
if self.thread is None:
return False
return self.thread.isAlive()
def join(self):
if self.thread is None:
return
self.ready = False
self.thread.join()
del self.thread
self.thread = None
self.ready = True
def listen(self):
if __debug__:
self.err_log.debug('Entering main loop.')
while True:
try:
sock, addr = self.listener.accept()
if self.secure:
sock = self.wrap_socket(sock)
self.active_queue.put(((sock, addr),
self.interface[1],
self.secure))
except socket.timeout:
# socket.timeout will be raised every THREAD_STOP_CHECK_INTERVAL
# seconds. When that happens, we check if it's time to die.
if not self.ready:
if __debug__:
self.err_log.debug('Listener exiting.')
try:
self.listener.shutdown(socket.SHUT_RDWR)
except socket.error:
self.err_log.warning('Socket shutdown() failed')
self.listener.close()
return
else:
continue
except:
self.err_log.error(str(traceback.format_exc()))
# Monolithic build...end of module: rocket/listener.py
# Monolithic build...start of module: rocket/main.py
# Import System Modules
import sys
import time
import socket
import logging
import traceback
from threading import Lock
try:
from queue import Queue
except ImportError:
from Queue import Queue
# Import Package Modules
# package imports removed in monolithic build
# Setup Logging
log = logging.getLogger('Rocket')
log.addHandler(NullHandler())
class Rocket(object):
"""The Rocket class is responsible for handling threads and accepting and
dispatching connections."""
def __init__(self,
interfaces = ('127.0.0.1', 8000),
method = 'wsgi',
app_info = None,
min_threads = None,
max_threads = None,
queue_size = None,
timeout = 600,
handle_signals = True):
self.handle_signals = handle_signals
self.startstop_lock = Lock()
self.timeout = timeout
if not isinstance(interfaces, list):
self.interfaces = [interfaces]
else:
self.interfaces = interfaces
if min_threads is None:
min_threads = DEFAULTS['MIN_THREADS']
if max_threads is None:
max_threads = DEFAULTS['MAX_THREADS']
if not queue_size:
if hasattr(socket, 'SOMAXCONN'):
queue_size = socket.SOMAXCONN
else:
queue_size = DEFAULTS['LISTEN_QUEUE_SIZE']
if max_threads and queue_size > max_threads:
queue_size = max_threads
if isinstance(app_info, dict):
app_info['server_software'] = SERVER_SOFTWARE
self.monitor_queue = Queue()
self.active_queue = Queue()
self._threadpool = ThreadPool(get_method(method),
app_info = app_info,
active_queue = self.active_queue,
monitor_queue = self.monitor_queue,
min_threads = min_threads,
max_threads = max_threads)
# Build our socket listeners
self.listeners = [Listener(i, queue_size, self.active_queue) for i in self.interfaces]
for ndx in range(len(self.listeners)-1, 0, -1):
if not self.listeners[ndx].ready:
del self.listeners[ndx]
if not self.listeners:
log.critical("No interfaces to listen on...closing.")
sys.exit(1)
def _sigterm(self, signum, frame):
log.info('Received SIGTERM')
self.stop()
def _sighup(self, signum, frame):
log.info('Received SIGHUP')
self.restart()
def start(self, background=False):
log.info('Starting %s' % SERVER_SOFTWARE)
self.startstop_lock.acquire()
try:
# Set up our shutdown signals
if self.handle_signals:
try:
import signal
signal.signal(signal.SIGTERM, self._sigterm)
signal.signal(signal.SIGUSR1, self._sighup)
except:
log.debug('This platform does not support signals.')
# Start our worker threads
self._threadpool.start()
# Start our monitor thread
self._monitor = Monitor(self.monitor_queue,
self.active_queue,
self.timeout,
self._threadpool)
self._monitor.setDaemon(True)
self._monitor.start()
# I know that EXPR and A or B is bad but I'm keeping it for Py2.4
# compatibility.
str_extract = lambda l: (l.addr, l.port, l.secure and '*' or '')
msg = 'Listening on sockets: '
msg += ', '.join(['%s:%i%s' % str_extract(l) for l in self.listeners])
log.info(msg)
for l in self.listeners:
l.start()
finally:
self.startstop_lock.release()
if background:
return
while self._monitor.isAlive():
try:
time.sleep(THREAD_STOP_CHECK_INTERVAL)
except KeyboardInterrupt:
# Capture a keyboard interrupt when running from a console
break
except:
if self._monitor.isAlive():
log.error(str(traceback.format_exc()))
continue
return self.stop()
def stop(self, stoplogging = False):
log.info('Stopping %s' % SERVER_SOFTWARE)
self.startstop_lock.acquire()
try:
# Stop listeners
for l in self.listeners:
l.ready = False
# Encourage a context switch
time.sleep(0.01)
for l in self.listeners:
if l.isAlive():
l.join()
# Stop Monitor
self._monitor.stop()
if self._monitor.isAlive():
self._monitor.join()
# Stop Worker threads
self._threadpool.stop()
if stoplogging:
logging.shutdown()
msg = "Calling logging.shutdown() is now the responsibility of \
the application developer. Please update your \
applications to no longer call rocket.stop(True)"
try:
import warnings
raise warnings.DeprecationWarning(msg)
except ImportError:
raise RuntimeError(msg)
finally:
self.startstop_lock.release()
def restart(self):
self.stop()
self.start()
def CherryPyWSGIServer(bind_addr,
wsgi_app,
numthreads = 10,
server_name = None,
max = -1,
request_queue_size = 5,
timeout = 10,
shutdown_timeout = 5):
""" A Cherrypy wsgiserver-compatible wrapper. """
max_threads = max
if max_threads < 0:
max_threads = 0
return Rocket(bind_addr, 'wsgi', {'wsgi_app': wsgi_app},
min_threads = numthreads,
max_threads = max_threads,
queue_size = request_queue_size,
timeout = timeout)
# Monolithic build...end of module: rocket/main.py
# Monolithic build...start of module: rocket/monitor.py
# Import System Modules
import time
import logging
import select
from threading import Thread
# Import Package Modules
# package imports removed in monolithic build
class Monitor(Thread):
# Monitor worker class.
def __init__(self,
monitor_queue,
active_queue,
timeout,
threadpool,
*args,
**kwargs):
Thread.__init__(self, *args, **kwargs)
self._threadpool = threadpool
# Instance Variables
self.monitor_queue = monitor_queue
self.active_queue = active_queue
self.timeout = timeout
self.log = logging.getLogger('Rocket.Monitor')
self.log.addHandler(NullHandler())
self.connections = set()
self.active = False
def run(self):
self.active = True
conn_list = list()
list_changed = False
# We need to make sure the queue is empty before we start
while not self.monitor_queue.empty():
self.monitor_queue.get()
if __debug__:
self.log.debug('Entering monitor loop.')
# Enter thread main loop
while self.active:
# Move the queued connections to the selection pool
while not self.monitor_queue.empty():
if __debug__:
self.log.debug('In "receive timed-out connections" loop.')
c = self.monitor_queue.get()
if c is None:
# A non-client is a signal to die
if __debug__:
self.log.debug('Received a death threat.')
self.stop()
break
self.log.debug('Received a timed out connection.')
if __debug__:
assert(c not in self.connections)
if IS_JYTHON:
# Jython requires a socket to be in Non-blocking mode in
# order to select on it.
c.setblocking(False)
if __debug__:
self.log.debug('Adding connection to monitor list.')
self.connections.add(c)
list_changed = True
# Wait on those connections
if list_changed:
conn_list = list(self.connections)
list_changed = False
try:
if len(conn_list):
readable = select.select(conn_list,
[],
[],
THREAD_STOP_CHECK_INTERVAL)[0]
else:
time.sleep(THREAD_STOP_CHECK_INTERVAL)
readable = []
if not self.active:
break
# If we have any readable connections, put them back
for r in readable:
if __debug__:
self.log.debug('Restoring readable connection')
if IS_JYTHON:
# Jython requires a socket to be in Non-blocking mode in
# order to select on it, but the rest of the code requires
# that it be in blocking mode.
r.setblocking(True)
r.start_time = time.time()
self.active_queue.put(r)
self.connections.remove(r)
list_changed = True
except:
if self.active:
raise
else:
break
# If we have any stale connections, kill them off.
if self.timeout:
now = time.time()
stale = set()
for c in self.connections:
if (now - c.start_time) >= self.timeout:
stale.add(c)
for c in stale:
if __debug__:
# "EXPR and A or B" kept for Py2.4 compatibility
data = (c.client_addr, c.server_port, c.ssl and '*' or '')
self.log.debug('Flushing stale connection: %s:%i%s' % data)
self.connections.remove(c)
list_changed = True
try:
c.close()
finally:
del c
# Dynamically resize the threadpool to adapt to our changing needs.
self._threadpool.dynamic_resize()
def stop(self):
self.active = False
if __debug__:
self.log.debug('Flushing waiting connections')
while self.connections:
c = self.connections.pop()
try:
c.close()
finally:
del c
if __debug__:
self.log.debug('Flushing queued connections')
while not self.monitor_queue.empty():
c = self.monitor_queue.get()
if c is None:
continue
try:
c.close()
finally:
del c
# Place a None sentry value to cause the monitor to die.
self.monitor_queue.put(None)
# Monolithic build...end of module: rocket/monitor.py
# Monolithic build...start of module: rocket/threadpool.py
# Import System Modules
import logging
# Import Package Modules
# package imports removed in monolithic build
# Setup Logging
log = logging.getLogger('Rocket.Errors.ThreadPool')
log.addHandler(NullHandler())
class ThreadPool:
"""The ThreadPool class is a container class for all the worker threads. It
manages the number of actively running threads."""
def __init__(self,
method,
app_info,
active_queue,
monitor_queue,
min_threads=DEFAULTS['MIN_THREADS'],
max_threads=DEFAULTS['MAX_THREADS'],
):
if __debug__:
log.debug("Initializing ThreadPool.")
self.check_for_dead_threads = 0
self.active_queue = active_queue
self.worker_class = method
self.min_threads = min_threads
self.max_threads = max_threads
self.monitor_queue = monitor_queue
self.stop_server = False
self.alive = False
# TODO - Optimize this based on some real-world usage data
self.grow_threshold = int(max_threads/10) + 2
if not isinstance(app_info, dict):
app_info = dict()
if has_futures and app_info.get('futures'):
app_info['executor'] = WSGIExecutor(max([DEFAULTS['MIN_THREADS'],
2]))
app_info.update(max_threads=max_threads,
min_threads=min_threads)
self.min_threads = min_threads
self.app_info = app_info
self.threads = set()
def start(self):
self.stop_server = False
if __debug__:
log.debug("Starting threads.")
self.grow(self.min_threads)
self.alive = True
def stop(self):
self.alive = False
if __debug__:
log.debug("Stopping threads.")
self.stop_server = True
# Prompt the threads to die
self.shrink(len(self.threads))
# Stop futures initially
if has_futures and self.app_info.get('futures'):
if __debug__:
log.debug("Future executor is present. Python will not "
"exit until all jobs have finished.")
self.app_info['executor'].shutdown(wait=False)
# Give them the gun
#active_threads = [t for t in self.threads if t.isAlive()]
#while active_threads:
# t = active_threads.pop()
# t.kill()
# Wait until they pull the trigger
for t in self.threads:
if t.isAlive():
t.join()
# Clean up the mess
self.bring_out_your_dead()
def bring_out_your_dead(self):
# Remove dead threads from the pool
dead_threads = [t for t in self.threads if not t.isAlive()]
for t in dead_threads:
if __debug__:
log.debug("Removing dead thread: %s." % t.getName())
try:
# Py2.4 complains here so we put it in a try block
self.threads.remove(t)
except:
pass
self.check_for_dead_threads -= len(dead_threads)
def grow(self, amount=None):
if self.stop_server:
return
if not amount:
amount = self.max_threads
if self.alive and self.max_threads > 0:
# Don't grow any further if we've reached max_threads
amount = min([amount, self.max_threads - len(self.threads)])
if __debug__:
log.debug("Growing by %i." % amount)
for x in range(amount):
worker = self.worker_class(self.app_info,
self.active_queue,
self.monitor_queue)
worker.setDaemon(True)
self.threads.add(worker)
worker.start()
def shrink(self, amount=1):
if __debug__:
log.debug("Shrinking by %i." % amount)
self.check_for_dead_threads += amount
for x in range(amount):
self.active_queue.put(None)
def dynamic_resize(self):
if self.max_threads > self.min_threads or self.max_threads == 0:
if self.check_for_dead_threads > 0:
self.bring_out_your_dead()
queueSize = self.active_queue.qsize()
threadCount = len(self.threads)
if __debug__:
log.debug("Examining ThreadPool. %i threads and %i Q'd conxions"
% (threadCount, queueSize))
if queueSize == 0 and threadCount > self.min_threads:
self.shrink()
elif queueSize > self.grow_threshold:
self.grow(queueSize)
# Monolithic build...end of module: rocket/threadpool.py
# Monolithic build...start of module: rocket/worker.py
# Import System Modules
import re
import sys
import socket
import logging
import traceback
from wsgiref.headers import Headers
from threading import Thread
from datetime import datetime
try:
from urllib import unquote
except ImportError:
from urllib.parse import unquote
try:
from io import StringIO
except ImportError:
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
try:
from ssl import SSLError
except ImportError:
class SSLError(socket.error):
pass
# Import Package Modules
# package imports removed in monolithic build
# Define Constants
re_SLASH = re.compile('%2F', re.IGNORECASE)
re_REQUEST_LINE = re.compile(r"""^
(?P<method>OPTIONS|GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT) # Request Method
\ # (single space)
(
(?P<scheme>[^:/]+) # Scheme
(://) #
(?P<host>[^/]+) # Host
)? #
(?P<path>(\*|/[^ \?]*)) # Path
(\? (?P<query_string>[^ ]+))? # Query String
\ # (single space)
(?P<protocol>HTTPS?/1\.[01]) # Protocol
$
""", re.X)
LOG_LINE = '%(client_ip)s - "%(request_line)s" - %(status)s %(size)s'
RESPONSE = '''\
HTTP/1.1 %s
Content-Length: %i
Content-Type: %s
%s
'''
if IS_JYTHON:
HTTP_METHODS = {'OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'CONNECT'}
class Worker(Thread):
"""The Worker class is a base class responsible for receiving connections
and (a subclass) will run an application to process the the connection """
def __init__(self,
app_info,
active_queue,
monitor_queue,
*args,
**kwargs):
Thread.__init__(self, *args, **kwargs)
# Instance Variables
self.app_info = app_info
self.active_queue = active_queue
self.monitor_queue = monitor_queue
self.size = 0
self.status = "200 OK"
self.closeConnection = True
self.request_line = ""
# Request Log
self.req_log = logging.getLogger('Rocket.Requests')
self.req_log.addHandler(NullHandler())
# Error Log
self.err_log = logging.getLogger('Rocket.Errors.'+self.getName())
self.err_log.addHandler(NullHandler())
def _handleError(self, typ, val, tb):
if typ == SSLError:
if 'timed out' in val.args[0]:
typ = SocketTimeout
if typ == SocketTimeout:
if __debug__:
self.err_log.debug('Socket timed out')
self.monitor_queue.put(self.conn)
return True
if typ == SocketClosed:
self.closeConnection = True
if __debug__:
self.err_log.debug('Client closed socket')
return False
if typ == BadRequest:
self.closeConnection = True
if __debug__:
self.err_log.debug('Client sent a bad request')
return True
if typ == socket.error:
self.closeConnection = True
if val.args[0] in IGNORE_ERRORS_ON_CLOSE:
if __debug__:
self.err_log.debug('Ignorable socket Error received...'
'closing connection.')
return False
else:
self.status = "999 Utter Server Failure"
tb_fmt = traceback.format_exception(typ, val, tb)
self.err_log.error('Unhandled Error when serving '
'connection:\n' + '\n'.join(tb_fmt))
return False
self.closeConnection = True
tb_fmt = traceback.format_exception(typ, val, tb)
self.err_log.error('\n'.join(tb_fmt))
self.send_response('500 Server Error')
return False
def run(self):
if __debug__:
self.err_log.debug('Entering main loop.')
# Enter thread main loop
while True:
conn = self.active_queue.get()
if not conn:
# A non-client is a signal to die
if __debug__:
self.err_log.debug('Received a death threat.')
return conn
if isinstance(conn, tuple):
conn = Connection(*conn)
self.conn = conn
if conn.ssl != conn.secure:
self.err_log.info('Received HTTP connection on HTTPS port.')
self.send_response('400 Bad Request')
self.closeConnection = True
conn.close()
continue
else:
if __debug__:
self.err_log.debug('Received a connection.')
self.closeConnection = False
# Enter connection serve loop
while True:
if __debug__:
self.err_log.debug('Serving a request')
try:
self.run_app(conn)
log_info = dict(client_ip = conn.client_addr,
time = datetime.now().strftime('%c'),
status = self.status.split(' ')[0],
size = self.size,
request_line = self.request_line)
self.req_log.info(LOG_LINE % log_info)
except:
exc = sys.exc_info()
handled = self._handleError(*exc)
if handled:
break
else:
if self.request_line:
log_info = dict(client_ip = conn.client_addr,
time = datetime.now().strftime('%c'),
status = self.status.split(' ')[0],
size = self.size,
request_line = self.request_line + ' - not stopping')
self.req_log.info(LOG_LINE % log_info)
if self.closeConnection:
try:
conn.close()
except:
self.err_log.error(str(traceback.format_exc()))
break
def run_app(self, conn):
# Must be overridden with a method reads the request from the socket
# and sends a response.
self.closeConnection = True
raise NotImplementedError('Overload this method!')
def send_response(self, status):
stat_msg = status.split(' ', 1)[1]
msg = RESPONSE % (status,
len(stat_msg),
'text/plain',
stat_msg)
try:
self.conn.sendall(b(msg))
except socket.error:
self.closeConnection = True
self.err_log.error('Tried to send "%s" to client but received socket'
' error' % status)
#def kill(self):
# if self.isAlive() and hasattr(self, 'conn'):
# try:
# self.conn.shutdown(socket.SHUT_RDWR)
# except socket.error:
# info = sys.exc_info()
# if info[1].args[0] != socket.EBADF:
# self.err_log.debug('Error on shutdown: '+str(info))
def read_request_line(self, sock_file):
self.request_line = ''
try:
# Grab the request line
d = sock_file.readline()
if PY3K:
d = d.decode('ISO-8859-1')
if d == '\r\n':
# Allow an extra NEWLINE at the beginning per HTTP 1.1 spec
if __debug__:
self.err_log.debug('Client sent newline')
d = sock_file.readline()
if PY3K:
d = d.decode('ISO-8859-1')
except socket.timeout:
raise SocketTimeout("Socket timed out before request.")
d = d.strip()
if not d:
if __debug__:
self.err_log.debug('Client did not send a recognizable request.')
raise SocketClosed('Client closed socket.')
self.request_line = d
# NOTE: I've replaced the traditional method of procedurally breaking
# apart the request line with a (rather unsightly) regular expression.
# However, Java's regexp support sucks so bad that it actually takes
# longer in Jython to process the regexp than procedurally. So I've
# left the old code here for Jython's sake...for now.
if IS_JYTHON:
return self._read_request_line_jython(d)
match = re_REQUEST_LINE.match(d)
if not match:
self.send_response('400 Bad Request')
raise BadRequest
req = match.groupdict()
for k,v in req.items():
if not v:
req[k] = ""
if k == 'path':
req['path'] = r'%2F'.join([unquote(x) for x in re_SLASH.split(v)])
return req
def _read_request_line_jython(self, d):
d = d.strip()
try:
method, uri, proto = d.split(' ')
if not proto.startswith('HTTP') or \
proto[-3:] not in ('1.0', '1.1') or \
method not in HTTP_METHODS:
self.send_response('400 Bad Request')
raise BadRequest
except ValueError:
self.send_response('400 Bad Request')
raise BadRequest
req = dict(method=method, protocol = proto)
scheme = ''
host = ''
if uri == '*' or uri.startswith('/'):
path = uri
elif '://' in uri:
scheme, rest = uri.split('://')
host, path = rest.split('/', 1)
path = '/' + path
else:
self.send_response('400 Bad Request')
raise BadRequest
query_string = ''
if '?' in path:
path, query_string = path.split('?', 1)
path = r'%2F'.join([unquote(x) for x in re_SLASH.split(path)])
req.update(path=path,
query_string=query_string,
scheme=scheme.lower(),
host=host)
return req
def read_headers(self, sock_file):
try:
headers = dict()
l = sock_file.readline()
lname = None
lval = None
while True:
if PY3K:
try:
l = str(l, 'ISO-8859-1')
except UnicodeDecodeError:
self.err_log.warning('Client sent invalid header: ' + repr(l))
if l == '\r\n':
break
if l[0] in ' \t' and lname:
# Some headers take more than one line
lval += ',' + l.strip()
else:
# HTTP header values are latin-1 encoded
l = l.split(':', 1)
# HTTP header names are us-ascii encoded
lname = l[0].strip().upper().replace('-', '_')
lval = l[-1].strip()
headers[str(lname)] = str(lval)
l = sock_file.readline()
except socket.timeout:
raise SocketTimeout("Socket timed out before request.")
return headers
class SocketTimeout(Exception):
"""Exception for when a socket times out between requests."""
pass
class BadRequest(Exception):
"""Exception for when a client sends an incomprehensible request."""
pass
class SocketClosed(Exception):
"""Exception for when a socket is closed by the client."""
pass
class ChunkedReader(object):
def __init__(self, sock_file):
self.stream = sock_file
self.chunk_size = 0
def _read_header(self):
chunk_len = ""
try:
while "" == chunk_len:
chunk_len = self.stream.readline().strip()
return int(chunk_len, 16)
except ValueError:
return 0
def read(self, size):
data = b('')
chunk_size = self.chunk_size
while size:
if not chunk_size:
chunk_size = self._read_header()
if size < chunk_size:
data += self.stream.read(size)
chunk_size -= size
break
else:
if not chunk_size:
break
data += self.stream.read(chunk_size)
size -= chunk_size
chunk_size = 0
self.chunk_size = chunk_size
return data
def readline(self):
data = b('')
c = self.read(1)
while c and c != b('\n'):
data += c
c = self.read(1)
data += c
return data
def readlines(self):
yield self.readline()
def get_method(method):
methods = dict(wsgi=WSGIWorker,
fs=FileSystemWorker)
return methods[method.lower()]
# Monolithic build...end of module: rocket/worker.py
# Monolithic build...start of module: rocket/methods/__init__.py
# Monolithic build...end of module: rocket/methods/__init__.py
# Monolithic build...start of module: rocket/methods/fs.py
# Import System Modules
import os
import time
import mimetypes
from email.utils import formatdate
from wsgiref.headers import Headers
from wsgiref.util import FileWrapper
# Import Package Modules
# package imports removed in monolithic build
# Define Constants
CHUNK_SIZE = 2**16 # 64 Kilobyte chunks
HEADER_RESPONSE = '''HTTP/1.1 %s\r\n%s'''
INDEX_HEADER = '''\
<html>
<head><title>Directory Index: %(path)s</title>
<style> .parent { margin-bottom: 1em; }</style>
</head>
<body><h1>Directory Index: %(path)s</h1>
<table>
<tr><th>Directories</th></tr>
'''
INDEX_ROW = '''<tr><td><div class="%(cls)s"><a href="/%(link)s">%(name)s</a></div></td></tr>'''
INDEX_FOOTER = '''</table></body></html>\r\n'''
class LimitingFileWrapper(FileWrapper):
def __init__(self, limit=None, *args, **kwargs):
self.limit = limit
FileWrapper.__init__(self, *args, **kwargs)
def read(self, amt):
if amt > self.limit:
amt = self.limit
self.limit -= amt
return FileWrapper.read(self, amt)
class FileSystemWorker(Worker):
def __init__(self, *args, **kwargs):
"""Builds some instance variables that will last the life of the
thread."""
Worker.__init__(self, *args, **kwargs)
self.root = os.path.abspath(self.app_info['document_root'])
self.display_index = self.app_info['display_index']
def serve_file(self, filepath, headers):
filestat = os.stat(filepath)
self.size = filestat.st_size
modtime = time.strftime("%a, %d %b %Y %H:%M:%S GMT",
time.gmtime(filestat.st_mtime))
self.headers.add_header('Last-Modified', modtime)
if headers.get('if_modified_since') == modtime:
# The browser cache is up-to-date, send a 304.
self.status = "304 Not Modified"
self.data = []
return
ct = mimetypes.guess_type(filepath)[0]
self.content_type = ct if ct else 'text/plain'
try:
f = open(filepath, 'rb')
self.headers['Pragma'] = 'cache'
self.headers['Cache-Control'] = 'private'
self.headers['Content-Length'] = str(self.size)
if self.etag:
self.headers.add_header('Etag', self.etag)
if self.expires:
self.headers.add_header('Expires', self.expires)
try:
# Implement 206 partial file support.
start, end = headers['range'].split('-')
start = 0 if not start.isdigit() else int(start)
end = self.size if not end.isdigit() else int(end)
if self.size < end or start < 0:
self.status = "214 Unsatisfiable Range Requested"
self.data = FileWrapper(f, CHUNK_SIZE)
else:
f.seek(start)
self.data = LimitingFileWrapper(f, blksize=CHUNK_SIZE, limit=end)
self.status = "206 Partial Content"
except:
self.data = FileWrapper(f, CHUNK_SIZE)
except IOError:
self.status = "403 Forbidden"
def serve_dir(self, pth, rpth):
def rel_path(path):
return os.path.normpath(path[len(self.root):] if path.startswith(self.root) else path)
if not self.display_index:
self.status = '404 File Not Found'
return b('')
else:
self.content_type = 'text/html'
dir_contents = [os.path.join(pth, x) for x in os.listdir(os.path.normpath(pth))]
dir_contents.sort()
dirs = [rel_path(x)+'/' for x in dir_contents if os.path.isdir(x)]
files = [rel_path(x) for x in dir_contents if os.path.isfile(x)]
self.data = [INDEX_HEADER % dict(path='/'+rpth)]
if rpth:
self.data += [INDEX_ROW % dict(name='(parent directory)', cls='dir parent', link='/'.join(rpth[:-1].split('/')[:-1]))]
self.data += [INDEX_ROW % dict(name=os.path.basename(x[:-1]), link=os.path.join(rpth, os.path.basename(x[:-1])).replace('\\', '/'), cls='dir') for x in dirs]
self.data += ['<tr><th>Files</th></tr>']
self.data += [INDEX_ROW % dict(name=os.path.basename(x), link=os.path.join(rpth, os.path.basename(x)).replace('\\', '/'), cls='file') for x in files]
self.data += [INDEX_FOOTER]
self.headers['Content-Length'] = self.size = str(sum([len(x) for x in self.data]))
self.status = '200 OK'
def run_app(self, conn):
self.status = "200 OK"
self.size = 0
self.expires = None
self.etag = None
self.content_type = 'text/plain'
self.content_length = None
if __debug__:
self.err_log.debug('Getting sock_file')
# Build our file-like object
sock_file = conn.makefile('rb',BUF_SIZE)
request = self.read_request_line(sock_file)
if request['method'].upper() not in ('GET', ):
self.status = "501 Not Implemented"
try:
# Get our file path
headers = dict([(str(k.lower()), v) for k, v in self.read_headers(sock_file).items()])
rpath = request.get('path', '').lstrip('/')
filepath = os.path.join(self.root, rpath)
filepath = os.path.abspath(filepath)
if __debug__:
self.err_log.debug('Request for path: %s' % filepath)
self.closeConnection = headers.get('connection', 'close').lower() == 'close'
self.headers = Headers([('Date', formatdate(usegmt=True)),
('Server', HTTP_SERVER_SOFTWARE),
('Connection', headers.get('connection', 'close')),
])
if not filepath.lower().startswith(self.root.lower()):
# File must be within our root directory
self.status = "400 Bad Request"
self.closeConnection = True
elif not os.path.exists(filepath):
self.status = "404 File Not Found"
self.closeConnection = True
elif os.path.isdir(filepath):
self.serve_dir(filepath, rpath)
elif os.path.isfile(filepath):
self.serve_file(filepath, headers)
else:
# It exists but it's not a file or a directory????
# What is it then?
self.status = "501 Not Implemented"
self.closeConnection = True
h = self.headers
statcode, statstr = self.status.split(' ', 1)
statcode = int(statcode)
if statcode >= 400:
h.add_header('Content-Type', self.content_type)
self.data = [statstr]
# Build our output headers
header_data = HEADER_RESPONSE % (self.status, str(h))
# Send the headers
if __debug__:
self.err_log.debug('Sending Headers: %s' % repr(header_data))
self.conn.sendall(b(header_data))
for data in self.data:
self.conn.sendall(b(data))
if hasattr(self.data, 'close'):
self.data.close()
finally:
if __debug__:
self.err_log.debug('Finally closing sock_file')
sock_file.close()
# Monolithic build...end of module: rocket/methods/fs.py
# Monolithic build...start of module: rocket/methods/wsgi.py
# Import System Modules
import sys
import socket
from wsgiref.headers import Headers
from wsgiref.util import FileWrapper
# Import Package Modules
# package imports removed in monolithic build
if PY3K:
from email.utils import formatdate
else:
# Caps Utils for Py2.4 compatibility
from email.Utils import formatdate
# Define Constants
NEWLINE = b('\r\n')
HEADER_RESPONSE = '''HTTP/1.1 %s\r\n%s'''
BASE_ENV = {'SERVER_NAME': SERVER_NAME,
'SCRIPT_NAME': '', # Direct call WSGI does not need a name
'wsgi.errors': sys.stderr,
'wsgi.version': (1, 0),
'wsgi.multiprocess': False,
'wsgi.run_once': False,
'wsgi.file_wrapper': FileWrapper
}
class WSGIWorker(Worker):
def __init__(self, *args, **kwargs):
"""Builds some instance variables that will last the life of the
thread."""
Worker.__init__(self, *args, **kwargs)
if isinstance(self.app_info, dict):
multithreaded = self.app_info.get('max_threads') != 1
else:
multithreaded = False
self.base_environ = dict({'SERVER_SOFTWARE': self.app_info['server_software'],
'wsgi.multithread': multithreaded,
})
self.base_environ.update(BASE_ENV)
# Grab our application
self.app = self.app_info.get('wsgi_app')
if not hasattr(self.app, "__call__"):
raise TypeError("The wsgi_app specified (%s) is not a valid WSGI application." % repr(self.app))
# Enable futures
if has_futures and self.app_info.get('futures'):
executor = self.app_info['executor']
self.base_environ.update({"wsgiorg.executor": executor,
"wsgiorg.futures": executor.futures})
def build_environ(self, sock_file, conn):
""" Build the execution environment. """
# Grab the request line
request = self.read_request_line(sock_file)
# Copy the Base Environment
environ = self.base_environ.copy()
# Grab the headers
for k, v in self.read_headers(sock_file).items():
environ[str('HTTP_'+k)] = v
# Add CGI Variables
environ['REQUEST_METHOD'] = request['method']
environ['PATH_INFO'] = request['path']
environ['SERVER_PROTOCOL'] = request['protocol']
environ['SERVER_PORT'] = str(conn.server_port)
environ['REMOTE_PORT'] = str(conn.client_port)
environ['REMOTE_ADDR'] = str(conn.client_addr)
environ['QUERY_STRING'] = request['query_string']
if 'HTTP_CONTENT_LENGTH' in environ:
environ['CONTENT_LENGTH'] = environ['HTTP_CONTENT_LENGTH']
if 'HTTP_CONTENT_TYPE' in environ:
environ['CONTENT_TYPE'] = environ['HTTP_CONTENT_TYPE']
# Save the request method for later
self.request_method = environ['REQUEST_METHOD']
# Add Dynamic WSGI Variables
if conn.ssl:
environ['wsgi.url_scheme'] = 'https'
environ['HTTPS'] = 'on'
else:
environ['wsgi.url_scheme'] = 'http'
if environ.get('HTTP_TRANSFER_ENCODING', '') == 'chunked':
environ['wsgi.input'] = ChunkedReader(sock_file)
else:
environ['wsgi.input'] = sock_file
return environ
def send_headers(self, data, sections):
h_set = self.header_set
# Does the app want us to send output chunked?
self.chunked = h_set.get('transfer-encoding', '').lower() == 'chunked'
# Add a Date header if it's not there already
if not 'date' in h_set:
h_set['Date'] = formatdate(usegmt=True)
# Add a Server header if it's not there already
if not 'server' in h_set:
h_set['Server'] = HTTP_SERVER_SOFTWARE
if 'content-length' in h_set:
self.size = int(h_set['content-length'])
else:
s = int(self.status.split(' ')[0])
if s < 200 or s not in (204, 205, 304):
if not self.chunked:
if sections == 1:
# Add a Content-Length header if it's not there already
h_set['Content-Length'] = str(len(data))
self.size = len(data)
else:
# If they sent us more than one section, we blow chunks
h_set['Transfer-Encoding'] = 'Chunked'
self.chunked = True
if __debug__:
self.err_log.debug('Adding header...'
'Transfer-Encoding: Chunked')
if 'connection' not in h_set:
# If the application did not provide a connection header, fill it in
client_conn = self.environ.get('HTTP_CONNECTION', '').lower()
if self.environ['SERVER_PROTOCOL'] == 'HTTP/1.1':
# HTTP = 1.1 defaults to keep-alive connections
if client_conn:
h_set['Connection'] = client_conn
else:
h_set['Connection'] = 'keep-alive'
else:
# HTTP < 1.1 supports keep-alive but it's quirky so we don't support it
h_set['Connection'] = 'close'
# Close our connection if we need to.
self.closeConnection = h_set.get('connection', '').lower() == 'close'
# Build our output headers
header_data = HEADER_RESPONSE % (self.status, str(h_set))
# Send the headers
if __debug__:
self.err_log.debug('Sending Headers: %s' % repr(header_data))
self.conn.sendall(b(header_data))
self.headers_sent = True
def write_warning(self, data, sections=None):
self.err_log.warning('WSGI app called write method directly. This is '
'deprecated behavior. Please update your app.')
return self.write(data, sections)
def write(self, data, sections=None):
""" Write the data to the output socket. """
if self.error[0]:
self.status = self.error[0]
data = b(self.error[1])
if not self.headers_sent:
self.send_headers(data, sections)
if self.request_method != 'HEAD':
try:
if self.chunked:
self.conn.sendall(b('%x\r\n%s\r\n' % (len(data), data)))
else:
self.conn.sendall(data)
except socket.error:
# But some clients will close the connection before that
# resulting in a socket error.
self.closeConnection = True
def start_response(self, status, response_headers, exc_info=None):
""" Store the HTTP status and headers to be sent when self.write is
called. """
if exc_info:
try:
if self.headers_sent:
# Re-raise original exception if headers sent
# because this violates WSGI specification.
raise
finally:
exc_info = None
elif self.header_set:
raise AssertionError("Headers already set!")
if PY3K and not isinstance(status, str):
self.status = str(status, 'ISO-8859-1')
else:
self.status = status
# Make sure headers are bytes objects
try:
self.header_set = Headers(response_headers)
except UnicodeDecodeError:
self.error = ('500 Internal Server Error',
'HTTP Headers should be bytes')
self.err_log.error('Received HTTP Headers from client that contain'
' invalid characters for Latin-1 encoding.')
return self.write_warning
def run_app(self, conn):
self.size = 0
self.header_set = Headers([])
self.headers_sent = False
self.error = (None, None)
self.chunked = False
sections = None
output = None
if __debug__:
self.err_log.debug('Getting sock_file')
# Build our file-like object
if PY3K:
sock_file = conn.makefile(mode='rb', buffering=BUF_SIZE)
else:
sock_file = conn.makefile(BUF_SIZE)
try:
# Read the headers and build our WSGI environment
self.environ = environ = self.build_environ(sock_file, conn)
# Handle 100 Continue
if environ.get('HTTP_EXPECT', '') == '100-continue':
res = environ['SERVER_PROTOCOL'] + ' 100 Continue\r\n\r\n'
conn.sendall(b(res))
# Send it to our WSGI application
output = self.app(environ, self.start_response)
if not hasattr(output, '__len__') and not hasattr(output, '__iter__'):
self.error = ('500 Internal Server Error',
'WSGI applications must return a list or '
'generator type.')
if hasattr(output, '__len__'):
sections = len(output)
for data in output:
# Don't send headers until body appears
if data:
self.write(data, sections)
if self.chunked:
# If chunked, send our final chunk length
self.conn.sendall(b('0\r\n\r\n'))
elif not self.headers_sent:
# Send headers if the body was empty
self.send_headers('', sections)
# Don't capture exceptions here. The Worker class handles
# them appropriately.
finally:
if __debug__:
self.err_log.debug('Finally closing output and sock_file')
if hasattr(output,'close'):
output.close()
sock_file.close()
# Monolithic build...end of module: rocket/methods/wsgi.py
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
961,
570,
365,
1777,
402,
314,
820,
1539,
6001,
7146,
199,
3,
1898,
334,
67,
9,
7760,
377,
73,
573,
273,
89,
481,
285,
264,
914,
199,
199,
3,
3161,
6187,
18167,
199,
646,
984,
199,
646,
7554,
199,
646,
2838,
199,
646,
2050,
199,
646,
4298,
199,
199,
3,
13930,
22296,
199,
4612,
275,
283,
17,
14,
18,
14,
20,
7,
199,
6613,
63,
2339,
275,
2838,
14,
29789,
342,
199,
6613,
63,
26734,
275,
283,
50,
1539,
450,
83,
7,
450,
15945,
199,
2856,
63,
6613,
63,
26734,
275,
1543,
83,
2018,
3149,
83,
7,
450,
334,
6613,
63,
26734,
12,
984,
14,
1023,
14,
1294,
360,
27618,
16,
566,
199,
21323,
63,
4305,
275,
24619,
1349,
199,
17462,
63,
8899,
275,
413,
327,
315,
20091,
199,
16103,
63,
11632,
63,
8936,
63,
17359,
275,
413,
327,
315,
20091,
12,
7494,
14115,
1077,
7183,
1104,
367,
282,
1654,
3631,
1245,
31,
199,
1311,
63,
42,
57,
8472,
275,
4298,
14,
2253,
342,
508,
283,
12576,
7,
327,
8690,
4539,
5560,
367,
25333,
199,
11209,
63,
21477,
63,
615,
63,
18219,
275,
469,
7931,
14,
37,
17489,
27113,
1149,
12,
7554,
14,
37,
17489,
18066,
93,
199,
3472,
63,
4924,
742,
63,
15125,
63,
4305,
275,
959,
199,
3472,
63,
4896,
63,
16103,
51,
275,
1616,
199,
3472,
63,
4283,
63,
16103,
51,
275,
378,
199,
30773,
275,
1211,
8,
4924,
742,
63,
15125,
63,
4305,
275,
6186,
63,
4924,
742,
63,
15125,
63,
4305,
12,
355,
15861,
63,
16103,
51,
275,
6186,
63,
4896,
63,
16103,
51,
12,
355,
9141,
63,
16103,
51,
275,
6186,
63,
4283,
63,
16103,
51,
9,
199,
199,
4521,
19,
43,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
690,
499,
199,
199,
533,
12119,
2461,
8,
4806,
14,
2461,
304,
272,
408,
33,
19928,
3016,
370,
7981,
3555,
2552,
1041,
272,
347,
8689,
8,
277,
12,
2777,
304,
267,
986,
199,
199,
692,
7843,
19,
43,
26,
272,
347,
330,
8,
637,
304,
267,
408,
7905,
1059,
15,
2975,
15,
2394,
18041,
1901,
2783,
14,
221,
961,
6127,
367,
267,
314,
2011,
1233,
370,
1255,
641,
2018,
499,
14,
88,
436,
650,
14,
88,
14,
408,
267,
340,
1228,
8,
637,
12,
620,
304,
288,
372,
1139,
14,
2143,
342,
267,
587,
26,
288,
372,
1139,
339,
347,
399,
8,
637,
12,
2644,
628,
527,
13,
4371,
2349,
267,
408,
7905,
2783,
1901,
1059,
15,
2975,
14,
221,
961,
6127,
367,
314,
267,
2011,
1233,
370,
1255,
641,
2018,
499,
14,
88,
436,
650,
14,
88,
14,
408,
267,
340,
1228,
8,
637,
12,
2783,
304,
288,
372,
1139,
14,
2708,
8,
2991,
9,
267,
587,
26,
288,
372,
1139,
199,
199,
2836,
26,
272,
347,
330,
8,
637,
304,
267,
408,
7905,
1059,
15,
2975,
15,
2394,
18041,
1901,
2783,
14,
221,
961,
6127,
367,
267,
314,
2011,
1233,
370,
1255,
641,
2018,
499,
14,
88,
436,
650,
14,
88,
14,
408,
267,
340,
1228,
8,
637,
12,
2649,
304,
288,
372,
1139,
14,
2143,
342,
267,
587,
26,
288,
372,
1139,
339,
347,
399,
8,
637,
12,
2644,
628,
527,
13,
4371,
2349,
267,
408,
7905,
2783,
1901,
1059,
15,
2975,
14,
221,
961,
6127,
367,
314,
267,
2011,
1233,
370,
1255,
641,
2018,
499,
14,
88,
436,
650,
14,
88,
14,
408,
267,
340,
1228,
8,
637,
12,
620,
304,
288,
372,
1139,
14,
2708,
8,
2991,
9,
267,
587,
26,
288,
372,
1139,
199,
199,
3,
3161,
15665,
18167,
199,
3,
2559,
8925,
4829,
315,
3485,
23711,
273,
530,
1900,
199,
199,
363,
452,
363,
275,
788,
4612,
297,
283,
6613,
63,
26734,
297,
283,
2856,
63,
6613,
63,
26734,
297,
283,
21323,
63,
4305,
297,
1779,
283,
1311,
63,
42,
57,
8472,
297,
283,
11209,
63,
21477,
63,
615,
63,
18219,
297,
283,
30773,
297,
283,
4521,
19,
43,
297,
283,
66,
297,
283,
85,
297,
1779,
283,
50,
1539,
297,
283,
1049,
281,
27794,
55,
28732,
297,
283,
6613,
63,
2339,
297,
283,
8849,
2461,
418,
199,
199,
3,
10953,
23711,
273,
530,
1900,
1396,
500,
402,
859,
26,
882,
2284,
22128,
826,
4343,
647,
199,
3,
10953,
23711,
273,
530,
1900,
1396,
928,
402,
859,
26,
882,
2284,
15,
2105,
14,
647,
199,
199,
3,
3161,
6187,
18167,
199,
646,
984,
199,
646,
900,
199,
646,
2838,
199,
893,
26,
272,
492,
6149,
272,
965,
63,
4266,
275,
715,
199,
2590,
3545,
26,
272,
965,
63,
4266,
275,
756,
199,
3,
3161,
15665,
18167,
199,
3,
2559,
8925,
4829,
315,
3485,
23711,
273,
530,
1900,
199,
3,
3254,
446,
961,
1777,
365,
5139,
7437,
22820,
14,
199,
3,
504,
1275,
493,
2930,
492,
3814,
12545,
3869,
199,
199,
533,
8113,
8,
785,
304,
272,
636,
7257,
363,
275,
359,
267,
283,
409,
13091,
297,
267,
283,
22695,
297,
267,
283,
8831,
297,
267,
283,
13941,
297,
267,
283,
9843,
297,
267,
283,
1258,
63,
2697,
297,
267,
283,
1258,
63,
719,
297,
267,
283,
1000,
63,
719,
297,
267,
283,
3450,
297,
267,
283,
928,
63,
521,
297,
267,
283,
4266,
297,
267,
283,
7817,
297,
267,
283,
7637,
297,
267,
283,
2254,
297,
267,
283,
739,
297,
267,
283,
952,
7,
272,
1622,
339,
347,
636,
826,
721,
277,
12,
6771,
63,
2960,
12,
1844,
12,
11153,
29,
797,
304,
267,
291,
14,
1258,
63,
2697,
12,
291,
14,
1258,
63,
719,
275,
6771,
63,
2960,
59,
17,
61,
267,
291,
14,
1000,
63,
719,
275,
1844,
267,
291,
14,
3450,
275,
6771,
63,
2960,
59,
16,
61,
267,
291,
14,
928,
63,
521,
275,
900,
14,
521,
342,
267,
291,
14,
4266,
275,
965,
63,
4266,
436,
1228,
8,
277,
14,
3450,
12,
6149,
14,
5413,
3869,
9,
267,
291,
14,
7817,
275,
11153,
398,
340,
2281,
63,
42,
57,
8472,
26,
288,
327,
1010,
25333,
781,
1471,
663,
13488,
63,
2826,
18616,
2348,
3967,
652,
1630,
440,
288,
327,
8287,
687,
314,
22721,
2838,
14,
288,
327,
1666,
26,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
969,
1643,
288,
291,
14,
3450
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
961,
570,
365,
1777,
402,
314,
820,
1539,
6001,
7146,
199,
3,
1898,
334,
67,
9,
7760,
377,
73,
573,
273,
89,
481,
285,
264,
914,
199,
199,
3,
3161,
6187,
18167,
199,
646,
984,
199,
646,
7554,
199,
646,
2838,
199,
646,
2050,
199,
646,
4298,
199,
199,
3,
13930,
22296,
199,
4612,
275,
283,
17,
14,
18,
14,
20,
7,
199,
6613,
63,
2339,
275,
2838,
14,
29789,
342,
199,
6613,
63,
26734,
275,
283,
50,
1539,
450,
83,
7,
450,
15945,
199,
2856,
63,
6613,
63,
26734,
275,
1543,
83,
2018,
3149,
83,
7,
450,
334,
6613,
63,
26734,
12,
984,
14,
1023,
14,
1294,
360,
27618,
16,
566,
199,
21323,
63,
4305,
275,
24619,
1349,
199,
17462,
63,
8899,
275,
413,
327,
315,
20091,
199,
16103,
63,
11632,
63,
8936,
63,
17359,
275,
413,
327,
315,
20091,
12,
7494,
14115,
1077,
7183,
1104,
367,
282,
1654,
3631,
1245,
31,
199,
1311,
63,
42,
57,
8472,
275,
4298,
14,
2253,
342,
508,
283,
12576,
7,
327,
8690,
4539,
5560,
367,
25333,
199,
11209,
63,
21477,
63,
615,
63,
18219,
275,
469,
7931,
14,
37,
17489,
27113,
1149,
12,
7554,
14,
37,
17489,
18066,
93,
199,
3472,
63,
4924,
742,
63,
15125,
63,
4305,
275,
959,
199,
3472,
63,
4896,
63,
16103,
51,
275,
1616,
199,
3472,
63,
4283,
63,
16103,
51,
275,
378,
199,
30773,
275,
1211,
8,
4924,
742,
63,
15125,
63,
4305,
275,
6186,
63,
4924,
742,
63,
15125,
63,
4305,
12,
355,
15861,
63,
16103,
51,
275,
6186,
63,
4896,
63,
16103,
51,
12,
355,
9141,
63,
16103,
51,
275,
6186,
63,
4283,
63,
16103,
51,
9,
199,
199,
4521,
19,
43,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
690,
499,
199,
199,
533,
12119,
2461,
8,
4806,
14,
2461,
304,
272,
408,
33,
19928,
3016,
370,
7981,
3555,
2552,
1041,
272,
347,
8689,
8,
277,
12,
2777,
304,
267,
986,
199,
199,
692,
7843,
19,
43,
26,
272,
347,
330,
8,
637,
304,
267,
408,
7905,
1059,
15,
2975,
15,
2394,
18041,
1901,
2783,
14,
221,
961,
6127,
367,
267,
314,
2011,
1233,
370,
1255,
641,
2018,
499,
14,
88,
436,
650,
14,
88,
14,
408,
267,
340,
1228,
8,
637,
12,
620,
304,
288,
372,
1139,
14,
2143,
342,
267,
587,
26,
288,
372,
1139,
339,
347,
399,
8,
637,
12,
2644,
628,
527,
13,
4371,
2349,
267,
408,
7905,
2783,
1901,
1059,
15,
2975,
14,
221,
961,
6127,
367,
314,
267,
2011,
1233,
370,
1255,
641,
2018,
499,
14,
88,
436,
650,
14,
88,
14,
408,
267,
340,
1228,
8,
637,
12,
2783,
304,
288,
372,
1139,
14,
2708,
8,
2991,
9,
267,
587,
26,
288,
372,
1139,
199,
199,
2836,
26,
272,
347,
330,
8,
637,
304,
267,
408,
7905,
1059,
15,
2975,
15,
2394,
18041,
1901,
2783,
14,
221,
961,
6127,
367,
267,
314,
2011,
1233,
370,
1255,
641,
2018,
499,
14,
88,
436,
650,
14,
88,
14,
408,
267,
340,
1228,
8,
637,
12,
2649,
304,
288,
372,
1139,
14,
2143,
342,
267,
587,
26,
288,
372,
1139,
339,
347,
399,
8,
637,
12,
2644,
628,
527,
13,
4371,
2349,
267,
408,
7905,
2783,
1901,
1059,
15,
2975,
14,
221,
961,
6127,
367,
314,
267,
2011,
1233,
370,
1255,
641,
2018,
499,
14,
88,
436,
650,
14,
88,
14,
408,
267,
340,
1228,
8,
637,
12,
620,
304,
288,
372,
1139,
14,
2708,
8,
2991,
9,
267,
587,
26,
288,
372,
1139,
199,
199,
3,
3161,
15665,
18167,
199,
3,
2559,
8925,
4829,
315,
3485,
23711,
273,
530,
1900,
199,
199,
363,
452,
363,
275,
788,
4612,
297,
283,
6613,
63,
26734,
297,
283,
2856,
63,
6613,
63,
26734,
297,
283,
21323,
63,
4305,
297,
1779,
283,
1311,
63,
42,
57,
8472,
297,
283,
11209,
63,
21477,
63,
615,
63,
18219,
297,
283,
30773,
297,
283,
4521,
19,
43,
297,
283,
66,
297,
283,
85,
297,
1779,
283,
50,
1539,
297,
283,
1049,
281,
27794,
55,
28732,
297,
283,
6613,
63,
2339,
297,
283,
8849,
2461,
418,
199,
199,
3,
10953,
23711,
273,
530,
1900,
1396,
500,
402,
859,
26,
882,
2284,
22128,
826,
4343,
647,
199,
3,
10953,
23711,
273,
530,
1900,
1396,
928,
402,
859,
26,
882,
2284,
15,
2105,
14,
647,
199,
199,
3,
3161,
6187,
18167,
199,
646,
984,
199,
646,
900,
199,
646,
2838,
199,
893,
26,
272,
492,
6149,
272,
965,
63,
4266,
275,
715,
199,
2590,
3545,
26,
272,
965,
63,
4266,
275,
756,
199,
3,
3161,
15665,
18167,
199,
3,
2559,
8925,
4829,
315,
3485,
23711,
273,
530,
1900,
199,
3,
3254,
446,
961,
1777,
365,
5139,
7437,
22820,
14,
199,
3,
504,
1275,
493,
2930,
492,
3814,
12545,
3869,
199,
199,
533,
8113,
8,
785,
304,
272,
636,
7257,
363,
275,
359,
267,
283,
409,
13091,
297,
267,
283,
22695,
297,
267,
283,
8831,
297,
267,
283,
13941,
297,
267,
283,
9843,
297,
267,
283,
1258,
63,
2697,
297,
267,
283,
1258,
63,
719,
297,
267,
283,
1000,
63,
719,
297,
267,
283,
3450,
297,
267,
283,
928,
63,
521,
297,
267,
283,
4266,
297,
267,
283,
7817,
297,
267,
283,
7637,
297,
267,
283,
2254,
297,
267,
283,
739,
297,
267,
283,
952,
7,
272,
1622,
339,
347,
636,
826,
721,
277,
12,
6771,
63,
2960,
12,
1844,
12,
11153,
29,
797,
304,
267,
291,
14,
1258,
63,
2697,
12,
291,
14,
1258,
63,
719,
275,
6771,
63,
2960,
59,
17,
61,
267,
291,
14,
1000,
63,
719,
275,
1844,
267,
291,
14,
3450,
275,
6771,
63,
2960,
59,
16,
61,
267,
291,
14,
928,
63,
521,
275,
900,
14,
521,
342,
267,
291,
14,
4266,
275,
965,
63,
4266,
436,
1228,
8,
277,
14,
3450,
12,
6149,
14,
5413,
3869,
9,
267,
291,
14,
7817,
275,
11153,
398,
340,
2281,
63,
42,
57,
8472,
26,
288,
327,
1010,
25333,
781,
1471,
663,
13488,
63,
2826,
18616,
2348,
3967,
652,
1630,
440,
288,
327,
8287,
687,
314,
22721,
2838,
14,
288,
327,
1666,
26,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
969,
1643,
288,
291,
14,
3450,
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,
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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
] |
openilabs/falconlab
|
env/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/connection.py
|
187
|
5659
|
# urllib3/connection.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
import socket
from socket import timeout as SocketTimeout
try: # Python 3
from http.client import HTTPConnection as _HTTPConnection, HTTPException
except ImportError:
from httplib import HTTPConnection as _HTTPConnection, HTTPException
class DummyConnection(object):
"Used to detect a failed ConnectionCls import."
pass
try: # Compiled with SSL?
ssl = None
HTTPSConnection = DummyConnection
class BaseSSLError(BaseException):
pass
try: # Python 3
from http.client import HTTPSConnection as _HTTPSConnection
except ImportError:
from httplib import HTTPSConnection as _HTTPSConnection
import ssl
BaseSSLError = ssl.SSLError
except (ImportError, AttributeError): # Platform-specific: No SSL.
pass
from .exceptions import (
ConnectTimeoutError,
)
from .packages.ssl_match_hostname import match_hostname
from .util import (
assert_fingerprint,
resolve_cert_reqs,
resolve_ssl_version,
ssl_wrap_socket,
)
port_by_scheme = {
'http': 80,
'https': 443,
}
class HTTPConnection(_HTTPConnection, object):
default_port = port_by_scheme['http']
# By default, disable Nagle's Algorithm.
tcp_nodelay = 1
def _new_conn(self):
""" Establish a socket connection and set nodelay settings on it
:return: a new socket connection
"""
try:
conn = socket.create_connection(
(self.host, self.port),
self.timeout,
self.source_address,
)
except AttributeError: # Python 2.6
conn = socket.create_connection(
(self.host, self.port),
self.timeout,
)
conn.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY,
self.tcp_nodelay)
return conn
def _prepare_conn(self, conn):
self.sock = conn
if self._tunnel_host:
# TODO: Fix tunnel so it doesn't depend on self.sock state.
self._tunnel()
def connect(self):
conn = self._new_conn()
self._prepare_conn(conn)
class HTTPSConnection(HTTPConnection):
default_port = port_by_scheme['https']
def __init__(self, host, port=None, key_file=None, cert_file=None,
strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None):
try:
HTTPConnection.__init__(self, host, port, strict, timeout, source_address)
except TypeError: # Python 2.6
HTTPConnection.__init__(self, host, port, strict, timeout)
self.key_file = key_file
self.cert_file = cert_file
def connect(self):
conn = self._new_conn()
self._prepare_conn(conn)
self.sock = ssl.wrap_socket(conn, self.key_file, self.cert_file)
class VerifiedHTTPSConnection(HTTPSConnection):
"""
Based on httplib.HTTPSConnection but wraps the socket with
SSL certification.
"""
cert_reqs = None
ca_certs = None
ssl_version = None
def set_cert(self, key_file=None, cert_file=None,
cert_reqs=None, ca_certs=None,
assert_hostname=None, assert_fingerprint=None):
self.key_file = key_file
self.cert_file = cert_file
self.cert_reqs = cert_reqs
self.ca_certs = ca_certs
self.assert_hostname = assert_hostname
self.assert_fingerprint = assert_fingerprint
def connect(self):
# Add certificate verification
try:
sock = socket.create_connection(
address=(self.host, self.port),
timeout=self.timeout,
)
except SocketTimeout:
raise ConnectTimeoutError(
self, "Connection to %s timed out. (connect timeout=%s)" %
(self.host, self.timeout))
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY,
self.tcp_nodelay)
resolved_cert_reqs = resolve_cert_reqs(self.cert_reqs)
resolved_ssl_version = resolve_ssl_version(self.ssl_version)
# the _tunnel_host attribute was added in python 2.6.3 (via
# http://hg.python.org/cpython/rev/0f57b30a152f) so pythons 2.6(0-2) do
# not have them.
if getattr(self, '_tunnel_host', None):
self.sock = sock
# Calls self._set_hostport(), so self.host is
# self._tunnel_host below.
self._tunnel()
# Wrap socket using verification with the root certs in
# trusted_root_certs
self.sock = ssl_wrap_socket(sock, self.key_file, self.cert_file,
cert_reqs=resolved_cert_reqs,
ca_certs=self.ca_certs,
server_hostname=self.host,
ssl_version=resolved_ssl_version)
if resolved_cert_reqs != ssl.CERT_NONE:
if self.assert_fingerprint:
assert_fingerprint(self.sock.getpeercert(binary_form=True),
self.assert_fingerprint)
elif self.assert_hostname is not False:
match_hostname(self.sock.getpeercert(),
self.assert_hostname or self.host)
if ssl:
# Make a copy for testing.
UnverifiedHTTPSConnection = HTTPSConnection
HTTPSConnection = VerifiedHTTPSConnection
|
mit
|
[
3,
4011,
19,
15,
2105,
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,
646,
2838,
199,
504,
2838,
492,
2653,
465,
17766,
6372,
199,
199,
893,
26,
327,
2018,
650,
272,
687,
1455,
14,
1258,
492,
3101,
3225,
465,
485,
19114,
12,
28185,
199,
2590,
3545,
26,
272,
687,
8809,
492,
3101,
3225,
465,
485,
19114,
12,
28185,
199,
199,
533,
9762,
3225,
8,
785,
304,
272,
298,
9167,
370,
9696,
282,
3405,
8113,
24342,
492,
2122,
272,
986,
199,
199,
893,
26,
327,
3599,
1672,
543,
7799,
31,
272,
6149,
275,
488,
272,
14147,
3225,
275,
9762,
3225,
339,
1021,
3523,
27102,
8,
29900,
304,
267,
986,
339,
862,
26,
327,
2018,
650,
267,
687,
1455,
14,
1258,
492,
14147,
3225,
465,
485,
27945,
272,
871,
3545,
26,
267,
687,
8809,
492,
14147,
3225,
465,
485,
27945,
339,
492,
6149,
272,
3523,
27102,
275,
6149,
14,
27102,
199,
199,
2590,
334,
17825,
12,
4281,
304,
327,
16078,
13,
6100,
26,
3091,
7799,
14,
272,
986,
199,
199,
504,
1275,
3924,
492,
334,
272,
15175,
19382,
12,
199,
9,
199,
504,
1275,
5154,
14,
4266,
63,
1431,
63,
4269,
492,
1336,
63,
4269,
199,
504,
1275,
1974,
492,
334,
272,
702,
63,
15077,
12,
272,
7512,
63,
4736,
63,
12720,
12,
272,
7512,
63,
4266,
63,
1023,
12,
272,
6149,
63,
3823,
63,
3450,
12,
199,
9,
421,
199,
719,
63,
991,
63,
5512,
275,
469,
272,
283,
1014,
356,
5939,
12,
272,
283,
2859,
356,
23865,
12,
199,
93,
421,
199,
533,
3101,
3225,
1547,
19114,
12,
909,
304,
272,
849,
63,
719,
275,
1844,
63,
991,
63,
5512,
459,
1014,
418,
339,
327,
4885,
849,
12,
3507,
653,
643,
274,
1159,
23823,
14,
272,
14719,
63,
932,
817,
275,
413,
339,
347,
485,
1222,
63,
1631,
8,
277,
304,
267,
408,
15896,
13306,
282,
2838,
1950,
436,
663,
1031,
817,
2202,
641,
652,
398,
520,
1107,
26,
282,
892,
2838,
1950,
267,
408,
267,
862,
26,
288,
2557,
275,
2838,
14,
981,
63,
2105,
8,
355,
334,
277,
14,
1102,
12,
291,
14,
719,
395,
355,
291,
14,
2593,
12,
355,
291,
14,
1365,
63,
1562,
12,
288,
776,
267,
871,
4281,
26,
327,
2018,
499,
14,
22,
288,
2557,
275,
2838,
14,
981,
63,
2105,
8,
355,
334,
277,
14,
1102,
12,
291,
14,
719,
395,
355,
291,
14,
2593,
12,
288,
776,
267,
2557,
14,
27689,
8,
3450,
14,
20130,
63,
9735,
12,
2838,
14,
9735,
63,
2826,
18616,
12,
717,
291,
14,
8815,
63,
932,
817,
9,
267,
372,
2557,
339,
347,
485,
6726,
63,
1631,
8,
277,
12,
2557,
304,
267,
291,
14,
5096,
275,
2557,
267,
340,
291,
423,
15360,
63,
1102,
26,
288,
327,
3254,
26,
14811,
21496,
880,
652,
3181,
1133,
11687,
641,
291,
14,
5096,
1174,
14,
288,
291,
423,
15360,
342,
339,
347,
4907,
8,
277,
304,
267,
2557,
275,
291,
423,
1222,
63,
1631,
342,
267,
291,
423,
6726,
63,
1631,
8,
1631,
9,
421,
199,
533,
14147,
3225,
8,
19114,
304,
272,
849,
63,
719,
275,
1844,
63,
991,
63,
5512,
459,
2859,
418,
339,
347,
636,
826,
721,
277,
12,
1591,
12,
1844,
29,
403,
12,
790,
63,
493,
29,
403,
12,
6250,
63,
493,
29,
403,
12,
326,
7478,
29,
403,
12,
2653,
29,
3450,
423,
13808,
63,
3472,
63,
8899,
12,
326,
1350,
63,
1562,
29,
403,
304,
267,
862,
26,
288,
3101,
3225,
855,
826,
721,
277,
12,
1591,
12,
1844,
12,
7478,
12,
2653,
12,
1350,
63,
1562,
9,
267,
871,
3146,
26,
327,
2018,
499,
14,
22,
288,
3101,
3225,
855,
826,
721,
277,
12,
1591,
12,
1844,
12,
7478,
12,
2653,
9,
267,
291,
14,
498,
63,
493,
275,
790,
63,
493,
267,
291,
14,
4736,
63,
493,
275,
6250,
63,
493,
339,
347,
4907,
8,
277,
304,
267,
2557,
275,
291,
423,
1222,
63,
1631,
342,
267,
291,
423,
6726,
63,
1631,
8,
1631,
9,
267,
291,
14,
5096,
275,
6149,
14,
3823,
63,
3450,
8,
1631,
12,
291,
14,
498,
63,
493,
12,
291,
14,
4736,
63,
493,
9,
421,
199,
533,
5444,
4541,
27945,
8,
27945,
304,
272,
408,
272,
21311,
641,
8809,
14,
27945,
1325,
14018,
314,
2838,
543,
272,
7799,
3361,
3793,
14,
272,
408,
272,
6250,
63,
12720,
275,
488,
272,
1704,
63,
8356,
275,
488,
272,
6149,
63,
1023,
275,
488,
339,
347,
663,
63,
4736,
8,
277,
12,
790,
63,
493,
29,
403,
12,
6250,
63,
493,
29,
403,
12,
326,
6250,
63,
12720,
29,
403,
12,
1704,
63,
8356,
29,
403,
12,
326,
702,
63,
4269,
29,
403,
12,
702,
63,
15077,
29,
403,
304,
398,
291,
14,
498,
63,
493,
275,
790,
63,
493,
267,
291,
14,
4736,
63,
493,
275,
6250,
63,
493,
267,
291,
14,
4736,
63,
12720,
275,
6250,
63,
12720,
267,
291,
14,
696,
63,
8356,
275,
1704,
63,
8356,
267,
291,
14,
479,
63,
4269,
275,
702,
63,
4269,
267,
291,
14,
479,
63,
15077,
275,
702,
63,
15077,
339,
347,
4907,
8,
277,
304,
267,
327,
2654,
5897,
14786,
267,
862,
26,
288,
6771,
275,
2838,
14,
981,
63,
2105,
8,
355,
2287,
2687,
277,
14,
1102,
12,
291,
14,
719,
395,
355,
2653,
29,
277,
14,
2593,
12,
288,
776,
267,
871,
17766,
6372,
26,
288,
746,
15175,
19382,
8,
355,
291,
12,
298,
3225,
370,
450,
83,
18590,
734,
14,
334,
2242,
2653,
2458,
83,
2924,
450,
355,
334,
277,
14,
1102,
12,
291,
14,
2593,
430,
398,
6771,
14,
27689,
8,
3450,
14,
20130,
63,
9735,
12,
2838,
14,
9735,
63,
2826,
18616,
12,
717,
291,
14,
8815,
63,
932,
817,
9,
398,
12152,
63,
4736,
63,
12720,
275,
7512,
63,
4736,
63,
12720,
8,
277,
14,
4736,
63,
12720,
9,
267,
12152,
63,
4266,
63,
1023,
275,
7512,
63,
4266,
63,
1023,
8
] |
[
4011,
19,
15,
2105,
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,
646,
2838,
199,
504,
2838,
492,
2653,
465,
17766,
6372,
199,
199,
893,
26,
327,
2018,
650,
272,
687,
1455,
14,
1258,
492,
3101,
3225,
465,
485,
19114,
12,
28185,
199,
2590,
3545,
26,
272,
687,
8809,
492,
3101,
3225,
465,
485,
19114,
12,
28185,
199,
199,
533,
9762,
3225,
8,
785,
304,
272,
298,
9167,
370,
9696,
282,
3405,
8113,
24342,
492,
2122,
272,
986,
199,
199,
893,
26,
327,
3599,
1672,
543,
7799,
31,
272,
6149,
275,
488,
272,
14147,
3225,
275,
9762,
3225,
339,
1021,
3523,
27102,
8,
29900,
304,
267,
986,
339,
862,
26,
327,
2018,
650,
267,
687,
1455,
14,
1258,
492,
14147,
3225,
465,
485,
27945,
272,
871,
3545,
26,
267,
687,
8809,
492,
14147,
3225,
465,
485,
27945,
339,
492,
6149,
272,
3523,
27102,
275,
6149,
14,
27102,
199,
199,
2590,
334,
17825,
12,
4281,
304,
327,
16078,
13,
6100,
26,
3091,
7799,
14,
272,
986,
199,
199,
504,
1275,
3924,
492,
334,
272,
15175,
19382,
12,
199,
9,
199,
504,
1275,
5154,
14,
4266,
63,
1431,
63,
4269,
492,
1336,
63,
4269,
199,
504,
1275,
1974,
492,
334,
272,
702,
63,
15077,
12,
272,
7512,
63,
4736,
63,
12720,
12,
272,
7512,
63,
4266,
63,
1023,
12,
272,
6149,
63,
3823,
63,
3450,
12,
199,
9,
421,
199,
719,
63,
991,
63,
5512,
275,
469,
272,
283,
1014,
356,
5939,
12,
272,
283,
2859,
356,
23865,
12,
199,
93,
421,
199,
533,
3101,
3225,
1547,
19114,
12,
909,
304,
272,
849,
63,
719,
275,
1844,
63,
991,
63,
5512,
459,
1014,
418,
339,
327,
4885,
849,
12,
3507,
653,
643,
274,
1159,
23823,
14,
272,
14719,
63,
932,
817,
275,
413,
339,
347,
485,
1222,
63,
1631,
8,
277,
304,
267,
408,
15896,
13306,
282,
2838,
1950,
436,
663,
1031,
817,
2202,
641,
652,
398,
520,
1107,
26,
282,
892,
2838,
1950,
267,
408,
267,
862,
26,
288,
2557,
275,
2838,
14,
981,
63,
2105,
8,
355,
334,
277,
14,
1102,
12,
291,
14,
719,
395,
355,
291,
14,
2593,
12,
355,
291,
14,
1365,
63,
1562,
12,
288,
776,
267,
871,
4281,
26,
327,
2018,
499,
14,
22,
288,
2557,
275,
2838,
14,
981,
63,
2105,
8,
355,
334,
277,
14,
1102,
12,
291,
14,
719,
395,
355,
291,
14,
2593,
12,
288,
776,
267,
2557,
14,
27689,
8,
3450,
14,
20130,
63,
9735,
12,
2838,
14,
9735,
63,
2826,
18616,
12,
717,
291,
14,
8815,
63,
932,
817,
9,
267,
372,
2557,
339,
347,
485,
6726,
63,
1631,
8,
277,
12,
2557,
304,
267,
291,
14,
5096,
275,
2557,
267,
340,
291,
423,
15360,
63,
1102,
26,
288,
327,
3254,
26,
14811,
21496,
880,
652,
3181,
1133,
11687,
641,
291,
14,
5096,
1174,
14,
288,
291,
423,
15360,
342,
339,
347,
4907,
8,
277,
304,
267,
2557,
275,
291,
423,
1222,
63,
1631,
342,
267,
291,
423,
6726,
63,
1631,
8,
1631,
9,
421,
199,
533,
14147,
3225,
8,
19114,
304,
272,
849,
63,
719,
275,
1844,
63,
991,
63,
5512,
459,
2859,
418,
339,
347,
636,
826,
721,
277,
12,
1591,
12,
1844,
29,
403,
12,
790,
63,
493,
29,
403,
12,
6250,
63,
493,
29,
403,
12,
326,
7478,
29,
403,
12,
2653,
29,
3450,
423,
13808,
63,
3472,
63,
8899,
12,
326,
1350,
63,
1562,
29,
403,
304,
267,
862,
26,
288,
3101,
3225,
855,
826,
721,
277,
12,
1591,
12,
1844,
12,
7478,
12,
2653,
12,
1350,
63,
1562,
9,
267,
871,
3146,
26,
327,
2018,
499,
14,
22,
288,
3101,
3225,
855,
826,
721,
277,
12,
1591,
12,
1844,
12,
7478,
12,
2653,
9,
267,
291,
14,
498,
63,
493,
275,
790,
63,
493,
267,
291,
14,
4736,
63,
493,
275,
6250,
63,
493,
339,
347,
4907,
8,
277,
304,
267,
2557,
275,
291,
423,
1222,
63,
1631,
342,
267,
291,
423,
6726,
63,
1631,
8,
1631,
9,
267,
291,
14,
5096,
275,
6149,
14,
3823,
63,
3450,
8,
1631,
12,
291,
14,
498,
63,
493,
12,
291,
14,
4736,
63,
493,
9,
421,
199,
533,
5444,
4541,
27945,
8,
27945,
304,
272,
408,
272,
21311,
641,
8809,
14,
27945,
1325,
14018,
314,
2838,
543,
272,
7799,
3361,
3793,
14,
272,
408,
272,
6250,
63,
12720,
275,
488,
272,
1704,
63,
8356,
275,
488,
272,
6149,
63,
1023,
275,
488,
339,
347,
663,
63,
4736,
8,
277,
12,
790,
63,
493,
29,
403,
12,
6250,
63,
493,
29,
403,
12,
326,
6250,
63,
12720,
29,
403,
12,
1704,
63,
8356,
29,
403,
12,
326,
702,
63,
4269,
29,
403,
12,
702,
63,
15077,
29,
403,
304,
398,
291,
14,
498,
63,
493,
275,
790,
63,
493,
267,
291,
14,
4736,
63,
493,
275,
6250,
63,
493,
267,
291,
14,
4736,
63,
12720,
275,
6250,
63,
12720,
267,
291,
14,
696,
63,
8356,
275,
1704,
63,
8356,
267,
291,
14,
479,
63,
4269,
275,
702,
63,
4269,
267,
291,
14,
479,
63,
15077,
275,
702,
63,
15077,
339,
347,
4907,
8,
277,
304,
267,
327,
2654,
5897,
14786,
267,
862,
26,
288,
6771,
275,
2838,
14,
981,
63,
2105,
8,
355,
2287,
2687,
277,
14,
1102,
12,
291,
14,
719,
395,
355,
2653,
29,
277,
14,
2593,
12,
288,
776,
267,
871,
17766,
6372,
26,
288,
746,
15175,
19382,
8,
355,
291,
12,
298,
3225,
370,
450,
83,
18590,
734,
14,
334,
2242,
2653,
2458,
83,
2924,
450,
355,
334,
277,
14,
1102,
12,
291,
14,
2593,
430,
398,
6771,
14,
27689,
8,
3450,
14,
20130,
63,
9735,
12,
2838,
14,
9735,
63,
2826,
18616,
12,
717,
291,
14,
8815,
63,
932,
817,
9,
398,
12152,
63,
4736,
63,
12720,
275,
7512,
63,
4736,
63,
12720,
8,
277,
14,
4736,
63,
12720,
9,
267,
12152,
63,
4266,
63,
1023,
275,
7512,
63,
4266,
63,
1023,
8,
0
] |
[
1,
1,
1,
1,
1,
1,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constants.py
|
1
|
4235
|
"""
Module for definition of shared constants between the modules.
This file is part of Pisi.
Pisi 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.
Pisi 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 Pisi. If not, see <http://www.gnu.org/licenses/>
"""
PISI_NAME = 'PISI'
"""'About'-information for user - program name"""
PISI_COMMENTS = "PISI is synchronizing information"
"""'About'-information for user - comments / explainations"""
PISI_VERSION = '0.5.3' #'-svn-' #
"""'About'-information for user - current version"""
FILEPATH_COPYING = "/opt/pisi/COPYING"
"""'About'-information for user - where to find the 'licence' file"""
PISI_AUTHORS = ["Esben Damgaard","Michael Pilgermann"]
"""'About'-information for user - list of programmers"""
PISI_HOMEPAGE = "http://freshmeat.net/projects/pisiom"
"""'About'-information for user - program home page"""
PISI_TRANSLATOR_CREDITS = None
"""'About'-information for user - list of translators"""
PISI_DOCUMENTERS = ['Michael Pilgermann']
"""'About'-information for user - list of documenters"""
CONSOLE_PROGRESSBAR_WIDTH = 80
"""Length of progress bar in CLI mode"""
MODE_CALENDAR = 0
"""Type of sources to deal with are calendars"""
MODE_CONTACTS = 1
"""Type of sources to deal with are contacts"""
MODE_STRINGS = ['calendar', 'contacts']
"""Names for the types of sources in order"""
MERGEMODE_SKIP = 0
"""Resolve conflicts between two entries from two sources by skipping the entry"""
MERGEMODE_FLUSH_A = 1
"""Resolve conflicts between two entries from two sources by flushing the entire data repository for the first data source"""
MERGEMODE_FLUSH_B = 2
"""Resolve conflicts between two entries from two sources by flushing the entire data repository for the second data source"""
MERGEMODE_OVERWRITE_A = 3
"""Resolve conflicts between two entries from two sources by overwriting the single entry on the first data source"""
MERGEMODE_OVERWRITE_B = 4
"""Resolve conflicts between two entries from two sources by overwriting the single entry on the second data source"""
MERGEMODE_MANUALCONFIRM = 5
"""Resolve conflicts between two entries from two sources by asking the user for decision for every single entry"""
MERGEMODE_STRINGS = ["Skip", "Flush source 1", "Flush source 2", "Overwrite entry in source 1", "Overwrite entry in source 2", "Manual confirmation"]
"""Names of merge modes in order"""
ACTIONID_ADD = 0
"""Entry in the history of activities for synchronization modules - here for ADD"""
ACTIONID_DELETE = 1
"""Entry in the history of activities for synchronization modules - here for DELETE"""
ACTIONID_MODIFY = 2
"""Entry in the history of activities for synchronization modules - here for MODIFY"""
GOOGLE_CONTACTS_APPNAME = "pisi" + PISI_VERSION
"""application name to use for connecting against google contacts services"""
GOOGLE_CONTACTS_MAXRESULTS = 1000
"""upper limit of result set when querying google contacts api"""
GOOGLE_CALENDAR_APPNAME = "pisi" + PISI_VERSION
"""application name to use for connecting against google calendar services"""
GOOGLE_CALENDAR_MAXRESULTS = GOOGLE_CONTACTS_MAXRESULTS
"""upper limit of result set when querying google calendar api"""
FILEDOWNLOAD_TIMEOUT = 10
"""Timeout for socket opeations (e.g. http download) in seconds - None for disable"""
FILEDOWNLOAD_TMPFILE = "/tmp/pisi-remotebuffer.data"
"""Temporary file for buffering information from remote file sources"""
VCF_BYTES_PER_ENTRY = 200
"""For guessing the number of entries inside a VCF file by evaluating its size we need an estimation of the size for a single entry - for the purpose of showing some progress"""
ICS_BYTES_PER_ENTRY = 200
"""For guessing the number of entries inside an ICS file by evaluating its size we need an estimation of the size for a single entry - for the purpose of showing some progress"""
|
gpl-3.0
|
[
624,
221,
199,
2377,
367,
5492,
402,
5709,
5262,
3382,
314,
4621,
14,
199,
199,
2765,
570,
365,
1777,
402,
19835,
338,
14,
199,
199,
10542,
338,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
390,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
1589,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
8,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
10542,
338,
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,
199,
5556,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
21632,
543,
19835,
338,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
3133,
199,
624,
199,
199,
48,
1311,
41,
63,
2339,
275,
283,
48,
1311,
41,
7,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
2240,
536,
624,
199,
48,
1311,
41,
63,
10973,
51,
275,
298,
48,
1311,
41,
365,
15354,
9147,
2556,
2,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
6786,
1182,
27797,
1298,
624,
199,
48,
1311,
41,
63,
4612,
275,
283,
16,
14,
21,
14,
19,
7,
327,
12418,
6836,
15668,
327,
221,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
1453,
1015,
624,
199,
3817,
3243,
63,
16188,
1206,
275,
3286,
2992,
15,
1038,
338,
15,
16188,
1206,
2,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
2382,
370,
2342,
314,
283,
606,
4894,
7,
570,
624,
199,
48,
1311,
41,
63,
5580,
4149,
275,
2097,
37,
9264,
287,
577,
455,
5294,
1005,
2266,
45,
11781,
18130,
836,
20059,
937,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
769,
402,
2240,
16465,
624,
199,
48,
1311,
41,
63,
9524,
12898,
275,
298,
1014,
921,
25488,
278,
292,
14,
846,
15,
6776,
15,
1038,
338,
676,
2,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
2240,
5629,
2034,
624,
199,
48,
1311,
41,
63,
26376,
6467,
63,
5798,
3841,
51,
275,
488,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
769,
402,
1752,
20830,
624,
199,
48,
1311,
41,
63,
1649,
5497,
12533,
51,
275,
788,
45,
11781,
18130,
836,
20059,
418,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
769,
402,
1382,
11678,
878,
624,
199,
199,
31774,
63,
24547,
13895,
63,
11139,
275,
5939,
199,
624,
4625,
402,
6696,
4681,
315,
14214,
818,
624,
199,
199,
6963,
63,
13329,
3902,
689,
275,
378,
199,
624,
804,
402,
5274,
370,
7962,
543,
787,
1704,
31276,
624,
199,
6963,
63,
5801,
3036,
51,
275,
413,
199,
624,
804,
402,
5274,
370,
7962,
543,
787,
27989,
624,
199,
6963,
63,
31271,
275,
788,
8183,
297,
221,
283,
18147,
418,
199,
624,
5866,
367,
314,
2943,
402,
5274,
315,
1865,
624,
199,
199,
25619,
6963,
63,
13525,
275,
378,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
16068,
314,
2397,
624,
199,
25619,
6963,
63,
32762,
63,
33,
275,
413,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
8976,
316,
314,
8039,
666,
7611,
367,
314,
1642,
666,
1350,
624,
199,
25619,
6963,
63,
32762,
63,
34,
275,
499,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
8976,
316,
314,
8039,
666,
7611,
367,
314,
3499,
666,
1350,
624,
199,
25619,
6963,
63,
14336,
10387,
63,
33,
275,
650,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
32592,
314,
2849,
2397,
641,
314,
1642,
666,
1350,
624,
199,
25619,
6963,
63,
14336,
10387,
63,
34,
275,
841,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
32592,
314,
2849,
2397,
641,
314,
3499,
666,
1350,
624,
199,
25619,
6963,
63,
6588,
13841,
1864,
28830,
275,
959,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
7198,
316,
314,
922,
367,
14692,
367,
4036,
2849,
2397,
624,
199,
25619,
6963,
63,
31271,
275,
2097,
7738,
401,
221,
298,
20053,
1350,
413,
401,
221,
298,
20053,
1350,
499,
401,
221,
298,
5674,
952,
2397,
315,
1350,
413,
401,
221,
298,
5674,
952,
2397,
315,
1350,
499,
401,
221,
298,
22382,
18791,
937,
199,
624,
5866,
402,
5389,
12404,
315,
1865,
624,
199,
199,
10052,
998,
63,
9732,
275,
378,
199,
624,
3900,
315,
314,
7994,
402,
30744,
367,
29509,
4621,
446,
2348,
367,
21380,
624,
199,
10052,
998,
63,
7014,
275,
413,
199,
624,
3900,
315,
314,
7994,
402,
30744,
367,
29509,
4621,
446,
2348,
367,
15137,
624,
199,
10052,
998,
63,
31225,
275,
499,
199,
624,
3900,
315,
314,
7994,
402,
30744,
367,
29509,
4621,
446,
2348,
367,
10362,
1914,
18114,
624,
199,
199,
24243,
63,
5801,
3036,
51,
63,
7121,
2339,
275,
298,
1038,
338,
2,
435,
510,
1311,
41,
63,
4612,
199,
624,
3578,
536,
370,
675,
367,
18170,
6169,
6233,
27989,
8500,
624,
199,
24243,
63,
5801,
3036,
51,
63,
4283,
23545,
275,
5198,
199,
624,
4142,
2304,
402,
754,
663,
1380,
27405,
6233,
27989,
2986,
624,
199,
24243,
63,
13329,
3902,
689,
63,
7121,
2339,
275,
298,
1038,
338,
2,
435,
510,
1311,
41,
63,
4612,
199,
624,
3578,
536,
370,
675,
367,
18170,
6169,
6233,
11234,
8500,
624,
199,
24243,
63,
13329,
3902,
689,
63,
4283,
23545,
275,
9173,
12827,
63,
5801,
3036,
51,
63,
4283,
23545,
199,
624,
4142,
2304,
402,
754,
663,
1380,
27405,
6233,
11234,
2986,
624,
199,
199,
3817,
24930,
63,
8899,
275,
1616,
199,
624,
6372,
367,
2838,
312,
321,
1298,
334,
69,
14,
71,
14,
1455,
5235,
9,
315,
4696,
446,
488,
367,
3507,
624,
199,
3817,
24930,
63,
17983,
3817,
275,
3286,
2791,
15,
1038,
338,
13,
3846,
2738,
14,
576,
2,
199,
624,
11360,
570,
367,
21033,
2556,
687,
3982,
570,
5274,
624,
199,
199,
54,
5487,
63,
20352,
63,
4227,
63,
7285,
275,
1926,
199,
624,
1858,
9519,
316,
314,
1329,
402,
4811,
6272,
282,
812,
5487,
570,
701,
27083,
2399,
1568,
781,
1929,
376
] |
[
221,
199,
2377,
367,
5492,
402,
5709,
5262,
3382,
314,
4621,
14,
199,
199,
2765,
570,
365,
1777,
402,
19835,
338,
14,
199,
199,
10542,
338,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
390,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
1589,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
8,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
10542,
338,
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,
199,
5556,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
21632,
543,
19835,
338,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
3133,
199,
624,
199,
199,
48,
1311,
41,
63,
2339,
275,
283,
48,
1311,
41,
7,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
2240,
536,
624,
199,
48,
1311,
41,
63,
10973,
51,
275,
298,
48,
1311,
41,
365,
15354,
9147,
2556,
2,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
6786,
1182,
27797,
1298,
624,
199,
48,
1311,
41,
63,
4612,
275,
283,
16,
14,
21,
14,
19,
7,
327,
12418,
6836,
15668,
327,
221,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
1453,
1015,
624,
199,
3817,
3243,
63,
16188,
1206,
275,
3286,
2992,
15,
1038,
338,
15,
16188,
1206,
2,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
2382,
370,
2342,
314,
283,
606,
4894,
7,
570,
624,
199,
48,
1311,
41,
63,
5580,
4149,
275,
2097,
37,
9264,
287,
577,
455,
5294,
1005,
2266,
45,
11781,
18130,
836,
20059,
937,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
769,
402,
2240,
16465,
624,
199,
48,
1311,
41,
63,
9524,
12898,
275,
298,
1014,
921,
25488,
278,
292,
14,
846,
15,
6776,
15,
1038,
338,
676,
2,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
2240,
5629,
2034,
624,
199,
48,
1311,
41,
63,
26376,
6467,
63,
5798,
3841,
51,
275,
488,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
769,
402,
1752,
20830,
624,
199,
48,
1311,
41,
63,
1649,
5497,
12533,
51,
275,
788,
45,
11781,
18130,
836,
20059,
418,
199,
624,
7,
18816,
12418,
11697,
367,
922,
446,
769,
402,
1382,
11678,
878,
624,
199,
199,
31774,
63,
24547,
13895,
63,
11139,
275,
5939,
199,
624,
4625,
402,
6696,
4681,
315,
14214,
818,
624,
199,
199,
6963,
63,
13329,
3902,
689,
275,
378,
199,
624,
804,
402,
5274,
370,
7962,
543,
787,
1704,
31276,
624,
199,
6963,
63,
5801,
3036,
51,
275,
413,
199,
624,
804,
402,
5274,
370,
7962,
543,
787,
27989,
624,
199,
6963,
63,
31271,
275,
788,
8183,
297,
221,
283,
18147,
418,
199,
624,
5866,
367,
314,
2943,
402,
5274,
315,
1865,
624,
199,
199,
25619,
6963,
63,
13525,
275,
378,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
16068,
314,
2397,
624,
199,
25619,
6963,
63,
32762,
63,
33,
275,
413,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
8976,
316,
314,
8039,
666,
7611,
367,
314,
1642,
666,
1350,
624,
199,
25619,
6963,
63,
32762,
63,
34,
275,
499,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
8976,
316,
314,
8039,
666,
7611,
367,
314,
3499,
666,
1350,
624,
199,
25619,
6963,
63,
14336,
10387,
63,
33,
275,
650,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
32592,
314,
2849,
2397,
641,
314,
1642,
666,
1350,
624,
199,
25619,
6963,
63,
14336,
10387,
63,
34,
275,
841,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
32592,
314,
2849,
2397,
641,
314,
3499,
666,
1350,
624,
199,
25619,
6963,
63,
6588,
13841,
1864,
28830,
275,
959,
199,
624,
27459,
18511,
3382,
2877,
4811,
687,
2877,
5274,
701,
7198,
316,
314,
922,
367,
14692,
367,
4036,
2849,
2397,
624,
199,
25619,
6963,
63,
31271,
275,
2097,
7738,
401,
221,
298,
20053,
1350,
413,
401,
221,
298,
20053,
1350,
499,
401,
221,
298,
5674,
952,
2397,
315,
1350,
413,
401,
221,
298,
5674,
952,
2397,
315,
1350,
499,
401,
221,
298,
22382,
18791,
937,
199,
624,
5866,
402,
5389,
12404,
315,
1865,
624,
199,
199,
10052,
998,
63,
9732,
275,
378,
199,
624,
3900,
315,
314,
7994,
402,
30744,
367,
29509,
4621,
446,
2348,
367,
21380,
624,
199,
10052,
998,
63,
7014,
275,
413,
199,
624,
3900,
315,
314,
7994,
402,
30744,
367,
29509,
4621,
446,
2348,
367,
15137,
624,
199,
10052,
998,
63,
31225,
275,
499,
199,
624,
3900,
315,
314,
7994,
402,
30744,
367,
29509,
4621,
446,
2348,
367,
10362,
1914,
18114,
624,
199,
199,
24243,
63,
5801,
3036,
51,
63,
7121,
2339,
275,
298,
1038,
338,
2,
435,
510,
1311,
41,
63,
4612,
199,
624,
3578,
536,
370,
675,
367,
18170,
6169,
6233,
27989,
8500,
624,
199,
24243,
63,
5801,
3036,
51,
63,
4283,
23545,
275,
5198,
199,
624,
4142,
2304,
402,
754,
663,
1380,
27405,
6233,
27989,
2986,
624,
199,
24243,
63,
13329,
3902,
689,
63,
7121,
2339,
275,
298,
1038,
338,
2,
435,
510,
1311,
41,
63,
4612,
199,
624,
3578,
536,
370,
675,
367,
18170,
6169,
6233,
11234,
8500,
624,
199,
24243,
63,
13329,
3902,
689,
63,
4283,
23545,
275,
9173,
12827,
63,
5801,
3036,
51,
63,
4283,
23545,
199,
624,
4142,
2304,
402,
754,
663,
1380,
27405,
6233,
11234,
2986,
624,
199,
199,
3817,
24930,
63,
8899,
275,
1616,
199,
624,
6372,
367,
2838,
312,
321,
1298,
334,
69,
14,
71,
14,
1455,
5235,
9,
315,
4696,
446,
488,
367,
3507,
624,
199,
3817,
24930,
63,
17983,
3817,
275,
3286,
2791,
15,
1038,
338,
13,
3846,
2738,
14,
576,
2,
199,
624,
11360,
570,
367,
21033,
2556,
687,
3982,
570,
5274,
624,
199,
199,
54,
5487,
63,
20352,
63,
4227,
63,
7285,
275,
1926,
199,
624,
1858,
9519,
316,
314,
1329,
402,
4811,
6272,
282,
812,
5487,
570,
701,
27083,
2399,
1568,
781,
1929,
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,
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
] |
yugui/grpc
|
src/python/grpcio_tests/tests/unit/_credentials_test.py
|
23
|
3384
|
# Copyright 2016, 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.
"""Tests of credentials."""
import unittest
import grpc
class CredentialsTest(unittest.TestCase):
def test_call_credentials_composition(self):
first = grpc.access_token_call_credentials('abc')
second = grpc.access_token_call_credentials('def')
third = grpc.access_token_call_credentials('ghi')
first_and_second = grpc.composite_call_credentials(first, second)
first_second_and_third = grpc.composite_call_credentials(first, second,
third)
self.assertIsInstance(first_and_second, grpc.CallCredentials)
self.assertIsInstance(first_second_and_third, grpc.CallCredentials)
def test_channel_credentials_composition(self):
first_call_credentials = grpc.access_token_call_credentials('abc')
second_call_credentials = grpc.access_token_call_credentials('def')
third_call_credentials = grpc.access_token_call_credentials('ghi')
channel_credentials = grpc.ssl_channel_credentials()
channel_and_first = grpc.composite_channel_credentials(
channel_credentials, first_call_credentials)
channel_first_and_second = grpc.composite_channel_credentials(
channel_credentials, first_call_credentials,
second_call_credentials)
channel_first_second_and_third = grpc.composite_channel_credentials(
channel_credentials, first_call_credentials,
second_call_credentials, third_call_credentials)
self.assertIsInstance(channel_and_first, grpc.ChannelCredentials)
self.assertIsInstance(channel_first_and_second, grpc.ChannelCredentials)
self.assertIsInstance(channel_first_second_and_third,
grpc.ChannelCredentials)
if __name__ == '__main__':
unittest.main(verbosity=2)
|
bsd-3-clause
|
[
3,
1898,
7800,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
624,
2925,
402,
6235,
1041,
199,
199,
646,
2882,
199,
199,
646,
19753,
421,
199,
533,
23934,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1250,
63,
6942,
63,
13000,
8,
277,
304,
267,
1642,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
3175,
358,
267,
3499,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
318,
358,
267,
10919,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
3561,
73,
358,
398,
1642,
63,
460,
63,
4375,
275,
19753,
14,
16907,
63,
1250,
63,
6942,
8,
2246,
12,
3499,
9,
267,
1642,
63,
4375,
63,
460,
63,
11470,
275,
19753,
14,
16907,
63,
1250,
63,
6942,
8,
2246,
12,
3499,
12,
6684,
10919,
9,
398,
291,
14,
6926,
8,
2246,
63,
460,
63,
4375,
12,
19753,
14,
2176,
13428,
9,
267,
291,
14,
6926,
8,
2246,
63,
4375,
63,
460,
63,
11470,
12,
19753,
14,
2176,
13428,
9,
339,
347,
511,
63,
2775,
63,
6942,
63,
13000,
8,
277,
304,
267,
1642,
63,
1250,
63,
6942,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
3175,
358,
267,
3499,
63,
1250,
63,
6942,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
318,
358,
267,
10919,
63,
1250,
63,
6942,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
3561,
73,
358,
267,
3623,
63,
6942,
275,
19753,
14,
4266,
63,
2775,
63,
6942,
342,
398,
3623,
63,
460,
63,
2246,
275,
19753,
14,
16907,
63,
2775,
63,
6942,
8,
288,
3623,
63,
6942,
12,
1642,
63,
1250,
63,
6942,
9,
267,
3623,
63,
2246,
63,
460,
63,
4375,
275,
19753,
14,
16907,
63,
2775,
63,
6942,
8,
288,
3623,
63,
6942,
12,
1642,
63,
1250,
63,
6942,
12,
288,
3499,
63,
1250,
63,
6942,
9,
267,
3623,
63,
2246,
63,
4375,
63,
460,
63,
11470,
275,
19753,
14,
16907,
63,
2775,
63,
6942,
8,
288,
3623,
63,
6942,
12,
1642,
63,
1250,
63,
6942,
12,
288,
3499,
63,
1250,
63,
6942,
12,
10919,
63,
1250,
63,
6942,
9,
398,
291,
14,
6926,
8,
2775,
63,
460,
63,
2246,
12,
19753,
14,
5358,
13428,
9,
267,
291,
14,
6926,
8,
2775,
63,
2246,
63,
460,
63,
4375,
12,
19753,
14,
5358,
13428,
9,
267,
291,
14,
6926,
8,
2775,
63,
2246,
63,
4375,
63,
460,
63,
11470,
12,
2892,
19753,
14,
5358,
13428,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
8,
9833,
29,
18,
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
] |
[
1898,
7800,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
624,
2925,
402,
6235,
1041,
199,
199,
646,
2882,
199,
199,
646,
19753,
421,
199,
533,
23934,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1250,
63,
6942,
63,
13000,
8,
277,
304,
267,
1642,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
3175,
358,
267,
3499,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
318,
358,
267,
10919,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
3561,
73,
358,
398,
1642,
63,
460,
63,
4375,
275,
19753,
14,
16907,
63,
1250,
63,
6942,
8,
2246,
12,
3499,
9,
267,
1642,
63,
4375,
63,
460,
63,
11470,
275,
19753,
14,
16907,
63,
1250,
63,
6942,
8,
2246,
12,
3499,
12,
6684,
10919,
9,
398,
291,
14,
6926,
8,
2246,
63,
460,
63,
4375,
12,
19753,
14,
2176,
13428,
9,
267,
291,
14,
6926,
8,
2246,
63,
4375,
63,
460,
63,
11470,
12,
19753,
14,
2176,
13428,
9,
339,
347,
511,
63,
2775,
63,
6942,
63,
13000,
8,
277,
304,
267,
1642,
63,
1250,
63,
6942,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
3175,
358,
267,
3499,
63,
1250,
63,
6942,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
318,
358,
267,
10919,
63,
1250,
63,
6942,
275,
19753,
14,
2732,
63,
1418,
63,
1250,
63,
6942,
360,
3561,
73,
358,
267,
3623,
63,
6942,
275,
19753,
14,
4266,
63,
2775,
63,
6942,
342,
398,
3623,
63,
460,
63,
2246,
275,
19753,
14,
16907,
63,
2775,
63,
6942,
8,
288,
3623,
63,
6942,
12,
1642,
63,
1250,
63,
6942,
9,
267,
3623,
63,
2246,
63,
460,
63,
4375,
275,
19753,
14,
16907,
63,
2775,
63,
6942,
8,
288,
3623,
63,
6942,
12,
1642,
63,
1250,
63,
6942,
12,
288,
3499,
63,
1250,
63,
6942,
9,
267,
3623,
63,
2246,
63,
4375,
63,
460,
63,
11470,
275,
19753,
14,
16907,
63,
2775,
63,
6942,
8,
288,
3623,
63,
6942,
12,
1642,
63,
1250,
63,
6942,
12,
288,
3499,
63,
1250,
63,
6942,
12,
10919,
63,
1250,
63,
6942,
9,
398,
291,
14,
6926,
8,
2775,
63,
460,
63,
2246,
12,
19753,
14,
5358,
13428,
9,
267,
291,
14,
6926,
8,
2775,
63,
2246,
63,
460,
63,
4375,
12,
19753,
14,
5358,
13428,
9,
267,
291,
14,
6926,
8,
2775,
63,
2246,
63,
4375,
63,
460,
63,
11470,
12,
2892,
19753,
14,
5358,
13428,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
8,
9833,
29,
18,
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,
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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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
] |
HyperloopTeam/FullOpenMDAO
|
lib/python2.7/site-packages/openmdao.main-0.13.0-py2.7.egg/openmdao/main/test/test_scaler_adder_example.py
|
1
|
5419
|
""" Tests the scaler/adder example in our docs. This test was inconvenient to test
in its place in the docs. """
# pylint: disable-msg=C0111,C0103
import unittest
from openmdao.lib.datatypes.api import Float
from openmdao.lib.drivers.api import SLSQPdriver
from openmdao.main.api import Assembly,Component
from openmdao.main.test.simpledriver import SimpleDriver
from openmdao.util.testutil import assert_rel_error
class Paraboloid_scale(Component):
""" Evaluates the equation f(x,y) = (1000*x-3)^2 + (1000*x)*(0.01*y) + (0.01*y+4)^2 - 3 """
# set up interface to the framework
# pylint: disable-msg=E1101
x = Float(0.0, iotype='in', desc='The variable x')
y = Float(0.0, iotype='in', desc='The variable y')
f_xy = Float(iotype='out', desc='F(x,y)')
def execute(self):
"""f(x,y) = (x-3)^2 + xy + (y+4)^2 - 3
Optimal solution (minimum): x = 0.0066666666666666671; y = -733.33333333333337
"""
x = self.x
y = self.y
self.f_xy = (1000.*x-3.)**2 + (1000.*x)*(0.01*y) + (0.01*y+4.)**2 - 3.
#print "Executing, %.33f, %.33f, %.33f" % (x, y, self.f_xy)
class OptimizationUnconstrainedScale(Assembly):
"""Unconstrained optimization of the unscaled Paraboloid Component."""
def configure(self):
""" Creates a new Assembly containing an unscaled Paraboloid and an optimizer"""
# Create Optimizer instance
self.add('driver', SLSQPdriver())
# Create Paraboloid component instances
self.add('paraboloid', Paraboloid_scale())
# Driver process definition
self.driver.workflow.add('paraboloid')
# SQLSQP Flags
self.driver.iprint = 0
# Objective
self.driver.add_objective('paraboloid.f_xy')
# Design Variables
self.driver.add_parameter('paraboloid.x', low=-1000., high=1000., scaler=0.001)
self.driver.add_parameter('paraboloid.y', low=-1000., high=1000., scaler=1000.0)
class Paraboloid_shift(Component):
""" Evaluates the equation f(x,y) = (1000*x-3)^2 + (1000*x)*(0.01*(y+1000)) + (0.01*(y+1000)+4)^2 - 3 """
# set up interface to the framework
# pylint: disable-msg=E1101
x = Float(0.0, iotype='in', desc='The variable x')
y = Float(0.0, iotype='in', desc='The variable y')
f_xy = Float(iotype='out', desc='F(x,y)')
def execute(self):
"""f(x,y) = (1000*x-3)^2 + (1000*x)*(0.01*(y+1000)) + (0.01*(y+1000)+4)^2 - 3
Optimal solution (minimum): x = 0.0066666666666666671; y = -1733.33333333333337
"""
x = self.x
y = self.y
self.f_xy = (1000*x-3)**2 + (1000*x)*(0.01*(y+1000)) + (0.01*(y+1000)+4)**2 - 3
class OptimizationUnconstrainedScaleShift(Assembly):
"""Unconstrained optimization of the Paraboloid Component."""
def configure(self):
""" Creates a new Assembly containing a Paraboloid and an optimizer"""
# pylint: disable-msg=E1101
# Create Optimizer instance
self.add('driver', SLSQPdriver())
# Create Paraboloid component instances
self.add('paraboloid', Paraboloid_shift())
# Driver process definition
self.driver.workflow.add('paraboloid')
# SQLSQP Flags
self.driver.iprint = 0
# Objective
self.driver.add_objective('paraboloid.f_xy')
# Design Variables
self.driver.add_parameter('paraboloid.x', low=-1000000., high=1000000.,
scaler=0.001)
self.driver.add_parameter('paraboloid.y', low=-1000000., high=1000000.,
scaler=1000.0, adder=-1000.0)
class ScalerAdderExampleTestCase(unittest.TestCase):
def test_scale(self):
opt_problem = OptimizationUnconstrainedScale()
opt_problem.run()
assert_rel_error(self, opt_problem.paraboloid.x, 0.006667, 0.001)
assert_rel_error(self, opt_problem.paraboloid.y, -733.333313, 0.001)
J = opt_problem.driver.calc_gradient()
Jdict = opt_problem.driver.calc_gradient(return_format='dict')
def test_scale_gradients(self):
opt_problem = OptimizationUnconstrainedScale()
opt_problem.replace('driver', SimpleDriver())
opt_problem.run()
J = opt_problem.driver.calc_gradient()
Jdict = opt_problem.driver.calc_gradient(return_format='dict')
# Make sure untransforming works for dicts too
self.assertTrue(J[0][0] == Jdict['_pseudo_0.out0']['paraboloid.x'])
self.assertTrue(J[0][1] == Jdict['_pseudo_0.out0']['paraboloid.y'])
Jfddict = opt_problem.driver.calc_gradient(mode='fd', return_format='dict')
opt_problem.driver.run_iteration()
Jfd = opt_problem.driver.calc_gradient(mode='fd')
# Make sure untransforming works for dicts too
self.assertTrue(Jfd[0][0] == Jfddict['_pseudo_0.out0']['paraboloid.x'])
self.assertTrue(Jfd[0][1] == Jfddict['_pseudo_0.out0']['paraboloid.y'])
def test_scale_adder(self):
opt_problem = OptimizationUnconstrainedScaleShift()
opt_problem.run()
assert_rel_error(self, opt_problem.paraboloid.x, 0.006667, 0.001)
assert_rel_error(self, opt_problem.paraboloid.y, -1733.333313, 0.001)
if __name__ == "__main__":
unittest.main()
|
gpl-2.0
|
[
624,
6496,
314,
31121,
15,
28874,
2893,
315,
4154,
9149,
14,
961,
511,
1990,
315,
388,
1856,
6792,
370,
511,
199,
262,
2399,
4192,
315,
314,
9149,
14,
408,
199,
199,
3,
4287,
26,
3507,
13,
1328,
29,
35,
28107,
12,
35,
28399,
199,
646,
2882,
199,
199,
504,
1551,
77,
20431,
14,
773,
14,
14184,
83,
14,
1246,
492,
11140,
199,
504,
1551,
77,
20431,
14,
773,
14,
13337,
14,
1246,
492,
428,
5296,
31208,
3090,
199,
504,
1551,
77,
20431,
14,
973,
14,
1246,
492,
3709,
9621,
12,
7004,
199,
504,
1551,
77,
20431,
14,
973,
14,
396,
14,
4129,
3090,
492,
5870,
6158,
199,
504,
1551,
77,
20431,
14,
1974,
14,
396,
1974,
492,
702,
63,
3369,
63,
705,
199,
199,
533,
2235,
13113,
320,
344,
63,
3467,
8,
7004,
304,
272,
408,
16494,
85,
2335,
314,
18649,
289,
8,
88,
12,
89,
9,
275,
334,
5279,
10,
88,
13,
19,
18979,
18,
435,
334,
5279,
10,
88,
14397,
16,
14,
614,
10,
89,
9,
435,
334,
16,
14,
614,
10,
89,
11,
20,
18979,
18,
446,
650,
408,
339,
327,
663,
1536,
3217,
370,
314,
10059,
272,
327,
4287,
26,
3507,
13,
1328,
29,
37,
24827,
272,
671,
275,
11140,
8,
16,
14,
16,
12,
284,
7818,
534,
262,
297,
4328,
534,
1918,
1750,
671,
358,
272,
612,
275,
11140,
8,
16,
14,
16,
12,
284,
7818,
534,
262,
297,
4328,
534,
1918,
1750,
612,
358,
339,
289,
63,
1702,
275,
11140,
8,
73,
7818,
534,
548,
297,
4328,
534,
38,
8,
88,
12,
89,
5942,
2378,
347,
5341,
8,
277,
304,
267,
408,
70,
8,
88,
12,
89,
9,
275,
334,
88,
13,
19,
18979,
18,
435,
13222,
435,
334,
89,
11,
20,
18979,
18,
446,
650,
267,
9319,
16757,
8744,
334,
10700,
304,
671,
275,
378,
14,
383,
24741,
1272,
23772,
27,
612,
275,
446,
31666,
14,
15093,
6772,
1401,
267,
408,
398,
671,
275,
291,
14,
88,
267,
612,
275,
291,
14,
89,
398,
291,
14,
70,
63,
1702,
275,
334,
5279,
2795,
88,
13,
19,
4959,
538,
18,
435,
334,
5279,
2795,
88,
14397,
16,
14,
614,
10,
89,
9,
435,
334,
16,
14,
614,
10,
89,
11,
20,
4959,
538,
18,
446,
650,
14,
267,
327,
1361,
298,
4858,
4655,
12,
10536,
1153,
70,
12,
10536,
1153,
70,
12,
10536,
1153,
70,
2,
450,
334,
88,
12,
612,
12,
291,
14,
70,
63,
1702,
9,
421,
199,
533,
19246,
2072,
1358,
25990,
9944,
8,
16489,
304,
267,
408,
1358,
25990,
13712,
402,
314,
625,
15120,
2235,
13113,
320,
344,
12727,
1041,
398,
347,
7908,
8,
277,
304,
288,
408,
10560,
282,
892,
3709,
9621,
3035,
376,
625,
15120,
2235,
13113,
320,
344,
436,
376,
10736,
624,
953,
327,
2790,
19246,
1793,
1256,
288,
291,
14,
525,
360,
3090,
297,
428,
5296,
31208,
3090,
1012,
953,
327,
2790,
2235,
13113,
320,
344,
3931,
4454,
288,
291,
14,
525,
360,
462,
13113,
320,
344,
297,
2235,
13113,
320,
344,
63,
3467,
1012,
953,
327,
19447,
2112,
5492,
288,
291,
14,
3090,
14,
8856,
14,
525,
360,
462,
13113,
320,
344,
358,
953,
327,
5385,
18445,
48,
24870,
288,
291,
14,
3090,
14,
711,
672,
275,
378,
953,
327,
24921,
6850,
288,
291,
14,
3090,
14,
525,
63,
24091,
360,
462,
13113,
320,
344,
14,
70,
63,
1702,
358,
953,
327,
29410,
17198,
288,
291,
14,
3090,
14,
525,
63,
5329,
360,
462,
13113,
320,
344,
14,
88,
297,
6465,
4022,
5279,
2020,
4721,
29,
5279,
2020,
31121,
29,
16,
14,
4587,
9,
288,
291,
14,
3090,
14,
525,
63,
5329,
360,
462,
13113,
320,
344,
14,
89,
297,
6465,
4022,
5279,
2020,
4721,
29,
5279,
2020,
31121,
29,
5279,
14,
16,
9,
199,
199,
533,
2235,
13113,
320,
344,
63,
4723,
8,
7004,
304,
267,
408,
16494,
85,
2335,
314,
18649,
289,
8,
88,
12,
89,
9,
275,
334,
5279,
10,
88,
13,
19,
18979,
18,
435,
334,
5279,
10,
88,
14397,
16,
14,
614,
5830,
89,
11,
5279,
430,
435,
334,
16,
14,
614,
5830,
89,
11,
5279,
6393,
20,
18979,
18,
446,
650,
221,
408,
398,
327,
663,
1536,
3217,
370,
314,
10059,
267,
327,
4287,
26,
3507,
13,
1328,
29,
37,
24827,
267,
671,
275,
11140,
8,
16,
14,
16,
12,
284,
7818,
534,
262,
297,
4328,
534,
1918,
1750,
671,
358,
267,
612,
275,
11140,
8,
16,
14,
16,
12,
284,
7818,
534,
262,
297,
4328,
534,
1918,
1750,
612,
358,
398,
289,
63,
1702,
275,
11140,
8,
73,
7818,
534,
548,
297,
4328,
534,
38,
8,
88,
12,
89,
5942,
7318,
347,
5341,
8,
277,
304,
288,
408,
70,
8,
88,
12,
89,
9,
275,
334,
5279,
10,
88,
13,
19,
18979,
18,
435,
334,
5279,
10,
88,
14397,
16,
14,
614,
5830,
89,
11,
5279,
430,
435,
334,
16,
14,
614,
5830,
89,
11,
5279,
6393,
20,
18979,
18,
446,
650,
288,
9319,
16757,
8744,
334,
10700,
304,
671,
275,
378,
14,
383,
24741,
1272,
23772,
27,
612,
275,
446,
1196,
1153,
14,
15093,
6772,
1401,
288,
408,
953,
671,
275,
291,
14,
88,
288,
612,
275,
291,
14,
89,
953,
291,
14,
70,
63,
1702,
275,
334,
5279,
10,
88,
13,
19,
6422,
18,
435,
334,
5279,
10,
88,
14397,
16,
14,
614,
5830,
89,
11,
5279,
430,
435,
334,
16,
14,
614,
5830,
89,
11,
5279,
6393,
20,
6422,
18,
446,
650,
199,
199,
533,
19246,
2072,
1358,
25990,
9944,
14379,
8,
16489,
304,
272,
408,
1358,
25990,
13712,
402,
314,
2235,
13113,
320,
344,
12727,
1041,
339,
347,
7908,
8,
277,
304,
267,
408,
10560,
282,
892,
3709,
9621,
3035,
282,
2235,
13113,
320,
344,
436,
376,
10736,
624,
398,
327,
4287,
26,
3507,
13,
1328,
29,
37,
24827,
398,
327,
2790,
19246,
1793,
1256,
267,
291,
14,
525,
360,
3090,
297,
428,
5296,
31208,
3090,
1012,
398,
327,
2790,
2235,
13113,
320,
344,
3931,
4454,
267,
291,
14,
525,
360,
462,
13113,
320,
344,
297,
2235,
13113,
320,
344,
63,
4723,
1012,
398,
327,
19447,
2112,
5492,
267,
291,
14,
3090,
14,
8856,
14,
525,
360,
462,
13113,
320,
344,
358,
398,
327,
5385,
18445,
48,
24870
] |
[
6496,
314,
31121,
15,
28874,
2893,
315,
4154,
9149,
14,
961,
511,
1990,
315,
388,
1856,
6792,
370,
511,
199,
262,
2399,
4192,
315,
314,
9149,
14,
408,
199,
199,
3,
4287,
26,
3507,
13,
1328,
29,
35,
28107,
12,
35,
28399,
199,
646,
2882,
199,
199,
504,
1551,
77,
20431,
14,
773,
14,
14184,
83,
14,
1246,
492,
11140,
199,
504,
1551,
77,
20431,
14,
773,
14,
13337,
14,
1246,
492,
428,
5296,
31208,
3090,
199,
504,
1551,
77,
20431,
14,
973,
14,
1246,
492,
3709,
9621,
12,
7004,
199,
504,
1551,
77,
20431,
14,
973,
14,
396,
14,
4129,
3090,
492,
5870,
6158,
199,
504,
1551,
77,
20431,
14,
1974,
14,
396,
1974,
492,
702,
63,
3369,
63,
705,
199,
199,
533,
2235,
13113,
320,
344,
63,
3467,
8,
7004,
304,
272,
408,
16494,
85,
2335,
314,
18649,
289,
8,
88,
12,
89,
9,
275,
334,
5279,
10,
88,
13,
19,
18979,
18,
435,
334,
5279,
10,
88,
14397,
16,
14,
614,
10,
89,
9,
435,
334,
16,
14,
614,
10,
89,
11,
20,
18979,
18,
446,
650,
408,
339,
327,
663,
1536,
3217,
370,
314,
10059,
272,
327,
4287,
26,
3507,
13,
1328,
29,
37,
24827,
272,
671,
275,
11140,
8,
16,
14,
16,
12,
284,
7818,
534,
262,
297,
4328,
534,
1918,
1750,
671,
358,
272,
612,
275,
11140,
8,
16,
14,
16,
12,
284,
7818,
534,
262,
297,
4328,
534,
1918,
1750,
612,
358,
339,
289,
63,
1702,
275,
11140,
8,
73,
7818,
534,
548,
297,
4328,
534,
38,
8,
88,
12,
89,
5942,
2378,
347,
5341,
8,
277,
304,
267,
408,
70,
8,
88,
12,
89,
9,
275,
334,
88,
13,
19,
18979,
18,
435,
13222,
435,
334,
89,
11,
20,
18979,
18,
446,
650,
267,
9319,
16757,
8744,
334,
10700,
304,
671,
275,
378,
14,
383,
24741,
1272,
23772,
27,
612,
275,
446,
31666,
14,
15093,
6772,
1401,
267,
408,
398,
671,
275,
291,
14,
88,
267,
612,
275,
291,
14,
89,
398,
291,
14,
70,
63,
1702,
275,
334,
5279,
2795,
88,
13,
19,
4959,
538,
18,
435,
334,
5279,
2795,
88,
14397,
16,
14,
614,
10,
89,
9,
435,
334,
16,
14,
614,
10,
89,
11,
20,
4959,
538,
18,
446,
650,
14,
267,
327,
1361,
298,
4858,
4655,
12,
10536,
1153,
70,
12,
10536,
1153,
70,
12,
10536,
1153,
70,
2,
450,
334,
88,
12,
612,
12,
291,
14,
70,
63,
1702,
9,
421,
199,
533,
19246,
2072,
1358,
25990,
9944,
8,
16489,
304,
267,
408,
1358,
25990,
13712,
402,
314,
625,
15120,
2235,
13113,
320,
344,
12727,
1041,
398,
347,
7908,
8,
277,
304,
288,
408,
10560,
282,
892,
3709,
9621,
3035,
376,
625,
15120,
2235,
13113,
320,
344,
436,
376,
10736,
624,
953,
327,
2790,
19246,
1793,
1256,
288,
291,
14,
525,
360,
3090,
297,
428,
5296,
31208,
3090,
1012,
953,
327,
2790,
2235,
13113,
320,
344,
3931,
4454,
288,
291,
14,
525,
360,
462,
13113,
320,
344,
297,
2235,
13113,
320,
344,
63,
3467,
1012,
953,
327,
19447,
2112,
5492,
288,
291,
14,
3090,
14,
8856,
14,
525,
360,
462,
13113,
320,
344,
358,
953,
327,
5385,
18445,
48,
24870,
288,
291,
14,
3090,
14,
711,
672,
275,
378,
953,
327,
24921,
6850,
288,
291,
14,
3090,
14,
525,
63,
24091,
360,
462,
13113,
320,
344,
14,
70,
63,
1702,
358,
953,
327,
29410,
17198,
288,
291,
14,
3090,
14,
525,
63,
5329,
360,
462,
13113,
320,
344,
14,
88,
297,
6465,
4022,
5279,
2020,
4721,
29,
5279,
2020,
31121,
29,
16,
14,
4587,
9,
288,
291,
14,
3090,
14,
525,
63,
5329,
360,
462,
13113,
320,
344,
14,
89,
297,
6465,
4022,
5279,
2020,
4721,
29,
5279,
2020,
31121,
29,
5279,
14,
16,
9,
199,
199,
533,
2235,
13113,
320,
344,
63,
4723,
8,
7004,
304,
267,
408,
16494,
85,
2335,
314,
18649,
289,
8,
88,
12,
89,
9,
275,
334,
5279,
10,
88,
13,
19,
18979,
18,
435,
334,
5279,
10,
88,
14397,
16,
14,
614,
5830,
89,
11,
5279,
430,
435,
334,
16,
14,
614,
5830,
89,
11,
5279,
6393,
20,
18979,
18,
446,
650,
221,
408,
398,
327,
663,
1536,
3217,
370,
314,
10059,
267,
327,
4287,
26,
3507,
13,
1328,
29,
37,
24827,
267,
671,
275,
11140,
8,
16,
14,
16,
12,
284,
7818,
534,
262,
297,
4328,
534,
1918,
1750,
671,
358,
267,
612,
275,
11140,
8,
16,
14,
16,
12,
284,
7818,
534,
262,
297,
4328,
534,
1918,
1750,
612,
358,
398,
289,
63,
1702,
275,
11140,
8,
73,
7818,
534,
548,
297,
4328,
534,
38,
8,
88,
12,
89,
5942,
7318,
347,
5341,
8,
277,
304,
288,
408,
70,
8,
88,
12,
89,
9,
275,
334,
5279,
10,
88,
13,
19,
18979,
18,
435,
334,
5279,
10,
88,
14397,
16,
14,
614,
5830,
89,
11,
5279,
430,
435,
334,
16,
14,
614,
5830,
89,
11,
5279,
6393,
20,
18979,
18,
446,
650,
288,
9319,
16757,
8744,
334,
10700,
304,
671,
275,
378,
14,
383,
24741,
1272,
23772,
27,
612,
275,
446,
1196,
1153,
14,
15093,
6772,
1401,
288,
408,
953,
671,
275,
291,
14,
88,
288,
612,
275,
291,
14,
89,
953,
291,
14,
70,
63,
1702,
275,
334,
5279,
10,
88,
13,
19,
6422,
18,
435,
334,
5279,
10,
88,
14397,
16,
14,
614,
5830,
89,
11,
5279,
430,
435,
334,
16,
14,
614,
5830,
89,
11,
5279,
6393,
20,
6422,
18,
446,
650,
199,
199,
533,
19246,
2072,
1358,
25990,
9944,
14379,
8,
16489,
304,
272,
408,
1358,
25990,
13712,
402,
314,
2235,
13113,
320,
344,
12727,
1041,
339,
347,
7908,
8,
277,
304,
267,
408,
10560,
282,
892,
3709,
9621,
3035,
282,
2235,
13113,
320,
344,
436,
376,
10736,
624,
398,
327,
4287,
26,
3507,
13,
1328,
29,
37,
24827,
398,
327,
2790,
19246,
1793,
1256,
267,
291,
14,
525,
360,
3090,
297,
428,
5296,
31208,
3090,
1012,
398,
327,
2790,
2235,
13113,
320,
344,
3931,
4454,
267,
291,
14,
525,
360,
462,
13113,
320,
344,
297,
2235,
13113,
320,
344,
63,
4723,
1012,
398,
327,
19447,
2112,
5492,
267,
291,
14,
3090,
14,
8856,
14,
525,
360,
462,
13113,
320,
344,
358,
398,
327,
5385,
18445,
48,
24870,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
j00bar/ansible
|
lib/ansible/plugins/lookup/sequence.py
|
29
|
7200
|
# (c) 2013, Jayson Vantuyl <jayson@aggressive.ly>
#
# 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/>.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from re import compile as re_compile, IGNORECASE
from ansible.errors import AnsibleError
from ansible.module_utils.six.moves import xrange
from ansible.parsing.splitter import parse_kv
from ansible.plugins.lookup import LookupBase
# shortcut format
NUM = "(0?x?[0-9a-f]+)"
SHORTCUT = re_compile(
"^(" + # Group 0
NUM + # Group 1: Start
"-)?" +
NUM + # Group 2: End
"(/" + # Group 3
NUM + # Group 4: Stride
")?" +
"(:(.+))?$", # Group 5, Group 6: Format String
IGNORECASE
)
class LookupModule(LookupBase):
"""
sequence lookup module
Used to generate some sequence of items. Takes arguments in two forms.
The simple / shortcut form is:
[start-]end[/stride][:format]
As indicated by the brackets: start, stride, and format string are all
optional. The format string is in the style of printf. This can be used
to pad with zeros, format in hexadecimal, etc. All of the numerical values
can be specified in octal (i.e. 0664) or hexadecimal (i.e. 0x3f8).
Negative numbers are not supported.
Some examples:
5 -> ["1","2","3","4","5"]
5-8 -> ["5", "6", "7", "8"]
2-10/2 -> ["2", "4", "6", "8", "10"]
4:host%02d -> ["host01","host02","host03","host04"]
The standard Ansible key-value form is accepted as well. For example:
start=5 end=11 stride=2 format=0x%02x -> ["0x05","0x07","0x09","0x0a"]
This format takes an alternate form of "end" called "count", which counts
some number from the starting value. For example:
count=5 -> ["1", "2", "3", "4", "5"]
start=0x0f00 count=4 format=%04x -> ["0f00", "0f01", "0f02", "0f03"]
start=0 count=5 stride=2 -> ["0", "2", "4", "6", "8"]
start=1 count=5 stride=2 -> ["1", "3", "5", "7", "9"]
The count option is mostly useful for avoiding off-by-one errors and errors
calculating the number of entries in a sequence when a stride is specified.
"""
def reset(self):
"""set sensible defaults"""
self.start = 1
self.count = None
self.end = None
self.stride = 1
self.format = "%d"
def parse_kv_args(self, args):
"""parse key-value style arguments"""
for arg in ["start", "end", "count", "stride"]:
try:
arg_raw = args.pop(arg, None)
if arg_raw is None:
continue
arg_cooked = int(arg_raw, 0)
setattr(self, arg, arg_cooked)
except ValueError:
raise AnsibleError(
"can't parse arg %s=%r as integer"
% (arg, arg_raw)
)
if 'format' in args:
self.format = args.pop("format")
if args:
raise AnsibleError(
"unrecognized arguments to with_sequence: %r"
% args.keys()
)
def parse_simple_args(self, term):
"""parse the shortcut forms, return True/False"""
match = SHORTCUT.match(term)
if not match:
return False
_, start, end, _, stride, _, format = match.groups()
if start is not None:
try:
start = int(start, 0)
except ValueError:
raise AnsibleError("can't parse start=%s as integer" % start)
if end is not None:
try:
end = int(end, 0)
except ValueError:
raise AnsibleError("can't parse end=%s as integer" % end)
if stride is not None:
try:
stride = int(stride, 0)
except ValueError:
raise AnsibleError("can't parse stride=%s as integer" % stride)
if start is not None:
self.start = start
if end is not None:
self.end = end
if stride is not None:
self.stride = stride
if format is not None:
self.format = format
return True
def sanity_check(self):
if self.count is None and self.end is None:
raise AnsibleError( "must specify count or end in with_sequence")
elif self.count is not None and self.end is not None:
raise AnsibleError( "can't specify both count and end in with_sequence")
elif self.count is not None:
# convert count to end
if self.count != 0:
self.end = self.start + self.count * self.stride - 1
else:
self.start = 0
self.end = 0
self.stride = 0
del self.count
if self.stride > 0 and self.end < self.start:
raise AnsibleError("to count backwards make stride negative")
if self.stride < 0 and self.end > self.start:
raise AnsibleError("to count forward don't make stride negative")
if self.format.count('%') != 1:
raise AnsibleError("bad formatting string: %s" % self.format)
def generate_sequence(self):
if self.stride >= 0:
adjust = 1
else:
adjust = -1
numbers = xrange(self.start, self.end + adjust, self.stride)
for i in numbers:
try:
formatted = self.format % i
yield formatted
except (ValueError, TypeError):
raise AnsibleError(
"problem formatting %r with %r" % self.format
)
def run(self, terms, variables, **kwargs):
results = []
for term in terms:
try:
self.reset() # clear out things for this iteration
try:
if not self.parse_simple_args(term):
self.parse_kv_args(parse_kv(term))
except AnsibleError:
raise
except Exception as e:
raise AnsibleError("unknown error parsing with_sequence arguments: %r. Error was: %s" % (term, e))
self.sanity_check()
if self.stride != 0:
results.extend(self.generate_sequence())
except AnsibleError:
raise
except Exception as e:
raise AnsibleError(
"unknown error generating sequence: %s" % e
)
return results
|
gpl-3.0
|
[
3,
334,
67,
9,
6171,
12,
1603,
5758,
265,
812,
867,
29514,
76,
665,
3387,
588,
265,
32,
643,
25787,
14,
590,
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,
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,
295,
492,
6555,
465,
295,
63,
2014,
12,
27499,
5788,
11320,
199,
199,
504,
3242,
14,
2550,
492,
13358,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
492,
4945,
199,
504,
3242,
14,
11059,
14,
25234,
492,
2198,
63,
11475,
199,
504,
3242,
14,
5265,
14,
3892,
492,
12785,
1563,
421,
199,
3,
17522,
1475,
199,
7125,
275,
7340,
16,
31,
88,
26736,
16,
13,
25,
65,
13,
70,
2807,
2924,
199,
13003,
24678,
275,
295,
63,
2014,
8,
272,
18129,
480,
435,
263,
327,
5611,
378,
272,
11576,
435,
260,
327,
5611,
413,
26,
7707,
272,
3905,
5547,
2,
435,
272,
11576,
435,
260,
327,
5611,
499,
26,
9599,
272,
7340,
6687,
435,
263,
327,
5611,
650,
272,
11576,
435,
260,
327,
5611,
841,
26,
31309,
271,
272,
298,
5547,
2,
435,
272,
7340,
20334,
6977,
22119,
11918,
221,
327,
5611,
959,
12,
5611,
1227,
26,
9701,
2624,
272,
27499,
5788,
11320,
199,
9,
421,
199,
533,
12785,
2377,
8,
7521,
1563,
304,
272,
408,
272,
3414,
4237,
859,
339,
8051,
370,
3550,
2005,
3414,
402,
2974,
14,
17415,
2368,
315,
2877,
4513,
14,
339,
710,
3486,
1182,
17522,
1824,
365,
26,
2541,
359,
928,
13,
61,
500,
28787,
12318,
19663,
908,
61,
339,
3709,
22141,
701,
314,
21873,
26,
1343,
12,
7345,
12,
436,
1475,
1059,
787,
1006,
272,
2716,
14,
221,
710,
1475,
1059,
365,
315,
314,
3449,
402,
870,
70,
14,
221,
961,
883,
506,
1202,
272,
370,
6567,
543,
10136,
12,
1475,
315,
20379,
12,
5423,
14,
221,
2900,
402,
314,
15470,
1338,
272,
883,
506,
2013,
315,
30100,
334,
73,
14,
69,
14,
24293,
772,
9,
503,
20379,
334,
73,
14,
69,
14,
378,
88,
19,
70,
24,
680,
272,
32548,
5579,
787,
440,
3748,
14,
339,
6601,
7251,
26,
2541,
959,
1035,
2097,
17,
2266,
18,
2266,
19,
2266,
20,
2266,
21,
937,
489,
959,
13,
24,
1035,
2097,
21,
401,
298,
22,
401,
298,
23,
401,
298,
24,
937,
489,
499,
13,
709,
15,
18,
1035,
2097,
18,
401,
298,
20,
401,
298,
22,
401,
298,
24,
401,
298,
709,
937,
489,
841,
26,
1102,
5,
996,
68,
1035,
2097,
1102,
614,
2266,
1102,
996,
2266,
1102,
1644,
2266,
1102,
966,
937,
339,
710,
4465,
2622,
790,
13,
585,
1824,
365,
10226,
465,
5521,
14,
221,
2104,
2893,
26,
2541,
1343,
29,
21,
1284,
29,
845,
7345,
29,
18,
1475,
29,
16,
88,
5,
996,
88,
1035,
2097,
16,
88,
1717,
2266,
16,
88,
1780,
2266,
16,
88,
1643,
2266,
16,
88,
16,
65,
937,
339,
961,
1475,
6181,
376,
18034,
1824,
402,
298,
500,
2,
2797,
298,
835,
401,
1314,
8242,
272,
2005,
1329,
687,
314,
6617,
574,
14,
221,
2104,
2893,
26,
2541,
2338,
29,
21,
1035,
2097,
17,
401,
298,
18,
401,
298,
19,
401,
298,
20,
401,
298,
21,
937,
489,
1343,
29,
16,
88,
16,
70,
383,
2338,
29,
20,
1475,
2458,
966,
88,
1035,
2097,
16,
70,
383,
401,
298,
16,
70,
614,
401,
298,
16,
70,
996,
401,
298,
16,
70,
1644,
937,
489,
1343,
29,
16,
2338,
29,
21,
7345,
29,
18,
1035,
2097,
16,
401,
298,
18,
401,
298,
20,
401,
298,
22,
401,
298,
24,
937,
489,
1343,
29,
17,
2338,
29,
21,
7345,
29,
18,
1035,
2097,
17,
401,
298,
19,
401,
298,
21,
401,
298,
23,
401,
298,
25,
937,
339,
710,
2338,
945,
365,
19762,
2997,
367,
5126,
316,
2331,
13,
991,
13,
368,
2552,
436,
2552,
272,
26079,
314,
1329,
402,
4811,
315,
282,
3414,
1380,
282,
7345,
365,
2013,
14,
272,
408,
339,
347,
5305,
8,
277,
304,
267,
408,
409,
27962,
4243,
624,
267,
291,
14,
928,
275,
413,
267,
291,
14,
835,
275,
488,
267,
291,
14,
500,
275,
488,
267,
291,
14,
12318,
275,
413,
267,
291,
14,
908,
275,
2071,
68,
2,
339,
347,
2198,
63,
11475,
63,
589,
8,
277,
12,
1249,
304,
267,
408,
1122,
790,
13,
585,
3449,
2368,
624,
267,
367,
1680,
315,
2097,
928,
401,
298,
500,
401,
298,
835,
401,
298,
12318,
6229,
288,
862,
26,
355,
1680,
63,
1773,
275,
1249,
14,
1935,
8,
1273,
12,
488,
9,
355,
340,
1680,
63,
1773,
365,
488,
26,
490,
1980,
355,
1680,
63,
331,
7620,
275,
1109,
8,
1273,
63,
1773,
12,
378,
9,
355,
5371,
8,
277,
12,
1680,
12,
1680,
63,
331,
7620,
9,
288,
871,
1722,
26,
355,
746,
13358,
8,
490,
298,
2425,
1133,
2198,
1680,
450,
83,
2458,
82,
465,
3000,
2,
490,
450,
334,
1273,
12,
1680,
63,
1773,
9,
355,
776,
267,
340,
283,
908,
7,
315,
1249,
26,
288,
291,
14,
908,
275,
1249,
14,
1935,
480,
908,
531,
267,
340,
1249,
26,
288,
746,
13358,
8,
355,
298,
324,
13221,
2368,
370,
543,
63,
4041,
26,
450,
82,
2,
355,
450,
1249,
14,
1612,
342,
288,
776,
339,
347,
2198,
63,
4129,
63
] |
[
334,
67,
9,
6171,
12,
1603,
5758,
265,
812,
867,
29514,
76,
665,
3387,
588,
265,
32,
643,
25787,
14,
590,
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,
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,
295,
492,
6555,
465,
295,
63,
2014,
12,
27499,
5788,
11320,
199,
199,
504,
3242,
14,
2550,
492,
13358,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
492,
4945,
199,
504,
3242,
14,
11059,
14,
25234,
492,
2198,
63,
11475,
199,
504,
3242,
14,
5265,
14,
3892,
492,
12785,
1563,
421,
199,
3,
17522,
1475,
199,
7125,
275,
7340,
16,
31,
88,
26736,
16,
13,
25,
65,
13,
70,
2807,
2924,
199,
13003,
24678,
275,
295,
63,
2014,
8,
272,
18129,
480,
435,
263,
327,
5611,
378,
272,
11576,
435,
260,
327,
5611,
413,
26,
7707,
272,
3905,
5547,
2,
435,
272,
11576,
435,
260,
327,
5611,
499,
26,
9599,
272,
7340,
6687,
435,
263,
327,
5611,
650,
272,
11576,
435,
260,
327,
5611,
841,
26,
31309,
271,
272,
298,
5547,
2,
435,
272,
7340,
20334,
6977,
22119,
11918,
221,
327,
5611,
959,
12,
5611,
1227,
26,
9701,
2624,
272,
27499,
5788,
11320,
199,
9,
421,
199,
533,
12785,
2377,
8,
7521,
1563,
304,
272,
408,
272,
3414,
4237,
859,
339,
8051,
370,
3550,
2005,
3414,
402,
2974,
14,
17415,
2368,
315,
2877,
4513,
14,
339,
710,
3486,
1182,
17522,
1824,
365,
26,
2541,
359,
928,
13,
61,
500,
28787,
12318,
19663,
908,
61,
339,
3709,
22141,
701,
314,
21873,
26,
1343,
12,
7345,
12,
436,
1475,
1059,
787,
1006,
272,
2716,
14,
221,
710,
1475,
1059,
365,
315,
314,
3449,
402,
870,
70,
14,
221,
961,
883,
506,
1202,
272,
370,
6567,
543,
10136,
12,
1475,
315,
20379,
12,
5423,
14,
221,
2900,
402,
314,
15470,
1338,
272,
883,
506,
2013,
315,
30100,
334,
73,
14,
69,
14,
24293,
772,
9,
503,
20379,
334,
73,
14,
69,
14,
378,
88,
19,
70,
24,
680,
272,
32548,
5579,
787,
440,
3748,
14,
339,
6601,
7251,
26,
2541,
959,
1035,
2097,
17,
2266,
18,
2266,
19,
2266,
20,
2266,
21,
937,
489,
959,
13,
24,
1035,
2097,
21,
401,
298,
22,
401,
298,
23,
401,
298,
24,
937,
489,
499,
13,
709,
15,
18,
1035,
2097,
18,
401,
298,
20,
401,
298,
22,
401,
298,
24,
401,
298,
709,
937,
489,
841,
26,
1102,
5,
996,
68,
1035,
2097,
1102,
614,
2266,
1102,
996,
2266,
1102,
1644,
2266,
1102,
966,
937,
339,
710,
4465,
2622,
790,
13,
585,
1824,
365,
10226,
465,
5521,
14,
221,
2104,
2893,
26,
2541,
1343,
29,
21,
1284,
29,
845,
7345,
29,
18,
1475,
29,
16,
88,
5,
996,
88,
1035,
2097,
16,
88,
1717,
2266,
16,
88,
1780,
2266,
16,
88,
1643,
2266,
16,
88,
16,
65,
937,
339,
961,
1475,
6181,
376,
18034,
1824,
402,
298,
500,
2,
2797,
298,
835,
401,
1314,
8242,
272,
2005,
1329,
687,
314,
6617,
574,
14,
221,
2104,
2893,
26,
2541,
2338,
29,
21,
1035,
2097,
17,
401,
298,
18,
401,
298,
19,
401,
298,
20,
401,
298,
21,
937,
489,
1343,
29,
16,
88,
16,
70,
383,
2338,
29,
20,
1475,
2458,
966,
88,
1035,
2097,
16,
70,
383,
401,
298,
16,
70,
614,
401,
298,
16,
70,
996,
401,
298,
16,
70,
1644,
937,
489,
1343,
29,
16,
2338,
29,
21,
7345,
29,
18,
1035,
2097,
16,
401,
298,
18,
401,
298,
20,
401,
298,
22,
401,
298,
24,
937,
489,
1343,
29,
17,
2338,
29,
21,
7345,
29,
18,
1035,
2097,
17,
401,
298,
19,
401,
298,
21,
401,
298,
23,
401,
298,
25,
937,
339,
710,
2338,
945,
365,
19762,
2997,
367,
5126,
316,
2331,
13,
991,
13,
368,
2552,
436,
2552,
272,
26079,
314,
1329,
402,
4811,
315,
282,
3414,
1380,
282,
7345,
365,
2013,
14,
272,
408,
339,
347,
5305,
8,
277,
304,
267,
408,
409,
27962,
4243,
624,
267,
291,
14,
928,
275,
413,
267,
291,
14,
835,
275,
488,
267,
291,
14,
500,
275,
488,
267,
291,
14,
12318,
275,
413,
267,
291,
14,
908,
275,
2071,
68,
2,
339,
347,
2198,
63,
11475,
63,
589,
8,
277,
12,
1249,
304,
267,
408,
1122,
790,
13,
585,
3449,
2368,
624,
267,
367,
1680,
315,
2097,
928,
401,
298,
500,
401,
298,
835,
401,
298,
12318,
6229,
288,
862,
26,
355,
1680,
63,
1773,
275,
1249,
14,
1935,
8,
1273,
12,
488,
9,
355,
340,
1680,
63,
1773,
365,
488,
26,
490,
1980,
355,
1680,
63,
331,
7620,
275,
1109,
8,
1273,
63,
1773,
12,
378,
9,
355,
5371,
8,
277,
12,
1680,
12,
1680,
63,
331,
7620,
9,
288,
871,
1722,
26,
355,
746,
13358,
8,
490,
298,
2425,
1133,
2198,
1680,
450,
83,
2458,
82,
465,
3000,
2,
490,
450,
334,
1273,
12,
1680,
63,
1773,
9,
355,
776,
267,
340,
283,
908,
7,
315,
1249,
26,
288,
291,
14,
908,
275,
1249,
14,
1935,
480,
908,
531,
267,
340,
1249,
26,
288,
746,
13358,
8,
355,
298,
324,
13221,
2368,
370,
543,
63,
4041,
26,
450,
82,
2,
355,
450,
1249,
14,
1612,
342,
288,
776,
339,
347,
2198,
63,
4129,
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,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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
] |
SoftwareKing/zstack-utility
|
kvmagent/kvmagent/test/test_vr_create_iso.py
|
3
|
1551
|
'''
@author: Frank
'''
import unittest
import time
from kvmagent import kvmagent
from kvmagent.plugins import virtualrouter_plugin
from zstacklib.utils import http
from zstacklib.utils import jsonobject
from zstacklib.utils import log
from zstacklib.utils import uuidhelper
class Test(unittest.TestCase):
CALLBACK_URL = 'http://localhost:7070/testcallback'
def setUp(self):
self.service = kvmagent.new_rest_service()
self.service.http_server.register_sync_uri('/testcallback', self.callback)
self.service.start()
time.sleep(1)
def callback(self, req):
rsp = jsonobject.loads(req[http.REQUEST_BODY])
print jsonobject.dumps(rsp)
def testName(self):
url = kvmagent._build_url_for_test([virtualrouter_plugin.VirtualRouterPlugin.VR_KVM_CREATE_BOOTSTRAP_ISO_PATH])
info = virtualrouter_plugin.BootstrapIsoInfo()
info.managementNicGateway = "192.168.1.1"
info.managementNicIp = "192.168.1.10"
info.managementNicMac = "50:E5:49:C9:65:A3"
info.managementNicNetmask = "255.255.255.0"
cmd = virtualrouter_plugin.CreateVritualRouterBootstrapIsoCmd()
cmd.isoInfo = info
cmd.isoPath = '/tmp/vr.iso'
rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
time.sleep(2)
self.service.stop()
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
unittest.main()
|
apache-2.0
|
[
2344,
2999,
199,
32,
2502,
26,
11007,
202,
199,
2344,
202,
199,
646,
2882,
202,
199,
646,
900,
202,
199,
504,
16616,
5615,
484,
492,
16616,
5615,
484,
202,
199,
504,
16616,
5615,
484,
14,
5265,
492,
5791,
4995,
63,
2718,
202,
199,
504,
1315,
2340,
773,
14,
1208,
492,
1455,
202,
199,
504,
1315,
2340,
773,
14,
1208,
492,
2022,
785,
202,
199,
504,
1315,
2340,
773,
14,
1208,
492,
943,
202,
199,
504,
1315,
2340,
773,
14,
1208,
492,
5377,
3676,
2999,
199,
533,
1379,
8,
2796,
14,
1746,
304,
1128,
24251,
7111,
63,
2632,
275,
283,
1014,
921,
5967,
26,
15378,
16,
15,
396,
3058,
7,
11787,
347,
3613,
8,
277,
304,
1039,
291,
14,
1364,
275,
16616,
5615,
484,
14,
1222,
63,
3911,
63,
1364,
342,
1039,
291,
14,
1364,
14,
1014,
63,
1000,
14,
2683,
63,
5186,
63,
2302,
2336,
396,
3058,
297,
291,
14,
3058,
9,
1039,
291,
14,
1364,
14,
928,
342,
1039,
900,
14,
4532,
8,
17,
9,
2958,
347,
3233,
8,
277,
12,
2648,
304,
1039,
13684,
275,
2022,
785,
14,
3640,
8,
2103,
59,
1014,
14,
6780,
63,
23708,
566,
1039,
870,
2022,
785,
14,
4180,
8,
15642,
9,
26016,
347,
511,
985,
8,
277,
304,
1039,
1166,
275,
16616,
5615,
484,
423,
1506,
63,
633,
63,
509,
63,
396,
779,
2065,
4995,
63,
2718,
14,
8735,
11691,
5061,
14,
20271,
63,
43,
6849,
63,
8366,
63,
22679,
3027,
1282,
63,
7336,
63,
3243,
566,
1039,
2256,
275,
5791,
4995,
63,
2718,
14,
17989,
7868,
41,
1152,
2354,
342,
1039,
2256,
14,
8110,
46,
530,
12455,
275,
298,
5756,
14,
6568,
14,
17,
14,
17,
2,
1039,
2256,
14,
8110,
46,
530,
6583,
275,
298,
5756,
14,
6568,
14,
17,
14,
709,
2,
1039,
2256,
14,
8110,
46,
530,
3399,
275,
298,
1400,
26,
37,
21,
26,
1887,
26,
35,
25,
26,
2182,
26,
33,
19,
2,
1039,
2256,
14,
8110,
46,
530,
2480,
2629,
275,
298,
2299,
14,
2299,
14,
2299,
14,
16,
2,
1039,
2088,
275,
5791,
4995,
63,
2718,
14,
2499,
54,
322,
1688,
11691,
17989,
7868,
41,
1152,
7874,
342,
1039,
2088,
14,
4595,
2354,
275,
2256,
1039,
2088,
14,
4595,
2042,
275,
1994,
2791,
15,
10922,
14,
4595,
7,
1039,
13684,
275,
1455,
14,
1001,
63,
2724,
63,
1932,
8,
633,
12,
2088,
12,
2323,
3126,
1014,
14,
17179,
63,
8757,
26,
2580,
3676,
14,
2580,
1062,
1455,
14,
28100,
63,
7639,
26,
277,
14,
28100,
63,
2632,
1552,
1039,
900,
14,
4532,
8,
18,
9,
1039,
291,
14,
1364,
14,
2379,
342,
2999,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
1128,
327,
646,
984,
27,
1274,
14,
3020,
275,
18179,
283,
774,
14,
396,
985,
418,
1128,
2882,
14,
973,
342,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2999,
199,
32,
2502,
26,
11007,
202,
199,
2344,
202,
199,
646,
2882,
202,
199,
646,
900,
202,
199,
504,
16616,
5615,
484,
492,
16616,
5615,
484,
202,
199,
504,
16616,
5615,
484,
14,
5265,
492,
5791,
4995,
63,
2718,
202,
199,
504,
1315,
2340,
773,
14,
1208,
492,
1455,
202,
199,
504,
1315,
2340,
773,
14,
1208,
492,
2022,
785,
202,
199,
504,
1315,
2340,
773,
14,
1208,
492,
943,
202,
199,
504,
1315,
2340,
773,
14,
1208,
492,
5377,
3676,
2999,
199,
533,
1379,
8,
2796,
14,
1746,
304,
1128,
24251,
7111,
63,
2632,
275,
283,
1014,
921,
5967,
26,
15378,
16,
15,
396,
3058,
7,
11787,
347,
3613,
8,
277,
304,
1039,
291,
14,
1364,
275,
16616,
5615,
484,
14,
1222,
63,
3911,
63,
1364,
342,
1039,
291,
14,
1364,
14,
1014,
63,
1000,
14,
2683,
63,
5186,
63,
2302,
2336,
396,
3058,
297,
291,
14,
3058,
9,
1039,
291,
14,
1364,
14,
928,
342,
1039,
900,
14,
4532,
8,
17,
9,
2958,
347,
3233,
8,
277,
12,
2648,
304,
1039,
13684,
275,
2022,
785,
14,
3640,
8,
2103,
59,
1014,
14,
6780,
63,
23708,
566,
1039,
870,
2022,
785,
14,
4180,
8,
15642,
9,
26016,
347,
511,
985,
8,
277,
304,
1039,
1166,
275,
16616,
5615,
484,
423,
1506,
63,
633,
63,
509,
63,
396,
779,
2065,
4995,
63,
2718,
14,
8735,
11691,
5061,
14,
20271,
63,
43,
6849,
63,
8366,
63,
22679,
3027,
1282,
63,
7336,
63,
3243,
566,
1039,
2256,
275,
5791,
4995,
63,
2718,
14,
17989,
7868,
41,
1152,
2354,
342,
1039,
2256,
14,
8110,
46,
530,
12455,
275,
298,
5756,
14,
6568,
14,
17,
14,
17,
2,
1039,
2256,
14,
8110,
46,
530,
6583,
275,
298,
5756,
14,
6568,
14,
17,
14,
709,
2,
1039,
2256,
14,
8110,
46,
530,
3399,
275,
298,
1400,
26,
37,
21,
26,
1887,
26,
35,
25,
26,
2182,
26,
33,
19,
2,
1039,
2256,
14,
8110,
46,
530,
2480,
2629,
275,
298,
2299,
14,
2299,
14,
2299,
14,
16,
2,
1039,
2088,
275,
5791,
4995,
63,
2718,
14,
2499,
54,
322,
1688,
11691,
17989,
7868,
41,
1152,
7874,
342,
1039,
2088,
14,
4595,
2354,
275,
2256,
1039,
2088,
14,
4595,
2042,
275,
1994,
2791,
15,
10922,
14,
4595,
7,
1039,
13684,
275,
1455,
14,
1001,
63,
2724,
63,
1932,
8,
633,
12,
2088,
12,
2323,
3126,
1014,
14,
17179,
63,
8757,
26,
2580,
3676,
14,
2580,
1062,
1455,
14,
28100,
63,
7639,
26,
277,
14,
28100,
63,
2632,
1552,
1039,
900,
14,
4532,
8,
18,
9,
1039,
291,
14,
1364,
14,
2379,
342,
2999,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
1128,
327,
646,
984,
27,
1274,
14,
3020,
275,
18179,
283,
774,
14,
396,
985,
418,
1128,
2882,
14,
973,
342,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
ruuk/service.xbmc.tts
|
enabler.py
|
1
|
3477
|
# -*- coding: utf-8 -*-
import os, sys, xbmc, xbmcaddon
DISABLE_PATH = os.path.join(xbmc.translatePath('special://profile').decode('utf-8'), 'addon_data', 'service.xbmc.tts', 'DISABLED')
ENABLE_PATH = os.path.join(xbmc.translatePath('special://profile').decode('utf-8'), 'addon_data', 'service.xbmc.tts', 'ENABLED')
def getXBMCVersion():
import json
resp = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Application.GetProperties", "params": {"properties": ["version", "name"]}, "id": 1 }')
data = json.loads(resp)
if not 'result' in data: return None
if not 'version' in data['result']: return None
return data['result']['version']
BASE = '{ "jsonrpc": "2.0", "method": "Addons.SetAddonEnabled", "params": { "addonid": "service.xbmc.tts","enabled":%s}, "id": 1 }'
def enableAddon():
if os.path.exists(DISABLE_PATH):
os.remove(DISABLE_PATH)
markPreOrPost(enable=True)
if isPostInstalled():
if addonIsEnabled():
xbmc.executebuiltin('RunScript(service.xbmc.tts)')
else:
xbmc.executeJSONRPC(BASE % 'true') #So enable it instead
else:
xbmc.executebuiltin('RunScript(service.xbmc.tts)')
def disableAddon():
if os.path.exists(ENABLE_PATH):
os.remove(ENABLE_PATH)
markPreOrPost(disable=True)
if isPostInstalled():
version = getXBMCVersion()
if not version or version['major'] < 13: return #Disabling in this manner crashes on Frodo
xbmc.executeJSONRPC(BASE % 'false') #Try to disable it
#if res and 'error' in res: #If we have an error, it's already disabled
#print res
def markPreOrPost(enable=False, disable=False):
if os.path.exists(ENABLE_PATH) or enable:
with open(ENABLE_PATH, 'w') as f:
f.write(isPostInstalled() and 'POST' or 'PRE')
if os.path.exists(DISABLE_PATH) or disable:
with open(DISABLE_PATH, 'w') as f:
f.write(isPostInstalled() and 'POST' or 'PRE')
def addonIsEnabled():
if os.path.exists(DISABLE_PATH):
return False
if isPostInstalled():
import json
resp = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddonDetails", "params": {"addonid":"service.xbmc.tts","properties": ["name","version","enabled"]}}')
data = json.loads(resp)
if not 'result' in data: return False
if not 'addon' in data['result']: return False
if not 'enabled' in data['result']['addon']: return False
return data['result']['addon']['enabled']
else:
return True
def toggleEnabled():
try:
if not addonIsEnabled(): raise Exception('Addon Disabled')
xbmcaddon.Addon('service.xbmc.tts')
xbmc.log('service.xbmc.tts: DISABLING')
xbmc.executebuiltin('XBMC.RunScript(service.xbmc.tts,key.SHUTDOWN)')
except:
xbmc.log('service.xbmc.tts: ENABLING')
enableAddon()
def reset():
if not addonIsEnabled(): return
disableAddon()
ct=0
while addonIsEnabled() and ct < 11:
xbmc.sleep(500)
ct+=1
enableAddon()
def isPostInstalled():
homePath = xbmc.translatePath('special://home').decode('utf-8')
postInstalledPath = os.path.join(homePath, 'addons', 'service.xbmc.tts')
return os.path.exists(postInstalledPath)
if __name__ == '__main__':
arg = None
if len(sys.argv) > 1: arg = sys.argv[1]
if arg == 'RESET':
reset()
else:
toggleEnabled()
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
747,
12,
984,
12,
11709,
12,
11709,
9291,
199,
199,
13052,
63,
3243,
275,
747,
14,
515,
14,
904,
8,
21382,
14,
5275,
2042,
360,
6664,
921,
2913,
1959,
2708,
360,
1624,
13,
24,
659,
283,
9291,
63,
576,
297,
283,
1364,
14,
21382,
14,
84,
1086,
297,
283,
16205,
358,
199,
8898,
63,
3243,
275,
747,
14,
515,
14,
904,
8,
21382,
14,
5275,
2042,
360,
6664,
921,
2913,
1959,
2708,
360,
1624,
13,
24,
659,
283,
9291,
63,
576,
297,
283,
1364,
14,
21382,
14,
84,
1086,
297,
283,
15704,
358,
199,
199,
318,
664,
20806,
7608,
3353,
837,
272,
492,
2022,
272,
3085,
275,
11709,
14,
2526,
6243,
8171,
11117,
298,
31395,
582,
298,
18,
14,
16,
401,
298,
765,
582,
298,
5039,
14,
1002,
8516,
401,
298,
1162,
582,
2420,
3282,
582,
2097,
1023,
401,
298,
354,
19057,
298,
344,
582,
413,
789,
358,
272,
666,
275,
2022,
14,
3640,
8,
4518,
9,
272,
340,
440,
283,
1099,
7,
315,
666,
26,
372,
488,
272,
340,
440,
283,
1023,
7,
315,
666,
459,
1099,
2565,
372,
488,
272,
372,
666,
459,
1099,
2545,
1023,
418,
199,
199,
5825,
275,
5041,
298,
31395,
582,
298,
18,
14,
16,
401,
298,
765,
582,
298,
1123,
4654,
14,
1084,
19654,
6589,
401,
298,
1162,
582,
469,
298,
9291,
344,
582,
298,
1364,
14,
21382,
14,
84,
1086,
2266,
3827,
582,
5,
83,
1386,
298,
344,
582,
413,
789,
7,
421,
199,
318,
4756,
19654,
837,
272,
340,
747,
14,
515,
14,
2444,
8,
13052,
63,
3243,
304,
267,
747,
14,
2168,
8,
13052,
63,
3243,
9,
339,
2216,
2398,
2844,
6564,
8,
4296,
29,
549,
9,
339,
340,
365,
6564,
21268,
837,
267,
340,
13553,
1831,
6589,
837,
288,
11709,
14,
2526,
5351,
360,
2540,
5229,
8,
1364,
14,
21382,
14,
84,
1086,
5942,
267,
587,
26,
288,
11709,
14,
2526,
6243,
8171,
8,
5825,
450,
283,
2052,
358,
327,
5158,
4756,
652,
3140,
272,
587,
26,
267,
11709,
14,
2526,
5351,
360,
2540,
5229,
8,
1364,
14,
21382,
14,
84,
1086,
5942,
421,
199,
318,
3507,
19654,
837,
272,
340,
747,
14,
515,
14,
2444,
8,
8898,
63,
3243,
304,
267,
747,
14,
2168,
8,
8898,
63,
3243,
9,
339,
2216,
2398,
2844,
6564,
8,
5993,
29,
549,
9,
339,
340,
365,
6564,
21268,
837,
267,
1015,
275,
664,
20806,
7608,
3353,
342,
267,
340,
440,
1015,
503,
1015,
459,
8452,
418,
665,
4944,
26,
372,
327,
2825,
14744,
315,
642,
30800,
2467,
9030,
641,
481,
293,
1117,
267,
11709,
14,
2526,
6243,
8171,
8,
5825,
450,
283,
3910,
358,
327,
12357,
370,
3507,
652,
267,
327,
692,
522,
436,
283,
705,
7,
315,
522,
26,
327,
3917,
781,
1172,
376,
1125,
12,
652,
1159,
2575,
6980,
267,
327,
1361,
522,
421,
199,
318,
2216,
2398,
2844,
6564,
8,
4296,
29,
797,
12,
3507,
29,
797,
304,
272,
340,
747,
14,
515,
14,
2444,
8,
8898,
63,
3243,
9,
503,
4756,
26,
267,
543,
1551,
8,
8898,
63,
3243,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
952,
8,
374,
6564,
21268,
342,
436,
283,
4030,
7,
503,
283,
4225,
358,
339,
340,
747,
14,
515,
14,
2444,
8,
13052,
63,
3243,
9,
503,
3507,
26,
267,
543,
1551,
8,
13052,
63,
3243,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
952,
8,
374,
6564,
21268,
342,
436,
283,
4030,
7,
503,
283,
4225,
358,
199,
199,
318,
13553,
1831,
6589,
837,
272,
340,
747,
14,
515,
14,
2444,
8,
13052,
63,
3243,
304,
267,
372,
756,
339,
340,
365,
6564,
21268,
837,
267,
492,
2022,
267,
3085,
275,
11709,
14,
2526,
6243,
8171,
11117,
298,
31395,
582,
298,
18,
14,
16,
401,
298,
344,
582,
413,
12,
298,
765,
582,
298,
1123,
4654,
14,
1002,
19654,
11347,
401,
298,
1162,
582,
2420,
9291,
344,
5122,
1364,
14,
21382,
14,
84,
1086,
2266,
3282,
582,
2097,
354,
2266,
1023,
2266,
3827,
937,
4863,
358,
267,
666,
275,
2022,
14,
3640,
8,
4518,
9,
267,
340,
440,
283,
1099,
7,
315,
666,
26,
372,
756,
267,
340,
440,
283,
9291,
7,
315,
666,
459,
1099,
2565,
372,
756,
267,
340,
440,
283,
3827,
7,
315,
666,
459,
1099,
2545,
9291,
2565,
372,
756,
267,
372,
666,
459,
1099,
2545,
9291,
2545,
3827,
418,
272,
587,
26,
267,
372,
715,
421,
199,
318,
19420,
6589,
837,
272,
862,
26,
267,
340,
440,
13553,
1831,
6589,
837,
746,
2186,
360,
19654,
5289,
1909,
358,
267,
11709,
9291,
14,
19654,
360,
1364,
14,
21382,
14,
84,
1086,
358,
267,
11709,
14,
793,
360,
1364,
14,
21382,
14,
84,
1086,
26,
7587,
1217,
44,
1206,
358,
267,
11709,
14,
2526,
5351,
360,
20806,
7608,
14,
2540,
5229,
8,
1364,
14,
21382,
14,
84,
1086,
12,
498,
14,
24340,
8819,
5942,
272,
871,
26,
267,
11709,
14,
793,
360,
1364,
14,
21382,
14,
84,
1086,
26,
5070,
1217,
44,
1206,
358,
267,
4756,
19654,
342,
421,
199,
318,
5305,
837,
272,
340,
440,
13553,
1831,
6589,
837,
372,
272,
3507,
19654,
342,
272,
9428,
29,
16,
272,
1830,
13553,
1831,
6589,
342,
436,
9428,
665,
4119,
26,
267,
11709,
14,
4532,
8,
5783,
9,
267,
9428,
10365,
17,
272,
4756,
19654,
342,
421,
199,
318,
365,
6564,
21268,
837,
272,
5629,
2042,
275,
11709,
14,
5275,
2042,
360,
6664,
921,
4219,
1959,
2708,
360,
1624,
13,
24,
358,
272,
2963,
21268,
2042,
275,
747,
14,
515,
14,
904,
8,
4219,
2042,
12,
283,
10788,
297,
283,
1364,
14,
21382,
14,
84,
1086,
358,
272,
372,
747,
14,
515,
14,
2444,
8,
1932,
21268,
2042,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1680,
275,
488,
272,
340,
822,
8,
1274,
14,
3020,
9,
690,
413,
26,
1680,
275,
984,
14,
3020,
59,
17,
61,
272,
340,
1680,
508,
283,
18066,
356,
267,
5305,
342,
272,
587,
26,
267,
19420,
6589,
342,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
747,
12,
984,
12,
11709,
12,
11709,
9291,
199,
199,
13052,
63,
3243,
275,
747,
14,
515,
14,
904,
8,
21382,
14,
5275,
2042,
360,
6664,
921,
2913,
1959,
2708,
360,
1624,
13,
24,
659,
283,
9291,
63,
576,
297,
283,
1364,
14,
21382,
14,
84,
1086,
297,
283,
16205,
358,
199,
8898,
63,
3243,
275,
747,
14,
515,
14,
904,
8,
21382,
14,
5275,
2042,
360,
6664,
921,
2913,
1959,
2708,
360,
1624,
13,
24,
659,
283,
9291,
63,
576,
297,
283,
1364,
14,
21382,
14,
84,
1086,
297,
283,
15704,
358,
199,
199,
318,
664,
20806,
7608,
3353,
837,
272,
492,
2022,
272,
3085,
275,
11709,
14,
2526,
6243,
8171,
11117,
298,
31395,
582,
298,
18,
14,
16,
401,
298,
765,
582,
298,
5039,
14,
1002,
8516,
401,
298,
1162,
582,
2420,
3282,
582,
2097,
1023,
401,
298,
354,
19057,
298,
344,
582,
413,
789,
358,
272,
666,
275,
2022,
14,
3640,
8,
4518,
9,
272,
340,
440,
283,
1099,
7,
315,
666,
26,
372,
488,
272,
340,
440,
283,
1023,
7,
315,
666,
459,
1099,
2565,
372,
488,
272,
372,
666,
459,
1099,
2545,
1023,
418,
199,
199,
5825,
275,
5041,
298,
31395,
582,
298,
18,
14,
16,
401,
298,
765,
582,
298,
1123,
4654,
14,
1084,
19654,
6589,
401,
298,
1162,
582,
469,
298,
9291,
344,
582,
298,
1364,
14,
21382,
14,
84,
1086,
2266,
3827,
582,
5,
83,
1386,
298,
344,
582,
413,
789,
7,
421,
199,
318,
4756,
19654,
837,
272,
340,
747,
14,
515,
14,
2444,
8,
13052,
63,
3243,
304,
267,
747,
14,
2168,
8,
13052,
63,
3243,
9,
339,
2216,
2398,
2844,
6564,
8,
4296,
29,
549,
9,
339,
340,
365,
6564,
21268,
837,
267,
340,
13553,
1831,
6589,
837,
288,
11709,
14,
2526,
5351,
360,
2540,
5229,
8,
1364,
14,
21382,
14,
84,
1086,
5942,
267,
587,
26,
288,
11709,
14,
2526,
6243,
8171,
8,
5825,
450,
283,
2052,
358,
327,
5158,
4756,
652,
3140,
272,
587,
26,
267,
11709,
14,
2526,
5351,
360,
2540,
5229,
8,
1364,
14,
21382,
14,
84,
1086,
5942,
421,
199,
318,
3507,
19654,
837,
272,
340,
747,
14,
515,
14,
2444,
8,
8898,
63,
3243,
304,
267,
747,
14,
2168,
8,
8898,
63,
3243,
9,
339,
2216,
2398,
2844,
6564,
8,
5993,
29,
549,
9,
339,
340,
365,
6564,
21268,
837,
267,
1015,
275,
664,
20806,
7608,
3353,
342,
267,
340,
440,
1015,
503,
1015,
459,
8452,
418,
665,
4944,
26,
372,
327,
2825,
14744,
315,
642,
30800,
2467,
9030,
641,
481,
293,
1117,
267,
11709,
14,
2526,
6243,
8171,
8,
5825,
450,
283,
3910,
358,
327,
12357,
370,
3507,
652,
267,
327,
692,
522,
436,
283,
705,
7,
315,
522,
26,
327,
3917,
781,
1172,
376,
1125,
12,
652,
1159,
2575,
6980,
267,
327,
1361,
522,
421,
199,
318,
2216,
2398,
2844,
6564,
8,
4296,
29,
797,
12,
3507,
29,
797,
304,
272,
340,
747,
14,
515,
14,
2444,
8,
8898,
63,
3243,
9,
503,
4756,
26,
267,
543,
1551,
8,
8898,
63,
3243,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
952,
8,
374,
6564,
21268,
342,
436,
283,
4030,
7,
503,
283,
4225,
358,
339,
340,
747,
14,
515,
14,
2444,
8,
13052,
63,
3243,
9,
503,
3507,
26,
267,
543,
1551,
8,
13052,
63,
3243,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
952,
8,
374,
6564,
21268,
342,
436,
283,
4030,
7,
503,
283,
4225,
358,
199,
199,
318,
13553,
1831,
6589,
837,
272,
340,
747,
14,
515,
14,
2444,
8,
13052,
63,
3243,
304,
267,
372,
756,
339,
340,
365,
6564,
21268,
837,
267,
492,
2022,
267,
3085,
275,
11709,
14,
2526,
6243,
8171,
11117,
298,
31395,
582,
298,
18,
14,
16,
401,
298,
344,
582,
413,
12,
298,
765,
582,
298,
1123,
4654,
14,
1002,
19654,
11347,
401,
298,
1162,
582,
2420,
9291,
344,
5122,
1364,
14,
21382,
14,
84,
1086,
2266,
3282,
582,
2097,
354,
2266,
1023,
2266,
3827,
937,
4863,
358,
267,
666,
275,
2022,
14,
3640,
8,
4518,
9,
267,
340,
440,
283,
1099,
7,
315,
666,
26,
372,
756,
267,
340,
440,
283,
9291,
7,
315,
666,
459,
1099,
2565,
372,
756,
267,
340,
440,
283,
3827,
7,
315,
666,
459,
1099,
2545,
9291,
2565,
372,
756,
267,
372,
666,
459,
1099,
2545,
9291,
2545,
3827,
418,
272,
587,
26,
267,
372,
715,
421,
199,
318,
19420,
6589,
837,
272,
862,
26,
267,
340,
440,
13553,
1831,
6589,
837,
746,
2186,
360,
19654,
5289,
1909,
358,
267,
11709,
9291,
14,
19654,
360,
1364,
14,
21382,
14,
84,
1086,
358,
267,
11709,
14,
793,
360,
1364,
14,
21382,
14,
84,
1086,
26,
7587,
1217,
44,
1206,
358,
267,
11709,
14,
2526,
5351,
360,
20806,
7608,
14,
2540,
5229,
8,
1364,
14,
21382,
14,
84,
1086,
12,
498,
14,
24340,
8819,
5942,
272,
871,
26,
267,
11709,
14,
793,
360,
1364,
14,
21382,
14,
84,
1086,
26,
5070,
1217,
44,
1206,
358,
267,
4756,
19654,
342,
421,
199,
318,
5305,
837,
272,
340,
440,
13553,
1831,
6589,
837,
372,
272,
3507,
19654,
342,
272,
9428,
29,
16,
272,
1830,
13553,
1831,
6589,
342,
436,
9428,
665,
4119,
26,
267,
11709,
14,
4532,
8,
5783,
9,
267,
9428,
10365,
17,
272,
4756,
19654,
342,
421,
199,
318,
365,
6564,
21268,
837,
272,
5629,
2042,
275,
11709,
14,
5275,
2042,
360,
6664,
921,
4219,
1959,
2708,
360,
1624,
13,
24,
358,
272,
2963,
21268,
2042,
275,
747,
14,
515,
14,
904,
8,
4219,
2042,
12,
283,
10788,
297,
283,
1364,
14,
21382,
14,
84,
1086,
358,
272,
372,
747,
14,
515,
14,
2444,
8,
1932,
21268,
2042,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1680,
275,
488,
272,
340,
822,
8,
1274,
14,
3020,
9,
690,
413,
26,
1680,
275,
984,
14,
3020,
59,
17,
61,
272,
340,
1680,
508,
283,
18066,
356,
267,
5305,
342,
272,
587,
26,
267,
19420,
6589,
342,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
npiganeau/odoo
|
addons/l10n_multilang/__openerp__.py
|
339
|
1670
|
# -*- 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/>.
#
##############################################################################
{
'name': 'Multi Language Chart of Accounts',
'version': '1.1',
'author': 'OpenERP SA',
'category': 'Hidden/Dependency',
'description': """
* Multi language support for Chart of Accounts, Taxes, Tax Codes, Journals,
Accounting Templates, Analytic Chart of Accounts and Analytic Journals.
* Setup wizard changes
- Copy translations for COA, Tax, Tax Code and Fiscal Position from
templates to target objects.
""",
'website': 'http://www.openerp.com',
'depends' : ['account'],
'data': [],
'demo': [],
'installable': True,
'auto_install': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
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,
199,
3,
199,
4605,
199,
199,
91,
272,
283,
354,
356,
283,
3947,
8466,
24874,
402,
4473,
6851,
297,
272,
283,
1023,
356,
283,
17,
14,
17,
297,
272,
283,
2502,
356,
283,
25347,
13950,
297,
272,
283,
3710,
356,
283,
14983,
15,
14403,
297,
272,
283,
1802,
356,
408,
272,
627,
6879,
2637,
2291,
367,
24874,
402,
4473,
6851,
12,
377,
6402,
12,
30174,
5495,
83,
12,
7135,
31212,
12,
489,
9973,
316,
31273,
12,
14279,
764,
24874,
402,
4473,
6851,
436,
14279,
764,
7135,
31212,
14,
272,
627,
12439,
12262,
4493,
267,
446,
11247,
15547,
367,
5099,
33,
12,
30174,
12,
30174,
5495,
436,
481,
15734,
15483,
687,
881,
7009,
370,
1347,
2251,
14,
272,
10327,
272,
283,
7360,
356,
283,
1014,
921,
1544,
14,
11267,
14,
957,
297,
272,
283,
8912,
7,
520,
788,
2048,
995,
272,
283,
576,
356,
990,
272,
283,
8768,
356,
990,
272,
283,
21762,
356,
715,
12,
272,
283,
2495,
63,
3174,
356,
756,
12,
199,
93,
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
] |
[
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,
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,
199,
3,
199,
4605,
199,
199,
91,
272,
283,
354,
356,
283,
3947,
8466,
24874,
402,
4473,
6851,
297,
272,
283,
1023,
356,
283,
17,
14,
17,
297,
272,
283,
2502,
356,
283,
25347,
13950,
297,
272,
283,
3710,
356,
283,
14983,
15,
14403,
297,
272,
283,
1802,
356,
408,
272,
627,
6879,
2637,
2291,
367,
24874,
402,
4473,
6851,
12,
377,
6402,
12,
30174,
5495,
83,
12,
7135,
31212,
12,
489,
9973,
316,
31273,
12,
14279,
764,
24874,
402,
4473,
6851,
436,
14279,
764,
7135,
31212,
14,
272,
627,
12439,
12262,
4493,
267,
446,
11247,
15547,
367,
5099,
33,
12,
30174,
12,
30174,
5495,
436,
481,
15734,
15483,
687,
881,
7009,
370,
1347,
2251,
14,
272,
10327,
272,
283,
7360,
356,
283,
1014,
921,
1544,
14,
11267,
14,
957,
297,
272,
283,
8912,
7,
520,
788,
2048,
995,
272,
283,
576,
356,
990,
272,
283,
8768,
356,
990,
272,
283,
21762,
356,
715,
12,
272,
283,
2495,
63,
3174,
356,
756,
12,
199,
93,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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file FILE
# and verifies that the sum of the region-lengths matches the total
# length of the function.
#
# Based on a shell/awk script originally written by Harish Patil,
# which was converted to Perl by Matthew Chapman, which was converted
# to Python by David Mosberger.
#
import os
import re
import sys
if len(sys.argv) != 2:
print "Usage: %s FILE" % sys.argv[0]
sys.exit(2)
readelf = os.getenv("READELF", "readelf")
start_pattern = re.compile("<([^>]*)>: \[0x([0-9a-f]+)-0x([0-9a-f]+)\]")
rlen_pattern = re.compile(".*rlen=([0-9]+)")
def check_func (func, slots, rlen_sum):
if slots != rlen_sum:
global num_errors
num_errors += 1
if not func: func = "[%#x-%#x]" % (start, end)
print "ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum)
return
num_funcs = 0
num_errors = 0
func = False
slots = 0
rlen_sum = 0
for line in os.popen("%s -u %s" % (readelf, sys.argv[1])):
m = start_pattern.match(line)
if m:
check_func(func, slots, rlen_sum)
func = m.group(1)
start = long(m.group(2), 16)
end = long(m.group(3), 16)
slots = 3 * (end - start) / 16
rlen_sum = 0L
num_funcs += 1
else:
m = rlen_pattern.match(line)
if m:
rlen_sum += long(m.group(1))
check_func(func, slots, rlen_sum)
if num_errors == 0:
print "No errors detected in %u functions." % num_funcs
else:
if num_errors > 1:
err="errors"
else:
err="error"
print "%u %s detected in %u functions." % (num_errors, err, num_funcs)
sys.exit(1)
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
11028,
26,
625,
87,
1074,
14,
647,
13024,
199,
3,
199,
3,
961,
2884,
5920,
314,
625,
11530,
2256,
402,
1924,
805,
315,
570,
13024,
199,
3,
436,
22694,
626,
314,
3089,
402,
314,
4897,
13,
14563,
4450,
314,
3141,
199,
3,
2582,
402,
314,
805,
14,
199,
3,
199,
3,
21311,
641,
282,
5218,
15,
10084,
75,
2884,
20657,
5313,
701,
25378,
2453,
510,
2159,
76,
12,
199,
3,
1314,
1990,
6702,
370,
3492,
76,
701,
18619,
29640,
2799,
439,
1237,
12,
1314,
1990,
6702,
199,
3,
370,
2018,
701,
20232,
603,
736,
605,
836,
14,
199,
3,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
1137,
499,
26,
272,
870,
298,
7692,
26,
450,
83,
13024,
2,
450,
984,
14,
3020,
59,
16,
61,
272,
984,
14,
2224,
8,
18,
9,
199,
199,
8273,
271,
276,
275,
747,
14,
12959,
480,
24345,
4424,
38,
401,
298,
8273,
271,
276,
531,
199,
199,
928,
63,
3401,
275,
295,
14,
2014,
6757,
7059,
30,
3672,
13032,
26,
30257,
16,
88,
779,
16,
13,
25,
65,
13,
70,
2807,
7216,
16,
88,
779,
16,
13,
25,
65,
13,
70,
18096,
12523,
199,
82,
552,
63,
3401,
221,
275,
295,
14,
2014,
480,
2795,
82,
552,
30982,
16,
13,
25,
2807,
6320,
199,
199,
318,
1104,
63,
1532,
334,
1532,
12,
14319,
12,
24746,
63,
1838,
304,
272,
340,
14319,
1137,
24746,
63,
1838,
26,
267,
2288,
1967,
63,
2550,
267,
1967,
63,
2550,
847,
413,
267,
340,
440,
2562,
26,
2562,
275,
26503,
3,
88,
3295,
3,
88,
8480,
450,
334,
928,
12,
1284,
9,
267,
870,
298,
3170,
26,
450,
83,
26,
450,
10836,
14319,
12,
3141,
4897,
2582,
275,
450,
10836,
2,
450,
334,
1532,
12,
14319,
12,
24746,
63,
1838,
9,
272,
372,
199,
199,
1507,
63,
9204,
275,
378,
199,
1507,
63,
2550,
275,
378,
199,
1532,
275,
756,
199,
7257,
275,
378,
199,
82,
552,
63,
1838,
275,
378,
199,
509,
1004,
315,
747,
14,
12207,
3647,
83,
446,
85,
450,
83,
2,
450,
334,
8273,
271,
276,
12,
984,
14,
3020,
59,
17,
18710,
272,
333,
275,
1343,
63,
3401,
14,
1431,
8,
604,
9,
272,
340,
333,
26,
267,
1104,
63,
1532,
8,
1532,
12,
14319,
12,
24746,
63,
1838,
9,
398,
2562,
221,
275,
333,
14,
923,
8,
17,
9,
267,
1343,
275,
1846,
8,
77,
14,
923,
8,
18,
395,
3193,
9,
267,
1284,
257,
275,
1846,
8,
77,
14,
923,
8,
19,
395,
3193,
9,
267,
14319,
275,
650,
627,
334,
500,
446,
1343,
9,
1182,
3193,
267,
24746,
63,
1838,
275,
378,
44,
267,
1967,
63,
9204,
847,
413,
272,
587,
26,
267,
333,
275,
24746,
63,
3401,
14,
1431,
8,
604,
9,
267,
340,
333,
26,
288,
24746,
63,
1838,
847,
1846,
8,
77,
14,
923,
8,
17,
430,
199,
1074,
63,
1532,
8,
1532,
12,
14319,
12,
24746,
63,
1838,
9,
199,
199,
692,
1967,
63,
2550,
508,
378,
26,
272,
870,
298,
1944,
2552,
10501,
315,
450,
85,
3423,
2122,
450,
1967,
63,
9204,
199,
2836,
26,
272,
340,
1967,
63,
2550,
690,
413,
26,
267,
2329,
628,
2550,
2,
272,
587,
26,
267,
2329,
628,
705,
2,
272,
870,
2071,
85,
450,
83,
10501,
315,
450,
85,
3423,
2122,
450,
334,
1507,
63,
2550,
12,
2329,
12,
1967,
63,
9204,
9,
272,
984,
14,
2224,
8,
17,
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
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
11028,
26,
625,
87,
1074,
14,
647,
13024,
199,
3,
199,
3,
961,
2884,
5920,
314,
625,
11530,
2256,
402,
1924,
805,
315,
570,
13024,
199,
3,
436,
22694,
626,
314,
3089,
402,
314,
4897,
13,
14563,
4450,
314,
3141,
199,
3,
2582,
402,
314,
805,
14,
199,
3,
199,
3,
21311,
641,
282,
5218,
15,
10084,
75,
2884,
20657,
5313,
701,
25378,
2453,
510,
2159,
76,
12,
199,
3,
1314,
1990,
6702,
370,
3492,
76,
701,
18619,
29640,
2799,
439,
1237,
12,
1314,
1990,
6702,
199,
3,
370,
2018,
701,
20232,
603,
736,
605,
836,
14,
199,
3,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
1137,
499,
26,
272,
870,
298,
7692,
26,
450,
83,
13024,
2,
450,
984,
14,
3020,
59,
16,
61,
272,
984,
14,
2224,
8,
18,
9,
199,
199,
8273,
271,
276,
275,
747,
14,
12959,
480,
24345,
4424,
38,
401,
298,
8273,
271,
276,
531,
199,
199,
928,
63,
3401,
275,
295,
14,
2014,
6757,
7059,
30,
3672,
13032,
26,
30257,
16,
88,
779,
16,
13,
25,
65,
13,
70,
2807,
7216,
16,
88,
779,
16,
13,
25,
65,
13,
70,
18096,
12523,
199,
82,
552,
63,
3401,
221,
275,
295,
14,
2014,
480,
2795,
82,
552,
30982,
16,
13,
25,
2807,
6320,
199,
199,
318,
1104,
63,
1532,
334,
1532,
12,
14319,
12,
24746,
63,
1838,
304,
272,
340,
14319,
1137,
24746,
63,
1838,
26,
267,
2288,
1967,
63,
2550,
267,
1967,
63,
2550,
847,
413,
267,
340,
440,
2562,
26,
2562,
275,
26503,
3,
88,
3295,
3,
88,
8480,
450,
334,
928,
12,
1284,
9,
267,
870,
298,
3170,
26,
450,
83,
26,
450,
10836,
14319,
12,
3141,
4897,
2582,
275,
450,
10836,
2,
450,
334,
1532,
12,
14319,
12,
24746,
63,
1838,
9,
272,
372,
199,
199,
1507,
63,
9204,
275,
378,
199,
1507,
63,
2550,
275,
378,
199,
1532,
275,
756,
199,
7257,
275,
378,
199,
82,
552,
63,
1838,
275,
378,
199,
509,
1004,
315,
747,
14,
12207,
3647,
83,
446,
85,
450,
83,
2,
450,
334,
8273,
271,
276,
12,
984,
14,
3020,
59,
17,
18710,
272,
333,
275,
1343,
63,
3401,
14,
1431,
8,
604,
9,
272,
340,
333,
26,
267,
1104,
63,
1532,
8,
1532,
12,
14319,
12,
24746,
63,
1838,
9,
398,
2562,
221,
275,
333,
14,
923,
8,
17,
9,
267,
1343,
275,
1846,
8,
77,
14,
923,
8,
18,
395,
3193,
9,
267,
1284,
257,
275,
1846,
8,
77,
14,
923,
8,
19,
395,
3193,
9,
267,
14319,
275,
650,
627,
334,
500,
446,
1343,
9,
1182,
3193,
267,
24746,
63,
1838,
275,
378,
44,
267,
1967,
63,
9204,
847,
413,
272,
587,
26,
267,
333,
275,
24746,
63,
3401,
14,
1431,
8,
604,
9,
267,
340,
333,
26,
288,
24746,
63,
1838,
847,
1846,
8,
77,
14,
923,
8,
17,
430,
199,
1074,
63,
1532,
8,
1532,
12,
14319,
12,
24746,
63,
1838,
9,
199,
199,
692,
1967,
63,
2550,
508,
378,
26,
272,
870,
298,
1944,
2552,
10501,
315,
450,
85,
3423,
2122,
450,
1967,
63,
9204,
199,
2836,
26,
272,
340,
1967,
63,
2550,
690,
413,
26,
267,
2329,
628,
2550,
2,
272,
587,
26,
267,
2329,
628,
705,
2,
272,
870,
2071,
85,
450,
83,
10501,
315,
450,
85,
3423,
2122,
450,
334,
1507,
63,
2550,
12,
2329,
12,
1967,
63,
9204,
9,
272,
984,
14,
2224,
8,
17,
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,
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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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
GaZ3ll3/numba
|
condatestall.py
|
7
|
1112
|
"""
Uses conda to run and test all supported python + numpy versions.
"""
from __future__ import print_function
import itertools
import subprocess
import os
import sys
if '-q' in sys.argv[1:]:
NPY = '18',
else:
NPY = '16', '17', '18'
PY = '26', '27', '33'
RECIPE_DIR = "./buildscripts/condarecipe.local"
def main():
failfast = '-v' in sys.argv[1:]
args = "conda build %s --no-binstar-upload" % RECIPE_DIR
failures = []
for py, npy in itertools.product(PY, NPY):
if py == '33' and npy == '16':
# Skip python3 + numpy16
continue
os.environ['CONDA_PY'] = py
os.environ['CONDA_NPY'] = npy
try:
subprocess.check_call(args.split())
except subprocess.CalledProcessError as e:
failures.append((py, npy, e))
if failfast:
break
print("=" * 80)
if failures:
for py, npy, err in failures:
print("Test failed for python %s numpy %s" % (py, npy))
print(err)
else:
print("All Passed")
if __name__ == '__main__':
main()
|
bsd-2-clause
|
[
624,
199,
21896,
406,
983,
370,
1255,
436,
511,
1006,
3748,
2366,
435,
2680,
5459,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
646,
7975,
199,
646,
3873,
199,
646,
747,
199,
646,
984,
199,
199,
692,
2475,
81,
7,
315,
984,
14,
3020,
59,
17,
10688,
272,
653,
4521,
275,
283,
1085,
297,
199,
2836,
26,
272,
653,
4521,
275,
283,
975,
297,
283,
1196,
297,
283,
1085,
7,
199,
4521,
275,
283,
1479,
297,
283,
1465,
297,
283,
1153,
7,
199,
907,
3553,
1510,
63,
3022,
275,
26069,
1506,
6429,
15,
23463,
13191,
14,
1832,
2,
421,
199,
318,
2446,
837,
272,
1433,
20803,
275,
2475,
86,
7,
315,
984,
14,
3020,
59,
17,
2938,
339,
1249,
275,
298,
23463,
1900,
450,
83,
1553,
889,
13,
1393,
7848,
13,
5064,
2,
450,
5363,
3553,
1510,
63,
3022,
339,
9081,
275,
942,
272,
367,
1134,
12,
302,
647,
315,
7975,
14,
2558,
8,
4521,
12,
653,
4521,
304,
267,
340,
1134,
508,
283,
1153,
7,
436,
302,
647,
508,
283,
975,
356,
288,
327,
8232,
2366,
19,
435,
2680,
975,
288,
1980,
398,
747,
14,
2314,
459,
1864,
8980,
63,
4521,
418,
275,
1134,
267,
747,
14,
2314,
459,
1864,
8980,
63,
46,
4521,
418,
275,
302,
647,
398,
862,
26,
288,
3873,
14,
1074,
63,
1250,
8,
589,
14,
1294,
1012,
267,
871,
3873,
14,
24691,
465,
325,
26,
288,
9081,
14,
740,
1332,
647,
12,
302,
647,
12,
325,
430,
288,
340,
1433,
20803,
26,
355,
2059,
339,
870,
480,
628,
627,
5939,
9,
272,
340,
9081,
26,
267,
367,
1134,
12,
302,
647,
12,
2329,
315,
9081,
26,
288,
870,
480,
774,
3405,
367,
2366,
450,
83,
2680,
450,
83,
2,
450,
334,
647,
12,
302,
647,
430,
288,
870,
8,
1508,
9,
272,
587,
26,
267,
870,
480,
2422,
510,
2744,
531,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
21896,
406,
983,
370,
1255,
436,
511,
1006,
3748,
2366,
435,
2680,
5459,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
646,
7975,
199,
646,
3873,
199,
646,
747,
199,
646,
984,
199,
199,
692,
2475,
81,
7,
315,
984,
14,
3020,
59,
17,
10688,
272,
653,
4521,
275,
283,
1085,
297,
199,
2836,
26,
272,
653,
4521,
275,
283,
975,
297,
283,
1196,
297,
283,
1085,
7,
199,
4521,
275,
283,
1479,
297,
283,
1465,
297,
283,
1153,
7,
199,
907,
3553,
1510,
63,
3022,
275,
26069,
1506,
6429,
15,
23463,
13191,
14,
1832,
2,
421,
199,
318,
2446,
837,
272,
1433,
20803,
275,
2475,
86,
7,
315,
984,
14,
3020,
59,
17,
2938,
339,
1249,
275,
298,
23463,
1900,
450,
83,
1553,
889,
13,
1393,
7848,
13,
5064,
2,
450,
5363,
3553,
1510,
63,
3022,
339,
9081,
275,
942,
272,
367,
1134,
12,
302,
647,
315,
7975,
14,
2558,
8,
4521,
12,
653,
4521,
304,
267,
340,
1134,
508,
283,
1153,
7,
436,
302,
647,
508,
283,
975,
356,
288,
327,
8232,
2366,
19,
435,
2680,
975,
288,
1980,
398,
747,
14,
2314,
459,
1864,
8980,
63,
4521,
418,
275,
1134,
267,
747,
14,
2314,
459,
1864,
8980,
63,
46,
4521,
418,
275,
302,
647,
398,
862,
26,
288,
3873,
14,
1074,
63,
1250,
8,
589,
14,
1294,
1012,
267,
871,
3873,
14,
24691,
465,
325,
26,
288,
9081,
14,
740,
1332,
647,
12,
302,
647,
12,
325,
430,
288,
340,
1433,
20803,
26,
355,
2059,
339,
870,
480,
628,
627,
5939,
9,
272,
340,
9081,
26,
267,
367,
1134,
12,
302,
647,
12,
2329,
315,
9081,
26,
288,
870,
480,
774,
3405,
367,
2366,
450,
83,
2680,
450,
83,
2,
450,
334,
647,
12,
302,
647,
430,
288,
870,
8,
1508,
9,
272,
587,
26,
267,
870,
480,
2422,
510,
2744,
531,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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"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 migrate
import sqlalchemy
from sqlalchemy import (func, Index, inspect, orm, String, Table, type_coerce)
# The _upgrade...get_duplicate() def's are separate functions to
# accommodate sqlite which locks the database against updates as long as
# db_recs is active.
# In addition, sqlite doesn't support the function 'concat' between
# Strings and Integers, so, the updating of records is also adjusted.
def _upgrade_metadef_namespaces_get_duplicates(migrate_engine):
meta = sqlalchemy.schema.MetaData(migrate_engine)
metadef_namespaces = Table('metadef_namespaces', meta, autoload=True)
session = orm.sessionmaker(bind=migrate_engine)()
db_recs = (session.query(func.min(metadef_namespaces.c.id),
metadef_namespaces.c.namespace)
.group_by(metadef_namespaces.c.namespace)
.having(func.count(metadef_namespaces.c.namespace) > 1))
dbrecs = []
for row in db_recs:
dbrecs.append({'id': row[0], 'namespace': row[1]})
session.close()
return dbrecs
def _upgrade_metadef_objects_get_duplicates(migrate_engine):
meta = sqlalchemy.schema.MetaData(migrate_engine)
metadef_objects = Table('metadef_objects', meta, autoload=True)
session = orm.sessionmaker(bind=migrate_engine)()
db_recs = (session.query(func.min(metadef_objects.c.id),
metadef_objects.c.namespace_id,
metadef_objects.c.name)
.group_by(metadef_objects.c.namespace_id,
metadef_objects.c.name)
.having(func.count() > 1))
dbrecs = []
for row in db_recs:
dbrecs.append({'id': row[0], 'namespace_id': row[1], 'name': row[2]})
session.close()
return dbrecs
def _upgrade_metadef_properties_get_duplicates(migrate_engine):
meta = sqlalchemy.schema.MetaData(migrate_engine)
metadef_properties = Table('metadef_properties', meta, autoload=True)
session = orm.sessionmaker(bind=migrate_engine)()
db_recs = (session.query(func.min(metadef_properties.c.id),
metadef_properties.c.namespace_id,
metadef_properties.c.name)
.group_by(metadef_properties.c.namespace_id,
metadef_properties.c.name)
.having(func.count() > 1))
dbrecs = []
for row in db_recs:
dbrecs.append({'id': row[0], 'namespace_id': row[1], 'name': row[2]})
session.close()
return dbrecs
def _upgrade_metadef_tags_get_duplicates(migrate_engine):
meta = sqlalchemy.schema.MetaData(migrate_engine)
metadef_tags = Table('metadef_tags', meta, autoload=True)
session = orm.sessionmaker(bind=migrate_engine)()
db_recs = (session.query(func.min(metadef_tags.c.id),
metadef_tags.c.namespace_id,
metadef_tags.c.name)
.group_by(metadef_tags.c.namespace_id,
metadef_tags.c.name)
.having(func.count() > 1))
dbrecs = []
for row in db_recs:
dbrecs.append({'id': row[0], 'namespace_id': row[1], 'name': row[2]})
session.close()
return dbrecs
def _upgrade_metadef_resource_types_get_duplicates(migrate_engine):
meta = sqlalchemy.schema.MetaData(migrate_engine)
metadef_resource_types = Table('metadef_resource_types', meta,
autoload=True)
session = orm.sessionmaker(bind=migrate_engine)()
db_recs = (session.query(func.min(metadef_resource_types.c.id),
metadef_resource_types.c.name)
.group_by(metadef_resource_types.c.name)
.having(func.count(metadef_resource_types.c.name) > 1))
dbrecs = []
for row in db_recs:
dbrecs.append({'id': row[0], 'name': row[1]})
session.close()
return dbrecs
def _upgrade_data(migrate_engine):
# Rename duplicates to be unique.
meta = sqlalchemy.schema.MetaData(migrate_engine)
# ORM tables
metadef_namespaces = Table('metadef_namespaces', meta, autoload=True)
metadef_objects = Table('metadef_objects', meta, autoload=True)
metadef_properties = Table('metadef_properties', meta, autoload=True)
metadef_tags = Table('metadef_tags', meta, autoload=True)
metadef_resource_types = Table('metadef_resource_types', meta,
autoload=True)
# Fix duplicate metadef_namespaces
# Update the non-first record(s) with an unique namespace value
dbrecs = _upgrade_metadef_namespaces_get_duplicates(migrate_engine)
for row in dbrecs:
s = (metadef_namespaces.update()
.where(metadef_namespaces.c.id > row['id'])
.where(metadef_namespaces.c.namespace == row['namespace'])
)
if migrate_engine.name == 'sqlite':
s = (s.values(namespace=(row['namespace'] + '-DUPL-' +
type_coerce(metadef_namespaces.c.id,
String)),
display_name=(row['namespace'] + '-DUPL-' +
type_coerce(metadef_namespaces.c.id,
String))))
else:
s = s.values(namespace=func.concat(row['namespace'],
'-DUPL-',
metadef_namespaces.c.id),
display_name=func.concat(row['namespace'],
'-DUPL-',
metadef_namespaces.c.id))
s.execute()
# Fix duplicate metadef_objects
dbrecs = _upgrade_metadef_objects_get_duplicates(migrate_engine)
for row in dbrecs:
s = (metadef_objects.update()
.where(metadef_objects.c.id > row['id'])
.where(metadef_objects.c.namespace_id == row['namespace_id'])
.where(metadef_objects.c.name == str(row['name']))
)
if migrate_engine.name == 'sqlite':
s = (s.values(name=(row['name'] + '-DUPL-'
+ type_coerce(metadef_objects.c.id, String))))
else:
s = s.values(name=func.concat(row['name'], '-DUPL-',
metadef_objects.c.id))
s.execute()
# Fix duplicate metadef_properties
dbrecs = _upgrade_metadef_properties_get_duplicates(migrate_engine)
for row in dbrecs:
s = (metadef_properties.update()
.where(metadef_properties.c.id > row['id'])
.where(metadef_properties.c.namespace_id == row['namespace_id'])
.where(metadef_properties.c.name == str(row['name']))
)
if migrate_engine.name == 'sqlite':
s = (s.values(name=(row['name'] + '-DUPL-' +
type_coerce(metadef_properties.c.id, String)))
)
else:
s = s.values(name=func.concat(row['name'], '-DUPL-',
metadef_properties.c.id))
s.execute()
# Fix duplicate metadef_tags
dbrecs = _upgrade_metadef_tags_get_duplicates(migrate_engine)
for row in dbrecs:
s = (metadef_tags.update()
.where(metadef_tags.c.id > row['id'])
.where(metadef_tags.c.namespace_id == row['namespace_id'])
.where(metadef_tags.c.name == str(row['name']))
)
if migrate_engine.name == 'sqlite':
s = (s.values(name=(row['name'] + '-DUPL-' +
type_coerce(metadef_tags.c.id, String)))
)
else:
s = s.values(name=func.concat(row['name'], '-DUPL-',
metadef_tags.c.id))
s.execute()
# Fix duplicate metadef_resource_types
dbrecs = _upgrade_metadef_resource_types_get_duplicates(migrate_engine)
for row in dbrecs:
s = (metadef_resource_types.update()
.where(metadef_resource_types.c.id > row['id'])
.where(metadef_resource_types.c.name == str(row['name']))
)
if migrate_engine.name == 'sqlite':
s = (s.values(name=(row['name'] + '-DUPL-' +
type_coerce(metadef_resource_types.c.id,
String)))
)
else:
s = s.values(name=func.concat(row['name'], '-DUPL-',
metadef_resource_types.c.id))
s.execute()
def _update_sqlite_namespace_id_name_constraint(metadef, metadef_namespaces,
new_constraint_name,
new_fk_name):
migrate.UniqueConstraint(
metadef.c.namespace_id, metadef.c.name).drop()
migrate.UniqueConstraint(
metadef.c.namespace_id, metadef.c.name,
name=new_constraint_name).create()
migrate.ForeignKeyConstraint(
[metadef.c.namespace_id],
[metadef_namespaces.c.id],
name=new_fk_name).create()
def _downgrade_sqlite_namespace_id_name_constraint(metadef,
metadef_namespaces,
constraint_name,
fk_name):
migrate.UniqueConstraint(
metadef.c.namespace_id,
metadef.c.name,
name=constraint_name).drop()
migrate.UniqueConstraint(
metadef.c.namespace_id,
metadef.c.name).create()
migrate.ForeignKeyConstraint(
[metadef.c.namespace_id],
[metadef_namespaces.c.id],
name=fk_name).drop()
migrate.ForeignKeyConstraint(
[metadef.c.namespace_id],
[metadef_namespaces.c.id]).create()
def _drop_unique_constraint_if_exists(inspector, table_name, metadef):
name = _get_unique_constraint_name(inspector,
table_name,
['namespace_id', 'name'])
if name:
migrate.UniqueConstraint(metadef.c.namespace_id,
metadef.c.name,
name=name).drop()
def _drop_index_with_fk_constraint(metadef, metadef_namespaces,
index_name,
fk_old_name, fk_new_name):
fkc = migrate.ForeignKeyConstraint([metadef.c.namespace_id],
[metadef_namespaces.c.id],
name=fk_old_name)
fkc.drop()
if index_name:
Index(index_name, metadef.c.namespace_id).drop()
# Rename the fk for consistency across all db's
fkc = migrate.ForeignKeyConstraint([metadef.c.namespace_id],
[metadef_namespaces.c.id],
name=fk_new_name)
fkc.create()
def _downgrade_constraint_with_fk(metadef, metadef_namespaces,
constraint_name,
fk_curr_name, fk_next_name):
fkc = migrate.ForeignKeyConstraint([metadef.c.namespace_id],
[metadef_namespaces.c.id],
name=fk_curr_name)
fkc.drop()
migrate.UniqueConstraint(metadef.c.namespace_id, metadef.c.name,
name=constraint_name).drop()
fkc = migrate.ForeignKeyConstraint([metadef.c.namespace_id],
[metadef_namespaces.c.id],
name=fk_next_name)
fkc.create()
def _get_unique_constraint_name(inspector, table_name, columns):
constraints = inspector.get_unique_constraints(table_name)
for constraint in constraints:
if set(constraint['column_names']) == set(columns):
return constraint['name']
return None
def _get_fk_constraint_name(inspector, table_name, columns):
constraints = inspector.get_foreign_keys(table_name)
for constraint in constraints:
if set(constraint['constrained_columns']) == set(columns):
return constraint['name']
return None
def upgrade(migrate_engine):
_upgrade_data(migrate_engine)
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
inspector = inspect(migrate_engine)
# ORM tables
metadef_namespaces = Table('metadef_namespaces', meta, autoload=True)
metadef_objects = Table('metadef_objects', meta, autoload=True)
metadef_properties = Table('metadef_properties', meta, autoload=True)
metadef_tags = Table('metadef_tags', meta, autoload=True)
metadef_ns_res_types = Table('metadef_namespace_resource_types',
meta, autoload=True)
metadef_resource_types = Table('metadef_resource_types', meta,
autoload=True)
# Drop the bad, non-unique indices.
if migrate_engine.name == 'sqlite':
# For sqlite:
# Only after the unique constraints have been added should the indices
# be dropped. If done the other way, sqlite complains during
# constraint adding/dropping that the index does/does not exist.
# Note: The _get_unique_constraint_name, _get_fk_constraint_name
# return None for constraints that do in fact exist. Also,
# get_index_names returns names, but, the names can not be used with
# the Index(name, blah).drop() command, so, putting sqlite into
# it's own section.
# Objects
_update_sqlite_namespace_id_name_constraint(
metadef_objects, metadef_namespaces,
'uq_metadef_objects_namespace_id_name',
'metadef_objects_fk_1')
# Properties
_update_sqlite_namespace_id_name_constraint(
metadef_properties, metadef_namespaces,
'uq_metadef_properties_namespace_id_name',
'metadef_properties_fk_1')
# Tags
_update_sqlite_namespace_id_name_constraint(
metadef_tags, metadef_namespaces,
'uq_metadef_tags_namespace_id_name',
'metadef_tags_fk_1')
# Namespaces
migrate.UniqueConstraint(
metadef_namespaces.c.namespace).drop()
migrate.UniqueConstraint(
metadef_namespaces.c.namespace,
name='uq_metadef_namespaces_namespace').create()
# ResourceTypes
migrate.UniqueConstraint(
metadef_resource_types.c.name).drop()
migrate.UniqueConstraint(
metadef_resource_types.c.name,
name='uq_metadef_resource_types_name').create()
# Now drop the bad indices
Index('ix_metadef_objects_namespace_id',
metadef_objects.c.namespace_id,
metadef_objects.c.name).drop()
Index('ix_metadef_properties_namespace_id',
metadef_properties.c.namespace_id,
metadef_properties.c.name).drop()
Index('ix_metadef_tags_namespace_id',
metadef_tags.c.namespace_id,
metadef_tags.c.name).drop()
else:
# First drop the bad non-unique indices.
# To do that (for mysql), must first drop foreign key constraints
# BY NAME and then drop the bad indices.
# Finally, re-create the foreign key constraints with a consistent
# name.
# DB2 still has unique constraints, but, they are badly named.
# Drop them, they will be recreated at the final step.
name = _get_unique_constraint_name(inspector, 'metadef_namespaces',
['namespace'])
if name:
migrate.UniqueConstraint(metadef_namespaces.c.namespace,
name=name).drop()
_drop_unique_constraint_if_exists(inspector, 'metadef_objects',
metadef_objects)
_drop_unique_constraint_if_exists(inspector, 'metadef_properties',
metadef_properties)
_drop_unique_constraint_if_exists(inspector, 'metadef_tags',
metadef_tags)
name = _get_unique_constraint_name(inspector, 'metadef_resource_types',
['name'])
if name:
migrate.UniqueConstraint(metadef_resource_types.c.name,
name=name).drop()
# Objects
_drop_index_with_fk_constraint(
metadef_objects, metadef_namespaces,
'ix_metadef_objects_namespace_id',
_get_fk_constraint_name(
inspector, 'metadef_objects', ['namespace_id']),
'metadef_objects_fk_1')
# Properties
_drop_index_with_fk_constraint(
metadef_properties, metadef_namespaces,
'ix_metadef_properties_namespace_id',
_get_fk_constraint_name(
inspector, 'metadef_properties', ['namespace_id']),
'metadef_properties_fk_1')
# Tags
_drop_index_with_fk_constraint(
metadef_tags, metadef_namespaces,
'ix_metadef_tags_namespace_id',
_get_fk_constraint_name(
inspector, 'metadef_tags', ['namespace_id']),
'metadef_tags_fk_1')
# Drop Others without fk constraints.
Index('ix_metadef_namespaces_namespace',
metadef_namespaces.c.namespace).drop()
# The next two don't exist in ibm_db_sa, but, drop them everywhere else.
if migrate_engine.name != 'ibm_db_sa':
Index('ix_metadef_resource_types_name',
metadef_resource_types.c.name).drop()
# Not needed due to primary key on same columns
Index('ix_metadef_ns_res_types_res_type_id_ns_id',
metadef_ns_res_types.c.resource_type_id,
metadef_ns_res_types.c.namespace_id).drop()
# Now, add back the dropped indexes as unique constraints
if migrate_engine.name != 'sqlite':
# Namespaces
migrate.UniqueConstraint(
metadef_namespaces.c.namespace,
name='uq_metadef_namespaces_namespace').create()
# Objects
migrate.UniqueConstraint(
metadef_objects.c.namespace_id,
metadef_objects.c.name,
name='uq_metadef_objects_namespace_id_name').create()
# Properties
migrate.UniqueConstraint(
metadef_properties.c.namespace_id,
metadef_properties.c.name,
name='uq_metadef_properties_namespace_id_name').create()
# Tags
migrate.UniqueConstraint(
metadef_tags.c.namespace_id,
metadef_tags.c.name,
name='uq_metadef_tags_namespace_id_name').create()
# Resource Types
migrate.UniqueConstraint(
metadef_resource_types.c.name,
name='uq_metadef_resource_types_name').create()
def downgrade(migrate_engine):
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
# ORM tables
metadef_namespaces = Table('metadef_namespaces', meta, autoload=True)
metadef_objects = Table('metadef_objects', meta, autoload=True)
metadef_properties = Table('metadef_properties', meta, autoload=True)
metadef_tags = Table('metadef_tags', meta, autoload=True)
metadef_resource_types = Table('metadef_resource_types', meta,
autoload=True)
metadef_ns_res_types = Table('metadef_namespace_resource_types',
meta, autoload=True)
# Drop the unique constraints
if migrate_engine.name == 'sqlite':
# Objects
_downgrade_sqlite_namespace_id_name_constraint(
metadef_objects, metadef_namespaces,
'uq_metadef_objects_namespace_id_name',
'metadef_objects_fk_1')
# Properties
_downgrade_sqlite_namespace_id_name_constraint(
metadef_properties, metadef_namespaces,
'uq_metadef_properties_namespace_id_name',
'metadef_properties_fk_1')
# Tags
_downgrade_sqlite_namespace_id_name_constraint(
metadef_tags, metadef_namespaces,
'uq_metadef_tags_namespace_id_name',
'metadef_tags_fk_1')
# Namespaces
migrate.UniqueConstraint(
metadef_namespaces.c.namespace,
name='uq_metadef_namespaces_namespace').drop()
migrate.UniqueConstraint(
metadef_namespaces.c.namespace).create()
# ResourceTypes
migrate.UniqueConstraint(
metadef_resource_types.c.name,
name='uq_metadef_resource_types_name').drop()
migrate.UniqueConstraint(
metadef_resource_types.c.name).create()
else:
# For mysql, must drop foreign key constraints before dropping the
# unique constraint. So drop the fkc, then drop the constraints,
# then recreate the fkc.
# Objects
_downgrade_constraint_with_fk(
metadef_objects, metadef_namespaces,
'uq_metadef_objects_namespace_id_name',
'metadef_objects_fk_1', None)
# Properties
_downgrade_constraint_with_fk(
metadef_properties, metadef_namespaces,
'uq_metadef_properties_namespace_id_name',
'metadef_properties_fk_1', None)
# Tags
_downgrade_constraint_with_fk(
metadef_tags, metadef_namespaces,
'uq_metadef_tags_namespace_id_name',
'metadef_tags_fk_1', 'metadef_tags_namespace_id_fkey')
# Namespaces
migrate.UniqueConstraint(
metadef_namespaces.c.namespace,
name='uq_metadef_namespaces_namespace').drop()
# Resource_types
migrate.UniqueConstraint(
metadef_resource_types.c.name,
name='uq_metadef_resource_types_name').drop()
# Create dropped unique constraints as bad, non-unique indexes
Index('ix_metadef_objects_namespace_id',
metadef_objects.c.namespace_id).create()
Index('ix_metadef_properties_namespace_id',
metadef_properties.c.namespace_id).create()
# These need to be done before the metadef_tags and metadef_namespaces
# unique constraints are created to avoid 'tuple out of range' errors
# in db2.
Index('ix_metadef_tags_namespace_id',
metadef_tags.c.namespace_id,
metadef_tags.c.name).create()
Index('ix_metadef_namespaces_namespace',
metadef_namespaces.c.namespace).create()
# Create these everywhere, except for db2
if migrate_engine.name != 'ibm_db_sa':
Index('ix_metadef_resource_types_name',
metadef_resource_types.c.name).create()
Index('ix_metadef_ns_res_types_res_type_id_ns_id',
metadef_ns_res_types.c.resource_type_id,
metadef_ns_res_types.c.namespace_id).create()
else:
# Recreate the badly named unique constraints in db2
migrate.UniqueConstraint(
metadef_namespaces.c.namespace,
name='ix_namespaces_namespace').create()
migrate.UniqueConstraint(
metadef_objects.c.namespace_id,
metadef_objects.c.name,
name='ix_objects_namespace_id_name').create()
migrate.UniqueConstraint(
metadef_properties.c.namespace_id,
metadef_properties.c.name,
name='ix_metadef_properties_namespace_id_name').create()
migrate.UniqueConstraint(
metadef_tags.c.namespace_id,
metadef_tags.c.name).create()
migrate.UniqueConstraint(
metadef_resource_types.c.name,
name='ix_metadef_resource_types_name').create()
|
apache-2.0
|
[
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,
12810,
199,
646,
8335,
199,
504,
8335,
492,
334,
1532,
12,
5499,
12,
6485,
12,
9813,
12,
2624,
12,
6957,
12,
730,
63,
14141,
9,
421,
199,
3,
710,
485,
9375,
1396,
362,
63,
11081,
342,
347,
1159,
787,
7396,
3423,
370,
199,
3,
1066,
1404,
364,
323,
11723,
1314,
23340,
314,
3050,
6169,
7029,
465,
1846,
465,
199,
3,
1592,
63,
23587,
365,
4702,
14,
199,
3,
1010,
10234,
12,
11723,
3181,
1133,
2291,
314,
805,
283,
9419,
7,
3382,
199,
3,
24361,
436,
7225,
83,
12,
880,
12,
314,
12928,
402,
5767,
365,
2597,
19477,
14,
199,
318,
485,
9375,
63,
2024,
318,
63,
9247,
63,
362,
63,
18563,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
3629,
14,
25285,
8,
8462,
63,
3908,
9,
272,
3404,
318,
63,
9247,
275,
6957,
360,
2024,
318,
63,
9247,
297,
3404,
12,
2599,
912,
29,
549,
9,
339,
2351,
275,
9813,
14,
1730,
14367,
8,
3409,
29,
8462,
63,
3908,
16315,
272,
1592,
63,
23587,
275,
334,
1730,
14,
1131,
8,
1532,
14,
827,
8,
2024,
318,
63,
9247,
14,
67,
14,
344,
395,
2490,
3404,
318,
63,
9247,
14,
67,
14,
3251,
9,
2049,
1275,
923,
63,
991,
8,
2024,
318,
63,
9247,
14,
67,
14,
3251,
9,
2049,
1275,
31569,
8,
1532,
14,
835,
8,
2024,
318,
63,
9247,
14,
67,
14,
3251,
9,
690,
413,
430,
272,
1592,
23587,
275,
942,
272,
367,
1962,
315,
1592,
63,
23587,
26,
267,
1592,
23587,
14,
740,
3252,
344,
356,
1962,
59,
16,
467,
283,
3251,
356,
1962,
59,
17,
13412,
272,
2351,
14,
1600,
342,
339,
372,
1592,
23587,
421,
199,
318,
485,
9375,
63,
2024,
318,
63,
1462,
63,
362,
63,
18563,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
3629,
14,
25285,
8,
8462,
63,
3908,
9,
272,
3404,
318,
63,
1462,
275,
6957,
360,
2024,
318,
63,
1462,
297,
3404,
12,
2599,
912,
29,
549,
9,
339,
2351,
275,
9813,
14,
1730,
14367,
8,
3409,
29,
8462,
63,
3908,
16315,
272,
1592,
63,
23587,
275,
334,
1730,
14,
1131,
8,
1532,
14,
827,
8,
2024,
318,
63,
1462,
14,
67,
14,
344,
395,
2490,
3404,
318,
63,
1462,
14,
67,
14,
3251,
63,
344,
12,
2490,
3404,
318,
63,
1462,
14,
67,
14,
354,
9,
2049,
1275,
923,
63,
991,
8,
2024,
318,
63,
1462,
14,
67,
14,
3251,
63,
344,
12,
586,
3404,
318,
63,
1462,
14,
67,
14,
354,
9,
2049,
1275,
31569,
8,
1532,
14,
835,
342,
690,
413,
430,
272,
1592,
23587,
275,
942,
272,
367,
1962,
315,
1592,
63,
23587,
26,
267,
1592,
23587,
14,
740,
3252,
344,
356,
1962,
59,
16,
467,
283,
3251,
63,
344,
356,
1962,
59,
17,
467,
283,
354,
356,
1962,
59,
18,
13412,
272,
2351,
14,
1600,
342,
339,
372,
1592,
23587,
421,
199,
318,
485,
9375,
63,
2024,
318,
63,
3282,
63,
362,
63,
18563,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
3629,
14,
25285,
8,
8462,
63,
3908,
9,
272,
3404,
318,
63,
3282,
275,
6957,
360,
2024,
318,
63,
3282,
297,
3404,
12,
2599,
912,
29,
549,
9,
339,
2351,
275,
9813,
14,
1730,
14367,
8,
3409,
29,
8462,
63,
3908,
16315,
272,
1592,
63,
23587,
275,
334,
1730,
14,
1131,
8,
1532,
14,
827,
8,
2024,
318,
63,
3282,
14,
67,
14,
344,
395,
2490,
3404,
318,
63,
3282,
14,
67,
14,
3251,
63,
344,
12,
2490,
3404,
318,
63,
3282,
14,
67,
14,
354,
9,
2049,
1275,
923,
63,
991,
8,
2024,
318,
63,
3282,
14,
67,
14,
3251,
63,
344,
12,
586,
3404,
318,
63,
3282,
14,
67,
14,
354,
9,
2049,
1275,
31569,
8,
1532,
14,
835,
342,
690,
413,
430,
272,
1592,
23587,
275,
942,
272,
367,
1962,
315,
1592,
63,
23587,
26,
267,
1592,
23587,
14,
740,
3252,
344,
356,
1962,
59,
16,
467,
283,
3251,
63,
344,
356,
1962,
59,
17,
467,
283,
354,
356,
1962,
59,
18,
13412,
272,
2351,
14,
1600,
342,
339,
372,
1592,
23587,
421,
199,
318,
485,
9375,
63,
2024,
318,
63,
2969,
63,
362,
63,
18563,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
3629,
14,
25285,
8,
8462,
63,
3908,
9,
272,
3404,
318,
63,
2969,
275,
6957,
360,
2024,
318,
63,
2969,
297,
3404,
12,
2599,
912,
29,
549,
9,
339,
2351,
275,
9813,
14,
1730,
14367,
8,
3409,
29,
8462,
63,
3908,
16315,
272,
1592,
63,
23587,
275,
334,
1730,
14,
1131,
8,
1532,
14,
827,
8,
2024,
318,
63,
2969,
14,
67,
14,
344,
395,
2490,
3404,
318,
63,
2969,
14,
67,
14,
3251,
63,
344,
12,
2490,
3404,
318,
63,
2969,
14,
67,
14,
354,
9,
2049,
1275,
923,
63,
991,
8,
2024,
318,
63,
2969,
14,
67,
14,
3251,
63,
344,
12,
586,
3404,
318,
63,
2969,
14,
67,
14,
354,
9,
2049,
1275,
31569,
8,
1532,
14,
835,
342,
690,
413,
430,
272,
1592,
23587,
275,
942,
272,
367,
1962,
315,
1592,
63,
23587,
26,
267,
1592,
23587,
14,
740,
3252,
344,
356,
1962,
59,
16,
467,
283,
3251,
63,
344,
356,
1962,
59,
17,
467,
283,
354,
356,
1962,
59,
18,
13412,
272,
2351,
14,
1600,
342,
339,
372,
1592,
23587,
421,
199,
318,
485,
9375,
63,
2024,
318,
63,
1927,
63,
1313,
63,
362,
63
] |
[
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,
12810,
199,
646,
8335,
199,
504,
8335,
492,
334,
1532,
12,
5499,
12,
6485,
12,
9813,
12,
2624,
12,
6957,
12,
730,
63,
14141,
9,
421,
199,
3,
710,
485,
9375,
1396,
362,
63,
11081,
342,
347,
1159,
787,
7396,
3423,
370,
199,
3,
1066,
1404,
364,
323,
11723,
1314,
23340,
314,
3050,
6169,
7029,
465,
1846,
465,
199,
3,
1592,
63,
23587,
365,
4702,
14,
199,
3,
1010,
10234,
12,
11723,
3181,
1133,
2291,
314,
805,
283,
9419,
7,
3382,
199,
3,
24361,
436,
7225,
83,
12,
880,
12,
314,
12928,
402,
5767,
365,
2597,
19477,
14,
199,
318,
485,
9375,
63,
2024,
318,
63,
9247,
63,
362,
63,
18563,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
3629,
14,
25285,
8,
8462,
63,
3908,
9,
272,
3404,
318,
63,
9247,
275,
6957,
360,
2024,
318,
63,
9247,
297,
3404,
12,
2599,
912,
29,
549,
9,
339,
2351,
275,
9813,
14,
1730,
14367,
8,
3409,
29,
8462,
63,
3908,
16315,
272,
1592,
63,
23587,
275,
334,
1730,
14,
1131,
8,
1532,
14,
827,
8,
2024,
318,
63,
9247,
14,
67,
14,
344,
395,
2490,
3404,
318,
63,
9247,
14,
67,
14,
3251,
9,
2049,
1275,
923,
63,
991,
8,
2024,
318,
63,
9247,
14,
67,
14,
3251,
9,
2049,
1275,
31569,
8,
1532,
14,
835,
8,
2024,
318,
63,
9247,
14,
67,
14,
3251,
9,
690,
413,
430,
272,
1592,
23587,
275,
942,
272,
367,
1962,
315,
1592,
63,
23587,
26,
267,
1592,
23587,
14,
740,
3252,
344,
356,
1962,
59,
16,
467,
283,
3251,
356,
1962,
59,
17,
13412,
272,
2351,
14,
1600,
342,
339,
372,
1592,
23587,
421,
199,
318,
485,
9375,
63,
2024,
318,
63,
1462,
63,
362,
63,
18563,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
3629,
14,
25285,
8,
8462,
63,
3908,
9,
272,
3404,
318,
63,
1462,
275,
6957,
360,
2024,
318,
63,
1462,
297,
3404,
12,
2599,
912,
29,
549,
9,
339,
2351,
275,
9813,
14,
1730,
14367,
8,
3409,
29,
8462,
63,
3908,
16315,
272,
1592,
63,
23587,
275,
334,
1730,
14,
1131,
8,
1532,
14,
827,
8,
2024,
318,
63,
1462,
14,
67,
14,
344,
395,
2490,
3404,
318,
63,
1462,
14,
67,
14,
3251,
63,
344,
12,
2490,
3404,
318,
63,
1462,
14,
67,
14,
354,
9,
2049,
1275,
923,
63,
991,
8,
2024,
318,
63,
1462,
14,
67,
14,
3251,
63,
344,
12,
586,
3404,
318,
63,
1462,
14,
67,
14,
354,
9,
2049,
1275,
31569,
8,
1532,
14,
835,
342,
690,
413,
430,
272,
1592,
23587,
275,
942,
272,
367,
1962,
315,
1592,
63,
23587,
26,
267,
1592,
23587,
14,
740,
3252,
344,
356,
1962,
59,
16,
467,
283,
3251,
63,
344,
356,
1962,
59,
17,
467,
283,
354,
356,
1962,
59,
18,
13412,
272,
2351,
14,
1600,
342,
339,
372,
1592,
23587,
421,
199,
318,
485,
9375,
63,
2024,
318,
63,
3282,
63,
362,
63,
18563,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
3629,
14,
25285,
8,
8462,
63,
3908,
9,
272,
3404,
318,
63,
3282,
275,
6957,
360,
2024,
318,
63,
3282,
297,
3404,
12,
2599,
912,
29,
549,
9,
339,
2351,
275,
9813,
14,
1730,
14367,
8,
3409,
29,
8462,
63,
3908,
16315,
272,
1592,
63,
23587,
275,
334,
1730,
14,
1131,
8,
1532,
14,
827,
8,
2024,
318,
63,
3282,
14,
67,
14,
344,
395,
2490,
3404,
318,
63,
3282,
14,
67,
14,
3251,
63,
344,
12,
2490,
3404,
318,
63,
3282,
14,
67,
14,
354,
9,
2049,
1275,
923,
63,
991,
8,
2024,
318,
63,
3282,
14,
67,
14,
3251,
63,
344,
12,
586,
3404,
318,
63,
3282,
14,
67,
14,
354,
9,
2049,
1275,
31569,
8,
1532,
14,
835,
342,
690,
413,
430,
272,
1592,
23587,
275,
942,
272,
367,
1962,
315,
1592,
63,
23587,
26,
267,
1592,
23587,
14,
740,
3252,
344,
356,
1962,
59,
16,
467,
283,
3251,
63,
344,
356,
1962,
59,
17,
467,
283,
354,
356,
1962,
59,
18,
13412,
272,
2351,
14,
1600,
342,
339,
372,
1592,
23587,
421,
199,
318,
485,
9375,
63,
2024,
318,
63,
2969,
63,
362,
63,
18563,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
3629,
14,
25285,
8,
8462,
63,
3908,
9,
272,
3404,
318,
63,
2969,
275,
6957,
360,
2024,
318,
63,
2969,
297,
3404,
12,
2599,
912,
29,
549,
9,
339,
2351,
275,
9813,
14,
1730,
14367,
8,
3409,
29,
8462,
63,
3908,
16315,
272,
1592,
63,
23587,
275,
334,
1730,
14,
1131,
8,
1532,
14,
827,
8,
2024,
318,
63,
2969,
14,
67,
14,
344,
395,
2490,
3404,
318,
63,
2969,
14,
67,
14,
3251,
63,
344,
12,
2490,
3404,
318,
63,
2969,
14,
67,
14,
354,
9,
2049,
1275,
923,
63,
991,
8,
2024,
318,
63,
2969,
14,
67,
14,
3251,
63,
344,
12,
586,
3404,
318,
63,
2969,
14,
67,
14,
354,
9,
2049,
1275,
31569,
8,
1532,
14,
835,
342,
690,
413,
430,
272,
1592,
23587,
275,
942,
272,
367,
1962,
315,
1592,
63,
23587,
26,
267,
1592,
23587,
14,
740,
3252,
344,
356,
1962,
59,
16,
467,
283,
3251,
63,
344,
356,
1962,
59,
17,
467,
283,
354,
356,
1962,
59,
18,
13412,
272,
2351,
14,
1600,
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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
] |
BeegorMif/HTPC-Manager
|
lib/unidecode/x06d.py
|
252
|
4651
|
data = (
'Zhou ', # 0x00
'Ji ', # 0x01
'Yi ', # 0x02
'Hui ', # 0x03
'Hui ', # 0x04
'Zui ', # 0x05
'Cheng ', # 0x06
'Yin ', # 0x07
'Wei ', # 0x08
'Hou ', # 0x09
'Jian ', # 0x0a
'Yang ', # 0x0b
'Lie ', # 0x0c
'Si ', # 0x0d
'Ji ', # 0x0e
'Er ', # 0x0f
'Xing ', # 0x10
'Fu ', # 0x11
'Sa ', # 0x12
'Suo ', # 0x13
'Zhi ', # 0x14
'Yin ', # 0x15
'Wu ', # 0x16
'Xi ', # 0x17
'Kao ', # 0x18
'Zhu ', # 0x19
'Jiang ', # 0x1a
'Luo ', # 0x1b
'[?] ', # 0x1c
'An ', # 0x1d
'Dong ', # 0x1e
'Yi ', # 0x1f
'Mou ', # 0x20
'Lei ', # 0x21
'Yi ', # 0x22
'Mi ', # 0x23
'Quan ', # 0x24
'Jin ', # 0x25
'Mo ', # 0x26
'Wei ', # 0x27
'Xiao ', # 0x28
'Xie ', # 0x29
'Hong ', # 0x2a
'Xu ', # 0x2b
'Shuo ', # 0x2c
'Kuang ', # 0x2d
'Tao ', # 0x2e
'Qie ', # 0x2f
'Ju ', # 0x30
'Er ', # 0x31
'Zhou ', # 0x32
'Ru ', # 0x33
'Ping ', # 0x34
'Xun ', # 0x35
'Xiong ', # 0x36
'Zhi ', # 0x37
'Guang ', # 0x38
'Huan ', # 0x39
'Ming ', # 0x3a
'Huo ', # 0x3b
'Wa ', # 0x3c
'Qia ', # 0x3d
'Pai ', # 0x3e
'Wu ', # 0x3f
'Qu ', # 0x40
'Liu ', # 0x41
'Yi ', # 0x42
'Jia ', # 0x43
'Jing ', # 0x44
'Qian ', # 0x45
'Jiang ', # 0x46
'Jiao ', # 0x47
'Cheng ', # 0x48
'Shi ', # 0x49
'Zhuo ', # 0x4a
'Ce ', # 0x4b
'Pal ', # 0x4c
'Kuai ', # 0x4d
'Ji ', # 0x4e
'Liu ', # 0x4f
'Chan ', # 0x50
'Hun ', # 0x51
'Hu ', # 0x52
'Nong ', # 0x53
'Xun ', # 0x54
'Jin ', # 0x55
'Lie ', # 0x56
'Qiu ', # 0x57
'Wei ', # 0x58
'Zhe ', # 0x59
'Jun ', # 0x5a
'Han ', # 0x5b
'Bang ', # 0x5c
'Mang ', # 0x5d
'Zhuo ', # 0x5e
'You ', # 0x5f
'Xi ', # 0x60
'Bo ', # 0x61
'Dou ', # 0x62
'Wan ', # 0x63
'Hong ', # 0x64
'Yi ', # 0x65
'Pu ', # 0x66
'Ying ', # 0x67
'Lan ', # 0x68
'Hao ', # 0x69
'Lang ', # 0x6a
'Han ', # 0x6b
'Li ', # 0x6c
'Geng ', # 0x6d
'Fu ', # 0x6e
'Wu ', # 0x6f
'Lian ', # 0x70
'Chun ', # 0x71
'Feng ', # 0x72
'Yi ', # 0x73
'Yu ', # 0x74
'Tong ', # 0x75
'Lao ', # 0x76
'Hai ', # 0x77
'Jin ', # 0x78
'Jia ', # 0x79
'Chong ', # 0x7a
'Weng ', # 0x7b
'Mei ', # 0x7c
'Sui ', # 0x7d
'Cheng ', # 0x7e
'Pei ', # 0x7f
'Xian ', # 0x80
'Shen ', # 0x81
'Tu ', # 0x82
'Kun ', # 0x83
'Pin ', # 0x84
'Nie ', # 0x85
'Han ', # 0x86
'Jing ', # 0x87
'Xiao ', # 0x88
'She ', # 0x89
'Nian ', # 0x8a
'Tu ', # 0x8b
'Yong ', # 0x8c
'Xiao ', # 0x8d
'Xian ', # 0x8e
'Ting ', # 0x8f
'E ', # 0x90
'Su ', # 0x91
'Tun ', # 0x92
'Juan ', # 0x93
'Cen ', # 0x94
'Ti ', # 0x95
'Li ', # 0x96
'Shui ', # 0x97
'Si ', # 0x98
'Lei ', # 0x99
'Shui ', # 0x9a
'Tao ', # 0x9b
'Du ', # 0x9c
'Lao ', # 0x9d
'Lai ', # 0x9e
'Lian ', # 0x9f
'Wei ', # 0xa0
'Wo ', # 0xa1
'Yun ', # 0xa2
'Huan ', # 0xa3
'Di ', # 0xa4
'[?] ', # 0xa5
'Run ', # 0xa6
'Jian ', # 0xa7
'Zhang ', # 0xa8
'Se ', # 0xa9
'Fu ', # 0xaa
'Guan ', # 0xab
'Xing ', # 0xac
'Shou ', # 0xad
'Shuan ', # 0xae
'Ya ', # 0xaf
'Chuo ', # 0xb0
'Zhang ', # 0xb1
'Ye ', # 0xb2
'Kong ', # 0xb3
'Wo ', # 0xb4
'Han ', # 0xb5
'Tuo ', # 0xb6
'Dong ', # 0xb7
'He ', # 0xb8
'Wo ', # 0xb9
'Ju ', # 0xba
'Gan ', # 0xbb
'Liang ', # 0xbc
'Hun ', # 0xbd
'Ta ', # 0xbe
'Zhuo ', # 0xbf
'Dian ', # 0xc0
'Qie ', # 0xc1
'De ', # 0xc2
'Juan ', # 0xc3
'Zi ', # 0xc4
'Xi ', # 0xc5
'Yao ', # 0xc6
'Qi ', # 0xc7
'Gu ', # 0xc8
'Guo ', # 0xc9
'Han ', # 0xca
'Lin ', # 0xcb
'Tang ', # 0xcc
'Zhou ', # 0xcd
'Peng ', # 0xce
'Hao ', # 0xcf
'Chang ', # 0xd0
'Shu ', # 0xd1
'Qi ', # 0xd2
'Fang ', # 0xd3
'Chi ', # 0xd4
'Lu ', # 0xd5
'Nao ', # 0xd6
'Ju ', # 0xd7
'Tao ', # 0xd8
'Cong ', # 0xd9
'Lei ', # 0xda
'Zhi ', # 0xdb
'Peng ', # 0xdc
'Fei ', # 0xdd
'Song ', # 0xde
'Tian ', # 0xdf
'Pi ', # 0xe0
'Dan ', # 0xe1
'Yu ', # 0xe2
'Ni ', # 0xe3
'Yu ', # 0xe4
'Lu ', # 0xe5
'Gan ', # 0xe6
'Mi ', # 0xe7
'Jing ', # 0xe8
'Ling ', # 0xe9
'Lun ', # 0xea
'Yin ', # 0xeb
'Cui ', # 0xec
'Qu ', # 0xed
'Huai ', # 0xee
'Yu ', # 0xef
'Nian ', # 0xf0
'Shen ', # 0xf1
'Piao ', # 0xf2
'Chun ', # 0xf3
'Wa ', # 0xf4
'Yuan ', # 0xf5
'Lai ', # 0xf6
'Hun ', # 0xf7
'Qing ', # 0xf8
'Yan ', # 0xf9
'Qian ', # 0xfa
'Tian ', # 0xfb
'Miao ', # 0xfc
'Zhi ', # 0xfd
'Yin ', # 0xfe
'Mi ', # 0xff
)
|
gpl-3.0
|
[
576,
275,
334,
199,
7,
58,
11586,
1656,
259,
327,
378,
88,
383,
199,
7,
16911,
1656,
259,
327,
378,
88,
614,
199,
7,
21001,
1656,
259,
327,
378,
88,
996,
199,
7,
40,
1907,
1656,
259,
327,
378,
88,
1644,
199,
7,
40,
1907,
1656,
259,
327,
378,
88,
966,
199,
7,
58,
1907,
1656,
259,
327,
378,
88,
1717,
199,
7,
1049,
7420,
1656,
259,
327,
378,
88,
1690,
199,
7,
57,
262,
1656,
259,
327,
378,
88,
1780,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
2036,
199,
7,
24386,
1656,
259,
327,
378,
88,
1643,
199,
7,
42,
5653,
1656,
259,
327,
378,
88,
16,
65,
199,
7,
57,
621,
1656,
259,
327,
378,
88,
16,
66,
199,
7,
44,
1873,
1656,
259,
327,
378,
88,
16,
67,
199,
7,
18934,
1656,
259,
327,
378,
88,
16,
68,
199,
7,
16911,
1656,
259,
327,
378,
88,
16,
69,
199,
7,
539,
1656,
259,
327,
378,
88,
16,
70,
199,
7,
56,
316,
1656,
259,
327,
378,
88,
709,
199,
7,
19590,
1656,
259,
327,
378,
88,
845,
199,
7,
12226,
1656,
259,
327,
378,
88,
713,
199,
7,
51,
13780,
1656,
259,
327,
378,
88,
969,
199,
7,
58,
5812,
1656,
259,
327,
378,
88,
1079,
199,
7,
57,
262,
1656,
259,
327,
378,
88,
1046,
199,
7,
25728,
1656,
259,
327,
378,
88,
975,
199,
7,
14828,
1656,
259,
327,
378,
88,
1196,
199,
7,
43,
8035,
1656,
259,
327,
378,
88,
1085,
199,
7,
31183,
1656,
259,
327,
378,
88,
1167,
199,
7,
16911,
621,
1656,
259,
327,
378,
88,
17,
65,
199,
7,
44,
13780,
1656,
259,
327,
378,
88,
17,
66,
199,
17892,
1656,
259,
327,
378,
88,
17,
67,
199,
7,
2493,
1656,
259,
327,
378,
88,
17,
68,
199,
7,
36,
951,
1656,
259,
327,
378,
88,
17,
69,
199,
7,
21001,
1656,
259,
327,
378,
88,
17,
70,
199,
7,
45,
810,
1656,
259,
327,
378,
88,
1165,
199,
7,
2553,
73,
1656,
259,
327,
378,
88,
2025,
199,
7,
21001,
1656,
259,
327,
378,
88,
1081,
199,
7,
14738,
1656,
259,
327,
378,
88,
1789,
199,
7,
2371,
290,
1656,
259,
327,
378,
88,
1194,
199,
7,
42,
262,
1656,
259,
327,
378,
88,
821,
199,
7,
3716,
1656,
259,
327,
378,
88,
1479,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
1465,
199,
7,
56,
18939,
1656,
259,
327,
378,
88,
1651,
199,
7,
56,
1873,
1656,
259,
327,
378,
88,
1398,
199,
7,
40,
951,
1656,
259,
327,
378,
88,
18,
65,
199,
7,
56,
85,
1656,
259,
327,
378,
88,
18,
66,
199,
7,
2662,
13780,
1656,
259,
327,
378,
88,
18,
67,
199,
7,
31487,
621,
1656,
259,
327,
378,
88,
18,
68,
199,
7,
52,
8035,
1656,
259,
327,
378,
88,
18,
69,
199,
7,
49,
1873,
1656,
259,
327,
378,
88,
18,
70,
199,
7,
24783,
1656,
259,
327,
378,
88,
1216,
199,
7,
539,
1656,
259,
327,
378,
88,
2192,
199,
7,
58,
11586,
1656,
259,
327,
378,
88,
708,
199,
7,
50,
85,
1656,
259,
327,
378,
88,
1153,
199,
7,
22638,
1656,
259,
327,
378,
88,
1082,
199,
7,
56,
324,
1656,
259,
327,
378,
88,
1276,
199,
7,
14828,
951,
1656,
259,
327,
378,
88,
1344,
199,
7,
58,
5812,
1656,
259,
327,
378,
88,
1401,
199,
7,
11548,
621,
1656,
259,
327,
378,
88,
1703,
199,
7,
40,
7856,
1656,
259,
327,
378,
88,
1355,
199,
7,
45,
316,
1656,
259,
327,
378,
88,
19,
65,
199,
7,
40,
13780,
1656,
259,
327,
378,
88,
19,
66,
199,
7,
24804,
1656,
259,
327,
378,
88,
19,
67,
199,
7,
49,
4674,
1656,
259,
327,
378,
88,
19,
68,
199,
7,
4232,
73,
1656,
259,
327,
378,
88,
19,
69,
199,
7,
25728,
1656,
259,
327,
378,
88,
19,
70,
199,
7,
2371,
1656,
259,
327,
378,
88,
2167,
199,
7,
13009,
85,
1656,
259,
327,
378,
88,
2953,
199,
7,
21001,
1656,
259,
327,
378,
88,
2260,
199,
7,
42,
4674,
1656,
259,
327,
378,
88,
2824,
199,
7,
42,
316,
1656,
259,
327,
378,
88,
1602,
199,
7,
49,
5653,
1656,
259,
327,
378,
88,
2322,
199,
7,
16911,
621,
1656,
259,
327,
378,
88,
2466,
199,
7,
42,
18939,
1656,
259,
327,
378,
88,
2417,
199,
7,
1049,
7420,
1656,
259,
327,
378,
88,
2006,
199,
7,
2662,
73,
1656,
259,
327,
378,
88,
1887,
199,
7,
31183,
79,
1656,
259,
327,
378,
88,
20,
65,
199,
7,
24417,
1656,
259,
327,
378,
88,
20,
66,
199,
7,
24666,
1656,
259,
327,
378,
88,
20,
67,
199,
7,
43,
1458,
73,
1656,
259,
327,
378,
88,
20,
68,
199,
7,
16911,
1656,
259,
327,
378,
88,
20,
69,
199,
7,
13009,
85,
1656,
259,
327,
378,
88,
20,
70,
199,
7,
27039,
1656,
259,
327,
378,
88,
1400,
199,
7,
40,
324,
1656,
259,
327,
378,
88,
2869,
199,
7,
25542,
1656,
259,
327,
378,
88,
2528,
199,
7,
46,
951,
1656,
259,
327,
378,
88,
2481,
199,
7,
56,
324,
1656,
259,
327,
378,
88,
1477,
199,
7,
42,
262,
1656,
259,
327,
378,
88,
1229,
199,
7,
44,
1873,
1656,
259,
327,
378,
88,
1367,
199,
7,
19910,
85,
1656,
259,
327,
378,
88,
1641,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
2010,
199,
7,
58,
426,
1656,
259,
327,
378,
88,
1427,
199,
7,
42,
324,
1656,
259,
327,
378,
88,
21,
65,
199,
7,
40,
290,
1656,
259,
327,
378,
88,
21,
66,
199,
7,
34,
621,
1656,
259,
327,
378,
88,
21,
67,
199,
7,
45,
621,
1656,
259,
327,
378,
88,
21,
68,
199,
7,
31183,
79,
1656,
259,
327,
378,
88,
21,
69,
199,
7,
5556,
1656,
259,
327,
378,
88,
21,
70,
199,
7,
14828,
1656,
259,
327,
378,
88,
2259,
199,
7,
2208,
1656,
259,
327,
378,
88,
2976,
199,
7,
36,
810,
1656,
259,
327,
378,
88,
2789,
199,
7,
55,
290,
1656,
259,
327,
378,
88,
2766,
199,
7,
40,
951,
1656,
259,
327,
378,
88,
772,
199,
7,
21001,
1656,
259,
327,
378
] |
[
275,
334,
199,
7,
58,
11586,
1656,
259,
327,
378,
88,
383,
199,
7,
16911,
1656,
259,
327,
378,
88,
614,
199,
7,
21001,
1656,
259,
327,
378,
88,
996,
199,
7,
40,
1907,
1656,
259,
327,
378,
88,
1644,
199,
7,
40,
1907,
1656,
259,
327,
378,
88,
966,
199,
7,
58,
1907,
1656,
259,
327,
378,
88,
1717,
199,
7,
1049,
7420,
1656,
259,
327,
378,
88,
1690,
199,
7,
57,
262,
1656,
259,
327,
378,
88,
1780,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
2036,
199,
7,
24386,
1656,
259,
327,
378,
88,
1643,
199,
7,
42,
5653,
1656,
259,
327,
378,
88,
16,
65,
199,
7,
57,
621,
1656,
259,
327,
378,
88,
16,
66,
199,
7,
44,
1873,
1656,
259,
327,
378,
88,
16,
67,
199,
7,
18934,
1656,
259,
327,
378,
88,
16,
68,
199,
7,
16911,
1656,
259,
327,
378,
88,
16,
69,
199,
7,
539,
1656,
259,
327,
378,
88,
16,
70,
199,
7,
56,
316,
1656,
259,
327,
378,
88,
709,
199,
7,
19590,
1656,
259,
327,
378,
88,
845,
199,
7,
12226,
1656,
259,
327,
378,
88,
713,
199,
7,
51,
13780,
1656,
259,
327,
378,
88,
969,
199,
7,
58,
5812,
1656,
259,
327,
378,
88,
1079,
199,
7,
57,
262,
1656,
259,
327,
378,
88,
1046,
199,
7,
25728,
1656,
259,
327,
378,
88,
975,
199,
7,
14828,
1656,
259,
327,
378,
88,
1196,
199,
7,
43,
8035,
1656,
259,
327,
378,
88,
1085,
199,
7,
31183,
1656,
259,
327,
378,
88,
1167,
199,
7,
16911,
621,
1656,
259,
327,
378,
88,
17,
65,
199,
7,
44,
13780,
1656,
259,
327,
378,
88,
17,
66,
199,
17892,
1656,
259,
327,
378,
88,
17,
67,
199,
7,
2493,
1656,
259,
327,
378,
88,
17,
68,
199,
7,
36,
951,
1656,
259,
327,
378,
88,
17,
69,
199,
7,
21001,
1656,
259,
327,
378,
88,
17,
70,
199,
7,
45,
810,
1656,
259,
327,
378,
88,
1165,
199,
7,
2553,
73,
1656,
259,
327,
378,
88,
2025,
199,
7,
21001,
1656,
259,
327,
378,
88,
1081,
199,
7,
14738,
1656,
259,
327,
378,
88,
1789,
199,
7,
2371,
290,
1656,
259,
327,
378,
88,
1194,
199,
7,
42,
262,
1656,
259,
327,
378,
88,
821,
199,
7,
3716,
1656,
259,
327,
378,
88,
1479,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
1465,
199,
7,
56,
18939,
1656,
259,
327,
378,
88,
1651,
199,
7,
56,
1873,
1656,
259,
327,
378,
88,
1398,
199,
7,
40,
951,
1656,
259,
327,
378,
88,
18,
65,
199,
7,
56,
85,
1656,
259,
327,
378,
88,
18,
66,
199,
7,
2662,
13780,
1656,
259,
327,
378,
88,
18,
67,
199,
7,
31487,
621,
1656,
259,
327,
378,
88,
18,
68,
199,
7,
52,
8035,
1656,
259,
327,
378,
88,
18,
69,
199,
7,
49,
1873,
1656,
259,
327,
378,
88,
18,
70,
199,
7,
24783,
1656,
259,
327,
378,
88,
1216,
199,
7,
539,
1656,
259,
327,
378,
88,
2192,
199,
7,
58,
11586,
1656,
259,
327,
378,
88,
708,
199,
7,
50,
85,
1656,
259,
327,
378,
88,
1153,
199,
7,
22638,
1656,
259,
327,
378,
88,
1082,
199,
7,
56,
324,
1656,
259,
327,
378,
88,
1276,
199,
7,
14828,
951,
1656,
259,
327,
378,
88,
1344,
199,
7,
58,
5812,
1656,
259,
327,
378,
88,
1401,
199,
7,
11548,
621,
1656,
259,
327,
378,
88,
1703,
199,
7,
40,
7856,
1656,
259,
327,
378,
88,
1355,
199,
7,
45,
316,
1656,
259,
327,
378,
88,
19,
65,
199,
7,
40,
13780,
1656,
259,
327,
378,
88,
19,
66,
199,
7,
24804,
1656,
259,
327,
378,
88,
19,
67,
199,
7,
49,
4674,
1656,
259,
327,
378,
88,
19,
68,
199,
7,
4232,
73,
1656,
259,
327,
378,
88,
19,
69,
199,
7,
25728,
1656,
259,
327,
378,
88,
19,
70,
199,
7,
2371,
1656,
259,
327,
378,
88,
2167,
199,
7,
13009,
85,
1656,
259,
327,
378,
88,
2953,
199,
7,
21001,
1656,
259,
327,
378,
88,
2260,
199,
7,
42,
4674,
1656,
259,
327,
378,
88,
2824,
199,
7,
42,
316,
1656,
259,
327,
378,
88,
1602,
199,
7,
49,
5653,
1656,
259,
327,
378,
88,
2322,
199,
7,
16911,
621,
1656,
259,
327,
378,
88,
2466,
199,
7,
42,
18939,
1656,
259,
327,
378,
88,
2417,
199,
7,
1049,
7420,
1656,
259,
327,
378,
88,
2006,
199,
7,
2662,
73,
1656,
259,
327,
378,
88,
1887,
199,
7,
31183,
79,
1656,
259,
327,
378,
88,
20,
65,
199,
7,
24417,
1656,
259,
327,
378,
88,
20,
66,
199,
7,
24666,
1656,
259,
327,
378,
88,
20,
67,
199,
7,
43,
1458,
73,
1656,
259,
327,
378,
88,
20,
68,
199,
7,
16911,
1656,
259,
327,
378,
88,
20,
69,
199,
7,
13009,
85,
1656,
259,
327,
378,
88,
20,
70,
199,
7,
27039,
1656,
259,
327,
378,
88,
1400,
199,
7,
40,
324,
1656,
259,
327,
378,
88,
2869,
199,
7,
25542,
1656,
259,
327,
378,
88,
2528,
199,
7,
46,
951,
1656,
259,
327,
378,
88,
2481,
199,
7,
56,
324,
1656,
259,
327,
378,
88,
1477,
199,
7,
42,
262,
1656,
259,
327,
378,
88,
1229,
199,
7,
44,
1873,
1656,
259,
327,
378,
88,
1367,
199,
7,
19910,
85,
1656,
259,
327,
378,
88,
1641,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
2010,
199,
7,
58,
426,
1656,
259,
327,
378,
88,
1427,
199,
7,
42,
324,
1656,
259,
327,
378,
88,
21,
65,
199,
7,
40,
290,
1656,
259,
327,
378,
88,
21,
66,
199,
7,
34,
621,
1656,
259,
327,
378,
88,
21,
67,
199,
7,
45,
621,
1656,
259,
327,
378,
88,
21,
68,
199,
7,
31183,
79,
1656,
259,
327,
378,
88,
21,
69,
199,
7,
5556,
1656,
259,
327,
378,
88,
21,
70,
199,
7,
14828,
1656,
259,
327,
378,
88,
2259,
199,
7,
2208,
1656,
259,
327,
378,
88,
2976,
199,
7,
36,
810,
1656,
259,
327,
378,
88,
2789,
199,
7,
55,
290,
1656,
259,
327,
378,
88,
2766,
199,
7,
40,
951,
1656,
259,
327,
378,
88,
772,
199,
7,
21001,
1656,
259,
327,
378,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
linjoahow/w17test_1
|
static/Brython3.1.0-20150301-090019/Lib/test/re_tests.py
|
879
|
31796
|
#!/usr/bin/env python3
# -*- mode: python -*-
# Re test suite and benchmark suite v1.5
# The 3 possible outcomes for each pattern
[SUCCEED, FAIL, SYNTAX_ERROR] = range(3)
# Benchmark suite (needs expansion)
#
# The benchmark suite does not test correctness, just speed. The
# first element of each tuple is the regex pattern; the second is a
# string to match it against. The benchmarking code will embed the
# second string inside several sizes of padding, to test how regex
# matching performs on large strings.
benchmarks = [
# test common prefix
('Python|Perl', 'Perl'), # Alternation
('(Python|Perl)', 'Perl'), # Grouped alternation
('Python|Perl|Tcl', 'Perl'), # Alternation
('(Python|Perl|Tcl)', 'Perl'), # Grouped alternation
('(Python)\\1', 'PythonPython'), # Backreference
('([0a-z][a-z0-9]*,)+', 'a5,b7,c9,'), # Disable the fastmap optimization
('([a-z][a-z0-9]*,)+', 'a5,b7,c9,'), # A few sets
('Python', 'Python'), # Simple text literal
('.*Python', 'Python'), # Bad text literal
('.*Python.*', 'Python'), # Worse text literal
('.*(Python)', 'Python'), # Bad text literal with grouping
]
# Test suite (for verifying correctness)
#
# The test suite is a list of 5- or 3-tuples. The 5 parts of a
# complete tuple are:
# element 0: a string containing the pattern
# 1: the string to match against the pattern
# 2: the expected result (SUCCEED, FAIL, SYNTAX_ERROR)
# 3: a string that will be eval()'ed to produce a test string.
# This is an arbitrary Python expression; the available
# variables are "found" (the whole match), and "g1", "g2", ...
# up to "g99" contain the contents of each group, or the
# string 'None' if the group wasn't given a value, or the
# string 'Error' if the group index was out of range;
# also "groups", the return value of m.group() (a tuple).
# 4: The expected result of evaluating the expression.
# If the two don't match, an error is reported.
#
# If the regex isn't expected to work, the latter two elements can be omitted.
tests = [
# Test ?P< and ?P= extensions
('(?P<foo_123', '', SYNTAX_ERROR), # Unterminated group identifier
('(?P<1>a)', '', SYNTAX_ERROR), # Begins with a digit
('(?P<!>a)', '', SYNTAX_ERROR), # Begins with an illegal char
('(?P<foo!>a)', '', SYNTAX_ERROR), # Begins with an illegal char
# Same tests, for the ?P= form
('(?P<foo_123>a)(?P=foo_123', 'aa', SYNTAX_ERROR),
('(?P<foo_123>a)(?P=1)', 'aa', SYNTAX_ERROR),
('(?P<foo_123>a)(?P=!)', 'aa', SYNTAX_ERROR),
('(?P<foo_123>a)(?P=foo_124', 'aa', SYNTAX_ERROR), # Backref to undefined group
('(?P<foo_123>a)', 'a', SUCCEED, 'g1', 'a'),
('(?P<foo_123>a)(?P=foo_123)', 'aa', SUCCEED, 'g1', 'a'),
# Test octal escapes
('\\1', 'a', SYNTAX_ERROR), # Backreference
('[\\1]', '\1', SUCCEED, 'found', '\1'), # Character
('\\09', chr(0) + '9', SUCCEED, 'found', chr(0) + '9'),
('\\141', 'a', SUCCEED, 'found', 'a'),
('(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\119', 'abcdefghijklk9', SUCCEED, 'found+"-"+g11', 'abcdefghijklk9-k'),
# Test \0 is handled everywhere
(r'\0', '\0', SUCCEED, 'found', '\0'),
(r'[\0a]', '\0', SUCCEED, 'found', '\0'),
(r'[a\0]', '\0', SUCCEED, 'found', '\0'),
(r'[^a\0]', '\0', FAIL),
# Test various letter escapes
(r'\a[\b]\f\n\r\t\v', '\a\b\f\n\r\t\v', SUCCEED, 'found', '\a\b\f\n\r\t\v'),
(r'[\a][\b][\f][\n][\r][\t][\v]', '\a\b\f\n\r\t\v', SUCCEED, 'found', '\a\b\f\n\r\t\v'),
# NOTE: not an error under PCRE/PRE:
# (r'\u', '', SYNTAX_ERROR), # A Perl escape
(r'\c\e\g\h\i\j\k\m\o\p\q\y\z', 'ceghijkmopqyz', SUCCEED, 'found', 'ceghijkmopqyz'),
(r'\xff', '\377', SUCCEED, 'found', chr(255)),
# new \x semantics
(r'\x00ffffffffffffff', '\377', FAIL, 'found', chr(255)),
(r'\x00f', '\017', FAIL, 'found', chr(15)),
(r'\x00fe', '\376', FAIL, 'found', chr(254)),
# (r'\x00ffffffffffffff', '\377', SUCCEED, 'found', chr(255)),
# (r'\x00f', '\017', SUCCEED, 'found', chr(15)),
# (r'\x00fe', '\376', SUCCEED, 'found', chr(254)),
(r"^\w+=(\\[\000-\277]|[^\n\\])*", "SRC=eval.c g.c blah blah blah \\\\\n\tapes.c",
SUCCEED, 'found', "SRC=eval.c g.c blah blah blah \\\\"),
# Test that . only matches \n in DOTALL mode
('a.b', 'acb', SUCCEED, 'found', 'acb'),
('a.b', 'a\nb', FAIL),
('a.*b', 'acc\nccb', FAIL),
('a.{4,5}b', 'acc\nccb', FAIL),
('a.b', 'a\rb', SUCCEED, 'found', 'a\rb'),
('a.b(?s)', 'a\nb', SUCCEED, 'found', 'a\nb'),
('a.*(?s)b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'),
('(?s)a.{4,5}b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'),
('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'),
(')', '', SYNTAX_ERROR), # Unmatched right bracket
('', '', SUCCEED, 'found', ''), # Empty pattern
('abc', 'abc', SUCCEED, 'found', 'abc'),
('abc', 'xbc', FAIL),
('abc', 'axc', FAIL),
('abc', 'abx', FAIL),
('abc', 'xabcy', SUCCEED, 'found', 'abc'),
('abc', 'ababc', SUCCEED, 'found', 'abc'),
('ab*c', 'abc', SUCCEED, 'found', 'abc'),
('ab*bc', 'abc', SUCCEED, 'found', 'abc'),
('ab*bc', 'abbc', SUCCEED, 'found', 'abbc'),
('ab*bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'),
('ab+bc', 'abbc', SUCCEED, 'found', 'abbc'),
('ab+bc', 'abc', FAIL),
('ab+bc', 'abq', FAIL),
('ab+bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'),
('ab?bc', 'abbc', SUCCEED, 'found', 'abbc'),
('ab?bc', 'abc', SUCCEED, 'found', 'abc'),
('ab?bc', 'abbbbc', FAIL),
('ab?c', 'abc', SUCCEED, 'found', 'abc'),
('^abc$', 'abc', SUCCEED, 'found', 'abc'),
('^abc$', 'abcc', FAIL),
('^abc', 'abcc', SUCCEED, 'found', 'abc'),
('^abc$', 'aabc', FAIL),
('abc$', 'aabc', SUCCEED, 'found', 'abc'),
('^', 'abc', SUCCEED, 'found+"-"', '-'),
('$', 'abc', SUCCEED, 'found+"-"', '-'),
('a.c', 'abc', SUCCEED, 'found', 'abc'),
('a.c', 'axc', SUCCEED, 'found', 'axc'),
('a.*c', 'axyzc', SUCCEED, 'found', 'axyzc'),
('a.*c', 'axyzd', FAIL),
('a[bc]d', 'abc', FAIL),
('a[bc]d', 'abd', SUCCEED, 'found', 'abd'),
('a[b-d]e', 'abd', FAIL),
('a[b-d]e', 'ace', SUCCEED, 'found', 'ace'),
('a[b-d]', 'aac', SUCCEED, 'found', 'ac'),
('a[-b]', 'a-', SUCCEED, 'found', 'a-'),
('a[\\-b]', 'a-', SUCCEED, 'found', 'a-'),
# NOTE: not an error under PCRE/PRE:
# ('a[b-]', 'a-', SYNTAX_ERROR),
('a[]b', '-', SYNTAX_ERROR),
('a[', '-', SYNTAX_ERROR),
('a\\', '-', SYNTAX_ERROR),
('abc)', '-', SYNTAX_ERROR),
('(abc', '-', SYNTAX_ERROR),
('a]', 'a]', SUCCEED, 'found', 'a]'),
('a[]]b', 'a]b', SUCCEED, 'found', 'a]b'),
('a[\]]b', 'a]b', SUCCEED, 'found', 'a]b'),
('a[^bc]d', 'aed', SUCCEED, 'found', 'aed'),
('a[^bc]d', 'abd', FAIL),
('a[^-b]c', 'adc', SUCCEED, 'found', 'adc'),
('a[^-b]c', 'a-c', FAIL),
('a[^]b]c', 'a]c', FAIL),
('a[^]b]c', 'adc', SUCCEED, 'found', 'adc'),
('\\ba\\b', 'a-', SUCCEED, '"-"', '-'),
('\\ba\\b', '-a', SUCCEED, '"-"', '-'),
('\\ba\\b', '-a-', SUCCEED, '"-"', '-'),
('\\by\\b', 'xy', FAIL),
('\\by\\b', 'yz', FAIL),
('\\by\\b', 'xyz', FAIL),
('x\\b', 'xyz', FAIL),
('x\\B', 'xyz', SUCCEED, '"-"', '-'),
('\\Bz', 'xyz', SUCCEED, '"-"', '-'),
('z\\B', 'xyz', FAIL),
('\\Bx', 'xyz', FAIL),
('\\Ba\\B', 'a-', FAIL, '"-"', '-'),
('\\Ba\\B', '-a', FAIL, '"-"', '-'),
('\\Ba\\B', '-a-', FAIL, '"-"', '-'),
('\\By\\B', 'xy', FAIL),
('\\By\\B', 'yz', FAIL),
('\\By\\b', 'xy', SUCCEED, '"-"', '-'),
('\\by\\B', 'yz', SUCCEED, '"-"', '-'),
('\\By\\B', 'xyz', SUCCEED, '"-"', '-'),
('ab|cd', 'abc', SUCCEED, 'found', 'ab'),
('ab|cd', 'abcd', SUCCEED, 'found', 'ab'),
('()ef', 'def', SUCCEED, 'found+"-"+g1', 'ef-'),
('$b', 'b', FAIL),
('a\\(b', 'a(b', SUCCEED, 'found+"-"+g1', 'a(b-Error'),
('a\\(*b', 'ab', SUCCEED, 'found', 'ab'),
('a\\(*b', 'a((b', SUCCEED, 'found', 'a((b'),
('a\\\\b', 'a\\b', SUCCEED, 'found', 'a\\b'),
('((a))', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'a-a-a'),
('(a)b(c)', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'abc-a-c'),
('a+b+c', 'aabbabc', SUCCEED, 'found', 'abc'),
('(a+|b)*', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'),
('(a+|b)+', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'),
('(a+|b)?', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'),
(')(', '-', SYNTAX_ERROR),
('[^ab]*', 'cde', SUCCEED, 'found', 'cde'),
('abc', '', FAIL),
('a*', '', SUCCEED, 'found', ''),
('a|b|c|d|e', 'e', SUCCEED, 'found', 'e'),
('(a|b|c|d|e)f', 'ef', SUCCEED, 'found+"-"+g1', 'ef-e'),
('abcd*efg', 'abcdefg', SUCCEED, 'found', 'abcdefg'),
('ab*', 'xabyabbbz', SUCCEED, 'found', 'ab'),
('ab*', 'xayabbbz', SUCCEED, 'found', 'a'),
('(ab|cd)e', 'abcde', SUCCEED, 'found+"-"+g1', 'cde-cd'),
('[abhgefdc]ij', 'hij', SUCCEED, 'found', 'hij'),
('^(ab|cd)e', 'abcde', FAIL, 'xg1y', 'xy'),
('(abc|)ef', 'abcdef', SUCCEED, 'found+"-"+g1', 'ef-'),
('(a|b)c*d', 'abcd', SUCCEED, 'found+"-"+g1', 'bcd-b'),
('(ab|ab*)bc', 'abc', SUCCEED, 'found+"-"+g1', 'abc-a'),
('a([bc]*)c*', 'abc', SUCCEED, 'found+"-"+g1', 'abc-bc'),
('a([bc]*)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'),
('a([bc]+)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'),
('a([bc]*)(c+d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-b-cd'),
('a[bcd]*dcdcde', 'adcdcde', SUCCEED, 'found', 'adcdcde'),
('a[bcd]+dcdcde', 'adcdcde', FAIL),
('(ab|a)b*c', 'abc', SUCCEED, 'found+"-"+g1', 'abc-ab'),
('((a)(b)c)(d)', 'abcd', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'),
('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', SUCCEED, 'found', 'alpha'),
('^a(bc+|b[eh])g|.h$', 'abh', SUCCEED, 'found+"-"+g1', 'bh-None'),
('(bc+d$|ef*g.|h?i(j|k))', 'effgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'),
('(bc+d$|ef*g.|h?i(j|k))', 'ij', SUCCEED, 'found+"-"+g1+"-"+g2', 'ij-ij-j'),
('(bc+d$|ef*g.|h?i(j|k))', 'effg', FAIL),
('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', FAIL),
('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'),
('(((((((((a)))))))))', 'a', SUCCEED, 'found', 'a'),
('multiple words of text', 'uh-uh', FAIL),
('multiple words', 'multiple words, yeah', SUCCEED, 'found', 'multiple words'),
('(.*)c(.*)', 'abcde', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcde-ab-de'),
('\\((.*), (.*)\\)', '(a, b)', SUCCEED, 'g2+"-"+g1', 'b-a'),
('[k]', 'ab', FAIL),
('a[-]?c', 'ac', SUCCEED, 'found', 'ac'),
('(abc)\\1', 'abcabc', SUCCEED, 'g1', 'abc'),
('([a-c]*)\\1', 'abcabc', SUCCEED, 'g1', 'abc'),
('^(.+)?B', 'AB', SUCCEED, 'g1', 'A'),
('(a+).\\1$', 'aaaaa', SUCCEED, 'found+"-"+g1', 'aaaaa-aa'),
('^(a+).\\1$', 'aaaa', FAIL),
('(abc)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'),
('([a-c]+)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'),
('(a)\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'),
('(a+)\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'),
('(a+)+\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'),
('(a).+\\1', 'aba', SUCCEED, 'found+"-"+g1', 'aba-a'),
('(a)ba*\\1', 'aba', SUCCEED, 'found+"-"+g1', 'aba-a'),
('(aa|a)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'),
('(a|aa)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'),
('(a+)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'),
('([abc]*)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'),
('(a)(b)c|ab', 'ab', SUCCEED, 'found+"-"+g1+"-"+g2', 'ab-None-None'),
('(a)+x', 'aaax', SUCCEED, 'found+"-"+g1', 'aaax-a'),
('([ac])+x', 'aacx', SUCCEED, 'found+"-"+g1', 'aacx-c'),
('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', SUCCEED, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/'),
('([^.]*)\\.([^:]*):[T ]+(.*)', 'track1.title:TBlah blah blah', SUCCEED, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah'),
('([^N]*N)+', 'abNNxyzN', SUCCEED, 'found+"-"+g1', 'abNNxyzN-xyzN'),
('([^N]*N)+', 'abNNxyz', SUCCEED, 'found+"-"+g1', 'abNN-N'),
('([abc]*)x', 'abcx', SUCCEED, 'found+"-"+g1', 'abcx-abc'),
('([abc]*)x', 'abc', FAIL),
('([xyz]*)x', 'abcx', SUCCEED, 'found+"-"+g1', 'x-'),
('(a)+b|aac', 'aac', SUCCEED, 'found+"-"+g1', 'aac-None'),
# Test symbolic groups
('(?P<i d>aaa)a', 'aaaa', SYNTAX_ERROR),
('(?P<id>aaa)a', 'aaaa', SUCCEED, 'found+"-"+id', 'aaaa-aaa'),
('(?P<id>aa)(?P=id)', 'aaaa', SUCCEED, 'found+"-"+id', 'aaaa-aa'),
('(?P<id>aa)(?P=xd)', 'aaaa', SYNTAX_ERROR),
# Test octal escapes/memory references
('\\1', 'a', SYNTAX_ERROR),
('\\09', chr(0) + '9', SUCCEED, 'found', chr(0) + '9'),
('\\141', 'a', SUCCEED, 'found', 'a'),
('(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\119', 'abcdefghijklk9', SUCCEED, 'found+"-"+g11', 'abcdefghijklk9-k'),
# All tests from Perl
('abc', 'abc', SUCCEED, 'found', 'abc'),
('abc', 'xbc', FAIL),
('abc', 'axc', FAIL),
('abc', 'abx', FAIL),
('abc', 'xabcy', SUCCEED, 'found', 'abc'),
('abc', 'ababc', SUCCEED, 'found', 'abc'),
('ab*c', 'abc', SUCCEED, 'found', 'abc'),
('ab*bc', 'abc', SUCCEED, 'found', 'abc'),
('ab*bc', 'abbc', SUCCEED, 'found', 'abbc'),
('ab*bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'),
('ab{0,}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'),
('ab+bc', 'abbc', SUCCEED, 'found', 'abbc'),
('ab+bc', 'abc', FAIL),
('ab+bc', 'abq', FAIL),
('ab{1,}bc', 'abq', FAIL),
('ab+bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'),
('ab{1,}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'),
('ab{1,3}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'),
('ab{3,4}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'),
('ab{4,5}bc', 'abbbbc', FAIL),
('ab?bc', 'abbc', SUCCEED, 'found', 'abbc'),
('ab?bc', 'abc', SUCCEED, 'found', 'abc'),
('ab{0,1}bc', 'abc', SUCCEED, 'found', 'abc'),
('ab?bc', 'abbbbc', FAIL),
('ab?c', 'abc', SUCCEED, 'found', 'abc'),
('ab{0,1}c', 'abc', SUCCEED, 'found', 'abc'),
('^abc$', 'abc', SUCCEED, 'found', 'abc'),
('^abc$', 'abcc', FAIL),
('^abc', 'abcc', SUCCEED, 'found', 'abc'),
('^abc$', 'aabc', FAIL),
('abc$', 'aabc', SUCCEED, 'found', 'abc'),
('^', 'abc', SUCCEED, 'found', ''),
('$', 'abc', SUCCEED, 'found', ''),
('a.c', 'abc', SUCCEED, 'found', 'abc'),
('a.c', 'axc', SUCCEED, 'found', 'axc'),
('a.*c', 'axyzc', SUCCEED, 'found', 'axyzc'),
('a.*c', 'axyzd', FAIL),
('a[bc]d', 'abc', FAIL),
('a[bc]d', 'abd', SUCCEED, 'found', 'abd'),
('a[b-d]e', 'abd', FAIL),
('a[b-d]e', 'ace', SUCCEED, 'found', 'ace'),
('a[b-d]', 'aac', SUCCEED, 'found', 'ac'),
('a[-b]', 'a-', SUCCEED, 'found', 'a-'),
('a[b-]', 'a-', SUCCEED, 'found', 'a-'),
('a[b-a]', '-', SYNTAX_ERROR),
('a[]b', '-', SYNTAX_ERROR),
('a[', '-', SYNTAX_ERROR),
('a]', 'a]', SUCCEED, 'found', 'a]'),
('a[]]b', 'a]b', SUCCEED, 'found', 'a]b'),
('a[^bc]d', 'aed', SUCCEED, 'found', 'aed'),
('a[^bc]d', 'abd', FAIL),
('a[^-b]c', 'adc', SUCCEED, 'found', 'adc'),
('a[^-b]c', 'a-c', FAIL),
('a[^]b]c', 'a]c', FAIL),
('a[^]b]c', 'adc', SUCCEED, 'found', 'adc'),
('ab|cd', 'abc', SUCCEED, 'found', 'ab'),
('ab|cd', 'abcd', SUCCEED, 'found', 'ab'),
('()ef', 'def', SUCCEED, 'found+"-"+g1', 'ef-'),
('*a', '-', SYNTAX_ERROR),
('(*)b', '-', SYNTAX_ERROR),
('$b', 'b', FAIL),
('a\\', '-', SYNTAX_ERROR),
('a\\(b', 'a(b', SUCCEED, 'found+"-"+g1', 'a(b-Error'),
('a\\(*b', 'ab', SUCCEED, 'found', 'ab'),
('a\\(*b', 'a((b', SUCCEED, 'found', 'a((b'),
('a\\\\b', 'a\\b', SUCCEED, 'found', 'a\\b'),
('abc)', '-', SYNTAX_ERROR),
('(abc', '-', SYNTAX_ERROR),
('((a))', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'a-a-a'),
('(a)b(c)', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'abc-a-c'),
('a+b+c', 'aabbabc', SUCCEED, 'found', 'abc'),
('a{1,}b{1,}c', 'aabbabc', SUCCEED, 'found', 'abc'),
('a**', '-', SYNTAX_ERROR),
('a.+?c', 'abcabc', SUCCEED, 'found', 'abc'),
('(a+|b)*', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'),
('(a+|b){0,}', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'),
('(a+|b)+', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'),
('(a+|b){1,}', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'),
('(a+|b)?', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'),
('(a+|b){0,1}', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'),
(')(', '-', SYNTAX_ERROR),
('[^ab]*', 'cde', SUCCEED, 'found', 'cde'),
('abc', '', FAIL),
('a*', '', SUCCEED, 'found', ''),
('([abc])*d', 'abbbcd', SUCCEED, 'found+"-"+g1', 'abbbcd-c'),
('([abc])*bcd', 'abcd', SUCCEED, 'found+"-"+g1', 'abcd-a'),
('a|b|c|d|e', 'e', SUCCEED, 'found', 'e'),
('(a|b|c|d|e)f', 'ef', SUCCEED, 'found+"-"+g1', 'ef-e'),
('abcd*efg', 'abcdefg', SUCCEED, 'found', 'abcdefg'),
('ab*', 'xabyabbbz', SUCCEED, 'found', 'ab'),
('ab*', 'xayabbbz', SUCCEED, 'found', 'a'),
('(ab|cd)e', 'abcde', SUCCEED, 'found+"-"+g1', 'cde-cd'),
('[abhgefdc]ij', 'hij', SUCCEED, 'found', 'hij'),
('^(ab|cd)e', 'abcde', FAIL),
('(abc|)ef', 'abcdef', SUCCEED, 'found+"-"+g1', 'ef-'),
('(a|b)c*d', 'abcd', SUCCEED, 'found+"-"+g1', 'bcd-b'),
('(ab|ab*)bc', 'abc', SUCCEED, 'found+"-"+g1', 'abc-a'),
('a([bc]*)c*', 'abc', SUCCEED, 'found+"-"+g1', 'abc-bc'),
('a([bc]*)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'),
('a([bc]+)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'),
('a([bc]*)(c+d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-b-cd'),
('a[bcd]*dcdcde', 'adcdcde', SUCCEED, 'found', 'adcdcde'),
('a[bcd]+dcdcde', 'adcdcde', FAIL),
('(ab|a)b*c', 'abc', SUCCEED, 'found+"-"+g1', 'abc-ab'),
('((a)(b)c)(d)', 'abcd', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'),
('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', SUCCEED, 'found', 'alpha'),
('^a(bc+|b[eh])g|.h$', 'abh', SUCCEED, 'found+"-"+g1', 'bh-None'),
('(bc+d$|ef*g.|h?i(j|k))', 'effgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'),
('(bc+d$|ef*g.|h?i(j|k))', 'ij', SUCCEED, 'found+"-"+g1+"-"+g2', 'ij-ij-j'),
('(bc+d$|ef*g.|h?i(j|k))', 'effg', FAIL),
('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', FAIL),
('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'),
('((((((((((a))))))))))', 'a', SUCCEED, 'g10', 'a'),
('((((((((((a))))))))))\\10', 'aa', SUCCEED, 'found', 'aa'),
# Python does not have the same rules for \\41 so this is a syntax error
# ('((((((((((a))))))))))\\41', 'aa', FAIL),
# ('((((((((((a))))))))))\\41', 'a!', SUCCEED, 'found', 'a!'),
('((((((((((a))))))))))\\41', '', SYNTAX_ERROR),
('(?i)((((((((((a))))))))))\\41', '', SYNTAX_ERROR),
('(((((((((a)))))))))', 'a', SUCCEED, 'found', 'a'),
('multiple words of text', 'uh-uh', FAIL),
('multiple words', 'multiple words, yeah', SUCCEED, 'found', 'multiple words'),
('(.*)c(.*)', 'abcde', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcde-ab-de'),
('\\((.*), (.*)\\)', '(a, b)', SUCCEED, 'g2+"-"+g1', 'b-a'),
('[k]', 'ab', FAIL),
('a[-]?c', 'ac', SUCCEED, 'found', 'ac'),
('(abc)\\1', 'abcabc', SUCCEED, 'g1', 'abc'),
('([a-c]*)\\1', 'abcabc', SUCCEED, 'g1', 'abc'),
('(?i)abc', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)abc', 'XBC', FAIL),
('(?i)abc', 'AXC', FAIL),
('(?i)abc', 'ABX', FAIL),
('(?i)abc', 'XABCY', SUCCEED, 'found', 'ABC'),
('(?i)abc', 'ABABC', SUCCEED, 'found', 'ABC'),
('(?i)ab*c', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)ab*bc', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)ab*bc', 'ABBC', SUCCEED, 'found', 'ABBC'),
('(?i)ab*?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'),
('(?i)ab{0,}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'),
('(?i)ab+?bc', 'ABBC', SUCCEED, 'found', 'ABBC'),
('(?i)ab+bc', 'ABC', FAIL),
('(?i)ab+bc', 'ABQ', FAIL),
('(?i)ab{1,}bc', 'ABQ', FAIL),
('(?i)ab+bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'),
('(?i)ab{1,}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'),
('(?i)ab{1,3}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'),
('(?i)ab{3,4}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'),
('(?i)ab{4,5}?bc', 'ABBBBC', FAIL),
('(?i)ab??bc', 'ABBC', SUCCEED, 'found', 'ABBC'),
('(?i)ab??bc', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)ab{0,1}?bc', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)ab??bc', 'ABBBBC', FAIL),
('(?i)ab??c', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)ab{0,1}?c', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)^abc$', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)^abc$', 'ABCC', FAIL),
('(?i)^abc', 'ABCC', SUCCEED, 'found', 'ABC'),
('(?i)^abc$', 'AABC', FAIL),
('(?i)abc$', 'AABC', SUCCEED, 'found', 'ABC'),
('(?i)^', 'ABC', SUCCEED, 'found', ''),
('(?i)$', 'ABC', SUCCEED, 'found', ''),
('(?i)a.c', 'ABC', SUCCEED, 'found', 'ABC'),
('(?i)a.c', 'AXC', SUCCEED, 'found', 'AXC'),
('(?i)a.*?c', 'AXYZC', SUCCEED, 'found', 'AXYZC'),
('(?i)a.*c', 'AXYZD', FAIL),
('(?i)a[bc]d', 'ABC', FAIL),
('(?i)a[bc]d', 'ABD', SUCCEED, 'found', 'ABD'),
('(?i)a[b-d]e', 'ABD', FAIL),
('(?i)a[b-d]e', 'ACE', SUCCEED, 'found', 'ACE'),
('(?i)a[b-d]', 'AAC', SUCCEED, 'found', 'AC'),
('(?i)a[-b]', 'A-', SUCCEED, 'found', 'A-'),
('(?i)a[b-]', 'A-', SUCCEED, 'found', 'A-'),
('(?i)a[b-a]', '-', SYNTAX_ERROR),
('(?i)a[]b', '-', SYNTAX_ERROR),
('(?i)a[', '-', SYNTAX_ERROR),
('(?i)a]', 'A]', SUCCEED, 'found', 'A]'),
('(?i)a[]]b', 'A]B', SUCCEED, 'found', 'A]B'),
('(?i)a[^bc]d', 'AED', SUCCEED, 'found', 'AED'),
('(?i)a[^bc]d', 'ABD', FAIL),
('(?i)a[^-b]c', 'ADC', SUCCEED, 'found', 'ADC'),
('(?i)a[^-b]c', 'A-C', FAIL),
('(?i)a[^]b]c', 'A]C', FAIL),
('(?i)a[^]b]c', 'ADC', SUCCEED, 'found', 'ADC'),
('(?i)ab|cd', 'ABC', SUCCEED, 'found', 'AB'),
('(?i)ab|cd', 'ABCD', SUCCEED, 'found', 'AB'),
('(?i)()ef', 'DEF', SUCCEED, 'found+"-"+g1', 'EF-'),
('(?i)*a', '-', SYNTAX_ERROR),
('(?i)(*)b', '-', SYNTAX_ERROR),
('(?i)$b', 'B', FAIL),
('(?i)a\\', '-', SYNTAX_ERROR),
('(?i)a\\(b', 'A(B', SUCCEED, 'found+"-"+g1', 'A(B-Error'),
('(?i)a\\(*b', 'AB', SUCCEED, 'found', 'AB'),
('(?i)a\\(*b', 'A((B', SUCCEED, 'found', 'A((B'),
('(?i)a\\\\b', 'A\\B', SUCCEED, 'found', 'A\\B'),
('(?i)abc)', '-', SYNTAX_ERROR),
('(?i)(abc', '-', SYNTAX_ERROR),
('(?i)((a))', 'ABC', SUCCEED, 'found+"-"+g1+"-"+g2', 'A-A-A'),
('(?i)(a)b(c)', 'ABC', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABC-A-C'),
('(?i)a+b+c', 'AABBABC', SUCCEED, 'found', 'ABC'),
('(?i)a{1,}b{1,}c', 'AABBABC', SUCCEED, 'found', 'ABC'),
('(?i)a**', '-', SYNTAX_ERROR),
('(?i)a.+?c', 'ABCABC', SUCCEED, 'found', 'ABC'),
('(?i)a.*?c', 'ABCABC', SUCCEED, 'found', 'ABC'),
('(?i)a.{0,5}?c', 'ABCABC', SUCCEED, 'found', 'ABC'),
('(?i)(a+|b)*', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'),
('(?i)(a+|b){0,}', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'),
('(?i)(a+|b)+', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'),
('(?i)(a+|b){1,}', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'),
('(?i)(a+|b)?', 'AB', SUCCEED, 'found+"-"+g1', 'A-A'),
('(?i)(a+|b){0,1}', 'AB', SUCCEED, 'found+"-"+g1', 'A-A'),
('(?i)(a+|b){0,1}?', 'AB', SUCCEED, 'found+"-"+g1', '-None'),
('(?i))(', '-', SYNTAX_ERROR),
('(?i)[^ab]*', 'CDE', SUCCEED, 'found', 'CDE'),
('(?i)abc', '', FAIL),
('(?i)a*', '', SUCCEED, 'found', ''),
('(?i)([abc])*d', 'ABBBCD', SUCCEED, 'found+"-"+g1', 'ABBBCD-C'),
('(?i)([abc])*bcd', 'ABCD', SUCCEED, 'found+"-"+g1', 'ABCD-A'),
('(?i)a|b|c|d|e', 'E', SUCCEED, 'found', 'E'),
('(?i)(a|b|c|d|e)f', 'EF', SUCCEED, 'found+"-"+g1', 'EF-E'),
('(?i)abcd*efg', 'ABCDEFG', SUCCEED, 'found', 'ABCDEFG'),
('(?i)ab*', 'XABYABBBZ', SUCCEED, 'found', 'AB'),
('(?i)ab*', 'XAYABBBZ', SUCCEED, 'found', 'A'),
('(?i)(ab|cd)e', 'ABCDE', SUCCEED, 'found+"-"+g1', 'CDE-CD'),
('(?i)[abhgefdc]ij', 'HIJ', SUCCEED, 'found', 'HIJ'),
('(?i)^(ab|cd)e', 'ABCDE', FAIL),
('(?i)(abc|)ef', 'ABCDEF', SUCCEED, 'found+"-"+g1', 'EF-'),
('(?i)(a|b)c*d', 'ABCD', SUCCEED, 'found+"-"+g1', 'BCD-B'),
('(?i)(ab|ab*)bc', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-A'),
('(?i)a([bc]*)c*', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-BC'),
('(?i)a([bc]*)(c*d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-BC-D'),
('(?i)a([bc]+)(c*d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-BC-D'),
('(?i)a([bc]*)(c+d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-B-CD'),
('(?i)a[bcd]*dcdcde', 'ADCDCDE', SUCCEED, 'found', 'ADCDCDE'),
('(?i)a[bcd]+dcdcde', 'ADCDCDE', FAIL),
('(?i)(ab|a)b*c', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-AB'),
('(?i)((a)(b)c)(d)', 'ABCD', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'ABC-A-B-D'),
('(?i)[a-zA-Z_][a-zA-Z0-9_]*', 'ALPHA', SUCCEED, 'found', 'ALPHA'),
('(?i)^a(bc+|b[eh])g|.h$', 'ABH', SUCCEED, 'found+"-"+g1', 'BH-None'),
('(?i)(bc+d$|ef*g.|h?i(j|k))', 'EFFGZ', SUCCEED, 'found+"-"+g1+"-"+g2', 'EFFGZ-EFFGZ-None'),
('(?i)(bc+d$|ef*g.|h?i(j|k))', 'IJ', SUCCEED, 'found+"-"+g1+"-"+g2', 'IJ-IJ-J'),
('(?i)(bc+d$|ef*g.|h?i(j|k))', 'EFFG', FAIL),
('(?i)(bc+d$|ef*g.|h?i(j|k))', 'BCDD', FAIL),
('(?i)(bc+d$|ef*g.|h?i(j|k))', 'REFFGZ', SUCCEED, 'found+"-"+g1+"-"+g2', 'EFFGZ-EFFGZ-None'),
('(?i)((((((((((a))))))))))', 'A', SUCCEED, 'g10', 'A'),
('(?i)((((((((((a))))))))))\\10', 'AA', SUCCEED, 'found', 'AA'),
#('(?i)((((((((((a))))))))))\\41', 'AA', FAIL),
#('(?i)((((((((((a))))))))))\\41', 'A!', SUCCEED, 'found', 'A!'),
('(?i)(((((((((a)))))))))', 'A', SUCCEED, 'found', 'A'),
('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))', 'A', SUCCEED, 'g1', 'A'),
('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))', 'C', SUCCEED, 'g1', 'C'),
('(?i)multiple words of text', 'UH-UH', FAIL),
('(?i)multiple words', 'MULTIPLE WORDS, YEAH', SUCCEED, 'found', 'MULTIPLE WORDS'),
('(?i)(.*)c(.*)', 'ABCDE', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCDE-AB-DE'),
('(?i)\\((.*), (.*)\\)', '(A, B)', SUCCEED, 'g2+"-"+g1', 'B-A'),
('(?i)[k]', 'AB', FAIL),
# ('(?i)abcd', 'ABCD', SUCCEED, 'found+"-"+\\found+"-"+\\\\found', 'ABCD-$&-\\ABCD'),
# ('(?i)a(bc)d', 'ABCD', SUCCEED, 'g1+"-"+\\g1+"-"+\\\\g1', 'BC-$1-\\BC'),
('(?i)a[-]?c', 'AC', SUCCEED, 'found', 'AC'),
('(?i)(abc)\\1', 'ABCABC', SUCCEED, 'g1', 'ABC'),
('(?i)([a-c]*)\\1', 'ABCABC', SUCCEED, 'g1', 'ABC'),
('a(?!b).', 'abad', SUCCEED, 'found', 'ad'),
('a(?=d).', 'abad', SUCCEED, 'found', 'ad'),
('a(?=c|d).', 'abad', SUCCEED, 'found', 'ad'),
('a(?:b|c|d)(.)', 'ace', SUCCEED, 'g1', 'e'),
('a(?:b|c|d)*(.)', 'ace', SUCCEED, 'g1', 'e'),
('a(?:b|c|d)+?(.)', 'ace', SUCCEED, 'g1', 'e'),
('a(?:b|(c|e){1,2}?|d)+?(.)', 'ace', SUCCEED, 'g1 + g2', 'ce'),
('^(.+)?B', 'AB', SUCCEED, 'g1', 'A'),
# lookbehind: split by : but not if it is escaped by -.
('(?<!-):(.*?)(?<!-):', 'a:bc-:de:f', SUCCEED, 'g1', 'bc-:de' ),
# escaping with \ as we know it
('(?<!\\\):(.*?)(?<!\\\):', 'a:bc\\:de:f', SUCCEED, 'g1', 'bc\\:de' ),
# terminating with ' and escaping with ? as in edifact
("(?<!\\?)'(.*?)(?<!\\?)'", "a'bc?'de'f", SUCCEED, 'g1', "bc?'de" ),
# Comments using the (?#...) syntax
('w(?# comment', 'w', SYNTAX_ERROR),
('w(?# comment 1)xy(?# comment 2)z', 'wxyz', SUCCEED, 'found', 'wxyz'),
# Check odd placement of embedded pattern modifiers
# not an error under PCRE/PRE:
('w(?i)', 'W', SUCCEED, 'found', 'W'),
# ('w(?i)', 'W', SYNTAX_ERROR),
# Comments using the x embedded pattern modifier
("""(?x)w# comment 1
x y
# comment 2
z""", 'wxyz', SUCCEED, 'found', 'wxyz'),
# using the m embedded pattern modifier
('^abc', """jkl
abc
xyz""", FAIL),
('(?m)^abc', """jkl
abc
xyz""", SUCCEED, 'found', 'abc'),
('(?m)abc$', """jkl
xyzabc
123""", SUCCEED, 'found', 'abc'),
# using the s embedded pattern modifier
('a.b', 'a\nb', FAIL),
('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'),
# test \w, etc. both inside and outside character classes
('\\w+', '--ab_cd0123--', SUCCEED, 'found', 'ab_cd0123'),
('[\\w]+', '--ab_cd0123--', SUCCEED, 'found', 'ab_cd0123'),
('\\D+', '1234abc5678', SUCCEED, 'found', 'abc'),
('[\\D]+', '1234abc5678', SUCCEED, 'found', 'abc'),
('[\\da-fA-F]+', '123abc', SUCCEED, 'found', '123abc'),
# not an error under PCRE/PRE:
# ('[\\d-x]', '-', SYNTAX_ERROR),
(r'([\s]*)([\S]*)([\s]*)', ' testing!1972', SUCCEED, 'g3+g2+g1', 'testing!1972 '),
(r'(\s*)(\S*)(\s*)', ' testing!1972', SUCCEED, 'g3+g2+g1', 'testing!1972 '),
(r'\xff', '\377', SUCCEED, 'found', chr(255)),
# new \x semantics
(r'\x00ff', '\377', FAIL),
# (r'\x00ff', '\377', SUCCEED, 'found', chr(255)),
(r'\t\n\v\r\f\a\g', '\t\n\v\r\f\ag', SUCCEED, 'found', '\t\n\v\r\f\ag'),
('\t\n\v\r\f\a\g', '\t\n\v\r\f\ag', SUCCEED, 'found', '\t\n\v\r\f\ag'),
(r'\t\n\v\r\f\a', '\t\n\v\r\f\a', SUCCEED, 'found', chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)),
(r'[\t][\n][\v][\r][\f][\b]', '\t\n\v\r\f\b', SUCCEED, 'found', '\t\n\v\r\f\b'),
#
# post-1.5.2 additions
# xmllib problem
(r'(([a-z]+):)?([a-z]+)$', 'smil', SUCCEED, 'g1+"-"+g2+"-"+g3', 'None-None-smil'),
# bug 110866: reference to undefined group
(r'((.)\1+)', '', SYNTAX_ERROR),
# bug 111869: search (PRE/PCRE fails on this one, SRE doesn't)
(r'.*d', 'abc\nabd', SUCCEED, 'found', 'abd'),
# bug 112468: various expected syntax errors
(r'(', '', SYNTAX_ERROR),
(r'[\41]', '!', SUCCEED, 'found', '!'),
# bug 114033: nothing to repeat
(r'(x?)?', 'x', SUCCEED, 'found', 'x'),
# bug 115040: rescan if flags are modified inside pattern
(r' (?x)foo ', 'foo', SUCCEED, 'found', 'foo'),
# bug 115618: negative lookahead
(r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'),
# bug 116251: character class bug
(r'[\w-]+', 'laser_beam', SUCCEED, 'found', 'laser_beam'),
# bug 123769+127259: non-greedy backtracking bug
(r'.*?\S *:', 'xx:', SUCCEED, 'found', 'xx:'),
(r'a[ ]*?\ (\d+).*', 'a 10', SUCCEED, 'found', 'a 10'),
(r'a[ ]*?\ (\d+).*', 'a 10', SUCCEED, 'found', 'a 10'),
# bug 127259: \Z shouldn't depend on multiline mode
(r'(?ms).*?x\s*\Z(.*)','xx\nx\n', SUCCEED, 'g1', ''),
# bug 128899: uppercase literals under the ignorecase flag
(r'(?i)M+', 'MMM', SUCCEED, 'found', 'MMM'),
(r'(?i)m+', 'MMM', SUCCEED, 'found', 'MMM'),
(r'(?i)[M]+', 'MMM', SUCCEED, 'found', 'MMM'),
(r'(?i)[m]+', 'MMM', SUCCEED, 'found', 'MMM'),
# bug 130748: ^* should be an error (nothing to repeat)
(r'^*', '', SYNTAX_ERROR),
# bug 133283: minimizing repeat problem
(r'"(?:\\"|[^"])*?"', r'"\""', SUCCEED, 'found', r'"\""'),
# bug 477728: minimizing repeat problem
(r'^.*?$', 'one\ntwo\nthree\n', FAIL),
# bug 483789: minimizing repeat problem
(r'a[^>]*?b', 'a>b', FAIL),
# bug 490573: minimizing repeat problem
(r'^a*?$', 'foo', FAIL),
# bug 470582: nested groups problem
(r'^((a)c)?(ab)$', 'ab', SUCCEED, 'g1+"-"+g2+"-"+g3', 'None-None-ab'),
# another minimizing repeat problem (capturing groups in assertions)
('^([ab]*?)(?=(b)?)c', 'abc', SUCCEED, 'g1+"-"+g2', 'ab-None'),
('^([ab]*?)(?!(b))c', 'abc', SUCCEED, 'g1+"-"+g2', 'ab-None'),
('^([ab]*?)(?<!(a))c', 'abc', SUCCEED, 'g1+"-"+g2', 'ab-None'),
]
u = '\N{LATIN CAPITAL LETTER A WITH DIAERESIS}'
tests.extend([
# bug 410271: \b broken under locales
(r'\b.\b', 'a', SUCCEED, 'found', 'a'),
(r'(?u)\b.\b', u, SUCCEED, 'found', u),
(r'(?u)\w', u, SUCCEED, 'found', u),
])
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1882,
818,
26,
2366,
1882,
199,
199,
3,
799,
511,
5241,
436,
12338,
5241,
373,
17,
14,
21,
199,
199,
3,
710,
650,
3962,
15955,
83,
367,
1924,
3851,
199,
59,
6195,
8890,
12,
10341,
12,
25486,
63,
3170,
61,
275,
1425,
8,
19,
9,
199,
199,
3,
27067,
5241,
334,
10065,
14819,
9,
199,
3,
199,
3,
710,
12338,
5241,
1630,
440,
511,
29102,
12,
2951,
8112,
14,
221,
710,
199,
3,
1642,
1819,
402,
1924,
2008,
365,
314,
5163,
3851,
27,
314,
3499,
365,
282,
199,
3,
1059,
370,
1336,
652,
6169,
14,
221,
710,
12338,
316,
1233,
911,
6441,
314,
199,
3,
3499,
1059,
6272,
9978,
10627,
402,
6273,
12,
370,
511,
4212,
5163,
199,
3,
4877,
18628,
641,
7031,
3326,
14,
199,
199,
11861,
83,
275,
359,
339,
327,
511,
2863,
2403,
272,
661,
4718,
92,
2623,
76,
297,
283,
2623,
76,
659,
259,
327,
17669,
425,
272,
23845,
4718,
92,
2623,
76,
3196,
283,
2623,
76,
659,
221,
327,
598,
11330,
8679,
425,
339,
661,
4718,
92,
2623,
76,
92,
29175,
297,
283,
2623,
76,
659,
263,
327,
17669,
425,
272,
23845,
4718,
92,
2623,
76,
92,
29175,
3196,
283,
2623,
76,
659,
420,
327,
598,
11330,
8679,
425,
339,
23845,
4718,
22532,
17,
297,
283,
4718,
4718,
659,
259,
327,
10257,
4443,
272,
661,
779,
16,
65,
13,
90,
1527,
65,
13,
90,
16,
13,
25,
3672,
4258,
7386,
283,
65,
21,
12,
66,
23,
12,
67,
25,
12,
659,
327,
17534,
314,
7377,
1130,
13712,
272,
661,
779,
65,
13,
90,
1527,
65,
13,
90,
16,
13,
25,
3672,
4258,
7386,
283,
65,
21,
12,
66,
23,
12,
67,
25,
12,
659,
327,
437,
9284,
5951,
339,
661,
4718,
297,
283,
4718,
659,
5185,
327,
5870,
1318,
8785,
272,
661,
2795,
4718,
297,
283,
4718,
659,
3777,
327,
8857,
1318,
8785,
272,
661,
2795,
4718,
16110,
283,
4718,
659,
3698,
327,
644,
9050,
1318,
8785,
272,
661,
2795,
8,
4718,
3196,
283,
4718,
659,
3698,
327,
8857,
1318,
8785,
543,
17786,
199,
199,
61,
199,
199,
3,
1379,
5241,
334,
509,
31866,
29102,
9,
199,
3,
199,
3,
710,
511,
5241,
365,
282,
769,
402,
959,
13,
503,
650,
13,
11760,
14,
221,
710,
959,
4184,
402,
282,
199,
3,
4890,
2008,
787,
26,
199,
3,
1819,
378,
26,
282,
1059,
3035,
314,
3851,
199,
3,
260,
413,
26,
314,
1059,
370,
1336,
6169,
314,
3851,
199,
3,
260,
499,
26,
314,
1420,
754,
334,
6195,
8890,
12,
10341,
12,
25486,
63,
3170,
9,
199,
3,
260,
650,
26,
282,
1059,
626,
911,
506,
3468,
11716,
379,
370,
7389,
282,
511,
1059,
14,
199,
3,
3322,
961,
365,
376,
9697,
2018,
3965,
27,
314,
2808,
199,
3,
3322,
2860,
787,
298,
4214,
2,
334,
1589,
8852,
1336,
395,
436,
298,
71,
17,
401,
298,
71,
18,
401,
2263,
199,
3,
3322,
1536,
370,
298,
71,
1020,
2,
1395,
314,
4072,
402,
1924,
1572,
12,
503,
314,
199,
3,
3322,
1059,
283,
403,
7,
340,
314,
1572,
17373,
1133,
1627,
282,
574,
12,
503,
314,
199,
3,
3322,
1059,
283,
547,
7,
340,
314,
1572,
1478,
1990,
734,
402,
1425,
27,
199,
3,
3322,
2597,
298,
2634,
401,
314,
372,
574,
402,
333,
14,
923,
342,
334,
65,
2008,
680,
199,
3,
260,
841,
26,
710,
1420,
754,
402,
27083,
314,
3965,
14,
199,
3,
3322,
982,
314,
2877,
2793,
1133,
1336,
12,
376,
1125,
365,
14581,
14,
199,
3,
199,
3,
982,
314,
5163,
5712,
1133,
1420,
370,
1736,
12,
314,
19045,
2877,
4008,
883,
506,
11684,
14,
199,
199,
2219,
275,
359,
272,
327,
1379,
5805,
48,
28,
436,
5805,
48,
29,
5478,
272,
15950,
48,
28,
1421,
63,
4288,
297,
3260,
25486,
63,
3170,
395,
420,
327,
1910,
18375,
1572,
5148,
272,
15950,
48,
28,
17,
30,
65,
3196,
3260,
25486,
63,
3170,
395,
260,
327,
25754,
83,
543,
282,
10964,
272,
15950,
48,
11230,
30,
65,
3196,
3260,
25486,
63,
3170,
395,
260,
327,
25754,
83,
543,
376,
20282,
1495,
272,
15950,
48,
28,
1421,
1,
30,
65,
3196,
3260,
25486,
63,
3170,
395,
420,
327,
25754,
83,
543,
376,
20282,
1495,
339,
327,
14766,
2295,
12,
367,
314,
5805,
48,
29,
1824,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
1421,
63,
4288,
297,
283,
2158,
297,
25486,
63,
3170,
395,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
17,
3196,
283,
2158,
297,
25486,
63,
3170,
395,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
1,
3196,
283,
2158,
297,
25486,
63,
3170,
395,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
1421,
63,
7214,
297,
283,
2158,
297,
25486,
63,
3170,
395,
221,
327,
10257,
1121,
370,
10942,
1572,
339,
15950,
48,
28,
1421,
63,
4288,
30,
65,
3196,
283,
65,
297,
8955,
12,
283,
71,
17,
297,
283,
65,
659,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
1421,
63,
4288,
3196,
283,
2158,
297,
8955,
12,
283,
71,
17,
297,
283,
65,
659,
339,
327,
1379,
30100,
24644,
272,
661,
1103,
17,
297,
283,
65,
297,
25486,
63,
3170,
395,
259,
327,
10257,
4443,
272,
23734,
1103,
17,
4300,
1557,
17,
297,
8955,
12,
283,
4214,
297,
1557,
17,
659,
221,
327,
17660,
272,
661,
1103,
1643,
297,
8678,
8,
16,
9,
435,
283,
25,
297,
8955,
12,
283,
4214,
297,
8678,
8,
16,
9,
435,
283,
25,
659,
272,
661,
1103,
12735,
297,
283,
65,
297,
8955,
12,
283,
4214,
297,
283,
65,
659,
272,
23845,
65,
5130,
66,
5130,
67,
5130,
68,
5130,
69,
5130,
70,
5130,
71,
5130,
72,
5130,
73,
5130,
74,
5130,
75,
5130,
76,
22532,
7119,
297,
283,
18677,
9503,
75,
25,
297,
8955,
12,
283,
4214,
15200,
71,
845,
297,
283,
18677,
9503,
75,
25,
13,
75,
659,
339,
327,
1379,
971,
16,
365,
8860,
4036,
4509,
272,
334,
82,
1154,
16,
297,
1557,
16,
297,
8955,
12,
283,
4214,
297,
1557,
16,
659,
272,
334,
82,
22123,
16,
65,
4300,
1557
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1882,
818,
26,
2366,
1882,
199,
199,
3,
799,
511,
5241,
436,
12338,
5241,
373,
17,
14,
21,
199,
199,
3,
710,
650,
3962,
15955,
83,
367,
1924,
3851,
199,
59,
6195,
8890,
12,
10341,
12,
25486,
63,
3170,
61,
275,
1425,
8,
19,
9,
199,
199,
3,
27067,
5241,
334,
10065,
14819,
9,
199,
3,
199,
3,
710,
12338,
5241,
1630,
440,
511,
29102,
12,
2951,
8112,
14,
221,
710,
199,
3,
1642,
1819,
402,
1924,
2008,
365,
314,
5163,
3851,
27,
314,
3499,
365,
282,
199,
3,
1059,
370,
1336,
652,
6169,
14,
221,
710,
12338,
316,
1233,
911,
6441,
314,
199,
3,
3499,
1059,
6272,
9978,
10627,
402,
6273,
12,
370,
511,
4212,
5163,
199,
3,
4877,
18628,
641,
7031,
3326,
14,
199,
199,
11861,
83,
275,
359,
339,
327,
511,
2863,
2403,
272,
661,
4718,
92,
2623,
76,
297,
283,
2623,
76,
659,
259,
327,
17669,
425,
272,
23845,
4718,
92,
2623,
76,
3196,
283,
2623,
76,
659,
221,
327,
598,
11330,
8679,
425,
339,
661,
4718,
92,
2623,
76,
92,
29175,
297,
283,
2623,
76,
659,
263,
327,
17669,
425,
272,
23845,
4718,
92,
2623,
76,
92,
29175,
3196,
283,
2623,
76,
659,
420,
327,
598,
11330,
8679,
425,
339,
23845,
4718,
22532,
17,
297,
283,
4718,
4718,
659,
259,
327,
10257,
4443,
272,
661,
779,
16,
65,
13,
90,
1527,
65,
13,
90,
16,
13,
25,
3672,
4258,
7386,
283,
65,
21,
12,
66,
23,
12,
67,
25,
12,
659,
327,
17534,
314,
7377,
1130,
13712,
272,
661,
779,
65,
13,
90,
1527,
65,
13,
90,
16,
13,
25,
3672,
4258,
7386,
283,
65,
21,
12,
66,
23,
12,
67,
25,
12,
659,
327,
437,
9284,
5951,
339,
661,
4718,
297,
283,
4718,
659,
5185,
327,
5870,
1318,
8785,
272,
661,
2795,
4718,
297,
283,
4718,
659,
3777,
327,
8857,
1318,
8785,
272,
661,
2795,
4718,
16110,
283,
4718,
659,
3698,
327,
644,
9050,
1318,
8785,
272,
661,
2795,
8,
4718,
3196,
283,
4718,
659,
3698,
327,
8857,
1318,
8785,
543,
17786,
199,
199,
61,
199,
199,
3,
1379,
5241,
334,
509,
31866,
29102,
9,
199,
3,
199,
3,
710,
511,
5241,
365,
282,
769,
402,
959,
13,
503,
650,
13,
11760,
14,
221,
710,
959,
4184,
402,
282,
199,
3,
4890,
2008,
787,
26,
199,
3,
1819,
378,
26,
282,
1059,
3035,
314,
3851,
199,
3,
260,
413,
26,
314,
1059,
370,
1336,
6169,
314,
3851,
199,
3,
260,
499,
26,
314,
1420,
754,
334,
6195,
8890,
12,
10341,
12,
25486,
63,
3170,
9,
199,
3,
260,
650,
26,
282,
1059,
626,
911,
506,
3468,
11716,
379,
370,
7389,
282,
511,
1059,
14,
199,
3,
3322,
961,
365,
376,
9697,
2018,
3965,
27,
314,
2808,
199,
3,
3322,
2860,
787,
298,
4214,
2,
334,
1589,
8852,
1336,
395,
436,
298,
71,
17,
401,
298,
71,
18,
401,
2263,
199,
3,
3322,
1536,
370,
298,
71,
1020,
2,
1395,
314,
4072,
402,
1924,
1572,
12,
503,
314,
199,
3,
3322,
1059,
283,
403,
7,
340,
314,
1572,
17373,
1133,
1627,
282,
574,
12,
503,
314,
199,
3,
3322,
1059,
283,
547,
7,
340,
314,
1572,
1478,
1990,
734,
402,
1425,
27,
199,
3,
3322,
2597,
298,
2634,
401,
314,
372,
574,
402,
333,
14,
923,
342,
334,
65,
2008,
680,
199,
3,
260,
841,
26,
710,
1420,
754,
402,
27083,
314,
3965,
14,
199,
3,
3322,
982,
314,
2877,
2793,
1133,
1336,
12,
376,
1125,
365,
14581,
14,
199,
3,
199,
3,
982,
314,
5163,
5712,
1133,
1420,
370,
1736,
12,
314,
19045,
2877,
4008,
883,
506,
11684,
14,
199,
199,
2219,
275,
359,
272,
327,
1379,
5805,
48,
28,
436,
5805,
48,
29,
5478,
272,
15950,
48,
28,
1421,
63,
4288,
297,
3260,
25486,
63,
3170,
395,
420,
327,
1910,
18375,
1572,
5148,
272,
15950,
48,
28,
17,
30,
65,
3196,
3260,
25486,
63,
3170,
395,
260,
327,
25754,
83,
543,
282,
10964,
272,
15950,
48,
11230,
30,
65,
3196,
3260,
25486,
63,
3170,
395,
260,
327,
25754,
83,
543,
376,
20282,
1495,
272,
15950,
48,
28,
1421,
1,
30,
65,
3196,
3260,
25486,
63,
3170,
395,
420,
327,
25754,
83,
543,
376,
20282,
1495,
339,
327,
14766,
2295,
12,
367,
314,
5805,
48,
29,
1824,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
1421,
63,
4288,
297,
283,
2158,
297,
25486,
63,
3170,
395,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
17,
3196,
283,
2158,
297,
25486,
63,
3170,
395,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
1,
3196,
283,
2158,
297,
25486,
63,
3170,
395,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
1421,
63,
7214,
297,
283,
2158,
297,
25486,
63,
3170,
395,
221,
327,
10257,
1121,
370,
10942,
1572,
339,
15950,
48,
28,
1421,
63,
4288,
30,
65,
3196,
283,
65,
297,
8955,
12,
283,
71,
17,
297,
283,
65,
659,
272,
15950,
48,
28,
1421,
63,
4288,
30,
65,
18168,
48,
29,
1421,
63,
4288,
3196,
283,
2158,
297,
8955,
12,
283,
71,
17,
297,
283,
65,
659,
339,
327,
1379,
30100,
24644,
272,
661,
1103,
17,
297,
283,
65,
297,
25486,
63,
3170,
395,
259,
327,
10257,
4443,
272,
23734,
1103,
17,
4300,
1557,
17,
297,
8955,
12,
283,
4214,
297,
1557,
17,
659,
221,
327,
17660,
272,
661,
1103,
1643,
297,
8678,
8,
16,
9,
435,
283,
25,
297,
8955,
12,
283,
4214,
297,
8678,
8,
16,
9,
435,
283,
25,
659,
272,
661,
1103,
12735,
297,
283,
65,
297,
8955,
12,
283,
4214,
297,
283,
65,
659,
272,
23845,
65,
5130,
66,
5130,
67,
5130,
68,
5130,
69,
5130,
70,
5130,
71,
5130,
72,
5130,
73,
5130,
74,
5130,
75,
5130,
76,
22532,
7119,
297,
283,
18677,
9503,
75,
25,
297,
8955,
12,
283,
4214,
15200,
71,
845,
297,
283,
18677,
9503,
75,
25,
13,
75,
659,
339,
327,
1379,
971,
16,
365,
8860,
4036,
4509,
272,
334,
82,
1154,
16,
297,
1557,
16,
297,
8955,
12,
283,
4214,
297,
1557,
16,
659,
272,
334,
82,
22123,
16,
65,
4300,
1557,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
tzaffi/git-in-practice-repo
|
book/lib/python2.7/site-packages/django/core/handlers/wsgi.py
|
58
|
7670
|
from __future__ import unicode_literals
import codecs
import logging
import sys
from io import BytesIO
from threading import Lock
from django import http
from django.core import signals
from django.core.handlers import base
from django.core.urlresolvers import set_script_prefix
from django.utils import datastructures
from django.utils.encoding import force_str, force_text, iri_to_uri
from django.utils import six
# For backwards compatibility -- lots of code uses this in the wild!
from django.http.response import REASON_PHRASES as STATUS_CODE_TEXT
logger = logging.getLogger('django.request')
class LimitedStream(object):
'''
LimitedStream wraps another stream in order to not allow reading from it
past specified amount of bytes.
'''
def __init__(self, stream, limit, buf_size=64 * 1024 * 1024):
self.stream = stream
self.remaining = limit
self.buffer = b''
self.buf_size = buf_size
def _read_limited(self, size=None):
if size is None or size > self.remaining:
size = self.remaining
if size == 0:
return b''
result = self.stream.read(size)
self.remaining -= len(result)
return result
def read(self, size=None):
if size is None:
result = self.buffer + self._read_limited()
self.buffer = b''
elif size < len(self.buffer):
result = self.buffer[:size]
self.buffer = self.buffer[size:]
else: # size >= len(self.buffer)
result = self.buffer + self._read_limited(size - len(self.buffer))
self.buffer = b''
return result
def readline(self, size=None):
while b'\n' not in self.buffer and \
(size is None or len(self.buffer) < size):
if size:
# since size is not None here, len(self.buffer) < size
chunk = self._read_limited(size - len(self.buffer))
else:
chunk = self._read_limited()
if not chunk:
break
self.buffer += chunk
sio = BytesIO(self.buffer)
if size:
line = sio.readline(size)
else:
line = sio.readline()
self.buffer = sio.read()
return line
class WSGIRequest(http.HttpRequest):
def __init__(self, environ):
script_name = base.get_script_name(environ)
path_info = base.get_path_info(environ)
if not path_info:
# Sometimes PATH_INFO exists, but is empty (e.g. accessing
# the SCRIPT_NAME URL without a trailing slash). We really need to
# operate as if they'd requested '/'. Not amazingly nice to force
# the path like this, but should be harmless.
path_info = '/'
self.environ = environ
self.path_info = path_info
self.path = '%s/%s' % (script_name.rstrip('/'), path_info.lstrip('/'))
self.META = environ
self.META['PATH_INFO'] = path_info
self.META['SCRIPT_NAME'] = script_name
self.method = environ['REQUEST_METHOD'].upper()
_, content_params = self._parse_content_type(self.META.get('CONTENT_TYPE', ''))
if 'charset' in content_params:
try:
codecs.lookup(content_params['charset'])
except LookupError:
pass
else:
self.encoding = content_params['charset']
self._post_parse_error = False
try:
content_length = int(self.environ.get('CONTENT_LENGTH'))
except (ValueError, TypeError):
content_length = 0
self._stream = LimitedStream(self.environ['wsgi.input'], content_length)
self._read_started = False
self.resolver_match = None
def _is_secure(self):
return 'wsgi.url_scheme' in self.environ and self.environ['wsgi.url_scheme'] == 'https'
def _parse_content_type(self, ctype):
"""
Media Types parsing according to RFC 2616, section 3.7.
Returns the data type and parameters. For example:
Input: "text/plain; charset=iso-8859-1"
Output: ('text/plain', {'charset': 'iso-8859-1'})
"""
content_type, _, params = ctype.partition(';')
content_params = {}
for parameter in params.split(';'):
k, _, v = parameter.strip().partition('=')
content_params[k] = v
return content_type, content_params
def _get_request(self):
if not hasattr(self, '_request'):
self._request = datastructures.MergeDict(self.POST, self.GET)
return self._request
def _get_get(self):
if not hasattr(self, '_get'):
# The WSGI spec says 'QUERY_STRING' may be absent.
raw_query_string = self.environ.get('QUERY_STRING', str(''))
if six.PY3:
raw_query_string = raw_query_string.encode('iso-8859-1').decode('utf-8')
self._get = http.QueryDict(raw_query_string, encoding=self._encoding)
return self._get
def _set_get(self, get):
self._get = get
def _get_post(self):
if not hasattr(self, '_post'):
self._load_post_and_files()
return self._post
def _set_post(self, post):
self._post = post
def _get_cookies(self):
if not hasattr(self, '_cookies'):
raw_cookie = self.environ.get('HTTP_COOKIE', str(''))
if six.PY3:
raw_cookie = raw_cookie.encode('iso-8859-1').decode('utf-8')
self._cookies = http.parse_cookie(raw_cookie)
return self._cookies
def _set_cookies(self, cookies):
self._cookies = cookies
def _get_files(self):
if not hasattr(self, '_files'):
self._load_post_and_files()
return self._files
GET = property(_get_get, _set_get)
POST = property(_get_post, _set_post)
COOKIES = property(_get_cookies, _set_cookies)
FILES = property(_get_files)
REQUEST = property(_get_request)
class WSGIHandler(base.BaseHandler):
initLock = Lock()
request_class = WSGIRequest
def __call__(self, environ, start_response):
# Set up middleware if needed. We couldn't do this earlier, because
# settings weren't available.
if self._request_middleware is None:
with self.initLock:
try:
# Check that middleware is still uninitialised.
if self._request_middleware is None:
self.load_middleware()
except:
# Unload whatever middleware we got
self._request_middleware = None
raise
set_script_prefix(base.get_script_name(environ))
signals.request_started.send(sender=self.__class__)
try:
request = self.request_class(environ)
except UnicodeDecodeError:
logger.warning('Bad Request (UnicodeDecodeError)',
exc_info=sys.exc_info(),
extra={
'status_code': 400,
}
)
response = http.HttpResponseBadRequest()
else:
response = self.get_response(request)
response._handler_class = self.__class__
status = '%s %s' % (response.status_code, response.reason_phrase)
response_headers = [(str(k), str(v)) for k, v in response.items()]
for c in response.cookies.values():
response_headers.append((str('Set-Cookie'), str(c.output(header=''))))
start_response(force_str(status), response_headers)
return response
|
mit
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
6010,
199,
646,
2050,
199,
646,
984,
199,
504,
5890,
492,
11808,
199,
504,
5796,
492,
15536,
199,
199,
504,
1639,
492,
1455,
199,
504,
1639,
14,
1018,
492,
10166,
199,
504,
1639,
14,
1018,
14,
5586,
492,
1300,
199,
504,
1639,
14,
1018,
14,
16522,
492,
663,
63,
1579,
63,
1861,
199,
504,
1639,
14,
1208,
492,
666,
13547,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
495,
12,
3542,
63,
505,
12,
24086,
63,
475,
63,
2302,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
3,
2104,
8552,
7163,
1553,
24213,
402,
1233,
4440,
642,
315,
314,
336,
668,
1,
199,
504,
1639,
14,
1014,
14,
1310,
492,
5363,
28883,
63,
9791,
50,
21983,
465,
18460,
63,
6012,
63,
3876,
199,
199,
2921,
275,
2050,
14,
5572,
360,
1176,
14,
1069,
358,
421,
199,
533,
23954,
3296,
8,
785,
304,
272,
1449,
272,
23954,
3296,
14018,
4573,
2547,
315,
1865,
370,
440,
2040,
7664,
687,
652,
272,
13541,
2013,
5982,
402,
2783,
14,
272,
1449,
272,
347,
636,
826,
721,
277,
12,
2547,
12,
2304,
12,
4123,
63,
890,
29,
772,
627,
6619,
627,
6619,
304,
267,
291,
14,
1745,
275,
2547,
267,
291,
14,
11266,
275,
2304,
267,
291,
14,
2738,
275,
330,
891,
267,
291,
14,
1436,
63,
890,
275,
4123,
63,
890,
339,
347,
485,
739,
63,
14136,
8,
277,
12,
1568,
29,
403,
304,
267,
340,
1568,
365,
488,
503,
1568,
690,
291,
14,
11266,
26,
288,
1568,
275,
291,
14,
11266,
267,
340,
1568,
508,
378,
26,
288,
372,
330,
891,
267,
754,
275,
291,
14,
1745,
14,
739,
8,
890,
9,
267,
291,
14,
11266,
4862,
822,
8,
1099,
9,
267,
372,
754,
339,
347,
1586,
8,
277,
12,
1568,
29,
403,
304,
267,
340,
1568,
365,
488,
26,
288,
754,
275,
291,
14,
2738,
435,
291,
423,
739,
63,
14136,
342,
288,
291,
14,
2738,
275,
330,
891,
267,
916,
1568,
665,
822,
8,
277,
14,
2738,
304,
288,
754,
275,
291,
14,
2738,
1491,
890,
61,
288,
291,
14,
2738,
275,
291,
14,
2738,
59,
890,
2938,
267,
587,
26,
327,
1568,
2356,
822,
8,
277,
14,
2738,
9,
288,
754,
275,
291,
14,
2738,
435,
291,
423,
739,
63,
14136,
8,
890,
446,
822,
8,
277,
14,
2738,
430,
288,
291,
14,
2738,
275,
330,
891,
267,
372,
754,
339,
347,
14441,
8,
277,
12,
1568,
29,
403,
304,
267,
1830,
330,
1154,
78,
7,
440,
315,
291,
14,
2738,
436,
971,
1598,
334,
890,
365,
488,
503,
822,
8,
277,
14,
2738,
9,
665,
1568,
304,
288,
340,
1568,
26,
355,
327,
3967,
1568,
365,
440,
488,
2348,
12,
822,
8,
277,
14,
2738,
9,
665,
1568,
355,
3728,
275,
291,
423,
739,
63,
14136,
8,
890,
446,
822,
8,
277,
14,
2738,
430,
288,
587,
26,
355,
3728,
275,
291,
423,
739,
63,
14136,
342,
288,
340,
440,
3728,
26,
355,
2059,
288,
291,
14,
2738,
847,
3728,
267,
29129,
275,
11808,
8,
277,
14,
2738,
9,
267,
340,
1568,
26,
288,
1004,
275,
29129,
14,
6407,
8,
890,
9,
267,
587,
26,
288,
1004,
275,
29129,
14,
6407,
342,
267,
291,
14,
2738,
275,
29129,
14,
739,
342,
267,
372,
1004,
421,
199,
533,
9279,
2017,
8,
1014,
14,
10441,
304,
272,
347,
636,
826,
721,
277,
12,
6160,
304,
267,
2884,
63,
354,
275,
1300,
14,
362,
63,
1579,
63,
354,
8,
2314,
9,
267,
931,
63,
815,
275,
1300,
14,
362,
63,
515,
63,
815,
8,
2314,
9,
267,
340,
440,
931,
63,
815,
26,
288,
327,
30094,
15097,
63,
4531,
3495,
12,
1325,
365,
2701,
334,
69,
14,
71,
14,
18549,
288,
327,
314,
30203,
63,
2339,
2851,
1928,
282,
8520,
14457,
680,
2136,
7710,
1929,
370,
288,
327,
19218,
465,
340,
2985,
5121,
5839,
20538,
2832,
282,
391,
20135,
590,
14213,
370,
3542,
288,
327,
314,
931,
2839,
642,
12,
1325,
1077,
506,
394,
5362,
2003,
14,
288,
931,
63,
815,
275,
7324,
267,
291,
14,
2314,
275,
6160,
267,
291,
14,
515,
63,
815,
275,
931,
63,
815,
267,
291,
14,
515,
275,
1543,
83,
3149,
83,
7,
450,
334,
1579,
63,
354,
14,
6735,
2336,
659,
931,
63,
815,
14,
10124,
28684,
267,
291,
14,
10614,
275,
6160,
267,
291,
14,
10614,
459,
3243,
63,
4531,
418,
275,
931,
63,
815,
267,
291,
14,
10614,
459,
10484,
63,
2339,
418,
275,
2884,
63,
354,
267,
291,
14,
765,
275,
6160,
459,
6780,
63,
9977,
2278,
4142,
342,
267,
5501,
1564,
63,
1162,
275,
291,
423,
1122,
63,
1317,
63,
466,
8,
277,
14,
10614,
14,
362,
360,
9663,
63,
2711,
297,
12381,
267,
340,
283,
6043,
7,
315,
1564,
63,
1162,
26,
288,
862,
26,
355,
6010,
14,
3892,
8,
1317,
63,
1162,
459,
6043,
1105,
288,
871,
19021,
26,
355,
986,
288,
587,
26,
355,
291,
14,
2991,
275,
1564,
63,
1162,
459,
6043,
418,
267,
291,
423,
1932,
63,
1122,
63,
705,
275,
756,
267,
862,
26,
288,
1564,
63,
1267,
275,
1109,
8,
277,
14,
2314,
14,
362,
360,
9663,
63,
9127,
1333,
267,
871,
334,
3393,
12,
3146,
304,
288,
1564,
63,
1267,
275,
378,
267,
291,
423,
1745,
275,
23954,
3296,
8,
277,
14,
2314,
459,
6508,
14,
1210,
995,
1564,
63,
1267,
9,
267,
291,
423,
739,
63,
8924,
275,
756,
267,
291,
14,
7717,
63,
1431,
275,
488,
339,
347,
485,
374,
63,
7817,
8,
277,
304,
267,
372,
283,
6508,
14,
633,
63,
5512,
7,
315,
291,
14,
2314,
436,
291,
14,
2314,
459,
6508,
14,
633,
63,
5512,
418,
508,
283,
2859,
7,
339,
347,
485,
1122,
63,
1317,
63,
466,
8,
277,
12,
16360,
304,
267,
408,
267,
12300,
18851,
6057,
7182,
370,
7329,
7875,
975,
12,
3420,
650,
14,
23,
14,
398,
1803,
314,
666,
730,
436,
2633,
14,
2104,
2893,
26,
267,
6924,
26,
298,
505,
15,
6104,
27,
5960,
29,
4595,
13,
4830,
13,
17,
2,
267,
7242,
26,
661,
505,
15,
6104,
297,
791,
6043,
356,
283,
4595,
13,
4830,
13,
17,
3071,
267,
408,
267
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
6010,
199,
646,
2050,
199,
646,
984,
199,
504,
5890,
492,
11808,
199,
504,
5796,
492,
15536,
199,
199,
504,
1639,
492,
1455,
199,
504,
1639,
14,
1018,
492,
10166,
199,
504,
1639,
14,
1018,
14,
5586,
492,
1300,
199,
504,
1639,
14,
1018,
14,
16522,
492,
663,
63,
1579,
63,
1861,
199,
504,
1639,
14,
1208,
492,
666,
13547,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
495,
12,
3542,
63,
505,
12,
24086,
63,
475,
63,
2302,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
3,
2104,
8552,
7163,
1553,
24213,
402,
1233,
4440,
642,
315,
314,
336,
668,
1,
199,
504,
1639,
14,
1014,
14,
1310,
492,
5363,
28883,
63,
9791,
50,
21983,
465,
18460,
63,
6012,
63,
3876,
199,
199,
2921,
275,
2050,
14,
5572,
360,
1176,
14,
1069,
358,
421,
199,
533,
23954,
3296,
8,
785,
304,
272,
1449,
272,
23954,
3296,
14018,
4573,
2547,
315,
1865,
370,
440,
2040,
7664,
687,
652,
272,
13541,
2013,
5982,
402,
2783,
14,
272,
1449,
272,
347,
636,
826,
721,
277,
12,
2547,
12,
2304,
12,
4123,
63,
890,
29,
772,
627,
6619,
627,
6619,
304,
267,
291,
14,
1745,
275,
2547,
267,
291,
14,
11266,
275,
2304,
267,
291,
14,
2738,
275,
330,
891,
267,
291,
14,
1436,
63,
890,
275,
4123,
63,
890,
339,
347,
485,
739,
63,
14136,
8,
277,
12,
1568,
29,
403,
304,
267,
340,
1568,
365,
488,
503,
1568,
690,
291,
14,
11266,
26,
288,
1568,
275,
291,
14,
11266,
267,
340,
1568,
508,
378,
26,
288,
372,
330,
891,
267,
754,
275,
291,
14,
1745,
14,
739,
8,
890,
9,
267,
291,
14,
11266,
4862,
822,
8,
1099,
9,
267,
372,
754,
339,
347,
1586,
8,
277,
12,
1568,
29,
403,
304,
267,
340,
1568,
365,
488,
26,
288,
754,
275,
291,
14,
2738,
435,
291,
423,
739,
63,
14136,
342,
288,
291,
14,
2738,
275,
330,
891,
267,
916,
1568,
665,
822,
8,
277,
14,
2738,
304,
288,
754,
275,
291,
14,
2738,
1491,
890,
61,
288,
291,
14,
2738,
275,
291,
14,
2738,
59,
890,
2938,
267,
587,
26,
327,
1568,
2356,
822,
8,
277,
14,
2738,
9,
288,
754,
275,
291,
14,
2738,
435,
291,
423,
739,
63,
14136,
8,
890,
446,
822,
8,
277,
14,
2738,
430,
288,
291,
14,
2738,
275,
330,
891,
267,
372,
754,
339,
347,
14441,
8,
277,
12,
1568,
29,
403,
304,
267,
1830,
330,
1154,
78,
7,
440,
315,
291,
14,
2738,
436,
971,
1598,
334,
890,
365,
488,
503,
822,
8,
277,
14,
2738,
9,
665,
1568,
304,
288,
340,
1568,
26,
355,
327,
3967,
1568,
365,
440,
488,
2348,
12,
822,
8,
277,
14,
2738,
9,
665,
1568,
355,
3728,
275,
291,
423,
739,
63,
14136,
8,
890,
446,
822,
8,
277,
14,
2738,
430,
288,
587,
26,
355,
3728,
275,
291,
423,
739,
63,
14136,
342,
288,
340,
440,
3728,
26,
355,
2059,
288,
291,
14,
2738,
847,
3728,
267,
29129,
275,
11808,
8,
277,
14,
2738,
9,
267,
340,
1568,
26,
288,
1004,
275,
29129,
14,
6407,
8,
890,
9,
267,
587,
26,
288,
1004,
275,
29129,
14,
6407,
342,
267,
291,
14,
2738,
275,
29129,
14,
739,
342,
267,
372,
1004,
421,
199,
533,
9279,
2017,
8,
1014,
14,
10441,
304,
272,
347,
636,
826,
721,
277,
12,
6160,
304,
267,
2884,
63,
354,
275,
1300,
14,
362,
63,
1579,
63,
354,
8,
2314,
9,
267,
931,
63,
815,
275,
1300,
14,
362,
63,
515,
63,
815,
8,
2314,
9,
267,
340,
440,
931,
63,
815,
26,
288,
327,
30094,
15097,
63,
4531,
3495,
12,
1325,
365,
2701,
334,
69,
14,
71,
14,
18549,
288,
327,
314,
30203,
63,
2339,
2851,
1928,
282,
8520,
14457,
680,
2136,
7710,
1929,
370,
288,
327,
19218,
465,
340,
2985,
5121,
5839,
20538,
2832,
282,
391,
20135,
590,
14213,
370,
3542,
288,
327,
314,
931,
2839,
642,
12,
1325,
1077,
506,
394,
5362,
2003,
14,
288,
931,
63,
815,
275,
7324,
267,
291,
14,
2314,
275,
6160,
267,
291,
14,
515,
63,
815,
275,
931,
63,
815,
267,
291,
14,
515,
275,
1543,
83,
3149,
83,
7,
450,
334,
1579,
63,
354,
14,
6735,
2336,
659,
931,
63,
815,
14,
10124,
28684,
267,
291,
14,
10614,
275,
6160,
267,
291,
14,
10614,
459,
3243,
63,
4531,
418,
275,
931,
63,
815,
267,
291,
14,
10614,
459,
10484,
63,
2339,
418,
275,
2884,
63,
354,
267,
291,
14,
765,
275,
6160,
459,
6780,
63,
9977,
2278,
4142,
342,
267,
5501,
1564,
63,
1162,
275,
291,
423,
1122,
63,
1317,
63,
466,
8,
277,
14,
10614,
14,
362,
360,
9663,
63,
2711,
297,
12381,
267,
340,
283,
6043,
7,
315,
1564,
63,
1162,
26,
288,
862,
26,
355,
6010,
14,
3892,
8,
1317,
63,
1162,
459,
6043,
1105,
288,
871,
19021,
26,
355,
986,
288,
587,
26,
355,
291,
14,
2991,
275,
1564,
63,
1162,
459,
6043,
418,
267,
291,
423,
1932,
63,
1122,
63,
705,
275,
756,
267,
862,
26,
288,
1564,
63,
1267,
275,
1109,
8,
277,
14,
2314,
14,
362,
360,
9663,
63,
9127,
1333,
267,
871,
334,
3393,
12,
3146,
304,
288,
1564,
63,
1267,
275,
378,
267,
291,
423,
1745,
275,
23954,
3296,
8,
277,
14,
2314,
459,
6508,
14,
1210,
995,
1564,
63,
1267,
9,
267,
291,
423,
739,
63,
8924,
275,
756,
267,
291,
14,
7717,
63,
1431,
275,
488,
339,
347,
485,
374,
63,
7817,
8,
277,
304,
267,
372,
283,
6508,
14,
633,
63,
5512,
7,
315,
291,
14,
2314,
436,
291,
14,
2314,
459,
6508,
14,
633,
63,
5512,
418,
508,
283,
2859,
7,
339,
347,
485,
1122,
63,
1317,
63,
466,
8,
277,
12,
16360,
304,
267,
408,
267,
12300,
18851,
6057,
7182,
370,
7329,
7875,
975,
12,
3420,
650,
14,
23,
14,
398,
1803,
314,
666,
730,
436,
2633,
14,
2104,
2893,
26,
267,
6924,
26,
298,
505,
15,
6104,
27,
5960,
29,
4595,
13,
4830,
13,
17,
2,
267,
7242,
26,
661,
505,
15,
6104,
297,
791,
6043,
356,
283,
4595,
13,
4830,
13,
17,
3071,
267,
408,
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,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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
] |
tequa/ammisoft
|
ammimain/WinPython-64bit-2.7.13.1Zero/python-2.7.13.amd64/Lib/site-packages/pygments/lexers/whiley.py
|
31
|
4012
|
# -*- coding: utf-8 -*-
"""
pygments.lexers.whiley
~~~~~~~~~~~~~~~~~~~~~~
Lexers for the Whiley language.
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.lexer import RegexLexer, bygroups, words
from pygments.token import Comment, Keyword, Name, Number, Operator, \
Punctuation, String, Text
__all__ = ['WhileyLexer']
class WhileyLexer(RegexLexer):
"""
Lexer for the Whiley programming language.
.. versionadded:: 2.2
"""
name = 'Whiley'
filenames = ['*.whiley']
aliases = ['whiley']
mimetypes = ['text/x-whiley']
# See the language specification:
# http://whiley.org/download/WhileyLanguageSpec.pdf
tokens = {
'root': [
# Whitespace
(r'\s+', Text),
# Comments
(r'//.*', Comment.Single),
# don't parse empty comment as doc comment
(r'/\*\*/', Comment.Multiline),
(r'(?s)/\*\*.*?\*/', String.Doc),
(r'(?s)/\*.*?\*/', Comment.Multiline),
# Keywords
(words((
'if', 'else', 'while', 'for', 'do', 'return',
'switch', 'case', 'default', 'break', 'continue',
'requires', 'ensures', 'where', 'assert', 'assume',
'all', 'no', 'some', 'in', 'is', 'new',
'throw', 'try', 'catch', 'debug', 'skip', 'fail',
'finite', 'total'), suffix=r'\b'), Keyword.Reserved),
(words((
'function', 'method', 'public', 'private', 'protected',
'export', 'native'), suffix=r'\b'), Keyword.Declaration),
# "constant" & "type" are not keywords unless used in declarations
(r'(constant|type)(\s+)([a-zA-Z_]\w*)(\s+)(is)\b',
bygroups(Keyword.Declaration, Text, Name, Text, Keyword.Reserved)),
(r'(true|false|null)\b', Keyword.Constant),
(r'(bool|byte|int|real|any|void)\b', Keyword.Type),
# "from" is not a keyword unless used with import
(r'(import)(\s+)(\*)([^\S\n]+)(from)\b',
bygroups(Keyword.Namespace, Text, Punctuation, Text, Keyword.Namespace)),
(r'(import)(\s+)([a-zA-Z_]\w*)([^\S\n]+)(from)\b',
bygroups(Keyword.Namespace, Text, Name, Text, Keyword.Namespace)),
(r'(package|import)\b', Keyword.Namespace),
# standard library: https://github.com/Whiley/WhileyLibs/
(words((
# types defined in whiley.lang.Int
'i8', 'i16', 'i32', 'i64',
'u8', 'u16', 'u32', 'u64',
'uint', 'nat',
# whiley.lang.Any
'toString'), suffix=r'\b'), Name.Builtin),
# byte literal
(r'[01]+b', Number.Bin),
# decimal literal
(r'[0-9]+\.[0-9]+', Number.Float),
# match "1." but not ranges like "3..5"
(r'[0-9]+\.(?!\.)', Number.Float),
# integer literal
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+', Number.Integer),
# character literal
(r"""'[^\\]'""", String.Char),
(r"""(')(\\['"\\btnfr])(')""",
bygroups(String.Char, String.Escape, String.Char)),
# string literal
(r'"', String, 'string'),
# operators and punctuation
(r'[{}()\[\],.;]', Punctuation),
(u'[+\\-*/%&|<>^!~@=:?'
# unicode operators
u'\u2200\u2203\u2205\u2282\u2286\u2283\u2287'
u'\u222A\u2229\u2264\u2265\u2208\u2227\u2228'
u']', Operator),
# identifier
(r'[a-zA-Z_]\w*', Name),
],
'string': [
(r'"', String, '#pop'),
(r'\\[btnfr]', String.Escape),
(r'\\u[0-9a-fA-F]{4}', String.Escape),
(r'\\.', String),
(r'[^\\"]+', String),
],
}
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
14,
6710,
89,
272,
18294,
2878,
1714,
339,
491,
476,
1192,
367,
314,
22117,
89,
2637,
14,
339,
520,
7307,
26,
1898,
8315,
13,
10680,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
504,
13277,
14,
11729,
492,
12939,
5838,
12,
10259,
12,
5932,
199,
504,
13277,
14,
1418,
492,
6819,
12,
6431,
12,
2812,
12,
4860,
12,
11013,
12,
971,
272,
10357,
12,
2624,
12,
4516,
199,
199,
363,
452,
363,
275,
788,
25215,
89,
5838,
418,
421,
199,
533,
22117,
89,
5838,
8,
19856,
304,
272,
408,
272,
21125,
367,
314,
22117,
89,
31768,
2637,
14,
339,
2508,
7445,
447,
499,
14,
18,
272,
408,
272,
536,
275,
283,
25215,
89,
7,
272,
6203,
275,
17855,
6710,
89,
418,
272,
5481,
275,
788,
6710,
89,
418,
272,
13290,
275,
788,
505,
15,
88,
13,
6710,
89,
418,
339,
327,
1666,
314,
2637,
8929,
26,
272,
327,
1455,
921,
6710,
89,
14,
1308,
15,
4249,
15,
25215,
89,
8493,
5307,
14,
5607,
339,
4645,
275,
469,
267,
283,
1231,
356,
359,
288,
327,
24403,
288,
334,
82,
1154,
83,
7386,
4516,
395,
953,
327,
5429,
1470,
288,
334,
82,
28866,
16110,
6819,
14,
7200,
395,
288,
327,
2793,
1133,
2198,
2701,
3721,
465,
1382,
3721,
288,
334,
82,
32575,
27804,
3678,
6819,
14,
18933,
395,
288,
334,
82,
10120,
83,
2447,
60,
27804,
21040,
10,
3678,
2624,
14,
3768,
395,
288,
334,
82,
10120,
83,
2447,
60,
10,
21040,
10,
3678,
6819,
14,
18933,
395,
953,
327,
2606,
3148,
288,
334,
3148,
1332,
355,
283,
692,
297,
283,
2836,
297,
283,
6710,
297,
283,
509,
297,
283,
1117,
297,
283,
1107,
297,
355,
283,
5656,
297,
283,
2546,
297,
283,
885,
297,
283,
4785,
297,
283,
6958,
297,
355,
283,
6537,
297,
283,
8764,
1482,
297,
283,
4509,
297,
283,
479,
297,
283,
21946,
297,
355,
283,
452,
297,
283,
889,
297,
283,
3972,
297,
283,
262,
297,
283,
374,
297,
283,
1222,
297,
355,
283,
11964,
297,
283,
893,
297,
283,
9341,
297,
283,
1757,
297,
283,
2759,
297,
283,
1633,
297,
355,
283,
8005,
297,
283,
2923,
659,
4739,
29,
82,
1154,
66,
659,
6431,
14,
10285,
395,
288,
334,
3148,
1332,
355,
283,
1593,
297,
283,
765,
297,
283,
3455,
297,
283,
4239,
297,
283,
6798,
297,
355,
283,
3790,
297,
283,
6106,
659,
4739,
29,
82,
1154,
66,
659,
6431,
14,
17737,
395,
288,
327,
298,
4083,
2,
1253,
298,
466,
2,
787,
440,
7681,
7444,
1202,
315,
18707,
288,
334,
82,
6774,
4083,
92,
466,
10127,
83,
8771,
779,
65,
13,
6353,
13,
58,
29588,
87,
10,
10127,
83,
29653,
374,
2862,
66,
297,
1467,
10259,
8,
10650,
14,
17737,
12,
4516,
12,
2812,
12,
4516,
12,
6431,
14,
10285,
1826,
288,
334,
82,
6774,
2052,
92,
3910,
92,
2307,
2862,
66,
297,
6431,
14,
9737,
395,
288,
334,
82,
6774,
2245,
92,
4414,
92,
442,
92,
3093,
92,
1629,
92,
1647,
2862,
66,
297,
6431,
14,
804,
395,
288,
327,
298,
504,
2,
365,
440,
282,
4252,
7444,
1202,
543,
492,
288,
334,
82,
6774,
646,
10127,
83,
27860,
13278,
21690,
51,
60,
78,
2807,
5130,
504,
2862,
66,
297,
1467,
10259,
8,
10650,
14,
8814,
12,
4516,
12,
10357,
12,
4516,
12,
6431,
14,
8814,
1826,
288,
334,
82,
6774,
646,
10127,
83,
8771,
779,
65,
13,
6353,
13,
58,
29588,
87,
13278,
21690,
51,
60,
78,
2807,
5130,
504,
2862,
66,
297,
1467,
10259,
8,
10650,
14,
8814,
12,
4516,
12,
2812,
12,
4516,
12,
6431,
14,
8814,
1826,
288,
334,
82,
6774,
2491,
92,
646,
2862,
66,
297,
6431,
14,
8814,
395,
953,
327,
4465,
3555,
26,
4178,
921,
5031,
14,
957,
15,
25215,
89,
15,
25215,
89,
13009,
1533,
15,
288,
334,
3148,
1332,
355,
327,
2943,
3247,
315,
1830,
89,
14,
4159,
14,
3241,
355,
283,
73,
24,
297,
283,
73,
975,
297,
283,
73,
708,
297,
283,
73,
772,
297,
355,
283,
85,
24,
297,
283,
85,
975,
297,
283,
85,
708,
297,
283,
85,
772,
297,
355,
283,
1635,
297,
283,
9468,
297,
2234,
327,
1830,
89,
14,
4159,
14,
9874,
355,
283,
16695,
659,
4739,
29,
82,
1154,
66,
659,
2812,
14,
12306,
395,
953,
327,
3696,
8785,
288,
334,
82,
3894,
614,
2807,
66,
297,
4860,
14,
13394,
395,
953,
327,
6107,
8785,
288,
334,
82,
3894,
16,
13,
25,
2807,
27658,
16,
13,
25,
11529,
4860,
14,
5136,
395,
288,
327,
1336,
298,
17,
2122,
1325,
440,
12271,
2839,
298,
19,
703,
21,
2,
288,
334,
82,
3894,
16,
13,
25,
2807,
4537,
26313,
4537,
3196,
4860,
14,
5136,
395,
953,
327,
3000,
8785,
288,
334,
82,
7,
16,
88,
59,
16,
13,
25,
65,
13,
13753,
13,
38,
11529,
4860,
14,
10373,
395,
288,
334,
82,
3894,
16,
13,
25,
11529,
4860,
14,
2674,
395,
953,
327,
4528,
8785,
288,
334,
82,
624,
16122,
1103,
6616,
7208,
2624,
14,
1610,
395,
288,
334,
82,
624,
8,
7533,
1103,
459,
22996,
9633,
4391,
566,
15938,
7208,
1467,
10259,
8,
1558,
14,
1610,
12,
2624,
14,
10260,
12,
2624,
14,
1610,
1826,
953,
327,
1059,
8785,
288,
334,
82,
24487,
2624,
12,
283,
875,
659,
953,
327,
10211,
436,
22929,
288,
334,
82,
3894,
2440,
17158,
7023,
467,
14,
27,
4300,
10357,
395,
288,
334,
85,
3894,
11,
1103,
13,
10,
3149,
6,
92,
16137,
62,
1,
94,
32,
29,
26,
14069,
1467,
327,
2649,
10211,
1467,
399,
1154,
85,
1081,
383,
60,
85,
1081,
1644,
60,
85,
1081,
1717,
60,
85,
1081,
2564,
60,
85,
1081,
1184,
60,
85,
1081,
2658,
60,
85,
1081,
1555,
7,
1467,
399,
1154,
85,
9485,
33,
60,
85,
1081,
1398,
60,
85,
30383,
60,
85,
30209,
60,
85,
1081,
2036,
60,
85,
1081,
1465,
60,
85,
1081,
1651,
7,
1467,
399,
418,
297,
11013,
395,
953,
327,
5148,
288,
334,
82,
3894,
65,
13,
6353,
13,
58,
29588,
87,
7693,
2812,
395,
267,
2156,
267,
283,
875,
356,
359,
288,
334,
82
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
14,
6710,
89,
272,
18294,
2878,
1714,
339,
491,
476,
1192,
367,
314,
22117,
89,
2637,
14,
339,
520,
7307,
26,
1898,
8315,
13,
10680,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
504,
13277,
14,
11729,
492,
12939,
5838,
12,
10259,
12,
5932,
199,
504,
13277,
14,
1418,
492,
6819,
12,
6431,
12,
2812,
12,
4860,
12,
11013,
12,
971,
272,
10357,
12,
2624,
12,
4516,
199,
199,
363,
452,
363,
275,
788,
25215,
89,
5838,
418,
421,
199,
533,
22117,
89,
5838,
8,
19856,
304,
272,
408,
272,
21125,
367,
314,
22117,
89,
31768,
2637,
14,
339,
2508,
7445,
447,
499,
14,
18,
272,
408,
272,
536,
275,
283,
25215,
89,
7,
272,
6203,
275,
17855,
6710,
89,
418,
272,
5481,
275,
788,
6710,
89,
418,
272,
13290,
275,
788,
505,
15,
88,
13,
6710,
89,
418,
339,
327,
1666,
314,
2637,
8929,
26,
272,
327,
1455,
921,
6710,
89,
14,
1308,
15,
4249,
15,
25215,
89,
8493,
5307,
14,
5607,
339,
4645,
275,
469,
267,
283,
1231,
356,
359,
288,
327,
24403,
288,
334,
82,
1154,
83,
7386,
4516,
395,
953,
327,
5429,
1470,
288,
334,
82,
28866,
16110,
6819,
14,
7200,
395,
288,
327,
2793,
1133,
2198,
2701,
3721,
465,
1382,
3721,
288,
334,
82,
32575,
27804,
3678,
6819,
14,
18933,
395,
288,
334,
82,
10120,
83,
2447,
60,
27804,
21040,
10,
3678,
2624,
14,
3768,
395,
288,
334,
82,
10120,
83,
2447,
60,
10,
21040,
10,
3678,
6819,
14,
18933,
395,
953,
327,
2606,
3148,
288,
334,
3148,
1332,
355,
283,
692,
297,
283,
2836,
297,
283,
6710,
297,
283,
509,
297,
283,
1117,
297,
283,
1107,
297,
355,
283,
5656,
297,
283,
2546,
297,
283,
885,
297,
283,
4785,
297,
283,
6958,
297,
355,
283,
6537,
297,
283,
8764,
1482,
297,
283,
4509,
297,
283,
479,
297,
283,
21946,
297,
355,
283,
452,
297,
283,
889,
297,
283,
3972,
297,
283,
262,
297,
283,
374,
297,
283,
1222,
297,
355,
283,
11964,
297,
283,
893,
297,
283,
9341,
297,
283,
1757,
297,
283,
2759,
297,
283,
1633,
297,
355,
283,
8005,
297,
283,
2923,
659,
4739,
29,
82,
1154,
66,
659,
6431,
14,
10285,
395,
288,
334,
3148,
1332,
355,
283,
1593,
297,
283,
765,
297,
283,
3455,
297,
283,
4239,
297,
283,
6798,
297,
355,
283,
3790,
297,
283,
6106,
659,
4739,
29,
82,
1154,
66,
659,
6431,
14,
17737,
395,
288,
327,
298,
4083,
2,
1253,
298,
466,
2,
787,
440,
7681,
7444,
1202,
315,
18707,
288,
334,
82,
6774,
4083,
92,
466,
10127,
83,
8771,
779,
65,
13,
6353,
13,
58,
29588,
87,
10,
10127,
83,
29653,
374,
2862,
66,
297,
1467,
10259,
8,
10650,
14,
17737,
12,
4516,
12,
2812,
12,
4516,
12,
6431,
14,
10285,
1826,
288,
334,
82,
6774,
2052,
92,
3910,
92,
2307,
2862,
66,
297,
6431,
14,
9737,
395,
288,
334,
82,
6774,
2245,
92,
4414,
92,
442,
92,
3093,
92,
1629,
92,
1647,
2862,
66,
297,
6431,
14,
804,
395,
288,
327,
298,
504,
2,
365,
440,
282,
4252,
7444,
1202,
543,
492,
288,
334,
82,
6774,
646,
10127,
83,
27860,
13278,
21690,
51,
60,
78,
2807,
5130,
504,
2862,
66,
297,
1467,
10259,
8,
10650,
14,
8814,
12,
4516,
12,
10357,
12,
4516,
12,
6431,
14,
8814,
1826,
288,
334,
82,
6774,
646,
10127,
83,
8771,
779,
65,
13,
6353,
13,
58,
29588,
87,
13278,
21690,
51,
60,
78,
2807,
5130,
504,
2862,
66,
297,
1467,
10259,
8,
10650,
14,
8814,
12,
4516,
12,
2812,
12,
4516,
12,
6431,
14,
8814,
1826,
288,
334,
82,
6774,
2491,
92,
646,
2862,
66,
297,
6431,
14,
8814,
395,
953,
327,
4465,
3555,
26,
4178,
921,
5031,
14,
957,
15,
25215,
89,
15,
25215,
89,
13009,
1533,
15,
288,
334,
3148,
1332,
355,
327,
2943,
3247,
315,
1830,
89,
14,
4159,
14,
3241,
355,
283,
73,
24,
297,
283,
73,
975,
297,
283,
73,
708,
297,
283,
73,
772,
297,
355,
283,
85,
24,
297,
283,
85,
975,
297,
283,
85,
708,
297,
283,
85,
772,
297,
355,
283,
1635,
297,
283,
9468,
297,
2234,
327,
1830,
89,
14,
4159,
14,
9874,
355,
283,
16695,
659,
4739,
29,
82,
1154,
66,
659,
2812,
14,
12306,
395,
953,
327,
3696,
8785,
288,
334,
82,
3894,
614,
2807,
66,
297,
4860,
14,
13394,
395,
953,
327,
6107,
8785,
288,
334,
82,
3894,
16,
13,
25,
2807,
27658,
16,
13,
25,
11529,
4860,
14,
5136,
395,
288,
327,
1336,
298,
17,
2122,
1325,
440,
12271,
2839,
298,
19,
703,
21,
2,
288,
334,
82,
3894,
16,
13,
25,
2807,
4537,
26313,
4537,
3196,
4860,
14,
5136,
395,
953,
327,
3000,
8785,
288,
334,
82,
7,
16,
88,
59,
16,
13,
25,
65,
13,
13753,
13,
38,
11529,
4860,
14,
10373,
395,
288,
334,
82,
3894,
16,
13,
25,
11529,
4860,
14,
2674,
395,
953,
327,
4528,
8785,
288,
334,
82,
624,
16122,
1103,
6616,
7208,
2624,
14,
1610,
395,
288,
334,
82,
624,
8,
7533,
1103,
459,
22996,
9633,
4391,
566,
15938,
7208,
1467,
10259,
8,
1558,
14,
1610,
12,
2624,
14,
10260,
12,
2624,
14,
1610,
1826,
953,
327,
1059,
8785,
288,
334,
82,
24487,
2624,
12,
283,
875,
659,
953,
327,
10211,
436,
22929,
288,
334,
82,
3894,
2440,
17158,
7023,
467,
14,
27,
4300,
10357,
395,
288,
334,
85,
3894,
11,
1103,
13,
10,
3149,
6,
92,
16137,
62,
1,
94,
32,
29,
26,
14069,
1467,
327,
2649,
10211,
1467,
399,
1154,
85,
1081,
383,
60,
85,
1081,
1644,
60,
85,
1081,
1717,
60,
85,
1081,
2564,
60,
85,
1081,
1184,
60,
85,
1081,
2658,
60,
85,
1081,
1555,
7,
1467,
399,
1154,
85,
9485,
33,
60,
85,
1081,
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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
] |
pozdnyakov/chromium-crosswalk
|
tools/heapcheck/chrome_tests.py
|
7
|
17636
|
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
''' Runs various chrome tests through heapcheck_test.py.
Most of this code is copied from ../valgrind/chrome_tests.py.
TODO(glider): put common functions to a standalone module.
'''
import glob
import logging
import optparse
import os
import stat
import sys
import logging_utils
import path_utils
import common
import heapcheck_test
class TestNotFound(Exception): pass
def Dir2IsNewer(dir1, dir2):
if dir2 is None or not os.path.isdir(dir2):
return False
if dir1 is None or not os.path.isdir(dir1):
return True
return os.stat(dir2)[stat.ST_MTIME] > os.stat(dir1)[stat.ST_MTIME]
def FindNewestDir(dirs):
newest_dir = None
for dir in dirs:
if Dir2IsNewer(newest_dir, dir):
newest_dir = dir
return newest_dir
def File2IsNewer(file1, file2):
if file2 is None or not os.path.isfile(file2):
return False
if file1 is None or not os.path.isfile(file1):
return True
return os.stat(file2)[stat.ST_MTIME] > os.stat(file1)[stat.ST_MTIME]
def FindDirContainingNewestFile(dirs, file):
"""Searches for the directory containing the newest copy of |file|.
Args:
dirs: A list of paths to the directories to search among.
file: A string containing the file name to search.
Returns:
The string representing the the directory containing the newest copy of
|file|.
Raises:
IOError: |file| was not found.
"""
newest_dir = None
newest_file = None
for dir in dirs:
the_file = os.path.join(dir, file)
if File2IsNewer(newest_file, the_file):
newest_dir = dir
newest_file = the_file
if newest_dir is None:
raise IOError("cannot find file %s anywhere, have you built it?" % file)
return newest_dir
class ChromeTests(object):
'''This class is derived from the chrome_tests.py file in ../purify/.
'''
def __init__(self, options, args, test):
# The known list of tests.
# Recognise the original abbreviations as well as full executable names.
self._test_list = {
"ash": self.TestAsh, "ash_unittests": self.TestAsh,
"aura": self.TestAura, "aura_unittests": self.TestAura,
"base": self.TestBase, "base_unittests": self.TestBase,
"browser": self.TestBrowser, "browser_tests": self.TestBrowser,
"chromeos": self.TestChromeOS, "chromeos_unittests": self.TestChromeOS,
"compositor": self.TestCompositor,
"compositor_unittests": self.TestCompositor,
"content": self.TestContent, "content_unittests": self.TestContent,
"content_browsertests": self.TestContentBrowser,
"courgette": self.TestCourgette,
"courgette_unittests": self.TestCourgette,
"crypto": self.TestCrypto, "crypto_unittests": self.TestCrypto,
"device": self.TestDevice, "device_unittests": self.TestDevice,
"googleurl": self.TestGURL, "googleurl_unittests": self.TestGURL,
"url": self.TestURL, "url_unittests": self.TestURL,
"ipc": self.TestIpc, "ipc_tests": self.TestIpc,
"layout": self.TestLayout, "layout_tests": self.TestLayout,
"media": self.TestMedia, "media_unittests": self.TestMedia,
"net": self.TestNet, "net_unittests": self.TestNet,
"printing": self.TestPrinting, "printing_unittests": self.TestPrinting,
"remoting": self.TestRemoting, "remoting_unittests": self.TestRemoting,
"sql": self.TestSql, "sql_unittests": self.TestSql,
"startup": self.TestStartup, "startup_tests": self.TestStartup,
"sync": self.TestSync, "sync_unit_tests": self.TestSync,
"ui_unit": self.TestUIUnit, "ui_unittests": self.TestUIUnit,
"unit": self.TestUnit, "unit_tests": self.TestUnit,
"views": self.TestViews, "views_unittests": self.TestViews,
}
if test not in self._test_list:
raise TestNotFound("Unknown test: %s" % test)
self._options = options
self._args = args
self._test = test
script_dir = path_utils.ScriptDir()
# Compute the top of the tree (the "source dir") from the script dir (where
# this script lives). We assume that the script dir is in tools/heapcheck/
# relative to the top of the tree.
self._source_dir = os.path.dirname(os.path.dirname(script_dir))
# Since this path is used for string matching, make sure it's always
# an absolute Unix-style path.
self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/')
heapcheck_test_script = os.path.join(script_dir, "heapcheck_test.py")
self._command_preamble = [heapcheck_test_script]
def _DefaultCommand(self, module, exe=None, heapcheck_test_args=None):
'''Generates the default command array that most tests will use.
Args:
module: The module name (corresponds to the dir in src/ where the test
data resides).
exe: The executable name.
heapcheck_test_args: additional arguments to append to the command line.
Returns:
A string with the command to run the test.
'''
if not self._options.build_dir:
dirs = [
os.path.join(self._source_dir, "xcodebuild", "Debug"),
os.path.join(self._source_dir, "out", "Debug"),
]
if exe:
self._options.build_dir = FindDirContainingNewestFile(dirs, exe)
else:
self._options.build_dir = FindNewestDir(dirs)
cmd = list(self._command_preamble)
if heapcheck_test_args != None:
for arg in heapcheck_test_args:
cmd.append(arg)
if exe:
cmd.append(os.path.join(self._options.build_dir, exe))
# Heapcheck runs tests slowly, so slow tests hurt more; show elapased time
# so we can find the slowpokes.
cmd.append("--gtest_print_time")
if self._options.gtest_repeat:
cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat)
return cmd
def Suppressions(self):
'''Builds the list of available suppressions files.'''
ret = []
directory = path_utils.ScriptDir()
suppression_file = os.path.join(directory, "suppressions.txt")
if os.path.exists(suppression_file):
ret.append(suppression_file)
suppression_file = os.path.join(directory, "suppressions_linux.txt")
if os.path.exists(suppression_file):
ret.append(suppression_file)
return ret
def Run(self):
'''Runs the test specified by command-line argument --test.'''
logging.info("running test %s" % (self._test))
return self._test_list[self._test]()
def _ReadGtestFilterFile(self, name, cmd):
'''Reads files which contain lists of tests to filter out with
--gtest_filter and appends the command-line option to |cmd|.
Args:
name: the test executable name.
cmd: the test running command line to be modified.
'''
filters = []
directory = path_utils.ScriptDir()
gtest_filter_files = [
os.path.join(directory, name + ".gtest-heapcheck.txt"),
# TODO(glider): Linux vs. CrOS?
]
logging.info("Reading gtest exclude filter files:")
for filename in gtest_filter_files:
# strip the leading absolute path (may be very long on the bot)
# and the following / or \.
readable_filename = filename.replace(self._source_dir, "")[1:]
if not os.path.exists(filename):
logging.info(" \"%s\" - not found" % readable_filename)
continue
logging.info(" \"%s\" - OK" % readable_filename)
f = open(filename, 'r')
for line in f.readlines():
if line.startswith("#") or line.startswith("//") or line.isspace():
continue
line = line.rstrip()
filters.append(line)
gtest_filter = self._options.gtest_filter
if len(filters):
if gtest_filter:
gtest_filter += ":"
if gtest_filter.find("-") < 0:
gtest_filter += "-"
else:
gtest_filter = "-"
gtest_filter += ":".join(filters)
if gtest_filter:
cmd.append("--gtest_filter=%s" % gtest_filter)
def SimpleTest(self, module, name, heapcheck_test_args=None, cmd_args=None):
'''Builds the command line and runs the specified test.
Args:
module: The module name (corresponds to the dir in src/ where the test
data resides).
name: The executable name.
heapcheck_test_args: Additional command line args for heap checker.
cmd_args: Additional command line args for the test.
'''
cmd = self._DefaultCommand(module, name, heapcheck_test_args)
supp = self.Suppressions()
self._ReadGtestFilterFile(name, cmd)
if cmd_args:
cmd.extend(["--"])
cmd.extend(cmd_args)
# Sets LD_LIBRARY_PATH to the build folder so external libraries can be
# loaded.
if (os.getenv("LD_LIBRARY_PATH")):
os.putenv("LD_LIBRARY_PATH", "%s:%s" % (os.getenv("LD_LIBRARY_PATH"),
self._options.build_dir))
else:
os.putenv("LD_LIBRARY_PATH", self._options.build_dir)
return heapcheck_test.RunTool(cmd, supp, module)
def TestAsh(self):
return self.SimpleTest("ash", "ash_unittests")
def TestAura(self):
return self.SimpleTest("aura", "aura_unittests")
def TestBase(self):
return self.SimpleTest("base", "base_unittests")
def TestBrowser(self):
return self.SimpleTest("chrome", "browser_tests")
def TestChromeOS(self):
return self.SimpleTest("chromeos", "chromeos_unittests")
def TestCompositor(self):
return self.SimpleTest("compositor", "compositor_unittests")
def TestContent(self):
return self.SimpleTest("content", "content_unittests")
def TestContentBrowser(self):
return self.SimpleTest("content", "content_browsertests")
def TestCourgette(self):
return self.SimpleTest("courgette", "courgette_unittests")
def TestCrypto(self):
return self.SimpleTest("crypto", "crypto_unittests")
def TestDevice(self):
return self.SimpleTest("device", "device_unittests")
def TestGURL(self):
return self.SimpleTest("chrome", "googleurl_unittests")
def TestURL(self):
return self.SimpleTest("chrome", "url_unittests")
def TestIpc(self):
return self.SimpleTest("ipc", "ipc_tests")
def TestMedia(self):
return self.SimpleTest("chrome", "media_unittests")
def TestNet(self):
return self.SimpleTest("net", "net_unittests")
def TestPrinting(self):
return self.SimpleTest("chrome", "printing_unittests")
def TestRemoting(self):
return self.SimpleTest("chrome", "remoting_unittests")
def TestSync(self):
return self.SimpleTest("chrome", "sync_unit_tests")
def TestStartup(self):
# We don't need the performance results, we're just looking for pointer
# errors, so set number of iterations down to the minimum.
os.putenv("STARTUP_TESTS_NUMCYCLES", "1")
logging.info("export STARTUP_TESTS_NUMCYCLES=1");
return self.SimpleTest("chrome", "startup_tests")
def TestUIUnit(self):
return self.SimpleTest("chrome", "ui_unittests")
def TestUnit(self):
return self.SimpleTest("chrome", "unit_tests")
def TestSql(self):
return self.SimpleTest("chrome", "sql_unittests")
def TestViews(self):
return self.SimpleTest("views", "views_unittests")
def TestLayoutChunk(self, chunk_num, chunk_size):
'''Runs tests [chunk_num*chunk_size .. (chunk_num+1)*chunk_size).
Wrap around to beginning of list at end. If chunk_size is zero, run all
tests in the list once. If a text file is given as argument, it is used as
the list of tests.
'''
# Build the ginormous commandline in 'cmd'.
# It's going to be roughly
# python heapcheck_test.py ... python run_webkit_tests.py ...
# but we'll use the --indirect flag to heapcheck_test.py
# to avoid heapchecking python.
# Start by building the heapcheck_test.py commandline.
cmd = self._DefaultCommand("webkit")
# Now build script_cmd, the run_webkits_tests.py commandline
# Store each chunk in its own directory so that we can find the data later
chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num)
out_dir = os.path.join(path_utils.ScriptDir(), "latest")
out_dir = os.path.join(out_dir, chunk_dir)
if os.path.exists(out_dir):
old_files = glob.glob(os.path.join(out_dir, "*.txt"))
for f in old_files:
os.remove(f)
else:
os.makedirs(out_dir)
script = os.path.join(self._source_dir, "webkit", "tools", "layout_tests",
"run_webkit_tests.py")
script_cmd = ["python", script, "--run-singly", "-v",
"--noshow-results", "--time-out-ms=200000",
"--nocheck-sys-deps"]
# Pass build mode to run_webkit_tests.py. We aren't passed it directly,
# so parse it out of build_dir. run_webkit_tests.py can only handle
# the two values "Release" and "Debug".
# TODO(Hercules): unify how all our scripts pass around build mode
# (--mode / --target / --build_dir / --debug)
if self._options.build_dir.endswith("Debug"):
script_cmd.append("--debug");
if (chunk_size > 0):
script_cmd.append("--run-chunk=%d:%d" % (chunk_num, chunk_size))
if len(self._args):
# if the arg is a txt file, then treat it as a list of tests
if os.path.isfile(self._args[0]) and self._args[0][-4:] == ".txt":
script_cmd.append("--test-list=%s" % self._args[0])
else:
script_cmd.extend(self._args)
self._ReadGtestFilterFile("layout", script_cmd)
# Now run script_cmd with the wrapper in cmd
cmd.extend(["--"])
cmd.extend(script_cmd)
supp = self.Suppressions()
return heapcheck_test.RunTool(cmd, supp, "layout")
def TestLayout(self):
'''Runs the layout tests.'''
# A "chunk file" is maintained in the local directory so that each test
# runs a slice of the layout tests of size chunk_size that increments with
# each run. Since tests can be added and removed from the layout tests at
# any time, this is not going to give exact coverage, but it will allow us
# to continuously run small slices of the layout tests under purify rather
# than having to run all of them in one shot.
chunk_size = self._options.num_tests
if (chunk_size == 0):
return self.TestLayoutChunk(0, 0)
chunk_num = 0
chunk_file = os.path.join("heapcheck_layout_chunk.txt")
logging.info("Reading state from " + chunk_file)
try:
f = open(chunk_file)
if f:
str = f.read()
if len(str):
chunk_num = int(str)
# This should be enough so that we have a couple of complete runs
# of test data stored in the archive (although note that when we loop
# that we almost guaranteed won't be at the end of the test list)
if chunk_num > 10000:
chunk_num = 0
f.close()
except IOError, (errno, strerror):
logging.error("error reading from file %s (%d, %s)" % (chunk_file,
errno, strerror))
ret = self.TestLayoutChunk(chunk_num, chunk_size)
# Wait until after the test runs to completion to write out the new chunk
# number. This way, if the bot is killed, we'll start running again from
# the current chunk rather than skipping it.
logging.info("Saving state to " + chunk_file)
try:
f = open(chunk_file, "w")
chunk_num += 1
f.write("%d" % chunk_num)
f.close()
except IOError, (errno, strerror):
logging.error("error writing to file %s (%d, %s)" % (chunk_file, errno,
strerror))
# Since we're running small chunks of the layout tests, it's important to
# mark the ones that have errors in them. These won't be visible in the
# summary list for long, but will be useful for someone reviewing this bot.
return ret
def main():
if not sys.platform.startswith('linux'):
logging.error("Heap checking works only on Linux at the moment.")
return 1
parser = optparse.OptionParser("usage: %prog -b <dir> -t <test> "
"[-t <test> ...]")
parser.disable_interspersed_args()
parser.add_option("-b", "--build_dir",
help="the location of the output of the compiler output")
parser.add_option("-t", "--test", action="append",
help="which test to run")
parser.add_option("", "--gtest_filter",
help="additional arguments to --gtest_filter")
parser.add_option("", "--gtest_repeat",
help="argument for --gtest_repeat")
parser.add_option("-v", "--verbose", action="store_true", default=False,
help="verbose output - enable debug log messages")
# My machine can do about 120 layout tests/hour in release mode.
# Let's do 30 minutes worth per run.
# The CPU is mostly idle, so perhaps we can raise this when
# we figure out how to run them more efficiently.
parser.add_option("-n", "--num_tests", default=60, type="int",
help="for layout tests: # of subtests per run. 0 for all.")
options, args = parser.parse_args()
if options.verbose:
logging_utils.config_root(logging.DEBUG)
else:
logging_utils.config_root()
if not options.test or not len(options.test):
parser.error("--test not specified")
for t in options.test:
tests = ChromeTests(options, args, t)
ret = tests.Run()
if ret:
return ret
return 0
if __name__ == "__main__":
sys.exit(main())
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
334,
67,
9,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
2344,
23773,
7750,
18221,
2295,
4012,
13295,
1074,
63,
396,
14,
647,
14,
199,
199,
24625,
402,
642,
1233,
365,
8876,
687,
24272,
637,
21510,
15,
9887,
63,
2219,
14,
647,
14,
199,
11768,
8,
71,
11306,
304,
5324,
2863,
3423,
370,
282,
18042,
859,
14,
199,
2344,
199,
199,
646,
5739,
199,
646,
2050,
199,
646,
8691,
199,
646,
747,
199,
646,
5672,
199,
646,
984,
199,
199,
646,
2050,
63,
1208,
199,
646,
931,
63,
1208,
199,
199,
646,
2863,
199,
646,
13295,
1074,
63,
396,
199,
199,
533,
1379,
4667,
8,
1726,
304,
986,
199,
199,
318,
25866,
18,
1831,
4665,
281,
8,
694,
17,
12,
2935,
18,
304,
523,
340,
2935,
18,
365,
488,
503,
440,
747,
14,
515,
14,
6027,
8,
694,
18,
304,
272,
372,
756,
523,
340,
2935,
17,
365,
488,
503,
440,
747,
14,
515,
14,
6027,
8,
694,
17,
304,
272,
372,
715,
523,
372,
747,
14,
3736,
8,
694,
18,
2788,
3736,
14,
840,
63,
45,
4961,
61,
690,
747,
14,
3736,
8,
694,
17,
2788,
3736,
14,
840,
63,
45,
4961,
61,
199,
199,
318,
6668,
4665,
597,
3567,
8,
3220,
304,
523,
29608,
63,
694,
275,
488,
523,
367,
2935,
315,
7606,
26,
272,
340,
25866,
18,
1831,
4665,
281,
8,
1222,
597,
63,
694,
12,
2935,
304,
489,
29608,
63,
694,
275,
2935,
523,
372,
29608,
63,
694,
199,
199,
318,
3814,
18,
1831,
4665,
281,
8,
493,
17,
12,
570,
18,
304,
523,
340,
570,
18,
365,
488,
503,
440,
747,
14,
515,
14,
6292,
8,
493,
18,
304,
272,
372,
756,
523,
340,
570,
17,
365,
488,
503,
440,
747,
14,
515,
14,
6292,
8,
493,
17,
304,
272,
372,
715,
523,
372,
747,
14,
3736,
8,
493,
18,
2788,
3736,
14,
840,
63,
45,
4961,
61,
690,
747,
14,
3736,
8,
493,
17,
2788,
3736,
14,
840,
63,
45,
4961,
61,
199,
199,
318,
6668,
3567,
714,
24522,
4665,
597,
1173,
8,
3220,
12,
570,
304,
523,
408,
5278,
397,
367,
314,
2082,
3035,
314,
29608,
1331,
402,
1204,
493,
18257,
819,
3033,
26,
272,
7606,
26,
437,
769,
402,
3792,
370,
314,
6602,
370,
2754,
16885,
14,
272,
570,
26,
437,
1059,
3035,
314,
570,
536,
370,
2754,
14,
819,
1803,
26,
272,
710,
1059,
6144,
314,
314,
2082,
3035,
314,
29608,
1331,
402,
272,
1204,
493,
18257,
819,
6218,
26,
272,
5925,
26,
1204,
493,
92,
1990,
440,
1911,
14,
523,
408,
523,
29608,
63,
694,
275,
488,
523,
29608,
63,
493,
275,
488,
523,
367,
2935,
315,
7606,
26,
272,
314,
63,
493,
275,
747,
14,
515,
14,
904,
8,
694,
12,
570,
9,
272,
340,
3814,
18,
1831,
4665,
281,
8,
1222,
597,
63,
493,
12,
314,
63,
493,
304,
489,
29608,
63,
694,
275,
2935,
489,
29608,
63,
493,
275,
314,
63,
493,
523,
340,
29608,
63,
694,
365,
488,
26,
272,
746,
5925,
480,
11250,
2342,
570,
450,
83,
26523,
12,
1172,
1265,
6137,
652,
13472,
450,
570,
9,
523,
372,
29608,
63,
694,
199,
199,
533,
16776,
2925,
8,
785,
304,
523,
1449,
2765,
1021,
365,
7131,
687,
314,
18221,
63,
2219,
14,
647,
570,
315,
24272,
6653,
2021,
8083,
523,
1449,
819,
347,
636,
826,
721,
277,
12,
1511,
12,
1249,
12,
511,
304,
272,
327,
710,
6040,
769,
402,
2295,
14,
272,
327,
799,
6862,
572,
314,
3379,
2236,
23988,
1298,
465,
5521,
465,
2615,
7286,
1561,
14,
272,
291,
423,
396,
63,
513,
275,
469,
489,
298,
1119,
582,
291,
14,
774,
33,
609,
12,
4519,
298,
1119,
63,
31053,
582,
291,
14,
774,
33,
609,
12,
489,
298,
65,
12417,
582,
291,
14,
774,
33,
12417,
12,
3322,
298,
65,
12417,
63,
31053,
582,
291,
14,
774,
33,
12417,
12,
489,
298,
1095,
582,
291,
14,
14440,
12,
3322,
298,
1095,
63,
31053,
582,
291,
14,
14440,
12,
489,
298,
5750,
582,
291,
14,
774,
11930,
12,
420,
298,
5750,
63,
2219,
582,
291,
14,
774,
11930,
12,
489,
298,
9887,
736,
582,
291,
14,
774,
18083,
3100,
12,
259,
298,
9887,
736,
63,
31053,
582,
291,
14,
774,
18083,
3100,
12,
489,
298,
7784,
2221,
269,
582,
291,
14,
774,
16273,
2221,
269,
12,
489,
298,
7784,
2221,
269,
63,
31053,
582,
291,
14,
774,
16273,
2221,
269,
12,
489,
298,
1317,
582,
291,
14,
774,
2714,
12,
420,
298,
1317,
63,
31053,
582,
291,
14,
774,
2714,
12,
489,
298,
1317,
63,
5750,
2219,
582,
291,
14,
774,
2714,
11930,
12,
489,
298,
25715,
362,
266,
582,
291,
14,
774,
35,
567,
362,
266,
12,
489,
298,
25715,
362,
266,
63,
31053,
582,
291,
14,
774,
35,
567,
362,
266,
12,
489,
298,
10316,
582,
291,
14,
774,
17134,
12,
263,
298,
10316,
63,
31053,
582,
291,
14,
774,
17134,
12,
489,
298,
1782,
582,
291,
14,
774,
2510,
12,
263,
298,
1782,
63,
31053,
582,
291,
14,
774,
2510,
12,
489,
298,
3098,
633,
582,
291,
14,
774,
39,
2632,
12,
755,
298,
3098,
633,
63,
31053,
582,
291,
14,
774,
39,
2632,
12,
489,
298,
633,
582,
291,
14,
774,
2632,
12,
4519,
298,
633,
63,
31053,
582,
291,
14,
774,
2632,
12,
489,
298,
32352,
582,
291,
14,
774,
41,
2352,
12,
4519,
298,
32352,
63,
2219,
582,
291,
14,
774,
41,
2352,
12,
489,
298,
4209,
582,
291,
14,
774,
4798,
12,
263,
298,
4209,
63,
2219,
582,
291,
14,
774,
4798,
12,
489,
298,
4603,
582,
291,
14,
774,
11398,
12,
3515,
298,
4603,
63,
31053,
582,
291,
14,
774,
11398,
12,
489,
298,
846,
582,
291,
14,
774,
2480,
12,
4519,
298,
846,
63,
31053,
582,
291,
14,
774,
2480,
12,
489,
298,
26514,
582,
291,
14,
774,
5375,
316,
12,
259,
298,
26514,
63,
31053,
582,
291,
14,
774,
5375,
316,
12,
489,
298,
13179,
15866,
582,
291
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
334,
67,
9,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
2344,
23773,
7750,
18221,
2295,
4012,
13295,
1074,
63,
396,
14,
647,
14,
199,
199,
24625,
402,
642,
1233,
365,
8876,
687,
24272,
637,
21510,
15,
9887,
63,
2219,
14,
647,
14,
199,
11768,
8,
71,
11306,
304,
5324,
2863,
3423,
370,
282,
18042,
859,
14,
199,
2344,
199,
199,
646,
5739,
199,
646,
2050,
199,
646,
8691,
199,
646,
747,
199,
646,
5672,
199,
646,
984,
199,
199,
646,
2050,
63,
1208,
199,
646,
931,
63,
1208,
199,
199,
646,
2863,
199,
646,
13295,
1074,
63,
396,
199,
199,
533,
1379,
4667,
8,
1726,
304,
986,
199,
199,
318,
25866,
18,
1831,
4665,
281,
8,
694,
17,
12,
2935,
18,
304,
523,
340,
2935,
18,
365,
488,
503,
440,
747,
14,
515,
14,
6027,
8,
694,
18,
304,
272,
372,
756,
523,
340,
2935,
17,
365,
488,
503,
440,
747,
14,
515,
14,
6027,
8,
694,
17,
304,
272,
372,
715,
523,
372,
747,
14,
3736,
8,
694,
18,
2788,
3736,
14,
840,
63,
45,
4961,
61,
690,
747,
14,
3736,
8,
694,
17,
2788,
3736,
14,
840,
63,
45,
4961,
61,
199,
199,
318,
6668,
4665,
597,
3567,
8,
3220,
304,
523,
29608,
63,
694,
275,
488,
523,
367,
2935,
315,
7606,
26,
272,
340,
25866,
18,
1831,
4665,
281,
8,
1222,
597,
63,
694,
12,
2935,
304,
489,
29608,
63,
694,
275,
2935,
523,
372,
29608,
63,
694,
199,
199,
318,
3814,
18,
1831,
4665,
281,
8,
493,
17,
12,
570,
18,
304,
523,
340,
570,
18,
365,
488,
503,
440,
747,
14,
515,
14,
6292,
8,
493,
18,
304,
272,
372,
756,
523,
340,
570,
17,
365,
488,
503,
440,
747,
14,
515,
14,
6292,
8,
493,
17,
304,
272,
372,
715,
523,
372,
747,
14,
3736,
8,
493,
18,
2788,
3736,
14,
840,
63,
45,
4961,
61,
690,
747,
14,
3736,
8,
493,
17,
2788,
3736,
14,
840,
63,
45,
4961,
61,
199,
199,
318,
6668,
3567,
714,
24522,
4665,
597,
1173,
8,
3220,
12,
570,
304,
523,
408,
5278,
397,
367,
314,
2082,
3035,
314,
29608,
1331,
402,
1204,
493,
18257,
819,
3033,
26,
272,
7606,
26,
437,
769,
402,
3792,
370,
314,
6602,
370,
2754,
16885,
14,
272,
570,
26,
437,
1059,
3035,
314,
570,
536,
370,
2754,
14,
819,
1803,
26,
272,
710,
1059,
6144,
314,
314,
2082,
3035,
314,
29608,
1331,
402,
272,
1204,
493,
18257,
819,
6218,
26,
272,
5925,
26,
1204,
493,
92,
1990,
440,
1911,
14,
523,
408,
523,
29608,
63,
694,
275,
488,
523,
29608,
63,
493,
275,
488,
523,
367,
2935,
315,
7606,
26,
272,
314,
63,
493,
275,
747,
14,
515,
14,
904,
8,
694,
12,
570,
9,
272,
340,
3814,
18,
1831,
4665,
281,
8,
1222,
597,
63,
493,
12,
314,
63,
493,
304,
489,
29608,
63,
694,
275,
2935,
489,
29608,
63,
493,
275,
314,
63,
493,
523,
340,
29608,
63,
694,
365,
488,
26,
272,
746,
5925,
480,
11250,
2342,
570,
450,
83,
26523,
12,
1172,
1265,
6137,
652,
13472,
450,
570,
9,
523,
372,
29608,
63,
694,
199,
199,
533,
16776,
2925,
8,
785,
304,
523,
1449,
2765,
1021,
365,
7131,
687,
314,
18221,
63,
2219,
14,
647,
570,
315,
24272,
6653,
2021,
8083,
523,
1449,
819,
347,
636,
826,
721,
277,
12,
1511,
12,
1249,
12,
511,
304,
272,
327,
710,
6040,
769,
402,
2295,
14,
272,
327,
799,
6862,
572,
314,
3379,
2236,
23988,
1298,
465,
5521,
465,
2615,
7286,
1561,
14,
272,
291,
423,
396,
63,
513,
275,
469,
489,
298,
1119,
582,
291,
14,
774,
33,
609,
12,
4519,
298,
1119,
63,
31053,
582,
291,
14,
774,
33,
609,
12,
489,
298,
65,
12417,
582,
291,
14,
774,
33,
12417,
12,
3322,
298,
65,
12417,
63,
31053,
582,
291,
14,
774,
33,
12417,
12,
489,
298,
1095,
582,
291,
14,
14440,
12,
3322,
298,
1095,
63,
31053,
582,
291,
14,
14440,
12,
489,
298,
5750,
582,
291,
14,
774,
11930,
12,
420,
298,
5750,
63,
2219,
582,
291,
14,
774,
11930,
12,
489,
298,
9887,
736,
582,
291,
14,
774,
18083,
3100,
12,
259,
298,
9887,
736,
63,
31053,
582,
291,
14,
774,
18083,
3100,
12,
489,
298,
7784,
2221,
269,
582,
291,
14,
774,
16273,
2221,
269,
12,
489,
298,
7784,
2221,
269,
63,
31053,
582,
291,
14,
774,
16273,
2221,
269,
12,
489,
298,
1317,
582,
291,
14,
774,
2714,
12,
420,
298,
1317,
63,
31053,
582,
291,
14,
774,
2714,
12,
489,
298,
1317,
63,
5750,
2219,
582,
291,
14,
774,
2714,
11930,
12,
489,
298,
25715,
362,
266,
582,
291,
14,
774,
35,
567,
362,
266,
12,
489,
298,
25715,
362,
266,
63,
31053,
582,
291,
14,
774,
35,
567,
362,
266,
12,
489,
298,
10316,
582,
291,
14,
774,
17134,
12,
263,
298,
10316,
63,
31053,
582,
291,
14,
774,
17134,
12,
489,
298,
1782,
582,
291,
14,
774,
2510,
12,
263,
298,
1782,
63,
31053,
582,
291,
14,
774,
2510,
12,
489,
298,
3098,
633,
582,
291,
14,
774,
39,
2632,
12,
755,
298,
3098,
633,
63,
31053,
582,
291,
14,
774,
39,
2632,
12,
489,
298,
633,
582,
291,
14,
774,
2632,
12,
4519,
298,
633,
63,
31053,
582,
291,
14,
774,
2632,
12,
489,
298,
32352,
582,
291,
14,
774,
41,
2352,
12,
4519,
298,
32352,
63,
2219,
582,
291,
14,
774,
41,
2352,
12,
489,
298,
4209,
582,
291,
14,
774,
4798,
12,
263,
298,
4209,
63,
2219,
582,
291,
14,
774,
4798,
12,
489,
298,
4603,
582,
291,
14,
774,
11398,
12,
3515,
298,
4603,
63,
31053,
582,
291,
14,
774,
11398,
12,
489,
298,
846,
582,
291,
14,
774,
2480,
12,
4519,
298,
846,
63,
31053,
582,
291,
14,
774,
2480,
12,
489,
298,
26514,
582,
291,
14,
774,
5375,
316,
12,
259,
298,
26514,
63,
31053,
582,
291,
14,
774,
5375,
316,
12,
489,
298,
13179,
15866,
582,
291,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
pplatek/odoo
|
openerp/modules/graph.py
|
260
|
7763
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2010-2014 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/>.
#
##############################################################################
""" Modules dependency graph. """
import os, sys, imp
from os.path import join as opj
import itertools
import zipimport
import openerp
import openerp.osv as osv
import openerp.tools as tools
import openerp.tools.osutil as osutil
from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools.translate import _
import zipfile
import openerp.release as release
import re
import base64
from zipfile import PyZipFile, ZIP_DEFLATED
from cStringIO import StringIO
import logging
_logger = logging.getLogger(__name__)
class Graph(dict):
""" Modules dependency graph.
The graph is a mapping from module name to Nodes.
"""
def add_node(self, name, info):
max_depth, father = 0, None
for d in info['depends']:
n = self.get(d) or Node(d, self, None) # lazy creation, do not use default value for get()
if n.depth >= max_depth:
father = n
max_depth = n.depth
if father:
return father.add_child(name, info)
else:
return Node(name, self, info)
def update_from_db(self, cr):
if not len(self):
return
# update the graph with values from the database (if exist)
## First, we set the default values for each package in graph
additional_data = dict((key, {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'installed_version': None}) for key in self.keys())
## Then we get the values from the database
cr.execute('SELECT name, id, state, demo AS dbdemo, latest_version AS installed_version'
' FROM ir_module_module'
' WHERE name IN %s',(tuple(additional_data),)
)
## and we update the default values with values from the database
additional_data.update((x['name'], x) for x in cr.dictfetchall())
for package in self.values():
for k, v in additional_data[package.name].items():
setattr(package, k, v)
def add_module(self, cr, module, force=None):
self.add_modules(cr, [module], force)
def add_modules(self, cr, module_list, force=None):
if force is None:
force = []
packages = []
len_graph = len(self)
for module in module_list:
# This will raise an exception if no/unreadable descriptor file.
# NOTE The call to load_information_from_description_file is already
# done by db.initialize, so it is possible to not do it again here.
info = openerp.modules.module.load_information_from_description_file(module)
if info and info['installable']:
packages.append((module, info)) # TODO directly a dict, like in get_modules_with_version
else:
_logger.warning('module %s: not installable, skipped', module)
dependencies = dict([(p, info['depends']) for p, info in packages])
current, later = set([p for p, info in packages]), set()
while packages and current > later:
package, info = packages[0]
deps = info['depends']
# if all dependencies of 'package' are already in the graph, add 'package' in the graph
if reduce(lambda x, y: x and y in self, deps, True):
if not package in current:
packages.pop(0)
continue
later.clear()
current.remove(package)
node = self.add_node(package, info)
for kind in ('init', 'demo', 'update'):
if package in tools.config[kind] or 'all' in tools.config[kind] or kind in force:
setattr(node, kind, True)
else:
later.add(package)
packages.append((package, info))
packages.pop(0)
self.update_from_db(cr)
for package in later:
unmet_deps = filter(lambda p: p not in self, dependencies[package])
_logger.error('module %s: Unmet dependencies: %s', package, ', '.join(unmet_deps))
result = len(self) - len_graph
if result != len(module_list):
_logger.warning('Some modules were not loaded.')
return result
def __iter__(self):
level = 0
done = set(self.keys())
while done:
level_modules = sorted((name, module) for name, module in self.items() if module.depth==level)
for name, module in level_modules:
done.remove(name)
yield module
level += 1
def __str__(self):
return '\n'.join(str(n) for n in self if n.depth == 0)
class Node(object):
""" One module in the modules dependency graph.
Node acts as a per-module singleton. A node is constructed via
Graph.add_module() or Graph.add_modules(). Some of its fields are from
ir_module_module (setted by Graph.update_from_db()).
"""
def __new__(cls, name, graph, info):
if name in graph:
inst = graph[name]
else:
inst = object.__new__(cls)
graph[name] = inst
return inst
def __init__(self, name, graph, info):
self.name = name
self.graph = graph
self.info = info or getattr(self, 'info', {})
if not hasattr(self, 'children'):
self.children = []
if not hasattr(self, 'depth'):
self.depth = 0
@property
def data(self):
return self.info
def add_child(self, name, info):
node = Node(name, self.graph, info)
node.depth = self.depth + 1
if node not in self.children:
self.children.append(node)
for attr in ('init', 'update', 'demo'):
if hasattr(self, attr):
setattr(node, attr, True)
self.children.sort(lambda x, y: cmp(x.name, y.name))
return node
def __setattr__(self, name, value):
super(Node, self).__setattr__(name, value)
if name in ('init', 'update', 'demo'):
tools.config[name][self.name] = 1
for child in self.children:
setattr(child, name, value)
if name == 'depth':
for child in self.children:
setattr(child, name, value + 1)
def __iter__(self):
return itertools.chain(iter(self.children), *map(iter, self.children))
def __str__(self):
return self._pprint()
def _pprint(self, depth=0):
s = '%s\n' % self.name
for c in self.children:
s += '%s`-> %s' % (' ' * depth, c._pprint(depth+1))
return s
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
259,
1898,
334,
35,
9,
7129,
13,
7280,
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,
199,
199,
624,
18167,
5936,
3343,
14,
408,
199,
199,
646,
747,
12,
984,
12,
1742,
199,
504,
747,
14,
515,
492,
4263,
465,
1687,
74,
199,
646,
7975,
199,
646,
3482,
646,
199,
199,
646,
5166,
199,
199,
646,
5166,
14,
4795,
465,
9506,
199,
646,
5166,
14,
2537,
465,
7249,
199,
646,
5166,
14,
2537,
14,
736,
1974,
465,
747,
1974,
199,
504,
5166,
14,
2537,
14,
3489,
63,
2579,
492,
5048,
63,
2579,
465,
3468,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
646,
10392,
199,
646,
5166,
14,
3221,
465,
4683,
199,
199,
646,
295,
199,
646,
1300,
772,
199,
504,
10392,
492,
1611,
15016,
12,
18402,
63,
28506,
199,
504,
15073,
492,
5228,
199,
199,
646,
2050,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
533,
11513,
8,
807,
304,
272,
408,
18167,
5936,
3343,
14,
339,
710,
3343,
365,
282,
4412,
687,
859,
536,
370,
23836,
14,
339,
408,
339,
347,
1050,
63,
932,
8,
277,
12,
536,
12,
2256,
304,
267,
1390,
63,
4631,
12,
1433,
728,
275,
378,
12,
488,
267,
367,
366,
315,
2256,
459,
8912,
2565,
288,
302,
275,
291,
14,
362,
8,
68,
9,
503,
5013,
8,
68,
12,
291,
12,
488,
9,
221,
327,
9617,
7143,
12,
886,
440,
675,
849,
574,
367,
664,
342,
288,
340,
302,
14,
4631,
2356,
1390,
63,
4631,
26,
355,
1433,
728,
275,
302,
355,
1390,
63,
4631,
275,
302,
14,
4631,
267,
340,
1433,
728,
26,
288,
372,
1433,
728,
14,
525,
63,
1739,
8,
354,
12,
2256,
9,
267,
587,
26,
288,
372,
5013,
8,
354,
12,
291,
12,
2256,
9,
339,
347,
1678,
63,
504,
63,
697,
8,
277,
12,
2467,
304,
267,
340,
440,
822,
8,
277,
304,
288,
372,
267,
327,
1678,
314,
3343,
543,
1338,
687,
314,
3050,
334,
692,
2187,
9,
267,
925,
7758,
12,
781,
663,
314,
849,
1338,
367,
1924,
2559,
315,
3343,
267,
4722,
63,
576,
275,
1211,
1332,
498,
12,
791,
344,
356,
378,
12,
283,
929,
356,
283,
324,
7657,
297,
283,
697,
8768,
356,
756,
12,
283,
7657,
63,
1023,
356,
488,
1552,
367,
790,
315,
291,
14,
1612,
1012,
267,
925,
9442,
781,
664,
314,
1338,
687,
314,
3050,
267,
2467,
14,
2526,
360,
4859,
536,
12,
1305,
12,
1174,
12,
14779,
4319,
1592,
8768,
12,
8839,
63,
1023,
4319,
4903,
63,
1023,
7,
673,
283,
221,
4442,
8190,
63,
578,
63,
578,
7,
673,
283,
6038,
536,
1621,
450,
83,
297,
8,
2960,
8,
8460,
63,
576,
16945,
673,
776,
398,
925,
436,
781,
1678,
314,
849,
1338,
543,
1338,
687,
314,
3050,
267,
4722,
63,
576,
14,
873,
1332,
88,
459,
354,
995,
671,
9,
367,
671,
315,
2467,
14,
807,
10174,
1012,
398,
367,
2559,
315,
291,
14,
1459,
837,
288,
367,
1022,
12,
373,
315,
4722,
63,
576,
59,
2491,
14,
354,
1055,
1744,
837,
355,
5371,
8,
2491,
12,
1022,
12,
373,
9,
339,
347,
1050,
63,
578,
8,
277,
12,
2467,
12,
859,
12,
3542,
29,
403,
304,
267,
291,
14,
525,
63,
3112,
8,
1556,
12,
359,
578,
467,
3542,
9,
339,
347,
1050,
63,
3112,
8,
277,
12,
2467,
12,
859,
63,
513,
12,
3542,
29,
403,
304,
267,
340,
3542,
365,
488,
26,
288,
3542,
275,
942,
267,
6117,
275,
942,
267,
822,
63,
2180,
275,
822,
8,
277,
9,
267,
367,
859,
315,
859,
63,
513,
26,
288,
327,
961,
911,
746,
376,
1919,
340,
949,
15,
324,
11875,
5872,
570,
14,
288,
327,
6944,
710,
1240,
370,
2248,
63,
11697,
63,
504,
63,
1802,
63,
493,
365,
2575,
288,
327,
4224,
701,
1592,
14,
8489,
12,
880,
652,
365,
3962,
370,
440,
886,
652,
4020,
2348,
14,
288,
2256,
275,
5166,
14,
3112,
14,
578,
14,
912,
63,
11697,
63,
504,
63,
1802,
63,
493,
8,
578,
9,
288,
340,
2256,
436,
2256,
459,
21762,
2565,
355,
6117,
14,
740,
1332,
578,
12,
2256,
430,
327,
3254,
5370,
282,
1211,
12,
2839,
315,
664,
63,
3112,
63,
1045,
63,
1023,
288,
587,
26,
355,
485,
2921,
14,
3764,
360,
578,
450,
83,
26,
440,
3907,
461,
12,
9645,
297,
859,
9,
398,
5124,
275,
1211,
7694,
80,
12,
2256,
459,
8912,
1105,
367,
299,
12,
2256,
315,
6117,
566,
267,
1453,
12,
2945,
275,
663,
779,
80,
367,
299,
12,
2256,
315,
6117,
2522,
663,
342,
398,
1830,
6117,
436,
1453,
690,
2945,
26,
288,
2559,
12,
2256,
275,
6117,
59,
16,
61,
288,
10140,
275,
2256,
459,
8912,
418,
953,
327,
340,
1006,
5124,
402,
283,
2491,
7,
787,
2575,
315,
314,
3343,
12,
1050,
283,
2491,
7,
315,
314,
3343,
288,
340,
7114,
8,
2734,
671,
12,
612,
26,
671,
436
] |
[
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,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
259,
1898,
334,
35,
9,
7129,
13,
7280,
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,
199,
199,
624,
18167,
5936,
3343,
14,
408,
199,
199,
646,
747,
12,
984,
12,
1742,
199,
504,
747,
14,
515,
492,
4263,
465,
1687,
74,
199,
646,
7975,
199,
646,
3482,
646,
199,
199,
646,
5166,
199,
199,
646,
5166,
14,
4795,
465,
9506,
199,
646,
5166,
14,
2537,
465,
7249,
199,
646,
5166,
14,
2537,
14,
736,
1974,
465,
747,
1974,
199,
504,
5166,
14,
2537,
14,
3489,
63,
2579,
492,
5048,
63,
2579,
465,
3468,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
646,
10392,
199,
646,
5166,
14,
3221,
465,
4683,
199,
199,
646,
295,
199,
646,
1300,
772,
199,
504,
10392,
492,
1611,
15016,
12,
18402,
63,
28506,
199,
504,
15073,
492,
5228,
199,
199,
646,
2050,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
533,
11513,
8,
807,
304,
272,
408,
18167,
5936,
3343,
14,
339,
710,
3343,
365,
282,
4412,
687,
859,
536,
370,
23836,
14,
339,
408,
339,
347,
1050,
63,
932,
8,
277,
12,
536,
12,
2256,
304,
267,
1390,
63,
4631,
12,
1433,
728,
275,
378,
12,
488,
267,
367,
366,
315,
2256,
459,
8912,
2565,
288,
302,
275,
291,
14,
362,
8,
68,
9,
503,
5013,
8,
68,
12,
291,
12,
488,
9,
221,
327,
9617,
7143,
12,
886,
440,
675,
849,
574,
367,
664,
342,
288,
340,
302,
14,
4631,
2356,
1390,
63,
4631,
26,
355,
1433,
728,
275,
302,
355,
1390,
63,
4631,
275,
302,
14,
4631,
267,
340,
1433,
728,
26,
288,
372,
1433,
728,
14,
525,
63,
1739,
8,
354,
12,
2256,
9,
267,
587,
26,
288,
372,
5013,
8,
354,
12,
291,
12,
2256,
9,
339,
347,
1678,
63,
504,
63,
697,
8,
277,
12,
2467,
304,
267,
340,
440,
822,
8,
277,
304,
288,
372,
267,
327,
1678,
314,
3343,
543,
1338,
687,
314,
3050,
334,
692,
2187,
9,
267,
925,
7758,
12,
781,
663,
314,
849,
1338,
367,
1924,
2559,
315,
3343,
267,
4722,
63,
576,
275,
1211,
1332,
498,
12,
791,
344,
356,
378,
12,
283,
929,
356,
283,
324,
7657,
297,
283,
697,
8768,
356,
756,
12,
283,
7657,
63,
1023,
356,
488,
1552,
367,
790,
315,
291,
14,
1612,
1012,
267,
925,
9442,
781,
664,
314,
1338,
687,
314,
3050,
267,
2467,
14,
2526,
360,
4859,
536,
12,
1305,
12,
1174,
12,
14779,
4319,
1592,
8768,
12,
8839,
63,
1023,
4319,
4903,
63,
1023,
7,
673,
283,
221,
4442,
8190,
63,
578,
63,
578,
7,
673,
283,
6038,
536,
1621,
450,
83,
297,
8,
2960,
8,
8460,
63,
576,
16945,
673,
776,
398,
925,
436,
781,
1678,
314,
849,
1338,
543,
1338,
687,
314,
3050,
267,
4722,
63,
576,
14,
873,
1332,
88,
459,
354,
995,
671,
9,
367,
671,
315,
2467,
14,
807,
10174,
1012,
398,
367,
2559,
315,
291,
14,
1459,
837,
288,
367,
1022,
12,
373,
315,
4722,
63,
576,
59,
2491,
14,
354,
1055,
1744,
837,
355,
5371,
8,
2491,
12,
1022,
12,
373,
9,
339,
347,
1050,
63,
578,
8,
277,
12,
2467,
12,
859,
12,
3542,
29,
403,
304,
267,
291,
14,
525,
63,
3112,
8,
1556,
12,
359,
578,
467,
3542,
9,
339,
347,
1050,
63,
3112,
8,
277,
12,
2467,
12,
859,
63,
513,
12,
3542,
29,
403,
304,
267,
340,
3542,
365,
488,
26,
288,
3542,
275,
942,
267,
6117,
275,
942,
267,
822,
63,
2180,
275,
822,
8,
277,
9,
267,
367,
859,
315,
859,
63,
513,
26,
288,
327,
961,
911,
746,
376,
1919,
340,
949,
15,
324,
11875,
5872,
570,
14,
288,
327,
6944,
710,
1240,
370,
2248,
63,
11697,
63,
504,
63,
1802,
63,
493,
365,
2575,
288,
327,
4224,
701,
1592,
14,
8489,
12,
880,
652,
365,
3962,
370,
440,
886,
652,
4020,
2348,
14,
288,
2256,
275,
5166,
14,
3112,
14,
578,
14,
912,
63,
11697,
63,
504,
63,
1802,
63,
493,
8,
578,
9,
288,
340,
2256,
436,
2256,
459,
21762,
2565,
355,
6117,
14,
740,
1332,
578,
12,
2256,
430,
327,
3254,
5370,
282,
1211,
12,
2839,
315,
664,
63,
3112,
63,
1045,
63,
1023,
288,
587,
26,
355,
485,
2921,
14,
3764,
360,
578,
450,
83,
26,
440,
3907,
461,
12,
9645,
297,
859,
9,
398,
5124,
275,
1211,
7694,
80,
12,
2256,
459,
8912,
1105,
367,
299,
12,
2256,
315,
6117,
566,
267,
1453,
12,
2945,
275,
663,
779,
80,
367,
299,
12,
2256,
315,
6117,
2522,
663,
342,
398,
1830,
6117,
436,
1453,
690,
2945,
26,
288,
2559,
12,
2256,
275,
6117,
59,
16,
61,
288,
10140,
275,
2256,
459,
8912,
418,
953,
327,
340,
1006,
5124,
402,
283,
2491,
7,
787,
2575,
315,
314,
3343,
12,
1050,
283,
2491,
7,
315,
314,
3343,
288,
340,
7114,
8,
2734,
671,
12,
612,
26,
671,
436,
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,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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
] |
mKeRix/home-assistant
|
tests/components/auth/test_init_link_user.py
|
21
|
3674
|
"""Tests for the link user flow."""
from . import async_setup_auth
from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI
async def async_get_code(hass, aiohttp_client):
"""Return authorization code for link user tests."""
config = [
{
"name": "Example",
"type": "insecure_example",
"users": [
{"username": "test-user", "password": "test-pass", "name": "Test Name"}
],
},
{
"name": "Example",
"id": "2nd auth",
"type": "insecure_example",
"users": [
{"username": "2nd-user", "password": "2nd-pass", "name": "2nd Name"}
],
},
]
client = await async_setup_auth(hass, aiohttp_client, config)
user = await hass.auth.async_create_user(name="Hello")
refresh_token = await hass.auth.async_create_refresh_token(user, CLIENT_ID)
access_token = hass.auth.async_create_access_token(refresh_token)
# Now authenticate with the 2nd flow
resp = await client.post(
"/auth/login_flow",
json={
"client_id": CLIENT_ID,
"handler": ["insecure_example", "2nd auth"],
"redirect_uri": CLIENT_REDIRECT_URI,
"type": "link_user",
},
)
assert resp.status == 200
step = await resp.json()
resp = await client.post(
f"/auth/login_flow/{step['flow_id']}",
json={"client_id": CLIENT_ID, "username": "2nd-user", "password": "2nd-pass"},
)
assert resp.status == 200
step = await resp.json()
return {
"user": user,
"code": step["result"],
"client": client,
"access_token": access_token,
}
async def test_link_user(hass, aiohttp_client):
"""Test linking a user to new credentials."""
info = await async_get_code(hass, aiohttp_client)
client = info["client"]
code = info["code"]
# Link user
resp = await client.post(
"/auth/link_user",
json={"client_id": CLIENT_ID, "code": code},
headers={"authorization": f"Bearer {info['access_token']}"},
)
assert resp.status == 200
assert len(info["user"].credentials) == 1
async def test_link_user_invalid_client_id(hass, aiohttp_client):
"""Test linking a user to new credentials."""
info = await async_get_code(hass, aiohttp_client)
client = info["client"]
code = info["code"]
# Link user
resp = await client.post(
"/auth/link_user",
json={"client_id": "invalid", "code": code},
headers={"authorization": f"Bearer {info['access_token']}"},
)
assert resp.status == 400
assert len(info["user"].credentials) == 0
async def test_link_user_invalid_code(hass, aiohttp_client):
"""Test linking a user to new credentials."""
info = await async_get_code(hass, aiohttp_client)
client = info["client"]
# Link user
resp = await client.post(
"/auth/link_user",
json={"client_id": CLIENT_ID, "code": "invalid"},
headers={"authorization": f"Bearer {info['access_token']}"},
)
assert resp.status == 400
assert len(info["user"].credentials) == 0
async def test_link_user_invalid_auth(hass, aiohttp_client):
"""Test linking a user to new credentials."""
info = await async_get_code(hass, aiohttp_client)
client = info["client"]
code = info["code"]
# Link user
resp = await client.post(
"/auth/link_user",
json={"client_id": CLIENT_ID, "code": code},
headers={"authorization": "Bearer invalid"},
)
assert resp.status == 401
assert len(info["user"].credentials) == 0
|
mit
|
[
624,
2925,
367,
314,
2142,
922,
6369,
1041,
199,
504,
1275,
492,
5316,
63,
2758,
63,
1178,
199,
199,
504,
2295,
14,
2330,
492,
14214,
1309,
63,
998,
12,
14214,
1309,
63,
19747,
63,
7639,
421,
199,
4146,
347,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
1767,
13448,
1233,
367,
2142,
922,
2295,
1041,
272,
1101,
275,
359,
267,
469,
288,
298,
354,
582,
298,
9846,
401,
288,
298,
466,
582,
298,
24824,
63,
2694,
401,
288,
298,
3707,
582,
359,
355,
2420,
2473,
582,
298,
396,
13,
751,
401,
298,
2060,
582,
298,
396,
13,
1529,
401,
298,
354,
582,
298,
774,
2812,
3570,
288,
2156,
267,
1660,
267,
469,
288,
298,
354,
582,
298,
9846,
401,
288,
298,
344,
582,
298,
18,
977,
1790,
401,
288,
298,
466,
582,
298,
24824,
63,
2694,
401,
288,
298,
3707,
582,
359,
355,
2420,
2473,
582,
298,
18,
977,
13,
751,
401,
298,
2060,
582,
298,
18,
977,
13,
1529,
401,
298,
354,
582,
298,
18,
977,
2812,
3570,
288,
2156,
267,
1660,
272,
1622,
272,
1890,
275,
5517,
5316,
63,
2758,
63,
1178,
8,
5387,
12,
30274,
63,
1258,
12,
1101,
9,
272,
922,
275,
5517,
6298,
14,
1178,
14,
4146,
63,
981,
63,
751,
8,
354,
628,
6257,
531,
272,
9236,
63,
1418,
275,
5517,
6298,
14,
1178,
14,
4146,
63,
981,
63,
6635,
63,
1418,
8,
751,
12,
14214,
1309,
63,
998,
9,
272,
2879,
63,
1418,
275,
6298,
14,
1178,
14,
4146,
63,
981,
63,
2732,
63,
1418,
8,
6635,
63,
1418,
9,
339,
327,
7356,
12895,
543,
314,
499,
977,
6369,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
2886,
63,
1659,
401,
267,
2022,
3126,
288,
298,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
288,
298,
2232,
582,
2097,
24824,
63,
2694,
401,
298,
18,
977,
1790,
2255,
288,
298,
4876,
63,
2302,
582,
14214,
1309,
63,
19747,
63,
7639,
12,
288,
298,
466,
582,
298,
1073,
63,
751,
401,
267,
1660,
272,
776,
272,
702,
3085,
14,
1205,
508,
1926,
272,
3650,
275,
5517,
3085,
14,
1001,
342,
339,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
289,
15313,
1178,
15,
2886,
63,
1659,
5321,
2926,
459,
1659,
63,
344,
418,
10750,
267,
2022,
8871,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
298,
2473,
582,
298,
18,
977,
13,
751,
401,
298,
2060,
582,
298,
18,
977,
13,
1529,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
1926,
272,
3650,
275,
5517,
3085,
14,
1001,
342,
339,
372,
469,
267,
298,
751,
582,
922,
12,
267,
298,
600,
582,
3650,
905,
1099,
2255,
267,
298,
1258,
582,
1890,
12,
267,
298,
2732,
63,
1418,
582,
2879,
63,
1418,
12,
272,
789,
421,
199,
4146,
347,
511,
63,
1073,
63,
751,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
774,
25833,
282,
922,
370,
892,
6235,
1041,
272,
2256,
275,
5517,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
9,
272,
1890,
275,
2256,
905,
1258,
937,
272,
1233,
275,
2256,
905,
600,
937,
339,
327,
10967,
922,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
1073,
63,
751,
401,
267,
2022,
8871,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
298,
600,
582,
1233,
1386,
267,
2323,
8871,
15846,
582,
289,
2,
3655,
21462,
469,
815,
459,
2732,
63,
1418,
12074,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
1926,
272,
702,
822,
8,
815,
905,
751,
4140,
6942,
9,
508,
413,
421,
199,
4146,
347,
511,
63,
1073,
63,
751,
63,
3197,
63,
1258,
63,
344,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
774,
25833,
282,
922,
370,
892,
6235,
1041,
272,
2256,
275,
5517,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
9,
272,
1890,
275,
2256,
905,
1258,
937,
272,
1233,
275,
2256,
905,
600,
937,
339,
327,
10967,
922,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
1073,
63,
751,
401,
267,
2022,
8871,
1258,
63,
344,
582,
298,
3197,
401,
298,
600,
582,
1233,
1386,
267,
2323,
8871,
15846,
582,
289,
2,
3655,
21462,
469,
815,
459,
2732,
63,
1418,
12074,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
8290,
272,
702,
822,
8,
815,
905,
751,
4140,
6942,
9,
508,
378,
421,
199,
4146,
347,
511,
63,
1073,
63,
751,
63,
3197,
63,
600,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
774,
25833,
282,
922,
370,
892,
6235,
1041,
272,
2256,
275,
5517,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
9,
272,
1890,
275,
2256,
905,
1258,
937,
339,
327,
10967,
922,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
1073,
63,
751,
401,
267,
2022,
8871,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
298,
600,
582,
298,
3197,
6018,
267,
2323,
8871,
15846,
582,
289,
2,
3655,
21462,
469,
815,
459,
2732,
63,
1418,
12074,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
8290,
272,
702,
822,
8,
815,
905,
751,
4140,
6942,
9,
508,
378,
421,
199,
4146,
347,
511,
63,
1073,
63,
751,
63,
3197,
63,
1178,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
774,
25833,
282,
922,
370,
892,
6235,
1041,
272,
2256,
275,
5517,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
9,
272,
1890,
275,
2256,
905,
1258,
937,
272,
1233,
275,
2256,
905,
600,
937,
339,
327,
10967,
922,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
1073,
63,
751,
401,
267,
2022,
8871,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
298,
600,
582,
1233,
1386,
267,
2323,
8871,
15846,
582,
298,
3655,
21462,
3866,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
13952,
272,
702,
822,
8,
815,
905,
751,
4140,
6942,
9,
508,
378,
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
] |
[
2925,
367,
314,
2142,
922,
6369,
1041,
199,
504,
1275,
492,
5316,
63,
2758,
63,
1178,
199,
199,
504,
2295,
14,
2330,
492,
14214,
1309,
63,
998,
12,
14214,
1309,
63,
19747,
63,
7639,
421,
199,
4146,
347,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
1767,
13448,
1233,
367,
2142,
922,
2295,
1041,
272,
1101,
275,
359,
267,
469,
288,
298,
354,
582,
298,
9846,
401,
288,
298,
466,
582,
298,
24824,
63,
2694,
401,
288,
298,
3707,
582,
359,
355,
2420,
2473,
582,
298,
396,
13,
751,
401,
298,
2060,
582,
298,
396,
13,
1529,
401,
298,
354,
582,
298,
774,
2812,
3570,
288,
2156,
267,
1660,
267,
469,
288,
298,
354,
582,
298,
9846,
401,
288,
298,
344,
582,
298,
18,
977,
1790,
401,
288,
298,
466,
582,
298,
24824,
63,
2694,
401,
288,
298,
3707,
582,
359,
355,
2420,
2473,
582,
298,
18,
977,
13,
751,
401,
298,
2060,
582,
298,
18,
977,
13,
1529,
401,
298,
354,
582,
298,
18,
977,
2812,
3570,
288,
2156,
267,
1660,
272,
1622,
272,
1890,
275,
5517,
5316,
63,
2758,
63,
1178,
8,
5387,
12,
30274,
63,
1258,
12,
1101,
9,
272,
922,
275,
5517,
6298,
14,
1178,
14,
4146,
63,
981,
63,
751,
8,
354,
628,
6257,
531,
272,
9236,
63,
1418,
275,
5517,
6298,
14,
1178,
14,
4146,
63,
981,
63,
6635,
63,
1418,
8,
751,
12,
14214,
1309,
63,
998,
9,
272,
2879,
63,
1418,
275,
6298,
14,
1178,
14,
4146,
63,
981,
63,
2732,
63,
1418,
8,
6635,
63,
1418,
9,
339,
327,
7356,
12895,
543,
314,
499,
977,
6369,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
2886,
63,
1659,
401,
267,
2022,
3126,
288,
298,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
288,
298,
2232,
582,
2097,
24824,
63,
2694,
401,
298,
18,
977,
1790,
2255,
288,
298,
4876,
63,
2302,
582,
14214,
1309,
63,
19747,
63,
7639,
12,
288,
298,
466,
582,
298,
1073,
63,
751,
401,
267,
1660,
272,
776,
272,
702,
3085,
14,
1205,
508,
1926,
272,
3650,
275,
5517,
3085,
14,
1001,
342,
339,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
289,
15313,
1178,
15,
2886,
63,
1659,
5321,
2926,
459,
1659,
63,
344,
418,
10750,
267,
2022,
8871,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
298,
2473,
582,
298,
18,
977,
13,
751,
401,
298,
2060,
582,
298,
18,
977,
13,
1529,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
1926,
272,
3650,
275,
5517,
3085,
14,
1001,
342,
339,
372,
469,
267,
298,
751,
582,
922,
12,
267,
298,
600,
582,
3650,
905,
1099,
2255,
267,
298,
1258,
582,
1890,
12,
267,
298,
2732,
63,
1418,
582,
2879,
63,
1418,
12,
272,
789,
421,
199,
4146,
347,
511,
63,
1073,
63,
751,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
774,
25833,
282,
922,
370,
892,
6235,
1041,
272,
2256,
275,
5517,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
9,
272,
1890,
275,
2256,
905,
1258,
937,
272,
1233,
275,
2256,
905,
600,
937,
339,
327,
10967,
922,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
1073,
63,
751,
401,
267,
2022,
8871,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
298,
600,
582,
1233,
1386,
267,
2323,
8871,
15846,
582,
289,
2,
3655,
21462,
469,
815,
459,
2732,
63,
1418,
12074,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
1926,
272,
702,
822,
8,
815,
905,
751,
4140,
6942,
9,
508,
413,
421,
199,
4146,
347,
511,
63,
1073,
63,
751,
63,
3197,
63,
1258,
63,
344,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
774,
25833,
282,
922,
370,
892,
6235,
1041,
272,
2256,
275,
5517,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
9,
272,
1890,
275,
2256,
905,
1258,
937,
272,
1233,
275,
2256,
905,
600,
937,
339,
327,
10967,
922,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
1073,
63,
751,
401,
267,
2022,
8871,
1258,
63,
344,
582,
298,
3197,
401,
298,
600,
582,
1233,
1386,
267,
2323,
8871,
15846,
582,
289,
2,
3655,
21462,
469,
815,
459,
2732,
63,
1418,
12074,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
8290,
272,
702,
822,
8,
815,
905,
751,
4140,
6942,
9,
508,
378,
421,
199,
4146,
347,
511,
63,
1073,
63,
751,
63,
3197,
63,
600,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
774,
25833,
282,
922,
370,
892,
6235,
1041,
272,
2256,
275,
5517,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
9,
272,
1890,
275,
2256,
905,
1258,
937,
339,
327,
10967,
922,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
1073,
63,
751,
401,
267,
2022,
8871,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
298,
600,
582,
298,
3197,
6018,
267,
2323,
8871,
15846,
582,
289,
2,
3655,
21462,
469,
815,
459,
2732,
63,
1418,
12074,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
8290,
272,
702,
822,
8,
815,
905,
751,
4140,
6942,
9,
508,
378,
421,
199,
4146,
347,
511,
63,
1073,
63,
751,
63,
3197,
63,
1178,
8,
5387,
12,
30274,
63,
1258,
304,
272,
408,
774,
25833,
282,
922,
370,
892,
6235,
1041,
272,
2256,
275,
5517,
5316,
63,
362,
63,
600,
8,
5387,
12,
30274,
63,
1258,
9,
272,
1890,
275,
2256,
905,
1258,
937,
272,
1233,
275,
2256,
905,
600,
937,
339,
327,
10967,
922,
272,
3085,
275,
5517,
1890,
14,
1932,
8,
267,
3286,
1178,
15,
1073,
63,
751,
401,
267,
2022,
8871,
1258,
63,
344,
582,
14214,
1309,
63,
998,
12,
298,
600,
582,
1233,
1386,
267,
2323,
8871,
15846,
582,
298,
3655,
21462,
3866,
6018,
272,
776,
339,
702,
3085,
14,
1205,
508,
13952,
272,
702,
822,
8,
815,
905,
751,
4140,
6942,
9,
508,
378,
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,
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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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
SBillion/aegroupware
|
registration/forms.py
|
12
|
4862
|
"""
Forms and validation code for user registration.
"""
from django.contrib.auth.models import User
from django import forms
from django.utils.translation import ugettext_lazy as _
# I put this on all required fields, because it's easier to pick up
# on them with CSS or JavaScript if they have a class of "required"
# in the HTML. Your mileage may vary. If/when Django ticket #3515
# lands in trunk, this will no longer be necessary.
attrs_dict = {'class': 'required'}
class RegistrationForm(forms.Form):
"""
Form for registering a new user account.
Validates that the requested username is not already in use, and
requires the password to be entered twice to catch typos.
Subclasses should feel free to add any additional validation they
need, but should avoid defining a ``save()`` method -- the actual
saving of collected user data is delegated to the active
registration backend.
"""
username = forms.RegexField(regex=r'^\w+$',
max_length=30,
widget=forms.TextInput(attrs=attrs_dict),
label=_("Username"),
error_messages={'invalid': _("This value must contain only letters, numbers and underscores.")})
email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
maxlength=75)),
label=_("Email address"))
password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
label=_("Password"))
password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
label=_("Password (again)"))
def clean_username(self):
"""
Validate that the username is alphanumeric and is not already
in use.
"""
try:
user = User.objects.get(username__iexact=self.cleaned_data['username'])
except User.DoesNotExist:
return self.cleaned_data['username']
raise forms.ValidationError(_("A user with that username already exists."))
def clean(self):
"""
Verifiy that the values entered into the two password fields
match. Note that an error here will end up in
``non_field_errors()`` because it doesn't apply to a single
field.
"""
if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
if self.cleaned_data['password1'] != self.cleaned_data['password2']:
raise forms.ValidationError(_("The two password fields didn't match."))
return self.cleaned_data
class RegistrationFormTermsOfService(RegistrationForm):
"""
Subclass of ``RegistrationForm`` which adds a required checkbox
for agreeing to a site's Terms of Service.
"""
tos = forms.BooleanField(widget=forms.CheckboxInput(attrs=attrs_dict),
label=_(u'I have read and agree to the Terms of Service'),
error_messages={'required': _("You must agree to the terms to register")})
class RegistrationFormUniqueEmail(RegistrationForm):
"""
Subclass of ``RegistrationForm`` which enforces uniqueness of
email addresses.
"""
def clean_email(self):
"""
Validate that the supplied email address is unique for the
site.
"""
if User.objects.filter(email__iexact=self.cleaned_data['email']):
raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
return self.cleaned_data['email']
class RegistrationFormNoFreeEmail(RegistrationForm):
"""
Subclass of ``RegistrationForm`` which disallows registration with
email addresses from popular free webmail services; moderately
useful for preventing automated spam registrations.
To change the list of banned domains, subclass this form and
override the attribute ``bad_domains``.
"""
bad_domains = ['aim.com', 'aol.com', 'email.com', 'gmail.com',
'googlemail.com', 'hotmail.com', 'hushmail.com',
'msn.com', 'mail.ru', 'mailinator.com', 'live.com',
'yahoo.com']
def clean_email(self):
"""
Check the supplied email address against a list of known free
webmail domains.
"""
email_domain = self.cleaned_data['email'].split('@')[1]
if email_domain in self.bad_domains:
raise forms.ValidationError(_("Registration using free email addresses is prohibited. Please supply a different email address."))
return self.cleaned_data['email']
|
mit
|
[
624,
199,
26028,
436,
6411,
1233,
367,
922,
10991,
14,
199,
199,
624,
421,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
492,
4513,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
3,
473,
5324,
642,
641,
1006,
1415,
1504,
12,
2952,
652,
1159,
14905,
370,
3732,
1536,
199,
3,
641,
3062,
543,
15750,
503,
15250,
340,
2985,
1172,
282,
1021,
402,
298,
2427,
2,
199,
3,
315,
314,
4163,
14,
19519,
333,
441,
474,
1443,
17083,
14,
982,
15,
6526,
5634,
12052,
327,
1276,
1046,
199,
3,
634,
5915,
315,
24764,
12,
642,
911,
949,
8088,
506,
5784,
14,
199,
3288,
63,
807,
275,
791,
533,
356,
283,
2427,
936,
421,
199,
533,
20764,
2821,
8,
3351,
14,
2821,
304,
272,
408,
272,
8204,
367,
2274,
316,
282,
892,
922,
2933,
14,
2286,
4821,
2335,
626,
314,
5839,
3434,
365,
440,
2575,
315,
675,
12,
436,
272,
5074,
314,
2505,
370,
506,
19138,
13373,
370,
8579,
10284,
1712,
14,
2286,
20196,
1077,
23109,
2867,
370,
1050,
1263,
4722,
6411,
2985,
272,
1929,
12,
1325,
1077,
5126,
12669,
282,
1124,
2117,
8497,
1083,
1553,
314,
3503,
272,
13369,
402,
13736,
922,
666,
365,
29598,
370,
314,
4702,
272,
10991,
4865,
14,
2286,
408,
272,
3434,
275,
4513,
14,
5103,
792,
8,
3821,
29,
82,
15542,
87,
11,
4268,
1816,
1390,
63,
1267,
29,
1216,
12,
1816,
3938,
29,
3351,
14,
18362,
8,
3288,
29,
3288,
63,
807,
395,
1816,
1768,
9384,
13355,
1288,
1816,
1125,
63,
3431,
3713,
3197,
356,
3824,
2765,
574,
1471,
1395,
1454,
14435,
12,
5579,
436,
23998,
2685,
1552,
272,
3031,
275,
4513,
14,
16577,
8,
3440,
29,
3351,
14,
18362,
8,
3288,
29,
807,
8,
3288,
63,
807,
12,
18295,
19096,
29,
2194,
1826,
2490,
1768,
9384,
7035,
2287,
2237,
272,
2505,
17,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
31804,
8,
3288,
29,
3288,
63,
807,
12,
3795,
63,
585,
29,
797,
395,
1816,
1768,
9384,
6139,
2237,
272,
2505,
18,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
31804,
8,
3288,
29,
3288,
63,
807,
12,
3795,
63,
585,
29,
797,
395,
1816,
1768,
9384,
6139,
334,
14199,
9,
2237,
2286,
347,
3633,
63,
2473,
8,
277,
304,
267,
408,
267,
12134,
626,
314,
3434,
365,
27964,
436,
365,
440,
2575,
267,
315,
675,
14,
2728,
408,
267,
862,
26,
288,
922,
275,
2876,
14,
1462,
14,
362,
8,
2473,
363,
32344,
29,
277,
14,
8275,
63,
576,
459,
2473,
1105,
267,
871,
2876,
14,
7400,
26,
288,
372,
291,
14,
8275,
63,
576,
459,
2473,
418,
267,
746,
4513,
14,
8172,
6115,
33,
922,
543,
626,
3434,
2575,
3495,
13853,
339,
347,
3633,
8,
277,
304,
267,
408,
267,
5444,
1903,
89,
626,
314,
1338,
19138,
1901,
314,
2877,
2505,
1504,
267,
1336,
14,
3390,
626,
376,
1125,
2348,
911,
1284,
1536,
315,
267,
1124,
2865,
63,
698,
63,
2550,
8497,
2952,
652,
3181,
1133,
4838,
370,
282,
2849,
267,
901,
14,
2728,
408,
267,
340,
283,
2060,
17,
7,
315,
291,
14,
8275,
63,
576,
436,
283,
2060,
18,
7,
315,
291,
14,
8275,
63,
576,
26,
288,
340,
291,
14,
8275,
63,
576,
459,
2060,
17,
418,
1137,
291,
14,
8275,
63,
576,
459,
2060,
18,
2565,
355,
746,
4513,
14,
8172,
6115,
1918,
2877,
2505,
1504,
9980,
1133,
1336,
13853,
267,
372,
291,
14,
8275,
63,
576,
421,
199,
533,
20764,
2821,
8600,
706,
3466,
3167,
8,
11757,
2821,
304,
272,
408,
272,
30184,
402,
1124,
11757,
2821,
1040,
1314,
9584,
282,
1415,
24190,
272,
367,
10601,
316,
370,
282,
4770,
1159,
13861,
706,
402,
7591,
14,
2286,
408,
272,
370,
83,
275,
4513,
14,
5036,
8,
3440,
29,
3351,
14,
26366,
3205,
8,
3288,
29,
3288,
63,
807,
395,
2490,
1768,
17441,
85,
7,
41,
1172,
1586,
436,
10601,
370,
314,
13861,
706,
402,
7591,
659,
2490,
1125,
63,
3431,
3713,
2427,
356,
3824,
5556,
1471,
10601,
370,
314,
2895,
370,
2274,
531,
1552,
421,
199,
533,
20764,
2821,
11427,
7035,
8,
11757,
2821,
304,
272,
408,
272,
30184,
402,
1124,
11757,
2821,
1040,
1314,
655,
509,
823,
15439,
31820,
402,
272,
3031,
7149,
14,
2286,
408,
272,
347,
3633,
63,
2123,
8,
277,
304,
267,
408,
267,
12134,
626,
314,
6841,
3031,
2287,
365,
3747,
367,
314,
267,
4770,
14,
2728,
408,
267,
340,
2876,
14,
1462,
14,
1541,
8,
2123,
363,
32344,
29,
277,
14,
8275,
63,
576,
459,
2123,
9090,
288,
746,
4513,
14,
8172,
6115,
2765,
3031,
2287,
365,
2575,
315,
675,
14,
7754,
17169,
282,
3365,
3031,
2287,
13853,
267,
372,
291,
14,
8275,
63,
576,
459,
2123,
418,
421,
199,
533,
20764,
2821,
1944,
10146,
7035,
8,
11757,
2821,
304,
272,
408,
272,
30184,
402,
1124,
11757,
2821,
1040,
1314,
2153,
24077,
10991,
543,
272,
3031,
7149,
687,
4560,
2238,
2867,
3330,
1198,
8500,
27,
818,
1866,
590,
272,
2997,
367,
7981,
316,
6384,
23513,
14909,
25483,
3801,
14,
2286,
4005,
1570,
314,
769,
402,
330,
9386,
14006,
12,
5516,
642,
1824,
436,
272,
4278,
314,
2225,
1124,
4087,
63,
9756,
4345,
2286,
408,
272,
4875,
63,
9756,
275,
788,
65,
1017,
14,
957,
297,
283,
65,
393,
14,
957,
297,
283,
2123,
14,
957,
297,
283,
6799,
14,
957,
297,
673,
283,
3098,
1198,
14,
957,
297,
283,
8885,
1198,
14,
957,
297,
283,
72,
2084,
1198,
14,
957,
297,
673,
283,
706,
78,
14,
957,
297,
283,
1198,
14,
6558,
297,
283,
1198,
8566,
14,
957,
297,
283,
6442,
14,
957,
297,
673,
283,
27231,
14,
957,
418,
2286,
347,
3633,
63,
2123,
8,
277,
304,
267,
408,
267,
2670,
314,
6841,
3031,
2287,
6169,
282,
769,
402,
6040,
2867,
267,
3330,
1198,
14006,
14,
2728,
408,
267,
3031,
63,
2261,
275,
291,
14,
8275,
63,
576,
459,
2123,
2278,
1294,
16591,
5832,
17,
61,
267,
340,
3031,
63,
2261,
315,
291,
14,
4087,
63,
9756,
26,
288,
746,
4513,
14,
8172,
6115,
11757,
1808,
2867,
3031,
7149,
365,
557,
20215,
5703,
14,
7754,
17169,
282,
3365,
3031,
2287,
13853,
267,
372,
291,
14,
8275,
63,
576,
459
] |
[
199,
26028,
436,
6411,
1233,
367,
922,
10991,
14,
199,
199,
624,
421,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
492,
4513,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
3,
473,
5324,
642,
641,
1006,
1415,
1504,
12,
2952,
652,
1159,
14905,
370,
3732,
1536,
199,
3,
641,
3062,
543,
15750,
503,
15250,
340,
2985,
1172,
282,
1021,
402,
298,
2427,
2,
199,
3,
315,
314,
4163,
14,
19519,
333,
441,
474,
1443,
17083,
14,
982,
15,
6526,
5634,
12052,
327,
1276,
1046,
199,
3,
634,
5915,
315,
24764,
12,
642,
911,
949,
8088,
506,
5784,
14,
199,
3288,
63,
807,
275,
791,
533,
356,
283,
2427,
936,
421,
199,
533,
20764,
2821,
8,
3351,
14,
2821,
304,
272,
408,
272,
8204,
367,
2274,
316,
282,
892,
922,
2933,
14,
2286,
4821,
2335,
626,
314,
5839,
3434,
365,
440,
2575,
315,
675,
12,
436,
272,
5074,
314,
2505,
370,
506,
19138,
13373,
370,
8579,
10284,
1712,
14,
2286,
20196,
1077,
23109,
2867,
370,
1050,
1263,
4722,
6411,
2985,
272,
1929,
12,
1325,
1077,
5126,
12669,
282,
1124,
2117,
8497,
1083,
1553,
314,
3503,
272,
13369,
402,
13736,
922,
666,
365,
29598,
370,
314,
4702,
272,
10991,
4865,
14,
2286,
408,
272,
3434,
275,
4513,
14,
5103,
792,
8,
3821,
29,
82,
15542,
87,
11,
4268,
1816,
1390,
63,
1267,
29,
1216,
12,
1816,
3938,
29,
3351,
14,
18362,
8,
3288,
29,
3288,
63,
807,
395,
1816,
1768,
9384,
13355,
1288,
1816,
1125,
63,
3431,
3713,
3197,
356,
3824,
2765,
574,
1471,
1395,
1454,
14435,
12,
5579,
436,
23998,
2685,
1552,
272,
3031,
275,
4513,
14,
16577,
8,
3440,
29,
3351,
14,
18362,
8,
3288,
29,
807,
8,
3288,
63,
807,
12,
18295,
19096,
29,
2194,
1826,
2490,
1768,
9384,
7035,
2287,
2237,
272,
2505,
17,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
31804,
8,
3288,
29,
3288,
63,
807,
12,
3795,
63,
585,
29,
797,
395,
1816,
1768,
9384,
6139,
2237,
272,
2505,
18,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
31804,
8,
3288,
29,
3288,
63,
807,
12,
3795,
63,
585,
29,
797,
395,
1816,
1768,
9384,
6139,
334,
14199,
9,
2237,
2286,
347,
3633,
63,
2473,
8,
277,
304,
267,
408,
267,
12134,
626,
314,
3434,
365,
27964,
436,
365,
440,
2575,
267,
315,
675,
14,
2728,
408,
267,
862,
26,
288,
922,
275,
2876,
14,
1462,
14,
362,
8,
2473,
363,
32344,
29,
277,
14,
8275,
63,
576,
459,
2473,
1105,
267,
871,
2876,
14,
7400,
26,
288,
372,
291,
14,
8275,
63,
576,
459,
2473,
418,
267,
746,
4513,
14,
8172,
6115,
33,
922,
543,
626,
3434,
2575,
3495,
13853,
339,
347,
3633,
8,
277,
304,
267,
408,
267,
5444,
1903,
89,
626,
314,
1338,
19138,
1901,
314,
2877,
2505,
1504,
267,
1336,
14,
3390,
626,
376,
1125,
2348,
911,
1284,
1536,
315,
267,
1124,
2865,
63,
698,
63,
2550,
8497,
2952,
652,
3181,
1133,
4838,
370,
282,
2849,
267,
901,
14,
2728,
408,
267,
340,
283,
2060,
17,
7,
315,
291,
14,
8275,
63,
576,
436,
283,
2060,
18,
7,
315,
291,
14,
8275,
63,
576,
26,
288,
340,
291,
14,
8275,
63,
576,
459,
2060,
17,
418,
1137,
291,
14,
8275,
63,
576,
459,
2060,
18,
2565,
355,
746,
4513,
14,
8172,
6115,
1918,
2877,
2505,
1504,
9980,
1133,
1336,
13853,
267,
372,
291,
14,
8275,
63,
576,
421,
199,
533,
20764,
2821,
8600,
706,
3466,
3167,
8,
11757,
2821,
304,
272,
408,
272,
30184,
402,
1124,
11757,
2821,
1040,
1314,
9584,
282,
1415,
24190,
272,
367,
10601,
316,
370,
282,
4770,
1159,
13861,
706,
402,
7591,
14,
2286,
408,
272,
370,
83,
275,
4513,
14,
5036,
8,
3440,
29,
3351,
14,
26366,
3205,
8,
3288,
29,
3288,
63,
807,
395,
2490,
1768,
17441,
85,
7,
41,
1172,
1586,
436,
10601,
370,
314,
13861,
706,
402,
7591,
659,
2490,
1125,
63,
3431,
3713,
2427,
356,
3824,
5556,
1471,
10601,
370,
314,
2895,
370,
2274,
531,
1552,
421,
199,
533,
20764,
2821,
11427,
7035,
8,
11757,
2821,
304,
272,
408,
272,
30184,
402,
1124,
11757,
2821,
1040,
1314,
655,
509,
823,
15439,
31820,
402,
272,
3031,
7149,
14,
2286,
408,
272,
347,
3633,
63,
2123,
8,
277,
304,
267,
408,
267,
12134,
626,
314,
6841,
3031,
2287,
365,
3747,
367,
314,
267,
4770,
14,
2728,
408,
267,
340,
2876,
14,
1462,
14,
1541,
8,
2123,
363,
32344,
29,
277,
14,
8275,
63,
576,
459,
2123,
9090,
288,
746,
4513,
14,
8172,
6115,
2765,
3031,
2287,
365,
2575,
315,
675,
14,
7754,
17169,
282,
3365,
3031,
2287,
13853,
267,
372,
291,
14,
8275,
63,
576,
459,
2123,
418,
421,
199,
533,
20764,
2821,
1944,
10146,
7035,
8,
11757,
2821,
304,
272,
408,
272,
30184,
402,
1124,
11757,
2821,
1040,
1314,
2153,
24077,
10991,
543,
272,
3031,
7149,
687,
4560,
2238,
2867,
3330,
1198,
8500,
27,
818,
1866,
590,
272,
2997,
367,
7981,
316,
6384,
23513,
14909,
25483,
3801,
14,
2286,
4005,
1570,
314,
769,
402,
330,
9386,
14006,
12,
5516,
642,
1824,
436,
272,
4278,
314,
2225,
1124,
4087,
63,
9756,
4345,
2286,
408,
272,
4875,
63,
9756,
275,
788,
65,
1017,
14,
957,
297,
283,
65,
393,
14,
957,
297,
283,
2123,
14,
957,
297,
283,
6799,
14,
957,
297,
673,
283,
3098,
1198,
14,
957,
297,
283,
8885,
1198,
14,
957,
297,
283,
72,
2084,
1198,
14,
957,
297,
673,
283,
706,
78,
14,
957,
297,
283,
1198,
14,
6558,
297,
283,
1198,
8566,
14,
957,
297,
283,
6442,
14,
957,
297,
673,
283,
27231,
14,
957,
418,
2286,
347,
3633,
63,
2123,
8,
277,
304,
267,
408,
267,
2670,
314,
6841,
3031,
2287,
6169,
282,
769,
402,
6040,
2867,
267,
3330,
1198,
14006,
14,
2728,
408,
267,
3031,
63,
2261,
275,
291,
14,
8275,
63,
576,
459,
2123,
2278,
1294,
16591,
5832,
17,
61,
267,
340,
3031,
63,
2261,
315,
291,
14,
4087,
63,
9756,
26,
288,
746,
4513,
14,
8172,
6115,
11757,
1808,
2867,
3031,
7149,
365,
557,
20215,
5703,
14,
7754,
17169,
282,
3365,
3031,
2287,
13853,
267,
372,
291,
14,
8275,
63,
576,
459,
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
] |
AutorestCI/azure-sdk-for-python
|
azure-mgmt-sql/azure/mgmt/sql/models/resource_identity.py
|
2
|
1661
|
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class ResourceIdentity(Model):
"""Azure Active Directory identity configuration for a resource.
Variables are only populated by the server, and will be ignored when
sending a request.
:ivar principal_id: The Azure Active Directory principal id.
:vartype principal_id: str
:param type: The identity type. Set this to 'SystemAssigned' in order to
automatically create and assign an Azure Active Directory principal for
the resource. Possible values include: 'SystemAssigned'
:type type: str or ~azure.mgmt.sql.models.IdentityType
:ivar tenant_id: The Azure Active Directory tenant id.
:vartype tenant_id: str
"""
_validation = {
'principal_id': {'readonly': True},
'tenant_id': {'readonly': True},
}
_attribute_map = {
'principal_id': {'key': 'principalId', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'tenant_id': {'key': 'tenantId', 'type': 'str'},
}
def __init__(self, type=None):
super(ResourceIdentity, self).__init__()
self.principal_id = None
self.type = type
self.tenant_id = None
|
mit
|
[
3,
2803,
29,
1624,
13,
24,
199,
3,
24775,
199,
3,
1898,
334,
67,
9,
15332,
11098,
14,
2900,
4481,
4644,
14,
199,
3,
3909,
1334,
314,
10697,
844,
14,
1666,
844,
14,
2424,
315,
314,
2199,
1738,
367,
199,
3,
4190,
2556,
14,
199,
3,
199,
3,
5495,
4046,
701,
15332,
334,
50,
9,
9195,
13726,
5495,
15042,
14,
199,
3,
18784,
1443,
7675,
8927,
5953,
436,
911,
506,
14669,
340,
314,
1233,
365,
199,
3,
31904,
14,
199,
3,
24775,
199,
199,
504,
6605,
3911,
14,
12161,
492,
5822,
421,
199,
533,
7337,
10193,
8,
1685,
304,
272,
408,
22386,
23241,
15191,
8503,
2897,
367,
282,
2073,
14,
339,
17198,
787,
1454,
16460,
701,
314,
1654,
12,
436,
911,
506,
5525,
1380,
272,
10209,
282,
1056,
14,
339,
520,
7725,
21646,
63,
344,
26,
710,
15474,
23241,
15191,
21646,
1305,
14,
272,
520,
19729,
21646,
63,
344,
26,
620,
272,
520,
635,
730,
26,
710,
8503,
730,
14,
2494,
642,
370,
283,
3989,
2822,
1737,
7,
315,
1865,
370,
1362,
5847,
1218,
436,
5090,
376,
15474,
23241,
15191,
21646,
367,
1362,
314,
2073,
14,
18558,
1338,
2387,
26,
283,
3989,
2822,
1737,
7,
272,
520,
466,
730,
26,
620,
503,
6146,
9078,
14,
9752,
14,
3009,
14,
992,
14,
10193,
804,
272,
520,
7725,
8261,
63,
344,
26,
710,
15474,
23241,
15191,
8261,
1305,
14,
272,
520,
19729,
8261,
63,
344,
26,
620,
272,
408,
339,
485,
6136,
275,
469,
267,
283,
19200,
63,
344,
356,
791,
6753,
356,
715,
1386,
267,
283,
4647,
63,
344,
356,
791,
6753,
356,
715,
1386,
272,
789,
339,
485,
3215,
63,
1130,
275,
469,
267,
283,
19200,
63,
344,
356,
791,
498,
356,
283,
19200,
1304,
297,
283,
466,
356,
283,
495,
2267,
267,
283,
466,
356,
791,
498,
356,
283,
466,
297,
283,
466,
356,
283,
495,
2267,
267,
283,
4647,
63,
344,
356,
791,
498,
356,
283,
4647,
1304,
297,
283,
466,
356,
283,
495,
2267,
272,
789,
339,
347,
636,
826,
721,
277,
12,
730,
29,
403,
304,
267,
1613,
8,
4031,
10193,
12,
291,
2843,
826,
4533,
267,
291,
14,
19200,
63,
344,
275,
488,
267,
291,
14,
466,
275,
730,
267,
291,
14,
4647,
63,
344,
275,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2803,
29,
1624,
13,
24,
199,
3,
24775,
199,
3,
1898,
334,
67,
9,
15332,
11098,
14,
2900,
4481,
4644,
14,
199,
3,
3909,
1334,
314,
10697,
844,
14,
1666,
844,
14,
2424,
315,
314,
2199,
1738,
367,
199,
3,
4190,
2556,
14,
199,
3,
199,
3,
5495,
4046,
701,
15332,
334,
50,
9,
9195,
13726,
5495,
15042,
14,
199,
3,
18784,
1443,
7675,
8927,
5953,
436,
911,
506,
14669,
340,
314,
1233,
365,
199,
3,
31904,
14,
199,
3,
24775,
199,
199,
504,
6605,
3911,
14,
12161,
492,
5822,
421,
199,
533,
7337,
10193,
8,
1685,
304,
272,
408,
22386,
23241,
15191,
8503,
2897,
367,
282,
2073,
14,
339,
17198,
787,
1454,
16460,
701,
314,
1654,
12,
436,
911,
506,
5525,
1380,
272,
10209,
282,
1056,
14,
339,
520,
7725,
21646,
63,
344,
26,
710,
15474,
23241,
15191,
21646,
1305,
14,
272,
520,
19729,
21646,
63,
344,
26,
620,
272,
520,
635,
730,
26,
710,
8503,
730,
14,
2494,
642,
370,
283,
3989,
2822,
1737,
7,
315,
1865,
370,
1362,
5847,
1218,
436,
5090,
376,
15474,
23241,
15191,
21646,
367,
1362,
314,
2073,
14,
18558,
1338,
2387,
26,
283,
3989,
2822,
1737,
7,
272,
520,
466,
730,
26,
620,
503,
6146,
9078,
14,
9752,
14,
3009,
14,
992,
14,
10193,
804,
272,
520,
7725,
8261,
63,
344,
26,
710,
15474,
23241,
15191,
8261,
1305,
14,
272,
520,
19729,
8261,
63,
344,
26,
620,
272,
408,
339,
485,
6136,
275,
469,
267,
283,
19200,
63,
344,
356,
791,
6753,
356,
715,
1386,
267,
283,
4647,
63,
344,
356,
791,
6753,
356,
715,
1386,
272,
789,
339,
485,
3215,
63,
1130,
275,
469,
267,
283,
19200,
63,
344,
356,
791,
498,
356,
283,
19200,
1304,
297,
283,
466,
356,
283,
495,
2267,
267,
283,
466,
356,
791,
498,
356,
283,
466,
297,
283,
466,
356,
283,
495,
2267,
267,
283,
4647,
63,
344,
356,
791,
498,
356,
283,
4647,
1304,
297,
283,
466,
356,
283,
495,
2267,
272,
789,
339,
347,
636,
826,
721,
277,
12,
730,
29,
403,
304,
267,
1613,
8,
4031,
10193,
12,
291,
2843,
826,
4533,
267,
291,
14,
19200,
63,
344,
275,
488,
267,
291,
14,
466,
275,
730,
267,
291,
14,
4647,
63,
344,
275,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
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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################
#
# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com)
# All Right Reserved
#
# Author : Nicolas Bessi (Camptocamp)
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
##############################################################################
import header
import company
import report_helper
import webkit_report
import ir_report
import wizard
import convert
import 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,
199,
3,
1898,
334,
67,
9,
7129,
24569,
475,
20290,
13950,
334,
1014,
921,
1544,
14,
20290,
475,
20290,
14,
957,
9,
221,
199,
3,
2900,
20854,
5702,
199,
3,
199,
3,
6529,
520,
30650,
761,
305,
699,
28601,
334,
3630,
311,
475,
20290,
9,
199,
3,
199,
3,
14750,
26,
961,
2240,
465,
4066,
365,
11619,
370,
506,
1202,
701,
22398,
28661,
199,
3,
2240,
16465,
3963,
5452,
314,
8852,
9163,
83,
3616,
402,
465,
5480,
316,
1006,
12330,
199,
3,
406,
13436,
9183,
687,
2399,
1566,
1061,
315,
9587,
27164,
2578,
436,
18227,
199,
3,
9599,
4390,
3963,
787,
10023,
367,
282,
10144,
13,
475,
13,
1180,
8744,
543,
2414,
23012,
199,
3,
486,
10475,
397,
436,
2291,
787,
30390,
1503,
722,
68,
370,
16077,
282,
2868,
2290,
199,
3,
7591,
15878,
199,
3,
199,
3,
961,
2240,
365,
2868,
2290,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
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,
3,
199,
4605,
199,
199,
646,
1406,
199,
646,
7233,
199,
646,
3622,
63,
3676,
199,
646,
15804,
63,
3070,
199,
646,
8190,
63,
3070,
199,
646,
12262,
199,
646,
3957,
199,
646,
3622,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
1898,
334,
67,
9,
7129,
24569,
475,
20290,
13950,
334,
1014,
921,
1544,
14,
20290,
475,
20290,
14,
957,
9,
221,
199,
3,
2900,
20854,
5702,
199,
3,
199,
3,
6529,
520,
30650,
761,
305,
699,
28601,
334,
3630,
311,
475,
20290,
9,
199,
3,
199,
3,
14750,
26,
961,
2240,
465,
4066,
365,
11619,
370,
506,
1202,
701,
22398,
28661,
199,
3,
2240,
16465,
3963,
5452,
314,
8852,
9163,
83,
3616,
402,
465,
5480,
316,
1006,
12330,
199,
3,
406,
13436,
9183,
687,
2399,
1566,
1061,
315,
9587,
27164,
2578,
436,
18227,
199,
3,
9599,
4390,
3963,
787,
10023,
367,
282,
10144,
13,
475,
13,
1180,
8744,
543,
2414,
23012,
199,
3,
486,
10475,
397,
436,
2291,
787,
30390,
1503,
722,
68,
370,
16077,
282,
2868,
2290,
199,
3,
7591,
15878,
199,
3,
199,
3,
961,
2240,
365,
2868,
2290,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
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,
3,
199,
4605,
199,
199,
646,
1406,
199,
646,
7233,
199,
646,
3622,
63,
3676,
199,
646,
15804,
63,
3070,
199,
646,
8190,
63,
3070,
199,
646,
12262,
199,
646,
3957,
199,
646,
3622,
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,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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
] |
krisys/django
|
tests/generic_inline_admin/models.py
|
281
|
1708
|
from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class Episode(models.Model):
name = models.CharField(max_length=100)
length = models.CharField(max_length=100, blank=True)
author = models.CharField(max_length=100, blank=True)
@python_2_unicode_compatible
class Media(models.Model):
"""
Media that can associated to any object.
"""
content_type = models.ForeignKey(ContentType, models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey()
url = models.URLField()
description = models.CharField(max_length=100, blank=True)
keywords = models.CharField(max_length=100, blank=True)
def __str__(self):
return self.url
#
# Generic inline with unique_together
#
class Category(models.Model):
name = models.CharField(max_length=50)
class PhoneNumber(models.Model):
content_type = models.ForeignKey(ContentType, models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
phone_number = models.CharField(max_length=30)
category = models.ForeignKey(Category, models.SET_NULL, null=True, blank=True)
class Meta:
unique_together = (('content_type', 'object_id', 'phone_number',),)
class Contact(models.Model):
name = models.CharField(max_length=50)
phone_numbers = GenericRelation(PhoneNumber, related_query_name='phone_numbers')
#
# Generic inline with can_delete=False
#
class EpisodePermanent(Episode):
pass
|
bsd-3-clause
|
[
504,
1639,
14,
2828,
14,
10778,
14,
955,
492,
334,
272,
8307,
3190,
12,
8307,
12617,
12,
199,
9,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1208,
14,
2991,
492,
2366,
63,
18,
63,
2975,
63,
6490,
421,
199,
533,
27255,
6045,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
272,
2582,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
9,
272,
4132,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
9,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
12300,
8,
992,
14,
1685,
304,
272,
408,
272,
12300,
626,
883,
4568,
370,
1263,
909,
14,
272,
408,
272,
1564,
63,
466,
275,
1709,
14,
3190,
8,
11282,
12,
1709,
14,
10855,
9,
272,
909,
63,
344,
275,
1709,
14,
8591,
342,
272,
1564,
63,
785,
275,
8307,
3190,
342,
272,
1166,
275,
1709,
14,
17363,
342,
272,
1369,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
9,
272,
7681,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
633,
421,
199,
3,
199,
3,
8307,
8308,
543,
3747,
63,
6314,
199,
3,
199,
533,
13573,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1400,
9,
421,
199,
533,
27585,
3259,
8,
992,
14,
1685,
304,
272,
1564,
63,
466,
275,
1709,
14,
3190,
8,
11282,
12,
1709,
14,
10855,
9,
272,
909,
63,
344,
275,
1709,
14,
8591,
342,
272,
1564,
63,
785,
275,
8307,
3190,
360,
1317,
63,
466,
297,
283,
785,
63,
344,
358,
272,
14617,
63,
1955,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1216,
9,
272,
4637,
275,
1709,
14,
3190,
8,
7841,
12,
1709,
14,
3597,
63,
8084,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
339,
1021,
6288,
26,
267,
3747,
63,
6314,
275,
13636,
1317,
63,
466,
297,
283,
785,
63,
344,
297,
283,
9339,
63,
1955,
5529,
9,
421,
199,
533,
18684,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1400,
9,
272,
14617,
63,
10548,
275,
8307,
12617,
8,
25640,
12,
4048,
63,
1131,
63,
354,
534,
9339,
63,
10548,
358,
421,
199,
3,
199,
3,
8307,
8308,
543,
883,
63,
1807,
29,
797,
199,
3,
199,
533,
27255,
6045,
31776,
8,
22887,
304,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
2828,
14,
10778,
14,
955,
492,
334,
272,
8307,
3190,
12,
8307,
12617,
12,
199,
9,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1208,
14,
2991,
492,
2366,
63,
18,
63,
2975,
63,
6490,
421,
199,
533,
27255,
6045,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
272,
2582,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
9,
272,
4132,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
9,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
12300,
8,
992,
14,
1685,
304,
272,
408,
272,
12300,
626,
883,
4568,
370,
1263,
909,
14,
272,
408,
272,
1564,
63,
466,
275,
1709,
14,
3190,
8,
11282,
12,
1709,
14,
10855,
9,
272,
909,
63,
344,
275,
1709,
14,
8591,
342,
272,
1564,
63,
785,
275,
8307,
3190,
342,
272,
1166,
275,
1709,
14,
17363,
342,
272,
1369,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
9,
272,
7681,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
633,
421,
199,
3,
199,
3,
8307,
8308,
543,
3747,
63,
6314,
199,
3,
199,
533,
13573,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1400,
9,
421,
199,
533,
27585,
3259,
8,
992,
14,
1685,
304,
272,
1564,
63,
466,
275,
1709,
14,
3190,
8,
11282,
12,
1709,
14,
10855,
9,
272,
909,
63,
344,
275,
1709,
14,
8591,
342,
272,
1564,
63,
785,
275,
8307,
3190,
360,
1317,
63,
466,
297,
283,
785,
63,
344,
358,
272,
14617,
63,
1955,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1216,
9,
272,
4637,
275,
1709,
14,
3190,
8,
7841,
12,
1709,
14,
3597,
63,
8084,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
339,
1021,
6288,
26,
267,
3747,
63,
6314,
275,
13636,
1317,
63,
466,
297,
283,
785,
63,
344,
297,
283,
9339,
63,
1955,
5529,
9,
421,
199,
533,
18684,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1400,
9,
272,
14617,
63,
10548,
275,
8307,
12617,
8,
25640,
12,
4048,
63,
1131,
63,
354,
534,
9339,
63,
10548,
358,
421,
199,
3,
199,
3,
8307,
8308,
543,
883,
63,
1807,
29,
797,
199,
3,
199,
533,
27255,
6045,
31776,
8,
22887,
304,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
alazaro/tennis_tournament
|
django/contrib/gis/db/models/query.py
|
290
|
35968
|
from django.db import connections
from django.db.models.query import QuerySet, Q, ValuesQuerySet, ValuesListQuerySet
from django.contrib.gis.db.models import aggregates
from django.contrib.gis.db.models.fields import get_srid_info, GeometryField, PointField, LineStringField
from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery, GeoWhereNode
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Area, Distance
class GeoQuerySet(QuerySet):
"The Geographic QuerySet."
### Methods overloaded from QuerySet ###
def __init__(self, model=None, query=None, using=None):
super(GeoQuerySet, self).__init__(model=model, query=query, using=using)
self.query = query or GeoQuery(self.model)
def values(self, *fields):
return self._clone(klass=GeoValuesQuerySet, setup=True, _fields=fields)
def values_list(self, *fields, **kwargs):
flat = kwargs.pop('flat', False)
if kwargs:
raise TypeError('Unexpected keyword arguments to values_list: %s'
% (kwargs.keys(),))
if flat and len(fields) > 1:
raise TypeError("'flat' is not valid when values_list is called with more than one field.")
return self._clone(klass=GeoValuesListQuerySet, setup=True, flat=flat,
_fields=fields)
### GeoQuerySet Methods ###
def area(self, tolerance=0.05, **kwargs):
"""
Returns the area of the geographic field in an `area` attribute on
each element of this GeoQuerySet.
"""
# Peforming setup here rather than in `_spatial_attribute` so that
# we can get the units for `AreaField`.
procedure_args, geo_field = self._spatial_setup('area', field_name=kwargs.get('field_name', None))
s = {'procedure_args' : procedure_args,
'geo_field' : geo_field,
'setup' : False,
}
connection = connections[self.db]
backend = connection.ops
if backend.oracle:
s['procedure_fmt'] = '%(geo_col)s,%(tolerance)s'
s['procedure_args']['tolerance'] = tolerance
s['select_field'] = AreaField('sq_m') # Oracle returns area in units of meters.
elif backend.postgis or backend.spatialite:
if backend.geography:
# Geography fields support area calculation, returns square meters.
s['select_field'] = AreaField('sq_m')
elif not geo_field.geodetic(connection):
# Getting the area units of the geographic field.
s['select_field'] = AreaField(Area.unit_attname(geo_field.units_name(connection)))
else:
# TODO: Do we want to support raw number areas for geodetic fields?
raise Exception('Area on geodetic coordinate systems not supported.')
return self._spatial_attribute('area', s, **kwargs)
def centroid(self, **kwargs):
"""
Returns the centroid of the geographic field in a `centroid`
attribute on each element of this GeoQuerySet.
"""
return self._geom_attribute('centroid', **kwargs)
def collect(self, **kwargs):
"""
Performs an aggregate collect operation on the given geometry field.
This is analagous to a union operation, but much faster because
boundaries are not dissolved.
"""
return self._spatial_aggregate(aggregates.Collect, **kwargs)
def difference(self, geom, **kwargs):
"""
Returns the spatial difference of the geographic field in a `difference`
attribute on each element of this GeoQuerySet.
"""
return self._geomset_attribute('difference', geom, **kwargs)
def distance(self, geom, **kwargs):
"""
Returns the distance from the given geographic field name to the
given geometry in a `distance` attribute on each element of the
GeoQuerySet.
Keyword Arguments:
`spheroid` => If the geometry field is geodetic and PostGIS is
the spatial database, then the more accurate
spheroid calculation will be used instead of the
quicker sphere calculation.
`tolerance` => Used only for Oracle. The tolerance is
in meters -- a default of 5 centimeters (0.05)
is used.
"""
return self._distance_attribute('distance', geom, **kwargs)
def envelope(self, **kwargs):
"""
Returns a Geometry representing the bounding box of the
Geometry field in an `envelope` attribute on each element of
the GeoQuerySet.
"""
return self._geom_attribute('envelope', **kwargs)
def extent(self, **kwargs):
"""
Returns the extent (aggregate) of the features in the GeoQuerySet. The
extent will be returned as a 4-tuple, consisting of (xmin, ymin, xmax, ymax).
"""
return self._spatial_aggregate(aggregates.Extent, **kwargs)
def extent3d(self, **kwargs):
"""
Returns the aggregate extent, in 3D, of the features in the
GeoQuerySet. It is returned as a 6-tuple, comprising:
(xmin, ymin, zmin, xmax, ymax, zmax).
"""
return self._spatial_aggregate(aggregates.Extent3D, **kwargs)
def force_rhr(self, **kwargs):
"""
Returns a modified version of the Polygon/MultiPolygon in which
all of the vertices follow the Right-Hand-Rule. By default,
this is attached as the `force_rhr` attribute on each element
of the GeoQuerySet.
"""
return self._geom_attribute('force_rhr', **kwargs)
def geojson(self, precision=8, crs=False, bbox=False, **kwargs):
"""
Returns a GeoJSON representation of the geomtry field in a `geojson`
attribute on each element of the GeoQuerySet.
The `crs` and `bbox` keywords may be set to True if the users wants
the coordinate reference system and the bounding box to be included
in the GeoJSON representation of the geometry.
"""
backend = connections[self.db].ops
if not backend.geojson:
raise NotImplementedError('Only PostGIS 1.3.4+ supports GeoJSON serialization.')
if not isinstance(precision, (int, long)):
raise TypeError('Precision keyword must be set with an integer.')
# Setting the options flag -- which depends on which version of
# PostGIS we're using.
if backend.spatial_version >= (1, 4, 0):
options = 0
if crs and bbox: options = 3
elif bbox: options = 1
elif crs: options = 2
else:
options = 0
if crs and bbox: options = 3
elif crs: options = 1
elif bbox: options = 2
s = {'desc' : 'GeoJSON',
'procedure_args' : {'precision' : precision, 'options' : options},
'procedure_fmt' : '%(geo_col)s,%(precision)s,%(options)s',
}
return self._spatial_attribute('geojson', s, **kwargs)
def geohash(self, precision=20, **kwargs):
"""
Returns a GeoHash representation of the given field in a `geohash`
attribute on each element of the GeoQuerySet.
The `precision` keyword may be used to custom the number of
_characters_ used in the output GeoHash, the default is 20.
"""
s = {'desc' : 'GeoHash',
'procedure_args': {'precision': precision},
'procedure_fmt': '%(geo_col)s,%(precision)s',
}
return self._spatial_attribute('geohash', s, **kwargs)
def gml(self, precision=8, version=2, **kwargs):
"""
Returns GML representation of the given field in a `gml` attribute
on each element of the GeoQuerySet.
"""
backend = connections[self.db].ops
s = {'desc' : 'GML', 'procedure_args' : {'precision' : precision}}
if backend.postgis:
# PostGIS AsGML() aggregate function parameter order depends on the
# version -- uggh.
if backend.spatial_version > (1, 3, 1):
procedure_fmt = '%(version)s,%(geo_col)s,%(precision)s'
else:
procedure_fmt = '%(geo_col)s,%(precision)s,%(version)s'
s['procedure_args'] = {'precision' : precision, 'version' : version}
return self._spatial_attribute('gml', s, **kwargs)
def intersection(self, geom, **kwargs):
"""
Returns the spatial intersection of the Geometry field in
an `intersection` attribute on each element of this
GeoQuerySet.
"""
return self._geomset_attribute('intersection', geom, **kwargs)
def kml(self, **kwargs):
"""
Returns KML representation of the geometry field in a `kml`
attribute on each element of this GeoQuerySet.
"""
s = {'desc' : 'KML',
'procedure_fmt' : '%(geo_col)s,%(precision)s',
'procedure_args' : {'precision' : kwargs.pop('precision', 8)},
}
return self._spatial_attribute('kml', s, **kwargs)
def length(self, **kwargs):
"""
Returns the length of the geometry field as a `Distance` object
stored in a `length` attribute on each element of this GeoQuerySet.
"""
return self._distance_attribute('length', None, **kwargs)
def make_line(self, **kwargs):
"""
Creates a linestring from all of the PointField geometries in the
this GeoQuerySet and returns it. This is a spatial aggregate
method, and thus returns a geometry rather than a GeoQuerySet.
"""
return self._spatial_aggregate(aggregates.MakeLine, geo_field_type=PointField, **kwargs)
def mem_size(self, **kwargs):
"""
Returns the memory size (number of bytes) that the geometry field takes
in a `mem_size` attribute on each element of this GeoQuerySet.
"""
return self._spatial_attribute('mem_size', {}, **kwargs)
def num_geom(self, **kwargs):
"""
Returns the number of geometries if the field is a
GeometryCollection or Multi* Field in a `num_geom`
attribute on each element of this GeoQuerySet; otherwise
the sets with None.
"""
return self._spatial_attribute('num_geom', {}, **kwargs)
def num_points(self, **kwargs):
"""
Returns the number of points in the first linestring in the
Geometry field in a `num_points` attribute on each element of
this GeoQuerySet; otherwise sets with None.
"""
return self._spatial_attribute('num_points', {}, **kwargs)
def perimeter(self, **kwargs):
"""
Returns the perimeter of the geometry field as a `Distance` object
stored in a `perimeter` attribute on each element of this GeoQuerySet.
"""
return self._distance_attribute('perimeter', None, **kwargs)
def point_on_surface(self, **kwargs):
"""
Returns a Point geometry guaranteed to lie on the surface of the
Geometry field in a `point_on_surface` attribute on each element
of this GeoQuerySet; otherwise sets with None.
"""
return self._geom_attribute('point_on_surface', **kwargs)
def reverse_geom(self, **kwargs):
"""
Reverses the coordinate order of the geometry, and attaches as a
`reverse` attribute on each element of this GeoQuerySet.
"""
s = {'select_field' : GeomField(),}
kwargs.setdefault('model_att', 'reverse_geom')
if connections[self.db].ops.oracle:
s['geo_field_type'] = LineStringField
return self._spatial_attribute('reverse', s, **kwargs)
def scale(self, x, y, z=0.0, **kwargs):
"""
Scales the geometry to a new size by multiplying the ordinates
with the given x,y,z scale factors.
"""
if connections[self.db].ops.spatialite:
if z != 0.0:
raise NotImplementedError('SpatiaLite does not support 3D scaling.')
s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s',
'procedure_args' : {'x' : x, 'y' : y},
'select_field' : GeomField(),
}
else:
s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s,%(z)s',
'procedure_args' : {'x' : x, 'y' : y, 'z' : z},
'select_field' : GeomField(),
}
return self._spatial_attribute('scale', s, **kwargs)
def snap_to_grid(self, *args, **kwargs):
"""
Snap all points of the input geometry to the grid. How the
geometry is snapped to the grid depends on how many arguments
were given:
- 1 argument : A single size to snap both the X and Y grids to.
- 2 arguments: X and Y sizes to snap the grid to.
- 4 arguments: X, Y sizes and the X, Y origins.
"""
if False in [isinstance(arg, (float, int, long)) for arg in args]:
raise TypeError('Size argument(s) for the grid must be a float or integer values.')
nargs = len(args)
if nargs == 1:
size = args[0]
procedure_fmt = '%(geo_col)s,%(size)s'
procedure_args = {'size' : size}
elif nargs == 2:
xsize, ysize = args
procedure_fmt = '%(geo_col)s,%(xsize)s,%(ysize)s'
procedure_args = {'xsize' : xsize, 'ysize' : ysize}
elif nargs == 4:
xsize, ysize, xorigin, yorigin = args
procedure_fmt = '%(geo_col)s,%(xorigin)s,%(yorigin)s,%(xsize)s,%(ysize)s'
procedure_args = {'xsize' : xsize, 'ysize' : ysize,
'xorigin' : xorigin, 'yorigin' : yorigin}
else:
raise ValueError('Must provide 1, 2, or 4 arguments to `snap_to_grid`.')
s = {'procedure_fmt' : procedure_fmt,
'procedure_args' : procedure_args,
'select_field' : GeomField(),
}
return self._spatial_attribute('snap_to_grid', s, **kwargs)
def svg(self, relative=False, precision=8, **kwargs):
"""
Returns SVG representation of the geographic field in a `svg`
attribute on each element of this GeoQuerySet.
Keyword Arguments:
`relative` => If set to True, this will evaluate the path in
terms of relative moves (rather than absolute).
`precision` => May be used to set the maximum number of decimal
digits used in output (defaults to 8).
"""
relative = int(bool(relative))
if not isinstance(precision, (int, long)):
raise TypeError('SVG precision keyword argument must be an integer.')
s = {'desc' : 'SVG',
'procedure_fmt' : '%(geo_col)s,%(rel)s,%(precision)s',
'procedure_args' : {'rel' : relative,
'precision' : precision,
}
}
return self._spatial_attribute('svg', s, **kwargs)
def sym_difference(self, geom, **kwargs):
"""
Returns the symmetric difference of the geographic field in a
`sym_difference` attribute on each element of this GeoQuerySet.
"""
return self._geomset_attribute('sym_difference', geom, **kwargs)
def translate(self, x, y, z=0.0, **kwargs):
"""
Translates the geometry to a new location using the given numeric
parameters as offsets.
"""
if connections[self.db].ops.spatialite:
if z != 0.0:
raise NotImplementedError('SpatiaLite does not support 3D translation.')
s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s',
'procedure_args' : {'x' : x, 'y' : y},
'select_field' : GeomField(),
}
else:
s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s,%(z)s',
'procedure_args' : {'x' : x, 'y' : y, 'z' : z},
'select_field' : GeomField(),
}
return self._spatial_attribute('translate', s, **kwargs)
def transform(self, srid=4326, **kwargs):
"""
Transforms the given geometry field to the given SRID. If no SRID is
provided, the transformation will default to using 4326 (WGS84).
"""
if not isinstance(srid, (int, long)):
raise TypeError('An integer SRID must be provided.')
field_name = kwargs.get('field_name', None)
tmp, geo_field = self._spatial_setup('transform', field_name=field_name)
# Getting the selection SQL for the given geographic field.
field_col = self._geocol_select(geo_field, field_name)
# Why cascading substitutions? Because spatial backends like
# Oracle and MySQL already require a function call to convert to text, thus
# when there's also a transformation we need to cascade the substitutions.
# For example, 'SDO_UTIL.TO_WKTGEOMETRY(SDO_CS.TRANSFORM( ... )'
geo_col = self.query.custom_select.get(geo_field, field_col)
# Setting the key for the field's column with the custom SELECT SQL to
# override the geometry column returned from the database.
custom_sel = '%s(%s, %s)' % (connections[self.db].ops.transform, geo_col, srid)
# TODO: Should we have this as an alias?
# custom_sel = '(%s(%s, %s)) AS %s' % (SpatialBackend.transform, geo_col, srid, qn(geo_field.name))
self.query.transformed_srid = srid # So other GeoQuerySet methods
self.query.custom_select[geo_field] = custom_sel
return self._clone()
def union(self, geom, **kwargs):
"""
Returns the union of the geographic field with the given
Geometry in a `union` attribute on each element of this GeoQuerySet.
"""
return self._geomset_attribute('union', geom, **kwargs)
def unionagg(self, **kwargs):
"""
Performs an aggregate union on the given geometry field. Returns
None if the GeoQuerySet is empty. The `tolerance` keyword is for
Oracle backends only.
"""
return self._spatial_aggregate(aggregates.Union, **kwargs)
### Private API -- Abstracted DRY routines. ###
def _spatial_setup(self, att, desc=None, field_name=None, geo_field_type=None):
"""
Performs set up for executing the spatial function.
"""
# Does the spatial backend support this?
connection = connections[self.db]
func = getattr(connection.ops, att, False)
if desc is None: desc = att
if not func:
raise NotImplementedError('%s stored procedure not available on '
'the %s backend.' %
(desc, connection.ops.name))
# Initializing the procedure arguments.
procedure_args = {'function' : func}
# Is there a geographic field in the model to perform this
# operation on?
geo_field = self.query._geo_field(field_name)
if not geo_field:
raise TypeError('%s output only available on GeometryFields.' % func)
# If the `geo_field_type` keyword was used, then enforce that
# type limitation.
if not geo_field_type is None and not isinstance(geo_field, geo_field_type):
raise TypeError('"%s" stored procedures may only be called on %ss.' % (func, geo_field_type.__name__))
# Setting the procedure args.
procedure_args['geo_col'] = self._geocol_select(geo_field, field_name)
return procedure_args, geo_field
def _spatial_aggregate(self, aggregate, field_name=None,
geo_field_type=None, tolerance=0.05):
"""
DRY routine for calling aggregate spatial stored procedures and
returning their result to the caller of the function.
"""
# Getting the field the geographic aggregate will be called on.
geo_field = self.query._geo_field(field_name)
if not geo_field:
raise TypeError('%s aggregate only available on GeometryFields.' % aggregate.name)
# Checking if there are any geo field type limitations on this
# aggregate (e.g. ST_Makeline only operates on PointFields).
if not geo_field_type is None and not isinstance(geo_field, geo_field_type):
raise TypeError('%s aggregate may only be called on %ss.' % (aggregate.name, geo_field_type.__name__))
# Getting the string expression of the field name, as this is the
# argument taken by `Aggregate` objects.
agg_col = field_name or geo_field.name
# Adding any keyword parameters for the Aggregate object. Oracle backends
# in particular need an additional `tolerance` parameter.
agg_kwargs = {}
if connections[self.db].ops.oracle: agg_kwargs['tolerance'] = tolerance
# Calling the QuerySet.aggregate, and returning only the value of the aggregate.
return self.aggregate(geoagg=aggregate(agg_col, **agg_kwargs))['geoagg']
def _spatial_attribute(self, att, settings, field_name=None, model_att=None):
"""
DRY routine for calling a spatial stored procedure on a geometry column
and attaching its output as an attribute of the model.
Arguments:
att:
The name of the spatial attribute that holds the spatial
SQL function to call.
settings:
Dictonary of internal settings to customize for the spatial procedure.
Public Keyword Arguments:
field_name:
The name of the geographic field to call the spatial
function on. May also be a lookup to a geometry field
as part of a foreign key relation.
model_att:
The name of the model attribute to attach the output of
the spatial function to.
"""
# Default settings.
settings.setdefault('desc', None)
settings.setdefault('geom_args', ())
settings.setdefault('geom_field', None)
settings.setdefault('procedure_args', {})
settings.setdefault('procedure_fmt', '%(geo_col)s')
settings.setdefault('select_params', [])
connection = connections[self.db]
backend = connection.ops
# Performing setup for the spatial column, unless told not to.
if settings.get('setup', True):
default_args, geo_field = self._spatial_setup(att, desc=settings['desc'], field_name=field_name,
geo_field_type=settings.get('geo_field_type', None))
for k, v in default_args.iteritems(): settings['procedure_args'].setdefault(k, v)
else:
geo_field = settings['geo_field']
# The attribute to attach to the model.
if not isinstance(model_att, basestring): model_att = att
# Special handling for any argument that is a geometry.
for name in settings['geom_args']:
# Using the field's get_placeholder() routine to get any needed
# transformation SQL.
geom = geo_field.get_prep_value(settings['procedure_args'][name])
params = geo_field.get_db_prep_lookup('contains', geom, connection=connection)
geom_placeholder = geo_field.get_placeholder(geom, connection)
# Replacing the procedure format with that of any needed
# transformation SQL.
old_fmt = '%%(%s)s' % name
new_fmt = geom_placeholder % '%%s'
settings['procedure_fmt'] = settings['procedure_fmt'].replace(old_fmt, new_fmt)
settings['select_params'].extend(params)
# Getting the format for the stored procedure.
fmt = '%%(function)s(%s)' % settings['procedure_fmt']
# If the result of this function needs to be converted.
if settings.get('select_field', False):
sel_fld = settings['select_field']
if isinstance(sel_fld, GeomField) and backend.select:
self.query.custom_select[model_att] = backend.select
if connection.ops.oracle:
sel_fld.empty_strings_allowed = False
self.query.extra_select_fields[model_att] = sel_fld
# Finally, setting the extra selection attribute with
# the format string expanded with the stored procedure
# arguments.
return self.extra(select={model_att : fmt % settings['procedure_args']},
select_params=settings['select_params'])
def _distance_attribute(self, func, geom=None, tolerance=0.05, spheroid=False, **kwargs):
"""
DRY routine for GeoQuerySet distance attribute routines.
"""
# Setting up the distance procedure arguments.
procedure_args, geo_field = self._spatial_setup(func, field_name=kwargs.get('field_name', None))
# If geodetic defaulting distance attribute to meters (Oracle and
# PostGIS spherical distances return meters). Otherwise, use the
# units of the geometry field.
connection = connections[self.db]
geodetic = geo_field.geodetic(connection)
geography = geo_field.geography
if geodetic:
dist_att = 'm'
else:
dist_att = Distance.unit_attname(geo_field.units_name(connection))
# Shortcut booleans for what distance function we're using and
# whether the geometry field is 3D.
distance = func == 'distance'
length = func == 'length'
perimeter = func == 'perimeter'
if not (distance or length or perimeter):
raise ValueError('Unknown distance function: %s' % func)
geom_3d = geo_field.dim == 3
# The field's get_db_prep_lookup() is used to get any
# extra distance parameters. Here we set up the
# parameters that will be passed in to field's function.
lookup_params = [geom or 'POINT (0 0)', 0]
# Getting the spatial backend operations.
backend = connection.ops
# If the spheroid calculation is desired, either by the `spheroid`
# keyword or when calculating the length of geodetic field, make
# sure the 'spheroid' distance setting string is passed in so we
# get the correct spatial stored procedure.
if spheroid or (backend.postgis and geodetic and
(not geography) and length):
lookup_params.append('spheroid')
lookup_params = geo_field.get_prep_value(lookup_params)
params = geo_field.get_db_prep_lookup('distance_lte', lookup_params, connection=connection)
# The `geom_args` flag is set to true if a geometry parameter was
# passed in.
geom_args = bool(geom)
if backend.oracle:
if distance:
procedure_fmt = '%(geo_col)s,%(geom)s,%(tolerance)s'
elif length or perimeter:
procedure_fmt = '%(geo_col)s,%(tolerance)s'
procedure_args['tolerance'] = tolerance
else:
# Getting whether this field is in units of degrees since the field may have
# been transformed via the `transform` GeoQuerySet method.
if self.query.transformed_srid:
u, unit_name, s = get_srid_info(self.query.transformed_srid, connection)
geodetic = unit_name in geo_field.geodetic_units
if backend.spatialite and geodetic:
raise ValueError('SQLite does not support linear distance calculations on geodetic coordinate systems.')
if distance:
if self.query.transformed_srid:
# Setting the `geom_args` flag to false because we want to handle
# transformation SQL here, rather than the way done by default
# (which will transform to the original SRID of the field rather
# than to what was transformed to).
geom_args = False
procedure_fmt = '%s(%%(geo_col)s, %s)' % (backend.transform, self.query.transformed_srid)
if geom.srid is None or geom.srid == self.query.transformed_srid:
# If the geom parameter srid is None, it is assumed the coordinates
# are in the transformed units. A placeholder is used for the
# geometry parameter. `GeomFromText` constructor is also needed
# to wrap geom placeholder for SpatiaLite.
if backend.spatialite:
procedure_fmt += ', %s(%%%%s, %s)' % (backend.from_text, self.query.transformed_srid)
else:
procedure_fmt += ', %%s'
else:
# We need to transform the geom to the srid specified in `transform()`,
# so wrapping the geometry placeholder in transformation SQL.
# SpatiaLite also needs geometry placeholder wrapped in `GeomFromText`
# constructor.
if backend.spatialite:
procedure_fmt += ', %s(%s(%%%%s, %s), %s)' % (backend.transform, backend.from_text,
geom.srid, self.query.transformed_srid)
else:
procedure_fmt += ', %s(%%%%s, %s)' % (backend.transform, self.query.transformed_srid)
else:
# `transform()` was not used on this GeoQuerySet.
procedure_fmt = '%(geo_col)s,%(geom)s'
if not geography and geodetic:
# Spherical distance calculation is needed (because the geographic
# field is geodetic). However, the PostGIS ST_distance_sphere/spheroid()
# procedures may only do queries from point columns to point geometries
# some error checking is required.
if not backend.geography:
if not isinstance(geo_field, PointField):
raise ValueError('Spherical distance calculation only supported on PointFields.')
if not str(Geometry(buffer(params[0].ewkb)).geom_type) == 'Point':
raise ValueError('Spherical distance calculation only supported with Point Geometry parameters')
# The `function` procedure argument needs to be set differently for
# geodetic distance calculations.
if spheroid:
# Call to distance_spheroid() requires spheroid param as well.
procedure_fmt += ",'%(spheroid)s'"
procedure_args.update({'function' : backend.distance_spheroid, 'spheroid' : params[1]})
else:
procedure_args.update({'function' : backend.distance_sphere})
elif length or perimeter:
procedure_fmt = '%(geo_col)s'
if not geography and geodetic and length:
# There's no `length_sphere`, and `length_spheroid` also
# works on 3D geometries.
procedure_fmt += ",'%(spheroid)s'"
procedure_args.update({'function' : backend.length_spheroid, 'spheroid' : params[1]})
elif geom_3d and backend.postgis:
# Use 3D variants of perimeter and length routines on PostGIS.
if perimeter:
procedure_args.update({'function' : backend.perimeter3d})
elif length:
procedure_args.update({'function' : backend.length3d})
# Setting up the settings for `_spatial_attribute`.
s = {'select_field' : DistanceField(dist_att),
'setup' : False,
'geo_field' : geo_field,
'procedure_args' : procedure_args,
'procedure_fmt' : procedure_fmt,
}
if geom_args:
s['geom_args'] = ('geom',)
s['procedure_args']['geom'] = geom
elif geom:
# The geometry is passed in as a parameter because we handled
# transformation conditions in this routine.
s['select_params'] = [backend.Adapter(geom)]
return self._spatial_attribute(func, s, **kwargs)
def _geom_attribute(self, func, tolerance=0.05, **kwargs):
"""
DRY routine for setting up a GeoQuerySet method that attaches a
Geometry attribute (e.g., `centroid`, `point_on_surface`).
"""
s = {'select_field' : GeomField(),}
if connections[self.db].ops.oracle:
s['procedure_fmt'] = '%(geo_col)s,%(tolerance)s'
s['procedure_args'] = {'tolerance' : tolerance}
return self._spatial_attribute(func, s, **kwargs)
def _geomset_attribute(self, func, geom, tolerance=0.05, **kwargs):
"""
DRY routine for setting up a GeoQuerySet method that attaches a
Geometry attribute and takes a Geoemtry parameter. This is used
for geometry set-like operations (e.g., intersection, difference,
union, sym_difference).
"""
s = {'geom_args' : ('geom',),
'select_field' : GeomField(),
'procedure_fmt' : '%(geo_col)s,%(geom)s',
'procedure_args' : {'geom' : geom},
}
if connections[self.db].ops.oracle:
s['procedure_fmt'] += ',%(tolerance)s'
s['procedure_args']['tolerance'] = tolerance
return self._spatial_attribute(func, s, **kwargs)
def _geocol_select(self, geo_field, field_name):
"""
Helper routine for constructing the SQL to select the geographic
column. Takes into account if the geographic field is in a
ForeignKey relation to the current model.
"""
opts = self.model._meta
if not geo_field in opts.fields:
# Is this operation going to be on a related geographic field?
# If so, it'll have to be added to the select related information
# (e.g., if 'location__point' was given as the field name).
self.query.add_select_related([field_name])
compiler = self.query.get_compiler(self.db)
compiler.pre_sql_setup()
rel_table, rel_col = self.query.related_select_cols[self.query.related_select_fields.index(geo_field)]
return compiler._field_column(geo_field, rel_table)
elif not geo_field in opts.local_fields:
# This geographic field is inherited from another model, so we have to
# use the db table for the _parent_ model instead.
tmp_fld, parent_model, direct, m2m = opts.get_field_by_name(geo_field.name)
return self.query.get_compiler(self.db)._field_column(geo_field, parent_model._meta.db_table)
else:
return self.query.get_compiler(self.db)._field_column(geo_field)
class GeoValuesQuerySet(ValuesQuerySet):
def __init__(self, *args, **kwargs):
super(GeoValuesQuerySet, self).__init__(*args, **kwargs)
# This flag tells `resolve_columns` to run the values through
# `convert_values`. This ensures that Geometry objects instead
# of string values are returned with `values()` or `values_list()`.
self.query.geo_values = True
class GeoValuesListQuerySet(GeoValuesQuerySet, ValuesListQuerySet):
pass
|
gpl-3.0
|
[
504,
1639,
14,
697,
492,
6947,
199,
504,
1639,
14,
697,
14,
992,
14,
1131,
492,
18397,
12,
1413,
12,
13468,
13689,
12,
13468,
1296,
13689,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
697,
14,
992,
492,
27535,
199,
504,
1639,
14,
2828,
14,
5668,
14,
697,
14,
992,
14,
955,
492,
664,
63,
10498,
63,
815,
12,
30490,
12,
7584,
792,
12,
7030,
14912,
199,
504,
1639,
14,
2828,
14,
5668,
14,
697,
14,
992,
14,
3009,
492,
26280,
792,
12,
21892,
792,
12,
5346,
676,
792,
12,
8875,
3227,
12,
8875,
26493,
1716,
199,
504,
1639,
14,
2828,
14,
5668,
14,
7660,
14,
4620,
492,
10579,
199,
504,
1639,
14,
2828,
14,
5668,
14,
9580,
492,
26280,
12,
21892,
199,
199,
533,
25587,
8,
13689,
304,
272,
298,
1918,
8875,
9770,
18397,
2122,
339,
6754,
17653,
1806,
4591,
687,
18397,
6754,
272,
347,
636,
826,
721,
277,
12,
1402,
29,
403,
12,
1827,
29,
403,
12,
1808,
29,
403,
304,
267,
1613,
8,
10748,
13689,
12,
291,
2843,
826,
721,
1238,
29,
1238,
12,
1827,
29,
1131,
12,
1808,
29,
4941,
9,
267,
291,
14,
1131,
275,
1827,
503,
8875,
3227,
8,
277,
14,
1238,
9,
339,
347,
1338,
8,
277,
12,
627,
955,
304,
267,
372,
291,
423,
6311,
8,
11645,
29,
10748,
6550,
13689,
12,
3272,
29,
549,
12,
485,
955,
29,
955,
9,
339,
347,
1338,
63,
513,
8,
277,
12,
627,
955,
12,
1011,
958,
304,
267,
6829,
275,
2074,
14,
1935,
360,
7088,
297,
756,
9,
267,
340,
2074,
26,
288,
746,
3146,
360,
8708,
4252,
2368,
370,
1338,
63,
513,
26,
450,
83,
7,
490,
450,
334,
958,
14,
1612,
1062,
430,
267,
340,
6829,
436,
822,
8,
955,
9,
690,
413,
26,
288,
746,
3146,
15587,
7088,
7,
365,
440,
1686,
1380,
1338,
63,
513,
365,
2797,
543,
1655,
2419,
1373,
901,
2685,
267,
372,
291,
423,
6311,
8,
11645,
29,
10748,
6550,
1296,
13689,
12,
3272,
29,
549,
12,
6829,
29,
7088,
12,
2574,
485,
955,
29,
955,
9,
339,
6754,
25587,
17653,
6754,
272,
347,
9150,
8,
277,
12,
13464,
29,
16,
14,
1717,
12,
1011,
958,
304,
267,
408,
267,
1803,
314,
9150,
402,
314,
25637,
901,
315,
376,
658,
6789,
64,
2225,
641,
267,
1924,
1819,
402,
642,
25587,
14,
267,
408,
267,
327,
11379,
964,
316,
3272,
2348,
7830,
2419,
315,
18494,
11679,
63,
3215,
64,
880,
626,
267,
327,
781,
883,
664,
314,
6204,
367,
658,
11043,
792,
2313,
267,
17782,
63,
589,
12,
8509,
63,
698,
275,
291,
423,
11679,
63,
2758,
360,
6789,
297,
901,
63,
354,
29,
958,
14,
362,
360,
698,
63,
354,
297,
488,
430,
267,
308,
275,
791,
21978,
63,
589,
7,
520,
17782,
63,
589,
12,
1467,
283,
6721,
63,
698,
7,
520,
8509,
63,
698,
12,
1467,
283,
2758,
7,
520,
756,
12,
1467,
789,
267,
1950,
275,
6947,
59,
277,
14,
697,
61,
267,
4865,
275,
1950,
14,
1483,
267,
340,
4865,
14,
16404,
26,
288,
308,
459,
21978,
63,
5045,
418,
275,
9487,
6721,
63,
761,
9,
83,
12,
2840,
16312,
9,
83,
7,
288,
308,
459,
21978,
63,
589,
2545,
16312,
418,
275,
13464,
288,
308,
459,
2416,
63,
698,
418,
275,
26280,
792,
360,
3526,
63,
77,
358,
327,
15309,
2529,
9150,
315,
6204,
402,
24808,
14,
267,
916,
4865,
14,
1932,
5668,
503,
4865,
14,
25873,
26,
288,
340,
4865,
14,
6721,
9773,
26,
355,
327,
8875,
9773,
1504,
2291,
9150,
15232,
12,
2529,
12386,
24808,
14,
355,
308,
459,
2416,
63,
698,
418,
275,
26280,
792,
360,
3526,
63,
77,
358,
288,
916,
440,
8509,
63,
698,
14,
303,
32230,
8,
2105,
304,
355,
327,
20703,
314,
9150,
6204,
402,
314,
25637,
901,
14,
355,
308,
459,
2416,
63,
698,
418,
275,
26280,
792,
8,
11043,
14,
3248,
63,
13651,
8,
6721,
63,
698,
14,
5260,
63,
354,
8,
2105,
1724,
288,
587,
26,
355,
327,
3254,
26,
4226,
781,
2934,
370,
2291,
3066,
1329,
787,
305,
367,
2312,
32230,
1504,
31,
355,
746,
2186,
360,
11043,
641,
2312,
32230,
10021,
10460,
440,
3748,
2659,
267,
372,
291,
423,
11679,
63,
3215,
360,
6789,
297,
308,
12,
1011,
958,
9,
339,
347,
27587,
8,
277,
12,
1011,
958,
304,
267,
408,
267,
1803,
314,
27587,
402,
314,
25637,
901,
315,
282,
658,
22098,
64,
267,
2225,
641,
1924,
1819,
402,
642,
25587,
14,
267,
408,
267,
372,
291,
423,
6481,
63,
3215,
360,
22098,
297,
1011,
958,
9,
339,
347,
8775,
8,
277,
12,
1011,
958,
304,
267,
408,
267,
29822,
376,
9531,
8775,
3439,
641,
314,
1627,
3400,
901,
14,
267,
961,
365,
376,
279,
643,
1785,
370,
282,
13629,
3439,
12,
1325,
8298,
12930,
2952,
267,
18135,
787,
440,
487,
385,
7064,
14,
267,
408,
267,
372,
291,
423,
11679,
63,
7516,
8,
21622,
14,
25023,
12,
1011,
958,
9,
339,
347,
8865,
8,
277,
12,
9671,
12,
1011,
958,
304,
267,
408,
267,
1803,
314,
11469,
8865,
402,
314,
25637,
901,
315,
282,
658,
9196,
64,
267,
2225,
641,
1924,
1819,
402,
642,
25587,
14,
267,
408,
267,
372,
291,
423,
6481,
409,
63,
3215,
360,
9196,
297,
9671,
12,
1011,
958,
9,
339,
347,
6033,
8,
277,
12,
9671,
12,
1011,
958,
304,
267,
408,
267,
1803,
314,
6033,
687,
314,
1627,
25637,
901,
536,
370,
314,
267,
1627,
3400,
315,
282,
658,
5590,
64,
2225,
641,
1924,
1819,
402,
314,
267,
25587,
14,
398,
6431,
7628,
26,
268,
658,
23286,
1170,
64,
221,
9265,
982,
314,
3400,
901,
365,
2312,
32230,
436,
20929,
365,
717,
314,
11469,
3050,
12,
2066,
314,
1655,
23189,
717,
308,
7722,
1170,
15232,
911,
506,
1202,
3140,
402,
314,
717,
12530,
281,
26941,
15232,
14,
13359,
658,
16312,
64,
9265,
8051,
1454,
367,
15309,
14,
710,
13464,
365,
717,
315,
24808,
1553,
282,
849,
402,
959,
9679,
521,
878,
334,
16,
14,
1717,
9,
717,
365,
1202,
14,
267,
408,
267,
372,
291,
423,
5590,
63,
3215,
360,
5590,
297,
9671,
12,
1011,
958,
9,
339,
347,
24631,
8,
277,
12,
1011,
958,
304,
267,
408,
267,
1803,
282,
10579,
6144,
314,
16842
] |
[
1639,
14,
697,
492,
6947,
199,
504,
1639,
14,
697,
14,
992,
14,
1131,
492,
18397,
12,
1413,
12,
13468,
13689,
12,
13468,
1296,
13689,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
697,
14,
992,
492,
27535,
199,
504,
1639,
14,
2828,
14,
5668,
14,
697,
14,
992,
14,
955,
492,
664,
63,
10498,
63,
815,
12,
30490,
12,
7584,
792,
12,
7030,
14912,
199,
504,
1639,
14,
2828,
14,
5668,
14,
697,
14,
992,
14,
3009,
492,
26280,
792,
12,
21892,
792,
12,
5346,
676,
792,
12,
8875,
3227,
12,
8875,
26493,
1716,
199,
504,
1639,
14,
2828,
14,
5668,
14,
7660,
14,
4620,
492,
10579,
199,
504,
1639,
14,
2828,
14,
5668,
14,
9580,
492,
26280,
12,
21892,
199,
199,
533,
25587,
8,
13689,
304,
272,
298,
1918,
8875,
9770,
18397,
2122,
339,
6754,
17653,
1806,
4591,
687,
18397,
6754,
272,
347,
636,
826,
721,
277,
12,
1402,
29,
403,
12,
1827,
29,
403,
12,
1808,
29,
403,
304,
267,
1613,
8,
10748,
13689,
12,
291,
2843,
826,
721,
1238,
29,
1238,
12,
1827,
29,
1131,
12,
1808,
29,
4941,
9,
267,
291,
14,
1131,
275,
1827,
503,
8875,
3227,
8,
277,
14,
1238,
9,
339,
347,
1338,
8,
277,
12,
627,
955,
304,
267,
372,
291,
423,
6311,
8,
11645,
29,
10748,
6550,
13689,
12,
3272,
29,
549,
12,
485,
955,
29,
955,
9,
339,
347,
1338,
63,
513,
8,
277,
12,
627,
955,
12,
1011,
958,
304,
267,
6829,
275,
2074,
14,
1935,
360,
7088,
297,
756,
9,
267,
340,
2074,
26,
288,
746,
3146,
360,
8708,
4252,
2368,
370,
1338,
63,
513,
26,
450,
83,
7,
490,
450,
334,
958,
14,
1612,
1062,
430,
267,
340,
6829,
436,
822,
8,
955,
9,
690,
413,
26,
288,
746,
3146,
15587,
7088,
7,
365,
440,
1686,
1380,
1338,
63,
513,
365,
2797,
543,
1655,
2419,
1373,
901,
2685,
267,
372,
291,
423,
6311,
8,
11645,
29,
10748,
6550,
1296,
13689,
12,
3272,
29,
549,
12,
6829,
29,
7088,
12,
2574,
485,
955,
29,
955,
9,
339,
6754,
25587,
17653,
6754,
272,
347,
9150,
8,
277,
12,
13464,
29,
16,
14,
1717,
12,
1011,
958,
304,
267,
408,
267,
1803,
314,
9150,
402,
314,
25637,
901,
315,
376,
658,
6789,
64,
2225,
641,
267,
1924,
1819,
402,
642,
25587,
14,
267,
408,
267,
327,
11379,
964,
316,
3272,
2348,
7830,
2419,
315,
18494,
11679,
63,
3215,
64,
880,
626,
267,
327,
781,
883,
664,
314,
6204,
367,
658,
11043,
792,
2313,
267,
17782,
63,
589,
12,
8509,
63,
698,
275,
291,
423,
11679,
63,
2758,
360,
6789,
297,
901,
63,
354,
29,
958,
14,
362,
360,
698,
63,
354,
297,
488,
430,
267,
308,
275,
791,
21978,
63,
589,
7,
520,
17782,
63,
589,
12,
1467,
283,
6721,
63,
698,
7,
520,
8509,
63,
698,
12,
1467,
283,
2758,
7,
520,
756,
12,
1467,
789,
267,
1950,
275,
6947,
59,
277,
14,
697,
61,
267,
4865,
275,
1950,
14,
1483,
267,
340,
4865,
14,
16404,
26,
288,
308,
459,
21978,
63,
5045,
418,
275,
9487,
6721,
63,
761,
9,
83,
12,
2840,
16312,
9,
83,
7,
288,
308,
459,
21978,
63,
589,
2545,
16312,
418,
275,
13464,
288,
308,
459,
2416,
63,
698,
418,
275,
26280,
792,
360,
3526,
63,
77,
358,
327,
15309,
2529,
9150,
315,
6204,
402,
24808,
14,
267,
916,
4865,
14,
1932,
5668,
503,
4865,
14,
25873,
26,
288,
340,
4865,
14,
6721,
9773,
26,
355,
327,
8875,
9773,
1504,
2291,
9150,
15232,
12,
2529,
12386,
24808,
14,
355,
308,
459,
2416,
63,
698,
418,
275,
26280,
792,
360,
3526,
63,
77,
358,
288,
916,
440,
8509,
63,
698,
14,
303,
32230,
8,
2105,
304,
355,
327,
20703,
314,
9150,
6204,
402,
314,
25637,
901,
14,
355,
308,
459,
2416,
63,
698,
418,
275,
26280,
792,
8,
11043,
14,
3248,
63,
13651,
8,
6721,
63,
698,
14,
5260,
63,
354,
8,
2105,
1724,
288,
587,
26,
355,
327,
3254,
26,
4226,
781,
2934,
370,
2291,
3066,
1329,
787,
305,
367,
2312,
32230,
1504,
31,
355,
746,
2186,
360,
11043,
641,
2312,
32230,
10021,
10460,
440,
3748,
2659,
267,
372,
291,
423,
11679,
63,
3215,
360,
6789,
297,
308,
12,
1011,
958,
9,
339,
347,
27587,
8,
277,
12,
1011,
958,
304,
267,
408,
267,
1803,
314,
27587,
402,
314,
25637,
901,
315,
282,
658,
22098,
64,
267,
2225,
641,
1924,
1819,
402,
642,
25587,
14,
267,
408,
267,
372,
291,
423,
6481,
63,
3215,
360,
22098,
297,
1011,
958,
9,
339,
347,
8775,
8,
277,
12,
1011,
958,
304,
267,
408,
267,
29822,
376,
9531,
8775,
3439,
641,
314,
1627,
3400,
901,
14,
267,
961,
365,
376,
279,
643,
1785,
370,
282,
13629,
3439,
12,
1325,
8298,
12930,
2952,
267,
18135,
787,
440,
487,
385,
7064,
14,
267,
408,
267,
372,
291,
423,
11679,
63,
7516,
8,
21622,
14,
25023,
12,
1011,
958,
9,
339,
347,
8865,
8,
277,
12,
9671,
12,
1011,
958,
304,
267,
408,
267,
1803,
314,
11469,
8865,
402,
314,
25637,
901,
315,
282,
658,
9196,
64,
267,
2225,
641,
1924,
1819,
402,
642,
25587,
14,
267,
408,
267,
372,
291,
423,
6481,
409,
63,
3215,
360,
9196,
297,
9671,
12,
1011,
958,
9,
339,
347,
6033,
8,
277,
12,
9671,
12,
1011,
958,
304,
267,
408,
267,
1803,
314,
6033,
687,
314,
1627,
25637,
901,
536,
370,
314,
267,
1627,
3400,
315,
282,
658,
5590,
64,
2225,
641,
1924,
1819,
402,
314,
267,
25587,
14,
398,
6431,
7628,
26,
268,
658,
23286,
1170,
64,
221,
9265,
982,
314,
3400,
901,
365,
2312,
32230,
436,
20929,
365,
717,
314,
11469,
3050,
12,
2066,
314,
1655,
23189,
717,
308,
7722,
1170,
15232,
911,
506,
1202,
3140,
402,
314,
717,
12530,
281,
26941,
15232,
14,
13359,
658,
16312,
64,
9265,
8051,
1454,
367,
15309,
14,
710,
13464,
365,
717,
315,
24808,
1553,
282,
849,
402,
959,
9679,
521,
878,
334,
16,
14,
1717,
9,
717,
365,
1202,
14,
267,
408,
267,
372,
291,
423,
5590,
63,
3215,
360,
5590,
297,
9671,
12,
1011,
958,
9,
339,
347,
24631,
8,
277,
12,
1011,
958,
304,
267,
408,
267,
1803,
282,
10579,
6144,
314,
16842,
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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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
glorizen/nupic
|
nupic/regions/ImageSensorExplorers/RandomJump.py
|
17
|
7511
|
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2013, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions apply:
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero Public License for more details.
#
# You should have received a copy of the GNU Affero Public License
# along with this program. If not, see http://www.gnu.org/licenses.
#
# http://numenta.org/licenses/
# ----------------------------------------------------------------------
from nupic.regions.ImageSensorExplorers.BaseExplorer import BaseExplorer
class RandomJump(BaseExplorer):
"""
This explorer randomly selects positions. It does not do any sweeping.
"""
def __init__(self, jumpOffObject=False, numJumpsPerImage=None,
numVisitsPerImage=None, spaceShape=None, *args, **kwargs):
"""
Parameters:
-----------------------------------------------------------------
jumpOffObject: Whether the sensor can only include a part of the object,
as specified by the bounding box. If False, it will only
move to positions that include as much of the object as
possible.
numJumpsPerImage: The number of iterations for which RandomJump
should dwell on one image before moving on to the next one.
numVisitsPerImage: The number of times RandomJump should visit each
image (and do numJumpsPerImage jumps on it).
spaceShape: The (height, width) of the 2-D space to explore. This
constrains how far away from the center point an image
is allowed to be presented.
"""
BaseExplorer.__init__(self, *args, **kwargs)
if type(jumpOffObject) not in (bool, int):
raise RuntimeError("'jumpOffObject' should be a boolean")
if numJumpsPerImage is not None and type(numJumpsPerImage) is not int:
raise RuntimeError("'numJumpsPerImage' should be an integer")
if numVisitsPerImage is not None and type(numVisitsPerImage) is not int:
raise RuntimeError("'numVisitsPerImage' should be an integer")
if numVisitsPerImage is not None and numJumpsPerImage is None:
raise RuntimeError("Must specify 'numJumpsPerImage'"
" when using 'numVisitsPerImage'")
if spaceShape is not None and \
(len(spaceShape) != 2 or spaceShape[0] < 1 or spaceShape[1] < 1):
raise RuntimeError("'spaceShape' should be a 2-item tuple specifying the"
"(height, width) of the overall space to explore.")
self.jumpOffObject = jumpOffObject
self.numJumpsPerImage = numJumpsPerImage
self.numVisitsPerImage = numVisitsPerImage
self.spaceShape = spaceShape
# Keeps track of how many jumps on this image
self.numJumpsThisImage = 0
self.lastImageIndex = None
def first(self):
"""
Set up the position.
BaseExplorer picks image 0, offset (0,0), etc., but explorers that wish
to set a different first position should extend this method. Such explorers
may wish to call BaseExplorer.first(center=False), which initializes the
position tuple but does not call centerImage() (which could cause
unnecessary filtering to occur).
"""
BaseExplorer.first(self, center=False)
if not self.numImages:
return
isBlank = True
while isBlank:
# Pick a random position
if not self.numJumpsPerImage or self.lastImageIndex is None or \
(self.numJumpsThisImage % self.numJumpsPerImage == 0):
# Pick new image
image = self.pickRandomImage(self.random)
self.lastImageIndex = image
self.numJumpsThisImage = 0
else:
image = self.lastImageIndex
self.position['image'] = image
self.position['filters'] = self.pickRandomFilters(self.random)
filteredImages = self.getFilteredImages()
# Pick a random offset
if self.spaceShape is not None:
self.centerImage()
# NOTE: self.position['offset'] is (x, y), whereas our spaceShape is
# (height, width). Also note that the self.position['offset']
# direction is counter-intuitive: negative numbers move us to the RIGHT
# and DOWN instead of LEFT and UP.
xOffset = self.random.randint(-(self.spaceShape[1]//2), self.spaceShape[1]//2)
yOffset = self.random.randint(-(self.spaceShape[0]//2), self.spaceShape[0]//2)
#print "(yOffset, xOffset) = ", yOffset, xOffset
self.position['offset'][0] += xOffset
self.position['offset'][1] += yOffset
else:
ebbox = self._getEffectiveBoundingBox(filteredImages[0])
self.position['offset'] = [
self.random.randint(ebbox[0], ebbox[2]-1),
self.random.randint(ebbox[1], ebbox[3]-1)
]
# Check if the position is blank
isBlank = self.isBlank(self.jumpOffObject)
self.position['reset'] = True
self.numJumpsThisImage += 1
def next(self, seeking=False):
"""
Go to the next position (next iteration).
seeking -- Boolean that indicates whether the explorer is calling next()
from seek(). If True, the explorer should avoid unnecessary computation
that would not affect the seek command. The last call to next() from
seek() will be with seeking=False.
"""
self.first()
def getNumIterations(self, image):
"""
Get the number of iterations required to completely explore the input space.
Explorers that do not wish to support this method should not override it.
image -- If None, returns the sum of the iterations for all the loaded
images. Otherwise, image should be an integer specifying the image for
which to calculate iterations.
ImageSensor takes care of the input validation.
"""
if self.numVisitsPerImage is None:
return -1
totalPerImage = self.numFilteredVersionsPerImage * self.numJumpsPerImage \
* self.numVisitsPerImage
if image is None:
return totalPerImage * self.numImages
else:
return totalPerImage
def _getEffectiveBoundingBox(self, image):
"""
Calculate the 'effective' bounding box from the image's bounding box,
taking into account the jumpOffObject parameter.
The effective bounding box determines which offsets the explorer should
consider. If 'ebbox' is the bounding box returned from this method, valid
offsets [x,y] are bounded by:
ebbox[0] <= x < ebbox[2]
ebbox[1] <= y < ebbox[3].
"""
bbox = image.split()[1].getbbox()
if self.jumpOffObject:
startX = bbox[0] - self.enabledWidth + 1
startY = bbox[1] - self.enabledHeight + 1
endX = bbox[2]
endY = bbox[3]
else:
startX = min(bbox[0], bbox[2] - self.enabledWidth)
startY = min(bbox[1], bbox[3] - self.enabledHeight)
endX = max(bbox[0], bbox[2] - self.enabledWidth) + 1
endY = max(bbox[1], bbox[3] - self.enabledHeight) + 1
return (startX, startY, endX, endY)
|
agpl-3.0
|
[
3,
20359,
199,
3,
22783,
16078,
367,
8883,
24024,
27799,
334,
21988,
26769,
9,
199,
3,
1898,
334,
35,
9,
6171,
12,
22783,
12,
3277,
14,
221,
4158,
1265,
1172,
376,
25025,
199,
3,
543,
22783,
12,
3277,
2020,
367,
282,
7396,
4190,
367,
642,
2032,
1233,
12,
314,
199,
3,
2569,
2895,
436,
3704,
4838,
26,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1684,
844,
1015,
650,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
199,
3,
1666,
314,
1664,
4265,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
14,
199,
3,
199,
3,
1455,
921,
78,
18952,
14,
1308,
15,
2383,
15,
199,
3,
20359,
199,
199,
504,
26084,
14,
11963,
14,
3491,
10160,
4527,
320,
21105,
14,
1563,
4527,
22732,
492,
3523,
4527,
22732,
421,
199,
533,
9571,
42,
1220,
8,
1563,
4527,
22732,
304,
819,
408,
523,
961,
15868,
3859,
19311,
24750,
12266,
14,
2779,
1630,
440,
886,
1263,
5584,
1024,
4073,
14,
523,
408,
8330,
347,
636,
826,
721,
277,
12,
14882,
5195,
1692,
29,
797,
12,
1967,
42,
1220,
83,
2623,
3491,
29,
403,
12,
2049,
1967,
2201,
30066,
2623,
3491,
29,
403,
12,
4601,
7238,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
3897,
26,
272,
5620,
13,
272,
14882,
5195,
1692,
26,
420,
7480,
314,
8778,
883,
1454,
2387,
282,
1777,
402,
314,
909,
12,
717,
465,
2013,
701,
314,
16842,
5689,
14,
982,
756,
12,
652,
911,
1454,
717,
4057,
370,
12266,
626,
2387,
465,
8298,
402,
314,
909,
465,
717,
3962,
14,
272,
1967,
42,
1220,
83,
2623,
3491,
26,
257,
710,
1329,
402,
10615,
367,
1314,
9571,
42,
1220,
717,
1077,
17594,
1697,
641,
1373,
1834,
2544,
12876,
641,
370,
314,
2163,
1373,
14,
272,
1967,
2201,
30066,
2623,
3491,
26,
221,
710,
1329,
402,
5431,
9571,
42,
1220,
1077,
5684,
1924,
717,
1834,
334,
460,
886,
1967,
42,
1220,
83,
2623,
3491,
14882,
83,
641,
652,
680,
272,
4601,
7238,
26,
260,
710,
334,
3333,
12,
3462,
9,
402,
314,
499,
13,
36,
4601,
370,
15868,
264,
14,
961,
717,
950,
345,
3617,
4212,
12474,
13437,
687,
314,
8126,
2376,
376,
1834,
717,
365,
4370,
370,
506,
26568,
14,
272,
408,
339,
3523,
4527,
22732,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
339,
340,
730,
8,
11126,
5195,
1692,
9,
440,
315,
334,
2245,
12,
1109,
304,
489,
746,
6064,
15587,
11126,
5195,
1692,
7,
1077,
506,
282,
5046,
531,
272,
340,
1967,
42,
1220,
83,
2623,
3491,
365,
440,
488,
436,
730,
8,
1507,
42,
1220,
83,
2623,
3491,
9,
365,
440,
1109,
26,
489,
746,
6064,
15587,
1507,
42,
1220,
83,
2623,
3491,
7,
1077,
506,
376,
3000,
531,
272,
340,
1967,
2201,
30066,
2623,
3491,
365,
440,
488,
436,
730,
8,
1507,
2201,
30066,
2623,
3491,
9,
365,
440,
1109,
26,
489,
746,
6064,
15587,
1507,
2201,
30066,
2623,
3491,
7,
1077,
506,
376,
3000,
531,
272,
340,
1967,
2201,
30066,
2623,
3491,
365,
440,
488,
436,
1967,
42,
1220,
83,
2623,
3491,
365,
488,
26,
489,
746,
6064,
480,
13757,
4165,
283,
1507,
42,
1220,
83,
2623,
3491,
4065,
267,
298,
1380,
1808,
283,
1507,
2201,
30066,
2623,
3491,
9859,
272,
340,
4601,
7238,
365,
440,
488,
436,
971,
2126,
334,
552,
8,
2638,
7238,
9,
1137,
499,
503,
4601,
7238,
59,
16,
61,
665,
413,
503,
4601,
7238,
59,
17,
61,
665,
413,
304,
489,
746,
6064,
15587,
2638,
7238,
7,
1077,
506,
282,
499,
13,
1053,
2008,
9176,
314,
2,
288,
7340,
3333,
12,
3462,
9,
402,
314,
20347,
4601,
370,
15868,
264,
2685,
2378,
291,
14,
11126,
5195,
1692,
275,
14882,
5195,
1692,
272,
291,
14,
1507,
42,
1220,
83,
2623,
3491,
275,
1967,
42,
1220,
83,
2623,
3491,
272,
291,
14,
1507,
2201,
30066,
2623,
3491,
275,
1967,
2201,
30066,
2623,
3491,
272,
291,
14,
2638,
7238,
275,
4601,
7238,
339,
327,
1804,
1024,
1190,
4426,
402,
4212,
5002,
14882,
83,
641,
642,
1834,
272,
291,
14,
1507,
42,
1220,
83,
2765,
3491,
275,
378,
272,
291,
14,
2019,
3491,
2681,
275,
488,
8330,
347,
1642,
8,
277,
304,
272,
408,
272,
2494,
1536,
314,
3421,
14,
339,
3523,
4527,
22732,
31055,
1834,
378,
12,
3268,
334,
16,
12,
16,
395,
5423,
2020,
1325,
15868,
21105,
626,
13809,
272,
370,
663,
282,
3365,
1642,
3421,
1077,
12247,
642,
1083,
14,
32753,
15868,
21105,
272,
1443,
13809,
370,
1240,
3523,
4527,
22732,
14,
2246,
8,
4218,
29,
797,
395,
1314,
2536,
6491,
314,
272,
3421,
2008,
1325,
1630,
440,
1240,
8126,
3491,
342,
334,
6777,
4293,
7675,
272,
23361,
14545,
370,
4781,
680,
272,
408,
339,
3523,
4527,
22732,
14,
2246,
8,
277,
12,
8126,
29,
797,
9,
339,
340,
440,
291,
14,
1507,
18882,
26,
489,
372,
339,
365,
28083,
275,
715,
272,
1830,
365,
28083,
26,
2541,
327,
16568,
282,
2196,
3421,
489,
340,
440,
291,
14,
1507,
42,
1220,
83,
2623,
3491,
503,
291,
14,
2019,
3491,
2681,
365,
488,
503,
971,
881,
334,
277,
14,
1507,
42,
1220,
83,
2765,
3491,
450,
291,
14,
1507,
42,
1220,
83,
2623,
3491,
508,
378,
304,
267,
327,
16568,
892,
1834,
267,
1834,
275,
291,
14,
4510,
3883,
3491,
8,
277,
14,
2355,
9,
267,
291,
14,
2019,
3491,
2681,
275,
1834,
267,
291,
14,
1507,
42,
1220,
83,
2765,
3491,
275,
378,
489,
587,
26,
267,
1834,
275,
291,
14,
2019,
3491,
2681,
489,
291,
14,
3124,
459,
1569,
418,
275,
1834,
489,
291,
14,
3124,
459,
4273,
418,
275,
291,
14,
4510,
3883,
18053,
8,
277
] |
[
20359,
199,
3,
22783,
16078,
367,
8883,
24024,
27799,
334,
21988,
26769,
9,
199,
3,
1898,
334,
35,
9,
6171,
12,
22783,
12,
3277,
14,
221,
4158,
1265,
1172,
376,
25025,
199,
3,
543,
22783,
12,
3277,
2020,
367,
282,
7396,
4190,
367,
642,
2032,
1233,
12,
314,
199,
3,
2569,
2895,
436,
3704,
4838,
26,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1684,
844,
1015,
650,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
199,
3,
1666,
314,
1664,
4265,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
14,
199,
3,
199,
3,
1455,
921,
78,
18952,
14,
1308,
15,
2383,
15,
199,
3,
20359,
199,
199,
504,
26084,
14,
11963,
14,
3491,
10160,
4527,
320,
21105,
14,
1563,
4527,
22732,
492,
3523,
4527,
22732,
421,
199,
533,
9571,
42,
1220,
8,
1563,
4527,
22732,
304,
819,
408,
523,
961,
15868,
3859,
19311,
24750,
12266,
14,
2779,
1630,
440,
886,
1263,
5584,
1024,
4073,
14,
523,
408,
8330,
347,
636,
826,
721,
277,
12,
14882,
5195,
1692,
29,
797,
12,
1967,
42,
1220,
83,
2623,
3491,
29,
403,
12,
2049,
1967,
2201,
30066,
2623,
3491,
29,
403,
12,
4601,
7238,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
3897,
26,
272,
5620,
13,
272,
14882,
5195,
1692,
26,
420,
7480,
314,
8778,
883,
1454,
2387,
282,
1777,
402,
314,
909,
12,
717,
465,
2013,
701,
314,
16842,
5689,
14,
982,
756,
12,
652,
911,
1454,
717,
4057,
370,
12266,
626,
2387,
465,
8298,
402,
314,
909,
465,
717,
3962,
14,
272,
1967,
42,
1220,
83,
2623,
3491,
26,
257,
710,
1329,
402,
10615,
367,
1314,
9571,
42,
1220,
717,
1077,
17594,
1697,
641,
1373,
1834,
2544,
12876,
641,
370,
314,
2163,
1373,
14,
272,
1967,
2201,
30066,
2623,
3491,
26,
221,
710,
1329,
402,
5431,
9571,
42,
1220,
1077,
5684,
1924,
717,
1834,
334,
460,
886,
1967,
42,
1220,
83,
2623,
3491,
14882,
83,
641,
652,
680,
272,
4601,
7238,
26,
260,
710,
334,
3333,
12,
3462,
9,
402,
314,
499,
13,
36,
4601,
370,
15868,
264,
14,
961,
717,
950,
345,
3617,
4212,
12474,
13437,
687,
314,
8126,
2376,
376,
1834,
717,
365,
4370,
370,
506,
26568,
14,
272,
408,
339,
3523,
4527,
22732,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
339,
340,
730,
8,
11126,
5195,
1692,
9,
440,
315,
334,
2245,
12,
1109,
304,
489,
746,
6064,
15587,
11126,
5195,
1692,
7,
1077,
506,
282,
5046,
531,
272,
340,
1967,
42,
1220,
83,
2623,
3491,
365,
440,
488,
436,
730,
8,
1507,
42,
1220,
83,
2623,
3491,
9,
365,
440,
1109,
26,
489,
746,
6064,
15587,
1507,
42,
1220,
83,
2623,
3491,
7,
1077,
506,
376,
3000,
531,
272,
340,
1967,
2201,
30066,
2623,
3491,
365,
440,
488,
436,
730,
8,
1507,
2201,
30066,
2623,
3491,
9,
365,
440,
1109,
26,
489,
746,
6064,
15587,
1507,
2201,
30066,
2623,
3491,
7,
1077,
506,
376,
3000,
531,
272,
340,
1967,
2201,
30066,
2623,
3491,
365,
440,
488,
436,
1967,
42,
1220,
83,
2623,
3491,
365,
488,
26,
489,
746,
6064,
480,
13757,
4165,
283,
1507,
42,
1220,
83,
2623,
3491,
4065,
267,
298,
1380,
1808,
283,
1507,
2201,
30066,
2623,
3491,
9859,
272,
340,
4601,
7238,
365,
440,
488,
436,
971,
2126,
334,
552,
8,
2638,
7238,
9,
1137,
499,
503,
4601,
7238,
59,
16,
61,
665,
413,
503,
4601,
7238,
59,
17,
61,
665,
413,
304,
489,
746,
6064,
15587,
2638,
7238,
7,
1077,
506,
282,
499,
13,
1053,
2008,
9176,
314,
2,
288,
7340,
3333,
12,
3462,
9,
402,
314,
20347,
4601,
370,
15868,
264,
2685,
2378,
291,
14,
11126,
5195,
1692,
275,
14882,
5195,
1692,
272,
291,
14,
1507,
42,
1220,
83,
2623,
3491,
275,
1967,
42,
1220,
83,
2623,
3491,
272,
291,
14,
1507,
2201,
30066,
2623,
3491,
275,
1967,
2201,
30066,
2623,
3491,
272,
291,
14,
2638,
7238,
275,
4601,
7238,
339,
327,
1804,
1024,
1190,
4426,
402,
4212,
5002,
14882,
83,
641,
642,
1834,
272,
291,
14,
1507,
42,
1220,
83,
2765,
3491,
275,
378,
272,
291,
14,
2019,
3491,
2681,
275,
488,
8330,
347,
1642,
8,
277,
304,
272,
408,
272,
2494,
1536,
314,
3421,
14,
339,
3523,
4527,
22732,
31055,
1834,
378,
12,
3268,
334,
16,
12,
16,
395,
5423,
2020,
1325,
15868,
21105,
626,
13809,
272,
370,
663,
282,
3365,
1642,
3421,
1077,
12247,
642,
1083,
14,
32753,
15868,
21105,
272,
1443,
13809,
370,
1240,
3523,
4527,
22732,
14,
2246,
8,
4218,
29,
797,
395,
1314,
2536,
6491,
314,
272,
3421,
2008,
1325,
1630,
440,
1240,
8126,
3491,
342,
334,
6777,
4293,
7675,
272,
23361,
14545,
370,
4781,
680,
272,
408,
339,
3523,
4527,
22732,
14,
2246,
8,
277,
12,
8126,
29,
797,
9,
339,
340,
440,
291,
14,
1507,
18882,
26,
489,
372,
339,
365,
28083,
275,
715,
272,
1830,
365,
28083,
26,
2541,
327,
16568,
282,
2196,
3421,
489,
340,
440,
291,
14,
1507,
42,
1220,
83,
2623,
3491,
503,
291,
14,
2019,
3491,
2681,
365,
488,
503,
971,
881,
334,
277,
14,
1507,
42,
1220,
83,
2765,
3491,
450,
291,
14,
1507,
42,
1220,
83,
2623,
3491,
508,
378,
304,
267,
327,
16568,
892,
1834,
267,
1834,
275,
291,
14,
4510,
3883,
3491,
8,
277,
14,
2355,
9,
267,
291,
14,
2019,
3491,
2681,
275,
1834,
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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
] |
mdblv2/joatu-django
|
application/site-packages/django/utils/timesince.py
|
79
|
2510
|
from __future__ import unicode_literals
import datetime
from django.utils.timezone import is_aware, utc
from django.utils.translation import ungettext, ugettext
def timesince(d, now=None, reversed=False):
"""
Takes two datetime objects and returns the time between d and now
as a nicely formatted string, e.g. "10 minutes". If d occurs after now,
then "0 minutes" is returned.
Units used are years, months, weeks, days, hours, and minutes.
Seconds and microseconds are ignored. Up to two adjacent units will be
displayed. For example, "2 weeks, 3 days" and "1 year, 3 months" are
possible outputs, but "2 weeks, 3 hours" and "1 year, 5 days" are not.
Adapted from
http://web.archive.org/web/20060617175230/http://blog.natbat.co.uk/archive/2003/Jun/14/time_since
"""
chunks = (
(60 * 60 * 24 * 365, lambda n: ungettext('year', 'years', n)),
(60 * 60 * 24 * 30, lambda n: ungettext('month', 'months', n)),
(60 * 60 * 24 * 7, lambda n : ungettext('week', 'weeks', n)),
(60 * 60 * 24, lambda n : ungettext('day', 'days', n)),
(60 * 60, lambda n: ungettext('hour', 'hours', n)),
(60, lambda n: ungettext('minute', 'minutes', n))
)
# Convert datetime.date to datetime.datetime for comparison.
if not isinstance(d, datetime.datetime):
d = datetime.datetime(d.year, d.month, d.day)
if now and not isinstance(now, datetime.datetime):
now = datetime.datetime(now.year, now.month, now.day)
if not now:
now = datetime.datetime.now(utc if is_aware(d) else None)
delta = (d - now) if reversed else (now - d)
# ignore microseconds
since = delta.days * 24 * 60 * 60 + delta.seconds
if since <= 0:
# d is in the future compared to now, stop processing.
return '0 ' + ugettext('minutes')
for i, (seconds, name) in enumerate(chunks):
count = since // seconds
if count != 0:
break
s = ugettext('%(number)d %(type)s') % {'number': count, 'type': name(count)}
if i + 1 < len(chunks):
# Now get the second item
seconds2, name2 = chunks[i + 1]
count2 = (since - (seconds * count)) // seconds2
if count2 != 0:
s += ugettext(', %(number)d %(type)s') % {'number': count2, 'type': name2(count2)}
return s
def timeuntil(d, now=None):
"""
Like timesince, but returns a string measuring the time until
the given time.
"""
return timesince(d, now, reversed=True)
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2197,
199,
199,
504,
1639,
14,
1208,
14,
7145,
492,
365,
63,
14600,
12,
19314,
199,
504,
1639,
14,
1208,
14,
6893,
492,
26843,
12,
10366,
199,
199,
318,
5431,
2855,
8,
68,
12,
3063,
29,
403,
12,
10822,
29,
797,
304,
272,
408,
272,
17415,
2877,
2197,
2251,
436,
2529,
314,
900,
3382,
366,
436,
3063,
272,
465,
282,
14213,
590,
7871,
1059,
12,
325,
14,
71,
14,
298,
709,
9395,
1674,
221,
982,
366,
11058,
2410,
3063,
12,
272,
2066,
298,
16,
9395,
2,
365,
2138,
14,
339,
1910,
1405,
1202,
787,
17399,
12,
20096,
12,
29540,
12,
7609,
12,
10857,
12,
436,
9395,
14,
272,
3240,
2776,
436,
21574,
787,
5525,
14,
221,
4949,
370,
2877,
24113,
6204,
911,
506,
272,
9080,
14,
221,
2104,
2893,
12,
298,
18,
29540,
12,
650,
7609,
2,
436,
298,
17,
5361,
12,
650,
20096,
2,
787,
272,
3962,
4704,
12,
1325,
298,
18,
29540,
12,
650,
10857,
2,
436,
298,
17,
5361,
12,
959,
7609,
2,
787,
440,
14,
339,
4431,
18309,
687,
272,
1455,
921,
2520,
14,
6404,
14,
1308,
15,
2520,
15,
7968,
1690,
1196,
1196,
2528,
1216,
15,
1014,
921,
11486,
14,
9468,
13475,
14,
331,
14,
3210,
15,
6404,
15,
17919,
15,
42,
324,
15,
1079,
15,
521,
63,
8585,
272,
408,
272,
8291,
275,
334,
489,
334,
2259,
627,
5212,
627,
5504,
627,
28046,
12,
2400,
302,
26,
26843,
360,
3403,
297,
283,
18431,
297,
302,
1826,
489,
334,
2259,
627,
5212,
627,
5504,
627,
4233,
12,
2400,
302,
26,
26843,
360,
4482,
297,
283,
16745,
297,
302,
1826,
489,
334,
2259,
627,
5212,
627,
5504,
627,
1520,
12,
2400,
302,
520,
26843,
360,
6419,
297,
283,
25287,
297,
302,
1826,
489,
334,
2259,
627,
5212,
627,
5504,
12,
2400,
302,
520,
26843,
360,
2977,
297,
283,
4899,
297,
302,
1826,
489,
334,
2259,
627,
5212,
12,
2400,
302,
26,
26843,
360,
5180,
297,
283,
8419,
297,
302,
1826,
489,
334,
2259,
12,
2400,
302,
26,
26843,
360,
10698,
297,
283,
10430,
297,
302,
430,
272,
776,
272,
327,
7905,
2197,
14,
602,
370,
2197,
14,
2083,
367,
9132,
14,
272,
340,
440,
1228,
8,
68,
12,
2197,
14,
2083,
304,
267,
366,
275,
2197,
14,
2083,
8,
68,
14,
3403,
12,
366,
14,
4482,
12,
366,
14,
2977,
9,
272,
340,
3063,
436,
440,
1228,
8,
2131,
12,
2197,
14,
2083,
304,
267,
3063,
275,
2197,
14,
2083,
8,
2131,
14,
3403,
12,
3063,
14,
4482,
12,
3063,
14,
2977,
9,
339,
340,
440,
3063,
26,
267,
3063,
275,
2197,
14,
2083,
14,
2131,
8,
5834,
340,
365,
63,
14600,
8,
68,
9,
587,
488,
9,
339,
5762,
275,
334,
68,
446,
3063,
9,
340,
10822,
587,
334,
2131,
446,
366,
9,
272,
327,
3686,
21574,
272,
3967,
275,
5762,
14,
4899,
627,
5504,
627,
5212,
627,
5212,
435,
5762,
14,
4515,
272,
340,
3967,
2695,
378,
26,
267,
327,
366,
365,
315,
314,
6466,
13524,
370,
3063,
12,
3631,
6661,
14,
267,
372,
283,
16,
283,
435,
10366,
360,
10430,
358,
272,
367,
284,
12,
334,
4515,
12,
536,
9,
315,
3874,
8,
10660,
304,
267,
2338,
275,
3967,
5001,
4696,
267,
340,
2338,
1137,
378,
26,
288,
2059,
272,
308,
275,
10366,
24713,
1955,
9,
68,
2818,
466,
9,
83,
358,
450,
791,
1955,
356,
2338,
12,
283,
466,
356,
536,
8,
835,
6769,
272,
340,
284,
435,
413,
665,
822,
8,
10660,
304,
267,
327,
7356,
664,
314,
3499,
1242,
267,
4696,
18,
12,
536,
18,
275,
8291,
59,
73,
435,
413,
61,
267,
2338,
18,
275,
334,
8585,
446,
334,
4515,
627,
2338,
430,
5001,
4696,
18,
267,
340,
2338,
18,
1137,
378,
26,
288,
308,
847,
10366,
5102,
2818,
1955,
9,
68,
2818,
466,
9,
83,
358,
450,
791,
1955,
356,
2338,
18,
12,
283,
466,
356,
536,
18,
8,
835,
18,
6769,
272,
372,
308,
199,
199,
318,
900,
8111,
8,
68,
12,
3063,
29,
403,
304,
272,
408,
272,
16485,
5431,
2855,
12,
1325,
2529,
282,
1059,
17616,
4039,
314,
900,
5133,
272,
314,
1627,
900,
14,
272,
408,
272,
372,
5431,
2855,
8,
68,
12,
3063,
12,
10822,
29,
549,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2197,
199,
199,
504,
1639,
14,
1208,
14,
7145,
492,
365,
63,
14600,
12,
19314,
199,
504,
1639,
14,
1208,
14,
6893,
492,
26843,
12,
10366,
199,
199,
318,
5431,
2855,
8,
68,
12,
3063,
29,
403,
12,
10822,
29,
797,
304,
272,
408,
272,
17415,
2877,
2197,
2251,
436,
2529,
314,
900,
3382,
366,
436,
3063,
272,
465,
282,
14213,
590,
7871,
1059,
12,
325,
14,
71,
14,
298,
709,
9395,
1674,
221,
982,
366,
11058,
2410,
3063,
12,
272,
2066,
298,
16,
9395,
2,
365,
2138,
14,
339,
1910,
1405,
1202,
787,
17399,
12,
20096,
12,
29540,
12,
7609,
12,
10857,
12,
436,
9395,
14,
272,
3240,
2776,
436,
21574,
787,
5525,
14,
221,
4949,
370,
2877,
24113,
6204,
911,
506,
272,
9080,
14,
221,
2104,
2893,
12,
298,
18,
29540,
12,
650,
7609,
2,
436,
298,
17,
5361,
12,
650,
20096,
2,
787,
272,
3962,
4704,
12,
1325,
298,
18,
29540,
12,
650,
10857,
2,
436,
298,
17,
5361,
12,
959,
7609,
2,
787,
440,
14,
339,
4431,
18309,
687,
272,
1455,
921,
2520,
14,
6404,
14,
1308,
15,
2520,
15,
7968,
1690,
1196,
1196,
2528,
1216,
15,
1014,
921,
11486,
14,
9468,
13475,
14,
331,
14,
3210,
15,
6404,
15,
17919,
15,
42,
324,
15,
1079,
15,
521,
63,
8585,
272,
408,
272,
8291,
275,
334,
489,
334,
2259,
627,
5212,
627,
5504,
627,
28046,
12,
2400,
302,
26,
26843,
360,
3403,
297,
283,
18431,
297,
302,
1826,
489,
334,
2259,
627,
5212,
627,
5504,
627,
4233,
12,
2400,
302,
26,
26843,
360,
4482,
297,
283,
16745,
297,
302,
1826,
489,
334,
2259,
627,
5212,
627,
5504,
627,
1520,
12,
2400,
302,
520,
26843,
360,
6419,
297,
283,
25287,
297,
302,
1826,
489,
334,
2259,
627,
5212,
627,
5504,
12,
2400,
302,
520,
26843,
360,
2977,
297,
283,
4899,
297,
302,
1826,
489,
334,
2259,
627,
5212,
12,
2400,
302,
26,
26843,
360,
5180,
297,
283,
8419,
297,
302,
1826,
489,
334,
2259,
12,
2400,
302,
26,
26843,
360,
10698,
297,
283,
10430,
297,
302,
430,
272,
776,
272,
327,
7905,
2197,
14,
602,
370,
2197,
14,
2083,
367,
9132,
14,
272,
340,
440,
1228,
8,
68,
12,
2197,
14,
2083,
304,
267,
366,
275,
2197,
14,
2083,
8,
68,
14,
3403,
12,
366,
14,
4482,
12,
366,
14,
2977,
9,
272,
340,
3063,
436,
440,
1228,
8,
2131,
12,
2197,
14,
2083,
304,
267,
3063,
275,
2197,
14,
2083,
8,
2131,
14,
3403,
12,
3063,
14,
4482,
12,
3063,
14,
2977,
9,
339,
340,
440,
3063,
26,
267,
3063,
275,
2197,
14,
2083,
14,
2131,
8,
5834,
340,
365,
63,
14600,
8,
68,
9,
587,
488,
9,
339,
5762,
275,
334,
68,
446,
3063,
9,
340,
10822,
587,
334,
2131,
446,
366,
9,
272,
327,
3686,
21574,
272,
3967,
275,
5762,
14,
4899,
627,
5504,
627,
5212,
627,
5212,
435,
5762,
14,
4515,
272,
340,
3967,
2695,
378,
26,
267,
327,
366,
365,
315,
314,
6466,
13524,
370,
3063,
12,
3631,
6661,
14,
267,
372,
283,
16,
283,
435,
10366,
360,
10430,
358,
272,
367,
284,
12,
334,
4515,
12,
536,
9,
315,
3874,
8,
10660,
304,
267,
2338,
275,
3967,
5001,
4696,
267,
340,
2338,
1137,
378,
26,
288,
2059,
272,
308,
275,
10366,
24713,
1955,
9,
68,
2818,
466,
9,
83,
358,
450,
791,
1955,
356,
2338,
12,
283,
466,
356,
536,
8,
835,
6769,
272,
340,
284,
435,
413,
665,
822,
8,
10660,
304,
267,
327,
7356,
664,
314,
3499,
1242,
267,
4696,
18,
12,
536,
18,
275,
8291,
59,
73,
435,
413,
61,
267,
2338,
18,
275,
334,
8585,
446,
334,
4515,
627,
2338,
430,
5001,
4696,
18,
267,
340,
2338,
18,
1137,
378,
26,
288,
308,
847,
10366,
5102,
2818,
1955,
9,
68,
2818,
466,
9,
83,
358,
450,
791,
1955,
356,
2338,
18,
12,
283,
466,
356,
536,
18,
8,
835,
18,
6769,
272,
372,
308,
199,
199,
318,
900,
8111,
8,
68,
12,
3063,
29,
403,
304,
272,
408,
272,
16485,
5431,
2855,
12,
1325,
2529,
282,
1059,
17616,
4039,
314,
900,
5133,
272,
314,
1627,
900,
14,
272,
408,
272,
372,
5431,
2855,
8,
68,
12,
3063,
12,
10822,
29,
549,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
simplyguru-dot/ansible-modules-extras
|
packaging/os/slackpkg.py
|
131
|
6382
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2014, Kim Nørgaard
# Written by Kim Nørgaard <jasen@jasen.dk>
# Based on pkgng module written by bleader <bleader@ratonland.org>
# that was based on pkgin module written by Shaun Zinck <shaun.zinck at gmail.com>
# that was based on pacman module written by Afterburn <http://github.com/afterburn>
# that was based on apt module written by Matthew Williams <matthew@flowroute.com>
#
# This module 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 software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
DOCUMENTATION = '''
---
module: slackpkg
short_description: Package manager for Slackware >= 12.2
description:
- Manage binary packages for Slackware using 'slackpkg' which
is available in versions after 12.2.
version_added: "2.0"
options:
name:
description:
- name of package to install/remove
required: true
state:
description:
- state of the package, you can use "installed" as an alias for C(present) and removed as one for c(absent).
choices: [ 'present', 'absent', 'latest' ]
required: false
default: present
update_cache:
description:
- update the package database first
required: false
default: false
choices: [ true, false ]
author: Kim Nørgaard (@KimNorgaard)
requirements: [ "Slackware >= 12.2" ]
'''
EXAMPLES = '''
# Install package foo
- slackpkg: name=foo state=present
# Remove packages foo and bar
- slackpkg: name=foo,bar state=absent
# Make sure that it is the most updated package
- slackpkg: name=foo state=latest
'''
def query_package(module, slackpkg_path, name):
import glob
import platform
machine = platform.machine()
packages = glob.glob("/var/log/packages/%s-*-[%s|noarch]*" % (name,
machine))
if len(packages) > 0:
return True
return False
def remove_packages(module, slackpkg_path, packages):
remove_c = 0
# Using a for loop incase of error, we can report the package that failed
for package in packages:
# Query the package first, to see if we even need to remove
if not query_package(module, slackpkg_path, package):
continue
if not module.check_mode:
rc, out, err = module.run_command("%s -default_answer=y -batch=on \
remove %s" % (slackpkg_path,
package))
if not module.check_mode and query_package(module, slackpkg_path,
package):
module.fail_json(msg="failed to remove %s: %s" % (package, out))
remove_c += 1
if remove_c > 0:
module.exit_json(changed=True, msg="removed %s package(s)" % remove_c)
module.exit_json(changed=False, msg="package(s) already absent")
def install_packages(module, slackpkg_path, packages):
install_c = 0
for package in packages:
if query_package(module, slackpkg_path, package):
continue
if not module.check_mode:
rc, out, err = module.run_command("%s -default_answer=y -batch=on \
install %s" % (slackpkg_path,
package))
if not module.check_mode and not query_package(module, slackpkg_path,
package):
module.fail_json(msg="failed to install %s: %s" % (package, out),
stderr=err)
install_c += 1
if install_c > 0:
module.exit_json(changed=True, msg="present %s package(s)"
% (install_c))
module.exit_json(changed=False, msg="package(s) already present")
def upgrade_packages(module, slackpkg_path, packages):
install_c = 0
for package in packages:
if not module.check_mode:
rc, out, err = module.run_command("%s -default_answer=y -batch=on \
upgrade %s" % (slackpkg_path,
package))
if not module.check_mode and not query_package(module, slackpkg_path,
package):
module.fail_json(msg="failed to install %s: %s" % (package, out),
stderr=err)
install_c += 1
if install_c > 0:
module.exit_json(changed=True, msg="present %s package(s)"
% (install_c))
module.exit_json(changed=False, msg="package(s) already present")
def update_cache(module, slackpkg_path):
rc, out, err = module.run_command("%s -batch=on update" % (slackpkg_path))
if rc != 0:
module.fail_json(msg="Could not update package cache")
def main():
module = AnsibleModule(
argument_spec=dict(
state=dict(default="installed", choices=['installed', 'removed', 'absent', 'present', 'latest']),
name=dict(aliases=["pkg"], required=True, type='list'),
update_cache=dict(default=False, aliases=["update-cache"],
type='bool'),
),
supports_check_mode=True)
slackpkg_path = module.get_bin_path('slackpkg', True)
p = module.params
pkgs = p['name']
if p["update_cache"]:
update_cache(module, slackpkg_path)
if p['state'] == 'latest':
upgrade_packages(module, slackpkg_path, pkgs)
elif p['state'] in ['present', 'installed']:
install_packages(module, slackpkg_path, pkgs)
elif p["state"] in ['removed', 'absent']:
remove_packages(module, slackpkg_path, pkgs)
# import module snippets
from ansible.module_utils.basic import *
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6927,
12,
1804,
1017,
653,
31087,
82,
5294,
1005,
199,
3,
27694,
701,
1804,
1017,
653,
31087,
82,
5294,
1005,
665,
74,
482,
78,
32,
74,
482,
78,
14,
6341,
30,
199,
3,
21311,
641,
3803,
784,
71,
859,
5313,
701,
330,
18498,
665,
830,
669,
32,
17565,
265,
9688,
14,
1308,
30,
199,
3,
626,
1990,
4079,
641,
3803,
903,
859,
5313,
701,
428,
2411,
324,
3107,
262,
346,
665,
4835,
324,
14,
90,
262,
346,
737,
29712,
14,
957,
30,
199,
3,
626,
1990,
4079,
641,
299,
645,
1237,
859,
5313,
701,
12836,
30736,
665,
1014,
921,
5031,
14,
957,
15,
4399,
30736,
30,
199,
3,
626,
1990,
4079,
641,
20932,
859,
5313,
701,
18619,
29640,
644,
8148,
19470,
665,
569,
29640,
32,
1659,
4449,
14,
957,
30,
199,
3,
199,
3,
961,
859,
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,
961,
2032,
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,
642,
2032,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
29877,
4600,
199,
3612,
63,
1802,
26,
15665,
5256,
367,
428,
5143,
1068,
2356,
3144,
14,
18,
199,
1802,
26,
272,
446,
14944,
3366,
6117,
367,
428,
5143,
1068,
1808,
283,
24567,
4600,
7,
1314,
489,
365,
2808,
315,
5459,
2410,
3144,
14,
18,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
1419,
26,
272,
536,
26,
267,
1369,
26,
288,
446,
536,
402,
2559,
370,
3907,
15,
2168,
267,
1415,
26,
2549,
339,
1174,
26,
267,
1369,
26,
288,
446,
1174,
402,
314,
2559,
12,
1265,
883,
675,
298,
7657,
2,
465,
376,
5162,
367,
445,
8,
1881,
9,
436,
4829,
465,
1373,
367,
286,
8,
5575,
680,
267,
3415,
26,
359,
283,
1881,
297,
283,
5575,
297,
283,
7410,
7,
1622,
267,
1415,
26,
3055,
267,
849,
26,
3451,
339,
1678,
63,
1637,
26,
267,
1369,
26,
288,
446,
1678,
314,
2559,
3050,
1642,
267,
1415,
26,
3055,
267,
849,
26,
3055,
267,
3415,
26,
359,
2549,
12,
3055,
1622,
199,
199,
2502,
26,
1804,
1017,
653,
31087,
82,
5294,
1005,
8593,
43,
1017,
46,
1308,
65,
1005,
9,
199,
7538,
26,
359,
298,
51,
5143,
1068,
2356,
3144,
14,
18,
2,
1622,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
13276,
2559,
3925,
199,
13,
29877,
4600,
26,
536,
29,
1421,
1174,
29,
1881,
199,
199,
3,
5852,
6117,
3925,
436,
4681,
199,
13,
29877,
4600,
26,
536,
29,
1421,
12,
1700,
1174,
29,
5575,
199,
199,
3,
4155,
3238,
626,
652,
365,
314,
4750,
4588,
2559,
199,
13,
29877,
4600,
26,
536,
29,
1421,
1174,
29,
7410,
199,
199,
2344,
421,
199,
318,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
536,
304,
339,
492,
5739,
272,
492,
4298,
339,
6844,
275,
4298,
14,
6744,
342,
272,
6117,
275,
5739,
14,
6463,
4769,
1391,
15,
793,
15,
5154,
3149,
83,
13,
1837,
9722,
83,
92,
889,
1047,
3672,
2,
450,
334,
354,
12,
25404,
6844,
430,
339,
340,
822,
8,
5154,
9,
690,
378,
26,
267,
372,
715,
339,
372,
756,
421,
199,
318,
2813,
63,
5154,
8,
578,
12,
29877,
4600,
63,
515,
12,
6117,
304,
339,
2813,
63,
67,
275,
378,
272,
327,
11719,
282,
367,
4438,
315,
2546,
402,
1125,
12,
781,
883,
3622,
314,
2559,
626,
3405,
272,
367,
2559,
315,
6117,
26,
267,
327,
8133,
314,
2559,
1642,
12,
370,
1937,
340,
781,
2755,
1929,
370,
2813,
267,
340,
440,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
2559,
304,
288,
1980,
398,
340,
440,
859,
14,
1074,
63,
632,
26,
288,
4819,
12,
734,
12,
2329,
275,
859,
14,
1065,
63,
1531,
3647,
83,
446,
885,
63,
5934,
29,
89,
446,
2912,
29,
265,
971,
6343,
2813,
450,
83,
2,
450,
334,
24567,
4600,
63,
515,
12,
6343,
2559,
430,
398,
340,
440,
859,
14,
1074,
63,
632,
436,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
8962,
2559,
304,
288,
859,
14,
1633,
63,
1001,
8,
1328,
628,
4892,
370,
2813,
450,
83,
26,
450,
83,
2,
450,
334,
2491,
12,
734,
430,
398,
2813,
63,
67,
847,
413,
339,
340,
2813,
63,
67,
690,
378,
26,
398,
859,
14,
2224,
63,
1001,
8,
2489,
29,
549,
12,
1499,
628,
10649,
450,
83,
2559,
8,
83,
2924,
450,
2813,
63,
67,
9,
339,
859,
14,
2224,
63,
1001,
8,
2489,
29,
797,
12,
1499,
628,
2491,
8,
83,
9,
2575,
9552,
531,
421,
199,
318,
3907,
63,
5154,
8,
578,
12,
29877,
4600,
63,
515,
12,
6117,
304,
339,
3907,
63,
67,
275,
378,
339,
367,
2559,
315,
6117,
26,
267,
340,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
2559,
304,
288,
1980,
398,
340,
440,
859,
14,
1074,
63,
632,
26,
288,
4819,
12,
734,
12,
2329,
275,
859,
14,
1065,
63,
1531,
3647,
83,
446,
885,
63,
5934,
29,
89,
446,
2912,
29,
265,
971,
6343,
3907,
450,
83,
2,
450,
334,
24567,
4600,
63,
515,
12,
6343,
2559,
430,
398,
340,
440,
859,
14,
1074,
63,
632,
436,
440,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
10940,
2559,
304,
288,
859,
14,
1633,
63,
1001,
8,
1328,
628,
4892,
370,
3907,
450,
83,
26,
450,
83
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6927,
12,
1804,
1017,
653,
31087,
82,
5294,
1005,
199,
3,
27694,
701,
1804,
1017,
653,
31087,
82,
5294,
1005,
665,
74,
482,
78,
32,
74,
482,
78,
14,
6341,
30,
199,
3,
21311,
641,
3803,
784,
71,
859,
5313,
701,
330,
18498,
665,
830,
669,
32,
17565,
265,
9688,
14,
1308,
30,
199,
3,
626,
1990,
4079,
641,
3803,
903,
859,
5313,
701,
428,
2411,
324,
3107,
262,
346,
665,
4835,
324,
14,
90,
262,
346,
737,
29712,
14,
957,
30,
199,
3,
626,
1990,
4079,
641,
299,
645,
1237,
859,
5313,
701,
12836,
30736,
665,
1014,
921,
5031,
14,
957,
15,
4399,
30736,
30,
199,
3,
626,
1990,
4079,
641,
20932,
859,
5313,
701,
18619,
29640,
644,
8148,
19470,
665,
569,
29640,
32,
1659,
4449,
14,
957,
30,
199,
3,
199,
3,
961,
859,
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,
961,
2032,
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,
642,
2032,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
29877,
4600,
199,
3612,
63,
1802,
26,
15665,
5256,
367,
428,
5143,
1068,
2356,
3144,
14,
18,
199,
1802,
26,
272,
446,
14944,
3366,
6117,
367,
428,
5143,
1068,
1808,
283,
24567,
4600,
7,
1314,
489,
365,
2808,
315,
5459,
2410,
3144,
14,
18,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
1419,
26,
272,
536,
26,
267,
1369,
26,
288,
446,
536,
402,
2559,
370,
3907,
15,
2168,
267,
1415,
26,
2549,
339,
1174,
26,
267,
1369,
26,
288,
446,
1174,
402,
314,
2559,
12,
1265,
883,
675,
298,
7657,
2,
465,
376,
5162,
367,
445,
8,
1881,
9,
436,
4829,
465,
1373,
367,
286,
8,
5575,
680,
267,
3415,
26,
359,
283,
1881,
297,
283,
5575,
297,
283,
7410,
7,
1622,
267,
1415,
26,
3055,
267,
849,
26,
3451,
339,
1678,
63,
1637,
26,
267,
1369,
26,
288,
446,
1678,
314,
2559,
3050,
1642,
267,
1415,
26,
3055,
267,
849,
26,
3055,
267,
3415,
26,
359,
2549,
12,
3055,
1622,
199,
199,
2502,
26,
1804,
1017,
653,
31087,
82,
5294,
1005,
8593,
43,
1017,
46,
1308,
65,
1005,
9,
199,
7538,
26,
359,
298,
51,
5143,
1068,
2356,
3144,
14,
18,
2,
1622,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
13276,
2559,
3925,
199,
13,
29877,
4600,
26,
536,
29,
1421,
1174,
29,
1881,
199,
199,
3,
5852,
6117,
3925,
436,
4681,
199,
13,
29877,
4600,
26,
536,
29,
1421,
12,
1700,
1174,
29,
5575,
199,
199,
3,
4155,
3238,
626,
652,
365,
314,
4750,
4588,
2559,
199,
13,
29877,
4600,
26,
536,
29,
1421,
1174,
29,
7410,
199,
199,
2344,
421,
199,
318,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
536,
304,
339,
492,
5739,
272,
492,
4298,
339,
6844,
275,
4298,
14,
6744,
342,
272,
6117,
275,
5739,
14,
6463,
4769,
1391,
15,
793,
15,
5154,
3149,
83,
13,
1837,
9722,
83,
92,
889,
1047,
3672,
2,
450,
334,
354,
12,
25404,
6844,
430,
339,
340,
822,
8,
5154,
9,
690,
378,
26,
267,
372,
715,
339,
372,
756,
421,
199,
318,
2813,
63,
5154,
8,
578,
12,
29877,
4600,
63,
515,
12,
6117,
304,
339,
2813,
63,
67,
275,
378,
272,
327,
11719,
282,
367,
4438,
315,
2546,
402,
1125,
12,
781,
883,
3622,
314,
2559,
626,
3405,
272,
367,
2559,
315,
6117,
26,
267,
327,
8133,
314,
2559,
1642,
12,
370,
1937,
340,
781,
2755,
1929,
370,
2813,
267,
340,
440,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
2559,
304,
288,
1980,
398,
340,
440,
859,
14,
1074,
63,
632,
26,
288,
4819,
12,
734,
12,
2329,
275,
859,
14,
1065,
63,
1531,
3647,
83,
446,
885,
63,
5934,
29,
89,
446,
2912,
29,
265,
971,
6343,
2813,
450,
83,
2,
450,
334,
24567,
4600,
63,
515,
12,
6343,
2559,
430,
398,
340,
440,
859,
14,
1074,
63,
632,
436,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
8962,
2559,
304,
288,
859,
14,
1633,
63,
1001,
8,
1328,
628,
4892,
370,
2813,
450,
83,
26,
450,
83,
2,
450,
334,
2491,
12,
734,
430,
398,
2813,
63,
67,
847,
413,
339,
340,
2813,
63,
67,
690,
378,
26,
398,
859,
14,
2224,
63,
1001,
8,
2489,
29,
549,
12,
1499,
628,
10649,
450,
83,
2559,
8,
83,
2924,
450,
2813,
63,
67,
9,
339,
859,
14,
2224,
63,
1001,
8,
2489,
29,
797,
12,
1499,
628,
2491,
8,
83,
9,
2575,
9552,
531,
421,
199,
318,
3907,
63,
5154,
8,
578,
12,
29877,
4600,
63,
515,
12,
6117,
304,
339,
3907,
63,
67,
275,
378,
339,
367,
2559,
315,
6117,
26,
267,
340,
1827,
63,
2491,
8,
578,
12,
29877,
4600,
63,
515,
12,
2559,
304,
288,
1980,
398,
340,
440,
859,
14,
1074,
63,
632,
26,
288,
4819,
12,
734,
12,
2329,
275,
859,
14,
1065,
63,
1531,
3647,
83,
446,
885,
63,
5934,
29,
89,
446,
2912,
29,
265,
971,
6343,
3907,
450,
83,
2,
450,
334,
24567,
4600,
63,
515,
12,
6343,
2559,
430,
398,
340,
440,
859,
14,
1074,
63,
632,
436,
440,
1827,
63,
2491,
8,
578,
12,
29877,
4600,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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
] |
waheedahmed/edx-platform
|
lms/djangoapps/lms_migration/migrate.py
|
47
|
8929
|
#
# migration tools for content team to go from stable-edx4edx to LMS+CMS
#
import json
import logging
import os
import xmodule.modulestore.django as xmodule_django
from xmodule.modulestore.django import modulestore
from django.http import HttpResponse
from django.conf import settings
import track.views
try:
from django.views.decorators.csrf import csrf_exempt
except ImportError:
from django.contrib.csrf.middleware import csrf_exempt
log = logging.getLogger("edx.lms_migrate")
LOCAL_DEBUG = True
ALLOWED_IPS = settings.LMS_MIGRATION_ALLOWED_IPS
def escape(s):
"""escape HTML special characters in string"""
return str(s).replace('<', '<').replace('>', '>')
def getip(request):
'''
Extract IP address of requester from header, even if behind proxy
'''
ip = request.META.get('HTTP_X_REAL_IP', '') # nginx reverse proxy
if not ip:
ip = request.META.get('REMOTE_ADDR', 'None')
return ip
def get_commit_id(course):
#return course.metadata.get('GIT_COMMIT_ID', 'No commit id')
return getattr(course, 'GIT_COMMIT_ID', 'No commit id')
# getattr(def_ms.courses[reload_dir], 'GIT_COMMIT_ID','No commit id')
def set_commit_id(course, commit_id):
#course.metadata['GIT_COMMIT_ID'] = commit_id
course.GIT_COMMIT_ID = commit_id
# def_ms.courses[reload_dir].GIT_COMMIT_ID = new_commit_id
def manage_modulestores(request, reload_dir=None, commit_id=None):
'''
Manage the static in-memory modulestores.
If reload_dir is not None, then instruct the xml loader to reload that course directory.
'''
html = "<html><body>"
def_ms = modulestore()
courses = def_ms.get_courses()
#----------------------------------------
# check on IP address of requester
ip = getip(request)
if LOCAL_DEBUG:
html += '<h3>IP address: %s <h3>' % ip
html += '<h3>User: %s </h3>' % request.user
html += '<h3>My pid: %s</h3>' % os.getpid()
log.debug(u'request from ip=%s, user=%s', ip, request.user)
if not (ip in ALLOWED_IPS or 'any' in ALLOWED_IPS):
if request.user and request.user.is_staff:
log.debug(u'request allowed because user=%s is staff', request.user)
else:
html += 'Permission denied'
html += "</body></html>"
log.debug('request denied, ALLOWED_IPS=%s', ALLOWED_IPS)
return HttpResponse(html, status=403)
#----------------------------------------
# reload course if specified; handle optional commit_id
if reload_dir is not None:
if reload_dir not in def_ms.courses:
html += '<h2 class="inline-error">Error: "%s" is not a valid course directory</h2>' % reload_dir
else:
# reloading based on commit_id is needed when running mutiple worker threads,
# so that a given thread doesn't reload the same commit multiple times
current_commit_id = get_commit_id(def_ms.courses[reload_dir])
log.debug('commit_id="%s"', commit_id)
log.debug('current_commit_id="%s"', current_commit_id)
if (commit_id is not None) and (commit_id == current_commit_id):
html += "<h2>Already at commit id %s for %s</h2>" % (commit_id, reload_dir)
track.views.server_track(request,
'reload %s skipped already at %s (pid=%s)' % (reload_dir,
commit_id,
os.getpid(),
),
{}, page='migrate')
else:
html += '<h2>Reloaded course directory "%s"</h2>' % reload_dir
def_ms.try_load_course(reload_dir)
gdir = settings.DATA_DIR / reload_dir
new_commit_id = os.popen('cd %s; git log -n 1 | head -1' % gdir).read().strip().split(' ')[1]
set_commit_id(def_ms.courses[reload_dir], new_commit_id)
html += '<p>commit_id=%s</p>' % new_commit_id
track.views.server_track(request, 'reloaded %s now at %s (pid=%s)' % (reload_dir,
new_commit_id,
os.getpid()), {}, page='migrate')
#----------------------------------------
html += '<h2>Courses loaded in the modulestore</h2>'
html += '<ol>'
for cdir, course in def_ms.courses.items():
html += '<li><a href="%s/migrate/reload/%s">%s</a> (%s)</li>' % (
settings.EDX_ROOT_URL,
escape(cdir),
escape(cdir),
course.location.to_deprecated_string()
)
html += '</ol>'
#----------------------------------------
#dumpfields = ['definition', 'location', 'metadata']
dumpfields = ['location', 'metadata']
for cdir, course in def_ms.courses.items():
html += '<hr width="100%"/>'
html += '<h2>Course: %s (%s)</h2>' % (course.display_name_with_default_escaped, cdir)
html += '<p>commit_id=%s</p>' % get_commit_id(course)
for field in dumpfields:
data = getattr(course, field, None)
html += '<h3>%s</h3>' % field
if isinstance(data, dict):
html += '<ul>'
for k, v in data.items():
html += '<li>%s:%s</li>' % (escape(k), escape(v))
html += '</ul>'
else:
html += '<ul><li>%s</li></ul>' % escape(data)
#----------------------------------------
html += '<hr width="100%"/>'
html += "courses: <pre>%s</pre>" % escape(courses)
ms = xmodule_django._MODULESTORES
html += "modules: <pre>%s</pre>" % escape(ms)
html += "default modulestore: <pre>%s</pre>" % escape(unicode(def_ms))
#----------------------------------------
log.debug('_MODULESTORES=%s', ms)
log.debug('courses=%s', courses)
log.debug('def_ms=%s', unicode(def_ms))
html += "</body></html>"
return HttpResponse(html)
@csrf_exempt
def gitreload(request, reload_dir=None):
'''
This can be used as a github WebHook Service Hook, for reloading of the content repo used by the LMS.
If reload_dir is not None, then instruct the xml loader to reload that course directory.
'''
html = "<html><body>"
ip = getip(request)
html += '<h3>IP address: %s ' % ip
html += '<h3>User: %s ' % request.user
ALLOWED_IPS = [] # allow none by default
if hasattr(settings, 'ALLOWED_GITRELOAD_IPS'): # allow override in settings
ALLOWED_IPS = settings.ALLOWED_GITRELOAD_IPS
if not (ip in ALLOWED_IPS or 'any' in ALLOWED_IPS):
if request.user and request.user.is_staff:
log.debug(u'request allowed because user=%s is staff', request.user)
else:
html += 'Permission denied'
html += "</body></html>"
log.debug('request denied from %s, ALLOWED_IPS=%s', ip, ALLOWED_IPS)
return HttpResponse(html)
#----------------------------------------
# see if request is from github (POST with JSON)
if reload_dir is None and 'payload' in request.POST:
payload = request.POST['payload']
log.debug("payload=%s", payload)
gitargs = json.loads(payload)
log.debug("gitargs=%s", gitargs)
reload_dir = gitargs['repository']['name']
log.debug("github reload_dir=%s", reload_dir)
gdir = settings.DATA_DIR / reload_dir
if not os.path.exists(gdir):
log.debug("====> ERROR in gitreload - no such directory %s", reload_dir)
return HttpResponse('Error')
cmd = "cd %s; git reset --hard HEAD; git clean -f -d; git pull origin; chmod g+w course.xml" % gdir
log.debug(os.popen(cmd).read())
if hasattr(settings, 'GITRELOAD_HOOK'): # hit this hook after reload, if set
gh = settings.GITRELOAD_HOOK
if gh:
ghurl = '%s/%s' % (gh, reload_dir)
r = requests.get(ghurl)
log.debug("GITRELOAD_HOOK to %s: %s", ghurl, r.text)
#----------------------------------------
# reload course if specified
if reload_dir is not None:
def_ms = modulestore()
if reload_dir not in def_ms.courses:
html += '<h2 class="inline-error">Error: "%s" is not a valid course directory</font></h2>' % reload_dir
else:
html += "<h2>Reloaded course directory '%s'</h2>" % reload_dir
def_ms.try_load_course(reload_dir)
track.views.server_track(request, 'reloaded %s' % reload_dir, {}, page='migrate')
return HttpResponse(html)
|
agpl-3.0
|
[
3,
199,
3,
8367,
7249,
367,
1564,
8099,
370,
2621,
687,
17830,
13,
8268,
20,
8268,
370,
27540,
11,
17834,
199,
3,
199,
199,
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
646,
9872,
14,
10012,
14,
1176,
465,
9872,
63,
1176,
199,
504,
9872,
14,
10012,
14,
1176,
492,
10996,
199,
199,
504,
1639,
14,
1014,
492,
6183,
199,
504,
1639,
14,
2190,
492,
2202,
199,
646,
4426,
14,
4196,
199,
199,
893,
26,
272,
687,
1639,
14,
4196,
14,
11582,
14,
10088,
492,
19213,
63,
25254,
199,
2590,
3545,
26,
272,
687,
1639,
14,
2828,
14,
10088,
14,
5754,
492,
19213,
63,
25254,
199,
199,
793,
275,
2050,
14,
5572,
480,
8268,
14,
15807,
63,
8462,
531,
199,
7486,
63,
5287,
275,
715,
199,
17350,
63,
12346,
275,
2202,
14,
44,
3053,
63,
22487,
23743,
63,
17350,
63,
12346,
421,
199,
318,
4772,
8,
83,
304,
272,
408,
3765,
4163,
4539,
4110,
315,
1059,
624,
272,
372,
620,
8,
83,
680,
1814,
4827,
297,
7673,
4116,
27,
1959,
1814,
360,
4206,
7673,
3308,
10784,
421,
199,
318,
2312,
8996,
8,
1069,
304,
272,
1449,
272,
12892,
3531,
2287,
402,
295,
18246,
687,
1406,
12,
2755,
340,
22172,
4566,
272,
1449,
272,
3384,
275,
1056,
14,
10614,
14,
362,
360,
2856,
63,
56,
63,
15508,
63,
1772,
297,
4074,
257,
198,
3,
302,
19101,
3837,
4566,
272,
340,
440,
3384,
26,
267,
3384,
275,
1056,
14,
10614,
14,
362,
360,
16058,
63,
7803,
297,
283,
403,
358,
272,
372,
3384,
421,
199,
318,
664,
63,
3543,
63,
344,
8,
1972,
304,
272,
327,
1107,
2518,
14,
2343,
14,
362,
360,
20072,
63,
23446,
63,
998,
297,
283,
1944,
5532,
1305,
358,
272,
372,
2519,
8,
1972,
12,
283,
20072,
63,
23446,
63,
998,
297,
283,
1944,
5532,
1305,
358,
272,
327,
2519,
8,
318,
63,
706,
14,
11653,
59,
9233,
63,
694,
467,
283,
20072,
63,
23446,
63,
998,
1673,
1944,
5532,
1305,
358,
421,
199,
318,
663,
63,
3543,
63,
344,
8,
1972,
12,
5532,
63,
344,
304,
272,
327,
1972,
14,
2343,
459,
20072,
63,
23446,
63,
998,
418,
275,
5532,
63,
344,
272,
2518,
14,
20072,
63,
23446,
63,
998,
275,
5532,
63,
344,
272,
327,
347,
63,
706,
14,
11653,
59,
9233,
63,
694,
1055,
20072,
63,
23446,
63,
998,
275,
892,
63,
3543,
63,
344,
421,
199,
318,
9635,
63,
578,
18958,
8,
1069,
12,
13101,
63,
694,
29,
403,
12,
5532,
63,
344,
29,
403,
304,
272,
1449,
272,
14944,
314,
2955,
315,
13,
4844,
859,
18958,
14,
339,
982,
13101,
63,
694,
365,
440,
488,
12,
2066,
315,
1820,
314,
2748,
5077,
370,
13101,
626,
2518,
2082,
14,
272,
1449,
272,
3517,
275,
3886,
1360,
2535,
2030,
4335,
339,
347,
63,
706,
275,
10996,
342,
272,
13588,
275,
347,
63,
706,
14,
362,
63,
11653,
342,
339,
327,
32111,
272,
327,
1104,
641,
3531,
2287,
402,
295,
18246,
339,
3384,
275,
2312,
8996,
8,
1069,
9,
339,
340,
20639,
63,
5287,
26,
267,
3517,
847,
2650,
72,
19,
30,
1772,
2287,
26,
450,
83,
665,
72,
19,
3524,
450,
3384,
267,
3517,
847,
2650,
72,
19,
30,
1899,
26,
450,
83,
3068,
72,
19,
3524,
450,
1056,
14,
751,
267,
3517,
847,
2650,
72,
19,
30,
5713,
4422,
26,
450,
83,
1108,
72,
19,
3524,
450,
747,
14,
17829,
342,
267,
943,
14,
1757,
8,
85,
3984,
613,
687,
3384,
2458,
83,
12,
922,
2458,
83,
297,
3384,
12,
1056,
14,
751,
9,
339,
340,
440,
334,
711,
315,
27805,
1149,
63,
12346,
503,
283,
1629,
7,
315,
27805,
1149,
63,
12346,
304,
267,
340,
1056,
14,
751,
436,
1056,
14,
751,
14,
374,
63,
7018,
26,
288,
943,
14,
1757,
8,
85,
3984,
613,
4370,
2952,
922,
2458,
83,
365,
12622,
297,
1056,
14,
751,
9,
267,
587,
26,
288,
3517,
847,
283,
7980,
23355,
7,
288,
3517,
847,
15683,
2030,
2957,
1360,
4335,
288,
943,
14,
1757,
360,
1069,
23355,
12,
27805,
1149,
63,
12346,
2458,
83,
297,
27805,
1149,
63,
12346,
9,
288,
372,
6183,
8,
1360,
12,
2004,
29,
13353,
9,
339,
327,
32111,
272,
327,
13101,
2518,
340,
2013,
27,
2429,
2716,
5532,
63,
344,
339,
340,
13101,
63,
694,
365,
440,
488,
26,
267,
340,
13101,
63,
694,
440,
315,
347,
63,
706,
14,
11653,
26,
288,
3517,
847,
2650,
72,
18,
1021,
628,
6460,
13,
705,
1743,
547,
26,
2071,
83,
2,
365,
440,
282,
1686,
2518,
2082,
1108,
72,
18,
3524,
450,
13101,
63,
694,
267,
587,
26,
288,
327,
295,
8786,
4079,
641,
5532,
63,
344,
365,
4346,
1380,
3879,
333,
935,
11045,
7239,
7183,
12,
288,
327,
880,
626,
282,
1627,
2462,
3181,
1133,
13101,
314,
2011,
5532,
3663,
5431,
288,
1453,
63,
3543,
63,
344,
275,
664,
63,
3543,
63,
344,
8,
318,
63,
706,
14,
11653,
59,
9233,
63,
694,
566,
288,
943,
14,
1757,
360,
3543,
63,
344,
5961,
83,
6949,
5532,
63,
344,
9,
288,
943,
14,
1757,
360,
1818,
63,
3543,
63,
344,
5961,
83,
6949,
1453,
63,
3543,
63,
344,
9,
953,
340,
334,
3543,
63,
344,
365,
440,
488,
9,
436,
334,
3543,
63,
344,
508,
1453,
63,
3543,
63,
344,
304,
355,
3517,
847,
3886,
72,
18,
30,
16760,
737,
5532,
1305,
450,
83,
367,
450,
83,
1108,
72,
18,
4335,
450,
334,
3543,
63,
344,
12,
13101,
63,
694,
9,
355,
4426,
14,
4196,
14,
1000,
63,
3885,
8,
1069,
12,
1460,
283,
9233,
450,
83,
9645,
2575,
737,
450,
83,
334,
3150,
2458,
83,
3171,
450,
334,
9233,
63,
694,
12,
12268,
755,
5532,
63,
344,
12,
12268,
755,
747,
14,
17829,
1062,
12268,
755,
2318,
1460,
5479,
2034,
534,
8462,
358,
288,
587,
26,
355,
3517,
847,
2650,
72,
18,
30,
497,
4591,
2518,
2082,
2071,
83,
2,
1108,
72,
18,
3524,
450,
13101,
63,
694,
355,
347,
63,
706,
14,
893,
63,
912,
63,
1972,
8,
9233,
63,
694,
9,
355,
486,
694,
275,
2202,
14,
3998,
63,
3022,
1182,
13101,
63,
694,
355,
892,
63,
3543,
63,
344,
275,
747,
14,
12207,
360,
2866,
450,
83,
27,
6135,
943,
446,
78,
413
] |
[
199,
3,
8367,
7249,
367,
1564,
8099,
370,
2621,
687,
17830,
13,
8268,
20,
8268,
370,
27540,
11,
17834,
199,
3,
199,
199,
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
646,
9872,
14,
10012,
14,
1176,
465,
9872,
63,
1176,
199,
504,
9872,
14,
10012,
14,
1176,
492,
10996,
199,
199,
504,
1639,
14,
1014,
492,
6183,
199,
504,
1639,
14,
2190,
492,
2202,
199,
646,
4426,
14,
4196,
199,
199,
893,
26,
272,
687,
1639,
14,
4196,
14,
11582,
14,
10088,
492,
19213,
63,
25254,
199,
2590,
3545,
26,
272,
687,
1639,
14,
2828,
14,
10088,
14,
5754,
492,
19213,
63,
25254,
199,
199,
793,
275,
2050,
14,
5572,
480,
8268,
14,
15807,
63,
8462,
531,
199,
7486,
63,
5287,
275,
715,
199,
17350,
63,
12346,
275,
2202,
14,
44,
3053,
63,
22487,
23743,
63,
17350,
63,
12346,
421,
199,
318,
4772,
8,
83,
304,
272,
408,
3765,
4163,
4539,
4110,
315,
1059,
624,
272,
372,
620,
8,
83,
680,
1814,
4827,
297,
7673,
4116,
27,
1959,
1814,
360,
4206,
7673,
3308,
10784,
421,
199,
318,
2312,
8996,
8,
1069,
304,
272,
1449,
272,
12892,
3531,
2287,
402,
295,
18246,
687,
1406,
12,
2755,
340,
22172,
4566,
272,
1449,
272,
3384,
275,
1056,
14,
10614,
14,
362,
360,
2856,
63,
56,
63,
15508,
63,
1772,
297,
4074,
257,
198,
3,
302,
19101,
3837,
4566,
272,
340,
440,
3384,
26,
267,
3384,
275,
1056,
14,
10614,
14,
362,
360,
16058,
63,
7803,
297,
283,
403,
358,
272,
372,
3384,
421,
199,
318,
664,
63,
3543,
63,
344,
8,
1972,
304,
272,
327,
1107,
2518,
14,
2343,
14,
362,
360,
20072,
63,
23446,
63,
998,
297,
283,
1944,
5532,
1305,
358,
272,
372,
2519,
8,
1972,
12,
283,
20072,
63,
23446,
63,
998,
297,
283,
1944,
5532,
1305,
358,
272,
327,
2519,
8,
318,
63,
706,
14,
11653,
59,
9233,
63,
694,
467,
283,
20072,
63,
23446,
63,
998,
1673,
1944,
5532,
1305,
358,
421,
199,
318,
663,
63,
3543,
63,
344,
8,
1972,
12,
5532,
63,
344,
304,
272,
327,
1972,
14,
2343,
459,
20072,
63,
23446,
63,
998,
418,
275,
5532,
63,
344,
272,
2518,
14,
20072,
63,
23446,
63,
998,
275,
5532,
63,
344,
272,
327,
347,
63,
706,
14,
11653,
59,
9233,
63,
694,
1055,
20072,
63,
23446,
63,
998,
275,
892,
63,
3543,
63,
344,
421,
199,
318,
9635,
63,
578,
18958,
8,
1069,
12,
13101,
63,
694,
29,
403,
12,
5532,
63,
344,
29,
403,
304,
272,
1449,
272,
14944,
314,
2955,
315,
13,
4844,
859,
18958,
14,
339,
982,
13101,
63,
694,
365,
440,
488,
12,
2066,
315,
1820,
314,
2748,
5077,
370,
13101,
626,
2518,
2082,
14,
272,
1449,
272,
3517,
275,
3886,
1360,
2535,
2030,
4335,
339,
347,
63,
706,
275,
10996,
342,
272,
13588,
275,
347,
63,
706,
14,
362,
63,
11653,
342,
339,
327,
32111,
272,
327,
1104,
641,
3531,
2287,
402,
295,
18246,
339,
3384,
275,
2312,
8996,
8,
1069,
9,
339,
340,
20639,
63,
5287,
26,
267,
3517,
847,
2650,
72,
19,
30,
1772,
2287,
26,
450,
83,
665,
72,
19,
3524,
450,
3384,
267,
3517,
847,
2650,
72,
19,
30,
1899,
26,
450,
83,
3068,
72,
19,
3524,
450,
1056,
14,
751,
267,
3517,
847,
2650,
72,
19,
30,
5713,
4422,
26,
450,
83,
1108,
72,
19,
3524,
450,
747,
14,
17829,
342,
267,
943,
14,
1757,
8,
85,
3984,
613,
687,
3384,
2458,
83,
12,
922,
2458,
83,
297,
3384,
12,
1056,
14,
751,
9,
339,
340,
440,
334,
711,
315,
27805,
1149,
63,
12346,
503,
283,
1629,
7,
315,
27805,
1149,
63,
12346,
304,
267,
340,
1056,
14,
751,
436,
1056,
14,
751,
14,
374,
63,
7018,
26,
288,
943,
14,
1757,
8,
85,
3984,
613,
4370,
2952,
922,
2458,
83,
365,
12622,
297,
1056,
14,
751,
9,
267,
587,
26,
288,
3517,
847,
283,
7980,
23355,
7,
288,
3517,
847,
15683,
2030,
2957,
1360,
4335,
288,
943,
14,
1757,
360,
1069,
23355,
12,
27805,
1149,
63,
12346,
2458,
83,
297,
27805,
1149,
63,
12346,
9,
288,
372,
6183,
8,
1360,
12,
2004,
29,
13353,
9,
339,
327,
32111,
272,
327,
13101,
2518,
340,
2013,
27,
2429,
2716,
5532,
63,
344,
339,
340,
13101,
63,
694,
365,
440,
488,
26,
267,
340,
13101,
63,
694,
440,
315,
347,
63,
706,
14,
11653,
26,
288,
3517,
847,
2650,
72,
18,
1021,
628,
6460,
13,
705,
1743,
547,
26,
2071,
83,
2,
365,
440,
282,
1686,
2518,
2082,
1108,
72,
18,
3524,
450,
13101,
63,
694,
267,
587,
26,
288,
327,
295,
8786,
4079,
641,
5532,
63,
344,
365,
4346,
1380,
3879,
333,
935,
11045,
7239,
7183,
12,
288,
327,
880,
626,
282,
1627,
2462,
3181,
1133,
13101,
314,
2011,
5532,
3663,
5431,
288,
1453,
63,
3543,
63,
344,
275,
664,
63,
3543,
63,
344,
8,
318,
63,
706,
14,
11653,
59,
9233,
63,
694,
566,
288,
943,
14,
1757,
360,
3543,
63,
344,
5961,
83,
6949,
5532,
63,
344,
9,
288,
943,
14,
1757,
360,
1818,
63,
3543,
63,
344,
5961,
83,
6949,
1453,
63,
3543,
63,
344,
9,
953,
340,
334,
3543,
63,
344,
365,
440,
488,
9,
436,
334,
3543,
63,
344,
508,
1453,
63,
3543,
63,
344,
304,
355,
3517,
847,
3886,
72,
18,
30,
16760,
737,
5532,
1305,
450,
83,
367,
450,
83,
1108,
72,
18,
4335,
450,
334,
3543,
63,
344,
12,
13101,
63,
694,
9,
355,
4426,
14,
4196,
14,
1000,
63,
3885,
8,
1069,
12,
1460,
283,
9233,
450,
83,
9645,
2575,
737,
450,
83,
334,
3150,
2458,
83,
3171,
450,
334,
9233,
63,
694,
12,
12268,
755,
5532,
63,
344,
12,
12268,
755,
747,
14,
17829,
1062,
12268,
755,
2318,
1460,
5479,
2034,
534,
8462,
358,
288,
587,
26,
355,
3517,
847,
2650,
72,
18,
30,
497,
4591,
2518,
2082,
2071,
83,
2,
1108,
72,
18,
3524,
450,
13101,
63,
694,
355,
347,
63,
706,
14,
893,
63,
912,
63,
1972,
8,
9233,
63,
694,
9,
355,
486,
694,
275,
2202,
14,
3998,
63,
3022,
1182,
13101,
63,
694,
355,
892,
63,
3543,
63,
344,
275,
747,
14,
12207,
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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
x303597316/hue
|
desktop/core/ext-py/Django-1.6.10/tests/generic_views/test_edit.py
|
50
|
17194
|
from __future__ import absolute_import
import warnings
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django import forms
from django.test import TestCase
from django.utils.unittest import expectedFailure
from django.test.client import RequestFactory
from django.views.generic.base import View
from django.views.generic.edit import FormMixin, CreateView
from . import views
from .models import Artist, Author
class FormMixinTests(TestCase):
def test_initial_data(self):
""" Test instance independence of initial data dict (see #16138) """
initial_1 = FormMixin().get_initial()
initial_1['foo'] = 'bar'
initial_2 = FormMixin().get_initial()
self.assertNotEqual(initial_1, initial_2)
def test_get_prefix(self):
""" Test prefix can be set (see #18872) """
test_string = 'test'
rf = RequestFactory()
get_request = rf.get('/')
class TestFormMixin(FormMixin):
request = get_request
default_kwargs = TestFormMixin().get_form_kwargs()
self.assertEqual(None, default_kwargs.get('prefix'))
set_mixin = TestFormMixin()
set_mixin.prefix = test_string
set_kwargs = set_mixin.get_form_kwargs()
self.assertEqual(test_string, set_kwargs.get('prefix'))
class BasicFormTests(TestCase):
urls = 'generic_views.urls'
def test_post_data(self):
res = self.client.post('/contact/', {'name': "Me", 'message': "Hello"})
self.assertRedirects(res, 'http://testserver/list/authors/')
class ModelFormMixinTests(TestCase):
def test_get_form(self):
form_class = views.AuthorGetQuerySetFormView().get_form_class()
self.assertEqual(form_class._meta.model, Author)
class CreateViewTests(TestCase):
urls = 'generic_views.urls'
def test_create(self):
res = self.client.get('/edit/authors/create/')
self.assertEqual(res.status_code, 200)
self.assertIsInstance(res.context['form'], forms.ModelForm)
self.assertIsInstance(res.context['view'], View)
self.assertFalse('object' in res.context)
self.assertFalse('author' in res.context)
self.assertTemplateUsed(res, 'generic_views/author_form.html')
res = self.client.post('/edit/authors/create/',
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/list/authors/')
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
def test_create_invalid(self):
res = self.client.post('/edit/authors/create/',
{'name': 'A' * 101, 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, 'generic_views/author_form.html')
self.assertEqual(len(res.context['form'].errors), 1)
self.assertEqual(Author.objects.count(), 0)
def test_create_with_object_url(self):
res = self.client.post('/edit/artists/create/',
{'name': 'Rene Magritte'})
self.assertEqual(res.status_code, 302)
artist = Artist.objects.get(name='Rene Magritte')
self.assertRedirects(res, 'http://testserver/detail/artist/%d/' % artist.pk)
self.assertQuerysetEqual(Artist.objects.all(), ['<Artist: Rene Magritte>'])
def test_create_with_redirect(self):
res = self.client.post('/edit/authors/create/redirect/',
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/edit/authors/create/')
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
def test_create_with_interpolated_redirect(self):
res = self.client.post('/edit/authors/create/interpolate_redirect/',
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
self.assertEqual(res.status_code, 302)
pk = Author.objects.all()[0].pk
self.assertRedirects(res, 'http://testserver/edit/author/%d/update/' % pk)
def test_create_with_special_properties(self):
res = self.client.get('/edit/authors/create/special/')
self.assertEqual(res.status_code, 200)
self.assertIsInstance(res.context['form'], views.AuthorForm)
self.assertFalse('object' in res.context)
self.assertFalse('author' in res.context)
self.assertTemplateUsed(res, 'generic_views/form.html')
res = self.client.post('/edit/authors/create/special/',
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
obj = Author.objects.get(slug='randall-munroe')
self.assertRedirects(res, reverse('author_detail', kwargs={'pk': obj.pk}))
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
def test_create_without_redirect(self):
try:
res = self.client.post('/edit/authors/create/naive/',
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
self.fail('Should raise exception -- No redirect URL provided, and no get_absolute_url provided')
except ImproperlyConfigured:
pass
def test_create_restricted(self):
res = self.client.post('/edit/authors/create/restricted/',
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/accounts/login/?next=/edit/authors/create/restricted/')
def test_create_view_with_restricted_fields(self):
class MyCreateView(CreateView):
model = Author
fields = ['name']
self.assertEqual(list(MyCreateView().get_form_class().base_fields),
['name'])
def test_create_view_all_fields(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", PendingDeprecationWarning)
class MyCreateView(CreateView):
model = Author
fields = '__all__'
self.assertEqual(list(MyCreateView().get_form_class().base_fields),
['name', 'slug'])
self.assertEqual(len(w), 0)
def test_create_view_without_explicit_fields(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", PendingDeprecationWarning)
class MyCreateView(CreateView):
model = Author
# Until end of the deprecation cycle, should still create the form
# as before:
self.assertEqual(list(MyCreateView().get_form_class().base_fields),
['name', 'slug'])
# but with a warning:
self.assertEqual(w[0].category, PendingDeprecationWarning)
class UpdateViewTests(TestCase):
urls = 'generic_views.urls'
def test_update_post(self):
a = Author.objects.create(
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.get('/edit/author/%d/update/' % a.pk)
self.assertEqual(res.status_code, 200)
self.assertIsInstance(res.context['form'], forms.ModelForm)
self.assertEqual(res.context['object'], Author.objects.get(pk=a.pk))
self.assertEqual(res.context['author'], Author.objects.get(pk=a.pk))
self.assertTemplateUsed(res, 'generic_views/author_form.html')
# Modification with both POST and PUT (browser compatible)
res = self.client.post('/edit/author/%d/update/' % a.pk,
{'name': 'Randall Munroe (xkcd)', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/list/authors/')
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (xkcd)>'])
@expectedFailure
def test_update_put(self):
a = Author.objects.create(
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.get('/edit/author/%d/update/' % a.pk)
self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, 'generic_views/author_form.html')
res = self.client.put('/edit/author/%d/update/' % a.pk,
{'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
# Here is the expected failure. PUT data are not processed in any special
# way by django. So the request will equal to a POST without data, hence
# the form will be invalid and redisplayed with errors (status code 200).
# See also #12635
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/list/authors/')
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
def test_update_invalid(self):
a = Author.objects.create(
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.post('/edit/author/%d/update/' % a.pk,
{'name': 'A' * 101, 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, 'generic_views/author_form.html')
self.assertEqual(len(res.context['form'].errors), 1)
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
def test_update_with_object_url(self):
a = Artist.objects.create(name='Rene Magritte')
res = self.client.post('/edit/artists/%d/update/' % a.pk,
{'name': 'Rene Magritte'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/detail/artist/%d/' % a.pk)
self.assertQuerysetEqual(Artist.objects.all(), ['<Artist: Rene Magritte>'])
def test_update_with_redirect(self):
a = Author.objects.create(
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.post('/edit/author/%d/update/redirect/' % a.pk,
{'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/edit/authors/create/')
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
def test_update_with_interpolated_redirect(self):
a = Author.objects.create(
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.post('/edit/author/%d/update/interpolate_redirect/' % a.pk,
{'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
self.assertEqual(res.status_code, 302)
pk = Author.objects.all()[0].pk
self.assertRedirects(res, 'http://testserver/edit/author/%d/update/' % pk)
def test_update_with_special_properties(self):
a = Author.objects.create(
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.get('/edit/author/%d/update/special/' % a.pk)
self.assertEqual(res.status_code, 200)
self.assertIsInstance(res.context['form'], views.AuthorForm)
self.assertEqual(res.context['object'], Author.objects.get(pk=a.pk))
self.assertEqual(res.context['thingy'], Author.objects.get(pk=a.pk))
self.assertFalse('author' in res.context)
self.assertTemplateUsed(res, 'generic_views/form.html')
res = self.client.post('/edit/author/%d/update/special/' % a.pk,
{'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/detail/author/%d/' % a.pk)
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
def test_update_without_redirect(self):
try:
a = Author.objects.create(
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.post('/edit/author/%d/update/naive/' % a.pk,
{'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
self.fail('Should raise exception -- No redirect URL provided, and no get_absolute_url provided')
except ImproperlyConfigured:
pass
def test_update_get_object(self):
a = Author.objects.create(
pk=1,
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.get('/edit/author/update/')
self.assertEqual(res.status_code, 200)
self.assertIsInstance(res.context['form'], forms.ModelForm)
self.assertIsInstance(res.context['view'], View)
self.assertEqual(res.context['object'], Author.objects.get(pk=a.pk))
self.assertEqual(res.context['author'], Author.objects.get(pk=a.pk))
self.assertTemplateUsed(res, 'generic_views/author_form.html')
# Modification with both POST and PUT (browser compatible)
res = self.client.post('/edit/author/update/',
{'name': 'Randall Munroe (xkcd)', 'slug': 'randall-munroe'})
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/list/authors/')
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (xkcd)>'])
class DeleteViewTests(TestCase):
urls = 'generic_views.urls'
def test_delete_by_post(self):
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
res = self.client.get('/edit/author/%d/delete/' % a.pk)
self.assertEqual(res.status_code, 200)
self.assertEqual(res.context['object'], Author.objects.get(pk=a.pk))
self.assertEqual(res.context['author'], Author.objects.get(pk=a.pk))
self.assertTemplateUsed(res, 'generic_views/author_confirm_delete.html')
# Deletion with POST
res = self.client.post('/edit/author/%d/delete/' % a.pk)
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/list/authors/')
self.assertQuerysetEqual(Author.objects.all(), [])
def test_delete_by_delete(self):
# Deletion with browser compatible DELETE method
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
res = self.client.delete('/edit/author/%d/delete/' % a.pk)
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/list/authors/')
self.assertQuerysetEqual(Author.objects.all(), [])
def test_delete_with_redirect(self):
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
res = self.client.post('/edit/author/%d/delete/redirect/' % a.pk)
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/edit/authors/create/')
self.assertQuerysetEqual(Author.objects.all(), [])
def test_delete_with_interpolated_redirect(self):
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
res = self.client.post('/edit/author/%d/delete/interpolate_redirect/' % a.pk)
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/edit/authors/create/?deleted=%d' % a.pk)
self.assertQuerysetEqual(Author.objects.all(), [])
def test_delete_with_special_properties(self):
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
res = self.client.get('/edit/author/%d/delete/special/' % a.pk)
self.assertEqual(res.status_code, 200)
self.assertEqual(res.context['object'], Author.objects.get(pk=a.pk))
self.assertEqual(res.context['thingy'], Author.objects.get(pk=a.pk))
self.assertFalse('author' in res.context)
self.assertTemplateUsed(res, 'generic_views/confirm_delete.html')
res = self.client.post('/edit/author/%d/delete/special/' % a.pk)
self.assertEqual(res.status_code, 302)
self.assertRedirects(res, 'http://testserver/list/authors/')
self.assertQuerysetEqual(Author.objects.all(), [])
def test_delete_without_redirect(self):
try:
a = Author.objects.create(
name='Randall Munroe',
slug='randall-munroe',
)
res = self.client.post('/edit/author/%d/delete/naive/' % a.pk)
self.fail('Should raise exception -- No redirect URL provided, and no get_absolute_url provided')
except ImproperlyConfigured:
pass
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
3598,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
492,
4513,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
1208,
14,
2796,
492,
1420,
6782,
199,
504,
1639,
14,
396,
14,
1258,
492,
18638,
199,
504,
1639,
14,
4196,
14,
6767,
14,
1095,
492,
10935,
199,
504,
1639,
14,
4196,
14,
6767,
14,
3773,
492,
8204,
4256,
12,
2790,
2768,
199,
199,
504,
1275,
492,
6858,
199,
504,
1275,
992,
492,
1952,
5011,
12,
6529,
421,
199,
533,
8204,
4256,
2925,
8,
1746,
304,
272,
347,
511,
63,
2747,
63,
576,
8,
277,
304,
267,
408,
1379,
1256,
31043,
29578,
402,
2536,
666,
1211,
334,
3239,
327,
975,
8527,
9,
408,
267,
2536,
63,
17,
275,
8204,
4256,
1252,
362,
63,
2747,
342,
267,
2536,
63,
17,
459,
1421,
418,
275,
283,
1700,
7,
267,
2536,
63,
18,
275,
8204,
4256,
1252,
362,
63,
2747,
342,
267,
291,
14,
7418,
8,
2747,
63,
17,
12,
2536,
63,
18,
9,
339,
347,
511,
63,
362,
63,
1861,
8,
277,
304,
267,
408,
1379,
2403,
883,
506,
663,
334,
3239,
327,
1085,
16357,
9,
408,
267,
511,
63,
875,
275,
283,
396,
7,
398,
17781,
275,
18638,
342,
267,
664,
63,
1069,
275,
17781,
14,
362,
7825,
398,
1021,
1379,
2821,
4256,
8,
2821,
4256,
304,
288,
1056,
275,
664,
63,
1069,
398,
849,
63,
958,
275,
1379,
2821,
4256,
1252,
362,
63,
964,
63,
958,
342,
267,
291,
14,
629,
8,
403,
12,
849,
63,
958,
14,
362,
360,
1861,
1333,
398,
663,
63,
20406,
275,
1379,
2821,
4256,
342,
267,
663,
63,
20406,
14,
1861,
275,
511,
63,
875,
267,
663,
63,
958,
275,
663,
63,
20406,
14,
362,
63,
964,
63,
958,
342,
267,
291,
14,
629,
8,
396,
63,
875,
12,
663,
63,
958,
14,
362,
360,
1861,
1333,
421,
199,
533,
10082,
2821,
2925,
8,
1746,
304,
272,
8187,
275,
283,
6767,
63,
4196,
14,
3603,
7,
339,
347,
511,
63,
1932,
63,
576,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
7811,
3678,
791,
354,
356,
298,
1352,
401,
283,
1188,
356,
298,
6257,
5984,
267,
291,
14,
17466,
8,
470,
12,
283,
1014,
921,
22471,
15,
513,
15,
8149,
6217,
421,
199,
533,
28455,
4256,
2925,
8,
1746,
304,
272,
347,
511,
63,
362,
63,
964,
8,
277,
304,
267,
1824,
63,
533,
275,
6858,
14,
5949,
1002,
13689,
2821,
2768,
1252,
362,
63,
964,
63,
533,
342,
267,
291,
14,
629,
8,
964,
63,
533,
423,
2024,
14,
1238,
12,
6529,
9,
421,
199,
533,
2790,
2768,
2925,
8,
1746,
304,
272,
8187,
275,
283,
6767,
63,
4196,
14,
3603,
7,
339,
347,
511,
63,
981,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
362,
2336,
3773,
15,
8149,
15,
981,
6217,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
1926,
9,
267,
291,
14,
6926,
8,
470,
14,
1100,
459,
964,
995,
4513,
14,
15937,
9,
267,
291,
14,
6926,
8,
470,
14,
1100,
459,
1345,
995,
10935,
9,
267,
291,
14,
3334,
360,
785,
7,
315,
522,
14,
1100,
9,
267,
291,
14,
3334,
360,
2502,
7,
315,
522,
14,
1100,
9,
267,
291,
14,
19661,
8,
470,
12,
283,
6767,
63,
4196,
15,
2502,
63,
964,
14,
1360,
358,
398,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
8149,
15,
981,
3678,
717,
791,
354,
356,
283,
50,
460,
452,
603,
324,
293,
69,
297,
283,
5464,
356,
283,
3759,
452,
13,
32368,
293,
69,
3071,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
11485,
9,
267,
291,
14,
17466,
8,
470,
12,
283,
1014,
921,
22471,
15,
513,
15,
8149,
6217,
267,
291,
14,
7108,
8,
5949,
14,
1462,
14,
452,
1062,
12329,
5949,
26,
820,
460,
452,
603,
324,
293,
69,
24782,
339,
347,
511,
63,
981,
63,
3197,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
8149,
15,
981,
3678,
717,
791,
354,
356,
283,
33,
7,
627,
14313,
12,
283,
5464,
356,
283,
3759,
452,
13,
32368,
293,
69,
3071,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
1926,
9,
267,
291,
14,
19661,
8,
470,
12,
283,
6767,
63,
4196,
15,
2502,
63,
964,
14,
1360,
358,
267,
291,
14,
629,
8,
552,
8,
470,
14,
1100,
459,
964,
2278,
2550,
395,
413,
9,
267,
291,
14,
629,
8,
5949,
14,
1462,
14,
835,
1062,
378,
9,
339,
347,
511,
63,
981,
63,
1045,
63,
785,
63,
633,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
11215,
83,
15,
981,
3678,
717,
791,
354,
356,
283,
5349,
69,
603,
643,
11133,
266,
3071,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
11485,
9,
267,
16459,
275,
1952,
5011,
14,
1462,
14,
362,
8,
354,
534,
5349,
69,
603,
643,
11133,
266,
358,
267,
291,
14,
17466,
8,
470,
12,
283,
1014,
921,
22471,
15,
5506,
15,
11215,
3149,
68,
4805,
450,
16459,
14,
2051,
9,
267,
291,
14,
7108,
8,
27711,
14,
1462,
14,
452,
1062,
12329,
27711,
26,
820,
6349,
603,
643,
11133,
266,
24782,
339,
347,
511,
63,
981,
63,
1045,
63,
4876,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
8149,
15,
981,
15,
4876,
3678,
1169,
791,
354,
356,
283,
50,
460,
452,
603,
324,
293,
69,
297,
283,
5464,
356,
283,
3759,
452,
13,
32368,
293,
69,
3071,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
11485,
9,
267,
291,
14,
17466,
8,
470,
12,
283,
1014,
921,
22471,
15,
3773,
15,
8149,
15,
981,
6217,
267,
291,
14,
7108,
8,
5949,
14,
1462,
14,
452,
1062,
12329,
5949,
26,
820,
460,
452,
603,
324,
293,
69,
24782,
339,
347,
511,
63,
981,
63,
1045,
63,
29690,
972,
63,
4876,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
8149,
15
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
3598,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
492,
4513,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
1208,
14,
2796,
492,
1420,
6782,
199,
504,
1639,
14,
396,
14,
1258,
492,
18638,
199,
504,
1639,
14,
4196,
14,
6767,
14,
1095,
492,
10935,
199,
504,
1639,
14,
4196,
14,
6767,
14,
3773,
492,
8204,
4256,
12,
2790,
2768,
199,
199,
504,
1275,
492,
6858,
199,
504,
1275,
992,
492,
1952,
5011,
12,
6529,
421,
199,
533,
8204,
4256,
2925,
8,
1746,
304,
272,
347,
511,
63,
2747,
63,
576,
8,
277,
304,
267,
408,
1379,
1256,
31043,
29578,
402,
2536,
666,
1211,
334,
3239,
327,
975,
8527,
9,
408,
267,
2536,
63,
17,
275,
8204,
4256,
1252,
362,
63,
2747,
342,
267,
2536,
63,
17,
459,
1421,
418,
275,
283,
1700,
7,
267,
2536,
63,
18,
275,
8204,
4256,
1252,
362,
63,
2747,
342,
267,
291,
14,
7418,
8,
2747,
63,
17,
12,
2536,
63,
18,
9,
339,
347,
511,
63,
362,
63,
1861,
8,
277,
304,
267,
408,
1379,
2403,
883,
506,
663,
334,
3239,
327,
1085,
16357,
9,
408,
267,
511,
63,
875,
275,
283,
396,
7,
398,
17781,
275,
18638,
342,
267,
664,
63,
1069,
275,
17781,
14,
362,
7825,
398,
1021,
1379,
2821,
4256,
8,
2821,
4256,
304,
288,
1056,
275,
664,
63,
1069,
398,
849,
63,
958,
275,
1379,
2821,
4256,
1252,
362,
63,
964,
63,
958,
342,
267,
291,
14,
629,
8,
403,
12,
849,
63,
958,
14,
362,
360,
1861,
1333,
398,
663,
63,
20406,
275,
1379,
2821,
4256,
342,
267,
663,
63,
20406,
14,
1861,
275,
511,
63,
875,
267,
663,
63,
958,
275,
663,
63,
20406,
14,
362,
63,
964,
63,
958,
342,
267,
291,
14,
629,
8,
396,
63,
875,
12,
663,
63,
958,
14,
362,
360,
1861,
1333,
421,
199,
533,
10082,
2821,
2925,
8,
1746,
304,
272,
8187,
275,
283,
6767,
63,
4196,
14,
3603,
7,
339,
347,
511,
63,
1932,
63,
576,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
7811,
3678,
791,
354,
356,
298,
1352,
401,
283,
1188,
356,
298,
6257,
5984,
267,
291,
14,
17466,
8,
470,
12,
283,
1014,
921,
22471,
15,
513,
15,
8149,
6217,
421,
199,
533,
28455,
4256,
2925,
8,
1746,
304,
272,
347,
511,
63,
362,
63,
964,
8,
277,
304,
267,
1824,
63,
533,
275,
6858,
14,
5949,
1002,
13689,
2821,
2768,
1252,
362,
63,
964,
63,
533,
342,
267,
291,
14,
629,
8,
964,
63,
533,
423,
2024,
14,
1238,
12,
6529,
9,
421,
199,
533,
2790,
2768,
2925,
8,
1746,
304,
272,
8187,
275,
283,
6767,
63,
4196,
14,
3603,
7,
339,
347,
511,
63,
981,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
362,
2336,
3773,
15,
8149,
15,
981,
6217,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
1926,
9,
267,
291,
14,
6926,
8,
470,
14,
1100,
459,
964,
995,
4513,
14,
15937,
9,
267,
291,
14,
6926,
8,
470,
14,
1100,
459,
1345,
995,
10935,
9,
267,
291,
14,
3334,
360,
785,
7,
315,
522,
14,
1100,
9,
267,
291,
14,
3334,
360,
2502,
7,
315,
522,
14,
1100,
9,
267,
291,
14,
19661,
8,
470,
12,
283,
6767,
63,
4196,
15,
2502,
63,
964,
14,
1360,
358,
398,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
8149,
15,
981,
3678,
717,
791,
354,
356,
283,
50,
460,
452,
603,
324,
293,
69,
297,
283,
5464,
356,
283,
3759,
452,
13,
32368,
293,
69,
3071,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
11485,
9,
267,
291,
14,
17466,
8,
470,
12,
283,
1014,
921,
22471,
15,
513,
15,
8149,
6217,
267,
291,
14,
7108,
8,
5949,
14,
1462,
14,
452,
1062,
12329,
5949,
26,
820,
460,
452,
603,
324,
293,
69,
24782,
339,
347,
511,
63,
981,
63,
3197,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
8149,
15,
981,
3678,
717,
791,
354,
356,
283,
33,
7,
627,
14313,
12,
283,
5464,
356,
283,
3759,
452,
13,
32368,
293,
69,
3071,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
1926,
9,
267,
291,
14,
19661,
8,
470,
12,
283,
6767,
63,
4196,
15,
2502,
63,
964,
14,
1360,
358,
267,
291,
14,
629,
8,
552,
8,
470,
14,
1100,
459,
964,
2278,
2550,
395,
413,
9,
267,
291,
14,
629,
8,
5949,
14,
1462,
14,
835,
1062,
378,
9,
339,
347,
511,
63,
981,
63,
1045,
63,
785,
63,
633,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
11215,
83,
15,
981,
3678,
717,
791,
354,
356,
283,
5349,
69,
603,
643,
11133,
266,
3071,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
11485,
9,
267,
16459,
275,
1952,
5011,
14,
1462,
14,
362,
8,
354,
534,
5349,
69,
603,
643,
11133,
266,
358,
267,
291,
14,
17466,
8,
470,
12,
283,
1014,
921,
22471,
15,
5506,
15,
11215,
3149,
68,
4805,
450,
16459,
14,
2051,
9,
267,
291,
14,
7108,
8,
27711,
14,
1462,
14,
452,
1062,
12329,
27711,
26,
820,
6349,
603,
643,
11133,
266,
24782,
339,
347,
511,
63,
981,
63,
1045,
63,
4876,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
8149,
15,
981,
15,
4876,
3678,
1169,
791,
354,
356,
283,
50,
460,
452,
603,
324,
293,
69,
297,
283,
5464,
356,
283,
3759,
452,
13,
32368,
293,
69,
3071,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
600,
12,
11485,
9,
267,
291,
14,
17466,
8,
470,
12,
283,
1014,
921,
22471,
15,
3773,
15,
8149,
15,
981,
6217,
267,
291,
14,
7108,
8,
5949,
14,
1462,
14,
452,
1062,
12329,
5949,
26,
820,
460,
452,
603,
324,
293,
69,
24782,
339,
347,
511,
63,
981,
63,
1045,
63,
29690,
972,
63,
4876,
8,
277,
304,
267,
522,
275,
291,
14,
1258,
14,
1932,
2336,
3773,
15,
8149,
15,
0
] |
[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] |
harshilasu/GraphicMelon
|
y/google-cloud-sdk/lib/requests/setup.py
|
11
|
1641
|
#!/usr/bin/env python
import os
import sys
import requests
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
if sys.argv[-1] == 'publish':
os.system('python setup.py sdist upload')
sys.exit()
packages = [
'requests',
'requests.packages',
'requests.packages.chardet',
'requests.packages.urllib3',
'requests.packages.urllib3.packages',
'requests.packages.urllib3.contrib',
'requests.packages.urllib3.util',
'requests.packages.urllib3.packages.ssl_match_hostname',
]
requires = []
with open('README.rst') as f:
readme = f.read()
with open('HISTORY.rst') as f:
history = f.read()
setup(
name='requests',
version=requests.__version__,
description='Python HTTP for Humans.',
long_description=readme + '\n\n' + history,
author='Kenneth Reitz',
author_email='me@kennethreitz.com',
url='http://python-requests.org',
packages=packages,
package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']},
package_dir={'requests': 'requests'},
include_package_data=True,
install_requires=requires,
license='Apache 2.0',
zip_safe=False,
classifiers=(
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Natural Language :: English',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
),
)
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
747,
199,
646,
984,
199,
199,
646,
4145,
199,
199,
893,
26,
272,
687,
9116,
492,
3272,
199,
2590,
3545,
26,
272,
687,
7065,
14,
1018,
492,
3272,
199,
199,
692,
984,
14,
3020,
1988,
17,
61,
508,
283,
4763,
356,
272,
747,
14,
2253,
360,
1548,
3272,
14,
647,
26644,
5802,
358,
272,
984,
14,
2224,
342,
199,
199,
5154,
275,
359,
272,
283,
6615,
297,
272,
283,
6615,
14,
5154,
297,
272,
283,
6615,
14,
5154,
14,
1560,
9886,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
14,
5154,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
14,
2828,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
14,
1974,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
14,
5154,
14,
4266,
63,
1431,
63,
4269,
297,
199,
61,
199,
199,
6537,
275,
942,
199,
199,
1045,
1551,
360,
18195,
14,
8332,
358,
465,
289,
26,
272,
1586,
278,
275,
289,
14,
739,
342,
199,
1045,
1551,
360,
30895,
14,
8332,
358,
465,
289,
26,
272,
7994,
275,
289,
14,
739,
342,
199,
199,
2758,
8,
272,
536,
534,
6615,
297,
272,
1015,
29,
6615,
855,
1023,
3108,
272,
1369,
534,
4718,
3101,
367,
869,
453,
796,
3130,
272,
1846,
63,
1802,
29,
32709,
435,
1557,
78,
60,
78,
7,
435,
7994,
12,
272,
4132,
534,
43,
287,
685,
273,
799,
23751,
297,
272,
4132,
63,
2123,
534,
278,
32,
917,
685,
273,
264,
23751,
14,
957,
297,
272,
1166,
534,
1014,
921,
1548,
13,
6615,
14,
1308,
297,
272,
6117,
29,
5154,
12,
272,
2559,
63,
576,
3713,
356,
788,
3961,
297,
283,
4609,
4047,
995,
283,
6615,
356,
17855,
13102,
14949,
272,
2559,
63,
694,
3713,
6615,
356,
283,
6615,
2267,
272,
2387,
63,
2491,
63,
576,
29,
549,
12,
272,
3907,
63,
6537,
29,
6537,
12,
272,
4190,
534,
28993,
499,
14,
16,
297,
272,
3482,
63,
3489,
29,
797,
12,
272,
19137,
2687,
267,
283,
23753,
9795,
3800,
959,
446,
24114,
15,
933,
461,
297,
267,
283,
23910,
23975,
3800,
23493,
297,
267,
283,
23604,
4889,
8466,
3800,
20144,
297,
267,
283,
3761,
3800,
25718,
26330,
3800,
3668,
2290,
844,
297,
267,
283,
11411,
8466,
3800,
2018,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
22,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
23,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
19,
297,
339,
2318,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
747,
199,
646,
984,
199,
199,
646,
4145,
199,
199,
893,
26,
272,
687,
9116,
492,
3272,
199,
2590,
3545,
26,
272,
687,
7065,
14,
1018,
492,
3272,
199,
199,
692,
984,
14,
3020,
1988,
17,
61,
508,
283,
4763,
356,
272,
747,
14,
2253,
360,
1548,
3272,
14,
647,
26644,
5802,
358,
272,
984,
14,
2224,
342,
199,
199,
5154,
275,
359,
272,
283,
6615,
297,
272,
283,
6615,
14,
5154,
297,
272,
283,
6615,
14,
5154,
14,
1560,
9886,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
14,
5154,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
14,
2828,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
14,
1974,
297,
272,
283,
6615,
14,
5154,
14,
4078,
19,
14,
5154,
14,
4266,
63,
1431,
63,
4269,
297,
199,
61,
199,
199,
6537,
275,
942,
199,
199,
1045,
1551,
360,
18195,
14,
8332,
358,
465,
289,
26,
272,
1586,
278,
275,
289,
14,
739,
342,
199,
1045,
1551,
360,
30895,
14,
8332,
358,
465,
289,
26,
272,
7994,
275,
289,
14,
739,
342,
199,
199,
2758,
8,
272,
536,
534,
6615,
297,
272,
1015,
29,
6615,
855,
1023,
3108,
272,
1369,
534,
4718,
3101,
367,
869,
453,
796,
3130,
272,
1846,
63,
1802,
29,
32709,
435,
1557,
78,
60,
78,
7,
435,
7994,
12,
272,
4132,
534,
43,
287,
685,
273,
799,
23751,
297,
272,
4132,
63,
2123,
534,
278,
32,
917,
685,
273,
264,
23751,
14,
957,
297,
272,
1166,
534,
1014,
921,
1548,
13,
6615,
14,
1308,
297,
272,
6117,
29,
5154,
12,
272,
2559,
63,
576,
3713,
356,
788,
3961,
297,
283,
4609,
4047,
995,
283,
6615,
356,
17855,
13102,
14949,
272,
2559,
63,
694,
3713,
6615,
356,
283,
6615,
2267,
272,
2387,
63,
2491,
63,
576,
29,
549,
12,
272,
3907,
63,
6537,
29,
6537,
12,
272,
4190,
534,
28993,
499,
14,
16,
297,
272,
3482,
63,
3489,
29,
797,
12,
272,
19137,
2687,
267,
283,
23753,
9795,
3800,
959,
446,
24114,
15,
933,
461,
297,
267,
283,
23910,
23975,
3800,
23493,
297,
267,
283,
23604,
4889,
8466,
3800,
20144,
297,
267,
283,
3761,
3800,
25718,
26330,
3800,
3668,
2290,
844,
297,
267,
283,
11411,
8466,
3800,
2018,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
22,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
23,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
19,
297,
339,
2318,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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
] |
podemos-info/odoo
|
addons/product/report/pricelist.py
|
9
|
4809
|
# -*- 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 datetime
from report.interface import report_rml
from report.interface import toxml
import pooler
from osv import osv
import datetime
class report_custom(report_rml):
def create_xml(self, cr, uid, ids, data, context):
pool = pooler.get_pool(cr.dbname)
price_list_id = data['form']['price_list']
product_categ_id =pool.get('product.category').search(cr, uid, [])
currency = pool.get('product.pricelist').read(cr, uid, [price_list_id], ['currency_id','name'])[0]
qty =[]
for i in range(1,6):
q = 'qty%d'%i
if data['form'][q]:
qty.append(data['form'][q])
if not qty:
qty.append(1)
product_xml = []
cols = ''
cols = cols+'6cm'
title ='<title name=" Description " number="0" />'
i=1
for q in qty:
cols = cols+',2.5cm'
if q==1:
title+='<title name="%d unit" number="%d"/>'%(q,i)
else:
title+='<title name="%d units" number="%d"/>'%(q,i)
i+=1
date = datetime.date.today()
str_date=date.strftime("%d/%m/%Y")
product_xml.append('<cols>'+cols+'</cols>')
product_xml.append('<pricelist> %s </pricelist>'%currency['name'])
product_xml.append('<currency> %s </currency>'%currency['currency_id'][1])
product_xml.append('<date> %s </date>'%str_date)
product_xml.append("<product>")
for p_categ_id in product_categ_id:
product_ids = pool.get('product.product').search(cr, uid, [('id','in',ids),('categ_id','=',p_categ_id)])
if product_ids:
categ_name = pool.get('product.category').read(cr, uid, [p_categ_id], ['name'])
products = pool.get('product.product').read(cr, uid, product_ids, ['id','name','code'])
pro = []
i=0
pro.append('<pro name="%s" categ="true">' % (categ_name[0]['name']))
temp = []
for q in qty:
temp.append('<price name=" " />')
pro.extend(temp)
pro.append('</pro>')
for x in products:
#Replacement of special characters with their code html for allowing reporting - Edited by Hasa
x['name'] = x['name'].replace("&","&")
x['name'] = x['name'].replace("\"",""")
if x['code']:
pro.append('<pro name="[%s] %s" >' % (x['code'], x['name']))
else:
pro.append('<pro name="%s" >' % (x['name']))
temp = []
for q in qty:
price_dict = pool.get('product.pricelist').price_get(cr, uid, [price_list_id], x['id'], q, context=context)
if price_dict[price_list_id]:
price = price_dict[price_list_id]
else:
res = pool.get('product.product').read(cr, uid, [x['id']])
price = res[0]['list_price']
temp.append('<price name="%.2f" />'%(price))
i+=1
pro.extend(temp)
pro.append('</pro>')
product_xml.extend(pro)
product_xml.append('</product>')
xml = '''<?xml version="1.0" encoding="UTF-8" ?>
<report>
%s
</report>
''' % (title+'\n'.join(product_xml))
return self.post_process_xml_data(cr, uid, xml, context)
report_custom('report.pricelist.pricelist', 'product.product','','addons/product_pricelist_print/report/product_price.xsl')
# 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,
2197,
199,
504,
3622,
14,
3266,
492,
3622,
63,
16300,
199,
504,
3622,
14,
3266,
492,
370,
1652,
199,
646,
1115,
79,
1435,
199,
504,
9506,
492,
9506,
199,
646,
2197,
199,
199,
533,
3622,
63,
4229,
8,
3070,
63,
16300,
304,
339,
347,
1218,
63,
1652,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
666,
12,
1067,
304,
267,
4203,
275,
1115,
79,
1435,
14,
362,
63,
2293,
8,
1556,
14,
13238,
9,
398,
8033,
63,
513,
63,
344,
275,
666,
459,
964,
2545,
4777,
63,
513,
418,
398,
3336,
63,
3533,
63,
344,
275,
2293,
14,
362,
360,
2558,
14,
3710,
1959,
1733,
8,
1556,
12,
1747,
12,
3073,
267,
9952,
275,
4203,
14,
362,
360,
2558,
14,
17385,
1959,
739,
8,
1556,
12,
1747,
12,
359,
4777,
63,
513,
63,
344,
467,
788,
4968,
63,
344,
1673,
354,
25945,
16,
61,
7318,
13556,
275,
8607,
398,
367,
284,
315,
1425,
8,
17,
12,
22,
304,
288,
1894,
275,
283,
5643,
5,
68,
5956,
73,
288,
340,
666,
459,
964,
3488,
81,
2189,
355,
13556,
14,
740,
8,
576,
459,
964,
3488,
81,
566,
398,
340,
440,
13556,
26,
288,
13556,
14,
740,
8,
17,
9,
398,
3336,
63,
1652,
275,
942,
267,
8850,
275,
2125,
267,
8850,
275,
8850,
4786,
22,
4400,
7,
267,
2538,
275,
7601,
1213,
536,
628,
11994,
298,
1329,
628,
16,
2,
22294,
267,
284,
29,
17,
267,
367,
1894,
315,
13556,
26,
288,
8850,
275,
8850,
7386,
18,
14,
21,
4400,
7,
288,
340,
1894,
389,
17,
26,
355,
2538,
11,
15829,
1213,
536,
5961,
68,
4137,
2,
1329,
5961,
68,
7897,
13328,
81,
12,
73,
9,
288,
587,
26,
355,
2538,
11,
15829,
1213,
536,
5961,
68,
6204,
2,
1329,
5961,
68,
7897,
13328,
81,
12,
73,
9,
288,
284,
10365,
17,
267,
1434,
275,
2197,
14,
602,
14,
8136,
342,
267,
620,
63,
602,
29,
602,
14,
6205,
3647,
68,
3149,
77,
3149,
57,
531,
267,
3336,
63,
1652,
14,
740,
4827,
4574,
3524,
11,
4574,
4786,
1108,
4574,
5971,
267,
3336,
63,
1652,
14,
740,
4827,
17385,
30,
450,
83,
3068,
17385,
3524,
5,
4968,
459,
354,
1105,
267,
3336,
63,
1652,
14,
740,
4827,
4968,
30,
450,
83,
3068,
4968,
3524,
5,
4968,
459,
4968,
63,
344,
3488,
17,
566,
267,
3336,
63,
1652,
14,
740,
4827,
602,
30,
450,
83,
3068,
602,
3524,
5,
495,
63,
602,
9,
267,
3336,
63,
1652,
14,
740,
6757,
2558,
9579,
398,
367,
299,
63,
3533,
63,
344,
315,
3336,
63,
3533,
63,
344,
26,
288,
3336,
63,
1580,
275,
4203,
14,
362,
360,
2558,
14,
2558,
1959,
1733,
8,
1556,
12,
1747,
12,
4274,
344,
1673,
262,
297,
1580,
11169,
3533,
63,
344,
18937,
80,
63,
3533,
63,
344,
3948,
288,
340,
3336,
63,
1580,
26,
355,
7737,
63,
354,
275,
4203,
14,
362,
360,
2558,
14,
3710,
1959,
739,
8,
1556,
12,
1747,
12,
359,
80,
63,
3533,
63,
344,
467,
788,
354,
1105,
355,
7585,
275,
4203,
14,
362,
360,
2558,
14,
2558,
1959,
739,
8,
1556,
12,
1747,
12,
3336,
63,
1580,
12,
788,
344,
1673,
354,
1673,
600,
1105,
355,
557,
275,
942,
355,
284,
29,
16,
355,
557,
14,
740,
4827,
496,
536,
5961,
83,
2,
7737,
628,
2052,
15603,
450,
334,
3533,
63,
354,
59,
16,
2733,
354,
5156,
355,
2388,
275,
942,
355,
367,
1894,
315,
13556,
26,
490,
2388,
14,
740,
4827,
4777,
536,
628,
298,
23266,
355,
557,
14,
2880,
8,
808,
9,
355,
557,
14,
740,
14264,
496,
5971,
355,
367,
671,
315,
7585,
26,
490,
327,
29475,
402,
4539,
4110,
543,
3932,
1233,
3517,
367,
17266,
17290,
446,
662,
328,
471,
701,
13481,
65,
490,
671,
459,
354,
418,
275,
671,
459,
354,
2278,
1814,
22077,
2266,
6,
5282,
15027,
490,
671,
459,
354,
418,
275,
671,
459,
354,
2278,
1814,
4582,
341,
4589,
6,
5184,
15027,
490,
340,
671,
459,
600,
2565,
717,
557,
14,
740,
4827,
496,
536,
628,
9722,
83,
61,
450,
83,
2,
690,
7,
450,
334,
88,
459,
600,
995,
671,
459,
354,
5156,
490,
587,
26,
717,
557,
14,
740,
4827,
496,
536,
5961,
83,
2,
690,
7,
450,
334,
88,
459,
354,
5156,
490,
2388,
275,
942,
490,
367,
1894,
315,
13556,
26,
717,
8033,
63,
807,
275,
4203,
14,
362,
360,
2558,
14,
17385,
1959,
4777,
63,
362,
8,
1556,
12,
1747,
12,
359,
4777,
63,
513,
63,
344,
467,
671,
459,
344,
995,
1894,
12,
1067,
29,
1100,
9,
717,
340,
8033,
63,
807,
59,
4777,
63,
513,
63,
344,
2189,
1169,
8033,
275,
8033,
63,
807,
59,
4777,
63,
513,
63,
344,
61,
717,
587,
26,
1169,
522,
275,
4203,
14,
362,
360,
2558,
14,
2558,
1959,
739,
8,
1556,
12,
1747,
12,
359,
88,
459,
344,
12121,
1169,
8033,
275,
221,
522,
59,
16,
2733,
513,
63,
4777
] |
[
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,
2197,
199,
504,
3622,
14,
3266,
492,
3622,
63,
16300,
199,
504,
3622,
14,
3266,
492,
370,
1652,
199,
646,
1115,
79,
1435,
199,
504,
9506,
492,
9506,
199,
646,
2197,
199,
199,
533,
3622,
63,
4229,
8,
3070,
63,
16300,
304,
339,
347,
1218,
63,
1652,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
666,
12,
1067,
304,
267,
4203,
275,
1115,
79,
1435,
14,
362,
63,
2293,
8,
1556,
14,
13238,
9,
398,
8033,
63,
513,
63,
344,
275,
666,
459,
964,
2545,
4777,
63,
513,
418,
398,
3336,
63,
3533,
63,
344,
275,
2293,
14,
362,
360,
2558,
14,
3710,
1959,
1733,
8,
1556,
12,
1747,
12,
3073,
267,
9952,
275,
4203,
14,
362,
360,
2558,
14,
17385,
1959,
739,
8,
1556,
12,
1747,
12,
359,
4777,
63,
513,
63,
344,
467,
788,
4968,
63,
344,
1673,
354,
25945,
16,
61,
7318,
13556,
275,
8607,
398,
367,
284,
315,
1425,
8,
17,
12,
22,
304,
288,
1894,
275,
283,
5643,
5,
68,
5956,
73,
288,
340,
666,
459,
964,
3488,
81,
2189,
355,
13556,
14,
740,
8,
576,
459,
964,
3488,
81,
566,
398,
340,
440,
13556,
26,
288,
13556,
14,
740,
8,
17,
9,
398,
3336,
63,
1652,
275,
942,
267,
8850,
275,
2125,
267,
8850,
275,
8850,
4786,
22,
4400,
7,
267,
2538,
275,
7601,
1213,
536,
628,
11994,
298,
1329,
628,
16,
2,
22294,
267,
284,
29,
17,
267,
367,
1894,
315,
13556,
26,
288,
8850,
275,
8850,
7386,
18,
14,
21,
4400,
7,
288,
340,
1894,
389,
17,
26,
355,
2538,
11,
15829,
1213,
536,
5961,
68,
4137,
2,
1329,
5961,
68,
7897,
13328,
81,
12,
73,
9,
288,
587,
26,
355,
2538,
11,
15829,
1213,
536,
5961,
68,
6204,
2,
1329,
5961,
68,
7897,
13328,
81,
12,
73,
9,
288,
284,
10365,
17,
267,
1434,
275,
2197,
14,
602,
14,
8136,
342,
267,
620,
63,
602,
29,
602,
14,
6205,
3647,
68,
3149,
77,
3149,
57,
531,
267,
3336,
63,
1652,
14,
740,
4827,
4574,
3524,
11,
4574,
4786,
1108,
4574,
5971,
267,
3336,
63,
1652,
14,
740,
4827,
17385,
30,
450,
83,
3068,
17385,
3524,
5,
4968,
459,
354,
1105,
267,
3336,
63,
1652,
14,
740,
4827,
4968,
30,
450,
83,
3068,
4968,
3524,
5,
4968,
459,
4968,
63,
344,
3488,
17,
566,
267,
3336,
63,
1652,
14,
740,
4827,
602,
30,
450,
83,
3068,
602,
3524,
5,
495,
63,
602,
9,
267,
3336,
63,
1652,
14,
740,
6757,
2558,
9579,
398,
367,
299,
63,
3533,
63,
344,
315,
3336,
63,
3533,
63,
344,
26,
288,
3336,
63,
1580,
275,
4203,
14,
362,
360,
2558,
14,
2558,
1959,
1733,
8,
1556,
12,
1747,
12,
4274,
344,
1673,
262,
297,
1580,
11169,
3533,
63,
344,
18937,
80,
63,
3533,
63,
344,
3948,
288,
340,
3336,
63,
1580,
26,
355,
7737,
63,
354,
275,
4203,
14,
362,
360,
2558,
14,
3710,
1959,
739,
8,
1556,
12,
1747,
12,
359,
80,
63,
3533,
63,
344,
467,
788,
354,
1105,
355,
7585,
275,
4203,
14,
362,
360,
2558,
14,
2558,
1959,
739,
8,
1556,
12,
1747,
12,
3336,
63,
1580,
12,
788,
344,
1673,
354,
1673,
600,
1105,
355,
557,
275,
942,
355,
284,
29,
16,
355,
557,
14,
740,
4827,
496,
536,
5961,
83,
2,
7737,
628,
2052,
15603,
450,
334,
3533,
63,
354,
59,
16,
2733,
354,
5156,
355,
2388,
275,
942,
355,
367,
1894,
315,
13556,
26,
490,
2388,
14,
740,
4827,
4777,
536,
628,
298,
23266,
355,
557,
14,
2880,
8,
808,
9,
355,
557,
14,
740,
14264,
496,
5971,
355,
367,
671,
315,
7585,
26,
490,
327,
29475,
402,
4539,
4110,
543,
3932,
1233,
3517,
367,
17266,
17290,
446,
662,
328,
471,
701,
13481,
65,
490,
671,
459,
354,
418,
275,
671,
459,
354,
2278,
1814,
22077,
2266,
6,
5282,
15027,
490,
671,
459,
354,
418,
275,
671,
459,
354,
2278,
1814,
4582,
341,
4589,
6,
5184,
15027,
490,
340,
671,
459,
600,
2565,
717,
557,
14,
740,
4827,
496,
536,
628,
9722,
83,
61,
450,
83,
2,
690,
7,
450,
334,
88,
459,
600,
995,
671,
459,
354,
5156,
490,
587,
26,
717,
557,
14,
740,
4827,
496,
536,
5961,
83,
2,
690,
7,
450,
334,
88,
459,
354,
5156,
490,
2388,
275,
942,
490,
367,
1894,
315,
13556,
26,
717,
8033,
63,
807,
275,
4203,
14,
362,
360,
2558,
14,
17385,
1959,
4777,
63,
362,
8,
1556,
12,
1747,
12,
359,
4777,
63,
513,
63,
344,
467,
671,
459,
344,
995,
1894,
12,
1067,
29,
1100,
9,
717,
340,
8033,
63,
807,
59,
4777,
63,
513,
63,
344,
2189,
1169,
8033,
275,
8033,
63,
807,
59,
4777,
63,
513,
63,
344,
61,
717,
587,
26,
1169,
522,
275,
4203,
14,
362,
360,
2558,
14,
2558,
1959,
739,
8,
1556,
12,
1747,
12,
359,
88,
459,
344,
12121,
1169,
8033,
275,
221,
522,
59,
16,
2733,
513,
63,
4777,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
silly-wacky-3-town-toon/SOURCE-COD
|
toontown/minigame/MinigameGlobals.py
|
5
|
2001
|
from direct.showbase import PythonUtil
from toontown.toonbase import ToontownGlobals
from toontown.hood import ZoneUtil
from random import choice
latencyTolerance = 10.0
MaxLoadTime = 40.0
rulesDuration = 16
JellybeanTrolleyHolidayScoreMultiplier = 2
DifficultyOverrideMult = int(1 << 16)
def QuantizeDifficultyOverride(diffOverride):
return int(round(diffOverride * DifficultyOverrideMult)) / float(DifficultyOverrideMult)
NoDifficultyOverride = 2147483647
NoTrolleyZoneOverride = -1
SafeZones = [ToontownGlobals.ToontownCentral,
ToontownGlobals.DonaldsDock,
ToontownGlobals.DaisyGardens,
ToontownGlobals.MinniesMelodyland,
ToontownGlobals.TheBrrrgh,
ToontownGlobals.DonaldsDreamland]
def getDifficulty(trolleyZone):
hoodZone = getSafezoneId(trolleyZone)
return float(SafeZones.index(hoodZone)) / (len(SafeZones) - 1)
def getSafezoneId(trolleyZone):
return ZoneUtil.getCanonicalHoodId(trolleyZone)
def getScoreMult(trolleyZone):
szId = getSafezoneId(trolleyZone)
multiplier = PythonUtil.lerp(1.0, 1.5, float(SafeZones.index(szId)) / (len(SafeZones) - 1))
return multiplier
# For Blueprint ARG
SuitSerialMessages = [
'DS-DEBUG1: Suit Serial #0043 -- METHOD',
'DS-DEBUG1: Suit Serial #0052 -- USED',
'DS-DEBUG1: Suit Serial #0045 -- IS',
'DS-DEBUG1: Suit Serial #0041 -- THE',
'DS-DEBUG1: Suit Serial #0054 -- SAME',
'DS-DEBUG1: Suit Serial #0049 -- AS',
'DS-DEBUG1: Suit Serial #004E -- LAST',
'DS-DEBUG1: Suit Serial #0047 -- TIME',
'DS-DEBUG2: Suit Serial #0045 -- ALL',
'DS-DEBUG2: Suit Serial #0051 -- RECORDS',
'DS-DEBUG2: Suit Serial #0055 -- EXPUNGED',
'DS-DEBUG2: Suit Serial #0049 -- FURTHER',
'DS-DEBUG2: Suit Serial #004D -- INVESTIGATION',
'DS-DEBUG2: Suit Serial #0045 -- WILL',
'DS-DEBUG2: Suit Serial #004E -- BE',
'DS-DEBUG2: Suit Serial #0054 -- NECESSARY'
]
def generateDebugARGPhrase():
phrase = choice(SuitSerialMessages)
base.localAvatar.setSystemMessage(0, phrase)
|
apache-2.0
|
[
504,
4125,
14,
2384,
1095,
492,
2018,
9562,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
4005,
265,
16231,
21675,
199,
504,
370,
265,
16231,
14,
10422,
492,
22518,
9562,
199,
504,
2196,
492,
7141,
199,
19645,
1378,
8807,
275,
1616,
14,
16,
199,
4261,
6200,
1366,
275,
6335,
14,
16,
199,
4423,
13283,
275,
3193,
199,
42,
29051,
28142,
52,
8459,
15515,
17810,
317,
2977,
12642,
25314,
5697,
275,
499,
199,
36,
692,
24161,
11954,
30233,
275,
1109,
8,
17,
5213,
3193,
9,
199,
199,
318,
5843,
4466,
806,
36,
692,
24161,
11954,
8,
3028,
11954,
304,
272,
372,
1109,
8,
2363,
8,
3028,
11954,
627,
577,
692,
24161,
11954,
30233,
430,
1182,
2069,
8,
36,
692,
24161,
11954,
30233,
9,
421,
199,
1944,
36,
692,
24161,
11954,
275,
21237,
16809,
8557,
199,
1944,
52,
8459,
15515,
11860,
11954,
275,
446,
17,
199,
11090,
58,
4548,
275,
359,
32435,
16231,
21675,
14,
32435,
16231,
25290,
12,
199,
4005,
265,
16231,
21675,
14,
36,
8125,
795,
28804,
12,
199,
4005,
265,
16231,
21675,
14,
25014,
19765,
39,
285,
28509,
12,
199,
4005,
265,
16231,
21675,
14,
4649,
78,
1500,
1352,
320,
8161,
9688,
12,
199,
4005,
265,
16231,
21675,
14,
1918,
34,
9734,
82,
3561,
12,
199,
4005,
265,
16231,
21675,
14,
36,
8125,
795,
36,
1091,
9688,
61,
199,
199,
318,
664,
36,
692,
24161,
8,
1492,
15515,
11860,
304,
272,
2636,
364,
11860,
275,
664,
11090,
2619,
1304,
8,
1492,
15515,
11860,
9,
272,
372,
2069,
8,
11090,
58,
4548,
14,
1080,
8,
10422,
11860,
430,
1182,
334,
552,
8,
11090,
58,
4548,
9,
446,
413,
9,
421,
199,
318,
664,
11090,
2619,
1304,
8,
1492,
15515,
11860,
304,
272,
372,
22518,
9562,
14,
362,
6049,
7174,
17810,
364,
1304,
8,
1492,
15515,
11860,
9,
421,
199,
318,
664,
12642,
30233,
8,
1492,
15515,
11860,
304,
272,
17176,
1304,
275,
664,
11090,
2619,
1304,
8,
1492,
15515,
11860,
9,
272,
22215,
275,
2018,
9562,
14,
1435,
80,
8,
17,
14,
16,
12,
413,
14,
21,
12,
2069,
8,
11090,
58,
4548,
14,
1080,
8,
11803,
1304,
430,
1182,
334,
552,
8,
11090,
58,
4548,
9,
446,
413,
430,
272,
372,
22215,
199,
199,
3,
2104,
22447,
1361,
4160,
39,
199,
51,
4993,
3571,
14508,
275,
359,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
383,
2824,
1553,
27411,
36,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
383,
2528,
1553,
4815,
36,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
31214,
1553,
2281,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
32466,
1553,
2334,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
32683,
1553,
428,
1991,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
31107,
1553,
4319,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
7979,
37,
1553,
491,
11307,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
31010,
1553,
17032,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
31214,
1553,
11727,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
383,
2869,
1553,
19461,
726,
3177,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
30760,
1553,
3651,
48,
1734,
39,
1149,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
31107,
1553,
481,
1230,
2080,
540,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
7979,
36,
1553,
1621,
54,
1719,
1277,
2594,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
31214,
1553,
644,
14961,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
7979,
37,
1553,
6262,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
32683,
1553,
653,
4220,
1608,
4392,
7,
199,
61,
199,
318,
3550,
7084,
11611,
5663,
8062,
837,
272,
21621,
275,
7141,
8,
51,
4993,
3571,
14508,
9,
272,
1300,
14,
1832,
24916,
14,
409,
3989,
2209,
8,
16,
12,
21621,
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
] |
[
4125,
14,
2384,
1095,
492,
2018,
9562,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
4005,
265,
16231,
21675,
199,
504,
370,
265,
16231,
14,
10422,
492,
22518,
9562,
199,
504,
2196,
492,
7141,
199,
19645,
1378,
8807,
275,
1616,
14,
16,
199,
4261,
6200,
1366,
275,
6335,
14,
16,
199,
4423,
13283,
275,
3193,
199,
42,
29051,
28142,
52,
8459,
15515,
17810,
317,
2977,
12642,
25314,
5697,
275,
499,
199,
36,
692,
24161,
11954,
30233,
275,
1109,
8,
17,
5213,
3193,
9,
199,
199,
318,
5843,
4466,
806,
36,
692,
24161,
11954,
8,
3028,
11954,
304,
272,
372,
1109,
8,
2363,
8,
3028,
11954,
627,
577,
692,
24161,
11954,
30233,
430,
1182,
2069,
8,
36,
692,
24161,
11954,
30233,
9,
421,
199,
1944,
36,
692,
24161,
11954,
275,
21237,
16809,
8557,
199,
1944,
52,
8459,
15515,
11860,
11954,
275,
446,
17,
199,
11090,
58,
4548,
275,
359,
32435,
16231,
21675,
14,
32435,
16231,
25290,
12,
199,
4005,
265,
16231,
21675,
14,
36,
8125,
795,
28804,
12,
199,
4005,
265,
16231,
21675,
14,
25014,
19765,
39,
285,
28509,
12,
199,
4005,
265,
16231,
21675,
14,
4649,
78,
1500,
1352,
320,
8161,
9688,
12,
199,
4005,
265,
16231,
21675,
14,
1918,
34,
9734,
82,
3561,
12,
199,
4005,
265,
16231,
21675,
14,
36,
8125,
795,
36,
1091,
9688,
61,
199,
199,
318,
664,
36,
692,
24161,
8,
1492,
15515,
11860,
304,
272,
2636,
364,
11860,
275,
664,
11090,
2619,
1304,
8,
1492,
15515,
11860,
9,
272,
372,
2069,
8,
11090,
58,
4548,
14,
1080,
8,
10422,
11860,
430,
1182,
334,
552,
8,
11090,
58,
4548,
9,
446,
413,
9,
421,
199,
318,
664,
11090,
2619,
1304,
8,
1492,
15515,
11860,
304,
272,
372,
22518,
9562,
14,
362,
6049,
7174,
17810,
364,
1304,
8,
1492,
15515,
11860,
9,
421,
199,
318,
664,
12642,
30233,
8,
1492,
15515,
11860,
304,
272,
17176,
1304,
275,
664,
11090,
2619,
1304,
8,
1492,
15515,
11860,
9,
272,
22215,
275,
2018,
9562,
14,
1435,
80,
8,
17,
14,
16,
12,
413,
14,
21,
12,
2069,
8,
11090,
58,
4548,
14,
1080,
8,
11803,
1304,
430,
1182,
334,
552,
8,
11090,
58,
4548,
9,
446,
413,
430,
272,
372,
22215,
199,
199,
3,
2104,
22447,
1361,
4160,
39,
199,
51,
4993,
3571,
14508,
275,
359,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
383,
2824,
1553,
27411,
36,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
383,
2528,
1553,
4815,
36,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
31214,
1553,
2281,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
32466,
1553,
2334,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
32683,
1553,
428,
1991,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
31107,
1553,
4319,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
7979,
37,
1553,
491,
11307,
297,
272,
283,
3177,
13,
5287,
17,
26,
428,
4993,
11973,
327,
31010,
1553,
17032,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
31214,
1553,
11727,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
383,
2869,
1553,
19461,
726,
3177,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
30760,
1553,
3651,
48,
1734,
39,
1149,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
31107,
1553,
481,
1230,
2080,
540,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
7979,
36,
1553,
1621,
54,
1719,
1277,
2594,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
31214,
1553,
644,
14961,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
7979,
37,
1553,
6262,
297,
272,
283,
3177,
13,
5287,
18,
26,
428,
4993,
11973,
327,
32683,
1553,
653,
4220,
1608,
4392,
7,
199,
61,
199,
318,
3550,
7084,
11611,
5663,
8062,
837,
272,
21621,
275,
7141,
8,
51,
4993,
3571,
14508,
9,
272,
1300,
14,
1832,
24916,
14,
409,
3989,
2209,
8,
16,
12,
21621,
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,
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,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
GauriGNaik/servo
|
tests/wpt/web-platform-tests/tools/pywebsocket/src/mod_pywebsocket/handshake/_base.py
|
652
|
6143
|
# Copyright 2012, 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.
"""Common functions and exceptions used by WebSocket opening handshake
processors.
"""
from mod_pywebsocket import common
from mod_pywebsocket import http_header_util
class AbortedByUserException(Exception):
"""Exception for aborting a connection intentionally.
If this exception is raised in do_extra_handshake handler, the connection
will be abandoned. No other WebSocket or HTTP(S) handler will be invoked.
If this exception is raised in transfer_data_handler, the connection will
be closed without closing handshake. No other WebSocket or HTTP(S) handler
will be invoked.
"""
pass
class HandshakeException(Exception):
"""This exception will be raised when an error occurred while processing
WebSocket initial handshake.
"""
def __init__(self, name, status=None):
super(HandshakeException, self).__init__(name)
self.status = status
class VersionException(Exception):
"""This exception will be raised when a version of client request does not
match with version the server supports.
"""
def __init__(self, name, supported_versions=''):
"""Construct an instance.
Args:
supported_version: a str object to show supported hybi versions.
(e.g. '8, 13')
"""
super(VersionException, self).__init__(name)
self.supported_versions = supported_versions
def get_default_port(is_secure):
if is_secure:
return common.DEFAULT_WEB_SOCKET_SECURE_PORT
else:
return common.DEFAULT_WEB_SOCKET_PORT
def validate_subprotocol(subprotocol):
"""Validate a value in the Sec-WebSocket-Protocol field.
See the Section 4.1., 4.2.2., and 4.3. of RFC 6455.
"""
if not subprotocol:
raise HandshakeException('Invalid subprotocol name: empty')
# Parameter should be encoded HTTP token.
state = http_header_util.ParsingState(subprotocol)
token = http_header_util.consume_token(state)
rest = http_header_util.peek(state)
# If |rest| is not None, |subprotocol| is not one token or invalid. If
# |rest| is None, |token| must not be None because |subprotocol| is
# concatenation of |token| and |rest| and is not None.
if rest is not None:
raise HandshakeException('Invalid non-token string in subprotocol '
'name: %r' % rest)
def parse_host_header(request):
fields = request.headers_in[common.HOST_HEADER].split(':', 1)
if len(fields) == 1:
return fields[0], get_default_port(request.is_https())
try:
return fields[0], int(fields[1])
except ValueError, e:
raise HandshakeException('Invalid port number format: %r' % e)
def format_header(name, value):
return '%s: %s\r\n' % (name, value)
def get_mandatory_header(request, key):
value = request.headers_in.get(key)
if value is None:
raise HandshakeException('Header %s is not defined' % key)
return value
def validate_mandatory_header(request, key, expected_value, fail_status=None):
value = get_mandatory_header(request, key)
if value.lower() != expected_value.lower():
raise HandshakeException(
'Expected %r for header %s but found %r (case-insensitive)' %
(expected_value, key, value), status=fail_status)
def check_request_line(request):
# 5.1 1. The three character UTF-8 string "GET".
# 5.1 2. A UTF-8-encoded U+0020 SPACE character (0x20 byte).
if request.method != 'GET':
raise HandshakeException('Method is not GET: %r' % request.method)
if request.protocol != 'HTTP/1.1':
raise HandshakeException('Version is not HTTP/1.1: %r' %
request.protocol)
def parse_token_list(data):
"""Parses a header value which follows 1#token and returns parsed elements
as a list of strings.
Leading LWSes must be trimmed.
"""
state = http_header_util.ParsingState(data)
token_list = []
while True:
token = http_header_util.consume_token(state)
if token is not None:
token_list.append(token)
http_header_util.consume_lwses(state)
if http_header_util.peek(state) is None:
break
if not http_header_util.consume_string(state, ','):
raise HandshakeException(
'Expected a comma but found %r' % http_header_util.peek(state))
http_header_util.consume_lwses(state)
if len(token_list) == 0:
raise HandshakeException('No valid token found')
return token_list
# vi:sts=4 sw=4 et
|
mpl-2.0
|
[
3,
1898,
6029,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
624,
7844,
3423,
436,
4967,
1202,
701,
18846,
13618,
14305,
199,
10547,
14,
199,
624,
421,
199,
504,
3413,
63,
21387,
492,
2863,
199,
504,
3413,
63,
21387,
492,
1455,
63,
1291,
63,
1974,
421,
199,
533,
8351,
1376,
2175,
1899,
1726,
8,
1726,
304,
272,
408,
1726,
367,
12004,
316,
282,
1950,
32005,
14,
339,
982,
642,
1919,
365,
4915,
315,
886,
63,
2911,
63,
11913,
3016,
12,
314,
1950,
272,
911,
506,
2236,
460,
28918,
14,
3091,
1163,
18846,
503,
3101,
8,
51,
9,
3016,
911,
506,
10302,
14,
339,
982,
642,
1919,
365,
4915,
315,
9307,
63,
576,
63,
2232,
12,
314,
1950,
911,
272,
506,
6876,
1928,
11261,
14305,
14,
3091,
1163,
18846,
503,
3101,
8,
51,
9,
3016,
272,
911,
506,
10302,
14,
272,
408,
339,
986,
421,
199,
533,
27451,
1726,
8,
1726,
304,
272,
408,
2765,
1919,
911,
506,
4915,
1380,
376,
1125,
8920,
1830,
6661,
272,
18846,
2536,
14305,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2004,
29,
403,
304,
267,
1613,
8,
26392,
1726,
12,
291,
2843,
826,
721,
354,
9,
267,
291,
14,
1205,
275,
2004,
421,
199,
533,
3394,
1726,
8,
1726,
304,
272,
408,
2765,
1919,
911,
506,
4915,
1380,
282,
1015,
402,
1890,
1056,
1630,
440,
272,
1336,
543,
1015,
314,
1654,
5171,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
536,
12,
3748,
63,
6234,
9280,
267,
408,
11493,
376,
1256,
14,
398,
3033,
26,
288,
3748,
63,
1023,
26,
282,
620,
909,
370,
2498,
3748,
7188,
4492,
5459,
14,
3044,
334,
69,
14,
71,
14,
283,
24,
12,
4944,
358,
267,
408,
267,
1613,
8,
3353,
1726,
12,
291,
2843,
826,
721,
354,
9,
267,
291,
14,
4946,
63,
6234,
275,
3748,
63,
6234,
421,
199,
318,
664,
63,
885,
63,
719,
8,
374,
63,
7817,
304,
272,
340,
365,
63,
7817,
26,
267,
372,
2863,
14,
3472,
63,
13166,
63,
17462,
63,
20696,
63,
3657,
272,
587,
26,
267,
372,
2863,
14,
3472,
63,
13166,
63,
17462,
63,
3657,
421,
199,
318,
4107,
63,
954,
3922,
8,
954,
3922,
304,
272,
408,
12584,
282,
574,
315,
314,
9433,
13,
18477,
13,
3658,
901,
14,
339,
1666,
314,
15247,
841,
14,
17,
2020,
841,
14,
18,
14,
18,
2020,
436,
841,
14,
19,
14,
402,
7329,
5049,
1229,
14,
272,
408,
339,
340,
440,
1007,
3922,
26,
267,
746,
27451,
1726,
360,
3364,
1007,
3922,
536,
26,
2701,
358,
339,
327,
12009,
1077,
506,
5737,
3101,
1526,
14,
272,
1174,
275,
1455,
63,
1291,
63,
1974,
14,
17412,
2223,
8,
954,
3922,
9,
272,
1526,
275,
1455,
63,
1291,
63,
1974,
14,
10235,
63,
1418,
8,
929,
9,
272,
4618,
275,
1455,
63,
1291,
63,
1974,
14,
13164,
8,
929,
9,
272,
327,
982,
1204,
3911,
92,
365,
440,
488,
12,
1204,
954,
3922,
92,
365,
440,
1373,
1526,
503,
3866,
14,
982,
272,
327,
1204,
3911,
92,
365,
488,
12,
1204,
1418,
92,
1471,
440,
506,
488,
2952,
1204,
954,
3922,
92,
365,
272,
327,
28207,
402,
1204,
1418,
92,
436,
1204,
3911,
92,
436,
365,
440,
488,
14,
272,
340,
4618,
365,
440,
488,
26,
267,
746,
27451,
1726,
360,
3364,
2222,
13,
1418,
1059,
315,
1007,
3922,
283,
639,
283,
354,
26,
450,
82,
7,
450,
4618,
9,
421,
199,
318,
2198,
63,
1102,
63,
1291,
8,
1069,
304,
272,
1504,
275,
1056,
14,
2139,
63,
262,
59,
2330,
14,
5449,
63,
7311,
1055,
1294,
16451,
413,
9,
272,
340,
822,
8,
955,
9,
508,
413,
26,
267,
372,
1504,
59,
16,
467,
664,
63,
885,
63,
719,
8,
1069,
14,
374,
63,
2859,
1012,
272,
862,
26,
267,
372,
1504,
59,
16,
467,
1109,
8,
955,
59,
17,
566,
272,
871,
1722,
12,
325,
26,
267,
746,
27451,
1726,
360,
3364,
1844,
1329,
1475,
26,
450,
82,
7,
450,
325,
9,
421,
199,
318,
1475,
63,
1291,
8,
354,
12,
574,
304,
272,
372,
1543,
83,
26,
450,
83,
60,
82,
60,
78,
7,
450,
334,
354,
12,
574,
9,
421,
199,
318,
664,
63,
19900,
63,
1291,
8,
1069,
12,
790,
304,
272,
574,
275,
1056,
14,
2139,
63,
262,
14,
362,
8,
498,
9
] |
[
1898,
6029,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
624,
7844,
3423,
436,
4967,
1202,
701,
18846,
13618,
14305,
199,
10547,
14,
199,
624,
421,
199,
504,
3413,
63,
21387,
492,
2863,
199,
504,
3413,
63,
21387,
492,
1455,
63,
1291,
63,
1974,
421,
199,
533,
8351,
1376,
2175,
1899,
1726,
8,
1726,
304,
272,
408,
1726,
367,
12004,
316,
282,
1950,
32005,
14,
339,
982,
642,
1919,
365,
4915,
315,
886,
63,
2911,
63,
11913,
3016,
12,
314,
1950,
272,
911,
506,
2236,
460,
28918,
14,
3091,
1163,
18846,
503,
3101,
8,
51,
9,
3016,
911,
506,
10302,
14,
339,
982,
642,
1919,
365,
4915,
315,
9307,
63,
576,
63,
2232,
12,
314,
1950,
911,
272,
506,
6876,
1928,
11261,
14305,
14,
3091,
1163,
18846,
503,
3101,
8,
51,
9,
3016,
272,
911,
506,
10302,
14,
272,
408,
339,
986,
421,
199,
533,
27451,
1726,
8,
1726,
304,
272,
408,
2765,
1919,
911,
506,
4915,
1380,
376,
1125,
8920,
1830,
6661,
272,
18846,
2536,
14305,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2004,
29,
403,
304,
267,
1613,
8,
26392,
1726,
12,
291,
2843,
826,
721,
354,
9,
267,
291,
14,
1205,
275,
2004,
421,
199,
533,
3394,
1726,
8,
1726,
304,
272,
408,
2765,
1919,
911,
506,
4915,
1380,
282,
1015,
402,
1890,
1056,
1630,
440,
272,
1336,
543,
1015,
314,
1654,
5171,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
536,
12,
3748,
63,
6234,
9280,
267,
408,
11493,
376,
1256,
14,
398,
3033,
26,
288,
3748,
63,
1023,
26,
282,
620,
909,
370,
2498,
3748,
7188,
4492,
5459,
14,
3044,
334,
69,
14,
71,
14,
283,
24,
12,
4944,
358,
267,
408,
267,
1613,
8,
3353,
1726,
12,
291,
2843,
826,
721,
354,
9,
267,
291,
14,
4946,
63,
6234,
275,
3748,
63,
6234,
421,
199,
318,
664,
63,
885,
63,
719,
8,
374,
63,
7817,
304,
272,
340,
365,
63,
7817,
26,
267,
372,
2863,
14,
3472,
63,
13166,
63,
17462,
63,
20696,
63,
3657,
272,
587,
26,
267,
372,
2863,
14,
3472,
63,
13166,
63,
17462,
63,
3657,
421,
199,
318,
4107,
63,
954,
3922,
8,
954,
3922,
304,
272,
408,
12584,
282,
574,
315,
314,
9433,
13,
18477,
13,
3658,
901,
14,
339,
1666,
314,
15247,
841,
14,
17,
2020,
841,
14,
18,
14,
18,
2020,
436,
841,
14,
19,
14,
402,
7329,
5049,
1229,
14,
272,
408,
339,
340,
440,
1007,
3922,
26,
267,
746,
27451,
1726,
360,
3364,
1007,
3922,
536,
26,
2701,
358,
339,
327,
12009,
1077,
506,
5737,
3101,
1526,
14,
272,
1174,
275,
1455,
63,
1291,
63,
1974,
14,
17412,
2223,
8,
954,
3922,
9,
272,
1526,
275,
1455,
63,
1291,
63,
1974,
14,
10235,
63,
1418,
8,
929,
9,
272,
4618,
275,
1455,
63,
1291,
63,
1974,
14,
13164,
8,
929,
9,
272,
327,
982,
1204,
3911,
92,
365,
440,
488,
12,
1204,
954,
3922,
92,
365,
440,
1373,
1526,
503,
3866,
14,
982,
272,
327,
1204,
3911,
92,
365,
488,
12,
1204,
1418,
92,
1471,
440,
506,
488,
2952,
1204,
954,
3922,
92,
365,
272,
327,
28207,
402,
1204,
1418,
92,
436,
1204,
3911,
92,
436,
365,
440,
488,
14,
272,
340,
4618,
365,
440,
488,
26,
267,
746,
27451,
1726,
360,
3364,
2222,
13,
1418,
1059,
315,
1007,
3922,
283,
639,
283,
354,
26,
450,
82,
7,
450,
4618,
9,
421,
199,
318,
2198,
63,
1102,
63,
1291,
8,
1069,
304,
272,
1504,
275,
1056,
14,
2139,
63,
262,
59,
2330,
14,
5449,
63,
7311,
1055,
1294,
16451,
413,
9,
272,
340,
822,
8,
955,
9,
508,
413,
26,
267,
372,
1504,
59,
16,
467,
664,
63,
885,
63,
719,
8,
1069,
14,
374,
63,
2859,
1012,
272,
862,
26,
267,
372,
1504,
59,
16,
467,
1109,
8,
955,
59,
17,
566,
272,
871,
1722,
12,
325,
26,
267,
746,
27451,
1726,
360,
3364,
1844,
1329,
1475,
26,
450,
82,
7,
450,
325,
9,
421,
199,
318,
1475,
63,
1291,
8,
354,
12,
574,
304,
272,
372,
1543,
83,
26,
450,
83,
60,
82,
60,
78,
7,
450,
334,
354,
12,
574,
9,
421,
199,
318,
664,
63,
19900,
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
] |
c0d3z3r0/linux-rockchip
|
tools/testing/selftests/tc-testing/TdcResults.py
|
557
|
4359
|
#!/usr/bin/env python3
from enum import Enum
class ResultState(Enum):
noresult = -1
skip = 0
success = 1
fail = 2
class TestResult:
def __init__(self, test_id="", test_name=""):
self.test_id = test_id
self.test_name = test_name
self.result = ResultState.noresult
self.failmsg = ""
self.errormsg = ""
self.steps = []
def set_result(self, result):
if (isinstance(result, ResultState)):
self.result = result
return True
else:
raise TypeError('Unknown result type, must be type ResultState')
def get_result(self):
return self.result
def set_errormsg(self, errormsg):
self.errormsg = errormsg
return True
def append_errormsg(self, errormsg):
self.errormsg = '{}\n{}'.format(self.errormsg, errormsg)
def get_errormsg(self):
return self.errormsg
def set_failmsg(self, failmsg):
self.failmsg = failmsg
return True
def append_failmsg(self, failmsg):
self.failmsg = '{}\n{}'.format(self.failmsg, failmsg)
def get_failmsg(self):
return self.failmsg
def add_steps(self, newstep):
if type(newstep) == list:
self.steps.extend(newstep)
elif type(newstep) == str:
self.steps.append(step)
else:
raise TypeError('TdcResults.add_steps() requires a list or str')
def get_executed_steps(self):
return self.steps
class TestSuiteReport():
_testsuite = []
def add_resultdata(self, result_data):
if isinstance(result_data, TestResult):
self._testsuite.append(result_data)
return True
def count_tests(self):
return len(self._testsuite)
def count_failures(self):
return sum(1 for t in self._testsuite if t.result == ResultState.fail)
def count_skips(self):
return sum(1 for t in self._testsuite if t.result == ResultState.skip)
def find_result(self, test_id):
return next((tr for tr in self._testsuite if tr.test_id == test_id), None)
def update_result(self, result_data):
orig = self.find_result(result_data.test_id)
if orig != None:
idx = self._testsuite.index(orig)
self._testsuite[idx] = result_data
else:
self.add_resultdata(result_data)
def format_tap(self):
ftap = ""
ftap += '1..{}\n'.format(self.count_tests())
index = 1
for t in self._testsuite:
if t.result == ResultState.fail:
ftap += 'not '
ftap += 'ok {} {} - {}'.format(str(index), t.test_id, t.test_name)
if t.result == ResultState.skip or t.result == ResultState.noresult:
ftap += ' # skipped - {}\n'.format(t.errormsg)
elif t.result == ResultState.fail:
if len(t.steps) > 0:
ftap += '\tCommands executed in this test case:'
for step in t.steps:
ftap += '\n\t\t{}'.format(step)
ftap += '\n\t{}'.format(t.failmsg)
ftap += '\n'
index += 1
return ftap
def format_xunit(self):
from xml.sax.saxutils import escape
xunit = "<testsuites>\n"
xunit += '\t<testsuite tests=\"{}\" skips=\"{}\">\n'.format(self.count_tests(), self.count_skips())
for t in self._testsuite:
xunit += '\t\t<testcase classname=\"{}\" '.format(escape(t.test_id))
xunit += 'name=\"{}\">\n'.format(escape(t.test_name))
if t.failmsg:
xunit += '\t\t\t<failure>\n'
if len(t.steps) > 0:
xunit += 'Commands executed in this test case:\n'
for step in t.steps:
xunit += '\t{}\n'.format(escape(step))
xunit += 'FAILURE: {}\n'.format(escape(t.failmsg))
xunit += '\t\t\t</failure>\n'
if t.errormsg:
xunit += '\t\t\t<error>\n{}\n'.format(escape(t.errormsg))
xunit += '\t\t\t</error>\n'
if t.result == ResultState.skip:
xunit += '\t\t\t<skipped/>\n'
xunit += '\t\t</testcase>\n'
xunit += '\t</testsuite>\n'
xunit += '</testsuites>\n'
return xunit
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
199,
504,
4952,
492,
11305,
199,
199,
533,
10695,
2223,
8,
5081,
304,
272,
949,
1099,
275,
446,
17,
272,
3372,
275,
378,
272,
3182,
275,
413,
272,
2449,
275,
499,
199,
199,
533,
23795,
26,
272,
347,
636,
826,
721,
277,
12,
511,
63,
344,
8772,
511,
63,
354,
17364,
2126,
291,
14,
396,
63,
344,
275,
511,
63,
344,
2126,
291,
14,
396,
63,
354,
275,
511,
63,
354,
2126,
291,
14,
1099,
275,
10695,
2223,
14,
889,
1099,
2126,
291,
14,
1633,
1328,
275,
3087,
2126,
291,
14,
705,
1328,
275,
3087,
2126,
291,
14,
5895,
275,
942,
339,
347,
663,
63,
1099,
8,
277,
12,
754,
304,
267,
340,
334,
6074,
8,
1099,
12,
10695,
2223,
2298,
288,
291,
14,
1099,
275,
754,
288,
372,
715,
267,
587,
26,
288,
746,
3146,
360,
5912,
754,
730,
12,
1471,
506,
730,
10695,
2223,
358,
339,
347,
664,
63,
1099,
8,
277,
304,
267,
372,
291,
14,
1099,
339,
347,
663,
63,
705,
1328,
8,
277,
12,
1125,
1328,
304,
267,
291,
14,
705,
1328,
275,
1125,
1328,
267,
372,
715,
339,
347,
5666,
63,
705,
1328,
8,
277,
12,
1125,
1328,
304,
267,
291,
14,
705,
1328,
275,
9005,
60,
78,
11123,
908,
8,
277,
14,
705,
1328,
12,
1125,
1328,
9,
339,
347,
664,
63,
705,
1328,
8,
277,
304,
267,
372,
291,
14,
705,
1328,
339,
347,
663,
63,
1633,
1328,
8,
277,
12,
2449,
1328,
304,
267,
291,
14,
1633,
1328,
275,
2449,
1328,
267,
372,
715,
339,
347,
5666,
63,
1633,
1328,
8,
277,
12,
2449,
1328,
304,
267,
291,
14,
1633,
1328,
275,
9005,
60,
78,
11123,
908,
8,
277,
14,
1633,
1328,
12,
2449,
1328,
9,
339,
347,
664,
63,
1633,
1328,
8,
277,
304,
267,
372,
291,
14,
1633,
1328,
339,
347,
1050,
63,
5895,
8,
277,
12,
892,
2926,
304,
267,
340,
730,
8,
1222,
2926,
9,
508,
769,
26,
288,
291,
14,
5895,
14,
2880,
8,
1222,
2926,
9,
267,
916,
730,
8,
1222,
2926,
9,
508,
620,
26,
288,
291,
14,
5895,
14,
740,
8,
2926,
9,
267,
587,
26,
288,
746,
3146,
360,
52,
3833,
6579,
14,
525,
63,
5895,
342,
5074,
282,
769,
503,
620,
358,
339,
347,
664,
63,
22564,
63,
5895,
8,
277,
304,
267,
372,
291,
14,
5895,
199,
199,
533,
20979,
7457,
837,
272,
485,
14239,
275,
942,
339,
347,
1050,
63,
1099,
576,
8,
277,
12,
754,
63,
576,
304,
267,
340,
1228,
8,
1099,
63,
576,
12,
23795,
304,
288,
291,
423,
14239,
14,
740,
8,
1099,
63,
576,
9,
288,
372,
715,
339,
347,
2338,
63,
2219,
8,
277,
304,
267,
372,
822,
8,
277,
423,
14239,
9,
339,
347,
2338,
63,
9968,
8,
277,
304,
267,
372,
3089,
8,
17,
367,
307,
315,
291,
423,
14239,
340,
307,
14,
1099,
508,
10695,
2223,
14,
1633,
9,
339,
347,
2338,
63,
2759,
83,
8,
277,
304,
267,
372,
3089,
8,
17,
367,
307,
315,
291,
423,
14239,
340,
307,
14,
1099,
508,
10695,
2223,
14,
2759,
9,
339,
347,
2342,
63,
1099,
8,
277,
12,
511,
63,
344,
304,
267,
372,
2163,
1332,
454,
367,
5651,
315,
291,
423,
14239,
340,
5651,
14,
396,
63,
344,
508,
511,
63,
344,
395,
488,
9,
339,
347,
1678,
63,
1099,
8,
277,
12,
754,
63,
576,
304,
267,
2306,
275,
291,
14,
1623,
63,
1099,
8,
1099,
63,
576,
14,
396,
63,
344,
9,
267,
340,
2306,
1137,
488,
26,
288,
4280,
275,
291,
423,
14239,
14,
1080,
8,
2981,
9,
288,
291,
423,
14239,
59,
2996,
61,
275,
754,
63,
576,
267,
587,
26,
288,
291,
14,
525,
63,
1099,
576,
8,
1099,
63,
576,
9,
339,
347,
1475,
63,
16609,
8,
277,
304,
267,
289,
16609,
275,
3087,
267,
289,
16609,
847,
283,
17,
703,
24423,
78,
1370,
908,
8,
277,
14,
835,
63,
2219,
1012,
267,
1478,
275,
413,
267,
367,
307,
315,
291,
423,
14239,
26,
288,
340,
307,
14,
1099,
508,
10695,
2223,
14,
1633,
26,
355,
289,
16609,
847,
283,
1397,
283,
288,
289,
16609,
847,
283,
745,
1052,
1052,
446,
9499,
908,
8,
495,
8,
1080,
395,
307,
14,
396,
63,
344,
12,
307,
14,
396,
63,
354,
9,
288,
340,
307,
14,
1099,
508,
10695,
2223,
14,
2759,
503,
307,
14,
1099,
508,
10695,
2223,
14,
889,
1099,
26,
355,
289,
16609,
847,
283,
327,
9645,
446,
22902,
78,
1370,
908,
8,
84,
14,
705,
1328,
9,
288,
916,
307,
14,
1099,
508,
10695,
2223,
14,
1633,
26,
355,
340,
822,
8,
84,
14,
5895,
9,
690,
378,
26,
490,
289,
16609,
847,
1557,
84,
14680,
7934,
315,
642,
511,
1930,
4881,
490,
367,
3650,
315,
307,
14,
5895,
26,
717,
289,
16609,
847,
1557,
78,
60,
84,
60,
84,
11123,
908,
8,
2926,
9,
355,
289,
16609,
847,
1557,
78,
60,
84,
11123,
908,
8,
84,
14,
1633,
1328,
9,
288,
289,
16609,
847,
1557,
78,
7,
288,
1478,
847,
413,
267,
372,
289,
16609,
339,
347,
1475,
63,
88,
3248,
8,
277,
304,
267,
687,
2748,
14,
14338,
14,
14338,
1208,
492,
4772,
267,
671,
3248,
275,
3886,
2219,
11650,
3072,
78,
2,
267,
671,
3248,
847,
1557,
84,
28,
14239,
2295,
8178,
2440,
4451,
30505,
8178,
24423,
14559,
78,
1370,
908,
8,
277,
14,
835,
63,
2219,
1062,
291,
14,
835,
63,
2759,
83,
1012,
267,
367,
307,
315,
291,
423,
14239,
26,
288,
671,
3248,
847,
1557,
84,
60,
84,
28,
10847,
15876,
8178,
2440,
4451,
1987,
908,
8,
3765,
8,
84,
14,
396,
63,
344,
430,
288,
671,
3248,
847,
283,
354,
8178,
24423,
14559,
78,
1370,
908,
8,
3765,
8,
84,
14,
396,
63,
354,
430,
288,
340,
307,
14,
1633,
1328,
26,
355,
671,
3248,
847,
1557,
84,
60,
84,
60,
84,
28,
5328,
3072,
78,
7,
355,
340,
822,
8,
84,
14,
5895,
9,
690,
378,
26,
490,
671,
3248,
847,
283,
14680,
7934,
315,
642,
511,
1930,
3427,
78,
7,
490,
367,
3650,
315,
307,
14,
5895,
26,
717,
671,
3248,
847,
1557,
84,
24423,
78,
1370,
908
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
199,
504,
4952,
492,
11305,
199,
199,
533,
10695,
2223,
8,
5081,
304,
272,
949,
1099,
275,
446,
17,
272,
3372,
275,
378,
272,
3182,
275,
413,
272,
2449,
275,
499,
199,
199,
533,
23795,
26,
272,
347,
636,
826,
721,
277,
12,
511,
63,
344,
8772,
511,
63,
354,
17364,
2126,
291,
14,
396,
63,
344,
275,
511,
63,
344,
2126,
291,
14,
396,
63,
354,
275,
511,
63,
354,
2126,
291,
14,
1099,
275,
10695,
2223,
14,
889,
1099,
2126,
291,
14,
1633,
1328,
275,
3087,
2126,
291,
14,
705,
1328,
275,
3087,
2126,
291,
14,
5895,
275,
942,
339,
347,
663,
63,
1099,
8,
277,
12,
754,
304,
267,
340,
334,
6074,
8,
1099,
12,
10695,
2223,
2298,
288,
291,
14,
1099,
275,
754,
288,
372,
715,
267,
587,
26,
288,
746,
3146,
360,
5912,
754,
730,
12,
1471,
506,
730,
10695,
2223,
358,
339,
347,
664,
63,
1099,
8,
277,
304,
267,
372,
291,
14,
1099,
339,
347,
663,
63,
705,
1328,
8,
277,
12,
1125,
1328,
304,
267,
291,
14,
705,
1328,
275,
1125,
1328,
267,
372,
715,
339,
347,
5666,
63,
705,
1328,
8,
277,
12,
1125,
1328,
304,
267,
291,
14,
705,
1328,
275,
9005,
60,
78,
11123,
908,
8,
277,
14,
705,
1328,
12,
1125,
1328,
9,
339,
347,
664,
63,
705,
1328,
8,
277,
304,
267,
372,
291,
14,
705,
1328,
339,
347,
663,
63,
1633,
1328,
8,
277,
12,
2449,
1328,
304,
267,
291,
14,
1633,
1328,
275,
2449,
1328,
267,
372,
715,
339,
347,
5666,
63,
1633,
1328,
8,
277,
12,
2449,
1328,
304,
267,
291,
14,
1633,
1328,
275,
9005,
60,
78,
11123,
908,
8,
277,
14,
1633,
1328,
12,
2449,
1328,
9,
339,
347,
664,
63,
1633,
1328,
8,
277,
304,
267,
372,
291,
14,
1633,
1328,
339,
347,
1050,
63,
5895,
8,
277,
12,
892,
2926,
304,
267,
340,
730,
8,
1222,
2926,
9,
508,
769,
26,
288,
291,
14,
5895,
14,
2880,
8,
1222,
2926,
9,
267,
916,
730,
8,
1222,
2926,
9,
508,
620,
26,
288,
291,
14,
5895,
14,
740,
8,
2926,
9,
267,
587,
26,
288,
746,
3146,
360,
52,
3833,
6579,
14,
525,
63,
5895,
342,
5074,
282,
769,
503,
620,
358,
339,
347,
664,
63,
22564,
63,
5895,
8,
277,
304,
267,
372,
291,
14,
5895,
199,
199,
533,
20979,
7457,
837,
272,
485,
14239,
275,
942,
339,
347,
1050,
63,
1099,
576,
8,
277,
12,
754,
63,
576,
304,
267,
340,
1228,
8,
1099,
63,
576,
12,
23795,
304,
288,
291,
423,
14239,
14,
740,
8,
1099,
63,
576,
9,
288,
372,
715,
339,
347,
2338,
63,
2219,
8,
277,
304,
267,
372,
822,
8,
277,
423,
14239,
9,
339,
347,
2338,
63,
9968,
8,
277,
304,
267,
372,
3089,
8,
17,
367,
307,
315,
291,
423,
14239,
340,
307,
14,
1099,
508,
10695,
2223,
14,
1633,
9,
339,
347,
2338,
63,
2759,
83,
8,
277,
304,
267,
372,
3089,
8,
17,
367,
307,
315,
291,
423,
14239,
340,
307,
14,
1099,
508,
10695,
2223,
14,
2759,
9,
339,
347,
2342,
63,
1099,
8,
277,
12,
511,
63,
344,
304,
267,
372,
2163,
1332,
454,
367,
5651,
315,
291,
423,
14239,
340,
5651,
14,
396,
63,
344,
508,
511,
63,
344,
395,
488,
9,
339,
347,
1678,
63,
1099,
8,
277,
12,
754,
63,
576,
304,
267,
2306,
275,
291,
14,
1623,
63,
1099,
8,
1099,
63,
576,
14,
396,
63,
344,
9,
267,
340,
2306,
1137,
488,
26,
288,
4280,
275,
291,
423,
14239,
14,
1080,
8,
2981,
9,
288,
291,
423,
14239,
59,
2996,
61,
275,
754,
63,
576,
267,
587,
26,
288,
291,
14,
525,
63,
1099,
576,
8,
1099,
63,
576,
9,
339,
347,
1475,
63,
16609,
8,
277,
304,
267,
289,
16609,
275,
3087,
267,
289,
16609,
847,
283,
17,
703,
24423,
78,
1370,
908,
8,
277,
14,
835,
63,
2219,
1012,
267,
1478,
275,
413,
267,
367,
307,
315,
291,
423,
14239,
26,
288,
340,
307,
14,
1099,
508,
10695,
2223,
14,
1633,
26,
355,
289,
16609,
847,
283,
1397,
283,
288,
289,
16609,
847,
283,
745,
1052,
1052,
446,
9499,
908,
8,
495,
8,
1080,
395,
307,
14,
396,
63,
344,
12,
307,
14,
396,
63,
354,
9,
288,
340,
307,
14,
1099,
508,
10695,
2223,
14,
2759,
503,
307,
14,
1099,
508,
10695,
2223,
14,
889,
1099,
26,
355,
289,
16609,
847,
283,
327,
9645,
446,
22902,
78,
1370,
908,
8,
84,
14,
705,
1328,
9,
288,
916,
307,
14,
1099,
508,
10695,
2223,
14,
1633,
26,
355,
340,
822,
8,
84,
14,
5895,
9,
690,
378,
26,
490,
289,
16609,
847,
1557,
84,
14680,
7934,
315,
642,
511,
1930,
4881,
490,
367,
3650,
315,
307,
14,
5895,
26,
717,
289,
16609,
847,
1557,
78,
60,
84,
60,
84,
11123,
908,
8,
2926,
9,
355,
289,
16609,
847,
1557,
78,
60,
84,
11123,
908,
8,
84,
14,
1633,
1328,
9,
288,
289,
16609,
847,
1557,
78,
7,
288,
1478,
847,
413,
267,
372,
289,
16609,
339,
347,
1475,
63,
88,
3248,
8,
277,
304,
267,
687,
2748,
14,
14338,
14,
14338,
1208,
492,
4772,
267,
671,
3248,
275,
3886,
2219,
11650,
3072,
78,
2,
267,
671,
3248,
847,
1557,
84,
28,
14239,
2295,
8178,
2440,
4451,
30505,
8178,
24423,
14559,
78,
1370,
908,
8,
277,
14,
835,
63,
2219,
1062,
291,
14,
835,
63,
2759,
83,
1012,
267,
367,
307,
315,
291,
423,
14239,
26,
288,
671,
3248,
847,
1557,
84,
60,
84,
28,
10847,
15876,
8178,
2440,
4451,
1987,
908,
8,
3765,
8,
84,
14,
396,
63,
344,
430,
288,
671,
3248,
847,
283,
354,
8178,
24423,
14559,
78,
1370,
908,
8,
3765,
8,
84,
14,
396,
63,
354,
430,
288,
340,
307,
14,
1633,
1328,
26,
355,
671,
3248,
847,
1557,
84,
60,
84,
60,
84,
28,
5328,
3072,
78,
7,
355,
340,
822,
8,
84,
14,
5895,
9,
690,
378,
26,
490,
671,
3248,
847,
283,
14680,
7934,
315,
642,
511,
1930,
3427,
78,
7,
490,
367,
3650,
315,
307,
14,
5895,
26,
717,
671,
3248,
847,
1557,
84,
24423,
78,
1370,
908,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rgeleta/odoo
|
openerp/addons/base/res/res_country.py
|
283
|
4728
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, osv
def location_name_search(self, cr, user, name='', args=None, operator='ilike',
context=None, limit=100):
if not args:
args = []
ids = []
if len(name) == 2:
ids = self.search(cr, user, [('code', 'ilike', name)] + args,
limit=limit, context=context)
search_domain = [('name', operator, name)]
if ids: search_domain.append(('id', 'not in', ids))
ids.extend(self.search(cr, user, search_domain + args,
limit=limit, context=context))
locations = self.name_get(cr, user, ids, context)
return sorted(locations, key=lambda (id, name): ids.index(id))
class Country(osv.osv):
_name = 'res.country'
_description = 'Country'
_columns = {
'name': fields.char('Country Name',
help='The full name of the country.', required=True, translate=True),
'code': fields.char('Country Code', size=2,
help='The ISO country code in two chars.\n'
'You can use this field for quick search.'),
'address_format': fields.text('Address Format', help="""You can state here the usual format to use for the \
addresses belonging to this country.\n\nYou can use the python-style string patern with all the field of the address \
(for example, use '%(street)s' to display the field 'street') plus
\n%(state_name)s: the name of the state
\n%(state_code)s: the code of the state
\n%(country_name)s: the name of the country
\n%(country_code)s: the code of the country"""),
'currency_id': fields.many2one('res.currency', 'Currency'),
'image': fields.binary("Image"),
'country_group_ids': fields.many2many('res.country.group', 'res_country_res_country_group_rel', 'res_country_id', 'res_country_group_id', string='Country Groups'),
}
_sql_constraints = [
('name_uniq', 'unique (name)',
'The name of the country must be unique !'),
('code_uniq', 'unique (code)',
'The code of the country must be unique !')
]
_defaults = {
'address_format': "%(street)s\n%(street2)s\n%(city)s %(state_code)s %(zip)s\n%(country_name)s",
}
_order='name'
name_search = location_name_search
def create(self, cursor, user, vals, context=None):
if vals.get('code'):
vals['code'] = vals['code'].upper()
return super(Country, self).create(cursor, user, vals,
context=context)
def write(self, cursor, user, ids, vals, context=None):
if vals.get('code'):
vals['code'] = vals['code'].upper()
return super(Country, self).write(cursor, user, ids, vals,
context=context)
class CountryGroup(osv.osv):
_description="Country Group"
_name = 'res.country.group'
_columns = {
'name': fields.char('Name', required=True),
'country_ids': fields.many2many('res.country', 'res_country_res_country_group_rel', 'res_country_group_id', 'res_country_id', string='Countries'),
}
class CountryState(osv.osv):
_description="Country state"
_name = 'res.country.state'
_columns = {
'country_id': fields.many2one('res.country', 'Country',
required=True),
'name': fields.char('State Name', required=True,
help='Administrative divisions of a country. E.g. Fed. State, Departement, Canton'),
'code': fields.char('State Code', size=3,
help='The state code in max. three chars.', required=True),
}
_order = 'code'
name_search = location_name_search
# 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,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
420,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
199,
318,
2909,
63,
354,
63,
1733,
8,
277,
12,
2467,
12,
922,
12,
536,
4581,
1249,
29,
403,
12,
4182,
534,
27774,
297,
586,
1067,
29,
403,
12,
2304,
29,
1960,
304,
272,
340,
440,
1249,
26,
267,
1249,
275,
942,
339,
2762,
275,
942,
272,
340,
822,
8,
354,
9,
508,
499,
26,
267,
2762,
275,
291,
14,
1733,
8,
1556,
12,
922,
12,
4274,
600,
297,
283,
27774,
297,
536,
1874,
435,
1249,
12,
2079,
2304,
29,
3097,
12,
1067,
29,
1100,
9,
339,
2754,
63,
2261,
275,
4274,
354,
297,
4182,
12,
536,
1874,
272,
340,
2762,
26,
2754,
63,
2261,
14,
740,
4725,
344,
297,
283,
1397,
315,
297,
2762,
430,
272,
2762,
14,
2880,
8,
277,
14,
1733,
8,
1556,
12,
922,
12,
2754,
63,
2261,
435,
1249,
12,
2574,
2304,
29,
3097,
12,
1067,
29,
1100,
430,
339,
9918,
275,
291,
14,
354,
63,
362,
8,
1556,
12,
922,
12,
2762,
12,
1067,
9,
272,
372,
3355,
8,
8022,
12,
790,
29,
2734,
334,
344,
12,
536,
304,
2762,
14,
1080,
8,
344,
430,
199,
199,
533,
19453,
8,
4795,
14,
4795,
304,
272,
485,
354,
275,
283,
470,
14,
6063,
7,
272,
485,
1802,
275,
283,
17393,
7,
272,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
17393,
2812,
297,
288,
1720,
534,
1918,
2615,
536,
402,
314,
9023,
3130,
1415,
29,
549,
12,
9028,
29,
549,
395,
267,
283,
600,
356,
1504,
14,
1560,
360,
17393,
5495,
297,
1568,
29,
18,
12,
288,
1720,
534,
1918,
9055,
9023,
1233,
315,
2877,
8365,
3134,
78,
7,
288,
283,
5556,
883,
675,
642,
901,
367,
12530,
2754,
8038,
267,
283,
1562,
63,
908,
356,
1504,
14,
505,
360,
1476,
9701,
297,
1720,
11916,
5556,
883,
1174,
2348,
314,
20195,
1475,
370,
675,
367,
314,
971,
199,
7423,
30226,
370,
642,
9023,
3134,
78,
60,
78,
5556,
883,
675,
314,
2366,
13,
2487,
1059,
299,
23825,
543,
1006,
314,
901,
402,
314,
2287,
971,
199,
8,
509,
2893,
12,
675,
9487,
20451,
9,
83,
7,
370,
2929,
314,
901,
283,
20451,
358,
12254,
288,
971,
78,
2840,
929,
63,
354,
9,
83,
26,
314,
536,
402,
314,
1174,
288,
971,
78,
2840,
929,
63,
600,
9,
83,
26,
314,
1233,
402,
314,
1174,
288,
971,
78,
2840,
6063,
63,
354,
9,
83,
26,
314,
536,
402,
314,
9023,
288,
971,
78,
2840,
6063,
63,
600,
9,
83,
26,
314,
1233,
402,
314,
9023,
624,
395,
267,
283,
4968,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
470,
14,
4968,
297,
283,
19567,
659,
267,
283,
1569,
356,
1504,
14,
3008,
480,
3491,
1288,
267,
283,
6063,
63,
923,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
470,
14,
6063,
14,
923,
297,
283,
470,
63,
6063,
63,
470,
63,
6063,
63,
923,
63,
3369,
297,
283,
470,
63,
6063,
63,
344,
297,
283,
470,
63,
6063,
63,
923,
63,
344,
297,
1059,
534,
17393,
25031,
659,
272,
789,
272,
485,
3009,
63,
9882,
275,
359,
267,
661,
354,
63,
22484,
297,
283,
3235,
334,
354,
3196,
288,
283,
1918,
536,
402,
314,
9023,
1471,
506,
3747,
8546,
659,
267,
661,
600,
63,
22484,
297,
283,
3235,
334,
600,
3196,
288,
283,
1918,
1233,
402,
314,
9023,
1471,
506,
3747,
8546,
358,
272,
1622,
272,
485,
4322,
275,
469,
267,
283,
1562,
63,
908,
356,
11792,
20451,
9,
83,
60,
78,
2840,
20451,
18,
9,
83,
60,
78,
2840,
3690,
9,
83,
2818,
929,
63,
600,
9,
83,
2818,
3065,
9,
83,
60,
78,
2840,
6063,
63,
354,
9,
83,
401,
272,
789,
272,
485,
1648,
534,
354,
7,
339,
536,
63,
1733,
275,
2909,
63,
354,
63,
1733,
339,
347,
1218,
8,
277,
12,
3920,
12,
922,
12,
5322,
12,
1067,
29,
403,
304,
267,
340,
5322,
14,
362,
360,
600,
735,
288,
5322,
459,
600,
418,
275,
5322,
459,
600,
2278,
4142,
342,
267,
372,
1613,
8,
17393,
12,
291,
680,
981,
8,
3937,
12,
922,
12,
5322,
12,
355,
1067,
29,
1100,
9,
339,
347,
2218,
8,
277,
12,
3920,
12,
922,
12,
2762,
12,
5322,
12,
1067,
29,
403,
304,
267,
340,
5322,
14,
362,
360,
600,
735,
288,
5322,
459,
600,
418,
275,
5322,
459,
600,
2278,
4142,
342,
267,
372,
1613,
8,
17393,
12,
291,
680,
952,
8,
3937,
12,
922,
12,
2762,
12,
5322,
12,
355,
1067,
29,
1100,
9,
421,
199,
533,
19453,
2448,
8,
4795,
14,
4795,
304,
272,
485,
1802,
628,
17393,
5611,
2,
272,
485,
354,
275,
283,
470,
14,
6063,
14,
923,
7,
272,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
985,
297,
1415,
29,
549,
395,
267,
283,
6063,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
470,
14,
6063,
297,
283,
470
] |
[
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,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
420,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
199,
318,
2909,
63,
354,
63,
1733,
8,
277,
12,
2467,
12,
922,
12,
536,
4581,
1249,
29,
403,
12,
4182,
534,
27774,
297,
586,
1067,
29,
403,
12,
2304,
29,
1960,
304,
272,
340,
440,
1249,
26,
267,
1249,
275,
942,
339,
2762,
275,
942,
272,
340,
822,
8,
354,
9,
508,
499,
26,
267,
2762,
275,
291,
14,
1733,
8,
1556,
12,
922,
12,
4274,
600,
297,
283,
27774,
297,
536,
1874,
435,
1249,
12,
2079,
2304,
29,
3097,
12,
1067,
29,
1100,
9,
339,
2754,
63,
2261,
275,
4274,
354,
297,
4182,
12,
536,
1874,
272,
340,
2762,
26,
2754,
63,
2261,
14,
740,
4725,
344,
297,
283,
1397,
315,
297,
2762,
430,
272,
2762,
14,
2880,
8,
277,
14,
1733,
8,
1556,
12,
922,
12,
2754,
63,
2261,
435,
1249,
12,
2574,
2304,
29,
3097,
12,
1067,
29,
1100,
430,
339,
9918,
275,
291,
14,
354,
63,
362,
8,
1556,
12,
922,
12,
2762,
12,
1067,
9,
272,
372,
3355,
8,
8022,
12,
790,
29,
2734,
334,
344,
12,
536,
304,
2762,
14,
1080,
8,
344,
430,
199,
199,
533,
19453,
8,
4795,
14,
4795,
304,
272,
485,
354,
275,
283,
470,
14,
6063,
7,
272,
485,
1802,
275,
283,
17393,
7,
272,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
17393,
2812,
297,
288,
1720,
534,
1918,
2615,
536,
402,
314,
9023,
3130,
1415,
29,
549,
12,
9028,
29,
549,
395,
267,
283,
600,
356,
1504,
14,
1560,
360,
17393,
5495,
297,
1568,
29,
18,
12,
288,
1720,
534,
1918,
9055,
9023,
1233,
315,
2877,
8365,
3134,
78,
7,
288,
283,
5556,
883,
675,
642,
901,
367,
12530,
2754,
8038,
267,
283,
1562,
63,
908,
356,
1504,
14,
505,
360,
1476,
9701,
297,
1720,
11916,
5556,
883,
1174,
2348,
314,
20195,
1475,
370,
675,
367,
314,
971,
199,
7423,
30226,
370,
642,
9023,
3134,
78,
60,
78,
5556,
883,
675,
314,
2366,
13,
2487,
1059,
299,
23825,
543,
1006,
314,
901,
402,
314,
2287,
971,
199,
8,
509,
2893,
12,
675,
9487,
20451,
9,
83,
7,
370,
2929,
314,
901,
283,
20451,
358,
12254,
288,
971,
78,
2840,
929,
63,
354,
9,
83,
26,
314,
536,
402,
314,
1174,
288,
971,
78,
2840,
929,
63,
600,
9,
83,
26,
314,
1233,
402,
314,
1174,
288,
971,
78,
2840,
6063,
63,
354,
9,
83,
26,
314,
536,
402,
314,
9023,
288,
971,
78,
2840,
6063,
63,
600,
9,
83,
26,
314,
1233,
402,
314,
9023,
624,
395,
267,
283,
4968,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
470,
14,
4968,
297,
283,
19567,
659,
267,
283,
1569,
356,
1504,
14,
3008,
480,
3491,
1288,
267,
283,
6063,
63,
923,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
470,
14,
6063,
14,
923,
297,
283,
470,
63,
6063,
63,
470,
63,
6063,
63,
923,
63,
3369,
297,
283,
470,
63,
6063,
63,
344,
297,
283,
470,
63,
6063,
63,
923,
63,
344,
297,
1059,
534,
17393,
25031,
659,
272,
789,
272,
485,
3009,
63,
9882,
275,
359,
267,
661,
354,
63,
22484,
297,
283,
3235,
334,
354,
3196,
288,
283,
1918,
536,
402,
314,
9023,
1471,
506,
3747,
8546,
659,
267,
661,
600,
63,
22484,
297,
283,
3235,
334,
600,
3196,
288,
283,
1918,
1233,
402,
314,
9023,
1471,
506,
3747,
8546,
358,
272,
1622,
272,
485,
4322,
275,
469,
267,
283,
1562,
63,
908,
356,
11792,
20451,
9,
83,
60,
78,
2840,
20451,
18,
9,
83,
60,
78,
2840,
3690,
9,
83,
2818,
929,
63,
600,
9,
83,
2818,
3065,
9,
83,
60,
78,
2840,
6063,
63,
354,
9,
83,
401,
272,
789,
272,
485,
1648,
534,
354,
7,
339,
536,
63,
1733,
275,
2909,
63,
354,
63,
1733,
339,
347,
1218,
8,
277,
12,
3920,
12,
922,
12,
5322,
12,
1067,
29,
403,
304,
267,
340,
5322,
14,
362,
360,
600,
735,
288,
5322,
459,
600,
418,
275,
5322,
459,
600,
2278,
4142,
342,
267,
372,
1613,
8,
17393,
12,
291,
680,
981,
8,
3937,
12,
922,
12,
5322,
12,
355,
1067,
29,
1100,
9,
339,
347,
2218,
8,
277,
12,
3920,
12,
922,
12,
2762,
12,
5322,
12,
1067,
29,
403,
304,
267,
340,
5322,
14,
362,
360,
600,
735,
288,
5322,
459,
600,
418,
275,
5322,
459,
600,
2278,
4142,
342,
267,
372,
1613,
8,
17393,
12,
291,
680,
952,
8,
3937,
12,
922,
12,
2762,
12,
5322,
12,
355,
1067,
29,
1100,
9,
421,
199,
533,
19453,
2448,
8,
4795,
14,
4795,
304,
272,
485,
1802,
628,
17393,
5611,
2,
272,
485,
354,
275,
283,
470,
14,
6063,
14,
923,
7,
272,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
985,
297,
1415,
29,
549,
395,
267,
283,
6063,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
470,
14,
6063,
297,
283,
470,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
seaotterman/tensorflow
|
tensorflow/contrib/linear_optimizer/python/sdca_optimizer.py
|
75
|
11131
|
"""Linear Estimators."""
# 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.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.contrib import layers
from tensorflow.contrib.linear_optimizer.python.ops import sdca_ops
from tensorflow.contrib.linear_optimizer.python.ops.sparse_feature_column import SparseFeatureColumn
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import math_ops
# TODO(sibyl-vie3Poto, sibyl-Aix6ihai): Add proper testing to this wrapper once the API is
# stable.
class SDCAOptimizer(object):
"""Wrapper class for SDCA optimizer.
The wrapper is currently meant for use as an optimizer within a tf.learn
Estimator.
Example usage:
```python
real_feature_column = real_valued_column(...)
sparse_feature_column = sparse_column_with_hash_bucket(...)
sdca_optimizer = linear.SDCAOptimizer(example_id_column='example_id',
num_loss_partitions=1,
num_table_shards=1,
symmetric_l2_regularization=2.0)
classifier = tf.contrib.learn.LinearClassifier(
feature_columns=[real_feature_column, sparse_feature_column],
weight_column_name=...,
optimizer=sdca_optimizer)
classifier.fit(input_fn_train, steps=50)
classifier.evaluate(input_fn=input_fn_eval)
```
Here the expectation is that the `input_fn_*` functions passed to train and
evaluate return a pair (dict, label_tensor) where dict has `example_id_column`
as `key` whose value is a `Tensor` of shape [batch_size] and dtype string.
num_loss_partitions defines the number of partitions of the global loss
function and should be set to `(#concurrent train ops/per worker)
x (#workers)`.
Convergence of (global) loss is guaranteed if `num_loss_partitions` is larger
or equal to the above product. Larger values for `num_loss_partitions` lead to
slower convergence. The recommended value for `num_loss_partitions` in
`tf.learn` (where currently there is one process per worker) is the number
of workers running the train steps. It defaults to 1 (single machine).
`num_table_shards` defines the number of shards for the internal state
table, typically set to match the number of parameter servers for large
data sets.
"""
def __init__(self,
example_id_column,
num_loss_partitions=1,
num_table_shards=None,
symmetric_l1_regularization=0.0,
symmetric_l2_regularization=1.0):
self._example_id_column = example_id_column
self._num_loss_partitions = num_loss_partitions
self._num_table_shards = num_table_shards
self._symmetric_l1_regularization = symmetric_l1_regularization
self._symmetric_l2_regularization = symmetric_l2_regularization
def get_name(self):
return 'SDCAOptimizer'
@property
def example_id_column(self):
return self._example_id_column
@property
def num_loss_partitions(self):
return self._num_loss_partitions
@property
def num_table_shards(self):
return self._num_table_shards
@property
def symmetric_l1_regularization(self):
return self._symmetric_l1_regularization
@property
def symmetric_l2_regularization(self):
return self._symmetric_l2_regularization
def get_train_step(self, columns_to_variables, weight_column_name, loss_type,
features, targets, global_step):
"""Returns the training operation of an SdcaModel optimizer."""
def _dense_tensor_to_sparse_feature_column(dense_tensor):
"""Returns SparseFeatureColumn for the input dense_tensor."""
ignore_value = 0.0
sparse_indices = array_ops.where(
math_ops.not_equal(dense_tensor,
math_ops.cast(ignore_value, dense_tensor.dtype)))
sparse_values = array_ops.gather_nd(dense_tensor, sparse_indices)
# TODO(sibyl-Aix6ihai, sibyl-vie3Poto): Makes this efficient, as now SDCA supports
# very sparse features with weights and not weights.
return SparseFeatureColumn(
array_ops.reshape(
array_ops.split(
value=sparse_indices, num_or_size_splits=2, axis=1)[0], [-1]),
array_ops.reshape(
array_ops.split(
value=sparse_indices, num_or_size_splits=2, axis=1)[1], [-1]),
array_ops.reshape(math_ops.to_float(sparse_values), [-1]))
def _training_examples_and_variables():
"""Returns dictionaries for training examples and variables."""
batch_size = targets.get_shape()[0]
# Iterate over all feature columns and create appropriate lists for dense
# and sparse features as well as dense and sparse weights (variables) for
# SDCA.
# TODO(sibyl-vie3Poto): Reshape variables stored as values in column_to_variables
# dict as 1-dimensional tensors.
dense_features, sparse_features, sparse_feature_with_values = [], [], []
dense_feature_weights = []
sparse_feature_weights, sparse_feature_with_values_weights = [], []
for column in sorted(columns_to_variables.keys(), key=lambda x: x.key):
transformed_tensor = features[column]
if isinstance(column, layers.feature_column._RealValuedColumn): # pylint: disable=protected-access
# A real-valued column corresponds to a dense feature in SDCA. A
# transformed tensor corresponding to a RealValuedColumn should have
# rank at most 2. In order to be passed to SDCA, its rank needs to be
# exactly 2 (i.e., its shape should be [batch_size, column.dim]).
check_rank_op = control_flow_ops.Assert(
math_ops.less_equal(array_ops.rank(transformed_tensor), 2),
['transformed_tensor shouls have rank at most 2.'])
# Reshape to [batch_size, dense_column_dimension].
with ops.control_dependencies([check_rank_op]):
transformed_tensor = array_ops.reshape(transformed_tensor, [
array_ops.shape(transformed_tensor)[0], -1
])
dense_features.append(transformed_tensor)
# For real valued columns, the variables list contains exactly one
# element.
dense_feature_weights.append(columns_to_variables[column][0])
elif isinstance(column, layers.feature_column._BucketizedColumn): # pylint: disable=protected-access
# A bucketized column corresponds to a sparse feature in SDCA. The
# bucketized feature is "sparsified" for SDCA by converting it to a
# SparseFeatureColumn respresenting the one-hot encoding of the
# bucketized feature.
#
# TODO(sibyl-vie3Poto): Explore whether it is more efficient to translate a
# bucketized feature column to a dense feature in SDCA. This will
# likely depend on the number of buckets.
dense_bucket_tensor = column._to_dnn_input_layer(transformed_tensor) # pylint: disable=protected-access
sparse_feature_column = _dense_tensor_to_sparse_feature_column(
dense_bucket_tensor)
sparse_feature_with_values.append(sparse_feature_column)
# For bucketized columns, the variables list contains exactly one
# element.
sparse_feature_with_values_weights.append(
columns_to_variables[column][0])
elif isinstance(
column,
(
layers.feature_column._CrossedColumn, # pylint: disable=protected-access
layers.feature_column._SparseColumn)): # pylint: disable=protected-access
sparse_features.append(
SparseFeatureColumn(
array_ops.reshape(
array_ops.split(
value=transformed_tensor.indices,
num_or_size_splits=2,
axis=1)[0], [-1]),
array_ops.reshape(transformed_tensor.values, [-1]), None))
sparse_feature_weights.append(columns_to_variables[column][0])
elif isinstance(column, layers.feature_column._WeightedSparseColumn): # pylint: disable=protected-access
id_tensor = column.id_tensor(transformed_tensor)
weight_tensor = column.weight_tensor(transformed_tensor)
sparse_feature_with_values.append(
SparseFeatureColumn(
array_ops.reshape(
array_ops.split(
value=id_tensor.indices, num_or_size_splits=2, axis=1)
[0], [-1]),
array_ops.reshape(id_tensor.values, [-1]),
array_ops.reshape(weight_tensor.values, [-1])))
sparse_feature_with_values_weights.append(
columns_to_variables[column][0])
else:
raise ValueError('SDCAOptimizer does not support column type %s.' %
type(column).__name__)
example_weights = array_ops.reshape(
features[weight_column_name],
shape=[-1]) if weight_column_name else array_ops.ones([batch_size])
example_ids = features[self._example_id_column]
sparse_feature_with_values.extend(sparse_features)
sparse_feature_with_values_weights.extend(sparse_feature_weights)
examples = dict(
sparse_features=sparse_feature_with_values,
dense_features=dense_features,
example_labels=math_ops.to_float(
array_ops.reshape(targets, shape=[-1])),
example_weights=example_weights,
example_ids=example_ids)
sdca_variables = dict(
sparse_features_weights=sparse_feature_with_values_weights,
dense_features_weights=dense_feature_weights)
return examples, sdca_variables
training_examples, training_variables = _training_examples_and_variables()
sdca_model = sdca_ops.SdcaModel(
examples=training_examples,
variables=training_variables,
options=dict(
symmetric_l1_regularization=self._symmetric_l1_regularization,
symmetric_l2_regularization=self._symmetric_l2_regularization,
num_loss_partitions=self._num_loss_partitions,
num_table_shards=self._num_table_shards,
loss_type=loss_type))
train_op = sdca_model.minimize(global_step=global_step)
return sdca_model, train_op
|
apache-2.0
|
[
624,
10608,
15896,
9095,
1041,
199,
3,
221,
1898,
6900,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
221,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
221,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
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,
221,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
221,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
221,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
221,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
221,
4204,
1334,
314,
844,
14,
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,
504,
3228,
14,
2828,
492,
9393,
199,
504,
3228,
14,
2828,
14,
6676,
63,
12290,
14,
1548,
14,
1483,
492,
14613,
696,
63,
1483,
199,
504,
3228,
14,
2828,
14,
6676,
63,
12290,
14,
1548,
14,
1483,
14,
4421,
63,
4445,
63,
2301,
492,
14531,
5968,
4547,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3304,
63,
1659,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3473,
63,
1483,
421,
199,
3,
3254,
8,
338,
991,
76,
13,
6620,
19,
48,
3459,
12,
13877,
991,
76,
13,
33,
1148,
22,
73,
17945,
304,
2654,
5576,
5343,
370,
642,
4975,
5403,
314,
3261,
365,
199,
3,
17830,
14,
199,
533,
428,
36,
3263,
13946,
8,
785,
304,
523,
408,
4590,
1021,
367,
428,
36,
3263,
10736,
14,
819,
710,
4975,
365,
5544,
18329,
367,
675,
465,
376,
10736,
4453,
282,
2833,
14,
4643,
523,
28992,
14,
819,
5679,
4503,
26,
819,
10841,
1548,
272,
3363,
63,
4445,
63,
2301,
275,
3363,
63,
16611,
63,
2301,
20186,
272,
5178,
63,
4445,
63,
2301,
275,
5178,
63,
2301,
63,
1045,
63,
2227,
63,
4623,
20186,
272,
14613,
696,
63,
12290,
275,
7798,
14,
3693,
3263,
13946,
8,
2694,
63,
344,
63,
2301,
534,
2694,
63,
344,
297,
5101,
1967,
63,
4358,
63,
12553,
29,
17,
12,
5101,
1967,
63,
1224,
63,
15570,
29,
17,
12,
5101,
16371,
63,
76,
18,
63,
18948,
29,
18,
14,
16,
9,
272,
12429,
275,
2833,
14,
2828,
14,
4643,
14,
10608,
8508,
8,
267,
3878,
63,
3406,
1524,
3093,
63,
4445,
63,
2301,
12,
5178,
63,
4445,
63,
2301,
467,
267,
5401,
63,
2301,
63,
354,
29,
11577,
267,
10736,
29,
3893,
696,
63,
12290,
9,
272,
12429,
14,
3269,
8,
1210,
63,
2324,
63,
2834,
12,
7124,
29,
1400,
9,
272,
12429,
14,
7383,
8,
1210,
63,
2324,
29,
1210,
63,
2324,
63,
2579,
9,
523,
10841,
819,
11842,
314,
17513,
365,
626,
314,
658,
1210,
63,
2324,
15192,
64,
3423,
3032,
370,
3560,
436,
523,
9352,
372,
282,
4092,
334,
807,
12,
1768,
63,
3128,
9,
2382,
1211,
965,
658,
2694,
63,
344,
63,
2301,
64,
523,
465,
658,
498,
64,
7447,
574,
365,
282,
658,
3861,
64,
402,
2215,
359,
2912,
63,
890,
61,
436,
2152,
1059,
14,
523,
1967,
63,
4358,
63,
12553,
7890,
314,
1329,
402,
16394,
402,
314,
2288,
5621,
523,
805,
436,
1077,
506,
663,
370,
16918,
3,
27237,
3560,
4156,
15,
529,
7239,
9,
523,
671,
15196,
11009,
20414,
523,
11801,
10925,
402,
334,
2966,
9,
5621,
365,
17334,
340,
658,
1507,
63,
4358,
63,
12553,
64,
365,
12142,
523,
503,
4472,
370,
314,
3432,
3336,
14,
491,
285,
836,
1338,
367,
658,
1507,
63,
4358,
63,
12553,
64,
12690,
370,
523,
26200,
21346,
14,
710,
14318,
574,
367,
658,
1507,
63,
4358,
63,
12553,
64,
315,
523,
658,
3249,
14,
4643,
64,
334,
4509,
5544,
2337,
365,
1373,
2112,
1126,
7239,
9,
365,
314,
1329,
523,
402,
14123,
3879,
314,
3560,
7124,
14,
2779,
4243,
370,
413,
334,
4780,
6844,
680,
523,
658,
1507,
63,
1224,
63,
15570,
64,
7890,
314,
1329,
402,
24130,
367,
314,
5007,
1174,
523,
1817,
12,
13609,
663,
370,
1336,
314,
1329,
402,
2725,
8037,
367,
7031,
523,
666,
5951,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
2049,
2893,
63,
344,
63,
2301,
12,
2049,
1967,
63,
4358,
63,
12553,
29,
17,
12,
2049,
1967,
63,
1224,
63,
15570,
29,
403,
12,
2049,
16371,
63,
76,
17,
63,
18948,
29,
16,
14,
16,
12,
2049,
16371,
63,
76,
18,
63,
18948,
29,
17,
14,
16,
304,
272,
291,
423,
2694,
63,
344,
63,
2301,
275,
2893,
63,
344,
63,
2301,
272,
291,
423,
1507,
63,
4358,
63,
12553,
275,
1967,
63,
4358,
63,
12553,
272,
291,
423,
1507,
63,
1224,
63,
15570,
275,
1967,
63,
1224,
63,
15570,
272,
291,
423,
18422,
63,
76,
17,
63,
18948,
275,
16371,
63,
76,
17,
63,
18948,
272,
291,
423,
18422,
63,
76,
18,
63,
18948,
275,
16371,
63,
76,
18,
63,
18948,
819,
347,
664,
63,
354,
8,
277,
304,
272,
372,
283,
3693,
3263,
13946,
7,
819,
768,
1829,
523,
347,
2893,
63,
344,
63,
2301,
8,
277,
304,
272,
372,
291,
423,
2694,
63,
344,
63,
2301,
819,
768,
1829,
523,
347,
1967,
63,
4358,
63,
12553,
8,
277,
304,
272,
372,
291,
423,
1507,
63,
4358,
63,
12553,
819,
768,
1829,
523,
347,
1967,
63,
1224,
63,
15570,
8,
277,
304,
272,
372,
291,
423,
1507,
63,
1224,
63,
15570,
819,
768,
1829,
523,
347,
16371,
63,
76,
17,
63,
18948,
8,
277,
304,
272,
372,
291,
423,
18422,
63,
76,
17,
63,
18948,
819,
768,
1829,
523,
347,
16371,
63,
76,
18,
63,
18948,
8,
277,
304,
272,
372,
291,
423,
18422,
63,
76,
18,
63,
18948,
819,
347,
664,
63,
2834,
63,
2926,
8,
277,
12,
4362,
63,
475,
63,
3669,
12,
5401,
63,
2301
] |
[
10608,
15896,
9095,
1041,
199,
3,
221,
1898,
6900,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
221,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
221,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
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,
221,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
221,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
221,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
221,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
221,
4204,
1334,
314,
844,
14,
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,
504,
3228,
14,
2828,
492,
9393,
199,
504,
3228,
14,
2828,
14,
6676,
63,
12290,
14,
1548,
14,
1483,
492,
14613,
696,
63,
1483,
199,
504,
3228,
14,
2828,
14,
6676,
63,
12290,
14,
1548,
14,
1483,
14,
4421,
63,
4445,
63,
2301,
492,
14531,
5968,
4547,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3304,
63,
1659,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3473,
63,
1483,
421,
199,
3,
3254,
8,
338,
991,
76,
13,
6620,
19,
48,
3459,
12,
13877,
991,
76,
13,
33,
1148,
22,
73,
17945,
304,
2654,
5576,
5343,
370,
642,
4975,
5403,
314,
3261,
365,
199,
3,
17830,
14,
199,
533,
428,
36,
3263,
13946,
8,
785,
304,
523,
408,
4590,
1021,
367,
428,
36,
3263,
10736,
14,
819,
710,
4975,
365,
5544,
18329,
367,
675,
465,
376,
10736,
4453,
282,
2833,
14,
4643,
523,
28992,
14,
819,
5679,
4503,
26,
819,
10841,
1548,
272,
3363,
63,
4445,
63,
2301,
275,
3363,
63,
16611,
63,
2301,
20186,
272,
5178,
63,
4445,
63,
2301,
275,
5178,
63,
2301,
63,
1045,
63,
2227,
63,
4623,
20186,
272,
14613,
696,
63,
12290,
275,
7798,
14,
3693,
3263,
13946,
8,
2694,
63,
344,
63,
2301,
534,
2694,
63,
344,
297,
5101,
1967,
63,
4358,
63,
12553,
29,
17,
12,
5101,
1967,
63,
1224,
63,
15570,
29,
17,
12,
5101,
16371,
63,
76,
18,
63,
18948,
29,
18,
14,
16,
9,
272,
12429,
275,
2833,
14,
2828,
14,
4643,
14,
10608,
8508,
8,
267,
3878,
63,
3406,
1524,
3093,
63,
4445,
63,
2301,
12,
5178,
63,
4445,
63,
2301,
467,
267,
5401,
63,
2301,
63,
354,
29,
11577,
267,
10736,
29,
3893,
696,
63,
12290,
9,
272,
12429,
14,
3269,
8,
1210,
63,
2324,
63,
2834,
12,
7124,
29,
1400,
9,
272,
12429,
14,
7383,
8,
1210,
63,
2324,
29,
1210,
63,
2324,
63,
2579,
9,
523,
10841,
819,
11842,
314,
17513,
365,
626,
314,
658,
1210,
63,
2324,
15192,
64,
3423,
3032,
370,
3560,
436,
523,
9352,
372,
282,
4092,
334,
807,
12,
1768,
63,
3128,
9,
2382,
1211,
965,
658,
2694,
63,
344,
63,
2301,
64,
523,
465,
658,
498,
64,
7447,
574,
365,
282,
658,
3861,
64,
402,
2215,
359,
2912,
63,
890,
61,
436,
2152,
1059,
14,
523,
1967,
63,
4358,
63,
12553,
7890,
314,
1329,
402,
16394,
402,
314,
2288,
5621,
523,
805,
436,
1077,
506,
663,
370,
16918,
3,
27237,
3560,
4156,
15,
529,
7239,
9,
523,
671,
15196,
11009,
20414,
523,
11801,
10925,
402,
334,
2966,
9,
5621,
365,
17334,
340,
658,
1507,
63,
4358,
63,
12553,
64,
365,
12142,
523,
503,
4472,
370,
314,
3432,
3336,
14,
491,
285,
836,
1338,
367,
658,
1507,
63,
4358,
63,
12553,
64,
12690,
370,
523,
26200,
21346,
14,
710,
14318,
574,
367,
658,
1507,
63,
4358,
63,
12553,
64,
315,
523,
658,
3249,
14,
4643,
64,
334,
4509,
5544,
2337,
365,
1373,
2112,
1126,
7239,
9,
365,
314,
1329,
523,
402,
14123,
3879,
314,
3560,
7124,
14,
2779,
4243,
370,
413,
334,
4780,
6844,
680,
523,
658,
1507,
63,
1224,
63,
15570,
64,
7890,
314,
1329,
402,
24130,
367,
314,
5007,
1174,
523,
1817,
12,
13609,
663,
370,
1336,
314,
1329,
402,
2725,
8037,
367,
7031,
523,
666,
5951,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
2049,
2893,
63,
344,
63,
2301,
12,
2049,
1967,
63,
4358,
63,
12553,
29,
17,
12,
2049,
1967,
63,
1224,
63,
15570,
29,
403,
12,
2049,
16371,
63,
76,
17,
63,
18948,
29,
16,
14,
16,
12,
2049,
16371,
63,
76,
18,
63,
18948,
29,
17,
14,
16,
304,
272,
291,
423,
2694,
63,
344,
63,
2301,
275,
2893,
63,
344,
63,
2301,
272,
291,
423,
1507,
63,
4358,
63,
12553,
275,
1967,
63,
4358,
63,
12553,
272,
291,
423,
1507,
63,
1224,
63,
15570,
275,
1967,
63,
1224,
63,
15570,
272,
291,
423,
18422,
63,
76,
17,
63,
18948,
275,
16371,
63,
76,
17,
63,
18948,
272,
291,
423,
18422,
63,
76,
18,
63,
18948,
275,
16371,
63,
76,
18,
63,
18948,
819,
347,
664,
63,
354,
8,
277,
304,
272,
372,
283,
3693,
3263,
13946,
7,
819,
768,
1829,
523,
347,
2893,
63,
344,
63,
2301,
8,
277,
304,
272,
372,
291,
423,
2694,
63,
344,
63,
2301,
819,
768,
1829,
523,
347,
1967,
63,
4358,
63,
12553,
8,
277,
304,
272,
372,
291,
423,
1507,
63,
4358,
63,
12553,
819,
768,
1829,
523,
347,
1967,
63,
1224,
63,
15570,
8,
277,
304,
272,
372,
291,
423,
1507,
63,
1224,
63,
15570,
819,
768,
1829,
523,
347,
16371,
63,
76,
17,
63,
18948,
8,
277,
304,
272,
372,
291,
423,
18422,
63,
76,
17,
63,
18948,
819,
768,
1829,
523,
347,
16371,
63,
76,
18,
63,
18948,
8,
277,
304,
272,
372,
291,
423,
18422,
63,
76,
18,
63,
18948,
819,
347,
664,
63,
2834,
63,
2926,
8,
277,
12,
4362,
63,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
slisson/intellij-community
|
python/lib/Lib/encodings/undefined.py
|
860
|
1299
|
""" Python 'undefined' Codec
This codec will always raise a ValueError exception when being
used. It is intended for use by the site.py file to switch off
automatic string to Unicode coercion.
Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""
import codecs
### Codec APIs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
raise UnicodeError("undefined encoding")
def decode(self,input,errors='strict'):
raise UnicodeError("undefined encoding")
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
raise UnicodeError("undefined encoding")
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
raise UnicodeError("undefined encoding")
class StreamWriter(Codec,codecs.StreamWriter):
pass
class StreamReader(Codec,codecs.StreamReader):
pass
### encodings module API
def getregentry():
return codecs.CodecInfo(
name='undefined',
encode=Codec().encode,
decode=Codec().decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamwriter=StreamWriter,
streamreader=StreamReader,
)
|
apache-2.0
|
[
624,
2018,
283,
10705,
7,
13732,
339,
961,
9076,
911,
3544,
746,
282,
1722,
1919,
1380,
3769,
272,
1202,
14,
2779,
365,
11619,
367,
675,
701,
314,
4770,
14,
647,
570,
370,
6258,
2331,
272,
4834,
1059,
370,
6140,
32021,
14,
199,
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,
199,
646,
6010,
199,
199,
5680,
13732,
15913,
199,
199,
533,
13732,
8,
8933,
14,
8818,
304,
339,
347,
3752,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
746,
20872,
480,
10705,
2644,
531,
339,
347,
4849,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
746,
20872,
480,
10705,
2644,
531,
199,
199,
533,
24350,
8,
8933,
14,
17016,
304,
272,
347,
3752,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
746,
20872,
480,
10705,
2644,
531,
199,
199,
533,
24385,
8,
8933,
14,
16703,
304,
272,
347,
4849,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
746,
20872,
480,
10705,
2644,
531,
199,
199,
533,
24163,
8,
8818,
12,
8933,
14,
16551,
304,
272,
986,
199,
199,
533,
22970,
8,
8818,
12,
8933,
14,
16132,
304,
272,
986,
199,
199,
5680,
14134,
859,
3261,
199,
199,
318,
26116,
837,
272,
372,
6010,
14,
26375,
8,
267,
536,
534,
10705,
297,
267,
3752,
29,
8818,
1252,
2143,
12,
267,
4849,
29,
8818,
1252,
2708,
12,
267,
26329,
29,
17016,
12,
267,
26317,
29,
16703,
12,
267,
26112,
29,
16551,
12,
267,
26101,
29,
16132,
12,
272,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2018,
283,
10705,
7,
13732,
339,
961,
9076,
911,
3544,
746,
282,
1722,
1919,
1380,
3769,
272,
1202,
14,
2779,
365,
11619,
367,
675,
701,
314,
4770,
14,
647,
570,
370,
6258,
2331,
272,
4834,
1059,
370,
6140,
32021,
14,
199,
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,
199,
646,
6010,
199,
199,
5680,
13732,
15913,
199,
199,
533,
13732,
8,
8933,
14,
8818,
304,
339,
347,
3752,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
746,
20872,
480,
10705,
2644,
531,
339,
347,
4849,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
746,
20872,
480,
10705,
2644,
531,
199,
199,
533,
24350,
8,
8933,
14,
17016,
304,
272,
347,
3752,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
746,
20872,
480,
10705,
2644,
531,
199,
199,
533,
24385,
8,
8933,
14,
16703,
304,
272,
347,
4849,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
746,
20872,
480,
10705,
2644,
531,
199,
199,
533,
24163,
8,
8818,
12,
8933,
14,
16551,
304,
272,
986,
199,
199,
533,
22970,
8,
8818,
12,
8933,
14,
16132,
304,
272,
986,
199,
199,
5680,
14134,
859,
3261,
199,
199,
318,
26116,
837,
272,
372,
6010,
14,
26375,
8,
267,
536,
534,
10705,
297,
267,
3752,
29,
8818,
1252,
2143,
12,
267,
4849,
29,
8818,
1252,
2708,
12,
267,
26329,
29,
17016,
12,
267,
26317,
29,
16703,
12,
267,
26112,
29,
16551,
12,
267,
26101,
29,
16132,
12,
272,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0
] |
kongseokhwan/kulcloud-iitp-neutron
|
neutron/db/migration/alembic_migrations/env.py
|
15
|
2997
|
# Copyright 2012 New Dream Network, LLC (DreamHost)
#
# 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 logging import config as logging_config
from alembic import context
from oslo_config import cfg
from oslo_db.sqlalchemy import session
import sqlalchemy as sa
from sqlalchemy import event
from neutron.db.migration.models import head # noqa
from neutron.db import model_base
MYSQL_ENGINE = None
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
neutron_config = config.neutron_config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
logging_config.fileConfig(config.config_file_name)
# set the target for 'autogenerate' support
target_metadata = model_base.BASEV2.metadata
def set_mysql_engine():
try:
mysql_engine = neutron_config.command.mysql_engine
except cfg.NoSuchOptError:
mysql_engine = None
global MYSQL_ENGINE
MYSQL_ENGINE = (mysql_engine or
model_base.BASEV2.__table_args__['mysql_engine'])
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with either a URL
or an Engine.
Calls to context.execute() here emit the given string to the
script output.
"""
set_mysql_engine()
kwargs = dict()
if neutron_config.database.connection:
kwargs['url'] = neutron_config.database.connection
else:
kwargs['dialect_name'] = neutron_config.database.engine
context.configure(**kwargs)
with context.begin_transaction():
context.run_migrations()
@event.listens_for(sa.Table, 'after_parent_attach')
def set_storage_engine(target, parent):
if MYSQL_ENGINE:
target.kwargs['mysql_engine'] = MYSQL_ENGINE
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
set_mysql_engine()
engine = session.create_engine(neutron_config.database.connection)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
engine.dispose()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
|
apache-2.0
|
[
3,
1898,
6029,
7053,
577,
1091,
7220,
12,
20376,
334,
36,
1091,
4965,
9,
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,
2050,
492,
1101,
465,
2050,
63,
888,
199,
199,
504,
30960,
20596,
492,
1067,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
697,
14,
14536,
492,
2351,
199,
646,
8335,
465,
2937,
199,
504,
8335,
492,
1566,
199,
199,
504,
8224,
14,
697,
14,
8998,
14,
992,
492,
4854,
221,
327,
8151,
199,
504,
8224,
14,
697,
492,
1402,
63,
1095,
421,
199,
12339,
4657,
63,
15956,
275,
488,
199,
199,
3,
642,
365,
314,
6832,
20596,
4094,
909,
12,
1314,
6571,
199,
3,
2879,
370,
314,
1338,
4453,
314,
1275,
2730,
570,
315,
675,
14,
199,
888,
275,
1067,
14,
888,
199,
10271,
63,
888,
275,
1101,
14,
10271,
63,
888,
199,
199,
3,
6551,
25133,
314,
1101,
570,
367,
2018,
2050,
14,
199,
3,
961,
1004,
5951,
1536,
23445,
26014,
14,
199,
4806,
63,
888,
14,
493,
2028,
8,
888,
14,
888,
63,
493,
63,
354,
9,
199,
199,
3,
663,
314,
1347,
367,
283,
6898,
974,
22978,
7,
2291,
199,
1375,
63,
2343,
275,
1402,
63,
1095,
14,
5825,
54,
18,
14,
2343,
421,
199,
318,
663,
63,
8644,
63,
3908,
837,
272,
862,
26,
267,
12896,
63,
3908,
275,
8224,
63,
888,
14,
1531,
14,
8644,
63,
3908,
272,
871,
4810,
14,
30049,
9985,
547,
26,
267,
12896,
63,
3908,
275,
488,
339,
2288,
603,
57,
4657,
63,
15956,
272,
603,
57,
4657,
63,
15956,
275,
334,
8644,
63,
3908,
503,
490,
1402,
63,
1095,
14,
5825,
54,
18,
855,
1224,
63,
589,
23010,
8644,
63,
3908,
1105,
421,
199,
318,
1255,
63,
7685,
63,
18430,
837,
272,
408,
2540,
6180,
315,
283,
18430,
7,
818,
14,
339,
961,
1101,
1482,
314,
1067,
543,
1902,
282,
2851,
272,
503,
376,
12580,
14,
339,
28055,
370,
1067,
14,
2526,
342,
2348,
8689,
314,
1627,
1059,
370,
314,
272,
2884,
1072,
14,
339,
408,
272,
663,
63,
8644,
63,
3908,
342,
339,
2074,
275,
1211,
342,
272,
340,
8224,
63,
888,
14,
4659,
14,
2105,
26,
267,
2074,
459,
633,
418,
275,
8224,
63,
888,
14,
4659,
14,
2105,
272,
587,
26,
267,
2074,
459,
11072,
63,
354,
418,
275,
8224,
63,
888,
14,
4659,
14,
3908,
272,
1067,
14,
6472,
3682,
958,
9,
339,
543,
1067,
14,
5037,
63,
5945,
837,
267,
1067,
14,
1065,
63,
7685,
342,
421,
199,
32,
1430,
14,
317,
1597,
561,
63,
509,
8,
2231,
14,
3186,
12,
283,
4399,
63,
1708,
63,
5040,
358,
199,
318,
663,
63,
3494,
63,
3908,
8,
1375,
12,
1676,
304,
272,
340,
603,
57,
4657,
63,
15956,
26,
267,
1347,
14,
958,
459,
8644,
63,
3908,
418,
275,
603,
57,
4657,
63,
15956,
421,
199,
318,
1255,
63,
7685,
63,
15178,
837,
272,
408,
2540,
6180,
315,
283,
15178,
7,
818,
14,
339,
1010,
642,
15728,
781,
1929,
370,
1218,
376,
12580,
272,
436,
20133,
282,
1950,
543,
314,
1067,
14,
339,
408,
272,
663,
63,
8644,
63,
3908,
342,
272,
6869,
275,
2351,
14,
981,
63,
3908,
8,
10271,
63,
888,
14,
4659,
14,
2105,
9,
339,
1950,
275,
6869,
14,
2242,
342,
272,
1067,
14,
6472,
8,
267,
1950,
29,
2105,
12,
267,
1347,
63,
2343,
29,
1375,
63,
2343,
272,
776,
339,
862,
26,
267,
543,
1067,
14,
5037,
63,
5945,
837,
288,
1067,
14,
1065,
63,
7685,
342,
272,
3753,
26,
267,
1950,
14,
1600,
342,
267,
6869,
14,
29842,
342,
421,
199,
692,
1067,
14,
374,
63,
18430,
63,
632,
837,
272,
1255,
63,
7685,
63,
18430,
342,
199,
2836,
26,
272,
1255,
63,
7685,
63,
15178,
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
] |
[
1898,
6029,
7053,
577,
1091,
7220,
12,
20376,
334,
36,
1091,
4965,
9,
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,
2050,
492,
1101,
465,
2050,
63,
888,
199,
199,
504,
30960,
20596,
492,
1067,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
697,
14,
14536,
492,
2351,
199,
646,
8335,
465,
2937,
199,
504,
8335,
492,
1566,
199,
199,
504,
8224,
14,
697,
14,
8998,
14,
992,
492,
4854,
221,
327,
8151,
199,
504,
8224,
14,
697,
492,
1402,
63,
1095,
421,
199,
12339,
4657,
63,
15956,
275,
488,
199,
199,
3,
642,
365,
314,
6832,
20596,
4094,
909,
12,
1314,
6571,
199,
3,
2879,
370,
314,
1338,
4453,
314,
1275,
2730,
570,
315,
675,
14,
199,
888,
275,
1067,
14,
888,
199,
10271,
63,
888,
275,
1101,
14,
10271,
63,
888,
199,
199,
3,
6551,
25133,
314,
1101,
570,
367,
2018,
2050,
14,
199,
3,
961,
1004,
5951,
1536,
23445,
26014,
14,
199,
4806,
63,
888,
14,
493,
2028,
8,
888,
14,
888,
63,
493,
63,
354,
9,
199,
199,
3,
663,
314,
1347,
367,
283,
6898,
974,
22978,
7,
2291,
199,
1375,
63,
2343,
275,
1402,
63,
1095,
14,
5825,
54,
18,
14,
2343,
421,
199,
318,
663,
63,
8644,
63,
3908,
837,
272,
862,
26,
267,
12896,
63,
3908,
275,
8224,
63,
888,
14,
1531,
14,
8644,
63,
3908,
272,
871,
4810,
14,
30049,
9985,
547,
26,
267,
12896,
63,
3908,
275,
488,
339,
2288,
603,
57,
4657,
63,
15956,
272,
603,
57,
4657,
63,
15956,
275,
334,
8644,
63,
3908,
503,
490,
1402,
63,
1095,
14,
5825,
54,
18,
855,
1224,
63,
589,
23010,
8644,
63,
3908,
1105,
421,
199,
318,
1255,
63,
7685,
63,
18430,
837,
272,
408,
2540,
6180,
315,
283,
18430,
7,
818,
14,
339,
961,
1101,
1482,
314,
1067,
543,
1902,
282,
2851,
272,
503,
376,
12580,
14,
339,
28055,
370,
1067,
14,
2526,
342,
2348,
8689,
314,
1627,
1059,
370,
314,
272,
2884,
1072,
14,
339,
408,
272,
663,
63,
8644,
63,
3908,
342,
339,
2074,
275,
1211,
342,
272,
340,
8224,
63,
888,
14,
4659,
14,
2105,
26,
267,
2074,
459,
633,
418,
275,
8224,
63,
888,
14,
4659,
14,
2105,
272,
587,
26,
267,
2074,
459,
11072,
63,
354,
418,
275,
8224,
63,
888,
14,
4659,
14,
3908,
272,
1067,
14,
6472,
3682,
958,
9,
339,
543,
1067,
14,
5037,
63,
5945,
837,
267,
1067,
14,
1065,
63,
7685,
342,
421,
199,
32,
1430,
14,
317,
1597,
561,
63,
509,
8,
2231,
14,
3186,
12,
283,
4399,
63,
1708,
63,
5040,
358,
199,
318,
663,
63,
3494,
63,
3908,
8,
1375,
12,
1676,
304,
272,
340,
603,
57,
4657,
63,
15956,
26,
267,
1347,
14,
958,
459,
8644,
63,
3908,
418,
275,
603,
57,
4657,
63,
15956,
421,
199,
318,
1255,
63,
7685,
63,
15178,
837,
272,
408,
2540,
6180,
315,
283,
15178,
7,
818,
14,
339,
1010,
642,
15728,
781,
1929,
370,
1218,
376,
12580,
272,
436,
20133,
282,
1950,
543,
314,
1067,
14,
339,
408,
272,
663,
63,
8644,
63,
3908,
342,
272,
6869,
275,
2351,
14,
981,
63,
3908,
8,
10271,
63,
888,
14,
4659,
14,
2105,
9,
339,
1950,
275,
6869,
14,
2242,
342,
272,
1067,
14,
6472,
8,
267,
1950,
29,
2105,
12,
267,
1347,
63,
2343,
29,
1375,
63,
2343,
272,
776,
339,
862,
26,
267,
543,
1067,
14,
5037,
63,
5945,
837,
288,
1067,
14,
1065,
63,
7685,
342,
272,
3753,
26,
267,
1950,
14,
1600,
342,
267,
6869,
14,
29842,
342,
421,
199,
692,
1067,
14,
374,
63,
18430,
63,
632,
837,
272,
1255,
63,
7685,
63,
18430,
342,
199,
2836,
26,
272,
1255,
63,
7685,
63,
15178,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
rbaindourov/v8-inspector
|
Source/chrome/tools/diagnose-me.py
|
128
|
3534
|
#!/usr/bin/python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Diagnose some common system configuration problems on Linux, and
suggest fixes."""
import os
import subprocess
import sys
all_checks = []
def Check(name):
"""Decorator that defines a diagnostic check."""
def wrap(func):
all_checks.append((name, func))
return func
return wrap
@Check("/usr/bin/ld is not gold")
def CheckSystemLd():
proc = subprocess.Popen(['/usr/bin/ld', '-v'], stdout=subprocess.PIPE)
stdout = proc.communicate()[0]
if 'GNU gold' in stdout:
return ("When /usr/bin/ld is gold, system updates can silently\n"
"corrupt your graphics drivers.\n"
"Try 'sudo apt-get remove binutils-gold'.\n")
return None
@Check("random lds are not in the $PATH")
def CheckPathLd():
proc = subprocess.Popen(['which', '-a', 'ld'], stdout=subprocess.PIPE)
stdout = proc.communicate()[0]
instances = stdout.split()
if len(instances) > 1:
return ("You have multiple 'ld' binaries in your $PATH:\n"
+ '\n'.join(' - ' + i for i in instances) + "\n"
"You should delete all of them but your system one.\n"
"gold is hooked into your build via gyp.\n")
return None
@Check("/usr/bin/ld doesn't point to gold")
def CheckLocalGold():
# Check /usr/bin/ld* symlinks.
for path in ('ld.bfd', 'ld'):
path = '/usr/bin/' + path
try:
target = os.readlink(path)
except OSError, e:
if e.errno == 2:
continue # No such file
if e.errno == 22:
continue # Not a symlink
raise
if '/usr/local/gold' in target:
return ("%s is a symlink into /usr/local/gold.\n"
"It's difficult to make a recommendation, because you\n"
"probably set this up yourself. But you should make\n"
"/usr/bin/ld be the standard linker, which you likely\n"
"renamed /usr/bin/ld.bfd or something like that.\n" % path)
return None
@Check("random ninja binaries are not in the $PATH")
def CheckPathNinja():
proc = subprocess.Popen(['which', 'ninja'], stdout=subprocess.PIPE)
stdout = proc.communicate()[0]
if not 'depot_tools' in stdout:
return ("The ninja binary in your path isn't from depot_tools:\n"
+ " " + stdout +
"Remove custom ninjas from your path so that the one\n"
"in depot_tools is used.\n")
return None
@Check("build dependencies are satisfied")
def CheckBuildDeps():
script_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'build',
'install-build-deps.sh')
proc = subprocess.Popen([script_path, '--quick-check'],
stdout=subprocess.PIPE)
stdout = proc.communicate()[0]
if 'WARNING' in stdout:
return ("Your build dependencies are out-of-date.\n"
"Run '" + script_path + "' to update.")
return None
def RunChecks():
for name, check in all_checks:
sys.stdout.write("* Checking %s: " % name)
sys.stdout.flush()
error = check()
if not error:
print "ok"
else:
print "FAIL"
print error
if __name__ == '__main__':
RunChecks()
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1898,
334,
67,
9,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
16094,
21085,
2005,
2863,
2656,
2897,
8826,
641,
10130,
12,
436,
199,
19957,
25079,
1041,
199,
199,
646,
747,
199,
646,
3873,
199,
646,
984,
199,
199,
452,
63,
8625,
275,
942,
199,
199,
318,
2670,
8,
354,
304,
272,
408,
14946,
626,
7890,
282,
8348,
19075,
1104,
1041,
272,
347,
4816,
8,
1532,
304,
267,
1006,
63,
8625,
14,
740,
1332,
354,
12,
2562,
430,
267,
372,
2562,
272,
372,
4816,
421,
199,
32,
1799,
4769,
2647,
15,
1393,
15,
1447,
365,
440,
486,
1753,
531,
199,
318,
2670,
3989,
30251,
837,
272,
6499,
275,
3873,
14,
7942,
26352,
2647,
15,
1393,
15,
1447,
297,
2475,
86,
995,
3839,
29,
5781,
14,
6089,
9,
272,
3839,
275,
6499,
14,
10664,
3430,
16,
61,
272,
340,
283,
17732,
486,
1753,
7,
315,
3839,
26,
267,
372,
1689,
11423,
1182,
2647,
15,
1393,
15,
1447,
365,
486,
1753,
12,
2656,
7029,
883,
18030,
60,
78,
2,
355,
298,
989,
6987,
2195,
24348,
19016,
3134,
78,
2,
355,
298,
12357,
283,
12095,
20932,
13,
362,
2813,
2517,
1208,
13,
23628,
1370,
60,
78,
531,
272,
372,
488,
421,
199,
32,
1799,
480,
2355,
634,
795,
787,
440,
315,
314,
2672,
3243,
531,
199,
318,
2670,
2042,
30251,
837,
272,
6499,
275,
3873,
14,
7942,
2941,
6777,
297,
2475,
65,
297,
283,
1447,
995,
3839,
29,
5781,
14,
6089,
9,
272,
3839,
275,
6499,
14,
10664,
3430,
16,
61,
272,
4454,
275,
3839,
14,
1294,
342,
272,
340,
822,
8,
5990,
9,
690,
413,
26,
267,
372,
1689,
5556,
1172,
3663,
283,
1447,
7,
21984,
315,
2195,
2672,
3243,
3427,
78,
2,
355,
435,
1557,
78,
1370,
904,
360,
446,
283,
435,
284,
367,
284,
315,
4454,
9,
435,
1867,
78,
2,
355,
298,
5556,
1077,
3145,
1006,
402,
3062,
1325,
2195,
2656,
1373,
3134,
78,
2,
355,
298,
23628,
365,
5759,
379,
1901,
2195,
1900,
4799,
4902,
3134,
78,
531,
272,
372,
488,
421,
199,
32,
1799,
4769,
2647,
15,
1393,
15,
1447,
3181,
1133,
2376,
370,
486,
1753,
531,
199,
318,
2670,
5339,
39,
1753,
837,
272,
327,
2670,
1182,
2647,
15,
1393,
15,
1447,
10,
19891,
14,
272,
367,
931,
315,
661,
1447,
14,
21090,
297,
283,
1447,
735,
267,
931,
275,
1994,
2647,
15,
1393,
4805,
435,
931,
267,
862,
26,
288,
1347,
275,
747,
14,
31654,
8,
515,
9,
267,
871,
6440,
12,
325,
26,
288,
340,
325,
14,
7931,
508,
499,
26,
355,
1980,
221,
327,
3091,
4066,
570,
288,
340,
325,
14,
7931,
508,
6928,
26,
355,
1980,
221,
327,
2832,
282,
15296,
288,
746,
267,
340,
1994,
2647,
15,
1832,
15,
23628,
7,
315,
1347,
26,
288,
372,
19426,
83,
365,
282,
15296,
1901,
1182,
2647,
15,
1832,
15,
23628,
3134,
78,
2,
490,
298,
7940,
1159,
29870,
370,
1852,
282,
295,
22105,
12,
2952,
1265,
60,
78,
2,
490,
298,
6101,
6665,
663,
642,
1536,
28225,
14,
221,
11017,
1265,
1077,
1852,
60,
78,
2,
490,
3286,
2647,
15,
1393,
15,
1447,
506,
314,
4465,
17261,
12,
1314,
1265,
12060,
60,
78,
2,
490,
298,
29401,
1182,
2647,
15,
1393,
15,
1447,
14,
21090,
503,
6020,
2839,
626,
3134,
78,
2,
450,
931,
9,
339,
372,
488,
421,
199,
32,
1799,
480,
2355,
14822,
21984,
787,
440,
315,
314,
2672,
3243,
531,
199,
318,
2670,
2042,
24237,
837,
272,
6499,
275,
3873,
14,
7942,
2941,
6777,
297,
283,
8675,
995,
3839,
29,
5781,
14,
6089,
9,
272,
3839,
275,
6499,
14,
10664,
3430,
16,
61,
272,
340,
440,
283,
27834,
63,
2537,
7,
315,
3839,
26,
267,
372,
1689,
1918,
14822,
3366,
315,
2195,
931,
5712,
1133,
687,
32544,
63,
2537,
3427,
78,
2,
355,
435,
298,
259,
298,
435,
3839,
435,
355,
298,
5587,
3537,
302,
262,
74,
305,
687,
2195,
931,
880,
626,
314,
1373,
60,
78,
2,
355,
298,
262,
32544,
63,
2537,
365,
1202,
3134,
78,
531,
272,
372,
488,
421,
199,
32,
1799,
480,
1506,
5124,
787,
23233,
531,
199,
318,
2670,
3425,
27683,
837,
272,
2884,
63,
515,
275,
747,
14,
515,
14,
904,
8,
267,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
395,
283,
1506,
297,
267,
283,
3174,
13,
1506,
13,
5846,
14,
609,
358,
272,
6499,
275,
3873,
14,
7942,
779,
1579,
63,
515,
12,
2850,
13239,
13,
1074,
995,
1169,
3839,
29,
5781,
14,
6089,
9,
272,
3839,
275,
6499,
14,
10664,
3430,
16,
61,
272,
340,
283,
9171,
7,
315,
3839,
26,
267,
372,
1689,
14398,
1900,
5124,
787,
734,
13,
1618,
13,
602,
3134,
78,
2,
355,
298,
2540,
5522,
435,
2884,
63,
515,
435,
3546,
370,
1678,
2685,
272,
372,
488,
421,
199,
318,
3378,
11834,
837,
272,
367,
536,
12,
1104,
315,
1006,
63,
8625,
26,
267,
984,
14,
2703,
14,
952,
23124,
25109,
450,
83,
26,
298,
450,
536,
9,
267,
984,
14,
2703,
14,
4939,
342,
267,
1125,
275,
1104,
342,
267,
340,
440,
1125,
26,
288,
870,
298,
745,
2,
267,
587,
26,
288,
870,
298,
8784,
2,
288,
870,
1125,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
3378,
11834,
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
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1898,
334,
67,
9,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
16094,
21085,
2005,
2863,
2656,
2897,
8826,
641,
10130,
12,
436,
199,
19957,
25079,
1041,
199,
199,
646,
747,
199,
646,
3873,
199,
646,
984,
199,
199,
452,
63,
8625,
275,
942,
199,
199,
318,
2670,
8,
354,
304,
272,
408,
14946,
626,
7890,
282,
8348,
19075,
1104,
1041,
272,
347,
4816,
8,
1532,
304,
267,
1006,
63,
8625,
14,
740,
1332,
354,
12,
2562,
430,
267,
372,
2562,
272,
372,
4816,
421,
199,
32,
1799,
4769,
2647,
15,
1393,
15,
1447,
365,
440,
486,
1753,
531,
199,
318,
2670,
3989,
30251,
837,
272,
6499,
275,
3873,
14,
7942,
26352,
2647,
15,
1393,
15,
1447,
297,
2475,
86,
995,
3839,
29,
5781,
14,
6089,
9,
272,
3839,
275,
6499,
14,
10664,
3430,
16,
61,
272,
340,
283,
17732,
486,
1753,
7,
315,
3839,
26,
267,
372,
1689,
11423,
1182,
2647,
15,
1393,
15,
1447,
365,
486,
1753,
12,
2656,
7029,
883,
18030,
60,
78,
2,
355,
298,
989,
6987,
2195,
24348,
19016,
3134,
78,
2,
355,
298,
12357,
283,
12095,
20932,
13,
362,
2813,
2517,
1208,
13,
23628,
1370,
60,
78,
531,
272,
372,
488,
421,
199,
32,
1799,
480,
2355,
634,
795,
787,
440,
315,
314,
2672,
3243,
531,
199,
318,
2670,
2042,
30251,
837,
272,
6499,
275,
3873,
14,
7942,
2941,
6777,
297,
2475,
65,
297,
283,
1447,
995,
3839,
29,
5781,
14,
6089,
9,
272,
3839,
275,
6499,
14,
10664,
3430,
16,
61,
272,
4454,
275,
3839,
14,
1294,
342,
272,
340,
822,
8,
5990,
9,
690,
413,
26,
267,
372,
1689,
5556,
1172,
3663,
283,
1447,
7,
21984,
315,
2195,
2672,
3243,
3427,
78,
2,
355,
435,
1557,
78,
1370,
904,
360,
446,
283,
435,
284,
367,
284,
315,
4454,
9,
435,
1867,
78,
2,
355,
298,
5556,
1077,
3145,
1006,
402,
3062,
1325,
2195,
2656,
1373,
3134,
78,
2,
355,
298,
23628,
365,
5759,
379,
1901,
2195,
1900,
4799,
4902,
3134,
78,
531,
272,
372,
488,
421,
199,
32,
1799,
4769,
2647,
15,
1393,
15,
1447,
3181,
1133,
2376,
370,
486,
1753,
531,
199,
318,
2670,
5339,
39,
1753,
837,
272,
327,
2670,
1182,
2647,
15,
1393,
15,
1447,
10,
19891,
14,
272,
367,
931,
315,
661,
1447,
14,
21090,
297,
283,
1447,
735,
267,
931,
275,
1994,
2647,
15,
1393,
4805,
435,
931,
267,
862,
26,
288,
1347,
275,
747,
14,
31654,
8,
515,
9,
267,
871,
6440,
12,
325,
26,
288,
340,
325,
14,
7931,
508,
499,
26,
355,
1980,
221,
327,
3091,
4066,
570,
288,
340,
325,
14,
7931,
508,
6928,
26,
355,
1980,
221,
327,
2832,
282,
15296,
288,
746,
267,
340,
1994,
2647,
15,
1832,
15,
23628,
7,
315,
1347,
26,
288,
372,
19426,
83,
365,
282,
15296,
1901,
1182,
2647,
15,
1832,
15,
23628,
3134,
78,
2,
490,
298,
7940,
1159,
29870,
370,
1852,
282,
295,
22105,
12,
2952,
1265,
60,
78,
2,
490,
298,
6101,
6665,
663,
642,
1536,
28225,
14,
221,
11017,
1265,
1077,
1852,
60,
78,
2,
490,
3286,
2647,
15,
1393,
15,
1447,
506,
314,
4465,
17261,
12,
1314,
1265,
12060,
60,
78,
2,
490,
298,
29401,
1182,
2647,
15,
1393,
15,
1447,
14,
21090,
503,
6020,
2839,
626,
3134,
78,
2,
450,
931,
9,
339,
372,
488,
421,
199,
32,
1799,
480,
2355,
14822,
21984,
787,
440,
315,
314,
2672,
3243,
531,
199,
318,
2670,
2042,
24237,
837,
272,
6499,
275,
3873,
14,
7942,
2941,
6777,
297,
283,
8675,
995,
3839,
29,
5781,
14,
6089,
9,
272,
3839,
275,
6499,
14,
10664,
3430,
16,
61,
272,
340,
440,
283,
27834,
63,
2537,
7,
315,
3839,
26,
267,
372,
1689,
1918,
14822,
3366,
315,
2195,
931,
5712,
1133,
687,
32544,
63,
2537,
3427,
78,
2,
355,
435,
298,
259,
298,
435,
3839,
435,
355,
298,
5587,
3537,
302,
262,
74,
305,
687,
2195,
931,
880,
626,
314,
1373,
60,
78,
2,
355,
298,
262,
32544,
63,
2537,
365,
1202,
3134,
78,
531,
272,
372,
488,
421,
199,
32,
1799,
480,
1506,
5124,
787,
23233,
531,
199,
318,
2670,
3425,
27683,
837,
272,
2884,
63,
515,
275,
747,
14,
515,
14,
904,
8,
267,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
395,
283,
1506,
297,
267,
283,
3174,
13,
1506,
13,
5846,
14,
609,
358,
272,
6499,
275,
3873,
14,
7942,
779,
1579,
63,
515,
12,
2850,
13239,
13,
1074,
995,
1169,
3839,
29,
5781,
14,
6089,
9,
272,
3839,
275,
6499,
14,
10664,
3430,
16,
61,
272,
340,
283,
9171,
7,
315,
3839,
26,
267,
372,
1689,
14398,
1900,
5124,
787,
734,
13,
1618,
13,
602,
3134,
78,
2,
355,
298,
2540,
5522,
435,
2884,
63,
515,
435,
3546,
370,
1678,
2685,
272,
372,
488,
421,
199,
318,
3378,
11834,
837,
272,
367,
536,
12,
1104,
315,
1006,
63,
8625,
26,
267,
984,
14,
2703,
14,
952,
23124,
25109,
450,
83,
26,
298,
450,
536,
9,
267,
984,
14,
2703,
14,
4939,
342,
267,
1125,
275,
1104,
342,
267,
340,
440,
1125,
26,
288,
870,
298,
745,
2,
267,
587,
26,
288,
870,
298,
8784,
2,
288,
870,
1125,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
3378,
11834,
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,
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,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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
dmpiergiacomo/scion
|
python/test/lib/sibra/ext/offer_test.py
|
3
|
3519
|
# Copyright 2016 ETH Zurich
#
# 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.
"""
:mod:`offer_test` --- lib.sibra.ext.offer unit tests
====================================================
"""
# Stdlib
from unittest.mock import call, patch
# External packages
import nose
import nose.tools as ntools
# SCION
from lib.sibra.ext.offer import OfferBlockBase
from test.testcommon import assert_these_calls, create_mock
class TestResvInfoBaseParse(object):
"""
Unit tests for lib.sibra.ext.info.ResvInfoBase._parse
"""
@patch("lib.sibra.ext.offer.BWClass", autospec=True)
@patch("lib.sibra.ext.offer.Raw", autospec=True)
def test(self, raw, bwcls):
inst = OfferBlockBase()
inst.NAME = "ResvInfoBase"
inst.RESVINFO = create_mock()
offers = []
for i in range(4):
offers.append("fwd %d" % i)
offers.append("rev %d" % i)
data = create_mock(["__bool__", "__len__", "pop"])
data.__bool__.side_effect = ([True] * 4) + [False]
data.pop.side_effect = ["resv info"] + offers
data.__len__.return_value = 4 * inst.OFFER_LEN
raw.return_value = data
# Call
inst._parse("data")
# Tests
inst.RESVINFO.assert_called_once_with("resv info")
ntools.eq_(inst.info, inst.RESVINFO.return_value)
ntools.eq_(inst.offer_hops, 4)
assert_these_calls(bwcls, [
call("fwd 0", "rev 0"), call("fwd 1", "rev 1"),
call("fwd 2", "rev 2"), call("fwd 3", "rev 3"),
])
class TestResvInfoBaseFromValues(object):
"""
Unit tests for lib.sibra.ext.info.ResvInfoBase.from_values
"""
def test(self):
inst = OfferBlockBase.from_values("info", 6)
# Tests
ntools.eq_(inst.info, "info")
ntools.eq_(inst.offer_hops, 8)
ntools.eq_(len(inst.offers), 8)
class TestResvInfoBasePack(object):
"""
Unit tests for lib.sibra.ext.info.ResvInfoBase._pack
"""
def test(self):
inst = OfferBlockBase()
inst.info = create_mock(["pack"])
inst.info.pack.return_value = bytes(range(inst.LINE_LEN))
for i in range(4):
offer = create_mock(["fwd", "rev"])
offer.fwd = i
offer.rev = i * 2
inst.offers.append(offer)
inst.offer_hops = 4
expected = b"".join([
bytes(range(inst.LINE_LEN)),
bytes.fromhex("0000 0102 0204 0306"),
])
# Call
ntools.eq_(inst.pack(), expected)
class TestResvInfoBaseGetMin(object):
"""
Unit tests for lib.sibra.ext.info.ResvInfoBase.get_min
"""
def test(self):
inst = OfferBlockBase()
inst.info = create_mock(["fail_hop"])
inst.info.fail_hop = 2
offer = create_mock(["min"])
inst.offers = [offer] * 5
# Call
ret = inst.get_min(5)
# Tests
assert_these_calls(ret.min, [call(offer)] * 3)
if __name__ == "__main__":
nose.run(defaultTest=__name__)
|
apache-2.0
|
[
3,
1898,
7800,
662,
2080,
3107,
300,
1158,
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,
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,
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,
624,
199,
26,
1494,
1705,
12786,
63,
396,
64,
10894,
1973,
14,
6637,
345,
14,
832,
14,
12786,
4137,
2295,
199,
12813,
532,
199,
624,
199,
3,
20992,
773,
199,
504,
2882,
14,
1805,
492,
1240,
12,
3371,
199,
199,
3,
18802,
6117,
199,
646,
11354,
199,
646,
11354,
14,
2537,
465,
302,
2537,
199,
199,
3,
12075,
1075,
199,
504,
1973,
14,
6637,
345,
14,
832,
14,
12786,
492,
593,
1260,
3142,
1563,
199,
504,
511,
14,
396,
2330,
492,
702,
63,
29032,
63,
5352,
12,
1218,
63,
1805,
421,
199,
533,
1379,
1322,
86,
2354,
1563,
4003,
8,
785,
304,
272,
408,
272,
12008,
2295,
367,
1973,
14,
6637,
345,
14,
832,
14,
815,
14,
1322,
86,
2354,
1563,
423,
1122,
272,
408,
272,
768,
2068,
480,
773,
14,
6637,
345,
14,
832,
14,
12786,
14,
18344,
2543,
401,
18052,
29,
549,
9,
272,
768,
2068,
480,
773,
14,
6637,
345,
14,
832,
14,
12786,
14,
7963,
401,
18052,
29,
549,
9,
272,
347,
511,
8,
277,
12,
3066,
12,
21028,
1886,
304,
267,
2727,
275,
593,
1260,
3142,
1563,
342,
267,
2727,
14,
2339,
275,
298,
1322,
86,
2354,
1563,
2,
267,
2727,
14,
3830,
54,
4531,
275,
1218,
63,
1805,
342,
267,
32563,
275,
942,
267,
367,
284,
315,
1425,
8,
20,
304,
288,
32563,
14,
740,
480,
27912,
450,
68,
2,
450,
284,
9,
288,
32563,
14,
740,
480,
4964,
450,
68,
2,
450,
284,
9,
267,
666,
275,
1218,
63,
1805,
5234,
363,
2245,
13915,
4396,
552,
13915,
298,
1935,
3135,
267,
666,
855,
2245,
4343,
2441,
63,
5881,
275,
7287,
549,
61,
627,
841,
9,
435,
359,
797,
61,
267,
666,
14,
1935,
14,
2441,
63,
5881,
275,
2097,
470,
86,
2256,
937,
435,
32563,
267,
666,
855,
552,
4343,
1107,
63,
585,
275,
841,
627,
2727,
14,
7517,
540,
63,
5304,
267,
3066,
14,
1107,
63,
585,
275,
666,
267,
327,
6523,
267,
2727,
423,
1122,
480,
576,
531,
267,
327,
6496,
267,
2727,
14,
3830,
54,
4531,
14,
479,
63,
3527,
63,
5089,
63,
1045,
480,
470,
86,
2256,
531,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
815,
12,
2727,
14,
3830,
54,
4531,
14,
1107,
63,
585,
9,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
12786,
63,
72,
1483,
12,
841,
9,
267,
702,
63,
29032,
63,
5352,
8,
12415,
1886,
12,
359,
288,
1240,
480,
27912,
378,
401,
298,
4964,
378,
1288,
1240,
480,
27912,
413,
401,
298,
4964,
413,
1288,
288,
1240,
480,
27912,
499,
401,
298,
4964,
499,
1288,
1240,
480,
27912,
650,
401,
298,
4964,
650,
1288,
267,
4794,
421,
199,
533,
1379,
1322,
86,
2354,
1563,
2532,
6550,
8,
785,
304,
272,
408,
272,
12008,
2295,
367,
1973,
14,
6637,
345,
14,
832,
14,
815,
14,
1322,
86,
2354,
1563,
14,
504,
63,
1459,
272,
408,
272,
347,
511,
8,
277,
304,
267,
2727,
275,
593,
1260,
3142,
1563,
14,
504,
63,
1459,
480,
815,
401,
1227,
9,
267,
327,
6496,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
815,
12,
298,
815,
531,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
12786,
63,
72,
1483,
12,
1695,
9,
267,
302,
2537,
14,
4077,
2531,
552,
8,
3615,
14,
1997,
1192,
395,
1695,
9,
421,
199,
533,
1379,
1322,
86,
2354,
1563,
2305,
8,
785,
304,
272,
408,
272,
12008,
2295,
367,
1973,
14,
6637,
345,
14,
832,
14,
815,
14,
1322,
86,
2354,
1563,
423,
1389,
272,
408,
272,
347,
511,
8,
277,
304,
267,
2727,
275,
593,
1260,
3142,
1563,
342,
267,
2727,
14,
815,
275,
1218,
63,
1805,
5234,
1389,
3135,
267,
2727,
14,
815,
14,
1389,
14,
1107,
63,
585,
275,
2783,
8,
1842,
8,
3615,
14,
6174,
63,
5304,
430,
267,
367,
284,
315,
1425,
8,
20,
304,
288,
19793,
275,
1218,
63,
1805,
5234,
27912,
401,
298,
4964,
3135,
288,
19793,
14,
27912,
275,
284,
288,
19793,
14,
4964,
275,
284,
627,
499,
288,
2727,
14,
1997,
1192,
14,
740,
8,
12786,
9,
267,
2727,
14,
12786,
63,
72,
1483,
275,
841,
267,
1420,
275,
330,
25148,
904,
779,
288,
2783,
8,
1842,
8,
3615,
14,
6174,
63,
5304,
1826,
288,
2783,
14,
504,
4097,
480,
993,
378,
7759,
378,
6686,
378,
11363,
1288,
267,
4794,
267,
327,
6523,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
1389,
1062,
1420,
9,
421,
199,
533,
1379,
1322,
86,
2354,
1563,
28745,
8,
785,
304,
272,
408,
272,
12008,
2295,
367,
1973,
14,
6637,
345,
14,
832,
14,
815,
14,
1322,
86,
2354,
1563,
14,
362,
63,
827,
272,
408,
272,
347,
511,
8,
277,
304,
267,
2727,
275,
593,
1260,
3142,
1563,
342,
267,
2727,
14,
815,
275,
1218,
63,
1805,
5234,
1633,
63,
13376,
3135,
267,
2727,
14,
815,
14,
1633,
63,
13376,
275,
499,
267,
19793,
275,
1218,
63,
1805,
5234,
827,
3135,
267,
2727,
14,
1997,
1192,
275,
359,
12786,
61,
627,
959,
267,
327,
6523,
267,
2203,
275,
2727,
14,
362,
63,
827,
8,
21,
9,
267,
327,
6496,
267,
702,
63,
29032,
63,
5352,
8,
3292,
14,
827,
12,
359,
1250,
8,
12786,
1874,
627,
650,
9,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
11354,
14,
1065,
8,
885,
774,
18971,
354,
3368,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
7800,
662,
2080,
3107,
300,
1158,
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,
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,
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,
624,
199,
26,
1494,
1705,
12786,
63,
396,
64,
10894,
1973,
14,
6637,
345,
14,
832,
14,
12786,
4137,
2295,
199,
12813,
532,
199,
624,
199,
3,
20992,
773,
199,
504,
2882,
14,
1805,
492,
1240,
12,
3371,
199,
199,
3,
18802,
6117,
199,
646,
11354,
199,
646,
11354,
14,
2537,
465,
302,
2537,
199,
199,
3,
12075,
1075,
199,
504,
1973,
14,
6637,
345,
14,
832,
14,
12786,
492,
593,
1260,
3142,
1563,
199,
504,
511,
14,
396,
2330,
492,
702,
63,
29032,
63,
5352,
12,
1218,
63,
1805,
421,
199,
533,
1379,
1322,
86,
2354,
1563,
4003,
8,
785,
304,
272,
408,
272,
12008,
2295,
367,
1973,
14,
6637,
345,
14,
832,
14,
815,
14,
1322,
86,
2354,
1563,
423,
1122,
272,
408,
272,
768,
2068,
480,
773,
14,
6637,
345,
14,
832,
14,
12786,
14,
18344,
2543,
401,
18052,
29,
549,
9,
272,
768,
2068,
480,
773,
14,
6637,
345,
14,
832,
14,
12786,
14,
7963,
401,
18052,
29,
549,
9,
272,
347,
511,
8,
277,
12,
3066,
12,
21028,
1886,
304,
267,
2727,
275,
593,
1260,
3142,
1563,
342,
267,
2727,
14,
2339,
275,
298,
1322,
86,
2354,
1563,
2,
267,
2727,
14,
3830,
54,
4531,
275,
1218,
63,
1805,
342,
267,
32563,
275,
942,
267,
367,
284,
315,
1425,
8,
20,
304,
288,
32563,
14,
740,
480,
27912,
450,
68,
2,
450,
284,
9,
288,
32563,
14,
740,
480,
4964,
450,
68,
2,
450,
284,
9,
267,
666,
275,
1218,
63,
1805,
5234,
363,
2245,
13915,
4396,
552,
13915,
298,
1935,
3135,
267,
666,
855,
2245,
4343,
2441,
63,
5881,
275,
7287,
549,
61,
627,
841,
9,
435,
359,
797,
61,
267,
666,
14,
1935,
14,
2441,
63,
5881,
275,
2097,
470,
86,
2256,
937,
435,
32563,
267,
666,
855,
552,
4343,
1107,
63,
585,
275,
841,
627,
2727,
14,
7517,
540,
63,
5304,
267,
3066,
14,
1107,
63,
585,
275,
666,
267,
327,
6523,
267,
2727,
423,
1122,
480,
576,
531,
267,
327,
6496,
267,
2727,
14,
3830,
54,
4531,
14,
479,
63,
3527,
63,
5089,
63,
1045,
480,
470,
86,
2256,
531,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
815,
12,
2727,
14,
3830,
54,
4531,
14,
1107,
63,
585,
9,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
12786,
63,
72,
1483,
12,
841,
9,
267,
702,
63,
29032,
63,
5352,
8,
12415,
1886,
12,
359,
288,
1240,
480,
27912,
378,
401,
298,
4964,
378,
1288,
1240,
480,
27912,
413,
401,
298,
4964,
413,
1288,
288,
1240,
480,
27912,
499,
401,
298,
4964,
499,
1288,
1240,
480,
27912,
650,
401,
298,
4964,
650,
1288,
267,
4794,
421,
199,
533,
1379,
1322,
86,
2354,
1563,
2532,
6550,
8,
785,
304,
272,
408,
272,
12008,
2295,
367,
1973,
14,
6637,
345,
14,
832,
14,
815,
14,
1322,
86,
2354,
1563,
14,
504,
63,
1459,
272,
408,
272,
347,
511,
8,
277,
304,
267,
2727,
275,
593,
1260,
3142,
1563,
14,
504,
63,
1459,
480,
815,
401,
1227,
9,
267,
327,
6496,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
815,
12,
298,
815,
531,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
12786,
63,
72,
1483,
12,
1695,
9,
267,
302,
2537,
14,
4077,
2531,
552,
8,
3615,
14,
1997,
1192,
395,
1695,
9,
421,
199,
533,
1379,
1322,
86,
2354,
1563,
2305,
8,
785,
304,
272,
408,
272,
12008,
2295,
367,
1973,
14,
6637,
345,
14,
832,
14,
815,
14,
1322,
86,
2354,
1563,
423,
1389,
272,
408,
272,
347,
511,
8,
277,
304,
267,
2727,
275,
593,
1260,
3142,
1563,
342,
267,
2727,
14,
815,
275,
1218,
63,
1805,
5234,
1389,
3135,
267,
2727,
14,
815,
14,
1389,
14,
1107,
63,
585,
275,
2783,
8,
1842,
8,
3615,
14,
6174,
63,
5304,
430,
267,
367,
284,
315,
1425,
8,
20,
304,
288,
19793,
275,
1218,
63,
1805,
5234,
27912,
401,
298,
4964,
3135,
288,
19793,
14,
27912,
275,
284,
288,
19793,
14,
4964,
275,
284,
627,
499,
288,
2727,
14,
1997,
1192,
14,
740,
8,
12786,
9,
267,
2727,
14,
12786,
63,
72,
1483,
275,
841,
267,
1420,
275,
330,
25148,
904,
779,
288,
2783,
8,
1842,
8,
3615,
14,
6174,
63,
5304,
1826,
288,
2783,
14,
504,
4097,
480,
993,
378,
7759,
378,
6686,
378,
11363,
1288,
267,
4794,
267,
327,
6523,
267,
302,
2537,
14,
4077,
2531,
3615,
14,
1389,
1062,
1420,
9,
421,
199,
533,
1379,
1322,
86,
2354,
1563,
28745,
8,
785,
304,
272,
408,
272,
12008,
2295,
367,
1973,
14,
6637,
345,
14,
832,
14,
815,
14,
1322,
86,
2354,
1563,
14,
362,
63,
827,
272,
408,
272,
347,
511,
8,
277,
304,
267,
2727,
275,
593,
1260,
3142,
1563,
342,
267,
2727,
14,
815,
275,
1218,
63,
1805,
5234,
1633,
63,
13376,
3135,
267,
2727,
14,
815,
14,
1633,
63,
13376,
275,
499,
267,
19793,
275,
1218,
63,
1805,
5234,
827,
3135,
267,
2727,
14,
1997,
1192,
275,
359,
12786,
61,
627,
959,
267,
327,
6523,
267,
2203,
275,
2727,
14,
362,
63,
827,
8,
21,
9,
267,
327,
6496,
267,
702,
63,
29032,
63,
5352,
8,
3292,
14,
827,
12,
359,
1250,
8,
12786,
1874,
627,
650,
9,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
11354,
14,
1065,
8,
885,
774,
18971,
354,
3368,
199,
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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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,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
beni55/edx-platform
|
lms/djangoapps/courseware/features/courseware_common.py
|
160
|
1067
|
# pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
from lettuce import world, step
@step('I click on View Courseware')
def i_click_on_view_courseware(step):
world.css_click('a.enter-course')
@step('I click on the "([^"]*)" tab$')
def i_click_on_the_tab(step, tab_text):
world.click_link(tab_text)
@step('I click on the "([^"]*)" link$')
def i_click_on_the_link(step, link_text):
world.click_link(link_text)
@step('I visit the courseware URL$')
def i_visit_the_course_info_url(step):
world.visit('/courses/MITx/6.002x/2012_Fall/courseware')
@step(u'I am on the dashboard page$')
def i_am_on_the_dashboard_page(step):
assert world.is_css_present('section.courses')
assert world.url_equals('/dashboard')
@step('the "([^"]*)" tab is active$')
def the_tab_is_active(step, tab_text):
assert world.css_text('.course-tabs a.active') == tab_text
@step('the login dialog is visible$')
def login_dialog_visible(step):
assert world.css_visible('form#login_form.login_form')
|
agpl-3.0
|
[
3,
4287,
26,
3507,
29,
4752,
13,
12485,
199,
3,
4287,
26,
3507,
29,
27913,
13,
7837,
13,
354,
199,
3,
4287,
26,
3507,
29,
8618,
13,
2094,
199,
199,
504,
4691,
84,
3683,
492,
6701,
12,
3650,
421,
199,
32,
2926,
360,
41,
8968,
641,
10935,
5531,
1068,
358,
199,
318,
284,
63,
4891,
63,
265,
63,
1345,
63,
17744,
8,
2926,
304,
272,
6701,
14,
3919,
63,
4891,
360,
65,
14,
4200,
13,
1972,
358,
421,
199,
32,
2926,
360,
41,
8968,
641,
314,
32397,
25952,
5174,
9988,
199,
318,
284,
63,
4891,
63,
265,
63,
1589,
63,
2902,
8,
2926,
12,
5174,
63,
505,
304,
272,
6701,
14,
4891,
63,
1073,
8,
2902,
63,
505,
9,
421,
199,
32,
2926,
360,
41,
8968,
641,
314,
32397,
25952,
2142,
9988,
199,
318,
284,
63,
4891,
63,
265,
63,
1589,
63,
1073,
8,
2926,
12,
2142,
63,
505,
304,
272,
6701,
14,
4891,
63,
1073,
8,
1073,
63,
505,
9,
421,
199,
32,
2926,
360,
41,
5684,
314,
20736,
2851,
9988,
199,
318,
284,
63,
5427,
63,
1589,
63,
1972,
63,
815,
63,
633,
8,
2926,
304,
272,
6701,
14,
5427,
2336,
11653,
15,
13965,
88,
15,
22,
14,
7432,
88,
15,
7409,
63,
31354,
15,
17744,
358,
421,
199,
32,
2926,
8,
85,
7,
41,
8140,
641,
314,
17216,
2034,
9988,
199,
318,
284,
63,
455,
63,
265,
63,
1589,
63,
9743,
63,
1606,
8,
2926,
304,
272,
702,
6701,
14,
374,
63,
3919,
63,
1881,
360,
2792,
14,
11653,
358,
272,
702,
6701,
14,
633,
63,
11332,
2336,
9743,
358,
421,
199,
32,
2926,
360,
1589,
32397,
25952,
5174,
365,
4702,
9988,
199,
318,
314,
63,
2902,
63,
374,
63,
2682,
8,
2926,
12,
5174,
63,
505,
304,
272,
702,
6701,
14,
3919,
63,
505,
5175,
1972,
13,
8741,
282,
14,
2682,
358,
508,
5174,
63,
505,
421,
199,
32,
2926,
360,
1589,
4676,
9592,
365,
8917,
9988,
199,
318,
4676,
63,
7196,
63,
6604,
8,
2926,
304,
272,
702,
6701,
14,
3919,
63,
6604,
360,
964,
3,
2886,
63,
964,
14,
2886,
63,
964,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4287,
26,
3507,
29,
4752,
13,
12485,
199,
3,
4287,
26,
3507,
29,
27913,
13,
7837,
13,
354,
199,
3,
4287,
26,
3507,
29,
8618,
13,
2094,
199,
199,
504,
4691,
84,
3683,
492,
6701,
12,
3650,
421,
199,
32,
2926,
360,
41,
8968,
641,
10935,
5531,
1068,
358,
199,
318,
284,
63,
4891,
63,
265,
63,
1345,
63,
17744,
8,
2926,
304,
272,
6701,
14,
3919,
63,
4891,
360,
65,
14,
4200,
13,
1972,
358,
421,
199,
32,
2926,
360,
41,
8968,
641,
314,
32397,
25952,
5174,
9988,
199,
318,
284,
63,
4891,
63,
265,
63,
1589,
63,
2902,
8,
2926,
12,
5174,
63,
505,
304,
272,
6701,
14,
4891,
63,
1073,
8,
2902,
63,
505,
9,
421,
199,
32,
2926,
360,
41,
8968,
641,
314,
32397,
25952,
2142,
9988,
199,
318,
284,
63,
4891,
63,
265,
63,
1589,
63,
1073,
8,
2926,
12,
2142,
63,
505,
304,
272,
6701,
14,
4891,
63,
1073,
8,
1073,
63,
505,
9,
421,
199,
32,
2926,
360,
41,
5684,
314,
20736,
2851,
9988,
199,
318,
284,
63,
5427,
63,
1589,
63,
1972,
63,
815,
63,
633,
8,
2926,
304,
272,
6701,
14,
5427,
2336,
11653,
15,
13965,
88,
15,
22,
14,
7432,
88,
15,
7409,
63,
31354,
15,
17744,
358,
421,
199,
32,
2926,
8,
85,
7,
41,
8140,
641,
314,
17216,
2034,
9988,
199,
318,
284,
63,
455,
63,
265,
63,
1589,
63,
9743,
63,
1606,
8,
2926,
304,
272,
702,
6701,
14,
374,
63,
3919,
63,
1881,
360,
2792,
14,
11653,
358,
272,
702,
6701,
14,
633,
63,
11332,
2336,
9743,
358,
421,
199,
32,
2926,
360,
1589,
32397,
25952,
5174,
365,
4702,
9988,
199,
318,
314,
63,
2902,
63,
374,
63,
2682,
8,
2926,
12,
5174,
63,
505,
304,
272,
702,
6701,
14,
3919,
63,
505,
5175,
1972,
13,
8741,
282,
14,
2682,
358,
508,
5174,
63,
505,
421,
199,
32,
2926,
360,
1589,
4676,
9592,
365,
8917,
9988,
199,
318,
4676,
63,
7196,
63,
6604,
8,
2926,
304,
272,
702,
6701,
14,
3919,
63,
6604,
360,
964,
3,
2886,
63,
964,
14,
2886,
63,
964,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
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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012
# Authors: Pietro Berkes,
# Andreas Muller
# Mathieu Blondel
# Olivier Grisel
# Arnaud Joly
# Denis Engemann
# Giorgio Patrini
# Thierry Guillemot
# License: BSD 3 clause
import os
import inspect
import pkgutil
import warnings
import sys
import struct
import scipy as sp
import scipy.io
from functools import wraps
from operator import itemgetter
try:
# Python 2
from urllib2 import urlopen
from urllib2 import HTTPError
except ImportError:
# Python 3+
from urllib.request import urlopen
from urllib.error import HTTPError
import tempfile
import shutil
import os.path as op
import atexit
import unittest
# WindowsError only exist on Windows
try:
WindowsError
except NameError:
WindowsError = None
import sklearn
from sklearn.base import BaseEstimator
from sklearn.externals import joblib
from nose.tools import raises
from nose import with_setup
from numpy.testing import assert_almost_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_less
from numpy.testing import assert_approx_equal
import numpy as np
from sklearn.base import (ClassifierMixin, RegressorMixin, TransformerMixin,
ClusterMixin)
from sklearn.cluster import DBSCAN
__all__ = ["assert_equal", "assert_not_equal", "assert_raises",
"assert_raises_regexp", "raises", "with_setup", "assert_true",
"assert_false", "assert_almost_equal", "assert_array_equal",
"assert_array_almost_equal", "assert_array_less",
"assert_less", "assert_less_equal",
"assert_greater", "assert_greater_equal",
"assert_approx_equal", "SkipTest"]
_dummy = unittest.TestCase('__init__')
assert_equal = _dummy.assertEqual
assert_not_equal = _dummy.assertNotEqual
assert_true = _dummy.assertTrue
assert_false = _dummy.assertFalse
assert_raises = _dummy.assertRaises
SkipTest = unittest.case.SkipTest
assert_dict_equal = _dummy.assertDictEqual
assert_in = _dummy.assertIn
assert_not_in = _dummy.assertNotIn
assert_less = _dummy.assertLess
assert_greater = _dummy.assertGreater
assert_less_equal = _dummy.assertLessEqual
assert_greater_equal = _dummy.assertGreaterEqual
try:
assert_raises_regex = _dummy.assertRaisesRegex
except AttributeError:
# Python 2.7
assert_raises_regex = _dummy.assertRaisesRegexp
# assert_raises_regexp is deprecated in Python 3.4 in favor of
# assert_raises_regex but lets keep the backward compat in scikit-learn with
# the old name for now
assert_raises_regexp = assert_raises_regex
def assert_warns(warning_class, func, *args, **kw):
"""Test that a certain warning occurs.
Parameters
----------
warning_class : the warning class
The class to test for, e.g. UserWarning.
func : callable
Calable object to trigger warnings.
*args : the positional arguments to `func`.
**kw : the keyword arguments to `func`
Returns
-------
result : the return value of `func`
"""
# very important to avoid uncontrolled state propagation
clean_warning_registry()
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
# Trigger a warning.
result = func(*args, **kw)
if hasattr(np, 'VisibleDeprecationWarning'):
# Filter out numpy-specific warnings in numpy >= 1.9
w = [e for e in w
if e.category is not np.VisibleDeprecationWarning]
# Verify some things
if not len(w) > 0:
raise AssertionError("No warning raised when calling %s"
% func.__name__)
found = any(warning.category is warning_class for warning in w)
if not found:
raise AssertionError("%s did not give warning: %s( is %s)"
% (func.__name__, warning_class, w))
return result
def assert_warns_message(warning_class, message, func, *args, **kw):
# very important to avoid uncontrolled state propagation
"""Test that a certain warning occurs and with a certain message.
Parameters
----------
warning_class : the warning class
The class to test for, e.g. UserWarning.
message : str | callable
The entire message or a substring to test for. If callable,
it takes a string as argument and will trigger an assertion error
if it returns `False`.
func : callable
Calable object to trigger warnings.
*args : the positional arguments to `func`.
**kw : the keyword arguments to `func`.
Returns
-------
result : the return value of `func`
"""
clean_warning_registry()
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
if hasattr(np, 'VisibleDeprecationWarning'):
# Let's not catch the numpy internal DeprecationWarnings
warnings.simplefilter('ignore', np.VisibleDeprecationWarning)
# Trigger a warning.
result = func(*args, **kw)
# Verify some things
if not len(w) > 0:
raise AssertionError("No warning raised when calling %s"
% func.__name__)
found = [issubclass(warning.category, warning_class) for warning in w]
if not any(found):
raise AssertionError("No warning raised for %s with class "
"%s"
% (func.__name__, warning_class))
message_found = False
# Checks the message of all warnings belong to warning_class
for index in [i for i, x in enumerate(found) if x]:
# substring will match, the entire message with typo won't
msg = w[index].message # For Python 3 compatibility
msg = str(msg.args[0] if hasattr(msg, 'args') else msg)
if callable(message): # add support for certain tests
check_in_message = message
else:
check_in_message = lambda msg: message in msg
if check_in_message(msg):
message_found = True
break
if not message_found:
raise AssertionError("Did not receive the message you expected "
"('%s') for <%s>, got: '%s'"
% (message, func.__name__, msg))
return result
# To remove when we support numpy 1.7
def assert_no_warnings(func, *args, **kw):
# very important to avoid uncontrolled state propagation
clean_warning_registry()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
result = func(*args, **kw)
if hasattr(np, 'VisibleDeprecationWarning'):
# Filter out numpy-specific warnings in numpy >= 1.9
w = [e for e in w
if e.category is not np.VisibleDeprecationWarning]
if len(w) > 0:
raise AssertionError("Got warnings when calling %s: [%s]"
% (func.__name__,
', '.join(str(warning) for warning in w)))
return result
def ignore_warnings(obj=None, category=Warning):
"""Context manager and decorator to ignore warnings.
Note. Using this (in both variants) will clear all warnings
from all python modules loaded. In case you need to test
cross-module-warning-logging this is not your tool of choice.
Parameters
----------
category : warning class, defaults to Warning.
The category to filter. If Warning, all categories will be muted.
Examples
--------
>>> with ignore_warnings():
... warnings.warn('buhuhuhu')
>>> def nasty_warn():
... warnings.warn('buhuhuhu')
... print(42)
>>> ignore_warnings(nasty_warn)()
42
"""
if callable(obj):
return _IgnoreWarnings(category=category)(obj)
else:
return _IgnoreWarnings(category=category)
class _IgnoreWarnings(object):
"""Improved and simplified Python warnings context manager and decorator.
This class allows to ignore the warnings raise by a function.
Copied from Python 2.7.5 and modified as required.
Parameters
----------
category : tuple of warning class, defaut to Warning
The category to filter. By default, all the categories will be muted.
"""
def __init__(self, category):
self._record = True
self._module = sys.modules['warnings']
self._entered = False
self.log = []
self.category = category
def __call__(self, fn):
"""Decorator to catch and hide warnings without visual nesting."""
@wraps(fn)
def wrapper(*args, **kwargs):
# very important to avoid uncontrolled state propagation
clean_warning_registry()
with warnings.catch_warnings():
warnings.simplefilter("ignore", self.category)
return fn(*args, **kwargs)
return wrapper
def __repr__(self):
args = []
if self._record:
args.append("record=True")
if self._module is not sys.modules['warnings']:
args.append("module=%r" % self._module)
name = type(self).__name__
return "%s(%s)" % (name, ", ".join(args))
def __enter__(self):
clean_warning_registry() # be safe and not propagate state + chaos
warnings.simplefilter("ignore", self.category)
if self._entered:
raise RuntimeError("Cannot enter %r twice" % self)
self._entered = True
self._filters = self._module.filters
self._module.filters = self._filters[:]
self._showwarning = self._module.showwarning
def __exit__(self, *exc_info):
if not self._entered:
raise RuntimeError("Cannot exit %r without entering first" % self)
self._module.filters = self._filters
self._module.showwarning = self._showwarning
self.log[:] = []
clean_warning_registry() # be safe and not propagate state + chaos
assert_less = _dummy.assertLess
assert_greater = _dummy.assertGreater
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
err_msg='', verbose=True):
actual, desired = np.asanyarray(actual), np.asanyarray(desired)
if np.allclose(actual, desired, rtol=rtol, atol=atol):
return
msg = ('Array not equal to tolerance rtol=%g, atol=%g: '
'actual %s, desired %s') % (rtol, atol, actual, desired)
raise AssertionError(msg)
if hasattr(np.testing, 'assert_allclose'):
assert_allclose = np.testing.assert_allclose
else:
assert_allclose = _assert_allclose
def assert_raise_message(exceptions, message, function, *args, **kwargs):
"""Helper function to test error messages in exceptions.
Parameters
----------
exceptions : exception or tuple of exception
Name of the estimator
function : callable
Calable object to raise error
*args : the positional arguments to `function`.
**kw : the keyword arguments to `function`
"""
try:
function(*args, **kwargs)
except exceptions as e:
error_message = str(e)
if message not in error_message:
raise AssertionError("Error message does not include the expected"
" string: %r. Observed error message: %r" %
(message, error_message))
else:
# concatenate exception names
if isinstance(exceptions, tuple):
names = " or ".join(e.__name__ for e in exceptions)
else:
names = exceptions.__name__
raise AssertionError("%s not raised by %s" %
(names, function.__name__))
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
"""Create a fake mldata data set.
Parameters
----------
columns_dict : dict, keys=str, values=ndarray
Contains data as columns_dict[column_name] = array of data.
dataname : string
Name of data set.
matfile : string or file object
The file name string or the file-like object of the output file.
ordering : list, default None
List of column_names, determines the ordering in the data set.
Notes
-----
This function transposes all arrays, while fetch_mldata only transposes
'data', keep that into account in the tests.
"""
datasets = dict(columns_dict)
# transpose all variables
for name in datasets:
datasets[name] = datasets[name].T
if ordering is None:
ordering = sorted(list(datasets.keys()))
# NOTE: setting up this array is tricky, because of the way Matlab
# re-packages 1D arrays
datasets['mldata_descr_ordering'] = sp.empty((1, len(ordering)),
dtype='object')
for i, name in enumerate(ordering):
datasets['mldata_descr_ordering'][0, i] = name
scipy.io.savemat(matfile, datasets, oned_as='column')
class mock_mldata_urlopen(object):
def __init__(self, mock_datasets):
"""Object that mocks the urlopen function to fake requests to mldata.
`mock_datasets` is a dictionary of {dataset_name: data_dict}, or
{dataset_name: (data_dict, ordering).
`data_dict` itself is a dictionary of {column_name: data_array},
and `ordering` is a list of column_names to determine the ordering
in the data set (see `fake_mldata` for details).
When requesting a dataset with a name that is in mock_datasets,
this object creates a fake dataset in a StringIO object and
returns it. Otherwise, it raises an HTTPError.
"""
self.mock_datasets = mock_datasets
def __call__(self, urlname):
dataset_name = urlname.split('/')[-1]
if dataset_name in self.mock_datasets:
resource_name = '_' + dataset_name
from io import BytesIO
matfile = BytesIO()
dataset = self.mock_datasets[dataset_name]
ordering = None
if isinstance(dataset, tuple):
dataset, ordering = dataset
fake_mldata(dataset, resource_name, matfile, ordering)
matfile.seek(0)
return matfile
else:
raise HTTPError(urlname, 404, dataset_name + " is not available",
[], None)
def install_mldata_mock(mock_datasets):
# Lazy import to avoid mutually recursive imports
from sklearn import datasets
datasets.mldata.urlopen = mock_mldata_urlopen(mock_datasets)
def uninstall_mldata_mock():
# Lazy import to avoid mutually recursive imports
from sklearn import datasets
datasets.mldata.urlopen = urlopen
# Meta estimators need another estimator to be instantiated.
META_ESTIMATORS = ["OneVsOneClassifier", "MultiOutputEstimator",
"MultiOutputRegressor", "MultiOutputClassifier",
"OutputCodeClassifier", "OneVsRestClassifier",
"RFE", "RFECV", "BaseEnsemble"]
# estimators that there is no way to default-construct sensibly
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV",
"SelectFromModel"]
# some trange ones
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
'LabelBinarizer', 'LabelEncoder',
'MultiLabelBinarizer', 'TfidfTransformer',
'TfidfVectorizer', 'IsotonicRegression',
'OneHotEncoder', 'RandomTreesEmbedding',
'FeatureHasher', 'DummyClassifier', 'DummyRegressor',
'TruncatedSVD', 'PolynomialFeatures',
'GaussianRandomProjectionHash', 'HashingVectorizer',
'CheckingClassifier', 'PatchExtractor', 'CountVectorizer',
# GradientBoosting base estimators, maybe should
# exclude them in another way
'ZeroEstimator', 'ScaledLogOddsEstimator',
'QuantileEstimator', 'MeanEstimator',
'LogOddsEstimator', 'PriorProbabilityEstimator',
'_SigmoidCalibration', 'VotingClassifier']
def all_estimators(include_meta_estimators=False,
include_other=False, type_filter=None,
include_dont_test=False):
"""Get a list of all estimators from sklearn.
This function crawls the module and gets all classes that inherit
from BaseEstimator. Classes that are defined in test-modules are not
included.
By default meta_estimators such as GridSearchCV are also not included.
Parameters
----------
include_meta_estimators : boolean, default=False
Whether to include meta-estimators that can be constructed using
an estimator as their first argument. These are currently
BaseEnsemble, OneVsOneClassifier, OutputCodeClassifier,
OneVsRestClassifier, RFE, RFECV.
include_other : boolean, default=False
Wether to include meta-estimators that are somehow special and can
not be default-constructed sensibly. These are currently
Pipeline, FeatureUnion and GridSearchCV
include_dont_test : boolean, default=False
Whether to include "special" label estimator or test processors.
type_filter : string, list of string, or None, default=None
Which kind of estimators should be returned. If None, no filter is
applied and all estimators are returned. Possible values are
'classifier', 'regressor', 'cluster' and 'transformer' to get
estimators only of these specific types, or a list of these to
get the estimators that fit at least one of the types.
Returns
-------
estimators : list of tuples
List of (name, class), where ``name`` is the class name as string
and ``class`` is the actuall type of the class.
"""
def is_abstract(c):
if not(hasattr(c, '__abstractmethods__')):
return False
if not len(c.__abstractmethods__):
return False
return True
all_classes = []
# get parent folder
path = sklearn.__path__
for importer, modname, ispkg in pkgutil.walk_packages(
path=path, prefix='sklearn.', onerror=lambda x: None):
if (".tests." in modname):
continue
module = __import__(modname, fromlist="dummy")
classes = inspect.getmembers(module, inspect.isclass)
all_classes.extend(classes)
all_classes = set(all_classes)
estimators = [c for c in all_classes
if (issubclass(c[1], BaseEstimator) and
c[0] != 'BaseEstimator')]
# get rid of abstract base classes
estimators = [c for c in estimators if not is_abstract(c[1])]
if not include_dont_test:
estimators = [c for c in estimators if not c[0] in DONT_TEST]
if not include_other:
estimators = [c for c in estimators if not c[0] in OTHER]
# possibly get rid of meta estimators
if not include_meta_estimators:
estimators = [c for c in estimators if not c[0] in META_ESTIMATORS]
if type_filter is not None:
if not isinstance(type_filter, list):
type_filter = [type_filter]
else:
type_filter = list(type_filter) # copy
filtered_estimators = []
filters = {'classifier': ClassifierMixin,
'regressor': RegressorMixin,
'transformer': TransformerMixin,
'cluster': ClusterMixin}
for name, mixin in filters.items():
if name in type_filter:
type_filter.remove(name)
filtered_estimators.extend([est for est in estimators
if issubclass(est[1], mixin)])
estimators = filtered_estimators
if type_filter:
raise ValueError("Parameter type_filter must be 'classifier', "
"'regressor', 'transformer', 'cluster' or "
"None, got"
" %s." % repr(type_filter))
# drop duplicates, sort for reproducibility
# itemgetter is used to ensure the sort does not extend to the 2nd item of
# the tuple
return sorted(set(estimators), key=itemgetter(0))
def set_random_state(estimator, random_state=0):
"""Set random state of an estimator if it has the `random_state` param.
Classes for whom random_state is deprecated are ignored. Currently DBSCAN
is one such class.
"""
if isinstance(estimator, DBSCAN):
return
if "random_state" in estimator.get_params():
estimator.set_params(random_state=random_state)
def if_matplotlib(func):
"""Test decorator that skips test if matplotlib not installed."""
@wraps(func)
def run_test(*args, **kwargs):
try:
import matplotlib
matplotlib.use('Agg', warn=False)
# this fails if no $DISPLAY specified
import matplotlib.pyplot as plt
plt.figure()
except ImportError:
raise SkipTest('Matplotlib not available.')
else:
return func(*args, **kwargs)
return run_test
def skip_if_32bit(func):
"""Test decorator that skips tests on 32bit platforms."""
@wraps(func)
def run_test(*args, **kwargs):
bits = 8 * struct.calcsize("P")
if bits == 32:
raise SkipTest('Test skipped on 32bit platforms.')
else:
return func(*args, **kwargs)
return run_test
def if_safe_multiprocessing_with_blas(func):
"""Decorator for tests involving both BLAS calls and multiprocessing.
Under POSIX (e.g. Linux or OSX), using multiprocessing in conjunction with
some implementation of BLAS (or other libraries that manage an internal
posix thread pool) can cause a crash or a freeze of the Python process.
In practice all known packaged distributions (from Linux distros or
Anaconda) of BLAS under Linux seems to be safe. So we this problem seems to
only impact OSX users.
This wrapper makes it possible to skip tests that can possibly cause
this crash under OS X with.
Under Python 3.4+ it is possible to use the `forkserver` start method
for multiprocessing to avoid this issue. However it can cause pickling
errors on interactively defined functions. It therefore not enabled by
default.
"""
@wraps(func)
def run_test(*args, **kwargs):
if sys.platform == 'darwin':
raise SkipTest(
"Possible multi-process bug with some BLAS")
return func(*args, **kwargs)
return run_test
def clean_warning_registry():
"""Safe way to reset warnings."""
warnings.resetwarnings()
reg = "__warningregistry__"
for mod_name, mod in list(sys.modules.items()):
if 'six.moves' in mod_name:
continue
if hasattr(mod, reg):
getattr(mod, reg).clear()
def check_skip_network():
if int(os.environ.get('SKLEARN_SKIP_NETWORK_TESTS', 0)):
raise SkipTest("Text tutorial requires large dataset download")
def check_skip_travis():
"""Skip test if being run on Travis."""
if os.environ.get('TRAVIS') == "true":
raise SkipTest("This test needs to be skipped on Travis")
def _delete_folder(folder_path, warn=False):
"""Utility function to cleanup a temporary folder if still existing.
Copy from joblib.pool (for independence).
"""
try:
if os.path.exists(folder_path):
# This can fail under windows,
# but will succeed when called by atexit
shutil.rmtree(folder_path)
except WindowsError:
if warn:
warnings.warn("Could not delete temporary folder %s" % folder_path)
class TempMemmap(object):
def __init__(self, data, mmap_mode='r'):
self.temp_folder = tempfile.mkdtemp(prefix='sklearn_testing_')
self.mmap_mode = mmap_mode
self.data = data
def __enter__(self):
fpath = op.join(self.temp_folder, 'data.pkl')
joblib.dump(self.data, fpath)
data_read_only = joblib.load(fpath, mmap_mode=self.mmap_mode)
atexit.register(lambda: _delete_folder(self.temp_folder, warn=True))
return data_read_only
def __exit__(self, exc_type, exc_val, exc_tb):
_delete_folder(self.temp_folder)
with_network = with_setup(check_skip_network)
with_travis = with_setup(check_skip_travis)
class _named_check(object):
"""Wraps a check to show a useful description
Parameters
----------
check : function
Must have ``__name__`` and ``__call__``
arg_text : str
A summary of arguments to the check
"""
# Setting the description on the function itself can give incorrect results
# in failing tests
def __init__(self, check, arg_text):
self.check = check
self.description = ("{0[1]}.{0[3]}:{1.__name__}({2})".format(
inspect.stack()[1], check, arg_text))
def __call__(self, *args, **kwargs):
return self.check(*args, **kwargs)
|
bsd-3-clause
|
[
624,
9029,
15841,
1041,
199,
199,
3,
1898,
334,
67,
9,
7760,
12,
6029,
199,
3,
6642,
26,
510,
14077,
293,
23207,
9246,
12,
199,
3,
3515,
6061,
264,
305,
22578,
1435,
199,
3,
3515,
21066,
29364,
699,
5298,
2264,
199,
3,
3515,
593,
317,
26645,
598,
322,
5891,
199,
3,
3515,
1952,
3540,
1181,
1603,
16242,
199,
3,
3515,
25187,
374,
3447,
303,
20059,
199,
3,
3515,
598,
73,
1308,
2308,
510,
292,
82,
2730,
199,
3,
3515,
3868,
4446,
651,
12436,
382,
3701,
357,
199,
3,
844,
26,
6289,
650,
8502,
199,
646,
747,
199,
646,
6485,
199,
646,
28728,
199,
646,
3598,
199,
646,
984,
199,
646,
2702,
199,
199,
646,
7026,
465,
2249,
199,
646,
7026,
14,
2308,
199,
504,
9143,
492,
14018,
199,
504,
4182,
492,
1242,
7416,
199,
893,
26,
272,
327,
2018,
499,
272,
687,
4011,
18,
492,
18279,
272,
687,
4011,
18,
492,
15050,
199,
2590,
3545,
26,
272,
327,
2018,
650,
11,
272,
687,
4011,
14,
1069,
492,
18279,
272,
687,
4011,
14,
705,
492,
15050,
199,
199,
646,
5549,
199,
646,
5145,
199,
646,
747,
14,
515,
465,
1687,
199,
646,
19840,
199,
646,
2882,
199,
199,
3,
23950,
1454,
2187,
641,
5417,
199,
893,
26,
272,
23950,
199,
2590,
12746,
26,
272,
23950,
275,
488,
199,
199,
646,
6357,
199,
504,
6357,
14,
1095,
492,
3523,
13183,
199,
504,
6357,
14,
24688,
492,
3906,
773,
199,
199,
504,
11354,
14,
2537,
492,
6534,
199,
504,
11354,
492,
543,
63,
2758,
199,
199,
504,
2680,
14,
4776,
492,
702,
63,
4398,
63,
1452,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
4398,
63,
1452,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
2003,
199,
504,
2680,
14,
4776,
492,
702,
63,
16815,
63,
1452,
199,
646,
2680,
465,
980,
199,
199,
504,
6357,
14,
1095,
492,
334,
8508,
4256,
12,
799,
3313,
269,
4256,
12,
30486,
4256,
12,
2079,
16454,
4256,
9,
199,
504,
6357,
14,
4201,
492,
6249,
24078,
199,
199,
363,
452,
363,
275,
2097,
479,
63,
1452,
401,
298,
479,
63,
1397,
63,
1452,
401,
298,
479,
63,
3536,
401,
1779,
298,
479,
63,
3536,
63,
11191,
401,
298,
3536,
401,
298,
1045,
63,
2758,
401,
298,
479,
63,
2052,
401,
1779,
298,
479,
63,
3910,
401,
298,
479,
63,
4398,
63,
1452,
401,
298,
479,
63,
1144,
63,
1452,
401,
1779,
298,
479,
63,
1144,
63,
4398,
63,
1452,
401,
298,
479,
63,
1144,
63,
2003,
401,
1779,
298,
479,
63,
2003,
401,
298,
479,
63,
2003,
63,
1452,
401,
1779,
298,
479,
63,
13154,
401,
298,
479,
63,
13154,
63,
1452,
401,
1779,
298,
479,
63,
16815,
63,
1452,
401,
298,
25755,
937,
421,
199,
63,
5869,
275,
2882,
14,
1746,
10714,
826,
13766,
199,
479,
63,
1452,
275,
485,
5869,
14,
629,
199,
479,
63,
1397,
63,
1452,
275,
485,
5869,
14,
7418,
199,
479,
63,
2052,
275,
485,
5869,
14,
1815,
199,
479,
63,
3910,
275,
485,
5869,
14,
3334,
199,
479,
63,
3536,
275,
485,
5869,
14,
1855,
199,
25755,
275,
2882,
14,
2546,
14,
25755,
199,
479,
63,
807,
63,
1452,
275,
485,
5869,
14,
19512,
199,
479,
63,
262,
275,
485,
5869,
14,
4080,
199,
479,
63,
1397,
63,
262,
275,
485,
5869,
14,
8795,
199,
479,
63,
2003,
275,
485,
5869,
14,
15625,
199,
479,
63,
13154,
275,
485,
5869,
14,
15070,
199,
479,
63,
2003,
63,
1452,
275,
485,
5869,
14,
15625,
591,
199,
479,
63,
13154,
63,
1452,
275,
485,
5869,
14,
26875,
421,
199,
893,
26,
272,
702,
63,
3536,
63,
3821,
275,
485,
5869,
14,
16499,
199,
2590,
4281,
26,
272,
327,
2018,
499,
14,
23,
272,
702,
63,
3536,
63,
3821,
275,
485,
5869,
14,
10835,
199,
3,
702,
63,
3536,
63,
11191,
365,
5906,
315,
2018,
650,
14,
20,
315,
17914,
402,
199,
3,
702,
63,
3536,
63,
3821,
1325,
19083,
4215,
314,
13388,
8434,
315,
6276,
6065,
13,
4643,
543,
199,
3,
314,
2269,
536,
367,
3063,
199,
479,
63,
3536,
63,
11191,
275,
702,
63,
3536,
63,
3821,
421,
199,
318,
702,
63,
19811,
8,
3764,
63,
533,
12,
2562,
12,
627,
589,
12,
1011,
829,
304,
272,
408,
774,
626,
282,
9842,
5721,
11058,
14,
339,
3897,
272,
4143,
272,
5721,
63,
533,
520,
314,
5721,
1021,
267,
710,
1021,
370,
511,
367,
12,
325,
14,
71,
14,
2876,
3849,
14,
339,
2562,
520,
4550,
267,
8256,
461,
909,
370,
6804,
3598,
14,
339,
627,
589,
520,
314,
11333,
2368,
370,
658,
1532,
2313,
339,
1011,
829,
520,
314,
4252,
2368,
370,
658,
1532,
64,
339,
1803,
272,
5514,
339,
754,
520,
314,
372,
574,
402,
658,
1532,
64,
339,
408,
272,
327,
7437,
11012,
370,
5126,
625,
2785,
1146,
1174,
17012,
272,
3633,
63,
3764,
63,
5189,
342,
272,
543,
3598,
14,
9341,
63,
5451,
8,
3059,
29,
549,
9,
465,
336,
26,
267,
327,
8790,
1180,
1006,
3598,
370,
3544,
506,
15572,
14,
267,
3598,
14,
18815,
480,
9223,
531,
267,
327,
24015,
282,
5721,
14,
267,
754,
275,
2562,
2031,
589,
12,
1011,
829,
9,
267,
340,
2688,
8,
1590,
12,
283,
14917,
15561,
735,
288,
327,
9388,
734,
2680,
13,
6100,
3598,
315,
2680,
2356,
413,
14,
25,
288,
336,
275,
359,
69,
367,
325,
315,
336,
326,
340,
325,
14,
3710,
365,
440,
980,
14,
14917,
15561,
61,
398,
327,
7635,
2005,
7645,
267,
340,
440,
822,
8,
87,
9,
690,
378,
26,
288,
746,
9070,
480,
1944,
5721,
4915,
1380,
6358,
450,
83,
2,
639,
450,
2562,
855,
354,
3368,
398,
1911,
275,
1263,
8,
3764,
14,
3710,
365,
5721,
63,
533,
367,
5721,
315,
336,
9,
267,
340,
440,
1911,
26,
288,
746,
9070,
3647,
83,
8103,
440,
8120,
5721,
26,
450,
83,
8,
365,
450,
83,
2924,
639,
450,
334,
1532,
855,
354,
3108,
5721,
63,
533,
12,
336,
430,
272,
372,
754,
421,
199,
318,
702,
63,
19811,
63,
1188,
8,
3764,
63,
533,
12,
1245,
12,
2562,
12,
627,
589,
12,
1011,
829,
304,
272,
327,
7437,
11012,
370
] |
[
9029,
15841,
1041,
199,
199,
3,
1898,
334,
67,
9,
7760,
12,
6029,
199,
3,
6642,
26,
510,
14077,
293,
23207,
9246,
12,
199,
3,
3515,
6061,
264,
305,
22578,
1435,
199,
3,
3515,
21066,
29364,
699,
5298,
2264,
199,
3,
3515,
593,
317,
26645,
598,
322,
5891,
199,
3,
3515,
1952,
3540,
1181,
1603,
16242,
199,
3,
3515,
25187,
374,
3447,
303,
20059,
199,
3,
3515,
598,
73,
1308,
2308,
510,
292,
82,
2730,
199,
3,
3515,
3868,
4446,
651,
12436,
382,
3701,
357,
199,
3,
844,
26,
6289,
650,
8502,
199,
646,
747,
199,
646,
6485,
199,
646,
28728,
199,
646,
3598,
199,
646,
984,
199,
646,
2702,
199,
199,
646,
7026,
465,
2249,
199,
646,
7026,
14,
2308,
199,
504,
9143,
492,
14018,
199,
504,
4182,
492,
1242,
7416,
199,
893,
26,
272,
327,
2018,
499,
272,
687,
4011,
18,
492,
18279,
272,
687,
4011,
18,
492,
15050,
199,
2590,
3545,
26,
272,
327,
2018,
650,
11,
272,
687,
4011,
14,
1069,
492,
18279,
272,
687,
4011,
14,
705,
492,
15050,
199,
199,
646,
5549,
199,
646,
5145,
199,
646,
747,
14,
515,
465,
1687,
199,
646,
19840,
199,
646,
2882,
199,
199,
3,
23950,
1454,
2187,
641,
5417,
199,
893,
26,
272,
23950,
199,
2590,
12746,
26,
272,
23950,
275,
488,
199,
199,
646,
6357,
199,
504,
6357,
14,
1095,
492,
3523,
13183,
199,
504,
6357,
14,
24688,
492,
3906,
773,
199,
199,
504,
11354,
14,
2537,
492,
6534,
199,
504,
11354,
492,
543,
63,
2758,
199,
199,
504,
2680,
14,
4776,
492,
702,
63,
4398,
63,
1452,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
4398,
63,
1452,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
2003,
199,
504,
2680,
14,
4776,
492,
702,
63,
16815,
63,
1452,
199,
646,
2680,
465,
980,
199,
199,
504,
6357,
14,
1095,
492,
334,
8508,
4256,
12,
799,
3313,
269,
4256,
12,
30486,
4256,
12,
2079,
16454,
4256,
9,
199,
504,
6357,
14,
4201,
492,
6249,
24078,
199,
199,
363,
452,
363,
275,
2097,
479,
63,
1452,
401,
298,
479,
63,
1397,
63,
1452,
401,
298,
479,
63,
3536,
401,
1779,
298,
479,
63,
3536,
63,
11191,
401,
298,
3536,
401,
298,
1045,
63,
2758,
401,
298,
479,
63,
2052,
401,
1779,
298,
479,
63,
3910,
401,
298,
479,
63,
4398,
63,
1452,
401,
298,
479,
63,
1144,
63,
1452,
401,
1779,
298,
479,
63,
1144,
63,
4398,
63,
1452,
401,
298,
479,
63,
1144,
63,
2003,
401,
1779,
298,
479,
63,
2003,
401,
298,
479,
63,
2003,
63,
1452,
401,
1779,
298,
479,
63,
13154,
401,
298,
479,
63,
13154,
63,
1452,
401,
1779,
298,
479,
63,
16815,
63,
1452,
401,
298,
25755,
937,
421,
199,
63,
5869,
275,
2882,
14,
1746,
10714,
826,
13766,
199,
479,
63,
1452,
275,
485,
5869,
14,
629,
199,
479,
63,
1397,
63,
1452,
275,
485,
5869,
14,
7418,
199,
479,
63,
2052,
275,
485,
5869,
14,
1815,
199,
479,
63,
3910,
275,
485,
5869,
14,
3334,
199,
479,
63,
3536,
275,
485,
5869,
14,
1855,
199,
25755,
275,
2882,
14,
2546,
14,
25755,
199,
479,
63,
807,
63,
1452,
275,
485,
5869,
14,
19512,
199,
479,
63,
262,
275,
485,
5869,
14,
4080,
199,
479,
63,
1397,
63,
262,
275,
485,
5869,
14,
8795,
199,
479,
63,
2003,
275,
485,
5869,
14,
15625,
199,
479,
63,
13154,
275,
485,
5869,
14,
15070,
199,
479,
63,
2003,
63,
1452,
275,
485,
5869,
14,
15625,
591,
199,
479,
63,
13154,
63,
1452,
275,
485,
5869,
14,
26875,
421,
199,
893,
26,
272,
702,
63,
3536,
63,
3821,
275,
485,
5869,
14,
16499,
199,
2590,
4281,
26,
272,
327,
2018,
499,
14,
23,
272,
702,
63,
3536,
63,
3821,
275,
485,
5869,
14,
10835,
199,
3,
702,
63,
3536,
63,
11191,
365,
5906,
315,
2018,
650,
14,
20,
315,
17914,
402,
199,
3,
702,
63,
3536,
63,
3821,
1325,
19083,
4215,
314,
13388,
8434,
315,
6276,
6065,
13,
4643,
543,
199,
3,
314,
2269,
536,
367,
3063,
199,
479,
63,
3536,
63,
11191,
275,
702,
63,
3536,
63,
3821,
421,
199,
318,
702,
63,
19811,
8,
3764,
63,
533,
12,
2562,
12,
627,
589,
12,
1011,
829,
304,
272,
408,
774,
626,
282,
9842,
5721,
11058,
14,
339,
3897,
272,
4143,
272,
5721,
63,
533,
520,
314,
5721,
1021,
267,
710,
1021,
370,
511,
367,
12,
325,
14,
71,
14,
2876,
3849,
14,
339,
2562,
520,
4550,
267,
8256,
461,
909,
370,
6804,
3598,
14,
339,
627,
589,
520,
314,
11333,
2368,
370,
658,
1532,
2313,
339,
1011,
829,
520,
314,
4252,
2368,
370,
658,
1532,
64,
339,
1803,
272,
5514,
339,
754,
520,
314,
372,
574,
402,
658,
1532,
64,
339,
408,
272,
327,
7437,
11012,
370,
5126,
625,
2785,
1146,
1174,
17012,
272,
3633,
63,
3764,
63,
5189,
342,
272,
543,
3598,
14,
9341,
63,
5451,
8,
3059,
29,
549,
9,
465,
336,
26,
267,
327,
8790,
1180,
1006,
3598,
370,
3544,
506,
15572,
14,
267,
3598,
14,
18815,
480,
9223,
531,
267,
327,
24015,
282,
5721,
14,
267,
754,
275,
2562,
2031,
589,
12,
1011,
829,
9,
267,
340,
2688,
8,
1590,
12,
283,
14917,
15561,
735,
288,
327,
9388,
734,
2680,
13,
6100,
3598,
315,
2680,
2356,
413,
14,
25,
288,
336,
275,
359,
69,
367,
325,
315,
336,
326,
340,
325,
14,
3710,
365,
440,
980,
14,
14917,
15561,
61,
398,
327,
7635,
2005,
7645,
267,
340,
440,
822,
8,
87,
9,
690,
378,
26,
288,
746,
9070,
480,
1944,
5721,
4915,
1380,
6358,
450,
83,
2,
639,
450,
2562,
855,
354,
3368,
398,
1911,
275,
1263,
8,
3764,
14,
3710,
365,
5721,
63,
533,
367,
5721,
315,
336,
9,
267,
340,
440,
1911,
26,
288,
746,
9070,
3647,
83,
8103,
440,
8120,
5721,
26,
450,
83,
8,
365,
450,
83,
2924,
639,
450,
334,
1532,
855,
354,
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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
] |
hkernbach/arangodb
|
3rdParty/V8/v5.7.492.77/tools/testrunner/network/endpoint.py
|
23
|
4536
|
# Copyright 2012 the V8 project 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:
#
# * 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 multiprocessing
import os
import Queue
import threading
import time
from ..local import execution
from ..local import progress
from ..local import testsuite
from ..local import utils
from ..server import compression
class EndpointProgress(progress.ProgressIndicator):
def __init__(self, sock, server, ctx):
super(EndpointProgress, self).__init__()
self.sock = sock
self.server = server
self.context = ctx
self.results_queue = [] # Accessors must synchronize themselves.
self.sender_lock = threading.Lock()
self.senderthread = threading.Thread(target=self._SenderThread)
self.senderthread.start()
def HasRun(self, test, has_unexpected_output):
# The runners that call this have a lock anyway, so this is safe.
self.results_queue.append(test)
def _SenderThread(self):
keep_running = True
tests = []
self.sender_lock.acquire()
while keep_running:
time.sleep(0.1)
# This should be "atomic enough" without locking :-)
# (We don't care which list any new elements get appended to, as long
# as we don't lose any and the last one comes last.)
current = self.results_queue
self.results_queue = []
for c in current:
if c is None:
keep_running = False
else:
tests.append(c)
if keep_running and len(tests) < 1:
continue # Wait for more results.
if len(tests) < 1: break # We're done here.
result = []
for t in tests:
result.append(t.PackResult())
try:
compression.Send(result, self.sock)
except:
self.runner.terminate = True
for t in tests:
self.server.CompareOwnPerf(t, self.context.arch, self.context.mode)
tests = []
self.sender_lock.release()
def Execute(workspace, ctx, tests, sock, server):
suite_paths = utils.GetSuitePaths(os.path.join(workspace, "test"))
suites = []
for root in suite_paths:
suite = testsuite.TestSuite.LoadTestSuite(
os.path.join(workspace, "test", root))
if suite:
suite.SetupWorkingDirectory()
suites.append(suite)
suites_dict = {}
for s in suites:
suites_dict[s.name] = s
s.tests = []
for t in tests:
suite = suites_dict[t.suite]
t.suite = suite
suite.tests.append(t)
suites = [ s for s in suites if len(s.tests) > 0 ]
for s in suites:
s.DownloadData()
progress_indicator = EndpointProgress(sock, server, ctx)
runner = execution.Runner(suites, progress_indicator, ctx)
try:
runner.Run(server.jobs)
except IOError, e:
if e.errno == 2:
message = ("File not found: %s, maybe you forgot to 'git add' it?" %
e.filename)
else:
message = "%s" % e
compression.Send([[-1, message]], sock)
progress_indicator.HasRun(None, None) # Sentinel to signal the end.
progress_indicator.sender_lock.acquire() # Released when sending is done.
progress_indicator.sender_lock.release()
|
apache-2.0
|
[
3,
1898,
6029,
314,
812,
24,
2199,
11462,
14,
2900,
4481,
4644,
14,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
755,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
199,
3,
755,
6450,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
199,
3,
755,
543,
314,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
755,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
199,
3,
755,
687,
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,
646,
12866,
199,
646,
747,
199,
646,
10703,
199,
646,
5796,
199,
646,
900,
199,
199,
504,
2508,
1832,
492,
6451,
199,
504,
2508,
1832,
492,
6696,
199,
504,
2508,
1832,
492,
2295,
2577,
199,
504,
2508,
1832,
492,
3778,
199,
504,
2508,
1000,
492,
10291,
421,
199,
533,
9599,
1403,
11504,
8,
5734,
14,
11504,
24000,
304,
523,
347,
636,
826,
721,
277,
12,
6771,
12,
1654,
12,
4027,
304,
272,
1613,
8,
11442,
11504,
12,
291,
2843,
826,
4533,
272,
291,
14,
5096,
275,
6771,
272,
291,
14,
1000,
275,
1654,
272,
291,
14,
1100,
275,
4027,
272,
291,
14,
2604,
63,
1825,
275,
942,
221,
327,
11003,
1384,
1471,
31021,
17279,
14,
272,
291,
14,
8114,
63,
831,
275,
5796,
14,
6432,
342,
272,
291,
14,
8114,
2671,
275,
5796,
14,
4436,
8,
1375,
29,
277,
423,
28002,
4436,
9,
272,
291,
14,
8114,
2671,
14,
928,
342,
819,
347,
13481,
2540,
8,
277,
12,
511,
12,
965,
63,
8953,
63,
1199,
304,
272,
327,
710,
1255,
8715,
626,
1240,
642,
1172,
282,
4650,
15988,
12,
880,
642,
365,
5048,
14,
272,
291,
14,
2604,
63,
1825,
14,
740,
8,
396,
9,
819,
347,
485,
28002,
4436,
8,
277,
304,
272,
4215,
63,
5720,
275,
715,
272,
2295,
275,
942,
272,
291,
14,
8114,
63,
831,
14,
8174,
342,
272,
1830,
4215,
63,
5720,
26,
489,
900,
14,
4532,
8,
16,
14,
17,
9,
489,
327,
961,
1077,
506,
298,
10910,
8321,
2,
1928,
27267,
22901,
9,
489,
327,
334,
6004,
2793,
1133,
10296,
1314,
769,
1263,
892,
4008,
664,
11544,
370,
12,
465,
1846,
489,
327,
465,
781,
2793,
1133,
27332,
1263,
436,
314,
2061,
1373,
12477,
2061,
4959,
489,
1453,
275,
291,
14,
2604,
63,
1825,
489,
291,
14,
2604,
63,
1825,
275,
942,
489,
367,
286,
315,
1453,
26,
267,
340,
286,
365,
488,
26,
881,
4215,
63,
5720,
275,
756,
267,
587,
26,
881,
2295,
14,
740,
8,
67,
9,
489,
340,
4215,
63,
5720,
436,
822,
8,
2219,
9,
665,
413,
26,
267,
1980,
221,
327,
13144,
367,
1655,
2058,
14,
489,
340,
822,
8,
2219,
9,
665,
413,
26,
2059,
221,
327,
2136,
3984,
4224,
2348,
14,
489,
754,
275,
942,
489,
367,
307,
315,
2295,
26,
267,
754,
14,
740,
8,
84,
14,
2305,
2889,
1012,
489,
862,
26,
267,
10291,
14,
6795,
8,
1099,
12,
291,
14,
5096,
9,
489,
871,
26,
267,
291,
14,
5933,
14,
14478,
275,
715,
489,
367,
307,
315,
2295,
26,
267,
291,
14,
1000,
14,
16051,
28492,
12387,
8,
84,
12,
291,
14,
1100,
14,
1047,
12,
291,
14,
1100,
14,
632,
9,
489,
2295,
275,
942,
272,
291,
14,
8114,
63,
831,
14,
3221,
342,
421,
199,
318,
17009,
8,
13249,
12,
4027,
12,
2295,
12,
6771,
12,
1654,
304,
523,
5241,
63,
3771,
275,
3778,
14,
1002,
6207,
11804,
8,
736,
14,
515,
14,
904,
8,
13249,
12,
298,
396,
2237,
523,
24203,
275,
942,
523,
367,
1738,
315,
5241,
63,
3771,
26,
272,
5241,
275,
2295,
2577,
14,
10591,
14,
6200,
10591,
8,
267,
747,
14,
515,
14,
904,
8,
13249,
12,
298,
396,
401,
1738,
430,
272,
340,
5241,
26,
489,
5241,
14,
8555,
18356,
6231,
342,
489,
24203,
14,
740,
8,
5768,
9,
819,
24203,
63,
807,
275,
1052,
523,
367,
308,
315,
24203,
26,
272,
24203,
63,
807,
59,
83,
14,
354,
61,
275,
308,
272,
308,
14,
2219,
275,
942,
523,
367,
307,
315,
2295,
26,
272,
5241,
275,
24203,
63,
807,
59,
84,
14,
5768,
61,
272,
307,
14,
5768,
275,
5241,
272,
5241,
14,
2219,
14,
740,
8,
84,
9,
819,
24203,
275,
359,
308,
367,
308,
315,
24203,
340,
822,
8,
83,
14,
2219,
9,
690,
378,
1622,
523,
367,
308,
315,
24203,
26,
272,
308,
14,
11950,
1451,
342,
819,
6696,
63,
15785,
275,
9599,
1403,
11504,
8,
5096,
12,
1654,
12,
4027,
9,
523,
7876,
275,
6451,
14,
7446,
8,
27034,
12,
6696,
63,
15785,
12,
4027,
9,
523,
862,
26,
272,
7876,
14,
2540,
8,
1000,
14,
6920,
9,
523,
871,
5925,
12,
325,
26,
272,
340,
325,
14,
7931,
508,
499,
26,
489,
1245,
275,
1689,
1173
] |
[
1898,
6029,
314,
812,
24,
2199,
11462,
14,
2900,
4481,
4644,
14,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
755,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
199,
3,
755,
6450,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
199,
3,
755,
543,
314,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
755,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
199,
3,
755,
687,
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,
646,
12866,
199,
646,
747,
199,
646,
10703,
199,
646,
5796,
199,
646,
900,
199,
199,
504,
2508,
1832,
492,
6451,
199,
504,
2508,
1832,
492,
6696,
199,
504,
2508,
1832,
492,
2295,
2577,
199,
504,
2508,
1832,
492,
3778,
199,
504,
2508,
1000,
492,
10291,
421,
199,
533,
9599,
1403,
11504,
8,
5734,
14,
11504,
24000,
304,
523,
347,
636,
826,
721,
277,
12,
6771,
12,
1654,
12,
4027,
304,
272,
1613,
8,
11442,
11504,
12,
291,
2843,
826,
4533,
272,
291,
14,
5096,
275,
6771,
272,
291,
14,
1000,
275,
1654,
272,
291,
14,
1100,
275,
4027,
272,
291,
14,
2604,
63,
1825,
275,
942,
221,
327,
11003,
1384,
1471,
31021,
17279,
14,
272,
291,
14,
8114,
63,
831,
275,
5796,
14,
6432,
342,
272,
291,
14,
8114,
2671,
275,
5796,
14,
4436,
8,
1375,
29,
277,
423,
28002,
4436,
9,
272,
291,
14,
8114,
2671,
14,
928,
342,
819,
347,
13481,
2540,
8,
277,
12,
511,
12,
965,
63,
8953,
63,
1199,
304,
272,
327,
710,
1255,
8715,
626,
1240,
642,
1172,
282,
4650,
15988,
12,
880,
642,
365,
5048,
14,
272,
291,
14,
2604,
63,
1825,
14,
740,
8,
396,
9,
819,
347,
485,
28002,
4436,
8,
277,
304,
272,
4215,
63,
5720,
275,
715,
272,
2295,
275,
942,
272,
291,
14,
8114,
63,
831,
14,
8174,
342,
272,
1830,
4215,
63,
5720,
26,
489,
900,
14,
4532,
8,
16,
14,
17,
9,
489,
327,
961,
1077,
506,
298,
10910,
8321,
2,
1928,
27267,
22901,
9,
489,
327,
334,
6004,
2793,
1133,
10296,
1314,
769,
1263,
892,
4008,
664,
11544,
370,
12,
465,
1846,
489,
327,
465,
781,
2793,
1133,
27332,
1263,
436,
314,
2061,
1373,
12477,
2061,
4959,
489,
1453,
275,
291,
14,
2604,
63,
1825,
489,
291,
14,
2604,
63,
1825,
275,
942,
489,
367,
286,
315,
1453,
26,
267,
340,
286,
365,
488,
26,
881,
4215,
63,
5720,
275,
756,
267,
587,
26,
881,
2295,
14,
740,
8,
67,
9,
489,
340,
4215,
63,
5720,
436,
822,
8,
2219,
9,
665,
413,
26,
267,
1980,
221,
327,
13144,
367,
1655,
2058,
14,
489,
340,
822,
8,
2219,
9,
665,
413,
26,
2059,
221,
327,
2136,
3984,
4224,
2348,
14,
489,
754,
275,
942,
489,
367,
307,
315,
2295,
26,
267,
754,
14,
740,
8,
84,
14,
2305,
2889,
1012,
489,
862,
26,
267,
10291,
14,
6795,
8,
1099,
12,
291,
14,
5096,
9,
489,
871,
26,
267,
291,
14,
5933,
14,
14478,
275,
715,
489,
367,
307,
315,
2295,
26,
267,
291,
14,
1000,
14,
16051,
28492,
12387,
8,
84,
12,
291,
14,
1100,
14,
1047,
12,
291,
14,
1100,
14,
632,
9,
489,
2295,
275,
942,
272,
291,
14,
8114,
63,
831,
14,
3221,
342,
421,
199,
318,
17009,
8,
13249,
12,
4027,
12,
2295,
12,
6771,
12,
1654,
304,
523,
5241,
63,
3771,
275,
3778,
14,
1002,
6207,
11804,
8,
736,
14,
515,
14,
904,
8,
13249,
12,
298,
396,
2237,
523,
24203,
275,
942,
523,
367,
1738,
315,
5241,
63,
3771,
26,
272,
5241,
275,
2295,
2577,
14,
10591,
14,
6200,
10591,
8,
267,
747,
14,
515,
14,
904,
8,
13249,
12,
298,
396,
401,
1738,
430,
272,
340,
5241,
26,
489,
5241,
14,
8555,
18356,
6231,
342,
489,
24203,
14,
740,
8,
5768,
9,
819,
24203,
63,
807,
275,
1052,
523,
367,
308,
315,
24203,
26,
272,
24203,
63,
807,
59,
83,
14,
354,
61,
275,
308,
272,
308,
14,
2219,
275,
942,
523,
367,
307,
315,
2295,
26,
272,
5241,
275,
24203,
63,
807,
59,
84,
14,
5768,
61,
272,
307,
14,
5768,
275,
5241,
272,
5241,
14,
2219,
14,
740,
8,
84,
9,
819,
24203,
275,
359,
308,
367,
308,
315,
24203,
340,
822,
8,
83,
14,
2219,
9,
690,
378,
1622,
523,
367,
308,
315,
24203,
26,
272,
308,
14,
11950,
1451,
342,
819,
6696,
63,
15785,
275,
9599,
1403,
11504,
8,
5096,
12,
1654,
12,
4027,
9,
523,
7876,
275,
6451,
14,
7446,
8,
27034,
12,
6696,
63,
15785,
12,
4027,
9,
523,
862,
26,
272,
7876,
14,
2540,
8,
1000,
14,
6920,
9,
523,
871,
5925,
12,
325,
26,
272,
340,
325,
14,
7931,
508,
499,
26,
489,
1245,
275,
1689,
1173,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
sebadiaz/kafka
|
tests/kafkatest/services/kafka_log4j_appender.py
|
14
|
4046
|
# 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 ducktape.services.background_thread import BackgroundThreadService
from kafkatest.directory_layout.kafka_path import KafkaPathResolverMixin
from kafkatest.services.security.security_config import SecurityConfig
class KafkaLog4jAppender(KafkaPathResolverMixin, BackgroundThreadService):
logs = {
"producer_log": {
"path": "/mnt/kafka_log4j_appender.log",
"collect_default": False}
}
def __init__(self, context, num_nodes, kafka, topic, max_messages=-1, security_protocol="PLAINTEXT"):
super(KafkaLog4jAppender, self).__init__(context, num_nodes)
self.kafka = kafka
self.topic = topic
self.max_messages = max_messages
self.security_protocol = security_protocol
self.security_config = SecurityConfig(self.context, security_protocol)
self.stop_timeout_sec = 30
def _worker(self, idx, node):
cmd = self.start_cmd(node)
self.logger.debug("VerifiableLog4jAppender %d command: %s" % (idx, cmd))
self.security_config.setup_node(node)
node.account.ssh(cmd)
def start_cmd(self, node):
cmd = self.path.script("kafka-run-class.sh", node)
cmd += " "
cmd += self.java_class_name()
cmd += " --topic %s --broker-list %s" % (self.topic, self.kafka.bootstrap_servers(self.security_protocol))
if self.max_messages > 0:
cmd += " --max-messages %s" % str(self.max_messages)
if self.security_protocol != SecurityConfig.PLAINTEXT:
cmd += " --security-protocol %s" % str(self.security_protocol)
if self.security_protocol == SecurityConfig.SSL or self.security_protocol == SecurityConfig.SASL_SSL:
cmd += " --ssl-truststore-location %s" % str(SecurityConfig.TRUSTSTORE_PATH)
cmd += " --ssl-truststore-password %s" % str(SecurityConfig.ssl_stores.truststore_passwd)
if self.security_protocol == SecurityConfig.SASL_PLAINTEXT or \
self.security_protocol == SecurityConfig.SASL_SSL or \
self.security_protocol == SecurityConfig.SASL_MECHANISM_GSSAPI or \
self.security_protocol == SecurityConfig.SASL_MECHANISM_PLAIN:
cmd += " --sasl-kerberos-service-name %s" % str('kafka')
cmd += " --client-jaas-conf-path %s" % str(SecurityConfig.JAAS_CONF_PATH)
cmd += " --kerb5-conf-path %s" % str(SecurityConfig.KRB5CONF_PATH)
cmd += " 2>> /mnt/kafka_log4j_appender.log | tee -a /mnt/kafka_log4j_appender.log &"
return cmd
def stop_node(self, node):
node.account.kill_java_processes(self.java_class_name(), allow_fail=False)
stopped = self.wait_node(node, timeout_sec=self.stop_timeout_sec)
assert stopped, "Node %s: did not stop within the specified timeout of %s seconds" % \
(str(node.account), str(self.stop_timeout_sec))
def clean_node(self, node):
node.account.kill_java_processes(self.java_class_name(), clean_shutdown=False,
allow_fail=False)
node.account.ssh("rm -rf /mnt/kafka_log4j_appender.log", allow_fail=False)
def java_class_name(self):
return "org.apache.kafka.tools.VerifiableLog4jAppender"
|
apache-2.0
|
[
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
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,
504,
366,
10112,
502,
321,
14,
5950,
14,
7451,
63,
2671,
492,
10257,
3928,
4436,
3167,
199,
199,
504,
1022,
2756,
75,
27126,
14,
3619,
63,
4209,
14,
26186,
63,
515,
492,
1804,
15294,
2042,
12407,
4256,
199,
504,
1022,
2756,
75,
27126,
14,
5950,
14,
4416,
14,
4416,
63,
888,
492,
13863,
2028,
421,
199,
533,
1804,
15294,
2445,
20,
74,
2640,
13747,
8,
43,
15294,
2042,
12407,
4256,
12,
10257,
3928,
4436,
3167,
304,
339,
9610,
275,
469,
267,
298,
16376,
63,
793,
582,
469,
288,
298,
515,
582,
3286,
20481,
15,
26186,
63,
793,
20,
74,
63,
5435,
424,
14,
793,
401,
288,
298,
7112,
63,
885,
582,
756,
93,
272,
789,
339,
347,
636,
826,
721,
277,
12,
1067,
12,
1967,
63,
2415,
12,
29576,
12,
7482,
12,
1390,
63,
3431,
4022,
17,
12,
6391,
63,
3922,
628,
2749,
33,
2919,
2472,
2349,
267,
1613,
8,
43,
15294,
2445,
20,
74,
2640,
13747,
12,
291,
2843,
826,
721,
1100,
12,
1967,
63,
2415,
9,
398,
291,
14,
26186,
275,
29576,
267,
291,
14,
5746,
275,
7482,
267,
291,
14,
988,
63,
3431,
275,
1390,
63,
3431,
267,
291,
14,
4416,
63,
3922,
275,
6391,
63,
3922,
267,
291,
14,
4416,
63,
888,
275,
13863,
2028,
8,
277,
14,
1100,
12,
6391,
63,
3922,
9,
267,
291,
14,
2379,
63,
2593,
63,
3321,
275,
4233,
339,
347,
485,
6599,
8,
277,
12,
4280,
12,
1031,
304,
267,
2088,
275,
291,
14,
928,
63,
1760,
8,
932,
9,
267,
291,
14,
2921,
14,
1757,
480,
3673,
1903,
461,
2445,
20,
74,
2640,
13747,
450,
68,
1414,
26,
450,
83,
2,
450,
334,
2996,
12,
2088,
430,
267,
291,
14,
4416,
63,
888,
14,
2758,
63,
932,
8,
932,
9,
267,
1031,
14,
2048,
14,
5510,
8,
1760,
9,
339,
347,
1343,
63,
1760,
8,
277,
12,
1031,
304,
267,
2088,
275,
291,
14,
515,
14,
1579,
480,
26186,
13,
1065,
13,
533,
14,
609,
401,
1031,
9,
267,
2088,
847,
298,
298,
267,
2088,
847,
291,
14,
6138,
63,
533,
63,
354,
342,
267,
2088,
847,
298,
1553,
5746,
450,
83,
1553,
16620,
13,
513,
450,
83,
2,
450,
334,
277,
14,
5746,
12,
291,
14,
26186,
14,
11146,
63,
5871,
8,
277,
14,
4416,
63,
3922,
430,
398,
340,
291,
14,
988,
63,
3431,
690,
378,
26,
288,
2088,
847,
298,
1553,
988,
13,
3431,
450,
83,
2,
450,
620,
8,
277,
14,
988,
63,
3431,
9,
267,
340,
291,
14,
4416,
63,
3922,
1137,
13863,
2028,
14,
2749,
33,
2919,
2472,
26,
288,
2088,
847,
298,
1553,
4416,
13,
3922,
450,
83,
2,
450,
620,
8,
277,
14,
4416,
63,
3922,
9,
267,
340,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
5413,
503,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
5413,
26,
288,
2088,
847,
298,
1553,
4266,
13,
15756,
1617,
13,
1985,
450,
83,
2,
450,
620,
8,
7676,
2028,
14,
1766,
7698,
16169,
63,
3243,
9,
288,
2088,
847,
298,
1553,
4266,
13,
15756,
1617,
13,
2060,
450,
83,
2,
450,
620,
8,
7676,
2028,
14,
4266,
63,
18958,
14,
15756,
1617,
63,
12671,
9,
267,
340,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
2749,
33,
2919,
2472,
503,
971,
355,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
5413,
503,
971,
355,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
3635,
1244,
879,
1311,
45,
63,
39,
2300,
3735,
503,
971,
355,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
3635,
1244,
879,
1311,
45,
63,
2749,
9021,
26,
288,
2088,
847,
298,
1553,
22601,
76,
13,
2570,
23920,
13,
1364,
13,
354,
450,
83,
2,
450,
620,
360,
26186,
358,
288,
2088,
847,
298,
1553,
1258,
13,
3387,
305,
13,
2190,
13,
515,
450,
83,
2,
450,
620,
8,
7676,
2028,
14,
29849,
1179,
63,
3103,
63,
3243,
9,
288,
2088,
847,
298,
1553,
2570,
66,
21,
13,
2190,
13,
515,
450,
83,
2,
450,
620,
8,
7676,
2028,
14,
43,
16567,
21,
3103,
63,
3243,
9,
398,
2088,
847,
298,
499,
1140,
1182,
20481,
15,
26186,
63,
793,
20,
74,
63,
5435,
424,
14,
793,
1204,
1565,
69,
446,
65,
1182,
20481,
15,
26186,
63,
793,
20,
74,
63,
5435,
424,
14,
793,
1253,
2,
267,
372,
2088,
339,
347,
3631,
63,
932,
8,
277,
12,
1031,
304,
267,
1031,
14,
2048,
14,
8997,
63,
6138,
63,
11816,
8,
277,
14,
6138,
63,
533,
63,
354,
1062,
2040,
63,
1633,
29,
797,
9,
398,
15248,
275,
291,
14,
2573,
63,
932,
8,
932,
12,
2653,
63,
3321,
29,
277,
14,
2379,
63,
2593,
63,
3321,
9,
267,
702,
15248,
12,
298,
1716,
450,
83,
26,
8103,
440,
3631,
4453,
314,
2013,
2653,
402,
450,
83,
4696,
2,
450,
971,
717,
334,
495,
8,
932,
14,
2048,
395,
620,
8,
277,
14,
2379,
63,
2593,
63,
3321,
430,
339,
347,
3633,
63,
932,
8,
277,
12,
1031,
304,
267,
1031,
14,
2048,
14,
8997,
63,
6138
] |
[
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,
199,
504,
366,
10112,
502,
321,
14,
5950,
14,
7451,
63,
2671,
492,
10257,
3928,
4436,
3167,
199,
199,
504,
1022,
2756,
75,
27126,
14,
3619,
63,
4209,
14,
26186,
63,
515,
492,
1804,
15294,
2042,
12407,
4256,
199,
504,
1022,
2756,
75,
27126,
14,
5950,
14,
4416,
14,
4416,
63,
888,
492,
13863,
2028,
421,
199,
533,
1804,
15294,
2445,
20,
74,
2640,
13747,
8,
43,
15294,
2042,
12407,
4256,
12,
10257,
3928,
4436,
3167,
304,
339,
9610,
275,
469,
267,
298,
16376,
63,
793,
582,
469,
288,
298,
515,
582,
3286,
20481,
15,
26186,
63,
793,
20,
74,
63,
5435,
424,
14,
793,
401,
288,
298,
7112,
63,
885,
582,
756,
93,
272,
789,
339,
347,
636,
826,
721,
277,
12,
1067,
12,
1967,
63,
2415,
12,
29576,
12,
7482,
12,
1390,
63,
3431,
4022,
17,
12,
6391,
63,
3922,
628,
2749,
33,
2919,
2472,
2349,
267,
1613,
8,
43,
15294,
2445,
20,
74,
2640,
13747,
12,
291,
2843,
826,
721,
1100,
12,
1967,
63,
2415,
9,
398,
291,
14,
26186,
275,
29576,
267,
291,
14,
5746,
275,
7482,
267,
291,
14,
988,
63,
3431,
275,
1390,
63,
3431,
267,
291,
14,
4416,
63,
3922,
275,
6391,
63,
3922,
267,
291,
14,
4416,
63,
888,
275,
13863,
2028,
8,
277,
14,
1100,
12,
6391,
63,
3922,
9,
267,
291,
14,
2379,
63,
2593,
63,
3321,
275,
4233,
339,
347,
485,
6599,
8,
277,
12,
4280,
12,
1031,
304,
267,
2088,
275,
291,
14,
928,
63,
1760,
8,
932,
9,
267,
291,
14,
2921,
14,
1757,
480,
3673,
1903,
461,
2445,
20,
74,
2640,
13747,
450,
68,
1414,
26,
450,
83,
2,
450,
334,
2996,
12,
2088,
430,
267,
291,
14,
4416,
63,
888,
14,
2758,
63,
932,
8,
932,
9,
267,
1031,
14,
2048,
14,
5510,
8,
1760,
9,
339,
347,
1343,
63,
1760,
8,
277,
12,
1031,
304,
267,
2088,
275,
291,
14,
515,
14,
1579,
480,
26186,
13,
1065,
13,
533,
14,
609,
401,
1031,
9,
267,
2088,
847,
298,
298,
267,
2088,
847,
291,
14,
6138,
63,
533,
63,
354,
342,
267,
2088,
847,
298,
1553,
5746,
450,
83,
1553,
16620,
13,
513,
450,
83,
2,
450,
334,
277,
14,
5746,
12,
291,
14,
26186,
14,
11146,
63,
5871,
8,
277,
14,
4416,
63,
3922,
430,
398,
340,
291,
14,
988,
63,
3431,
690,
378,
26,
288,
2088,
847,
298,
1553,
988,
13,
3431,
450,
83,
2,
450,
620,
8,
277,
14,
988,
63,
3431,
9,
267,
340,
291,
14,
4416,
63,
3922,
1137,
13863,
2028,
14,
2749,
33,
2919,
2472,
26,
288,
2088,
847,
298,
1553,
4416,
13,
3922,
450,
83,
2,
450,
620,
8,
277,
14,
4416,
63,
3922,
9,
267,
340,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
5413,
503,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
5413,
26,
288,
2088,
847,
298,
1553,
4266,
13,
15756,
1617,
13,
1985,
450,
83,
2,
450,
620,
8,
7676,
2028,
14,
1766,
7698,
16169,
63,
3243,
9,
288,
2088,
847,
298,
1553,
4266,
13,
15756,
1617,
13,
2060,
450,
83,
2,
450,
620,
8,
7676,
2028,
14,
4266,
63,
18958,
14,
15756,
1617,
63,
12671,
9,
267,
340,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
2749,
33,
2919,
2472,
503,
971,
355,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
5413,
503,
971,
355,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
3635,
1244,
879,
1311,
45,
63,
39,
2300,
3735,
503,
971,
355,
291,
14,
4416,
63,
3922,
508,
13863,
2028,
14,
15319,
44,
63,
3635,
1244,
879,
1311,
45,
63,
2749,
9021,
26,
288,
2088,
847,
298,
1553,
22601,
76,
13,
2570,
23920,
13,
1364,
13,
354,
450,
83,
2,
450,
620,
360,
26186,
358,
288,
2088,
847,
298,
1553,
1258,
13,
3387,
305,
13,
2190,
13,
515,
450,
83,
2,
450,
620,
8,
7676,
2028,
14,
29849,
1179,
63,
3103,
63,
3243,
9,
288,
2088,
847,
298,
1553,
2570,
66,
21,
13,
2190,
13,
515,
450,
83,
2,
450,
620,
8,
7676,
2028,
14,
43,
16567,
21,
3103,
63,
3243,
9,
398,
2088,
847,
298,
499,
1140,
1182,
20481,
15,
26186,
63,
793,
20,
74,
63,
5435,
424,
14,
793,
1204,
1565,
69,
446,
65,
1182,
20481,
15,
26186,
63,
793,
20,
74,
63,
5435,
424,
14,
793,
1253,
2,
267,
372,
2088,
339,
347,
3631,
63,
932,
8,
277,
12,
1031,
304,
267,
1031,
14,
2048,
14,
8997,
63,
6138,
63,
11816,
8,
277,
14,
6138,
63,
533,
63,
354,
1062,
2040,
63,
1633,
29,
797,
9,
398,
15248,
275,
291,
14,
2573,
63,
932,
8,
932,
12,
2653,
63,
3321,
29,
277,
14,
2379,
63,
2593,
63,
3321,
9,
267,
702,
15248,
12,
298,
1716,
450,
83,
26,
8103,
440,
3631,
4453,
314,
2013,
2653,
402,
450,
83,
4696,
2,
450,
971,
717,
334,
495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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
] |
HybridF5/tempest
|
tempest/lib/services/network/security_group_rules_client.py
|
8
|
1378
|
# 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.services.network import base
class SecurityGroupRulesClient(base.BaseNetworkClient):
def create_security_group_rule(self, **kwargs):
uri = '/security-group-rules'
post_data = {'security_group_rule': kwargs}
return self.create_resource(uri, post_data)
def show_security_group_rule(self, security_group_rule_id, **fields):
uri = '/security-group-rules/%s' % security_group_rule_id
return self.show_resource(uri, **fields)
def delete_security_group_rule(self, security_group_rule_id):
uri = '/security-group-rules/%s' % security_group_rule_id
return self.delete_resource(uri)
def list_security_group_rules(self, **filters):
uri = '/security-group-rules'
return self.list_resources(uri, **filters)
|
apache-2.0
|
[
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
24076,
14,
773,
14,
5950,
14,
1200,
492,
1300,
421,
199,
533,
13863,
2448,
12920,
3041,
8,
1095,
14,
1563,
4491,
3041,
304,
339,
347,
1218,
63,
4416,
63,
923,
63,
2200,
8,
277,
12,
1011,
958,
304,
267,
5108,
275,
1994,
4416,
13,
923,
13,
4423,
7,
267,
2963,
63,
576,
275,
791,
4416,
63,
923,
63,
2200,
356,
2074,
93,
267,
372,
291,
14,
981,
63,
1927,
8,
2302,
12,
2963,
63,
576,
9,
339,
347,
2498,
63,
4416,
63,
923,
63,
2200,
8,
277,
12,
6391,
63,
923,
63,
2200,
63,
344,
12,
1011,
955,
304,
267,
5108,
275,
1994,
4416,
13,
923,
13,
4423,
3149,
83,
7,
450,
6391,
63,
923,
63,
2200,
63,
344,
267,
372,
291,
14,
2384,
63,
1927,
8,
2302,
12,
1011,
955,
9,
339,
347,
3145,
63,
4416,
63,
923,
63,
2200,
8,
277,
12,
6391,
63,
923,
63,
2200,
63,
344,
304,
267,
5108,
275,
1994,
4416,
13,
923,
13,
4423,
3149,
83,
7,
450,
6391,
63,
923,
63,
2200,
63,
344,
267,
372,
291,
14,
1807,
63,
1927,
8,
2302,
9,
339,
347,
769,
63,
4416,
63,
923,
63,
4423,
8,
277,
12,
1011,
4273,
304,
267,
5108,
275,
1994,
4416,
13,
923,
13,
4423,
7,
267,
372,
291,
14,
513,
63,
4435,
8,
2302,
12,
1011,
4273,
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
] |
[
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,
5950,
14,
1200,
492,
1300,
421,
199,
533,
13863,
2448,
12920,
3041,
8,
1095,
14,
1563,
4491,
3041,
304,
339,
347,
1218,
63,
4416,
63,
923,
63,
2200,
8,
277,
12,
1011,
958,
304,
267,
5108,
275,
1994,
4416,
13,
923,
13,
4423,
7,
267,
2963,
63,
576,
275,
791,
4416,
63,
923,
63,
2200,
356,
2074,
93,
267,
372,
291,
14,
981,
63,
1927,
8,
2302,
12,
2963,
63,
576,
9,
339,
347,
2498,
63,
4416,
63,
923,
63,
2200,
8,
277,
12,
6391,
63,
923,
63,
2200,
63,
344,
12,
1011,
955,
304,
267,
5108,
275,
1994,
4416,
13,
923,
13,
4423,
3149,
83,
7,
450,
6391,
63,
923,
63,
2200,
63,
344,
267,
372,
291,
14,
2384,
63,
1927,
8,
2302,
12,
1011,
955,
9,
339,
347,
3145,
63,
4416,
63,
923,
63,
2200,
8,
277,
12,
6391,
63,
923,
63,
2200,
63,
344,
304,
267,
5108,
275,
1994,
4416,
13,
923,
13,
4423,
3149,
83,
7,
450,
6391,
63,
923,
63,
2200,
63,
344,
267,
372,
291,
14,
1807,
63,
1927,
8,
2302,
9,
339,
347,
769,
63,
4416,
63,
923,
63,
4423,
8,
277,
12,
1011,
4273,
304,
267,
5108,
275,
1994,
4416,
13,
923,
13,
4423,
7,
267,
372,
291,
14,
513,
63,
4435,
8,
2302,
12,
1011,
4273,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ShinyROM/android_external_chromium_org
|
build/android/pylib/forwarder.py
|
26
|
12720
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import fcntl
import logging
import os
import psutil
import re
import sys
import time
import android_commands
import cmd_helper
import constants
from pylib import valgrind_tools
def _GetProcessStartTime(pid):
return psutil.Process(pid).create_time
class _FileLock(object):
"""With statement-aware implementation of a file lock.
File locks are needed for cross-process synchronization when the
multiprocessing Python module is used.
"""
def __init__(self, path):
self._path = path
def __enter__(self):
self._fd = os.open(self._path, os.O_RDONLY | os.O_CREAT)
if self._fd < 0:
raise Exception('Could not open file %s for reading' % self._path)
fcntl.flock(self._fd, fcntl.LOCK_EX)
def __exit__(self, type, value, traceback):
fcntl.flock(self._fd, fcntl.LOCK_UN)
os.close(self._fd)
class Forwarder(object):
"""Thread-safe class to manage port forwards from the device to the host."""
_DEVICE_FORWARDER_FOLDER = (constants.TEST_EXECUTABLE_DIR +
'/forwarder/')
_DEVICE_FORWARDER_PATH = (constants.TEST_EXECUTABLE_DIR +
'/forwarder/device_forwarder')
_LD_LIBRARY_PATH = 'LD_LIBRARY_PATH=%s' % _DEVICE_FORWARDER_FOLDER
_LOCK_PATH = '/tmp/chrome.forwarder.lock'
_MULTIPROCESSING_ENV_VAR = 'CHROME_FORWARDER_USE_MULTIPROCESSING'
# Defined in host_forwarder_main.cc
_HOST_FORWARDER_LOG = '/tmp/host_forwarder_log'
_instance = None
@staticmethod
def UseMultiprocessing():
"""Tells the forwarder that multiprocessing is used."""
os.environ[Forwarder._MULTIPROCESSING_ENV_VAR] = '1'
@staticmethod
def Map(port_pairs, adb, tool=None):
"""Runs the forwarder.
Args:
port_pairs: A list of tuples (device_port, host_port) to forward. Note
that you can specify 0 as a device_port, in which case a
port will by dynamically assigned on the device. You can
get the number of the assigned port using the
DevicePortForHostPort method.
adb: An AndroidCommands instance.
tool: Tool class to use to get wrapper, if necessary, for executing the
forwarder (see valgrind_tools.py).
Raises:
Exception on failure to forward the port.
"""
if not tool:
tool = valgrind_tools.CreateTool(None, adb)
with _FileLock(Forwarder._LOCK_PATH):
instance = Forwarder._GetInstanceLocked(tool)
instance._InitDeviceLocked(adb, tool)
device_serial = adb.Adb().GetSerialNumber()
redirection_commands = [
['--serial-id=' + device_serial, '--map', str(device),
str(host)] for device, host in port_pairs]
logging.info('Forwarding using commands: %s', redirection_commands)
for redirection_command in redirection_commands:
try:
(exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
[instance._host_forwarder_path] + redirection_command)
except OSError as e:
if e.errno == 2:
raise Exception('Unable to start host forwarder. Make sure you have'
' built host_forwarder.')
else: raise
if exit_code != 0:
raise Exception('%s exited with %d:\n%s' % (
instance._host_forwarder_path, exit_code, '\n'.join(output)))
tokens = output.split(':')
if len(tokens) != 2:
raise Exception(('Unexpected host forwarder output "%s", ' +
'expected "device_port:host_port"') % output)
device_port = int(tokens[0])
host_port = int(tokens[1])
serial_with_port = (device_serial, device_port)
instance._device_to_host_port_map[serial_with_port] = host_port
instance._host_to_device_port_map[host_port] = serial_with_port
logging.info('Forwarding device port: %d to host port: %d.',
device_port, host_port)
@staticmethod
def UnmapDevicePort(device_port, adb):
"""Unmaps a previously forwarded device port.
Args:
adb: An AndroidCommands instance.
device_port: A previously forwarded port (through Map()).
"""
with _FileLock(Forwarder._LOCK_PATH):
Forwarder._UnmapDevicePortLocked(device_port, adb)
@staticmethod
def UnmapAllDevicePorts(adb):
"""Unmaps all the previously forwarded ports for the provided device.
Args:
adb: An AndroidCommands instance.
port_pairs: A list of tuples (device_port, host_port) to unmap.
"""
with _FileLock(Forwarder._LOCK_PATH):
if not Forwarder._instance:
return
adb_serial = adb.Adb().GetSerialNumber()
if adb_serial not in Forwarder._instance._initialized_devices:
return
port_map = Forwarder._GetInstanceLocked(
None)._device_to_host_port_map
for (device_serial, device_port) in port_map.keys():
if adb_serial == device_serial:
Forwarder._UnmapDevicePortLocked(device_port, adb)
# There are no more ports mapped, kill the device_forwarder.
tool = valgrind_tools.CreateTool(None, adb)
Forwarder._KillDeviceLocked(adb, tool)
Forwarder._instance._initialized_devices.remove(adb_serial)
@staticmethod
def DevicePortForHostPort(host_port):
"""Returns the device port that corresponds to a given host port."""
with _FileLock(Forwarder._LOCK_PATH):
(device_serial, device_port) = Forwarder._GetInstanceLocked(
None)._host_to_device_port_map.get(host_port)
return device_port
@staticmethod
def RemoveHostLog():
if os.path.exists(Forwarder._HOST_FORWARDER_LOG):
os.unlink(Forwarder._HOST_FORWARDER_LOG)
@staticmethod
def GetHostLog():
if not os.path.exists(Forwarder._HOST_FORWARDER_LOG):
return ''
with file(Forwarder._HOST_FORWARDER_LOG, 'r') as f:
return f.read()
@staticmethod
def _GetInstanceLocked(tool):
"""Returns the singleton instance.
Note that the global lock must be acquired before calling this method.
Args:
tool: Tool class to use to get wrapper, if necessary, for executing the
forwarder (see valgrind_tools.py).
"""
if not Forwarder._instance:
Forwarder._instance = Forwarder(tool)
return Forwarder._instance
def __init__(self, tool):
"""Constructs a new instance of Forwarder.
Note that Forwarder is a singleton therefore this constructor should be
called only once.
Args:
tool: Tool class to use to get wrapper, if necessary, for executing the
forwarder (see valgrind_tools.py).
"""
assert not Forwarder._instance
self._tool = tool
self._initialized_devices = set()
self._device_to_host_port_map = dict()
self._host_to_device_port_map = dict()
self._host_forwarder_path = os.path.join(
constants.GetOutDirectory(), 'host_forwarder')
assert os.path.exists(self._host_forwarder_path), 'Please build forwarder2'
self._device_forwarder_path_on_host = os.path.join(
constants.GetOutDirectory(), 'forwarder_dist')
self._InitHostLocked()
@staticmethod
def _UnmapDevicePortLocked(device_port, adb):
"""Internal method used by UnmapDevicePort().
Note that the global lock must be acquired before calling this method.
"""
instance = Forwarder._GetInstanceLocked(None)
serial = adb.Adb().GetSerialNumber()
serial_with_port = (serial, device_port)
if not serial_with_port in instance._device_to_host_port_map:
logging.error('Trying to unmap non-forwarded port %d' % device_port)
return
redirection_command = ['--serial-id=' + serial, '--unmap', str(device_port)]
(exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
[instance._host_forwarder_path] + redirection_command)
if exit_code != 0:
logging.error('%s exited with %d:\n%s' % (
instance._host_forwarder_path, exit_code, '\n'.join(output)))
host_port = instance._device_to_host_port_map[serial_with_port]
del instance._device_to_host_port_map[serial_with_port]
del instance._host_to_device_port_map[host_port]
@staticmethod
def _GetPidForLock():
"""Returns the PID used for host_forwarder initialization.
In case multi-process sharding is used, the PID of the "sharder" is used.
The "sharder" is the initial process that forks that is the parent process.
By default, multi-processing is not used. In that case the PID of the
current process is returned.
"""
use_multiprocessing = Forwarder._MULTIPROCESSING_ENV_VAR in os.environ
return os.getppid() if use_multiprocessing else os.getpid()
def _InitHostLocked(self):
"""Initializes the host forwarder daemon.
Note that the global lock must be acquired before calling this method. This
method kills any existing host_forwarder process that could be stale.
"""
# See if the host_forwarder daemon was already initialized by a concurrent
# process or thread (in case multi-process sharding is not used).
pid_for_lock = Forwarder._GetPidForLock()
fd = os.open(Forwarder._LOCK_PATH, os.O_RDWR | os.O_CREAT)
with os.fdopen(fd, 'r+') as pid_file:
pid_with_start_time = pid_file.readline()
if pid_with_start_time:
(pid, process_start_time) = pid_with_start_time.split(':')
if pid == str(pid_for_lock):
if process_start_time == str(_GetProcessStartTime(pid_for_lock)):
return
self._KillHostLocked()
pid_file.seek(0)
pid_file.write(
'%s:%s' % (pid_for_lock, str(_GetProcessStartTime(pid_for_lock))))
def _InitDeviceLocked(self, adb, tool):
"""Initializes the device_forwarder daemon for a specific device (once).
Note that the global lock must be acquired before calling this method. This
method kills any existing device_forwarder daemon on the device that could
be stale, pushes the latest version of the daemon (to the device) and starts
it.
Args:
adb: An AndroidCommands instance.
tool: Tool class to use to get wrapper, if necessary, for executing the
forwarder (see valgrind_tools.py).
"""
device_serial = adb.Adb().GetSerialNumber()
if device_serial in self._initialized_devices:
return
Forwarder._KillDeviceLocked(adb, tool)
adb.PushIfNeeded(
self._device_forwarder_path_on_host,
Forwarder._DEVICE_FORWARDER_FOLDER)
(exit_code, output) = adb.GetShellCommandStatusAndOutput(
'%s %s %s' % (Forwarder._LD_LIBRARY_PATH, tool.GetUtilWrapper(),
Forwarder._DEVICE_FORWARDER_PATH))
if exit_code != 0:
raise Exception(
'Failed to start device forwarder:\n%s' % '\n'.join(output))
self._initialized_devices.add(device_serial)
def _KillHostLocked(self):
"""Kills the forwarder process running on the host.
Note that the global lock must be acquired before calling this method.
"""
logging.info('Killing host_forwarder.')
(exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
[self._host_forwarder_path, '--kill-server'])
if exit_code != 0:
(exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
['pkill', '-9', 'host_forwarder'])
if exit_code != 0:
raise Exception('%s exited with %d:\n%s' % (
self._host_forwarder_path, exit_code, '\n'.join(output)))
@staticmethod
def _KillDeviceLocked(adb, tool):
"""Kills the forwarder process running on the device.
Note that the global lock must be acquired before calling this method.
Args:
adb: Instance of AndroidCommands for talking to the device.
tool: Wrapper tool (e.g. valgrind) that can be used to execute the device
forwarder (see valgrind_tools.py).
"""
logging.info('Killing device_forwarder.')
if not adb.FileExistsOnDevice(Forwarder._DEVICE_FORWARDER_PATH):
return
(exit_code, output) = adb.GetShellCommandStatusAndOutput(
'%s %s --kill-server' % (tool.GetUtilWrapper(),
Forwarder._DEVICE_FORWARDER_PATH))
# TODO(pliard): Remove the following call to KillAllBlocking() when we are
# sure that the old version of device_forwarder (not supporting
# 'kill-server') is not running on the bots anymore.
timeout_sec = 5
processes_killed = adb.KillAllBlocking('device_forwarder', timeout_sec)
if not processes_killed:
pids = adb.ExtractPid('device_forwarder')
if pids:
raise Exception('Timed out while killing device_forwarder')
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
12871,
199,
646,
2050,
199,
646,
747,
199,
646,
22214,
199,
646,
295,
199,
646,
984,
199,
646,
900,
199,
199,
646,
15516,
63,
4405,
199,
646,
2088,
63,
3676,
199,
646,
5262,
199,
199,
504,
29219,
492,
1139,
21510,
63,
2537,
421,
199,
318,
485,
1002,
3498,
25087,
8,
3150,
304,
523,
372,
22214,
14,
3498,
8,
3150,
680,
981,
63,
521,
421,
199,
533,
485,
1173,
6432,
8,
785,
304,
523,
408,
3007,
5164,
13,
14600,
4514,
402,
282,
570,
4650,
14,
819,
3814,
23340,
787,
4346,
367,
8059,
13,
1412,
29509,
1380,
314,
523,
12866,
2018,
859,
365,
1202,
14,
523,
408,
523,
347,
636,
826,
721,
277,
12,
931,
304,
272,
291,
423,
515,
275,
931,
819,
347,
636,
4200,
721,
277,
304,
272,
291,
423,
2592,
275,
747,
14,
1490,
8,
277,
423,
515,
12,
747,
14,
47,
63,
15543,
10452,
1204,
747,
14,
47,
63,
32120,
9,
272,
340,
291,
423,
2592,
665,
378,
26,
489,
746,
2186,
360,
6531,
440,
1551,
570,
450,
83,
367,
7664,
7,
450,
291,
423,
515,
9,
272,
12871,
14,
28977,
8,
277,
423,
2592,
12,
12871,
14,
4406,
63,
1438,
9,
819,
347,
636,
2224,
721,
277,
12,
730,
12,
574,
12,
5190,
304,
272,
12871,
14,
28977,
8,
277,
423,
2592,
12,
12871,
14,
4406,
63,
1734,
9,
272,
747,
14,
1600,
8,
277,
423,
2592,
9,
421,
199,
533,
2104,
26829,
8,
785,
304,
523,
408,
4436,
13,
3489,
1021,
370,
9635,
1844,
17465,
687,
314,
2243,
370,
314,
1591,
1041,
819,
485,
10555,
63,
22371,
11733,
63,
19041,
275,
334,
5559,
14,
2864,
63,
21623,
63,
3022,
435,
2892,
1994,
509,
26829,
6217,
523,
485,
10555,
63,
22371,
11733,
63,
3243,
275,
334,
5559,
14,
2864,
63,
21623,
63,
3022,
435,
1169,
1994,
509,
26829,
15,
1782,
63,
509,
26829,
358,
523,
485,
6533,
63,
16983,
63,
3243,
275,
283,
6533,
63,
16983,
63,
3243,
2458,
83,
7,
450,
485,
10555,
63,
22371,
11733,
63,
19041,
523,
485,
4406,
63,
3243,
275,
1994,
2791,
15,
9887,
14,
509,
26829,
14,
831,
7,
523,
485,
21894,
24762,
1608,
1206,
63,
9984,
63,
5568,
275,
283,
1244,
31364,
63,
22371,
11733,
63,
4701,
63,
21894,
24762,
1608,
1206,
7,
523,
327,
11391,
1942,
315,
1591,
63,
509,
26829,
63,
973,
14,
2055,
523,
485,
5449,
63,
22371,
11733,
63,
4947,
275,
1994,
2791,
15,
1102,
63,
509,
26829,
63,
793,
7,
819,
485,
842,
275,
488,
819,
768,
4639,
523,
347,
3645,
3947,
6338,
837,
272,
408,
52,
6840,
314,
367,
26829,
626,
12866,
365,
1202,
1041,
272,
747,
14,
2314,
59,
1858,
26829,
423,
21894,
24762,
1608,
1206,
63,
9984,
63,
5568,
61,
275,
283,
17,
7,
819,
768,
4639,
523,
347,
9672,
8,
719,
63,
7322,
12,
28173,
12,
4744,
29,
403,
304,
272,
408,
16291,
314,
367,
26829,
14,
339,
3033,
26,
489,
1844,
63,
7322,
26,
437,
769,
402,
6346,
334,
1782,
63,
719,
12,
1591,
63,
719,
9,
370,
7568,
14,
3390,
326,
626,
1265,
883,
4165,
378,
465,
282,
2243,
63,
719,
12,
315,
1314,
1930,
282,
326,
1844,
911,
701,
18774,
7943,
641,
314,
2243,
14,
2047,
883,
326,
664,
314,
1329,
402,
314,
7943,
1844,
1808,
314,
326,
12272,
4313,
1858,
4965,
4313,
1083,
14,
489,
28173,
26,
1626,
14694,
14680,
1256,
14,
489,
4744,
26,
15650,
1021,
370,
675,
370,
664,
4975,
12,
340,
5784,
12,
367,
14043,
314,
288,
367,
26829,
334,
3239,
1139,
21510,
63,
2537,
14,
647,
680,
339,
6218,
26,
489,
2186,
641,
5988,
370,
7568,
314,
1844,
14,
272,
408,
272,
340,
440,
4744,
26,
489,
4744,
275,
1139,
21510,
63,
2537,
14,
2499,
5157,
8,
403,
12,
28173,
9,
272,
543,
485,
1173,
6432,
8,
1858,
26829,
423,
4406,
63,
3243,
304,
489,
1256,
275,
2104,
26829,
423,
16486,
22408,
8,
3557,
9,
489,
1256,
423,
9346,
2510,
22408,
8,
13741,
12,
4744,
9,
2541,
2243,
63,
2171,
275,
28173,
14,
33,
697,
1252,
1002,
3571,
3259,
342,
489,
23713,
63,
4405,
275,
359,
881,
14574,
2171,
13,
344,
534,
435,
2243,
63,
2171,
12,
2850,
1130,
297,
620,
8,
1782,
395,
1779,
620,
8,
1102,
1874,
367,
2243,
12,
1591,
315,
1844,
63,
7322,
61,
489,
2050,
14,
815,
360,
26427,
1808,
3718,
26,
450,
83,
297,
23713,
63,
4405,
9,
2541,
367,
23713,
63,
1531,
315,
23713,
63,
4405,
26,
267,
862,
26,
881,
334,
2224,
63,
600,
12,
1072,
9,
275,
2088,
63,
3676,
14,
1002,
7874,
3694,
3325,
2959,
8,
1598,
359,
842,
423,
1102,
63,
509,
26829,
63,
515,
61,
435,
23713,
63,
1531,
9,
267,
871,
6440,
465,
325,
26,
881,
340,
325,
14,
7931,
508,
499,
26,
288,
746,
2186,
360,
6005,
370,
1343,
1591,
367,
26829,
14,
4155,
3238,
1265,
1172,
7,
1169,
283,
6137,
1591,
63,
509,
26829,
2659,
881,
587,
26,
746,
267,
340,
4458,
63,
600,
1137,
378,
26,
881,
746,
2186,
3508,
83,
22987,
543,
450,
68,
3427,
78,
5,
83,
7,
450,
334,
1598,
1256,
423,
1102,
63,
509,
26829,
63,
515,
12,
4458,
63,
600,
12,
1557,
78,
1370,
904,
8,
1199,
1724,
267,
4645,
275,
1072,
14,
1294,
11633,
267,
340,
822,
8,
4504,
9,
1137,
499,
26,
881,
746,
2186,
4725,
8708,
1591,
367,
26829,
1072,
2071,
83,
401,
283,
435,
2079,
283,
2062,
298,
1782,
63,
719,
26,
1102,
63,
719,
9008,
450,
1072,
9,
267,
2243,
63,
719,
275,
1109,
8,
4504,
59,
16,
566,
267,
1591,
63,
719,
275,
1109,
8,
4504,
59,
17,
566,
267,
3012,
63,
1045,
63,
719,
275,
334,
1782,
63,
2171,
12,
2243,
63,
719,
9,
267,
1256,
423,
1782,
63,
475,
63,
1102,
63,
719,
63,
1130,
59,
2171,
63,
1045,
63,
719,
61,
275,
1591,
63,
719,
267,
1256,
423,
1102,
63,
475,
63,
1782,
63,
719,
63,
1130,
59,
1102,
63,
719,
61,
275,
3012
] |
[
1898,
334,
67,
9,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
12871,
199,
646,
2050,
199,
646,
747,
199,
646,
22214,
199,
646,
295,
199,
646,
984,
199,
646,
900,
199,
199,
646,
15516,
63,
4405,
199,
646,
2088,
63,
3676,
199,
646,
5262,
199,
199,
504,
29219,
492,
1139,
21510,
63,
2537,
421,
199,
318,
485,
1002,
3498,
25087,
8,
3150,
304,
523,
372,
22214,
14,
3498,
8,
3150,
680,
981,
63,
521,
421,
199,
533,
485,
1173,
6432,
8,
785,
304,
523,
408,
3007,
5164,
13,
14600,
4514,
402,
282,
570,
4650,
14,
819,
3814,
23340,
787,
4346,
367,
8059,
13,
1412,
29509,
1380,
314,
523,
12866,
2018,
859,
365,
1202,
14,
523,
408,
523,
347,
636,
826,
721,
277,
12,
931,
304,
272,
291,
423,
515,
275,
931,
819,
347,
636,
4200,
721,
277,
304,
272,
291,
423,
2592,
275,
747,
14,
1490,
8,
277,
423,
515,
12,
747,
14,
47,
63,
15543,
10452,
1204,
747,
14,
47,
63,
32120,
9,
272,
340,
291,
423,
2592,
665,
378,
26,
489,
746,
2186,
360,
6531,
440,
1551,
570,
450,
83,
367,
7664,
7,
450,
291,
423,
515,
9,
272,
12871,
14,
28977,
8,
277,
423,
2592,
12,
12871,
14,
4406,
63,
1438,
9,
819,
347,
636,
2224,
721,
277,
12,
730,
12,
574,
12,
5190,
304,
272,
12871,
14,
28977,
8,
277,
423,
2592,
12,
12871,
14,
4406,
63,
1734,
9,
272,
747,
14,
1600,
8,
277,
423,
2592,
9,
421,
199,
533,
2104,
26829,
8,
785,
304,
523,
408,
4436,
13,
3489,
1021,
370,
9635,
1844,
17465,
687,
314,
2243,
370,
314,
1591,
1041,
819,
485,
10555,
63,
22371,
11733,
63,
19041,
275,
334,
5559,
14,
2864,
63,
21623,
63,
3022,
435,
2892,
1994,
509,
26829,
6217,
523,
485,
10555,
63,
22371,
11733,
63,
3243,
275,
334,
5559,
14,
2864,
63,
21623,
63,
3022,
435,
1169,
1994,
509,
26829,
15,
1782,
63,
509,
26829,
358,
523,
485,
6533,
63,
16983,
63,
3243,
275,
283,
6533,
63,
16983,
63,
3243,
2458,
83,
7,
450,
485,
10555,
63,
22371,
11733,
63,
19041,
523,
485,
4406,
63,
3243,
275,
1994,
2791,
15,
9887,
14,
509,
26829,
14,
831,
7,
523,
485,
21894,
24762,
1608,
1206,
63,
9984,
63,
5568,
275,
283,
1244,
31364,
63,
22371,
11733,
63,
4701,
63,
21894,
24762,
1608,
1206,
7,
523,
327,
11391,
1942,
315,
1591,
63,
509,
26829,
63,
973,
14,
2055,
523,
485,
5449,
63,
22371,
11733,
63,
4947,
275,
1994,
2791,
15,
1102,
63,
509,
26829,
63,
793,
7,
819,
485,
842,
275,
488,
819,
768,
4639,
523,
347,
3645,
3947,
6338,
837,
272,
408,
52,
6840,
314,
367,
26829,
626,
12866,
365,
1202,
1041,
272,
747,
14,
2314,
59,
1858,
26829,
423,
21894,
24762,
1608,
1206,
63,
9984,
63,
5568,
61,
275,
283,
17,
7,
819,
768,
4639,
523,
347,
9672,
8,
719,
63,
7322,
12,
28173,
12,
4744,
29,
403,
304,
272,
408,
16291,
314,
367,
26829,
14,
339,
3033,
26,
489,
1844,
63,
7322,
26,
437,
769,
402,
6346,
334,
1782,
63,
719,
12,
1591,
63,
719,
9,
370,
7568,
14,
3390,
326,
626,
1265,
883,
4165,
378,
465,
282,
2243,
63,
719,
12,
315,
1314,
1930,
282,
326,
1844,
911,
701,
18774,
7943,
641,
314,
2243,
14,
2047,
883,
326,
664,
314,
1329,
402,
314,
7943,
1844,
1808,
314,
326,
12272,
4313,
1858,
4965,
4313,
1083,
14,
489,
28173,
26,
1626,
14694,
14680,
1256,
14,
489,
4744,
26,
15650,
1021,
370,
675,
370,
664,
4975,
12,
340,
5784,
12,
367,
14043,
314,
288,
367,
26829,
334,
3239,
1139,
21510,
63,
2537,
14,
647,
680,
339,
6218,
26,
489,
2186,
641,
5988,
370,
7568,
314,
1844,
14,
272,
408,
272,
340,
440,
4744,
26,
489,
4744,
275,
1139,
21510,
63,
2537,
14,
2499,
5157,
8,
403,
12,
28173,
9,
272,
543,
485,
1173,
6432,
8,
1858,
26829,
423,
4406,
63,
3243,
304,
489,
1256,
275,
2104,
26829,
423,
16486,
22408,
8,
3557,
9,
489,
1256,
423,
9346,
2510,
22408,
8,
13741,
12,
4744,
9,
2541,
2243,
63,
2171,
275,
28173,
14,
33,
697,
1252,
1002,
3571,
3259,
342,
489,
23713,
63,
4405,
275,
359,
881,
14574,
2171,
13,
344,
534,
435,
2243,
63,
2171,
12,
2850,
1130,
297,
620,
8,
1782,
395,
1779,
620,
8,
1102,
1874,
367,
2243,
12,
1591,
315,
1844,
63,
7322,
61,
489,
2050,
14,
815,
360,
26427,
1808,
3718,
26,
450,
83,
297,
23713,
63,
4405,
9,
2541,
367,
23713,
63,
1531,
315,
23713,
63,
4405,
26,
267,
862,
26,
881,
334,
2224,
63,
600,
12,
1072,
9,
275,
2088,
63,
3676,
14,
1002,
7874,
3694,
3325,
2959,
8,
1598,
359,
842,
423,
1102,
63,
509,
26829,
63,
515,
61,
435,
23713,
63,
1531,
9,
267,
871,
6440,
465,
325,
26,
881,
340,
325,
14,
7931,
508,
499,
26,
288,
746,
2186,
360,
6005,
370,
1343,
1591,
367,
26829,
14,
4155,
3238,
1265,
1172,
7,
1169,
283,
6137,
1591,
63,
509,
26829,
2659,
881,
587,
26,
746,
267,
340,
4458,
63,
600,
1137,
378,
26,
881,
746,
2186,
3508,
83,
22987,
543,
450,
68,
3427,
78,
5,
83,
7,
450,
334,
1598,
1256,
423,
1102,
63,
509,
26829,
63,
515,
12,
4458,
63,
600,
12,
1557,
78,
1370,
904,
8,
1199,
1724,
267,
4645,
275,
1072,
14,
1294,
11633,
267,
340,
822,
8,
4504,
9,
1137,
499,
26,
881,
746,
2186,
4725,
8708,
1591,
367,
26829,
1072,
2071,
83,
401,
283,
435,
2079,
283,
2062,
298,
1782,
63,
719,
26,
1102,
63,
719,
9008,
450,
1072,
9,
267,
2243,
63,
719,
275,
1109,
8,
4504,
59,
16,
566,
267,
1591,
63,
719,
275,
1109,
8,
4504,
59,
17,
566,
267,
3012,
63,
1045,
63,
719,
275,
334,
1782,
63,
2171,
12,
2243,
63,
719,
9,
267,
1256,
423,
1782,
63,
475,
63,
1102,
63,
719,
63,
1130,
59,
2171,
63,
1045,
63,
719,
61,
275,
1591,
63,
719,
267,
1256,
423,
1102,
63,
475,
63,
1782,
63,
719,
63,
1130,
59,
1102,
63,
719,
61,
275,
3012,
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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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
] |
raycarnes/stock-logistics-warehouse
|
stock_reserve/model/product.py
|
12
|
2881
|
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
# Copyright 2013 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/>.
#
##############################################################################
from openerp import models, fields, api
class ProductTemplate(models.Model):
_inherit = 'product.template'
reservation_count = fields.Float(
compute='_reservation_count',
string='# Sales')
@api.one
def _reservation_count(self):
self.reservation_count = sum(variant.reservation_count
for variant in self.product_variant_ids)
@api.multi
def action_view_reservations(self):
assert len(self._ids) == 1, "Expected 1 ID, got %r" % self._ids
ref = 'stock_reserve.action_stock_reservation_tree'
product_ids = self._get_products()
action_dict = self._get_act_window_dict(ref)
action_dict['domain'] = [('product_id', 'in', product_ids)]
action_dict['context'] = {
'search_default_draft': 1,
'search_default_reserved': 1
}
return action_dict
class ProductProduct(models.Model):
_inherit = 'product.product'
reservation_count = fields.Float(
compute='_reservation_count',
string='# Sales')
@api.one
def _reservation_count(self):
domain = [('product_id', '=', self.id),
('state', 'in', ['draft', 'assigned'])]
reservations = self.env['stock.reservation'].search(domain)
self.reservation_count = sum(reserv.product_qty
for reserv in reservations)
@api.multi
def action_view_reservations(self):
assert len(self._ids) == 1, "Expected 1 ID, got %r" % self._ids
ref = 'stock_reserve.action_stock_reservation_tree'
product_id = self._ids[0]
action_dict = self.product_tmpl_id._get_act_window_dict(ref)
action_dict['domain'] = [('product_id', '=', product_id)]
action_dict['context'] = {
'search_default_draft': 1,
'search_default_reserved': 1
}
return action_dict
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
6529,
26,
598,
310,
87,
287,
699,
65,
1631,
4446,
199,
3,
259,
1898,
6171,
24569,
475,
20290,
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,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
421,
199,
533,
12705,
4231,
8,
992,
14,
1685,
304,
272,
485,
6486,
275,
283,
2558,
14,
1160,
7,
339,
25476,
63,
835,
275,
1504,
14,
5136,
8,
267,
4526,
17574,
20522,
63,
835,
297,
267,
1059,
26431,
428,
7098,
358,
339,
768,
1246,
14,
368,
272,
347,
485,
20522,
63,
835,
8,
277,
304,
267,
291,
14,
20522,
63,
835,
275,
3089,
8,
8759,
14,
20522,
63,
835,
3660,
367,
9854,
315,
291,
14,
2558,
63,
8759,
63,
1580,
9,
339,
768,
1246,
14,
3029,
272,
347,
1595,
63,
1345,
63,
264,
12225,
8,
277,
304,
267,
702,
822,
8,
277,
423,
1580,
9,
508,
413,
12,
298,
6964,
413,
2870,
12,
4788,
450,
82,
2,
450,
291,
423,
1580,
267,
2984,
275,
283,
6088,
63,
19643,
14,
1287,
63,
6088,
63,
20522,
63,
2350,
7,
267,
3336,
63,
1580,
275,
291,
423,
362,
63,
13336,
342,
267,
1595,
63,
807,
275,
291,
423,
362,
63,
2442,
63,
3806,
63,
807,
8,
1121,
9,
267,
1595,
63,
807,
459,
2261,
418,
275,
4274,
2558,
63,
344,
297,
283,
262,
297,
3336,
63,
1580,
1874,
267,
1595,
63,
807,
459,
1100,
418,
275,
469,
288,
283,
1733,
63,
885,
63,
7185,
356,
413,
12,
288,
283,
1733,
63,
885,
63,
10421,
356,
413,
288,
789,
267,
372,
1595,
63,
807,
421,
199,
533,
12705,
5884,
8,
992,
14,
1685,
304,
272,
485,
6486,
275,
283,
2558,
14,
2558,
7,
339,
25476,
63,
835,
275,
1504,
14,
5136,
8,
267,
4526,
17574,
20522,
63,
835,
297,
267,
1059,
26431,
428,
7098,
358,
339,
768,
1246,
14,
368,
272,
347,
485,
20522,
63,
835,
8,
277,
304,
267,
2881,
275,
4274,
2558,
63,
344,
297,
6291,
291,
14,
344,
395,
2116,
661,
929,
297,
283,
262,
297,
788,
7185,
297,
283,
12941,
24437,
267,
31494,
275,
291,
14,
1813,
459,
6088,
14,
20522,
2278,
1733,
8,
2261,
9,
267,
291,
14,
20522,
63,
835,
275,
3089,
8,
264,
7297,
14,
2558,
63,
5643,
3660,
367,
295,
7297,
315,
31494,
9,
339,
768,
1246,
14,
3029,
272,
347,
1595,
63,
1345,
63,
264,
12225,
8,
277,
304,
267,
702,
822,
8,
277,
423,
1580,
9,
508,
413,
12,
298,
6964,
413,
2870,
12,
4788,
450,
82,
2,
450,
291,
423,
1580,
267,
2984,
275,
283,
6088,
63,
19643,
14,
1287,
63,
6088,
63,
20522,
63,
2350,
7,
267,
3336,
63,
344,
275,
291,
423,
1580,
59,
16,
61,
267,
1595,
63,
807,
275,
291,
14,
2558,
63,
11510,
63,
344,
423,
362,
63,
2442,
63,
3806,
63,
807,
8,
1121,
9,
267,
1595,
63,
807,
459,
2261,
418,
275,
4274,
2558,
63,
344,
297,
6291,
3336,
63,
344,
1874,
267,
1595,
63,
807,
459,
1100,
418,
275,
469,
288,
283,
1733,
63,
885,
63,
7185,
356,
413,
12,
288,
283,
1733,
63,
885,
63,
10421,
356,
413,
288,
789,
267,
372,
1595,
63,
807,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
6529,
26,
598,
310,
87,
287,
699,
65,
1631,
4446,
199,
3,
259,
1898,
6171,
24569,
475,
20290,
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,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
421,
199,
533,
12705,
4231,
8,
992,
14,
1685,
304,
272,
485,
6486,
275,
283,
2558,
14,
1160,
7,
339,
25476,
63,
835,
275,
1504,
14,
5136,
8,
267,
4526,
17574,
20522,
63,
835,
297,
267,
1059,
26431,
428,
7098,
358,
339,
768,
1246,
14,
368,
272,
347,
485,
20522,
63,
835,
8,
277,
304,
267,
291,
14,
20522,
63,
835,
275,
3089,
8,
8759,
14,
20522,
63,
835,
3660,
367,
9854,
315,
291,
14,
2558,
63,
8759,
63,
1580,
9,
339,
768,
1246,
14,
3029,
272,
347,
1595,
63,
1345,
63,
264,
12225,
8,
277,
304,
267,
702,
822,
8,
277,
423,
1580,
9,
508,
413,
12,
298,
6964,
413,
2870,
12,
4788,
450,
82,
2,
450,
291,
423,
1580,
267,
2984,
275,
283,
6088,
63,
19643,
14,
1287,
63,
6088,
63,
20522,
63,
2350,
7,
267,
3336,
63,
1580,
275,
291,
423,
362,
63,
13336,
342,
267,
1595,
63,
807,
275,
291,
423,
362,
63,
2442,
63,
3806,
63,
807,
8,
1121,
9,
267,
1595,
63,
807,
459,
2261,
418,
275,
4274,
2558,
63,
344,
297,
283,
262,
297,
3336,
63,
1580,
1874,
267,
1595,
63,
807,
459,
1100,
418,
275,
469,
288,
283,
1733,
63,
885,
63,
7185,
356,
413,
12,
288,
283,
1733,
63,
885,
63,
10421,
356,
413,
288,
789,
267,
372,
1595,
63,
807,
421,
199,
533,
12705,
5884,
8,
992,
14,
1685,
304,
272,
485,
6486,
275,
283,
2558,
14,
2558,
7,
339,
25476,
63,
835,
275,
1504,
14,
5136,
8,
267,
4526,
17574,
20522,
63,
835,
297,
267,
1059,
26431,
428,
7098,
358,
339,
768,
1246,
14,
368,
272,
347,
485,
20522,
63,
835,
8,
277,
304,
267,
2881,
275,
4274,
2558,
63,
344,
297,
6291,
291,
14,
344,
395,
2116,
661,
929,
297,
283,
262,
297,
788,
7185,
297,
283,
12941,
24437,
267,
31494,
275,
291,
14,
1813,
459,
6088,
14,
20522,
2278,
1733,
8,
2261,
9,
267,
291,
14,
20522,
63,
835,
275,
3089,
8,
264,
7297,
14,
2558,
63,
5643,
3660,
367,
295,
7297,
315,
31494,
9,
339,
768,
1246,
14,
3029,
272,
347,
1595,
63,
1345,
63,
264,
12225,
8,
277,
304,
267,
702,
822,
8,
277,
423,
1580,
9,
508,
413,
12,
298,
6964,
413,
2870,
12,
4788,
450,
82,
2,
450,
291,
423,
1580,
267,
2984,
275,
283,
6088,
63,
19643,
14,
1287,
63,
6088,
63,
20522,
63,
2350,
7,
267,
3336,
63,
344,
275,
291,
423,
1580,
59,
16,
61,
267,
1595,
63,
807,
275,
291,
14,
2558,
63,
11510,
63,
344,
423,
362,
63,
2442,
63,
3806,
63,
807,
8,
1121,
9,
267,
1595,
63,
807,
459,
2261,
418,
275,
4274,
2558,
63,
344,
297,
6291,
3336,
63,
344,
1874,
267,
1595,
63,
807,
459,
1100,
418,
275,
469,
288,
283,
1733,
63,
885,
63,
7185,
356,
413,
12,
288,
283,
1733,
63,
885,
63,
10421,
356,
413,
288,
789,
267,
372,
1595,
63,
807,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Allow2CEO/browser-ios
|
brave/node_modules/ad-block/node_modules/bloom-filter-cpp/vendor/depot_tools/testing_support/super_mox.py
|
25
|
5140
|
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Simplify unit tests based on pymox."""
import os
import random
import shutil
import string
import StringIO
import subprocess
import sys
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from third_party.pymox import mox
class IsOneOf(mox.Comparator):
def __init__(self, keys):
self._keys = keys
def equals(self, rhs):
return rhs in self._keys
def __repr__(self):
return '<sequence or map containing \'%s\'>' % str(self._keys)
class TestCaseUtils(object):
"""Base class with some additional functionalities. People will usually want
to use SuperMoxTestBase instead."""
# Backup the separator in case it gets mocked
_OS_SEP = os.sep
_RANDOM_CHOICE = random.choice
_RANDOM_RANDINT = random.randint
_STRING_LETTERS = string.letters
## Some utilities for generating arbitrary arguments.
def String(self, max_length):
return ''.join([self._RANDOM_CHOICE(self._STRING_LETTERS)
for _ in xrange(self._RANDOM_RANDINT(1, max_length))])
def Strings(self, max_arg_count, max_arg_length):
return [self.String(max_arg_length) for _ in xrange(max_arg_count)]
def Args(self, max_arg_count=8, max_arg_length=16):
return self.Strings(max_arg_count,
self._RANDOM_RANDINT(1, max_arg_length))
def _DirElts(self, max_elt_count=4, max_elt_length=8):
return self._OS_SEP.join(self.Strings(max_elt_count, max_elt_length))
def Dir(self, max_elt_count=4, max_elt_length=8):
return (self._RANDOM_CHOICE((self._OS_SEP, '')) +
self._DirElts(max_elt_count, max_elt_length))
def RootDir(self, max_elt_count=4, max_elt_length=8):
return self._OS_SEP + self._DirElts(max_elt_count, max_elt_length)
def compareMembers(self, obj, members):
"""If you add a member, be sure to add the relevant test!"""
# Skip over members starting with '_' since they are usually not meant to
# be for public use.
actual_members = [x for x in sorted(dir(obj))
if not x.startswith('_')]
expected_members = sorted(members)
if actual_members != expected_members:
diff = ([i for i in actual_members if i not in expected_members] +
[i for i in expected_members if i not in actual_members])
print >> sys.stderr, diff
# pylint: disable=E1101
self.assertEqual(actual_members, expected_members)
def setUp(self):
self.root_dir = self.Dir()
self.args = self.Args()
self.relpath = self.String(200)
def tearDown(self):
pass
class StdoutCheck(object):
def setUp(self):
# Override the mock with a StringIO, it's much less painful to test.
self._old_stdout = sys.stdout
stdout = StringIO.StringIO()
stdout.flush = lambda: None
sys.stdout = stdout
def tearDown(self):
try:
# If sys.stdout was used, self.checkstdout() must be called.
# pylint: disable=E1101
if not sys.stdout.closed:
self.assertEquals('', sys.stdout.getvalue())
except AttributeError:
pass
sys.stdout = self._old_stdout
def checkstdout(self, expected):
value = sys.stdout.getvalue()
sys.stdout.close()
# pylint: disable=E1101
self.assertEquals(expected, value)
class SuperMoxTestBase(TestCaseUtils, StdoutCheck, mox.MoxTestBase):
def setUp(self):
"""Patch a few functions with know side-effects."""
TestCaseUtils.setUp(self)
mox.MoxTestBase.setUp(self)
os_to_mock = ('chdir', 'chown', 'close', 'closerange', 'dup', 'dup2',
'fchdir', 'fchmod', 'fchown', 'fdopen', 'getcwd', 'lseek',
'makedirs', 'mkdir', 'open', 'popen', 'popen2', 'popen3', 'popen4',
'read', 'remove', 'removedirs', 'rename', 'renames', 'rmdir', 'symlink',
'system', 'tmpfile', 'walk', 'write')
self.MockList(os, os_to_mock)
os_path_to_mock = ('abspath', 'exists', 'getsize', 'isdir', 'isfile',
'islink', 'ismount', 'lexists', 'realpath', 'samefile', 'walk')
self.MockList(os.path, os_path_to_mock)
self.MockList(shutil, ('rmtree'))
self.MockList(subprocess, ('call', 'Popen'))
# Don't mock stderr since it confuses unittests.
self.MockList(sys, ('stdin'))
StdoutCheck.setUp(self)
def tearDown(self):
StdoutCheck.tearDown(self)
TestCaseUtils.tearDown(self)
mox.MoxTestBase.tearDown(self)
def MockList(self, parent, items_to_mock):
for item in items_to_mock:
# Skip over items not present because of OS-specific implementation,
# implemented only in later python version, etc.
if hasattr(parent, item):
try:
self.mox.StubOutWithMock(parent, item)
except TypeError, e:
raise TypeError(
'Couldn\'t mock %s in %s: %s' % (item, parent.__name__, e))
def UnMock(self, obj, name):
"""Restore an object inside a test."""
for (parent, old_child, child_name) in self.mox.stubs.cache:
if parent == obj and child_name == name:
setattr(parent, child_name, old_child)
break
|
mpl-2.0
|
[
3,
1898,
334,
67,
9,
7760,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
51,
3236,
8209,
4137,
2295,
4079,
641,
1134,
6625,
1041,
199,
199,
646,
747,
199,
646,
2196,
199,
646,
5145,
199,
646,
1059,
199,
646,
5228,
199,
646,
3873,
199,
646,
984,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
3460,
493,
29658,
199,
504,
10919,
63,
7522,
14,
647,
6625,
492,
18610,
421,
199,
533,
6596,
4395,
3466,
8,
6625,
14,
26636,
304,
523,
347,
636,
826,
721,
277,
12,
2883,
304,
272,
291,
423,
1612,
275,
2883,
819,
347,
18527,
8,
277,
12,
9085,
304,
272,
372,
9085,
315,
291,
423,
1612,
819,
347,
636,
2722,
721,
277,
304,
272,
372,
2650,
4041,
503,
2341,
3035,
19095,
83,
3985,
3524,
450,
620,
8,
277,
423,
1612,
9,
421,
199,
533,
7640,
7535,
8,
785,
304,
523,
408,
1563,
1021,
543,
2005,
4722,
805,
10874,
1417,
14,
11379,
7939,
911,
9987,
2934,
523,
370,
675,
17897,
3716,
88,
14440,
3140,
1041,
523,
327,
10257,
384,
314,
9432,
315,
1930,
652,
7545,
16991,
523,
485,
3100,
63,
20848,
275,
747,
14,
4127,
523,
485,
27644,
10462,
63,
22544,
275,
2196,
14,
5095,
523,
485,
27644,
10462,
63,
50,
3649,
2919,
275,
2196,
14,
8393,
523,
485,
5353,
63,
44,
1573,
51,
275,
1059,
14,
16415,
819,
925,
6601,
15841,
367,
12999,
9697,
2368,
14,
523,
347,
2624,
8,
277,
12,
1390,
63,
1267,
304,
272,
372,
6522,
904,
779,
277,
423,
27644,
10462,
63,
22544,
8,
277,
423,
5353,
63,
44,
1573,
51,
9,
490,
367,
485,
315,
4945,
8,
277,
423,
27644,
10462,
63,
50,
3649,
2919,
8,
17,
12,
1390,
63,
1267,
18229,
819,
347,
24361,
8,
277,
12,
1390,
63,
1273,
63,
835,
12,
1390,
63,
1273,
63,
1267,
304,
272,
372,
359,
277,
14,
1558,
8,
988,
63,
1273,
63,
1267,
9,
367,
485,
315,
4945,
8,
988,
63,
1273,
63,
835,
1874,
819,
347,
3033,
8,
277,
12,
1390,
63,
1273,
63,
835,
29,
24,
12,
1390,
63,
1273,
63,
1267,
29,
975,
304,
272,
372,
291,
14,
12672,
8,
988,
63,
1273,
63,
835,
12,
717,
291,
423,
27644,
10462,
63,
50,
3649,
2919,
8,
17,
12,
1390,
63,
1273,
63,
1267,
430,
819,
347,
485,
3567,
10420,
1086,
8,
277,
12,
1390,
63,
15330,
63,
835,
29,
20,
12,
1390,
63,
15330,
63,
1267,
29,
24,
304,
272,
372,
291,
423,
3100,
63,
20848,
14,
904,
8,
277,
14,
12672,
8,
988,
63,
15330,
63,
835,
12,
1390,
63,
15330,
63,
1267,
430,
819,
347,
25866,
8,
277,
12,
1390,
63,
15330,
63,
835,
29,
20,
12,
1390,
63,
15330,
63,
1267,
29,
24,
304,
272,
372,
334,
277,
423,
27644,
10462,
63,
22544,
1332,
277,
423,
3100,
63,
20848,
12,
12381,
435,
288,
291,
423,
3567,
10420,
1086,
8,
988,
63,
15330,
63,
835,
12,
1390,
63,
15330,
63,
1267,
430,
819,
347,
12826,
3567,
8,
277,
12,
1390,
63,
15330,
63,
835,
29,
20,
12,
1390,
63,
15330,
63,
1267,
29,
24,
304,
272,
372,
291,
423,
3100,
63,
20848,
435,
291,
423,
3567,
10420,
1086,
8,
988,
63,
15330,
63,
835,
12,
1390,
63,
15330,
63,
1267,
9,
819,
347,
6540,
23056,
8,
277,
12,
1559,
12,
7556,
304,
272,
408,
3917,
1265,
1050,
282,
3653,
12,
506,
3238,
370,
1050,
314,
12082,
511,
1,
624,
272,
327,
8232,
1806,
7556,
6617,
543,
14135,
3967,
2985,
787,
9987,
440,
18329,
370,
272,
327,
506,
367,
4575,
675,
14,
272,
3503,
63,
6334,
275,
359,
88,
367,
671,
315,
3355,
8,
694,
8,
1113,
430,
1993,
340,
440,
671,
14,
2460,
6412,
5440,
272,
1420,
63,
6334,
275,
3355,
8,
6334,
9,
272,
340,
3503,
63,
6334,
1137,
1420,
63,
6334,
26,
489,
3915,
275,
7287,
73,
367,
284,
315,
3503,
63,
6334,
340,
284,
440,
315,
1420,
63,
6334,
61,
435,
1598,
359,
73,
367,
284,
315,
1420,
63,
6334,
340,
284,
440,
315,
3503,
63,
6334,
566,
489,
870,
4331,
984,
14,
3083,
12,
3915,
272,
327,
4287,
26,
3507,
29,
37,
24827,
272,
291,
14,
629,
8,
6514,
63,
6334,
12,
1420,
63,
6334,
9,
819,
347,
3613,
8,
277,
304,
272,
291,
14,
1231,
63,
694,
275,
291,
14,
3567,
342,
272,
291,
14,
589,
275,
291,
14,
6213,
342,
272,
291,
14,
12405,
275,
291,
14,
1558,
8,
1840,
9,
819,
347,
6766,
8,
277,
304,
272,
986,
421,
199,
533,
20992,
548,
1799,
8,
785,
304,
523,
347,
3613,
8,
277,
304,
272,
327,
11041,
314,
1683,
543,
282,
5228,
12,
652,
1159,
8298,
6656,
691,
262,
1893,
370,
511,
14,
272,
291,
423,
1753,
63,
2703,
275,
984,
14,
2703,
272,
3839,
275,
5228,
14,
6424,
342,
272,
3839,
14,
4939,
275,
2400,
26,
488,
272,
984,
14,
2703,
275,
3839,
819,
347,
6766,
8,
277,
304,
272,
862,
26,
489,
327,
982,
984,
14,
2703,
1990,
1202,
12,
291,
14,
1074,
2703,
342,
1471,
506,
2797,
14,
489,
327,
4287,
26,
3507,
29,
37,
24827,
489,
340,
440,
984,
14,
2703,
14,
5938,
26,
267,
291,
14,
2947,
8594,
984,
14,
2703,
14,
7150,
1012,
272,
871,
4281,
26,
489,
986,
272,
984,
14,
2703,
275,
291,
423,
1753,
63,
2703,
819,
347,
1104,
2703,
8,
277,
12,
1420,
304,
272,
574,
275,
984,
14,
2703,
14,
7150,
342,
272,
984,
14,
2703,
14,
1600,
342,
272,
327,
4287,
26,
3507,
29,
37,
24827,
272,
291,
14,
2947,
8,
2062,
12,
574,
9,
421,
199,
533,
17897,
3716,
88,
14440,
8,
1746,
7535,
12,
20992,
548,
1799,
12,
18610,
14,
3716,
88,
14440,
304,
523,
347,
3613,
8,
277,
304,
272,
408,
11173,
282,
9284,
3423,
543,
5715,
5366,
13,
27626,
1041,
272,
7640,
7535,
14,
5996,
8,
277,
9,
272,
18610,
14,
3716,
88,
14440,
14,
5996,
8,
277,
9,
272,
747,
63,
475,
63,
1805,
275,
661,
8563,
297,
283,
20933
] |
[
1898,
334,
67,
9,
7760,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
51,
3236,
8209,
4137,
2295,
4079,
641,
1134,
6625,
1041,
199,
199,
646,
747,
199,
646,
2196,
199,
646,
5145,
199,
646,
1059,
199,
646,
5228,
199,
646,
3873,
199,
646,
984,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
3460,
493,
29658,
199,
504,
10919,
63,
7522,
14,
647,
6625,
492,
18610,
421,
199,
533,
6596,
4395,
3466,
8,
6625,
14,
26636,
304,
523,
347,
636,
826,
721,
277,
12,
2883,
304,
272,
291,
423,
1612,
275,
2883,
819,
347,
18527,
8,
277,
12,
9085,
304,
272,
372,
9085,
315,
291,
423,
1612,
819,
347,
636,
2722,
721,
277,
304,
272,
372,
2650,
4041,
503,
2341,
3035,
19095,
83,
3985,
3524,
450,
620,
8,
277,
423,
1612,
9,
421,
199,
533,
7640,
7535,
8,
785,
304,
523,
408,
1563,
1021,
543,
2005,
4722,
805,
10874,
1417,
14,
11379,
7939,
911,
9987,
2934,
523,
370,
675,
17897,
3716,
88,
14440,
3140,
1041,
523,
327,
10257,
384,
314,
9432,
315,
1930,
652,
7545,
16991,
523,
485,
3100,
63,
20848,
275,
747,
14,
4127,
523,
485,
27644,
10462,
63,
22544,
275,
2196,
14,
5095,
523,
485,
27644,
10462,
63,
50,
3649,
2919,
275,
2196,
14,
8393,
523,
485,
5353,
63,
44,
1573,
51,
275,
1059,
14,
16415,
819,
925,
6601,
15841,
367,
12999,
9697,
2368,
14,
523,
347,
2624,
8,
277,
12,
1390,
63,
1267,
304,
272,
372,
6522,
904,
779,
277,
423,
27644,
10462,
63,
22544,
8,
277,
423,
5353,
63,
44,
1573,
51,
9,
490,
367,
485,
315,
4945,
8,
277,
423,
27644,
10462,
63,
50,
3649,
2919,
8,
17,
12,
1390,
63,
1267,
18229,
819,
347,
24361,
8,
277,
12,
1390,
63,
1273,
63,
835,
12,
1390,
63,
1273,
63,
1267,
304,
272,
372,
359,
277,
14,
1558,
8,
988,
63,
1273,
63,
1267,
9,
367,
485,
315,
4945,
8,
988,
63,
1273,
63,
835,
1874,
819,
347,
3033,
8,
277,
12,
1390,
63,
1273,
63,
835,
29,
24,
12,
1390,
63,
1273,
63,
1267,
29,
975,
304,
272,
372,
291,
14,
12672,
8,
988,
63,
1273,
63,
835,
12,
717,
291,
423,
27644,
10462,
63,
50,
3649,
2919,
8,
17,
12,
1390,
63,
1273,
63,
1267,
430,
819,
347,
485,
3567,
10420,
1086,
8,
277,
12,
1390,
63,
15330,
63,
835,
29,
20,
12,
1390,
63,
15330,
63,
1267,
29,
24,
304,
272,
372,
291,
423,
3100,
63,
20848,
14,
904,
8,
277,
14,
12672,
8,
988,
63,
15330,
63,
835,
12,
1390,
63,
15330,
63,
1267,
430,
819,
347,
25866,
8,
277,
12,
1390,
63,
15330,
63,
835,
29,
20,
12,
1390,
63,
15330,
63,
1267,
29,
24,
304,
272,
372,
334,
277,
423,
27644,
10462,
63,
22544,
1332,
277,
423,
3100,
63,
20848,
12,
12381,
435,
288,
291,
423,
3567,
10420,
1086,
8,
988,
63,
15330,
63,
835,
12,
1390,
63,
15330,
63,
1267,
430,
819,
347,
12826,
3567,
8,
277,
12,
1390,
63,
15330,
63,
835,
29,
20,
12,
1390,
63,
15330,
63,
1267,
29,
24,
304,
272,
372,
291,
423,
3100,
63,
20848,
435,
291,
423,
3567,
10420,
1086,
8,
988,
63,
15330,
63,
835,
12,
1390,
63,
15330,
63,
1267,
9,
819,
347,
6540,
23056,
8,
277,
12,
1559,
12,
7556,
304,
272,
408,
3917,
1265,
1050,
282,
3653,
12,
506,
3238,
370,
1050,
314,
12082,
511,
1,
624,
272,
327,
8232,
1806,
7556,
6617,
543,
14135,
3967,
2985,
787,
9987,
440,
18329,
370,
272,
327,
506,
367,
4575,
675,
14,
272,
3503,
63,
6334,
275,
359,
88,
367,
671,
315,
3355,
8,
694,
8,
1113,
430,
1993,
340,
440,
671,
14,
2460,
6412,
5440,
272,
1420,
63,
6334,
275,
3355,
8,
6334,
9,
272,
340,
3503,
63,
6334,
1137,
1420,
63,
6334,
26,
489,
3915,
275,
7287,
73,
367,
284,
315,
3503,
63,
6334,
340,
284,
440,
315,
1420,
63,
6334,
61,
435,
1598,
359,
73,
367,
284,
315,
1420,
63,
6334,
340,
284,
440,
315,
3503,
63,
6334,
566,
489,
870,
4331,
984,
14,
3083,
12,
3915,
272,
327,
4287,
26,
3507,
29,
37,
24827,
272,
291,
14,
629,
8,
6514,
63,
6334,
12,
1420,
63,
6334,
9,
819,
347,
3613,
8,
277,
304,
272,
291,
14,
1231,
63,
694,
275,
291,
14,
3567,
342,
272,
291,
14,
589,
275,
291,
14,
6213,
342,
272,
291,
14,
12405,
275,
291,
14,
1558,
8,
1840,
9,
819,
347,
6766,
8,
277,
304,
272,
986,
421,
199,
533,
20992,
548,
1799,
8,
785,
304,
523,
347,
3613,
8,
277,
304,
272,
327,
11041,
314,
1683,
543,
282,
5228,
12,
652,
1159,
8298,
6656,
691,
262,
1893,
370,
511,
14,
272,
291,
423,
1753,
63,
2703,
275,
984,
14,
2703,
272,
3839,
275,
5228,
14,
6424,
342,
272,
3839,
14,
4939,
275,
2400,
26,
488,
272,
984,
14,
2703,
275,
3839,
819,
347,
6766,
8,
277,
304,
272,
862,
26,
489,
327,
982,
984,
14,
2703,
1990,
1202,
12,
291,
14,
1074,
2703,
342,
1471,
506,
2797,
14,
489,
327,
4287,
26,
3507,
29,
37,
24827,
489,
340,
440,
984,
14,
2703,
14,
5938,
26,
267,
291,
14,
2947,
8594,
984,
14,
2703,
14,
7150,
1012,
272,
871,
4281,
26,
489,
986,
272,
984,
14,
2703,
275,
291,
423,
1753,
63,
2703,
819,
347,
1104,
2703,
8,
277,
12,
1420,
304,
272,
574,
275,
984,
14,
2703,
14,
7150,
342,
272,
984,
14,
2703,
14,
1600,
342,
272,
327,
4287,
26,
3507,
29,
37,
24827,
272,
291,
14,
2947,
8,
2062,
12,
574,
9,
421,
199,
533,
17897,
3716,
88,
14440,
8,
1746,
7535,
12,
20992,
548,
1799,
12,
18610,
14,
3716,
88,
14440,
304,
523,
347,
3613,
8,
277,
304,
272,
408,
11173,
282,
9284,
3423,
543,
5715,
5366,
13,
27626,
1041,
272,
7640,
7535,
14,
5996,
8,
277,
9,
272,
18610,
14,
3716,
88,
14440,
14,
5996,
8,
277,
9,
272,
747,
63,
475,
63,
1805,
275,
661,
8563,
297,
283,
20933,
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,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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
] |
uclouvain/osis
|
base/models/session_exam_deadline.py
|
1
|
4136
|
##############################################################################
#
# OSIS stands for Open Student Information System. It's an application
# designed to manage the core business of higher education institutions,
# such as universities, faculties, institutes and professional schools.
# The core business involves the administration of students, teachers,
# courses, programs and so on.
#
# Copyright (C) 2015-2019 Université catholique de Louvain (http://www.uclouvain.be)
#
# 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.
#
# A copy of this license - GNU General Public License - is available
# at the root of the source code of this program. If not,
# see http://www.gnu.org/licenses/.
#
##############################################################################
import datetime
from django.db import models
from base.models.enums import number_session
from base.signals.publisher import compute_student_score_encoding_deadline
from osis_common.models.osis_model_admin import OsisModelAdmin
class SessionExamDeadlineAdmin(OsisModelAdmin):
list_display = ('offer_enrollment', 'deadline', 'deadline_tutor', 'number_session', 'changed')
list_filter = ('number_session',)
raw_id_fields = ('offer_enrollment',)
search_fields = ['offer_enrollment__student__person__first_name', 'offer_enrollment__student__person__last_name',
'offer_enrollment__student__registration_id', 'offer_enrollment__education_group_year__acronym']
class SessionExamDeadline(models.Model):
external_id = models.CharField(max_length=100, blank=True, null=True, db_index=True)
changed = models.DateTimeField(null=True, auto_now=True)
deadline = models.DateField()
deliberation_date = models.DateField(blank=True, null=True)
deadline_tutor = models.IntegerField(null=True, blank=True) # Delta day(s)
number_session = models.IntegerField(choices=number_session.NUMBERS_SESSION)
offer_enrollment = models.ForeignKey('OfferEnrollment', on_delete=models.CASCADE)
__original_deliberation_date = None
def __init__(self, *args, **kwargs):
super(SessionExamDeadline, self).__init__(*args, **kwargs)
self.__original_deliberation_date = self.deliberation_date
def save(self, *args, **kwargs):
super(SessionExamDeadline, self).save(*args, **kwargs)
if self.deliberation_date != self.__original_deliberation_date:
compute_student_score_encoding_deadline.send(sender=self.__class__, session_exam_deadline=self)
@property
def deadline_tutor_computed(self):
return compute_deadline_tutor(self.deadline, self.deadline_tutor)
@property
def is_deadline_reached(self):
return self.deadline < datetime.date.today()
@property
def is_deadline_tutor_reached(self):
if self.deadline_tutor_computed:
return self.deadline_tutor_computed < datetime.date.today()
return self.is_deadline_reached
def __str__(self):
return u"%s-%s" % (self.offer_enrollment, self.number_session)
def compute_deadline_tutor(deadline, deadline_tutor):
if deadline_tutor is not None:
return deadline - datetime.timedelta(days=deadline_tutor)
return None
def filter_by_nb_session(nb_session):
return SessionExamDeadline.objects.filter(number_session=nb_session)
def get_by_offer_enrollment_nb_session(offer_enrollment, nb_session):
try:
return SessionExamDeadline.objects.get(offer_enrollment=offer_enrollment.id,
number_session=nb_session)
except SessionExamDeadline.DoesNotExist:
return None
|
agpl-3.0
|
[
4605,
199,
3,
199,
3,
259,
4403,
1311,
410,
5915,
367,
3232,
17246,
17064,
6187,
14,
2779,
1159,
376,
4223,
199,
3,
259,
19829,
370,
9635,
314,
6170,
26440,
402,
10948,
3988,
30500,
2727,
390,
8653,
12,
199,
3,
259,
4066,
465,
625,
4380,
338,
1417,
12,
21625,
1141,
397,
12,
2727,
390,
3862,
436,
22398,
28661,
308,
2239,
1446,
14,
199,
3,
259,
710,
6170,
26440,
25613,
2310,
314,
4628,
4633,
402,
18557,
12,
1565,
1225,
1192,
12,
199,
3,
259,
13588,
12,
18572,
436,
880,
641,
14,
199,
3,
199,
3,
259,
1898,
334,
35,
9,
6900,
13,
14982,
1910,
4380,
2221,
5741,
286,
1619,
23711,
544,
477,
491,
810,
86,
1581,
334,
1014,
921,
1544,
14,
947,
320,
9154,
1581,
14,
1235,
9,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
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,
437,
1331,
402,
642,
4190,
446,
1664,
1696,
1684,
844,
446,
365,
2808,
199,
3,
259,
737,
314,
1738,
402,
314,
1350,
1233,
402,
642,
2240,
14,
221,
982,
440,
12,
199,
3,
259,
1937,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
8083,
199,
3,
199,
4605,
199,
646,
2197,
199,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
504,
1300,
14,
992,
14,
19921,
492,
1329,
63,
1730,
199,
504,
1300,
14,
10458,
14,
12789,
492,
4526,
63,
5500,
63,
3397,
63,
2991,
63,
22357,
199,
504,
312,
2316,
63,
2330,
14,
992,
14,
79,
2316,
63,
1238,
63,
2113,
492,
593,
2316,
12976,
421,
199,
533,
8596,
920,
455,
22147,
604,
4880,
8,
47,
2316,
12976,
304,
272,
769,
63,
2918,
275,
661,
12786,
63,
12214,
297,
283,
22357,
297,
283,
22357,
63,
84,
4139,
297,
283,
1955,
63,
1730,
297,
283,
2489,
358,
272,
769,
63,
1541,
275,
661,
1955,
63,
1730,
9538,
272,
3066,
63,
344,
63,
955,
275,
661,
12786,
63,
12214,
9538,
272,
2754,
63,
955,
275,
788,
12786,
63,
12214,
363,
5500,
363,
5484,
363,
2246,
63,
354,
297,
283,
12786,
63,
12214,
363,
5500,
363,
5484,
363,
2019,
63,
354,
297,
2151,
283,
12786,
63,
12214,
363,
5500,
363,
8054,
63,
344,
297,
283,
12786,
63,
12214,
363,
379,
30500,
63,
923,
63,
3403,
363,
645,
2641,
12828,
418,
421,
199,
533,
8596,
920,
455,
22147,
604,
8,
992,
14,
1685,
304,
272,
5957,
63,
344,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
12,
2973,
29,
549,
12,
1592,
63,
1080,
29,
549,
9,
272,
2896,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
2599,
63,
2131,
29,
549,
9,
272,
23081,
275,
1709,
14,
14071,
342,
272,
9122,
605,
425,
63,
602,
275,
1709,
14,
14071,
8,
2500,
29,
549,
12,
2973,
29,
549,
9,
272,
23081,
63,
84,
4139,
275,
1709,
14,
3901,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
221,
327,
18464,
502,
5382,
8,
83,
9,
272,
1329,
63,
1730,
275,
1709,
14,
3901,
8,
4577,
29,
1955,
63,
1730,
14,
8861,
3960,
63,
12763,
9,
272,
19793,
63,
12214,
275,
1709,
14,
3190,
360,
22154,
13842,
297,
641,
63,
1807,
29,
992,
14,
10855,
9,
339,
636,
5043,
63,
6933,
605,
425,
63,
602,
275,
488,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
4434,
920,
455,
22147,
604,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
855,
5043,
63,
6933,
605,
425,
63,
602,
275,
291,
14,
6933,
605,
425,
63,
602,
339,
347,
3354,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
4434,
920,
455,
22147,
604,
12,
291,
680,
2117,
2031,
589,
12,
1011,
958,
9,
267,
340,
291,
14,
6933,
605,
425,
63,
602,
1137,
291,
855,
5043,
63,
6933,
605,
425,
63,
602,
26,
288,
4526,
63,
5500,
63,
3397,
63,
2991,
63,
22357,
14,
2254,
8,
8114,
29,
277,
855,
533,
3108,
2351,
63,
15425,
63,
22357,
29,
277,
9,
339,
768,
1829,
272,
347,
23081,
63,
84,
4139,
63,
14378,
8,
277,
304,
267,
372,
4526,
63,
22357,
63,
84,
4139,
8,
277,
14,
22357,
12,
291,
14,
22357,
63,
84,
4139,
9,
339,
768,
1829,
272,
347,
365,
63,
22357,
63,
30931,
8,
277,
304,
267,
372,
291,
14,
22357,
665,
2197,
14,
602,
14,
8136,
342,
339,
768,
1829,
272,
347,
365,
63,
22357,
63,
84,
4139,
63,
30931,
8,
277,
304,
267,
340,
291,
14,
22357,
63,
84,
4139,
63,
14378,
26,
288,
372,
291,
14,
22357,
63,
84,
4139,
63,
14378,
665,
2197,
14,
602,
14,
8136,
342,
267,
372,
291,
14,
374,
63,
22357,
63,
30931,
339,
347,
636,
495,
721,
277,
304,
267,
372,
399,
6808,
83,
3295,
83,
2,
450,
334,
277,
14,
12786,
63,
12214,
12,
291,
14,
1955,
63,
1730,
9,
421,
199,
318,
4526,
63,
22357,
63,
84,
4139,
8,
22357,
12,
23081,
63,
84,
4139,
304,
272,
340,
23081,
63,
84,
4139,
365,
440,
488,
26,
267,
372,
23081,
446,
2197,
14,
7473,
8,
4899,
29,
22357,
63,
84,
4139,
9,
272,
372,
488,
421,
199,
318,
2457,
63,
991,
63,
4994,
63,
1730,
8,
4994,
63,
1730,
304,
272,
372,
8596,
920,
455,
22147,
604,
14,
1462,
14,
1541,
8,
1955,
63,
1730,
29,
4994,
63,
1730,
9,
421,
199,
318,
664,
63,
991,
63,
12786,
63,
12214,
63,
4994,
63,
1730,
8,
12786,
63,
12214,
12,
8526,
63,
1730,
304,
272,
862,
26,
267,
372,
8596,
920,
455,
22147,
604,
14
] |
[
199,
3,
199,
3,
259,
4403,
1311,
410,
5915,
367,
3232,
17246,
17064,
6187,
14,
2779,
1159,
376,
4223,
199,
3,
259,
19829,
370,
9635,
314,
6170,
26440,
402,
10948,
3988,
30500,
2727,
390,
8653,
12,
199,
3,
259,
4066,
465,
625,
4380,
338,
1417,
12,
21625,
1141,
397,
12,
2727,
390,
3862,
436,
22398,
28661,
308,
2239,
1446,
14,
199,
3,
259,
710,
6170,
26440,
25613,
2310,
314,
4628,
4633,
402,
18557,
12,
1565,
1225,
1192,
12,
199,
3,
259,
13588,
12,
18572,
436,
880,
641,
14,
199,
3,
199,
3,
259,
1898,
334,
35,
9,
6900,
13,
14982,
1910,
4380,
2221,
5741,
286,
1619,
23711,
544,
477,
491,
810,
86,
1581,
334,
1014,
921,
1544,
14,
947,
320,
9154,
1581,
14,
1235,
9,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
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,
437,
1331,
402,
642,
4190,
446,
1664,
1696,
1684,
844,
446,
365,
2808,
199,
3,
259,
737,
314,
1738,
402,
314,
1350,
1233,
402,
642,
2240,
14,
221,
982,
440,
12,
199,
3,
259,
1937,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
8083,
199,
3,
199,
4605,
199,
646,
2197,
199,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
504,
1300,
14,
992,
14,
19921,
492,
1329,
63,
1730,
199,
504,
1300,
14,
10458,
14,
12789,
492,
4526,
63,
5500,
63,
3397,
63,
2991,
63,
22357,
199,
504,
312,
2316,
63,
2330,
14,
992,
14,
79,
2316,
63,
1238,
63,
2113,
492,
593,
2316,
12976,
421,
199,
533,
8596,
920,
455,
22147,
604,
4880,
8,
47,
2316,
12976,
304,
272,
769,
63,
2918,
275,
661,
12786,
63,
12214,
297,
283,
22357,
297,
283,
22357,
63,
84,
4139,
297,
283,
1955,
63,
1730,
297,
283,
2489,
358,
272,
769,
63,
1541,
275,
661,
1955,
63,
1730,
9538,
272,
3066,
63,
344,
63,
955,
275,
661,
12786,
63,
12214,
9538,
272,
2754,
63,
955,
275,
788,
12786,
63,
12214,
363,
5500,
363,
5484,
363,
2246,
63,
354,
297,
283,
12786,
63,
12214,
363,
5500,
363,
5484,
363,
2019,
63,
354,
297,
2151,
283,
12786,
63,
12214,
363,
5500,
363,
8054,
63,
344,
297,
283,
12786,
63,
12214,
363,
379,
30500,
63,
923,
63,
3403,
363,
645,
2641,
12828,
418,
421,
199,
533,
8596,
920,
455,
22147,
604,
8,
992,
14,
1685,
304,
272,
5957,
63,
344,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
12,
4596,
29,
549,
12,
2973,
29,
549,
12,
1592,
63,
1080,
29,
549,
9,
272,
2896,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
2599,
63,
2131,
29,
549,
9,
272,
23081,
275,
1709,
14,
14071,
342,
272,
9122,
605,
425,
63,
602,
275,
1709,
14,
14071,
8,
2500,
29,
549,
12,
2973,
29,
549,
9,
272,
23081,
63,
84,
4139,
275,
1709,
14,
3901,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
221,
327,
18464,
502,
5382,
8,
83,
9,
272,
1329,
63,
1730,
275,
1709,
14,
3901,
8,
4577,
29,
1955,
63,
1730,
14,
8861,
3960,
63,
12763,
9,
272,
19793,
63,
12214,
275,
1709,
14,
3190,
360,
22154,
13842,
297,
641,
63,
1807,
29,
992,
14,
10855,
9,
339,
636,
5043,
63,
6933,
605,
425,
63,
602,
275,
488,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
4434,
920,
455,
22147,
604,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
855,
5043,
63,
6933,
605,
425,
63,
602,
275,
291,
14,
6933,
605,
425,
63,
602,
339,
347,
3354,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
4434,
920,
455,
22147,
604,
12,
291,
680,
2117,
2031,
589,
12,
1011,
958,
9,
267,
340,
291,
14,
6933,
605,
425,
63,
602,
1137,
291,
855,
5043,
63,
6933,
605,
425,
63,
602,
26,
288,
4526,
63,
5500,
63,
3397,
63,
2991,
63,
22357,
14,
2254,
8,
8114,
29,
277,
855,
533,
3108,
2351,
63,
15425,
63,
22357,
29,
277,
9,
339,
768,
1829,
272,
347,
23081,
63,
84,
4139,
63,
14378,
8,
277,
304,
267,
372,
4526,
63,
22357,
63,
84,
4139,
8,
277,
14,
22357,
12,
291,
14,
22357,
63,
84,
4139,
9,
339,
768,
1829,
272,
347,
365,
63,
22357,
63,
30931,
8,
277,
304,
267,
372,
291,
14,
22357,
665,
2197,
14,
602,
14,
8136,
342,
339,
768,
1829,
272,
347,
365,
63,
22357,
63,
84,
4139,
63,
30931,
8,
277,
304,
267,
340,
291,
14,
22357,
63,
84,
4139,
63,
14378,
26,
288,
372,
291,
14,
22357,
63,
84,
4139,
63,
14378,
665,
2197,
14,
602,
14,
8136,
342,
267,
372,
291,
14,
374,
63,
22357,
63,
30931,
339,
347,
636,
495,
721,
277,
304,
267,
372,
399,
6808,
83,
3295,
83,
2,
450,
334,
277,
14,
12786,
63,
12214,
12,
291,
14,
1955,
63,
1730,
9,
421,
199,
318,
4526,
63,
22357,
63,
84,
4139,
8,
22357,
12,
23081,
63,
84,
4139,
304,
272,
340,
23081,
63,
84,
4139,
365,
440,
488,
26,
267,
372,
23081,
446,
2197,
14,
7473,
8,
4899,
29,
22357,
63,
84,
4139,
9,
272,
372,
488,
421,
199,
318,
2457,
63,
991,
63,
4994,
63,
1730,
8,
4994,
63,
1730,
304,
272,
372,
8596,
920,
455,
22147,
604,
14,
1462,
14,
1541,
8,
1955,
63,
1730,
29,
4994,
63,
1730,
9,
421,
199,
318,
664,
63,
991,
63,
12786,
63,
12214,
63,
4994,
63,
1730,
8,
12786,
63,
12214,
12,
8526,
63,
1730,
304,
272,
862,
26,
267,
372,
8596,
920,
455,
22147,
604,
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,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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
] |
drmrd/ansible
|
lib/ansible/modules/windows/win_domain_user.py
|
24
|
10493
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# 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_domain_user
version_added: '2.4'
short_description: Manages Windows Active Directory user accounts
description:
- Manages Windows Active Directory user accounts.
options:
name:
description:
- Name of the user to create, remove or modify.
required: true
state:
description:
- When C(present), creates or updates the user account. When C(absent),
removes the user account if it exists. When C(query),
retrieves the user account details without making any changes.
choices: [ absent, present, query ]
default: present
enabled:
description:
- C(yes) will enable the user account.
- C(no) will disable the account.
type: bool
default: 'yes'
account_locked:
description:
- C(no) will unlock the user account if locked. Note that there is not a
way to lock an account as an administrator. Accounts are locked due to
user actions; as an admin, you may only unlock a locked account. If you
wish to administratively disable an account, set I(enabled) to C(no).
choices: [ 'no' ]
description:
description:
- Description of the user
groups:
description:
- Adds or removes the user from this list of groups,
depending on the value of I(groups_action). To remove all but the
Principal Group, set C(groups=<principal group name>) and
I(groups_action=replace). Note that users cannot be removed from
their principal group (for example, "Domain Users").
groups_action:
description:
- If C(add), the user is added to each group in I(groups) where not
already a member.
- If C(remove), the user is removed from each group in I(groups).
- If C(replace), the user is added as a member of each group in
I(groups) and removed from any other groups.
choices: [ add, remove, replace ]
default: replace
password:
description:
- Optionally set the user's password to this (plain text) value. In order
to enable an account - I(enabled) - a password must already be
configured on the account, or you must provide a password here.
update_password:
description:
- C(always) will update passwords if they differ.
- C(on_create) will only set the password for newly created users.
- Note that C(always) will always report an Ansible status of 'changed'
because we cannot determine whether the new password differs from
the old password.
choices: [ always, on_create ]
default: always
password_expired:
description:
- C(yes) will require the user to change their password at next login.
- C(no) will clear the expired password flag.
- This is mutually exclusive with I(password_never_expires).
type: bool
password_never_expires:
description:
- C(yes) will set the password to never expire.
- C(no) will allow the password to expire.
- This is mutually exclusive with I(password_expired).
type: bool
user_cannot_change_password:
description:
- C(yes) will prevent the user from changing their password.
- C(no) will allow the user to change their password.
type: bool
firstname:
description:
- Configures the user's first name (given name).
surname:
description:
- Configures the user's last name (surname).
company:
description:
- Configures the user's company name.
upn:
description:
- Configures the User Principal Name (UPN) for the account.
- This is not required, but is best practice to configure for modern
versions of Active Directory.
- The format is C(<username>@<domain>).
email:
description:
- Configures the user's email address.
- This is a record in AD and does not do anything to configure any email
servers or systems.
street:
description:
- Configures the user's street address.
city:
description:
- Configures the user's city.
state_province:
description:
- Configures the user's state or province.
postal_code:
description:
- Configures the user's postal code / zip code.
country:
description:
- Configures the user's country code.
- Note that this is a two-character ISO 3166 code.
path:
description:
- Container or OU for the new user; if you do not specify this, the
user will be placed in the default container for users in the domain.
- Setting the path is only available when a new user is created;
if you specify a path on an existing user, the user's path will not
be updated - you must delete (e.g., state=absent) the user and
then re-add the user with the appropriate path.
attributes:
description:
- A dict of custom LDAP attributes to set on the user.
- This can be used to set custom attributes that are not exposed as module
parameters, e.g. C(telephoneNumber).
- See the examples on how to format this parameter.
version_added: '2.5'
domain_username:
description:
- The username to use when interacting with AD.
- If this is not set then the user Ansible used to log in with will be
used instead when using CredSSP or Kerberos with credential delegation.
version_added: '2.5'
domain_password:
description:
- The password for I(username).
version_added: '2.5'
domain_server:
description:
- Specifies the Active Directory Domain Services instance to connect to.
- Can be in the form of an FQDN or NetBIOS name.
- If not specified then the value is based on the domain of the computer
running PowerShell.
version_added: '2.5'
notes:
- Works with Windows 2012R2 and newer.
- If running on a server that is not a Domain Controller, credential
delegation through CredSSP or Kerberos with delegation must be used or the
I(domain_username), I(domain_password) must be set.
- Note that some individuals have confirmed successful operation on Windows
2008R2 servers with AD and AD Web Services enabled, but this has not
received the same degree of testing as Windows 2012R2.
author:
- Nick Chandler (@nwchandler)
'''
EXAMPLES = r'''
- name: Ensure user bob is present with address information
win_domain_user:
name: bob
firstname: Bob
surname: Smith
company: BobCo
password: B0bP4ssw0rd
state: present
groups:
- Domain Admins
street: 123 4th St.
city: Sometown
state_province: IN
postal_code: 12345
country: US
attributes:
telephoneNumber: 555-123456
- name: Ensure user bob is created and use custom credentials to create the user
win_domain_user:
name: bob
firstname: Bob
surname: Smith
password: B0bP4ssw0rd
state: present
domain_username: DOMAIN\admin-account
domain_password: SomePas2w0rd
domain_server: domain@DOMAIN.COM
- name: Ensure user bob is present in OU ou=test,dc=domain,dc=local
win_domain_user:
name: bob
password: B0bP4ssw0rd
state: present
path: ou=test,dc=domain,dc=local
groups:
- Domain Admins
- name: Ensure user bob is absent
win_domain_user:
name: bob
state: absent
'''
RETURN = r'''
account_locked:
description: true if the account is locked
returned: always
type: boolean
sample: false
changed:
description: true if the account changed during execution
returned: always
type: boolean
sample: false
city:
description: The user city
returned: always
type: string
sample: Indianapolis
company:
description: The user company
returned: always
type: string
sample: RedHat
country:
description: The user country
returned: always
type: string
sample: US
description:
description: A description of the account
returned: always
type: string
sample: Server Administrator
distinguished_name:
description: DN of the user account
returned: always
type: string
sample: CN=nick,OU=test,DC=domain,DC=local
email:
description: The user email address
returned: always
type: string
sample: nick@domain.local
enabled:
description: true if the account is enabled and false if disabled
returned: always
type: string
sample: true
firstname:
description: The user first name
returned: always
type: string
sample: Nick
groups:
description: AD Groups to which the account belongs
returned: always
type: list
sample: [ "Domain Admins", "Domain Users" ]
msg:
description: Summary message of whether the user is present or absent
returned: always
type: string
sample: User nick is present
name:
description: The username on the account
returned: always
type: string
sample: nick
password_expired:
description: true if the account password has expired
returned: always
type: boolean
sample: false
password_updated:
description: true if the password changed during this execution
returned: always
type: boolean
sample: true
postal_code:
description: The user postal code
returned: always
type: string
sample: 46033
sid:
description: The SID of the account
returned: always
type: string
sample: S-1-5-21-2752426336-228313920-2202711348-1175
state:
description: The state of the user account
returned: always
type: string
sample: present
state_province:
description: The user state or province
returned: always
type: string
sample: IN
street:
description: The user street address
returned: always
type: string
sample: 123 4th St.
surname:
description: The user last name
returned: always
type: string
sample: Doe
upn:
description: The User Principal Name of the account
returned: always
type: string
sample: nick@domain.local
user_cannot_change_password:
description: true if the user is not allowed to change password
returned: always
type: string
sample: false
'''
|
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,
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,
2261,
63,
751,
199,
1023,
63,
3270,
26,
283,
18,
14,
20,
7,
199,
3612,
63,
1802,
26,
21612,
5417,
23241,
15191,
922,
12639,
199,
1802,
26,
1362,
446,
21612,
5417,
23241,
15191,
922,
12639,
14,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
922,
370,
1218,
12,
2813,
503,
2811,
14,
272,
1415,
26,
2549,
523,
1174,
26,
272,
1369,
26,
489,
446,
3979,
445,
8,
1881,
395,
8491,
503,
7029,
314,
922,
2933,
14,
221,
3979,
445,
8,
5575,
395,
267,
14185,
314,
922,
2933,
340,
652,
3495,
14,
221,
3979,
445,
8,
1131,
395,
267,
9619,
2310,
314,
922,
2933,
2436,
1928,
10663,
1263,
4493,
14,
272,
3415,
26,
359,
9552,
12,
3451,
12,
1827,
1622,
272,
849,
26,
3451,
523,
5223,
26,
272,
1369,
26,
489,
446,
445,
8,
5066,
9,
911,
4756,
314,
922,
2933,
14,
489,
446,
445,
8,
889,
9,
911,
3507,
314,
2933,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
5066,
7,
523,
2933,
63,
9325,
26,
272,
1369,
26,
489,
446,
445,
8,
889,
9,
911,
28451,
314,
922,
2933,
340,
14233,
14,
3390,
626,
2337,
365,
440,
282,
267,
4340,
370,
4650,
376,
2933,
465,
376,
31056,
14,
4473,
6851,
787,
14233,
7037,
370,
267,
922,
5445,
27,
465,
376,
4628,
12,
1265,
1443,
1454,
28451,
282,
14233,
2933,
14,
982,
1265,
267,
13809,
370,
4628,
17590,
9462,
3507,
376,
2933,
12,
663,
473,
8,
3827,
9,
370,
445,
8,
889,
680,
272,
3415,
26,
359,
283,
889,
7,
1622,
523,
1369,
26,
272,
1369,
26,
489,
446,
11994,
402,
314,
922,
523,
4652,
26,
272,
1369,
26,
489,
446,
15747,
503,
14185,
314,
922,
687,
642,
769,
402,
4652,
12,
267,
10298,
641,
314,
574,
402,
473,
8,
2634,
63,
1287,
680,
4005,
2813,
1006,
1325,
314,
267,
25716,
11590,
5611,
12,
663,
445,
8,
2634,
18987,
19200,
1572,
536,
18956,
436,
267,
473,
8,
2634,
63,
1287,
29,
1814,
680,
3390,
626,
4390,
3913,
506,
4829,
687,
267,
3932,
21646,
1572,
334,
509,
2893,
12,
298,
7705,
20123,
3471,
523,
4652,
63,
1287,
26,
272,
1369,
26,
489,
446,
982,
445,
8,
525,
395,
314,
922,
365,
3483,
370,
1924,
1572,
315,
473,
8,
2634,
9,
2382,
440,
267,
2575,
282,
3653,
14,
489,
446,
982,
445,
8,
2168,
395,
314,
922,
365,
4829,
687,
1924,
1572,
315,
473,
8,
2634,
680,
489,
446,
982,
445,
8,
1814,
395,
314,
922,
365,
3483,
465,
282,
3653,
402,
1924,
1572,
315,
267,
473,
8,
2634,
9,
436,
4829,
687,
1263,
1163,
4652,
14,
272,
3415,
26,
359,
1050,
12,
2813,
12,
3350,
1622,
272,
849,
26,
3350,
523,
2505,
26,
272,
1369,
26,
489,
446,
22383,
663,
314,
922,
1159,
2505,
370,
642,
334,
6104,
1318,
9,
574,
14,
1010,
1865,
267,
370,
4756,
376,
2933,
446,
473,
8,
3827,
9,
446,
282,
2505,
1471,
2575,
506,
267,
7526,
641,
314,
2933,
12,
503,
1265,
1471,
5647,
282,
2505,
2348,
14,
523,
1678,
63,
2060,
26,
272,
1369,
26,
489,
446,
445,
8,
9223,
9,
911,
1678,
19572,
340,
2985,
14460,
14,
489,
446,
445,
8,
265,
63,
981,
9,
911,
1454,
663,
314,
2505,
367,
13903,
2737,
4390,
14,
489,
446,
3390,
626,
445,
8,
9223,
9,
911,
3544,
3622,
376,
2622,
2004,
402,
283,
2489,
7,
267,
2952,
781,
3913,
6705,
3775,
314,
892,
2505,
22754,
687,
267,
314,
2269,
2505,
14,
272,
3415,
26,
359,
3544,
12,
641,
63,
981,
1622,
272,
849,
26,
3544,
523,
2505,
63,
16340,
26,
272,
1369,
26,
489,
446,
445,
8,
5066,
9,
911,
4409,
314,
922,
370,
1570,
3932,
2505,
737,
2163,
4676,
14,
489,
446,
445,
8,
889,
9,
911,
5436,
314,
14721,
2505,
3305,
14,
489,
446,
961,
365,
16108,
13914,
543,
473,
8,
2060,
63,
18178,
63,
12342,
680,
272,
730,
26,
2155,
523,
2505,
63,
18178,
63,
12342,
26,
272,
1369,
26,
489,
446,
445,
8,
5066,
9,
911,
663,
314,
2505,
370,
7078,
16667,
14,
489,
446,
445,
8,
889,
9,
911,
2040,
314,
2505,
370,
16667,
14,
489,
446,
961,
365,
16108,
13914,
543,
473,
8,
2060,
63,
16340,
680,
272,
730,
26,
2155,
523,
922,
63,
11250,
63,
1461,
63,
2060,
26,
272,
1369,
26,
489,
446,
445,
8,
5066,
9,
911,
7981,
314,
922,
687,
13729,
3932,
2505,
14,
489,
446,
445,
8,
889,
9,
911,
2040,
314,
922,
370,
1570,
3932,
2505,
14,
272,
730,
26,
2155,
523,
1642,
354,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
922,
1159,
1642,
536,
334,
11809,
536,
680,
523,
308,
21121,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
922,
1159,
2061,
536,
334,
30959,
680,
523,
7233,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
922,
1159,
7233,
536,
14,
523,
1536,
78,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
2876,
25716,
11590,
2812,
334,
2160,
46,
9,
367,
314,
2933,
14,
489,
446,
961,
365,
440,
1415,
12,
1325,
365,
5526,
24471,
370,
7908,
367,
818,
11641,
267,
5459,
402,
23241,
15191,
14,
489,
446,
710,
1475,
365,
445,
27530,
2473,
30,
32,
28,
2261,
10121,
523,
3031,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
922,
1159,
3031,
2287,
14,
489,
446,
961,
365,
282,
2777,
315,
16271,
436,
1630,
440,
886,
7003,
370,
7908,
1263,
3031,
267,
8037,
503,
10460,
14,
523,
410,
7936,
26,
272,
1369,
26
] |
[
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,
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,
2261,
63,
751,
199,
1023,
63,
3270,
26,
283,
18,
14,
20,
7,
199,
3612,
63,
1802,
26,
21612,
5417,
23241,
15191,
922,
12639,
199,
1802,
26,
1362,
446,
21612,
5417,
23241,
15191,
922,
12639,
14,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
922,
370,
1218,
12,
2813,
503,
2811,
14,
272,
1415,
26,
2549,
523,
1174,
26,
272,
1369,
26,
489,
446,
3979,
445,
8,
1881,
395,
8491,
503,
7029,
314,
922,
2933,
14,
221,
3979,
445,
8,
5575,
395,
267,
14185,
314,
922,
2933,
340,
652,
3495,
14,
221,
3979,
445,
8,
1131,
395,
267,
9619,
2310,
314,
922,
2933,
2436,
1928,
10663,
1263,
4493,
14,
272,
3415,
26,
359,
9552,
12,
3451,
12,
1827,
1622,
272,
849,
26,
3451,
523,
5223,
26,
272,
1369,
26,
489,
446,
445,
8,
5066,
9,
911,
4756,
314,
922,
2933,
14,
489,
446,
445,
8,
889,
9,
911,
3507,
314,
2933,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
5066,
7,
523,
2933,
63,
9325,
26,
272,
1369,
26,
489,
446,
445,
8,
889,
9,
911,
28451,
314,
922,
2933,
340,
14233,
14,
3390,
626,
2337,
365,
440,
282,
267,
4340,
370,
4650,
376,
2933,
465,
376,
31056,
14,
4473,
6851,
787,
14233,
7037,
370,
267,
922,
5445,
27,
465,
376,
4628,
12,
1265,
1443,
1454,
28451,
282,
14233,
2933,
14,
982,
1265,
267,
13809,
370,
4628,
17590,
9462,
3507,
376,
2933,
12,
663,
473,
8,
3827,
9,
370,
445,
8,
889,
680,
272,
3415,
26,
359,
283,
889,
7,
1622,
523,
1369,
26,
272,
1369,
26,
489,
446,
11994,
402,
314,
922,
523,
4652,
26,
272,
1369,
26,
489,
446,
15747,
503,
14185,
314,
922,
687,
642,
769,
402,
4652,
12,
267,
10298,
641,
314,
574,
402,
473,
8,
2634,
63,
1287,
680,
4005,
2813,
1006,
1325,
314,
267,
25716,
11590,
5611,
12,
663,
445,
8,
2634,
18987,
19200,
1572,
536,
18956,
436,
267,
473,
8,
2634,
63,
1287,
29,
1814,
680,
3390,
626,
4390,
3913,
506,
4829,
687,
267,
3932,
21646,
1572,
334,
509,
2893,
12,
298,
7705,
20123,
3471,
523,
4652,
63,
1287,
26,
272,
1369,
26,
489,
446,
982,
445,
8,
525,
395,
314,
922,
365,
3483,
370,
1924,
1572,
315,
473,
8,
2634,
9,
2382,
440,
267,
2575,
282,
3653,
14,
489,
446,
982,
445,
8,
2168,
395,
314,
922,
365,
4829,
687,
1924,
1572,
315,
473,
8,
2634,
680,
489,
446,
982,
445,
8,
1814,
395,
314,
922,
365,
3483,
465,
282,
3653,
402,
1924,
1572,
315,
267,
473,
8,
2634,
9,
436,
4829,
687,
1263,
1163,
4652,
14,
272,
3415,
26,
359,
1050,
12,
2813,
12,
3350,
1622,
272,
849,
26,
3350,
523,
2505,
26,
272,
1369,
26,
489,
446,
22383,
663,
314,
922,
1159,
2505,
370,
642,
334,
6104,
1318,
9,
574,
14,
1010,
1865,
267,
370,
4756,
376,
2933,
446,
473,
8,
3827,
9,
446,
282,
2505,
1471,
2575,
506,
267,
7526,
641,
314,
2933,
12,
503,
1265,
1471,
5647,
282,
2505,
2348,
14,
523,
1678,
63,
2060,
26,
272,
1369,
26,
489,
446,
445,
8,
9223,
9,
911,
1678,
19572,
340,
2985,
14460,
14,
489,
446,
445,
8,
265,
63,
981,
9,
911,
1454,
663,
314,
2505,
367,
13903,
2737,
4390,
14,
489,
446,
3390,
626,
445,
8,
9223,
9,
911,
3544,
3622,
376,
2622,
2004,
402,
283,
2489,
7,
267,
2952,
781,
3913,
6705,
3775,
314,
892,
2505,
22754,
687,
267,
314,
2269,
2505,
14,
272,
3415,
26,
359,
3544,
12,
641,
63,
981,
1622,
272,
849,
26,
3544,
523,
2505,
63,
16340,
26,
272,
1369,
26,
489,
446,
445,
8,
5066,
9,
911,
4409,
314,
922,
370,
1570,
3932,
2505,
737,
2163,
4676,
14,
489,
446,
445,
8,
889,
9,
911,
5436,
314,
14721,
2505,
3305,
14,
489,
446,
961,
365,
16108,
13914,
543,
473,
8,
2060,
63,
18178,
63,
12342,
680,
272,
730,
26,
2155,
523,
2505,
63,
18178,
63,
12342,
26,
272,
1369,
26,
489,
446,
445,
8,
5066,
9,
911,
663,
314,
2505,
370,
7078,
16667,
14,
489,
446,
445,
8,
889,
9,
911,
2040,
314,
2505,
370,
16667,
14,
489,
446,
961,
365,
16108,
13914,
543,
473,
8,
2060,
63,
16340,
680,
272,
730,
26,
2155,
523,
922,
63,
11250,
63,
1461,
63,
2060,
26,
272,
1369,
26,
489,
446,
445,
8,
5066,
9,
911,
7981,
314,
922,
687,
13729,
3932,
2505,
14,
489,
446,
445,
8,
889,
9,
911,
2040,
314,
922,
370,
1570,
3932,
2505,
14,
272,
730,
26,
2155,
523,
1642,
354,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
922,
1159,
1642,
536,
334,
11809,
536,
680,
523,
308,
21121,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
922,
1159,
2061,
536,
334,
30959,
680,
523,
7233,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
922,
1159,
7233,
536,
14,
523,
1536,
78,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
2876,
25716,
11590,
2812,
334,
2160,
46,
9,
367,
314,
2933,
14,
489,
446,
961,
365,
440,
1415,
12,
1325,
365,
5526,
24471,
370,
7908,
367,
818,
11641,
267,
5459,
402,
23241,
15191,
14,
489,
446,
710,
1475,
365,
445,
27530,
2473,
30,
32,
28,
2261,
10121,
523,
3031,
26,
272,
1369,
26,
489,
446,
4094,
1482,
314,
922,
1159,
3031,
2287,
14,
489,
446,
961,
365,
282,
2777,
315,
16271,
436,
1630,
440,
886,
7003,
370,
7908,
1263,
3031,
267,
8037,
503,
10460,
14,
523,
410,
7936,
26,
272,
1369,
26,
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,
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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
] |
neale/CS-program
|
434-MachineLearning/final_project/linearClassifier/sklearn/datasets/mlcomp.py
|
289
|
3855
|
# Copyright (c) 2010 Olivier Grisel <olivier.grisel@ensta.org>
# License: BSD 3 clause
"""Glue code to load http://mlcomp.org data as a scikit.learn dataset"""
import os
import numbers
from sklearn.datasets.base import load_files
def _load_document_classification(dataset_path, metadata, set_=None, **kwargs):
if set_ is not None:
dataset_path = os.path.join(dataset_path, set_)
return load_files(dataset_path, metadata.get('description'), **kwargs)
LOADERS = {
'DocumentClassification': _load_document_classification,
# TODO: implement the remaining domain formats
}
def load_mlcomp(name_or_id, set_="raw", mlcomp_root=None, **kwargs):
"""Load a datasets as downloaded from http://mlcomp.org
Parameters
----------
name_or_id : the integer id or the string name metadata of the MLComp
dataset to load
set_ : select the portion to load: 'train', 'test' or 'raw'
mlcomp_root : the filesystem path to the root folder where MLComp datasets
are stored, if mlcomp_root is None, the MLCOMP_DATASETS_HOME
environment variable is looked up instead.
**kwargs : domain specific kwargs to be passed to the dataset loader.
Read more in the :ref:`User Guide <datasets>`.
Returns
-------
data : Bunch
Dictionary-like object, the interesting attributes are:
'filenames', the files holding the raw to learn, 'target', the
classification labels (integer index), 'target_names',
the meaning of the labels, and 'DESCR', the full description of the
dataset.
Note on the lookup process: depending on the type of name_or_id,
will choose between integer id lookup or metadata name lookup by
looking at the unzipped archives and metadata file.
TODO: implement zip dataset loading too
"""
if mlcomp_root is None:
try:
mlcomp_root = os.environ['MLCOMP_DATASETS_HOME']
except KeyError:
raise ValueError("MLCOMP_DATASETS_HOME env variable is undefined")
mlcomp_root = os.path.expanduser(mlcomp_root)
mlcomp_root = os.path.abspath(mlcomp_root)
mlcomp_root = os.path.normpath(mlcomp_root)
if not os.path.exists(mlcomp_root):
raise ValueError("Could not find folder: " + mlcomp_root)
# dataset lookup
if isinstance(name_or_id, numbers.Integral):
# id lookup
dataset_path = os.path.join(mlcomp_root, str(name_or_id))
else:
# assume name based lookup
dataset_path = None
expected_name_line = "name: " + name_or_id
for dataset in os.listdir(mlcomp_root):
metadata_file = os.path.join(mlcomp_root, dataset, 'metadata')
if not os.path.exists(metadata_file):
continue
with open(metadata_file) as f:
for line in f:
if line.strip() == expected_name_line:
dataset_path = os.path.join(mlcomp_root, dataset)
break
if dataset_path is None:
raise ValueError("Could not find dataset with metadata line: " +
expected_name_line)
# loading the dataset metadata
metadata = dict()
metadata_file = os.path.join(dataset_path, 'metadata')
if not os.path.exists(metadata_file):
raise ValueError(dataset_path + ' is not a valid MLComp dataset')
with open(metadata_file) as f:
for line in f:
if ":" in line:
key, value = line.split(":", 1)
metadata[key.strip()] = value.strip()
format = metadata.get('format', 'unknow')
loader = LOADERS.get(format)
if loader is None:
raise ValueError("No loader implemented for format: " + format)
return loader(dataset_path, metadata, set_=set_, **kwargs)
|
unlicense
|
[
3,
1898,
334,
67,
9,
7129,
593,
317,
26645,
598,
322,
5891,
665,
23711,
26645,
14,
7928,
5891,
32,
287,
1207,
14,
1308,
30,
199,
3,
844,
26,
6289,
650,
8502,
199,
624,
39,
11322,
1233,
370,
2248,
1455,
921,
757,
863,
14,
1308,
666,
465,
282,
6276,
6065,
14,
4643,
4789,
624,
199,
199,
646,
747,
199,
646,
5579,
199,
504,
6357,
14,
12281,
14,
1095,
492,
2248,
63,
1725,
421,
199,
318,
485,
912,
63,
3554,
63,
14368,
8,
5214,
63,
515,
12,
3341,
12,
663,
10683,
403,
12,
1011,
958,
304,
272,
340,
663,
63,
365,
440,
488,
26,
267,
4789,
63,
515,
275,
747,
14,
515,
14,
904,
8,
5214,
63,
515,
12,
663,
4602,
272,
372,
2248,
63,
1725,
8,
5214,
63,
515,
12,
3341,
14,
362,
360,
1802,
659,
1011,
958,
9,
421,
199,
7405,
3960,
275,
469,
272,
283,
5564,
28362,
356,
485,
912,
63,
3554,
63,
14368,
12,
272,
327,
3254,
26,
5669,
314,
7971,
2881,
6752,
199,
93,
421,
199,
318,
2248,
63,
757,
863,
8,
354,
63,
269,
63,
344,
12,
663,
63,
628,
1773,
401,
19184,
863,
63,
1231,
29,
403,
12,
1011,
958,
304,
272,
408,
6200,
282,
13148,
465,
13557,
687,
1455,
921,
757,
863,
14,
1308,
339,
3897,
272,
4143,
339,
536,
63,
269,
63,
344,
520,
314,
3000,
1305,
503,
314,
1059,
536,
3341,
402,
314,
28007,
2404,
326,
4789,
370,
2248,
339,
663,
63,
520,
3504,
314,
18046,
370,
2248,
26,
283,
2834,
297,
283,
396,
7,
503,
283,
1773,
7,
339,
19184,
863,
63,
1231,
520,
314,
10036,
931,
370,
314,
1738,
4922,
2382,
28007,
2404,
13148,
2116,
787,
5489,
12,
340,
19184,
863,
63,
1231,
365,
488,
12,
314,
28007,
6790,
63,
28231,
30416,
63,
9524,
2116,
3734,
1750,
365,
21182,
1536,
3140,
14,
339,
1011,
958,
520,
2881,
2488,
2074,
370,
506,
3032,
370,
314,
4789,
5077,
14,
339,
5574,
1655,
315,
314,
520,
1121,
1705,
1899,
15423,
665,
12281,
14943,
339,
1803,
272,
5514,
339,
666,
520,
699,
4689,
267,
11932,
13,
2930,
909,
12,
314,
19604,
3004,
787,
26,
267,
283,
10309,
297,
314,
1584,
17573,
314,
3066,
370,
12537,
12,
283,
1375,
297,
314,
267,
12505,
3628,
334,
4115,
1478,
395,
283,
1375,
63,
1247,
297,
267,
314,
11150,
402,
314,
3628,
12,
436,
283,
4448,
2944,
297,
314,
2615,
1369,
402,
314,
267,
4789,
14,
339,
3390,
641,
314,
4237,
2112,
26,
10298,
641,
314,
730,
402,
536,
63,
269,
63,
344,
12,
272,
911,
11496,
3382,
3000,
1305,
4237,
503,
3341,
536,
4237,
701,
272,
10023,
737,
314,
29379,
1915,
25993,
436,
3341,
570,
14,
339,
3254,
26,
5669,
3482,
4789,
8697,
4634,
272,
408,
339,
340,
19184,
863,
63,
1231,
365,
488,
26,
267,
862,
26,
288,
19184,
863,
63,
1231,
275,
747,
14,
2314,
459,
1698,
6790,
63,
28231,
30416,
63,
9524,
418,
267,
871,
4067,
26,
288,
746,
1722,
480,
1698,
6790,
63,
28231,
30416,
63,
9524,
2589,
1750,
365,
10942,
531,
339,
19184,
863,
63,
1231,
275,
747,
14,
515,
14,
12131,
8,
757,
863,
63,
1231,
9,
272,
19184,
863,
63,
1231,
275,
747,
14,
515,
14,
4832,
8,
757,
863,
63,
1231,
9,
272,
19184,
863,
63,
1231,
275,
747,
14,
515,
14,
9267,
8,
757,
863,
63,
1231,
9,
339,
340,
440,
747,
14,
515,
14,
2444,
8,
757,
863,
63,
1231,
304,
267,
746,
1722,
480,
6531,
440,
2342,
4922,
26,
298,
435,
19184,
863,
63,
1231,
9,
339,
327,
4789,
4237,
272,
340,
1228,
8,
354,
63,
269,
63,
344,
12,
5579,
14,
18949,
304,
267,
327,
1305,
4237,
267,
4789,
63,
515,
275,
747,
14,
515,
14,
904,
8,
757,
863,
63,
1231,
12,
620,
8,
354,
63,
269,
63,
344,
430,
272,
587,
26,
267,
327,
5534,
536,
4079,
4237,
267,
4789,
63,
515,
275,
488,
267,
1420,
63,
354,
63,
604,
275,
298,
354,
26,
298,
435,
536,
63,
269,
63,
344,
267,
367,
4789,
315,
747,
14,
7374,
8,
757,
863,
63,
1231,
304,
288,
3341,
63,
493,
275,
747,
14,
515,
14,
904,
8,
757,
863,
63,
1231,
12,
4789,
12,
283,
2343,
358,
288,
340,
440,
747,
14,
515,
14,
2444,
8,
2343,
63,
493,
304,
355,
1980,
288,
543,
1551,
8,
2343,
63,
493,
9,
465,
289,
26,
355,
367,
1004,
315,
289,
26,
490,
340,
1004,
14,
1913,
342,
508,
1420,
63,
354,
63,
604,
26,
717,
4789,
63,
515,
275,
747,
14,
515,
14,
904,
8,
757,
863,
63,
1231,
12,
4789,
9,
717,
2059,
267,
340,
4789,
63,
515,
365,
488,
26,
288,
746,
1722,
480,
6531,
440,
2342,
4789,
543,
3341,
1004,
26,
298,
435,
2490,
1420,
63,
354,
63,
604,
9,
339,
327,
8697,
314,
4789,
3341,
272,
3341,
275,
1211,
342,
272,
3341,
63,
493,
275,
747,
14,
515,
14,
904,
8,
5214,
63,
515,
12,
283,
2343,
358,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
2343,
63,
493,
304,
267,
746,
1722,
8,
5214,
63,
515,
435,
283,
365,
440,
282,
1686,
28007,
2404,
4789,
358,
272,
543,
1551,
8,
2343,
63,
493,
9,
465,
289,
26,
267,
367,
1004,
315,
289,
26,
288,
340,
14725,
315,
1004,
26,
355,
790,
12,
574,
275,
1004,
14,
1294,
480,
6783,
413,
9,
355,
3341,
59,
498,
14,
1913,
5106,
275,
574,
14,
1913,
342,
339,
1475,
275,
3341,
14,
362,
360,
908,
297,
283,
1778,
2131,
358,
272,
5077,
275,
3412,
1554,
3960,
14,
362,
8,
908,
9,
272,
340,
5077,
365,
488,
26,
267,
746,
1722,
480,
1944,
5077,
6366,
367,
1475,
26,
298,
435,
1475,
9,
272,
372,
5077,
8,
5214,
63,
515,
12,
3341,
12,
663,
10683,
409,
3131,
1011,
958,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
7129,
593,
317,
26645,
598,
322,
5891,
665,
23711,
26645,
14,
7928,
5891,
32,
287,
1207,
14,
1308,
30,
199,
3,
844,
26,
6289,
650,
8502,
199,
624,
39,
11322,
1233,
370,
2248,
1455,
921,
757,
863,
14,
1308,
666,
465,
282,
6276,
6065,
14,
4643,
4789,
624,
199,
199,
646,
747,
199,
646,
5579,
199,
504,
6357,
14,
12281,
14,
1095,
492,
2248,
63,
1725,
421,
199,
318,
485,
912,
63,
3554,
63,
14368,
8,
5214,
63,
515,
12,
3341,
12,
663,
10683,
403,
12,
1011,
958,
304,
272,
340,
663,
63,
365,
440,
488,
26,
267,
4789,
63,
515,
275,
747,
14,
515,
14,
904,
8,
5214,
63,
515,
12,
663,
4602,
272,
372,
2248,
63,
1725,
8,
5214,
63,
515,
12,
3341,
14,
362,
360,
1802,
659,
1011,
958,
9,
421,
199,
7405,
3960,
275,
469,
272,
283,
5564,
28362,
356,
485,
912,
63,
3554,
63,
14368,
12,
272,
327,
3254,
26,
5669,
314,
7971,
2881,
6752,
199,
93,
421,
199,
318,
2248,
63,
757,
863,
8,
354,
63,
269,
63,
344,
12,
663,
63,
628,
1773,
401,
19184,
863,
63,
1231,
29,
403,
12,
1011,
958,
304,
272,
408,
6200,
282,
13148,
465,
13557,
687,
1455,
921,
757,
863,
14,
1308,
339,
3897,
272,
4143,
339,
536,
63,
269,
63,
344,
520,
314,
3000,
1305,
503,
314,
1059,
536,
3341,
402,
314,
28007,
2404,
326,
4789,
370,
2248,
339,
663,
63,
520,
3504,
314,
18046,
370,
2248,
26,
283,
2834,
297,
283,
396,
7,
503,
283,
1773,
7,
339,
19184,
863,
63,
1231,
520,
314,
10036,
931,
370,
314,
1738,
4922,
2382,
28007,
2404,
13148,
2116,
787,
5489,
12,
340,
19184,
863,
63,
1231,
365,
488,
12,
314,
28007,
6790,
63,
28231,
30416,
63,
9524,
2116,
3734,
1750,
365,
21182,
1536,
3140,
14,
339,
1011,
958,
520,
2881,
2488,
2074,
370,
506,
3032,
370,
314,
4789,
5077,
14,
339,
5574,
1655,
315,
314,
520,
1121,
1705,
1899,
15423,
665,
12281,
14943,
339,
1803,
272,
5514,
339,
666,
520,
699,
4689,
267,
11932,
13,
2930,
909,
12,
314,
19604,
3004,
787,
26,
267,
283,
10309,
297,
314,
1584,
17573,
314,
3066,
370,
12537,
12,
283,
1375,
297,
314,
267,
12505,
3628,
334,
4115,
1478,
395,
283,
1375,
63,
1247,
297,
267,
314,
11150,
402,
314,
3628,
12,
436,
283,
4448,
2944,
297,
314,
2615,
1369,
402,
314,
267,
4789,
14,
339,
3390,
641,
314,
4237,
2112,
26,
10298,
641,
314,
730,
402,
536,
63,
269,
63,
344,
12,
272,
911,
11496,
3382,
3000,
1305,
4237,
503,
3341,
536,
4237,
701,
272,
10023,
737,
314,
29379,
1915,
25993,
436,
3341,
570,
14,
339,
3254,
26,
5669,
3482,
4789,
8697,
4634,
272,
408,
339,
340,
19184,
863,
63,
1231,
365,
488,
26,
267,
862,
26,
288,
19184,
863,
63,
1231,
275,
747,
14,
2314,
459,
1698,
6790,
63,
28231,
30416,
63,
9524,
418,
267,
871,
4067,
26,
288,
746,
1722,
480,
1698,
6790,
63,
28231,
30416,
63,
9524,
2589,
1750,
365,
10942,
531,
339,
19184,
863,
63,
1231,
275,
747,
14,
515,
14,
12131,
8,
757,
863,
63,
1231,
9,
272,
19184,
863,
63,
1231,
275,
747,
14,
515,
14,
4832,
8,
757,
863,
63,
1231,
9,
272,
19184,
863,
63,
1231,
275,
747,
14,
515,
14,
9267,
8,
757,
863,
63,
1231,
9,
339,
340,
440,
747,
14,
515,
14,
2444,
8,
757,
863,
63,
1231,
304,
267,
746,
1722,
480,
6531,
440,
2342,
4922,
26,
298,
435,
19184,
863,
63,
1231,
9,
339,
327,
4789,
4237,
272,
340,
1228,
8,
354,
63,
269,
63,
344,
12,
5579,
14,
18949,
304,
267,
327,
1305,
4237,
267,
4789,
63,
515,
275,
747,
14,
515,
14,
904,
8,
757,
863,
63,
1231,
12,
620,
8,
354,
63,
269,
63,
344,
430,
272,
587,
26,
267,
327,
5534,
536,
4079,
4237,
267,
4789,
63,
515,
275,
488,
267,
1420,
63,
354,
63,
604,
275,
298,
354,
26,
298,
435,
536,
63,
269,
63,
344,
267,
367,
4789,
315,
747,
14,
7374,
8,
757,
863,
63,
1231,
304,
288,
3341,
63,
493,
275,
747,
14,
515,
14,
904,
8,
757,
863,
63,
1231,
12,
4789,
12,
283,
2343,
358,
288,
340,
440,
747,
14,
515,
14,
2444,
8,
2343,
63,
493,
304,
355,
1980,
288,
543,
1551,
8,
2343,
63,
493,
9,
465,
289,
26,
355,
367,
1004,
315,
289,
26,
490,
340,
1004,
14,
1913,
342,
508,
1420,
63,
354,
63,
604,
26,
717,
4789,
63,
515,
275,
747,
14,
515,
14,
904,
8,
757,
863,
63,
1231,
12,
4789,
9,
717,
2059,
267,
340,
4789,
63,
515,
365,
488,
26,
288,
746,
1722,
480,
6531,
440,
2342,
4789,
543,
3341,
1004,
26,
298,
435,
2490,
1420,
63,
354,
63,
604,
9,
339,
327,
8697,
314,
4789,
3341,
272,
3341,
275,
1211,
342,
272,
3341,
63,
493,
275,
747,
14,
515,
14,
904,
8,
5214,
63,
515,
12,
283,
2343,
358,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
2343,
63,
493,
304,
267,
746,
1722,
8,
5214,
63,
515,
435,
283,
365,
440,
282,
1686,
28007,
2404,
4789,
358,
272,
543,
1551,
8,
2343,
63,
493,
9,
465,
289,
26,
267,
367,
1004,
315,
289,
26,
288,
340,
14725,
315,
1004,
26,
355,
790,
12,
574,
275,
1004,
14,
1294,
480,
6783,
413,
9,
355,
3341,
59,
498,
14,
1913,
5106,
275,
574,
14,
1913,
342,
339,
1475,
275,
3341,
14,
362,
360,
908,
297,
283,
1778,
2131,
358,
272,
5077,
275,
3412,
1554,
3960,
14,
362,
8,
908,
9,
272,
340,
5077,
365,
488,
26,
267,
746,
1722,
480,
1944,
5077,
6366,
367,
1475,
26,
298,
435,
1475,
9,
272,
372,
5077,
8,
5214,
63,
515,
12,
3341,
12,
663,
10683,
409,
3131,
1011,
958,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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UDP",
18:"MUX",
19:"DCN-MEAS",
20:"HMP",
21:"PRM",
22:"XNS-IDP",
23:"TRUNK-1",
24:"TRUNK-2",
25:"LEAF-1",
26:"LEAF-2",
27:"RDP",
28:"IRTP",
29:"ISO-TP4",
30:"NETBLT",
31:"MFE-NSP",
32:"MERIT-INP",
33:"DCCP",
34:"3PC",
35:"IDPR",
36:"XTP",
37:"DDP",
38:"IDPR-CMTP",
39:"TP++",
40:"IL",
41:"IPv6",
42:"SDRP",
43:"IPv6-Route",
44:"IPv6-Frag",
45:"IDRP",
46:"RSVP",
47:"GRE",
48:"DSR",
49:"BNA",
50:"ESP",
51:"AH",
52:"I-NLSP",
53:"SWIPE",
54:"NARP",
55:"MOBILE",
56:"TLSP",
57:"SKIP",
58:"IPv6-ICMP",
59:"IPv6-NoNxt",
60:"IPv6-Opts",
61:"Host-interal",
62:"CFTP",
63:"Local Network",
64:"SAT-EXPAK",
65:"KRYPTOLAN",
66:"RVD",
67:"IPPC",
68:"Dist-FS",
69:"SAT-MON",
70:"VISA",
71:"IPCV",
72:"CPNX",
73:"CPHB",
74:"WSN",
75:"PVP",
76:"BR-SAT-MON",
77:"SUN-ND",
78:"WB-MON",
79:"WB-EXPAK",
80:"ISO-IP",
81:"VMTP",
82:"SECURE-VMTP",
83:"VINES",
84:"TTP",
84:"IPTM",
85:"NSFNET-IGP",
86:"DGP",
87:"TCF",
88:"EIGRP",
89:"OSPFIGP",
90:"Sprite-RPC",
91:"LARP",
92:"MTP",
93:"AX.25",
94:"IPIP",
95:"MICP",
96:"SCC-SP",
97:"ETHERIP",
98:"ENCAP",
99:"Encryption",
100:"GMTP",
101:"IFMP",
102:"PNNI",
103:"PIM",
104:"ARIS",
105:"SCPS",
106:"QNX",
107:"A/N",
108:"IPComp",
109:"SNP",
110:"Compaq-Peer",
111:"IPX-in-IP",
112:"VRRP",
113:"PGM",
114:"0-hop",
115:"L2TP",
116:"DDX",
117:"IATP",
118:"STP",
119:"SRP",
120:"UTI",
121:"SMP",
122:"SM",
123:"PTP",
124:"ISIS over IPv4",
125:"FIRE",
126:"CRTP",
127:"CRUDP",
128:"SSCOPMCE",
129:"IPLT",
130:"SPS",
131:"PIPE",
132:"SCTP",
133:"FC",
134:"RSVP-E2E-IGNORE",
135:"Mobility Header",
136:"UDPLite",
137:"MPLS-in-IP",
138:"manet",
139:"HIP",
140:"Shim6",
141:"WESP",
142:"ROHC",
143:"Unassigned",
144:"Unassigned",
145:"Unassigned",
146:"Unassigned",
147:"Unassigned",
148:"Unassigned",
149:"Unassigned",
150:"Unassigned",
151:"Unassigned",
152:"Unassigned",
153:"Unassigned",
154:"Unassigned",
155:"Unassigned",
156:"Unassigned",
157:"Unassigned",
158:"Unassigned",
159:"Unassigned",
160:"Unassigned",
161:"Unassigned",
162:"Unassigned",
163:"Unassigned",
164:"Unassigned",
165:"Unassigned",
166:"Unassigned",
167:"Unassigned",
168:"Unassigned",
169:"Unassigned",
170:"Unassigned",
171:"Unassigned",
172:"Unassigned",
173:"Unassigned",
174:"Unassigned",
175:"Unassigned",
176:"Unassigned",
177:"Unassigned",
178:"Unassigned",
179:"Unassigned",
180:"Unassigned",
181:"Unassigned",
182:"Unassigned",
183:"Unassigned",
184:"Unassigned",
185:"Unassigned",
186:"Unassigned",
187:"Unassigned",
188:"Unassigned",
189:"Unassigned",
190:"Unassigned",
191:"Unassigned",
192:"Unassigned",
193:"Unassigned",
194:"Unassigned",
195:"Unassigned",
196:"Unassigned",
197:"Unassigned",
198:"Unassigned",
199:"Unassigned",
200:"Unassigned",
201:"Unassigned",
202:"Unassigned",
203:"Unassigned",
204:"Unassigned",
205:"Unassigned",
206:"Unassigned",
207:"Unassigned",
208:"Unassigned",
209:"Unassigned",
210:"Unassigned",
211:"Unassigned",
212:"Unassigned",
213:"Unassigned",
214:"Unassigned",
215:"Unassigned",
216:"Unassigned",
217:"Unassigned",
218:"Unassigned",
219:"Unassigned",
220:"Unassigned",
221:"Unassigned",
222:"Unassigned",
223:"Unassigned",
224:"Unassigned",
225:"Unassigned",
226:"Unassigned",
227:"Unassigned",
228:"Unassigned",
229:"Unassigned",
230:"Unassigned",
231:"Unassigned",
232:"Unassigned",
233:"Unassigned",
234:"Unassigned",
235:"Unassigned",
236:"Unassigned",
237:"Unassigned",
238:"Unassigned",
239:"Unassigned",
240:"Unassigned",
241:"Unassigned",
242:"Unassigned",
243:"Unassigned",
244:"Unassigned",
245:"Unassigned",
246:"Unassigned",
247:"Unassigned",
248:"Unassigned",
249:"Unassigned",
250:"Unassigned",
251:"Unassigned",
252:"Unassigned",
253:"Experimental",
254:"Experimental",
255:"Reserved",
}
|
gpl-2.0
|
[
27478,
275,
469,
881,
378,
5424,
2979,
1512,
4189,
401,
881,
413,
5424,
26616,
401,
881,
499,
5424,
1277,
1658,
401,
881,
650,
5424,
2916,
48,
401,
881,
841,
5424,
12179,
20,
401,
881,
959,
5424,
840,
401,
881,
1227,
5424,
9735,
401,
881,
1520,
5424,
9956,
52,
401,
881,
1695,
5424,
4680,
48,
401,
881,
1749,
5424,
1277,
48,
401,
881,
1616,
5424,
5342,
46,
13,
50,
2571,
13,
11710,
401,
881,
4119,
5424,
7312,
48,
13,
8921,
401,
881,
3144,
5424,
48,
2160,
401,
881,
4944,
5424,
11611,
1668,
401,
881,
4329,
5424,
2769,
1864,
401,
881,
4114,
5424,
56,
7278,
401,
881,
3193,
5424,
26363,
3100,
401,
881,
5557,
5424,
17457,
401,
881,
6155,
5424,
45,
14272,
401,
881,
5851,
5424,
5196,
46,
13,
31097,
401,
881,
3388,
5424,
40,
1658,
401,
881,
7829,
5424,
3311,
45,
401,
881,
6928,
5424,
56,
2709,
13,
998,
48,
401,
881,
6546,
5424,
1766,
8019,
13,
17,
401,
881,
5504,
5424,
1766,
8019,
13,
18,
401,
881,
5661,
5424,
906,
5699,
13,
17,
401,
881,
7875,
5424,
906,
5699,
13,
18,
401,
881,
8087,
5424,
50,
11741,
401,
881,
7294,
5424,
3927,
6495,
401,
881,
7349,
5424,
7336,
13,
6495,
20,
401,
881,
4233,
5424,
7278,
7847,
52,
401,
881,
7105,
5424,
45,
5100,
13,
2709,
48,
401,
881,
4337,
5424,
20263,
649,
13,
568,
48,
401,
881,
9404,
5424,
36,
2571,
48,
401,
881,
8177,
5424,
19,
4222,
401,
881,
8685,
5424,
998,
3311,
401,
881,
8780,
5424,
56,
6495,
401,
881,
6877,
5424,
5745,
48,
401,
881,
10448,
5424,
998,
3311,
13,
35,
5747,
48,
401,
881,
10551,
5424,
6495,
4176,
401,
881,
6335,
5424,
1193,
401,
881,
13385,
5424,
12179,
22,
401,
881,
5685,
5424,
3693,
18612,
401,
881,
11851,
5424,
12179,
22,
13,
7161,
401,
881,
10868,
5424,
12179,
22,
13,
24552,
401,
881,
10416,
5424,
998,
18612,
401,
881,
12426,
5424,
50,
4985,
48,
401,
881,
10954,
5424,
39,
907,
401,
881,
9615,
5424,
3177,
50,
401,
881,
12260,
5424,
34,
7170,
401,
881,
5238,
5424,
7613,
401,
881,
8026,
5424,
20755,
401,
881,
14589,
5424,
41,
13,
46,
5296,
48,
401,
881,
13564,
5424,
8745,
41,
1510,
401,
881,
13470,
5424,
46,
23610,
401,
881,
12766,
5424,
2679,
34,
8453,
401,
881,
12001,
5424,
10224,
48,
401,
881,
12699,
5424,
13525,
401,
881,
13713,
5424,
12179,
22,
13,
26616,
401,
881,
8155,
5424,
12179,
22,
13,
1944,
46,
400,
401,
881,
5212,
5424,
12179,
22,
13,
24429,
401,
881,
17017,
5424,
4965,
13,
1058,
279,
401,
881,
16202,
5424,
35,
15123,
401,
881,
13668,
5424,
5339,
7220,
401,
881,
5049,
5424,
51,
619,
13,
11992,
7872,
401,
881,
11738,
5424,
43,
5782,
4189,
2228,
879,
401,
881,
14157,
5424,
50,
26197,
401,
881,
13296,
5424,
1772,
4222,
401,
881,
10851,
5424,
12012,
13,
7079,
401,
881,
14610,
5424,
51,
619,
13,
11710,
401,
881,
10045,
5424,
11793,
33,
401,
881,
17245,
5424,
1772,
12847,
401,
881,
15323,
5424,
2890,
16764,
401,
881,
18525,
5424,
2890,
25262,
401,
881,
9720,
5424,
5035,
46,
401,
881,
13098,
5424,
48,
14159,
401,
881,
14646,
5424,
7184,
13,
51,
619,
13,
11710,
401,
881,
8375,
5424,
23627,
13,
8711,
401,
881,
14679,
5424,
24819,
13,
11710,
401,
881,
13734,
5424,
24819,
13,
11992,
7872,
401,
881,
5939,
5424,
7336,
13,
1772,
401,
881,
19071,
5424,
54,
5747,
48,
401,
881,
18051,
5424,
20696,
13,
54,
5747,
48,
401,
881,
20582,
5424,
54,
568,
654,
401,
881,
8264,
5424,
1878,
401,
881,
8264,
5424,
4385,
45,
401,
881,
16412,
5424,
2709,
4963,
775,
13,
1277,
48,
401,
881,
10300,
5424,
36,
8225,
401,
881,
10513,
5424,
52,
5487,
401,
881,
10523,
5424,
37,
1277,
18612,
401,
881,
17838,
5424,
3100,
10966,
1277,
48,
401,
881,
9137,
5424,
30185,
13,
8171,
401,
881,
21358,
5424,
13174,
48,
401,
881,
20140,
5424,
5747,
48,
401,
881,
18969,
5424,
9839,
14,
821,
401,
881,
18729,
5424,
1772,
1772,
401,
881,
16102,
5424,
17233,
48,
401,
881,
15580,
5424,
51,
2571,
13,
5763,
401,
881,
15997,
5424,
6919,
1772,
401,
881,
16096,
5424,
742,
8549,
401,
881,
8806,
5424,
25687,
401,
881,
2948,
5424,
17274,
48,
401,
881,
14313,
5424,
4656,
1658,
401,
881,
12996,
5424,
48,
7178,
41,
401,
881,
22363,
5424,
48,
1469,
401,
881,
21083,
5424,
689,
1311,
401,
881,
20462,
5424,
51,
2890,
51,
401,
881,
23746,
5424,
49,
16764,
401,
881,
23543,
5424,
33,
15,
46,
401,
881,
24579,
5424,
1772,
2404,
401,
881,
24058,
5424,
8199,
48,
401,
881,
16814,
5424,
2404,
30030,
13,
12566,
401,
881,
20128,
5424,
1772,
56,
13,
262,
13,
1772,
401,
881,
20240,
5424,
54,
13381,
48,
401,
881,
24073,
5424,
11115,
45,
401,
881,
23510,
5424,
16,
13,
13376,
401,
881,
22560,
5424,
44,
18,
6495,
401,
881,
25186,
5424,
5745,
56,
401,
881,
26189,
5424,
41,
619,
48,
401,
881,
25760,
5424,
840,
48,
401,
881,
26497,
5424,
32527,
401,
881,
13960,
5424,
934,
41,
401,
881,
26228,
5424,
51,
1658,
401,
881,
24557,
5424,
4029,
401,
881,
11869,
5424,
4189,
48,
401,
881,
25442,
5424,
1311,
1311,
1806,
6509,
20,
401,
881,
19163,
5424,
1976,
907,
401,
881,
21572,
5424,
2944,
6495,
401,
881,
12792,
5424,
2944,
17457,
401,
881,
7960,
5424,
2300,
1439,
10793,
2089,
401,
881,
25454,
5424,
1772,
17090,
401,
881,
21334,
5424,
51,
5067,
401,
881,
30542,
5424,
6089,
401,
881,
27207,
5424,
51,
1028,
48,
401,
881,
28416,
5424,
4161,
401,
881,
25956,
5424,
50,
4985,
48,
13,
37,
18,
37,
13,
11209,
401,
881,
23051,
5424,
12947,
10240,
401,
881,
27208,
5424,
3383,
2749,
1175,
401,
881,
27750,
5424,
3950,
51,
13,
262,
13,
1772,
401,
881,
26309,
5424,
1237,
386,
401,
881,
22317,
5424,
40,
1772,
401,
881,
22796,
5424,
2662,
1017,
22,
401,
881,
413,
2953,
5424,
55,
7613,
401,
881,
31308,
5424,
1092,
28460,
401,
881,
29235,
5424,
1358,
12941,
401,
881,
21771,
5424,
1358,
12941,
401,
881,
28818,
5424,
1358,
12941,
401,
881,
31263,
5424,
1358,
12941,
401,
881,
28513,
5424,
1358,
12941,
401,
881,
30300,
5424,
1358,
12941,
401,
881,
28528,
5424,
1358,
12941,
401,
881,
14711,
5424,
1358,
12941,
401,
881
] |
[
275,
469,
881,
378,
5424,
2979,
1512,
4189,
401,
881,
413,
5424,
26616,
401,
881,
499,
5424,
1277,
1658,
401,
881,
650,
5424,
2916,
48,
401,
881,
841,
5424,
12179,
20,
401,
881,
959,
5424,
840,
401,
881,
1227,
5424,
9735,
401,
881,
1520,
5424,
9956,
52,
401,
881,
1695,
5424,
4680,
48,
401,
881,
1749,
5424,
1277,
48,
401,
881,
1616,
5424,
5342,
46,
13,
50,
2571,
13,
11710,
401,
881,
4119,
5424,
7312,
48,
13,
8921,
401,
881,
3144,
5424,
48,
2160,
401,
881,
4944,
5424,
11611,
1668,
401,
881,
4329,
5424,
2769,
1864,
401,
881,
4114,
5424,
56,
7278,
401,
881,
3193,
5424,
26363,
3100,
401,
881,
5557,
5424,
17457,
401,
881,
6155,
5424,
45,
14272,
401,
881,
5851,
5424,
5196,
46,
13,
31097,
401,
881,
3388,
5424,
40,
1658,
401,
881,
7829,
5424,
3311,
45,
401,
881,
6928,
5424,
56,
2709,
13,
998,
48,
401,
881,
6546,
5424,
1766,
8019,
13,
17,
401,
881,
5504,
5424,
1766,
8019,
13,
18,
401,
881,
5661,
5424,
906,
5699,
13,
17,
401,
881,
7875,
5424,
906,
5699,
13,
18,
401,
881,
8087,
5424,
50,
11741,
401,
881,
7294,
5424,
3927,
6495,
401,
881,
7349,
5424,
7336,
13,
6495,
20,
401,
881,
4233,
5424,
7278,
7847,
52,
401,
881,
7105,
5424,
45,
5100,
13,
2709,
48,
401,
881,
4337,
5424,
20263,
649,
13,
568,
48,
401,
881,
9404,
5424,
36,
2571,
48,
401,
881,
8177,
5424,
19,
4222,
401,
881,
8685,
5424,
998,
3311,
401,
881,
8780,
5424,
56,
6495,
401,
881,
6877,
5424,
5745,
48,
401,
881,
10448,
5424,
998,
3311,
13,
35,
5747,
48,
401,
881,
10551,
5424,
6495,
4176,
401,
881,
6335,
5424,
1193,
401,
881,
13385,
5424,
12179,
22,
401,
881,
5685,
5424,
3693,
18612,
401,
881,
11851,
5424,
12179,
22,
13,
7161,
401,
881,
10868,
5424,
12179,
22,
13,
24552,
401,
881,
10416,
5424,
998,
18612,
401,
881,
12426,
5424,
50,
4985,
48,
401,
881,
10954,
5424,
39,
907,
401,
881,
9615,
5424,
3177,
50,
401,
881,
12260,
5424,
34,
7170,
401,
881,
5238,
5424,
7613,
401,
881,
8026,
5424,
20755,
401,
881,
14589,
5424,
41,
13,
46,
5296,
48,
401,
881,
13564,
5424,
8745,
41,
1510,
401,
881,
13470,
5424,
46,
23610,
401,
881,
12766,
5424,
2679,
34,
8453,
401,
881,
12001,
5424,
10224,
48,
401,
881,
12699,
5424,
13525,
401,
881,
13713,
5424,
12179,
22,
13,
26616,
401,
881,
8155,
5424,
12179,
22,
13,
1944,
46,
400,
401,
881,
5212,
5424,
12179,
22,
13,
24429,
401,
881,
17017,
5424,
4965,
13,
1058,
279,
401,
881,
16202,
5424,
35,
15123,
401,
881,
13668,
5424,
5339,
7220,
401,
881,
5049,
5424,
51,
619,
13,
11992,
7872,
401,
881,
11738,
5424,
43,
5782,
4189,
2228,
879,
401,
881,
14157,
5424,
50,
26197,
401,
881,
13296,
5424,
1772,
4222,
401,
881,
10851,
5424,
12012,
13,
7079,
401,
881,
14610,
5424,
51,
619,
13,
11710,
401,
881,
10045,
5424,
11793,
33,
401,
881,
17245,
5424,
1772,
12847,
401,
881,
15323,
5424,
2890,
16764,
401,
881,
18525,
5424,
2890,
25262,
401,
881,
9720,
5424,
5035,
46,
401,
881,
13098,
5424,
48,
14159,
401,
881,
14646,
5424,
7184,
13,
51,
619,
13,
11710,
401,
881,
8375,
5424,
23627,
13,
8711,
401,
881,
14679,
5424,
24819,
13,
11710,
401,
881,
13734,
5424,
24819,
13,
11992,
7872,
401,
881,
5939,
5424,
7336,
13,
1772,
401,
881,
19071,
5424,
54,
5747,
48,
401,
881,
18051,
5424,
20696,
13,
54,
5747,
48,
401,
881,
20582,
5424,
54,
568,
654,
401,
881,
8264,
5424,
1878,
401,
881,
8264,
5424,
4385,
45,
401,
881,
16412,
5424,
2709,
4963,
775,
13,
1277,
48,
401,
881,
10300,
5424,
36,
8225,
401,
881,
10513,
5424,
52,
5487,
401,
881,
10523,
5424,
37,
1277,
18612,
401,
881,
17838,
5424,
3100,
10966,
1277,
48,
401,
881,
9137,
5424,
30185,
13,
8171,
401,
881,
21358,
5424,
13174,
48,
401,
881,
20140,
5424,
5747,
48,
401,
881,
18969,
5424,
9839,
14,
821,
401,
881,
18729,
5424,
1772,
1772,
401,
881,
16102,
5424,
17233,
48,
401,
881,
15580,
5424,
51,
2571,
13,
5763,
401,
881,
15997,
5424,
6919,
1772,
401,
881,
16096,
5424,
742,
8549,
401,
881,
8806,
5424,
25687,
401,
881,
2948,
5424,
17274,
48,
401,
881,
14313,
5424,
4656,
1658,
401,
881,
12996,
5424,
48,
7178,
41,
401,
881,
22363,
5424,
48,
1469,
401,
881,
21083,
5424,
689,
1311,
401,
881,
20462,
5424,
51,
2890,
51,
401,
881,
23746,
5424,
49,
16764,
401,
881,
23543,
5424,
33,
15,
46,
401,
881,
24579,
5424,
1772,
2404,
401,
881,
24058,
5424,
8199,
48,
401,
881,
16814,
5424,
2404,
30030,
13,
12566,
401,
881,
20128,
5424,
1772,
56,
13,
262,
13,
1772,
401,
881,
20240,
5424,
54,
13381,
48,
401,
881,
24073,
5424,
11115,
45,
401,
881,
23510,
5424,
16,
13,
13376,
401,
881,
22560,
5424,
44,
18,
6495,
401,
881,
25186,
5424,
5745,
56,
401,
881,
26189,
5424,
41,
619,
48,
401,
881,
25760,
5424,
840,
48,
401,
881,
26497,
5424,
32527,
401,
881,
13960,
5424,
934,
41,
401,
881,
26228,
5424,
51,
1658,
401,
881,
24557,
5424,
4029,
401,
881,
11869,
5424,
4189,
48,
401,
881,
25442,
5424,
1311,
1311,
1806,
6509,
20,
401,
881,
19163,
5424,
1976,
907,
401,
881,
21572,
5424,
2944,
6495,
401,
881,
12792,
5424,
2944,
17457,
401,
881,
7960,
5424,
2300,
1439,
10793,
2089,
401,
881,
25454,
5424,
1772,
17090,
401,
881,
21334,
5424,
51,
5067,
401,
881,
30542,
5424,
6089,
401,
881,
27207,
5424,
51,
1028,
48,
401,
881,
28416,
5424,
4161,
401,
881,
25956,
5424,
50,
4985,
48,
13,
37,
18,
37,
13,
11209,
401,
881,
23051,
5424,
12947,
10240,
401,
881,
27208,
5424,
3383,
2749,
1175,
401,
881,
27750,
5424,
3950,
51,
13,
262,
13,
1772,
401,
881,
26309,
5424,
1237,
386,
401,
881,
22317,
5424,
40,
1772,
401,
881,
22796,
5424,
2662,
1017,
22,
401,
881,
413,
2953,
5424,
55,
7613,
401,
881,
31308,
5424,
1092,
28460,
401,
881,
29235,
5424,
1358,
12941,
401,
881,
21771,
5424,
1358,
12941,
401,
881,
28818,
5424,
1358,
12941,
401,
881,
31263,
5424,
1358,
12941,
401,
881,
28513,
5424,
1358,
12941,
401,
881,
30300,
5424,
1358,
12941,
401,
881,
28528,
5424,
1358,
12941,
401,
881,
14711,
5424,
1358,
12941,
401,
881,
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
] |
rhurkes/chasegame
|
venv/lib/python2.7/site-packages/werkzeug/testsuite/utils.py
|
146
|
11435
|
# -*- coding: utf-8 -*-
"""
werkzeug.testsuite.utils
~~~~~~~~~~~~~~~~~~~~~~~~
General utilities.
:copyright: (c) 2014 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import unittest
from datetime import datetime
from functools import partial
from werkzeug.testsuite import WerkzeugTestCase
from werkzeug import utils
from werkzeug.datastructures import Headers
from werkzeug.http import parse_date, http_date
from werkzeug.wrappers import BaseResponse
from werkzeug.test import Client, run_wsgi_app
from werkzeug._compat import text_type, implements_iterator
class GeneralUtilityTestCase(WerkzeugTestCase):
def test_redirect(self):
resp = utils.redirect(u'/füübär')
self.assert_in(b'/f%C3%BC%C3%BCb%C3%A4r', resp.get_data())
self.assert_equal(resp.headers['Location'], '/f%C3%BC%C3%BCb%C3%A4r')
self.assert_equal(resp.status_code, 302)
resp = utils.redirect(u'http://☃.net/', 307)
self.assert_in(b'http://xn--n3h.net/', resp.get_data())
self.assert_equal(resp.headers['Location'], 'http://xn--n3h.net/')
self.assert_equal(resp.status_code, 307)
resp = utils.redirect('http://example.com/', 305)
self.assert_equal(resp.headers['Location'], 'http://example.com/')
self.assert_equal(resp.status_code, 305)
def test_redirect_no_unicode_header_keys(self):
# Make sure all headers are native keys. This was a bug at one point
# due to an incorrect conversion.
resp = utils.redirect('http://example.com/', 305)
for key, value in resp.headers.items():
self.assert_equal(type(key), str)
self.assert_equal(type(value), text_type)
self.assert_equal(resp.headers['Location'], 'http://example.com/')
self.assert_equal(resp.status_code, 305)
def test_redirect_xss(self):
location = 'http://example.com/?xss="><script>alert(1)</script>'
resp = utils.redirect(location)
self.assert_not_in(b'<script>alert(1)</script>', resp.get_data())
location = 'http://example.com/?xss="onmouseover="alert(1)'
resp = utils.redirect(location)
self.assert_not_in(b'href="http://example.com/?xss="onmouseover="alert(1)"', resp.get_data())
def test_cached_property(self):
foo = []
class A(object):
def prop(self):
foo.append(42)
return 42
prop = utils.cached_property(prop)
a = A()
p = a.prop
q = a.prop
self.assert_true(p == q == 42)
self.assert_equal(foo, [42])
foo = []
class A(object):
def _prop(self):
foo.append(42)
return 42
prop = utils.cached_property(_prop, name='prop')
del _prop
a = A()
p = a.prop
q = a.prop
self.assert_true(p == q == 42)
self.assert_equal(foo, [42])
def test_environ_property(self):
class A(object):
environ = {'string': 'abc', 'number': '42'}
string = utils.environ_property('string')
missing = utils.environ_property('missing', 'spam')
read_only = utils.environ_property('number')
number = utils.environ_property('number', load_func=int)
broken_number = utils.environ_property('broken_number', load_func=int)
date = utils.environ_property('date', None, parse_date, http_date,
read_only=False)
foo = utils.environ_property('foo')
a = A()
self.assert_equal(a.string, 'abc')
self.assert_equal(a.missing, 'spam')
def test_assign():
a.read_only = 'something'
self.assert_raises(AttributeError, test_assign)
self.assert_equal(a.number, 42)
self.assert_equal(a.broken_number, None)
self.assert_is_none(a.date)
a.date = datetime(2008, 1, 22, 10, 0, 0, 0)
self.assert_equal(a.environ['date'], 'Tue, 22 Jan 2008 10:00:00 GMT')
def test_escape(self):
class Foo(str):
def __html__(self):
return text_type(self)
self.assert_equal(utils.escape(None), '')
self.assert_equal(utils.escape(42), '42')
self.assert_equal(utils.escape('<>'), '<>')
self.assert_equal(utils.escape('"foo"'), '"foo"')
self.assert_equal(utils.escape(Foo('<foo>')), '<foo>')
def test_unescape(self):
self.assert_equal(utils.unescape('<ä>'), u'<ä>')
def test_run_wsgi_app(self):
def foo(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
yield '1'
yield '2'
yield '3'
app_iter, status, headers = run_wsgi_app(foo, {})
self.assert_equal(status, '200 OK')
self.assert_equal(list(headers), [('Content-Type', 'text/plain')])
self.assert_equal(next(app_iter), '1')
self.assert_equal(next(app_iter), '2')
self.assert_equal(next(app_iter), '3')
self.assert_raises(StopIteration, partial(next, app_iter))
got_close = []
@implements_iterator
class CloseIter(object):
def __init__(self):
self.iterated = False
def __iter__(self):
return self
def close(self):
got_close.append(None)
def __next__(self):
if self.iterated:
raise StopIteration()
self.iterated = True
return 'bar'
def bar(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return CloseIter()
app_iter, status, headers = run_wsgi_app(bar, {})
self.assert_equal(status, '200 OK')
self.assert_equal(list(headers), [('Content-Type', 'text/plain')])
self.assert_equal(next(app_iter), 'bar')
self.assert_raises(StopIteration, partial(next, app_iter))
app_iter.close()
self.assert_equal(run_wsgi_app(bar, {}, True)[0], ['bar'])
self.assert_equal(len(got_close), 2)
def test_import_string(self):
import cgi
from werkzeug.debug import DebuggedApplication
self.assert_is(utils.import_string('cgi.escape'), cgi.escape)
self.assert_is(utils.import_string(u'cgi.escape'), cgi.escape)
self.assert_is(utils.import_string('cgi:escape'), cgi.escape)
self.assert_is_none(utils.import_string('XXXXXXXXXXXX', True))
self.assert_is_none(utils.import_string('cgi.XXXXXXXXXXXX', True))
self.assert_is(utils.import_string(u'cgi.escape'), cgi.escape)
self.assert_is(utils.import_string(u'werkzeug.debug.DebuggedApplication'), DebuggedApplication)
self.assert_raises(ImportError, utils.import_string, 'XXXXXXXXXXXXXXXX')
self.assert_raises(ImportError, utils.import_string, 'cgi.XXXXXXXXXX')
def test_find_modules(self):
self.assert_equal(list(utils.find_modules('werkzeug.debug')), \
['werkzeug.debug.console', 'werkzeug.debug.repr',
'werkzeug.debug.tbtools'])
def test_html_builder(self):
html = utils.html
xhtml = utils.xhtml
self.assert_equal(html.p('Hello World'), '<p>Hello World</p>')
self.assert_equal(html.a('Test', href='#'), '<a href="#">Test</a>')
self.assert_equal(html.br(), '<br>')
self.assert_equal(xhtml.br(), '<br />')
self.assert_equal(html.img(src='foo'), '<img src="foo">')
self.assert_equal(xhtml.img(src='foo'), '<img src="foo" />')
self.assert_equal(html.html(
html.head(
html.title('foo'),
html.script(type='text/javascript')
)
), '<html><head><title>foo</title><script type="text/javascript">'
'</script></head></html>')
self.assert_equal(html('<foo>'), '<foo>')
self.assert_equal(html.input(disabled=True), '<input disabled>')
self.assert_equal(xhtml.input(disabled=True), '<input disabled="disabled" />')
self.assert_equal(html.input(disabled=''), '<input>')
self.assert_equal(xhtml.input(disabled=''), '<input />')
self.assert_equal(html.input(disabled=None), '<input>')
self.assert_equal(xhtml.input(disabled=None), '<input />')
self.assert_equal(html.script('alert("Hello World");'), '<script>' \
'alert("Hello World");</script>')
self.assert_equal(xhtml.script('alert("Hello World");'), '<script>' \
'/*<![CDATA[*/alert("Hello World");/*]]>*/</script>')
def test_validate_arguments(self):
take_none = lambda: None
take_two = lambda a, b: None
take_two_one_default = lambda a, b=0: None
self.assert_equal(utils.validate_arguments(take_two, (1, 2,), {}), ((1, 2), {}))
self.assert_equal(utils.validate_arguments(take_two, (1,), {'b': 2}), ((1, 2), {}))
self.assert_equal(utils.validate_arguments(take_two_one_default, (1,), {}), ((1, 0), {}))
self.assert_equal(utils.validate_arguments(take_two_one_default, (1, 2), {}), ((1, 2), {}))
self.assert_raises(utils.ArgumentValidationError,
utils.validate_arguments, take_two, (), {})
self.assert_equal(utils.validate_arguments(take_none, (1, 2,), {'c': 3}), ((), {}))
self.assert_raises(utils.ArgumentValidationError,
utils.validate_arguments, take_none, (1,), {}, drop_extra=False)
self.assert_raises(utils.ArgumentValidationError,
utils.validate_arguments, take_none, (), {'a': 1}, drop_extra=False)
def test_header_set_duplication_bug(self):
headers = Headers([
('Content-Type', 'text/html'),
('Foo', 'bar'),
('Blub', 'blah')
])
headers['blub'] = 'hehe'
headers['blafasel'] = 'humm'
self.assert_equal(headers, Headers([
('Content-Type', 'text/html'),
('Foo', 'bar'),
('blub', 'hehe'),
('blafasel', 'humm')
]))
def test_append_slash_redirect(self):
def app(env, sr):
return utils.append_slash_redirect(env)(env, sr)
client = Client(app, BaseResponse)
response = client.get('foo', base_url='http://example.org/app')
self.assert_equal(response.status_code, 301)
self.assert_equal(response.headers['Location'], 'http://example.org/app/foo/')
def test_cached_property_doc(self):
@utils.cached_property
def foo():
"""testing"""
return 42
self.assert_equal(foo.__doc__, 'testing')
self.assert_equal(foo.__name__, 'foo')
self.assert_equal(foo.__module__, __name__)
def test_secure_filename(self):
self.assert_equal(utils.secure_filename('My cool movie.mov'),
'My_cool_movie.mov')
self.assert_equal(utils.secure_filename('../../../etc/passwd'),
'etc_passwd')
self.assert_equal(utils.secure_filename(u'i contain cool \xfcml\xe4uts.txt'),
'i_contain_cool_umlauts.txt')
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(GeneralUtilityTestCase))
return suite
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10380,
14,
14239,
14,
1208,
272,
18294,
4919,
339,
1696,
15841,
14,
339,
520,
7307,
26,
334,
67,
9,
6927,
701,
1952,
827,
32472,
19728,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
646,
2882,
199,
504,
2197,
492,
2197,
199,
504,
9143,
492,
7417,
199,
199,
504,
10380,
14,
14239,
492,
22798,
1746,
199,
199,
504,
10380,
492,
3778,
199,
504,
10380,
14,
23004,
492,
21391,
199,
504,
10380,
14,
1014,
492,
2198,
63,
602,
12,
1455,
63,
602,
199,
504,
10380,
14,
21148,
492,
3523,
2364,
199,
504,
10380,
14,
396,
492,
6810,
12,
1255,
63,
6508,
63,
571,
199,
504,
10380,
423,
5819,
492,
1318,
63,
466,
12,
9031,
63,
5778,
421,
199,
533,
1696,
17505,
1746,
8,
55,
8756,
1746,
304,
339,
347,
511,
63,
4876,
8,
277,
304,
267,
3085,
275,
3778,
14,
4876,
8,
85,
9807,
70,
17709,
17709,
66,
13733,
82,
358,
267,
291,
14,
479,
63,
262,
8,
66,
9807,
70,
5,
35,
19,
5,
6265,
5,
35,
19,
5,
6265,
66,
5,
35,
19,
5,
33,
20,
82,
297,
3085,
14,
362,
63,
576,
1012,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
2139,
459,
6592,
995,
1994,
70,
5,
35,
19,
5,
6265,
5,
35,
19,
5,
6265,
66,
5,
35,
19,
5,
33,
20,
82,
358,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
1205,
63,
600,
12,
11485,
9,
398,
3085,
275,
3778,
14,
4876,
8,
85,
7,
1014,
921,
159,
247,
226,
14,
846,
3678,
26959,
9,
267,
291,
14,
479,
63,
262,
8,
66,
7,
1014,
921,
5032,
306,
78,
19,
72,
14,
846,
3678,
3085,
14,
362,
63,
576,
1012,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
2139,
459,
6592,
995,
283,
1014,
921,
5032,
306,
78,
19,
72,
14,
846,
6217,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
1205,
63,
600,
12,
26959,
9,
398,
3085,
275,
3778,
14,
4876,
360,
1014,
921,
2694,
14,
957,
3678,
650,
1717,
9,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
2139,
459,
6592,
995,
283,
1014,
921,
2694,
14,
957,
6217,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
1205,
63,
600,
12,
650,
1717,
9,
339,
347,
511,
63,
4876,
63,
889,
63,
2975,
63,
1291,
63,
1612,
8,
277,
304,
267,
327,
4155,
3238,
1006,
2323,
787,
5438,
2883,
14,
221,
961,
1990,
282,
6519,
737,
1373,
2376,
267,
327,
7037,
370,
376,
8927,
8603,
14,
267,
3085,
275,
3778,
14,
4876,
360,
1014,
921,
2694,
14,
957,
3678,
650,
1717,
9,
267,
367,
790,
12,
574,
315,
3085,
14,
2139,
14,
1744,
837,
288,
291,
14,
479,
63,
1452,
8,
466,
8,
498,
395,
620,
9,
288,
291,
14,
479,
63,
1452,
8,
466,
8,
585,
395,
1318,
63,
466,
9,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
2139,
459,
6592,
995,
283,
1014,
921,
2694,
14,
957,
6217,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
1205,
63,
600,
12,
650,
1717,
9,
339,
347,
511,
63,
4876,
63,
88,
385,
8,
277,
304,
267,
2909,
275,
283,
1014,
921,
2694,
14,
957,
10197,
88,
385,
628,
2535,
1579,
30,
9241,
8,
17,
15939,
1579,
3524,
267,
3085,
275,
3778,
14,
4876,
8,
1985,
9,
267,
291,
14,
479,
63,
1397,
63,
262,
8,
66,
7601,
1579,
30,
9241,
8,
17,
15939,
1579,
4206,
3085,
14,
362,
63,
576,
1012,
398,
2909,
275,
283,
1014,
921,
2694,
14,
957,
10197,
88,
385,
628,
265,
10544,
1883,
628,
9241,
8,
17,
3171,
267,
3085,
275,
3778,
14,
4876,
8,
1985,
9,
267,
291,
14,
479,
63,
1397,
63,
262,
8,
66,
7,
6399,
628,
1014,
921,
2694,
14,
957,
10197,
88,
385,
628,
265,
10544,
1883,
628,
9241,
8,
17,
32691,
3085,
14,
362,
63,
576,
1012,
339,
347,
511,
63,
5245,
63,
1829,
8,
277,
304,
267,
3925,
275,
942,
267,
1021,
437,
8,
785,
304,
288,
347,
5931,
8,
277,
304,
355,
3925,
14,
740,
8,
2260,
9,
355,
372,
5685,
288,
5931,
275,
3778,
14,
5245,
63,
1829,
8,
4469,
9,
398,
282,
275,
437,
342,
267,
299,
275,
282,
14,
4469,
267,
1894,
275,
282,
14,
4469,
267,
291,
14,
479,
63,
2052,
8,
80,
508,
1894,
508,
5685,
9,
267,
291,
14,
479,
63,
1452,
8,
1421,
12,
359,
2260,
566,
398,
3925,
275,
942,
267,
1021,
437,
8,
785,
304,
288,
347,
485,
4469,
8,
277,
304,
355,
3925,
14,
740,
8,
2260,
9,
355,
372,
5685,
288,
5931,
275,
3778,
14,
5245,
63,
1829,
1547,
4469,
12,
536,
534,
4469,
358,
288,
2150,
485,
4469,
398,
282,
275,
437,
342,
267,
299,
275,
282,
14,
4469,
267,
1894,
275,
282,
14,
4469,
267,
291,
14,
479,
63,
2052,
8,
80,
508,
1894,
508,
5685,
9,
267,
291,
14,
479,
63,
1452,
8,
1421,
12,
359,
2260,
566,
339,
347,
511,
63,
2314,
63,
1829,
8,
277,
304,
267,
1021,
437,
8,
785,
304,
288,
6160,
275,
791,
875,
356,
283,
3175,
297,
283,
1955,
356,
283,
2260,
936,
953,
1059,
275,
3778,
14,
2314,
63,
1829,
360,
875,
358,
288,
4124,
275,
3778,
14,
2314,
63,
1829,
360,
4752,
297,
283,
8283,
358,
288,
1586,
63,
2118,
275,
3778,
14,
2314,
63,
1829,
360,
1955,
358,
288,
1329,
275,
3778,
14,
2314,
63,
1829,
360,
1955,
297,
2248,
63,
1532,
29,
442,
9,
288,
10529,
63,
1955,
275,
3778,
14,
2314,
63,
1829,
360,
15697,
63,
1955,
297,
2248,
63,
1532,
29,
442,
9,
288,
1434,
275,
3778,
14,
2314,
63,
1829,
360,
602,
297,
488,
12,
2198,
63,
602,
12,
1455,
63,
602,
12,
2511,
1586,
63,
2118,
29,
797,
9,
288,
3925,
275,
3778,
14,
2314,
63,
1829,
360,
1421,
358,
398,
282,
275,
437,
342,
267,
291,
14,
479,
63,
1452,
8,
65,
14,
875,
12,
283,
3175,
358,
267,
291,
14,
479,
63,
1452,
8,
65,
14,
4752,
12,
283,
8283,
358,
267,
347,
511
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10380,
14,
14239,
14,
1208,
272,
18294,
4919,
339,
1696,
15841,
14,
339,
520,
7307,
26,
334,
67,
9,
6927,
701,
1952,
827,
32472,
19728,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
646,
2882,
199,
504,
2197,
492,
2197,
199,
504,
9143,
492,
7417,
199,
199,
504,
10380,
14,
14239,
492,
22798,
1746,
199,
199,
504,
10380,
492,
3778,
199,
504,
10380,
14,
23004,
492,
21391,
199,
504,
10380,
14,
1014,
492,
2198,
63,
602,
12,
1455,
63,
602,
199,
504,
10380,
14,
21148,
492,
3523,
2364,
199,
504,
10380,
14,
396,
492,
6810,
12,
1255,
63,
6508,
63,
571,
199,
504,
10380,
423,
5819,
492,
1318,
63,
466,
12,
9031,
63,
5778,
421,
199,
533,
1696,
17505,
1746,
8,
55,
8756,
1746,
304,
339,
347,
511,
63,
4876,
8,
277,
304,
267,
3085,
275,
3778,
14,
4876,
8,
85,
9807,
70,
17709,
17709,
66,
13733,
82,
358,
267,
291,
14,
479,
63,
262,
8,
66,
9807,
70,
5,
35,
19,
5,
6265,
5,
35,
19,
5,
6265,
66,
5,
35,
19,
5,
33,
20,
82,
297,
3085,
14,
362,
63,
576,
1012,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
2139,
459,
6592,
995,
1994,
70,
5,
35,
19,
5,
6265,
5,
35,
19,
5,
6265,
66,
5,
35,
19,
5,
33,
20,
82,
358,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
1205,
63,
600,
12,
11485,
9,
398,
3085,
275,
3778,
14,
4876,
8,
85,
7,
1014,
921,
159,
247,
226,
14,
846,
3678,
26959,
9,
267,
291,
14,
479,
63,
262,
8,
66,
7,
1014,
921,
5032,
306,
78,
19,
72,
14,
846,
3678,
3085,
14,
362,
63,
576,
1012,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
2139,
459,
6592,
995,
283,
1014,
921,
5032,
306,
78,
19,
72,
14,
846,
6217,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
1205,
63,
600,
12,
26959,
9,
398,
3085,
275,
3778,
14,
4876,
360,
1014,
921,
2694,
14,
957,
3678,
650,
1717,
9,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
2139,
459,
6592,
995,
283,
1014,
921,
2694,
14,
957,
6217,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
1205,
63,
600,
12,
650,
1717,
9,
339,
347,
511,
63,
4876,
63,
889,
63,
2975,
63,
1291,
63,
1612,
8,
277,
304,
267,
327,
4155,
3238,
1006,
2323,
787,
5438,
2883,
14,
221,
961,
1990,
282,
6519,
737,
1373,
2376,
267,
327,
7037,
370,
376,
8927,
8603,
14,
267,
3085,
275,
3778,
14,
4876,
360,
1014,
921,
2694,
14,
957,
3678,
650,
1717,
9,
267,
367,
790,
12,
574,
315,
3085,
14,
2139,
14,
1744,
837,
288,
291,
14,
479,
63,
1452,
8,
466,
8,
498,
395,
620,
9,
288,
291,
14,
479,
63,
1452,
8,
466,
8,
585,
395,
1318,
63,
466,
9,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
2139,
459,
6592,
995,
283,
1014,
921,
2694,
14,
957,
6217,
267,
291,
14,
479,
63,
1452,
8,
4518,
14,
1205,
63,
600,
12,
650,
1717,
9,
339,
347,
511,
63,
4876,
63,
88,
385,
8,
277,
304,
267,
2909,
275,
283,
1014,
921,
2694,
14,
957,
10197,
88,
385,
628,
2535,
1579,
30,
9241,
8,
17,
15939,
1579,
3524,
267,
3085,
275,
3778,
14,
4876,
8,
1985,
9,
267,
291,
14,
479,
63,
1397,
63,
262,
8,
66,
7601,
1579,
30,
9241,
8,
17,
15939,
1579,
4206,
3085,
14,
362,
63,
576,
1012,
398,
2909,
275,
283,
1014,
921,
2694,
14,
957,
10197,
88,
385,
628,
265,
10544,
1883,
628,
9241,
8,
17,
3171,
267,
3085,
275,
3778,
14,
4876,
8,
1985,
9,
267,
291,
14,
479,
63,
1397,
63,
262,
8,
66,
7,
6399,
628,
1014,
921,
2694,
14,
957,
10197,
88,
385,
628,
265,
10544,
1883,
628,
9241,
8,
17,
32691,
3085,
14,
362,
63,
576,
1012,
339,
347,
511,
63,
5245,
63,
1829,
8,
277,
304,
267,
3925,
275,
942,
267,
1021,
437,
8,
785,
304,
288,
347,
5931,
8,
277,
304,
355,
3925,
14,
740,
8,
2260,
9,
355,
372,
5685,
288,
5931,
275,
3778,
14,
5245,
63,
1829,
8,
4469,
9,
398,
282,
275,
437,
342,
267,
299,
275,
282,
14,
4469,
267,
1894,
275,
282,
14,
4469,
267,
291,
14,
479,
63,
2052,
8,
80,
508,
1894,
508,
5685,
9,
267,
291,
14,
479,
63,
1452,
8,
1421,
12,
359,
2260,
566,
398,
3925,
275,
942,
267,
1021,
437,
8,
785,
304,
288,
347,
485,
4469,
8,
277,
304,
355,
3925,
14,
740,
8,
2260,
9,
355,
372,
5685,
288,
5931,
275,
3778,
14,
5245,
63,
1829,
1547,
4469,
12,
536,
534,
4469,
358,
288,
2150,
485,
4469,
398,
282,
275,
437,
342,
267,
299,
275,
282,
14,
4469,
267,
1894,
275,
282,
14,
4469,
267,
291,
14,
479,
63,
2052,
8,
80,
508,
1894,
508,
5685,
9,
267,
291,
14,
479,
63,
1452,
8,
1421,
12,
359,
2260,
566,
339,
347,
511,
63,
2314,
63,
1829,
8,
277,
304,
267,
1021,
437,
8,
785,
304,
288,
6160,
275,
791,
875,
356,
283,
3175,
297,
283,
1955,
356,
283,
2260,
936,
953,
1059,
275,
3778,
14,
2314,
63,
1829,
360,
875,
358,
288,
4124,
275,
3778,
14,
2314,
63,
1829,
360,
4752,
297,
283,
8283,
358,
288,
1586,
63,
2118,
275,
3778,
14,
2314,
63,
1829,
360,
1955,
358,
288,
1329,
275,
3778,
14,
2314,
63,
1829,
360,
1955,
297,
2248,
63,
1532,
29,
442,
9,
288,
10529,
63,
1955,
275,
3778,
14,
2314,
63,
1829,
360,
15697,
63,
1955,
297,
2248,
63,
1532,
29,
442,
9,
288,
1434,
275,
3778,
14,
2314,
63,
1829,
360,
602,
297,
488,
12,
2198,
63,
602,
12,
1455,
63,
602,
12,
2511,
1586,
63,
2118,
29,
797,
9,
288,
3925,
275,
3778,
14,
2314,
63,
1829,
360,
1421,
358,
398,
282,
275,
437,
342,
267,
291,
14,
479,
63,
1452,
8,
65,
14,
875,
12,
283,
3175,
358,
267,
291,
14,
479,
63,
1452,
8,
65,
14,
4752,
12,
283,
8283,
358,
267,
347,
511,
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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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
eharney/cinder
|
cinder/tests/unit/volume/drivers/dell_emc/sc/test_fc.py
|
1
|
43968
|
# Copyright (c) 2014 Dell Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from cinder import context
from cinder import exception
from cinder import test
from cinder.tests.unit import fake_constants as fake
from cinder.volume.drivers.dell_emc.sc import storagecenter_api
from cinder.volume.drivers.dell_emc.sc import storagecenter_fc
# We patch these here as they are used by every test to keep
# from trying to contact a Dell Storage Center.
@mock.patch.object(storagecenter_api.HttpClient,
'__init__',
return_value=None)
@mock.patch.object(storagecenter_api.SCApi,
'open_connection')
@mock.patch.object(storagecenter_api.SCApi,
'close_connection')
class DellSCSanFCDriverTestCase(test.TestCase):
VOLUME = {u'instanceId': u'64702.4829',
u'scSerialNumber': 64702,
u'replicationSource': False,
u'liveVolume': False,
u'vpdId': 4831,
u'objectType': u'ScVolume',
u'index': 4829,
u'volumeFolderPath': u'dopnstktst/',
u'hostCacheEnabled': False,
u'usedByLegacyFluidFsNasVolume': False,
u'inRecycleBin': False,
u'volumeFolderIndex': 17,
u'instanceName': u'5729f1db-4c45-416c-bc15-c8ea13a4465d',
u'statusMessage': u'',
u'status': u'Down',
u'storageType': {u'instanceId': u'64702.1',
u'instanceName': u'Assigned - Redundant - 2 MB',
u'objectType': u'ScStorageType'},
u'cmmDestination': False,
u'replicationDestination': False,
u'volumeFolder': {u'instanceId': u'64702.17',
u'instanceName': u'opnstktst',
u'objectType': u'ScVolumeFolder'},
u'deviceId': u'6000d31000fcbe0000000000000012df',
u'active': False,
u'portableVolumeDestination': False,
u'deleteAllowed': True,
u'name': u'5729f1db-4c45-416c-bc15-c8ea13a4465d',
u'scName': u'Storage Center 64702',
u'secureDataUsed': False,
u'serialNumber': u'0000fcbe-000012df',
u'replayAllowed': False,
u'flashOptimized': False,
u'configuredSize': u'1.073741824E9 Bytes',
u'mapped': False,
u'cmmSource': False}
SCSERVER = {u'scName': u'Storage Center 64702',
u'volumeCount': 0,
u'removeHbasAllowed': True,
u'legacyFluidFs': False,
u'serverFolderIndex': 4,
u'alertOnConnectivity': True,
u'objectType': u'ScPhysicalServer',
u'instanceName': u'Server_21000024ff30441d',
u'instanceId': u'64702.47',
u'serverFolderPath': u'opnstktst/',
u'portType': [u'FibreChannel'],
u'type': u'Physical',
u'statusMessage': u'Only 5 of 6 expected paths are up',
u'status': u'Degraded',
u'scSerialNumber': 64702,
u'serverFolder': {u'instanceId': u'64702.4',
u'instanceName': u'opnstktst',
u'objectType': u'ScServerFolder'},
u'parentIndex': 0,
u'connectivity': u'Partial',
u'hostCacheIndex': 0,
u'deleteAllowed': True,
u'pathCount': 5,
u'name': u'Server_21000024ff30441d',
u'hbaPresent': True,
u'hbaCount': 2,
u'notes': u'Created by Dell EMC Cinder Driver',
u'mapped': False,
u'operatingSystem': {u'instanceId': u'64702.38',
u'instanceName': u'Red Hat Linux 6.x',
u'objectType': u'ScServerOperatingSystem'}
}
MAPPING = {u'instanceId': u'64702.2183',
u'scName': u'Storage Center 64702',
u'scSerialNumber': 64702,
u'controller': {u'instanceId': u'64702.64702',
u'instanceName': u'SN 64702',
u'objectType': u'ScController'},
u'lunUsed': [1],
u'server': {u'instanceId': u'64702.47',
u'instanceName': u'Server_21000024ff30441d',
u'objectType': u'ScPhysicalServer'},
u'volume': {u'instanceId': u'64702.4829',
u'instanceName':
u'5729f1db-4c45-416c-bc15-c8ea13a4465d',
u'objectType': u'ScVolume'},
u'connectivity': u'Up',
u'readOnly': False,
u'objectType': u'ScMappingProfile',
u'hostCache': False,
u'mappedVia': u'Server',
u'mapCount': 2,
u'instanceName': u'4829-47',
u'lunRequested': u'N/A'
}
def setUp(self):
super(DellSCSanFCDriverTestCase, self).setUp()
# configuration is a mock. A mock is pretty much a blank
# slate. I believe mock's done in setup are not happy time
# mocks. So we just do a few things like driver config here.
self.configuration = mock.Mock()
self.configuration.san_is_local = False
self.configuration.san_ip = "192.168.0.1"
self.configuration.san_login = "admin"
self.configuration.san_password = "pwd"
self.configuration.dell_sc_ssn = 64702
self.configuration.dell_sc_server_folder = 'opnstktst'
self.configuration.dell_sc_volume_folder = 'opnstktst'
self.configuration.dell_sc_api_port = 3033
self._context = context.get_admin_context()
self.driver = storagecenter_fc.SCFCDriver(
configuration=self.configuration)
self.driver.do_setup(None)
self.driver._stats = {'QoS_support': False,
'volume_backend_name': 'dell-1',
'free_capacity_gb': 12123,
'driver_version': '1.0.1',
'total_capacity_gb': 12388,
'reserved_percentage': 0,
'vendor_name': 'Dell',
'storage_protocol': 'FC'}
# Start with none. Add in the specific tests later.
# Mock tests bozo this.
self.driver.backends = None
self.driver.replication_enabled = False
self.volid = '5729f1db-4c45-416c-bc15-c8ea13a4465d'
self.volume_name = "volume" + self.volid
self.connector = {'ip': '192.168.0.77',
'host': 'cinderfc-vm',
'wwnns': ['20000024ff30441c', '20000024ff30441d'],
'initiator': 'iqn.1993-08.org.debian:01:e1b1312f9e1',
'wwpns': ['21000024ff30441c', '21000024ff30441d']}
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=None)
@mock.patch.object(storagecenter_api.SCApi,
'create_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'get_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'map_volume',
return_value=MAPPING)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(1,
[u'5000D31000FCBE3D',
u'5000D31000FCBE35'],
{u'21000024FF30441C':
[u'5000D31000FCBE35'],
u'21000024FF30441D':
[u'5000D31000FCBE3D']}))
def test_initialize_connection(self,
mock_find_wwns,
mock_map_volume,
mock_get_volume,
mock_find_volume,
mock_create_server,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
res = self.driver.initialize_connection(volume, connector)
expected = {'data':
{'discard': True,
'initiator_target_map':
{u'21000024FF30441C': [u'5000D31000FCBE35'],
u'21000024FF30441D': [u'5000D31000FCBE3D']},
'target_discovered': True,
'target_lun': 1,
'target_wwn':
[u'5000D31000FCBE3D', u'5000D31000FCBE35']},
'driver_volume_type': 'fibre_channel'}
self.assertEqual(expected, res, 'Unexpected return data')
# verify find_volume has been called and that is has been called twice
mock_find_volume.assert_called_once_with(fake.VOLUME_ID, None, False)
mock_get_volume.assert_called_once_with(self.VOLUME[u'instanceId'])
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'get_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'map_volume',
return_value=MAPPING)
@mock.patch.object(storagecenter_fc.SCFCDriver,
'_is_live_vol')
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns')
@mock.patch.object(storagecenter_fc.SCFCDriver,
'initialize_secondary')
@mock.patch.object(storagecenter_api.SCApi,
'get_live_volume')
def test_initialize_connection_live_vol(self,
mock_get_live_volume,
mock_initialize_secondary,
mock_find_wwns,
mock_is_live_volume,
mock_map_volume,
mock_get_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
sclivevol = {'instanceId': '101.101',
'secondaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 102,
'secondaryRole': 'Secondary'}
mock_is_live_volume.return_value = True
mock_find_wwns.return_value = (
1, [u'5000D31000FCBE3D', u'5000D31000FCBE35'],
{u'21000024FF30441C': [u'5000D31000FCBE35'],
u'21000024FF30441D': [u'5000D31000FCBE3D']})
mock_initialize_secondary.return_value = (
1, [u'5000D31000FCBE3E', u'5000D31000FCBE36'],
{u'21000024FF30441E': [u'5000D31000FCBE36'],
u'21000024FF30441F': [u'5000D31000FCBE3E']})
mock_get_live_volume.return_value = sclivevol
res = self.driver.initialize_connection(volume, connector)
expected = {'data':
{'discard': True,
'initiator_target_map':
{u'21000024FF30441C': [u'5000D31000FCBE35'],
u'21000024FF30441D': [u'5000D31000FCBE3D'],
u'21000024FF30441E': [u'5000D31000FCBE36'],
u'21000024FF30441F': [u'5000D31000FCBE3E']},
'target_discovered': True,
'target_lun': 1,
'target_wwn': [u'5000D31000FCBE3D', u'5000D31000FCBE35',
u'5000D31000FCBE3E', u'5000D31000FCBE36']},
'driver_volume_type': 'fibre_channel'}
self.assertEqual(expected, res, 'Unexpected return data')
# verify find_volume has been called and that is has been called twice
mock_find_volume.assert_called_once_with(fake.VOLUME_ID, None, True)
mock_get_volume.assert_called_once_with(self.VOLUME[u'instanceId'])
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume')
@mock.patch.object(storagecenter_api.SCApi,
'get_volume')
@mock.patch.object(storagecenter_api.SCApi,
'map_volume',
return_value=MAPPING)
@mock.patch.object(storagecenter_fc.SCFCDriver,
'_is_live_vol')
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns')
@mock.patch.object(storagecenter_fc.SCFCDriver,
'initialize_secondary')
@mock.patch.object(storagecenter_api.SCApi,
'get_live_volume')
def test_initialize_connection_live_vol_afo(self,
mock_get_live_volume,
mock_initialize_secondary,
mock_find_wwns,
mock_is_live_volume,
mock_map_volume,
mock_get_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID, 'provider_id': '101.101'}
scvol = {'instanceId': '102.101'}
mock_find_volume.return_value = scvol
mock_get_volume.return_value = scvol
connector = self.connector
sclivevol = {'instanceId': '101.10001',
'primaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID},
'primaryScSerialNumber': 102,
'secondaryVolume': {'instanceId': '101.101',
'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 101,
'secondaryRole': 'Activated'}
mock_is_live_volume.return_value = True
mock_find_wwns.return_value = (
1, [u'5000D31000FCBE3D', u'5000D31000FCBE35'],
{u'21000024FF30441C': [u'5000D31000FCBE35'],
u'21000024FF30441D': [u'5000D31000FCBE3D']})
mock_get_live_volume.return_value = sclivevol
res = self.driver.initialize_connection(volume, connector)
expected = {'data':
{'discard': True,
'initiator_target_map':
{u'21000024FF30441C': [u'5000D31000FCBE35'],
u'21000024FF30441D': [u'5000D31000FCBE3D']},
'target_discovered': True,
'target_lun': 1,
'target_wwn': [u'5000D31000FCBE3D', u'5000D31000FCBE35']},
'driver_volume_type': 'fibre_channel'}
self.assertEqual(expected, res, 'Unexpected return data')
# verify find_volume has been called and that is has been called twice
self.assertFalse(mock_initialize_secondary.called)
mock_find_volume.assert_called_once_with(
fake.VOLUME_ID, '101.101', True)
mock_get_volume.assert_called_once_with('102.101')
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'get_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'map_volume',
return_value=MAPPING)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(None, [], {}))
def test_initialize_connection_no_wwns(self,
mock_find_wwns,
mock_map_volume,
mock_get_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.initialize_connection,
volume,
connector)
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=None)
@mock.patch.object(storagecenter_api.SCApi,
'create_server',
return_value=None)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'map_volume',
return_value=MAPPING)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(None, [], {}))
def test_initialize_connection_no_server(self,
mock_find_wwns,
mock_map_volume,
mock_find_volume,
mock_create_server,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.initialize_connection,
volume,
connector)
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=None)
@mock.patch.object(storagecenter_api.SCApi,
'map_volume',
return_value=MAPPING)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(None, [], {}))
def test_initialize_connection_vol_not_found(self,
mock_find_wwns,
mock_map_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.initialize_connection,
volume,
connector)
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'map_volume',
return_value=None)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(None, [], {}))
def test_initialize_connection_map_vol_fail(self,
mock_find_wwns,
mock_map_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
# Test case where map_volume returns None (no mappings)
volume = {'id': fake.VOLUME_ID}
connector = self.connector
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.initialize_connection,
volume,
connector)
def test_initialize_secondary(self,
mock_close_connection,
mock_open_connection,
mock_init):
sclivevol = {'instanceId': '101.101',
'secondaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 102}
mock_api = mock.MagicMock()
mock_api.find_server = mock.MagicMock(return_value=self.SCSERVER)
mock_api.map_secondary_volume = mock.MagicMock(
return_value=self.VOLUME)
find_wwns_ret = (1, [u'5000D31000FCBE3D', u'5000D31000FCBE35'],
{u'21000024FF30441C': [u'5000D31000FCBE35'],
u'21000024FF30441D': [u'5000D31000FCBE3D']})
mock_api.find_wwns = mock.MagicMock(return_value=find_wwns_ret)
mock_api.get_volume = mock.MagicMock(return_value=self.VOLUME)
ret = self.driver.initialize_secondary(mock_api, sclivevol,
['wwn1', 'wwn2'])
self.assertEqual(find_wwns_ret, ret)
def test_initialize_secondary_create_server(self,
mock_close_connection,
mock_open_connection,
mock_init):
sclivevol = {'instanceId': '101.101',
'secondaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 102}
mock_api = mock.MagicMock()
mock_api.find_server = mock.MagicMock(return_value=None)
mock_api.create_server = mock.MagicMock(return_value=self.SCSERVER)
mock_api.map_secondary_volume = mock.MagicMock(
return_value=self.VOLUME)
find_wwns_ret = (1, [u'5000D31000FCBE3D', u'5000D31000FCBE35'],
{u'21000024FF30441C': [u'5000D31000FCBE35'],
u'21000024FF30441D': [u'5000D31000FCBE3D']})
mock_api.find_wwns = mock.MagicMock(return_value=find_wwns_ret)
mock_api.get_volume = mock.MagicMock(return_value=self.VOLUME)
ret = self.driver.initialize_secondary(mock_api, sclivevol,
['wwn1', 'wwn2'])
self.assertEqual(find_wwns_ret, ret)
def test_initialize_secondary_no_server(self,
mock_close_connection,
mock_open_connection,
mock_init):
sclivevol = {'instanceId': '101.101',
'secondaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 102}
mock_api = mock.MagicMock()
mock_api.find_server = mock.MagicMock(return_value=None)
mock_api.create_server = mock.MagicMock(return_value=None)
ret = self.driver.initialize_secondary(mock_api, sclivevol,
['wwn1', 'wwn2'])
expected = (None, [], {})
self.assertEqual(expected, ret)
def test_initialize_secondary_map_fail(self,
mock_close_connection,
mock_open_connection,
mock_init):
sclivevol = {'instanceId': '101.101',
'secondaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 102}
mock_api = mock.MagicMock()
mock_api.find_server = mock.MagicMock(return_value=self.SCSERVER)
mock_api.map_secondary_volume = mock.MagicMock(return_value=None)
ret = self.driver.initialize_secondary(mock_api, sclivevol,
['wwn1', 'wwn2'])
expected = (None, [], {})
self.assertEqual(expected, ret)
def test_initialize_secondary_vol_not_found(self,
mock_close_connection,
mock_open_connection,
mock_init):
sclivevol = {'instanceId': '101.101',
'secondaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 102}
mock_api = mock.MagicMock()
mock_api.find_server = mock.MagicMock(return_value=self.SCSERVER)
mock_api.map_secondary_volume = mock.MagicMock(
return_value=self.VOLUME)
mock_api.get_volume = mock.MagicMock(return_value=None)
ret = self.driver.initialize_secondary(mock_api, sclivevol,
['wwn1', 'wwn2'])
expected = (None, [], {})
self.assertEqual(expected, ret)
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'unmap_volume',
return_value=True)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(1,
[u'5000D31000FCBE3D',
u'5000D31000FCBE35'],
{u'21000024FF30441C':
[u'5000D31000FCBE35'],
u'21000024FF30441D':
[u'5000D31000FCBE3D']}))
@mock.patch.object(storagecenter_api.SCApi,
'get_volume_count',
return_value=1)
def test_terminate_connection(self,
mock_get_volume_count,
mock_find_wwns,
mock_unmap_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
res = self.driver.terminate_connection(volume, connector)
mock_unmap_volume.assert_called_once_with(self.VOLUME, self.SCSERVER)
expected = {'driver_volume_type': 'fibre_channel',
'data': {}}
self.assertEqual(expected, res, 'Unexpected return data')
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'unmap_volume',
return_value=True)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(1,
[u'5000D31000FCBE3D',
u'5000D31000FCBE35'],
{u'21000024FF30441C':
[u'5000D31000FCBE35'],
u'21000024FF30441D':
[u'5000D31000FCBE3D']}))
@mock.patch.object(storagecenter_api.SCApi,
'get_volume_count',
return_value=1)
@mock.patch.object(storagecenter_fc.SCFCDriver,
'_is_live_vol')
@mock.patch.object(storagecenter_fc.SCFCDriver,
'terminate_secondary')
def test_terminate_connection_live_vol(self,
mock_terminate_secondary,
mock_is_live_vol,
mock_get_volume_count,
mock_find_wwns,
mock_unmap_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
mock_terminate_secondary.return_value = (None, [], {})
mock_is_live_vol.return_value = True
res = self.driver.terminate_connection(volume, connector)
mock_unmap_volume.assert_called_once_with(self.VOLUME, self.SCSERVER)
expected = {'driver_volume_type': 'fibre_channel',
'data': {}}
self.assertEqual(expected, res, 'Unexpected return data')
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=None)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'unmap_volume',
return_value=True)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(1,
[u'5000D31000FCBE3D',
u'5000D31000FCBE35'],
{u'21000024FF30441C':
[u'5000D31000FCBE35'],
u'21000024FF30441D':
[u'5000D31000FCBE3D']}))
@mock.patch.object(storagecenter_api.SCApi,
'get_volume_count',
return_value=1)
def test_terminate_connection_no_server(self,
mock_get_volume_count,
mock_find_wwns,
mock_unmap_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.terminate_connection,
volume,
connector)
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=None)
@mock.patch.object(storagecenter_api.SCApi,
'unmap_volume',
return_value=True)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(1,
[u'5000D31000FCBE3D',
u'5000D31000FCBE35'],
{u'21000024FF30441C':
[u'5000D31000FCBE35'],
u'21000024FF30441D':
[u'5000D31000FCBE3D']}))
@mock.patch.object(storagecenter_api.SCApi,
'get_volume_count',
return_value=1)
def test_terminate_connection_no_volume(self,
mock_get_volume_count,
mock_find_wwns,
mock_unmap_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.terminate_connection,
volume,
connector)
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'unmap_volume',
return_value=True)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(None,
[],
{}))
@mock.patch.object(storagecenter_api.SCApi,
'get_volume_count',
return_value=1)
def test_terminate_connection_no_wwns(self,
mock_get_volume_count,
mock_find_wwns,
mock_unmap_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
res = self.driver.terminate_connection(volume, connector)
expected = {'driver_volume_type': 'fibre_channel',
'data': {}}
self.assertEqual(expected, res, 'Unexpected return data')
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'unmap_volume',
return_value=False)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(1,
[u'5000D31000FCBE3D',
u'5000D31000FCBE35'],
{u'21000024FF30441C':
[u'5000D31000FCBE35'],
u'21000024FF30441D':
[u'5000D31000FCBE3D']}))
@mock.patch.object(storagecenter_api.SCApi,
'get_volume_count',
return_value=1)
def test_terminate_connection_failure(self,
mock_get_volume_count,
mock_find_wwns,
mock_unmap_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
volume = {'id': fake.VOLUME_ID}
connector = self.connector
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.terminate_connection,
volume,
connector)
@mock.patch.object(storagecenter_api.SCApi,
'find_server',
return_value=SCSERVER)
@mock.patch.object(storagecenter_api.SCApi,
'find_volume',
return_value=VOLUME)
@mock.patch.object(storagecenter_api.SCApi,
'unmap_volume',
return_value=True)
@mock.patch.object(storagecenter_api.SCApi,
'find_wwns',
return_value=(1,
[u'5000D31000FCBE3D',
u'5000D31000FCBE35'],
{u'21000024FF30441C':
[u'5000D31000FCBE35'],
u'21000024FF30441D':
[u'5000D31000FCBE3D']}))
@mock.patch.object(storagecenter_api.SCApi,
'get_volume_count',
return_value=0)
def test_terminate_connection_vol_count_zero(self,
mock_get_volume_count,
mock_find_wwns,
mock_unmap_volume,
mock_find_volume,
mock_find_server,
mock_close_connection,
mock_open_connection,
mock_init):
# Test case where get_volume_count is zero
volume = {'id': fake.VOLUME_ID}
connector = self.connector
res = self.driver.terminate_connection(volume, connector)
mock_unmap_volume.assert_called_once_with(self.VOLUME, self.SCSERVER)
expected = {'data':
{'initiator_target_map':
{u'21000024FF30441C': [u'5000D31000FCBE35'],
u'21000024FF30441D': [u'5000D31000FCBE3D']},
'target_wwn':
[u'5000D31000FCBE3D', u'5000D31000FCBE35']},
'driver_volume_type': 'fibre_channel'}
self.assertEqual(expected, res, 'Unexpected return data')
def test_terminate_secondary(self,
mock_close_connection,
mock_open_connection,
mock_init):
mock_api = mock.MagicMock()
mock_api.find_server = mock.MagicMock(return_value=self.SCSERVER)
mock_api.get_volume = mock.MagicMock(return_value=self.VOLUME)
mock_api.find_wwns = mock.MagicMock(return_value=(None, [], {}))
mock_api.unmap_volume = mock.MagicMock(return_value=True)
sclivevol = {'instanceId': '101.101',
'secondaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 102}
ret = self.driver.terminate_secondary(mock_api, sclivevol,
['wwn1', 'wwn2'])
expected = (None, [], {})
self.assertEqual(expected, ret)
@mock.patch.object(storagecenter_api.SCApi,
'get_storage_usage',
return_value={'availableSpace': 100, 'freeSpace': 50})
def test_update_volume_stats_with_refresh(self,
mock_get_storage_usage,
mock_close_connection,
mock_open_connection,
mock_init):
stats = self.driver.get_volume_stats(True)
self.assertEqual('FC', stats['storage_protocol'])
mock_get_storage_usage.assert_called_once_with()
@mock.patch.object(storagecenter_api.SCApi,
'get_storage_usage',
return_value={'availableSpace': 100, 'freeSpace': 50})
def test_get_volume_stats_no_refresh(self,
mock_get_storage_usage,
mock_close_connection,
mock_open_connection,
mock_init):
stats = self.driver.get_volume_stats(False)
self.assertEqual('FC', stats['storage_protocol'])
mock_get_storage_usage.assert_not_called()
|
apache-2.0
|
[
3,
259,
1898,
334,
67,
9,
6927,
577,
1697,
3277,
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,
1683,
199,
199,
504,
13069,
492,
1067,
199,
504,
13069,
492,
1919,
199,
504,
13069,
492,
511,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
5559,
465,
4026,
199,
504,
13069,
14,
2405,
14,
13337,
14,
271,
914,
63,
69,
5466,
14,
551,
492,
4887,
4218,
63,
1246,
199,
504,
13069,
14,
2405,
14,
13337,
14,
271,
914,
63,
69,
5466,
14,
551,
492,
4887,
4218,
63,
3003,
421,
199,
3,
2136,
3371,
3520,
2348,
465,
2985,
787,
1202,
701,
4036,
511,
370,
4215,
199,
3,
687,
9936,
370,
8966,
282,
577,
1697,
10533,
24699,
14,
199,
32,
1805,
14,
2068,
14,
785,
8,
3494,
4218,
63,
1246,
14,
5779,
3041,
12,
673,
2560,
826,
7500,
673,
372,
63,
585,
29,
403,
9,
199,
32,
1805,
14,
2068,
14,
785,
8,
3494,
4218,
63,
1246,
14,
51,
3263,
1038,
12,
673,
283,
1490,
63,
2105,
358,
199,
32,
1805,
14,
2068,
14,
785,
8,
3494,
4218,
63,
1246,
14,
51,
3263,
1038,
12,
673,
283,
1600,
63,
2105,
358,
199,
533,
577,
1697,
14897,
290,
4161,
6158,
1746,
8,
396,
14,
1746,
304,
339,
812,
2228,
13847,
275,
469,
85,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
2006,
1398,
297,
1598,
399,
1159,
67,
3571,
3259,
356,
5049,
29422,
12,
1598,
399,
3984,
80,
1863,
2980,
356,
756,
12,
1598,
399,
7,
6442,
6464,
356,
756,
12,
1598,
399,
7,
86,
8961,
1304,
356,
9615,
2192,
12,
1598,
399,
7,
785,
804,
356,
399,
7,
7181,
6464,
297,
1598,
399,
7,
1080,
356,
9615,
1398,
12,
1598,
399,
7,
2405,
7850,
2042,
356,
399,
5121,
411,
78,
270,
5973,
270,
3678,
1598,
399,
7,
1102,
4437,
6589,
356,
756,
12,
1598,
399,
7,
2972,
2175,
22628,
7579,
1535,
19239,
46,
305,
6464,
356,
756,
12,
1598,
399,
7,
262,
497,
7612,
13394,
356,
756,
12,
1598,
399,
7,
2405,
7850,
2681,
356,
5557,
12,
1598,
399,
7,
842,
985,
356,
399,
7,
1641,
1398,
70,
17,
697,
13,
20,
67,
2322,
13,
25209,
67,
13,
3776,
1046,
13,
67,
24,
4489,
969,
65,
1602,
2182,
68,
297,
1598,
399,
1159,
84,
896,
2209,
356,
399,
6448,
1598,
399,
1159,
84,
896,
356,
399,
7,
3514,
297,
1598,
399,
1159,
84,
2128,
804,
356,
469,
85,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
17,
297,
3044,
399,
7,
842,
985,
356,
399,
7,
2822,
1737,
446,
9572,
17013,
446,
499,
19487,
297,
3044,
399,
7,
785,
804,
356,
399,
7,
7181,
6408,
804,
2267,
1598,
399,
7,
67,
596,
13151,
356,
756,
12,
1598,
399,
3984,
80,
1863,
13151,
356,
756,
12,
1598,
399,
7,
2405,
7850,
356,
469,
85,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
1196,
297,
1816,
399,
7,
842,
985,
356,
399,
7,
411,
78,
270,
5973,
270,
297,
1816,
399,
7,
785,
804,
356,
399,
7,
7181,
6464,
7850,
2267,
1598,
399,
5121,
69,
722,
1304,
356,
399,
7,
32623,
68,
2192,
1493,
3003,
1235,
17994,
713,
1587,
297,
1598,
399,
7,
2682,
356,
756,
12,
1598,
399,
7,
719,
461,
6464,
13151,
356,
756,
12,
1598,
399,
5121,
69,
1268,
16070,
356,
715,
12,
1598,
399,
7,
354,
356,
399,
7,
1641,
1398,
70,
17,
697,
13,
20,
67,
2322,
13,
25209,
67,
13,
3776,
1046,
13,
67,
24,
4489,
969,
65,
1602,
2182,
68,
297,
1598,
399,
1159,
67,
985,
356,
399,
7,
6408,
24699,
5049,
29422,
297,
1598,
399,
1159,
825,
608,
1451,
9167,
356,
756,
12,
1598,
399,
1159,
281,
2380,
3259,
356,
399,
7,
993,
3003,
1235,
13,
993,
713,
1587,
297,
1598,
399,
3984,
2802,
16070,
356,
756,
12,
1598,
399,
7,
11331,
9867,
1759,
356,
756,
12,
1598,
399,
7,
11786,
2320,
356,
399,
7,
17,
14,
1780,
9880,
1085,
1194,
37,
25,
9879,
297,
1598,
399,
6704,
439,
1915,
356,
756,
12,
1598,
399,
7,
67,
596,
2980,
356,
756,
93,
339,
12075,
6613,
275,
469,
85,
1159,
67,
985,
356,
399,
7,
6408,
24699,
5049,
29422,
297,
355,
399,
7,
2405,
2353,
356,
378,
12,
355,
399,
3984,
1185,
40,
31917,
16070,
356,
715,
12,
355,
399,
7,
10000,
7579,
1535,
19239,
356,
756,
12,
355,
399,
1159,
23685,
7850,
2681,
356,
841,
12,
355,
399,
7,
9241,
3314,
714,
13498,
356,
715,
12,
355,
399,
7,
785,
804,
356,
399,
7,
7181,
20303,
3120,
297,
355,
399,
7,
842,
985,
356,
399,
7,
3120,
63,
2025,
993,
1194,
556,
8533,
2953,
68,
297,
355,
399,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
2417,
297,
355,
399,
1159,
23685,
7850,
2042,
356,
399,
7,
411,
78,
270,
5973,
270,
3678,
355,
399,
7,
719,
804,
356,
359,
85,
7,
38,
1892,
264,
5358,
995,
355,
399,
1133,
514,
356,
399,
7,
20303,
297,
355,
399,
1159,
84,
896,
2209,
356,
399,
7,
5903,
959,
402,
1227,
1420,
3792,
787,
1536,
297,
355,
399,
1159,
84,
896,
356,
399,
7,
872,
13688,
297,
355,
399,
1159,
67,
3571,
3259,
356,
5049,
29422,
12,
355,
399,
1159,
23685,
7850,
356,
469,
85,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
20,
297,
3303,
399,
7,
842,
985,
356,
399,
7,
411,
78,
270,
5973,
270,
297,
3303,
399,
7
] |
[
259,
1898,
334,
67,
9,
6927,
577,
1697,
3277,
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,
1683,
199,
199,
504,
13069,
492,
1067,
199,
504,
13069,
492,
1919,
199,
504,
13069,
492,
511,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
5559,
465,
4026,
199,
504,
13069,
14,
2405,
14,
13337,
14,
271,
914,
63,
69,
5466,
14,
551,
492,
4887,
4218,
63,
1246,
199,
504,
13069,
14,
2405,
14,
13337,
14,
271,
914,
63,
69,
5466,
14,
551,
492,
4887,
4218,
63,
3003,
421,
199,
3,
2136,
3371,
3520,
2348,
465,
2985,
787,
1202,
701,
4036,
511,
370,
4215,
199,
3,
687,
9936,
370,
8966,
282,
577,
1697,
10533,
24699,
14,
199,
32,
1805,
14,
2068,
14,
785,
8,
3494,
4218,
63,
1246,
14,
5779,
3041,
12,
673,
2560,
826,
7500,
673,
372,
63,
585,
29,
403,
9,
199,
32,
1805,
14,
2068,
14,
785,
8,
3494,
4218,
63,
1246,
14,
51,
3263,
1038,
12,
673,
283,
1490,
63,
2105,
358,
199,
32,
1805,
14,
2068,
14,
785,
8,
3494,
4218,
63,
1246,
14,
51,
3263,
1038,
12,
673,
283,
1600,
63,
2105,
358,
199,
533,
577,
1697,
14897,
290,
4161,
6158,
1746,
8,
396,
14,
1746,
304,
339,
812,
2228,
13847,
275,
469,
85,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
2006,
1398,
297,
1598,
399,
1159,
67,
3571,
3259,
356,
5049,
29422,
12,
1598,
399,
3984,
80,
1863,
2980,
356,
756,
12,
1598,
399,
7,
6442,
6464,
356,
756,
12,
1598,
399,
7,
86,
8961,
1304,
356,
9615,
2192,
12,
1598,
399,
7,
785,
804,
356,
399,
7,
7181,
6464,
297,
1598,
399,
7,
1080,
356,
9615,
1398,
12,
1598,
399,
7,
2405,
7850,
2042,
356,
399,
5121,
411,
78,
270,
5973,
270,
3678,
1598,
399,
7,
1102,
4437,
6589,
356,
756,
12,
1598,
399,
7,
2972,
2175,
22628,
7579,
1535,
19239,
46,
305,
6464,
356,
756,
12,
1598,
399,
7,
262,
497,
7612,
13394,
356,
756,
12,
1598,
399,
7,
2405,
7850,
2681,
356,
5557,
12,
1598,
399,
7,
842,
985,
356,
399,
7,
1641,
1398,
70,
17,
697,
13,
20,
67,
2322,
13,
25209,
67,
13,
3776,
1046,
13,
67,
24,
4489,
969,
65,
1602,
2182,
68,
297,
1598,
399,
1159,
84,
896,
2209,
356,
399,
6448,
1598,
399,
1159,
84,
896,
356,
399,
7,
3514,
297,
1598,
399,
1159,
84,
2128,
804,
356,
469,
85,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
17,
297,
3044,
399,
7,
842,
985,
356,
399,
7,
2822,
1737,
446,
9572,
17013,
446,
499,
19487,
297,
3044,
399,
7,
785,
804,
356,
399,
7,
7181,
6408,
804,
2267,
1598,
399,
7,
67,
596,
13151,
356,
756,
12,
1598,
399,
3984,
80,
1863,
13151,
356,
756,
12,
1598,
399,
7,
2405,
7850,
356,
469,
85,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
1196,
297,
1816,
399,
7,
842,
985,
356,
399,
7,
411,
78,
270,
5973,
270,
297,
1816,
399,
7,
785,
804,
356,
399,
7,
7181,
6464,
7850,
2267,
1598,
399,
5121,
69,
722,
1304,
356,
399,
7,
32623,
68,
2192,
1493,
3003,
1235,
17994,
713,
1587,
297,
1598,
399,
7,
2682,
356,
756,
12,
1598,
399,
7,
719,
461,
6464,
13151,
356,
756,
12,
1598,
399,
5121,
69,
1268,
16070,
356,
715,
12,
1598,
399,
7,
354,
356,
399,
7,
1641,
1398,
70,
17,
697,
13,
20,
67,
2322,
13,
25209,
67,
13,
3776,
1046,
13,
67,
24,
4489,
969,
65,
1602,
2182,
68,
297,
1598,
399,
1159,
67,
985,
356,
399,
7,
6408,
24699,
5049,
29422,
297,
1598,
399,
1159,
825,
608,
1451,
9167,
356,
756,
12,
1598,
399,
1159,
281,
2380,
3259,
356,
399,
7,
993,
3003,
1235,
13,
993,
713,
1587,
297,
1598,
399,
3984,
2802,
16070,
356,
756,
12,
1598,
399,
7,
11331,
9867,
1759,
356,
756,
12,
1598,
399,
7,
11786,
2320,
356,
399,
7,
17,
14,
1780,
9880,
1085,
1194,
37,
25,
9879,
297,
1598,
399,
6704,
439,
1915,
356,
756,
12,
1598,
399,
7,
67,
596,
2980,
356,
756,
93,
339,
12075,
6613,
275,
469,
85,
1159,
67,
985,
356,
399,
7,
6408,
24699,
5049,
29422,
297,
355,
399,
7,
2405,
2353,
356,
378,
12,
355,
399,
3984,
1185,
40,
31917,
16070,
356,
715,
12,
355,
399,
7,
10000,
7579,
1535,
19239,
356,
756,
12,
355,
399,
1159,
23685,
7850,
2681,
356,
841,
12,
355,
399,
7,
9241,
3314,
714,
13498,
356,
715,
12,
355,
399,
7,
785,
804,
356,
399,
7,
7181,
20303,
3120,
297,
355,
399,
7,
842,
985,
356,
399,
7,
3120,
63,
2025,
993,
1194,
556,
8533,
2953,
68,
297,
355,
399,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
2417,
297,
355,
399,
1159,
23685,
7850,
2042,
356,
399,
7,
411,
78,
270,
5973,
270,
3678,
355,
399,
7,
719,
804,
356,
359,
85,
7,
38,
1892,
264,
5358,
995,
355,
399,
1133,
514,
356,
399,
7,
20303,
297,
355,
399,
1159,
84,
896,
2209,
356,
399,
7,
5903,
959,
402,
1227,
1420,
3792,
787,
1536,
297,
355,
399,
1159,
84,
896,
356,
399,
7,
872,
13688,
297,
355,
399,
1159,
67,
3571,
3259,
356,
5049,
29422,
12,
355,
399,
1159,
23685,
7850,
356,
469,
85,
7,
842,
1304,
356,
399,
7,
8557,
996,
14,
20,
297,
3303,
399,
7,
842,
985,
356,
399,
7,
411,
78,
270,
5973,
270,
297,
3303,
399,
7,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
saeki-masaki/cinder
|
cinder/zonemanager/fc_san_lookup_service.py
|
23
|
3551
|
# (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.
#
"""
Base Lookup Service for name server lookup to find the initiator to target port
mapping for available SAN contexts.
Vendor specific lookup classes are expected to implement the interfaces
defined in this class.
"""
from oslo_log import log as logging
from oslo_utils import importutils
from cinder import exception
from cinder.i18n import _, _LE
from cinder.volume import configuration as config
from cinder.zonemanager import fc_common
from cinder.zonemanager import fc_zone_manager
LOG = logging.getLogger(__name__)
class FCSanLookupService(fc_common.FCCommon):
"""Base Lookup Service.
Base Lookup Service for name server lookup to find the initiator to
target port mapping for available SAN contexts.
"""
lookup_service = None
def __init__(self, **kwargs):
super(FCSanLookupService, self).__init__(**kwargs)
opts = fc_zone_manager.zone_manager_opts
self.configuration = config.Configuration(opts, 'fc-zone-manager')
def get_device_mapping_from_network(self, initiator_list, target_list):
"""Get device mapping from FC network.
Gets a filtered list of initiator ports and target ports for each SAN
available.
:param initiator_list list of initiator port WWN
:param target_list list of target port WWN
:return device wwn map in following format
{
<San name>: {
'initiator_port_wwn_list':
('200000051E55A100', '200000051E55A121'..)
'target_port_wwn_list':
('100000051E55A100', '100000051E55A121'..)
}
}
:raise Exception when a lookup service implementation is not specified
in cinder.conf:fc_san_lookup_service
"""
# Initialize vendor specific implementation of FCZoneDriver
if (self.configuration.fc_san_lookup_service):
lookup_service = self.configuration.fc_san_lookup_service
LOG.debug("Lookup service to invoke: "
"%s", lookup_service)
self.lookup_service = importutils.import_object(
lookup_service, configuration=self.configuration)
else:
msg = _("Lookup service not configured. Config option for "
"fc_san_lookup_service needs to specify a concrete "
"implementation of the lookup service.")
LOG.error(msg)
raise exception.FCSanLookupServiceException(msg)
try:
device_map = self.lookup_service.get_device_mapping_from_network(
initiator_list, target_list)
except Exception as e:
LOG.exception(_LE('Unable to get device mapping from network.'))
raise exception.FCSanLookupServiceException(e)
return device_map
|
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,
624,
199,
1563,
12785,
7591,
367,
536,
1654,
4237,
370,
2342,
314,
22094,
370,
1347,
1844,
199,
4745,
367,
2808,
428,
879,
18191,
14,
199,
27111,
2488,
4237,
3992,
787,
1420,
370,
5669,
314,
8386,
199,
4037,
315,
642,
1021,
14,
199,
199,
624,
199,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
11258,
63,
1208,
492,
492,
1208,
199,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
73,
1085,
78,
492,
5501,
485,
906,
199,
504,
13069,
14,
2405,
492,
2897,
465,
1101,
199,
504,
13069,
14,
2619,
2609,
492,
10821,
63,
2330,
199,
504,
13069,
14,
2619,
2609,
492,
10821,
63,
2619,
63,
2609,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
481,
3298,
290,
7521,
3167,
8,
3003,
63,
2330,
14,
4161,
7844,
304,
272,
408,
1563,
12785,
7591,
14,
339,
3523,
12785,
7591,
367,
536,
1654,
4237,
370,
2342,
314,
22094,
370,
272,
1347,
1844,
4412,
367,
2808,
428,
879,
18191,
14,
339,
408,
339,
4237,
63,
1364,
275,
488,
339,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
1613,
8,
38,
3298,
290,
7521,
3167,
12,
291,
2843,
826,
14155,
958,
9,
398,
3999,
275,
10821,
63,
2619,
63,
2609,
14,
2619,
63,
2609,
63,
3291,
267,
291,
14,
4758,
275,
1101,
14,
5688,
8,
3291,
12,
283,
3003,
13,
2619,
13,
2609,
358,
339,
347,
664,
63,
1782,
63,
4745,
63,
504,
63,
1200,
8,
277,
12,
22094,
63,
513,
12,
1347,
63,
513,
304,
267,
408,
1002,
2243,
4412,
687,
20934,
2784,
14,
398,
14509,
282,
9806,
769,
402,
22094,
8873,
436,
1347,
8873,
367,
1924,
428,
879,
267,
2808,
14,
267,
520,
635,
22094,
63,
513,
769,
402,
22094,
1844,
644,
3705,
267,
520,
635,
1347,
63,
513,
769,
402,
1347,
1844,
644,
3705,
267,
520,
1107,
2243,
336,
3501,
2341,
315,
2569,
1475,
288,
469,
355,
665,
23906,
536,
20020,
469,
490,
283,
17974,
63,
719,
63,
10988,
63,
513,
356,
490,
661,
18,
3273,
2869,
37,
1229,
33,
1960,
297,
283,
18,
3273,
2869,
37,
1229,
33,
10753,
7,
703,
9,
490,
283,
1375,
63,
719,
63,
10988,
63,
513,
356,
490,
661,
22589,
2869,
37,
1229,
33,
1960,
297,
283,
22589,
2869,
37,
1229,
33,
10753,
7,
703,
9,
355,
789,
288,
789,
267,
520,
3730,
2186,
1380,
282,
4237,
2435,
4514,
365,
440,
2013,
267,
315,
13069,
14,
2190,
26,
3003,
63,
18904,
63,
3892,
63,
1364,
267,
408,
267,
327,
11578,
20868,
2488,
4514,
402,
221,
20934,
11860,
6158,
267,
340,
334,
277,
14,
4758,
14,
3003,
63,
18904,
63,
3892,
63,
1364,
304,
288,
4237,
63,
1364,
275,
291,
14,
4758,
14,
3003,
63,
18904,
63,
3892,
63,
1364,
288,
5051,
14,
1757,
480,
7521,
2435,
370,
12677,
26,
298,
1993,
2071,
83,
401,
4237,
63,
1364,
9,
288,
291,
14,
3892,
63,
1364,
275,
492,
1208,
14,
646,
63,
785,
8,
355,
4237,
63,
1364,
12,
2897,
29,
277,
14,
4758,
9,
267,
587,
26,
288,
1499,
275,
3824,
7521,
2435,
440,
7526,
14,
4094,
945,
367,
298,
490,
298,
3003,
63,
18904,
63,
3892,
63,
1364,
4839,
370,
4165,
282,
13801,
298,
490,
298,
12236,
402,
314,
4237,
2435,
2685,
288,
5051,
14,
705,
8,
1328,
9,
288,
746,
1919,
14,
38,
3298,
290,
7521,
3167,
1726,
8,
1328,
9,
267,
862,
26,
288,
2243,
63,
1130,
275,
291,
14,
3892,
63,
1364,
14,
362,
63,
1782,
63,
4745,
63,
504,
63,
1200,
8,
355,
22094,
63,
513,
12,
1347,
63,
513,
9,
267,
871,
2186,
465,
325,
26,
288,
5051,
14,
1971,
1547,
906,
360,
6005,
370,
664,
2243,
4412,
687,
2784,
12459,
288,
746,
1919,
14,
38,
3298,
290,
7521,
3167,
1726,
8,
69,
9,
267,
372,
2243,
63,
1130,
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
] |
[
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,
624,
199,
1563,
12785,
7591,
367,
536,
1654,
4237,
370,
2342,
314,
22094,
370,
1347,
1844,
199,
4745,
367,
2808,
428,
879,
18191,
14,
199,
27111,
2488,
4237,
3992,
787,
1420,
370,
5669,
314,
8386,
199,
4037,
315,
642,
1021,
14,
199,
199,
624,
199,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
11258,
63,
1208,
492,
492,
1208,
199,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
73,
1085,
78,
492,
5501,
485,
906,
199,
504,
13069,
14,
2405,
492,
2897,
465,
1101,
199,
504,
13069,
14,
2619,
2609,
492,
10821,
63,
2330,
199,
504,
13069,
14,
2619,
2609,
492,
10821,
63,
2619,
63,
2609,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
481,
3298,
290,
7521,
3167,
8,
3003,
63,
2330,
14,
4161,
7844,
304,
272,
408,
1563,
12785,
7591,
14,
339,
3523,
12785,
7591,
367,
536,
1654,
4237,
370,
2342,
314,
22094,
370,
272,
1347,
1844,
4412,
367,
2808,
428,
879,
18191,
14,
339,
408,
339,
4237,
63,
1364,
275,
488,
339,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
1613,
8,
38,
3298,
290,
7521,
3167,
12,
291,
2843,
826,
14155,
958,
9,
398,
3999,
275,
10821,
63,
2619,
63,
2609,
14,
2619,
63,
2609,
63,
3291,
267,
291,
14,
4758,
275,
1101,
14,
5688,
8,
3291,
12,
283,
3003,
13,
2619,
13,
2609,
358,
339,
347,
664,
63,
1782,
63,
4745,
63,
504,
63,
1200,
8,
277,
12,
22094,
63,
513,
12,
1347,
63,
513,
304,
267,
408,
1002,
2243,
4412,
687,
20934,
2784,
14,
398,
14509,
282,
9806,
769,
402,
22094,
8873,
436,
1347,
8873,
367,
1924,
428,
879,
267,
2808,
14,
267,
520,
635,
22094,
63,
513,
769,
402,
22094,
1844,
644,
3705,
267,
520,
635,
1347,
63,
513,
769,
402,
1347,
1844,
644,
3705,
267,
520,
1107,
2243,
336,
3501,
2341,
315,
2569,
1475,
288,
469,
355,
665,
23906,
536,
20020,
469,
490,
283,
17974,
63,
719,
63,
10988,
63,
513,
356,
490,
661,
18,
3273,
2869,
37,
1229,
33,
1960,
297,
283,
18,
3273,
2869,
37,
1229,
33,
10753,
7,
703,
9,
490,
283,
1375,
63,
719,
63,
10988,
63,
513,
356,
490,
661,
22589,
2869,
37,
1229,
33,
1960,
297,
283,
22589,
2869,
37,
1229,
33,
10753,
7,
703,
9,
355,
789,
288,
789,
267,
520,
3730,
2186,
1380,
282,
4237,
2435,
4514,
365,
440,
2013,
267,
315,
13069,
14,
2190,
26,
3003,
63,
18904,
63,
3892,
63,
1364,
267,
408,
267,
327,
11578,
20868,
2488,
4514,
402,
221,
20934,
11860,
6158,
267,
340,
334,
277,
14,
4758,
14,
3003,
63,
18904,
63,
3892,
63,
1364,
304,
288,
4237,
63,
1364,
275,
291,
14,
4758,
14,
3003,
63,
18904,
63,
3892,
63,
1364,
288,
5051,
14,
1757,
480,
7521,
2435,
370,
12677,
26,
298,
1993,
2071,
83,
401,
4237,
63,
1364,
9,
288,
291,
14,
3892,
63,
1364,
275,
492,
1208,
14,
646,
63,
785,
8,
355,
4237,
63,
1364,
12,
2897,
29,
277,
14,
4758,
9,
267,
587,
26,
288,
1499,
275,
3824,
7521,
2435,
440,
7526,
14,
4094,
945,
367,
298,
490,
298,
3003,
63,
18904,
63,
3892,
63,
1364,
4839,
370,
4165,
282,
13801,
298,
490,
298,
12236,
402,
314,
4237,
2435,
2685,
288,
5051,
14,
705,
8,
1328,
9,
288,
746,
1919,
14,
38,
3298,
290,
7521,
3167,
1726,
8,
1328,
9,
267,
862,
26,
288,
2243,
63,
1130,
275,
291,
14,
3892,
63,
1364,
14,
362,
63,
1782,
63,
4745,
63,
504,
63,
1200,
8,
355,
22094,
63,
513,
12,
1347,
63,
513,
9,
267,
871,
2186,
465,
325,
26,
288,
5051,
14,
1971,
1547,
906,
360,
6005,
370,
664,
2243,
4412,
687,
2784,
12459,
288,
746,
1919,
14,
38,
3298,
290,
7521,
3167,
1726,
8,
69,
9,
267,
372,
2243,
63,
1130,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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3304
|
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from appengine_wrappers import GetAppVersion
from cache_chain_object_store import CacheChainObjectStore
from memcache_object_store import MemcacheObjectStore
from test_object_store import TestObjectStore
from persistent_object_store import PersistentObjectStore
_unspecified = object()
class ObjectStoreCreator(object):
'''Creates ObjectStores with a namespacing and behaviour configuration.
The initial configuration is specified on object store construction. When
creating ObjectStores via Create this configuration can be overridden (or
via the variants of Create which do this automatically).
'''
def __init__(self,
# TODO(kalman): rename start_dirty?
start_empty=_unspecified,
# Override for testing. A custom ObjectStore type to construct
# on Create(). Useful with TestObjectStore, for example.
store_type=None,
# Override for testing. Whether the ObjectStore type specified
# with |store_type| should be wrapped e.g. with Caching. This is
# useful to override when specific state tests/manipulations are
# being done on the underlying object store.
disable_wrappers=False):
if start_empty is _unspecified:
raise ValueError('start_empty must be specified (typically False)')
self._start_empty = start_empty
self._store_type = store_type
if disable_wrappers and store_type is None:
raise ValueError('disable_wrappers much specify a store_type')
self._disable_wrappers = disable_wrappers
@staticmethod
def ForTest(start_empty=False,
store_type=TestObjectStore,
disable_wrappers=True):
return ObjectStoreCreator(start_empty=start_empty,
store_type=store_type,
disable_wrappers=disable_wrappers)
def Create(self,
cls,
category=None,
# Override any of these for a custom configuration.
start_empty=_unspecified,
app_version=_unspecified):
# Resolve namespace components.
if start_empty is not _unspecified:
start_empty = bool(start_empty)
else:
start_empty = self._start_empty
if app_version is _unspecified:
app_version = GetAppVersion()
# Reserve & and = for namespace separators.
for component in (category, app_version):
if component and ('&' in component or '=' in component):
raise ValueError('%s cannot be used in a namespace')
namespace = '&'.join(
'%s=%s' % (key, value)
for key, value in (('class', cls.__name__),
('category', category),
('app_version', app_version))
if value is not None)
if self._disable_wrappers:
return self._store_type(namespace, start_empty=start_empty)
if self._store_type is not None:
chain = (self._store_type(namespace),)
else:
chain = (MemcacheObjectStore(namespace), PersistentObjectStore(namespace))
return CacheChainObjectStore(chain, start_empty=start_empty)
|
bsd-3-clause
|
[
3,
1898,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
504,
1145,
3908,
63,
21148,
492,
2372,
2640,
3353,
199,
504,
2581,
63,
4429,
63,
785,
63,
1617,
492,
11977,
10720,
1692,
5502,
199,
504,
21598,
63,
785,
63,
1617,
492,
30465,
1637,
1692,
5502,
199,
504,
511,
63,
785,
63,
1617,
492,
1379,
1692,
5502,
199,
504,
16149,
63,
785,
63,
1617,
492,
3492,
6082,
1692,
5502,
199,
199,
63,
324,
10085,
275,
909,
342,
199,
199,
533,
6935,
5502,
17523,
8,
785,
304,
523,
1449,
10607,
6935,
4759,
470,
543,
282,
1561,
29277,
436,
13942,
2897,
14,
819,
710,
2536,
2897,
365,
2013,
641,
909,
3877,
14538,
14,
3979,
523,
6425,
6935,
4759,
470,
4799,
2790,
642,
2897,
883,
506,
10087,
334,
269,
523,
4799,
314,
21169,
402,
2790,
1314,
886,
642,
5847,
680,
523,
1449,
523,
347,
636,
826,
721,
277,
12,
2049,
327,
3254,
8,
26446,
1237,
304,
11441,
1343,
63,
8799,
31,
2049,
1343,
63,
1667,
3699,
324,
10085,
12,
2049,
327,
11041,
367,
5343,
14,
437,
3537,
6935,
5502,
730,
370,
6982,
2049,
327,
641,
2790,
1252,
18491,
543,
1379,
1692,
5502,
12,
367,
2893,
14,
2049,
3877,
63,
466,
29,
403,
12,
2049,
327,
11041,
367,
5343,
14,
7480,
314,
6935,
5502,
730,
2013,
2049,
327,
543,
1204,
1617,
63,
466,
92,
1077,
506,
8072,
325,
14,
71,
14,
543,
445,
23302,
14,
961,
365,
2049,
327,
2997,
370,
4278,
1380,
2488,
1174,
2295,
15,
29798,
21429,
787,
2049,
327,
3769,
4224,
641,
314,
8793,
909,
3877,
14,
2049,
3507,
63,
21148,
29,
797,
304,
272,
340,
1343,
63,
1667,
365,
485,
324,
10085,
26,
489,
746,
1722,
360,
928,
63,
1667,
1471,
506,
2013,
334,
32251,
756,
5942,
272,
291,
423,
928,
63,
1667,
275,
1343,
63,
1667,
272,
291,
423,
1617,
63,
466,
275,
3877,
63,
466,
272,
340,
3507,
63,
21148,
436,
3877,
63,
466,
365,
488,
26,
489,
746,
1722,
360,
5993,
63,
21148,
8298,
4165,
282,
3877,
63,
466,
358,
272,
291,
423,
5993,
63,
21148,
275,
3507,
63,
21148,
819,
768,
4639,
523,
347,
2104,
774,
8,
928,
63,
1667,
29,
797,
12,
1598,
3877,
63,
466,
29,
774,
1692,
5502,
12,
1598,
3507,
63,
21148,
29,
549,
304,
272,
372,
6935,
5502,
17523,
8,
928,
63,
1667,
29,
928,
63,
1667,
12,
2892,
3877,
63,
466,
29,
1617,
63,
466,
12,
2892,
3507,
63,
21148,
29,
5993,
63,
21148,
9,
819,
347,
2790,
8,
277,
12,
1467,
843,
12,
1467,
4637,
29,
403,
12,
1467,
327,
11041,
1263,
402,
3520,
367,
282,
3537,
2897,
14,
1467,
1343,
63,
1667,
3699,
324,
10085,
12,
1467,
1145,
63,
1023,
3699,
324,
10085,
304,
272,
327,
31096,
3231,
7323,
14,
272,
340,
1343,
63,
1667,
365,
440,
485,
324,
10085,
26,
489,
1343,
63,
1667,
275,
2155,
8,
928,
63,
1667,
9,
272,
587,
26,
489,
1343,
63,
1667,
275,
291,
423,
928,
63,
1667,
272,
340,
1145,
63,
1023,
365,
485,
324,
10085,
26,
489,
1145,
63,
1023,
275,
2372,
2640,
3353,
342,
339,
327,
799,
4909,
1253,
436,
275,
367,
3231,
17658,
14,
272,
367,
3931,
315,
334,
3710,
12,
1145,
63,
1023,
304,
489,
340,
3931,
436,
661,
6,
7,
315,
3931,
503,
14051,
315,
3931,
304,
267,
746,
1722,
3508,
83,
3913,
506,
1202,
315,
282,
3231,
358,
339,
3231,
275,
7673,
1370,
904,
8,
267,
1543,
83,
2458,
83,
7,
450,
334,
498,
12,
574,
9,
267,
367,
790,
12,
574,
315,
13636,
533,
297,
843,
855,
354,
10139,
2574,
661,
3710,
297,
4637,
395,
2574,
661,
571,
63,
1023,
297,
1145,
63,
1023,
430,
267,
340,
574,
365,
440,
488,
9,
339,
340,
291,
423,
5993,
63,
21148,
26,
489,
372,
291,
423,
1617,
63,
466,
8,
3251,
12,
1343,
63,
1667,
29,
928,
63,
1667,
9,
339,
340,
291,
423,
1617,
63,
466,
365,
440,
488,
26,
489,
6036,
275,
334,
277,
423,
1617,
63,
466,
8,
3251,
16945,
272,
587,
26,
489,
6036,
275,
334,
14169,
1637,
1692,
5502,
8,
3251,
395,
3492,
6082,
1692,
5502,
8,
3251,
430,
272,
372,
11977,
10720,
1692,
5502,
8,
4429,
12,
1343,
63,
1667,
29,
928,
63,
1667,
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
] |
[
1898,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
504,
1145,
3908,
63,
21148,
492,
2372,
2640,
3353,
199,
504,
2581,
63,
4429,
63,
785,
63,
1617,
492,
11977,
10720,
1692,
5502,
199,
504,
21598,
63,
785,
63,
1617,
492,
30465,
1637,
1692,
5502,
199,
504,
511,
63,
785,
63,
1617,
492,
1379,
1692,
5502,
199,
504,
16149,
63,
785,
63,
1617,
492,
3492,
6082,
1692,
5502,
199,
199,
63,
324,
10085,
275,
909,
342,
199,
199,
533,
6935,
5502,
17523,
8,
785,
304,
523,
1449,
10607,
6935,
4759,
470,
543,
282,
1561,
29277,
436,
13942,
2897,
14,
819,
710,
2536,
2897,
365,
2013,
641,
909,
3877,
14538,
14,
3979,
523,
6425,
6935,
4759,
470,
4799,
2790,
642,
2897,
883,
506,
10087,
334,
269,
523,
4799,
314,
21169,
402,
2790,
1314,
886,
642,
5847,
680,
523,
1449,
523,
347,
636,
826,
721,
277,
12,
2049,
327,
3254,
8,
26446,
1237,
304,
11441,
1343,
63,
8799,
31,
2049,
1343,
63,
1667,
3699,
324,
10085,
12,
2049,
327,
11041,
367,
5343,
14,
437,
3537,
6935,
5502,
730,
370,
6982,
2049,
327,
641,
2790,
1252,
18491,
543,
1379,
1692,
5502,
12,
367,
2893,
14,
2049,
3877,
63,
466,
29,
403,
12,
2049,
327,
11041,
367,
5343,
14,
7480,
314,
6935,
5502,
730,
2013,
2049,
327,
543,
1204,
1617,
63,
466,
92,
1077,
506,
8072,
325,
14,
71,
14,
543,
445,
23302,
14,
961,
365,
2049,
327,
2997,
370,
4278,
1380,
2488,
1174,
2295,
15,
29798,
21429,
787,
2049,
327,
3769,
4224,
641,
314,
8793,
909,
3877,
14,
2049,
3507,
63,
21148,
29,
797,
304,
272,
340,
1343,
63,
1667,
365,
485,
324,
10085,
26,
489,
746,
1722,
360,
928,
63,
1667,
1471,
506,
2013,
334,
32251,
756,
5942,
272,
291,
423,
928,
63,
1667,
275,
1343,
63,
1667,
272,
291,
423,
1617,
63,
466,
275,
3877,
63,
466,
272,
340,
3507,
63,
21148,
436,
3877,
63,
466,
365,
488,
26,
489,
746,
1722,
360,
5993,
63,
21148,
8298,
4165,
282,
3877,
63,
466,
358,
272,
291,
423,
5993,
63,
21148,
275,
3507,
63,
21148,
819,
768,
4639,
523,
347,
2104,
774,
8,
928,
63,
1667,
29,
797,
12,
1598,
3877,
63,
466,
29,
774,
1692,
5502,
12,
1598,
3507,
63,
21148,
29,
549,
304,
272,
372,
6935,
5502,
17523,
8,
928,
63,
1667,
29,
928,
63,
1667,
12,
2892,
3877,
63,
466,
29,
1617,
63,
466,
12,
2892,
3507,
63,
21148,
29,
5993,
63,
21148,
9,
819,
347,
2790,
8,
277,
12,
1467,
843,
12,
1467,
4637,
29,
403,
12,
1467,
327,
11041,
1263,
402,
3520,
367,
282,
3537,
2897,
14,
1467,
1343,
63,
1667,
3699,
324,
10085,
12,
1467,
1145,
63,
1023,
3699,
324,
10085,
304,
272,
327,
31096,
3231,
7323,
14,
272,
340,
1343,
63,
1667,
365,
440,
485,
324,
10085,
26,
489,
1343,
63,
1667,
275,
2155,
8,
928,
63,
1667,
9,
272,
587,
26,
489,
1343,
63,
1667,
275,
291,
423,
928,
63,
1667,
272,
340,
1145,
63,
1023,
365,
485,
324,
10085,
26,
489,
1145,
63,
1023,
275,
2372,
2640,
3353,
342,
339,
327,
799,
4909,
1253,
436,
275,
367,
3231,
17658,
14,
272,
367,
3931,
315,
334,
3710,
12,
1145,
63,
1023,
304,
489,
340,
3931,
436,
661,
6,
7,
315,
3931,
503,
14051,
315,
3931,
304,
267,
746,
1722,
3508,
83,
3913,
506,
1202,
315,
282,
3231,
358,
339,
3231,
275,
7673,
1370,
904,
8,
267,
1543,
83,
2458,
83,
7,
450,
334,
498,
12,
574,
9,
267,
367,
790,
12,
574,
315,
13636,
533,
297,
843,
855,
354,
10139,
2574,
661,
3710,
297,
4637,
395,
2574,
661,
571,
63,
1023,
297,
1145,
63,
1023,
430,
267,
340,
574,
365,
440,
488,
9,
339,
340,
291,
423,
5993,
63,
21148,
26,
489,
372,
291,
423,
1617,
63,
466,
8,
3251,
12,
1343,
63,
1667,
29,
928,
63,
1667,
9,
339,
340,
291,
423,
1617,
63,
466,
365,
440,
488,
26,
489,
6036,
275,
334,
277,
423,
1617,
63,
466,
8,
3251,
16945,
272,
587,
26,
489,
6036,
275,
334,
14169,
1637,
1692,
5502,
8,
3251,
395,
3492,
6082,
1692,
5502,
8,
3251,
430,
272,
372,
11977,
10720,
1692,
5502,
8,
4429,
12,
1343,
63,
1667,
29,
928,
63,
1667,
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,
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,
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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
] |
moble/sympy
|
sympy/matrices/immutable.py
|
60
|
4889
|
from __future__ import print_function, division
from sympy.core import Basic, Integer, Tuple, Dict, S, sympify
from sympy.core.sympify import converter as sympify_converter
from sympy.matrices.matrices import MatrixBase
from sympy.matrices.dense import DenseMatrix
from sympy.matrices.sparse import SparseMatrix, MutableSparseMatrix
from sympy.matrices.expressions import MatrixExpr
def sympify_matrix(arg):
return arg.as_immutable()
sympify_converter[MatrixBase] = sympify_matrix
class ImmutableMatrix(MatrixExpr, DenseMatrix):
"""Create an immutable version of a matrix.
Examples
========
>>> from sympy import eye
>>> from sympy.matrices import ImmutableMatrix
>>> ImmutableMatrix(eye(3))
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
>>> _[0, 0] = 42
Traceback (most recent call last):
...
TypeError: Cannot set values of ImmutableDenseMatrix
"""
_class_priority = 8
@classmethod
def _new(cls, *args, **kwargs):
if len(args) == 1 and isinstance(args[0], ImmutableMatrix):
return args[0]
rows, cols, flat_list = cls._handle_creation_inputs(*args, **kwargs)
rows = Integer(rows)
cols = Integer(cols)
mat = Tuple(*flat_list)
return Basic.__new__(cls, rows, cols, mat)
def __new__(cls, *args, **kwargs):
return cls._new(*args, **kwargs)
@property
def shape(self):
return tuple([int(i) for i in self.args[:2]])
@property
def _mat(self):
return list(self.args[2])
def _entry(self, i, j):
return DenseMatrix.__getitem__(self, (i, j))
__getitem__ = DenseMatrix.__getitem__
def __setitem__(self, *args):
raise TypeError("Cannot set values of ImmutableMatrix")
def _eval_Eq(self, other):
"""Helper method for Equality with matrices.
Relational automatically converts matrices to ImmutableMatrix
instances, so this method only applies here. Returns True if the
matrices are definitively the same, False if they are definitively
different, and None if undetermined (e.g. if they contain Symbols).
Returning None triggers default handling of Equalities.
"""
if not hasattr(other, 'shape') or self.shape != other.shape:
return S.false
if isinstance(other, MatrixExpr) and not isinstance(
other, ImmutableMatrix):
return None
diff = self - other
return sympify(diff.is_zero)
adjoint = MatrixBase.adjoint
conjugate = MatrixBase.conjugate
# C and T are defined in MatrixExpr...I don't know why C alone
# needs to be defined here
C = MatrixBase.C
as_mutable = DenseMatrix.as_mutable
_eval_trace = DenseMatrix._eval_trace
_eval_transpose = DenseMatrix._eval_transpose
_eval_conjugate = DenseMatrix._eval_conjugate
_eval_adjoint = DenseMatrix._eval_adjoint
_eval_inverse = DenseMatrix._eval_inverse
_eval_simplify = DenseMatrix._eval_simplify
equals = DenseMatrix.equals
is_Identity = DenseMatrix.is_Identity
__add__ = MatrixBase.__add__
__radd__ = MatrixBase.__radd__
__mul__ = MatrixBase.__mul__
__rmul__ = MatrixBase.__rmul__
__pow__ = MatrixBase.__pow__
__sub__ = MatrixBase.__sub__
__rsub__ = MatrixBase.__rsub__
__neg__ = MatrixBase.__neg__
__div__ = MatrixBase.__div__
__truediv__ = MatrixBase.__truediv__
# This is included after the class definition as a workaround for issue 7213.
# See https://github.com/sympy/sympy/issues/7213
ImmutableMatrix.is_zero = DenseMatrix.is_zero
class ImmutableSparseMatrix(Basic, SparseMatrix):
"""Create an immutable version of a sparse matrix.
Examples
========
>>> from sympy import eye
>>> from sympy.matrices.immutable import ImmutableSparseMatrix
>>> ImmutableSparseMatrix(1, 1, {})
Matrix([[0]])
>>> ImmutableSparseMatrix(eye(3))
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
>>> _[0, 0] = 42
Traceback (most recent call last):
...
TypeError: Cannot set values of ImmutableSparseMatrix
>>> _.shape
(3, 3)
"""
_class_priority = 9
@classmethod
def _new(cls, *args, **kwargs):
s = MutableSparseMatrix(*args)
rows = Integer(s.rows)
cols = Integer(s.cols)
mat = Dict(s._smat)
obj = Basic.__new__(cls, rows, cols, mat)
obj.rows = s.rows
obj.cols = s.cols
obj._smat = s._smat
return obj
def __new__(cls, *args, **kwargs):
return cls._new(*args, **kwargs)
def __setitem__(self, *args):
raise TypeError("Cannot set values of ImmutableSparseMatrix")
subs = MatrixBase.subs
def __hash__(self):
return hash((type(self).__name__,) + (self.shape, tuple(self._smat)))
_eval_Eq = ImmutableMatrix._eval_Eq
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
870,
63,
1593,
12,
4629,
199,
199,
504,
5840,
14,
1018,
492,
10082,
12,
7225,
12,
11634,
12,
7448,
12,
428,
12,
25991,
199,
504,
5840,
14,
1018,
14,
1786,
18456,
492,
11109,
465,
25991,
63,
11256,
199,
199,
504,
5840,
14,
19032,
14,
19032,
492,
8449,
1563,
199,
504,
5840,
14,
19032,
14,
7253,
492,
20847,
6443,
199,
504,
5840,
14,
19032,
14,
4421,
492,
14531,
6443,
12,
19610,
8629,
6443,
199,
504,
5840,
14,
19032,
14,
15264,
492,
8449,
8561,
421,
199,
318,
25991,
63,
3642,
8,
1273,
304,
272,
372,
1680,
14,
305,
63,
17836,
342,
199,
1786,
18456,
63,
11256,
59,
6443,
1563,
61,
275,
25991,
63,
3642,
199,
199,
533,
25609,
6443,
8,
6443,
8561,
12,
20847,
6443,
304,
272,
408,
2499,
376,
17092,
1015,
402,
282,
3634,
14,
339,
6058,
272,
12655,
339,
1306,
687,
5840,
492,
25892,
272,
1306,
687,
5840,
14,
19032,
492,
25609,
6443,
272,
1306,
25609,
6443,
8,
15240,
8,
19,
430,
272,
8449,
779,
272,
359,
17,
12,
378,
12,
378,
467,
272,
359,
16,
12,
413,
12,
378,
467,
272,
359,
16,
12,
378,
12,
413,
3934,
272,
1306,
485,
59,
16,
12,
378,
61,
275,
5685,
272,
15273,
334,
2786,
8058,
1240,
2061,
304,
272,
2263,
272,
3146,
26,
18435,
663,
1338,
402,
25609,
15327,
6443,
272,
408,
339,
485,
533,
63,
6693,
275,
1695,
339,
768,
3744,
272,
347,
485,
1222,
8,
1886,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
822,
8,
589,
9,
508,
413,
436,
1228,
8,
589,
59,
16,
467,
25609,
6443,
304,
288,
372,
1249,
59,
16,
61,
267,
4730,
12,
8850,
12,
6829,
63,
513,
275,
843,
423,
2479,
63,
8782,
63,
3711,
2031,
589,
12,
1011,
958,
9,
267,
4730,
275,
7225,
8,
3838,
9,
267,
8850,
275,
7225,
8,
4574,
9,
267,
2530,
275,
11634,
2031,
7088,
63,
513,
9,
267,
372,
10082,
855,
1222,
721,
1886,
12,
4730,
12,
8850,
12,
2530,
9,
339,
347,
636,
1222,
721,
1886,
12,
627,
589,
12,
1011,
958,
304,
267,
372,
843,
423,
1222,
2031,
589,
12,
1011,
958,
9,
339,
768,
1829,
272,
347,
2215,
8,
277,
304,
267,
372,
2008,
779,
442,
8,
73,
9,
367,
284,
315,
291,
14,
589,
1491,
18,
3934,
339,
768,
1829,
272,
347,
485,
569,
8,
277,
304,
267,
372,
769,
8,
277,
14,
589,
59,
18,
566,
339,
347,
485,
2373,
8,
277,
12,
284,
12,
1335,
304,
267,
372,
20847,
6443,
855,
6095,
721,
277,
12,
334,
73,
12,
1335,
430,
339,
636,
6095,
363,
275,
20847,
6443,
855,
6095,
363,
339,
347,
636,
8617,
721,
277,
12,
627,
589,
304,
267,
746,
3146,
480,
6612,
663,
1338,
402,
25609,
6443,
531,
339,
347,
485,
2579,
63,
19706,
8,
277,
12,
1163,
304,
267,
408,
4433,
1083,
367,
221,
22977,
543,
12627,
14,
398,
9781,
6279,
5847,
15373,
12627,
370,
25609,
6443,
267,
4454,
12,
880,
642,
1083,
1454,
12966,
2348,
14,
221,
1803,
715,
340,
314,
267,
12627,
787,
347,
2730,
9462,
314,
2011,
12,
756,
340,
2985,
787,
347,
2730,
9462,
267,
3365,
12,
436,
488,
340,
625,
27248,
334,
69,
14,
71,
14,
340,
2985,
1395,
5515,
4356,
680,
267,
1432,
316,
488,
18899,
849,
7252,
402,
221,
591,
12107,
14,
398,
408,
267,
340,
440,
2688,
8,
1848,
12,
283,
1392,
358,
503,
291,
14,
1392,
1137,
1163,
14,
1392,
26,
288,
372,
428,
14,
3910,
267,
340,
1228,
8,
1848,
12,
8449,
8561,
9,
436,
440,
1228,
8,
355,
1163,
12,
25609,
6443,
304,
288,
372,
488,
267,
3915,
275,
291,
446,
1163,
267,
372,
25991,
8,
3028,
14,
374,
63,
4262,
9,
339,
24132,
275,
8449,
1563,
14,
26055,
272,
27246,
275,
8449,
1563,
14,
26000,
272,
327,
445,
436,
377,
787,
3247,
315,
8449,
8561,
1396,
41,
2793,
1133,
5715,
10842,
445,
23016,
272,
327,
4839,
370,
506,
3247,
2348,
272,
445,
275,
8449,
1563,
14,
35,
339,
465,
63,
17404,
275,
20847,
6443,
14,
305,
63,
17404,
272,
485,
2579,
63,
3446,
275,
20847,
6443,
423,
2579,
63,
3446,
272,
485,
2579,
63,
10483,
275,
20847,
6443,
423,
2579,
63,
10483,
272,
485,
2579,
63,
26000,
275,
20847,
6443,
423,
2579,
63,
26000,
272,
485,
2579,
63,
26055,
275,
20847,
6443,
423,
2579,
63,
26055,
272,
485,
2579,
63,
11668,
275,
20847,
6443,
423,
2579,
63,
11668,
272,
485,
2579,
63,
19084,
275,
20847,
6443,
423,
2579,
63,
19084,
339,
18527,
275,
20847,
6443,
14,
11332,
272,
365,
63,
10193,
275,
20847,
6443,
14,
374,
63,
10193,
339,
636,
525,
363,
275,
8449,
1563,
855,
525,
363,
272,
636,
22958,
363,
275,
8449,
1563,
855,
22958,
363,
272,
636,
3703,
363,
275,
8449,
1563,
855,
3703,
363,
272,
636,
27968,
363,
275,
8449,
1563,
855,
27968,
363,
272,
636,
8278,
363,
275,
8449,
1563,
855,
8278,
363,
272,
636,
954,
363,
275,
8449,
1563,
855,
954,
363,
272,
636,
82,
954,
363,
275,
8449,
1563,
855,
82,
954,
363,
272,
636,
8705,
363,
275,
8449,
1563,
855,
8705,
363,
272,
636,
3015,
363,
275,
8449,
1563,
855,
3015,
363,
272,
636,
22062,
363,
275,
8449,
1563,
855,
22062,
363,
199,
3,
961,
365,
5120,
2410,
314,
1021,
5492,
465,
282,
18092,
367,
4976,
1520,
14271,
14,
199,
3,
1666,
4178,
921,
5031,
14,
957,
15,
18132,
15,
18132,
15,
10115,
15,
2819,
969,
199,
29174,
6443,
14,
374,
63,
4262,
275,
20847,
6443,
14,
374,
63,
4262,
421,
199,
533,
25609,
8629,
6443,
8,
6845,
12,
14531,
6443,
304,
272,
408,
2499,
376,
17092,
1015,
402,
282,
5178,
3634,
14,
339,
6058,
272,
12655,
339,
1306,
687,
5840,
492,
25892,
272,
1306,
687,
5840,
14,
19032,
14,
17836,
492,
25609,
8629,
6443,
272,
1306,
25609,
8629,
6443,
8,
17,
12,
413,
12,
5009,
272,
8449,
4038,
16,
3934,
272,
1306,
25609,
8629,
6443,
8,
15240,
8,
19,
430,
272,
8449,
779,
272,
359,
17,
12,
378,
12,
378,
467,
272,
359,
16,
12,
413,
12,
378,
467,
272,
359,
16,
12,
378,
12,
413,
3934,
272,
1306,
485,
59,
16,
12,
378,
61,
275,
5685,
272,
15273,
334,
2786,
8058
] |
[
636,
2443,
363,
492,
870,
63,
1593,
12,
4629,
199,
199,
504,
5840,
14,
1018,
492,
10082,
12,
7225,
12,
11634,
12,
7448,
12,
428,
12,
25991,
199,
504,
5840,
14,
1018,
14,
1786,
18456,
492,
11109,
465,
25991,
63,
11256,
199,
199,
504,
5840,
14,
19032,
14,
19032,
492,
8449,
1563,
199,
504,
5840,
14,
19032,
14,
7253,
492,
20847,
6443,
199,
504,
5840,
14,
19032,
14,
4421,
492,
14531,
6443,
12,
19610,
8629,
6443,
199,
504,
5840,
14,
19032,
14,
15264,
492,
8449,
8561,
421,
199,
318,
25991,
63,
3642,
8,
1273,
304,
272,
372,
1680,
14,
305,
63,
17836,
342,
199,
1786,
18456,
63,
11256,
59,
6443,
1563,
61,
275,
25991,
63,
3642,
199,
199,
533,
25609,
6443,
8,
6443,
8561,
12,
20847,
6443,
304,
272,
408,
2499,
376,
17092,
1015,
402,
282,
3634,
14,
339,
6058,
272,
12655,
339,
1306,
687,
5840,
492,
25892,
272,
1306,
687,
5840,
14,
19032,
492,
25609,
6443,
272,
1306,
25609,
6443,
8,
15240,
8,
19,
430,
272,
8449,
779,
272,
359,
17,
12,
378,
12,
378,
467,
272,
359,
16,
12,
413,
12,
378,
467,
272,
359,
16,
12,
378,
12,
413,
3934,
272,
1306,
485,
59,
16,
12,
378,
61,
275,
5685,
272,
15273,
334,
2786,
8058,
1240,
2061,
304,
272,
2263,
272,
3146,
26,
18435,
663,
1338,
402,
25609,
15327,
6443,
272,
408,
339,
485,
533,
63,
6693,
275,
1695,
339,
768,
3744,
272,
347,
485,
1222,
8,
1886,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
822,
8,
589,
9,
508,
413,
436,
1228,
8,
589,
59,
16,
467,
25609,
6443,
304,
288,
372,
1249,
59,
16,
61,
267,
4730,
12,
8850,
12,
6829,
63,
513,
275,
843,
423,
2479,
63,
8782,
63,
3711,
2031,
589,
12,
1011,
958,
9,
267,
4730,
275,
7225,
8,
3838,
9,
267,
8850,
275,
7225,
8,
4574,
9,
267,
2530,
275,
11634,
2031,
7088,
63,
513,
9,
267,
372,
10082,
855,
1222,
721,
1886,
12,
4730,
12,
8850,
12,
2530,
9,
339,
347,
636,
1222,
721,
1886,
12,
627,
589,
12,
1011,
958,
304,
267,
372,
843,
423,
1222,
2031,
589,
12,
1011,
958,
9,
339,
768,
1829,
272,
347,
2215,
8,
277,
304,
267,
372,
2008,
779,
442,
8,
73,
9,
367,
284,
315,
291,
14,
589,
1491,
18,
3934,
339,
768,
1829,
272,
347,
485,
569,
8,
277,
304,
267,
372,
769,
8,
277,
14,
589,
59,
18,
566,
339,
347,
485,
2373,
8,
277,
12,
284,
12,
1335,
304,
267,
372,
20847,
6443,
855,
6095,
721,
277,
12,
334,
73,
12,
1335,
430,
339,
636,
6095,
363,
275,
20847,
6443,
855,
6095,
363,
339,
347,
636,
8617,
721,
277,
12,
627,
589,
304,
267,
746,
3146,
480,
6612,
663,
1338,
402,
25609,
6443,
531,
339,
347,
485,
2579,
63,
19706,
8,
277,
12,
1163,
304,
267,
408,
4433,
1083,
367,
221,
22977,
543,
12627,
14,
398,
9781,
6279,
5847,
15373,
12627,
370,
25609,
6443,
267,
4454,
12,
880,
642,
1083,
1454,
12966,
2348,
14,
221,
1803,
715,
340,
314,
267,
12627,
787,
347,
2730,
9462,
314,
2011,
12,
756,
340,
2985,
787,
347,
2730,
9462,
267,
3365,
12,
436,
488,
340,
625,
27248,
334,
69,
14,
71,
14,
340,
2985,
1395,
5515,
4356,
680,
267,
1432,
316,
488,
18899,
849,
7252,
402,
221,
591,
12107,
14,
398,
408,
267,
340,
440,
2688,
8,
1848,
12,
283,
1392,
358,
503,
291,
14,
1392,
1137,
1163,
14,
1392,
26,
288,
372,
428,
14,
3910,
267,
340,
1228,
8,
1848,
12,
8449,
8561,
9,
436,
440,
1228,
8,
355,
1163,
12,
25609,
6443,
304,
288,
372,
488,
267,
3915,
275,
291,
446,
1163,
267,
372,
25991,
8,
3028,
14,
374,
63,
4262,
9,
339,
24132,
275,
8449,
1563,
14,
26055,
272,
27246,
275,
8449,
1563,
14,
26000,
272,
327,
445,
436,
377,
787,
3247,
315,
8449,
8561,
1396,
41,
2793,
1133,
5715,
10842,
445,
23016,
272,
327,
4839,
370,
506,
3247,
2348,
272,
445,
275,
8449,
1563,
14,
35,
339,
465,
63,
17404,
275,
20847,
6443,
14,
305,
63,
17404,
272,
485,
2579,
63,
3446,
275,
20847,
6443,
423,
2579,
63,
3446,
272,
485,
2579,
63,
10483,
275,
20847,
6443,
423,
2579,
63,
10483,
272,
485,
2579,
63,
26000,
275,
20847,
6443,
423,
2579,
63,
26000,
272,
485,
2579,
63,
26055,
275,
20847,
6443,
423,
2579,
63,
26055,
272,
485,
2579,
63,
11668,
275,
20847,
6443,
423,
2579,
63,
11668,
272,
485,
2579,
63,
19084,
275,
20847,
6443,
423,
2579,
63,
19084,
339,
18527,
275,
20847,
6443,
14,
11332,
272,
365,
63,
10193,
275,
20847,
6443,
14,
374,
63,
10193,
339,
636,
525,
363,
275,
8449,
1563,
855,
525,
363,
272,
636,
22958,
363,
275,
8449,
1563,
855,
22958,
363,
272,
636,
3703,
363,
275,
8449,
1563,
855,
3703,
363,
272,
636,
27968,
363,
275,
8449,
1563,
855,
27968,
363,
272,
636,
8278,
363,
275,
8449,
1563,
855,
8278,
363,
272,
636,
954,
363,
275,
8449,
1563,
855,
954,
363,
272,
636,
82,
954,
363,
275,
8449,
1563,
855,
82,
954,
363,
272,
636,
8705,
363,
275,
8449,
1563,
855,
8705,
363,
272,
636,
3015,
363,
275,
8449,
1563,
855,
3015,
363,
272,
636,
22062,
363,
275,
8449,
1563,
855,
22062,
363,
199,
3,
961,
365,
5120,
2410,
314,
1021,
5492,
465,
282,
18092,
367,
4976,
1520,
14271,
14,
199,
3,
1666,
4178,
921,
5031,
14,
957,
15,
18132,
15,
18132,
15,
10115,
15,
2819,
969,
199,
29174,
6443,
14,
374,
63,
4262,
275,
20847,
6443,
14,
374,
63,
4262,
421,
199,
533,
25609,
8629,
6443,
8,
6845,
12,
14531,
6443,
304,
272,
408,
2499,
376,
17092,
1015,
402,
282,
5178,
3634,
14,
339,
6058,
272,
12655,
339,
1306,
687,
5840,
492,
25892,
272,
1306,
687,
5840,
14,
19032,
14,
17836,
492,
25609,
8629,
6443,
272,
1306,
25609,
8629,
6443,
8,
17,
12,
413,
12,
5009,
272,
8449,
4038,
16,
3934,
272,
1306,
25609,
8629,
6443,
8,
15240,
8,
19,
430,
272,
8449,
779,
272,
359,
17,
12,
378,
12,
378,
467,
272,
359,
16,
12,
413,
12,
378,
467,
272,
359,
16,
12,
378,
12,
413,
3934,
272,
1306,
485,
59,
16,
12,
378,
61,
275,
5685,
272,
15273,
334,
2786,
8058,
0
] |
[
1,
1,
1,
1,
1,
1,
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y/ma/tests/test_old_ma.py
|
12
|
34497
|
import numpy
import types
from numpy.ma import *
from numpy.core.numerictypes import float32
from numpy.ma.core import umath
from numpy.testing import *
import sys
if sys.version_info[0] >= 3:
from functools import reduce
pi = numpy.pi
def eq(v, w, msg=''):
result = allclose(v, w)
if not result:
print """Not eq:%s
%s
----
%s""" % (msg, str(v), str(w))
return result
class TestMa(TestCase):
def setUp (self):
x = numpy.array([1., 1., 1., -2., pi / 2.0, 4., 5., -10., 10., 1., 2., 3.])
y = numpy.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])
a10 = 10.
m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0 , 0, 1]
xm = array(x, mask=m1)
ym = array(y, mask=m2)
z = numpy.array([-.5, 0., .5, .8])
zm = array(z, mask=[0, 1, 0, 0])
xf = numpy.where(m1, 1e+20, x)
s = x.shape
xm.set_fill_value(1e+20)
self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf, s)
def test_testBasic1d(self):
"Test of basic array creation and properties in 1 dimension."
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
self.assertFalse(isMaskedArray(x))
self.assertTrue(isMaskedArray(xm))
self.assertEqual(shape(xm), s)
self.assertEqual(xm.shape, s)
self.assertEqual(xm.dtype, x.dtype)
self.assertEqual(xm.size , reduce(lambda x, y:x * y, s))
self.assertEqual(count(xm) , len(m1) - reduce(lambda x, y:x + y, m1))
self.assertTrue(eq(xm, xf))
self.assertTrue(eq(filled(xm, 1.e20), xf))
self.assertTrue(eq(x, xm))
def test_testBasic2d(self):
"Test of basic array creation and properties in 2 dimensions."
for s in [(4, 3), (6, 2)]:
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
x.shape = s
y.shape = s
xm.shape = s
ym.shape = s
xf.shape = s
self.assertFalse(isMaskedArray(x))
self.assertTrue(isMaskedArray(xm))
self.assertEqual(shape(xm), s)
self.assertEqual(xm.shape, s)
self.assertEqual(xm.size , reduce(lambda x, y:x * y, s))
self.assertEqual(count(xm) , len(m1) - reduce(lambda x, y:x + y, m1))
self.assertTrue(eq(xm, xf))
self.assertTrue(eq(filled(xm, 1.e20), xf))
self.assertTrue(eq(x, xm))
self.setUp()
def test_testArithmetic (self):
"Test of basic arithmetic."
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
a2d = array([[1, 2], [0, 4]])
a2dm = masked_array(a2d, [[0, 0], [1, 0]])
self.assertTrue(eq (a2d * a2d, a2d * a2dm))
self.assertTrue(eq (a2d + a2d, a2d + a2dm))
self.assertTrue(eq (a2d - a2d, a2d - a2dm))
for s in [(12,), (4, 3), (2, 6)]:
x = x.reshape(s)
y = y.reshape(s)
xm = xm.reshape(s)
ym = ym.reshape(s)
xf = xf.reshape(s)
self.assertTrue(eq(-x, -xm))
self.assertTrue(eq(x + y, xm + ym))
self.assertTrue(eq(x - y, xm - ym))
self.assertTrue(eq(x * y, xm * ym))
olderr = numpy.seterr(divide='ignore', invalid='ignore')
try:
self.assertTrue(eq(x / y, xm / ym))
finally:
numpy.seterr(**olderr)
self.assertTrue(eq(a10 + y, a10 + ym))
self.assertTrue(eq(a10 - y, a10 - ym))
self.assertTrue(eq(a10 * y, a10 * ym))
olderr = numpy.seterr(divide='ignore', invalid='ignore')
try:
self.assertTrue(eq(a10 / y, a10 / ym))
finally:
numpy.seterr(**olderr)
self.assertTrue(eq(x + a10, xm + a10))
self.assertTrue(eq(x - a10, xm - a10))
self.assertTrue(eq(x * a10, xm * a10))
self.assertTrue(eq(x / a10, xm / a10))
self.assertTrue(eq(x ** 2, xm ** 2))
self.assertTrue(eq(abs(x) ** 2.5, abs(xm) ** 2.5))
self.assertTrue(eq(x ** y, xm ** ym))
self.assertTrue(eq(numpy.add(x, y), add(xm, ym)))
self.assertTrue(eq(numpy.subtract(x, y), subtract(xm, ym)))
self.assertTrue(eq(numpy.multiply(x, y), multiply(xm, ym)))
olderr = numpy.seterr(divide='ignore', invalid='ignore')
try:
self.assertTrue(eq(numpy.divide(x, y), divide(xm, ym)))
finally:
numpy.seterr(**olderr)
def test_testMixedArithmetic(self):
na = numpy.array([1])
ma = array([1])
self.assertTrue(isinstance(na + ma, MaskedArray))
self.assertTrue(isinstance(ma + na, MaskedArray))
def test_testUfuncs1 (self):
"Test various functions such as sin, cos."
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
self.assertTrue (eq(numpy.cos(x), cos(xm)))
self.assertTrue (eq(numpy.cosh(x), cosh(xm)))
self.assertTrue (eq(numpy.sin(x), sin(xm)))
self.assertTrue (eq(numpy.sinh(x), sinh(xm)))
self.assertTrue (eq(numpy.tan(x), tan(xm)))
self.assertTrue (eq(numpy.tanh(x), tanh(xm)))
olderr = numpy.seterr(divide='ignore', invalid='ignore')
try:
self.assertTrue (eq(numpy.sqrt(abs(x)), sqrt(xm)))
self.assertTrue (eq(numpy.log(abs(x)), log(xm)))
self.assertTrue (eq(numpy.log10(abs(x)), log10(xm)))
finally:
numpy.seterr(**olderr)
self.assertTrue (eq(numpy.exp(x), exp(xm)))
self.assertTrue (eq(numpy.arcsin(z), arcsin(zm)))
self.assertTrue (eq(numpy.arccos(z), arccos(zm)))
self.assertTrue (eq(numpy.arctan(z), arctan(zm)))
self.assertTrue (eq(numpy.arctan2(x, y), arctan2(xm, ym)))
self.assertTrue (eq(numpy.absolute(x), absolute(xm)))
self.assertTrue (eq(numpy.equal(x, y), equal(xm, ym)))
self.assertTrue (eq(numpy.not_equal(x, y), not_equal(xm, ym)))
self.assertTrue (eq(numpy.less(x, y), less(xm, ym)))
self.assertTrue (eq(numpy.greater(x, y), greater(xm, ym)))
self.assertTrue (eq(numpy.less_equal(x, y), less_equal(xm, ym)))
self.assertTrue (eq(numpy.greater_equal(x, y), greater_equal(xm, ym)))
self.assertTrue (eq(numpy.conjugate(x), conjugate(xm)))
self.assertTrue (eq(numpy.concatenate((x, y)), concatenate((xm, ym))))
self.assertTrue (eq(numpy.concatenate((x, y)), concatenate((x, y))))
self.assertTrue (eq(numpy.concatenate((x, y)), concatenate((xm, y))))
self.assertTrue (eq(numpy.concatenate((x, y, x)), concatenate((x, ym, x))))
def test_xtestCount (self):
"Test count"
ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
if sys.version_info[0] >= 3:
self.assertTrue(isinstance(count(ott), numpy.integer))
else:
self.assertTrue(isinstance(count(ott), types.IntType))
self.assertEqual(3, count(ott))
self.assertEqual(1, count(1))
self.assertTrue (eq(0, array(1, mask=[1])))
ott = ott.reshape((2, 2))
assert_(isinstance(count(ott, 0), numpy.ndarray))
if sys.version_info[0] >= 3:
assert_(isinstance(count(ott), numpy.integer))
else:
assert_(isinstance(count(ott), types.IntType))
self.assertTrue (eq(3, count(ott)))
assert_(getmask(count(ott, 0)) is nomask)
self.assertTrue (eq([1, 2], count(ott, 0)))
def test_testMinMax (self):
"Test minimum and maximum."
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
xr = numpy.ravel(x) #max doesn't work if shaped
xmr = ravel(xm)
#true because of careful selection of data
self.assertTrue(eq(max(xr), maximum(xmr)))
#true because of careful selection of data
self.assertTrue(eq(min(xr), minimum(xmr)))
def test_testAddSumProd (self):
"Test add, sum, product."
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
self.assertTrue (eq(numpy.add.reduce(x), add.reduce(x)))
self.assertTrue (eq(numpy.add.accumulate(x), add.accumulate(x)))
self.assertTrue (eq(4, sum(array(4), axis=0)))
self.assertTrue (eq(4, sum(array(4), axis=0)))
self.assertTrue (eq(numpy.sum(x, axis=0), sum(x, axis=0)))
self.assertTrue (eq(numpy.sum(filled(xm, 0), axis=0), sum(xm, axis=0)))
self.assertTrue (eq(numpy.sum(x, 0), sum(x, 0)))
self.assertTrue (eq(numpy.product(x, axis=0), product(x, axis=0)))
self.assertTrue (eq(numpy.product(x, 0), product(x, 0)))
self.assertTrue (eq(numpy.product(filled(xm, 1), axis=0),
product(xm, axis=0)))
if len(s) > 1:
self.assertTrue (eq(numpy.concatenate((x, y), 1),
concatenate((xm, ym), 1)))
self.assertTrue (eq(numpy.add.reduce(x, 1), add.reduce(x, 1)))
self.assertTrue (eq(numpy.sum(x, 1), sum(x, 1)))
self.assertTrue (eq(numpy.product(x, 1), product(x, 1)))
def test_testCI(self):
"Test of conversions and indexing"
x1 = numpy.array([1, 2, 4, 3])
x2 = array(x1, mask=[1, 0, 0, 0])
x3 = array(x1, mask=[0, 1, 0, 1])
x4 = array(x1)
# test conversion to strings
junk, garbage = str(x2), repr(x2)
assert_(eq(numpy.sort(x1), sort(x2, fill_value=0)))
# tests of indexing
assert_(type(x2[1]) is type(x1[1]))
assert_(x1[1] == x2[1])
assert_(x2[0] is masked)
assert_(eq(x1[2], x2[2]))
assert_(eq(x1[2:5], x2[2:5]))
assert_(eq(x1[:], x2[:]))
assert_(eq(x1[1:], x3[1:]))
x1[2] = 9
x2[2] = 9
assert_(eq(x1, x2))
x1[1:3] = 99
x2[1:3] = 99
assert_(eq(x1, x2))
x2[1] = masked
assert_(eq(x1, x2))
x2[1:3] = masked
assert_(eq(x1, x2))
x2[:] = x1
x2[1] = masked
assert_(allequal(getmask(x2), array([0, 1, 0, 0])))
x3[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0])
assert_(allequal(getmask(x3), array([0, 1, 1, 0])))
x4[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0])
assert_(allequal(getmask(x4), array([0, 1, 1, 0])))
assert_(allequal(x4, array([1, 2, 3, 4])))
x1 = numpy.arange(5) * 1.0
x2 = masked_values(x1, 3.0)
assert_(eq(x1, x2))
assert_(allequal(array([0, 0, 0, 1, 0], MaskType), x2.mask))
assert_(eq(3.0, x2.fill_value))
x1 = array([1, 'hello', 2, 3], object)
x2 = numpy.array([1, 'hello', 2, 3], object)
s1 = x1[1]
s2 = x2[1]
self.assertEqual(type(s2), str)
self.assertEqual(type(s1), str)
self.assertEqual(s1, s2)
assert_(x1[1:1].shape == (0,))
def test_testCopySize(self):
"Tests of some subtle points of copying and sizing."
n = [0, 0, 1, 0, 0]
m = make_mask(n)
m2 = make_mask(m)
self.assertTrue(m is m2)
m3 = make_mask(m, copy=1)
self.assertTrue(m is not m3)
x1 = numpy.arange(5)
y1 = array(x1, mask=m)
self.assertTrue(y1._data is not x1)
self.assertTrue(allequal(x1, y1._data))
self.assertTrue(y1.mask is m)
y1a = array(y1, copy=0)
self.assertTrue(y1a.mask is y1.mask)
y2 = array(x1, mask=m, copy=0)
self.assertTrue(y2.mask is m)
self.assertTrue(y2[2] is masked)
y2[2] = 9
self.assertTrue(y2[2] is not masked)
self.assertTrue(y2.mask is not m)
self.assertTrue(allequal(y2.mask, 0))
y3 = array(x1 * 1.0, mask=m)
self.assertTrue(filled(y3).dtype is (x1 * 1.0).dtype)
x4 = arange(4)
x4[2] = masked
y4 = resize(x4, (8,))
self.assertTrue(eq(concatenate([x4, x4]), y4))
self.assertTrue(eq(getmask(y4), [0, 0, 1, 0, 0, 0, 1, 0]))
y5 = repeat(x4, (2, 2, 2, 2), axis=0)
self.assertTrue(eq(y5, [0, 0, 1, 1, 2, 2, 3, 3]))
y6 = repeat(x4, 2, axis=0)
self.assertTrue(eq(y5, y6))
def test_testPut(self):
"Test of put"
d = arange(5)
n = [0, 0, 0, 1, 1]
m = make_mask(n)
x = array(d, mask=m)
self.assertTrue(x[3] is masked)
self.assertTrue(x[4] is masked)
x[[1, 4]] = [10, 40]
self.assertTrue(x.mask is not m)
self.assertTrue(x[3] is masked)
self.assertTrue(x[4] is not masked)
self.assertTrue(eq(x, [0, 10, 2, -1, 40]))
x = array(d, mask=m)
x.put([0, 1, 2], [-1, 100, 200])
self.assertTrue(eq(x, [-1, 100, 200, 0, 0]))
self.assertTrue(x[3] is masked)
self.assertTrue(x[4] is masked)
def test_testMaPut(self):
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]
i = numpy.nonzero(m)[0]
put(ym, i, zm)
assert_(all(take(ym, i, axis=0) == zm))
def test_testOddFeatures(self):
"Test of other odd features"
x = arange(20); x = x.reshape(4, 5)
x.flat[5] = 12
assert_(x[1, 0] == 12)
z = x + 10j * x
assert_(eq(z.real, x))
assert_(eq(z.imag, 10 * x))
assert_(eq((z * conjugate(z)).real, 101 * x * x))
z.imag[...] = 0.0
x = arange(10)
x[3] = masked
assert_(str(x[3]) == str(masked))
c = x >= 8
assert_(count(where(c, masked, masked)) == 0)
assert_(shape(where(c, masked, masked)) == c.shape)
z = where(c , x, masked)
assert_(z.dtype is x.dtype)
assert_(z[3] is masked)
assert_(z[4] is masked)
assert_(z[7] is masked)
assert_(z[8] is not masked)
assert_(z[9] is not masked)
assert_(eq(x, z))
z = where(c , masked, x)
assert_(z.dtype is x.dtype)
assert_(z[3] is masked)
assert_(z[4] is not masked)
assert_(z[7] is not masked)
assert_(z[8] is masked)
assert_(z[9] is masked)
z = masked_where(c, x)
assert_(z.dtype is x.dtype)
assert_(z[3] is masked)
assert_(z[4] is not masked)
assert_(z[7] is not masked)
assert_(z[8] is masked)
assert_(z[9] is masked)
assert_(eq(x, z))
x = array([1., 2., 3., 4., 5.])
c = array([1, 1, 1, 0, 0])
x[2] = masked
z = where(c, x, -x)
assert_(eq(z, [1., 2., 0., -4., -5]))
c[0] = masked
z = where(c, x, -x)
assert_(eq(z, [1., 2., 0., -4., -5]))
assert_(z[0] is masked)
assert_(z[1] is not masked)
assert_(z[2] is masked)
assert_(eq(masked_where(greater(x, 2), x), masked_greater(x, 2)))
assert_(eq(masked_where(greater_equal(x, 2), x),
masked_greater_equal(x, 2)))
assert_(eq(masked_where(less(x, 2), x), masked_less(x, 2)))
assert_(eq(masked_where(less_equal(x, 2), x), masked_less_equal(x, 2)))
assert_(eq(masked_where(not_equal(x, 2), x), masked_not_equal(x, 2)))
assert_(eq(masked_where(equal(x, 2), x), masked_equal(x, 2)))
assert_(eq(masked_where(not_equal(x, 2), x), masked_not_equal(x, 2)))
assert_(eq(masked_inside(range(5), 1, 3), [0, 199, 199, 199, 4]))
assert_(eq(masked_outside(range(5), 1, 3), [199, 1, 2, 3, 199]))
assert_(eq(masked_inside(array(range(5), mask=[1, 0, 0, 0, 0]), 1, 3).mask,
[1, 1, 1, 1, 0]))
assert_(eq(masked_outside(array(range(5), mask=[0, 1, 0, 0, 0]), 1, 3).mask,
[1, 1, 0, 0, 1]))
assert_(eq(masked_equal(array(range(5), mask=[1, 0, 0, 0, 0]), 2).mask,
[1, 0, 1, 0, 0]))
assert_(eq(masked_not_equal(array([2, 2, 1, 2, 1], mask=[1, 0, 0, 0, 0]), 2).mask,
[1, 0, 1, 0, 1]))
assert_(eq(masked_where([1, 1, 0, 0, 0], [1, 2, 3, 4, 5]), [99, 99, 3, 4, 5]))
atest = ones((10, 10, 10), dtype=float32)
btest = zeros(atest.shape, MaskType)
ctest = masked_where(btest, atest)
assert_(eq(atest, ctest))
z = choose(c, (-x, x))
assert_(eq(z, [1., 2., 0., -4., -5]))
assert_(z[0] is masked)
assert_(z[1] is not masked)
assert_(z[2] is masked)
x = arange(6)
x[5] = masked
y = arange(6) * 10
y[2] = masked
c = array([1, 1, 1, 0, 0, 0], mask=[1, 0, 0, 0, 0, 0])
cm = c.filled(1)
z = where(c, x, y)
zm = where(cm, x, y)
assert_(eq(z, zm))
assert_(getmask(zm) is nomask)
assert_(eq(zm, [0, 1, 2, 30, 40, 50]))
z = where(c, masked, 1)
assert_(eq(z, [99, 99, 99, 1, 1, 1]))
z = where(c, 1, masked)
assert_(eq(z, [99, 1, 1, 99, 99, 99]))
def test_testMinMax(self):
"Test of minumum, maximum."
assert_(eq(minimum([1, 2, 3], [4, 0, 9]), [1, 0, 3]))
assert_(eq(maximum([1, 2, 3], [4, 0, 9]), [4, 2, 9]))
x = arange(5)
y = arange(5) - 2
x[3] = masked
y[0] = masked
assert_(eq(minimum(x, y), where(less(x, y), x, y)))
assert_(eq(maximum(x, y), where(greater(x, y), x, y)))
assert_(minimum(x) == 0)
assert_(maximum(x) == 4)
def test_testTakeTransposeInnerOuter(self):
"Test of take, transpose, inner, outer products"
x = arange(24)
y = numpy.arange(24)
x[5:6] = masked
x = x.reshape(2, 3, 4)
y = y.reshape(2, 3, 4)
assert_(eq(numpy.transpose(y, (2, 0, 1)), transpose(x, (2, 0, 1))))
assert_(eq(numpy.take(y, (2, 0, 1), 1), take(x, (2, 0, 1), 1)))
assert_(eq(numpy.inner(filled(x, 0), filled(y, 0)),
inner(x, y)))
assert_(eq(numpy.outer(filled(x, 0), filled(y, 0)),
outer(x, y)))
y = array(['abc', 1, 'def', 2, 3], object)
y[2] = masked
t = take(y, [0, 3, 4])
assert_(t[0] == 'abc')
assert_(t[1] == 2)
assert_(t[2] == 3)
def test_testInplace(self):
"""Test of inplace operations and rich comparisons"""
y = arange(10)
x = arange(10)
xm = arange(10)
xm[2] = masked
x += 1
assert_(eq(x, y + 1))
xm += 1
assert_(eq(x, y + 1))
x = arange(10)
xm = arange(10)
xm[2] = masked
x -= 1
assert_(eq(x, y - 1))
xm -= 1
assert_(eq(xm, y - 1))
x = arange(10) * 1.0
xm = arange(10) * 1.0
xm[2] = masked
x *= 2.0
assert_(eq(x, y * 2))
xm *= 2.0
assert_(eq(xm, y * 2))
x = arange(10) * 2
xm = arange(10)
xm[2] = masked
x //= 2
assert_(eq(x, y))
xm //= 2
assert_(eq(x, y))
x = arange(10) * 1.0
xm = arange(10) * 1.0
xm[2] = masked
x /= 2.0
assert_(eq(x, y / 2.0))
xm /= arange(10)
assert_(eq(xm, ones((10,))))
x = arange(10).astype(float32)
xm = arange(10)
xm[2] = masked
x += 1.
assert_(eq(x, y + 1.))
def test_testPickle(self):
"Test of pickling"
import pickle
x = arange(12)
x[4:10:2] = masked
x = x.reshape(4, 3)
s = pickle.dumps(x)
y = pickle.loads(s)
assert_(eq(x, y))
def test_testMasked(self):
"Test of masked element"
xx = arange(6)
xx[1] = masked
self.assertTrue(str(masked) == '--')
self.assertTrue(xx[1] is masked)
self.assertEqual(filled(xx[1], 0), 0)
# don't know why these should raise an exception...
#self.assertRaises(Exception, lambda x,y: x+y, masked, masked)
#self.assertRaises(Exception, lambda x,y: x+y, masked, 2)
#self.assertRaises(Exception, lambda x,y: x+y, masked, xx)
#self.assertRaises(Exception, lambda x,y: x+y, xx, masked)
def test_testAverage1(self):
"Test of average."
ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
self.assertTrue(eq(2.0, average(ott, axis=0)))
self.assertTrue(eq(2.0, average(ott, weights=[1., 1., 2., 1.])))
result, wts = average(ott, weights=[1., 1., 2., 1.], returned=1)
self.assertTrue(eq(2.0, result))
self.assertTrue(wts == 4.0)
ott[:] = masked
self.assertTrue(average(ott, axis=0) is masked)
ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
ott = ott.reshape(2, 2)
ott[:, 1] = masked
self.assertTrue(eq(average(ott, axis=0), [2.0, 0.0]))
self.assertTrue(average(ott, axis=1)[0] is masked)
self.assertTrue(eq([2., 0.], average(ott, axis=0)))
result, wts = average(ott, axis=0, returned=1)
self.assertTrue(eq(wts, [1., 0.]))
def test_testAverage2(self):
"More tests of average."
w1 = [0, 1, 1, 1, 1, 0]
w2 = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1]]
x = arange(6)
self.assertTrue(allclose(average(x, axis=0), 2.5))
self.assertTrue(allclose(average(x, axis=0, weights=w1), 2.5))
y = array([arange(6), 2.0 * arange(6)])
self.assertTrue(allclose(average(y, None),
numpy.add.reduce(numpy.arange(6)) * 3. / 12.))
self.assertTrue(allclose(average(y, axis=0), numpy.arange(6) * 3. / 2.))
self.assertTrue(allclose(average(y, axis=1),
[average(x, axis=0), average(x, axis=0) * 2.0]))
self.assertTrue(allclose(average(y, None, weights=w2), 20. / 6.))
self.assertTrue(allclose(average(y, axis=0, weights=w2),
[0., 1., 2., 3., 4., 10.]))
self.assertTrue(allclose(average(y, axis=1),
[average(x, axis=0), average(x, axis=0) * 2.0]))
m1 = zeros(6)
m2 = [0, 0, 1, 1, 0, 0]
m3 = [[0, 0, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0]]
m4 = ones(6)
m5 = [0, 1, 1, 1, 1, 1]
self.assertTrue(allclose(average(masked_array(x, m1), axis=0), 2.5))
self.assertTrue(allclose(average(masked_array(x, m2), axis=0), 2.5))
self.assertTrue(average(masked_array(x, m4), axis=0) is masked)
self.assertEqual(average(masked_array(x, m5), axis=0), 0.0)
self.assertEqual(count(average(masked_array(x, m4), axis=0)), 0)
z = masked_array(y, m3)
self.assertTrue(allclose(average(z, None), 20. / 6.))
self.assertTrue(allclose(average(z, axis=0), [0., 1., 99., 99., 4.0, 7.5]))
self.assertTrue(allclose(average(z, axis=1), [2.5, 5.0]))
self.assertTrue(allclose(average(z, axis=0, weights=w2),
[0., 1., 99., 99., 4.0, 10.0]))
a = arange(6)
b = arange(6) * 3
r1, w1 = average([[a, b], [b, a]], axis=1, returned=1)
self.assertEqual(shape(r1) , shape(w1))
self.assertEqual(r1.shape , w1.shape)
r2, w2 = average(ones((2, 2, 3)), axis=0, weights=[3, 1], returned=1)
self.assertEqual(shape(w2) , shape(r2))
r2, w2 = average(ones((2, 2, 3)), returned=1)
self.assertEqual(shape(w2) , shape(r2))
r2, w2 = average(ones((2, 2, 3)), weights=ones((2, 2, 3)), returned=1)
self.assertTrue(shape(w2) == shape(r2))
a2d = array([[1, 2], [0, 4]], float)
a2dm = masked_array(a2d, [[0, 0], [1, 0]])
a2da = average(a2d, axis=0)
self.assertTrue(eq (a2da, [0.5, 3.0]))
a2dma = average(a2dm, axis=0)
self.assertTrue(eq(a2dma, [1.0, 3.0]))
a2dma = average(a2dm, axis=None)
self.assertTrue(eq(a2dma, 7. / 3.))
a2dma = average(a2dm, axis=1)
self.assertTrue(eq(a2dma, [1.5, 4.0]))
def test_testToPython(self):
self.assertEqual(1, int(array(1)))
self.assertEqual(1.0, float(array(1)))
self.assertEqual(1, int(array([[[1]]])))
self.assertEqual(1.0, float(array([[1]])))
self.assertRaises(TypeError, float, array([1, 1]))
self.assertRaises(ValueError, bool, array([0, 1]))
self.assertRaises(ValueError, bool, array([0, 0], mask=[0, 1]))
def test_testScalarArithmetic(self):
xm = array(0, mask=1)
#TODO FIXME: Find out what the following raises a warning in r8247
err_status = numpy.geterr()
try:
numpy.seterr(divide='ignore')
self.assertTrue((1 / array(0)).mask)
finally:
numpy.seterr(**err_status)
self.assertTrue((1 + xm).mask)
self.assertTrue((-xm).mask)
self.assertTrue((-xm).mask)
self.assertTrue(maximum(xm, xm).mask)
self.assertTrue(minimum(xm, xm).mask)
self.assertTrue(xm.filled().dtype is xm._data.dtype)
x = array(0, mask=0)
self.assertTrue(x.filled() == x._data)
self.assertEqual(str(xm), str(masked_print_option))
def test_testArrayMethods(self):
a = array([1, 3, 2])
b = array([1, 3, 2], mask=[1, 0, 1])
self.assertTrue(eq(a.any(), a._data.any()))
self.assertTrue(eq(a.all(), a._data.all()))
self.assertTrue(eq(a.argmax(), a._data.argmax()))
self.assertTrue(eq(a.argmin(), a._data.argmin()))
self.assertTrue(eq(a.choose(0, 1, 2, 3, 4), a._data.choose(0, 1, 2, 3, 4)))
self.assertTrue(eq(a.compress([1, 0, 1]), a._data.compress([1, 0, 1])))
self.assertTrue(eq(a.conj(), a._data.conj()))
self.assertTrue(eq(a.conjugate(), a._data.conjugate()))
m = array([[1, 2], [3, 4]])
self.assertTrue(eq(m.diagonal(), m._data.diagonal()))
self.assertTrue(eq(a.sum(), a._data.sum()))
self.assertTrue(eq(a.take([1, 2]), a._data.take([1, 2])))
self.assertTrue(eq(m.transpose(), m._data.transpose()))
def test_testArrayAttributes(self):
a = array([1, 3, 2])
b = array([1, 3, 2], mask=[1, 0, 1])
self.assertEqual(a.ndim, 1)
def test_testAPI(self):
self.assertFalse([m for m in dir(numpy.ndarray)
if m not in dir(MaskedArray) and not m.startswith('_')])
def test_testSingleElementSubscript(self):
a = array([1, 3, 2])
b = array([1, 3, 2], mask=[1, 0, 1])
self.assertEqual(a[0].shape, ())
self.assertEqual(b[0].shape, ())
self.assertEqual(b[1].shape, ())
class TestUfuncs(TestCase):
def setUp(self):
self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6),
array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),)
def test_testUfuncRegression(self):
f_invalid_ignore = ['sqrt', 'arctanh', 'arcsin', 'arccos',
'arccosh', 'arctanh', 'log', 'log10', 'divide',
'true_divide', 'floor_divide', 'remainder', 'fmod']
for f in ['sqrt', 'log', 'log10', 'exp', 'conjugate',
'sin', 'cos', 'tan',
'arcsin', 'arccos', 'arctan',
'sinh', 'cosh', 'tanh',
'arcsinh',
'arccosh',
'arctanh',
'absolute', 'fabs', 'negative',
# 'nonzero', 'around',
'floor', 'ceil',
# 'sometrue', 'alltrue',
'logical_not',
'add', 'subtract', 'multiply',
'divide', 'true_divide', 'floor_divide',
'remainder', 'fmod', 'hypot', 'arctan2',
'equal', 'not_equal', 'less_equal', 'greater_equal',
'less', 'greater',
'logical_and', 'logical_or', 'logical_xor',
]:
try:
uf = getattr(umath, f)
except AttributeError:
uf = getattr(fromnumeric, f)
mf = getattr(numpy.ma, f)
args = self.d[:uf.nin]
olderr = numpy.geterr()
try:
if f in f_invalid_ignore:
numpy.seterr(invalid='ignore')
if f in ['arctanh', 'log', 'log10']:
numpy.seterr(divide='ignore')
ur = uf(*args)
mr = mf(*args)
finally:
numpy.seterr(**olderr)
self.assertTrue(eq(ur.filled(0), mr.filled(0), f))
self.assertTrue(eqmask(ur.mask, mr.mask))
def test_reduce(self):
a = self.d[0]
self.assertFalse(alltrue(a, axis=0))
self.assertTrue(sometrue(a, axis=0))
self.assertEqual(sum(a[:3], axis=0), 0)
self.assertEqual(product(a, axis=0), 0)
def test_minmax(self):
a = arange(1, 13).reshape(3, 4)
amask = masked_where(a < 5, a)
self.assertEqual(amask.max(), a.max())
self.assertEqual(amask.min(), 5)
self.assertTrue((amask.max(0) == a.max(0)).all())
self.assertTrue((amask.min(0) == [5, 6, 7, 8]).all())
self.assertTrue(amask.max(1)[0].mask)
self.assertTrue(amask.min(1)[0].mask)
def test_nonzero(self):
for t in "?bhilqpBHILQPfdgFDGO":
x = array([1, 0, 2, 0], mask=[0, 0, 1, 1])
self.assertTrue(eq(nonzero(x), [0]))
class TestArrayMethods(TestCase):
def setUp(self):
x = numpy.array([ 8.375, 7.545, 8.828, 8.5 , 1.757, 5.928,
8.43 , 7.78 , 9.865, 5.878, 8.979, 4.732,
3.012, 6.022, 5.095, 3.116, 5.238, 3.957,
6.04 , 9.63 , 7.712, 3.382, 4.489, 6.479,
7.189, 9.645, 5.395, 4.961, 9.894, 2.893,
7.357, 9.828, 6.272, 3.758, 6.693, 0.993])
X = x.reshape(6, 6)
XX = x.reshape(3, 2, 2, 3)
m = numpy.array([0, 1, 0, 1, 0, 0,
1, 0, 1, 1, 0, 1,
0, 0, 0, 1, 0, 1,
0, 0, 0, 1, 1, 1,
1, 0, 0, 1, 0, 0,
0, 0, 1, 0, 1, 0])
mx = array(data=x, mask=m)
mX = array(data=X, mask=m.reshape(X.shape))
mXX = array(data=XX, mask=m.reshape(XX.shape))
m2 = numpy.array([1, 1, 0, 1, 0, 0,
1, 1, 1, 1, 0, 1,
0, 0, 1, 1, 0, 1,
0, 0, 0, 1, 1, 1,
1, 0, 0, 1, 1, 0,
0, 0, 1, 0, 1, 1])
m2x = array(data=x, mask=m2)
m2X = array(data=X, mask=m2.reshape(X.shape))
m2XX = array(data=XX, mask=m2.reshape(XX.shape))
self.d = (x, X, XX, m, mx, mX, mXX)
#------------------------------------------------------
def test_trace(self):
(x, X, XX, m, mx, mX, mXX,) = self.d
mXdiag = mX.diagonal()
self.assertEqual(mX.trace(), mX.diagonal().compressed().sum())
self.assertTrue(eq(mX.trace(),
X.trace() - sum(mXdiag.mask * X.diagonal(), axis=0)))
def test_clip(self):
(x, X, XX, m, mx, mX, mXX,) = self.d
clipped = mx.clip(2, 8)
self.assertTrue(eq(clipped.mask, mx.mask))
self.assertTrue(eq(clipped._data, x.clip(2, 8)))
self.assertTrue(eq(clipped._data, mx._data.clip(2, 8)))
def test_ptp(self):
(x, X, XX, m, mx, mX, mXX,) = self.d
(n, m) = X.shape
self.assertEqual(mx.ptp(), mx.compressed().ptp())
rows = numpy.zeros(n, numpy.float_)
cols = numpy.zeros(m, numpy.float_)
for k in range(m):
cols[k] = mX[:, k].compressed().ptp()
for k in range(n):
rows[k] = mX[k].compressed().ptp()
self.assertTrue(eq(mX.ptp(0), cols))
self.assertTrue(eq(mX.ptp(1), rows))
def test_swapaxes(self):
(x, X, XX, m, mx, mX, mXX,) = self.d
mXswapped = mX.swapaxes(0, 1)
self.assertTrue(eq(mXswapped[-1], mX[:, -1]))
mXXswapped = mXX.swapaxes(0, 2)
self.assertEqual(mXXswapped.shape, (2, 2, 3, 3))
def test_cumprod(self):
(x, X, XX, m, mx, mX, mXX,) = self.d
mXcp = mX.cumprod(0)
self.assertTrue(eq(mXcp._data, mX.filled(1).cumprod(0)))
mXcp = mX.cumprod(1)
self.assertTrue(eq(mXcp._data, mX.filled(1).cumprod(1)))
def test_cumsum(self):
(x, X, XX, m, mx, mX, mXX,) = self.d
mXcp = mX.cumsum(0)
self.assertTrue(eq(mXcp._data, mX.filled(0).cumsum(0)))
mXcp = mX.cumsum(1)
self.assertTrue(eq(mXcp._data, mX.filled(0).cumsum(1)))
def test_varstd(self):
(x, X, XX, m, mx, mX, mXX,) = self.d
self.assertTrue(eq(mX.var(axis=None), mX.compressed().var()))
self.assertTrue(eq(mX.std(axis=None), mX.compressed().std()))
self.assertTrue(eq(mXX.var(axis=3).shape, XX.var(axis=3).shape))
self.assertTrue(eq(mX.var().shape, X.var().shape))
(mXvar0, mXvar1) = (mX.var(axis=0), mX.var(axis=1))
for k in range(6):
self.assertTrue(eq(mXvar1[k], mX[k].compressed().var()))
self.assertTrue(eq(mXvar0[k], mX[:, k].compressed().var()))
self.assertTrue(eq(numpy.sqrt(mXvar0[k]),
mX[:, k].compressed().std()))
def eqmask(m1, m2):
if m1 is nomask:
return m2 is nomask
if m2 is nomask:
return m1 is nomask
return (m1 == m2).all()
#def timingTest():
# for f in [testf, testinplace]:
# for n in [1000,10000,50000]:
# t = testta(n, f)
# t1 = testtb(n, f)
# t2 = testtc(n, f)
# print f.test_name
# print """\
#n = %7d
#numpy time (ms) %6.1f
#MA maskless ratio %6.1f
#MA masked ratio %6.1f
#""" % (n, t*1000.0, t1/t, t2/t)
#def testta(n, f):
# x=numpy.arange(n) + 1.0
# tn0 = time.time()
# z = f(x)
# return time.time() - tn0
#def testtb(n, f):
# x=arange(n) + 1.0
# tn0 = time.time()
# z = f(x)
# return time.time() - tn0
#def testtc(n, f):
# x=arange(n) + 1.0
# x[0] = masked
# tn0 = time.time()
# z = f(x)
# return time.time() - tn0
#def testf(x):
# for i in range(25):
# y = x **2 + 2.0 * x - 1.0
# w = x **2 + 1.0
# z = (y / w) ** 2
# return z
#testf.test_name = 'Simple arithmetic'
#def testinplace(x):
# for i in range(25):
# y = x**2
# y += 2.0*x
# y -= 1.0
# y /= x
# return y
#testinplace.test_name = 'Inplace operations'
if __name__ == "__main__":
run_module_suite()
|
bsd-3-clause
|
[
646,
2680,
199,
646,
2943,
199,
504,
2680,
14,
391,
492,
627,
199,
504,
2680,
14,
1018,
14,
10563,
322,
9798,
492,
2069,
708,
199,
504,
2680,
14,
391,
14,
1018,
492,
399,
3442,
199,
504,
2680,
14,
4776,
492,
627,
199,
199,
646,
984,
199,
692,
984,
14,
1023,
63,
815,
59,
16,
61,
2356,
650,
26,
272,
687,
9143,
492,
7114,
199,
199,
1038,
275,
2680,
14,
1038,
199,
318,
3850,
8,
86,
12,
336,
12,
1499,
9280,
272,
754,
275,
1006,
1600,
8,
86,
12,
336,
9,
272,
340,
440,
754,
26,
267,
870,
408,
1763,
3850,
2689,
83,
199,
5,
83,
199,
375,
199,
5,
83,
624,
450,
334,
1328,
12,
620,
8,
86,
395,
620,
8,
87,
430,
272,
372,
754,
199,
199,
533,
1379,
11903,
8,
1746,
304,
272,
347,
3613,
334,
277,
304,
267,
671,
275,
2680,
14,
1144,
779,
17,
2020,
413,
2020,
413,
2020,
446,
18,
2020,
6682,
1182,
499,
14,
16,
12,
841,
2020,
959,
2020,
446,
709,
2020,
1616,
2020,
413,
2020,
499,
2020,
650,
14444,
267,
612,
275,
2680,
14,
1144,
779,
21,
2020,
378,
2020,
650,
2020,
499,
2020,
446,
17,
2020,
446,
20,
2020,
378,
2020,
446,
709,
2020,
1616,
2020,
413,
2020,
378,
2020,
650,
14444,
267,
282,
709,
275,
1616,
14,
267,
333,
17,
275,
359,
17,
12,
378,
12,
378,
12,
378,
12,
378,
12,
378,
12,
413,
12,
378,
12,
378,
12,
378,
12,
378,
12,
378,
61,
267,
333,
18,
275,
359,
16,
12,
378,
12,
413,
12,
378,
12,
378,
12,
413,
12,
413,
12,
378,
12,
378,
12,
378,
2360,
378,
12,
413,
61,
267,
17725,
275,
1625,
8,
88,
12,
3656,
29,
77,
17,
9,
267,
612,
77,
275,
1625,
8,
89,
12,
3656,
29,
77,
18,
9,
267,
1315,
275,
2680,
14,
1144,
11468,
14,
21,
12,
378,
2020,
1275,
21,
12,
1275,
24,
566,
267,
1315,
77,
275,
1625,
8,
90,
12,
3656,
1524,
16,
12,
413,
12,
378,
12,
378,
566,
267,
27366,
275,
2680,
14,
4509,
8,
77,
17,
12,
413,
69,
11,
1165,
12,
671,
9,
267,
308,
275,
671,
14,
1392,
267,
17725,
14,
409,
63,
4498,
63,
585,
8,
17,
69,
11,
1165,
9,
267,
291,
14,
68,
275,
334,
88,
12,
612,
12,
282,
709,
12,
333,
17,
12,
333,
18,
12,
17725,
12,
612,
77,
12,
1315,
12,
1315,
77,
12,
27366,
12,
308,
9,
339,
347,
511,
63,
396,
6845,
17,
68,
8,
277,
304,
267,
298,
774,
402,
5678,
1625,
7143,
436,
4382,
315,
413,
6240,
2122,
267,
334,
88,
12,
612,
12,
282,
709,
12,
333,
17,
12,
333,
18,
12,
17725,
12,
612,
77,
12,
1315,
12,
1315,
77,
12,
27366,
12,
308,
9,
275,
291,
14,
68,
267,
291,
14,
3334,
8,
374,
5144,
20999,
8,
88,
430,
267,
291,
14,
1815,
8,
374,
5144,
20999,
8,
10198,
430,
267,
291,
14,
629,
8,
1392,
8,
10198,
395,
308,
9,
267,
291,
14,
629,
8,
10198,
14,
1392,
12,
308,
9,
267,
291,
14,
629,
8,
10198,
14,
2271,
12,
671,
14,
2271,
9,
267,
291,
14,
629,
8,
10198,
14,
890,
2360,
7114,
8,
2734,
671,
12,
612,
26,
88,
627,
612,
12,
308,
430,
267,
291,
14,
629,
8,
835,
8,
10198,
9,
2360,
822,
8,
77,
17,
9,
446,
7114,
8,
2734,
671,
12,
612,
26,
88,
435,
612,
12,
333,
17,
430,
267,
291,
14,
1815,
8,
4077,
8,
10198,
12,
27366,
430,
267,
291,
14,
1815,
8,
4077,
8,
17647,
8,
10198,
12,
413,
14,
69,
1165,
395,
27366,
430,
267,
291,
14,
1815,
8,
4077,
8,
88,
12,
17725,
430,
339,
347,
511,
63,
396,
6845,
18,
68,
8,
277,
304,
267,
298,
774,
402,
5678,
1625,
7143,
436,
4382,
315,
499,
7365,
2122,
267,
367,
308,
315,
3842,
20,
12,
650,
395,
334,
22,
12,
499,
19532,
288,
334,
88,
12,
612,
12,
282,
709,
12,
333,
17,
12,
333,
18,
12,
17725,
12,
612,
77,
12,
1315,
12,
1315,
77,
12,
27366,
12,
308,
9,
275,
291,
14,
68,
288,
671,
14,
1392,
275,
308,
288,
612,
14,
1392,
275,
308,
288,
17725,
14,
1392,
275,
308,
288,
612,
77,
14,
1392,
275,
308,
288,
27366,
14,
1392,
275,
308,
953,
291,
14,
3334,
8,
374,
5144,
20999,
8,
88,
430,
288,
291,
14,
1815,
8,
374,
5144,
20999,
8,
10198,
430,
288,
291,
14,
629,
8,
1392,
8,
10198,
395,
308,
9,
288,
291,
14,
629,
8,
10198,
14,
1392,
12,
308,
9,
288,
291,
14,
629,
8,
10198,
14,
890,
2360,
7114,
8,
2734,
671,
12,
612,
26,
88,
627,
612,
12,
308,
430,
288,
291,
14,
629,
8,
835,
8,
10198,
9,
2360,
822,
8,
77,
17,
9,
446,
7114,
8,
2734,
671,
12,
612,
26,
88,
435,
612,
12,
333,
17,
430,
288,
291,
14,
1815,
8,
4077,
8,
10198,
12,
27366,
430,
288,
291,
14,
1815,
8,
4077,
8,
17647,
8,
10198,
12,
413,
14,
69,
1165,
395,
27366,
430,
288,
291,
14,
1815,
8,
4077,
8,
88,
12,
17725,
430,
288,
291,
14,
5996,
342,
339,
347,
511,
63,
396,
26291,
18764,
334,
277,
304,
267,
298,
774,
402,
5678,
24166,
2122,
267,
334,
88,
12,
612,
12,
282,
709,
12,
333,
17,
12,
333,
18,
12,
17725,
12,
612,
77,
12,
1315,
12,
1315,
77,
12,
27366,
12,
308,
9,
275,
291,
14,
68,
267,
282,
18,
68,
275,
1625,
4038,
17,
12,
499,
467,
359,
16,
12,
841,
3934,
267,
282,
18,
6428,
275,
9742,
63,
1144,
8,
65,
18,
68,
12,
3474,
16,
12,
378,
467,
359,
17,
12,
378,
3934,
267,
291,
14,
1815,
8,
4077,
334,
65,
18,
68,
627,
282,
18,
68,
12,
282,
18,
68,
627,
282,
18,
6428,
430,
267,
291,
14,
1815,
8,
4077,
334,
65,
18,
68,
435,
282,
18,
68,
12,
282,
18,
68,
435,
282,
18,
6428,
430,
267,
291,
14,
1815,
8,
4077,
334,
65,
18,
68,
446,
282,
18,
68,
12,
282,
18,
68,
446,
282,
18,
6428,
430,
267,
367,
308,
315,
3842,
713,
4706,
334,
20,
12,
650
] |
[
2680,
199,
646,
2943,
199,
504,
2680,
14,
391,
492,
627,
199,
504,
2680,
14,
1018,
14,
10563,
322,
9798,
492,
2069,
708,
199,
504,
2680,
14,
391,
14,
1018,
492,
399,
3442,
199,
504,
2680,
14,
4776,
492,
627,
199,
199,
646,
984,
199,
692,
984,
14,
1023,
63,
815,
59,
16,
61,
2356,
650,
26,
272,
687,
9143,
492,
7114,
199,
199,
1038,
275,
2680,
14,
1038,
199,
318,
3850,
8,
86,
12,
336,
12,
1499,
9280,
272,
754,
275,
1006,
1600,
8,
86,
12,
336,
9,
272,
340,
440,
754,
26,
267,
870,
408,
1763,
3850,
2689,
83,
199,
5,
83,
199,
375,
199,
5,
83,
624,
450,
334,
1328,
12,
620,
8,
86,
395,
620,
8,
87,
430,
272,
372,
754,
199,
199,
533,
1379,
11903,
8,
1746,
304,
272,
347,
3613,
334,
277,
304,
267,
671,
275,
2680,
14,
1144,
779,
17,
2020,
413,
2020,
413,
2020,
446,
18,
2020,
6682,
1182,
499,
14,
16,
12,
841,
2020,
959,
2020,
446,
709,
2020,
1616,
2020,
413,
2020,
499,
2020,
650,
14444,
267,
612,
275,
2680,
14,
1144,
779,
21,
2020,
378,
2020,
650,
2020,
499,
2020,
446,
17,
2020,
446,
20,
2020,
378,
2020,
446,
709,
2020,
1616,
2020,
413,
2020,
378,
2020,
650,
14444,
267,
282,
709,
275,
1616,
14,
267,
333,
17,
275,
359,
17,
12,
378,
12,
378,
12,
378,
12,
378,
12,
378,
12,
413,
12,
378,
12,
378,
12,
378,
12,
378,
12,
378,
61,
267,
333,
18,
275,
359,
16,
12,
378,
12,
413,
12,
378,
12,
378,
12,
413,
12,
413,
12,
378,
12,
378,
12,
378,
2360,
378,
12,
413,
61,
267,
17725,
275,
1625,
8,
88,
12,
3656,
29,
77,
17,
9,
267,
612,
77,
275,
1625,
8,
89,
12,
3656,
29,
77,
18,
9,
267,
1315,
275,
2680,
14,
1144,
11468,
14,
21,
12,
378,
2020,
1275,
21,
12,
1275,
24,
566,
267,
1315,
77,
275,
1625,
8,
90,
12,
3656,
1524,
16,
12,
413,
12,
378,
12,
378,
566,
267,
27366,
275,
2680,
14,
4509,
8,
77,
17,
12,
413,
69,
11,
1165,
12,
671,
9,
267,
308,
275,
671,
14,
1392,
267,
17725,
14,
409,
63,
4498,
63,
585,
8,
17,
69,
11,
1165,
9,
267,
291,
14,
68,
275,
334,
88,
12,
612,
12,
282,
709,
12,
333,
17,
12,
333,
18,
12,
17725,
12,
612,
77,
12,
1315,
12,
1315,
77,
12,
27366,
12,
308,
9,
339,
347,
511,
63,
396,
6845,
17,
68,
8,
277,
304,
267,
298,
774,
402,
5678,
1625,
7143,
436,
4382,
315,
413,
6240,
2122,
267,
334,
88,
12,
612,
12,
282,
709,
12,
333,
17,
12,
333,
18,
12,
17725,
12,
612,
77,
12,
1315,
12,
1315,
77,
12,
27366,
12,
308,
9,
275,
291,
14,
68,
267,
291,
14,
3334,
8,
374,
5144,
20999,
8,
88,
430,
267,
291,
14,
1815,
8,
374,
5144,
20999,
8,
10198,
430,
267,
291,
14,
629,
8,
1392,
8,
10198,
395,
308,
9,
267,
291,
14,
629,
8,
10198,
14,
1392,
12,
308,
9,
267,
291,
14,
629,
8,
10198,
14,
2271,
12,
671,
14,
2271,
9,
267,
291,
14,
629,
8,
10198,
14,
890,
2360,
7114,
8,
2734,
671,
12,
612,
26,
88,
627,
612,
12,
308,
430,
267,
291,
14,
629,
8,
835,
8,
10198,
9,
2360,
822,
8,
77,
17,
9,
446,
7114,
8,
2734,
671,
12,
612,
26,
88,
435,
612,
12,
333,
17,
430,
267,
291,
14,
1815,
8,
4077,
8,
10198,
12,
27366,
430,
267,
291,
14,
1815,
8,
4077,
8,
17647,
8,
10198,
12,
413,
14,
69,
1165,
395,
27366,
430,
267,
291,
14,
1815,
8,
4077,
8,
88,
12,
17725,
430,
339,
347,
511,
63,
396,
6845,
18,
68,
8,
277,
304,
267,
298,
774,
402,
5678,
1625,
7143,
436,
4382,
315,
499,
7365,
2122,
267,
367,
308,
315,
3842,
20,
12,
650,
395,
334,
22,
12,
499,
19532,
288,
334,
88,
12,
612,
12,
282,
709,
12,
333,
17,
12,
333,
18,
12,
17725,
12,
612,
77,
12,
1315,
12,
1315,
77,
12,
27366,
12,
308,
9,
275,
291,
14,
68,
288,
671,
14,
1392,
275,
308,
288,
612,
14,
1392,
275,
308,
288,
17725,
14,
1392,
275,
308,
288,
612,
77,
14,
1392,
275,
308,
288,
27366,
14,
1392,
275,
308,
953,
291,
14,
3334,
8,
374,
5144,
20999,
8,
88,
430,
288,
291,
14,
1815,
8,
374,
5144,
20999,
8,
10198,
430,
288,
291,
14,
629,
8,
1392,
8,
10198,
395,
308,
9,
288,
291,
14,
629,
8,
10198,
14,
1392,
12,
308,
9,
288,
291,
14,
629,
8,
10198,
14,
890,
2360,
7114,
8,
2734,
671,
12,
612,
26,
88,
627,
612,
12,
308,
430,
288,
291,
14,
629,
8,
835,
8,
10198,
9,
2360,
822,
8,
77,
17,
9,
446,
7114,
8,
2734,
671,
12,
612,
26,
88,
435,
612,
12,
333,
17,
430,
288,
291,
14,
1815,
8,
4077,
8,
10198,
12,
27366,
430,
288,
291,
14,
1815,
8,
4077,
8,
17647,
8,
10198,
12,
413,
14,
69,
1165,
395,
27366,
430,
288,
291,
14,
1815,
8,
4077,
8,
88,
12,
17725,
430,
288,
291,
14,
5996,
342,
339,
347,
511,
63,
396,
26291,
18764,
334,
277,
304,
267,
298,
774,
402,
5678,
24166,
2122,
267,
334,
88,
12,
612,
12,
282,
709,
12,
333,
17,
12,
333,
18,
12,
17725,
12,
612,
77,
12,
1315,
12,
1315,
77,
12,
27366,
12,
308,
9,
275,
291,
14,
68,
267,
282,
18,
68,
275,
1625,
4038,
17,
12,
499,
467,
359,
16,
12,
841,
3934,
267,
282,
18,
6428,
275,
9742,
63,
1144,
8,
65,
18,
68,
12,
3474,
16,
12,
378,
467,
359,
17,
12,
378,
3934,
267,
291,
14,
1815,
8,
4077,
334,
65,
18,
68,
627,
282,
18,
68,
12,
282,
18,
68,
627,
282,
18,
6428,
430,
267,
291,
14,
1815,
8,
4077,
334,
65,
18,
68,
435,
282,
18,
68,
12,
282,
18,
68,
435,
282,
18,
6428,
430,
267,
291,
14,
1815,
8,
4077,
334,
65,
18,
68,
446,
282,
18,
68,
12,
282,
18,
68,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mabhub/Geotrek
|
geotrek/settings/base.py
|
1
|
17906
|
import os
import sys
from django.contrib.messages import constants as messages
from geotrek import __version__
from . import PROJECT_ROOT_PATH
def gettext_noop(s):
return s
DEBUG = False
TEMPLATE_DEBUG = DEBUG
TEST = 'test' in sys.argv
VERSION = __version__
ADMINS = (
('Makina Corpus', 'geobi@makina-corpus.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'OPTIONS': {},
'NAME': '', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
#
# PostgreSQL Schemas for apps and models.
#
# Caution: editing this setting might not be enough.
# Indeed, it won't apply to apps that not managed of South, nor database views and functions.
# See all sql/*-schemas.sql files in each Geotrek app.
#
DATABASE_SCHEMAS = {
'default': 'geotrek',
'auth': 'django',
'django': 'django',
'easy_thumbnails': 'django',
'south': 'django',
'feedback': 'gestion',
'infrastructure': 'gestion',
'maintenance': 'gestion',
'tourism': 'tourisme',
'trekking': 'rando',
'zoning': 'zonage',
'land': 'foncier',
}
DATABASES['default']['OPTIONS'] = {
'options': '-c search_path=public,%s' % ','.join(set(DATABASE_SCHEMAS.values()))
}
#
# Authentication
#
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',)
AUTH_PROFILE_MODULE = 'authent.UserProfile'
# Settings required for geotrek.authent.backend.DatabaseBackend :
AUTHENT_DATABASE = None
AUTHENT_TABLENAME = None
AUTHENT_GROUPS_MAPPING = {
'PATH_MANAGER': 1,
'TREKKING_MANAGER': 2,
'EDITOR': 3,
'READER': 4,
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Paris'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'fr'
MODELTRANSLATION_DEFAULT_LANGUAGE = LANGUAGE_CODE
LANGUAGES = (
('en', gettext_noop('English')),
('fr', gettext_noop('French')),
('it', gettext_noop('Italian')),
('es', gettext_noop('Spanish')),
)
LOCALE_PATHS = (
os.path.join(PROJECT_ROOT_PATH, 'locale'),
)
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
DATE_INPUT_FORMATS = ('%d/%m/%Y',)
ROOT_URL = ''
LOGIN_URL = 'login'
LOGOUT_URL = 'logout'
LOGIN_REDIRECT_URL = 'home'
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT_PATH, 'media')
UPLOAD_DIR = 'upload' # media root subdir
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
MEDIA_URL_SECURE = '/media_secure/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT_PATH, 'static'),
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
'compressor.finders.CompressorFinder',
)
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
COMPRESSOR_ENABLED = False
COMPRESS_PARSER = 'compressor.parser.HtmlParser'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'public_key'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'geotrek.authent.middleware.LocaleForcedMiddleware',
'django.middleware.locale.LocaleMiddleware',
'geotrek.common.middleware.APILocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'geotrek.authent.middleware.CorsMiddleware',
'mapentity.middleware.AutoLoginMiddleware'
)
ROOT_URLCONF = 'geotrek.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'geotrek.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'mapentity.context_processors.settings',
)
#
# /!\ Application names (last levels) must be unique
# (c.f. auth/authent)
# https://code.djangoproject.com/ticket/12288
#
PROJECT_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.gis',
)
# Do not migrate translated fields, they differ per instance, and
# can be added/removed using `update_translation_fields`
if 'schemamigration' not in sys.argv:
PROJECT_APPS += ('modeltranslation',)
PROJECT_APPS += (
'south',
'leaflet',
'floppyforms',
'crispy_forms',
'compressor',
'djgeojson',
'tinymce',
'easy_thumbnails',
'shapes',
'paperclip',
'mapentity',
'rest_framework',
'embed_video',
'djcelery',
)
INSTALLED_APPS = PROJECT_APPS + (
'geotrek.cirkwi',
'geotrek.authent',
'geotrek.common',
'geotrek.altimetry',
'geotrek.core',
'geotrek.infrastructure',
'geotrek.maintenance',
'geotrek.zoning',
'geotrek.land',
'geotrek.trekking',
'geotrek.tourism',
'geotrek.flatpages',
'geotrek.feedback',
)
SERIALIZATION_MODULES = {
'geojson': 'djgeojson.serializers'
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
},
# The fat backend is used to store big chunk of data (>1 Mo)
'fat': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'simple': {
'format': '%(levelname)s %(asctime)s %(name)s %(message)s'
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'logging.NullHandler'
},
'console': {
'level': 'WARNING',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
},
'loggers': {
'django.db.backends': {
'handlers': ['console', 'mail_admins'],
'level': 'ERROR',
'propagate': False,
},
'django.request': {
'handlers': ['console', 'mail_admins'],
'level': 'ERROR',
'propagate': False,
},
'django': {
'handlers': ['console', 'mail_admins'],
'level': 'ERROR',
'propagate': False,
},
'south': {
'handlers': ['console', 'mail_admins'],
'level': 'ERROR',
'propagate': False,
},
'geotrek': {
'handlers': ['console', 'mail_admins'],
'level': 'INFO',
'propagate': False,
},
'mapentity': {
'handlers': ['console', 'mail_admins'],
'level': 'INFO',
'propagate': False,
},
'': {
'handlers': ['console', 'mail_admins'],
'level': 'INFO',
'propagate': False,
},
}
}
THUMBNAIL_ALIASES = {
'': {
'thumbnail': {'size': (150, 150)},
# Thumbnails for public trek website
'small-square': {'size': (120, 120), 'crop': True},
'medium': {'size': (800, 800)},
# Header image for trek export (keep ratio of TREK_EXPORT_HEADER_IMAGE_SIZE)
'print': {'size': (1000, 500), 'crop': 'smart'},
},
}
PAPERCLIP_CONFIG = {
'ENABLE_VIDEO': True,
'FILETYPE_MODEL': 'common.FileType',
'ATTACHMENT_TABLE_NAME': 'fl_t_fichier',
}
# Data projection
SRID = 3857
# API projection (client-side), can differ from SRID (database). Leaflet requires 4326.
API_SRID = 4326
# Extent in native projection (Toulouse area)
SPATIAL_EXTENT = (144968, 5415668, 175412, 5388753)
MAPENTITY_CONFIG = {
'TITLE': gettext_noop("Geotrek"),
'TEMP_DIR': '/tmp',
'HISTORY_ITEMS_MAX': 7,
'CONVERSION_SERVER': 'http://127.0.0.1:6543',
'CAPTURE_SERVER': 'http://127.0.0.1:8001',
'ROOT_URL': ROOT_URL,
'MAP_BACKGROUND_FOGGED': True,
'GEOJSON_LAYERS_CACHE_BACKEND': 'fat',
'SENDFILE_HTTP_HEADER': 'X-Accel-Redirect',
'DRF_API_URL_PREFIX': r'^api/(?P<lang>\w+)/',
}
DEFAULT_STRUCTURE_NAME = gettext_noop('Default')
VIEWPORT_MARGIN = 0.1 # On list page, around spatial extent from settings.ini
PATHS_LINE_MARKER = 'dotL'
PATH_SNAPPING_DISTANCE = 1 # Distance of path snapping in meters
SNAP_DISTANCE = 30 # Distance of snapping in pixels
ALTIMETRIC_PROFILE_PRECISION = 25 # Sampling precision in meters
ALTIMETRIC_PROFILE_BACKGROUND = 'white'
ALTIMETRIC_PROFILE_COLOR = '#F77E00'
ALTIMETRIC_PROFILE_HEIGHT = 400
ALTIMETRIC_PROFILE_WIDTH = 800
ALTIMETRIC_PROFILE_FONTSIZE = 25
ALTIMETRIC_PROFILE_FONT = 'ubuntu'
ALTIMETRIC_PROFILE_MIN_YSCALE = 1200 # Minimum y scale (in meters)
ALTIMETRIC_AREA_MAX_RESOLUTION = 150 # Maximum number of points (by width/height)
ALTIMETRIC_AREA_MARGIN = 0.15
# Let this be defined at instance-level
LEAFLET_CONFIG = {
'SRID': SRID,
'TILES': [
('Scan', 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',),
('Ortho', 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.jpg'),
],
'TILES_EXTENT': SPATIAL_EXTENT,
# Extent in API projection (Leaflet view default extent)
'SPATIAL_EXTENT': (1.3, 43.7, 1.5, 43.5),
'NO_GLOBALS': False,
'PLUGINS': {
'geotrek': {'js': ['core/leaflet.lineextremities.js',
'core/leaflet.textpath.js',
'trekking/points_reference.js',
'trekking/parking_location.js']},
'topofields': {'js': ['core/geotrek.forms.snap.js',
'core/geotrek.forms.topology.js',
'core/dijkstra.js',
'core/multipath.js',
'core/topology_helper.js']}
}
}
""" This *pool* of colors is used to colorized lands records.
"""
COLORS_POOL = {'land': ['#f37e79', '#7998f3', '#bbf379', '#f379df', '#f3bf79', '#9c79f3', '#7af379'],
'physical': ['#f3799d', '#79c1f3', '#e4f379', '#de79f3', '#79f3ba', '#f39779', '#797ff3'],
'competence': ['#a2f379', '#f379c6', '#79e9f3', '#f3d979', '#b579f3', '#79f392', '#f37984'],
'signagemanagement': ['#79a8f3', '#cbf379', '#f379ee', '#79f3e3', '#79f3d3'],
'workmanagement': ['#79a8f3', '#cbf379', '#f379ee', '#79f3e3', '#79f3d3'],
'restrictedarea': ['plum', 'violet', 'deeppink', 'orchid',
'darkviolet', 'lightcoral', 'palevioletred',
'MediumVioletRed', 'MediumOrchid', 'Magenta',
'LightSalmon', 'HotPink', 'Fuchsia']}
MAP_STYLES = {
'path': {'weight': 2, 'opacity': 1.0, 'color': '#FF4800'},
'city': {'weight': 4, 'color': 'orange', 'opacity': 0.3, 'fillOpacity': 0.0},
'district': {'weight': 6, 'color': 'orange', 'opacity': 0.3, 'fillOpacity': 0.0, 'dashArray': '12, 12'},
'restrictedarea': {'weight': 2, 'color': 'red', 'opacity': 0.5, 'fillOpacity': 0.5},
'land': {'weight': 4, 'color': 'red', 'opacity': 1.0},
'physical': {'weight': 6, 'color': 'red', 'opacity': 1.0},
'competence': {'weight': 4, 'color': 'red', 'opacity': 1.0},
'workmanagement': {'weight': 4, 'color': 'red', 'opacity': 1.0},
'signagemanagement': {'weight': 5, 'color': 'red', 'opacity': 1.0},
'print': {
'path': {'weight': 1},
'trek': {'color': '#FF3300', 'weight': 7, 'opacity': 0.5,
'arrowColor': 'black', 'arrowSize': 10},
}
}
LAYER_PRECISION_LAND = 4 # Number of fraction digit
LAYER_SIMPLIFY_LAND = 10 # Simplification tolerance
LAND_BBOX_CITIES_ENABLED = True
LAND_BBOX_DISTRICTS_ENABLED = True
LAND_BBOX_AREAS_ENABLED = False
PUBLISHED_BY_LANG = True
EXPORT_MAP_IMAGE_SIZE = {
'trek': (14.1, 11),
'poi': (14.1, 11),
'touristiccontent': (14.1, 11),
'touristicevent': (14.1, 11),
}
EXPORT_HEADER_IMAGE_SIZE = {
'trek': (10.7, 5.35), # Keep ratio of THUMBNAIL_ALIASES['print']
'poi': (10.7, 5.35), # Keep ratio of THUMBNAIL_ALIASES['print']
'touristiccontent': (10.7, 5.35), # Keep ratio of THUMBNAIL_ALIASES['print']
'touristicevent': (10.7, 5.35), # Keep ratio of THUMBNAIL_ALIASES['print']
}
COMPLETENESS_FIELDS = {
'trek': ['departure', 'duration', 'difficulty', 'description_teaser']
}
TRAIL_MODEL_ENABLED = True
TREKKING_TOPOLOGY_ENABLED = True
FLATPAGES_ENABLED = False # False because still experimental
TOURISM_ENABLED = False # False because still experimental
TREK_POI_INTERSECTION_MARGIN = 500 # meters (used only if TREKKING_TOPOLOGY_ENABLED = False)
TOURISM_INTERSECTION_MARGIN = 500 # meters (always used)
SIGNAGE_LINE_ENABLED = False
TREK_POINTS_OF_REFERENCE_ENABLED = True
TREK_EXPORT_POI_LIST_LIMIT = 14
TREK_EXPORT_INFORMATION_DESK_LIST_LIMIT = 2
TREK_DAY_DURATION = 10 # Max duration to be done in one day
TREK_ICON_SIZE_POI = 18
TREK_ICON_SIZE_PARKING = 18
TREK_ICON_SIZE_INFORMATION_DESK = 18
# Static offsets in projection units
TOPOLOGY_STATIC_OFFSETS = {'land': -5,
'physical': 0,
'competence': 5,
'signagemanagement': -10,
'workmanagement': 10}
MESSAGE_TAGS = {
messages.SUCCESS: 'alert-success',
messages.INFO: 'alert-info',
messages.DEBUG: 'alert-info',
messages.WARNING: 'alert-error',
messages.ERROR: 'alert-error',
}
CACHE_TIMEOUT_LAND_LAYERS = 60 * 60 * 24
CACHE_TIMEOUT_TOURISM_DATASOURCES = 60 * 60 * 24
TREK_CATEGORY_ORDER = None
TOURISTIC_EVENT_CATEGORY_ORDER = None
SPLIT_TREKS_CATEGORIES_BY_PRACTICE = False
SPLIT_TREKS_CATEGORIES_BY_ACCESSIBILITY = False
HIDE_PUBLISHED_TREKS_IN_TOPOLOGIES = False
ZIP_TOURISTIC_CONTENTS_AS_POI = False
CRISPY_ALLOWED_TEMPLATE_PACKS = ('bootstrap', 'bootstrap3')
CRISPY_TEMPLATE_PACK = 'bootstrap'
# Mobile app_directories
MOBILE_TILES_URL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
MOBILE_TILES_RADIUS_LARGE = 0.01 # ~1 km
MOBILE_TILES_RADIUS_SMALL = 0.005 # ~500 m
MOBILE_TILES_GLOBAL_ZOOMS = range(13)
MOBILE_TILES_LOW_ZOOMS = range(13, 15)
MOBILE_TILES_HIGH_ZOOMS = range(15, 17)
import djcelery
djcelery.setup_loader()
CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend'
BROKER_URL = 'redis://127.0.0.1:6379/0'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_RESULT_EXPIRES = 5
TEST_RUNNER = 'djcelery.contrib.test_runner.CeleryTestSuiteRunner'
|
bsd-2-clause
|
[
646,
747,
199,
646,
984,
199,
199,
504,
1639,
14,
2828,
14,
3431,
492,
5262,
465,
3788,
199,
199,
504,
2312,
357,
264,
75,
492,
636,
1023,
363,
199,
504,
1275,
492,
21915,
63,
5441,
63,
3243,
421,
199,
318,
9796,
63,
12921,
8,
83,
304,
272,
372,
308,
421,
199,
5287,
275,
756,
199,
7433,
63,
5287,
275,
10990,
199,
2864,
275,
283,
396,
7,
315,
984,
14,
3020,
199,
4612,
275,
636,
1023,
363,
199,
199,
14288,
51,
275,
334,
272,
661,
45,
1151,
13765,
7499,
8843,
297,
283,
303,
2873,
73,
32,
22191,
13765,
13,
16780,
14,
957,
659,
199,
9,
199,
199,
20600,
3960,
275,
29948,
51,
199,
199,
27260,
275,
469,
272,
283,
885,
356,
469,
267,
283,
15956,
356,
283,
1176,
14,
2828,
14,
5668,
14,
697,
14,
7765,
14,
1932,
5668,
297,
267,
283,
8808,
356,
5479,
267,
283,
2339,
356,
3260,
10473,
327,
4236,
931,
370,
3050,
570,
340,
1808,
11723,
19,
14,
267,
283,
3791,
356,
3260,
10473,
327,
2832,
1202,
543,
11723,
19,
14,
267,
283,
9032,
356,
3260,
8295,
327,
2832,
1202,
543,
11723,
19,
14,
267,
283,
5449,
356,
3260,
10473,
327,
2494,
370,
2701,
1059,
367,
11667,
14,
2832,
1202,
543,
11723,
19,
14,
267,
283,
3657,
356,
3260,
10473,
327,
2494,
370,
2701,
1059,
367,
849,
14,
2832,
1202,
543,
11723,
19,
14,
272,
789,
199,
93,
199,
199,
3,
199,
3,
20175,
428,
8532,
367,
8686,
436,
1709,
14,
199,
3,
199,
3,
8790,
2206,
26,
20401,
642,
4260,
5594,
440,
506,
8321,
14,
199,
3,
1010,
271,
379,
12,
652,
7859,
1133,
4838,
370,
8686,
626,
440,
12883,
402,
23150,
12,
6590,
3050,
6858,
436,
3423,
14,
199,
3,
1666,
1006,
3875,
15,
1837,
9482,
14,
3009,
1584,
315,
1924,
5346,
357,
264,
75,
1145,
14,
199,
3,
199,
17873,
63,
17859,
1179,
275,
469,
272,
283,
885,
356,
283,
303,
357,
264,
75,
297,
339,
283,
1178,
356,
283,
1176,
297,
272,
283,
1176,
356,
283,
1176,
297,
272,
283,
13581,
63,
8311,
83,
356,
283,
1176,
297,
272,
283,
22607,
356,
283,
1176,
297,
272,
283,
13485,
356,
283,
3199,
1636,
297,
272,
283,
19505,
6976,
356,
283,
3199,
1636,
297,
272,
283,
19725,
356,
283,
3199,
1636,
297,
272,
283,
10808,
19185,
356,
283,
10808,
374,
278,
297,
272,
283,
18468,
16247,
316,
356,
283,
3759,
79,
297,
272,
283,
8384,
316,
356,
283,
8384,
474,
297,
272,
283,
9688,
356,
283,
70,
265,
559,
281,
297,
199,
93,
199,
199,
27260,
459,
885,
2545,
8808,
418,
275,
469,
272,
283,
1419,
356,
2475,
67,
2754,
63,
515,
29,
3455,
8719,
83,
7,
450,
12814,
904,
8,
409,
8,
17873,
63,
17859,
1179,
14,
1459,
4059,
199,
93,
199,
199,
3,
199,
3,
15995,
199,
3,
199,
29599,
63,
28988,
275,
661,
1176,
14,
2828,
14,
1178,
14,
7765,
14,
1685,
8447,
9538,
199,
5580,
63,
16632,
63,
10001,
275,
283,
1178,
484,
14,
23544,
7,
199,
199,
3,
13303,
1415,
367,
2312,
357,
264,
75,
14,
1178,
484,
14,
4620,
14,
7243,
8447,
520,
199,
5580,
1309,
63,
17873,
275,
488,
199,
5580,
1309,
63,
10129,
5304,
1991,
275,
488,
199,
5580,
1309,
63,
27544,
63,
20351,
275,
469,
272,
283,
3243,
63,
28541,
356,
413,
12,
272,
283,
52,
907,
27511,
1206,
63,
28541,
356,
499,
12,
272,
283,
17929,
726,
356,
650,
12,
272,
283,
5670,
540,
356,
841,
12,
199,
93,
199,
199,
3,
10111,
900,
5718,
367,
642,
12096,
14,
8802,
2370,
883,
506,
1911,
2348,
26,
199,
3,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1296,
63,
1618,
63,
3903,
63,
13325,
63,
991,
63,
354,
199,
3,
22160,
440,
1006,
3415,
1443,
506,
2808,
641,
1006,
17406,
10460,
14,
199,
3,
4068,
13074,
10460,
12,
282,
574,
402,
488,
911,
7675,
5634,
370,
675,
314,
2011,
199,
3,
7137,
465,
314,
17406,
2656,
14,
199,
3,
982,
3879,
315,
282,
5417,
3734,
642,
1471,
506,
663,
370,
314,
2011,
465,
2195,
199,
3,
2656,
900,
5718,
14,
199,
4961,
63,
15353,
275,
283,
15201,
15,
1262,
374,
7,
199,
199,
3,
8466,
1233,
367,
642,
12096,
14,
2900,
3415,
883,
506,
1911,
2348,
26,
199,
3,
1455,
921,
1544,
14,
73,
1085,
2753,
29514,
14,
957,
15,
2975,
15,
3671,
13,
14227,
14,
1360,
199,
13947,
63,
6012,
275,
283,
4391,
7,
199,
199,
11429,
26376,
2594,
63,
3472,
63,
13947,
275,
30508,
2962,
63,
6012,
421,
199,
26886,
275,
334,
272,
661,
287,
297,
9796,
63,
12921,
360,
19410,
3855,
272,
661,
4391,
297,
9796,
63,
12921,
360,
38,
15148,
3855,
272,
661,
390,
297,
9796,
63,
12921,
360,
7940,
25861,
3855,
272,
661,
397,
297,
9796,
63,
12921,
360,
23717,
2453,
3855,
199,
9,
199,
199,
20828,
63,
20202,
275,
334,
272,
747,
14,
515,
14,
904,
8,
10797,
63,
5441,
63,
3243,
12,
283,
5508,
659,
199,
9,
199,
199,
7917,
63,
998,
275,
413,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
1852,
2005,
5323,
12270,
880,
465,
440,
199,
3,
370,
2248,
314,
10757,
6279,
2072,
28540,
14,
199,
4701,
63,
41,
1085,
46,
275,
715,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
440,
1475,
10831,
12,
5579,
436,
199,
3,
1704,
31276,
7182,
370,
314,
1453,
5867,
14,
199,
4701,
63,
44,
709,
46,
275,
715,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
440,
675,
7137,
13,
14600,
29297,
14,
199,
4701,
63,
14226,
275,
715,
199,
199,
5390,
63,
7321,
63,
14019,
275,
16651,
68,
3149,
77,
3149,
57,
9538,
199,
199,
5441,
63,
2632,
275,
2125,
199,
17208,
63,
2632,
275,
283,
2886,
7,
199,
4947,
1877,
63,
2632,
275,
283,
11646,
7,
199,
17208,
63,
19747,
63,
2632,
275,
283,
4219,
7,
199,
199,
3,
24964,
10036,
931,
370,
314,
2082,
626,
911,
10266,
922,
13,
19044,
1584,
14,
199,
3,
5679,
26,
3286,
4219,
15,
4603,
15,
4603,
14,
22277,
4646,
14,
957,
15,
4603,
6687,
199,
13669,
63,
5441,
275,
747,
14,
515,
14,
904,
8,
10797,
63,
5441,
63
] |
[
747,
199,
646,
984,
199,
199,
504,
1639,
14,
2828,
14,
3431,
492,
5262,
465,
3788,
199,
199,
504,
2312,
357,
264,
75,
492,
636,
1023,
363,
199,
504,
1275,
492,
21915,
63,
5441,
63,
3243,
421,
199,
318,
9796,
63,
12921,
8,
83,
304,
272,
372,
308,
421,
199,
5287,
275,
756,
199,
7433,
63,
5287,
275,
10990,
199,
2864,
275,
283,
396,
7,
315,
984,
14,
3020,
199,
4612,
275,
636,
1023,
363,
199,
199,
14288,
51,
275,
334,
272,
661,
45,
1151,
13765,
7499,
8843,
297,
283,
303,
2873,
73,
32,
22191,
13765,
13,
16780,
14,
957,
659,
199,
9,
199,
199,
20600,
3960,
275,
29948,
51,
199,
199,
27260,
275,
469,
272,
283,
885,
356,
469,
267,
283,
15956,
356,
283,
1176,
14,
2828,
14,
5668,
14,
697,
14,
7765,
14,
1932,
5668,
297,
267,
283,
8808,
356,
5479,
267,
283,
2339,
356,
3260,
10473,
327,
4236,
931,
370,
3050,
570,
340,
1808,
11723,
19,
14,
267,
283,
3791,
356,
3260,
10473,
327,
2832,
1202,
543,
11723,
19,
14,
267,
283,
9032,
356,
3260,
8295,
327,
2832,
1202,
543,
11723,
19,
14,
267,
283,
5449,
356,
3260,
10473,
327,
2494,
370,
2701,
1059,
367,
11667,
14,
2832,
1202,
543,
11723,
19,
14,
267,
283,
3657,
356,
3260,
10473,
327,
2494,
370,
2701,
1059,
367,
849,
14,
2832,
1202,
543,
11723,
19,
14,
272,
789,
199,
93,
199,
199,
3,
199,
3,
20175,
428,
8532,
367,
8686,
436,
1709,
14,
199,
3,
199,
3,
8790,
2206,
26,
20401,
642,
4260,
5594,
440,
506,
8321,
14,
199,
3,
1010,
271,
379,
12,
652,
7859,
1133,
4838,
370,
8686,
626,
440,
12883,
402,
23150,
12,
6590,
3050,
6858,
436,
3423,
14,
199,
3,
1666,
1006,
3875,
15,
1837,
9482,
14,
3009,
1584,
315,
1924,
5346,
357,
264,
75,
1145,
14,
199,
3,
199,
17873,
63,
17859,
1179,
275,
469,
272,
283,
885,
356,
283,
303,
357,
264,
75,
297,
339,
283,
1178,
356,
283,
1176,
297,
272,
283,
1176,
356,
283,
1176,
297,
272,
283,
13581,
63,
8311,
83,
356,
283,
1176,
297,
272,
283,
22607,
356,
283,
1176,
297,
272,
283,
13485,
356,
283,
3199,
1636,
297,
272,
283,
19505,
6976,
356,
283,
3199,
1636,
297,
272,
283,
19725,
356,
283,
3199,
1636,
297,
272,
283,
10808,
19185,
356,
283,
10808,
374,
278,
297,
272,
283,
18468,
16247,
316,
356,
283,
3759,
79,
297,
272,
283,
8384,
316,
356,
283,
8384,
474,
297,
272,
283,
9688,
356,
283,
70,
265,
559,
281,
297,
199,
93,
199,
199,
27260,
459,
885,
2545,
8808,
418,
275,
469,
272,
283,
1419,
356,
2475,
67,
2754,
63,
515,
29,
3455,
8719,
83,
7,
450,
12814,
904,
8,
409,
8,
17873,
63,
17859,
1179,
14,
1459,
4059,
199,
93,
199,
199,
3,
199,
3,
15995,
199,
3,
199,
29599,
63,
28988,
275,
661,
1176,
14,
2828,
14,
1178,
14,
7765,
14,
1685,
8447,
9538,
199,
5580,
63,
16632,
63,
10001,
275,
283,
1178,
484,
14,
23544,
7,
199,
199,
3,
13303,
1415,
367,
2312,
357,
264,
75,
14,
1178,
484,
14,
4620,
14,
7243,
8447,
520,
199,
5580,
1309,
63,
17873,
275,
488,
199,
5580,
1309,
63,
10129,
5304,
1991,
275,
488,
199,
5580,
1309,
63,
27544,
63,
20351,
275,
469,
272,
283,
3243,
63,
28541,
356,
413,
12,
272,
283,
52,
907,
27511,
1206,
63,
28541,
356,
499,
12,
272,
283,
17929,
726,
356,
650,
12,
272,
283,
5670,
540,
356,
841,
12,
199,
93,
199,
199,
3,
10111,
900,
5718,
367,
642,
12096,
14,
8802,
2370,
883,
506,
1911,
2348,
26,
199,
3,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1296,
63,
1618,
63,
3903,
63,
13325,
63,
991,
63,
354,
199,
3,
22160,
440,
1006,
3415,
1443,
506,
2808,
641,
1006,
17406,
10460,
14,
199,
3,
4068,
13074,
10460,
12,
282,
574,
402,
488,
911,
7675,
5634,
370,
675,
314,
2011,
199,
3,
7137,
465,
314,
17406,
2656,
14,
199,
3,
982,
3879,
315,
282,
5417,
3734,
642,
1471,
506,
663,
370,
314,
2011,
465,
2195,
199,
3,
2656,
900,
5718,
14,
199,
4961,
63,
15353,
275,
283,
15201,
15,
1262,
374,
7,
199,
199,
3,
8466,
1233,
367,
642,
12096,
14,
2900,
3415,
883,
506,
1911,
2348,
26,
199,
3,
1455,
921,
1544,
14,
73,
1085,
2753,
29514,
14,
957,
15,
2975,
15,
3671,
13,
14227,
14,
1360,
199,
13947,
63,
6012,
275,
283,
4391,
7,
199,
199,
11429,
26376,
2594,
63,
3472,
63,
13947,
275,
30508,
2962,
63,
6012,
421,
199,
26886,
275,
334,
272,
661,
287,
297,
9796,
63,
12921,
360,
19410,
3855,
272,
661,
4391,
297,
9796,
63,
12921,
360,
38,
15148,
3855,
272,
661,
390,
297,
9796,
63,
12921,
360,
7940,
25861,
3855,
272,
661,
397,
297,
9796,
63,
12921,
360,
23717,
2453,
3855,
199,
9,
199,
199,
20828,
63,
20202,
275,
334,
272,
747,
14,
515,
14,
904,
8,
10797,
63,
5441,
63,
3243,
12,
283,
5508,
659,
199,
9,
199,
199,
7917,
63,
998,
275,
413,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
1852,
2005,
5323,
12270,
880,
465,
440,
199,
3,
370,
2248,
314,
10757,
6279,
2072,
28540,
14,
199,
4701,
63,
41,
1085,
46,
275,
715,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
440,
1475,
10831,
12,
5579,
436,
199,
3,
1704,
31276,
7182,
370,
314,
1453,
5867,
14,
199,
4701,
63,
44,
709,
46,
275,
715,
199,
199,
3,
982,
1265,
663,
642,
370,
756,
12,
5634,
911,
440,
675,
7137,
13,
14600,
29297,
14,
199,
4701,
63,
14226,
275,
715,
199,
199,
5390,
63,
7321,
63,
14019,
275,
16651,
68,
3149,
77,
3149,
57,
9538,
199,
199,
5441,
63,
2632,
275,
2125,
199,
17208,
63,
2632,
275,
283,
2886,
7,
199,
4947,
1877,
63,
2632,
275,
283,
11646,
7,
199,
17208,
63,
19747,
63,
2632,
275,
283,
4219,
7,
199,
199,
3,
24964,
10036,
931,
370,
314,
2082,
626,
911,
10266,
922,
13,
19044,
1584,
14,
199,
3,
5679,
26,
3286,
4219,
15,
4603,
15,
4603,
14,
22277,
4646,
14,
957,
15,
4603,
6687,
199,
13669,
63,
5441,
275,
747,
14,
515,
14,
904,
8,
10797,
63,
5441,
63,
0
] |
[
1,
1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ey/ansible
|
lib/ansible/utils/ssh_functions.py
|
87
|
1482
|
# (c) 2016, James Tanner
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.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
import subprocess
_HAS_CONTROLPERSIST = {}
def check_for_controlpersist(ssh_executable):
try:
# If we've already checked this executable
return _HAS_CONTROLPERSIST[ssh_executable]
except KeyError:
pass
has_cp = True
try:
cmd = subprocess.Popen([ssh_executable,'-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = cmd.communicate()
if b"Bad configuration option" in err or b"Usage:" in err:
has_cp = False
except OSError:
has_cp = False
_HAS_CONTROLPERSIST[ssh_executable] = has_cp
return has_cp
|
gpl-3.0
|
[
3,
334,
67,
9,
7800,
12,
1603,
14015,
377,
5161,
199,
3,
334,
67,
9,
7800,
12,
4005,
609,
2308,
1804,
300,
4188,
73,
665,
2663,
300,
4188,
73,
32,
4853,
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,
646,
3873,
421,
199,
63,
13533,
63,
13060,
4227,
29367,
275,
1052,
421,
199,
318,
1104,
63,
509,
63,
2785,
23619,
8,
5510,
63,
5904,
304,
272,
862,
26,
267,
327,
982,
781,
9064,
2575,
7923,
642,
7286,
267,
372,
485,
13533,
63,
13060,
4227,
29367,
59,
5510,
63,
5904,
61,
272,
871,
4067,
26,
267,
986,
339,
965,
63,
1850,
275,
715,
272,
862,
26,
267,
2088,
275,
3873,
14,
7942,
779,
5510,
63,
5904,
2584,
13,
79,
1673,
3717,
2623,
11734,
995,
3839,
29,
5781,
14,
6089,
12,
4635,
29,
5781,
14,
6089,
9,
267,
334,
548,
12,
2329,
9,
275,
2088,
14,
10664,
342,
267,
340,
330,
2,
5725,
2897,
945,
2,
315,
2329,
503,
330,
2,
7692,
5424,
315,
2329,
26,
288,
965,
63,
1850,
275,
756,
272,
871,
6440,
26,
267,
965,
63,
1850,
275,
756,
339,
485,
13533,
63,
13060,
4227,
29367,
59,
5510,
63,
5904,
61,
275,
965,
63,
1850,
272,
372,
965,
63,
1850,
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
] |
[
334,
67,
9,
7800,
12,
1603,
14015,
377,
5161,
199,
3,
334,
67,
9,
7800,
12,
4005,
609,
2308,
1804,
300,
4188,
73,
665,
2663,
300,
4188,
73,
32,
4853,
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,
646,
3873,
421,
199,
63,
13533,
63,
13060,
4227,
29367,
275,
1052,
421,
199,
318,
1104,
63,
509,
63,
2785,
23619,
8,
5510,
63,
5904,
304,
272,
862,
26,
267,
327,
982,
781,
9064,
2575,
7923,
642,
7286,
267,
372,
485,
13533,
63,
13060,
4227,
29367,
59,
5510,
63,
5904,
61,
272,
871,
4067,
26,
267,
986,
339,
965,
63,
1850,
275,
715,
272,
862,
26,
267,
2088,
275,
3873,
14,
7942,
779,
5510,
63,
5904,
2584,
13,
79,
1673,
3717,
2623,
11734,
995,
3839,
29,
5781,
14,
6089,
12,
4635,
29,
5781,
14,
6089,
9,
267,
334,
548,
12,
2329,
9,
275,
2088,
14,
10664,
342,
267,
340,
330,
2,
5725,
2897,
945,
2,
315,
2329,
503,
330,
2,
7692,
5424,
315,
2329,
26,
288,
965,
63,
1850,
275,
756,
272,
871,
6440,
26,
267,
965,
63,
1850,
275,
756,
339,
485,
13533,
63,
13060,
4227,
29367,
59,
5510,
63,
5904,
61,
275,
965,
63,
1850,
272,
372,
965,
63,
1850,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
amith01994/intellij-community
|
python/lib/Lib/site-packages/django/contrib/localflavor/jp/jp_prefectures.py
|
543
|
2089
|
from django.utils.translation import ugettext_lazy
JP_PREFECTURES = (
('hokkaido', ugettext_lazy('Hokkaido'),),
('aomori', ugettext_lazy('Aomori'),),
('iwate', ugettext_lazy('Iwate'),),
('miyagi', ugettext_lazy('Miyagi'),),
('akita', ugettext_lazy('Akita'),),
('yamagata', ugettext_lazy('Yamagata'),),
('fukushima', ugettext_lazy('Fukushima'),),
('ibaraki', ugettext_lazy('Ibaraki'),),
('tochigi', ugettext_lazy('Tochigi'),),
('gunma', ugettext_lazy('Gunma'),),
('saitama', ugettext_lazy('Saitama'),),
('chiba', ugettext_lazy('Chiba'),),
('tokyo', ugettext_lazy('Tokyo'),),
('kanagawa', ugettext_lazy('Kanagawa'),),
('yamanashi', ugettext_lazy('Yamanashi'),),
('nagano', ugettext_lazy('Nagano'),),
('niigata', ugettext_lazy('Niigata'),),
('toyama', ugettext_lazy('Toyama'),),
('ishikawa', ugettext_lazy('Ishikawa'),),
('fukui', ugettext_lazy('Fukui'),),
('gifu', ugettext_lazy('Gifu'),),
('shizuoka', ugettext_lazy('Shizuoka'),),
('aichi', ugettext_lazy('Aichi'),),
('mie', ugettext_lazy('Mie'),),
('shiga', ugettext_lazy('Shiga'),),
('kyoto', ugettext_lazy('Kyoto'),),
('osaka', ugettext_lazy('Osaka'),),
('hyogo', ugettext_lazy('Hyogo'),),
('nara', ugettext_lazy('Nara'),),
('wakayama', ugettext_lazy('Wakayama'),),
('tottori', ugettext_lazy('Tottori'),),
('shimane', ugettext_lazy('Shimane'),),
('okayama', ugettext_lazy('Okayama'),),
('hiroshima', ugettext_lazy('Hiroshima'),),
('yamaguchi', ugettext_lazy('Yamaguchi'),),
('tokushima', ugettext_lazy('Tokushima'),),
('kagawa', ugettext_lazy('Kagawa'),),
('ehime', ugettext_lazy('Ehime'),),
('kochi', ugettext_lazy('Kochi'),),
('fukuoka', ugettext_lazy('Fukuoka'),),
('saga', ugettext_lazy('Saga'),),
('nagasaki', ugettext_lazy('Nagasaki'),),
('kumamoto', ugettext_lazy('Kumamoto'),),
('oita', ugettext_lazy('Oita'),),
('miyazaki', ugettext_lazy('Miyazaki'),),
('kagoshima', ugettext_lazy('Kagoshima'),),
('okinawa', ugettext_lazy('Okinawa'),),
)
|
apache-2.0
|
[
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
199,
199,
15819,
63,
4225,
38,
3582,
10799,
275,
334,
272,
661,
526,
75,
7351,
31090,
297,
10366,
63,
6395,
360,
40,
745,
7351,
31090,
659,
395,
272,
661,
65,
676,
16039,
297,
10366,
63,
6395,
360,
33,
676,
16039,
659,
395,
272,
661,
73,
87,
323,
297,
10366,
63,
6395,
360,
41,
87,
323,
659,
395,
272,
661,
2664,
89,
643,
73,
297,
10366,
63,
6395,
360,
14738,
89,
643,
73,
659,
395,
272,
661,
1151,
21492,
297,
10366,
63,
6395,
360,
33,
6065,
65,
659,
395,
272,
661,
11552,
5615,
419,
297,
10366,
63,
6395,
360,
28786,
5615,
419,
659,
395,
272,
661,
70,
3210,
2084,
11744,
297,
10366,
63,
6395,
360,
38,
3210,
2084,
11744,
659,
395,
272,
661,
73,
1700,
27387,
297,
10366,
63,
6395,
360,
41,
1700,
27387,
659,
395,
272,
661,
475,
335,
13721,
297,
10366,
63,
6395,
360,
1378,
335,
13721,
659,
395,
272,
661,
17924,
391,
297,
10366,
63,
6395,
360,
39,
324,
391,
659,
395,
272,
661,
2231,
390,
14541,
297,
10366,
63,
6395,
360,
51,
2781,
14541,
659,
395,
272,
661,
335,
1892,
65,
297,
10366,
63,
6395,
360,
1049,
1892,
65,
659,
395,
272,
661,
9305,
16540,
297,
10366,
63,
6395,
360,
29117,
16540,
659,
395,
272,
661,
29305,
643,
65,
758,
297,
10366,
63,
6395,
360,
43,
290,
643,
65,
758,
659,
395,
272,
661,
89,
455,
290,
1119,
73,
297,
10366,
63,
6395,
360,
57,
455,
290,
1119,
73,
659,
395,
272,
661,
78,
643,
8143,
297,
10366,
63,
6395,
360,
46,
643,
8143,
659,
395,
272,
661,
8445,
528,
419,
297,
10366,
63,
6395,
360,
20959,
528,
419,
659,
395,
272,
661,
475,
11552,
391,
297,
10366,
63,
6395,
360,
1378,
11552,
391,
659,
395,
272,
661,
2453,
26966,
758,
297,
10366,
63,
6395,
360,
41,
609,
26966,
758,
659,
395,
272,
661,
70,
3210,
1907,
297,
10366,
63,
6395,
360,
38,
3210,
1907,
659,
395,
272,
661,
14513,
85,
297,
10366,
63,
6395,
360,
39,
692,
85,
659,
395,
272,
661,
609,
565,
85,
745,
65,
297,
10366,
63,
6395,
360,
2662,
565,
85,
745,
65,
659,
395,
272,
661,
65,
1158,
73,
297,
10366,
63,
6395,
360,
33,
1158,
73,
659,
395,
272,
661,
77,
1873,
297,
10366,
63,
6395,
360,
45,
1873,
659,
395,
272,
661,
609,
29055,
297,
10366,
63,
6395,
360,
2662,
29055,
659,
395,
272,
661,
10562,
3459,
297,
10366,
63,
6395,
360,
43,
89,
3459,
659,
395,
272,
661,
736,
24685,
297,
10366,
63,
6395,
360,
24351,
24685,
659,
395,
272,
661,
3577,
974,
79,
297,
10366,
63,
6395,
360,
21568,
974,
79,
659,
395,
272,
661,
78,
17956,
297,
10366,
63,
6395,
360,
46,
17956,
659,
395,
272,
661,
758,
75,
1187,
14541,
297,
10366,
63,
6395,
360,
55,
1151,
1187,
14541,
659,
395,
272,
661,
13280,
8270,
73,
297,
10366,
63,
6395,
360,
52,
357,
8270,
73,
659,
395,
272,
661,
28238,
5865,
297,
10366,
63,
6395,
360,
2662,
1017,
5865,
659,
395,
272,
661,
745,
1187,
14541,
297,
10366,
63,
6395,
360,
11622,
1187,
14541,
659,
395,
272,
661,
5812,
293,
609,
11744,
297,
10366,
63,
6395,
360,
40,
14352,
609,
11744,
659,
395,
272,
661,
11552,
5615,
2133,
73,
297,
10366,
63,
6395,
360,
28786,
5615,
2133,
73,
659,
395,
272,
661,
9305,
2084,
11744,
297,
10366,
63,
6395,
360,
29117,
2084,
11744,
659,
395,
272,
661,
75,
643,
65,
758,
297,
10366,
63,
6395,
360,
43,
643,
65,
758,
659,
395,
272,
661,
24528,
1036,
297,
10366,
63,
6395,
360,
37,
72,
1036,
659,
395,
272,
661,
7697,
13175,
297,
10366,
63,
6395,
360,
31305,
13175,
659,
395,
272,
661,
70,
3210,
85,
745,
65,
297,
10366,
63,
6395,
360,
38,
3210,
85,
745,
65,
659,
395,
272,
661,
83,
643,
65,
297,
10366,
63,
6395,
360,
51,
643,
65,
659,
395,
272,
661,
78,
643,
305,
27387,
297,
10366,
63,
6395,
360,
46,
643,
305,
27387,
659,
395,
272,
661,
20661,
391,
77,
3459,
297,
10366,
63,
6395,
360,
31487,
391,
77,
3459,
659,
395,
272,
661,
79,
21492,
297,
10366,
63,
6395,
360,
47,
21492,
659,
395,
272,
661,
2664,
89,
4651,
27387,
297,
10366,
63,
6395,
360,
14738,
89,
4651,
27387,
659,
395,
272,
661,
75,
14315,
609,
11744,
297,
10366,
63,
6395,
360,
43,
14315,
609,
11744,
659,
395,
272,
661,
745,
13765,
758,
297,
10366,
63,
6395,
360,
11622,
13765,
758,
659,
395,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
199,
199,
15819,
63,
4225,
38,
3582,
10799,
275,
334,
272,
661,
526,
75,
7351,
31090,
297,
10366,
63,
6395,
360,
40,
745,
7351,
31090,
659,
395,
272,
661,
65,
676,
16039,
297,
10366,
63,
6395,
360,
33,
676,
16039,
659,
395,
272,
661,
73,
87,
323,
297,
10366,
63,
6395,
360,
41,
87,
323,
659,
395,
272,
661,
2664,
89,
643,
73,
297,
10366,
63,
6395,
360,
14738,
89,
643,
73,
659,
395,
272,
661,
1151,
21492,
297,
10366,
63,
6395,
360,
33,
6065,
65,
659,
395,
272,
661,
11552,
5615,
419,
297,
10366,
63,
6395,
360,
28786,
5615,
419,
659,
395,
272,
661,
70,
3210,
2084,
11744,
297,
10366,
63,
6395,
360,
38,
3210,
2084,
11744,
659,
395,
272,
661,
73,
1700,
27387,
297,
10366,
63,
6395,
360,
41,
1700,
27387,
659,
395,
272,
661,
475,
335,
13721,
297,
10366,
63,
6395,
360,
1378,
335,
13721,
659,
395,
272,
661,
17924,
391,
297,
10366,
63,
6395,
360,
39,
324,
391,
659,
395,
272,
661,
2231,
390,
14541,
297,
10366,
63,
6395,
360,
51,
2781,
14541,
659,
395,
272,
661,
335,
1892,
65,
297,
10366,
63,
6395,
360,
1049,
1892,
65,
659,
395,
272,
661,
9305,
16540,
297,
10366,
63,
6395,
360,
29117,
16540,
659,
395,
272,
661,
29305,
643,
65,
758,
297,
10366,
63,
6395,
360,
43,
290,
643,
65,
758,
659,
395,
272,
661,
89,
455,
290,
1119,
73,
297,
10366,
63,
6395,
360,
57,
455,
290,
1119,
73,
659,
395,
272,
661,
78,
643,
8143,
297,
10366,
63,
6395,
360,
46,
643,
8143,
659,
395,
272,
661,
8445,
528,
419,
297,
10366,
63,
6395,
360,
20959,
528,
419,
659,
395,
272,
661,
475,
11552,
391,
297,
10366,
63,
6395,
360,
1378,
11552,
391,
659,
395,
272,
661,
2453,
26966,
758,
297,
10366,
63,
6395,
360,
41,
609,
26966,
758,
659,
395,
272,
661,
70,
3210,
1907,
297,
10366,
63,
6395,
360,
38,
3210,
1907,
659,
395,
272,
661,
14513,
85,
297,
10366,
63,
6395,
360,
39,
692,
85,
659,
395,
272,
661,
609,
565,
85,
745,
65,
297,
10366,
63,
6395,
360,
2662,
565,
85,
745,
65,
659,
395,
272,
661,
65,
1158,
73,
297,
10366,
63,
6395,
360,
33,
1158,
73,
659,
395,
272,
661,
77,
1873,
297,
10366,
63,
6395,
360,
45,
1873,
659,
395,
272,
661,
609,
29055,
297,
10366,
63,
6395,
360,
2662,
29055,
659,
395,
272,
661,
10562,
3459,
297,
10366,
63,
6395,
360,
43,
89,
3459,
659,
395,
272,
661,
736,
24685,
297,
10366,
63,
6395,
360,
24351,
24685,
659,
395,
272,
661,
3577,
974,
79,
297,
10366,
63,
6395,
360,
21568,
974,
79,
659,
395,
272,
661,
78,
17956,
297,
10366,
63,
6395,
360,
46,
17956,
659,
395,
272,
661,
758,
75,
1187,
14541,
297,
10366,
63,
6395,
360,
55,
1151,
1187,
14541,
659,
395,
272,
661,
13280,
8270,
73,
297,
10366,
63,
6395,
360,
52,
357,
8270,
73,
659,
395,
272,
661,
28238,
5865,
297,
10366,
63,
6395,
360,
2662,
1017,
5865,
659,
395,
272,
661,
745,
1187,
14541,
297,
10366,
63,
6395,
360,
11622,
1187,
14541,
659,
395,
272,
661,
5812,
293,
609,
11744,
297,
10366,
63,
6395,
360,
40,
14352,
609,
11744,
659,
395,
272,
661,
11552,
5615,
2133,
73,
297,
10366,
63,
6395,
360,
28786,
5615,
2133,
73,
659,
395,
272,
661,
9305,
2084,
11744,
297,
10366,
63,
6395,
360,
29117,
2084,
11744,
659,
395,
272,
661,
75,
643,
65,
758,
297,
10366,
63,
6395,
360,
43,
643,
65,
758,
659,
395,
272,
661,
24528,
1036,
297,
10366,
63,
6395,
360,
37,
72,
1036,
659,
395,
272,
661,
7697,
13175,
297,
10366,
63,
6395,
360,
31305,
13175,
659,
395,
272,
661,
70,
3210,
85,
745,
65,
297,
10366,
63,
6395,
360,
38,
3210,
85,
745,
65,
659,
395,
272,
661,
83,
643,
65,
297,
10366,
63,
6395,
360,
51,
643,
65,
659,
395,
272,
661,
78,
643,
305,
27387,
297,
10366,
63,
6395,
360,
46,
643,
305,
27387,
659,
395,
272,
661,
20661,
391,
77,
3459,
297,
10366,
63,
6395,
360,
31487,
391,
77,
3459,
659,
395,
272,
661,
79,
21492,
297,
10366,
63,
6395,
360,
47,
21492,
659,
395,
272,
661,
2664,
89,
4651,
27387,
297,
10366,
63,
6395,
360,
14738,
89,
4651,
27387,
659,
395,
272,
661,
75,
14315,
609,
11744,
297,
10366,
63,
6395,
360,
43,
14315,
609,
11744,
659,
395,
272,
661,
745,
13765,
758,
297,
10366,
63,
6395,
360,
11622,
13765,
758,
659,
395,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
shsingh/ansible
|
lib/ansible/galaxy/__init__.py
|
51
|
2495
|
########################################################################
#
# (C) 2015, Brian Coca <bcoca@ansible.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/>.
#
########################################################################
''' This manages remote shared Ansible objects, mainly roles'''
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import yaml
import ansible.constants as C
from ansible import context
from ansible.module_utils._text import to_bytes
# default_readme_template
# default_meta_template
def get_collections_galaxy_meta_info():
meta_path = os.path.join(os.path.dirname(__file__), 'data', 'collections_galaxy_meta.yml')
with open(to_bytes(meta_path, errors='surrogate_or_strict'), 'rb') as galaxy_obj:
return yaml.safe_load(galaxy_obj)
class Galaxy(object):
''' Keeps global galaxy info '''
def __init__(self):
# TODO: eventually remove this as it contains a mismash of properties that aren't really global
# roles_path needs to be a list and will be by default
roles_path = context.CLIARGS.get('roles_path', C.DEFAULT_ROLES_PATH)
# cli option handling is responsible for splitting roles_path
self.roles_paths = roles_path
self.roles = {}
# load data path for resource usage
this_dir, this_filename = os.path.split(__file__)
type_path = context.CLIARGS.get('role_type', 'default')
if type_path == 'default':
type_path = os.path.join(type_path, context.CLIARGS.get('type'))
self.DATA_PATH = os.path.join(this_dir, 'data', type_path)
@property
def default_role_skeleton_path(self):
return self.DATA_PATH
def add_role(self, role):
self.roles[role.name] = role
def remove_role(self, role_name):
del self.roles[role_name]
|
gpl-3.0
|
[
3949,
199,
3,
199,
3,
334,
35,
9,
6900,
12,
699,
18429,
445,
679,
65,
665,
66,
331,
696,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
3949,
199,
2344,
961,
31965,
3982,
5709,
2622,
2251,
12,
27580,
11689,
2344,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
8864,
199,
199,
646,
3242,
14,
5559,
465,
445,
199,
504,
3242,
492,
1067,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
2394,
199,
199,
3,
420,
849,
63,
32709,
63,
1160,
199,
3,
420,
849,
63,
2024,
63,
1160,
421,
199,
318,
664,
63,
7882,
63,
24806,
63,
2024,
63,
815,
837,
272,
3404,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
576,
297,
283,
7882,
63,
24806,
63,
2024,
14,
11714,
358,
272,
543,
1551,
8,
475,
63,
2394,
8,
2024,
63,
515,
12,
2552,
534,
16380,
63,
269,
63,
4768,
659,
283,
4848,
358,
465,
486,
15914,
63,
1113,
26,
267,
372,
8864,
14,
3489,
63,
912,
8,
24806,
63,
1113,
9,
421,
199,
533,
598,
15914,
8,
785,
304,
272,
1449,
1804,
1024,
1190,
2288,
486,
15914,
2256,
1449,
339,
347,
636,
826,
721,
277,
304,
267,
327,
3254,
26,
21356,
2813,
642,
465,
652,
3509,
282,
3201,
77,
1119,
402,
4382,
626,
10621,
1133,
7710,
2288,
398,
327,
11689,
63,
515,
4839,
370,
506,
282,
769,
436,
911,
506,
701,
849,
267,
11689,
63,
515,
275,
1067,
14,
7802,
13990,
14,
362,
360,
8050,
63,
515,
297,
445,
14,
3472,
63,
6245,
654,
63,
3243,
9,
267,
327,
5053,
945,
7252,
365,
17845,
367,
26518,
11689,
63,
515,
267,
291,
14,
8050,
63,
3771,
275,
11689,
63,
515,
398,
291,
14,
8050,
275,
1052,
398,
327,
2248,
666,
931,
367,
2073,
4503,
267,
642,
63,
694,
12,
642,
63,
1501,
275,
747,
14,
515,
14,
1294,
3460,
493,
3368,
267,
730,
63,
515,
275,
1067,
14,
7802,
13990,
14,
362,
360,
3756,
63,
466,
297,
283,
885,
358,
267,
340,
730,
63,
515,
508,
283,
885,
356,
288,
730,
63,
515,
275,
747,
14,
515,
14,
904,
8,
466,
63,
515,
12,
1067,
14,
7802,
13990,
14,
362,
360,
466,
1333,
398,
291,
14,
3998,
63,
3243,
275,
747,
14,
515,
14,
904,
8,
3749,
63,
694,
12,
283,
576,
297,
730,
63,
515,
9,
339,
768,
1829,
272,
347,
849,
63,
3756,
63,
29250,
63,
515,
8,
277,
304,
267,
372,
291,
14,
3998,
63,
3243,
339,
347,
1050,
63,
3756,
8,
277,
12,
4719,
304,
267,
291,
14,
8050,
59,
3756,
14,
354,
61,
275,
4719,
339,
347,
2813,
63,
3756,
8,
277,
12,
4719,
63,
354,
304,
267,
2150,
291,
14,
8050,
59,
3756,
63,
354,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
199,
3,
334,
35,
9,
6900,
12,
699,
18429,
445,
679,
65,
665,
66,
331,
696,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
3949,
199,
2344,
961,
31965,
3982,
5709,
2622,
2251,
12,
27580,
11689,
2344,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
8864,
199,
199,
646,
3242,
14,
5559,
465,
445,
199,
504,
3242,
492,
1067,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
2394,
199,
199,
3,
420,
849,
63,
32709,
63,
1160,
199,
3,
420,
849,
63,
2024,
63,
1160,
421,
199,
318,
664,
63,
7882,
63,
24806,
63,
2024,
63,
815,
837,
272,
3404,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
576,
297,
283,
7882,
63,
24806,
63,
2024,
14,
11714,
358,
272,
543,
1551,
8,
475,
63,
2394,
8,
2024,
63,
515,
12,
2552,
534,
16380,
63,
269,
63,
4768,
659,
283,
4848,
358,
465,
486,
15914,
63,
1113,
26,
267,
372,
8864,
14,
3489,
63,
912,
8,
24806,
63,
1113,
9,
421,
199,
533,
598,
15914,
8,
785,
304,
272,
1449,
1804,
1024,
1190,
2288,
486,
15914,
2256,
1449,
339,
347,
636,
826,
721,
277,
304,
267,
327,
3254,
26,
21356,
2813,
642,
465,
652,
3509,
282,
3201,
77,
1119,
402,
4382,
626,
10621,
1133,
7710,
2288,
398,
327,
11689,
63,
515,
4839,
370,
506,
282,
769,
436,
911,
506,
701,
849,
267,
11689,
63,
515,
275,
1067,
14,
7802,
13990,
14,
362,
360,
8050,
63,
515,
297,
445,
14,
3472,
63,
6245,
654,
63,
3243,
9,
267,
327,
5053,
945,
7252,
365,
17845,
367,
26518,
11689,
63,
515,
267,
291,
14,
8050,
63,
3771,
275,
11689,
63,
515,
398,
291,
14,
8050,
275,
1052,
398,
327,
2248,
666,
931,
367,
2073,
4503,
267,
642,
63,
694,
12,
642,
63,
1501,
275,
747,
14,
515,
14,
1294,
3460,
493,
3368,
267,
730,
63,
515,
275,
1067,
14,
7802,
13990,
14,
362,
360,
3756,
63,
466,
297,
283,
885,
358,
267,
340,
730,
63,
515,
508,
283,
885,
356,
288,
730,
63,
515,
275,
747,
14,
515,
14,
904,
8,
466,
63,
515,
12,
1067,
14,
7802,
13990,
14,
362,
360,
466,
1333,
398,
291,
14,
3998,
63,
3243,
275,
747,
14,
515,
14,
904,
8,
3749,
63,
694,
12,
283,
576,
297,
730,
63,
515,
9,
339,
768,
1829,
272,
347,
849,
63,
3756,
63,
29250,
63,
515,
8,
277,
304,
267,
372,
291,
14,
3998,
63,
3243,
339,
347,
1050,
63,
3756,
8,
277,
12,
4719,
304,
267,
291,
14,
8050,
59,
3756,
14,
354,
61,
275,
4719,
339,
347,
2813,
63,
3756,
8,
277,
12,
4719,
63,
354,
304,
267,
2150,
291,
14,
8050,
59,
3756,
63,
354,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
40223117cda/w16cdaa
|
static/Brython3.1.0-20150301-090019/Lib/site-packages/pygame/sprite.py
|
603
|
55779
|
## pygame - Python Game Library
## Copyright (C) 2000-2003, 2007 Pete Shinners
## (C) 2004 Joe Wreschnig
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Library General Public
## License as published by the Free Software Foundation; either
## version 2 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
## Library General Public License for more details.
##
## You should have received a copy of the GNU Library General Public
## License along with this library; if not, write to the Free
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
## Pete Shinners
## pete@shinners.org
"""pygame module with basic game object classes
This module contains several simple classes to be used within games. There
are the main Sprite class and several Group classes that contain Sprites.
The use of these classes is entirely optional when using Pygame. The classes
are fairly lightweight and only provide a starting place for the code
that is common to most games.
The Sprite class is intended to be used as a base class for the different
types of objects in the game. There is also a base Group class that simply
stores sprites. A game could create new types of Group classes that operate
on specially customized Sprite instances they contain.
The basic Sprite class can draw the Sprites it contains to a Surface. The
Group.draw() method requires that each Sprite have a Surface.image attribute
and a Surface.rect. The Group.clear() method requires these same attributes
and can be used to erase all the Sprites with background. There are also
more advanced Groups: pygame.sprite.RenderUpdates() and
pygame.sprite.OrderedUpdates().
Lastly, this module contains several collision functions. These help find
sprites inside multiple groups that have intersecting bounding rectangles.
To find the collisions, the Sprites are required to have a Surface.rect
attribute assigned.
The groups are designed for high efficiency in removing and adding Sprites
to them. They also allow cheap testing to see if a Sprite already exists in
a Group. A given Sprite can exist in any number of groups. A game could use
some groups to control object rendering, and a completely separate set of
groups to control interaction or player movement. Instead of adding type
attributes or bools to a derived Sprite class, consider keeping the
Sprites inside organized Groups. This will allow for easier lookup later
in the game.
Sprites and Groups manage their relationships with the add() and remove()
methods. These methods can accept a single or multiple group arguments for
membership. The default initializers for these classes also take a
single group or list of groups as argments for initial membership. It is safe
to repeatedly add and remove the same Sprite from a Group.
While it is possible to design sprite and group classes that don't derive
from the Sprite and AbstractGroup classes below, it is strongly recommended
that you extend those when you create a new Sprite or Group class.
Sprites are not thread safe, so lock them yourself if using threads.
"""
##todo
## a group that holds only the 'n' most recent elements.
## sort of like the GroupSingle class, but holding more
## than one sprite
##
## drawing groups that can 'automatically' store the area
## underneath so they can "clear" without needing a background
## function. obviously a little slower than normal, but nice
## to use in many situations. (also remember it must "clear"
## in the reverse order that it draws :])
##
## the drawing groups should also be able to take a background
## function, instead of just a background surface. the function
## would take a surface and a rectangle on that surface to erase.
##
## perhaps more types of collision functions? the current two
## should handle just about every need, but perhaps more optimized
## specific ones that aren't quite so general but fit into common
## specialized cases.
import pygame
from pygame.rect import Rect
from pygame.time import get_ticks
from operator import truth
# Python 3 does not have the callable function, but an equivalent can be made
# with the hasattr function.
#if 'callable' not in dir(__builtins__):
callable = lambda obj: hasattr(obj, '__call__')
# Don't depend on pygame.mask if it's not there...
try:
from pygame.mask import from_surface
except:
pass
class Sprite(object):
"""simple base class for visible game objects
pygame.sprite.Sprite(*groups): return Sprite
The base class for visible game objects. Derived classes will want to
override the Sprite.update() method and assign Sprite.image and Sprite.rect
attributes. The initializer can accept any number of Group instances that
the Sprite will become a member of.
When subclassing the Sprite class, be sure to call the base initializer
before adding the Sprite to Groups.
"""
def __init__(self, *groups):
self.__g = {} # The groups the sprite is in
if groups:
self.add(*groups)
def add(self, *groups):
"""add the sprite to groups
Sprite.add(*groups): return None
Any number of Group instances can be passed as arguments. The
Sprite will be added to the Groups it is not already a member of.
"""
has = self.__g.__contains__
for group in groups:
if hasattr(group, '_spritegroup'):
if not has(group):
group.add_internal(self)
self.add_internal(group)
else:
self.add(*group)
def remove(self, *groups):
"""remove the sprite from groups
Sprite.remove(*groups): return None
Any number of Group instances can be passed as arguments. The Sprite
will be removed from the Groups it is currently a member of.
"""
has = self.__g.__contains__
for group in groups:
if hasattr(group, '_spritegroup'):
if has(group):
group.remove_internal(self)
self.remove_internal(group)
else:
self.remove(*group)
def add_internal(self, group):
self.__g[group] = 0
def remove_internal(self, group):
del self.__g[group]
def update(self, *args):
"""method to control sprite behavior
Sprite.update(*args):
The default implementation of this method does nothing; it's just a
convenient "hook" that you can override. This method is called by
Group.update() with whatever arguments you give it.
There is no need to use this method if not using the convenience
method by the same name in the Group class.
"""
pass
def kill(self):
"""remove the Sprite from all Groups
Sprite.kill(): return None
The Sprite is removed from all the Groups that contain it. This won't
change anything about the state of the Sprite. It is possible to
continue to use the Sprite after this method has been called, including
adding it to Groups.
"""
for c in self.__g:
c.remove_internal(self)
self.__g.clear()
def groups(self):
"""list of Groups that contain this Sprite
Sprite.groups(): return group_list
Returns a list of all the Groups that contain this Sprite.
"""
return list(self.__g)
def alive(self):
"""does the sprite belong to any groups
Sprite.alive(): return bool
Returns True when the Sprite belongs to one or more Groups.
"""
return truth(self.__g)
def __repr__(self):
return "<%s sprite(in %d groups)>" % (self.__class__.__name__, len(self.__g))
class DirtySprite(Sprite):
"""a more featureful subclass of Sprite with more attributes
pygame.sprite.DirtySprite(*groups): return DirtySprite
Extra DirtySprite attributes with their default values:
dirty = 1
If set to 1, it is repainted and then set to 0 again.
If set to 2, it is always dirty (repainted each frame;
flag is not reset).
If set to 0, it is not dirty and therefore not repainted again.
blendmode = 0
It's the special_flags argument of Surface.blit; see the blendmodes in
the Surface.blit documentation
source_rect = None
This is the source rect to use. Remember that it is relative to the top
left corner (0, 0) of self.image.
visible = 1
Normally this is 1. If set to 0, it will not be repainted. (If you
change visible to 1, you must set dirty to 1 for it to be erased from
the screen.)
_layer = 0
A READ ONLY value, it is read when adding it to the LayeredUpdates
group. For details see documentation of sprite.LayeredUpdates.
"""
def __init__(self, *groups):
self.dirty = 1
self.blendmode = 0 # pygame 1.8, referred to as special_flags in
# the documentation of Surface.blit
self._visible = 1
self._layer = 0 # READ ONLY by LayeredUpdates or LayeredDirty
self.source_rect = None
Sprite.__init__(self, *groups)
def _set_visible(self, val):
"""set the visible value (0 or 1) and makes the sprite dirty"""
self._visible = val
if self.dirty < 2:
self.dirty = 1
def _get_visible(self):
"""return the visible value of that sprite"""
return self._visible
visible = property(lambda self: self._get_visible(),
lambda self, value: self._set_visible(value),
doc="you can make this sprite disappear without "
"removing it from the group,\n"
"assign 0 for invisible and 1 for visible")
def __repr__(self):
return "<%s DirtySprite(in %d groups)>" % \
(self.__class__.__name__, len(self.groups()))
class AbstractGroup(object):
"""base class for containers of sprites
AbstractGroup does everything needed to behave as a normal group. You can
easily subclass a new group class from this or the other groups below if
you want to add more features.
Any AbstractGroup-derived sprite groups act like sequences and support
iteration, len, and so on.
"""
# dummy val to identify sprite groups, and avoid infinite recursion
_spritegroup = True
def __init__(self):
self.spritedict = {}
self.lostsprites = []
def sprites(self):
"""get a list of sprites in the group
Group.sprite(): return list
Returns an object that can be looped over with a 'for' loop. (For now,
it is always a list, but this could change in a future version of
pygame.) Alternatively, you can get the same information by iterating
directly over the sprite group, e.g. 'for sprite in group'.
"""
return list(self.spritedict)
def add_internal(self, sprite):
self.spritedict[sprite] = 0
def remove_internal(self, sprite):
r = self.spritedict[sprite]
if r:
self.lostsprites.append(r)
del self.spritedict[sprite]
def has_internal(self, sprite):
return sprite in self.spritedict
def copy(self):
"""copy a group with all the same sprites
Group.copy(): return Group
Returns a copy of the group that is an instance of the same class
and has the same sprites in it.
"""
return self.__class__(self.sprites())
def __iter__(self):
return iter(self.sprites())
def __contains__(self, sprite):
return self.has(sprite)
def add(self, *sprites):
"""add sprite(s) to group
Group.add(sprite, list, group, ...): return None
Adds a sprite or sequence of sprites to a group.
"""
for sprite in sprites:
# It's possible that some sprite is also an iterator.
# If this is the case, we should add the sprite itself,
# and not the iterator object.
if isinstance(sprite, Sprite):
if not self.has_internal(sprite):
self.add_internal(sprite)
sprite.add_internal(self)
else:
try:
# See if sprite is an iterator, like a list or sprite
# group.
self.add(*sprite)
except (TypeError, AttributeError):
# Not iterable. This is probably a sprite that is not an
# instance of the Sprite class or is not an instance of a
# subclass of the Sprite class. Alternately, it could be an
# old-style sprite group.
if hasattr(sprite, '_spritegroup'):
for spr in sprite.sprites():
if not self.has_internal(spr):
self.add_internal(spr)
spr.add_internal(self)
elif not self.has_internal(sprite):
self.add_internal(sprite)
sprite.add_internal(self)
def remove(self, *sprites):
"""remove sprite(s) from group
Group.remove(sprite, list, or group, ...): return None
Removes a sprite or sequence of sprites from a group.
"""
# This function behaves essentially the same as Group.add. It first
# tries to handle each argument as an instance of the Sprite class. If
# that failes, then it tries to handle the argument as an iterable
# object. If that failes, then it tries to handle the argument as an
# old-style sprite group. Lastly, if that fails, it assumes that the
# normal Sprite methods should be used.
for sprite in sprites:
if isinstance(sprite, Sprite):
if self.has_internal(sprite):
self.remove_internal(sprite)
sprite.remove_internal(self)
else:
try:
self.remove(*sprite)
except (TypeError, AttributeError):
if hasattr(sprite, '_spritegroup'):
for spr in sprite.sprites():
if self.has_internal(spr):
self.remove_internal(spr)
spr.remove_internal(self)
elif self.has_internal(sprite):
self.remove_internal(sprite)
sprite.remove_internal(self)
def has(self, *sprites):
"""ask if group has a sprite or sprites
Group.has(sprite or group, ...): return bool
Returns True if the given sprite or sprites are contained in the
group. Alternatively, you can get the same information using the
'in' operator, e.g. 'sprite in group', 'subgroup in group'.
"""
return_value = False
for sprite in sprites:
if isinstance(sprite, Sprite):
# Check for Sprite instance's membership in this group
if self.has_internal(sprite):
return_value = True
else:
return False
else:
try:
if self.has(*sprite):
return_value = True
else:
return False
except (TypeError, AttributeError):
if hasattr(sprite, '_spritegroup'):
for spr in sprite.sprites():
if self.has_internal(spr):
return_value = True
else:
return False
else:
if self.has_internal(sprite):
return_value = True
else:
return False
return return_value
def update(self, *args):
"""call the update method of every member sprite
Group.update(*args): return None
Calls the update method of every member sprite. All arguments that
were passed to this method are passed to the Sprite update function.
"""
for s in self.sprites():
s.update(*args)
def draw(self, surface):
"""draw all sprites onto the surface
Group.draw(surface): return None
Draws all of the member sprites onto the given surface.
"""
#from javascript import console
sprites = self.sprites()
surface_blit = surface.blit
for spr in sprites:
#console.log(spr.image, spr.rect)
#console.log(spr.image._canvas.width, spr.image._canvas.height)
self.spritedict[spr] = surface_blit(spr.image, spr.rect)
self.lostsprites = []
def clear(self, surface, bgd):
"""erase the previous position of all sprites
Group.clear(surface, bgd): return None
Clears the area under every drawn sprite in the group. The bgd
argument should be Surface which is the same dimensions as the
screen surface. The bgd could also be a function which accepts
the given surface and the area to be cleared as arguments.
"""
if callable(bgd):
for r in self.lostsprites:
bgd(surface, r)
for r in self.spritedict.values():
if r:
bgd(surface, r)
else:
surface_blit = surface.blit
for r in self.lostsprites:
surface_blit(bgd, r, r)
for r in self.spritedict.values():
if r:
surface_blit(bgd, r, r)
def empty(self):
"""remove all sprites
Group.empty(): return None
Removes all the sprites from the group.
"""
for s in self.sprites():
self.remove_internal(s)
s.remove_internal(self)
def __nonzero__(self):
return truth(self.sprites())
def __len__(self):
"""return number of sprites in group
Group.len(group): return int
Returns the number of sprites contained in the group.
"""
return len(self.sprites())
def __repr__(self):
return "<%s(%d sprites)>" % (self.__class__.__name__, len(self))
class Group(AbstractGroup):
"""container class for many Sprites
pygame.sprite.Group(*sprites): return Group
A simple container for Sprite objects. This class can be subclassed to
create containers with more specific behaviors. The constructor takes any
number of Sprite arguments to add to the Group. The group supports the
following standard Python operations:
in test if a Sprite is contained
len the number of Sprites contained
bool test if any Sprites are contained
iter iterate through all the Sprites
The Sprites in the Group are not ordered, so the Sprites are drawn and
iterated over in no particular order.
"""
def __init__(self, *sprites):
AbstractGroup.__init__(self)
self.add(*sprites)
RenderPlain = Group
RenderClear = Group
class RenderUpdates(Group):
"""Group class that tracks dirty updates
pygame.sprite.RenderUpdates(*sprites): return RenderUpdates
This class is derived from pygame.sprite.Group(). It has an enhanced draw
method that tracks the changed areas of the screen.
"""
def draw(self, surface):
spritedict = self.spritedict
surface_blit = surface.blit
dirty = self.lostsprites
self.lostsprites = []
dirty_append = dirty.append
for s in self.sprites():
r = spritedict[s]
newrect = surface_blit(s.image, s.rect)
if r:
if newrect.colliderect(r):
dirty_append(newrect.union(r))
else:
dirty_append(newrect)
dirty_append(r)
else:
dirty_append(newrect)
spritedict[s] = newrect
return dirty
class OrderedUpdates(RenderUpdates):
"""RenderUpdates class that draws Sprites in order of addition
pygame.sprite.OrderedUpdates(*spites): return OrderedUpdates
This class derives from pygame.sprite.RenderUpdates(). It maintains
the order in which the Sprites were added to the Group for rendering.
This makes adding and removing Sprites from the Group a little
slower than regular Groups.
"""
def __init__(self, *sprites):
self._spritelist = []
RenderUpdates.__init__(self, *sprites)
def sprites(self):
return list(self._spritelist)
def add_internal(self, sprite):
RenderUpdates.add_internal(self, sprite)
self._spritelist.append(sprite)
def remove_internal(self, sprite):
RenderUpdates.remove_internal(self, sprite)
self._spritelist.remove(sprite)
class LayeredUpdates(AbstractGroup):
"""LayeredUpdates Group handles layers, which are drawn like OrderedUpdates
pygame.sprite.LayeredUpdates(*spites, **kwargs): return LayeredUpdates
This group is fully compatible with pygame.sprite.Sprite.
New in pygame 1.8.0
"""
_init_rect = Rect(0, 0, 0, 0)
def __init__(self, *sprites, **kwargs):
"""initialize an instance of LayeredUpdates with the given attributes
You can set the default layer through kwargs using 'default_layer'
and an integer for the layer. The default layer is 0.
If the sprite you add has an attribute _layer, then that layer will be
used. If **kwarg contains 'layer', then the passed sprites will be
added to that layer (overriding the sprite._layer attribute). If
neither the sprite nor **kwarg has a 'layer', then the default layer is
used to add the sprites.
"""
self._spritelayers = {}
self._spritelist = []
AbstractGroup.__init__(self)
self._default_layer = kwargs.get('default_layer', 0)
self.add(*sprites, **kwargs)
def add_internal(self, sprite, layer=None):
"""Do not use this method directly.
It is used by the group to add a sprite internally.
"""
self.spritedict[sprite] = self._init_rect
if layer is None:
try:
layer = sprite._layer
except AttributeError:
layer = sprite._layer = self._default_layer
elif hasattr(sprite, '_layer'):
sprite._layer = layer
sprites = self._spritelist # speedup
sprites_layers = self._spritelayers
sprites_layers[sprite] = layer
# add the sprite at the right position
# bisect algorithmus
leng = len(sprites)
low = mid = 0
high = leng - 1
while low <= high:
mid = low + (high - low) // 2
if sprites_layers[sprites[mid]] <= layer:
low = mid + 1
else:
high = mid - 1
# linear search to find final position
while mid < leng and sprites_layers[sprites[mid]] <= layer:
mid += 1
sprites.insert(mid, sprite)
def add(self, *sprites, **kwargs):
"""add a sprite or sequence of sprites to a group
LayeredUpdates.add(*sprites, **kwargs): return None
If the sprite you add has an attribute _layer, then that layer will be
used. If **kwarg contains 'layer', then the passed sprites will be
added to that layer (overriding the sprite._layer attribute). If
neither the sprite nor **kwarg has a 'layer', then the default layer is
used to add the sprites.
"""
if not sprites:
return
if 'layer' in kwargs:
layer = kwargs['layer']
else:
layer = None
for sprite in sprites:
# It's possible that some sprite is also an iterator.
# If this is the case, we should add the sprite itself,
# and not the iterator object.
if isinstance(sprite, Sprite):
if not self.has_internal(sprite):
self.add_internal(sprite, layer)
sprite.add_internal(self)
else:
try:
# See if sprite is an iterator, like a list or sprite
# group.
self.add(*sprite, **kwargs)
except (TypeError, AttributeError):
# Not iterable. This is probably a sprite that is not an
# instance of the Sprite class or is not an instance of a
# subclass of the Sprite class. Alternately, it could be an
# old-style sprite group.
if hasattr(sprite, '_spritegroup'):
for spr in sprite.sprites():
if not self.has_internal(spr):
self.add_internal(spr, layer)
spr.add_internal(self)
elif not self.has_internal(sprite):
self.add_internal(sprite, layer)
sprite.add_internal(self)
def remove_internal(self, sprite):
"""Do not use this method directly.
The group uses it to add a sprite.
"""
self._spritelist.remove(sprite)
# these dirty rects are suboptimal for one frame
r = self.spritedict[sprite]
if r is not self._init_rect:
self.lostsprites.append(r) # dirty rect
if hasattr(sprite, 'rect'):
self.lostsprites.append(sprite.rect) # dirty rect
del self.spritedict[sprite]
del self._spritelayers[sprite]
def sprites(self):
"""return a ordered list of sprites (first back, last top).
LayeredUpdates.sprites(): return sprites
"""
return list(self._spritelist)
def draw(self, surface):
"""draw all sprites in the right order onto the passed surface
LayeredUpdates.draw(surface): return Rect_list
"""
spritedict = self.spritedict
surface_blit = surface.blit
dirty = self.lostsprites
self.lostsprites = []
dirty_append = dirty.append
init_rect = self._init_rect
for spr in self.sprites():
rec = spritedict[spr]
newrect = surface_blit(spr.image, spr.rect)
if rec is init_rect:
dirty_append(newrect)
else:
if newrect.colliderect(rec):
dirty_append(newrect.union(rec))
else:
dirty_append(newrect)
dirty_append(rec)
spritedict[spr] = newrect
return dirty
def get_sprites_at(self, pos):
"""return a list with all sprites at that position
LayeredUpdates.get_sprites_at(pos): return colliding_sprites
Bottom sprites are listed first; the top ones are listed last.
"""
_sprites = self._spritelist
rect = Rect(pos, (0, 0))
colliding_idx = rect.collidelistall(_sprites)
colliding = [_sprites[i] for i in colliding_idx]
return colliding
def get_sprite(self, idx):
"""return the sprite at the index idx from the groups sprites
LayeredUpdates.get_sprite(idx): return sprite
Raises IndexOutOfBounds if the idx is not within range.
"""
return self._spritelist[idx]
def remove_sprites_of_layer(self, layer_nr):
"""remove all sprites from a layer and return them as a list
LayeredUpdates.remove_sprites_of_layer(layer_nr): return sprites
"""
sprites = self.get_sprites_from_layer(layer_nr)
self.remove(*sprites)
return sprites
#---# layer methods
def layers(self):
"""return a list of unique defined layers defined.
LayeredUpdates.layers(): return layers
"""
return sorted(set(self._spritelayers.values()))
def change_layer(self, sprite, new_layer):
"""change the layer of the sprite
LayeredUpdates.change_layer(sprite, new_layer): return None
The sprite must have been added to the renderer already. This is not
checked.
"""
sprites = self._spritelist # speedup
sprites_layers = self._spritelayers # speedup
sprites.remove(sprite)
sprites_layers.pop(sprite)
# add the sprite at the right position
# bisect algorithmus
leng = len(sprites)
low = mid = 0
high = leng - 1
while low <= high:
mid = low + (high - low) // 2
if sprites_layers[sprites[mid]] <= new_layer:
low = mid + 1
else:
high = mid - 1
# linear search to find final position
while mid < leng and sprites_layers[sprites[mid]] <= new_layer:
mid += 1
sprites.insert(mid, sprite)
if hasattr(sprite, 'layer'):
sprite.layer = new_layer
# add layer info
sprites_layers[sprite] = new_layer
def get_layer_of_sprite(self, sprite):
"""return the layer that sprite is currently in
If the sprite is not found, then it will return the default layer.
"""
return self._spritelayers.get(sprite, self._default_layer)
def get_top_layer(self):
"""return the top layer
LayeredUpdates.get_top_layer(): return layer
"""
return self._spritelayers[self._spritelist[-1]]
def get_bottom_layer(self):
"""return the bottom layer
LayeredUpdates.get_bottom_layer(): return layer
"""
return self._spritelayers[self._spritelist[0]]
def move_to_front(self, sprite):
"""bring the sprite to front layer
LayeredUpdates.move_to_front(sprite): return None
Brings the sprite to front by changing the sprite layer to the top-most
layer. The sprite is added at the end of the list of sprites in that
top-most layer.
"""
self.change_layer(sprite, self.get_top_layer())
def move_to_back(self, sprite):
"""move the sprite to the bottom layer
LayeredUpdates.move_to_back(sprite): return None
Moves the sprite to the bottom layer by moving it to a new layer below
the current bottom layer.
"""
self.change_layer(sprite, self.get_bottom_layer() - 1)
def get_top_sprite(self):
"""return the topmost sprite
LayeredUpdates.get_top_sprite(): return Sprite
"""
return self._spritelist[-1]
def get_sprites_from_layer(self, layer):
"""return all sprites from a layer ordered as they where added
LayeredUpdates.get_sprites_from_layer(layer): return sprites
Returns all sprites from a layer. The sprites are ordered in the
sequence that they where added. (The sprites are not removed from the
layer.
"""
sprites = []
sprites_append = sprites.append
sprite_layers = self._spritelayers
for spr in self._spritelist:
if sprite_layers[spr] == layer:
sprites_append(spr)
elif sprite_layers[spr] > layer:# break after because no other will
# follow with same layer
break
return sprites
def switch_layer(self, layer1_nr, layer2_nr):
"""switch the sprites from layer1_nr to layer2_nr
LayeredUpdates.switch_layer(layer1_nr, layer2_nr): return None
The layers number must exist. This method does not check for the
existence of the given layers.
"""
sprites1 = self.remove_sprites_of_layer(layer1_nr)
for spr in self.get_sprites_from_layer(layer2_nr):
self.change_layer(spr, layer1_nr)
self.add(layer=layer2_nr, *sprites1)
class LayeredDirty(LayeredUpdates):
"""LayeredDirty Group is for DirtySprites; subclasses LayeredUpdates
pygame.sprite.LayeredDirty(*spites, **kwargs): return LayeredDirty
This group requires pygame.sprite.DirtySprite or any sprite that
has the following attributes:
image, rect, dirty, visible, blendmode (see doc of DirtySprite).
It uses the dirty flag technique and is therefore faster than
pygame.sprite.RenderUpdates if you have many static sprites. It
also switches automatically between dirty rect updating and full
screen drawing, so you do no have to worry which would be faster.
As with the pygame.sprite.Group, you can specify some additional attributes
through kwargs:
_use_update: True/False (default is False)
_default_layer: default layer where the sprites without a layer are
added
_time_threshold: treshold time for switching between dirty rect mode
and fullscreen mode; defaults to updating at 80 frames per second,
which is equal to 1000.0 / 80.0
New in pygame 1.8.0
"""
def __init__(self, *sprites, **kwargs):
"""initialize group.
pygame.sprite.LayeredDirty(*spites, **kwargs): return LayeredDirty
You can specify some additional attributes through kwargs:
_use_update: True/False (default is False)
_default_layer: default layer where the sprites without a layer are
added
_time_threshold: treshold time for switching between dirty rect
mode and fullscreen mode; defaults to updating at 80 frames per
second, which is equal to 1000.0 / 80.0
"""
LayeredUpdates.__init__(self, *sprites, **kwargs)
self._clip = None
self._use_update = False
self._time_threshold = 1000.0 / 80.0 # 1000.0 / fps
self._bgd = None
for key, val in kwargs.items():
if key in ['_use_update', '_time_threshold', '_default_layer']:
if hasattr(self, key):
setattr(self, key, val)
def add_internal(self, sprite, layer=None):
"""Do not use this method directly.
It is used by the group to add a sprite internally.
"""
# check if all needed attributes are set
if not hasattr(sprite, 'dirty'):
raise AttributeError()
if not hasattr(sprite, 'visible'):
raise AttributeError()
if not hasattr(sprite, 'blendmode'):
raise AttributeError()
if not isinstance(sprite, DirtySprite):
raise TypeError()
if sprite.dirty == 0: # set it dirty if it is not
sprite.dirty = 1
LayeredUpdates.add_internal(self, sprite, layer)
def draw(self, surface, bgd=None):
"""draw all sprites in the right order onto the given surface
LayeredDirty.draw(surface, bgd=None): return Rect_list
You can pass the background too. If a self.bgd is already set to some
value that is not None, then the bgd argument has no effect.
"""
# speedups
_orig_clip = surface.get_clip()
_clip = self._clip
if _clip is None:
_clip = _orig_clip
_surf = surface
_sprites = self._spritelist
_old_rect = self.spritedict
_update = self.lostsprites
_update_append = _update.append
_ret = None
_surf_blit = _surf.blit
_rect = Rect
if bgd is not None:
self._bgd = bgd
_bgd = self._bgd
init_rect = self._init_rect
_surf.set_clip(_clip)
# -------
# 0. decide whether to render with update or flip
start_time = get_ticks()
if self._use_update: # dirty rects mode
# 1. find dirty area on screen and put the rects into _update
# still not happy with that part
for spr in _sprites:
if 0 < spr.dirty:
# chose the right rect
if spr.source_rect:
_union_rect = _rect(spr.rect.topleft,
spr.source_rect.size)
else:
_union_rect = _rect(spr.rect)
_union_rect_collidelist = _union_rect.collidelist
_union_rect_union_ip = _union_rect.union_ip
i = _union_rect_collidelist(_update)
while -1 < i:
_union_rect_union_ip(_update[i])
del _update[i]
i = _union_rect_collidelist(_update)
_update_append(_union_rect.clip(_clip))
if _old_rect[spr] is not init_rect:
_union_rect = _rect(_old_rect[spr])
_union_rect_collidelist = _union_rect.collidelist
_union_rect_union_ip = _union_rect.union_ip
i = _union_rect_collidelist(_update)
while -1 < i:
_union_rect_union_ip(_update[i])
del _update[i]
i = _union_rect_collidelist(_update)
_update_append(_union_rect.clip(_clip))
# can it be done better? because that is an O(n**2) algorithm in
# worst case
# clear using background
if _bgd is not None:
for rec in _update:
_surf_blit(_bgd, rec, rec)
# 2. draw
for spr in _sprites:
if 1 > spr.dirty:
if spr._visible:
# sprite not dirty; blit only the intersecting part
_spr_rect = spr.rect
if spr.source_rect is not None:
_spr_rect = Rect(spr.rect.topleft,
spr.source_rect.size)
_spr_rect_clip = _spr_rect.clip
for idx in _spr_rect.collidelistall(_update):
# clip
clip = _spr_rect_clip(_update[idx])
_surf_blit(spr.image,
clip,
(clip[0] - _spr_rect[0],
clip[1] - _spr_rect[1],
clip[2],
clip[3]),
spr.blendmode)
else: # dirty sprite
if spr._visible:
_old_rect[spr] = _surf_blit(spr.image,
spr.rect,
spr.source_rect,
spr.blendmode)
if spr.dirty == 1:
spr.dirty = 0
_ret = list(_update)
else: # flip, full screen mode
if _bgd is not None:
_surf_blit(_bgd, (0, 0))
for spr in _sprites:
if spr._visible:
_old_rect[spr] = _surf_blit(spr.image,
spr.rect,
spr.source_rect,
spr.blendmode)
_ret = [_rect(_clip)] # return only the part of the screen changed
# timing for switching modes
# How may a good threshold be found? It depends on the hardware.
end_time = get_ticks()
if end_time-start_time > self._time_threshold:
self._use_update = False
else:
self._use_update = True
## # debug
## print " check: using dirty rects:", self._use_update
# emtpy dirty rects list
_update[:] = []
# -------
# restore original clip
_surf.set_clip(_orig_clip)
return _ret
def clear(self, surface, bgd):
"""use to set background
Group.clear(surface, bgd): return None
"""
self._bgd = bgd
def repaint_rect(self, screen_rect):
"""repaint the given area
LayeredDirty.repaint_rect(screen_rect): return None
screen_rect is in screen coordinates.
"""
if self._clip:
self.lostsprites.append(screen_rect.clip(self._clip))
else:
self.lostsprites.append(Rect(screen_rect))
def set_clip(self, screen_rect=None):
"""clip the area where to draw; pass None (default) to reset the clip
LayeredDirty.set_clip(screen_rect=None): return None
"""
if screen_rect is None:
self._clip = pygame.display.get_surface().get_rect()
else:
self._clip = screen_rect
self._use_update = False
def get_clip(self):
"""get the area where drawing will occur
LayeredDirty.get_clip(): return Rect
"""
return self._clip
def change_layer(self, sprite, new_layer):
"""change the layer of the sprite
LayeredUpdates.change_layer(sprite, new_layer): return None
The sprite must have been added to the renderer already. This is not
checked.
"""
LayeredUpdates.change_layer(self, sprite, new_layer)
if sprite.dirty == 0:
sprite.dirty = 1
def set_timing_treshold(self, time_ms):
"""set the treshold in milliseconds
set_timing_treshold(time_ms): return None
Defaults to 1000.0 / 80.0. This means that the screen will be painted
using the flip method rather than the update method if the update
method is taking so long to update the screen that the frame rate falls
below 80 frames per second.
"""
self._time_threshold = time_ms
class GroupSingle(AbstractGroup):
"""A group container that holds a single most recent item.
This class works just like a regular group, but it only keeps a single
sprite in the group. Whatever sprite has been added to the group last will
be the only sprite in the group.
You can access its one sprite as the .sprite attribute. Assigning to this
attribute will properly remove the old sprite and then add the new one.
"""
def __init__(self, sprite=None):
AbstractGroup.__init__(self)
self.__sprite = None
if sprite is not None:
self.add(sprite)
def copy(self):
return GroupSingle(self.__sprite)
def sprites(self):
if self.__sprite is not None:
return [self.__sprite]
else:
return []
def add_internal(self, sprite):
if self.__sprite is not None:
self.__sprite.remove_internal(self)
self.remove_internal(self.__sprite)
self.__sprite = sprite
def __nonzero__(self):
return self.__sprite is not None
def _get_sprite(self):
return self.__sprite
def _set_sprite(self, sprite):
self.add_internal(sprite)
sprite.add_internal(self)
return sprite
sprite = property(_get_sprite,
_set_sprite,
None,
"The sprite contained in this group")
def remove_internal(self, sprite):
if sprite is self.__sprite:
self.__sprite = None
if sprite in self.spritedict:
AbstractGroup.remove_internal(self, sprite)
def has_internal(self, sprite):
return self.__sprite is sprite
# Optimizations...
def __contains__(self, sprite):
return self.__sprite is sprite
# Some different collision detection functions that could be used.
def collide_rect(left, right):
"""collision detection between two sprites, using rects.
pygame.sprite.collide_rect(left, right): return bool
Tests for collision between two sprites. Uses the pygame.Rect colliderect
function to calculate the collision. It is intended to be passed as a
collided callback function to the *collide functions. Sprites must have
"rect" attributes.
New in pygame 1.8.0
"""
return left.rect.colliderect(right.rect)
class collide_rect_ratio:
"""A callable class that checks for collisions using scaled rects
The class checks for collisions between two sprites using a scaled version
of the sprites' rects. Is created with a ratio; the instance is then
intended to be passed as a collided callback function to the *collide
functions.
New in pygame 1.8.1
"""
def __init__(self, ratio):
"""create a new collide_rect_ratio callable
Ratio is expected to be a floating point value used to scale
the underlying sprite rect before checking for collisions.
"""
self.ratio = ratio
def __call__(self, left, right):
"""detect collision between two sprites using scaled rects
pygame.sprite.collide_rect_ratio(ratio)(left, right): return bool
Tests for collision between two sprites. Uses the pygame.Rect
colliderect function to calculate the collision after scaling the rects
by the stored ratio. Sprites must have "rect" attributes.
"""
ratio = self.ratio
leftrect = left.rect
width = leftrect.width
height = leftrect.height
leftrect = leftrect.inflate(width * ratio - width,
height * ratio - height)
rightrect = right.rect
width = rightrect.width
height = rightrect.height
rightrect = rightrect.inflate(width * ratio - width,
height * ratio - height)
return leftrect.colliderect(rightrect)
def collide_circle(left, right):
"""detect collision between two sprites using circles
pygame.sprite.collide_circle(left, right): return bool
Tests for collision between two sprites by testing whether two circles
centered on the sprites overlap. If the sprites have a "radius" attribute,
then that radius is used to create the circle; otherwise, a circle is
created that is big enough to completely enclose the sprite's rect as
given by the "rect" attribute. This function is intended to be passed as
a collided callback function to the *collide functions. Sprites must have a
"rect" and an optional "radius" attribute.
New in pygame 1.8.0
"""
xdistance = left.rect.centerx - right.rect.centerx
ydistance = left.rect.centery - right.rect.centery
distancesquared = xdistance ** 2 + ydistance ** 2
if hasattr(left, 'radius'):
leftradius = left.radius
else:
leftrect = left.rect
# approximating the radius of a square by using half of the diagonal,
# might give false positives (especially if its a long small rect)
leftradius = 0.5 * ((leftrect.width ** 2 + leftrect.height ** 2) ** 0.5)
# store the radius on the sprite for next time
setattr(left, 'radius', leftradius)
if hasattr(right, 'radius'):
rightradius = right.radius
else:
rightrect = right.rect
# approximating the radius of a square by using half of the diagonal
# might give false positives (especially if its a long small rect)
rightradius = 0.5 * ((rightrect.width ** 2 + rightrect.height ** 2) ** 0.5)
# store the radius on the sprite for next time
setattr(right, 'radius', rightradius)
return distancesquared <= (leftradius + rightradius) ** 2
class collide_circle_ratio(object):
"""detect collision between two sprites using scaled circles
This callable class checks for collisions between two sprites using a
scaled version of a sprite's radius. It is created with a ratio as the
argument to the constructor. The instance is then intended to be passed as
a collided callback function to the *collide functions.
New in pygame 1.8.1
"""
def __init__(self, ratio):
"""creates a new collide_circle_ratio callable instance
The given ratio is expected to be a floating point value used to scale
the underlying sprite radius before checking for collisions.
When the ratio is ratio=1.0, then it behaves exactly like the
collide_circle method.
"""
self.ratio = ratio
def __call__(self, left, right):
"""detect collision between two sprites using scaled circles
pygame.sprite.collide_circle_radio(ratio)(left, right): return bool
Tests for collision between two sprites by testing whether two circles
centered on the sprites overlap after scaling the circle's radius by
the stored ratio. If the sprites have a "radius" attribute, that is
used to create the circle; otherwise, a circle is created that is big
enough to completely enclose the sprite's rect as given by the "rect"
attribute. Intended to be passed as a collided callback function to the
*collide functions. Sprites must have a "rect" and an optional "radius"
attribute.
"""
ratio = self.ratio
xdistance = left.rect.centerx - right.rect.centerx
ydistance = left.rect.centery - right.rect.centery
distancesquared = xdistance ** 2 + ydistance ** 2
if hasattr(left, "radius"):
leftradius = left.radius * ratio
else:
leftrect = left.rect
leftradius = ratio * 0.5 * ((leftrect.width ** 2 + leftrect.height ** 2) ** 0.5)
# store the radius on the sprite for next time
setattr(left, 'radius', leftradius)
if hasattr(right, "radius"):
rightradius = right.radius * ratio
else:
rightrect = right.rect
rightradius = ratio * 0.5 * ((rightrect.width ** 2 + rightrect.height ** 2) ** 0.5)
# store the radius on the sprite for next time
setattr(right, 'radius', rightradius)
return distancesquared <= (leftradius + rightradius) ** 2
def collide_mask(left, right):
"""collision detection between two sprites, using masks.
pygame.sprite.collide_mask(SpriteLeft, SpriteRight): bool
Tests for collision between two sprites by testing if their bitmasks
overlap. If the sprites have a "mask" attribute, that is used as the mask;
otherwise, a mask is created from the sprite image. Intended to be passed
as a collided callback function to the *collide functions. Sprites must
have a "rect" and an optional "mask" attribute.
New in pygame 1.8.0
"""
xoffset = right.rect[0] - left.rect[0]
yoffset = right.rect[1] - left.rect[1]
try:
leftmask = left.mask
except AttributeError:
leftmask = from_surface(left.image)
try:
rightmask = right.mask
except AttributeError:
rightmask = from_surface(right.image)
return leftmask.overlap(rightmask, (xoffset, yoffset))
def spritecollide(sprite, group, dokill, collided=None):
"""find Sprites in a Group that intersect another Sprite
pygame.sprite.spritecollide(sprite, group, dokill, collided=None):
return Sprite_list
Return a list containing all Sprites in a Group that intersect with another
Sprite. Intersection is determined by comparing the Sprite.rect attribute
of each Sprite.
The dokill argument is a bool. If set to True, all Sprites that collide
will be removed from the Group.
The collided argument is a callback function used to calculate if two
sprites are colliding. it should take two sprites as values, and return a
bool value indicating if they are colliding. If collided is not passed, all
sprites must have a "rect" value, which is a rectangle of the sprite area,
which will be used to calculate the collision.
"""
if dokill:
crashed = []
append = crashed.append
if collided:
for s in group.sprites():
if collided(sprite, s):
s.kill()
append(s)
else:
spritecollide = sprite.rect.colliderect
for s in group.sprites():
if spritecollide(s.rect):
s.kill()
append(s)
return crashed
elif collided:
return [s for s in group if collided(sprite, s)]
else:
spritecollide = sprite.rect.colliderect
return [s for s in group if spritecollide(s.rect)]
def groupcollide(groupa, groupb, dokilla, dokillb, collided=None):
"""detect collision between a group and another group
pygame.sprite.groupcollide(groupa, groupb, dokilla, dokillb):
return dict
Given two groups, this will find the intersections between all sprites in
each group. It returns a dictionary of all sprites in the first group that
collide. The value for each item in the dictionary is a list of the sprites
in the second group it collides with. The two dokill arguments control if
the sprites from either group will be automatically removed from all
groups. Collided is a callback function used to calculate if two sprites
are colliding. it should take two sprites as values, and return a bool
value indicating if they are colliding. If collided is not passed, all
sprites must have a "rect" value, which is a rectangle of the sprite area
that will be used to calculate the collision.
"""
crashed = {}
SC = spritecollide
if dokilla:
for s in groupa.sprites():
c = SC(s, groupb, dokillb, collided)
if c:
crashed[s] = c
s.kill()
else:
for s in groupa:
c = SC(s, groupb, dokillb, collided)
if c:
crashed[s] = c
return crashed
def spritecollideany(sprite, group, collided=None):
"""finds any sprites in a group that collide with the given sprite
pygame.sprite.spritecollideany(sprite, group): return sprite
Given a sprite and a group of sprites, this will return return any single
sprite that collides with with the given sprite. If there are no
collisions, then this returns None.
If you don't need all the features of the spritecollide function, this
function will be a bit quicker.
Collided is a callback function used to calculate if two sprites are
colliding. It should take two sprites as values and return a bool value
indicating if they are colliding. If collided is not passed, then all
sprites must have a "rect" value, which is a rectangle of the sprite area,
which will be used to calculate the collision.
"""
if collided:
for s in group:
if collided(sprite, s):
return s
else:
# Special case old behaviour for speed.
spritecollide = sprite.rect.colliderect
for s in group:
if spritecollide(s.rect):
return s
return None
|
gpl-3.0
|
[
309,
259,
9193,
446,
2018,
25132,
11243,
199,
309,
259,
1898,
334,
35,
9,
12293,
13,
17919,
12,
10219,
221,
11379,
266,
5244,
262,
8715,
199,
309,
4519,
334,
35,
9,
8353,
7135,
69,
644,
470,
11019,
528,
199,
309,
259,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
309,
259,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
11243,
1696,
1684,
199,
309,
259,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
309,
259,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
199,
309,
259,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
309,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
309,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
309,
259,
11243,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
309,
199,
309,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
11243,
1696,
1684,
199,
309,
259,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
199,
309,
259,
2752,
12,
3277,
2020,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
221,
8217,
199,
309,
199,
309,
259,
11379,
266,
5244,
262,
8715,
199,
309,
259,
4837,
266,
32,
609,
262,
8715,
14,
1308,
199,
199,
624,
22278,
859,
543,
5678,
9219,
909,
3992,
199,
199,
2765,
859,
3509,
9978,
3486,
3992,
370,
506,
1202,
4453,
9219,
83,
14,
6006,
199,
1530,
314,
2446,
8360,
752,
1021,
436,
9978,
5611,
3992,
626,
1395,
428,
21483,
14,
199,
1918,
675,
402,
3520,
3992,
365,
21926,
2716,
1380,
1808,
1611,
5097,
14,
710,
3992,
199,
1530,
28092,
590,
10540,
3463,
436,
1454,
5647,
282,
6617,
4192,
367,
314,
1233,
199,
9099,
365,
2863,
370,
4750,
9219,
83,
14,
199,
199,
1918,
8360,
752,
1021,
365,
11619,
370,
506,
1202,
465,
282,
1300,
1021,
367,
314,
3365,
199,
1313,
402,
2251,
315,
314,
9219,
14,
6006,
365,
2597,
282,
1300,
5611,
1021,
626,
9329,
199,
18958,
25328,
14,
437,
9219,
4293,
1218,
892,
2943,
402,
5611,
3992,
626,
19218,
199,
265,
1106,
1183,
26707,
8360,
752,
4454,
2985,
1395,
14,
199,
199,
1918,
5678,
8360,
752,
1021,
883,
5954,
314,
428,
21483,
652,
3509,
370,
282,
29564,
14,
710,
199,
2448,
14,
5485,
342,
1083,
5074,
626,
1924,
8360,
752,
1172,
282,
29564,
14,
1569,
2225,
199,
460,
282,
29564,
14,
1201,
14,
710,
5611,
14,
3584,
342,
1083,
5074,
3520,
2011,
3004,
199,
460,
883,
506,
1202,
370,
28343,
1006,
314,
428,
21483,
543,
8020,
14,
6006,
787,
2597,
199,
6878,
19472,
25031,
26,
9193,
14,
15972,
14,
9216,
16083,
342,
436,
199,
22278,
14,
15972,
14,
22567,
16083,
1252,
199,
199,
6090,
590,
12,
642,
859,
3509,
9978,
25061,
3423,
14,
5723,
1720,
2342,
199,
27495,
6272,
3663,
4652,
626,
1172,
26066,
316,
16842,
8626,
13162,
14,
199,
1378,
2342,
314,
30063,
12,
314,
428,
21483,
787,
1415,
370,
1172,
282,
29564,
14,
1201,
199,
3215,
7943,
14,
199,
199,
1918,
4652,
787,
19829,
367,
4721,
25978,
315,
12881,
436,
7791,
428,
21483,
199,
475,
3062,
14,
9322,
2597,
2040,
286,
12492,
5343,
370,
1937,
340,
282,
8360,
752,
2575,
3495,
315,
199,
65,
5611,
14,
437,
1627,
8360,
752,
883,
2187,
315,
1263,
1329,
402,
4652,
14,
437,
9219,
4293,
675,
199,
3972,
4652,
370,
3304,
909,
14066,
12,
436,
282,
14793,
7396,
663,
402,
199,
2634,
370,
3304,
18752,
503,
7748,
4057,
434,
14,
15345,
402,
7791,
730,
199,
2987,
503,
1234,
1446,
370,
282,
7131,
8360,
752,
1021,
12,
11201,
22181,
314,
199,
51,
21483,
6272,
20765,
1759,
25031,
14,
961,
911,
2040,
367,
14905,
4237,
2945,
199,
262,
314,
9219,
14,
199,
199,
51,
21483,
436,
25031,
9635,
3932,
20045,
543,
314,
1050,
342,
436,
2813,
342,
199,
2474,
14,
5723,
3102,
883,
4729,
282,
2849,
503,
3663,
1572,
2368,
367,
199,
13105,
14,
221,
710,
849,
2536,
6315,
367,
3520,
3992,
2597,
5452,
282,
199,
4780,
1572,
503,
769,
402,
4652,
465,
1680,
1470,
367,
2536,
14616,
14,
2779,
365,
5048,
199,
475,
27714,
1050,
436,
2813,
314,
2011,
8360,
752,
687,
282,
5611,
14,
199,
199,
25215,
652,
365,
3962,
370,
12899,
17325,
436,
1572,
3992,
626,
2793,
1133,
23519,
199,
504,
314,
8360,
752,
436,
11836,
2448,
3992,
5084,
12,
652,
365,
30390,
14318,
199,
9099,
1265,
12247,
5204,
1380,
1265,
1218,
282,
892,
8360,
752,
503,
5611,
1021,
14,
199,
199,
51,
21483,
787,
440,
2462,
5048,
12,
880,
4650,
3062,
28225,
340,
1808,
7183,
14,
199,
199,
624,
199,
199,
309,
11396,
199,
309,
282,
1572,
626,
15164,
1454,
314,
283,
78,
7,
4750,
8058,
4008,
14,
199,
309,
4069,
402,
2839,
314,
5611,
7200,
1021,
12,
1325,
17573,
1655,
199,
309,
2419,
1373,
17325,
199,
309,
199,
309,
17455,
4652,
626,
883,
283,
2495,
17174,
7,
3877,
314,
9150,
199,
309,
1334,
685,
1619,
880,
2985,
883,
298,
3584,
2,
1928,
1929,
316,
282,
8020,
199,
309,
805,
14,
25259,
590,
282,
12050,
26200,
2419,
3293,
12,
1325,
14213,
199,
309,
370,
675,
315,
5002,
24325,
14,
334,
12344,
21027,
652,
1471,
298,
3584,
2,
199,
309,
315,
314,
3837,
1865,
626,
652,
5954,
83,
520,
566,
199,
309,
199,
309,
314,
17455,
4652,
1077,
2597,
506,
7688,
370,
5452,
282,
8020,
199,
309,
805,
12,
3140,
402,
2951,
282,
8020,
13195,
14,
314,
805,
199,
309,
3955,
5452,
282,
13195,
436,
282,
20412,
641,
626,
13195,
370,
28343,
14,
199,
309,
199,
309,
25358,
1655,
2943,
402,
25061,
3423,
31,
314,
1453,
2877,
199,
309,
1077,
2429,
2951,
3595,
4036,
1929,
12,
1325,
25358,
1655,
20212,
199,
309,
2488,
7869,
626,
10621,
1133,
18794,
880,
8605,
1325,
5542,
1901,
2863,
199,
309,
27877,
5560,
14,
199,
199,
646,
9193,
199,
504,
9193,
14,
1201,
492,
21536,
199,
504,
9193,
14,
521,
492,
664,
63,
10406,
199,
504,
4182,
492,
16865,
199,
199,
3,
2018,
650,
1630,
440,
1172,
314,
4550,
805,
12,
1325,
376,
7353,
883,
506,
6326,
199,
3,
543,
314,
2688
] |
[
259,
9193,
446,
2018,
25132,
11243,
199,
309,
259,
1898,
334,
35,
9,
12293,
13,
17919,
12,
10219,
221,
11379,
266,
5244,
262,
8715,
199,
309,
4519,
334,
35,
9,
8353,
7135,
69,
644,
470,
11019,
528,
199,
309,
259,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
309,
259,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
11243,
1696,
1684,
199,
309,
259,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
309,
259,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
199,
309,
259,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
309,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
309,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
309,
259,
11243,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
309,
199,
309,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
11243,
1696,
1684,
199,
309,
259,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
199,
309,
259,
2752,
12,
3277,
2020,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
221,
8217,
199,
309,
199,
309,
259,
11379,
266,
5244,
262,
8715,
199,
309,
259,
4837,
266,
32,
609,
262,
8715,
14,
1308,
199,
199,
624,
22278,
859,
543,
5678,
9219,
909,
3992,
199,
199,
2765,
859,
3509,
9978,
3486,
3992,
370,
506,
1202,
4453,
9219,
83,
14,
6006,
199,
1530,
314,
2446,
8360,
752,
1021,
436,
9978,
5611,
3992,
626,
1395,
428,
21483,
14,
199,
1918,
675,
402,
3520,
3992,
365,
21926,
2716,
1380,
1808,
1611,
5097,
14,
710,
3992,
199,
1530,
28092,
590,
10540,
3463,
436,
1454,
5647,
282,
6617,
4192,
367,
314,
1233,
199,
9099,
365,
2863,
370,
4750,
9219,
83,
14,
199,
199,
1918,
8360,
752,
1021,
365,
11619,
370,
506,
1202,
465,
282,
1300,
1021,
367,
314,
3365,
199,
1313,
402,
2251,
315,
314,
9219,
14,
6006,
365,
2597,
282,
1300,
5611,
1021,
626,
9329,
199,
18958,
25328,
14,
437,
9219,
4293,
1218,
892,
2943,
402,
5611,
3992,
626,
19218,
199,
265,
1106,
1183,
26707,
8360,
752,
4454,
2985,
1395,
14,
199,
199,
1918,
5678,
8360,
752,
1021,
883,
5954,
314,
428,
21483,
652,
3509,
370,
282,
29564,
14,
710,
199,
2448,
14,
5485,
342,
1083,
5074,
626,
1924,
8360,
752,
1172,
282,
29564,
14,
1569,
2225,
199,
460,
282,
29564,
14,
1201,
14,
710,
5611,
14,
3584,
342,
1083,
5074,
3520,
2011,
3004,
199,
460,
883,
506,
1202,
370,
28343,
1006,
314,
428,
21483,
543,
8020,
14,
6006,
787,
2597,
199,
6878,
19472,
25031,
26,
9193,
14,
15972,
14,
9216,
16083,
342,
436,
199,
22278,
14,
15972,
14,
22567,
16083,
1252,
199,
199,
6090,
590,
12,
642,
859,
3509,
9978,
25061,
3423,
14,
5723,
1720,
2342,
199,
27495,
6272,
3663,
4652,
626,
1172,
26066,
316,
16842,
8626,
13162,
14,
199,
1378,
2342,
314,
30063,
12,
314,
428,
21483,
787,
1415,
370,
1172,
282,
29564,
14,
1201,
199,
3215,
7943,
14,
199,
199,
1918,
4652,
787,
19829,
367,
4721,
25978,
315,
12881,
436,
7791,
428,
21483,
199,
475,
3062,
14,
9322,
2597,
2040,
286,
12492,
5343,
370,
1937,
340,
282,
8360,
752,
2575,
3495,
315,
199,
65,
5611,
14,
437,
1627,
8360,
752,
883,
2187,
315,
1263,
1329,
402,
4652,
14,
437,
9219,
4293,
675,
199,
3972,
4652,
370,
3304,
909,
14066,
12,
436,
282,
14793,
7396,
663,
402,
199,
2634,
370,
3304,
18752,
503,
7748,
4057,
434,
14,
15345,
402,
7791,
730,
199,
2987,
503,
1234,
1446,
370,
282,
7131,
8360,
752,
1021,
12,
11201,
22181,
314,
199,
51,
21483,
6272,
20765,
1759,
25031,
14,
961,
911,
2040,
367,
14905,
4237,
2945,
199,
262,
314,
9219,
14,
199,
199,
51,
21483,
436,
25031,
9635,
3932,
20045,
543,
314,
1050,
342,
436,
2813,
342,
199,
2474,
14,
5723,
3102,
883,
4729,
282,
2849,
503,
3663,
1572,
2368,
367,
199,
13105,
14,
221,
710,
849,
2536,
6315,
367,
3520,
3992,
2597,
5452,
282,
199,
4780,
1572,
503,
769,
402,
4652,
465,
1680,
1470,
367,
2536,
14616,
14,
2779,
365,
5048,
199,
475,
27714,
1050,
436,
2813,
314,
2011,
8360,
752,
687,
282,
5611,
14,
199,
199,
25215,
652,
365,
3962,
370,
12899,
17325,
436,
1572,
3992,
626,
2793,
1133,
23519,
199,
504,
314,
8360,
752,
436,
11836,
2448,
3992,
5084,
12,
652,
365,
30390,
14318,
199,
9099,
1265,
12247,
5204,
1380,
1265,
1218,
282,
892,
8360,
752,
503,
5611,
1021,
14,
199,
199,
51,
21483,
787,
440,
2462,
5048,
12,
880,
4650,
3062,
28225,
340,
1808,
7183,
14,
199,
199,
624,
199,
199,
309,
11396,
199,
309,
282,
1572,
626,
15164,
1454,
314,
283,
78,
7,
4750,
8058,
4008,
14,
199,
309,
4069,
402,
2839,
314,
5611,
7200,
1021,
12,
1325,
17573,
1655,
199,
309,
2419,
1373,
17325,
199,
309,
199,
309,
17455,
4652,
626,
883,
283,
2495,
17174,
7,
3877,
314,
9150,
199,
309,
1334,
685,
1619,
880,
2985,
883,
298,
3584,
2,
1928,
1929,
316,
282,
8020,
199,
309,
805,
14,
25259,
590,
282,
12050,
26200,
2419,
3293,
12,
1325,
14213,
199,
309,
370,
675,
315,
5002,
24325,
14,
334,
12344,
21027,
652,
1471,
298,
3584,
2,
199,
309,
315,
314,
3837,
1865,
626,
652,
5954,
83,
520,
566,
199,
309,
199,
309,
314,
17455,
4652,
1077,
2597,
506,
7688,
370,
5452,
282,
8020,
199,
309,
805,
12,
3140,
402,
2951,
282,
8020,
13195,
14,
314,
805,
199,
309,
3955,
5452,
282,
13195,
436,
282,
20412,
641,
626,
13195,
370,
28343,
14,
199,
309,
199,
309,
25358,
1655,
2943,
402,
25061,
3423,
31,
314,
1453,
2877,
199,
309,
1077,
2429,
2951,
3595,
4036,
1929,
12,
1325,
25358,
1655,
20212,
199,
309,
2488,
7869,
626,
10621,
1133,
18794,
880,
8605,
1325,
5542,
1901,
2863,
199,
309,
27877,
5560,
14,
199,
199,
646,
9193,
199,
504,
9193,
14,
1201,
492,
21536,
199,
504,
9193,
14,
521,
492,
664,
63,
10406,
199,
504,
4182,
492,
16865,
199,
199,
3,
2018,
650,
1630,
440,
1172,
314,
4550,
805,
12,
1325,
376,
7353,
883,
506,
6326,
199,
3,
543,
314,
2688,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
inspyration/odoo
|
addons/l10n_be/wizard/l10n_be_vat_intra.py
|
4
|
14737
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# Adapted by Noviat to
# - make the 'mand_id' field optional
# - support Noviat tax code scheme
#
# 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 time
import base64
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.report import report_sxw
class partner_vat_intra(osv.osv_memory):
"""
Partner Vat Intra
"""
_name = "partner.vat.intra"
_description = 'Partner VAT Intra'
def _get_xml_data(self, cr, uid, context=None):
if context.get('file_save', False):
return base64.encodestring(context['file_save'].encode('utf8'))
return ''
def _get_europe_country(self, cursor, user, context=None):
return self.pool.get('res.country').search(cursor, user, [('code', 'in', ['AT', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'])])
_columns = {
'name': fields.char('File Name'),
'period_code': fields.char('Period Code', size=6, required=True, help='''This is where you have to set the period code for the intracom declaration using the format: ppyyyy
PP can stand for a month: from '01' to '12'.
PP can stand for a trimester: '31','32','33','34'
The first figure means that it is a trimester,
The second figure identify the trimester.
PP can stand for a complete fiscal year: '00'.
YYYY stands for the year (4 positions).
'''
),
'period_ids': fields.many2many('account.period', 'account_period_rel', 'acc_id', 'period_id', 'Period (s)', help = 'Select here the period(s) you want to include in your intracom declaration'),
'tax_code_id': fields.many2one('account.tax.code', 'Company', domain=[('parent_id', '=', False)], help="Keep empty to use the user's company", required=True),
'test_xml': fields.boolean('Test XML file', help="Sets the XML output as test file"),
'mand_id' : fields.char('Reference', help="Reference given by the Representative of the sending company."),
'msg': fields.text('File created', readonly=True),
'no_vat': fields.text('Partner With No VAT', readonly=True, help="The Partner whose VAT number is not defined and they are not included in XML File."),
'file_save' : fields.binary('Save File', readonly=True),
'country_ids': fields.many2many('res.country', 'vat_country_rel', 'vat_id', 'country_id', 'European Countries'),
'comments': fields.text('Comments'),
}
def _get_tax_code(self, cr, uid, context=None):
obj_tax_code = self.pool.get('account.tax.code')
obj_user = self.pool.get('res.users')
company_id = obj_user.browse(cr, uid, uid, context=context).company_id.id
tax_code_ids = obj_tax_code.search(cr, uid, [('company_id', '=', company_id), ('parent_id', '=', False)], context=context)
return tax_code_ids and tax_code_ids[0] or False
_defaults = {
'country_ids': _get_europe_country,
'file_save': _get_xml_data,
'name': 'vat_intra.xml',
'tax_code_id': _get_tax_code,
}
def _get_datas(self, cr, uid, ids, context=None):
"""Collects require data for vat intra xml
:param ids: id of wizard.
:return: dict of all data to be used to generate xml for Partner VAT Intra.
:rtype: dict
"""
if context is None:
context = {}
obj_user = self.pool.get('res.users')
obj_sequence = self.pool.get('ir.sequence')
obj_partner = self.pool.get('res.partner')
xmldict = {}
post_code = street = city = country = data_clientinfo = ''
seq = amount_sum = 0
wiz_data = self.browse(cr, uid, ids[0], context=context)
comments = wiz_data.comments
if wiz_data.tax_code_id:
data_company = wiz_data.tax_code_id.company_id
else:
data_company = obj_user.browse(cr, uid, uid, context=context).company_id
# Get Company vat
company_vat = data_company.partner_id.vat
if not company_vat:
raise osv.except_osv(_('Insufficient Data!'),_('No VAT number associated with your company.'))
company_vat = company_vat.replace(' ','').upper()
issued_by = company_vat[:2]
if len(wiz_data.period_code) != 6:
raise osv.except_osv(_('Error!'), _('Period code is not valid.'))
if not wiz_data.period_ids:
raise osv.except_osv(_('Insufficient Data!'),_('Please select at least one Period.'))
p_id_list = obj_partner.search(cr, uid, [('vat','!=',False)], context=context)
if not p_id_list:
raise osv.except_osv(_('Insufficient Data!'),_('No partner has a VAT number associated with him.'))
seq_declarantnum = obj_sequence.next_by_code(cr, uid, 'declarantnum')
dnum = company_vat[2:] + seq_declarantnum[-4:]
addr = obj_partner.address_get(cr, uid, [data_company.partner_id.id], ['invoice'])
email = data_company.partner_id.email or ''
phone = data_company.partner_id.phone or ''
if addr.get('invoice',False):
ads = obj_partner.browse(cr, uid, [addr['invoice']])[0]
city = (ads.city or '')
post_code = (ads.zip or '')
if ads.street:
street = ads.street
if ads.street2:
street += ' '
street += ads.street2
if ads.country_id:
country = ads.country_id.code
if not country:
country = company_vat[:2]
if not email:
raise osv.except_osv(_('Insufficient Data!'),_('No email address associated with the company.'))
if not phone:
raise osv.except_osv(_('Insufficient Data!'),_('No phone associated with the company.'))
xmldict.update({
'company_name': data_company.name,
'company_vat': company_vat,
'vatnum': company_vat[2:],
'mand_id': wiz_data.mand_id,
'sender_date': str(time.strftime('%Y-%m-%d')),
'street': street,
'city': city,
'post_code': post_code,
'country': country,
'email': email,
'phone': phone.replace('/','').replace('.','').replace('(','').replace(')','').replace(' ',''),
'period': wiz_data.period_code,
'clientlist': [],
'comments': comments,
'issued_by': issued_by,
})
#tax code 44: services
#tax code 46L: normal good deliveries
#tax code 46T: ABC good deliveries
#tax code 48xxx: credite note on tax code xxx
codes = ('44', '46L', '46T', '48s44', '48s46L', '48s46T')
cr.execute('''SELECT p.name As partner_name, l.partner_id AS partner_id, p.vat AS vat,
(CASE WHEN t.code = '48s44' THEN '44'
WHEN t.code = '48s46L' THEN '46L'
WHEN t.code = '48s46T' THEN '46T'
ELSE t.code END) AS intra_code,
SUM(CASE WHEN t.code in ('48s44','48s46L','48s46T') THEN -l.tax_amount ELSE l.tax_amount END) AS amount
FROM account_move_line l
LEFT JOIN account_tax_code t ON (l.tax_code_id = t.id)
LEFT JOIN res_partner p ON (l.partner_id = p.id)
WHERE t.code IN %s
AND l.period_id IN %s
AND t.company_id = %s
GROUP BY p.name, l.partner_id, p.vat, intra_code''', (codes, tuple([p.id for p in wiz_data.period_ids]), data_company.id))
p_count = 0
for row in cr.dictfetchall():
if not row['vat']:
row['vat'] = ''
p_count += 1
seq += 1
amt = row['amount'] or 0.0
amount_sum += amt
intra_code = row['intra_code'] == '44' and 'S' or (row['intra_code'] == '46L' and 'L' or (row['intra_code'] == '46T' and 'T' or ''))
xmldict['clientlist'].append({
'partner_name': row['partner_name'],
'seq': seq,
'vatnum': row['vat'][2:].replace(' ','').upper(),
'vat': row['vat'],
'country': row['vat'][:2],
'amount': round(amt,2),
'intra_code': row['intra_code'],
'code': intra_code})
xmldict.update({'dnum': dnum, 'clientnbr': str(seq), 'amountsum': round(amount_sum,2), 'partner_wo_vat': p_count})
return xmldict
def create_xml(self, cursor, user, ids, context=None):
"""Creates xml that is to be exported and sent to estate for partner vat intra.
:return: Value for next action.
:rtype: dict
"""
mod_obj = self.pool.get('ir.model.data')
xml_data = self._get_datas(cursor, user, ids, context=context)
month_quarter = xml_data['period'][:2]
year = xml_data['period'][2:]
data_file = ''
# Can't we do this by etree?
data_head = """<?xml version="1.0" encoding="ISO-8859-1"?>
<ns2:IntraConsignment xmlns="http://www.minfin.fgov.be/InputCommon" xmlns:ns2="http://www.minfin.fgov.be/IntraConsignment" IntraListingsNbr="1">
<ns2:Representative>
<RepresentativeID identificationType="NVAT" issuedBy="%(issued_by)s">%(vatnum)s</RepresentativeID>
<Name>%(company_name)s</Name>
<Street>%(street)s</Street>
<PostCode>%(post_code)s</PostCode>
<City>%(city)s</City>
<CountryCode>%(country)s</CountryCode>
<EmailAddress>%(email)s</EmailAddress>
<Phone>%(phone)s</Phone>
</ns2:Representative>""" % (xml_data)
if xml_data['mand_id']:
data_head += '\n\t\t<ns2:RepresentativeReference>%(mand_id)s</ns2:RepresentativeReference>' % (xml_data)
data_comp_period = '\n\t\t<ns2:Declarant>\n\t\t\t<VATNumber>%(vatnum)s</VATNumber>\n\t\t\t<Name>%(company_name)s</Name>\n\t\t\t<Street>%(street)s</Street>\n\t\t\t<PostCode>%(post_code)s</PostCode>\n\t\t\t<City>%(city)s</City>\n\t\t\t<CountryCode>%(country)s</CountryCode>\n\t\t\t<EmailAddress>%(email)s</EmailAddress>\n\t\t\t<Phone>%(phone)s</Phone>\n\t\t</ns2:Declarant>' % (xml_data)
if month_quarter.startswith('3'):
data_comp_period += '\n\t\t<ns2:Period>\n\t\t\t<ns2:Quarter>'+month_quarter[1]+'</ns2:Quarter> \n\t\t\t<ns2:Year>'+year+'</ns2:Year>\n\t\t</ns2:Period>'
elif month_quarter.startswith('0') and month_quarter.endswith('0'):
data_comp_period+= '\n\t\t<ns2:Period>\n\t\t\t<ns2:Year>'+year+'</ns2:Year>\n\t\t</ns2:Period>'
else:
data_comp_period += '\n\t\t<ns2:Period>\n\t\t\t<ns2:Month>'+month_quarter+'</ns2:Month> \n\t\t\t<ns2:Year>'+year+'</ns2:Year>\n\t\t</ns2:Period>'
data_clientinfo = ''
for client in xml_data['clientlist']:
if not client['vatnum']:
raise osv.except_osv(_('Insufficient Data!'),_('No vat number defined for %s.') % client['partner_name'])
data_clientinfo +='\n\t\t<ns2:IntraClient SequenceNumber="%(seq)s">\n\t\t\t<ns2:CompanyVATNumber issuedBy="%(country)s">%(vatnum)s</ns2:CompanyVATNumber>\n\t\t\t<ns2:Code>%(code)s</ns2:Code>\n\t\t\t<ns2:Amount>%(amount).2f</ns2:Amount>\n\t\t</ns2:IntraClient>' % (client)
data_decl = '\n\t<ns2:IntraListing SequenceNumber="1" ClientsNbr="%(clientnbr)s" DeclarantReference="%(dnum)s" AmountSum="%(amountsum).2f">' % (xml_data)
data_file += data_head + data_decl + data_comp_period + data_clientinfo + '\n\t\t<ns2:Comment>%(comments)s</ns2:Comment>\n\t</ns2:IntraListing>\n</ns2:IntraConsignment>' % (xml_data)
context = dict(context or {})
context['file_save'] = data_file
model_data_ids = mod_obj.search(cursor, user,[('model','=','ir.ui.view'),('name','=','view_vat_intra_save')], context=context)
resource_id = mod_obj.read(cursor, user, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
return {
'name': _('Save'),
'context': context,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'partner.vat.intra',
'views': [(resource_id,'form')],
'view_id': 'view_vat_intra_save',
'type': 'ir.actions.act_window',
'target': 'new',
}
def preview(self, cr, uid, ids, context=None):
xml_data = self._get_datas(cr, uid, ids, context=context)
datas = {
'ids': [],
'model': 'partner.vat.intra',
'form': xml_data
}
return self.pool['report'].get_action(
cr, uid, [], 'l10n_be.report_l10nvatintraprint', data=datas, context=context
)
class vat_intra_print(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(vat_intra_print, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
})
class wrapped_vat_intra_print(osv.AbstractModel):
_name = 'report.l10n_be.report_l10nvatintraprint'
_inherit = 'report.abstract_report'
_template = 'l10n_be.report_l10nvatintraprint'
_wrapped_report_class = vat_intra_print
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
4431,
18309,
701,
3091,
433,
292,
370,
199,
3,
258,
446,
1852,
314,
283,
10333,
63,
344,
7,
901,
2716,
199,
3,
258,
446,
2291,
3091,
433,
292,
9067,
1233,
5687,
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,
646,
900,
199,
646,
1300,
772,
199,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
14,
3070,
492,
3622,
63,
20851,
421,
199,
533,
5854,
63,
16305,
63,
442,
345,
8,
4795,
14,
4795,
63,
4844,
304,
272,
408,
272,
31351,
812,
292,
9805,
345,
272,
408,
272,
485,
354,
275,
298,
3899,
14,
16305,
14,
442,
345,
2,
272,
485,
1802,
275,
283,
24120,
812,
619,
9805,
345,
7,
339,
347,
485,
362,
63,
1652,
63,
576,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
340,
1067,
14,
362,
360,
493,
63,
2117,
297,
756,
304,
288,
372,
1300,
772,
14,
2143,
875,
8,
1100,
459,
493,
63,
2117,
2278,
2143,
360,
1624,
24,
1333,
267,
372,
2125,
339,
347,
485,
362,
63,
69,
12646,
63,
6063,
8,
277,
12,
3920,
12,
922,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
2293,
14,
362,
360,
470,
14,
6063,
1959,
1733,
8,
3937,
12,
922,
12,
4274,
600,
297,
283,
262,
297,
788,
619,
297,
283,
18998,
297,
283,
15068,
297,
283,
27808,
297,
283,
10892,
297,
283,
8699,
297,
283,
1976,
297,
283,
5372,
297,
283,
1093,
297,
283,
3975,
297,
283,
28327,
297,
283,
4332,
297,
283,
649,
297,
283,
18750,
297,
283,
17090,
297,
283,
20237,
297,
283,
5747,
297,
283,
14176,
297,
283,
2749,
297,
283,
4189,
297,
283,
1092,
297,
283,
8656,
297,
283,
2684,
297,
283,
654,
297,
283,
899,
297,
283,
6487,
31161,
339,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
1173,
2812,
659,
267,
283,
5191,
63,
600,
356,
1504,
14,
1560,
360,
15518,
5495,
297,
1568,
29,
22,
12,
1415,
29,
549,
12,
1720,
19938,
2765,
365,
2382,
1265,
1172,
370,
663,
314,
6247,
1233,
367,
314,
1109,
345,
957,
12560,
1808,
314,
1475,
26,
299,
647,
30917,
489,
510,
48,
883,
10584,
367,
282,
5794,
26,
687,
283,
614,
7,
370,
283,
713,
1370,
489,
510,
48,
883,
10584,
367,
282,
3229,
6415,
351,
26,
283,
2192,
1673,
708,
1673,
1153,
1673,
1082,
7,
881,
710,
1642,
9658,
4910,
626,
652,
365,
282,
3229,
6415,
351,
12,
881,
710,
3499,
9658,
10405,
314,
3229,
6415,
351,
14,
489,
510,
48,
883,
10584,
367,
282,
4890,
18672,
5361,
26,
283,
383,
1370,
489,
31946,
410,
5915,
367,
314,
5361,
334,
20,
12266,
680,
272,
1449,
272,
2318,
267,
283,
5191,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
2048,
14,
5191,
297,
283,
2048,
63,
5191,
63,
3369,
297,
283,
5470,
63,
344,
297,
283,
5191,
63,
344,
297,
283,
15518,
334,
83,
3196,
1720,
275,
283,
5446,
2348,
314,
6247,
8,
83,
9,
1265,
2934,
370,
2387,
315,
2195,
1109,
345,
957,
12560,
659,
267,
283,
5530,
63,
600,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5530,
14,
600,
297,
283,
16063,
297,
2881,
11699,
1708,
63,
344,
297,
6291,
756,
4360,
1720,
628,
18567,
2701,
370,
675,
314,
922,
1159,
7233,
401,
1415,
29,
549,
395,
267,
283,
396,
63,
1652,
356,
1504,
14,
4871,
360,
774,
4692,
570,
297,
1720,
628,
9899,
314,
4692,
1072,
465,
511,
570,
1288,
267,
283,
10333,
63,
344,
7,
520,
1504,
14,
1560,
360,
5083,
297,
1720,
628,
5083,
1627,
701,
314,
17634,
1905,
402,
314,
10209,
7233,
7651,
267,
283,
1328,
356,
1504,
14,
505,
360,
1173,
2737,
297,
6863,
29,
549,
395,
267,
283,
889,
63,
16305,
356,
1504,
14,
505,
360,
24120,
8777,
3091,
812,
619,
297,
6863,
29,
549,
12,
1720,
628,
1918,
31351,
7447,
812,
619,
1329,
365,
440,
3247,
436,
2985,
787,
440,
5120,
315,
4692,
3814,
7651,
267,
283,
493,
63,
2117,
7,
520,
1504,
14,
3008,
360,
8229,
3814,
297,
6863,
29,
549,
395,
267,
283,
6063,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
470,
14,
6063,
297,
283,
16305,
63,
6063,
63,
3369,
297,
283,
16305,
63,
344,
297,
283,
6063,
63,
344,
297,
283,
15201,
290,
1849,
324,
6264,
659,
267,
283,
6223,
356,
1504,
14,
505,
360,
18929,
659,
267,
789,
339,
347,
485,
362,
63,
5530,
63,
600,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
1559,
63,
5530,
63,
600,
275,
291,
14,
2293,
14,
362,
360,
2048,
14,
5530,
14,
600,
358,
267,
1559,
63,
751,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
3707,
358,
267,
7233,
63,
344,
275,
1559,
63,
751,
14,
4570,
8,
1556,
12,
1747,
12,
1747,
12,
1067,
29,
1100,
680,
4627,
63,
344,
14,
344,
267,
9067,
63,
600,
63,
1580,
275,
1559,
63,
5530
] |
[
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,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
4431,
18309,
701,
3091,
433,
292,
370,
199,
3,
258,
446,
1852,
314,
283,
10333,
63,
344,
7,
901,
2716,
199,
3,
258,
446,
2291,
3091,
433,
292,
9067,
1233,
5687,
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,
646,
900,
199,
646,
1300,
772,
199,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
14,
3070,
492,
3622,
63,
20851,
421,
199,
533,
5854,
63,
16305,
63,
442,
345,
8,
4795,
14,
4795,
63,
4844,
304,
272,
408,
272,
31351,
812,
292,
9805,
345,
272,
408,
272,
485,
354,
275,
298,
3899,
14,
16305,
14,
442,
345,
2,
272,
485,
1802,
275,
283,
24120,
812,
619,
9805,
345,
7,
339,
347,
485,
362,
63,
1652,
63,
576,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
340,
1067,
14,
362,
360,
493,
63,
2117,
297,
756,
304,
288,
372,
1300,
772,
14,
2143,
875,
8,
1100,
459,
493,
63,
2117,
2278,
2143,
360,
1624,
24,
1333,
267,
372,
2125,
339,
347,
485,
362,
63,
69,
12646,
63,
6063,
8,
277,
12,
3920,
12,
922,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
2293,
14,
362,
360,
470,
14,
6063,
1959,
1733,
8,
3937,
12,
922,
12,
4274,
600,
297,
283,
262,
297,
788,
619,
297,
283,
18998,
297,
283,
15068,
297,
283,
27808,
297,
283,
10892,
297,
283,
8699,
297,
283,
1976,
297,
283,
5372,
297,
283,
1093,
297,
283,
3975,
297,
283,
28327,
297,
283,
4332,
297,
283,
649,
297,
283,
18750,
297,
283,
17090,
297,
283,
20237,
297,
283,
5747,
297,
283,
14176,
297,
283,
2749,
297,
283,
4189,
297,
283,
1092,
297,
283,
8656,
297,
283,
2684,
297,
283,
654,
297,
283,
899,
297,
283,
6487,
31161,
339,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
1173,
2812,
659,
267,
283,
5191,
63,
600,
356,
1504,
14,
1560,
360,
15518,
5495,
297,
1568,
29,
22,
12,
1415,
29,
549,
12,
1720,
19938,
2765,
365,
2382,
1265,
1172,
370,
663,
314,
6247,
1233,
367,
314,
1109,
345,
957,
12560,
1808,
314,
1475,
26,
299,
647,
30917,
489,
510,
48,
883,
10584,
367,
282,
5794,
26,
687,
283,
614,
7,
370,
283,
713,
1370,
489,
510,
48,
883,
10584,
367,
282,
3229,
6415,
351,
26,
283,
2192,
1673,
708,
1673,
1153,
1673,
1082,
7,
881,
710,
1642,
9658,
4910,
626,
652,
365,
282,
3229,
6415,
351,
12,
881,
710,
3499,
9658,
10405,
314,
3229,
6415,
351,
14,
489,
510,
48,
883,
10584,
367,
282,
4890,
18672,
5361,
26,
283,
383,
1370,
489,
31946,
410,
5915,
367,
314,
5361,
334,
20,
12266,
680,
272,
1449,
272,
2318,
267,
283,
5191,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
2048,
14,
5191,
297,
283,
2048,
63,
5191,
63,
3369,
297,
283,
5470,
63,
344,
297,
283,
5191,
63,
344,
297,
283,
15518,
334,
83,
3196,
1720,
275,
283,
5446,
2348,
314,
6247,
8,
83,
9,
1265,
2934,
370,
2387,
315,
2195,
1109,
345,
957,
12560,
659,
267,
283,
5530,
63,
600,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5530,
14,
600,
297,
283,
16063,
297,
2881,
11699,
1708,
63,
344,
297,
6291,
756,
4360,
1720,
628,
18567,
2701,
370,
675,
314,
922,
1159,
7233,
401,
1415,
29,
549,
395,
267,
283,
396,
63,
1652,
356,
1504,
14,
4871,
360,
774,
4692,
570,
297,
1720,
628,
9899,
314,
4692,
1072,
465,
511,
570,
1288,
267,
283,
10333,
63,
344,
7,
520,
1504,
14,
1560,
360,
5083,
297,
1720,
628,
5083,
1627,
701,
314,
17634,
1905,
402,
314,
10209,
7233,
7651,
267,
283,
1328,
356,
1504,
14,
505,
360,
1173,
2737,
297,
6863,
29,
549,
395,
267,
283,
889,
63,
16305,
356,
1504,
14,
505,
360,
24120,
8777,
3091,
812,
619,
297,
6863,
29,
549,
12,
1720,
628,
1918,
31351,
7447,
812,
619,
1329,
365,
440,
3247,
436,
2985,
787,
440,
5120,
315,
4692,
3814,
7651,
267,
283,
493,
63,
2117,
7,
520,
1504,
14,
3008,
360,
8229,
3814,
297,
6863,
29,
549,
395,
267,
283,
6063,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
470,
14,
6063,
297,
283,
16305,
63,
6063,
63,
3369,
297,
283,
16305,
63,
344,
297,
283,
6063,
63,
344,
297,
283,
15201,
290,
1849,
324,
6264,
659,
267,
283,
6223,
356,
1504,
14,
505,
360,
18929,
659,
267,
789,
339,
347,
485,
362,
63,
5530,
63,
600,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
1559,
63,
5530,
63,
600,
275,
291,
14,
2293,
14,
362,
360,
2048,
14,
5530,
14,
600,
358,
267,
1559,
63,
751,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
3707,
358,
267,
7233,
63,
344,
275,
1559,
63,
751,
14,
4570,
8,
1556,
12,
1747,
12,
1747,
12,
1067,
29,
1100,
680,
4627,
63,
344,
14,
344,
267,
9067,
63,
600,
63,
1580,
275,
1559,
63,
5530,
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
] |
edesiocs/namebench
|
nb_third_party/jinja2/__init__.py
|
175
|
2270
|
# -*- coding: utf-8 -*-
"""
jinja2
~~~~~~
Jinja2 is a template engine written in pure Python. It provides a
Django inspired non-XML syntax but supports inline expressions and
an optional sandboxed environment.
Nutshell
--------
Here a small example of a Jinja2 template::
{% extends 'base.html' %}
{% block title %}Memberlist{% endblock %}
{% block content %}
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
{% endblock %}
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
__docformat__ = 'restructuredtext en'
__version__ = '2.4.1'
# high level interface
from jinja2.environment import Environment, Template
# loaders
from jinja2.loaders import BaseLoader, FileSystemLoader, PackageLoader, \
DictLoader, FunctionLoader, PrefixLoader, ChoiceLoader, \
ModuleLoader
# bytecode caches
from jinja2.bccache import BytecodeCache, FileSystemBytecodeCache, \
MemcachedBytecodeCache
# undefined types
from jinja2.runtime import Undefined, DebugUndefined, StrictUndefined
# exceptions
from jinja2.exceptions import TemplateError, UndefinedError, \
TemplateNotFound, TemplatesNotFound, TemplateSyntaxError, \
TemplateAssertionError
# decorators and public utilities
from jinja2.filters import environmentfilter, contextfilter, \
evalcontextfilter
from jinja2.utils import Markup, escape, clear_caches, \
environmentfunction, evalcontextfunction, contextfunction, \
is_undefined
__all__ = [
'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',
'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader',
'ChoiceLoader', 'BytecodeCache', 'FileSystemBytecodeCache',
'MemcachedBytecodeCache', 'Undefined', 'DebugUndefined',
'StrictUndefined', 'TemplateError', 'UndefinedError', 'TemplateNotFound',
'TemplatesNotFound', 'TemplateSyntaxError', 'TemplateAssertionError',
'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape',
'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',
'evalcontextfilter', 'evalcontextfunction'
]
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
272,
221,
2878,
1714,
339,
17300,
18,
365,
282,
1978,
6869,
5313,
315,
15111,
2018,
14,
221,
2779,
6571,
282,
272,
5634,
315,
8721,
581,
2222,
13,
4317,
6302,
1325,
5171,
8308,
8455,
436,
272,
376,
2716,
19699,
379,
3734,
14,
339,
653,
337,
5641,
272,
3001,
339,
11842,
282,
7425,
2893,
402,
282,
17300,
18,
1978,
447,
398,
7749,
16879,
283,
1095,
14,
1360,
7,
3674,
267,
7749,
1853,
2538,
3674,
7021,
513,
3996,
21525,
3674,
267,
7749,
1853,
1564,
3674,
881,
665,
348,
30,
881,
7749,
367,
922,
315,
4390,
3674,
288,
665,
317,
2535,
65,
4369,
628,
3638,
922,
14,
633,
3586,
1743,
3638,
922,
14,
2473,
18519,
65,
2957,
317,
30,
881,
7749,
17273,
3674,
881,
3068,
348,
30,
267,
7749,
21525,
3674,
2378,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
363,
21841,
363,
275,
283,
26854,
655,
7,
199,
363,
1023,
363,
275,
283,
18,
14,
20,
14,
17,
7,
199,
199,
3,
4721,
2166,
3217,
199,
504,
10321,
18,
14,
5418,
492,
9711,
12,
5458,
199,
199,
3,
25520,
199,
504,
10321,
18,
14,
16370,
492,
3523,
5455,
12,
23754,
5455,
12,
15665,
5455,
12,
971,
1362,
7448,
5455,
12,
6801,
5455,
12,
25110,
5455,
12,
16053,
5455,
12,
971,
1362,
5673,
5455,
199,
199,
3,
16855,
18014,
199,
504,
10321,
18,
14,
3776,
1637,
492,
20301,
600,
4437,
12,
23754,
4861,
600,
4437,
12,
971,
1362,
30465,
5245,
4861,
600,
4437,
199,
199,
3,
10942,
2943,
199,
504,
10321,
18,
14,
7726,
492,
25868,
12,
14245,
16283,
12,
23052,
16283,
199,
199,
3,
4967,
199,
504,
10321,
18,
14,
3924,
492,
5458,
547,
12,
25868,
547,
12,
971,
1362,
5458,
4667,
12,
31273,
4667,
12,
17762,
12,
971,
1362,
5458,
14844,
199,
199,
3,
20419,
436,
4575,
15841,
199,
504,
10321,
18,
14,
4273,
492,
3734,
1541,
12,
1067,
1541,
12,
971,
1362,
3468,
1100,
1541,
199,
504,
10321,
18,
14,
1208,
492,
17504,
12,
4772,
12,
5436,
63,
17595,
12,
971,
1362,
3734,
1593,
12,
3468,
1100,
1593,
12,
1067,
1593,
12,
971,
1362,
365,
63,
10705,
199,
199,
363,
452,
363,
275,
359,
272,
283,
8263,
297,
283,
4231,
297,
283,
1563,
5455,
297,
283,
17521,
5455,
297,
272,
283,
8599,
5455,
297,
283,
2141,
5455,
297,
283,
3481,
5455,
297,
283,
4793,
5455,
297,
272,
283,
9054,
5455,
297,
283,
4861,
600,
4437,
297,
283,
17521,
4861,
600,
4437,
297,
272,
283,
14169,
5245,
4861,
600,
4437,
297,
283,
16283,
297,
283,
7084,
16283,
297,
272,
283,
18625,
16283,
297,
283,
4231,
547,
297,
283,
16283,
547,
297,
283,
4231,
4667,
297,
272,
283,
17969,
4667,
297,
283,
20837,
297,
283,
4231,
14844,
297,
272,
283,
2377,
5455,
297,
283,
5418,
1541,
297,
283,
1100,
1541,
297,
283,
23393,
297,
283,
3765,
297,
272,
283,
5418,
1593,
297,
283,
1100,
1593,
297,
283,
3584,
63,
17595,
297,
283,
374,
63,
10705,
297,
272,
283,
2579,
1100,
1541,
297,
283,
2579,
1100,
1593,
7,
199,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
624,
272,
10321,
18,
272,
221,
2878,
1714,
339,
17300,
18,
365,
282,
1978,
6869,
5313,
315,
15111,
2018,
14,
221,
2779,
6571,
282,
272,
5634,
315,
8721,
581,
2222,
13,
4317,
6302,
1325,
5171,
8308,
8455,
436,
272,
376,
2716,
19699,
379,
3734,
14,
339,
653,
337,
5641,
272,
3001,
339,
11842,
282,
7425,
2893,
402,
282,
17300,
18,
1978,
447,
398,
7749,
16879,
283,
1095,
14,
1360,
7,
3674,
267,
7749,
1853,
2538,
3674,
7021,
513,
3996,
21525,
3674,
267,
7749,
1853,
1564,
3674,
881,
665,
348,
30,
881,
7749,
367,
922,
315,
4390,
3674,
288,
665,
317,
2535,
65,
4369,
628,
3638,
922,
14,
633,
3586,
1743,
3638,
922,
14,
2473,
18519,
65,
2957,
317,
30,
881,
7749,
17273,
3674,
881,
3068,
348,
30,
267,
7749,
21525,
3674,
2378,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
363,
21841,
363,
275,
283,
26854,
655,
7,
199,
363,
1023,
363,
275,
283,
18,
14,
20,
14,
17,
7,
199,
199,
3,
4721,
2166,
3217,
199,
504,
10321,
18,
14,
5418,
492,
9711,
12,
5458,
199,
199,
3,
25520,
199,
504,
10321,
18,
14,
16370,
492,
3523,
5455,
12,
23754,
5455,
12,
15665,
5455,
12,
971,
1362,
7448,
5455,
12,
6801,
5455,
12,
25110,
5455,
12,
16053,
5455,
12,
971,
1362,
5673,
5455,
199,
199,
3,
16855,
18014,
199,
504,
10321,
18,
14,
3776,
1637,
492,
20301,
600,
4437,
12,
23754,
4861,
600,
4437,
12,
971,
1362,
30465,
5245,
4861,
600,
4437,
199,
199,
3,
10942,
2943,
199,
504,
10321,
18,
14,
7726,
492,
25868,
12,
14245,
16283,
12,
23052,
16283,
199,
199,
3,
4967,
199,
504,
10321,
18,
14,
3924,
492,
5458,
547,
12,
25868,
547,
12,
971,
1362,
5458,
4667,
12,
31273,
4667,
12,
17762,
12,
971,
1362,
5458,
14844,
199,
199,
3,
20419,
436,
4575,
15841,
199,
504,
10321,
18,
14,
4273,
492,
3734,
1541,
12,
1067,
1541,
12,
971,
1362,
3468,
1100,
1541,
199,
504,
10321,
18,
14,
1208,
492,
17504,
12,
4772,
12,
5436,
63,
17595,
12,
971,
1362,
3734,
1593,
12,
3468,
1100,
1593,
12,
1067,
1593,
12,
971,
1362,
365,
63,
10705,
199,
199,
363,
452,
363,
275,
359,
272,
283,
8263,
297,
283,
4231,
297,
283,
1563,
5455,
297,
283,
17521,
5455,
297,
272,
283,
8599,
5455,
297,
283,
2141,
5455,
297,
283,
3481,
5455,
297,
283,
4793,
5455,
297,
272,
283,
9054,
5455,
297,
283,
4861,
600,
4437,
297,
283,
17521,
4861,
600,
4437,
297,
272,
283,
14169,
5245,
4861,
600,
4437,
297,
283,
16283,
297,
283,
7084,
16283,
297,
272,
283,
18625,
16283,
297,
283,
4231,
547,
297,
283,
16283,
547,
297,
283,
4231,
4667,
297,
272,
283,
17969,
4667,
297,
283,
20837,
297,
283,
4231,
14844,
297,
272,
283,
2377,
5455,
297,
283,
5418,
1541,
297,
283,
1100,
1541,
297,
283,
23393,
297,
283,
3765,
297,
272,
283,
5418,
1593,
297,
283,
1100,
1593,
297,
283,
3584,
63,
17595,
297,
283,
374,
63,
10705,
297,
272,
283,
2579,
1100,
1541,
297,
283,
2579,
1100,
1593,
7,
199,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
eBay/restcommander
|
play-1.2.4/python/Lib/encodings/euc_jisx0213.py
|
816
|
1051
|
#
# euc_jisx0213.py: Python Unicode Codec for EUC_JISX0213
#
# Written by Hye-Shik Chang <perky@FreeBSD.org>
#
import _codecs_jp, codecs
import _multibytecodec as mbc
codec = _codecs_jp.getcodec('euc_jisx0213')
class Codec(codecs.Codec):
encode = codec.encode
decode = codec.decode
class IncrementalEncoder(mbc.MultibyteIncrementalEncoder,
codecs.IncrementalEncoder):
codec = codec
class IncrementalDecoder(mbc.MultibyteIncrementalDecoder,
codecs.IncrementalDecoder):
codec = codec
class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader):
codec = codec
class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter):
codec = codec
def getregentry():
return codecs.CodecInfo(
name='euc_jisx0213',
encode=Codec().encode,
decode=Codec().decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamreader=StreamReader,
streamwriter=StreamWriter,
)
|
apache-2.0
|
[
3,
199,
3,
325,
947,
63,
18941,
88,
996,
969,
14,
647,
26,
2018,
6140,
13732,
367,
662,
13371,
63,
22290,
56,
996,
969,
199,
3,
199,
3,
27694,
701,
869,
8048,
13,
2662,
3258,
2799,
621,
665,
529,
10562,
32,
10146,
15400,
14,
1308,
30,
199,
3,
199,
199,
646,
485,
8933,
63,
11538,
12,
6010,
199,
646,
485,
3029,
4414,
9276,
465,
333,
3776,
199,
199,
9276,
275,
485,
8933,
63,
11538,
14,
362,
9276,
360,
15149,
63,
18941,
88,
996,
969,
358,
199,
199,
533,
13732,
8,
8933,
14,
8818,
304,
272,
3752,
275,
9076,
14,
2143,
272,
4849,
275,
9076,
14,
2708,
199,
199,
533,
24350,
8,
887,
67,
14,
3947,
4414,
17016,
12,
586,
6010,
14,
17016,
304,
272,
9076,
275,
9076,
199,
199,
533,
24385,
8,
887,
67,
14,
3947,
4414,
16703,
12,
586,
6010,
14,
16703,
304,
272,
9076,
275,
9076,
199,
199,
533,
22970,
8,
8818,
12,
333,
3776,
14,
3947,
4414,
16132,
12,
6010,
14,
16132,
304,
272,
9076,
275,
9076,
199,
199,
533,
24163,
8,
8818,
12,
333,
3776,
14,
3947,
4414,
16551,
12,
6010,
14,
16551,
304,
272,
9076,
275,
9076,
199,
199,
318,
26116,
837,
272,
372,
6010,
14,
26375,
8,
267,
536,
534,
15149,
63,
18941,
88,
996,
969,
297,
267,
3752,
29,
8818,
1252,
2143,
12,
267,
4849,
29,
8818,
1252,
2708,
12,
267,
26329,
29,
17016,
12,
267,
26317,
29,
16703,
12,
267,
26101,
29,
16132,
12,
267,
26112,
29,
16551,
12,
272,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
325,
947,
63,
18941,
88,
996,
969,
14,
647,
26,
2018,
6140,
13732,
367,
662,
13371,
63,
22290,
56,
996,
969,
199,
3,
199,
3,
27694,
701,
869,
8048,
13,
2662,
3258,
2799,
621,
665,
529,
10562,
32,
10146,
15400,
14,
1308,
30,
199,
3,
199,
199,
646,
485,
8933,
63,
11538,
12,
6010,
199,
646,
485,
3029,
4414,
9276,
465,
333,
3776,
199,
199,
9276,
275,
485,
8933,
63,
11538,
14,
362,
9276,
360,
15149,
63,
18941,
88,
996,
969,
358,
199,
199,
533,
13732,
8,
8933,
14,
8818,
304,
272,
3752,
275,
9076,
14,
2143,
272,
4849,
275,
9076,
14,
2708,
199,
199,
533,
24350,
8,
887,
67,
14,
3947,
4414,
17016,
12,
586,
6010,
14,
17016,
304,
272,
9076,
275,
9076,
199,
199,
533,
24385,
8,
887,
67,
14,
3947,
4414,
16703,
12,
586,
6010,
14,
16703,
304,
272,
9076,
275,
9076,
199,
199,
533,
22970,
8,
8818,
12,
333,
3776,
14,
3947,
4414,
16132,
12,
6010,
14,
16132,
304,
272,
9076,
275,
9076,
199,
199,
533,
24163,
8,
8818,
12,
333,
3776,
14,
3947,
4414,
16551,
12,
6010,
14,
16551,
304,
272,
9076,
275,
9076,
199,
199,
318,
26116,
837,
272,
372,
6010,
14,
26375,
8,
267,
536,
534,
15149,
63,
18941,
88,
996,
969,
297,
267,
3752,
29,
8818,
1252,
2143,
12,
267,
4849,
29,
8818,
1252,
2708,
12,
267,
26329,
29,
17016,
12,
267,
26317,
29,
16703,
12,
267,
26101,
29,
16132,
12,
267,
26112,
29,
16551,
12,
272,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
schlueter/ansible
|
lib/ansible/modules/packaging/os/pkgutil.py
|
52
|
6757
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2013, Alexander Winkler <mail () winkler-alexander.de>
# based on svr4pkg by
# Boyd Adamson <boyd () boydadamson.com> (2012)
#
# 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: pkgutil
short_description: Manage CSW-Packages on Solaris
description:
- Manages CSW packages (SVR4 format) on Solaris 10 and 11.
- These were the native packages on Solaris <= 10 and are available
as a legacy feature in Solaris 11.
- Pkgutil is an advanced packaging system, which resolves dependency on installation.
It is designed for CSW packages.
version_added: "1.3"
author: "Alexander Winkler (@dermute)"
options:
name:
description:
- Package name, e.g. (C(CSWnrpe))
required: true
site:
description:
- Specifies the repository path to install the package from.
- Its global definition is done in C(/etc/opt/csw/pkgutil.conf).
required: false
state:
description:
- Whether to install (C(present)), or remove (C(absent)) a package.
- The upgrade (C(latest)) operation will update/install the package to the latest version available.
- "Note: The module has a limitation that (C(latest)) only works for one package, not lists of them."
required: true
choices: ["present", "absent", "latest"]
update_catalog:
description:
- If you want to refresh your catalog from the mirror, set this to (C(yes)).
required: false
default: False
version_added: "2.1"
'''
EXAMPLES = '''
# Install a package
- pkgutil:
name: CSWcommon
state: present
# Install a package from a specific repository
- pkgutil:
name: CSWnrpe
site: 'ftp://myinternal.repo/opencsw/kiel'
state: latest
'''
from ansible.module_utils.basic import AnsibleModule
def package_installed(module, name):
cmd = ['pkginfo']
cmd.append('-q')
cmd.append(name)
rc, out, err = run_command(module, cmd)
if rc == 0:
return True
else:
return False
def package_latest(module, name, site):
# Only supports one package
cmd = ['pkgutil', '-U', '--single', '-c']
if site is not None:
cmd += ['-t', site]
cmd.append(name)
rc, out, err = run_command(module, cmd)
# replace | tail -1 |grep -v SAME
# use -2, because splitting on \n create a empty line
# at the end of the list
return 'SAME' in out.split('\n')[-2]
def run_command(module, cmd, **kwargs):
progname = cmd[0]
cmd[0] = module.get_bin_path(progname, True, ['/opt/csw/bin'])
return module.run_command(cmd, **kwargs)
def package_install(module, state, name, site, update_catalog):
cmd = ['pkgutil', '-iy']
if update_catalog:
cmd += ['-U']
if site is not None:
cmd += ['-t', site]
if state == 'latest':
cmd += ['-f']
cmd.append(name)
(rc, out, err) = run_command(module, cmd)
return (rc, out, err)
def package_upgrade(module, name, site, update_catalog):
cmd = ['pkgutil', '-ufy']
if update_catalog:
cmd += ['-U']
if site is not None:
cmd += ['-t', site]
cmd.append(name)
(rc, out, err) = run_command(module, cmd)
return (rc, out, err)
def package_uninstall(module, name):
cmd = ['pkgutil', '-ry', name]
(rc, out, err) = run_command(module, cmd)
return (rc, out, err)
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True),
state=dict(required=True, choices=['present', 'absent', 'latest']),
site=dict(default=None),
update_catalog=dict(required=False, default=False, type='bool'),
),
supports_check_mode=True
)
name = module.params['name']
state = module.params['state']
site = module.params['site']
update_catalog = module.params['update_catalog']
rc = None
out = ''
err = ''
result = {}
result['name'] = name
result['state'] = state
if state == 'present':
if not package_installed(module, name):
if module.check_mode:
module.exit_json(changed=True)
(rc, out, err) = package_install(module, state, name, site, update_catalog)
# Stdout is normally empty but for some packages can be
# very long and is not often useful
if len(out) > 75:
out = out[:75] + '...'
if rc != 0:
if err:
msg = err
else:
msg = out
module.fail_json(msg=msg)
elif state == 'latest':
if not package_installed(module, name):
if module.check_mode:
module.exit_json(changed=True)
(rc, out, err) = package_install(module, state, name, site, update_catalog)
if len(out) > 75:
out = out[:75] + '...'
if rc != 0:
if err:
msg = err
else:
msg = out
module.fail_json(msg=msg)
else:
if not package_latest(module, name, site):
if module.check_mode:
module.exit_json(changed=True)
(rc, out, err) = package_upgrade(module, name, site, update_catalog)
if len(out) > 75:
out = out[:75] + '...'
if rc != 0:
if err:
msg = err
else:
msg = out
module.fail_json(msg=msg)
elif state == 'absent':
if package_installed(module, name):
if module.check_mode:
module.exit_json(changed=True)
(rc, out, err) = package_uninstall(module, name)
if len(out) > 75:
out = out[:75] + '...'
if rc != 0:
if err:
msg = err
else:
msg = out
module.fail_json(msg=msg)
if rc is None:
# pkgutil was not executed because the package was already present/absent
result['changed'] = False
elif rc == 0:
result['changed'] = True
else:
result['changed'] = False
result['failed'] = True
if out:
result['stdout'] = out
if err:
result['stderr'] = err
module.exit_json(**result)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6171,
12,
22986,
11438,
644,
2292,
1435,
665,
1198,
6248,
336,
2292,
1435,
13,
24421,
11438,
14,
271,
30,
199,
3,
4079,
641,
308,
10922,
20,
4600,
701,
199,
3,
221,
5088,
24503,
4431,
455,
834,
665,
656,
24503,
6248,
1234,
24503,
27679,
834,
14,
957,
30,
334,
7409,
9,
199,
3,
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,
2595,
199,
578,
26,
28728,
199,
3612,
63,
1802,
26,
14944,
445,
8745,
13,
25135,
641,
17991,
4663,
199,
1802,
26,
272,
446,
21612,
445,
8745,
6117,
334,
4985,
50,
20,
1475,
9,
641,
17991,
4663,
1616,
436,
4119,
14,
272,
446,
5723,
4898,
314,
5438,
6117,
641,
17991,
4663,
2695,
1616,
436,
787,
2808,
489,
465,
282,
12139,
3878,
315,
17991,
4663,
4119,
14,
272,
446,
510,
9761,
1974,
365,
376,
19472,
27369,
2656,
12,
1314,
32253,
5936,
641,
12096,
14,
489,
2779,
365,
19829,
367,
445,
8745,
6117,
14,
199,
1023,
63,
3270,
26,
298,
17,
14,
19,
2,
199,
2502,
26,
298,
33,
3113,
11438,
644,
2292,
1435,
8593,
424,
12423,
2924,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
15665,
536,
12,
325,
14,
71,
14,
334,
35,
8,
3298,
55,
7865,
321,
430,
272,
1415,
26,
2549,
523,
4770,
26,
272,
1369,
26,
489,
446,
11015,
314,
7611,
931,
370,
3907,
314,
2559,
687,
14,
489,
446,
22940,
2288,
5492,
365,
4224,
315,
445,
29478,
6839,
15,
2992,
15,
29735,
15,
4600,
1974,
14,
2190,
680,
272,
1415,
26,
3055,
523,
1174,
26,
272,
1369,
26,
489,
446,
7480,
370,
3907,
334,
35,
8,
1881,
1826,
503,
2813,
334,
35,
8,
5575,
430,
282,
2559,
14,
489,
446,
710,
10754,
334,
35,
8,
7410,
430,
3439,
911,
1678,
15,
3174,
314,
2559,
370,
314,
8839,
1015,
2808,
14,
489,
446,
298,
7443,
26,
710,
859,
965,
282,
12305,
626,
334,
35,
8,
7410,
430,
1454,
5419,
367,
1373,
2559,
12,
440,
5548,
402,
3062,
2122,
272,
1415,
26,
2549,
272,
3415,
26,
2097,
1881,
401,
298,
5575,
401,
298,
7410,
937,
523,
1678,
63,
7959,
26,
272,
1369,
26,
489,
446,
982,
1265,
2934,
370,
9236,
2195,
10594,
687,
314,
15216,
12,
663,
642,
370,
334,
35,
8,
5066,
4992,
272,
1415,
26,
3055,
272,
849,
26,
756,
272,
1015,
63,
3270,
26,
298,
18,
14,
17,
2,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
13276,
282,
2559,
199,
13,
28728,
26,
272,
536,
26,
445,
8745,
2330,
272,
1174,
26,
3451,
199,
199,
3,
13276,
282,
2559,
687,
282,
2488,
7611,
199,
13,
28728,
26,
272,
536,
26,
445,
8745,
7865,
321,
272,
4770,
26,
283,
8915,
921,
1662,
4672,
14,
3417,
15,
1490,
29735,
15,
8810,
352,
7,
272,
1174,
26,
8839,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
421,
199,
318,
2559,
63,
7657,
8,
578,
12,
536,
304,
272,
2088,
275,
788,
4600,
815,
418,
272,
2088,
14,
740,
3654,
81,
358,
272,
2088,
14,
740,
8,
354,
9,
272,
4819,
12,
734,
12,
2329,
275,
1255,
63,
1531,
8,
578,
12,
2088,
9,
272,
340,
4819,
508,
378,
26,
267,
372,
715,
272,
587,
26,
267,
372,
756,
421,
199,
318,
2559,
63,
7410,
8,
578,
12,
536,
12,
4770,
304,
272,
327,
5972,
5171,
1373,
2559,
272,
2088,
275,
788,
4600,
1974,
297,
2475,
53,
297,
2850,
4780,
297,
2475,
67,
418,
272,
340,
4770,
365,
440,
488,
26,
267,
2088,
847,
11573,
84,
297,
4770,
61,
272,
2088,
14,
740,
8,
354,
9,
272,
4819,
12,
734,
12,
2329,
275,
1255,
63,
1531,
8,
578,
12,
2088,
9,
272,
327,
3350,
1204,
9483,
446,
17,
1204,
25914,
446,
86,
428,
1991,
272,
327,
675,
446,
18,
12,
2952,
26518,
641,
971,
78,
1218,
282,
2701,
1004,
272,
327,
737,
314,
1284,
402,
314,
769,
272,
372,
283,
19935,
7,
315,
734,
14,
1294,
2258,
78,
358,
1988,
18,
61,
421,
199,
318,
1255,
63,
1531,
8,
578,
12,
2088,
12,
1011,
958,
304,
272,
13205,
354,
275,
2088,
59,
16,
61,
272,
2088,
59,
16,
61,
275,
859,
14,
362,
63,
1393,
63,
515,
8,
6595,
354,
12,
715,
12,
18744,
2992,
15,
29735,
15,
1393,
1105,
272,
372,
859,
14,
1065,
63,
1531,
8,
1760,
12,
1011,
958,
9,
421,
199,
318,
2559,
63,
3174,
8,
578,
12,
1174,
12,
536,
12,
4770,
12,
1678,
63,
7959,
304,
272,
2088,
275,
788,
4600,
1974,
297,
2475,
31256,
418,
272,
340,
1678,
63,
7959,
26,
267,
2088,
847,
11573,
53,
418,
272,
340,
4770,
365,
440,
488,
26,
267,
2088,
847,
11573,
84,
297,
4770,
61,
272,
340,
1174,
508,
283,
7410,
356,
267,
2088,
847,
11573,
70,
418,
272,
2088,
14,
740,
8,
354,
9,
272,
334,
1195,
12,
734,
12,
2329,
9,
275,
1255,
63,
1531,
8,
578,
12,
2088,
9,
272,
372,
334,
1195,
12,
734,
12,
2329,
9,
421,
199,
318,
2559,
63,
9375,
8,
578,
12,
536,
12,
4770,
12,
1678,
63,
7959,
304,
272,
2088,
275,
788,
4600,
1974,
297,
2475,
1286,
89,
418,
272,
340,
1678,
63,
7959,
26,
267,
2088,
847,
11573,
53,
418,
272,
340,
4770,
365,
440,
488,
26,
267,
2088,
847,
11573,
84,
297,
4770,
61,
272,
2088,
14,
740,
8,
354,
9,
272,
334,
1195,
12,
734,
12,
2329,
9,
275,
1255,
63,
1531,
8,
578,
12,
2088,
9,
272,
372,
334,
1195,
12,
734,
12,
2329,
9,
421,
199,
318,
2559,
63,
19502,
8,
578,
12,
536,
304,
272,
2088
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6171,
12,
22986,
11438,
644,
2292,
1435,
665,
1198,
6248,
336,
2292,
1435,
13,
24421,
11438,
14,
271,
30,
199,
3,
4079,
641,
308,
10922,
20,
4600,
701,
199,
3,
221,
5088,
24503,
4431,
455,
834,
665,
656,
24503,
6248,
1234,
24503,
27679,
834,
14,
957,
30,
334,
7409,
9,
199,
3,
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,
2595,
199,
578,
26,
28728,
199,
3612,
63,
1802,
26,
14944,
445,
8745,
13,
25135,
641,
17991,
4663,
199,
1802,
26,
272,
446,
21612,
445,
8745,
6117,
334,
4985,
50,
20,
1475,
9,
641,
17991,
4663,
1616,
436,
4119,
14,
272,
446,
5723,
4898,
314,
5438,
6117,
641,
17991,
4663,
2695,
1616,
436,
787,
2808,
489,
465,
282,
12139,
3878,
315,
17991,
4663,
4119,
14,
272,
446,
510,
9761,
1974,
365,
376,
19472,
27369,
2656,
12,
1314,
32253,
5936,
641,
12096,
14,
489,
2779,
365,
19829,
367,
445,
8745,
6117,
14,
199,
1023,
63,
3270,
26,
298,
17,
14,
19,
2,
199,
2502,
26,
298,
33,
3113,
11438,
644,
2292,
1435,
8593,
424,
12423,
2924,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
15665,
536,
12,
325,
14,
71,
14,
334,
35,
8,
3298,
55,
7865,
321,
430,
272,
1415,
26,
2549,
523,
4770,
26,
272,
1369,
26,
489,
446,
11015,
314,
7611,
931,
370,
3907,
314,
2559,
687,
14,
489,
446,
22940,
2288,
5492,
365,
4224,
315,
445,
29478,
6839,
15,
2992,
15,
29735,
15,
4600,
1974,
14,
2190,
680,
272,
1415,
26,
3055,
523,
1174,
26,
272,
1369,
26,
489,
446,
7480,
370,
3907,
334,
35,
8,
1881,
1826,
503,
2813,
334,
35,
8,
5575,
430,
282,
2559,
14,
489,
446,
710,
10754,
334,
35,
8,
7410,
430,
3439,
911,
1678,
15,
3174,
314,
2559,
370,
314,
8839,
1015,
2808,
14,
489,
446,
298,
7443,
26,
710,
859,
965,
282,
12305,
626,
334,
35,
8,
7410,
430,
1454,
5419,
367,
1373,
2559,
12,
440,
5548,
402,
3062,
2122,
272,
1415,
26,
2549,
272,
3415,
26,
2097,
1881,
401,
298,
5575,
401,
298,
7410,
937,
523,
1678,
63,
7959,
26,
272,
1369,
26,
489,
446,
982,
1265,
2934,
370,
9236,
2195,
10594,
687,
314,
15216,
12,
663,
642,
370,
334,
35,
8,
5066,
4992,
272,
1415,
26,
3055,
272,
849,
26,
756,
272,
1015,
63,
3270,
26,
298,
18,
14,
17,
2,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
13276,
282,
2559,
199,
13,
28728,
26,
272,
536,
26,
445,
8745,
2330,
272,
1174,
26,
3451,
199,
199,
3,
13276,
282,
2559,
687,
282,
2488,
7611,
199,
13,
28728,
26,
272,
536,
26,
445,
8745,
7865,
321,
272,
4770,
26,
283,
8915,
921,
1662,
4672,
14,
3417,
15,
1490,
29735,
15,
8810,
352,
7,
272,
1174,
26,
8839,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
421,
199,
318,
2559,
63,
7657,
8,
578,
12,
536,
304,
272,
2088,
275,
788,
4600,
815,
418,
272,
2088,
14,
740,
3654,
81,
358,
272,
2088,
14,
740,
8,
354,
9,
272,
4819,
12,
734,
12,
2329,
275,
1255,
63,
1531,
8,
578,
12,
2088,
9,
272,
340,
4819,
508,
378,
26,
267,
372,
715,
272,
587,
26,
267,
372,
756,
421,
199,
318,
2559,
63,
7410,
8,
578,
12,
536,
12,
4770,
304,
272,
327,
5972,
5171,
1373,
2559,
272,
2088,
275,
788,
4600,
1974,
297,
2475,
53,
297,
2850,
4780,
297,
2475,
67,
418,
272,
340,
4770,
365,
440,
488,
26,
267,
2088,
847,
11573,
84,
297,
4770,
61,
272,
2088,
14,
740,
8,
354,
9,
272,
4819,
12,
734,
12,
2329,
275,
1255,
63,
1531,
8,
578,
12,
2088,
9,
272,
327,
3350,
1204,
9483,
446,
17,
1204,
25914,
446,
86,
428,
1991,
272,
327,
675,
446,
18,
12,
2952,
26518,
641,
971,
78,
1218,
282,
2701,
1004,
272,
327,
737,
314,
1284,
402,
314,
769,
272,
372,
283,
19935,
7,
315,
734,
14,
1294,
2258,
78,
358,
1988,
18,
61,
421,
199,
318,
1255,
63,
1531,
8,
578,
12,
2088,
12,
1011,
958,
304,
272,
13205,
354,
275,
2088,
59,
16,
61,
272,
2088,
59,
16,
61,
275,
859,
14,
362,
63,
1393,
63,
515,
8,
6595,
354,
12,
715,
12,
18744,
2992,
15,
29735,
15,
1393,
1105,
272,
372,
859,
14,
1065,
63,
1531,
8,
1760,
12,
1011,
958,
9,
421,
199,
318,
2559,
63,
3174,
8,
578,
12,
1174,
12,
536,
12,
4770,
12,
1678,
63,
7959,
304,
272,
2088,
275,
788,
4600,
1974,
297,
2475,
31256,
418,
272,
340,
1678,
63,
7959,
26,
267,
2088,
847,
11573,
53,
418,
272,
340,
4770,
365,
440,
488,
26,
267,
2088,
847,
11573,
84,
297,
4770,
61,
272,
340,
1174,
508,
283,
7410,
356,
267,
2088,
847,
11573,
70,
418,
272,
2088,
14,
740,
8,
354,
9,
272,
334,
1195,
12,
734,
12,
2329,
9,
275,
1255,
63,
1531,
8,
578,
12,
2088,
9,
272,
372,
334,
1195,
12,
734,
12,
2329,
9,
421,
199,
318,
2559,
63,
9375,
8,
578,
12,
536,
12,
4770,
12,
1678,
63,
7959,
304,
272,
2088,
275,
788,
4600,
1974,
297,
2475,
1286,
89,
418,
272,
340,
1678,
63,
7959,
26,
267,
2088,
847,
11573,
53,
418,
272,
340,
4770,
365,
440,
488,
26,
267,
2088,
847,
11573,
84,
297,
4770,
61,
272,
2088,
14,
740,
8,
354,
9,
272,
334,
1195,
12,
734,
12,
2329,
9,
275,
1255,
63,
1531,
8,
578,
12,
2088,
9,
272,
372,
334,
1195,
12,
734,
12,
2329,
9,
421,
199,
318,
2559,
63,
19502,
8,
578,
12,
536,
304,
272,
2088,
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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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Orochimarufan/youtube-dl
|
devscripts/gh-pages/add-version.py
|
174
|
1170
|
#!/usr/bin/env python3
from __future__ import unicode_literals
import json
import sys
import hashlib
import os.path
if len(sys.argv) <= 1:
print('Specify the version number as parameter')
sys.exit()
version = sys.argv[1]
with open('update/LATEST_VERSION', 'w') as f:
f.write(version)
versions_info = json.load(open('update/versions.json'))
if 'signature' in versions_info:
del versions_info['signature']
new_version = {}
filenames = {
'bin': 'youtube-dl',
'exe': 'youtube-dl.exe',
'tar': 'youtube-dl-%s.tar.gz' % version}
build_dir = os.path.join('..', '..', 'build', version)
for key, filename in filenames.items():
url = 'https://yt-dl.org/downloads/%s/%s' % (version, filename)
fn = os.path.join(build_dir, filename)
with open(fn, 'rb') as f:
data = f.read()
if not data:
raise ValueError('File %s is empty!' % fn)
sha256sum = hashlib.sha256(data).hexdigest()
new_version[key] = (url, sha256sum)
versions_info['versions'][version] = new_version
versions_info['latest'] = version
with open('update/versions.json', 'w') as jsonf:
json.dump(versions_info, jsonf, indent=4, sort_keys=True)
|
unlicense
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2022,
199,
646,
984,
199,
646,
8337,
199,
646,
747,
14,
515,
421,
199,
692,
822,
8,
1274,
14,
3020,
9,
2695,
413,
26,
272,
870,
360,
17768,
314,
1015,
1329,
465,
2725,
358,
272,
984,
14,
2224,
342,
199,
1023,
275,
984,
14,
3020,
59,
17,
61,
199,
199,
1045,
1551,
360,
873,
15,
20307,
1719,
63,
4612,
297,
283,
87,
358,
465,
289,
26,
272,
289,
14,
952,
8,
1023,
9,
199,
199,
6234,
63,
815,
275,
2022,
14,
912,
8,
1490,
360,
873,
15,
6234,
14,
1001,
1333,
199,
692,
283,
5233,
7,
315,
5459,
63,
815,
26,
272,
2150,
5459,
63,
815,
459,
5233,
418,
199,
199,
1222,
63,
1023,
275,
1052,
199,
199,
10309,
275,
469,
272,
283,
1393,
356,
283,
9788,
13,
5030,
297,
272,
283,
5803,
356,
283,
9788,
13,
5030,
14,
5803,
297,
272,
283,
5369,
356,
283,
9788,
13,
5030,
3295,
83,
14,
5369,
14,
6838,
7,
450,
1015,
93,
199,
1506,
63,
694,
275,
747,
14,
515,
14,
904,
24893,
297,
19155,
283,
1506,
297,
1015,
9,
199,
509,
790,
12,
1788,
315,
6203,
14,
1744,
837,
272,
1166,
275,
283,
2859,
921,
24264,
13,
5030,
14,
1308,
15,
20373,
3149,
83,
3149,
83,
7,
450,
334,
1023,
12,
1788,
9,
272,
4325,
275,
747,
14,
515,
14,
904,
8,
1506,
63,
694,
12,
1788,
9,
272,
543,
1551,
8,
2324,
12,
283,
4848,
358,
465,
289,
26,
267,
666,
275,
289,
14,
739,
342,
272,
340,
440,
666,
26,
267,
746,
1722,
360,
1173,
450,
83,
365,
2701,
11213,
450,
4325,
9,
272,
7793,
3912,
1838,
275,
8337,
14,
4835,
3912,
8,
576,
680,
11453,
342,
272,
892,
63,
1023,
59,
498,
61,
275,
334,
633,
12,
7793,
3912,
1838,
9,
199,
199,
6234,
63,
815,
459,
6234,
3488,
1023,
61,
275,
892,
63,
1023,
199,
6234,
63,
815,
459,
7410,
418,
275,
1015,
199,
199,
1045,
1551,
360,
873,
15,
6234,
14,
1001,
297,
283,
87,
358,
465,
2022,
70,
26,
272,
2022,
14,
2724,
8,
6234,
63,
815,
12,
2022,
70,
12,
4363,
29,
20,
12,
4069,
63,
1612,
29,
549,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2022,
199,
646,
984,
199,
646,
8337,
199,
646,
747,
14,
515,
421,
199,
692,
822,
8,
1274,
14,
3020,
9,
2695,
413,
26,
272,
870,
360,
17768,
314,
1015,
1329,
465,
2725,
358,
272,
984,
14,
2224,
342,
199,
1023,
275,
984,
14,
3020,
59,
17,
61,
199,
199,
1045,
1551,
360,
873,
15,
20307,
1719,
63,
4612,
297,
283,
87,
358,
465,
289,
26,
272,
289,
14,
952,
8,
1023,
9,
199,
199,
6234,
63,
815,
275,
2022,
14,
912,
8,
1490,
360,
873,
15,
6234,
14,
1001,
1333,
199,
692,
283,
5233,
7,
315,
5459,
63,
815,
26,
272,
2150,
5459,
63,
815,
459,
5233,
418,
199,
199,
1222,
63,
1023,
275,
1052,
199,
199,
10309,
275,
469,
272,
283,
1393,
356,
283,
9788,
13,
5030,
297,
272,
283,
5803,
356,
283,
9788,
13,
5030,
14,
5803,
297,
272,
283,
5369,
356,
283,
9788,
13,
5030,
3295,
83,
14,
5369,
14,
6838,
7,
450,
1015,
93,
199,
1506,
63,
694,
275,
747,
14,
515,
14,
904,
24893,
297,
19155,
283,
1506,
297,
1015,
9,
199,
509,
790,
12,
1788,
315,
6203,
14,
1744,
837,
272,
1166,
275,
283,
2859,
921,
24264,
13,
5030,
14,
1308,
15,
20373,
3149,
83,
3149,
83,
7,
450,
334,
1023,
12,
1788,
9,
272,
4325,
275,
747,
14,
515,
14,
904,
8,
1506,
63,
694,
12,
1788,
9,
272,
543,
1551,
8,
2324,
12,
283,
4848,
358,
465,
289,
26,
267,
666,
275,
289,
14,
739,
342,
272,
340,
440,
666,
26,
267,
746,
1722,
360,
1173,
450,
83,
365,
2701,
11213,
450,
4325,
9,
272,
7793,
3912,
1838,
275,
8337,
14,
4835,
3912,
8,
576,
680,
11453,
342,
272,
892,
63,
1023,
59,
498,
61,
275,
334,
633,
12,
7793,
3912,
1838,
9,
199,
199,
6234,
63,
815,
459,
6234,
3488,
1023,
61,
275,
892,
63,
1023,
199,
6234,
63,
815,
459,
7410,
418,
275,
1015,
199,
199,
1045,
1551,
360,
873,
15,
6234,
14,
1001,
297,
283,
87,
358,
465,
2022,
70,
26,
272,
2022,
14,
2724,
8,
6234,
63,
815,
12,
2022,
70,
12,
4363,
29,
20,
12,
4069,
63,
1612,
29,
549,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
fiji-flo/servo
|
tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/environment.py
|
1
|
8310
|
import json
import os
import multiprocessing
import signal
import socket
import sys
import time
from mozlog import get_default_logger, handlers, proxy
from wptlogging import LogLevelRewriter
from wptserve.handlers import StringHandler
here = os.path.split(__file__)[0]
repo_root = os.path.abspath(os.path.join(here, os.pardir, os.pardir, os.pardir))
serve = None
sslutils = None
def do_delayed_imports(logger, test_paths):
global serve, sslutils
serve_root = serve_path(test_paths)
sys.path.insert(0, serve_root)
failed = []
try:
from tools.serve import serve
except ImportError:
failed.append("serve")
try:
import sslutils
except ImportError:
failed.append("sslutils")
if failed:
logger.critical(
"Failed to import %s. Ensure that tests path %s contains web-platform-tests" %
(", ".join(failed), serve_root))
sys.exit(1)
def serve_path(test_paths):
return test_paths["/"]["tests_path"]
def get_ssl_kwargs(**kwargs):
if kwargs["ssl_type"] == "openssl":
args = {"openssl_binary": kwargs["openssl_binary"]}
elif kwargs["ssl_type"] == "pregenerated":
args = {"host_key_path": kwargs["host_key_path"],
"host_cert_path": kwargs["host_cert_path"],
"ca_cert_path": kwargs["ca_cert_path"]}
else:
args = {}
return args
def ssl_env(logger, **kwargs):
ssl_env_cls = sslutils.environments[kwargs["ssl_type"]]
return ssl_env_cls(logger, **get_ssl_kwargs(**kwargs))
class TestEnvironmentError(Exception):
pass
class TestEnvironment(object):
def __init__(self, test_paths, ssl_env, pause_after_test, debug_info, options, env_extras):
"""Context manager that owns the test environment i.e. the http and
websockets servers"""
self.test_paths = test_paths
self.ssl_env = ssl_env
self.server = None
self.config = None
self.pause_after_test = pause_after_test
self.test_server_port = options.pop("test_server_port", True)
self.debug_info = debug_info
self.options = options if options is not None else {}
self.cache_manager = multiprocessing.Manager()
self.stash = serve.stash.StashServer()
self.env_extras = env_extras
self.env_extras_cms = None
def __enter__(self):
self.stash.__enter__()
self.ssl_env.__enter__()
self.cache_manager.__enter__()
self.config = self.load_config()
self.setup_server_logging()
ports = serve.get_ports(self.config, self.ssl_env)
self.config = serve.normalise_config(self.config, ports)
assert self.env_extras_cms is None, (
"A TestEnvironment object cannot be nested")
self.env_extras_cms = []
for env in self.env_extras:
cm = env(self.options, self.config)
cm.__enter__()
self.env_extras_cms.append(cm)
self.servers = serve.start(self.config, self.ssl_env,
self.get_routes())
if self.options.get("supports_debugger") and self.debug_info and self.debug_info.interactive:
self.ignore_interrupts()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.process_interrupts()
for scheme, servers in self.servers.iteritems():
for port, server in servers:
server.kill()
for cm in self.env_extras_cms:
cm.__exit__(exc_type, exc_val, exc_tb)
self.env_extras_cms = None
self.cache_manager.__exit__(exc_type, exc_val, exc_tb)
self.ssl_env.__exit__(exc_type, exc_val, exc_tb)
self.stash.__exit__()
def ignore_interrupts(self):
signal.signal(signal.SIGINT, signal.SIG_IGN)
def process_interrupts(self):
signal.signal(signal.SIGINT, signal.SIG_DFL)
def load_config(self):
default_config_path = os.path.join(serve_path(self.test_paths), "config.default.json")
local_config = {
"ports": {
"http": [8000, 8001],
"https": [8443],
"ws": [8888]
},
"check_subdomains": False,
"bind_hostname": self.options["bind_hostname"],
"ssl": {}
}
if "host" in self.options:
local_config["host"] = self.options["host"]
with open(default_config_path) as f:
default_config = json.load(f)
#TODO: allow non-default configuration for ssl
local_config["external_host"] = self.options.get("external_host", None)
local_config["ssl"]["encrypt_after_connect"] = self.options.get("encrypt_after_connect", False)
config = serve.merge_json(default_config, local_config)
config["doc_root"] = serve_path(self.test_paths)
if not self.ssl_env.ssl_enabled:
config["ports"]["https"] = [None]
host = self.options.get("certificate_domain", config["host"])
hosts = [host]
hosts.extend("%s.%s" % (item[0], host) for item in serve.get_subdomains(host).values())
key_file, certificate = self.ssl_env.host_cert_path(hosts)
config["key_file"] = key_file
config["certificate"] = certificate
serve.set_computed_defaults(config)
return config
def setup_server_logging(self):
server_logger = get_default_logger(component="wptserve")
assert server_logger is not None
log_filter = handlers.LogLevelFilter(lambda x:x, "info")
# Downgrade errors to warnings for the server
log_filter = LogLevelRewriter(log_filter, ["error"], "warning")
server_logger.component_filter = log_filter
server_logger = proxy.QueuedProxyLogger(server_logger)
try:
#Set as the default logger for wptserve
serve.set_logger(server_logger)
serve.logger = server_logger
except Exception:
# This happens if logging has already been set up for wptserve
pass
def get_routes(self):
route_builder = serve.RoutesBuilder()
for path, format_args, content_type, route in [
("testharness_runner.html", {}, "text/html", "/testharness_runner.html"),
(self.options.get("testharnessreport", "testharnessreport.js"),
{"output": self.pause_after_test}, "text/javascript",
"/resources/testharnessreport.js")]:
path = os.path.normpath(os.path.join(here, path))
route_builder.add_static(path, format_args, content_type, route)
data = b""
with open(os.path.join(repo_root, "resources", "testdriver.js"), "rb") as fp:
data += fp.read()
with open(os.path.join(here, "testdriver-extra.js"), "rb") as fp:
data += fp.read()
route_builder.add_handler(b"GET", b"/resources/testdriver.js",
StringHandler(data, "text/javascript"))
for url_base, paths in self.test_paths.iteritems():
if url_base == "/":
continue
route_builder.add_mount_point(url_base, paths["tests_path"])
if "/" not in self.test_paths:
del route_builder.mountpoint_routes["/"]
return route_builder.get_routes()
def ensure_started(self):
# Pause for a while to ensure that the server has a chance to start
for _ in xrange(20):
failed = self.test_servers()
if not failed:
return
time.sleep(0.5)
raise EnvironmentError("Servers failed to start (scheme:port): %s" % ("%s:%s" for item in failed))
def test_servers(self):
failed = []
for scheme, servers in self.servers.iteritems():
for port, server in servers:
if self.test_server_port:
s = socket.socket()
try:
s.connect((self.config["host"], port))
except socket.error:
failed.append((scheme, port))
finally:
s.close()
if not server.is_alive():
failed.append((scheme, port))
|
mpl-2.0
|
[
646,
2022,
199,
646,
747,
199,
646,
12866,
199,
646,
4673,
199,
646,
2838,
199,
646,
984,
199,
646,
900,
199,
199,
504,
1303,
90,
793,
492,
664,
63,
885,
63,
2921,
12,
8297,
12,
4566,
199,
199,
504,
336,
541,
4806,
492,
5297,
4670,
497,
5491,
199,
504,
336,
541,
4909,
14,
5586,
492,
2624,
2461,
199,
199,
1681,
275,
747,
14,
515,
14,
1294,
3460,
493,
363,
2788,
16,
61,
199,
3417,
63,
1231,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
904,
8,
1681,
12,
747,
14,
21386,
12,
747,
14,
21386,
12,
747,
14,
21386,
430,
199,
199,
4909,
275,
488,
199,
4266,
1208,
275,
488,
421,
199,
318,
886,
63,
21830,
63,
12775,
8,
2921,
12,
511,
63,
3771,
304,
272,
2288,
14062,
12,
6149,
1208,
339,
14062,
63,
1231,
275,
14062,
63,
515,
8,
396,
63,
3771,
9,
272,
984,
14,
515,
14,
3176,
8,
16,
12,
14062,
63,
1231,
9,
339,
3405,
275,
942,
339,
862,
26,
267,
687,
7249,
14,
4909,
492,
14062,
272,
871,
3545,
26,
267,
3405,
14,
740,
480,
4909,
531,
339,
862,
26,
267,
492,
6149,
1208,
272,
871,
3545,
26,
267,
3405,
14,
740,
480,
4266,
1208,
531,
339,
340,
3405,
26,
267,
2512,
14,
13138,
8,
288,
298,
4276,
370,
492,
450,
83,
14,
7523,
626,
2295,
931,
450,
83,
3509,
3330,
13,
3246,
13,
2219,
2,
450,
288,
334,
401,
3680,
904,
8,
4892,
395,
14062,
63,
1231,
430,
267,
984,
14,
2224,
8,
17,
9,
421,
199,
318,
14062,
63,
515,
8,
396,
63,
3771,
304,
272,
372,
511,
63,
3771,
905,
15,
6611,
2219,
63,
515,
937,
421,
199,
318,
664,
63,
4266,
63,
958,
3682,
958,
304,
272,
340,
2074,
905,
4266,
63,
466,
937,
508,
298,
14837,
582,
267,
1249,
275,
2420,
14837,
63,
3008,
582,
2074,
905,
14837,
63,
3008,
27635,
272,
916,
2074,
905,
4266,
63,
466,
937,
508,
298,
657,
10176,
582,
267,
1249,
275,
2420,
1102,
63,
498,
63,
515,
582,
2074,
905,
1102,
63,
498,
63,
515,
2255,
355,
298,
1102,
63,
4736,
63,
515,
582,
2074,
905,
1102,
63,
4736,
63,
515,
2255,
355,
298,
696,
63,
4736,
63,
515,
582,
2074,
905,
696,
63,
4736,
63,
515,
27635,
272,
587,
26,
267,
1249,
275,
1052,
272,
372,
1249,
421,
199,
318,
6149,
63,
1813,
8,
2921,
12,
1011,
958,
304,
272,
6149,
63,
1813,
63,
1886,
275,
6149,
1208,
14,
26411,
59,
958,
905,
4266,
63,
466,
15261,
272,
372,
6149,
63,
1813,
63,
1886,
8,
2921,
12,
1011,
362,
63,
4266,
63,
958,
3682,
958,
430,
421,
199,
533,
1379,
8263,
547,
8,
1726,
304,
272,
986,
421,
199,
533,
1379,
8263,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
511,
63,
3771,
12,
6149,
63,
1813,
12,
16834,
63,
4399,
63,
396,
12,
3105,
63,
815,
12,
1511,
12,
2589,
63,
9975,
304,
267,
408,
2998,
5256,
626,
22182,
561,
314,
511,
3734,
284,
14,
69,
14,
314,
1455,
436,
267,
24897,
83,
8037,
624,
267,
291,
14,
396,
63,
3771,
275,
511,
63,
3771,
267,
291,
14,
4266,
63,
1813,
275,
6149,
63,
1813,
267,
291,
14,
1000,
275,
488,
267,
291,
14,
888,
275,
488,
267,
291,
14,
11241,
63,
4399,
63,
396,
275,
16834,
63,
4399,
63,
396,
267,
291,
14,
396,
63,
1000,
63,
719,
275,
1511,
14,
1935,
480,
396,
63,
1000,
63,
719,
401,
715,
9,
267,
291,
14,
1757,
63,
815,
275,
3105,
63,
815,
267,
291,
14,
1419,
275,
1511,
340,
1511,
365,
440,
488,
587,
1052,
398,
291,
14,
1637,
63,
2609,
275,
12866,
14,
2988,
342,
267,
291,
14,
27145,
275,
14062,
14,
27145,
14,
933,
1119,
3120,
342,
267,
291,
14,
1813,
63,
9975,
275,
2589,
63,
9975,
267,
291,
14,
1813,
63,
9975,
63,
10781,
275,
488,
2378,
347,
636,
4200,
721,
277,
304,
267,
291,
14,
27145,
855,
4200,
4533,
267,
291,
14,
4266,
63,
1813,
855,
4200,
4533,
267,
291,
14,
1637,
63,
2609,
855,
4200,
4533,
398,
291,
14,
888,
275,
291,
14,
912,
63,
888,
342,
267,
291,
14,
2758,
63,
1000,
63,
4806,
342,
267,
8873,
275,
14062,
14,
362,
63,
5203,
8,
277,
14,
888,
12,
291,
14,
4266,
63,
1813,
9,
267,
291,
14,
888,
275,
14062,
14,
3302,
572,
63,
888,
8,
277,
14,
888,
12,
8873,
9,
398,
702,
291,
14,
1813,
63,
9975,
63,
10781,
365,
488,
12,
334,
288,
298,
33,
1379,
8263,
909,
3913,
506,
6032,
531,
398,
291,
14,
1813,
63,
9975,
63,
10781,
275,
942,
398,
367,
2589,
315,
291,
14,
1813,
63,
9975,
26,
288,
6904,
275,
2589,
8,
277,
14,
1419,
12,
291,
14,
888,
9,
288,
6904,
855,
4200,
4533,
288,
291,
14,
1813,
63,
9975,
63,
10781,
14,
740,
8,
4400,
9,
398,
291,
14,
5871,
275,
14062,
14,
928,
8,
277,
14,
888,
12,
291,
14,
4266,
63,
1813,
12,
3521,
291,
14,
362,
63,
13243,
1012,
267,
340,
291,
14,
1419,
14,
362,
480,
9823,
63,
17612,
531,
436,
291,
14,
1757,
63,
815,
436,
291,
14,
1757,
63,
815,
14,
13543,
26,
288,
291,
14,
4247,
63,
1058,
5505,
1086,
342,
267,
372,
291,
339,
347,
636,
2224,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
304,
267,
291,
14,
1412,
63,
1058,
5505,
1086,
342,
398,
367,
5687,
12,
8037,
315,
291,
14,
5871,
14,
4611,
837,
288,
367,
1844,
12,
1654,
315,
8037,
26,
355,
1654,
14,
8997,
342,
267,
367,
6904,
315,
291,
14,
1813,
63,
9975,
63,
10781,
26,
288,
6904,
855,
2224,
721,
2804,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
9,
398,
291,
14,
1813,
63,
9975,
63,
10781,
275,
488,
398,
291,
14,
1637,
63,
2609,
855,
2224,
721,
2804,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
9,
267,
291,
14,
4266,
63,
1813,
855,
2224,
721,
2804,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
9,
267,
291,
14,
27145,
855,
2224,
4533,
339,
347,
3686,
63,
1058,
5505,
1086,
8,
277,
304,
267,
4673,
14
] |
[
2022,
199,
646,
747,
199,
646,
12866,
199,
646,
4673,
199,
646,
2838,
199,
646,
984,
199,
646,
900,
199,
199,
504,
1303,
90,
793,
492,
664,
63,
885,
63,
2921,
12,
8297,
12,
4566,
199,
199,
504,
336,
541,
4806,
492,
5297,
4670,
497,
5491,
199,
504,
336,
541,
4909,
14,
5586,
492,
2624,
2461,
199,
199,
1681,
275,
747,
14,
515,
14,
1294,
3460,
493,
363,
2788,
16,
61,
199,
3417,
63,
1231,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
904,
8,
1681,
12,
747,
14,
21386,
12,
747,
14,
21386,
12,
747,
14,
21386,
430,
199,
199,
4909,
275,
488,
199,
4266,
1208,
275,
488,
421,
199,
318,
886,
63,
21830,
63,
12775,
8,
2921,
12,
511,
63,
3771,
304,
272,
2288,
14062,
12,
6149,
1208,
339,
14062,
63,
1231,
275,
14062,
63,
515,
8,
396,
63,
3771,
9,
272,
984,
14,
515,
14,
3176,
8,
16,
12,
14062,
63,
1231,
9,
339,
3405,
275,
942,
339,
862,
26,
267,
687,
7249,
14,
4909,
492,
14062,
272,
871,
3545,
26,
267,
3405,
14,
740,
480,
4909,
531,
339,
862,
26,
267,
492,
6149,
1208,
272,
871,
3545,
26,
267,
3405,
14,
740,
480,
4266,
1208,
531,
339,
340,
3405,
26,
267,
2512,
14,
13138,
8,
288,
298,
4276,
370,
492,
450,
83,
14,
7523,
626,
2295,
931,
450,
83,
3509,
3330,
13,
3246,
13,
2219,
2,
450,
288,
334,
401,
3680,
904,
8,
4892,
395,
14062,
63,
1231,
430,
267,
984,
14,
2224,
8,
17,
9,
421,
199,
318,
14062,
63,
515,
8,
396,
63,
3771,
304,
272,
372,
511,
63,
3771,
905,
15,
6611,
2219,
63,
515,
937,
421,
199,
318,
664,
63,
4266,
63,
958,
3682,
958,
304,
272,
340,
2074,
905,
4266,
63,
466,
937,
508,
298,
14837,
582,
267,
1249,
275,
2420,
14837,
63,
3008,
582,
2074,
905,
14837,
63,
3008,
27635,
272,
916,
2074,
905,
4266,
63,
466,
937,
508,
298,
657,
10176,
582,
267,
1249,
275,
2420,
1102,
63,
498,
63,
515,
582,
2074,
905,
1102,
63,
498,
63,
515,
2255,
355,
298,
1102,
63,
4736,
63,
515,
582,
2074,
905,
1102,
63,
4736,
63,
515,
2255,
355,
298,
696,
63,
4736,
63,
515,
582,
2074,
905,
696,
63,
4736,
63,
515,
27635,
272,
587,
26,
267,
1249,
275,
1052,
272,
372,
1249,
421,
199,
318,
6149,
63,
1813,
8,
2921,
12,
1011,
958,
304,
272,
6149,
63,
1813,
63,
1886,
275,
6149,
1208,
14,
26411,
59,
958,
905,
4266,
63,
466,
15261,
272,
372,
6149,
63,
1813,
63,
1886,
8,
2921,
12,
1011,
362,
63,
4266,
63,
958,
3682,
958,
430,
421,
199,
533,
1379,
8263,
547,
8,
1726,
304,
272,
986,
421,
199,
533,
1379,
8263,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
511,
63,
3771,
12,
6149,
63,
1813,
12,
16834,
63,
4399,
63,
396,
12,
3105,
63,
815,
12,
1511,
12,
2589,
63,
9975,
304,
267,
408,
2998,
5256,
626,
22182,
561,
314,
511,
3734,
284,
14,
69,
14,
314,
1455,
436,
267,
24897,
83,
8037,
624,
267,
291,
14,
396,
63,
3771,
275,
511,
63,
3771,
267,
291,
14,
4266,
63,
1813,
275,
6149,
63,
1813,
267,
291,
14,
1000,
275,
488,
267,
291,
14,
888,
275,
488,
267,
291,
14,
11241,
63,
4399,
63,
396,
275,
16834,
63,
4399,
63,
396,
267,
291,
14,
396,
63,
1000,
63,
719,
275,
1511,
14,
1935,
480,
396,
63,
1000,
63,
719,
401,
715,
9,
267,
291,
14,
1757,
63,
815,
275,
3105,
63,
815,
267,
291,
14,
1419,
275,
1511,
340,
1511,
365,
440,
488,
587,
1052,
398,
291,
14,
1637,
63,
2609,
275,
12866,
14,
2988,
342,
267,
291,
14,
27145,
275,
14062,
14,
27145,
14,
933,
1119,
3120,
342,
267,
291,
14,
1813,
63,
9975,
275,
2589,
63,
9975,
267,
291,
14,
1813,
63,
9975,
63,
10781,
275,
488,
2378,
347,
636,
4200,
721,
277,
304,
267,
291,
14,
27145,
855,
4200,
4533,
267,
291,
14,
4266,
63,
1813,
855,
4200,
4533,
267,
291,
14,
1637,
63,
2609,
855,
4200,
4533,
398,
291,
14,
888,
275,
291,
14,
912,
63,
888,
342,
267,
291,
14,
2758,
63,
1000,
63,
4806,
342,
267,
8873,
275,
14062,
14,
362,
63,
5203,
8,
277,
14,
888,
12,
291,
14,
4266,
63,
1813,
9,
267,
291,
14,
888,
275,
14062,
14,
3302,
572,
63,
888,
8,
277,
14,
888,
12,
8873,
9,
398,
702,
291,
14,
1813,
63,
9975,
63,
10781,
365,
488,
12,
334,
288,
298,
33,
1379,
8263,
909,
3913,
506,
6032,
531,
398,
291,
14,
1813,
63,
9975,
63,
10781,
275,
942,
398,
367,
2589,
315,
291,
14,
1813,
63,
9975,
26,
288,
6904,
275,
2589,
8,
277,
14,
1419,
12,
291,
14,
888,
9,
288,
6904,
855,
4200,
4533,
288,
291,
14,
1813,
63,
9975,
63,
10781,
14,
740,
8,
4400,
9,
398,
291,
14,
5871,
275,
14062,
14,
928,
8,
277,
14,
888,
12,
291,
14,
4266,
63,
1813,
12,
3521,
291,
14,
362,
63,
13243,
1012,
267,
340,
291,
14,
1419,
14,
362,
480,
9823,
63,
17612,
531,
436,
291,
14,
1757,
63,
815,
436,
291,
14,
1757,
63,
815,
14,
13543,
26,
288,
291,
14,
4247,
63,
1058,
5505,
1086,
342,
267,
372,
291,
339,
347,
636,
2224,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
304,
267,
291,
14,
1412,
63,
1058,
5505,
1086,
342,
398,
367,
5687,
12,
8037,
315,
291,
14,
5871,
14,
4611,
837,
288,
367,
1844,
12,
1654,
315,
8037,
26,
355,
1654,
14,
8997,
342,
267,
367,
6904,
315,
291,
14,
1813,
63,
9975,
63,
10781,
26,
288,
6904,
855,
2224,
721,
2804,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
9,
398,
291,
14,
1813,
63,
9975,
63,
10781,
275,
488,
398,
291,
14,
1637,
63,
2609,
855,
2224,
721,
2804,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
9,
267,
291,
14,
4266,
63,
1813,
855,
2224,
721,
2804,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
9,
267,
291,
14,
27145,
855,
2224,
4533,
339,
347,
3686,
63,
1058,
5505,
1086,
8,
277,
304,
267,
4673,
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,
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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
] |
CamelBackNotation/CarnotKE
|
jyhton/Lib/test/test_zlib_jy.py
|
23
|
1039
|
"""Misc zlib tests
Made for Jython.
"""
import unittest
import zlib
from array import array
from test import test_support
class ArrayTestCase(unittest.TestCase):
def test_array(self):
self._test_array(zlib.compress, zlib.decompress)
def test_array_compressobj(self):
def compress(value):
co = zlib.compressobj()
return co.compress(value) + co.flush()
def decompress(value):
dco = zlib.decompressobj()
return dco.decompress(value) + dco.flush()
self._test_array(compress, decompress)
def _test_array(self, compress, decompress):
self.assertEqual(compress(array('c', 'jython')), compress('jython'))
intarray = array('i', range(5))
self.assertEqual(compress(intarray), compress(intarray.tostring()))
compressed = array('c', compress('jython'))
self.assertEqual('jython', decompress(compressed))
def test_main():
test_support.run_unittest(ArrayTestCase)
if __name__ == '__main__':
test_main()
|
apache-2.0
|
[
624,
29926,
12472,
2295,
199,
199,
26973,
367,
25333,
14,
199,
624,
199,
646,
2882,
199,
646,
12472,
199,
504,
1625,
492,
1625,
199,
504,
511,
492,
511,
63,
4058,
199,
199,
533,
8725,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1144,
8,
277,
304,
267,
291,
423,
396,
63,
1144,
8,
15371,
14,
6447,
12,
12472,
14,
14954,
9,
339,
347,
511,
63,
1144,
63,
6447,
1113,
8,
277,
304,
267,
347,
11029,
8,
585,
304,
288,
512,
275,
12472,
14,
6447,
1113,
342,
288,
372,
512,
14,
6447,
8,
585,
9,
435,
512,
14,
4939,
342,
267,
347,
24733,
8,
585,
304,
288,
366,
331,
275,
12472,
14,
14954,
1113,
342,
288,
372,
366,
331,
14,
14954,
8,
585,
9,
435,
221,
366,
331,
14,
4939,
342,
267,
291,
423,
396,
63,
1144,
8,
6447,
12,
24733,
9,
339,
347,
485,
396,
63,
1144,
8,
277,
12,
11029,
12,
24733,
304,
267,
291,
14,
629,
8,
6447,
8,
1144,
360,
67,
297,
283,
27179,
3855,
11029,
360,
27179,
1333,
267,
1109,
1144,
275,
1625,
360,
73,
297,
1425,
8,
21,
430,
267,
291,
14,
629,
8,
6447,
8,
442,
1144,
395,
11029,
8,
442,
1144,
14,
14028,
4059,
267,
12335,
275,
1625,
360,
67,
297,
11029,
360,
27179,
1333,
267,
291,
14,
629,
360,
27179,
297,
24733,
8,
10895,
430,
421,
199,
318,
511,
63,
973,
837,
272,
511,
63,
4058,
14,
1065,
63,
2796,
8,
3836,
1746,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
511,
63,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
29926,
12472,
2295,
199,
199,
26973,
367,
25333,
14,
199,
624,
199,
646,
2882,
199,
646,
12472,
199,
504,
1625,
492,
1625,
199,
504,
511,
492,
511,
63,
4058,
199,
199,
533,
8725,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1144,
8,
277,
304,
267,
291,
423,
396,
63,
1144,
8,
15371,
14,
6447,
12,
12472,
14,
14954,
9,
339,
347,
511,
63,
1144,
63,
6447,
1113,
8,
277,
304,
267,
347,
11029,
8,
585,
304,
288,
512,
275,
12472,
14,
6447,
1113,
342,
288,
372,
512,
14,
6447,
8,
585,
9,
435,
512,
14,
4939,
342,
267,
347,
24733,
8,
585,
304,
288,
366,
331,
275,
12472,
14,
14954,
1113,
342,
288,
372,
366,
331,
14,
14954,
8,
585,
9,
435,
221,
366,
331,
14,
4939,
342,
267,
291,
423,
396,
63,
1144,
8,
6447,
12,
24733,
9,
339,
347,
485,
396,
63,
1144,
8,
277,
12,
11029,
12,
24733,
304,
267,
291,
14,
629,
8,
6447,
8,
1144,
360,
67,
297,
283,
27179,
3855,
11029,
360,
27179,
1333,
267,
1109,
1144,
275,
1625,
360,
73,
297,
1425,
8,
21,
430,
267,
291,
14,
629,
8,
6447,
8,
442,
1144,
395,
11029,
8,
442,
1144,
14,
14028,
4059,
267,
12335,
275,
1625,
360,
67,
297,
11029,
360,
27179,
1333,
267,
291,
14,
629,
360,
27179,
297,
24733,
8,
10895,
430,
421,
199,
318,
511,
63,
973,
837,
272,
511,
63,
4058,
14,
1065,
63,
2796,
8,
3836,
1746,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
511,
63,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
IllusionRom-deprecated/android_platform_tools_idea
|
python/helpers/pydev/pydevd_vars.py
|
3
|
9451
|
""" pydevd_vars deals with variables:
resolution/conversion to XML.
"""
import pickle
from django_frame import DjangoTemplateFrame
from pydevd_constants import * #@UnusedWildImport
from types import * #@UnusedWildImport
from pydevd_xml import *
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
import sys #@Reimport
if USE_LIB_COPY:
import _pydev_threading as threading
else:
import threading
import pydevd_resolver
import traceback
try:
from pydevd_exec import Exec
except:
from pydevd_exec2 import Exec
#-------------------------------------------------------------------------- defining true and false for earlier versions
try:
__setFalse = False
except:
import __builtin__
setattr(__builtin__, 'True', 1)
setattr(__builtin__, 'False', 0)
#------------------------------------------------------------------------------------------------------ class for errors
class VariableError(RuntimeError): pass
class FrameNotFoundError(RuntimeError): pass
if USE_PSYCO_OPTIMIZATION:
try:
import psyco
varToXML = psyco.proxy(varToXML)
except ImportError:
if hasattr(sys, 'exc_clear'): #jython does not have it
sys.exc_clear() #don't keep the traceback -- clients don't want to see it
def iterFrames(initialFrame):
"""NO-YIELD VERSION: Iterates through all the frames starting at the specified frame (which will be the first returned item)"""
#cannot use yield
frames = []
while initialFrame is not None:
frames.append(initialFrame)
initialFrame = initialFrame.f_back
return frames
def dumpFrames(thread_id):
sys.stdout.write('dumping frames\n')
if thread_id != GetThreadId(threading.currentThread()):
raise VariableError("findFrame: must execute on same thread")
curFrame = GetFrame()
for frame in iterFrames(curFrame):
sys.stdout.write('%s\n' % pickle.dumps(frame))
#===============================================================================
# AdditionalFramesContainer
#===============================================================================
class AdditionalFramesContainer:
lock = threading.Lock()
additional_frames = {} #dict of dicts
def addAdditionalFrameById(thread_id, frames_by_id):
AdditionalFramesContainer.additional_frames[thread_id] = frames_by_id
def removeAdditionalFrameById(thread_id):
del AdditionalFramesContainer.additional_frames[thread_id]
def findFrame(thread_id, frame_id):
""" returns a frame on the thread that has a given frame_id """
if thread_id != GetThreadId(threading.currentThread()):
raise VariableError("findFrame: must execute on same thread")
lookingFor = int(frame_id)
if AdditionalFramesContainer.additional_frames:
if DictContains(AdditionalFramesContainer.additional_frames, thread_id):
frame = AdditionalFramesContainer.additional_frames[thread_id].get(lookingFor)
if frame is not None:
return frame
curFrame = GetFrame()
if frame_id == "*":
return curFrame # any frame is specified with "*"
frameFound = None
for frame in iterFrames(curFrame):
if lookingFor == id(frame):
frameFound = frame
del frame
break
del frame
#Important: python can hold a reference to the frame from the current context
#if an exception is raised, so, if we don't explicitly add those deletes
#we might have those variables living much more than we'd want to.
#I.e.: sys.exc_info holding reference to frame that raises exception (so, other places
#need to call sys.exc_clear())
del curFrame
if frameFound is None:
msgFrames = ''
i = 0
for frame in iterFrames(GetFrame()):
i += 1
msgFrames += str(id(frame))
if i % 5 == 0:
msgFrames += '\n'
else:
msgFrames += ' - '
errMsg = '''findFrame: frame not found.
Looking for thread_id:%s, frame_id:%s
Current thread_id:%s, available frames:
%s
''' % (thread_id, lookingFor, GetThreadId(threading.currentThread()), msgFrames)
sys.stderr.write(errMsg)
return None
return frameFound
def resolveCompoundVariable(thread_id, frame_id, scope, attrs):
""" returns the value of the compound variable as a dictionary"""
frame = findFrame(thread_id, frame_id)
if frame is None:
return {}
attrList = attrs.split('\t')
if scope == "GLOBAL":
var = frame.f_globals
del attrList[0] # globals are special, and they get a single dummy unused attribute
else:
var = frame.f_locals
type, _typeName, resolver = getType(var)
try:
resolver.resolve(var, attrList[0])
except:
var = frame.f_globals
for k in attrList:
type, _typeName, resolver = getType(var)
var = resolver.resolve(var, k)
try:
type, _typeName, resolver = getType(var)
return resolver.getDictionary(var)
except:
traceback.print_exc()
def resolveVar(var, attrs):
attrList = attrs.split('\t')
for k in attrList:
type, _typeName, resolver = getType(var)
var = resolver.resolve(var, k)
try:
type, _typeName, resolver = getType(var)
return resolver.getDictionary(var)
except:
traceback.print_exc()
def evaluateExpression(thread_id, frame_id, expression, doExec):
"""returns the result of the evaluated expression
@param doExec: determines if we should do an exec or an eval
"""
frame = findFrame(thread_id, frame_id)
if frame is None:
return
expression = str(expression.replace('@LINE@', '\n'))
#Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329
#(Names not resolved in generator expression in method)
#See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html
updated_globals = {}
updated_globals.update(frame.f_globals)
updated_globals.update(frame.f_locals) #locals later because it has precedence over the actual globals
try:
if doExec:
try:
#try to make it an eval (if it is an eval we can print it, otherwise we'll exec it and
#it will have whatever the user actually did)
compiled = compile(expression, '<string>', 'eval')
except:
Exec(expression, updated_globals, frame.f_locals)
else:
result = eval(compiled, updated_globals, frame.f_locals)
if result is not None: #Only print if it's not None (as python does)
sys.stdout.write('%s\n' % (result,))
return
else:
result = None
try:
result = eval(expression, updated_globals, frame.f_locals)
except Exception:
s = StringIO()
traceback.print_exc(file=s)
result = s.getvalue()
try:
try:
etype, value, tb = sys.exc_info()
result = value
finally:
etype = value = tb = None
except:
pass
result = ExceptionOnEvaluate(result)
return result
finally:
#Should not be kept alive if an exception happens and this frame is kept in the stack.
del updated_globals
del frame
def changeAttrExpression(thread_id, frame_id, attr, expression):
"""Changes some attribute in a given frame.
@note: it will not (currently) work if we're not in the topmost frame (that's a python
deficiency -- and it appears that there is no way of making it currently work --
will probably need some change to the python internals)
"""
frame = findFrame(thread_id, frame_id)
if frame is None:
return
if isinstance(frame, DjangoTemplateFrame):
result = eval(expression, frame.f_globals, frame.f_locals)
frame.changeVariable(attr, result)
try:
expression = expression.replace('@LINE@', '\n')
#tests (needs proposed patch in python accepted)
# if hasattr(frame, 'savelocals'):
# if attr in frame.f_locals:
# frame.f_locals[attr] = eval(expression, frame.f_globals, frame.f_locals)
# frame.savelocals()
# return
#
# elif attr in frame.f_globals:
# frame.f_globals[attr] = eval(expression, frame.f_globals, frame.f_locals)
# return
if attr[:7] == "Globals":
attr = attr[8:]
if attr in frame.f_globals:
frame.f_globals[attr] = eval(expression, frame.f_globals, frame.f_locals)
return frame.f_globals[attr]
else:
#default way (only works for changing it in the topmost frame)
result = eval(expression, frame.f_globals, frame.f_locals)
Exec('%s=%s' % (attr, expression), frame.f_globals, frame.f_locals)
return result
except Exception:
traceback.print_exc()
|
apache-2.0
|
[
624,
29240,
68,
63,
2936,
477,
2551,
543,
2860,
26,
272,
12401,
15,
15083,
370,
4692,
14,
199,
624,
199,
646,
5927,
199,
504,
1639,
63,
1943,
492,
5634,
4231,
3160,
199,
504,
29240,
68,
63,
5559,
492,
627,
9213,
20782,
55,
668,
6295,
199,
504,
2943,
492,
627,
9213,
20782,
55,
668,
6295,
199,
199,
504,
29240,
68,
63,
1652,
492,
627,
199,
199,
893,
26,
272,
687,
5228,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5890,
492,
5228,
199,
646,
984,
9213,
497,
646,
199,
199,
692,
4815,
63,
5617,
63,
16188,
26,
272,
492,
485,
23996,
63,
12562,
465,
5796,
199,
2836,
26,
272,
492,
5796,
199,
646,
29240,
68,
63,
7717,
199,
646,
5190,
199,
199,
893,
26,
272,
687,
29240,
68,
63,
1628,
492,
9434,
199,
2590,
26,
272,
687,
29240,
68,
63,
1628,
18,
492,
9434,
199,
199,
7656,
9460,
12669,
2549,
436,
3055,
367,
14119,
5459,
199,
199,
893,
26,
272,
636,
409,
797,
275,
756,
199,
2590,
26,
272,
492,
636,
5351,
363,
339,
5371,
3460,
5351,
3108,
283,
549,
297,
413,
9,
272,
5371,
3460,
5351,
3108,
283,
797,
297,
378,
9,
199,
199,
7656,
1444,
8648,
1021,
367,
2552,
199,
199,
533,
4905,
547,
8,
13281,
304,
986,
199,
199,
533,
11726,
10870,
8,
13281,
304,
986,
421,
199,
692,
4815,
63,
48,
4669,
1439,
63,
5123,
1469,
22800,
26,
272,
862,
26,
267,
492,
14177,
331,
398,
2729,
1378,
4317,
275,
14177,
331,
14,
3280,
8,
1391,
1378,
4317,
9,
272,
871,
3545,
26,
267,
340,
2688,
8,
1274,
12,
283,
2804,
63,
3584,
735,
327,
27179,
1630,
440,
1172,
652,
288,
984,
14,
2804,
63,
3584,
342,
327,
13196,
1133,
4215,
314,
5190,
1553,
13431,
2793,
1133,
2934,
370,
1937,
652,
199,
199,
318,
2740,
22024,
8,
2747,
3160,
304,
272,
408,
2826,
13,
57,
41,
23339,
15945,
26,
11953,
2335,
4012,
1006,
314,
11223,
6617,
737,
314,
2013,
2787,
334,
6777,
911,
506,
314,
1642,
2138,
1242,
9471,
272,
327,
11250,
675,
1995,
272,
11223,
275,
942,
339,
1830,
2536,
3160,
365,
440,
488,
26,
267,
11223,
14,
740,
8,
2747,
3160,
9,
267,
2536,
3160,
275,
2536,
3160,
14,
70,
63,
894,
339,
372,
11223,
199,
199,
318,
5461,
22024,
8,
2671,
63,
344,
304,
272,
984,
14,
2703,
14,
952,
360,
2724,
316,
11223,
60,
78,
358,
272,
340,
2462,
63,
344,
1137,
2372,
4436,
1304,
8,
12562,
14,
1818,
4436,
5109,
267,
746,
4905,
547,
480,
1623,
3160,
26,
1471,
5341,
641,
2011,
2462,
531,
339,
1094,
3160,
275,
2372,
3160,
342,
272,
367,
2787,
315,
2740,
22024,
8,
895,
3160,
304,
267,
984,
14,
2703,
14,
952,
3508,
83,
60,
78,
7,
450,
5927,
14,
4180,
8,
1943,
430,
421,
199,
14813,
16964,
199,
3,
10961,
22024,
4076,
199,
14813,
16964,
199,
533,
10961,
22024,
4076,
26,
272,
4650,
275,
5796,
14,
6432,
342,
272,
4722,
63,
8444,
275,
1052,
327,
807,
402,
10809,
421,
199,
318,
1050,
8824,
3160,
18954,
8,
2671,
63,
344,
12,
11223,
63,
991,
63,
344,
304,
272,
10961,
22024,
4076,
14,
8460,
63,
8444,
59,
2671,
63,
344,
61,
275,
11223,
63,
991,
63,
344,
421,
199,
318,
2813,
8824,
3160,
18954,
8,
2671,
63,
344,
304,
272,
2150,
10961,
22024,
4076,
14,
8460,
63,
8444,
59,
2671,
63,
344,
61,
4388,
199,
318,
2342,
3160,
8,
2671,
63,
344,
12,
2787,
63,
344,
304,
272,
408,
2529,
282,
2787,
641,
314,
2462,
626,
965,
282,
1627,
2787,
63,
344,
408,
272,
340,
2462,
63,
344,
1137,
2372,
4436,
1304,
8,
12562,
14,
1818,
4436,
5109,
267,
746,
4905,
547,
480,
1623,
3160,
26,
1471,
5341,
641,
2011,
2462,
531,
339,
10023,
1858,
275,
1109,
8,
1943,
63,
344,
9,
339,
340,
10961,
22024,
4076,
14,
8460,
63,
8444,
26,
267,
340,
7448,
6906,
8,
8824,
22024,
4076,
14,
8460,
63,
8444,
12,
2462,
63,
344,
304,
288,
2787,
275,
10961,
22024,
4076,
14,
8460,
63,
8444,
59,
2671,
63,
344,
1055,
362,
8,
11660,
316,
1858,
9,
953,
340,
2787,
365,
440,
488,
26,
355,
372,
2787,
339,
1094,
3160,
275,
2372,
3160,
342,
272,
340,
2787,
63,
344,
508,
8969,
582,
267,
372,
1094,
3160,
327,
1263,
2787,
365,
2013,
543,
22423,
339,
2787,
3601,
275,
488,
339,
367,
2787,
315,
2740,
22024,
8,
895,
3160,
304,
267,
340,
10023,
1858,
508,
1305,
8,
1943,
304,
288,
2787,
3601,
275,
2787,
288,
2150,
2787,
288,
2059,
398,
2150,
2787,
339,
327,
6295,
867,
26,
2366,
883,
10266,
282,
3659,
370,
314,
2787,
687,
314,
1453,
1067,
5591,
327,
692,
376,
1919,
365,
4915,
12,
880,
12,
340,
781,
2793,
1133,
7662,
1050,
5204,
21812,
272,
327,
1129,
5594,
1172,
5204,
2860,
1212,
4007,
8298,
1655,
2419,
781,
5121,
2934,
370,
14,
339,
327,
41,
14,
69,
16781,
984,
14,
2804,
63,
815,
17573,
3659,
370,
2787,
626,
6534,
1919,
334,
1152,
12,
1163,
9825,
272,
327,
9321,
370,
1240,
984,
14,
2804,
63,
3584,
1012,
5591,
2150,
1094,
3160,
339,
340,
2787,
3601,
365,
488,
26,
267,
1499,
22024,
275,
2125,
267,
284,
275,
378,
398,
367,
2787,
315,
2740,
22024,
8,
1002,
3160,
5109,
288,
284,
847,
413,
288,
1499,
22024,
847,
620,
8,
344,
8,
1943,
430,
288,
340,
284,
450,
959,
508,
378,
26,
355,
1499,
22024,
847,
1557,
78,
7,
288,
587,
26,
355,
1499,
22024,
847,
283,
221,
446,
221,
283,
398,
2329,
6173,
275,
1449,
1623,
3160,
26,
2787,
440,
1911,
14,
199,
2041,
17967,
367,
2462,
63,
344,
2689,
83,
12,
2787,
63,
344,
2689,
83,
199,
5639,
258,
2462,
63,
344,
2689,
83,
12,
2808,
11223,
26,
199,
5,
83,
199,
2344,
450,
334,
2671,
63,
344,
12,
10023,
1858,
12,
2372,
4436,
1304,
8,
12562,
14,
1818,
4436,
4000,
1499,
22024,
9,
398,
984,
14,
3083,
14,
952,
8,
1508,
6173,
9,
267,
372,
488,
339,
372,
2787,
3601,
199,
199,
318,
7512,
26552,
2773,
8,
2671,
63,
344,
12,
2787,
63,
344,
12,
4194,
12,
3290,
304,
272,
408,
2529,
314,
574,
402,
314,
16487,
1750,
465,
282,
2600,
624,
272,
2787,
275,
2342,
3160,
8,
2671,
63
] |
[
29240,
68,
63,
2936,
477,
2551,
543,
2860,
26,
272,
12401,
15,
15083,
370,
4692,
14,
199,
624,
199,
646,
5927,
199,
504,
1639,
63,
1943,
492,
5634,
4231,
3160,
199,
504,
29240,
68,
63,
5559,
492,
627,
9213,
20782,
55,
668,
6295,
199,
504,
2943,
492,
627,
9213,
20782,
55,
668,
6295,
199,
199,
504,
29240,
68,
63,
1652,
492,
627,
199,
199,
893,
26,
272,
687,
5228,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5890,
492,
5228,
199,
646,
984,
9213,
497,
646,
199,
199,
692,
4815,
63,
5617,
63,
16188,
26,
272,
492,
485,
23996,
63,
12562,
465,
5796,
199,
2836,
26,
272,
492,
5796,
199,
646,
29240,
68,
63,
7717,
199,
646,
5190,
199,
199,
893,
26,
272,
687,
29240,
68,
63,
1628,
492,
9434,
199,
2590,
26,
272,
687,
29240,
68,
63,
1628,
18,
492,
9434,
199,
199,
7656,
9460,
12669,
2549,
436,
3055,
367,
14119,
5459,
199,
199,
893,
26,
272,
636,
409,
797,
275,
756,
199,
2590,
26,
272,
492,
636,
5351,
363,
339,
5371,
3460,
5351,
3108,
283,
549,
297,
413,
9,
272,
5371,
3460,
5351,
3108,
283,
797,
297,
378,
9,
199,
199,
7656,
1444,
8648,
1021,
367,
2552,
199,
199,
533,
4905,
547,
8,
13281,
304,
986,
199,
199,
533,
11726,
10870,
8,
13281,
304,
986,
421,
199,
692,
4815,
63,
48,
4669,
1439,
63,
5123,
1469,
22800,
26,
272,
862,
26,
267,
492,
14177,
331,
398,
2729,
1378,
4317,
275,
14177,
331,
14,
3280,
8,
1391,
1378,
4317,
9,
272,
871,
3545,
26,
267,
340,
2688,
8,
1274,
12,
283,
2804,
63,
3584,
735,
327,
27179,
1630,
440,
1172,
652,
288,
984,
14,
2804,
63,
3584,
342,
327,
13196,
1133,
4215,
314,
5190,
1553,
13431,
2793,
1133,
2934,
370,
1937,
652,
199,
199,
318,
2740,
22024,
8,
2747,
3160,
304,
272,
408,
2826,
13,
57,
41,
23339,
15945,
26,
11953,
2335,
4012,
1006,
314,
11223,
6617,
737,
314,
2013,
2787,
334,
6777,
911,
506,
314,
1642,
2138,
1242,
9471,
272,
327,
11250,
675,
1995,
272,
11223,
275,
942,
339,
1830,
2536,
3160,
365,
440,
488,
26,
267,
11223,
14,
740,
8,
2747,
3160,
9,
267,
2536,
3160,
275,
2536,
3160,
14,
70,
63,
894,
339,
372,
11223,
199,
199,
318,
5461,
22024,
8,
2671,
63,
344,
304,
272,
984,
14,
2703,
14,
952,
360,
2724,
316,
11223,
60,
78,
358,
272,
340,
2462,
63,
344,
1137,
2372,
4436,
1304,
8,
12562,
14,
1818,
4436,
5109,
267,
746,
4905,
547,
480,
1623,
3160,
26,
1471,
5341,
641,
2011,
2462,
531,
339,
1094,
3160,
275,
2372,
3160,
342,
272,
367,
2787,
315,
2740,
22024,
8,
895,
3160,
304,
267,
984,
14,
2703,
14,
952,
3508,
83,
60,
78,
7,
450,
5927,
14,
4180,
8,
1943,
430,
421,
199,
14813,
16964,
199,
3,
10961,
22024,
4076,
199,
14813,
16964,
199,
533,
10961,
22024,
4076,
26,
272,
4650,
275,
5796,
14,
6432,
342,
272,
4722,
63,
8444,
275,
1052,
327,
807,
402,
10809,
421,
199,
318,
1050,
8824,
3160,
18954,
8,
2671,
63,
344,
12,
11223,
63,
991,
63,
344,
304,
272,
10961,
22024,
4076,
14,
8460,
63,
8444,
59,
2671,
63,
344,
61,
275,
11223,
63,
991,
63,
344,
421,
199,
318,
2813,
8824,
3160,
18954,
8,
2671,
63,
344,
304,
272,
2150,
10961,
22024,
4076,
14,
8460,
63,
8444,
59,
2671,
63,
344,
61,
4388,
199,
318,
2342,
3160,
8,
2671,
63,
344,
12,
2787,
63,
344,
304,
272,
408,
2529,
282,
2787,
641,
314,
2462,
626,
965,
282,
1627,
2787,
63,
344,
408,
272,
340,
2462,
63,
344,
1137,
2372,
4436,
1304,
8,
12562,
14,
1818,
4436,
5109,
267,
746,
4905,
547,
480,
1623,
3160,
26,
1471,
5341,
641,
2011,
2462,
531,
339,
10023,
1858,
275,
1109,
8,
1943,
63,
344,
9,
339,
340,
10961,
22024,
4076,
14,
8460,
63,
8444,
26,
267,
340,
7448,
6906,
8,
8824,
22024,
4076,
14,
8460,
63,
8444,
12,
2462,
63,
344,
304,
288,
2787,
275,
10961,
22024,
4076,
14,
8460,
63,
8444,
59,
2671,
63,
344,
1055,
362,
8,
11660,
316,
1858,
9,
953,
340,
2787,
365,
440,
488,
26,
355,
372,
2787,
339,
1094,
3160,
275,
2372,
3160,
342,
272,
340,
2787,
63,
344,
508,
8969,
582,
267,
372,
1094,
3160,
327,
1263,
2787,
365,
2013,
543,
22423,
339,
2787,
3601,
275,
488,
339,
367,
2787,
315,
2740,
22024,
8,
895,
3160,
304,
267,
340,
10023,
1858,
508,
1305,
8,
1943,
304,
288,
2787,
3601,
275,
2787,
288,
2150,
2787,
288,
2059,
398,
2150,
2787,
339,
327,
6295,
867,
26,
2366,
883,
10266,
282,
3659,
370,
314,
2787,
687,
314,
1453,
1067,
5591,
327,
692,
376,
1919,
365,
4915,
12,
880,
12,
340,
781,
2793,
1133,
7662,
1050,
5204,
21812,
272,
327,
1129,
5594,
1172,
5204,
2860,
1212,
4007,
8298,
1655,
2419,
781,
5121,
2934,
370,
14,
339,
327,
41,
14,
69,
16781,
984,
14,
2804,
63,
815,
17573,
3659,
370,
2787,
626,
6534,
1919,
334,
1152,
12,
1163,
9825,
272,
327,
9321,
370,
1240,
984,
14,
2804,
63,
3584,
1012,
5591,
2150,
1094,
3160,
339,
340,
2787,
3601,
365,
488,
26,
267,
1499,
22024,
275,
2125,
267,
284,
275,
378,
398,
367,
2787,
315,
2740,
22024,
8,
1002,
3160,
5109,
288,
284,
847,
413,
288,
1499,
22024,
847,
620,
8,
344,
8,
1943,
430,
288,
340,
284,
450,
959,
508,
378,
26,
355,
1499,
22024,
847,
1557,
78,
7,
288,
587,
26,
355,
1499,
22024,
847,
283,
221,
446,
221,
283,
398,
2329,
6173,
275,
1449,
1623,
3160,
26,
2787,
440,
1911,
14,
199,
2041,
17967,
367,
2462,
63,
344,
2689,
83,
12,
2787,
63,
344,
2689,
83,
199,
5639,
258,
2462,
63,
344,
2689,
83,
12,
2808,
11223,
26,
199,
5,
83,
199,
2344,
450,
334,
2671,
63,
344,
12,
10023,
1858,
12,
2372,
4436,
1304,
8,
12562,
14,
1818,
4436,
4000,
1499,
22024,
9,
398,
984,
14,
3083,
14,
952,
8,
1508,
6173,
9,
267,
372,
488,
339,
372,
2787,
3601,
199,
199,
318,
7512,
26552,
2773,
8,
2671,
63,
344,
12,
2787,
63,
344,
12,
4194,
12,
3290,
304,
272,
408,
2529,
314,
574,
402,
314,
16487,
1750,
465,
282,
2600,
624,
272,
2787,
275,
2342,
3160,
8,
2671,
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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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
] |
EricCline/CEM_inc
|
env/lib/python2.7/site-packages/django/contrib/localflavor/pl/forms.py
|
110
|
7602
|
"""
Polish-specific form helpers
"""
from __future__ import absolute_import, unicode_literals
import re
from django.contrib.localflavor.pl.pl_administrativeunits import ADMINISTRATIVE_UNIT_CHOICES
from django.contrib.localflavor.pl.pl_voivodeships import VOIVODESHIP_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Select, RegexField
from django.utils.translation import ugettext_lazy as _
class PLProvinceSelect(Select):
"""
A select widget with list of Polish administrative provinces as choices.
"""
def __init__(self, attrs=None):
super(PLProvinceSelect, self).__init__(attrs, choices=VOIVODESHIP_CHOICES)
class PLCountySelect(Select):
"""
A select widget with list of Polish administrative units as choices.
"""
def __init__(self, attrs=None):
super(PLCountySelect, self).__init__(attrs, choices=ADMINISTRATIVE_UNIT_CHOICES)
class PLPESELField(RegexField):
"""
A form field that validates as Polish Identification Number (PESEL).
Checks the following rules:
* the length consist of 11 digits
* has a valid checksum
The algorithm is documented at http://en.wikipedia.org/wiki/PESEL.
"""
default_error_messages = {
'invalid': _('National Identification Number consists of 11 digits.'),
'checksum': _('Wrong checksum for the National Identification Number.'),
}
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
super(PLPESELField, self).__init__(r'^\d{11}$',
max_length, min_length, *args, **kwargs)
def clean(self, value):
super(PLPESELField, self).clean(value)
if value in EMPTY_VALUES:
return ''
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
return '%s' % value
def has_valid_checksum(self, number):
"""
Calculates a checksum with the provided algorithm.
"""
multiple_table = (1, 3, 7, 9, 1, 3, 7, 9, 1, 3, 1)
result = 0
for i in range(len(number)):
result += int(number[i]) * multiple_table[i]
return result % 10 == 0
class PLNationalIDCardNumberField(RegexField):
"""
A form field that validates as Polish National ID Card Number.
Checks the following rules:
* the length consist of 3 letter and 6 digits
* has a valid checksum
The algorithm is documented at http://en.wikipedia.org/wiki/Polish_identity_card.
"""
default_error_messages = {
'invalid': _('National ID Card Number consists of 3 letters and 6 digits.'),
'checksum': _('Wrong checksum for the National ID Card Number.'),
}
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
super(PLNationalIDCardNumberField, self).__init__(r'^[A-Za-z]{3}\d{6}$',
max_length, min_length, *args, **kwargs)
def clean(self,value):
super(PLNationalIDCardNumberField, self).clean(value)
if value in EMPTY_VALUES:
return ''
value = value.upper()
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
return '%s' % value
def has_valid_checksum(self, number):
"""
Calculates a checksum with the provided algorithm.
"""
letter_dict = {'A': 10, 'B': 11, 'C': 12, 'D': 13,
'E': 14, 'F': 15, 'G': 16, 'H': 17,
'I': 18, 'J': 19, 'K': 20, 'L': 21,
'M': 22, 'N': 23, 'O': 24, 'P': 25,
'Q': 26, 'R': 27, 'S': 28, 'T': 29,
'U': 30, 'V': 31, 'W': 32, 'X': 33,
'Y': 34, 'Z': 35}
# convert letters to integer values
int_table = [(not c.isdigit()) and letter_dict[c] or int(c)
for c in number]
multiple_table = (7, 3, 1, -1, 7, 3, 1, 7, 3)
result = 0
for i in range(len(int_table)):
result += int_table[i] * multiple_table[i]
return result % 10 == 0
class PLNIPField(RegexField):
"""
A form field that validates as Polish Tax Number (NIP).
Valid forms are: XXX-YYY-YY-YY, XXX-YY-YY-YYY or XXXYYYYYYY.
Checksum algorithm based on documentation at
http://wipos.p.lodz.pl/zylla/ut/nip-rego.html
"""
default_error_messages = {
'invalid': _('Enter a tax number field (NIP) in the format XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX.'),
'checksum': _('Wrong checksum for the Tax Number (NIP).'),
}
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
super(PLNIPField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{3}-\d{2}-\d{2}-\d{3}$|^\d{10}$',
max_length, min_length, *args, **kwargs)
def clean(self,value):
super(PLNIPField, self).clean(value)
if value in EMPTY_VALUES:
return ''
value = re.sub("[-]", "", value)
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
return '%s' % value
def has_valid_checksum(self, number):
"""
Calculates a checksum with the provided algorithm.
"""
multiple_table = (6, 5, 7, 2, 3, 4, 5, 6, 7)
result = 0
for i in range(len(number)-1):
result += int(number[i]) * multiple_table[i]
result %= 11
if result == int(number[-1]):
return True
else:
return False
class PLREGONField(RegexField):
"""
A form field that validates its input is a REGON number.
Valid regon number consists of 9 or 14 digits.
See http://www.stat.gov.pl/bip/regon_ENG_HTML.htm for more information.
"""
default_error_messages = {
'invalid': _('National Business Register Number (REGON) consists of 9 or 14 digits.'),
'checksum': _('Wrong checksum for the National Business Register Number (REGON).'),
}
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
super(PLREGONField, self).__init__(r'^\d{9,14}$',
max_length, min_length, *args, **kwargs)
def clean(self,value):
super(PLREGONField, self).clean(value)
if value in EMPTY_VALUES:
return ''
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
return '%s' % value
def has_valid_checksum(self, number):
"""
Calculates a checksum with the provided algorithm.
"""
weights = (
(8, 9, 2, 3, 4, 5, 6, 7, -1),
(2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8, -1),
(8, 9, 2, 3, 4, 5, 6, 7, -1, 0, 0, 0, 0, 0),
)
weights = [table for table in weights if len(table) == len(number)]
for table in weights:
checksum = sum([int(n) * w for n, w in zip(number, table)])
if checksum % 11 % 10:
return False
return bool(weights)
class PLPostalCodeField(RegexField):
"""
A form field that validates as Polish postal code.
Valid code is XX-XXX where X is digit.
"""
default_error_messages = {
'invalid': _('Enter a postal code in the format XX-XXX.'),
}
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
super(PLPostalCodeField, self).__init__(r'^\d{2}-\d{3}$',
max_length, min_length, *args, **kwargs)
|
mit
|
[
624,
199,
1575,
1891,
13,
6100,
1824,
10897,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
1168,
14,
1168,
63,
2113,
25124,
5260,
492,
29948,
21340,
14277,
63,
15505,
63,
16236,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
1168,
14,
1168,
63,
2392,
1003,
380,
3319,
83,
492,
812,
47,
6882,
47,
4448,
40,
1772,
63,
16236,
199,
504,
1639,
14,
1018,
14,
11346,
492,
16589,
63,
15514,
199,
504,
1639,
14,
3351,
492,
8505,
199,
504,
1639,
14,
3351,
14,
955,
492,
9496,
12,
12939,
792,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
533,
10092,
919,
86,
2855,
5446,
8,
5446,
304,
272,
408,
272,
437,
3504,
3938,
543,
769,
402,
4376,
1891,
4628,
25124,
557,
11908,
823,
465,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
1613,
8,
2749,
919,
86,
2855,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
10662,
6882,
47,
4448,
40,
1772,
63,
16236,
9,
199,
199,
533,
10092,
24532,
369,
5446,
8,
5446,
304,
272,
408,
272,
437,
3504,
3938,
543,
769,
402,
4376,
1891,
4628,
25124,
6204,
465,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
1613,
8,
2749,
24532,
369,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
14288,
21340,
14277,
63,
15505,
63,
16236,
9,
199,
199,
533,
510,
9257,
654,
2901,
792,
8,
5103,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
465,
4376,
1891,
473,
24926,
4860,
334,
48,
654,
2901,
680,
339,
13813,
314,
2569,
4713,
26,
267,
627,
314,
2582,
17568,
402,
4119,
7576,
267,
627,
965,
282,
1686,
9040,
339,
710,
5563,
365,
22751,
737,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
48,
654,
2901,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
46,
6279,
473,
24926,
4860,
18581,
402,
4119,
7576,
8038,
267,
283,
8928,
356,
4018,
14858,
9040,
367,
314,
20548,
473,
24926,
4860,
8038,
272,
789,
339,
347,
636,
826,
721,
277,
12,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
2749,
48,
654,
2901,
792,
12,
291,
2843,
826,
721,
82,
15542,
68,
91,
845,
19204,
288,
1390,
63,
1267,
12,
1748,
63,
1267,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
1613,
8,
2749,
48,
654,
2901,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
267,
340,
440,
291,
14,
1989,
63,
1078,
63,
8928,
8,
585,
304,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
8928,
1105,
267,
372,
1543,
83,
7,
450,
574,
339,
347,
965,
63,
1078,
63,
8928,
8,
277,
12,
1329,
304,
267,
408,
267,
28562,
282,
9040,
543,
314,
2741,
5563,
14,
267,
408,
267,
3663,
63,
1224,
275,
334,
17,
12,
650,
12,
1520,
12,
1749,
12,
413,
12,
650,
12,
1520,
12,
1749,
12,
413,
12,
650,
12,
413,
9,
267,
754,
275,
378,
267,
367,
284,
315,
1425,
8,
552,
8,
1955,
2298,
288,
754,
847,
1109,
8,
1955,
59,
73,
566,
627,
3663,
63,
1224,
59,
73,
61,
267,
372,
754,
450,
1616,
508,
378,
199,
199,
533,
10092,
46,
6279,
998,
13832,
3259,
792,
8,
5103,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
465,
4376,
1891,
20548,
2870,
445,
1005,
4860,
14,
339,
13813,
314,
2569,
4713,
26,
267,
627,
314,
2582,
17568,
402,
650,
8082,
436,
1227,
7576,
267,
627,
965,
282,
1686,
9040,
339,
710,
5563,
365,
22751,
737,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1575,
1891,
63,
5582,
63,
5841,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
46,
6279,
2870,
445,
1005,
4860,
18581,
402,
650,
14435,
436,
1227,
7576,
8038,
267,
283,
8928,
356,
4018,
14858,
9040,
367,
314,
20548,
2870,
445,
1005,
4860,
8038,
272,
789,
339,
347,
636,
826,
721,
277,
12,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
2749,
46,
6279,
998,
13832,
3259,
792,
12,
291,
2843,
826,
721,
82,
23811,
33,
13,
13163,
13,
90,
8194,
19,
4988,
68,
91,
22,
19204,
288,
1390,
63,
1267,
12,
1748,
63,
1267,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3633,
8,
277,
12,
585,
304,
267,
1613,
8,
2749,
46,
6279,
998,
13832,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
398,
574,
275,
574,
14,
4142,
342,
398,
340,
440,
291,
14,
1989,
63,
1078,
63,
8928,
8,
585,
304,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
8928,
1105,
267,
372,
1543,
83,
7,
450,
574,
339,
347,
965,
63,
1078,
63,
8928,
8,
277,
12,
1329,
304,
267,
408,
267,
28562,
282,
9040,
543,
314,
2741,
5563,
14,
267,
408,
267,
8082,
63,
807,
275,
791,
33,
356,
1616,
12,
283,
34,
356,
4119,
12,
283,
35,
356,
3144,
12,
283,
36,
356,
4944,
12,
2432,
283,
37,
356,
4329,
12,
283,
38,
356,
4114,
12,
283,
39,
356,
3193,
12,
283,
40,
356,
5557,
12,
2432,
283,
41,
356,
6155,
12,
283,
42,
356,
5851,
12,
283,
43,
356,
3388,
12,
283,
44,
356,
7829,
12,
2432,
283,
45,
356,
6928,
12,
283,
46,
356,
6546,
12,
283,
47,
356,
5504,
12,
283,
48,
356,
5661,
12,
2432,
283,
49,
356,
7875,
12,
283,
50,
356,
8087,
12,
283,
51,
356,
7294,
12,
283,
52,
356,
7349,
12,
2432,
283,
53,
356,
4233,
12,
283,
54,
356,
7105,
12,
283,
55,
356,
4337,
12,
283,
56,
356,
9404,
12,
2432,
283,
57,
356,
8177,
12,
283,
58,
356,
8685,
93,
398,
327,
3957
] |
[
199,
1575,
1891,
13,
6100,
1824,
10897,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
1168,
14,
1168,
63,
2113,
25124,
5260,
492,
29948,
21340,
14277,
63,
15505,
63,
16236,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
1168,
14,
1168,
63,
2392,
1003,
380,
3319,
83,
492,
812,
47,
6882,
47,
4448,
40,
1772,
63,
16236,
199,
504,
1639,
14,
1018,
14,
11346,
492,
16589,
63,
15514,
199,
504,
1639,
14,
3351,
492,
8505,
199,
504,
1639,
14,
3351,
14,
955,
492,
9496,
12,
12939,
792,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
533,
10092,
919,
86,
2855,
5446,
8,
5446,
304,
272,
408,
272,
437,
3504,
3938,
543,
769,
402,
4376,
1891,
4628,
25124,
557,
11908,
823,
465,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
1613,
8,
2749,
919,
86,
2855,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
10662,
6882,
47,
4448,
40,
1772,
63,
16236,
9,
199,
199,
533,
10092,
24532,
369,
5446,
8,
5446,
304,
272,
408,
272,
437,
3504,
3938,
543,
769,
402,
4376,
1891,
4628,
25124,
6204,
465,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
1613,
8,
2749,
24532,
369,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
14288,
21340,
14277,
63,
15505,
63,
16236,
9,
199,
199,
533,
510,
9257,
654,
2901,
792,
8,
5103,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
465,
4376,
1891,
473,
24926,
4860,
334,
48,
654,
2901,
680,
339,
13813,
314,
2569,
4713,
26,
267,
627,
314,
2582,
17568,
402,
4119,
7576,
267,
627,
965,
282,
1686,
9040,
339,
710,
5563,
365,
22751,
737,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
48,
654,
2901,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
46,
6279,
473,
24926,
4860,
18581,
402,
4119,
7576,
8038,
267,
283,
8928,
356,
4018,
14858,
9040,
367,
314,
20548,
473,
24926,
4860,
8038,
272,
789,
339,
347,
636,
826,
721,
277,
12,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
2749,
48,
654,
2901,
792,
12,
291,
2843,
826,
721,
82,
15542,
68,
91,
845,
19204,
288,
1390,
63,
1267,
12,
1748,
63,
1267,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
1613,
8,
2749,
48,
654,
2901,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
267,
340,
440,
291,
14,
1989,
63,
1078,
63,
8928,
8,
585,
304,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
8928,
1105,
267,
372,
1543,
83,
7,
450,
574,
339,
347,
965,
63,
1078,
63,
8928,
8,
277,
12,
1329,
304,
267,
408,
267,
28562,
282,
9040,
543,
314,
2741,
5563,
14,
267,
408,
267,
3663,
63,
1224,
275,
334,
17,
12,
650,
12,
1520,
12,
1749,
12,
413,
12,
650,
12,
1520,
12,
1749,
12,
413,
12,
650,
12,
413,
9,
267,
754,
275,
378,
267,
367,
284,
315,
1425,
8,
552,
8,
1955,
2298,
288,
754,
847,
1109,
8,
1955,
59,
73,
566,
627,
3663,
63,
1224,
59,
73,
61,
267,
372,
754,
450,
1616,
508,
378,
199,
199,
533,
10092,
46,
6279,
998,
13832,
3259,
792,
8,
5103,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
465,
4376,
1891,
20548,
2870,
445,
1005,
4860,
14,
339,
13813,
314,
2569,
4713,
26,
267,
627,
314,
2582,
17568,
402,
650,
8082,
436,
1227,
7576,
267,
627,
965,
282,
1686,
9040,
339,
710,
5563,
365,
22751,
737,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1575,
1891,
63,
5582,
63,
5841,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
46,
6279,
2870,
445,
1005,
4860,
18581,
402,
650,
14435,
436,
1227,
7576,
8038,
267,
283,
8928,
356,
4018,
14858,
9040,
367,
314,
20548,
2870,
445,
1005,
4860,
8038,
272,
789,
339,
347,
636,
826,
721,
277,
12,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
2749,
46,
6279,
998,
13832,
3259,
792,
12,
291,
2843,
826,
721,
82,
23811,
33,
13,
13163,
13,
90,
8194,
19,
4988,
68,
91,
22,
19204,
288,
1390,
63,
1267,
12,
1748,
63,
1267,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3633,
8,
277,
12,
585,
304,
267,
1613,
8,
2749,
46,
6279,
998,
13832,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
398,
574,
275,
574,
14,
4142,
342,
398,
340,
440,
291,
14,
1989,
63,
1078,
63,
8928,
8,
585,
304,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
8928,
1105,
267,
372,
1543,
83,
7,
450,
574,
339,
347,
965,
63,
1078,
63,
8928,
8,
277,
12,
1329,
304,
267,
408,
267,
28562,
282,
9040,
543,
314,
2741,
5563,
14,
267,
408,
267,
8082,
63,
807,
275,
791,
33,
356,
1616,
12,
283,
34,
356,
4119,
12,
283,
35,
356,
3144,
12,
283,
36,
356,
4944,
12,
2432,
283,
37,
356,
4329,
12,
283,
38,
356,
4114,
12,
283,
39,
356,
3193,
12,
283,
40,
356,
5557,
12,
2432,
283,
41,
356,
6155,
12,
283,
42,
356,
5851,
12,
283,
43,
356,
3388,
12,
283,
44,
356,
7829,
12,
2432,
283,
45,
356,
6928,
12,
283,
46,
356,
6546,
12,
283,
47,
356,
5504,
12,
283,
48,
356,
5661,
12,
2432,
283,
49,
356,
7875,
12,
283,
50,
356,
8087,
12,
283,
51,
356,
7294,
12,
283,
52,
356,
7349,
12,
2432,
283,
53,
356,
4233,
12,
283,
54,
356,
7105,
12,
283,
55,
356,
4337,
12,
283,
56,
356,
9404,
12,
2432,
283,
57,
356,
8177,
12,
283,
58,
356,
8685,
93,
398,
327,
3957,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Endika/OpenUpgrade
|
addons/crm/tests/test_new_lead_notification.py
|
70
|
1354
|
# -*- coding: utf-8 -*-
from openerp.tests.common import TransactionCase
class NewLeadNotificationTest(TransactionCase):
def test_new_lead_notification(self):
# Create a new user
user = self.env["res.users"].create({
"name": __file__,
"login": __file__,
})
# Subscribe him to sales department
team = self.env.ref("sales_team.section_sales_department")
subtype = self.env.ref("crm.mt_salesteam_lead")
team.sudo(user).message_subscribe_users(subtype_ids=[subtype.id])
# Imitate what happens in the controller when somebody creates a new
# lead from the website form
lead = (self.env["crm.lead"]
.with_context(mail_create_nosubscribe=True)
.sudo()
.create({"contact_name": "Somebody",
"description": "Some question",
"email_from": "somemail@example.com",
"name": "Some subject",
"partner_name": "Some company",
"section_id": self.env.ref(
"sales_team.section_sales_department").id,
"phone": "+0000000000"}))
# The user should have a new unread message
self.assertTrue(lead.sudo(user).message_unread)
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
5166,
14,
2219,
14,
2330,
492,
18244,
1538,
421,
199,
533,
7053,
29006,
11598,
774,
8,
10161,
1538,
304,
272,
347,
511,
63,
1222,
63,
13799,
63,
6761,
8,
277,
304,
267,
327,
2790,
282,
892,
922,
267,
922,
275,
291,
14,
1813,
905,
470,
14,
3707,
4140,
981,
2561,
288,
298,
354,
582,
636,
493,
3108,
288,
298,
2886,
582,
636,
493,
3108,
267,
3828,
398,
327,
4804,
5355,
26457,
370,
21702,
27669,
267,
8099,
275,
291,
14,
1813,
14,
1121,
480,
16175,
63,
5969,
14,
2792,
63,
16175,
63,
19623,
531,
267,
15686,
275,
291,
14,
1813,
14,
1121,
480,
15213,
14,
2037,
63,
8515,
1597,
455,
63,
13799,
531,
267,
8099,
14,
12095,
8,
751,
680,
1188,
63,
10108,
63,
3707,
8,
10512,
63,
1580,
1524,
10512,
14,
344,
566,
398,
327,
473,
1147,
323,
4052,
10986,
315,
314,
7614,
1380,
2005,
2030,
8491,
282,
892,
267,
327,
12690,
687,
314,
10691,
1824,
267,
12690,
275,
334,
277,
14,
1813,
905,
15213,
14,
13799,
937,
355,
1275,
1045,
63,
1100,
8,
1198,
63,
981,
63,
12712,
456,
5355,
29,
549,
9,
355,
1275,
12095,
342,
355,
1275,
981,
6333,
7811,
63,
354,
582,
298,
7700,
2030,
401,
586,
298,
1802,
582,
298,
7700,
7894,
401,
586,
298,
2123,
63,
504,
582,
298,
3972,
1198,
32,
2694,
14,
957,
401,
586,
298,
354,
582,
298,
7700,
5420,
401,
586,
298,
3899,
63,
354,
582,
298,
7700,
7233,
401,
586,
298,
2792,
63,
344,
582,
291,
14,
1813,
14,
1121,
8,
2490,
298,
16175,
63,
5969,
14,
2792,
63,
16175,
63,
19623,
3471,
344,
12,
586,
298,
9339,
582,
7210,
20625,
3570,
430,
398,
327,
710,
922,
1077,
1172,
282,
892,
625,
739,
1245,
267,
291,
14,
1815,
8,
13799,
14,
12095,
8,
751,
680,
1188,
63,
28677,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
5166,
14,
2219,
14,
2330,
492,
18244,
1538,
421,
199,
533,
7053,
29006,
11598,
774,
8,
10161,
1538,
304,
272,
347,
511,
63,
1222,
63,
13799,
63,
6761,
8,
277,
304,
267,
327,
2790,
282,
892,
922,
267,
922,
275,
291,
14,
1813,
905,
470,
14,
3707,
4140,
981,
2561,
288,
298,
354,
582,
636,
493,
3108,
288,
298,
2886,
582,
636,
493,
3108,
267,
3828,
398,
327,
4804,
5355,
26457,
370,
21702,
27669,
267,
8099,
275,
291,
14,
1813,
14,
1121,
480,
16175,
63,
5969,
14,
2792,
63,
16175,
63,
19623,
531,
267,
15686,
275,
291,
14,
1813,
14,
1121,
480,
15213,
14,
2037,
63,
8515,
1597,
455,
63,
13799,
531,
267,
8099,
14,
12095,
8,
751,
680,
1188,
63,
10108,
63,
3707,
8,
10512,
63,
1580,
1524,
10512,
14,
344,
566,
398,
327,
473,
1147,
323,
4052,
10986,
315,
314,
7614,
1380,
2005,
2030,
8491,
282,
892,
267,
327,
12690,
687,
314,
10691,
1824,
267,
12690,
275,
334,
277,
14,
1813,
905,
15213,
14,
13799,
937,
355,
1275,
1045,
63,
1100,
8,
1198,
63,
981,
63,
12712,
456,
5355,
29,
549,
9,
355,
1275,
12095,
342,
355,
1275,
981,
6333,
7811,
63,
354,
582,
298,
7700,
2030,
401,
586,
298,
1802,
582,
298,
7700,
7894,
401,
586,
298,
2123,
63,
504,
582,
298,
3972,
1198,
32,
2694,
14,
957,
401,
586,
298,
354,
582,
298,
7700,
5420,
401,
586,
298,
3899,
63,
354,
582,
298,
7700,
7233,
401,
586,
298,
2792,
63,
344,
582,
291,
14,
1813,
14,
1121,
8,
2490,
298,
16175,
63,
5969,
14,
2792,
63,
16175,
63,
19623,
3471,
344,
12,
586,
298,
9339,
582,
7210,
20625,
3570,
430,
398,
327,
710,
922,
1077,
1172,
282,
892,
625,
739,
1245,
267,
291,
14,
1815,
8,
13799,
14,
12095,
8,
751,
680,
1188,
63,
28677,
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,
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
] |
nugget/home-assistant
|
homeassistant/components/alarmdecoder/alarm_control_panel.py
|
2
|
4611
|
"""Support for AlarmDecoder-based alarm control panels (Honeywell/DSC)."""
import logging
import voluptuous as vol
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarmdecoder import DATA_AD, SIGNAL_PANEL_MESSAGE
from homeassistant.const import (
ATTR_CODE, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME,
STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED)
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['alarmdecoder']
SERVICE_ALARM_TOGGLE_CHIME = 'alarmdecoder_alarm_toggle_chime'
ALARM_TOGGLE_CHIME_SCHEMA = vol.Schema({
vol.Required(ATTR_CODE): cv.string,
})
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up for AlarmDecoder alarm panels."""
device = AlarmDecoderAlarmPanel()
add_entities([device])
def alarm_toggle_chime_handler(service):
"""Register toggle chime handler."""
code = service.data.get(ATTR_CODE)
device.alarm_toggle_chime(code)
hass.services.register(
alarm.DOMAIN, SERVICE_ALARM_TOGGLE_CHIME, alarm_toggle_chime_handler,
schema=ALARM_TOGGLE_CHIME_SCHEMA)
class AlarmDecoderAlarmPanel(alarm.AlarmControlPanel):
"""Representation of an AlarmDecoder-based alarm panel."""
def __init__(self):
"""Initialize the alarm panel."""
self._display = ""
self._name = "Alarm Panel"
self._state = None
self._ac_power = None
self._backlight_on = None
self._battery_low = None
self._check_zone = None
self._chime = None
self._entry_delay_off = None
self._programming_mode = None
self._ready = None
self._zone_bypassed = None
async def async_added_to_hass(self):
"""Register callbacks."""
self.hass.helpers.dispatcher.async_dispatcher_connect(
SIGNAL_PANEL_MESSAGE, self._message_callback)
def _message_callback(self, message):
"""Handle received messages."""
if message.alarm_sounding or message.fire_alarm:
self._state = STATE_ALARM_TRIGGERED
elif message.armed_away:
self._state = STATE_ALARM_ARMED_AWAY
elif message.armed_home:
self._state = STATE_ALARM_ARMED_HOME
else:
self._state = STATE_ALARM_DISARMED
self._ac_power = message.ac_power
self._backlight_on = message.backlight_on
self._battery_low = message.battery_low
self._check_zone = message.check_zone
self._chime = message.chime_on
self._entry_delay_off = message.entry_delay_off
self._programming_mode = message.programming_mode
self._ready = message.ready
self._zone_bypassed = message.zone_bypassed
self.schedule_update_ha_state()
@property
def name(self):
"""Return the name of the device."""
return self._name
@property
def should_poll(self):
"""Return the polling state."""
return False
@property
def code_format(self):
"""Return one or more digits/characters."""
return alarm.FORMAT_NUMBER
@property
def state(self):
"""Return the state of the device."""
return self._state
@property
def device_state_attributes(self):
"""Return the state attributes."""
return {
'ac_power': self._ac_power,
'backlight_on': self._backlight_on,
'battery_low': self._battery_low,
'check_zone': self._check_zone,
'chime': self._chime,
'entry_delay_off': self._entry_delay_off,
'programming_mode': self._programming_mode,
'ready': self._ready,
'zone_bypassed': self._zone_bypassed,
}
def alarm_disarm(self, code=None):
"""Send disarm command."""
if code:
self.hass.data[DATA_AD].send("{!s}1".format(code))
def alarm_arm_away(self, code=None):
"""Send arm away command."""
if code:
self.hass.data[DATA_AD].send("{!s}2".format(code))
def alarm_arm_home(self, code=None):
"""Send arm home command."""
if code:
self.hass.data[DATA_AD].send("{!s}3".format(code))
def alarm_arm_night(self, code=None):
"""Send arm night command."""
if code:
self.hass.data[DATA_AD].send("{!s}33".format(code))
def alarm_toggle_chime(self, code=None):
"""Send toggle chime command."""
if code:
self.hass.data[DATA_AD].send("{!s}9".format(code))
|
apache-2.0
|
[
624,
11532,
367,
4580,
5362,
8326,
13,
6788,
17987,
3304,
12748,
83,
334,
40,
13234,
20501,
15,
3177,
35,
10477,
199,
646,
2050,
199,
199,
646,
30291,
465,
5236,
199,
199,
646,
8846,
14,
4608,
14,
14160,
63,
2785,
63,
7885,
465,
17987,
199,
504,
8846,
14,
4608,
14,
14160,
8813,
492,
7126,
63,
1554,
12,
24360,
63,
26685,
2901,
63,
8272,
199,
504,
8846,
14,
1297,
492,
334,
272,
10762,
63,
6012,
12,
11377,
63,
748,
12482,
63,
12482,
1149,
63,
15088,
3448,
12,
11377,
63,
748,
12482,
63,
12482,
1149,
63,
9524,
12,
272,
11377,
63,
748,
12482,
63,
6178,
12482,
1149,
12,
11377,
63,
748,
12482,
63,
30073,
1149,
9,
199,
646,
8846,
14,
7546,
14,
888,
63,
6136,
465,
6277,
199,
199,
63,
10186,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
25743,
9415,
2563,
275,
788,
14160,
8813,
418,
199,
199,
10486,
63,
748,
12482,
63,
2566,
2916,
906,
63,
1244,
3465,
275,
283,
14160,
8813,
63,
14160,
63,
13396,
63,
335,
1036,
7,
199,
748,
12482,
63,
2566,
2916,
906,
63,
1244,
3465,
63,
10926,
275,
5236,
14,
6700,
2561,
272,
5236,
14,
8030,
8,
5280,
63,
6012,
304,
6277,
14,
875,
12,
199,
1552,
421,
199,
318,
3272,
63,
3246,
8,
5387,
12,
1101,
12,
1050,
63,
8327,
12,
13172,
63,
815,
29,
403,
304,
272,
408,
1084,
1536,
367,
4580,
5362,
8326,
17987,
12748,
83,
1041,
272,
2243,
275,
4580,
5362,
8326,
30655,
10185,
342,
272,
1050,
63,
8327,
779,
1782,
566,
339,
347,
17987,
63,
13396,
63,
335,
1036,
63,
2232,
8,
1364,
304,
267,
408,
7099,
19420,
682,
1036,
3016,
1041,
267,
1233,
275,
2435,
14,
576,
14,
362,
8,
5280,
63,
6012,
9,
267,
2243,
14,
14160,
63,
13396,
63,
335,
1036,
8,
600,
9,
339,
6298,
14,
5950,
14,
2683,
8,
267,
17987,
14,
7378,
12,
16655,
63,
748,
12482,
63,
2566,
2916,
906,
63,
1244,
3465,
12,
17987,
63,
13396,
63,
335,
1036,
63,
2232,
12,
267,
4177,
29,
748,
12482,
63,
2566,
2916,
906,
63,
1244,
3465,
63,
10926,
9,
421,
199,
533,
4580,
5362,
8326,
30655,
10185,
8,
14160,
14,
30655,
3717,
10185,
304,
272,
408,
20609,
402,
376,
4580,
5362,
8326,
13,
6788,
17987,
12748,
1041,
339,
347,
636,
826,
721,
277,
304,
267,
408,
9345,
314,
17987,
12748,
1041,
267,
291,
423,
2918,
275,
3087,
267,
291,
423,
354,
275,
298,
30655,
510,
4822,
2,
267,
291,
423,
929,
275,
488,
267,
291,
423,
645,
63,
5652,
275,
488,
267,
291,
423,
894,
4040,
63,
265,
275,
488,
267,
291,
423,
21113,
63,
674,
275,
488,
267,
291,
423,
1074,
63,
2619,
275,
488,
267,
291,
423,
335,
1036,
275,
488,
267,
291,
423,
2373,
63,
5814,
63,
1997,
275,
488,
267,
291,
423,
496,
9258,
63,
632,
275,
488,
267,
291,
423,
2179,
275,
488,
267,
291,
423,
2619,
63,
991,
12070,
275,
488,
339,
5316,
347,
5316,
63,
3270,
63,
475,
63,
5387,
8,
277,
304,
267,
408,
7099,
13484,
1041,
267,
291,
14,
5387,
14,
7546,
14,
14913,
14,
4146,
63,
14913,
63,
2242,
8,
288,
24360,
63,
26685,
2901,
63,
8272,
12,
291,
423,
1188,
63,
3058,
9,
339,
347,
485,
1188,
63,
3058,
8,
277,
12,
1245,
304,
267,
408,
5940,
3086,
3788,
1041,
267,
340,
1245,
14,
14160,
63,
14990,
316,
503,
1245,
14,
8935,
63,
14160,
26,
288,
291,
423,
929,
275,
11377,
63,
748,
12482,
63,
30073,
1149,
267,
916,
1245,
14,
285,
3594,
63,
22703,
26,
288,
291,
423,
929,
275,
11377,
63,
748,
12482,
63,
12482,
1149,
63,
15088,
3448,
267,
916,
1245,
14,
285,
3594,
63,
4219,
26,
288,
291,
423,
929,
275,
11377,
63,
748,
12482,
63,
12482,
1149,
63,
9524,
267,
587,
26,
288,
291,
423,
929,
275,
11377,
63,
748,
12482,
63,
6178,
12482,
1149,
398,
291,
423,
645,
63,
5652,
275,
1245,
14,
645,
63,
5652,
267,
291,
423,
894,
4040,
63,
265,
275,
1245,
14,
894,
4040,
63,
265,
267,
291,
423,
21113,
63,
674,
275,
1245,
14,
21113,
63,
674,
267,
291,
423,
1074,
63,
2619,
275,
1245,
14,
1074,
63,
2619,
267,
291,
423,
335,
1036,
275,
1245,
14,
335,
1036,
63,
265,
267,
291,
423,
2373,
63,
5814,
63,
1997,
275,
1245,
14,
2373,
63,
5814,
63,
1997,
267,
291,
423,
496,
9258,
63,
632,
275,
1245,
14,
496,
9258,
63,
632,
267,
291,
423,
2179,
275,
1245,
14,
2179,
267,
291,
423,
2619,
63,
991,
12070,
275,
1245,
14,
2619,
63,
991,
12070,
398,
291,
14,
7211,
63,
873,
63,
2411,
63,
929,
342,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
408,
1767,
314,
536,
402,
314,
2243,
1041,
267,
372,
291,
423,
354,
339,
768,
1829,
272,
347,
1077,
63,
6843,
8,
277,
304,
267,
408,
1767,
314,
12353,
1174,
1041,
267,
372,
756,
339,
768,
1829,
272,
347,
1233,
63,
908,
8,
277,
304,
267,
408,
1767,
1373,
503,
1655,
7576,
15,
16516,
1041,
267,
372,
17987,
14,
4807,
63,
9190,
339,
768,
1829,
272,
347,
1174,
8,
277,
304,
267,
408,
1767,
314,
1174,
402,
314,
2243,
1041,
267,
372,
291,
423,
929,
339,
768,
1829,
272,
347,
2243,
63,
929,
63,
2987,
8,
277,
304,
267,
408,
1767,
314,
1174,
3004,
1041,
267,
372,
469,
288,
283,
645,
63,
5652,
356,
291,
423,
645,
63,
5652,
12,
288,
283,
894,
4040,
63,
265,
356,
291,
423,
894,
4040,
63,
265,
12,
288,
283,
21113,
63,
674,
356,
291,
423,
21113,
63,
674,
12,
288,
283,
1074,
63,
2619,
356,
291,
423,
1074,
63,
2619,
12,
288,
283,
335,
1036,
356,
291,
423,
335,
1036,
12,
288,
283,
2373,
63,
5814,
63,
1997,
356,
291,
423,
2373,
63,
5814,
63,
1997,
12,
288,
283,
496,
9258,
63,
632,
356,
291,
423,
496,
9258,
63,
632,
12,
288,
283,
2179,
356,
291,
423,
2179,
12,
288,
283,
2619,
63,
991,
12070,
356,
291,
423,
2619,
63,
991,
12070,
12,
267,
789,
339,
347,
17987,
63,
2297,
5362,
8,
277,
12,
1233,
29,
403,
304,
267,
408,
6795,
2153,
5362,
1414,
1041,
267,
340,
1233,
26,
288,
291,
14,
5387,
14,
576
] |
[
11532,
367,
4580,
5362,
8326,
13,
6788,
17987,
3304,
12748,
83,
334,
40,
13234,
20501,
15,
3177,
35,
10477,
199,
646,
2050,
199,
199,
646,
30291,
465,
5236,
199,
199,
646,
8846,
14,
4608,
14,
14160,
63,
2785,
63,
7885,
465,
17987,
199,
504,
8846,
14,
4608,
14,
14160,
8813,
492,
7126,
63,
1554,
12,
24360,
63,
26685,
2901,
63,
8272,
199,
504,
8846,
14,
1297,
492,
334,
272,
10762,
63,
6012,
12,
11377,
63,
748,
12482,
63,
12482,
1149,
63,
15088,
3448,
12,
11377,
63,
748,
12482,
63,
12482,
1149,
63,
9524,
12,
272,
11377,
63,
748,
12482,
63,
6178,
12482,
1149,
12,
11377,
63,
748,
12482,
63,
30073,
1149,
9,
199,
646,
8846,
14,
7546,
14,
888,
63,
6136,
465,
6277,
199,
199,
63,
10186,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
25743,
9415,
2563,
275,
788,
14160,
8813,
418,
199,
199,
10486,
63,
748,
12482,
63,
2566,
2916,
906,
63,
1244,
3465,
275,
283,
14160,
8813,
63,
14160,
63,
13396,
63,
335,
1036,
7,
199,
748,
12482,
63,
2566,
2916,
906,
63,
1244,
3465,
63,
10926,
275,
5236,
14,
6700,
2561,
272,
5236,
14,
8030,
8,
5280,
63,
6012,
304,
6277,
14,
875,
12,
199,
1552,
421,
199,
318,
3272,
63,
3246,
8,
5387,
12,
1101,
12,
1050,
63,
8327,
12,
13172,
63,
815,
29,
403,
304,
272,
408,
1084,
1536,
367,
4580,
5362,
8326,
17987,
12748,
83,
1041,
272,
2243,
275,
4580,
5362,
8326,
30655,
10185,
342,
272,
1050,
63,
8327,
779,
1782,
566,
339,
347,
17987,
63,
13396,
63,
335,
1036,
63,
2232,
8,
1364,
304,
267,
408,
7099,
19420,
682,
1036,
3016,
1041,
267,
1233,
275,
2435,
14,
576,
14,
362,
8,
5280,
63,
6012,
9,
267,
2243,
14,
14160,
63,
13396,
63,
335,
1036,
8,
600,
9,
339,
6298,
14,
5950,
14,
2683,
8,
267,
17987,
14,
7378,
12,
16655,
63,
748,
12482,
63,
2566,
2916,
906,
63,
1244,
3465,
12,
17987,
63,
13396,
63,
335,
1036,
63,
2232,
12,
267,
4177,
29,
748,
12482,
63,
2566,
2916,
906,
63,
1244,
3465,
63,
10926,
9,
421,
199,
533,
4580,
5362,
8326,
30655,
10185,
8,
14160,
14,
30655,
3717,
10185,
304,
272,
408,
20609,
402,
376,
4580,
5362,
8326,
13,
6788,
17987,
12748,
1041,
339,
347,
636,
826,
721,
277,
304,
267,
408,
9345,
314,
17987,
12748,
1041,
267,
291,
423,
2918,
275,
3087,
267,
291,
423,
354,
275,
298,
30655,
510,
4822,
2,
267,
291,
423,
929,
275,
488,
267,
291,
423,
645,
63,
5652,
275,
488,
267,
291,
423,
894,
4040,
63,
265,
275,
488,
267,
291,
423,
21113,
63,
674,
275,
488,
267,
291,
423,
1074,
63,
2619,
275,
488,
267,
291,
423,
335,
1036,
275,
488,
267,
291,
423,
2373,
63,
5814,
63,
1997,
275,
488,
267,
291,
423,
496,
9258,
63,
632,
275,
488,
267,
291,
423,
2179,
275,
488,
267,
291,
423,
2619,
63,
991,
12070,
275,
488,
339,
5316,
347,
5316,
63,
3270,
63,
475,
63,
5387,
8,
277,
304,
267,
408,
7099,
13484,
1041,
267,
291,
14,
5387,
14,
7546,
14,
14913,
14,
4146,
63,
14913,
63,
2242,
8,
288,
24360,
63,
26685,
2901,
63,
8272,
12,
291,
423,
1188,
63,
3058,
9,
339,
347,
485,
1188,
63,
3058,
8,
277,
12,
1245,
304,
267,
408,
5940,
3086,
3788,
1041,
267,
340,
1245,
14,
14160,
63,
14990,
316,
503,
1245,
14,
8935,
63,
14160,
26,
288,
291,
423,
929,
275,
11377,
63,
748,
12482,
63,
30073,
1149,
267,
916,
1245,
14,
285,
3594,
63,
22703,
26,
288,
291,
423,
929,
275,
11377,
63,
748,
12482,
63,
12482,
1149,
63,
15088,
3448,
267,
916,
1245,
14,
285,
3594,
63,
4219,
26,
288,
291,
423,
929,
275,
11377,
63,
748,
12482,
63,
12482,
1149,
63,
9524,
267,
587,
26,
288,
291,
423,
929,
275,
11377,
63,
748,
12482,
63,
6178,
12482,
1149,
398,
291,
423,
645,
63,
5652,
275,
1245,
14,
645,
63,
5652,
267,
291,
423,
894,
4040,
63,
265,
275,
1245,
14,
894,
4040,
63,
265,
267,
291,
423,
21113,
63,
674,
275,
1245,
14,
21113,
63,
674,
267,
291,
423,
1074,
63,
2619,
275,
1245,
14,
1074,
63,
2619,
267,
291,
423,
335,
1036,
275,
1245,
14,
335,
1036,
63,
265,
267,
291,
423,
2373,
63,
5814,
63,
1997,
275,
1245,
14,
2373,
63,
5814,
63,
1997,
267,
291,
423,
496,
9258,
63,
632,
275,
1245,
14,
496,
9258,
63,
632,
267,
291,
423,
2179,
275,
1245,
14,
2179,
267,
291,
423,
2619,
63,
991,
12070,
275,
1245,
14,
2619,
63,
991,
12070,
398,
291,
14,
7211,
63,
873,
63,
2411,
63,
929,
342,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
408,
1767,
314,
536,
402,
314,
2243,
1041,
267,
372,
291,
423,
354,
339,
768,
1829,
272,
347,
1077,
63,
6843,
8,
277,
304,
267,
408,
1767,
314,
12353,
1174,
1041,
267,
372,
756,
339,
768,
1829,
272,
347,
1233,
63,
908,
8,
277,
304,
267,
408,
1767,
1373,
503,
1655,
7576,
15,
16516,
1041,
267,
372,
17987,
14,
4807,
63,
9190,
339,
768,
1829,
272,
347,
1174,
8,
277,
304,
267,
408,
1767,
314,
1174,
402,
314,
2243,
1041,
267,
372,
291,
423,
929,
339,
768,
1829,
272,
347,
2243,
63,
929,
63,
2987,
8,
277,
304,
267,
408,
1767,
314,
1174,
3004,
1041,
267,
372,
469,
288,
283,
645,
63,
5652,
356,
291,
423,
645,
63,
5652,
12,
288,
283,
894,
4040,
63,
265,
356,
291,
423,
894,
4040,
63,
265,
12,
288,
283,
21113,
63,
674,
356,
291,
423,
21113,
63,
674,
12,
288,
283,
1074,
63,
2619,
356,
291,
423,
1074,
63,
2619,
12,
288,
283,
335,
1036,
356,
291,
423,
335,
1036,
12,
288,
283,
2373,
63,
5814,
63,
1997,
356,
291,
423,
2373,
63,
5814,
63,
1997,
12,
288,
283,
496,
9258,
63,
632,
356,
291,
423,
496,
9258,
63,
632,
12,
288,
283,
2179,
356,
291,
423,
2179,
12,
288,
283,
2619,
63,
991,
12070,
356,
291,
423,
2619,
63,
991,
12070,
12,
267,
789,
339,
347,
17987,
63,
2297,
5362,
8,
277,
12,
1233,
29,
403,
304,
267,
408,
6795,
2153,
5362,
1414,
1041,
267,
340,
1233,
26,
288,
291,
14,
5387,
14,
576,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
haoqili/MozSecWorld
|
vendor-local/lib/python2.7/Crypto/Protocol/Chaffing.py
|
226
|
9467
|
"""This file implements the chaffing algorithm.
Winnowing and chaffing is a technique for enhancing privacy without requiring
strong encryption. In short, the technique takes a set of authenticated
message blocks (the wheat) and adds a number of chaff blocks which have
randomly chosen data and MAC fields. This means that to an adversary, the
chaff blocks look as valid as the wheat blocks, and so the authentication
would have to be performed on every block. By tailoring the number of chaff
blocks added to the message, the sender can make breaking the message
computationally infeasible. There are many other interesting properties of
the winnow/chaff technique.
For example, say Alice is sending a message to Bob. She packetizes the
message and performs an all-or-nothing transformation on the packets. Then
she authenticates each packet with a message authentication code (MAC). The
MAC is a hash of the data packet, and there is a secret key which she must
share with Bob (key distribution is an exercise left to the reader). She then
adds a serial number to each packet, and sends the packets to Bob.
Bob receives the packets, and using the shared secret authentication key,
authenticates the MACs for each packet. Those packets that have bad MACs are
simply discarded. The remainder are sorted by serial number, and passed
through the reverse all-or-nothing transform. The transform means that an
eavesdropper (say Eve) must acquire all the packets before any of the data can
be read. If even one packet is missing, the data is useless.
There's one twist: by adding chaff packets, Alice and Bob can make Eve's job
much harder, since Eve now has to break the shared secret key, or try every
combination of wheat and chaff packet to read any of the message. The cool
thing is that Bob doesn't need to add any additional code; the chaff packets
are already filtered out because their MACs don't match (in all likelihood --
since the data and MACs for the chaff packets are randomly chosen it is
possible, but very unlikely that a chaff MAC will match the chaff data). And
Alice need not even be the party adding the chaff! She could be completely
unaware that a third party, say Charles, is adding chaff packets to her
messages as they are transmitted.
For more information on winnowing and chaffing see this paper:
Ronald L. Rivest, "Chaffing and Winnowing: Confidentiality without Encryption"
http://theory.lcs.mit.edu/~rivest/chaffing.txt
"""
__revision__ = "$Id: Chaffing.py,v 1.7 2003/02/28 15:23:21 akuchling Exp $"
from Crypto.Util.number import bytes_to_long
class Chaff:
"""Class implementing the chaff adding algorithm.
Methods for subclasses:
_randnum(size):
Returns a randomly generated number with a byte-length equal
to size. Subclasses can use this to implement better random
data and MAC generating algorithms. The default algorithm is
probably not very cryptographically secure. It is most
important that the chaff data does not contain any patterns
that can be used to discern it from wheat data without running
the MAC.
"""
def __init__(self, factor=1.0, blocksper=1):
"""Chaff(factor:float, blocksper:int)
factor is the number of message blocks to add chaff to,
expressed as a percentage between 0.0 and 1.0. blocksper is
the number of chaff blocks to include for each block being
chaffed. Thus the defaults add one chaff block to every
message block. By changing the defaults, you can adjust how
computationally difficult it could be for an adversary to
brute-force crack the message. The difficulty is expressed
as:
pow(blocksper, int(factor * number-of-blocks))
For ease of implementation, when factor < 1.0, only the first
int(factor*number-of-blocks) message blocks are chaffed.
"""
if not (0.0<=factor<=1.0):
raise ValueError, "'factor' must be between 0.0 and 1.0"
if blocksper < 0:
raise ValueError, "'blocksper' must be zero or more"
self.__factor = factor
self.__blocksper = blocksper
def chaff(self, blocks):
"""chaff( [(serial-number:int, data:string, MAC:string)] )
: [(int, string, string)]
Add chaff to message blocks. blocks is a list of 3-tuples of the
form (serial-number, data, MAC).
Chaff is created by choosing a random number of the same
byte-length as data, and another random number of the same
byte-length as MAC. The message block's serial number is
placed on the chaff block and all the packet's chaff blocks
are randomly interspersed with the single wheat block. This
method then returns a list of 3-tuples of the same form.
Chaffed blocks will contain multiple instances of 3-tuples
with the same serial number, but the only way to figure out
which blocks are wheat and which are chaff is to perform the
MAC hash and compare values.
"""
chaffedblocks = []
# count is the number of blocks to add chaff to. blocksper is the
# number of chaff blocks to add per message block that is being
# chaffed.
count = len(blocks) * self.__factor
blocksper = range(self.__blocksper)
for i, wheat in map(None, range(len(blocks)), blocks):
# it shouldn't matter which of the n blocks we add chaff to, so for
# ease of implementation, we'll just add them to the first count
# blocks
if i < count:
serial, data, mac = wheat
datasize = len(data)
macsize = len(mac)
addwheat = 1
# add chaff to this block
for j in blocksper:
import sys
chaffdata = self._randnum(datasize)
chaffmac = self._randnum(macsize)
chaff = (serial, chaffdata, chaffmac)
# mix up the order, if the 5th bit is on then put the
# wheat on the list
if addwheat and bytes_to_long(self._randnum(16)) & 0x40:
chaffedblocks.append(wheat)
addwheat = 0
chaffedblocks.append(chaff)
if addwheat:
chaffedblocks.append(wheat)
else:
# just add the wheat
chaffedblocks.append(wheat)
return chaffedblocks
def _randnum(self, size):
# TBD: Not a very secure algorithm.
# TBD: size * 2 to work around possible bug in RandomPool
from Crypto.Util import randpool
import time
pool = randpool.RandomPool(size * 2)
while size > pool.entropy:
pass
# we now have enough entropy in the pool to get size bytes of random
# data... well, probably
return pool.get_bytes(size)
if __name__ == '__main__':
text = """\
We hold these truths to be self-evident, that all men are created equal, that
they are endowed by their Creator with certain unalienable Rights, that among
these are Life, Liberty, and the pursuit of Happiness. That to secure these
rights, Governments are instituted among Men, deriving their just powers from
the consent of the governed. That whenever any Form of Government becomes
destructive of these ends, it is the Right of the People to alter or to
abolish it, and to institute new Government, laying its foundation on such
principles and organizing its powers in such form, as to them shall seem most
likely to effect their Safety and Happiness.
"""
print 'Original text:\n=========='
print text
print '=========='
# first transform the text into packets
blocks = [] ; size = 40
for i in range(0, len(text), size):
blocks.append( text[i:i+size] )
# now get MACs for all the text blocks. The key is obvious...
print 'Calculating MACs...'
from Crypto.Hash import HMAC, SHA
key = 'Jefferson'
macs = [HMAC.new(key, block, digestmod=SHA).digest()
for block in blocks]
assert len(blocks) == len(macs)
# put these into a form acceptable as input to the chaffing procedure
source = []
m = map(None, range(len(blocks)), blocks, macs)
print m
for i, data, mac in m:
source.append((i, data, mac))
# now chaff these
print 'Adding chaff...'
c = Chaff(factor=0.5, blocksper=2)
chaffed = c.chaff(source)
from base64 import encodestring
# print the chaffed message blocks. meanwhile, separate the wheat from
# the chaff
wheat = []
print 'chaffed message blocks:'
for i, data, mac in chaffed:
# do the authentication
h = HMAC.new(key, data, digestmod=SHA)
pmac = h.digest()
if pmac == mac:
tag = '-->'
wheat.append(data)
else:
tag = ' '
# base64 adds a trailing newline
print tag, '%3d' % i, \
repr(data), encodestring(mac)[:-1]
# now decode the message packets and check it against the original text
print 'Undigesting wheat...'
newtext = "".join(wheat)
if newtext == text:
print 'They match!'
else:
print 'They differ!'
|
bsd-3-clause
|
[
624,
2765,
570,
9031,
314,
682,
9181,
316,
5563,
14,
199,
199,
8886,
2131,
316,
436,
682,
9181,
316,
365,
282,
32414,
367,
655,
72,
15763,
16254,
4085,
1928,
29963,
199,
9370,
14396,
14,
221,
1010,
3974,
12,
314,
32414,
6181,
282,
663,
402,
15082,
199,
1188,
5664,
334,
1589,
336,
16614,
9,
436,
9584,
282,
1329,
402,
682,
9181,
5664,
1314,
1172,
199,
2355,
590,
12414,
666,
436,
13347,
1504,
14,
221,
961,
4910,
626,
370,
376,
1503,
14895,
695,
12,
314,
199,
335,
9181,
5664,
3648,
465,
1686,
465,
314,
336,
16614,
5664,
12,
436,
880,
314,
6299,
199,
2027,
854,
1172,
370,
506,
10585,
641,
4036,
1853,
14,
221,
4885,
9483,
6854,
314,
1329,
402,
682,
9181,
199,
4166,
3483,
370,
314,
1245,
12,
314,
8904,
883,
1852,
27485,
314,
1245,
199,
31598,
1183,
315,
771,
305,
7247,
14,
221,
6006,
787,
5002,
1163,
19604,
4382,
402,
199,
1589,
4747,
2131,
15,
335,
9181,
32414,
14,
199,
199,
1858,
2893,
12,
14722,
437,
3037,
365,
10209,
282,
1245,
370,
699,
2873,
14,
221,
428,
426,
1706,
69,
280,
90,
397,
314,
199,
1188,
436,
18628,
376,
1006,
13,
269,
13,
16323,
13315,
641,
314,
14593,
14,
221,
9442,
199,
19195,
28532,
2335,
1924,
3644,
543,
282,
1245,
6299,
1233,
334,
9410,
680,
221,
710,
199,
9410,
365,
282,
2631,
402,
314,
666,
3644,
12,
436,
2337,
365,
282,
7565,
790,
1314,
21920,
1471,
199,
6251,
543,
699,
2873,
334,
498,
4084,
365,
376,
26511,
3602,
370,
314,
7002,
680,
221,
428,
426,
2066,
199,
525,
83,
282,
3012,
1329,
370,
1924,
3644,
12,
436,
16178,
314,
14593,
370,
699,
2873,
14,
199,
199,
22593,
23192,
314,
14593,
12,
436,
1808,
314,
5709,
7565,
6299,
790,
12,
199,
1178,
2815,
2335,
314,
13347,
83,
367,
1924,
3644,
14,
221,
18049,
261,
14593,
626,
1172,
4875,
13347,
83,
787,
199,
11184,
590,
22002,
14,
221,
710,
15748,
787,
3355,
701,
3012,
1329,
12,
436,
3032,
199,
8304,
314,
3837,
1006,
13,
269,
13,
16323,
5793,
14,
221,
710,
5793,
4910,
626,
376,
199,
69,
7047,
4824,
529,
334,
19787,
662,
432,
9,
1471,
16919,
1006,
314,
14593,
2544,
1263,
402,
314,
666,
883,
199,
1235,
1586,
14,
221,
982,
2755,
1373,
3644,
365,
4124,
12,
314,
666,
365,
31291,
14,
199,
199,
10924,
1159,
1373,
8900,
631,
26,
701,
7791,
682,
9181,
14593,
12,
437,
3037,
436,
699,
2873,
883,
1852,
662,
432,
1159,
3906,
199,
77,
2133,
12159,
424,
12,
3967,
662,
432,
3063,
965,
370,
2059,
314,
5709,
7565,
790,
12,
503,
862,
4036,
199,
6560,
3155,
402,
336,
16614,
436,
682,
9181,
3644,
370,
1586,
1263,
402,
314,
1245,
14,
221,
710,
32268,
199,
2127,
365,
626,
699,
2873,
3181,
1133,
1929,
370,
1050,
1263,
4722,
1233,
27,
314,
682,
9181,
14593,
199,
1530,
2575,
9806,
734,
2952,
3932,
13347,
83,
2793,
1133,
1336,
334,
262,
1006,
22046,
1553,
199,
8585,
314,
666,
436,
13347,
83,
367,
314,
682,
9181,
14593,
787,
19311,
12414,
652,
365,
199,
13893,
12,
1325,
7437,
625,
24227,
626,
282,
682,
9181,
13347,
911,
1336,
314,
682,
9181,
666,
680,
221,
6061,
199,
28001,
1929,
440,
2755,
506,
314,
17135,
7791,
314,
682,
9181,
1,
221,
428,
426,
4293,
506,
14793,
199,
324,
14600,
626,
282,
10919,
17135,
12,
14722,
6659,
2978,
12,
365,
7791,
682,
9181,
14593,
370,
14737,
199,
3431,
465,
2985,
787,
29818,
14,
199,
199,
1858,
1655,
2556,
641,
4747,
2131,
316,
436,
682,
9181,
316,
1937,
642,
15220,
26,
199,
199,
50,
8125,
68,
491,
14,
820,
1912,
270,
12,
298,
1049,
9181,
316,
436,
13036,
2131,
316,
26,
1448,
329,
3256,
1209,
1928,
3447,
7950,
2,
199,
1014,
921,
1589,
1089,
14,
76,
1259,
14,
1147,
14,
8654,
22500,
6053,
270,
15,
335,
9181,
316,
14,
2424,
199,
199,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
26,
445,
2411,
556,
316,
14,
647,
12,
86,
413,
14,
23,
13004,
15,
996,
15,
1651,
4114,
26,
1789,
26,
2025,
282,
75,
2133,
2983,
7910,
2672,
2,
199,
199,
504,
18855,
14,
9562,
14,
1955,
492,
2783,
63,
475,
63,
2809,
199,
199,
533,
445,
2411,
556,
26,
272,
408,
2543,
18234,
314,
682,
9181,
7791,
5563,
14,
339,
17653,
367,
9180,
26,
953,
485,
3759,
1507,
8,
890,
304,
355,
1803,
282,
19311,
4046,
1329,
543,
282,
3696,
13,
1267,
4472,
355,
370,
1568,
14,
221,
20196,
883,
675,
642,
370,
5669,
8034,
2196,
355,
666,
436,
13347,
12999,
18036,
14,
221,
710,
849,
5563,
365,
355,
8646,
440,
7437,
13230,
25537,
11153,
14,
221,
2779,
365,
4750,
355,
11012,
626,
314,
682,
9181,
666,
1630,
440,
1395,
1263,
7970,
355,
626,
883,
506,
1202,
370,
4339,
27569,
652,
687,
336,
16614,
666,
1928,
3879,
355,
314,
13347,
14,
339,
408,
339,
347,
636,
826,
721,
277,
12,
6535,
29,
17,
14,
16,
12,
5664,
529,
29,
17,
304,
267,
408,
1049,
9181,
8,
4778,
26,
1609,
12,
5664,
529,
26,
442,
9,
398,
6535,
365,
314,
1329,
402,
1245,
5664,
370,
1050,
682,
9181,
370,
12,
267,
19147,
465,
282,
16327,
3382,
378,
14,
16,
436,
413,
14,
16,
14,
221,
5664,
529,
365,
267,
314,
1329,
402,
682,
9181,
5664,
370,
2387,
367,
1924,
1853,
3769,
267,
682,
9181,
379,
14,
221,
20227,
314,
4243,
1050,
1373,
682,
9181,
1853,
370,
4036,
267,
1245,
1853,
14,
221,
4885,
13729,
314,
4243,
12,
1265,
883,
11311,
4212,
267,
14009,
1183,
29870,
652,
4293,
506,
367,
376,
1503,
14895,
695,
370,
267,
11665,
938,
13,
3990,
286,
8085,
314,
1245,
14,
221,
710,
23976,
17323,
365,
19147,
267,
465,
26,
953,
13131,
8,
4166,
529,
12,
1109,
8,
4778,
627,
1329,
13,
1618,
13,
4166,
430,
398,
2104,
325,
482,
402,
4514,
12,
1380,
6535,
665,
413,
14,
16,
12,
1454,
314,
1642,
267,
1109,
8,
4778,
10,
1955,
13,
1618,
13,
4166,
9,
1245,
5664,
787,
682,
9181,
379,
14,
267,
408,
398,
340,
440,
334,
16,
14,
16,
12932,
4778,
12932,
17,
14,
16,
304,
288,
746,
1722,
12,
3546,
4778,
7,
1471,
506,
3382,
378,
14,
16,
436,
413,
14,
16,
2,
267,
340,
5664
] |
[
2765,
570,
9031,
314,
682,
9181,
316,
5563,
14,
199,
199,
8886,
2131,
316,
436,
682,
9181,
316,
365,
282,
32414,
367,
655,
72,
15763,
16254,
4085,
1928,
29963,
199,
9370,
14396,
14,
221,
1010,
3974,
12,
314,
32414,
6181,
282,
663,
402,
15082,
199,
1188,
5664,
334,
1589,
336,
16614,
9,
436,
9584,
282,
1329,
402,
682,
9181,
5664,
1314,
1172,
199,
2355,
590,
12414,
666,
436,
13347,
1504,
14,
221,
961,
4910,
626,
370,
376,
1503,
14895,
695,
12,
314,
199,
335,
9181,
5664,
3648,
465,
1686,
465,
314,
336,
16614,
5664,
12,
436,
880,
314,
6299,
199,
2027,
854,
1172,
370,
506,
10585,
641,
4036,
1853,
14,
221,
4885,
9483,
6854,
314,
1329,
402,
682,
9181,
199,
4166,
3483,
370,
314,
1245,
12,
314,
8904,
883,
1852,
27485,
314,
1245,
199,
31598,
1183,
315,
771,
305,
7247,
14,
221,
6006,
787,
5002,
1163,
19604,
4382,
402,
199,
1589,
4747,
2131,
15,
335,
9181,
32414,
14,
199,
199,
1858,
2893,
12,
14722,
437,
3037,
365,
10209,
282,
1245,
370,
699,
2873,
14,
221,
428,
426,
1706,
69,
280,
90,
397,
314,
199,
1188,
436,
18628,
376,
1006,
13,
269,
13,
16323,
13315,
641,
314,
14593,
14,
221,
9442,
199,
19195,
28532,
2335,
1924,
3644,
543,
282,
1245,
6299,
1233,
334,
9410,
680,
221,
710,
199,
9410,
365,
282,
2631,
402,
314,
666,
3644,
12,
436,
2337,
365,
282,
7565,
790,
1314,
21920,
1471,
199,
6251,
543,
699,
2873,
334,
498,
4084,
365,
376,
26511,
3602,
370,
314,
7002,
680,
221,
428,
426,
2066,
199,
525,
83,
282,
3012,
1329,
370,
1924,
3644,
12,
436,
16178,
314,
14593,
370,
699,
2873,
14,
199,
199,
22593,
23192,
314,
14593,
12,
436,
1808,
314,
5709,
7565,
6299,
790,
12,
199,
1178,
2815,
2335,
314,
13347,
83,
367,
1924,
3644,
14,
221,
18049,
261,
14593,
626,
1172,
4875,
13347,
83,
787,
199,
11184,
590,
22002,
14,
221,
710,
15748,
787,
3355,
701,
3012,
1329,
12,
436,
3032,
199,
8304,
314,
3837,
1006,
13,
269,
13,
16323,
5793,
14,
221,
710,
5793,
4910,
626,
376,
199,
69,
7047,
4824,
529,
334,
19787,
662,
432,
9,
1471,
16919,
1006,
314,
14593,
2544,
1263,
402,
314,
666,
883,
199,
1235,
1586,
14,
221,
982,
2755,
1373,
3644,
365,
4124,
12,
314,
666,
365,
31291,
14,
199,
199,
10924,
1159,
1373,
8900,
631,
26,
701,
7791,
682,
9181,
14593,
12,
437,
3037,
436,
699,
2873,
883,
1852,
662,
432,
1159,
3906,
199,
77,
2133,
12159,
424,
12,
3967,
662,
432,
3063,
965,
370,
2059,
314,
5709,
7565,
790,
12,
503,
862,
4036,
199,
6560,
3155,
402,
336,
16614,
436,
682,
9181,
3644,
370,
1586,
1263,
402,
314,
1245,
14,
221,
710,
32268,
199,
2127,
365,
626,
699,
2873,
3181,
1133,
1929,
370,
1050,
1263,
4722,
1233,
27,
314,
682,
9181,
14593,
199,
1530,
2575,
9806,
734,
2952,
3932,
13347,
83,
2793,
1133,
1336,
334,
262,
1006,
22046,
1553,
199,
8585,
314,
666,
436,
13347,
83,
367,
314,
682,
9181,
14593,
787,
19311,
12414,
652,
365,
199,
13893,
12,
1325,
7437,
625,
24227,
626,
282,
682,
9181,
13347,
911,
1336,
314,
682,
9181,
666,
680,
221,
6061,
199,
28001,
1929,
440,
2755,
506,
314,
17135,
7791,
314,
682,
9181,
1,
221,
428,
426,
4293,
506,
14793,
199,
324,
14600,
626,
282,
10919,
17135,
12,
14722,
6659,
2978,
12,
365,
7791,
682,
9181,
14593,
370,
14737,
199,
3431,
465,
2985,
787,
29818,
14,
199,
199,
1858,
1655,
2556,
641,
4747,
2131,
316,
436,
682,
9181,
316,
1937,
642,
15220,
26,
199,
199,
50,
8125,
68,
491,
14,
820,
1912,
270,
12,
298,
1049,
9181,
316,
436,
13036,
2131,
316,
26,
1448,
329,
3256,
1209,
1928,
3447,
7950,
2,
199,
1014,
921,
1589,
1089,
14,
76,
1259,
14,
1147,
14,
8654,
22500,
6053,
270,
15,
335,
9181,
316,
14,
2424,
199,
199,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
26,
445,
2411,
556,
316,
14,
647,
12,
86,
413,
14,
23,
13004,
15,
996,
15,
1651,
4114,
26,
1789,
26,
2025,
282,
75,
2133,
2983,
7910,
2672,
2,
199,
199,
504,
18855,
14,
9562,
14,
1955,
492,
2783,
63,
475,
63,
2809,
199,
199,
533,
445,
2411,
556,
26,
272,
408,
2543,
18234,
314,
682,
9181,
7791,
5563,
14,
339,
17653,
367,
9180,
26,
953,
485,
3759,
1507,
8,
890,
304,
355,
1803,
282,
19311,
4046,
1329,
543,
282,
3696,
13,
1267,
4472,
355,
370,
1568,
14,
221,
20196,
883,
675,
642,
370,
5669,
8034,
2196,
355,
666,
436,
13347,
12999,
18036,
14,
221,
710,
849,
5563,
365,
355,
8646,
440,
7437,
13230,
25537,
11153,
14,
221,
2779,
365,
4750,
355,
11012,
626,
314,
682,
9181,
666,
1630,
440,
1395,
1263,
7970,
355,
626,
883,
506,
1202,
370,
4339,
27569,
652,
687,
336,
16614,
666,
1928,
3879,
355,
314,
13347,
14,
339,
408,
339,
347,
636,
826,
721,
277,
12,
6535,
29,
17,
14,
16,
12,
5664,
529,
29,
17,
304,
267,
408,
1049,
9181,
8,
4778,
26,
1609,
12,
5664,
529,
26,
442,
9,
398,
6535,
365,
314,
1329,
402,
1245,
5664,
370,
1050,
682,
9181,
370,
12,
267,
19147,
465,
282,
16327,
3382,
378,
14,
16,
436,
413,
14,
16,
14,
221,
5664,
529,
365,
267,
314,
1329,
402,
682,
9181,
5664,
370,
2387,
367,
1924,
1853,
3769,
267,
682,
9181,
379,
14,
221,
20227,
314,
4243,
1050,
1373,
682,
9181,
1853,
370,
4036,
267,
1245,
1853,
14,
221,
4885,
13729,
314,
4243,
12,
1265,
883,
11311,
4212,
267,
14009,
1183,
29870,
652,
4293,
506,
367,
376,
1503,
14895,
695,
370,
267,
11665,
938,
13,
3990,
286,
8085,
314,
1245,
14,
221,
710,
23976,
17323,
365,
19147,
267,
465,
26,
953,
13131,
8,
4166,
529,
12,
1109,
8,
4778,
627,
1329,
13,
1618,
13,
4166,
430,
398,
2104,
325,
482,
402,
4514,
12,
1380,
6535,
665,
413,
14,
16,
12,
1454,
314,
1642,
267,
1109,
8,
4778,
10,
1955,
13,
1618,
13,
4166,
9,
1245,
5664,
787,
682,
9181,
379,
14,
267,
408,
398,
340,
440,
334,
16,
14,
16,
12932,
4778,
12932,
17,
14,
16,
304,
288,
746,
1722,
12,
3546,
4778,
7,
1471,
506,
3382,
378,
14,
16,
436,
413,
14,
16,
2,
267,
340,
5664,
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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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
] |
brijeshkesariya/odoo
|
openerp/addons/base/tests/test_views.py
|
176
|
39717
|
# -*- encoding: utf-8 -*-
from functools import partial
import itertools
import unittest2
from lxml import etree as ET
from lxml.builder import E
from psycopg2 import IntegrityError
from openerp.tests import common
import openerp.tools
Field = E.field
class ViewCase(common.TransactionCase):
def setUp(self):
super(ViewCase, self).setUp()
self.addTypeEqualityFunc(ET._Element, self.assertTreesEqual)
self.Views = self.registry('ir.ui.view')
def browse(self, id, context=None):
return self.Views.browse(self.cr, self.uid, id, context=context)
def create(self, value, context=None):
return self.Views.create(self.cr, self.uid, value, context=context)
def read_combined(self, id):
return self.Views.read_combined(
self.cr, self.uid,
id, ['arch'],
context={'check_view_ids': self.Views.search(self.cr, self.uid, [])}
)
def assertTreesEqual(self, n1, n2, msg=None):
self.assertEqual(n1.tag, n2.tag, msg)
self.assertEqual((n1.text or '').strip(), (n2.text or '').strip(), msg)
self.assertEqual((n1.tail or '').strip(), (n2.tail or '').strip(), msg)
# Because lxml uses ordereddicts in which order is important to
# equality (!?!?!?!)
self.assertEqual(dict(n1.attrib), dict(n2.attrib), msg)
for c1, c2 in itertools.izip_longest(n1, n2):
self.assertEqual(c1, c2, msg)
class TestNodeLocator(common.TransactionCase):
"""
The node locator returns None when it can not find a node, and the first
match when it finds something (no jquery-style node sets)
"""
def setUp(self):
super(TestNodeLocator, self).setUp()
self.Views = self.registry('ir.ui.view')
def test_no_match_xpath(self):
"""
xpath simply uses the provided @expr pattern to find a node
"""
node = self.Views.locate_node(
E.root(E.foo(), E.bar(), E.baz()),
E.xpath(expr="//qux"))
self.assertIsNone(node)
def test_match_xpath(self):
bar = E.bar()
node = self.Views.locate_node(
E.root(E.foo(), bar, E.baz()),
E.xpath(expr="//bar"))
self.assertIs(node, bar)
def test_no_match_field(self):
"""
A field spec will match by @name against all fields of the view
"""
node = self.Views.locate_node(
E.root(E.foo(), E.bar(), E.baz()),
Field(name="qux"))
self.assertIsNone(node)
node = self.Views.locate_node(
E.root(Field(name="foo"), Field(name="bar"), Field(name="baz")),
Field(name="qux"))
self.assertIsNone(node)
def test_match_field(self):
bar = Field(name="bar")
node = self.Views.locate_node(
E.root(Field(name="foo"), bar, Field(name="baz")),
Field(name="bar"))
self.assertIs(node, bar)
def test_no_match_other(self):
"""
Non-xpath non-fields are matched by node name first
"""
node = self.Views.locate_node(
E.root(E.foo(), E.bar(), E.baz()),
E.qux())
self.assertIsNone(node)
def test_match_other(self):
bar = E.bar()
node = self.Views.locate_node(
E.root(E.foo(), bar, E.baz()),
E.bar())
self.assertIs(bar, node)
def test_attribute_mismatch(self):
"""
Non-xpath non-field are filtered by matching attributes on spec and
matched nodes
"""
node = self.Views.locate_node(
E.root(E.foo(attr='1'), E.bar(attr='2'), E.baz(attr='3')),
E.bar(attr='5'))
self.assertIsNone(node)
def test_attribute_filter(self):
match = E.bar(attr='2')
node = self.Views.locate_node(
E.root(E.bar(attr='1'), match, E.root(E.bar(attr='3'))),
E.bar(attr='2'))
self.assertIs(node, match)
def test_version_mismatch(self):
"""
A @version on the spec will be matched against the view's version
"""
node = self.Views.locate_node(
E.root(E.foo(attr='1'), version='4'),
E.foo(attr='1', version='3'))
self.assertIsNone(node)
class TestViewInheritance(ViewCase):
def arch_for(self, name, view_type='form', parent=None):
""" Generates a trivial view of the specified ``view_type``.
The generated view is empty but ``name`` is set as its root's ``@string``.
If ``parent`` is not falsy, generates an extension view (instead of
a root view) replacing the parent's ``@string`` by ``name``
:param str name: ``@string`` value for the view root
:param str view_type:
:param bool parent:
:return: generated arch
:rtype: str
"""
if not parent:
element = E(view_type, string=name)
else:
element = E(view_type,
E.attribute(name, name='string'),
position='attributes'
)
return ET.tostring(element)
def makeView(self, name, parent=None, arch=None):
""" Generates a basic ir.ui.view with the provided name, parent and arch.
If no parent is provided, the view is top-level.
If no arch is provided, generates one by calling :meth:`~.arch_for`.
:param str name:
:param int parent: id of the parent view, if any
:param str arch:
:returns: the created view's id.
:rtype: int
"""
view_id = self.View.create(self.cr, self.uid, {
'model': self.model,
'name': name,
'arch': arch or self.arch_for(name, parent=parent),
'inherit_id': parent,
'priority': 5, # higher than default views
})
self.ids[name] = view_id
return view_id
def setUp(self):
super(TestViewInheritance, self).setUp()
self.model = 'ir.ui.view.custom'
self.View = self.registry('ir.ui.view')
self._init = self.View.pool._init
self.View.pool._init = False
self.ids = {}
a = self.makeView("A")
a1 = self.makeView("A1", a)
a11 = self.makeView("A11", a1)
self.makeView("A111", a11)
self.makeView("A12", a1)
a2 = self.makeView("A2", a)
self.makeView("A21", a2)
a22 = self.makeView("A22", a2)
self.makeView("A221", a22)
b = self.makeView('B', arch=self.arch_for("B", 'tree'))
self.makeView('B1', b, arch=self.arch_for("B1", 'tree', parent=b))
c = self.makeView('C', arch=self.arch_for("C", 'tree'))
self.View.write(self.cr, self.uid, c, {'priority': 1})
def tearDown(self):
self.View.pool._init = self._init
super(TestViewInheritance, self).tearDown()
def test_get_inheriting_views_arch(self):
self.assertEqual(self.View.get_inheriting_views_arch(
self.cr, self.uid, self.ids['A'], self.model), [
(self.arch_for('A1', parent=True), self.ids['A1']),
(self.arch_for('A2', parent=True), self.ids['A2']),
])
self.assertEqual(self.View.get_inheriting_views_arch(
self.cr, self.uid, self.ids['A21'], self.model),
[])
self.assertEqual(self.View.get_inheriting_views_arch(
self.cr, self.uid, self.ids['A11'], self.model),
[(self.arch_for('A111', parent=True), self.ids['A111'])])
def test_default_view(self):
default = self.View.default_view(
self.cr, self.uid, model=self.model, view_type='form')
self.assertEqual(default, self.ids['A'])
default_tree = self.View.default_view(
self.cr, self.uid, model=self.model, view_type='tree')
self.assertEqual(default_tree, self.ids['C'])
def test_no_default_view(self):
self.assertFalse(
self.View.default_view(
self.cr, self.uid, model='does.not.exist', view_type='form'))
self.assertFalse(
self.View.default_view(
self.cr, self.uid, model=self.model, view_type='graph'))
class TestApplyInheritanceSpecs(ViewCase):
""" Applies a sequence of inheritance specification nodes to a base
architecture. IO state parameters (cr, uid, model, context) are used for
error reporting
The base architecture is altered in-place.
"""
def setUp(self):
super(TestApplyInheritanceSpecs, self).setUp()
self.View = self.registry('ir.ui.view')
self.base_arch = E.form(
Field(name="target"),
string="Title")
def test_replace(self):
spec = Field(
Field(name="replacement"),
name="target", position="replace")
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
spec, None)
self.assertEqual(
self.base_arch,
E.form(Field(name="replacement"), string="Title"))
def test_delete(self):
spec = Field(name="target", position="replace")
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
spec, None)
self.assertEqual(
self.base_arch,
E.form(string="Title"))
def test_insert_after(self):
spec = Field(
Field(name="inserted"),
name="target", position="after")
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
spec, None)
self.assertEqual(
self.base_arch,
E.form(
Field(name="target"),
Field(name="inserted"),
string="Title"
))
def test_insert_before(self):
spec = Field(
Field(name="inserted"),
name="target", position="before")
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
spec, None)
self.assertEqual(
self.base_arch,
E.form(
Field(name="inserted"),
Field(name="target"),
string="Title"))
def test_insert_inside(self):
default = Field(Field(name="inserted"), name="target")
spec = Field(Field(name="inserted 2"), name="target", position='inside')
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
default, None)
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
spec, None)
self.assertEqual(
self.base_arch,
E.form(
Field(
Field(name="inserted"),
Field(name="inserted 2"),
name="target"),
string="Title"))
def test_unpack_data(self):
spec = E.data(
Field(Field(name="inserted 0"), name="target"),
Field(Field(name="inserted 1"), name="target"),
Field(Field(name="inserted 2"), name="target"),
Field(Field(name="inserted 3"), name="target"),
)
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
spec, None)
self.assertEqual(
self.base_arch,
E.form(
Field(
Field(name="inserted 0"),
Field(name="inserted 1"),
Field(name="inserted 2"),
Field(name="inserted 3"),
name="target"),
string="Title"))
@openerp.tools.mute_logger('openerp.addons.base.ir.ir_ui_view')
def test_invalid_position(self):
spec = Field(
Field(name="whoops"),
name="target", position="serious_series")
with self.assertRaises(AttributeError):
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
spec, None)
@openerp.tools.mute_logger('openerp.addons.base.ir.ir_ui_view')
def test_incorrect_version(self):
# Version ignored on //field elements, so use something else
arch = E.form(E.element(foo="42"))
spec = E.element(
Field(name="placeholder"),
foo="42", version="7.0")
with self.assertRaises(AttributeError):
self.View.apply_inheritance_specs(self.cr, self.uid,
arch,
spec, None)
@openerp.tools.mute_logger('openerp.addons.base.ir.ir_ui_view')
def test_target_not_found(self):
spec = Field(name="targut")
with self.assertRaises(AttributeError):
self.View.apply_inheritance_specs(self.cr, self.uid,
self.base_arch,
spec, None)
class TestApplyInheritedArchs(ViewCase):
""" Applies a sequence of modificator archs to a base view
"""
class TestNoModel(ViewCase):
def test_create_view_nomodel(self):
View = self.registry('ir.ui.view')
view_id = View.create(self.cr, self.uid, {
'name': 'dummy',
'arch': '<template name="foo"/>',
'inherit_id': False,
'type': 'qweb',
})
fields = ['name', 'arch', 'type', 'priority', 'inherit_id', 'model']
[view] = View.read(self.cr, self.uid, [view_id], fields)
self.assertEqual(view, {
'id': view_id,
'name': 'dummy',
'arch': '<template name="foo"/>',
'type': 'qweb',
'priority': 16,
'inherit_id': False,
'model': False,
})
text_para = E.p("", {'class': 'legalese'})
arch = E.body(
E.div(
E.h1("Title"),
id="header"),
E.p("Welcome!"),
E.div(
E.hr(),
text_para,
id="footer"),
{'class': "index"},)
def test_qweb_translation(self):
"""
Test if translations work correctly without a model
"""
View = self.registry('ir.ui.view')
self.registry('res.lang').load_lang(self.cr, self.uid, 'fr_FR')
orig_text = "Copyright copyrighter"
translated_text = u"Copyrighter, tous droits réservés"
self.text_para.text = orig_text
self.registry('ir.translation').create(self.cr, self.uid, {
'name': 'website',
'type': 'view',
'lang': 'fr_FR',
'src': orig_text,
'value': translated_text,
})
sarch = View.translate_qweb(self.cr, self.uid, None, self.arch, 'fr_FR')
self.text_para.text = translated_text
self.assertEqual(sarch, self.arch)
class TestTemplating(ViewCase):
def setUp(self):
import openerp.modules
super(TestTemplating, self).setUp()
self._pool = openerp.modules.registry.RegistryManager.get(common.get_db_name())
self._init = self._pool._init
# fuck off
self._pool._init = False
def tearDown(self):
self._pool._init = self._init
super(TestTemplating, self).tearDown()
def test_branding_inherit(self):
Views = self.registry('ir.ui.view')
id = Views.create(self.cr, self.uid, {
'name': "Base view",
'type': 'qweb',
'arch': """<root>
<item order="1"/>
</root>
"""
})
id2 = Views.create(self.cr, self.uid, {
'name': "Extension",
'type': 'qweb',
'inherit_id': id,
'arch': """<xpath expr="//item" position="before">
<item order="2"/>
</xpath>
"""
})
arch_string = Views.read_combined(
self.cr, self.uid, id, fields=['arch'],
context={'inherit_branding': True})['arch']
arch = ET.fromstring(arch_string)
Views.distribute_branding(arch)
[initial] = arch.xpath('//item[@order=1]')
self.assertEqual(
str(id),
initial.get('data-oe-id'),
"initial should come from the root view")
self.assertEqual(
'/root[1]/item[1]',
initial.get('data-oe-xpath'),
"initial's xpath should be within the root view only")
[second] = arch.xpath('//item[@order=2]')
self.assertEqual(
str(id2),
second.get('data-oe-id'),
"second should come from the extension view")
def test_branding_distribute_inner(self):
""" Checks that the branding is correctly distributed within a view
extension
"""
Views = self.registry('ir.ui.view')
id = Views.create(self.cr, self.uid, {
'name': "Base view",
'type': 'qweb',
'arch': """<root>
<item order="1"/>
</root>"""
})
id2 = Views.create(self.cr, self.uid, {
'name': "Extension",
'type': 'qweb',
'inherit_id': id,
'arch': """<xpath expr="//item" position="before">
<item order="2">
<content t-att-href="foo">bar</content>
</item>
</xpath>"""
})
arch_string = Views.read_combined(
self.cr, self.uid, id, fields=['arch'],
context={'inherit_branding': True})['arch']
arch = ET.fromstring(arch_string)
Views.distribute_branding(arch)
self.assertEqual(
arch,
E.root(
E.item(
E.content("bar", {
't-att-href': "foo",
'data-oe-model': 'ir.ui.view',
'data-oe-id': str(id2),
'data-oe-field': 'arch',
'data-oe-xpath': '/xpath/item/content[1]',
'data-oe-source-id': str(id)
}), {
'order': '2',
}),
E.item({
'order': '1',
'data-oe-model': 'ir.ui.view',
'data-oe-id': str(id),
'data-oe-field': 'arch',
'data-oe-xpath': '/root[1]/item[1]'
})
)
)
def test_esc_no_branding(self):
Views = self.registry('ir.ui.view')
id = Views.create(self.cr, self.uid, {
'name': "Base View",
'type': 'qweb',
'arch': """<root>
<item><span t-esc="foo"/></item>
</root>""",
})
arch_string = Views.read_combined(
self.cr, self.uid, id, fields=['arch'],
context={'inherit_branding': True})['arch']
arch = ET.fromstring(arch_string)
Views.distribute_branding(arch)
self.assertEqual(arch, E.root(E.item(E.span({'t-esc': "foo"}))))
def test_ignore_unbrand(self):
Views = self.registry('ir.ui.view')
id = Views.create(self.cr, self.uid, {
'name': "Base view",
'type': 'qweb',
'arch': """<root>
<item order="1" t-ignore="true">
<t t-esc="foo"/>
</item>
</root>"""
})
id2 = Views.create(self.cr, self.uid, {
'name': "Extension",
'type': 'qweb',
'inherit_id': id,
'arch': """<xpath expr="//item[@order='1']" position="inside">
<item order="2">
<content t-att-href="foo">bar</content>
</item>
</xpath>"""
})
arch_string = Views.read_combined(
self.cr, self.uid, id, fields=['arch'],
context={'inherit_branding': True})['arch']
arch = ET.fromstring(arch_string)
Views.distribute_branding(arch)
self.assertEqual(
arch,
E.root(
E.item(
{'t-ignore': 'true', 'order': '1'},
E.t({'t-esc': 'foo'}),
E.item(
{'order': '2'},
E.content(
{'t-att-href': 'foo'},
"bar")
)
)
),
"t-ignore should apply to injected sub-view branding, not just to"
" the main view's"
)
class test_views(ViewCase):
def test_nonexistent_attribute_removal(self):
Views = self.registry('ir.ui.view')
Views.create(self.cr, self.uid, {
'name': 'Test View',
'model': 'ir.ui.view',
'inherit_id': self.browse_ref('base.view_view_tree').id,
'arch': """<?xml version="1.0"?>
<xpath expr="//field[@name='name']" position="attributes">
<attribute name="non_existing_attribute"></attribute>
</xpath>
""",
})
def _insert_view(self, **kw):
"""Insert view into database via a query to passtrough validation"""
kw.pop('id', None)
kw.setdefault('mode', 'extension' if kw.get('inherit_id') else 'primary')
kw.setdefault('active', True)
keys = sorted(kw.keys())
fields = ','.join('"%s"' % (k.replace('"', r'\"'),) for k in keys)
params = ','.join('%%(%s)s' % (k,) for k in keys)
query = 'INSERT INTO ir_ui_view(%s) VALUES(%s) RETURNING id' % (fields, params)
self.cr.execute(query, kw)
return self.cr.fetchone()[0]
def test_custom_view_validation(self):
Views = self.registry('ir.ui.view')
model = 'ir.actions.act_url'
validate = partial(Views._validate_custom_views, self.cr, self.uid, model)
# validation of a single view
vid = self._insert_view(
name='base view',
model=model,
priority=1,
arch="""<?xml version="1.0"?>
<tree string="view">
<field name="url"/>
</tree>
""",
)
self.assertTrue(validate()) # single view
# validation of a inherited view
self._insert_view(
name='inherited view',
model=model,
priority=1,
inherit_id=vid,
arch="""<?xml version="1.0"?>
<xpath expr="//field[@name='url']" position="before">
<field name="name"/>
</xpath>
""",
)
self.assertTrue(validate()) # inherited view
# validation of a second inherited view (depending on 1st)
self._insert_view(
name='inherited view 2',
model=model,
priority=5,
inherit_id=vid,
arch="""<?xml version="1.0"?>
<xpath expr="//field[@name='name']" position="after">
<field name="target"/>
</xpath>
""",
)
self.assertTrue(validate()) # inherited view
def test_view_inheritance(self):
Views = self.registry('ir.ui.view')
v1 = Views.create(self.cr, self.uid, {
'name': "bob",
'model': 'ir.ui.view',
'arch': """
<form string="Base title" version="7.0">
<separator string="separator" colspan="4"/>
<footer>
<button name="action_next" type="object" string="Next button"/>
or
<button string="Skip" special="cancel" />
</footer>
</form>
"""
})
v2 = Views.create(self.cr, self.uid, {
'name': "edmund",
'model': 'ir.ui.view',
'inherit_id': v1,
'arch': """
<data>
<form position="attributes" version="7.0">
<attribute name="string">Replacement title</attribute>
</form>
<footer position="replace">
<footer>
<button name="action_next" type="object" string="New button"/>
</footer>
</footer>
<separator string="separator" position="replace">
<p>Replacement data</p>
</separator>
</data>
"""
})
v3 = Views.create(self.cr, self.uid, {
'name': 'jake',
'model': 'ir.ui.view',
'inherit_id': v1,
'priority': 17,
'arch': """
<footer position="attributes">
<attribute name="thing">bob</attribute>
</footer>
"""
})
view = self.registry('ir.ui.view').fields_view_get(
self.cr, self.uid, v2, view_type='form', context={
# fucking what?
'check_view_ids': [v2, v3]
})
self.assertEqual(view['type'], 'form')
self.assertEqual(
ET.fromstring(
view['arch'],
parser=ET.XMLParser(remove_blank_text=True)
),
E.form(
E.p("Replacement data"),
E.footer(
E.button(name="action_next", type="object", string="New button"),
thing="bob"
),
string="Replacement title", version="7.0"))
def test_view_inheritance_divergent_models(self):
Views = self.registry('ir.ui.view')
v1 = Views.create(self.cr, self.uid, {
'name': "bob",
'model': 'ir.ui.view.custom',
'arch': """
<form string="Base title" version="7.0">
<separator string="separator" colspan="4"/>
<footer>
<button name="action_next" type="object" string="Next button"/>
or
<button string="Skip" special="cancel" />
</footer>
</form>
"""
})
v2 = Views.create(self.cr, self.uid, {
'name': "edmund",
'model': 'ir.ui.view',
'inherit_id': v1,
'arch': """
<data>
<form position="attributes" version="7.0">
<attribute name="string">Replacement title</attribute>
</form>
<footer position="replace">
<footer>
<button name="action_next" type="object" string="New button"/>
</footer>
</footer>
<separator string="separator" position="replace">
<p>Replacement data</p>
</separator>
</data>
"""
})
v3 = Views.create(self.cr, self.uid, {
'name': 'jake',
'model': 'ir.ui.menu',
'inherit_id': v1,
'priority': 17,
'arch': """
<footer position="attributes">
<attribute name="thing">bob</attribute>
</footer>
"""
})
view = self.registry('ir.ui.view').fields_view_get(
self.cr, self.uid, v2, view_type='form', context={
# fucking what?
'check_view_ids': [v2, v3]
})
self.assertEqual(view['type'], 'form')
self.assertEqual(
ET.fromstring(
view['arch'],
parser=ET.XMLParser(remove_blank_text=True)
),
E.form(
E.p("Replacement data"),
E.footer(
E.button(name="action_next", type="object", string="New button")),
string="Replacement title", version="7.0"
))
class ViewModeField(ViewCase):
"""
This should probably, eventually, be folded back into other test case
classes, integrating the test (or not) of the mode field to regular cases
"""
def testModeImplicitValue(self):
""" mode is auto-generated from inherit_id:
* inherit_id -> mode=extension
* not inherit_id -> mode=primary
"""
view = self.browse(self.create({
'inherit_id': None,
'arch': '<qweb/>'
}))
self.assertEqual(view.mode, 'primary')
view2 = self.browse(self.create({
'inherit_id': view.id,
'arch': '<qweb/>'
}))
self.assertEqual(view2.mode, 'extension')
@openerp.tools.mute_logger('openerp.sql_db')
def testModeExplicit(self):
view = self.browse(self.create({
'inherit_id': None,
'arch': '<qweb/>'
}))
view2 = self.browse(self.create({
'inherit_id': view.id,
'mode': 'primary',
'arch': '<qweb/>'
}))
self.assertEqual(view.mode, 'primary')
with self.assertRaises(IntegrityError):
self.create({
'inherit_id': None,
'mode': 'extension',
'arch': '<qweb/>'
})
@openerp.tools.mute_logger('openerp.sql_db')
def testPurePrimaryToExtension(self):
"""
A primary view with inherit_id=None can't be converted to extension
"""
view_pure_primary = self.browse(self.create({
'inherit_id': None,
'arch': '<qweb/>'
}))
with self.assertRaises(IntegrityError):
view_pure_primary.write({'mode': 'extension'})
def testInheritPrimaryToExtension(self):
"""
A primary view with an inherit_id can be converted to extension
"""
base = self.create({'inherit_id': None, 'arch': '<qweb/>'})
view = self.browse(self.create({
'inherit_id': base,
'mode': 'primary',
'arch': '<qweb/>'
}))
view.write({'mode': 'extension'})
def testDefaultExtensionToPrimary(self):
"""
An extension view can be converted to primary
"""
base = self.create({'inherit_id': None, 'arch': '<qweb/>'})
view = self.browse(self.create({
'inherit_id': base,
'arch': '<qweb/>'
}))
view.write({'mode': 'primary'})
class TestDefaultView(ViewCase):
def testDefaultViewBase(self):
self.create({
'inherit_id': False,
'priority': 10,
'mode': 'primary',
'arch': '<qweb/>',
})
v2 = self.create({
'inherit_id': False,
'priority': 1,
'mode': 'primary',
'arch': '<qweb/>',
})
default = self.Views.default_view(self.cr, self.uid, False, 'qweb')
self.assertEqual(
default, v2,
"default_view should get the view with the lowest priority for "
"a (model, view_type) pair"
)
def testDefaultViewPrimary(self):
v1 = self.create({
'inherit_id': False,
'priority': 10,
'mode': 'primary',
'arch': '<qweb/>',
})
self.create({
'inherit_id': False,
'priority': 5,
'mode': 'primary',
'arch': '<qweb/>',
})
v3 = self.create({
'inherit_id': v1,
'priority': 1,
'mode': 'primary',
'arch': '<qweb/>',
})
default = self.Views.default_view(self.cr, self.uid, False, 'qweb')
self.assertEqual(
default, v3,
"default_view should get the view with the lowest priority for "
"a (model, view_type) pair in all the primary tables"
)
class TestViewCombined(ViewCase):
"""
* When asked for a view, instead of looking for the closest parent with
inherit_id=False look for mode=primary
* If root.inherit_id, resolve the arch for root.inherit_id (?using which
model?), then apply root's inheritance specs to it
* Apply inheriting views on top
"""
def setUp(self):
super(TestViewCombined, self).setUp()
self.a1 = self.create({
'model': 'a',
'arch': '<qweb><a1/></qweb>'
})
self.a2 = self.create({
'model': 'a',
'inherit_id': self.a1,
'priority': 5,
'arch': '<xpath expr="//a1" position="after"><a2/></xpath>'
})
self.a3 = self.create({
'model': 'a',
'inherit_id': self.a1,
'arch': '<xpath expr="//a1" position="after"><a3/></xpath>'
})
# mode=primary should be an inheritance boundary in both direction,
# even within a model it should not extend the parent
self.a4 = self.create({
'model': 'a',
'inherit_id': self.a1,
'mode': 'primary',
'arch': '<xpath expr="//a1" position="after"><a4/></xpath>',
})
self.b1 = self.create({
'model': 'b',
'inherit_id': self.a3,
'mode': 'primary',
'arch': '<xpath expr="//a1" position="after"><b1/></xpath>'
})
self.b2 = self.create({
'model': 'b',
'inherit_id': self.b1,
'arch': '<xpath expr="//a1" position="after"><b2/></xpath>'
})
self.c1 = self.create({
'model': 'c',
'inherit_id': self.a1,
'mode': 'primary',
'arch': '<xpath expr="//a1" position="after"><c1/></xpath>'
})
self.c2 = self.create({
'model': 'c',
'inherit_id': self.c1,
'priority': 5,
'arch': '<xpath expr="//a1" position="after"><c2/></xpath>'
})
self.c3 = self.create({
'model': 'c',
'inherit_id': self.c2,
'priority': 10,
'arch': '<xpath expr="//a1" position="after"><c3/></xpath>'
})
self.d1 = self.create({
'model': 'd',
'inherit_id': self.b1,
'mode': 'primary',
'arch': '<xpath expr="//a1" position="after"><d1/></xpath>'
})
def test_basic_read(self):
arch = self.read_combined(self.a1)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.a1(),
E.a3(),
E.a2(),
), arch)
def test_read_from_child(self):
arch = self.read_combined(self.a3)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.a1(),
E.a3(),
E.a2(),
), arch)
def test_read_from_child_primary(self):
arch = self.read_combined(self.a4)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.a1(),
E.a4(),
E.a3(),
E.a2(),
), arch)
def test_cross_model_simple(self):
arch = self.read_combined(self.c2)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.a1(),
E.c3(),
E.c2(),
E.c1(),
E.a3(),
E.a2(),
), arch)
def test_cross_model_double(self):
arch = self.read_combined(self.d1)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.a1(),
E.d1(),
E.b2(),
E.b1(),
E.a3(),
E.a2(),
), arch)
class TestOptionalViews(ViewCase):
"""
Tests ability to enable/disable inherited views, formerly known as
inherit_option_id
"""
def setUp(self):
super(TestOptionalViews, self).setUp()
self.v0 = self.create({
'model': 'a',
'arch': '<qweb><base/></qweb>',
})
self.v1 = self.create({
'model': 'a',
'inherit_id': self.v0,
'active': True,
'priority': 10,
'arch': '<xpath expr="//base" position="after"><v1/></xpath>',
})
self.v2 = self.create({
'model': 'a',
'inherit_id': self.v0,
'active': True,
'priority': 9,
'arch': '<xpath expr="//base" position="after"><v2/></xpath>',
})
self.v3 = self.create({
'model': 'a',
'inherit_id': self.v0,
'active': False,
'priority': 8,
'arch': '<xpath expr="//base" position="after"><v3/></xpath>'
})
def test_applied(self):
""" mandatory and enabled views should be applied
"""
arch = self.read_combined(self.v0)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.base(),
E.v1(),
E.v2(),
)
)
def test_applied_state_toggle(self):
""" Change active states of v2 and v3, check that the results
are as expected
"""
self.browse(self.v2).toggle()
arch = self.read_combined(self.v0)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.base(),
E.v1(),
)
)
self.browse(self.v3).toggle()
arch = self.read_combined(self.v0)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.base(),
E.v1(),
E.v3(),
)
)
self.browse(self.v2).toggle()
arch = self.read_combined(self.v0)['arch']
self.assertEqual(
ET.fromstring(arch),
E.qweb(
E.base(),
E.v1(),
E.v2(),
E.v3(),
)
)
class TestXPathExtentions(common.BaseCase):
def test_hasclass(self):
tree = E.node(
E.node({'class': 'foo bar baz'}),
E.node({'class': 'foo bar'}),
{'class': "foo"})
self.assertEqual(
len(tree.xpath('//node[hasclass("foo")]')),
3)
self.assertEqual(
len(tree.xpath('//node[hasclass("bar")]')),
2)
self.assertEqual(
len(tree.xpath('//node[hasclass("baz")]')),
1)
self.assertEqual(
len(tree.xpath('//node[hasclass("foo")][not(hasclass("bar"))]')),
1)
self.assertEqual(
len(tree.xpath('//node[hasclass("foo", "baz")]')),
1)
|
agpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
9143,
492,
7417,
199,
646,
7975,
199,
199,
646,
2882,
18,
199,
199,
504,
14490,
492,
7559,
465,
12265,
199,
504,
14490,
14,
5649,
492,
662,
199,
199,
504,
15492,
18,
492,
26864,
199,
199,
504,
5166,
14,
2219,
492,
2863,
199,
646,
5166,
14,
2537,
199,
199,
792,
275,
662,
14,
698,
199,
199,
533,
10935,
1538,
8,
2330,
14,
10161,
1538,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
2768,
1538,
12,
291,
680,
5996,
342,
267,
291,
14,
525,
804,
22977,
7465,
8,
775,
423,
2162,
12,
291,
14,
479,
28785,
591,
9,
267,
291,
14,
21180,
275,
291,
14,
5189,
360,
723,
14,
1907,
14,
1345,
358,
339,
347,
19249,
8,
277,
12,
1305,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
21180,
14,
4570,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
1305,
12,
1067,
29,
1100,
9,
272,
347,
1218,
8,
277,
12,
574,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
21180,
14,
981,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
574,
12,
1067,
29,
1100,
9,
339,
347,
1586,
63,
17583,
8,
277,
12,
1305,
304,
267,
372,
291,
14,
21180,
14,
739,
63,
17583,
8,
288,
291,
14,
1556,
12,
291,
14,
1535,
12,
288,
1305,
12,
788,
1047,
995,
288,
1067,
3713,
1074,
63,
1345,
63,
1580,
356,
291,
14,
21180,
14,
1733,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
3073,
93,
267,
776,
339,
347,
702,
28785,
591,
8,
277,
12,
302,
17,
12,
302,
18,
12,
1499,
29,
403,
304,
267,
291,
14,
629,
8,
78,
17,
14,
1450,
12,
302,
18,
14,
1450,
12,
1499,
9,
267,
291,
14,
629,
1332,
78,
17,
14,
505,
503,
12548,
1913,
1062,
334,
78,
18,
14,
505,
503,
12548,
1913,
1062,
1499,
9,
267,
291,
14,
629,
1332,
78,
17,
14,
1521,
503,
12548,
1913,
1062,
334,
78,
18,
14,
1521,
503,
12548,
1913,
1062,
1499,
9,
398,
327,
13821,
14490,
4440,
7741,
7892,
315,
1314,
1865,
365,
11012,
370,
267,
327,
16612,
19452,
31,
1,
31,
1,
31,
21866,
267,
291,
14,
629,
8,
807,
8,
78,
17,
14,
6640,
395,
1211,
8,
78,
18,
14,
6640,
395,
1499,
9,
398,
367,
286,
17,
12,
286,
18,
315,
7975,
14,
565,
711,
63,
20820,
8,
78,
17,
12,
302,
18,
304,
288,
291,
14,
629,
8,
67,
17,
12,
286,
18,
12,
1499,
9,
421,
199,
533,
1379,
1716,
10725,
8,
2330,
14,
10161,
1538,
304,
272,
408,
272,
710,
1031,
14067,
2529,
488,
1380,
652,
883,
440,
2342,
282,
1031,
12,
436,
314,
1642,
272,
1336,
1380,
652,
17651,
6020,
334,
889,
1335,
1131,
13,
2487,
1031,
5951,
9,
272,
408,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
1716,
10725,
12,
291,
680,
5996,
342,
267,
291,
14,
21180,
275,
291,
14,
5189,
360,
723,
14,
1907,
14,
1345,
358,
339,
347,
511,
63,
889,
63,
1431,
63,
8006,
8,
277,
304,
267,
408,
267,
14462,
9329,
4440,
314,
2741,
768,
3684,
3851,
370,
2342,
282,
1031,
267,
408,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
662,
14,
1700,
1062,
662,
14,
6185,
4000,
288,
662,
14,
8006,
8,
3684,
628,
501,
27519,
2237,
267,
291,
14,
7702,
8,
932,
9,
339,
347,
511,
63,
1431,
63,
8006,
8,
277,
304,
267,
4681,
275,
662,
14,
1700,
342,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
4681,
12,
662,
14,
6185,
4000,
288,
662,
14,
8006,
8,
3684,
628,
501,
1700,
2237,
267,
291,
14,
3436,
8,
932,
12,
4681,
9,
2378,
347,
511,
63,
889,
63,
1431,
63,
698,
8,
277,
304,
267,
408,
267,
437,
901,
3158,
911,
1336,
701,
768,
354,
6169,
1006,
1504,
402,
314,
2455,
267,
408,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
662,
14,
1700,
1062,
662,
14,
6185,
4000,
288,
5024,
8,
354,
628,
27519,
2237,
267,
291,
14,
7702,
8,
932,
9,
398,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
792,
8,
354,
628,
1421,
1288,
5024,
8,
354,
628,
1700,
1288,
5024,
8,
354,
628,
6185,
8150,
288,
5024,
8,
354,
628,
27519,
2237,
267,
291,
14,
7702,
8,
932,
9,
339,
347,
511,
63,
1431,
63,
698,
8,
277,
304,
267,
4681,
275,
5024,
8,
354,
628,
1700,
531,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
792,
8,
354,
628,
1421,
1288,
4681,
12,
5024,
8,
354,
628,
6185,
8150,
288,
5024,
8,
354,
628,
1700,
2237,
267,
291,
14,
3436,
8,
932,
12,
4681,
9,
2378,
347,
511,
63,
889,
63,
1431,
63,
1848,
8,
277,
304,
267,
408,
267,
10172,
13,
8006,
2222,
13,
955,
787,
7838,
701,
1031,
536,
1642,
267,
408,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
662,
14,
1700,
1062,
662,
14,
6185,
4000,
288,
662,
14,
27519,
1012,
267,
291,
14,
7702,
8,
932,
9,
339,
347,
511,
63,
1431,
63,
1848,
8,
277,
304,
267,
4681,
275,
662,
14,
1700,
342,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
4681,
12,
662,
14,
6185,
4000,
288,
662,
14,
1700,
1012,
267,
291,
14,
3436,
8,
1700,
12,
1031,
9,
339,
347,
511,
63,
3215,
63,
20759,
8,
277,
304,
267,
408,
267,
10172,
13,
8006,
2222,
13,
698,
787,
9806,
701,
4877,
3004,
641,
3158,
436,
267,
7838,
3380,
267,
408,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
8,
962,
534,
17,
659,
662,
14,
1700,
8,
962,
534,
18,
659,
662,
14,
6185,
8,
962,
534,
19,
3855,
288,
662,
14,
1700,
8,
962,
534,
21,
1333,
267
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
9143,
492,
7417,
199,
646,
7975,
199,
199,
646,
2882,
18,
199,
199,
504,
14490,
492,
7559,
465,
12265,
199,
504,
14490,
14,
5649,
492,
662,
199,
199,
504,
15492,
18,
492,
26864,
199,
199,
504,
5166,
14,
2219,
492,
2863,
199,
646,
5166,
14,
2537,
199,
199,
792,
275,
662,
14,
698,
199,
199,
533,
10935,
1538,
8,
2330,
14,
10161,
1538,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
2768,
1538,
12,
291,
680,
5996,
342,
267,
291,
14,
525,
804,
22977,
7465,
8,
775,
423,
2162,
12,
291,
14,
479,
28785,
591,
9,
267,
291,
14,
21180,
275,
291,
14,
5189,
360,
723,
14,
1907,
14,
1345,
358,
339,
347,
19249,
8,
277,
12,
1305,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
21180,
14,
4570,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
1305,
12,
1067,
29,
1100,
9,
272,
347,
1218,
8,
277,
12,
574,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
21180,
14,
981,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
574,
12,
1067,
29,
1100,
9,
339,
347,
1586,
63,
17583,
8,
277,
12,
1305,
304,
267,
372,
291,
14,
21180,
14,
739,
63,
17583,
8,
288,
291,
14,
1556,
12,
291,
14,
1535,
12,
288,
1305,
12,
788,
1047,
995,
288,
1067,
3713,
1074,
63,
1345,
63,
1580,
356,
291,
14,
21180,
14,
1733,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
3073,
93,
267,
776,
339,
347,
702,
28785,
591,
8,
277,
12,
302,
17,
12,
302,
18,
12,
1499,
29,
403,
304,
267,
291,
14,
629,
8,
78,
17,
14,
1450,
12,
302,
18,
14,
1450,
12,
1499,
9,
267,
291,
14,
629,
1332,
78,
17,
14,
505,
503,
12548,
1913,
1062,
334,
78,
18,
14,
505,
503,
12548,
1913,
1062,
1499,
9,
267,
291,
14,
629,
1332,
78,
17,
14,
1521,
503,
12548,
1913,
1062,
334,
78,
18,
14,
1521,
503,
12548,
1913,
1062,
1499,
9,
398,
327,
13821,
14490,
4440,
7741,
7892,
315,
1314,
1865,
365,
11012,
370,
267,
327,
16612,
19452,
31,
1,
31,
1,
31,
21866,
267,
291,
14,
629,
8,
807,
8,
78,
17,
14,
6640,
395,
1211,
8,
78,
18,
14,
6640,
395,
1499,
9,
398,
367,
286,
17,
12,
286,
18,
315,
7975,
14,
565,
711,
63,
20820,
8,
78,
17,
12,
302,
18,
304,
288,
291,
14,
629,
8,
67,
17,
12,
286,
18,
12,
1499,
9,
421,
199,
533,
1379,
1716,
10725,
8,
2330,
14,
10161,
1538,
304,
272,
408,
272,
710,
1031,
14067,
2529,
488,
1380,
652,
883,
440,
2342,
282,
1031,
12,
436,
314,
1642,
272,
1336,
1380,
652,
17651,
6020,
334,
889,
1335,
1131,
13,
2487,
1031,
5951,
9,
272,
408,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
1716,
10725,
12,
291,
680,
5996,
342,
267,
291,
14,
21180,
275,
291,
14,
5189,
360,
723,
14,
1907,
14,
1345,
358,
339,
347,
511,
63,
889,
63,
1431,
63,
8006,
8,
277,
304,
267,
408,
267,
14462,
9329,
4440,
314,
2741,
768,
3684,
3851,
370,
2342,
282,
1031,
267,
408,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
662,
14,
1700,
1062,
662,
14,
6185,
4000,
288,
662,
14,
8006,
8,
3684,
628,
501,
27519,
2237,
267,
291,
14,
7702,
8,
932,
9,
339,
347,
511,
63,
1431,
63,
8006,
8,
277,
304,
267,
4681,
275,
662,
14,
1700,
342,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
4681,
12,
662,
14,
6185,
4000,
288,
662,
14,
8006,
8,
3684,
628,
501,
1700,
2237,
267,
291,
14,
3436,
8,
932,
12,
4681,
9,
2378,
347,
511,
63,
889,
63,
1431,
63,
698,
8,
277,
304,
267,
408,
267,
437,
901,
3158,
911,
1336,
701,
768,
354,
6169,
1006,
1504,
402,
314,
2455,
267,
408,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
662,
14,
1700,
1062,
662,
14,
6185,
4000,
288,
5024,
8,
354,
628,
27519,
2237,
267,
291,
14,
7702,
8,
932,
9,
398,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
792,
8,
354,
628,
1421,
1288,
5024,
8,
354,
628,
1700,
1288,
5024,
8,
354,
628,
6185,
8150,
288,
5024,
8,
354,
628,
27519,
2237,
267,
291,
14,
7702,
8,
932,
9,
339,
347,
511,
63,
1431,
63,
698,
8,
277,
304,
267,
4681,
275,
5024,
8,
354,
628,
1700,
531,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
792,
8,
354,
628,
1421,
1288,
4681,
12,
5024,
8,
354,
628,
6185,
8150,
288,
5024,
8,
354,
628,
1700,
2237,
267,
291,
14,
3436,
8,
932,
12,
4681,
9,
2378,
347,
511,
63,
889,
63,
1431,
63,
1848,
8,
277,
304,
267,
408,
267,
10172,
13,
8006,
2222,
13,
955,
787,
7838,
701,
1031,
536,
1642,
267,
408,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
662,
14,
1700,
1062,
662,
14,
6185,
4000,
288,
662,
14,
27519,
1012,
267,
291,
14,
7702,
8,
932,
9,
339,
347,
511,
63,
1431,
63,
1848,
8,
277,
304,
267,
4681,
275,
662,
14,
1700,
342,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
1062,
4681,
12,
662,
14,
6185,
4000,
288,
662,
14,
1700,
1012,
267,
291,
14,
3436,
8,
1700,
12,
1031,
9,
339,
347,
511,
63,
3215,
63,
20759,
8,
277,
304,
267,
408,
267,
10172,
13,
8006,
2222,
13,
698,
787,
9806,
701,
4877,
3004,
641,
3158,
436,
267,
7838,
3380,
267,
408,
267,
1031,
275,
291,
14,
21180,
14,
6280,
63,
932,
8,
288,
662,
14,
1231,
8,
37,
14,
1421,
8,
962,
534,
17,
659,
662,
14,
1700,
8,
962,
534,
18,
659,
662,
14,
6185,
8,
962,
534,
19,
3855,
288,
662,
14,
1700,
8,
962,
534,
21,
1333,
267,
0
] |
[
1,
1,
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Liu/animated-broccoli
|
nova/objects/dns_domain.py
|
29
|
2606
|
# Copyright (C) 2014, Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from nova import db
from nova import objects
from nova.objects import base
from nova.objects import fields
# TODO(berrange): Remove NovaObjectDictCompat
@base.NovaObjectRegistry.register
class DNSDomain(base.NovaPersistentObject, base.NovaObject,
base.NovaObjectDictCompat):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
'domain': fields.StringField(),
'scope': fields.StringField(nullable=True),
'availability_zone': fields.StringField(nullable=True),
'project_id': fields.StringField(nullable=True),
}
@staticmethod
def _from_db_object(context, vif, db_vif):
for field in vif.fields:
vif[field] = db_vif[field]
vif._context = context
vif.obj_reset_changes()
return vif
@base.remotable_classmethod
def get_by_domain(cls, context, domain):
db_dnsd = db.dnsdomain_get(context, domain)
if db_dnsd:
return cls._from_db_object(context, cls(), db_dnsd)
@base.remotable_classmethod
def register_for_zone(cls, context, domain, zone):
db.dnsdomain_register_for_zone(context, domain, zone)
@base.remotable_classmethod
def register_for_project(cls, context, domain, project):
db.dnsdomain_register_for_project(context, domain, project)
@base.remotable_classmethod
def delete_by_domain(cls, context, domain):
db.dnsdomain_unregister(context, domain)
@base.NovaObjectRegistry.register
class DNSDomainList(base.ObjectListBase, base.NovaObject):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
'objects': fields.ListOfObjectsField('DNSDomain'),
}
obj_relationships = {
'objects': [('1.0', '1.0')],
}
@base.remotable_classmethod
def get_all(cls, context):
db_domains = db.dnsdomain_get_all(context)
return base.obj_make_list(context, cls(context), objects.DNSDomain,
db_domains)
|
apache-2.0
|
[
3,
1898,
334,
35,
9,
6927,
12,
9572,
13002,
12,
3277,
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,
5913,
492,
1592,
199,
504,
5913,
492,
2251,
199,
504,
5913,
14,
1462,
492,
1300,
199,
504,
5913,
14,
1462,
492,
1504,
421,
199,
3,
3254,
8,
605,
1842,
304,
5852,
28184,
1692,
2141,
2404,
292,
199,
32,
1095,
14,
19884,
1692,
10899,
14,
2683,
199,
533,
10237,
7705,
8,
1095,
14,
19884,
31966,
1692,
12,
1300,
14,
19884,
1692,
12,
355,
1300,
14,
19884,
1692,
2141,
2404,
292,
304,
272,
327,
3394,
413,
14,
16,
26,
6026,
1015,
272,
15945,
275,
283,
17,
14,
16,
7,
339,
1504,
275,
469,
267,
283,
2261,
356,
1504,
14,
14912,
1062,
267,
283,
2645,
356,
1504,
14,
14912,
8,
16375,
29,
549,
395,
267,
283,
11856,
63,
2619,
356,
1504,
14,
14912,
8,
16375,
29,
549,
395,
267,
283,
1715,
63,
344,
356,
1504,
14,
14912,
8,
16375,
29,
549,
395,
272,
789,
339,
768,
4639,
272,
347,
485,
504,
63,
697,
63,
785,
8,
1100,
12,
15205,
12,
1592,
63,
14430,
304,
267,
367,
901,
315,
15205,
14,
955,
26,
288,
15205,
59,
698,
61,
275,
1592,
63,
14430,
59,
698,
61,
267,
15205,
423,
1100,
275,
1067,
267,
15205,
14,
1113,
63,
3958,
63,
6627,
342,
267,
372,
15205,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
664,
63,
991,
63,
2261,
8,
1886,
12,
1067,
12,
2881,
304,
267,
1592,
63,
5797,
68,
275,
1592,
14,
5797,
2261,
63,
362,
8,
1100,
12,
2881,
9,
267,
340,
1592,
63,
5797,
68,
26,
288,
372,
843,
423,
504,
63,
697,
63,
785,
8,
1100,
12,
843,
1062,
1592,
63,
5797,
68,
9,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
2274,
63,
509,
63,
2619,
8,
1886,
12,
1067,
12,
2881,
12,
5718,
304,
267,
1592,
14,
5797,
2261,
63,
2683,
63,
509,
63,
2619,
8,
1100,
12,
2881,
12,
5718,
9,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
2274,
63,
509,
63,
1715,
8,
1886,
12,
1067,
12,
2881,
12,
2199,
304,
267,
1592,
14,
5797,
2261,
63,
2683,
63,
509,
63,
1715,
8,
1100,
12,
2881,
12,
2199,
9,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
3145,
63,
991,
63,
2261,
8,
1886,
12,
1067,
12,
2881,
304,
267,
1592,
14,
5797,
2261,
63,
18408,
8,
1100,
12,
2881,
9,
421,
199,
32,
1095,
14,
19884,
1692,
10899,
14,
2683,
199,
533,
10237,
7705,
1296,
8,
1095,
14,
1692,
1296,
1563,
12,
1300,
14,
19884,
1692,
304,
272,
327,
3394,
413,
14,
16,
26,
6026,
1015,
272,
15945,
275,
283,
17,
14,
16,
7,
272,
1504,
275,
469,
267,
283,
1462,
356,
1504,
14,
30210,
11188,
792,
360,
12323,
7705,
659,
272,
789,
272,
1559,
63,
24034,
275,
469,
267,
283,
1462,
356,
4274,
17,
14,
16,
297,
283,
17,
14,
16,
2665,
272,
789,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
664,
63,
452,
8,
1886,
12,
1067,
304,
267,
1592,
63,
9756,
275,
1592,
14,
5797,
2261,
63,
362,
63,
452,
8,
1100,
9,
267,
372,
1300,
14,
1113,
63,
1875,
63,
513,
8,
1100,
12,
843,
8,
1100,
395,
2251,
14,
12323,
7705,
12,
3303,
1592,
63,
9756,
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
] |
[
1898,
334,
35,
9,
6927,
12,
9572,
13002,
12,
3277,
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,
5913,
492,
1592,
199,
504,
5913,
492,
2251,
199,
504,
5913,
14,
1462,
492,
1300,
199,
504,
5913,
14,
1462,
492,
1504,
421,
199,
3,
3254,
8,
605,
1842,
304,
5852,
28184,
1692,
2141,
2404,
292,
199,
32,
1095,
14,
19884,
1692,
10899,
14,
2683,
199,
533,
10237,
7705,
8,
1095,
14,
19884,
31966,
1692,
12,
1300,
14,
19884,
1692,
12,
355,
1300,
14,
19884,
1692,
2141,
2404,
292,
304,
272,
327,
3394,
413,
14,
16,
26,
6026,
1015,
272,
15945,
275,
283,
17,
14,
16,
7,
339,
1504,
275,
469,
267,
283,
2261,
356,
1504,
14,
14912,
1062,
267,
283,
2645,
356,
1504,
14,
14912,
8,
16375,
29,
549,
395,
267,
283,
11856,
63,
2619,
356,
1504,
14,
14912,
8,
16375,
29,
549,
395,
267,
283,
1715,
63,
344,
356,
1504,
14,
14912,
8,
16375,
29,
549,
395,
272,
789,
339,
768,
4639,
272,
347,
485,
504,
63,
697,
63,
785,
8,
1100,
12,
15205,
12,
1592,
63,
14430,
304,
267,
367,
901,
315,
15205,
14,
955,
26,
288,
15205,
59,
698,
61,
275,
1592,
63,
14430,
59,
698,
61,
267,
15205,
423,
1100,
275,
1067,
267,
15205,
14,
1113,
63,
3958,
63,
6627,
342,
267,
372,
15205,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
664,
63,
991,
63,
2261,
8,
1886,
12,
1067,
12,
2881,
304,
267,
1592,
63,
5797,
68,
275,
1592,
14,
5797,
2261,
63,
362,
8,
1100,
12,
2881,
9,
267,
340,
1592,
63,
5797,
68,
26,
288,
372,
843,
423,
504,
63,
697,
63,
785,
8,
1100,
12,
843,
1062,
1592,
63,
5797,
68,
9,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
2274,
63,
509,
63,
2619,
8,
1886,
12,
1067,
12,
2881,
12,
5718,
304,
267,
1592,
14,
5797,
2261,
63,
2683,
63,
509,
63,
2619,
8,
1100,
12,
2881,
12,
5718,
9,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
2274,
63,
509,
63,
1715,
8,
1886,
12,
1067,
12,
2881,
12,
2199,
304,
267,
1592,
14,
5797,
2261,
63,
2683,
63,
509,
63,
1715,
8,
1100,
12,
2881,
12,
2199,
9,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
3145,
63,
991,
63,
2261,
8,
1886,
12,
1067,
12,
2881,
304,
267,
1592,
14,
5797,
2261,
63,
18408,
8,
1100,
12,
2881,
9,
421,
199,
32,
1095,
14,
19884,
1692,
10899,
14,
2683,
199,
533,
10237,
7705,
1296,
8,
1095,
14,
1692,
1296,
1563,
12,
1300,
14,
19884,
1692,
304,
272,
327,
3394,
413,
14,
16,
26,
6026,
1015,
272,
15945,
275,
283,
17,
14,
16,
7,
272,
1504,
275,
469,
267,
283,
1462,
356,
1504,
14,
30210,
11188,
792,
360,
12323,
7705,
659,
272,
789,
272,
1559,
63,
24034,
275,
469,
267,
283,
1462,
356,
4274,
17,
14,
16,
297,
283,
17,
14,
16,
2665,
272,
789,
339,
768,
1095,
14,
13179,
357,
461,
63,
3744,
272,
347,
664,
63,
452,
8,
1886,
12,
1067,
304,
267,
1592,
63,
9756,
275,
1592,
14,
5797,
2261,
63,
362,
63,
452,
8,
1100,
9,
267,
372,
1300,
14,
1113,
63,
1875,
63,
513,
8,
1100,
12,
843,
8,
1100,
395,
2251,
14,
12323,
7705,
12,
3303,
1592,
63,
9756,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
boooka/GeoPowerOff
|
venv/lib/python2.7/site-packages/pip/_vendor/distlib/database.py
|
360
|
49138
|
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2013 The Python Software Foundation.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
"""PEP 376 implementation."""
from __future__ import unicode_literals
import base64
import codecs
import contextlib
import hashlib
import logging
import os
import posixpath
import sys
import zipimport
from . import DistlibException, resources
from .compat import StringIO
from .version import get_scheme, UnsupportedVersionError
from .metadata import Metadata, METADATA_FILENAME
from .util import (parse_requirement, cached_property, parse_name_and_version,
read_exports, write_exports, CSVReader, CSVWriter)
__all__ = ['Distribution', 'BaseInstalledDistribution',
'InstalledDistribution', 'EggInfoDistribution',
'DistributionPath']
logger = logging.getLogger(__name__)
EXPORTS_FILENAME = 'pydist-exports.json'
COMMANDS_FILENAME = 'pydist-commands.json'
DIST_FILES = ('INSTALLER', METADATA_FILENAME, 'RECORD', 'REQUESTED',
'RESOURCES', EXPORTS_FILENAME, 'SHARED')
DISTINFO_EXT = '.dist-info'
class _Cache(object):
"""
A simple cache mapping names and .dist-info paths to distributions
"""
def __init__(self):
"""
Initialise an instance. There is normally one for each DistributionPath.
"""
self.name = {}
self.path = {}
self.generated = False
def clear(self):
"""
Clear the cache, setting it to its initial state.
"""
self.name.clear()
self.path.clear()
self.generated = False
def add(self, dist):
"""
Add a distribution to the cache.
:param dist: The distribution to add.
"""
if dist.path not in self.path:
self.path[dist.path] = dist
self.name.setdefault(dist.key, []).append(dist)
class DistributionPath(object):
"""
Represents a set of distributions installed on a path (typically sys.path).
"""
def __init__(self, path=None, include_egg=False):
"""
Create an instance from a path, optionally including legacy (distutils/
setuptools/distribute) distributions.
:param path: The path to use, as a list of directories. If not specified,
sys.path is used.
:param include_egg: If True, this instance will look for and return legacy
distributions as well as those based on PEP 376.
"""
if path is None:
path = sys.path
self.path = path
self._include_dist = True
self._include_egg = include_egg
self._cache = _Cache()
self._cache_egg = _Cache()
self._cache_enabled = True
self._scheme = get_scheme('default')
def _get_cache_enabled(self):
return self._cache_enabled
def _set_cache_enabled(self, value):
self._cache_enabled = value
cache_enabled = property(_get_cache_enabled, _set_cache_enabled)
def clear_cache(self):
"""
Clears the internal cache.
"""
self._cache.clear()
self._cache_egg.clear()
def _yield_distributions(self):
"""
Yield .dist-info and/or .egg(-info) distributions.
"""
# We need to check if we've seen some resources already, because on
# some Linux systems (e.g. some Debian/Ubuntu variants) there are
# symlinks which alias other files in the environment.
seen = set()
for path in self.path:
finder = resources.finder_for_path(path)
if finder is None:
continue
r = finder.find('')
if not r or not r.is_container:
continue
rset = sorted(r.resources)
for entry in rset:
r = finder.find(entry)
if not r or r.path in seen:
continue
if self._include_dist and entry.endswith(DISTINFO_EXT):
metadata_path = posixpath.join(entry, METADATA_FILENAME)
pydist = finder.find(metadata_path)
if not pydist:
continue
metadata = Metadata(fileobj=pydist.as_stream(),
scheme='legacy')
logger.debug('Found %s', r.path)
seen.add(r.path)
yield new_dist_class(r.path, metadata=metadata,
env=self)
elif self._include_egg and entry.endswith(('.egg-info',
'.egg')):
logger.debug('Found %s', r.path)
seen.add(r.path)
yield old_dist_class(r.path, self)
def _generate_cache(self):
"""
Scan the path for distributions and populate the cache with
those that are found.
"""
gen_dist = not self._cache.generated
gen_egg = self._include_egg and not self._cache_egg.generated
if gen_dist or gen_egg:
for dist in self._yield_distributions():
if isinstance(dist, InstalledDistribution):
self._cache.add(dist)
else:
self._cache_egg.add(dist)
if gen_dist:
self._cache.generated = True
if gen_egg:
self._cache_egg.generated = True
@classmethod
def distinfo_dirname(cls, name, version):
"""
The *name* and *version* parameters are converted into their
filename-escaped form, i.e. any ``'-'`` characters are replaced
with ``'_'`` other than the one in ``'dist-info'`` and the one
separating the name from the version number.
:parameter name: is converted to a standard distribution name by replacing
any runs of non- alphanumeric characters with a single
``'-'``.
:type name: string
:parameter version: is converted to a standard version string. Spaces
become dots, and all other non-alphanumeric characters
(except dots) become dashes, with runs of multiple
dashes condensed to a single dash.
:type version: string
:returns: directory name
:rtype: string"""
name = name.replace('-', '_')
return '-'.join([name, version]) + DISTINFO_EXT
def get_distributions(self):
"""
Provides an iterator that looks for distributions and returns
:class:`InstalledDistribution` or
:class:`EggInfoDistribution` instances for each one of them.
:rtype: iterator of :class:`InstalledDistribution` and
:class:`EggInfoDistribution` instances
"""
if not self._cache_enabled:
for dist in self._yield_distributions():
yield dist
else:
self._generate_cache()
for dist in self._cache.path.values():
yield dist
if self._include_egg:
for dist in self._cache_egg.path.values():
yield dist
def get_distribution(self, name):
"""
Looks for a named distribution on the path.
This function only returns the first result found, as no more than one
value is expected. If nothing is found, ``None`` is returned.
:rtype: :class:`InstalledDistribution`, :class:`EggInfoDistribution`
or ``None``
"""
result = None
name = name.lower()
if not self._cache_enabled:
for dist in self._yield_distributions():
if dist.key == name:
result = dist
break
else:
self._generate_cache()
if name in self._cache.name:
result = self._cache.name[name][0]
elif self._include_egg and name in self._cache_egg.name:
result = self._cache_egg.name[name][0]
return result
def provides_distribution(self, name, version=None):
"""
Iterates over all distributions to find which distributions provide *name*.
If a *version* is provided, it will be used to filter the results.
This function only returns the first result found, since no more than
one values are expected. If the directory is not found, returns ``None``.
:parameter version: a version specifier that indicates the version
required, conforming to the format in ``PEP-345``
:type name: string
:type version: string
"""
matcher = None
if not version is None:
try:
matcher = self._scheme.matcher('%s (%s)' % (name, version))
except ValueError:
raise DistlibException('invalid name or version: %r, %r' %
(name, version))
for dist in self.get_distributions():
provided = dist.provides
for p in provided:
p_name, p_ver = parse_name_and_version(p)
if matcher is None:
if p_name == name:
yield dist
break
else:
if p_name == name and matcher.match(p_ver):
yield dist
break
def get_file_path(self, name, relative_path):
"""
Return the path to a resource file.
"""
dist = self.get_distribution(name)
if dist is None:
raise LookupError('no distribution named %r found' % name)
return dist.get_resource_path(relative_path)
def get_exported_entries(self, category, name=None):
"""
Return all of the exported entries in a particular category.
:param category: The category to search for entries.
:param name: If specified, only entries with that name are returned.
"""
for dist in self.get_distributions():
r = dist.exports
if category in r:
d = r[category]
if name is not None:
if name in d:
yield d[name]
else:
for v in d.values():
yield v
class Distribution(object):
"""
A base class for distributions, whether installed or from indexes.
Either way, it must have some metadata, so that's all that's needed
for construction.
"""
build_time_dependency = False
"""
Set to True if it's known to be only a build-time dependency (i.e.
not needed after installation).
"""
requested = False
"""A boolean that indicates whether the ``REQUESTED`` metadata file is
present (in other words, whether the package was installed by user
request or it was installed as a dependency)."""
def __init__(self, metadata):
"""
Initialise an instance.
:param metadata: The instance of :class:`Metadata` describing this
distribution.
"""
self.metadata = metadata
self.name = metadata.name
self.key = self.name.lower() # for case-insensitive comparisons
self.version = metadata.version
self.locator = None
self.digest = None
self.extras = None # additional features requested
self.context = None # environment marker overrides
@property
def source_url(self):
"""
The source archive download URL for this distribution.
"""
return self.metadata.source_url
download_url = source_url # Backward compatibility
@property
def name_and_version(self):
"""
A utility property which displays the name and version in parentheses.
"""
return '%s (%s)' % (self.name, self.version)
@property
def provides(self):
"""
A set of distribution names and versions provided by this distribution.
:return: A set of "name (version)" strings.
"""
plist = self.metadata.provides
s = '%s (%s)' % (self.name, self.version)
if s not in plist:
plist.append(s)
return plist
def _get_requirements(self, req_attr):
reqts = getattr(self.metadata, req_attr)
return set(self.metadata.get_requirements(reqts, extras=self.extras,
env=self.context))
@property
def run_requires(self):
return self._get_requirements('run_requires')
@property
def meta_requires(self):
return self._get_requirements('meta_requires')
@property
def build_requires(self):
return self._get_requirements('build_requires')
@property
def test_requires(self):
return self._get_requirements('test_requires')
@property
def dev_requires(self):
return self._get_requirements('dev_requires')
def matches_requirement(self, req):
"""
Say if this instance matches (fulfills) a requirement.
:param req: The requirement to match.
:rtype req: str
:return: True if it matches, else False.
"""
# Requirement may contain extras - parse to lose those
# from what's passed to the matcher
r = parse_requirement(req)
scheme = get_scheme(self.metadata.scheme)
try:
matcher = scheme.matcher(r.requirement)
except UnsupportedVersionError:
# XXX compat-mode if cannot read the version
logger.warning('could not read version %r - using name only',
req)
name = req.split()[0]
matcher = scheme.matcher(name)
name = matcher.key # case-insensitive
result = False
for p in self.provides:
p_name, p_ver = parse_name_and_version(p)
if p_name != name:
continue
try:
result = matcher.match(p_ver)
break
except UnsupportedVersionError:
pass
return result
def __repr__(self):
"""
Return a textual representation of this instance,
"""
if self.source_url:
suffix = ' [%s]' % self.source_url
else:
suffix = ''
return '<Distribution %s (%s)%s>' % (self.name, self.version, suffix)
def __eq__(self, other):
"""
See if this distribution is the same as another.
:param other: The distribution to compare with. To be equal to one
another. distributions must have the same type, name,
version and source_url.
:return: True if it is the same, else False.
"""
if type(other) is not type(self):
result = False
else:
result = (self.name == other.name and
self.version == other.version and
self.source_url == other.source_url)
return result
def __hash__(self):
"""
Compute hash in a way which matches the equality test.
"""
return hash(self.name) + hash(self.version) + hash(self.source_url)
class BaseInstalledDistribution(Distribution):
"""
This is the base class for installed distributions (whether PEP 376 or
legacy).
"""
hasher = None
def __init__(self, metadata, path, env=None):
"""
Initialise an instance.
:param metadata: An instance of :class:`Metadata` which describes the
distribution. This will normally have been initialised
from a metadata file in the ``path``.
:param path: The path of the ``.dist-info`` or ``.egg-info``
directory for the distribution.
:param env: This is normally the :class:`DistributionPath`
instance where this distribution was found.
"""
super(BaseInstalledDistribution, self).__init__(metadata)
self.path = path
self.dist_path = env
def get_hash(self, data, hasher=None):
"""
Get the hash of some data, using a particular hash algorithm, if
specified.
:param data: The data to be hashed.
:type data: bytes
:param hasher: The name of a hash implementation, supported by hashlib,
or ``None``. Examples of valid values are ``'sha1'``,
``'sha224'``, ``'sha384'``, '``sha256'``, ``'md5'`` and
``'sha512'``. If no hasher is specified, the ``hasher``
attribute of the :class:`InstalledDistribution` instance
is used. If the hasher is determined to be ``None``, MD5
is used as the hashing algorithm.
:returns: The hash of the data. If a hasher was explicitly specified,
the returned hash will be prefixed with the specified hasher
followed by '='.
:rtype: str
"""
if hasher is None:
hasher = self.hasher
if hasher is None:
hasher = hashlib.md5
prefix = ''
else:
hasher = getattr(hashlib, hasher)
prefix = '%s=' % self.hasher
digest = hasher(data).digest()
digest = base64.urlsafe_b64encode(digest).rstrip(b'=').decode('ascii')
return '%s%s' % (prefix, digest)
class InstalledDistribution(BaseInstalledDistribution):
"""
Created with the *path* of the ``.dist-info`` directory provided to the
constructor. It reads the metadata contained in ``pydist.json`` when it is
instantiated., or uses a passed in Metadata instance (useful for when
dry-run mode is being used).
"""
hasher = 'sha256'
def __init__(self, path, metadata=None, env=None):
self.finder = finder = resources.finder_for_path(path)
if finder is None:
import pdb; pdb.set_trace ()
if env and env._cache_enabled and path in env._cache.path:
metadata = env._cache.path[path].metadata
elif metadata is None:
r = finder.find(METADATA_FILENAME)
# Temporary - for legacy support
if r is None:
r = finder.find('METADATA')
if r is None:
raise ValueError('no %s found in %s' % (METADATA_FILENAME,
path))
with contextlib.closing(r.as_stream()) as stream:
metadata = Metadata(fileobj=stream, scheme='legacy')
super(InstalledDistribution, self).__init__(metadata, path, env)
if env and env._cache_enabled:
env._cache.add(self)
try:
r = finder.find('REQUESTED')
except AttributeError:
import pdb; pdb.set_trace ()
self.requested = r is not None
def __repr__(self):
return '<InstalledDistribution %r %s at %r>' % (
self.name, self.version, self.path)
def __str__(self):
return "%s %s" % (self.name, self.version)
def _get_records(self):
"""
Get the list of installed files for the distribution
:return: A list of tuples of path, hash and size. Note that hash and
size might be ``None`` for some entries. The path is exactly
as stored in the file (which is as in PEP 376).
"""
results = []
r = self.get_distinfo_resource('RECORD')
with contextlib.closing(r.as_stream()) as stream:
with CSVReader(stream=stream) as record_reader:
# Base location is parent dir of .dist-info dir
#base_location = os.path.dirname(self.path)
#base_location = os.path.abspath(base_location)
for row in record_reader:
missing = [None for i in range(len(row), 3)]
path, checksum, size = row + missing
#if not os.path.isabs(path):
# path = path.replace('/', os.sep)
# path = os.path.join(base_location, path)
results.append((path, checksum, size))
return results
@cached_property
def exports(self):
"""
Return the information exported by this distribution.
:return: A dictionary of exports, mapping an export category to a dict
of :class:`ExportEntry` instances describing the individual
export entries, and keyed by name.
"""
result = {}
r = self.get_distinfo_resource(EXPORTS_FILENAME)
if r:
result = self.read_exports()
return result
def read_exports(self):
"""
Read exports data from a file in .ini format.
:return: A dictionary of exports, mapping an export category to a list
of :class:`ExportEntry` instances describing the individual
export entries.
"""
result = {}
r = self.get_distinfo_resource(EXPORTS_FILENAME)
if r:
with contextlib.closing(r.as_stream()) as stream:
result = read_exports(stream)
return result
def write_exports(self, exports):
"""
Write a dictionary of exports to a file in .ini format.
:param exports: A dictionary of exports, mapping an export category to
a list of :class:`ExportEntry` instances describing the
individual export entries.
"""
rf = self.get_distinfo_file(EXPORTS_FILENAME)
with open(rf, 'w') as f:
write_exports(exports, f)
def get_resource_path(self, relative_path):
"""
NOTE: This API may change in the future.
Return the absolute path to a resource file with the given relative
path.
:param relative_path: The path, relative to .dist-info, of the resource
of interest.
:return: The absolute path where the resource is to be found.
"""
r = self.get_distinfo_resource('RESOURCES')
with contextlib.closing(r.as_stream()) as stream:
with CSVReader(stream=stream) as resources_reader:
for relative, destination in resources_reader:
if relative == relative_path:
return destination
raise KeyError('no resource file with relative path %r '
'is installed' % relative_path)
def list_installed_files(self):
"""
Iterates over the ``RECORD`` entries and returns a tuple
``(path, hash, size)`` for each line.
:returns: iterator of (path, hash, size)
"""
for result in self._get_records():
yield result
def write_installed_files(self, paths, prefix, dry_run=False):
"""
Writes the ``RECORD`` file, using the ``paths`` iterable passed in. Any
existing ``RECORD`` file is silently overwritten.
prefix is used to determine when to write absolute paths.
"""
prefix = os.path.join(prefix, '')
base = os.path.dirname(self.path)
base_under_prefix = base.startswith(prefix)
base = os.path.join(base, '')
record_path = self.get_distinfo_file('RECORD')
logger.info('creating %s', record_path)
if dry_run:
return None
with CSVWriter(record_path) as writer:
for path in paths:
if os.path.isdir(path) or path.endswith(('.pyc', '.pyo')):
# do not put size and hash, as in PEP-376
hash_value = size = ''
else:
size = '%d' % os.path.getsize(path)
with open(path, 'rb') as fp:
hash_value = self.get_hash(fp.read())
if path.startswith(base) or (base_under_prefix and
path.startswith(prefix)):
path = os.path.relpath(path, base)
writer.writerow((path, hash_value, size))
# add the RECORD file itself
if record_path.startswith(base):
record_path = os.path.relpath(record_path, base)
writer.writerow((record_path, '', ''))
return record_path
def check_installed_files(self):
"""
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' according to what didn't match
(existence is checked first, then size, then hash), the expected
value and the actual value.
"""
mismatches = []
base = os.path.dirname(self.path)
record_path = self.get_distinfo_file('RECORD')
for path, hash_value, size in self.list_installed_files():
if not os.path.isabs(path):
path = os.path.join(base, path)
if path == record_path:
continue
if not os.path.exists(path):
mismatches.append((path, 'exists', True, False))
elif os.path.isfile(path):
actual_size = str(os.path.getsize(path))
if size and actual_size != size:
mismatches.append((path, 'size', size, actual_size))
elif hash_value:
if '=' in hash_value:
hasher = hash_value.split('=', 1)[0]
else:
hasher = None
with open(path, 'rb') as f:
actual_hash = self.get_hash(f.read(), hasher)
if actual_hash != hash_value:
mismatches.append((path, 'hash', hash_value, actual_hash))
return mismatches
@cached_property
def shared_locations(self):
"""
A dictionary of shared locations whose keys are in the set 'prefix',
'purelib', 'platlib', 'scripts', 'headers', 'data' and 'namespace'.
The corresponding value is the absolute path of that category for
this distribution, and takes into account any paths selected by the
user at installation time (e.g. via command-line arguments). In the
case of the 'namespace' key, this would be a list of absolute paths
for the roots of namespace packages in this distribution.
The first time this property is accessed, the relevant information is
read from the SHARED file in the .dist-info directory.
"""
result = {}
shared_path = os.path.join(self.path, 'SHARED')
if os.path.isfile(shared_path):
with codecs.open(shared_path, 'r', encoding='utf-8') as f:
lines = f.read().splitlines()
for line in lines:
key, value = line.split('=', 1)
if key == 'namespace':
result.setdefault(key, []).append(value)
else:
result[key] = value
return result
def write_shared_locations(self, paths, dry_run=False):
"""
Write shared location information to the SHARED file in .dist-info.
:param paths: A dictionary as described in the documentation for
:meth:`shared_locations`.
:param dry_run: If True, the action is logged but no file is actually
written.
:return: The path of the file written to.
"""
shared_path = os.path.join(self.path, 'SHARED')
logger.info('creating %s', shared_path)
if dry_run:
return None
lines = []
for key in ('prefix', 'lib', 'headers', 'scripts', 'data'):
path = paths[key]
if os.path.isdir(paths[key]):
lines.append('%s=%s' % (key, path))
for ns in paths.get('namespace', ()):
lines.append('namespace=%s' % ns)
with codecs.open(shared_path, 'w', encoding='utf-8') as f:
f.write('\n'.join(lines))
return shared_path
def get_distinfo_resource(self, path):
if path not in DIST_FILES:
raise DistlibException('invalid path for a dist-info file: '
'%r at %r' % (path, self.path))
finder = resources.finder_for_path(self.path)
if finder is None:
raise DistlibException('Unable to get a finder for %s' % self.path)
return finder.find(path)
def get_distinfo_file(self, path):
"""
Returns a path located under the ``.dist-info`` directory. Returns a
string representing the path.
:parameter path: a ``'/'``-separated path relative to the
``.dist-info`` directory or an absolute path;
If *path* is an absolute path and doesn't start
with the ``.dist-info`` directory path,
a :class:`DistlibException` is raised
:type path: str
:rtype: str
"""
# Check if it is an absolute path # XXX use relpath, add tests
if path.find(os.sep) >= 0:
# it's an absolute path?
distinfo_dirname, path = path.split(os.sep)[-2:]
if distinfo_dirname != self.path.split(os.sep)[-1]:
raise DistlibException(
'dist-info file %r does not belong to the %r %s '
'distribution' % (path, self.name, self.version))
# The file must be relative
if path not in DIST_FILES:
raise DistlibException('invalid path for a dist-info file: '
'%r at %r' % (path, self.path))
return os.path.join(self.path, path)
def list_distinfo_files(self):
"""
Iterates over the ``RECORD`` entries and returns paths for each line if
the path is pointing to a file located in the ``.dist-info`` directory
or one of its subdirectories.
:returns: iterator of paths
"""
base = os.path.dirname(self.path)
for path, checksum, size in self._get_records():
# XXX add separator or use real relpath algo
if not os.path.isabs(path):
path = os.path.join(base, path)
if path.startswith(self.path):
yield path
def __eq__(self, other):
return (isinstance(other, InstalledDistribution) and
self.path == other.path)
# See http://docs.python.org/reference/datamodel#object.__hash__
__hash__ = object.__hash__
class EggInfoDistribution(BaseInstalledDistribution):
"""Created with the *path* of the ``.egg-info`` directory or file provided
to the constructor. It reads the metadata contained in the file itself, or
if the given path happens to be a directory, the metadata is read from the
file ``PKG-INFO`` under that directory."""
requested = True # as we have no way of knowing, assume it was
shared_locations = {}
def __init__(self, path, env=None):
def set_name_and_version(s, n, v):
s.name = n
s.key = n.lower() # for case-insensitive comparisons
s.version = v
self.path = path
self.dist_path = env
if env and env._cache_enabled and path in env._cache_egg.path:
metadata = env._cache_egg.path[path].metadata
set_name_and_version(self, metadata.name, metadata.version)
else:
metadata = self._get_metadata(path)
# Need to be set before caching
set_name_and_version(self, metadata.name, metadata.version)
if env and env._cache_enabled:
env._cache_egg.add(self)
super(EggInfoDistribution, self).__init__(metadata, path, env)
def _get_metadata(self, path):
requires = None
def parse_requires_data(data):
"""Create a list of dependencies from a requires.txt file.
*data*: the contents of a setuptools-produced requires.txt file.
"""
reqs = []
lines = data.splitlines()
for line in lines:
line = line.strip()
if line.startswith('['):
logger.warning('Unexpected line: quitting requirement scan: %r',
line)
break
r = parse_requirement(line)
if not r:
logger.warning('Not recognised as a requirement: %r', line)
continue
if r.extras:
logger.warning('extra requirements in requires.txt are '
'not supported')
if not r.constraints:
reqs.append(r.name)
else:
cons = ', '.join('%s%s' % c for c in r.constraints)
reqs.append('%s (%s)' % (r.name, cons))
return reqs
def parse_requires_path(req_path):
"""Create a list of dependencies from a requires.txt file.
*req_path*: the path to a setuptools-produced requires.txt file.
"""
reqs = []
try:
with codecs.open(req_path, 'r', 'utf-8') as fp:
reqs = parse_requires_data(fp.read())
except IOError:
pass
return reqs
if path.endswith('.egg'):
if os.path.isdir(path):
meta_path = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
metadata = Metadata(path=meta_path, scheme='legacy')
req_path = os.path.join(path, 'EGG-INFO', 'requires.txt')
requires = parse_requires_path(req_path)
else:
# FIXME handle the case where zipfile is not available
zipf = zipimport.zipimporter(path)
fileobj = StringIO(
zipf.get_data('EGG-INFO/PKG-INFO').decode('utf8'))
metadata = Metadata(fileobj=fileobj, scheme='legacy')
try:
data = zipf.get_data('EGG-INFO/requires.txt')
requires = parse_requires_data(data.decode('utf-8'))
except IOError:
requires = None
elif path.endswith('.egg-info'):
if os.path.isdir(path):
path = os.path.join(path, 'PKG-INFO')
req_path = os.path.join(path, 'requires.txt')
requires = parse_requires_path(req_path)
metadata = Metadata(path=path, scheme='legacy')
else:
raise DistlibException('path must end with .egg-info or .egg, '
'got %r' % path)
if requires:
metadata.add_requirements(requires)
return metadata
def __repr__(self):
return '<EggInfoDistribution %r %s at %r>' % (
self.name, self.version, self.path)
def __str__(self):
return "%s %s" % (self.name, self.version)
def check_installed_files(self):
"""
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' according to what didn't match
(existence is checked first, then size, then hash), the expected
value and the actual value.
"""
mismatches = []
record_path = os.path.join(self.path, 'installed-files.txt')
if os.path.exists(record_path):
for path, _, _ in self.list_installed_files():
if path == record_path:
continue
if not os.path.exists(path):
mismatches.append((path, 'exists', True, False))
return mismatches
def list_installed_files(self):
"""
Iterates over the ``installed-files.txt`` entries and returns a tuple
``(path, hash, size)`` for each line.
:returns: a list of (path, hash, size)
"""
def _md5(path):
f = open(path, 'rb')
try:
content = f.read()
finally:
f.close()
return hashlib.md5(content).hexdigest()
def _size(path):
return os.stat(path).st_size
record_path = os.path.join(self.path, 'installed-files.txt')
result = []
if os.path.exists(record_path):
with codecs.open(record_path, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
p = os.path.normpath(os.path.join(self.path, line))
# "./" is present as a marker between installed files
# and installation metadata files
if not os.path.exists(p):
logger.warning('Non-existent file: %s', p)
if p.endswith(('.pyc', '.pyo')):
continue
#otherwise fall through and fail
if not os.path.isdir(p):
result.append((p, _md5(p), _size(p)))
result.append((record_path, None, None))
return result
def list_distinfo_files(self, absolute=False):
"""
Iterates over the ``installed-files.txt`` entries and returns paths for
each line if the path is pointing to a file located in the
``.egg-info`` directory or one of its subdirectories.
:parameter absolute: If *absolute* is ``True``, each returned path is
transformed into a local absolute path. Otherwise the
raw value from ``installed-files.txt`` is returned.
:type absolute: boolean
:returns: iterator of paths
"""
record_path = os.path.join(self.path, 'installed-files.txt')
skip = True
with codecs.open(record_path, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
if line == './':
skip = False
continue
if not skip:
p = os.path.normpath(os.path.join(self.path, line))
if p.startswith(self.path):
if absolute:
yield p
else:
yield line
def __eq__(self, other):
return (isinstance(other, EggInfoDistribution) and
self.path == other.path)
# See http://docs.python.org/reference/datamodel#object.__hash__
__hash__ = object.__hash__
new_dist_class = InstalledDistribution
old_dist_class = EggInfoDistribution
class DependencyGraph(object):
"""
Represents a dependency graph between distributions.
The dependency relationships are stored in an ``adjacency_list`` that maps
distributions to a list of ``(other, label)`` tuples where ``other``
is a distribution and the edge is labeled with ``label`` (i.e. the version
specifier, if such was provided). Also, for more efficient traversal, for
every distribution ``x``, a list of predecessors is kept in
``reverse_list[x]``. An edge from distribution ``a`` to
distribution ``b`` means that ``a`` depends on ``b``. If any missing
dependencies are found, they are stored in ``missing``, which is a
dictionary that maps distributions to a list of requirements that were not
provided by any other distributions.
"""
def __init__(self):
self.adjacency_list = {}
self.reverse_list = {}
self.missing = {}
def add_distribution(self, distribution):
"""Add the *distribution* to the graph.
:type distribution: :class:`distutils2.database.InstalledDistribution`
or :class:`distutils2.database.EggInfoDistribution`
"""
self.adjacency_list[distribution] = []
self.reverse_list[distribution] = []
#self.missing[distribution] = []
def add_edge(self, x, y, label=None):
"""Add an edge from distribution *x* to distribution *y* with the given
*label*.
:type x: :class:`distutils2.database.InstalledDistribution` or
:class:`distutils2.database.EggInfoDistribution`
:type y: :class:`distutils2.database.InstalledDistribution` or
:class:`distutils2.database.EggInfoDistribution`
:type label: ``str`` or ``None``
"""
self.adjacency_list[x].append((y, label))
# multiple edges are allowed, so be careful
if x not in self.reverse_list[y]:
self.reverse_list[y].append(x)
def add_missing(self, distribution, requirement):
"""
Add a missing *requirement* for the given *distribution*.
:type distribution: :class:`distutils2.database.InstalledDistribution`
or :class:`distutils2.database.EggInfoDistribution`
:type requirement: ``str``
"""
logger.debug('%s missing %r', distribution, requirement)
self.missing.setdefault(distribution, []).append(requirement)
def _repr_dist(self, dist):
return '%s %s' % (dist.name, dist.version)
def repr_node(self, dist, level=1):
"""Prints only a subgraph"""
output = [self._repr_dist(dist)]
for other, label in self.adjacency_list[dist]:
dist = self._repr_dist(other)
if label is not None:
dist = '%s [%s]' % (dist, label)
output.append(' ' * level + str(dist))
suboutput = self.repr_node(other, level + 1)
subs = suboutput.split('\n')
output.extend(subs[1:])
return '\n'.join(output)
def to_dot(self, f, skip_disconnected=True):
"""Writes a DOT output for the graph to the provided file *f*.
If *skip_disconnected* is set to ``True``, then all distributions
that are not dependent on any other distribution are skipped.
:type f: has to support ``file``-like operations
:type skip_disconnected: ``bool``
"""
disconnected = []
f.write("digraph dependencies {\n")
for dist, adjs in self.adjacency_list.items():
if len(adjs) == 0 and not skip_disconnected:
disconnected.append(dist)
for other, label in adjs:
if not label is None:
f.write('"%s" -> "%s" [label="%s"]\n' %
(dist.name, other.name, label))
else:
f.write('"%s" -> "%s"\n' % (dist.name, other.name))
if not skip_disconnected and len(disconnected) > 0:
f.write('subgraph disconnected {\n')
f.write('label = "Disconnected"\n')
f.write('bgcolor = red\n')
for dist in disconnected:
f.write('"%s"' % dist.name)
f.write('\n')
f.write('}\n')
f.write('}\n')
def topological_sort(self):
"""
Perform a topological sort of the graph.
:return: A tuple, the first element of which is a topologically sorted
list of distributions, and the second element of which is a
list of distributions that cannot be sorted because they have
circular dependencies and so form a cycle.
"""
result = []
# Make a shallow copy of the adjacency list
alist = {}
for k, v in self.adjacency_list.items():
alist[k] = v[:]
while True:
# See what we can remove in this run
to_remove = []
for k, v in list(alist.items())[:]:
if not v:
to_remove.append(k)
del alist[k]
if not to_remove:
# What's left in alist (if anything) is a cycle.
break
# Remove from the adjacency list of others
for k, v in alist.items():
alist[k] = [(d, r) for d, r in v if d not in to_remove]
logger.debug('Moving to result: %s',
['%s (%s)' % (d.name, d.version) for d in to_remove])
result.extend(to_remove)
return result, list(alist.keys())
def __repr__(self):
"""Representation of the graph"""
output = []
for dist, adjs in self.adjacency_list.items():
output.append(self.repr_node(dist))
return '\n'.join(output)
def make_graph(dists, scheme='default'):
"""Makes a dependency graph from the given distributions.
:parameter dists: a list of distributions
:type dists: list of :class:`distutils2.database.InstalledDistribution` and
:class:`distutils2.database.EggInfoDistribution` instances
:rtype: a :class:`DependencyGraph` instance
"""
scheme = get_scheme(scheme)
graph = DependencyGraph()
provided = {} # maps names to lists of (version, dist) tuples
# first, build the graph and find out what's provided
for dist in dists:
graph.add_distribution(dist)
for p in dist.provides:
name, version = parse_name_and_version(p)
logger.debug('Add to provided: %s, %s, %s', name, version, dist)
provided.setdefault(name, []).append((version, dist))
# now make the edges
for dist in dists:
requires = (dist.run_requires | dist.meta_requires |
dist.build_requires | dist.dev_requires)
for req in requires:
try:
matcher = scheme.matcher(req)
except UnsupportedVersionError:
# XXX compat-mode if cannot read the version
logger.warning('could not read version %r - using name only',
req)
name = req.split()[0]
matcher = scheme.matcher(name)
name = matcher.key # case-insensitive
matched = False
if name in provided:
for version, provider in provided[name]:
try:
match = matcher.match(version)
except UnsupportedVersionError:
match = False
if match:
graph.add_edge(dist, provider, req)
matched = True
break
if not matched:
graph.add_missing(dist, req)
return graph
def get_dependent_dists(dists, dist):
"""Recursively generate a list of distributions from *dists* that are
dependent on *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
"""
if dist not in dists:
raise DistlibException('given distribution %r is not a member '
'of the list' % dist.name)
graph = make_graph(dists)
dep = [dist] # dependent distributions
todo = graph.reverse_list[dist] # list of nodes we should inspect
while todo:
d = todo.pop()
dep.append(d)
for succ in graph.reverse_list[d]:
if succ not in dep:
todo.append(succ)
dep.pop(0) # remove dist from dep, was there to prevent infinite loops
return dep
def get_required_dists(dists, dist):
"""Recursively generate a list of distributions from *dists* that are
required by *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
"""
if dist not in dists:
raise DistlibException('given distribution %r is not a member '
'of the list' % dist.name)
graph = make_graph(dists)
req = [] # required distributions
todo = graph.adjacency_list[dist] # list of nodes we should inspect
while todo:
d = todo.pop()[0]
req.append(d)
for pred in graph.adjacency_list[d]:
if pred not in req:
todo.append(pred)
return req
def make_dist(name, version, **kwargs):
"""
A convenience method for making a dist given just a name and version.
"""
summary = kwargs.pop('summary', 'Placeholder for summary')
md = Metadata(**kwargs)
md.name = name
md.version = version
md.summary = summary or 'Plaeholder for summary'
return Distribution(md)
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
35,
9,
6029,
13,
6965,
710,
2018,
2290,
2752,
14,
199,
3,
1666,
5113,
14,
2424,
436,
6483,
14,
2424,
14,
199,
3,
199,
624,
25633,
650,
2114,
4514,
1041,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
1300,
772,
199,
646,
6010,
199,
646,
15502,
199,
646,
8337,
199,
646,
2050,
199,
646,
747,
199,
646,
15454,
199,
646,
984,
199,
646,
3482,
646,
199,
199,
504,
1275,
492,
28801,
12,
5944,
199,
504,
1275,
5819,
492,
5228,
199,
504,
1275,
1023,
492,
664,
63,
5512,
12,
19022,
3353,
547,
199,
504,
1275,
2343,
492,
16160,
12,
19357,
8071,
63,
15440,
199,
504,
1275,
1974,
492,
334,
1122,
63,
12434,
12,
6328,
63,
1829,
12,
2198,
63,
354,
63,
460,
63,
1023,
12,
673,
1586,
63,
20775,
12,
2218,
63,
20775,
12,
14689,
5929,
12,
14689,
6261,
9,
421,
199,
363,
452,
363,
275,
788,
8580,
297,
283,
1563,
21268,
8580,
297,
1779,
283,
21268,
8580,
297,
283,
37,
2721,
2354,
8580,
297,
1779,
283,
8580,
2042,
418,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
18341,
51,
63,
15440,
275,
283,
647,
2686,
13,
20775,
14,
1001,
7,
199,
28442,
63,
15440,
275,
283,
647,
2686,
13,
4405,
14,
1001,
7,
199,
199,
13783,
63,
9472,
275,
661,
16811,
540,
297,
19357,
8071,
63,
15440,
12,
283,
15060,
297,
283,
6780,
1149,
297,
1598,
283,
3830,
11237,
16734,
297,
3651,
3657,
51,
63,
15440,
12,
283,
13772,
358,
199,
199,
13783,
4531,
63,
2472,
275,
1987,
2686,
13,
815,
7,
421,
199,
533,
485,
4437,
8,
785,
304,
272,
408,
272,
437,
3486,
2581,
4412,
1561,
436,
1275,
2686,
13,
815,
3792,
370,
10208,
272,
408,
272,
347,
636,
826,
721,
277,
304,
267,
408,
267,
6026,
572,
376,
1256,
14,
6006,
365,
12252,
1373,
367,
1924,
11839,
2042,
14,
267,
408,
267,
291,
14,
354,
275,
1052,
267,
291,
14,
515,
275,
1052,
267,
291,
14,
10176,
275,
756,
339,
347,
5436,
8,
277,
304,
267,
408,
267,
14836,
314,
2581,
12,
4260,
652,
370,
2399,
2536,
1174,
14,
267,
408,
267,
291,
14,
354,
14,
3584,
342,
267,
291,
14,
515,
14,
3584,
342,
267,
291,
14,
10176,
275,
756,
339,
347,
1050,
8,
277,
12,
2917,
304,
267,
408,
267,
2654,
282,
4084,
370,
314,
2581,
14,
267,
520,
635,
2917,
26,
710,
4084,
370,
1050,
14,
267,
408,
267,
340,
2917,
14,
515,
440,
315,
291,
14,
515,
26,
288,
291,
14,
515,
59,
2686,
14,
515,
61,
275,
2917,
288,
291,
14,
354,
14,
5486,
8,
2686,
14,
498,
12,
15364,
740,
8,
2686,
9,
421,
199,
533,
11839,
2042,
8,
785,
304,
272,
408,
272,
21591,
282,
663,
402,
10208,
4903,
641,
282,
931,
334,
32251,
984,
14,
515,
680,
272,
408,
272,
347,
636,
826,
721,
277,
12,
931,
29,
403,
12,
2387,
63,
5799,
29,
797,
304,
267,
408,
267,
2790,
376,
1256,
687,
282,
931,
12,
14190,
5893,
12139,
334,
13350,
15,
267,
9116,
15,
3470,
9,
10208,
14,
267,
520,
635,
931,
26,
710,
931,
370,
675,
12,
465,
282,
769,
402,
6602,
14,
982,
440,
2013,
12,
2151,
984,
14,
515,
365,
1202,
14,
267,
520,
635,
2387,
63,
5799,
26,
982,
715,
12,
642,
1256,
911,
3648,
367,
436,
372,
12139,
1169,
10208,
465,
5521,
465,
5204,
4079,
641,
13663,
650,
2114,
14,
267,
408,
267,
340,
931,
365,
488,
26,
288,
931,
275,
984,
14,
515,
267,
291,
14,
515,
275,
931,
267,
291,
423,
2613,
63,
2686,
275,
715,
267,
291,
423,
2613,
63,
5799,
275,
2387,
63,
5799,
398,
291,
423,
1637,
275,
485,
4437,
342,
267,
291,
423,
1637,
63,
5799,
275,
485,
4437,
342,
267,
291,
423,
1637,
63,
3827,
275,
715,
267,
291,
423,
5512,
275,
664,
63,
5512,
360,
885,
358,
339,
347,
485,
362,
63,
1637,
63,
3827,
8,
277,
304,
267,
372,
291,
423,
1637,
63,
3827,
339,
347,
485,
409,
63,
1637,
63,
3827,
8,
277,
12,
574,
304,
267,
291,
423,
1637,
63,
3827,
275,
574,
339,
2581,
63,
3827,
275,
3324,
1547,
362,
63,
1637,
63,
3827,
12,
485,
409,
63,
1637,
63,
3827,
9,
339,
347,
5436,
63,
1637,
8,
277,
304,
267,
408,
267,
14836,
83,
314,
5007,
2581,
14,
267,
408,
267,
291,
423,
1637,
14,
3584,
342,
267,
291,
423,
1637,
63,
5799,
14,
3584,
342,
2378,
347,
485,
11481,
63,
5613,
8,
277,
304,
267,
408,
267,
23771,
1275,
2686,
13,
815,
436,
15,
269,
1275,
5799,
2801,
815,
9,
10208,
14,
267,
408,
267,
327,
2136,
1929,
370,
1104,
340,
781,
9064,
6775,
2005,
5944,
2575,
12,
2952,
641,
267,
327,
2005,
10130,
10460,
334,
69,
14,
71,
14,
2005,
30445,
15,
53,
19313,
21169,
9,
2337,
787,
267,
327,
19891,
1314,
5162,
1163,
1584,
315,
314,
3734,
14,
267,
6775,
275,
663,
342,
267,
367,
931,
315,
291,
14,
515,
26,
288,
11569,
275,
5944,
14,
11681,
63,
509,
63,
515,
8,
515,
9,
288,
340,
11569,
365,
488,
26,
355,
1980,
288,
519,
275,
11569,
14,
1623,
8355,
288,
340,
440,
519,
503,
440,
519,
14,
374,
63,
3600,
26,
355,
1980,
288,
519,
409,
275,
3355,
8,
82,
14,
4435,
9,
288,
367,
2397,
315,
519,
409,
26,
355,
519,
275,
11569,
14,
1623,
8,
2373,
9,
355,
340,
440,
519,
503,
519,
14,
515,
315,
6775,
26,
490,
1980,
355,
340,
291,
423,
2613,
63,
2686,
436,
2397,
14,
4130,
8,
13783,
4531,
63,
2472,
304,
490,
3341,
63,
515,
275,
15454,
14,
904,
8,
2373,
12,
19357,
8071,
63,
15440,
9,
490,
1134,
2686,
275,
11569,
14,
1623,
8,
2343,
63,
515,
9,
490,
340,
440,
1134,
2686,
26,
717,
1980,
4951,
3341,
275,
16160,
8,
9234,
29,
647,
2686,
14,
305,
63,
1745,
1062,
3147,
5687,
534,
10000,
358,
490,
2512,
14,
1757,
360,
3601,
450,
83,
297,
519,
14,
515,
9,
490,
6775,
14,
525,
8,
82,
14,
515,
9,
490,
1995,
892,
63,
2686,
63,
533,
8,
82,
14,
515,
12
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
35,
9,
6029,
13,
6965,
710,
2018,
2290,
2752,
14,
199,
3,
1666,
5113,
14,
2424,
436,
6483,
14,
2424,
14,
199,
3,
199,
624,
25633,
650,
2114,
4514,
1041,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
1300,
772,
199,
646,
6010,
199,
646,
15502,
199,
646,
8337,
199,
646,
2050,
199,
646,
747,
199,
646,
15454,
199,
646,
984,
199,
646,
3482,
646,
199,
199,
504,
1275,
492,
28801,
12,
5944,
199,
504,
1275,
5819,
492,
5228,
199,
504,
1275,
1023,
492,
664,
63,
5512,
12,
19022,
3353,
547,
199,
504,
1275,
2343,
492,
16160,
12,
19357,
8071,
63,
15440,
199,
504,
1275,
1974,
492,
334,
1122,
63,
12434,
12,
6328,
63,
1829,
12,
2198,
63,
354,
63,
460,
63,
1023,
12,
673,
1586,
63,
20775,
12,
2218,
63,
20775,
12,
14689,
5929,
12,
14689,
6261,
9,
421,
199,
363,
452,
363,
275,
788,
8580,
297,
283,
1563,
21268,
8580,
297,
1779,
283,
21268,
8580,
297,
283,
37,
2721,
2354,
8580,
297,
1779,
283,
8580,
2042,
418,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
18341,
51,
63,
15440,
275,
283,
647,
2686,
13,
20775,
14,
1001,
7,
199,
28442,
63,
15440,
275,
283,
647,
2686,
13,
4405,
14,
1001,
7,
199,
199,
13783,
63,
9472,
275,
661,
16811,
540,
297,
19357,
8071,
63,
15440,
12,
283,
15060,
297,
283,
6780,
1149,
297,
1598,
283,
3830,
11237,
16734,
297,
3651,
3657,
51,
63,
15440,
12,
283,
13772,
358,
199,
199,
13783,
4531,
63,
2472,
275,
1987,
2686,
13,
815,
7,
421,
199,
533,
485,
4437,
8,
785,
304,
272,
408,
272,
437,
3486,
2581,
4412,
1561,
436,
1275,
2686,
13,
815,
3792,
370,
10208,
272,
408,
272,
347,
636,
826,
721,
277,
304,
267,
408,
267,
6026,
572,
376,
1256,
14,
6006,
365,
12252,
1373,
367,
1924,
11839,
2042,
14,
267,
408,
267,
291,
14,
354,
275,
1052,
267,
291,
14,
515,
275,
1052,
267,
291,
14,
10176,
275,
756,
339,
347,
5436,
8,
277,
304,
267,
408,
267,
14836,
314,
2581,
12,
4260,
652,
370,
2399,
2536,
1174,
14,
267,
408,
267,
291,
14,
354,
14,
3584,
342,
267,
291,
14,
515,
14,
3584,
342,
267,
291,
14,
10176,
275,
756,
339,
347,
1050,
8,
277,
12,
2917,
304,
267,
408,
267,
2654,
282,
4084,
370,
314,
2581,
14,
267,
520,
635,
2917,
26,
710,
4084,
370,
1050,
14,
267,
408,
267,
340,
2917,
14,
515,
440,
315,
291,
14,
515,
26,
288,
291,
14,
515,
59,
2686,
14,
515,
61,
275,
2917,
288,
291,
14,
354,
14,
5486,
8,
2686,
14,
498,
12,
15364,
740,
8,
2686,
9,
421,
199,
533,
11839,
2042,
8,
785,
304,
272,
408,
272,
21591,
282,
663,
402,
10208,
4903,
641,
282,
931,
334,
32251,
984,
14,
515,
680,
272,
408,
272,
347,
636,
826,
721,
277,
12,
931,
29,
403,
12,
2387,
63,
5799,
29,
797,
304,
267,
408,
267,
2790,
376,
1256,
687,
282,
931,
12,
14190,
5893,
12139,
334,
13350,
15,
267,
9116,
15,
3470,
9,
10208,
14,
267,
520,
635,
931,
26,
710,
931,
370,
675,
12,
465,
282,
769,
402,
6602,
14,
982,
440,
2013,
12,
2151,
984,
14,
515,
365,
1202,
14,
267,
520,
635,
2387,
63,
5799,
26,
982,
715,
12,
642,
1256,
911,
3648,
367,
436,
372,
12139,
1169,
10208,
465,
5521,
465,
5204,
4079,
641,
13663,
650,
2114,
14,
267,
408,
267,
340,
931,
365,
488,
26,
288,
931,
275,
984,
14,
515,
267,
291,
14,
515,
275,
931,
267,
291,
423,
2613,
63,
2686,
275,
715,
267,
291,
423,
2613,
63,
5799,
275,
2387,
63,
5799,
398,
291,
423,
1637,
275,
485,
4437,
342,
267,
291,
423,
1637,
63,
5799,
275,
485,
4437,
342,
267,
291,
423,
1637,
63,
3827,
275,
715,
267,
291,
423,
5512,
275,
664,
63,
5512,
360,
885,
358,
339,
347,
485,
362,
63,
1637,
63,
3827,
8,
277,
304,
267,
372,
291,
423,
1637,
63,
3827,
339,
347,
485,
409,
63,
1637,
63,
3827,
8,
277,
12,
574,
304,
267,
291,
423,
1637,
63,
3827,
275,
574,
339,
2581,
63,
3827,
275,
3324,
1547,
362,
63,
1637,
63,
3827,
12,
485,
409,
63,
1637,
63,
3827,
9,
339,
347,
5436,
63,
1637,
8,
277,
304,
267,
408,
267,
14836,
83,
314,
5007,
2581,
14,
267,
408,
267,
291,
423,
1637,
14,
3584,
342,
267,
291,
423,
1637,
63,
5799,
14,
3584,
342,
2378,
347,
485,
11481,
63,
5613,
8,
277,
304,
267,
408,
267,
23771,
1275,
2686,
13,
815,
436,
15,
269,
1275,
5799,
2801,
815,
9,
10208,
14,
267,
408,
267,
327,
2136,
1929,
370,
1104,
340,
781,
9064,
6775,
2005,
5944,
2575,
12,
2952,
641,
267,
327,
2005,
10130,
10460,
334,
69,
14,
71,
14,
2005,
30445,
15,
53,
19313,
21169,
9,
2337,
787,
267,
327,
19891,
1314,
5162,
1163,
1584,
315,
314,
3734,
14,
267,
6775,
275,
663,
342,
267,
367,
931,
315,
291,
14,
515,
26,
288,
11569,
275,
5944,
14,
11681,
63,
509,
63,
515,
8,
515,
9,
288,
340,
11569,
365,
488,
26,
355,
1980,
288,
519,
275,
11569,
14,
1623,
8355,
288,
340,
440,
519,
503,
440,
519,
14,
374,
63,
3600,
26,
355,
1980,
288,
519,
409,
275,
3355,
8,
82,
14,
4435,
9,
288,
367,
2397,
315,
519,
409,
26,
355,
519,
275,
11569,
14,
1623,
8,
2373,
9,
355,
340,
440,
519,
503,
519,
14,
515,
315,
6775,
26,
490,
1980,
355,
340,
291,
423,
2613,
63,
2686,
436,
2397,
14,
4130,
8,
13783,
4531,
63,
2472,
304,
490,
3341,
63,
515,
275,
15454,
14,
904,
8,
2373,
12,
19357,
8071,
63,
15440,
9,
490,
1134,
2686,
275,
11569,
14,
1623,
8,
2343,
63,
515,
9,
490,
340,
440,
1134,
2686,
26,
717,
1980,
4951,
3341,
275,
16160,
8,
9234,
29,
647,
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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
] |
itmanagerro/tresting
|
qa/rpc-tests/getchaintips.py
|
101
|
2205
|
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Exercise the getchaintips API. We introduce a network split, work
# on chains of different lengths, and join the network together again.
# This gives us two tips, verify that it works.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
class GetChainTipsTest (BitcoinTestFramework):
def __init__(self):
super().__init__()
self.num_nodes = 4
self.setup_clean_chain = False
def run_test (self):
tips = self.nodes[0].getchaintips ()
assert_equal (len (tips), 1)
assert_equal (tips[0]['branchlen'], 0)
assert_equal (tips[0]['height'], 200)
assert_equal (tips[0]['status'], 'active')
# Split the network and build two chains of different lengths.
self.split_network ()
self.nodes[0].generate(10)
self.nodes[2].generate(20)
self.sync_all ()
tips = self.nodes[1].getchaintips ()
assert_equal (len (tips), 1)
shortTip = tips[0]
assert_equal (shortTip['branchlen'], 0)
assert_equal (shortTip['height'], 210)
assert_equal (tips[0]['status'], 'active')
tips = self.nodes[3].getchaintips ()
assert_equal (len (tips), 1)
longTip = tips[0]
assert_equal (longTip['branchlen'], 0)
assert_equal (longTip['height'], 220)
assert_equal (tips[0]['status'], 'active')
# Join the network halves and check that we now have two tips
# (at least at the nodes that previously had the short chain).
self.join_network ()
tips = self.nodes[0].getchaintips ()
assert_equal (len (tips), 2)
assert_equal (tips[0], longTip)
assert_equal (tips[1]['branchlen'], 10)
assert_equal (tips[1]['status'], 'valid-fork')
tips[1]['branchlen'] = 0
tips[1]['status'] = 'active'
assert_equal (tips[1], shortTip)
if __name__ == '__main__':
GetChainTipsTest ().main ()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
6927,
13,
9261,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
199,
3,
1316,
20616,
314,
664,
4429,
25842,
3261,
14,
221,
2136,
13318,
3402,
282,
2784,
3715,
12,
1736,
199,
3,
641,
30640,
402,
3365,
17464,
12,
436,
4263,
314,
2784,
10451,
4020,
14,
199,
3,
961,
10557,
2739,
2877,
3367,
1190,
12,
4911,
626,
652,
5419,
14,
199,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
21158,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
702,
63,
1452,
199,
199,
533,
2372,
10720,
52,
6142,
774,
334,
4734,
9061,
26203,
304,
272,
347,
636,
826,
721,
277,
304,
267,
1613,
11027,
826,
4533,
267,
291,
14,
1507,
63,
2415,
275,
841,
267,
291,
14,
2758,
63,
3118,
63,
4429,
275,
756,
339,
347,
1255,
63,
396,
334,
277,
304,
398,
3367,
1190,
275,
291,
14,
2415,
59,
16,
1055,
362,
4429,
25842,
6248,
267,
702,
63,
1452,
334,
552,
334,
25842,
395,
413,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
4694,
552,
995,
378,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
3333,
995,
1926,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
1205,
995,
283,
2682,
358,
398,
327,
11740,
314,
2784,
436,
1900,
2877,
30640,
402,
3365,
17464,
14,
267,
291,
14,
1294,
63,
1200,
6248,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
709,
9,
267,
291,
14,
2415,
59,
18,
1055,
4208,
8,
1165,
9,
267,
291,
14,
5186,
63,
452,
6248,
398,
3367,
1190,
275,
291,
14,
2415,
59,
17,
1055,
362,
4429,
25842,
6248,
267,
702,
63,
1452,
334,
552,
334,
25842,
395,
413,
9,
267,
3974,
15915,
275,
3367,
1190,
59,
16,
61,
267,
702,
63,
1452,
334,
3612,
15915,
459,
4694,
552,
995,
378,
9,
267,
702,
63,
1452,
334,
3612,
15915,
459,
3333,
995,
26160,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
1205,
995,
283,
2682,
358,
398,
3367,
1190,
275,
291,
14,
2415,
59,
19,
1055,
362,
4429,
25842,
6248,
267,
702,
63,
1452,
334,
552,
334,
25842,
395,
413,
9,
267,
1846,
15915,
275,
3367,
1190,
59,
16,
61,
267,
702,
63,
1452,
334,
2809,
15915,
459,
4694,
552,
995,
378,
9,
267,
702,
63,
1452,
334,
2809,
15915,
459,
3333,
995,
25647,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
1205,
995,
283,
2682,
358,
398,
327,
25733,
314,
2784,
22939,
2310,
436,
1104,
626,
781,
3063,
1172,
2877,
3367,
1190,
267,
327,
334,
292,
5210,
737,
314,
3380,
626,
10889,
10530,
314,
3974,
6036,
680,
267,
291,
14,
904,
63,
1200,
6248,
398,
3367,
1190,
275,
291,
14,
2415,
59,
16,
1055,
362,
4429,
25842,
6248,
267,
702,
63,
1452,
334,
552,
334,
25842,
395,
499,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
467,
1846,
15915,
9,
398,
702,
63,
1452,
334,
25842,
59,
17,
2733,
4694,
552,
995,
1616,
9,
267,
702,
63,
1452,
334,
25842,
59,
17,
2733,
1205,
995,
283,
1078,
13,
11796,
358,
267,
3367,
1190,
59,
17,
2733,
4694,
552,
418,
275,
378,
267,
3367,
1190,
59,
17,
2733,
1205,
418,
275,
283,
2682,
7,
267,
702,
63,
1452,
334,
25842,
59,
17,
467,
3974,
15915,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2372,
10720,
52,
6142,
774,
334,
680,
973,
6248,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
6927,
13,
9261,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
199,
3,
1316,
20616,
314,
664,
4429,
25842,
3261,
14,
221,
2136,
13318,
3402,
282,
2784,
3715,
12,
1736,
199,
3,
641,
30640,
402,
3365,
17464,
12,
436,
4263,
314,
2784,
10451,
4020,
14,
199,
3,
961,
10557,
2739,
2877,
3367,
1190,
12,
4911,
626,
652,
5419,
14,
199,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
21158,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
702,
63,
1452,
199,
199,
533,
2372,
10720,
52,
6142,
774,
334,
4734,
9061,
26203,
304,
272,
347,
636,
826,
721,
277,
304,
267,
1613,
11027,
826,
4533,
267,
291,
14,
1507,
63,
2415,
275,
841,
267,
291,
14,
2758,
63,
3118,
63,
4429,
275,
756,
339,
347,
1255,
63,
396,
334,
277,
304,
398,
3367,
1190,
275,
291,
14,
2415,
59,
16,
1055,
362,
4429,
25842,
6248,
267,
702,
63,
1452,
334,
552,
334,
25842,
395,
413,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
4694,
552,
995,
378,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
3333,
995,
1926,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
1205,
995,
283,
2682,
358,
398,
327,
11740,
314,
2784,
436,
1900,
2877,
30640,
402,
3365,
17464,
14,
267,
291,
14,
1294,
63,
1200,
6248,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
709,
9,
267,
291,
14,
2415,
59,
18,
1055,
4208,
8,
1165,
9,
267,
291,
14,
5186,
63,
452,
6248,
398,
3367,
1190,
275,
291,
14,
2415,
59,
17,
1055,
362,
4429,
25842,
6248,
267,
702,
63,
1452,
334,
552,
334,
25842,
395,
413,
9,
267,
3974,
15915,
275,
3367,
1190,
59,
16,
61,
267,
702,
63,
1452,
334,
3612,
15915,
459,
4694,
552,
995,
378,
9,
267,
702,
63,
1452,
334,
3612,
15915,
459,
3333,
995,
26160,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
1205,
995,
283,
2682,
358,
398,
3367,
1190,
275,
291,
14,
2415,
59,
19,
1055,
362,
4429,
25842,
6248,
267,
702,
63,
1452,
334,
552,
334,
25842,
395,
413,
9,
267,
1846,
15915,
275,
3367,
1190,
59,
16,
61,
267,
702,
63,
1452,
334,
2809,
15915,
459,
4694,
552,
995,
378,
9,
267,
702,
63,
1452,
334,
2809,
15915,
459,
3333,
995,
25647,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
2733,
1205,
995,
283,
2682,
358,
398,
327,
25733,
314,
2784,
22939,
2310,
436,
1104,
626,
781,
3063,
1172,
2877,
3367,
1190,
267,
327,
334,
292,
5210,
737,
314,
3380,
626,
10889,
10530,
314,
3974,
6036,
680,
267,
291,
14,
904,
63,
1200,
6248,
398,
3367,
1190,
275,
291,
14,
2415,
59,
16,
1055,
362,
4429,
25842,
6248,
267,
702,
63,
1452,
334,
552,
334,
25842,
395,
499,
9,
267,
702,
63,
1452,
334,
25842,
59,
16,
467,
1846,
15915,
9,
398,
702,
63,
1452,
334,
25842,
59,
17,
2733,
4694,
552,
995,
1616,
9,
267,
702,
63,
1452,
334,
25842,
59,
17,
2733,
1205,
995,
283,
1078,
13,
11796,
358,
267,
3367,
1190,
59,
17,
2733,
4694,
552,
418,
275,
378,
267,
3367,
1190,
59,
17,
2733,
1205,
418,
275,
283,
2682,
7,
267,
702,
63,
1452,
334,
25842,
59,
17,
467,
3974,
15915,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2372,
10720,
52,
6142,
774,
334,
680,
973,
6248,
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,
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,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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
] |
jelly/calibre
|
manual/conf.py
|
2
|
7503
|
# -*- coding: utf-8 -*-
#
# calibre documentation build configuration file, created by
# sphinx-quickstart.py on Sun Mar 23 01:23:55 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable (module imports are okay, they're removed automatically).
#
# All configuration values have a default value; values that are commented out
# serve to show the default value.
import sys, os, errno
from datetime import date
# If your extensions are in another directory, add it here.
base = os.path.dirname(os.path.abspath(__file__))
sys.path.append(base)
sys.path.insert(0, os.path.dirname(base))
from setup import __appname__, __version__
import calibre.utils.localization as l # Ensure calibre translations are installed
import custom
del sys.path[0]
del l
custom
# General configuration
# ---------------------
needs_sphinx = '1.2'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.addons.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'custom', 'sidebar_toc', 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index' if tags.has('online') else 'simple_index' # noqa
# kill the warning about index/simple_index not being in a toctree
exclude_patterns = ['simple_index.rst'] if master_doc == 'index' else ['index.rst']
exclude_patterns.append('cli-options-header.rst')
if tags.has('gettext'): # noqa
# Do not exclude anything as the strings must be translated. This will
# generate a warning about the documents not being in a toctree, just ignore
# it.
exclude_patterns = []
# The language
language = os.environ.get('CALIBRE_OVERRIDE_LANG', 'en')
def generated_langs():
try:
return os.listdir(os.path.join(base, 'generated'))
except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
return ()
# ignore generated files in languages other than the language we are building for
ge = {'generated/' + x for x in generated_langs()} | {
'generated/' + x for x in os.environ.get('ALL_USER_MANUAL_LANGUAGES', '').split()}
ge.discard('generated/' + language)
exclude_patterns += list(ge)
del ge
# General substitutions.
project = __appname__
copyright = 'Kovid Goyal'
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# The short X.Y version.
version = __version__
# The full version, including alpha/beta/rc tags.
release = __version__
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
unused_docs = ['global', 'cli/global']
locale_dirs = ['locale/']
title = '%s User Manual' % __appname__
if language not in {'en', 'eng'}:
import gettext
try:
t = gettext.translation('simple_index', locale_dirs[0], [language])
except IOError:
pass
else:
title = t.ugettext(title)
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# Options for HTML output
# -----------------------
# The style sheet to use for HTML and HTML Help pages. A file of that name
# must exist either in Sphinx' static/ path, or in one of the custom paths
# given in html_static_path.
html_theme = 'alabaster'
html_sidebars = {
'**': [
'about.html',
'searchbox.html',
'localtoc.html',
'relations.html',
]
}
html_theme_options = {
'logo': 'logo.png',
'show_powered_by': False,
'fixed_sidebar': True,
'sidebar_collapse': True,
'analytics_id': 'UA-20736318-1',
'github_button': False,
}
# The favicon
html_favicon = '../icons/favicon.ico'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the built-in static files,
# so a file named "default.css" will overwrite the built-in "default.css".
html_static_path = ['resources', '../icons/favicon.ico']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
html_last_updated_fmt = '%b %d, %Y'
# Overall title of the documentation
# html_title = title
html_short_title = _('Start')
from calibre.utils.localization import get_language
html_context = {}
html_context['other_languages'] = [
(lc, get_language(lc)) for lc in os.environ.get('ALL_USER_MANUAL_LANGUAGES', '').split() if lc != language]
def sort_languages(x):
from calibre.utils.icu import sort_key
lc, name = x
if lc == language:
return ''
return sort_key(unicode(name))
html_context['other_languages'].sort(key=sort_languages)
html_context['support_text'] = _('Support calibre')
html_context['support_tooltip'] = _('Contribute to support calibre development')
del sort_languages, get_language
epub_author = u'Kovid Goyal'
epub_publisher = u'Kovid Goyal'
epub_copyright = u'© {} Kovid Goyal'.format(date.today().year)
epub_description = u'Comprehensive documentation for calibre'
epub_identifier = u'https://manual.calibre-ebook.com'
epub_scheme = u'url'
epub_uid = u'S54a88f8e9d42455e9c6db000e989225f'
epub_tocdepth = 4
epub_tocdup = True
epub_cover = ('epub_cover.jpg', 'epub_cover_template.html')
# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
html_use_modindex = False
html_use_index = False
# If true, the reST sources are included in the HTML build as _sources/<name>.
html_copy_source = True
# Output file base name for HTML help builder.
htmlhelp_basename = 'calibredoc'
html_use_opensearch = 'https://manual.calibre-ebook.com'
html_show_sphinx = False
# Options for LaTeX output
# ------------------------
# The paper size ('letter' or 'a4').
latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [(master_doc, 'calibre.tex', title, 'Kovid Goyal', 'manual', False)]
# Additional stuff for the LaTeX preamble.
# latex_preamble = ''
# Documents to append as an appendix to all manuals.
# latex_appendices = []
# If false, no module index is generated.
# latex_use_modindex = True
latex_logo = 'resources/logo.png'
latex_show_pagerefs = True
latex_show_urls = 'footnote'
latex_elements = {
'papersize':'letterpaper',
'fontenc':r'\usepackage[T2A,T1]{fontenc}',
'preamble': r'\renewcommand{\pageautorefname}{%s}' % _('page'),
}
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
19238,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
14,
647,
641,
25625,
16794,
6546,
17163,
26,
1789,
26,
1229,
9079,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
3035,
2935,
14,
199,
3,
199,
3,
710,
4072,
402,
642,
570,
787,
18731,
12,
880,
2793,
1133,
5324,
1338,
315,
314,
3231,
199,
3,
626,
10621,
1133,
5927,
461,
334,
578,
8925,
787,
5849,
12,
2985,
3984,
4829,
5847,
680,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
574,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
574,
14,
199,
199,
646,
984,
12,
747,
12,
7554,
199,
504,
2197,
492,
1434,
199,
199,
3,
982,
2195,
5478,
787,
315,
4573,
2082,
12,
1050,
652,
2348,
14,
199,
1095,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
199,
1274,
14,
515,
14,
740,
8,
1095,
9,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
3475,
8,
1095,
430,
199,
504,
3272,
492,
636,
21653,
3108,
636,
1023,
363,
199,
646,
19238,
14,
1208,
14,
1832,
2072,
465,
634,
221,
327,
7523,
19238,
15547,
787,
4903,
199,
646,
3537,
199,
2264,
984,
14,
515,
59,
16,
61,
199,
2264,
634,
199,
4229,
199,
3,
1696,
2897,
199,
3,
10652,
9858,
199,
199,
10065,
63,
8008,
275,
283,
17,
14,
18,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
5478,
199,
3,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
10788,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
788,
8008,
14,
832,
14,
28056,
297,
283,
4229,
297,
283,
27372,
63,
13255,
297,
283,
8008,
14,
832,
14,
1345,
600,
418,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
788,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
340,
3762,
14,
1989,
360,
15178,
358,
587,
283,
4129,
63,
1080,
7,
221,
327,
8151,
199,
3,
14561,
314,
5721,
3595,
1478,
15,
4129,
63,
1080,
440,
3769,
315,
282,
28310,
199,
5473,
63,
7435,
275,
788,
4129,
63,
1080,
14,
8332,
418,
340,
5288,
63,
1301,
508,
283,
1080,
7,
587,
788,
1080,
14,
8332,
418,
199,
5473,
63,
7435,
14,
740,
360,
2764,
13,
1419,
13,
1291,
14,
8332,
358,
199,
692,
3762,
14,
1989,
360,
5152,
735,
221,
327,
8151,
272,
327,
4226,
440,
5760,
7003,
465,
314,
3326,
1471,
506,
14598,
14,
961,
911,
272,
327,
3550,
282,
5721,
3595,
314,
8247,
440,
3769,
315,
282,
28310,
12,
2951,
3686,
272,
327,
652,
14,
272,
5760,
63,
7435,
275,
942,
199,
199,
3,
710,
2637,
199,
3671,
275,
747,
14,
2314,
14,
362,
360,
13329,
2100,
907,
63,
30024,
11259,
63,
7442,
297,
283,
287,
358,
421,
199,
318,
4046,
63,
28182,
837,
272,
862,
26,
267,
372,
747,
14,
7374,
8,
736,
14,
515,
14,
904,
8,
1095,
12,
283,
10176,
1333,
272,
871,
25139,
465,
325,
26,
267,
340,
325,
14,
7931,
1137,
7554,
14,
20465,
26,
288,
746,
272,
372,
6248,
421,
199,
3,
3686,
4046,
1584,
315,
10815,
1163,
2419,
314,
2637,
781,
787,
10015,
367,
199,
303,
275,
791,
10176,
4805,
435,
671,
367,
671,
315,
4046,
63,
28182,
12737,
1204,
469,
272,
283,
10176,
4805,
435,
671,
367,
671,
315,
747,
14,
2314,
14,
362,
360,
1761,
63,
3791,
63,
6588,
13841,
63,
26886,
297,
12548,
1294,
12737,
199,
303,
14,
14394,
360,
10176,
4805,
435,
2637,
9,
199,
5473,
63,
7435,
847,
769,
8,
303,
9,
199,
2264,
2312,
199,
199,
3,
1696,
20873,
14,
199,
1715,
275,
636,
21653,
363,
199,
7307,
275,
283,
31305,
5017,
3971,
31876,
7,
199,
199,
3,
710,
849,
22372,
367,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
199,
3,
1163,
9825,
23088,
314,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
636,
1023,
363,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
636,
1023,
363,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
11168,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
8247,
626,
9296,
1133,
506,
5120,
315,
314,
1900,
14,
199,
8618,
63,
4757,
275,
788,
2966,
297,
283,
2764,
15,
2966,
418,
199,
199,
5508,
63,
3220,
275,
788,
5508,
15,
418,
199,
1213,
275,
1543,
83,
2876,
30247,
7,
450,
636,
21653,
363,
199,
692,
2637,
440,
315,
791,
287,
297,
283,
7420,
936,
26,
272,
492,
9796,
272,
862,
26,
267,
307,
275,
9796,
14,
6893,
360,
4129,
63,
1080,
297,
5867,
63,
3220,
59,
16,
467,
359,
3671,
566,
272,
871,
5925,
26,
267,
986,
272,
587,
26,
267,
2538,
275,
307,
14,
23499,
8,
1213,
9,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
1050,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
1050,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2498,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
19238,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
14,
647,
641,
25625,
16794,
6546,
17163,
26,
1789,
26,
1229,
9079,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
3035,
2935,
14,
199,
3,
199,
3,
710,
4072,
402,
642,
570,
787,
18731,
12,
880,
2793,
1133,
5324,
1338,
315,
314,
3231,
199,
3,
626,
10621,
1133,
5927,
461,
334,
578,
8925,
787,
5849,
12,
2985,
3984,
4829,
5847,
680,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
574,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
574,
14,
199,
199,
646,
984,
12,
747,
12,
7554,
199,
504,
2197,
492,
1434,
199,
199,
3,
982,
2195,
5478,
787,
315,
4573,
2082,
12,
1050,
652,
2348,
14,
199,
1095,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
199,
1274,
14,
515,
14,
740,
8,
1095,
9,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
3475,
8,
1095,
430,
199,
504,
3272,
492,
636,
21653,
3108,
636,
1023,
363,
199,
646,
19238,
14,
1208,
14,
1832,
2072,
465,
634,
221,
327,
7523,
19238,
15547,
787,
4903,
199,
646,
3537,
199,
2264,
984,
14,
515,
59,
16,
61,
199,
2264,
634,
199,
4229,
199,
3,
1696,
2897,
199,
3,
10652,
9858,
199,
199,
10065,
63,
8008,
275,
283,
17,
14,
18,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
5478,
199,
3,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
10788,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
788,
8008,
14,
832,
14,
28056,
297,
283,
4229,
297,
283,
27372,
63,
13255,
297,
283,
8008,
14,
832,
14,
1345,
600,
418,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
788,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
340,
3762,
14,
1989,
360,
15178,
358,
587,
283,
4129,
63,
1080,
7,
221,
327,
8151,
199,
3,
14561,
314,
5721,
3595,
1478,
15,
4129,
63,
1080,
440,
3769,
315,
282,
28310,
199,
5473,
63,
7435,
275,
788,
4129,
63,
1080,
14,
8332,
418,
340,
5288,
63,
1301,
508,
283,
1080,
7,
587,
788,
1080,
14,
8332,
418,
199,
5473,
63,
7435,
14,
740,
360,
2764,
13,
1419,
13,
1291,
14,
8332,
358,
199,
692,
3762,
14,
1989,
360,
5152,
735,
221,
327,
8151,
272,
327,
4226,
440,
5760,
7003,
465,
314,
3326,
1471,
506,
14598,
14,
961,
911,
272,
327,
3550,
282,
5721,
3595,
314,
8247,
440,
3769,
315,
282,
28310,
12,
2951,
3686,
272,
327,
652,
14,
272,
5760,
63,
7435,
275,
942,
199,
199,
3,
710,
2637,
199,
3671,
275,
747,
14,
2314,
14,
362,
360,
13329,
2100,
907,
63,
30024,
11259,
63,
7442,
297,
283,
287,
358,
421,
199,
318,
4046,
63,
28182,
837,
272,
862,
26,
267,
372,
747,
14,
7374,
8,
736,
14,
515,
14,
904,
8,
1095,
12,
283,
10176,
1333,
272,
871,
25139,
465,
325,
26,
267,
340,
325,
14,
7931,
1137,
7554,
14,
20465,
26,
288,
746,
272,
372,
6248,
421,
199,
3,
3686,
4046,
1584,
315,
10815,
1163,
2419,
314,
2637,
781,
787,
10015,
367,
199,
303,
275,
791,
10176,
4805,
435,
671,
367,
671,
315,
4046,
63,
28182,
12737,
1204,
469,
272,
283,
10176,
4805,
435,
671,
367,
671,
315,
747,
14,
2314,
14,
362,
360,
1761,
63,
3791,
63,
6588,
13841,
63,
26886,
297,
12548,
1294,
12737,
199,
303,
14,
14394,
360,
10176,
4805,
435,
2637,
9,
199,
5473,
63,
7435,
847,
769,
8,
303,
9,
199,
2264,
2312,
199,
199,
3,
1696,
20873,
14,
199,
1715,
275,
636,
21653,
363,
199,
7307,
275,
283,
31305,
5017,
3971,
31876,
7,
199,
199,
3,
710,
849,
22372,
367,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
199,
3,
1163,
9825,
23088,
314,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
636,
1023,
363,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
636,
1023,
363,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
11168,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
8247,
626,
9296,
1133,
506,
5120,
315,
314,
1900,
14,
199,
8618,
63,
4757,
275,
788,
2966,
297,
283,
2764,
15,
2966,
418,
199,
199,
5508,
63,
3220,
275,
788,
5508,
15,
418,
199,
1213,
275,
1543,
83,
2876,
30247,
7,
450,
636,
21653,
363,
199,
692,
2637,
440,
315,
791,
287,
297,
283,
7420,
936,
26,
272,
492,
9796,
272,
862,
26,
267,
307,
275,
9796,
14,
6893,
360,
4129,
63,
1080,
297,
5867,
63,
3220,
59,
16,
467,
359,
3671,
566,
272,
871,
5925,
26,
267,
986,
272,
587,
26,
267,
2538,
275,
307,
14,
23499,
8,
1213,
9,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
1050,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
1050,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2498,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
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,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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
] |
aforalee/rally
|
tests/functional/test_cli_plugin.py
|
15
|
3018
|
# Copyright 2015: Mirantis 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 tests.functional import utils
class PluginTestCase(unittest.TestCase):
def setUp(self):
super(PluginTestCase, self).setUp()
self.rally = utils.Rally()
def test_show_one(self):
result = self.rally("plugin show Dummy.dummy_with_scenario_output")
self.assertIn("NAME", result)
self.assertIn("NAMESPACE", result)
self.assertIn("Dummy.dummy_with_scenario_output", result)
self.assertIn("MODULE", result)
def test_show_multiple_and_full_match(self):
result = self.rally("plugin show Dummy.dummy")
self.assertIn("NAME", result)
self.assertIn("NAMESPACE", result)
self.assertIn("Dummy.dummy", result)
self.assertIn("MODULE", result)
def test_show_multiple(self):
result = self.rally("plugin show Dummy")
self.assertIn("Multiple plugins found:", result)
self.assertIn("Dummy.dummy", result)
self.assertIn("Dummy.dummy_exception", result)
self.assertIn("Dummy.dummy_with_scenario_output", result)
self.assertIn("Dummy.dummy_random_fail_in_atomic", result)
def test_show_not_found(self):
name = "Dummy666666"
result = self.rally("plugin show %s" % name)
self.assertIn("There is no plugin: %s" % name, result)
def test_show_not_found_in_specific_namespace(self):
name = "Dummy"
namespace = "non_existing"
result = self.rally(
"plugin show --name %(name)s --namespace %(namespace)s"
% {"name": name, "namespace": namespace})
self.assertIn(
"There is no plugin: %(name)s in %(namespace)s namespace"
% {"name": name, "namespace": namespace},
result)
def test_list(self):
result = self.rally("plugin list Dummy")
self.assertIn("Dummy.dummy", result)
self.assertIn("Dummy.dummy_exception", result)
self.assertIn("Dummy.dummy_with_scenario_output", result)
self.assertIn("Dummy.dummy_random_fail_in_atomic", result)
def test_list_not_found_namespace(self):
result = self.rally("plugin list --namespace some")
self.assertIn("There is no plugin namespace: some", result)
def test_list_not_found_name(self):
result = self.rally("plugin list Dummy2222")
self.assertIn("There is no plugin: Dummy2222", result)
|
apache-2.0
|
[
3,
1898,
6900,
26,
603,
723,
4466,
83,
3277,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
2882,
199,
199,
504,
2295,
14,
15481,
492,
3778,
421,
199,
533,
11349,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
5061,
1746,
12,
291,
680,
5996,
342,
267,
291,
14,
82,
1183,
275,
3778,
14,
50,
1183,
342,
339,
347,
511,
63,
2384,
63,
368,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
2498,
9762,
14,
5869,
63,
1045,
63,
13444,
63,
1199,
531,
267,
291,
14,
4080,
480,
2339,
401,
754,
9,
267,
291,
14,
4080,
480,
13001,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1045,
63,
13444,
63,
1199,
401,
754,
9,
267,
291,
14,
4080,
480,
10001,
401,
754,
9,
339,
347,
511,
63,
2384,
63,
6048,
63,
460,
63,
2861,
63,
1431,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
2498,
9762,
14,
5869,
531,
267,
291,
14,
4080,
480,
2339,
401,
754,
9,
267,
291,
14,
4080,
480,
13001,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
401,
754,
9,
267,
291,
14,
4080,
480,
10001,
401,
754,
9,
339,
347,
511,
63,
2384,
63,
6048,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
2498,
9762,
531,
267,
291,
14,
4080,
480,
8433,
8963,
1911,
6783,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1971,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1045,
63,
13444,
63,
1199,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
2355,
63,
1633,
63,
262,
63,
10910,
401,
754,
9,
339,
347,
511,
63,
2384,
63,
1397,
63,
4214,
8,
277,
304,
267,
536,
275,
298,
11324,
6997,
1272,
2,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
2498,
450,
83,
2,
450,
536,
9,
267,
291,
14,
4080,
480,
10924,
365,
949,
3589,
26,
450,
83,
2,
450,
536,
12,
754,
9,
339,
347,
511,
63,
2384,
63,
1397,
63,
4214,
63,
262,
63,
6100,
63,
3251,
8,
277,
304,
267,
536,
275,
298,
11324,
2,
267,
3231,
275,
298,
2865,
63,
5952,
2,
267,
754,
275,
291,
14,
82,
1183,
8,
288,
298,
2718,
2498,
1553,
354,
2818,
354,
9,
83,
1553,
3251,
2818,
3251,
9,
83,
2,
288,
450,
2420,
354,
582,
536,
12,
298,
3251,
582,
3231,
1552,
267,
291,
14,
4080,
8,
288,
298,
10924,
365,
949,
3589,
26,
2818,
354,
9,
83,
315,
2818,
3251,
9,
83,
3231,
2,
288,
450,
2420,
354,
582,
536,
12,
298,
3251,
582,
3231,
1386,
288,
754,
9,
339,
347,
511,
63,
513,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
769,
9762,
531,
267,
291,
14,
4080,
480,
11324,
14,
5869,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1971,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1045,
63,
13444,
63,
1199,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
2355,
63,
1633,
63,
262,
63,
10910,
401,
754,
9,
339,
347,
511,
63,
513,
63,
1397,
63,
4214,
63,
3251,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
769,
1553,
3251,
2005,
531,
267,
291,
14,
4080,
480,
10924,
365,
949,
3589,
3231,
26,
2005,
401,
754,
9,
339,
347,
511,
63,
513,
63,
1397,
63,
4214,
63,
354,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
769,
9762,
9993,
531,
267,
291,
14,
4080,
480,
10924,
365,
949,
3589,
26,
9762,
9993,
401,
754,
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
] |
[
1898,
6900,
26,
603,
723,
4466,
83,
3277,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
2882,
199,
199,
504,
2295,
14,
15481,
492,
3778,
421,
199,
533,
11349,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
5061,
1746,
12,
291,
680,
5996,
342,
267,
291,
14,
82,
1183,
275,
3778,
14,
50,
1183,
342,
339,
347,
511,
63,
2384,
63,
368,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
2498,
9762,
14,
5869,
63,
1045,
63,
13444,
63,
1199,
531,
267,
291,
14,
4080,
480,
2339,
401,
754,
9,
267,
291,
14,
4080,
480,
13001,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1045,
63,
13444,
63,
1199,
401,
754,
9,
267,
291,
14,
4080,
480,
10001,
401,
754,
9,
339,
347,
511,
63,
2384,
63,
6048,
63,
460,
63,
2861,
63,
1431,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
2498,
9762,
14,
5869,
531,
267,
291,
14,
4080,
480,
2339,
401,
754,
9,
267,
291,
14,
4080,
480,
13001,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
401,
754,
9,
267,
291,
14,
4080,
480,
10001,
401,
754,
9,
339,
347,
511,
63,
2384,
63,
6048,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
2498,
9762,
531,
267,
291,
14,
4080,
480,
8433,
8963,
1911,
6783,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1971,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1045,
63,
13444,
63,
1199,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
2355,
63,
1633,
63,
262,
63,
10910,
401,
754,
9,
339,
347,
511,
63,
2384,
63,
1397,
63,
4214,
8,
277,
304,
267,
536,
275,
298,
11324,
6997,
1272,
2,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
2498,
450,
83,
2,
450,
536,
9,
267,
291,
14,
4080,
480,
10924,
365,
949,
3589,
26,
450,
83,
2,
450,
536,
12,
754,
9,
339,
347,
511,
63,
2384,
63,
1397,
63,
4214,
63,
262,
63,
6100,
63,
3251,
8,
277,
304,
267,
536,
275,
298,
11324,
2,
267,
3231,
275,
298,
2865,
63,
5952,
2,
267,
754,
275,
291,
14,
82,
1183,
8,
288,
298,
2718,
2498,
1553,
354,
2818,
354,
9,
83,
1553,
3251,
2818,
3251,
9,
83,
2,
288,
450,
2420,
354,
582,
536,
12,
298,
3251,
582,
3231,
1552,
267,
291,
14,
4080,
8,
288,
298,
10924,
365,
949,
3589,
26,
2818,
354,
9,
83,
315,
2818,
3251,
9,
83,
3231,
2,
288,
450,
2420,
354,
582,
536,
12,
298,
3251,
582,
3231,
1386,
288,
754,
9,
339,
347,
511,
63,
513,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
769,
9762,
531,
267,
291,
14,
4080,
480,
11324,
14,
5869,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1971,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
1045,
63,
13444,
63,
1199,
401,
754,
9,
267,
291,
14,
4080,
480,
11324,
14,
5869,
63,
2355,
63,
1633,
63,
262,
63,
10910,
401,
754,
9,
339,
347,
511,
63,
513,
63,
1397,
63,
4214,
63,
3251,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
769,
1553,
3251,
2005,
531,
267,
291,
14,
4080,
480,
10924,
365,
949,
3589,
3231,
26,
2005,
401,
754,
9,
339,
347,
511,
63,
513,
63,
1397,
63,
4214,
63,
354,
8,
277,
304,
267,
754,
275,
291,
14,
82,
1183,
480,
2718,
769,
9762,
9993,
531,
267,
291,
14,
4080,
480,
10924,
365,
949,
3589,
26,
9762,
9993,
401,
754,
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,
0
] |
[
1,
1,
1,
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ing_iphone_pdf_417
|
cpp/scons/scons-local-2.0.0.final.0/SCons/Tool/dvipdf.py
|
34
|
4094
|
"""SCons.Tool.dvipdf
Tool-specific initialization for dvipdf.
There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""
#
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
__revision__ = "src/engine/SCons/Tool/dvipdf.py 5023 2010/06/14 22:05:46 scons"
import SCons.Action
import SCons.Defaults
import SCons.Tool.pdf
import SCons.Tool.tex
import SCons.Util
_null = SCons.Scanner.LaTeX._null
def DviPdfPsFunction(XXXDviAction, target = None, source= None, env=None):
"""A builder for DVI files that sets the TEXPICTS environment
variable before running dvi2ps or dvipdf."""
try:
abspath = source[0].attributes.path
except AttributeError :
abspath = ''
saved_env = SCons.Scanner.LaTeX.modify_env_var(env, 'TEXPICTS', abspath)
result = XXXDviAction(target, source, env)
if saved_env is _null:
try:
del env['ENV']['TEXPICTS']
except KeyError:
pass # was never set
else:
env['ENV']['TEXPICTS'] = saved_env
return result
def DviPdfFunction(target = None, source= None, env=None):
result = DviPdfPsFunction(PDFAction,target,source,env)
return result
def DviPdfStrFunction(target = None, source= None, env=None):
"""A strfunction for dvipdf that returns the appropriate
command string for the no_exec options."""
if env.GetOption("no_exec"):
result = env.subst('$DVIPDFCOM',0,target,source)
else:
result = ''
return result
PDFAction = None
DVIPDFAction = None
def PDFEmitter(target, source, env):
"""Strips any .aux or .log files from the input source list.
These are created by the TeX Builder that in all likelihood was
used to generate the .dvi file we're using as input, and we only
care about the .dvi file.
"""
def strip_suffixes(n):
return not SCons.Util.splitext(str(n))[1] in ['.aux', '.log']
source = list(filter(strip_suffixes, source))
return (target, source)
def generate(env):
"""Add Builders and construction variables for dvipdf to an Environment."""
global PDFAction
if PDFAction is None:
PDFAction = SCons.Action.Action('$DVIPDFCOM', '$DVIPDFCOMSTR')
global DVIPDFAction
if DVIPDFAction is None:
DVIPDFAction = SCons.Action.Action(DviPdfFunction, strfunction = DviPdfStrFunction)
import pdf
pdf.generate(env)
bld = env['BUILDERS']['PDF']
bld.add_action('.dvi', DVIPDFAction)
bld.add_emitter('.dvi', PDFEmitter)
env['DVIPDF'] = 'dvipdf'
env['DVIPDFFLAGS'] = SCons.Util.CLVar('')
env['DVIPDFCOM'] = 'cd ${TARGET.dir} && $DVIPDF $DVIPDFFLAGS ${SOURCE.file} ${TARGET.file}'
# Deprecated synonym.
env['PDFCOM'] = ['$DVIPDFCOM']
def exists(env):
return env.Detect('dvipdf')
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
|
apache-2.0
|
[
624,
18521,
14,
5157,
14,
68,
433,
5607,
199,
199,
5157,
13,
6100,
11097,
367,
366,
433,
5607,
14,
199,
199,
10924,
12252,
9296,
1133,
506,
1263,
1929,
370,
492,
642,
859,
5370,
14,
199,
7940,
911,
9987,
506,
8439,
4012,
314,
7809,
8218,
14,
5157,
14,
5157,
342,
199,
5592,
1083,
14,
199,
199,
624,
199,
199,
3,
199,
3,
1898,
334,
67,
9,
12521,
12,
14790,
12,
13004,
12,
8353,
12,
11811,
12,
8315,
12,
10219,
12,
9079,
12,
8937,
12,
7129,
710,
8218,
2752,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
199,
3,
282,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
199,
3,
11207,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
199,
3,
11291,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
199,
3,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
199,
3,
3826,
12,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
199,
3,
2990,
1634,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
5877,
8164,
6262,
199,
3,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
1621,
1261,
9612,
199,
3,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
11287,
199,
3,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
4141,
14,
199,
199,
363,
5792,
363,
275,
298,
2164,
15,
3908,
15,
18521,
15,
5157,
15,
68,
433,
5607,
14,
647,
959,
16771,
7129,
15,
1690,
15,
1079,
6928,
26,
1717,
26,
2466,
31551,
2,
199,
199,
646,
8218,
14,
3310,
199,
646,
8218,
14,
16986,
199,
646,
8218,
14,
5157,
14,
5607,
199,
646,
8218,
14,
5157,
14,
3858,
199,
646,
8218,
14,
9562,
199,
199,
63,
2307,
275,
8218,
14,
20843,
14,
7833,
12589,
423,
2307,
199,
199,
318,
577,
433,
48,
1587,
25512,
3481,
8,
13933,
36,
433,
3310,
12,
1347,
275,
488,
12,
1350,
29,
488,
12,
2589,
29,
403,
304,
272,
408,
33,
6545,
367,
577,
17655,
1584,
626,
5951,
314,
377,
11992,
6196,
51,
3734,
2126,
1750,
2544,
3879,
366,
433,
18,
1190,
503,
366,
433,
5607,
1041,
339,
862,
26,
267,
19529,
275,
1350,
59,
16,
1055,
2987,
14,
515,
272,
871,
4281,
520,
267,
19529,
275,
221,
2125,
339,
6290,
63,
1813,
275,
8218,
14,
20843,
14,
7833,
12589,
14,
8951,
63,
1813,
63,
1391,
8,
1813,
12,
283,
52,
11992,
6196,
51,
297,
19529,
9,
339,
754,
275,
5787,
36,
433,
3310,
8,
1375,
12,
1350,
12,
2589,
9,
339,
340,
6290,
63,
1813,
365,
485,
2307,
26,
267,
862,
26,
288,
2150,
2589,
459,
9984,
2545,
52,
11992,
6196,
51,
418,
267,
871,
4067,
26,
288,
986,
327,
1990,
7078,
663,
272,
587,
26,
267,
2589,
459,
9984,
2545,
52,
11992,
6196,
51,
418,
275,
6290,
63,
1813,
339,
372,
754,
199,
199,
318,
577,
433,
48,
1587,
3481,
8,
1375,
275,
488,
12,
1350,
29,
488,
12,
2589,
29,
403,
304,
272,
754,
275,
577,
433,
48,
1587,
25512,
3481,
8,
11435,
2078,
414,
12,
1375,
12,
1365,
12,
1813,
9,
272,
372,
754,
199,
199,
318,
577,
433,
48,
1587,
2848,
3481,
8,
1375,
275,
488,
12,
1350,
29,
488,
12,
2589,
29,
403,
304,
272,
408,
33,
620,
1593,
367,
366,
433,
5607,
626,
2529,
314,
5827,
272,
1414,
1059,
367,
314,
949,
63,
1628,
1511,
1041,
272,
340,
2589,
14,
1002,
2602,
480,
889,
63,
1628,
2349,
267,
754,
275,
2589,
14,
16747,
14676,
6741,
1772,
3888,
11265,
297,
16,
12,
1375,
12,
1365,
9,
272,
587,
26,
267,
754,
275,
2125,
272,
372,
754,
199,
199,
11435,
2078,
414,
275,
488,
199,
6741,
1772,
36,
2078,
414,
275,
488,
199,
199,
318,
15537,
37,
22541,
8,
1375,
12,
1350,
12,
2589,
304,
272,
408,
24125,
1190,
1263,
1275,
10962,
503,
1275,
793,
1584,
687,
314,
1324,
1350,
769,
14,
272,
5723,
787,
2737,
701,
314,
5773,
56,
19286,
626,
315,
1006,
22046,
1990,
272,
1202,
370,
3550,
314,
1275,
68,
433,
570,
781,
3984,
1808,
465,
1324,
12,
436,
781,
1454,
272,
10296,
3595,
314,
1275,
68,
433,
570,
14,
272,
408,
272,
347,
6202,
63,
16097,
8,
78,
304,
267,
372,
440,
8218,
14,
9562,
14,
7973,
8,
495,
8,
78,
11515,
17,
61,
315,
18953,
10962,
297,
1987,
793,
418,
272,
1350,
275,
769,
8,
1541,
8,
1913,
63,
16097,
12,
1350,
430,
272,
372,
334,
1375,
12,
1350,
9,
199,
199,
318,
3550,
8,
1813,
304,
272,
408,
1123,
19286,
83,
436,
14538,
2860,
367,
366,
433,
5607,
370,
376,
9711,
1041,
272,
2288,
510,
36,
2078,
414,
272,
340,
510,
36,
2078,
414,
365,
488,
26,
267,
510,
36,
2078,
414,
275,
8218,
14,
3310,
14,
3310,
14676,
6741,
1772,
3888,
11265,
297,
4505,
6741,
1772,
3888,
11265,
3027,
358,
339,
2288,
577,
54,
1772,
36,
2078,
414,
272,
340,
577,
54,
1772,
36,
2078,
414,
365,
488,
26,
267,
577,
54,
1772,
36,
2078,
414,
275,
8218,
14,
3310,
14,
3310,
8,
36,
433,
48,
1587,
3481,
12,
620,
1593,
275,
577,
433,
48,
1587,
2848,
3481,
9,
339,
492,
11249,
272,
11249,
14,
4208,
8,
1813,
9,
339,
27971,
275,
2589,
459,
8248,
3960,
2545,
7638,
418,
272,
27971,
14,
525,
63,
1287,
5175,
68,
433,
297,
577,
54,
1772,
36,
2078,
414,
9,
272,
27971,
14,
525,
63,
8159,
351,
5175,
68,
433,
297,
15537,
37,
22541,
9,
339,
2589,
459,
6741,
1772,
3888,
418,
420,
275,
283,
68,
433,
5607,
7,
272,
2589,
459,
6741,
1772,
36,
1665,
44,
1254,
51,
418,
275,
8218
] |
[
18521,
14,
5157,
14,
68,
433,
5607,
199,
199,
5157,
13,
6100,
11097,
367,
366,
433,
5607,
14,
199,
199,
10924,
12252,
9296,
1133,
506,
1263,
1929,
370,
492,
642,
859,
5370,
14,
199,
7940,
911,
9987,
506,
8439,
4012,
314,
7809,
8218,
14,
5157,
14,
5157,
342,
199,
5592,
1083,
14,
199,
199,
624,
199,
199,
3,
199,
3,
1898,
334,
67,
9,
12521,
12,
14790,
12,
13004,
12,
8353,
12,
11811,
12,
8315,
12,
10219,
12,
9079,
12,
8937,
12,
7129,
710,
8218,
2752,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
199,
3,
282,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
199,
3,
11207,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
199,
3,
11291,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
199,
3,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
199,
3,
3826,
12,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
199,
3,
2990,
1634,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
5877,
8164,
6262,
199,
3,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
1621,
1261,
9612,
199,
3,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
11287,
199,
3,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
4141,
14,
199,
199,
363,
5792,
363,
275,
298,
2164,
15,
3908,
15,
18521,
15,
5157,
15,
68,
433,
5607,
14,
647,
959,
16771,
7129,
15,
1690,
15,
1079,
6928,
26,
1717,
26,
2466,
31551,
2,
199,
199,
646,
8218,
14,
3310,
199,
646,
8218,
14,
16986,
199,
646,
8218,
14,
5157,
14,
5607,
199,
646,
8218,
14,
5157,
14,
3858,
199,
646,
8218,
14,
9562,
199,
199,
63,
2307,
275,
8218,
14,
20843,
14,
7833,
12589,
423,
2307,
199,
199,
318,
577,
433,
48,
1587,
25512,
3481,
8,
13933,
36,
433,
3310,
12,
1347,
275,
488,
12,
1350,
29,
488,
12,
2589,
29,
403,
304,
272,
408,
33,
6545,
367,
577,
17655,
1584,
626,
5951,
314,
377,
11992,
6196,
51,
3734,
2126,
1750,
2544,
3879,
366,
433,
18,
1190,
503,
366,
433,
5607,
1041,
339,
862,
26,
267,
19529,
275,
1350,
59,
16,
1055,
2987,
14,
515,
272,
871,
4281,
520,
267,
19529,
275,
221,
2125,
339,
6290,
63,
1813,
275,
8218,
14,
20843,
14,
7833,
12589,
14,
8951,
63,
1813,
63,
1391,
8,
1813,
12,
283,
52,
11992,
6196,
51,
297,
19529,
9,
339,
754,
275,
5787,
36,
433,
3310,
8,
1375,
12,
1350,
12,
2589,
9,
339,
340,
6290,
63,
1813,
365,
485,
2307,
26,
267,
862,
26,
288,
2150,
2589,
459,
9984,
2545,
52,
11992,
6196,
51,
418,
267,
871,
4067,
26,
288,
986,
327,
1990,
7078,
663,
272,
587,
26,
267,
2589,
459,
9984,
2545,
52,
11992,
6196,
51,
418,
275,
6290,
63,
1813,
339,
372,
754,
199,
199,
318,
577,
433,
48,
1587,
3481,
8,
1375,
275,
488,
12,
1350,
29,
488,
12,
2589,
29,
403,
304,
272,
754,
275,
577,
433,
48,
1587,
25512,
3481,
8,
11435,
2078,
414,
12,
1375,
12,
1365,
12,
1813,
9,
272,
372,
754,
199,
199,
318,
577,
433,
48,
1587,
2848,
3481,
8,
1375,
275,
488,
12,
1350,
29,
488,
12,
2589,
29,
403,
304,
272,
408,
33,
620,
1593,
367,
366,
433,
5607,
626,
2529,
314,
5827,
272,
1414,
1059,
367,
314,
949,
63,
1628,
1511,
1041,
272,
340,
2589,
14,
1002,
2602,
480,
889,
63,
1628,
2349,
267,
754,
275,
2589,
14,
16747,
14676,
6741,
1772,
3888,
11265,
297,
16,
12,
1375,
12,
1365,
9,
272,
587,
26,
267,
754,
275,
2125,
272,
372,
754,
199,
199,
11435,
2078,
414,
275,
488,
199,
6741,
1772,
36,
2078,
414,
275,
488,
199,
199,
318,
15537,
37,
22541,
8,
1375,
12,
1350,
12,
2589,
304,
272,
408,
24125,
1190,
1263,
1275,
10962,
503,
1275,
793,
1584,
687,
314,
1324,
1350,
769,
14,
272,
5723,
787,
2737,
701,
314,
5773,
56,
19286,
626,
315,
1006,
22046,
1990,
272,
1202,
370,
3550,
314,
1275,
68,
433,
570,
781,
3984,
1808,
465,
1324,
12,
436,
781,
1454,
272,
10296,
3595,
314,
1275,
68,
433,
570,
14,
272,
408,
272,
347,
6202,
63,
16097,
8,
78,
304,
267,
372,
440,
8218,
14,
9562,
14,
7973,
8,
495,
8,
78,
11515,
17,
61,
315,
18953,
10962,
297,
1987,
793,
418,
272,
1350,
275,
769,
8,
1541,
8,
1913,
63,
16097,
12,
1350,
430,
272,
372,
334,
1375,
12,
1350,
9,
199,
199,
318,
3550,
8,
1813,
304,
272,
408,
1123,
19286,
83,
436,
14538,
2860,
367,
366,
433,
5607,
370,
376,
9711,
1041,
272,
2288,
510,
36,
2078,
414,
272,
340,
510,
36,
2078,
414,
365,
488,
26,
267,
510,
36,
2078,
414,
275,
8218,
14,
3310,
14,
3310,
14676,
6741,
1772,
3888,
11265,
297,
4505,
6741,
1772,
3888,
11265,
3027,
358,
339,
2288,
577,
54,
1772,
36,
2078,
414,
272,
340,
577,
54,
1772,
36,
2078,
414,
365,
488,
26,
267,
577,
54,
1772,
36,
2078,
414,
275,
8218,
14,
3310,
14,
3310,
8,
36,
433,
48,
1587,
3481,
12,
620,
1593,
275,
577,
433,
48,
1587,
2848,
3481,
9,
339,
492,
11249,
272,
11249,
14,
4208,
8,
1813,
9,
339,
27971,
275,
2589,
459,
8248,
3960,
2545,
7638,
418,
272,
27971,
14,
525,
63,
1287,
5175,
68,
433,
297,
577,
54,
1772,
36,
2078,
414,
9,
272,
27971,
14,
525,
63,
8159,
351,
5175,
68,
433,
297,
15537,
37,
22541,
9,
339,
2589,
459,
6741,
1772,
3888,
418,
420,
275,
283,
68,
433,
5607,
7,
272,
2589,
459,
6741,
1772,
36,
1665,
44,
1254,
51,
418,
275,
8218,
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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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
aboutsajjad/Bridge
|
app_packages/youtube_dl/extractor/litv.py
|
64
|
6254
|
# coding: utf-8
from __future__ import unicode_literals
import json
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
smuggle_url,
unsmuggle_url,
)
class LiTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:vod|promo)/[^/]+/(?:content\.do)?\?.*?\b(?:content_)?id=(?P<id>[^&]+)'
_URL_TEMPLATE = 'https://www.litv.tv/vod/%s/content.do?id=%s'
_TESTS = [{
'url': 'https://www.litv.tv/vod/drama/content.do?brc_id=root&id=VOD00041610&isUHEnabled=true&autoPlay=1',
'info_dict': {
'id': 'VOD00041606',
'title': '花千骨',
},
'playlist_count': 50,
}, {
'url': 'https://www.litv.tv/vod/drama/content.do?brc_id=root&id=VOD00041610&isUHEnabled=true&autoPlay=1',
'md5': '969e343d9244778cb29acec608e53640',
'info_dict': {
'id': 'VOD00041610',
'ext': 'mp4',
'title': '花千骨第1集',
'thumbnail': r're:https?://.*\.jpg$',
'description': 'md5:c7017aa144c87467c4fb2909c4b05d6f',
'episode_number': 1,
},
'params': {
'noplaylist': True,
},
'skip': 'Georestricted to Taiwan',
}, {
'url': 'https://www.litv.tv/promo/miyuezhuan/?content_id=VOD00044841&',
'md5': '88322ea132f848d6e3e18b32a832b918',
'info_dict': {
'id': 'VOD00044841',
'ext': 'mp4',
'title': '芈月傳第1集 霸星芈月降世楚國',
'description': '楚威王二年,太史令唐昧夜觀星象,發現霸星即將現世。王后得知霸星的預言後,想盡辦法不讓孩子順利出生,幸得莒姬相護化解危機。沒想到眾人期待下出生的霸星卻是位公主,楚威王對此失望至極。楚王后命人將女嬰丟棄河中,居然奇蹟似的被少司命像攔下,楚威王認為此女非同凡響,為她取名芈月。',
},
'skip': 'Georestricted to Taiwan',
}]
def _extract_playlist(self, season_list, video_id, program_info, prompt=True):
episode_title = program_info['title']
content_id = season_list['contentId']
if prompt:
self.to_screen('Downloading playlist %s - add --no-playlist to just download video %s' % (content_id, video_id))
all_episodes = [
self.url_result(smuggle_url(
self._URL_TEMPLATE % (program_info['contentType'], episode['contentId']),
{'force_noplaylist': True})) # To prevent infinite recursion
for episode in season_list['episode']]
return self.playlist_result(all_episodes, content_id, episode_title)
def _real_extract(self, url):
url, data = unsmuggle_url(url, {})
video_id = self._match_id(url)
noplaylist = self._downloader.params.get('noplaylist')
noplaylist_prompt = True
if 'force_noplaylist' in data:
noplaylist = data['force_noplaylist']
noplaylist_prompt = False
webpage = self._download_webpage(url, video_id)
program_info = self._parse_json(self._search_regex(
r'var\s+programInfo\s*=\s*([^;]+)', webpage, 'VOD data', default='{}'),
video_id)
season_list = list(program_info.get('seasonList', {}).values())
if season_list:
if not noplaylist:
return self._extract_playlist(
season_list[0], video_id, program_info,
prompt=noplaylist_prompt)
if noplaylist_prompt:
self.to_screen('Downloading just video %s because of --no-playlist' % video_id)
# In browsers `getMainUrl` request is always issued. Usually this
# endpoint gives the same result as the data embedded in the webpage.
# If georestricted, there are no embedded data, so an extra request is
# necessary to get the error code
if 'assetId' not in program_info:
program_info = self._download_json(
'https://www.litv.tv/vod/ajax/getProgramInfo', video_id,
query={'contentId': video_id},
headers={'Accept': 'application/json'})
video_data = self._parse_json(self._search_regex(
r'uiHlsUrl\s*=\s*testBackendData\(([^;]+)\);',
webpage, 'video data', default='{}'), video_id)
if not video_data:
payload = {
'assetId': program_info['assetId'],
'watchDevices': program_info['watchDevices'],
'contentType': program_info['contentType'],
}
video_data = self._download_json(
'https://www.litv.tv/vod/getMainUrl', video_id,
data=json.dumps(payload).encode('utf-8'),
headers={'Content-Type': 'application/json'})
if not video_data.get('fullpath'):
error_msg = video_data.get('errorMessage')
if error_msg == 'vod.error.outsideregionerror':
self.raise_geo_restricted('This video is available in Taiwan only')
if error_msg:
raise ExtractorError('%s said: %s' % (self.IE_NAME, error_msg), expected=True)
raise ExtractorError('Unexpected result from %s' % self.IE_NAME)
formats = self._extract_m3u8_formats(
video_data['fullpath'], video_id, ext='mp4',
entry_protocol='m3u8_native', m3u8_id='hls')
for a_format in formats:
# LiTV HLS segments doesn't like compressions
a_format.setdefault('http_headers', {})['Youtubedl-no-compression'] = True
title = program_info['title'] + program_info.get('secondaryMark', '')
description = program_info.get('description')
thumbnail = program_info.get('imageFile')
categories = [item['name'] for item in program_info.get('category', [])]
episode = int_or_none(program_info.get('episode'))
return {
'id': video_id,
'formats': formats,
'title': title,
'description': description,
'thumbnail': thumbnail,
'categories': categories,
'episode_number': episode,
}
|
mit
|
[
3,
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2022,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
1208,
492,
334,
272,
19783,
12,
272,
1109,
63,
269,
63,
3592,
12,
272,
4383,
1518,
3845,
63,
633,
12,
272,
625,
3300,
1518,
3845,
63,
633,
12,
199,
9,
421,
199,
533,
24157,
12764,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
24524,
1544,
20316,
1051,
86,
4537,
6993,
32576,
86,
364,
92,
12741,
79,
2447,
26285,
32576,
1317,
4537,
1117,
5547,
29635,
21040,
66,
5169,
1317,
4602,
31,
344,
29,
2229,
48,
28,
344,
13489,
6,
29716,
339,
485,
2632,
63,
7433,
275,
283,
2859,
921,
1544,
14,
1051,
86,
14,
6993,
15,
86,
364,
3149,
83,
15,
1317,
14,
1117,
31,
344,
2458,
83,
7,
339,
485,
7569,
275,
8910,
267,
283,
633,
356,
283,
2859,
921,
1544,
14,
1051,
86,
14,
6993,
15,
86,
364,
15,
28385,
391,
15,
1317,
14,
1117,
31,
66,
1195,
63,
344,
29,
1231,
6,
344,
29,
10662,
36,
16643,
975,
709,
6,
374,
53,
40,
6589,
29,
2052,
6,
2495,
9651,
29,
17,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
10662,
36,
16643,
975,
1690,
297,
288,
283,
1213,
356,
283,
165,
233,
110,
10450,
226,
166,
104,
102,
297,
267,
1660,
267,
283,
10411,
63,
835,
356,
5238,
12,
272,
1660,
469,
267,
283,
633,
356,
283,
2859,
921,
1544,
14,
1051,
86,
14,
6993,
15,
86,
364,
15,
28385,
391,
15,
1317,
14,
1117,
31,
66,
1195,
63,
344,
29,
1231,
6,
344,
29,
10662,
36,
16643,
975,
709,
6,
374,
53,
40,
6589,
29,
2052,
6,
2495,
9651,
29,
17,
297,
267,
283,
1064,
21,
356,
283,
25675,
69,
14761,
68,
25,
11603,
16156,
2894,
1398,
7984,
67,
32700,
69,
2481,
12021,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
10662,
36,
16643,
975,
709,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
165,
233,
110,
10450,
226,
166,
104,
102,
25238,
106,
17,
22982,
229,
297,
288,
283,
8311,
356,
519,
3984,
26,
2859,
32569,
8476,
4268,
288,
283,
1802,
356,
283,
1064,
21,
26,
67,
23,
9570,
2158,
9862,
67,
28664,
1822,
67,
20,
4675,
1398,
1643,
67,
20,
66,
1717,
68,
22,
70,
297,
288,
283,
9544,
63,
1955,
356,
413,
12,
267,
1660,
267,
283,
1162,
356,
469,
288,
283,
20443,
817,
513,
356,
715,
12,
267,
1660,
267,
283,
2759,
356,
283,
4240,
720,
816,
1522,
370,
377,
5789,
20444,
297,
272,
1660,
469,
267,
283,
633,
356,
283,
2859,
921,
1544,
14,
1051,
86,
14,
6993,
15,
12741,
79,
15,
2664,
89,
310,
3951,
7856,
10197,
1317,
63,
344,
29,
10662,
36,
383,
9111,
19211,
16749,
267,
283,
1064,
21,
356,
283,
1299,
15858,
4489,
6557,
70,
15186,
68,
22,
69,
19,
69,
1085,
66,
708,
65,
24,
708,
66,
32486,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
10662,
36,
383,
9111,
19211,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
165,
233,
231,
31452,
162,
225,
112,
25238,
106,
17,
22982,
229,
12805,
223,
166,
251,
117,
6812,
254,
165,
233,
231,
31452,
17087,
236,
4344,
245,
163,
99,
249,
11987,
234,
297,
288,
283,
1802,
356,
283,
163,
99,
249,
162,
102,
224,
23434,
234,
6923,
235,
16322,
113,
12356,
11546,
104,
6075,
111,
5498,
98,
162,
243,
239,
6812,
101,
11546,
251,
21482,
223,
6812,
254,
165,
110,
95,
12356,
23460,
121,
164,
238,
123,
166,
251,
117,
6812,
254,
10450,
112,
15348,
230,
164,
238,
123,
4344,
245,
20061,
23434,
234,
30368,
19073,
246,
164,
18304,
166,
251,
117,
6812,
254,
8106,
166,
255,
239,
20278,
223,
19073,
235,
12356,
28190,
112,
15545,
95,
27252,
100,
27397,
19594,
14082,
242,
14651,
103,
14651,
239,
166,
255,
229,
9051,
103,
22914,
29319,
12356,
16322,
117,
19073,
246,
165,
237,
241,
25712,
106,
15545,
117,
165,
256,
116,
21018,
245,
21482,
97,
10450,
110,
163,
103,
254,
20061,
163,
111,
241,
28190,
112,
29507,
164,
251,
123,
25196,
14152,
19073,
228,
24233,
22914,
29319,
8106,
166,
251,
117,
6812,
254,
10450,
120,
9729,
30555,
19150,
4344,
120,
12356,
163,
99,
249,
162,
102,
224,
23434,
234,
15348,
236,
17627,
98,
11546,
110,
6587,
250,
27345,
112,
163,
99,
114,
20061,
163,
99,
249,
23434,
234,
30368,
19580,
122,
25196,
15348,
230,
25440,
112,
162,
106,
109,
4344,
254,
163,
97,
227,
163,
111,
112,
17088,
12356,
27289,
228,
164,
227,
115,
25440,
230,
165,
118,
254,
17848,
121,
8106,
165,
96,
105,
15348,
240,
20484,
19580,
122,
162,
226,
238,
17130,
243,
24233,
12356,
163,
99,
249,
162,
102,
224,
23434,
234,
165,
104,
236,
24889,
17627,
98,
25440,
112,
26398,
253,
28956,
15977,
95,
166,
254,
124,
12356,
24889,
25440,
118,
22924,
21434,
165,
233,
231,
31452,
20061,
297,
267,
1660,
267,
283,
2759,
356,
283,
4240,
720,
816,
1522,
370,
377,
5789,
20444,
297,
272,
14877,
339,
347,
485,
5005,
63,
10411,
8,
277,
12,
14718,
63,
513,
12,
3991,
63,
344,
12,
2240,
63,
815,
12,
8457,
29,
549,
304,
267,
11052,
63,
1213,
275,
2240,
63,
815,
459,
1213,
418,
267,
1564,
63,
344,
275,
14718,
63,
513,
459,
1317,
1304,
418,
398,
340,
8457,
26,
288,
291,
14,
475,
63,
5410,
360,
18085,
13210,
450,
83,
446,
1050,
1553,
889,
13,
10411,
370,
2951,
5235,
3991,
450,
83,
7,
450,
334,
1317,
63,
344,
12,
3991,
63,
344,
430,
398,
1006,
63,
22027,
275,
359,
288,
291,
14,
633,
63,
1099,
8,
3300,
1518,
3845,
63,
633,
8,
355,
291,
423,
2632,
63,
7433,
450,
334,
6815,
63,
815,
459,
1317,
804,
995,
11052,
459,
1317,
1304,
3815,
355,
791,
3990,
63,
20443,
817,
513,
356,
715,
12466,
221,
327,
4005,
7981,
15258,
16189,
288,
367,
11052,
315,
14718,
63,
513,
459,
9544,
6538,
398,
372,
291,
14,
10411,
63,
1099,
8,
452,
63,
22027,
12,
1564,
63,
344,
12,
11052,
63,
1213,
9,
339
] |
[
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2022,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
1208,
492,
334,
272,
19783,
12,
272,
1109,
63,
269,
63,
3592,
12,
272,
4383,
1518,
3845,
63,
633,
12,
272,
625,
3300,
1518,
3845,
63,
633,
12,
199,
9,
421,
199,
533,
24157,
12764,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
24524,
1544,
20316,
1051,
86,
4537,
6993,
32576,
86,
364,
92,
12741,
79,
2447,
26285,
32576,
1317,
4537,
1117,
5547,
29635,
21040,
66,
5169,
1317,
4602,
31,
344,
29,
2229,
48,
28,
344,
13489,
6,
29716,
339,
485,
2632,
63,
7433,
275,
283,
2859,
921,
1544,
14,
1051,
86,
14,
6993,
15,
86,
364,
3149,
83,
15,
1317,
14,
1117,
31,
344,
2458,
83,
7,
339,
485,
7569,
275,
8910,
267,
283,
633,
356,
283,
2859,
921,
1544,
14,
1051,
86,
14,
6993,
15,
86,
364,
15,
28385,
391,
15,
1317,
14,
1117,
31,
66,
1195,
63,
344,
29,
1231,
6,
344,
29,
10662,
36,
16643,
975,
709,
6,
374,
53,
40,
6589,
29,
2052,
6,
2495,
9651,
29,
17,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
10662,
36,
16643,
975,
1690,
297,
288,
283,
1213,
356,
283,
165,
233,
110,
10450,
226,
166,
104,
102,
297,
267,
1660,
267,
283,
10411,
63,
835,
356,
5238,
12,
272,
1660,
469,
267,
283,
633,
356,
283,
2859,
921,
1544,
14,
1051,
86,
14,
6993,
15,
86,
364,
15,
28385,
391,
15,
1317,
14,
1117,
31,
66,
1195,
63,
344,
29,
1231,
6,
344,
29,
10662,
36,
16643,
975,
709,
6,
374,
53,
40,
6589,
29,
2052,
6,
2495,
9651,
29,
17,
297,
267,
283,
1064,
21,
356,
283,
25675,
69,
14761,
68,
25,
11603,
16156,
2894,
1398,
7984,
67,
32700,
69,
2481,
12021,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
10662,
36,
16643,
975,
709,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
165,
233,
110,
10450,
226,
166,
104,
102,
25238,
106,
17,
22982,
229,
297,
288,
283,
8311,
356,
519,
3984,
26,
2859,
32569,
8476,
4268,
288,
283,
1802,
356,
283,
1064,
21,
26,
67,
23,
9570,
2158,
9862,
67,
28664,
1822,
67,
20,
4675,
1398,
1643,
67,
20,
66,
1717,
68,
22,
70,
297,
288,
283,
9544,
63,
1955,
356,
413,
12,
267,
1660,
267,
283,
1162,
356,
469,
288,
283,
20443,
817,
513,
356,
715,
12,
267,
1660,
267,
283,
2759,
356,
283,
4240,
720,
816,
1522,
370,
377,
5789,
20444,
297,
272,
1660,
469,
267,
283,
633,
356,
283,
2859,
921,
1544,
14,
1051,
86,
14,
6993,
15,
12741,
79,
15,
2664,
89,
310,
3951,
7856,
10197,
1317,
63,
344,
29,
10662,
36,
383,
9111,
19211,
16749,
267,
283,
1064,
21,
356,
283,
1299,
15858,
4489,
6557,
70,
15186,
68,
22,
69,
19,
69,
1085,
66,
708,
65,
24,
708,
66,
32486,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
10662,
36,
383,
9111,
19211,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
165,
233,
231,
31452,
162,
225,
112,
25238,
106,
17,
22982,
229,
12805,
223,
166,
251,
117,
6812,
254,
165,
233,
231,
31452,
17087,
236,
4344,
245,
163,
99,
249,
11987,
234,
297,
288,
283,
1802,
356,
283,
163,
99,
249,
162,
102,
224,
23434,
234,
6923,
235,
16322,
113,
12356,
11546,
104,
6075,
111,
5498,
98,
162,
243,
239,
6812,
101,
11546,
251,
21482,
223,
6812,
254,
165,
110,
95,
12356,
23460,
121,
164,
238,
123,
166,
251,
117,
6812,
254,
10450,
112,
15348,
230,
164,
238,
123,
4344,
245,
20061,
23434,
234,
30368,
19073,
246,
164,
18304,
166,
251,
117,
6812,
254,
8106,
166,
255,
239,
20278,
223,
19073,
235,
12356,
28190,
112,
15545,
95,
27252,
100,
27397,
19594,
14082,
242,
14651,
103,
14651,
239,
166,
255,
229,
9051,
103,
22914,
29319,
12356,
16322,
117,
19073,
246,
165,
237,
241,
25712,
106,
15545,
117,
165,
256,
116,
21018,
245,
21482,
97,
10450,
110,
163,
103,
254,
20061,
163,
111,
241,
28190,
112,
29507,
164,
251,
123,
25196,
14152,
19073,
228,
24233,
22914,
29319,
8106,
166,
251,
117,
6812,
254,
10450,
120,
9729,
30555,
19150,
4344,
120,
12356,
163,
99,
249,
162,
102,
224,
23434,
234,
15348,
236,
17627,
98,
11546,
110,
6587,
250,
27345,
112,
163,
99,
114,
20061,
163,
99,
249,
23434,
234,
30368,
19580,
122,
25196,
15348,
230,
25440,
112,
162,
106,
109,
4344,
254,
163,
97,
227,
163,
111,
112,
17088,
12356,
27289,
228,
164,
227,
115,
25440,
230,
165,
118,
254,
17848,
121,
8106,
165,
96,
105,
15348,
240,
20484,
19580,
122,
162,
226,
238,
17130,
243,
24233,
12356,
163,
99,
249,
162,
102,
224,
23434,
234,
165,
104,
236,
24889,
17627,
98,
25440,
112,
26398,
253,
28956,
15977,
95,
166,
254,
124,
12356,
24889,
25440,
118,
22924,
21434,
165,
233,
231,
31452,
20061,
297,
267,
1660,
267,
283,
2759,
356,
283,
4240,
720,
816,
1522,
370,
377,
5789,
20444,
297,
272,
14877,
339,
347,
485,
5005,
63,
10411,
8,
277,
12,
14718,
63,
513,
12,
3991,
63,
344,
12,
2240,
63,
815,
12,
8457,
29,
549,
304,
267,
11052,
63,
1213,
275,
2240,
63,
815,
459,
1213,
418,
267,
1564,
63,
344,
275,
14718,
63,
513,
459,
1317,
1304,
418,
398,
340,
8457,
26,
288,
291,
14,
475,
63,
5410,
360,
18085,
13210,
450,
83,
446,
1050,
1553,
889,
13,
10411,
370,
2951,
5235,
3991,
450,
83,
7,
450,
334,
1317,
63,
344,
12,
3991,
63,
344,
430,
398,
1006,
63,
22027,
275,
359,
288,
291,
14,
633,
63,
1099,
8,
3300,
1518,
3845,
63,
633,
8,
355,
291,
423,
2632,
63,
7433,
450,
334,
6815,
63,
815,
459,
1317,
804,
995,
11052,
459,
1317,
1304,
3815,
355,
791,
3990,
63,
20443,
817,
513,
356,
715,
12466,
221,
327,
4005,
7981,
15258,
16189,
288,
367,
11052,
315,
14718,
63,
513,
459,
9544,
6538,
398,
372,
291,
14,
10411,
63,
1099,
8,
452,
63,
22027,
12,
1564,
63,
344,
12,
11052,
63,
1213,
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,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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
] |
resmo/ansible
|
test/units/modules/cloud/misc/virt_net/test_virt_net.py
|
38
|
1081
|
# -*- coding: utf-8 -*-
#
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from units.compat import mock
def test_virt_net_create_already_active(virt_net_obj, dummy_libvirt):
virt_net_obj.conn.create = mock.Mock()
assert virt_net_obj.create("active_net") is None
virt_net_obj.conn.create.assert_not_called()
def test_virt_net_recreate(virt_net_obj, dummy_libvirt):
virt_net_obj.conn.create = mock.Mock()
dummy_libvirt.libvirtError.error_code = 'VIR_ERR_NETWORK_EXIST'
virt_net_obj.conn.create.side_effect = dummy_libvirt.libvirtError
assert virt_net_obj.create("active_net") is None
def test_virt_stop_ignore_inactive(virt_net_obj):
virt_net_obj.conn.destroy = mock.Mock()
virt_net_obj.stop('inactive_net')
virt_net_obj.conn.destroy.assert_not_called()
def test_virt_stop_active(virt_net_obj, monkeypatch):
virt_net_obj.conn.destroy = mock.Mock()
virt_net_obj.stop('active_net')
virt_net_obj.conn.destroy.assert_called_with('active_net')
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
20312,
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,
504,
6204,
14,
5819,
492,
1683,
421,
199,
318,
511,
63,
4549,
63,
846,
63,
981,
63,
14039,
63,
2682,
8,
4549,
63,
846,
63,
1113,
12,
7283,
63,
11877,
304,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
981,
275,
1683,
14,
3346,
342,
272,
702,
12043,
63,
846,
63,
1113,
14,
981,
480,
2682,
63,
846,
531,
365,
488,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
981,
14,
479,
63,
1397,
63,
3527,
342,
421,
199,
318,
511,
63,
4549,
63,
846,
63,
264,
981,
8,
4549,
63,
846,
63,
1113,
12,
7283,
63,
11877,
304,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
981,
275,
1683,
14,
3346,
342,
272,
7283,
63,
11877,
14,
11877,
547,
14,
705,
63,
600,
275,
283,
13679,
63,
2666,
63,
14560,
63,
13301,
7,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
981,
14,
2441,
63,
5881,
275,
7283,
63,
11877,
14,
11877,
547,
272,
702,
12043,
63,
846,
63,
1113,
14,
981,
480,
2682,
63,
846,
531,
365,
488,
421,
199,
318,
511,
63,
4549,
63,
2379,
63,
4247,
63,
16856,
8,
4549,
63,
846,
63,
1113,
304,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
7237,
275,
1683,
14,
3346,
342,
272,
12043,
63,
846,
63,
1113,
14,
2379,
360,
16856,
63,
846,
358,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
7237,
14,
479,
63,
1397,
63,
3527,
342,
421,
199,
318,
511,
63,
4549,
63,
2379,
63,
2682,
8,
4549,
63,
846,
63,
1113,
12,
17309,
304,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
7237,
275,
1683,
14,
3346,
342,
272,
12043,
63,
846,
63,
1113,
14,
2379,
360,
2682,
63,
846,
358,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
7237,
14,
479,
63,
3527,
63,
1045,
360,
2682,
63,
846,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
20312,
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,
504,
6204,
14,
5819,
492,
1683,
421,
199,
318,
511,
63,
4549,
63,
846,
63,
981,
63,
14039,
63,
2682,
8,
4549,
63,
846,
63,
1113,
12,
7283,
63,
11877,
304,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
981,
275,
1683,
14,
3346,
342,
272,
702,
12043,
63,
846,
63,
1113,
14,
981,
480,
2682,
63,
846,
531,
365,
488,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
981,
14,
479,
63,
1397,
63,
3527,
342,
421,
199,
318,
511,
63,
4549,
63,
846,
63,
264,
981,
8,
4549,
63,
846,
63,
1113,
12,
7283,
63,
11877,
304,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
981,
275,
1683,
14,
3346,
342,
272,
7283,
63,
11877,
14,
11877,
547,
14,
705,
63,
600,
275,
283,
13679,
63,
2666,
63,
14560,
63,
13301,
7,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
981,
14,
2441,
63,
5881,
275,
7283,
63,
11877,
14,
11877,
547,
272,
702,
12043,
63,
846,
63,
1113,
14,
981,
480,
2682,
63,
846,
531,
365,
488,
421,
199,
318,
511,
63,
4549,
63,
2379,
63,
4247,
63,
16856,
8,
4549,
63,
846,
63,
1113,
304,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
7237,
275,
1683,
14,
3346,
342,
272,
12043,
63,
846,
63,
1113,
14,
2379,
360,
16856,
63,
846,
358,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
7237,
14,
479,
63,
1397,
63,
3527,
342,
421,
199,
318,
511,
63,
4549,
63,
2379,
63,
2682,
8,
4549,
63,
846,
63,
1113,
12,
17309,
304,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
7237,
275,
1683,
14,
3346,
342,
272,
12043,
63,
846,
63,
1113,
14,
2379,
360,
2682,
63,
846,
358,
272,
12043,
63,
846,
63,
1113,
14,
1631,
14,
7237,
14,
479,
63,
3527,
63,
1045,
360,
2682,
63,
846,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
laszlocsomor/tensorflow
|
tensorflow/python/keras/_impl/keras/applications/inception_v3_test.py
|
34
|
2148
|
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for Inception V3 application."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from tensorflow.python.keras._impl import keras
from tensorflow.python.platform import test
class InceptionV3Test(test.TestCase):
def test_with_top(self):
model = keras.applications.InceptionV3(weights=None)
self.assertEqual(model.output_shape, (None, 1000))
def test_no_top(self):
model = keras.applications.InceptionV3(weights=None, include_top=False)
self.assertEqual(model.output_shape, (None, None, None, 2048))
def test_with_pooling(self):
model = keras.applications.InceptionV3(weights=None,
include_top=False,
pooling='avg')
self.assertEqual(model.output_shape, (None, 2048))
def test_weight_loading(self):
with self.assertRaises(ValueError):
keras.applications.InceptionV3(weights='unknown',
include_top=False)
with self.assertRaises(ValueError):
keras.applications.InceptionV3(weights='imagenet',
classes=2000)
def test_preprocess_input(self):
x = np.random.uniform(0, 255, (2, 300, 200, 3))
out1 = keras.applications.inception_v3.preprocess_input(x)
self.assertAllClose(np.mean(out1), 0., atol=0.1)
if __name__ == '__main__':
test.main()
|
apache-2.0
|
[
3,
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
2925,
367,
1010,
814,
812,
19,
4223,
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,
8811,
423,
5472,
492,
11708,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
421,
199,
533,
1010,
814,
54,
19,
774,
8,
396,
14,
1746,
304,
819,
347,
511,
63,
1045,
63,
2119,
8,
277,
304,
272,
1402,
275,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
29,
403,
9,
272,
291,
14,
629,
8,
1238,
14,
1199,
63,
1392,
12,
334,
403,
12,
5198,
430,
819,
347,
511,
63,
889,
63,
2119,
8,
277,
304,
272,
1402,
275,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
29,
403,
12,
2387,
63,
2119,
29,
797,
9,
272,
291,
14,
629,
8,
1238,
14,
1199,
63,
1392,
12,
334,
403,
12,
488,
12,
488,
12,
18427,
430,
819,
347,
511,
63,
1045,
63,
28624,
8,
277,
304,
272,
1402,
275,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
29,
403,
12,
5644,
2387,
63,
2119,
29,
797,
12,
5644,
20699,
534,
8595,
358,
272,
291,
14,
629,
8,
1238,
14,
1199,
63,
1392,
12,
334,
403,
12,
18427,
430,
819,
347,
511,
63,
3463,
63,
8786,
8,
277,
304,
272,
543,
291,
14,
1855,
8,
3393,
304,
489,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
534,
5187,
297,
3660,
2387,
63,
2119,
29,
797,
9,
272,
543,
291,
14,
1855,
8,
3393,
304,
489,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
534,
11744,
2268,
386,
297,
3660,
3992,
29,
8269,
9,
819,
347,
511,
63,
17677,
63,
1210,
8,
277,
304,
272,
671,
275,
980,
14,
2355,
14,
8830,
8,
16,
12,
5450,
12,
334,
18,
12,
9601,
12,
1926,
12,
650,
430,
272,
734,
17,
275,
11708,
14,
15853,
14,
262,
814,
63,
86,
19,
14,
17677,
63,
1210,
8,
88,
9,
272,
291,
14,
7260,
8,
1590,
14,
3670,
8,
548,
17,
395,
378,
2020,
9543,
29,
16,
14,
17,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
511,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
2925,
367,
1010,
814,
812,
19,
4223,
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,
8811,
423,
5472,
492,
11708,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
421,
199,
533,
1010,
814,
54,
19,
774,
8,
396,
14,
1746,
304,
819,
347,
511,
63,
1045,
63,
2119,
8,
277,
304,
272,
1402,
275,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
29,
403,
9,
272,
291,
14,
629,
8,
1238,
14,
1199,
63,
1392,
12,
334,
403,
12,
5198,
430,
819,
347,
511,
63,
889,
63,
2119,
8,
277,
304,
272,
1402,
275,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
29,
403,
12,
2387,
63,
2119,
29,
797,
9,
272,
291,
14,
629,
8,
1238,
14,
1199,
63,
1392,
12,
334,
403,
12,
488,
12,
488,
12,
18427,
430,
819,
347,
511,
63,
1045,
63,
28624,
8,
277,
304,
272,
1402,
275,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
29,
403,
12,
5644,
2387,
63,
2119,
29,
797,
12,
5644,
20699,
534,
8595,
358,
272,
291,
14,
629,
8,
1238,
14,
1199,
63,
1392,
12,
334,
403,
12,
18427,
430,
819,
347,
511,
63,
3463,
63,
8786,
8,
277,
304,
272,
543,
291,
14,
1855,
8,
3393,
304,
489,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
534,
5187,
297,
3660,
2387,
63,
2119,
29,
797,
9,
272,
543,
291,
14,
1855,
8,
3393,
304,
489,
11708,
14,
15853,
14,
607,
814,
54,
19,
8,
4916,
534,
11744,
2268,
386,
297,
3660,
3992,
29,
8269,
9,
819,
347,
511,
63,
17677,
63,
1210,
8,
277,
304,
272,
671,
275,
980,
14,
2355,
14,
8830,
8,
16,
12,
5450,
12,
334,
18,
12,
9601,
12,
1926,
12,
650,
430,
272,
734,
17,
275,
11708,
14,
15853,
14,
262,
814,
63,
86,
19,
14,
17677,
63,
1210,
8,
88,
9,
272,
291,
14,
7260,
8,
1590,
14,
3670,
8,
548,
17,
395,
378,
2020,
9543,
29,
16,
14,
17,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
511,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
BMJHayward/django
|
django/db/backends/mysql/introspection.py
|
363
|
9023
|
from collections import namedtuple
from MySQLdb.constants import FIELD_TYPE
from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo, TableInfo,
)
from django.utils.datastructures import OrderedSet
from django.utils.encoding import force_text
FieldInfo = namedtuple('FieldInfo', FieldInfo._fields + ('extra', 'default'))
InfoLine = namedtuple('InfoLine', 'col_name data_type max_len num_prec num_scale extra column_default')
class DatabaseIntrospection(BaseDatabaseIntrospection):
data_types_reverse = {
FIELD_TYPE.BLOB: 'TextField',
FIELD_TYPE.CHAR: 'CharField',
FIELD_TYPE.DECIMAL: 'DecimalField',
FIELD_TYPE.NEWDECIMAL: 'DecimalField',
FIELD_TYPE.DATE: 'DateField',
FIELD_TYPE.DATETIME: 'DateTimeField',
FIELD_TYPE.DOUBLE: 'FloatField',
FIELD_TYPE.FLOAT: 'FloatField',
FIELD_TYPE.INT24: 'IntegerField',
FIELD_TYPE.LONG: 'IntegerField',
FIELD_TYPE.LONGLONG: 'BigIntegerField',
FIELD_TYPE.SHORT: 'SmallIntegerField',
FIELD_TYPE.STRING: 'CharField',
FIELD_TYPE.TIME: 'TimeField',
FIELD_TYPE.TIMESTAMP: 'DateTimeField',
FIELD_TYPE.TINY: 'IntegerField',
FIELD_TYPE.TINY_BLOB: 'TextField',
FIELD_TYPE.MEDIUM_BLOB: 'TextField',
FIELD_TYPE.LONG_BLOB: 'TextField',
FIELD_TYPE.VAR_STRING: 'CharField',
}
def get_field_type(self, data_type, description):
field_type = super(DatabaseIntrospection, self).get_field_type(data_type, description)
if field_type == 'IntegerField' and 'auto_increment' in description.extra:
return 'AutoField'
return field_type
def get_table_list(self, cursor):
"""
Returns a list of table and view names in the current database.
"""
cursor.execute("SHOW FULL TABLES")
return [TableInfo(row[0], {'BASE TABLE': 't', 'VIEW': 'v'}.get(row[1]))
for row in cursor.fetchall()]
def get_table_description(self, cursor, table_name):
"""
Returns a description of the table, with the DB-API cursor.description interface."
"""
# information_schema database gives more accurate results for some figures:
# - varchar length returned by cursor.description is an internal length,
# not visible length (#5725)
# - precision and scale (for decimal fields) (#5014)
# - auto_increment is not available in cursor.description
cursor.execute("""
SELECT column_name, data_type, character_maximum_length, numeric_precision,
numeric_scale, extra, column_default
FROM information_schema.columns
WHERE table_name = %s AND table_schema = DATABASE()""", [table_name])
field_info = {line[0]: InfoLine(*line) for line in cursor.fetchall()}
cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
to_int = lambda i: int(i) if i is not None else i
fields = []
for line in cursor.description:
col_name = force_text(line[0])
fields.append(
FieldInfo(*((col_name,)
+ line[1:3]
+ (to_int(field_info[col_name].max_len) or line[3],
to_int(field_info[col_name].num_prec) or line[4],
to_int(field_info[col_name].num_scale) or line[5])
+ (line[6],)
+ (field_info[col_name].extra,)
+ (field_info[col_name].column_default,)))
)
return fields
def get_relations(self, cursor, table_name):
"""
Returns a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
"""
constraints = self.get_key_columns(cursor, table_name)
relations = {}
for my_fieldname, other_table, other_field in constraints:
relations[my_fieldname] = (other_field, other_table)
return relations
def get_key_columns(self, cursor, table_name):
"""
Returns a list of (column_name, referenced_table_name, referenced_column_name) for all
key columns in given table.
"""
key_columns = []
cursor.execute("""
SELECT column_name, referenced_table_name, referenced_column_name
FROM information_schema.key_column_usage
WHERE table_name = %s
AND table_schema = DATABASE()
AND referenced_table_name IS NOT NULL
AND referenced_column_name IS NOT NULL""", [table_name])
key_columns.extend(cursor.fetchall())
return key_columns
def get_indexes(self, cursor, table_name):
cursor.execute("SHOW INDEX FROM %s" % self.connection.ops.quote_name(table_name))
# Do a two-pass search for indexes: on first pass check which indexes
# are multicolumn, on second pass check which single-column indexes
# are present.
rows = list(cursor.fetchall())
multicol_indexes = set()
for row in rows:
if row[3] > 1:
multicol_indexes.add(row[2])
indexes = {}
for row in rows:
if row[2] in multicol_indexes:
continue
if row[4] not in indexes:
indexes[row[4]] = {'primary_key': False, 'unique': False}
# It's possible to have the unique and PK constraints in separate indexes.
if row[2] == 'PRIMARY':
indexes[row[4]]['primary_key'] = True
if not row[1]:
indexes[row[4]]['unique'] = True
return indexes
def get_storage_engine(self, cursor, table_name):
"""
Retrieves the storage engine for a given table. Returns the default
storage engine if the table doesn't exist.
"""
cursor.execute(
"SELECT engine "
"FROM information_schema.tables "
"WHERE table_name = %s", [table_name])
result = cursor.fetchone()
if not result:
return self.connection.features._mysql_storage_engine
return result[0]
def get_constraints(self, cursor, table_name):
"""
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
"""
constraints = {}
# Get the actual constraint names and columns
name_query = """
SELECT kc.`constraint_name`, kc.`column_name`,
kc.`referenced_table_name`, kc.`referenced_column_name`
FROM information_schema.key_column_usage AS kc
WHERE
kc.table_schema = %s AND
kc.table_name = %s
"""
cursor.execute(name_query, [self.connection.settings_dict['NAME'], table_name])
for constraint, column, ref_table, ref_column in cursor.fetchall():
if constraint not in constraints:
constraints[constraint] = {
'columns': OrderedSet(),
'primary_key': False,
'unique': False,
'index': False,
'check': False,
'foreign_key': (ref_table, ref_column) if ref_column else None,
}
constraints[constraint]['columns'].add(column)
# Now get the constraint types
type_query = """
SELECT c.constraint_name, c.constraint_type
FROM information_schema.table_constraints AS c
WHERE
c.table_schema = %s AND
c.table_name = %s
"""
cursor.execute(type_query, [self.connection.settings_dict['NAME'], table_name])
for constraint, kind in cursor.fetchall():
if kind.lower() == "primary key":
constraints[constraint]['primary_key'] = True
constraints[constraint]['unique'] = True
elif kind.lower() == "unique":
constraints[constraint]['unique'] = True
# Now add in the indexes
cursor.execute("SHOW INDEX FROM %s" % self.connection.ops.quote_name(table_name))
for table, non_unique, index, colseq, column in [x[:5] for x in cursor.fetchall()]:
if index not in constraints:
constraints[index] = {
'columns': OrderedSet(),
'primary_key': False,
'unique': False,
'index': True,
'check': False,
'foreign_key': None,
}
constraints[index]['index'] = True
constraints[index]['columns'].add(column)
# Convert the sorted sets to lists
for constraint in constraints.values():
constraint['columns'] = list(constraint['columns'])
return constraints
|
bsd-3-clause
|
[
504,
5055,
492,
12863,
199,
199,
504,
25709,
14,
5559,
492,
26130,
63,
2711,
199,
199,
504,
1639,
14,
697,
14,
7765,
14,
1095,
14,
21627,
492,
334,
272,
29103,
30516,
12,
5024,
2354,
12,
6957,
2354,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
23004,
492,
23617,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
199,
792,
2354,
275,
12863,
360,
792,
2354,
297,
5024,
2354,
423,
955,
435,
661,
2911,
297,
283,
885,
1333,
199,
2354,
3049,
275,
12863,
360,
2354,
3049,
297,
283,
761,
63,
354,
666,
63,
466,
1390,
63,
552,
1967,
63,
9218,
1967,
63,
3467,
2402,
2763,
63,
885,
358,
421,
199,
533,
8692,
30516,
8,
1563,
7243,
30516,
304,
272,
666,
63,
1313,
63,
4471,
275,
469,
267,
26130,
63,
2711,
14,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
5901,
26,
283,
2183,
297,
267,
26130,
63,
2711,
14,
23925,
26,
283,
15975,
297,
267,
26130,
63,
2711,
14,
11365,
23925,
26,
283,
15975,
297,
267,
26130,
63,
2711,
14,
5390,
26,
283,
14071,
297,
267,
26130,
63,
2711,
14,
12488,
26,
283,
4626,
297,
267,
26130,
63,
2711,
14,
14989,
26,
283,
13019,
297,
267,
26130,
63,
2711,
14,
11783,
26,
283,
13019,
297,
267,
26130,
63,
2711,
14,
2919,
1194,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
12375,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
44,
615,
2226,
7770,
26,
283,
25175,
297,
267,
26130,
63,
2711,
14,
13003,
26,
283,
14640,
297,
267,
26130,
63,
2711,
14,
5353,
26,
283,
2183,
297,
267,
26130,
63,
2711,
14,
4961,
26,
283,
27115,
297,
267,
26130,
63,
2711,
14,
20277,
26,
283,
4626,
297,
267,
26130,
63,
2711,
14,
31178,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
31178,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
9754,
2639,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
12375,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
5568,
63,
5353,
26,
283,
2183,
297,
272,
789,
339,
347,
664,
63,
698,
63,
466,
8,
277,
12,
666,
63,
466,
12,
1369,
304,
267,
901,
63,
466,
275,
1613,
8,
7243,
30516,
12,
291,
680,
362,
63,
698,
63,
466,
8,
576,
63,
466,
12,
1369,
9,
267,
340,
901,
63,
466,
508,
283,
3901,
7,
436,
283,
2495,
63,
9728,
7,
315,
1369,
14,
2911,
26,
288,
372,
283,
4378,
7,
267,
372,
901,
63,
466,
339,
347,
664,
63,
1224,
63,
513,
8,
277,
12,
3920,
304,
267,
408,
267,
1803,
282,
769,
402,
1817,
436,
2455,
1561,
315,
314,
1453,
3050,
14,
267,
408,
267,
3920,
14,
2526,
480,
19085,
18530,
377,
17041,
531,
267,
372,
359,
3186,
2354,
8,
1143,
59,
16,
467,
791,
5825,
9934,
356,
283,
84,
297,
283,
12058,
356,
283,
86,
936,
14,
362,
8,
1143,
59,
17,
2459,
355,
367,
1962,
315,
3920,
14,
10174,
5106,
339,
347,
664,
63,
1224,
63,
1802,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
1369,
402,
314,
1817,
12,
543,
314,
6249,
13,
3735,
3920,
14,
1802,
3217,
2122,
267,
408,
267,
327,
2556,
63,
3629,
3050,
10557,
1655,
23189,
2058,
367,
2005,
6085,
1482,
26,
267,
327,
446,
31044,
2582,
2138,
701,
3920,
14,
1802,
365,
376,
5007,
2582,
12,
267,
327,
257,
440,
8917,
2582,
15196,
1641,
821,
9,
267,
327,
446,
7151,
436,
4666,
334,
509,
6107,
1504,
9,
15196,
8216,
20,
9,
267,
327,
446,
2599,
63,
9728,
365,
440,
2808,
315,
3920,
14,
1802,
267,
3920,
14,
2526,
4852,
288,
10468,
2763,
63,
354,
12,
666,
63,
466,
12,
4528,
63,
11555,
63,
1267,
12,
8950,
63,
6833,
12,
673,
8950,
63,
3467,
12,
2402,
12,
2763,
63,
885,
288,
4442,
2556,
63,
3629,
14,
3406,
288,
6038,
1817,
63,
354,
275,
450,
83,
2401,
1817,
63,
3629,
275,
31705,
342,
7208,
359,
1224,
63,
354,
566,
267,
901,
63,
815,
275,
469,
604,
59,
16,
2189,
10332,
3049,
2031,
604,
9,
367,
1004,
315,
3920,
14,
10174,
12737,
398,
3920,
14,
2526,
480,
4859,
627,
4442,
450,
83,
5138,
413,
2,
450,
291,
14,
2105,
14,
1483,
14,
3513,
63,
354,
8,
1224,
63,
354,
430,
267,
370,
63,
442,
275,
2400,
284,
26,
1109,
8,
73,
9,
340,
284,
365,
440,
488,
587,
284,
267,
1504,
275,
942,
267,
367,
1004,
315,
3920,
14,
1802,
26,
288,
1048,
63,
354,
275,
3542,
63,
505,
8,
604,
59,
16,
566,
288,
1504,
14,
740,
8,
355,
5024,
2354,
2031,
1332,
761,
63,
354,
4258,
1169,
435,
1004,
59,
17,
26,
19,
61,
1169,
435,
334,
475,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
988,
63,
552,
9,
503,
1004,
59,
19,
467,
3044,
370,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
1507,
63,
9218,
9,
503,
1004,
59,
20,
467,
3044,
370,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
1507,
63,
3467,
9,
503,
1004,
59,
21,
566,
1169,
435,
334,
604,
59,
22,
467,
9,
1169,
435,
334,
698,
63,
815,
59,
761,
63,
354,
1055,
2911,
4258,
1169,
435,
334,
698,
63,
815,
59,
761,
63,
354,
1055,
2301,
63,
885,
20097,
288,
776,
267,
372,
1504,
339,
347,
664,
63,
15741,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
2600,
402,
469,
698,
63,
354,
26,
334,
698,
63,
354,
63,
1848,
63,
1224,
12,
1163,
63,
1224,
6769,
267,
6144,
1006,
20045,
370,
314,
1627,
1817,
14,
267,
408,
267,
9565,
275,
291,
14,
362,
63,
498,
63,
3406,
8,
3937,
12,
1817,
63,
354,
9,
267,
16109,
275,
1052,
267,
367,
3002,
63,
13646,
12,
1163,
63,
1224,
12,
1163,
63,
698,
315,
9565,
26,
288,
16109,
59,
1662,
63,
13646,
61,
275,
334,
1848,
63,
698,
12,
1163,
63,
1224,
9,
267,
372,
16109,
339,
347,
664,
63,
498,
63,
3406,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
769,
402,
334,
2301,
63,
354,
12,
11812,
63
] |
[
5055,
492,
12863,
199,
199,
504,
25709,
14,
5559,
492,
26130,
63,
2711,
199,
199,
504,
1639,
14,
697,
14,
7765,
14,
1095,
14,
21627,
492,
334,
272,
29103,
30516,
12,
5024,
2354,
12,
6957,
2354,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
23004,
492,
23617,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
199,
792,
2354,
275,
12863,
360,
792,
2354,
297,
5024,
2354,
423,
955,
435,
661,
2911,
297,
283,
885,
1333,
199,
2354,
3049,
275,
12863,
360,
2354,
3049,
297,
283,
761,
63,
354,
666,
63,
466,
1390,
63,
552,
1967,
63,
9218,
1967,
63,
3467,
2402,
2763,
63,
885,
358,
421,
199,
533,
8692,
30516,
8,
1563,
7243,
30516,
304,
272,
666,
63,
1313,
63,
4471,
275,
469,
267,
26130,
63,
2711,
14,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
5901,
26,
283,
2183,
297,
267,
26130,
63,
2711,
14,
23925,
26,
283,
15975,
297,
267,
26130,
63,
2711,
14,
11365,
23925,
26,
283,
15975,
297,
267,
26130,
63,
2711,
14,
5390,
26,
283,
14071,
297,
267,
26130,
63,
2711,
14,
12488,
26,
283,
4626,
297,
267,
26130,
63,
2711,
14,
14989,
26,
283,
13019,
297,
267,
26130,
63,
2711,
14,
11783,
26,
283,
13019,
297,
267,
26130,
63,
2711,
14,
2919,
1194,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
12375,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
44,
615,
2226,
7770,
26,
283,
25175,
297,
267,
26130,
63,
2711,
14,
13003,
26,
283,
14640,
297,
267,
26130,
63,
2711,
14,
5353,
26,
283,
2183,
297,
267,
26130,
63,
2711,
14,
4961,
26,
283,
27115,
297,
267,
26130,
63,
2711,
14,
20277,
26,
283,
4626,
297,
267,
26130,
63,
2711,
14,
31178,
26,
283,
3901,
297,
267,
26130,
63,
2711,
14,
31178,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
9754,
2639,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
12375,
63,
26275,
26,
283,
6254,
297,
267,
26130,
63,
2711,
14,
5568,
63,
5353,
26,
283,
2183,
297,
272,
789,
339,
347,
664,
63,
698,
63,
466,
8,
277,
12,
666,
63,
466,
12,
1369,
304,
267,
901,
63,
466,
275,
1613,
8,
7243,
30516,
12,
291,
680,
362,
63,
698,
63,
466,
8,
576,
63,
466,
12,
1369,
9,
267,
340,
901,
63,
466,
508,
283,
3901,
7,
436,
283,
2495,
63,
9728,
7,
315,
1369,
14,
2911,
26,
288,
372,
283,
4378,
7,
267,
372,
901,
63,
466,
339,
347,
664,
63,
1224,
63,
513,
8,
277,
12,
3920,
304,
267,
408,
267,
1803,
282,
769,
402,
1817,
436,
2455,
1561,
315,
314,
1453,
3050,
14,
267,
408,
267,
3920,
14,
2526,
480,
19085,
18530,
377,
17041,
531,
267,
372,
359,
3186,
2354,
8,
1143,
59,
16,
467,
791,
5825,
9934,
356,
283,
84,
297,
283,
12058,
356,
283,
86,
936,
14,
362,
8,
1143,
59,
17,
2459,
355,
367,
1962,
315,
3920,
14,
10174,
5106,
339,
347,
664,
63,
1224,
63,
1802,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
1369,
402,
314,
1817,
12,
543,
314,
6249,
13,
3735,
3920,
14,
1802,
3217,
2122,
267,
408,
267,
327,
2556,
63,
3629,
3050,
10557,
1655,
23189,
2058,
367,
2005,
6085,
1482,
26,
267,
327,
446,
31044,
2582,
2138,
701,
3920,
14,
1802,
365,
376,
5007,
2582,
12,
267,
327,
257,
440,
8917,
2582,
15196,
1641,
821,
9,
267,
327,
446,
7151,
436,
4666,
334,
509,
6107,
1504,
9,
15196,
8216,
20,
9,
267,
327,
446,
2599,
63,
9728,
365,
440,
2808,
315,
3920,
14,
1802,
267,
3920,
14,
2526,
4852,
288,
10468,
2763,
63,
354,
12,
666,
63,
466,
12,
4528,
63,
11555,
63,
1267,
12,
8950,
63,
6833,
12,
673,
8950,
63,
3467,
12,
2402,
12,
2763,
63,
885,
288,
4442,
2556,
63,
3629,
14,
3406,
288,
6038,
1817,
63,
354,
275,
450,
83,
2401,
1817,
63,
3629,
275,
31705,
342,
7208,
359,
1224,
63,
354,
566,
267,
901,
63,
815,
275,
469,
604,
59,
16,
2189,
10332,
3049,
2031,
604,
9,
367,
1004,
315,
3920,
14,
10174,
12737,
398,
3920,
14,
2526,
480,
4859,
627,
4442,
450,
83,
5138,
413,
2,
450,
291,
14,
2105,
14,
1483,
14,
3513,
63,
354,
8,
1224,
63,
354,
430,
267,
370,
63,
442,
275,
2400,
284,
26,
1109,
8,
73,
9,
340,
284,
365,
440,
488,
587,
284,
267,
1504,
275,
942,
267,
367,
1004,
315,
3920,
14,
1802,
26,
288,
1048,
63,
354,
275,
3542,
63,
505,
8,
604,
59,
16,
566,
288,
1504,
14,
740,
8,
355,
5024,
2354,
2031,
1332,
761,
63,
354,
4258,
1169,
435,
1004,
59,
17,
26,
19,
61,
1169,
435,
334,
475,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
988,
63,
552,
9,
503,
1004,
59,
19,
467,
3044,
370,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
1507,
63,
9218,
9,
503,
1004,
59,
20,
467,
3044,
370,
63,
442,
8,
698,
63,
815,
59,
761,
63,
354,
1055,
1507,
63,
3467,
9,
503,
1004,
59,
21,
566,
1169,
435,
334,
604,
59,
22,
467,
9,
1169,
435,
334,
698,
63,
815,
59,
761,
63,
354,
1055,
2911,
4258,
1169,
435,
334,
698,
63,
815,
59,
761,
63,
354,
1055,
2301,
63,
885,
20097,
288,
776,
267,
372,
1504,
339,
347,
664,
63,
15741,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
2600,
402,
469,
698,
63,
354,
26,
334,
698,
63,
354,
63,
1848,
63,
1224,
12,
1163,
63,
1224,
6769,
267,
6144,
1006,
20045,
370,
314,
1627,
1817,
14,
267,
408,
267,
9565,
275,
291,
14,
362,
63,
498,
63,
3406,
8,
3937,
12,
1817,
63,
354,
9,
267,
16109,
275,
1052,
267,
367,
3002,
63,
13646,
12,
1163,
63,
1224,
12,
1163,
63,
698,
315,
9565,
26,
288,
16109,
59,
1662,
63,
13646,
61,
275,
334,
1848,
63,
698,
12,
1163,
63,
1224,
9,
267,
372,
16109,
339,
347,
664,
63,
498,
63,
3406,
8,
277,
12,
3920,
12,
1817,
63,
354,
304,
267,
408,
267,
1803,
282,
769,
402,
334,
2301,
63,
354,
12,
11812,
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,
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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
] |
gallifrey17/eden
|
static/scripts/tools/apps_db_comparison.py
|
46
|
4490
|
# This script compares the db schema of 2 eden apps to tell the differences
#
# Just run the script with 3 necessary arguments in this order
# 1. WEB2PY_PATH
# 2. OLD_APP
# 3. NEW_APP
# python applications/eden/static/scripts/tools/apps_db_comparison.py /home/web2py eden_old eden_new
#
# This script also has a Test script that makes 2 new web2py apps to compare:
# python applications/eden/tests/dbmigration TestScript.py
import os
import sys
import copy
import subprocess
# Set Variables
WEB2PY_PATH = sys.argv[1]
if not "WEB2PY_PATH" in os.environ:
os.environ["WEB2PY_PATH"] = WEB2PY_PATH
NEW_APP = sys.argv[3]
OLD_APP = sys.argv[2]
NEW_PATH = "%s/applications/%s" % (os.environ["WEB2PY_PATH"], NEW_APP)
OLD_PATH = "%s/applications/%s" % (os.environ["WEB2PY_PATH"], OLD_APP)
# Load the 2 environments with all their models
os.chdir(os.environ["WEB2PY_PATH"])
sys.path.append(os.environ["WEB2PY_PATH"])
from gluon.custom_import import custom_import_install
custom_import_install(os.environ["WEB2PY_PATH"])
from gluon.shell import env
from gluon import DAL, Field
new_env = env(NEW_APP, c=None, import_models=True)
d = globals().copy()
d.update(**new_env)
new_str ='''
try:
s3db.load_all_models()
except NameError:
print "s3db not defined"
new_db = db
'''
exec new_str in d, locals()
d.clear()
old_env = env(OLD_APP, c=None, import_models=True)
old_str ='''
try:
s3db.load_all_models()
except NameError:
print "s3db not defined"
old_db = db
'''
d = globals().copy()
d.update(**old_env)
exec old_str in d, locals()
# Get the Table and fields from the db
def get_tables_fields(db, database):
tables = db.tables
for table in tables:
database[table] = {}
database[table]["id"] = str(db[table]["_id"]).split(".")[-1]
fields = db[table]["_fields"]
for field in fields:
database[table][field]= {}
database[table]["referenced_by"] = db[table]["_referenced_by"]
old_database = {}
new_database = {}
get_tables_fields(old_db, old_database)
get_tables_fields(new_db, new_database)
# Get the union of the of the tables 2 databases
def intersect(a, b):
return list(set(a) & set(b))
def union(a, b):
return list(set(a) | set(b))
def all_tables(traversed):
traversed.extend(union(old_database, new_database))
traversed = []
all_tables(traversed)
# Detect Changes
change = {}
tables_disappeared = list(set(old_database) - set(new_database))
tables_appeared = list(set(new_database) - set(old_database))
# Detect the changes in Tables: Renaming, Adding or Deleting fields
for table in intersect(old_database,new_database):
change[table] = {}
change[table]["appeared"] = list(set(new_database[table]) - set(old_database[table]))
change[table]["disappeared"] = list(set(old_database[table]) - set(new_database[table]))
attributes = ["type", "length", "default", "required", "requires", "ondelete", "notnull", "unique",
"uploadfield", "widget", "label", "comment", "writable", "readable", "update", "authorize",
"autodelete", "represent", "uploadfolder", "uploadseparate", "uploadfs", "compute", "custom_store",
"custom_retrieve", "custom_retrieve_file_properties", "custom_delete", "filter_in", "filter_out"]
change_attribute = {}
for table in intersect(old_database,new_database):
for field in intersect(old_db[table]["_fields"], new_db[table]["_fields"]):
if not hasattr(change_attribute,table):
change_attribute[table] = {}
change_attribute[table][field] = []
for attribute in attributes:
if not eval("old_db[table][field].%(attribute)s == new_db[table][field].%(attribute)s" % {"attribute":attribute}):
change_attribute[table][field].append(attribute)
# Generate a Report of the Changes
print "\nTables Appeared = %s" % tables_appeared
print "\nTables Disappeared = %s" % tables_disappeared
for table in change.keys():
if change[table]["appeared"]:
print "table =", table, "changes appeared = ", change[table]["appeared"]
if change[table]["disappeared"]:
print "table =", table, "changes disappeared = ", change[table]["disappeared"]
for table in change_attribute.keys():
for field in change_attribute[table].keys():
if change_attribute[table][field] :
print "table = ", table, " field = ", field, " changes = ", change_attribute[table][field]
# END =========================================================================
|
mit
|
[
3,
961,
2884,
30827,
314,
1592,
4177,
402,
499,
325,
848,
8686,
370,
11480,
314,
15109,
199,
3,
199,
3,
13870,
1255,
314,
2884,
543,
650,
5784,
2368,
315,
642,
1865,
199,
3,
413,
14,
644,
14138,
18,
4521,
63,
3243,
199,
3,
499,
14,
593,
6533,
63,
7121,
199,
3,
650,
14,
18689,
63,
7121,
199,
3,
2366,
13103,
15,
69,
848,
15,
1986,
15,
6429,
15,
2537,
15,
5181,
63,
697,
63,
8547,
14,
647,
1182,
4219,
15,
2520,
18,
647,
325,
848,
63,
1753,
325,
848,
63,
1222,
199,
3,
199,
3,
961,
2884,
2597,
965,
282,
1379,
2884,
626,
7704,
499,
892,
3330,
18,
647,
8686,
370,
6540,
26,
199,
3,
2366,
13103,
15,
69,
848,
15,
2219,
15,
697,
8998,
1379,
5229,
14,
647,
199,
199,
646,
747,
199,
646,
984,
199,
646,
1331,
199,
646,
3873,
199,
199,
3,
2494,
17198,
199,
13166,
18,
4521,
63,
3243,
275,
984,
14,
3020,
59,
17,
61,
199,
692,
440,
298,
13166,
18,
4521,
63,
3243,
2,
315,
747,
14,
2314,
26,
272,
747,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
937,
275,
644,
14138,
18,
4521,
63,
3243,
199,
199,
11365,
63,
7121,
275,
984,
14,
3020,
59,
19,
61,
199,
5104,
63,
7121,
275,
984,
14,
3020,
59,
18,
61,
199,
11365,
63,
3243,
275,
2071,
83,
15,
15853,
3149,
83,
2,
450,
334,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
2255,
18689,
63,
7121,
9,
199,
5104,
63,
3243,
275,
2071,
83,
15,
15853,
3149,
83,
2,
450,
334,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
2255,
593,
6533,
63,
7121,
9,
199,
199,
3,
7190,
314,
499,
22196,
543,
1006,
3932,
1709,
199,
736,
14,
8563,
8,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
3135,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
3135,
199,
199,
504,
26752,
14,
4229,
63,
646,
492,
3537,
63,
646,
63,
3174,
199,
4229,
63,
646,
63,
3174,
8,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
3135,
199,
504,
26752,
14,
5641,
492,
2589,
199,
504,
26752,
492,
577,
748,
12,
5024,
199,
199,
1222,
63,
1813,
275,
2589,
8,
11365,
63,
7121,
12,
286,
29,
403,
12,
492,
63,
992,
29,
549,
9,
199,
68,
275,
7992,
1252,
1574,
342,
199,
68,
14,
873,
3682,
1222,
63,
1813,
9,
199,
1222,
63,
495,
275,
2344,
199,
893,
26,
272,
308,
19,
697,
14,
912,
63,
452,
63,
992,
342,
199,
2590,
12746,
26,
272,
870,
298,
83,
19,
697,
440,
3247,
2,
199,
1222,
63,
697,
275,
1592,
199,
2344,
199,
1628,
892,
63,
495,
315,
366,
12,
9480,
342,
199,
199,
68,
14,
3584,
342,
199,
199,
1753,
63,
1813,
275,
2589,
8,
5104,
63,
7121,
12,
286,
29,
403,
12,
492,
63,
992,
29,
549,
9,
199,
1753,
63,
495,
275,
2344,
199,
893,
26,
272,
308,
19,
697,
14,
912,
63,
452,
63,
992,
342,
199,
2590,
12746,
26,
272,
870,
298,
83,
19,
697,
440,
3247,
2,
199,
1753,
63,
697,
275,
1592,
199,
2344,
199,
68,
275,
7992,
1252,
1574,
342,
199,
68,
14,
873,
3682,
1753,
63,
1813,
9,
199,
1628,
2269,
63,
495,
315,
366,
12,
9480,
342,
199,
199,
3,
2372,
314,
6957,
436,
1504,
687,
314,
1592,
199,
318,
664,
63,
5987,
63,
955,
8,
697,
12,
3050,
304,
272,
6716,
275,
1592,
14,
5987,
272,
367,
1817,
315,
6716,
26,
267,
3050,
59,
1224,
61,
275,
1052,
267,
3050,
59,
1224,
7541,
344,
937,
275,
620,
8,
697,
59,
1224,
7541,
63,
344,
29126,
1294,
15857,
1988,
17,
61,
267,
1504,
275,
1592,
59,
1224,
7541,
63,
955,
937,
267,
367,
901,
315,
1504,
26,
288,
3050,
59,
1224,
1527,
698,
10404,
1052,
267,
3050,
59,
1224,
7541,
22355,
63,
991,
937,
275,
1592,
59,
1224,
7541,
63,
22355,
63,
991,
937,
199,
199,
1753,
63,
4659,
275,
1052,
199,
1222,
63,
4659,
275,
1052,
199,
362,
63,
5987,
63,
955,
8,
1753,
63,
697,
12,
2269,
63,
4659,
9,
199,
362,
63,
5987,
63,
955,
8,
1222,
63,
697,
12,
892,
63,
4659,
9,
199,
199,
3,
2372,
314,
13629,
402,
314,
402,
314,
6716,
499,
16219,
199,
318,
26066,
8,
65,
12,
330,
304,
272,
372,
769,
8,
409,
8,
65,
9,
1253,
663,
8,
66,
430,
199,
199,
318,
13629,
8,
65,
12,
330,
304,
272,
372,
769,
8,
409,
8,
65,
9,
1204,
663,
8,
66,
430,
199,
199,
318,
1006,
63,
5987,
8,
1239,
7460,
304,
272,
1468,
7460,
14,
2880,
8,
8888,
8,
1753,
63,
4659,
12,
892,
63,
4659,
430,
199,
199,
1239,
7460,
275,
942,
199,
452,
63,
5987,
8,
1239,
7460,
9,
199,
199,
3,
30577,
18784,
199,
1461,
275,
1052,
199,
199,
5987,
63,
2297,
31711,
2899,
275,
769,
8,
409,
8,
1753,
63,
4659,
9,
446,
663,
8,
1222,
63,
4659,
430,
199,
5987,
63,
31711,
2899,
275,
769,
8,
409,
8,
1222,
63,
4659,
9,
446,
663,
8,
1753,
63,
4659,
430,
199,
199,
3,
30577,
314,
4493,
315,
377,
5921,
26,
10055,
9568,
12,
12934,
503,
15920,
1504,
199,
509,
1817,
315,
26066,
8,
1753,
63,
4659,
12,
1222,
63,
4659,
304,
272,
1570,
59,
1224,
61,
275,
1052,
272,
1570,
59,
1224,
7541,
31711,
2899,
937,
275,
769,
8,
409,
8,
1222,
63,
4659,
59,
1224,
566,
446,
663,
8,
1753,
63,
4659,
59,
1224,
2459,
272,
1570,
59,
1224,
7541,
2297,
31711,
2899,
937,
275,
769,
8,
409,
8,
1753,
63,
4659,
59,
1224,
566,
446,
663,
8,
1222,
63,
4659,
59,
1224,
2459,
199,
199,
2987,
275,
2097,
466,
401,
298,
1267,
401,
298,
885,
401,
298,
2427,
401,
298,
6537,
401,
298,
265,
1807,
401,
298,
1397,
2307,
401,
298,
3235,
401,
267,
298,
5064,
698,
401,
298,
3440,
401,
298,
1302,
401,
298,
3349,
401,
298,
15053,
401,
298,
11875,
401,
298,
873,
401,
298,
14204,
401,
267,
298,
6898,
380,
1268,
401,
298,
13063,
401,
298,
5064,
3741,
401,
298,
5064,
24904,
401,
298,
5064,
2319,
401,
298,
3357,
401,
298,
4229,
63,
1617
] |
[
961,
2884,
30827,
314,
1592,
4177,
402,
499,
325,
848,
8686,
370,
11480,
314,
15109,
199,
3,
199,
3,
13870,
1255,
314,
2884,
543,
650,
5784,
2368,
315,
642,
1865,
199,
3,
413,
14,
644,
14138,
18,
4521,
63,
3243,
199,
3,
499,
14,
593,
6533,
63,
7121,
199,
3,
650,
14,
18689,
63,
7121,
199,
3,
2366,
13103,
15,
69,
848,
15,
1986,
15,
6429,
15,
2537,
15,
5181,
63,
697,
63,
8547,
14,
647,
1182,
4219,
15,
2520,
18,
647,
325,
848,
63,
1753,
325,
848,
63,
1222,
199,
3,
199,
3,
961,
2884,
2597,
965,
282,
1379,
2884,
626,
7704,
499,
892,
3330,
18,
647,
8686,
370,
6540,
26,
199,
3,
2366,
13103,
15,
69,
848,
15,
2219,
15,
697,
8998,
1379,
5229,
14,
647,
199,
199,
646,
747,
199,
646,
984,
199,
646,
1331,
199,
646,
3873,
199,
199,
3,
2494,
17198,
199,
13166,
18,
4521,
63,
3243,
275,
984,
14,
3020,
59,
17,
61,
199,
692,
440,
298,
13166,
18,
4521,
63,
3243,
2,
315,
747,
14,
2314,
26,
272,
747,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
937,
275,
644,
14138,
18,
4521,
63,
3243,
199,
199,
11365,
63,
7121,
275,
984,
14,
3020,
59,
19,
61,
199,
5104,
63,
7121,
275,
984,
14,
3020,
59,
18,
61,
199,
11365,
63,
3243,
275,
2071,
83,
15,
15853,
3149,
83,
2,
450,
334,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
2255,
18689,
63,
7121,
9,
199,
5104,
63,
3243,
275,
2071,
83,
15,
15853,
3149,
83,
2,
450,
334,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
2255,
593,
6533,
63,
7121,
9,
199,
199,
3,
7190,
314,
499,
22196,
543,
1006,
3932,
1709,
199,
736,
14,
8563,
8,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
3135,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
3135,
199,
199,
504,
26752,
14,
4229,
63,
646,
492,
3537,
63,
646,
63,
3174,
199,
4229,
63,
646,
63,
3174,
8,
736,
14,
2314,
905,
13166,
18,
4521,
63,
3243,
3135,
199,
504,
26752,
14,
5641,
492,
2589,
199,
504,
26752,
492,
577,
748,
12,
5024,
199,
199,
1222,
63,
1813,
275,
2589,
8,
11365,
63,
7121,
12,
286,
29,
403,
12,
492,
63,
992,
29,
549,
9,
199,
68,
275,
7992,
1252,
1574,
342,
199,
68,
14,
873,
3682,
1222,
63,
1813,
9,
199,
1222,
63,
495,
275,
2344,
199,
893,
26,
272,
308,
19,
697,
14,
912,
63,
452,
63,
992,
342,
199,
2590,
12746,
26,
272,
870,
298,
83,
19,
697,
440,
3247,
2,
199,
1222,
63,
697,
275,
1592,
199,
2344,
199,
1628,
892,
63,
495,
315,
366,
12,
9480,
342,
199,
199,
68,
14,
3584,
342,
199,
199,
1753,
63,
1813,
275,
2589,
8,
5104,
63,
7121,
12,
286,
29,
403,
12,
492,
63,
992,
29,
549,
9,
199,
1753,
63,
495,
275,
2344,
199,
893,
26,
272,
308,
19,
697,
14,
912,
63,
452,
63,
992,
342,
199,
2590,
12746,
26,
272,
870,
298,
83,
19,
697,
440,
3247,
2,
199,
1753,
63,
697,
275,
1592,
199,
2344,
199,
68,
275,
7992,
1252,
1574,
342,
199,
68,
14,
873,
3682,
1753,
63,
1813,
9,
199,
1628,
2269,
63,
495,
315,
366,
12,
9480,
342,
199,
199,
3,
2372,
314,
6957,
436,
1504,
687,
314,
1592,
199,
318,
664,
63,
5987,
63,
955,
8,
697,
12,
3050,
304,
272,
6716,
275,
1592,
14,
5987,
272,
367,
1817,
315,
6716,
26,
267,
3050,
59,
1224,
61,
275,
1052,
267,
3050,
59,
1224,
7541,
344,
937,
275,
620,
8,
697,
59,
1224,
7541,
63,
344,
29126,
1294,
15857,
1988,
17,
61,
267,
1504,
275,
1592,
59,
1224,
7541,
63,
955,
937,
267,
367,
901,
315,
1504,
26,
288,
3050,
59,
1224,
1527,
698,
10404,
1052,
267,
3050,
59,
1224,
7541,
22355,
63,
991,
937,
275,
1592,
59,
1224,
7541,
63,
22355,
63,
991,
937,
199,
199,
1753,
63,
4659,
275,
1052,
199,
1222,
63,
4659,
275,
1052,
199,
362,
63,
5987,
63,
955,
8,
1753,
63,
697,
12,
2269,
63,
4659,
9,
199,
362,
63,
5987,
63,
955,
8,
1222,
63,
697,
12,
892,
63,
4659,
9,
199,
199,
3,
2372,
314,
13629,
402,
314,
402,
314,
6716,
499,
16219,
199,
318,
26066,
8,
65,
12,
330,
304,
272,
372,
769,
8,
409,
8,
65,
9,
1253,
663,
8,
66,
430,
199,
199,
318,
13629,
8,
65,
12,
330,
304,
272,
372,
769,
8,
409,
8,
65,
9,
1204,
663,
8,
66,
430,
199,
199,
318,
1006,
63,
5987,
8,
1239,
7460,
304,
272,
1468,
7460,
14,
2880,
8,
8888,
8,
1753,
63,
4659,
12,
892,
63,
4659,
430,
199,
199,
1239,
7460,
275,
942,
199,
452,
63,
5987,
8,
1239,
7460,
9,
199,
199,
3,
30577,
18784,
199,
1461,
275,
1052,
199,
199,
5987,
63,
2297,
31711,
2899,
275,
769,
8,
409,
8,
1753,
63,
4659,
9,
446,
663,
8,
1222,
63,
4659,
430,
199,
5987,
63,
31711,
2899,
275,
769,
8,
409,
8,
1222,
63,
4659,
9,
446,
663,
8,
1753,
63,
4659,
430,
199,
199,
3,
30577,
314,
4493,
315,
377,
5921,
26,
10055,
9568,
12,
12934,
503,
15920,
1504,
199,
509,
1817,
315,
26066,
8,
1753,
63,
4659,
12,
1222,
63,
4659,
304,
272,
1570,
59,
1224,
61,
275,
1052,
272,
1570,
59,
1224,
7541,
31711,
2899,
937,
275,
769,
8,
409,
8,
1222,
63,
4659,
59,
1224,
566,
446,
663,
8,
1753,
63,
4659,
59,
1224,
2459,
272,
1570,
59,
1224,
7541,
2297,
31711,
2899,
937,
275,
769,
8,
409,
8,
1753,
63,
4659,
59,
1224,
566,
446,
663,
8,
1222,
63,
4659,
59,
1224,
2459,
199,
199,
2987,
275,
2097,
466,
401,
298,
1267,
401,
298,
885,
401,
298,
2427,
401,
298,
6537,
401,
298,
265,
1807,
401,
298,
1397,
2307,
401,
298,
3235,
401,
267,
298,
5064,
698,
401,
298,
3440,
401,
298,
1302,
401,
298,
3349,
401,
298,
15053,
401,
298,
11875,
401,
298,
873,
401,
298,
14204,
401,
267,
298,
6898,
380,
1268,
401,
298,
13063,
401,
298,
5064,
3741,
401,
298,
5064,
24904,
401,
298,
5064,
2319,
401,
298,
3357,
401,
298,
4229,
63,
1617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1,
1,
1
] |
nmarcetic/weblines.io
|
weblines/apps/cms/tests/test_models.py
|
1
|
2950
|
"""
Domain objects test suites
"""
from django.db import IntegrityError
from django.test import TestCase
from weblines.apps.cms import models
class PageTestCase(TestCase):
"""
Contains page-related test scenarios
"""
def test_creation(self):
"""
Tests various creation scenarios
Each object is assigned unique slug, generated from its title. Once
created, slug retains its value even when page title is updated.
"""
# object creation
new_page = models.Page.objects.create(title='First page')
self.assertEqual(new_page.slug, 'first-page')
self.assertEqual(new_page.id, 1)
# title update
new_page.title = 'Different title'
new_page.save(update_fields=['title'])
self.assertEqual(new_page.slug, 'first-page')
# slug duplication
with self.assertRaises(IntegrityError):
models.Page.objects.create(title='First page')
class GalleryTestCase(TestCase):
"""
Contains gallery-related test scenarios
"""
def setUp(self):
"""
Creates dummy gallery
"""
# create owner page
page = models.Page.objects.create(title='first page')
# create new display type
display_type = models.DisplayType.objects.create(name='gallery',
code='G')
# instantiate gallery and bind it to a created display type
self.gallery = models.Gallery.objects.create(name='slider',
page=page,
display_type=display_type)
def test_item_addition(self):
"""
Tests item addition
"""
self.gallery.add_item('gallery-item')
self.assertEqual(1, self.gallery.items.count())
self.assertEqual('gallery-item', self.gallery.items.first().caption)
# in case of same captions, slugs must remain unique
self.gallery.add_item('gallery-item')
first = self.gallery.items.first()
last = self.gallery.items.last()
self.assertNotEqual(first.slug, last.slug)
def test_item_removal(self):
"""
Tests item removal
Gallery item is removed if its name is found in added items.
"""
self.test_item_addition()
self.assertEqual(2, self.gallery.items.count())
# failed search should result with False
return_value = self.gallery.remove_item('invalid-item')
self.assertEqual(False, return_value)
# successful search should remove item and return True
return_value = self.gallery.remove_item('gallery-item-1')
self.assertEqual(True, return_value)
self.assertEqual(1, self.gallery.items.count())
# slide should be completely removed from system
self.assertEqual(1, models.GalleryItem.objects.count())
|
gpl-2.0
|
[
624,
199,
7705,
2251,
511,
24203,
199,
624,
199,
504,
1639,
14,
697,
492,
26864,
199,
504,
1639,
14,
396,
492,
7640,
199,
199,
504,
3330,
1278,
14,
5181,
14,
10781,
492,
1709,
421,
199,
533,
10331,
1746,
8,
1746,
304,
272,
408,
272,
22493,
2034,
13,
2407,
511,
28444,
272,
408,
272,
347,
511,
63,
8782,
8,
277,
304,
267,
408,
267,
6496,
7750,
7143,
28444,
398,
7048,
909,
365,
7943,
3747,
8889,
12,
4046,
687,
2399,
2538,
14,
19468,
267,
2737,
12,
8889,
295,
3953,
2399,
574,
2755,
1380,
2034,
2538,
365,
4588,
14,
267,
408,
267,
327,
909,
7143,
267,
892,
63,
1606,
275,
1709,
14,
3276,
14,
1462,
14,
981,
8,
1213,
534,
7147,
2034,
358,
267,
291,
14,
629,
8,
1222,
63,
1606,
14,
5464,
12,
283,
2246,
13,
1606,
358,
267,
291,
14,
629,
8,
1222,
63,
1606,
14,
344,
12,
413,
9,
398,
327,
2538,
1678,
267,
892,
63,
1606,
14,
1213,
275,
283,
31409,
2538,
7,
267,
892,
63,
1606,
14,
2117,
8,
873,
63,
955,
2968,
1213,
1105,
267,
291,
14,
629,
8,
1222,
63,
1606,
14,
5464,
12,
283,
2246,
13,
1606,
358,
398,
327,
8889,
11866,
1863,
267,
543,
291,
14,
1855,
8,
24823,
304,
288,
1709,
14,
3276,
14,
1462,
14,
981,
8,
1213,
534,
7147,
221,
2034,
358,
421,
199,
533,
598,
17787,
1746,
8,
1746,
304,
272,
408,
272,
22493,
486,
17787,
13,
2407,
511,
28444,
272,
408,
272,
347,
3613,
8,
277,
304,
267,
408,
267,
10560,
7283,
486,
17787,
267,
408,
267,
327,
1218,
5771,
2034,
267,
2034,
275,
1709,
14,
3276,
14,
1462,
14,
981,
8,
1213,
534,
2246,
2034,
358,
398,
327,
1218,
892,
2929,
730,
267,
2929,
63,
466,
275,
1709,
14,
7687,
804,
14,
1462,
14,
981,
8,
354,
534,
25372,
297,
12740,
1233,
534,
39,
358,
398,
327,
17321,
486,
17787,
436,
5398,
652,
370,
282,
2737,
2929,
730,
267,
291,
14,
25372,
275,
1709,
14,
39,
17787,
14,
1462,
14,
981,
8,
354,
534,
20860,
297,
9349,
2034,
29,
1606,
12,
9349,
2929,
63,
466,
29,
2918,
63,
466,
9,
339,
347,
511,
63,
1053,
63,
26799,
8,
277,
304,
267,
408,
267,
6496,
1242,
10234,
267,
408,
267,
291,
14,
25372,
14,
525,
63,
1053,
360,
25372,
13,
1053,
358,
267,
291,
14,
629,
8,
17,
12,
291,
14,
25372,
14,
1744,
14,
835,
1012,
267,
291,
14,
629,
360,
25372,
13,
1053,
297,
291,
14,
25372,
14,
1744,
14,
2246,
1252,
13410,
9,
398,
327,
315,
1930,
402,
2011,
4021,
852,
12,
5340,
85,
458,
1471,
5706,
3747,
267,
291,
14,
25372,
14,
525,
63,
1053,
360,
25372,
13,
1053,
358,
267,
1642,
275,
291,
14,
25372,
14,
1744,
14,
2246,
342,
267,
2061,
275,
291,
14,
25372,
14,
1744,
14,
2019,
342,
267,
291,
14,
7418,
8,
2246,
14,
5464,
12,
2061,
14,
5464,
9,
339,
347,
511,
63,
1053,
63,
25818,
8,
277,
304,
267,
408,
267,
6496,
1242,
20055,
398,
598,
17787,
1242,
365,
4829,
340,
2399,
536,
365,
1911,
315,
3483,
2974,
14,
267,
408,
267,
291,
14,
396,
63,
1053,
63,
26799,
342,
267,
291,
14,
629,
8,
18,
12,
291,
14,
25372,
14,
1744,
14,
835,
1012,
398,
327,
3405,
2754,
1077,
754,
543,
756,
267,
372,
63,
585,
275,
291,
14,
25372,
14,
2168,
63,
1053,
360,
3197,
13,
1053,
358,
267,
291,
14,
629,
8,
797,
12,
372,
63,
585,
9,
398,
327,
9512,
2754,
1077,
2813,
1242,
436,
372,
715,
267,
372,
63,
585,
275,
291,
14,
25372,
14,
2168,
63,
1053,
360,
25372,
13,
1053,
13,
17,
358,
267,
291,
14,
629,
8,
549,
12,
372,
63,
585,
9,
267,
291,
14,
629,
8,
17,
12,
291,
14,
25372,
14,
1744,
14,
835,
1012,
398,
327,
27063,
1077,
506,
14793,
4829,
687,
2656,
267,
291,
14,
629,
8,
17,
12,
1709,
14,
39,
17787,
2081,
14,
1462,
14,
835,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
7705,
2251,
511,
24203,
199,
624,
199,
504,
1639,
14,
697,
492,
26864,
199,
504,
1639,
14,
396,
492,
7640,
199,
199,
504,
3330,
1278,
14,
5181,
14,
10781,
492,
1709,
421,
199,
533,
10331,
1746,
8,
1746,
304,
272,
408,
272,
22493,
2034,
13,
2407,
511,
28444,
272,
408,
272,
347,
511,
63,
8782,
8,
277,
304,
267,
408,
267,
6496,
7750,
7143,
28444,
398,
7048,
909,
365,
7943,
3747,
8889,
12,
4046,
687,
2399,
2538,
14,
19468,
267,
2737,
12,
8889,
295,
3953,
2399,
574,
2755,
1380,
2034,
2538,
365,
4588,
14,
267,
408,
267,
327,
909,
7143,
267,
892,
63,
1606,
275,
1709,
14,
3276,
14,
1462,
14,
981,
8,
1213,
534,
7147,
2034,
358,
267,
291,
14,
629,
8,
1222,
63,
1606,
14,
5464,
12,
283,
2246,
13,
1606,
358,
267,
291,
14,
629,
8,
1222,
63,
1606,
14,
344,
12,
413,
9,
398,
327,
2538,
1678,
267,
892,
63,
1606,
14,
1213,
275,
283,
31409,
2538,
7,
267,
892,
63,
1606,
14,
2117,
8,
873,
63,
955,
2968,
1213,
1105,
267,
291,
14,
629,
8,
1222,
63,
1606,
14,
5464,
12,
283,
2246,
13,
1606,
358,
398,
327,
8889,
11866,
1863,
267,
543,
291,
14,
1855,
8,
24823,
304,
288,
1709,
14,
3276,
14,
1462,
14,
981,
8,
1213,
534,
7147,
221,
2034,
358,
421,
199,
533,
598,
17787,
1746,
8,
1746,
304,
272,
408,
272,
22493,
486,
17787,
13,
2407,
511,
28444,
272,
408,
272,
347,
3613,
8,
277,
304,
267,
408,
267,
10560,
7283,
486,
17787,
267,
408,
267,
327,
1218,
5771,
2034,
267,
2034,
275,
1709,
14,
3276,
14,
1462,
14,
981,
8,
1213,
534,
2246,
2034,
358,
398,
327,
1218,
892,
2929,
730,
267,
2929,
63,
466,
275,
1709,
14,
7687,
804,
14,
1462,
14,
981,
8,
354,
534,
25372,
297,
12740,
1233,
534,
39,
358,
398,
327,
17321,
486,
17787,
436,
5398,
652,
370,
282,
2737,
2929,
730,
267,
291,
14,
25372,
275,
1709,
14,
39,
17787,
14,
1462,
14,
981,
8,
354,
534,
20860,
297,
9349,
2034,
29,
1606,
12,
9349,
2929,
63,
466,
29,
2918,
63,
466,
9,
339,
347,
511,
63,
1053,
63,
26799,
8,
277,
304,
267,
408,
267,
6496,
1242,
10234,
267,
408,
267,
291,
14,
25372,
14,
525,
63,
1053,
360,
25372,
13,
1053,
358,
267,
291,
14,
629,
8,
17,
12,
291,
14,
25372,
14,
1744,
14,
835,
1012,
267,
291,
14,
629,
360,
25372,
13,
1053,
297,
291,
14,
25372,
14,
1744,
14,
2246,
1252,
13410,
9,
398,
327,
315,
1930,
402,
2011,
4021,
852,
12,
5340,
85,
458,
1471,
5706,
3747,
267,
291,
14,
25372,
14,
525,
63,
1053,
360,
25372,
13,
1053,
358,
267,
1642,
275,
291,
14,
25372,
14,
1744,
14,
2246,
342,
267,
2061,
275,
291,
14,
25372,
14,
1744,
14,
2019,
342,
267,
291,
14,
7418,
8,
2246,
14,
5464,
12,
2061,
14,
5464,
9,
339,
347,
511,
63,
1053,
63,
25818,
8,
277,
304,
267,
408,
267,
6496,
1242,
20055,
398,
598,
17787,
1242,
365,
4829,
340,
2399,
536,
365,
1911,
315,
3483,
2974,
14,
267,
408,
267,
291,
14,
396,
63,
1053,
63,
26799,
342,
267,
291,
14,
629,
8,
18,
12,
291,
14,
25372,
14,
1744,
14,
835,
1012,
398,
327,
3405,
2754,
1077,
754,
543,
756,
267,
372,
63,
585,
275,
291,
14,
25372,
14,
2168,
63,
1053,
360,
3197,
13,
1053,
358,
267,
291,
14,
629,
8,
797,
12,
372,
63,
585,
9,
398,
327,
9512,
2754,
1077,
2813,
1242,
436,
372,
715,
267,
372,
63,
585,
275,
291,
14,
25372,
14,
2168,
63,
1053,
360,
25372,
13,
1053,
13,
17,
358,
267,
291,
14,
629,
8,
549,
12,
372,
63,
585,
9,
267,
291,
14,
629,
8,
17,
12,
291,
14,
25372,
14,
1744,
14,
835,
1012,
398,
327,
27063,
1077,
506,
14793,
4829,
687,
2656,
267,
291,
14,
629,
8,
17,
12,
1709,
14,
39,
17787,
2081,
14,
1462,
14,
835,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,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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
] |
sojournexx/python
|
Assignments/TanAndrew_assign6.py
|
1
|
5318
|
#Andrew Tan, 3/25, Section 010
import myfunctions
import random
#Ask user for inputs and check validity
while True:
qns = int(input("How many problems would you like to attempt? "))
if qns <= 0:
print("Invalid number, try again\n")
continue
else:
break
while True:
width = int(input("How wide do you want your digits to be? 5-10: "))
if width < 5 or width > 10:
print("Invalid width, try again\n")
continue
else:
break
while True:
drill = str.lower(input("Would you like to activate 'drill' mode? yes or no: "))
if drill != "yes" and drill != "no":
print("Invalid response, try again\n")
continue
else:
break
print("\nHere we go!")
#Define variables to track score and statistics
tscore = 0
addition = 0
subtraction = 0
multiplication = 0
division = 0
addition_score = 0
subtraction_score = 0
multiplication_score = 0
division_score = 0
#Set number of questions
for i in range(qns):
print("\nWhat is .....\n")
#Define parameters
x = random.randint(0, 9)
op = random.randint(1, 4)
y = random.randint(0, 9)
#Check for valid division equation
if op == 4:
if y == 0:
y = random.randint(1, 9)
while x % y != 0:
x = random.randint(0, 9)
y = random.randint(1, 9)
#Display first number
if x == 0:
myfunctions.number_0(width)
elif x == 1:
myfunctions.number_1(width)
elif x == 2:
myfunctions.number_2(width)
elif x == 3:
myfunctions.number_3(width)
elif x == 4:
myfunctions.number_4(width)
elif x == 5:
myfunctions.number_5(width)
elif x == 6:
myfunctions.number_6(width)
elif x == 7:
myfunctions.number_7(width)
elif x == 8:
myfunctions.number_8(width)
elif x == 9:
myfunctions.number_9(width)
#Display operator
if op == 1:
op = "+"
myfunctions.plus(width)
addition += 1
elif op == 2:
op = "-"
myfunctions.minus(width)
subtraction += 1
elif op == 3:
op = "*"
myfunctions.multiply(width)
multiplication += 1
elif op == 4:
op = "/"
myfunctions.divide(width)
division += 1
#Display second number
if y == 0:
myfunctions.number_0(width)
elif y == 1:
myfunctions.number_1(width)
elif y == 2:
myfunctions.number_2(width)
elif y == 3:
myfunctions.number_3(width)
elif y == 4:
myfunctions.number_4(width)
elif y == 5:
myfunctions.number_5(width)
elif y == 6:
myfunctions.number_6(width)
elif y == 7:
myfunctions.number_7(width)
elif y == 8:
myfunctions.number_8(width)
elif y == 9:
myfunctions.number_9(width)
#Ask user for answer and check answer
if drill == "no":
z = int(input("= "))
if myfunctions.check_answer(x, y, z, op) == True:
print("Correct!")
tscore += 1
if op == "+":
addition_score += 1
if op == "-":
subtraction_score += 1
if op == "*":
multiplication_score += 1
if op == "/":
division_score += 1
else:
print("Sorry, that's not correct.")
elif drill == "yes":
while True:
z = int(input("= "))
if myfunctions.check_answer(x, y, z, op) == False:
print("Sorry, that's not correct.")
if op == "+":
addition_score += 1
if op == "-":
subtraction_score += 1
if op == "*":
multiplication_score += 1
if op == "/":
division_score += 1
continue
else:
print("Correct!")
break
#Display score
if drill == "no":
print("\nYou got %d out of %d correct!" %(tscore, qns))
for operator, count, score in zip(["addition", "subtraction", "multiplication", "division"], [addition, subtraction, multiplication, division], [addition_score, subtraction_score, multiplication_score, division_score]):
if count == 0:
print("\nNo %s problems presented" %(operator))
else:
print("\nTotal %s problems presented: %d" %(operator, count))
print("Correct %s problems: %d (%s)" %(operator, score, format(score/count, ".1%")))
elif drill == "yes":
for operator, count, score in zip(["addition", "subtraction", "multiplication", "division"], [addition, subtraction, multiplication, division], [addition_score, subtraction_score, multiplication_score, division_score]):
if score == 0:
praise = "(perfect!)"
else:
praise = ""
if count == 0:
print("\nNo %s problems presented" %(operator))
else:
print("\nTotal %s problems presented: %d" %(operator, count))
print("# of extra attempts needed: %d %s" %(score, praise))
|
mit
|
[
3,
3325,
5257,
377,
290,
12,
650,
15,
821,
12,
15247,
378,
709,
2999,
199,
646,
3002,
5777,
202,
199,
646,
2196,
2999,
199,
3,
25525,
922,
367,
4153,
436,
1104,
25667,
202,
199,
6710,
715,
26,
1128,
1894,
561,
275,
1109,
8,
1210,
480,
18335,
5002,
8826,
3955,
1265,
2839,
370,
7427,
31,
26725,
1128,
340,
1894,
561,
2695,
378,
26,
1039,
870,
480,
3364,
1329,
12,
862,
4020,
60,
78,
531,
1039,
1980,
1128,
587,
26,
1039,
2059,
2999,
199,
6710,
715,
26,
1128,
3462,
275,
1109,
8,
1210,
480,
18335,
20239,
886,
1265,
2934,
2195,
7576,
370,
506,
31,
959,
13,
709,
26,
26725,
1128,
340,
3462,
665,
959,
503,
3462,
690,
1616,
26,
1039,
870,
480,
3364,
3462,
12,
862,
4020,
60,
78,
531,
1039,
1980,
1128,
587,
26,
1039,
2059,
2999,
199,
6710,
715,
26,
1128,
20921,
914,
275,
620,
14,
2325,
8,
1210,
480,
55,
3857,
1265,
2839,
370,
15422,
283,
17824,
914,
7,
818,
31,
9456,
503,
949,
26,
26725,
1128,
340,
20921,
914,
1137,
298,
5066,
2,
436,
20921,
914,
1137,
298,
889,
582,
1039,
870,
480,
3364,
1177,
12,
862,
4020,
60,
78,
531,
1039,
1980,
1128,
587,
26,
1039,
2059,
8428,
202,
199,
1361,
4582,
78,
21741,
781,
2621,
9124,
2999,
199,
3,
16213,
2860,
370,
4426,
5396,
436,
11076,
202,
199,
1086,
1018,
275,
378,
202,
199,
26799,
275,
378,
202,
199,
954,
26137,
275,
378,
202,
199,
8016,
1863,
275,
378,
202,
199,
25035,
275,
378,
202,
199,
26799,
63,
3397,
275,
378,
202,
199,
954,
26137,
63,
3397,
275,
378,
202,
199,
8016,
1863,
63,
3397,
275,
378,
202,
199,
25035,
63,
3397,
275,
378,
2999,
199,
3,
1084,
1329,
402,
23071,
202,
199,
509,
284,
315,
1425,
8,
81,
561,
304,
1128,
870,
4582,
78,
21015,
365,
2508,
29279,
78,
531,
2958,
327,
16213,
2633,
1128,
671,
275,
2196,
14,
8393,
8,
16,
12,
1749,
9,
1128,
1687,
275,
2196,
14,
8393,
8,
17,
12,
841,
9,
1128,
612,
275,
2196,
14,
8393,
8,
16,
12,
1749,
9,
2958,
327,
1799,
367,
1686,
4629,
18649,
1128,
340,
1687,
508,
841,
26,
1039,
340,
612,
508,
378,
26,
1675,
612,
275,
2196,
14,
8393,
8,
17,
12,
1749,
9,
1039,
1830,
671,
450,
612,
1137,
378,
26,
1675,
671,
275,
2196,
14,
8393,
8,
16,
12,
1749,
9,
1675,
612,
275,
2196,
14,
8393,
8,
17,
12,
1749,
9,
8740,
202,
199,
3,
7687,
1642,
1329,
1128,
340,
671,
508,
378,
26,
1039,
3002,
5777,
14,
1955,
63,
16,
8,
2063,
9,
1128,
916,
671,
508,
413,
26,
1039,
3002,
5777,
14,
1955,
63,
17,
8,
2063,
9,
1128,
916,
671,
508,
499,
26,
1039,
3002,
5777,
14,
1955,
63,
18,
8,
2063,
9,
1128,
916,
671,
508,
650,
26,
1039,
3002,
5777,
14,
1955,
63,
19,
8,
2063,
9,
1128,
916,
671,
508,
841,
26,
1039,
3002,
5777,
14,
1955,
63,
20,
8,
2063,
9,
1128,
916,
671,
508,
959,
26,
1039,
3002,
5777,
14,
1955,
63,
21,
8,
2063,
9,
1128,
916,
671,
508,
1227,
26,
1039,
3002,
5777,
14,
1955,
63,
22,
8,
2063,
9,
1128,
916,
671,
508,
1520,
26,
1039,
3002,
5777,
14,
1955,
63,
23,
8,
2063,
9,
1128,
916,
671,
508,
1695,
26,
1039,
3002,
5777,
14,
1955,
63,
24,
8,
2063,
9,
1128,
916,
671,
508,
1749,
26,
1039,
3002,
5777,
14,
1955,
63,
25,
8,
2063,
9,
2999,
199,
3,
7687,
4182,
1128,
340,
1687,
508,
413,
26,
1039,
1687,
275,
298,
5207,
1039,
3002,
5777,
14,
6666,
8,
2063,
9,
1039,
10234,
847,
413,
1128,
916,
1687,
508,
499,
26,
1039,
1687,
275,
17155,
1039,
3002,
5777,
14,
13084,
8,
2063,
9,
1039,
1007,
26137,
847,
413,
1128,
916,
1687,
508,
650,
26,
1039,
1687,
275,
22423,
1039,
3002,
5777,
14,
13710,
8,
2063,
9,
1039,
24638,
847,
413,
1128,
916,
1687,
508,
841,
26,
1039,
1687,
275,
10609,
1039,
3002,
5777,
14,
16081,
8,
2063,
9,
1039,
4629,
847,
413,
2999,
199,
3,
7687,
3499,
1329,
1128,
340,
612,
508,
378,
26,
1039,
3002,
5777,
14,
1955,
63,
16,
8,
2063,
9,
1128,
916,
612,
508,
413,
26,
1039,
3002,
5777,
14,
1955,
63,
17,
8,
2063,
9,
1128,
916,
612,
508,
499,
26,
1039,
3002,
5777,
14,
1955,
63,
18,
8,
2063,
9,
1128,
916,
612,
508,
650,
26,
1039,
3002,
5777,
14,
1955,
63,
19,
8,
2063,
9,
1128,
916,
612,
508,
841,
26,
1039,
3002,
5777,
14,
1955,
63,
20,
8,
2063,
9,
1128,
916,
612,
508,
959,
26,
1039,
3002,
5777,
14,
1955,
63,
21,
8,
2063,
9,
1128,
916,
612,
508,
1227,
26,
1039,
3002,
5777,
14,
1955,
63,
22,
8,
2063,
9,
1128,
916,
612,
508,
1520,
26,
1039,
3002,
5777,
14,
1955,
63,
23,
8,
2063,
9,
1128,
916,
612,
508,
1695,
26,
1039,
3002,
5777,
14,
1955,
63,
24,
8,
2063,
9,
1128,
916,
612,
508,
1749,
26,
1039,
3002,
5777,
14,
1955,
63,
25,
8,
2063,
9,
2999,
199,
3,
25525,
922,
367,
6385,
436,
1104,
6385,
1128,
340,
20921,
914,
508,
298,
889,
582,
1039,
1315,
275,
1109,
8,
1210,
480,
29,
26725,
1039,
340,
3002,
5777,
14,
1074,
63,
5934,
8,
88,
12,
612,
12,
1315,
12,
1687,
9,
508,
715,
26,
1675,
870,
480,
19993,
9124,
1675,
307,
3397,
847,
413,
1675,
340,
1687,
508,
7210,
582,
2628,
10234,
63,
3397,
847,
413,
1675,
340,
1687,
508,
30312,
2628,
1007,
26137,
63,
3397,
847,
413,
1675,
340,
1687,
508,
8969,
582,
2628,
24638,
63,
3397,
847,
413,
1675,
340,
1687,
508,
30681,
2628,
4629,
63,
3397,
847,
413,
1039,
587,
26,
1675,
870,
480,
27143,
12,
626,
1159,
440,
3211,
2685,
17554,
1128,
916,
20921,
914,
508,
298,
5066,
582,
1039,
1830,
715,
26,
1675,
1315,
275,
1109,
8,
1210,
480,
29,
26725,
1675,
340,
3002,
5777,
14,
1074,
63,
5934,
8,
88,
12,
612,
12,
1315,
12,
1687,
9,
508,
756,
26,
2628,
870,
480,
27143,
12,
626,
1159,
440,
3211,
2685,
2628,
340,
1687,
508,
7210,
582,
4906,
10234,
63,
3397,
847,
413,
2628,
340,
1687,
508,
30312,
4906,
1007,
26137,
63,
3397,
847,
413,
2628
] |
[
3325,
5257,
377,
290,
12,
650,
15,
821,
12,
15247,
378,
709,
2999,
199,
646,
3002,
5777,
202,
199,
646,
2196,
2999,
199,
3,
25525,
922,
367,
4153,
436,
1104,
25667,
202,
199,
6710,
715,
26,
1128,
1894,
561,
275,
1109,
8,
1210,
480,
18335,
5002,
8826,
3955,
1265,
2839,
370,
7427,
31,
26725,
1128,
340,
1894,
561,
2695,
378,
26,
1039,
870,
480,
3364,
1329,
12,
862,
4020,
60,
78,
531,
1039,
1980,
1128,
587,
26,
1039,
2059,
2999,
199,
6710,
715,
26,
1128,
3462,
275,
1109,
8,
1210,
480,
18335,
20239,
886,
1265,
2934,
2195,
7576,
370,
506,
31,
959,
13,
709,
26,
26725,
1128,
340,
3462,
665,
959,
503,
3462,
690,
1616,
26,
1039,
870,
480,
3364,
3462,
12,
862,
4020,
60,
78,
531,
1039,
1980,
1128,
587,
26,
1039,
2059,
2999,
199,
6710,
715,
26,
1128,
20921,
914,
275,
620,
14,
2325,
8,
1210,
480,
55,
3857,
1265,
2839,
370,
15422,
283,
17824,
914,
7,
818,
31,
9456,
503,
949,
26,
26725,
1128,
340,
20921,
914,
1137,
298,
5066,
2,
436,
20921,
914,
1137,
298,
889,
582,
1039,
870,
480,
3364,
1177,
12,
862,
4020,
60,
78,
531,
1039,
1980,
1128,
587,
26,
1039,
2059,
8428,
202,
199,
1361,
4582,
78,
21741,
781,
2621,
9124,
2999,
199,
3,
16213,
2860,
370,
4426,
5396,
436,
11076,
202,
199,
1086,
1018,
275,
378,
202,
199,
26799,
275,
378,
202,
199,
954,
26137,
275,
378,
202,
199,
8016,
1863,
275,
378,
202,
199,
25035,
275,
378,
202,
199,
26799,
63,
3397,
275,
378,
202,
199,
954,
26137,
63,
3397,
275,
378,
202,
199,
8016,
1863,
63,
3397,
275,
378,
202,
199,
25035,
63,
3397,
275,
378,
2999,
199,
3,
1084,
1329,
402,
23071,
202,
199,
509,
284,
315,
1425,
8,
81,
561,
304,
1128,
870,
4582,
78,
21015,
365,
2508,
29279,
78,
531,
2958,
327,
16213,
2633,
1128,
671,
275,
2196,
14,
8393,
8,
16,
12,
1749,
9,
1128,
1687,
275,
2196,
14,
8393,
8,
17,
12,
841,
9,
1128,
612,
275,
2196,
14,
8393,
8,
16,
12,
1749,
9,
2958,
327,
1799,
367,
1686,
4629,
18649,
1128,
340,
1687,
508,
841,
26,
1039,
340,
612,
508,
378,
26,
1675,
612,
275,
2196,
14,
8393,
8,
17,
12,
1749,
9,
1039,
1830,
671,
450,
612,
1137,
378,
26,
1675,
671,
275,
2196,
14,
8393,
8,
16,
12,
1749,
9,
1675,
612,
275,
2196,
14,
8393,
8,
17,
12,
1749,
9,
8740,
202,
199,
3,
7687,
1642,
1329,
1128,
340,
671,
508,
378,
26,
1039,
3002,
5777,
14,
1955,
63,
16,
8,
2063,
9,
1128,
916,
671,
508,
413,
26,
1039,
3002,
5777,
14,
1955,
63,
17,
8,
2063,
9,
1128,
916,
671,
508,
499,
26,
1039,
3002,
5777,
14,
1955,
63,
18,
8,
2063,
9,
1128,
916,
671,
508,
650,
26,
1039,
3002,
5777,
14,
1955,
63,
19,
8,
2063,
9,
1128,
916,
671,
508,
841,
26,
1039,
3002,
5777,
14,
1955,
63,
20,
8,
2063,
9,
1128,
916,
671,
508,
959,
26,
1039,
3002,
5777,
14,
1955,
63,
21,
8,
2063,
9,
1128,
916,
671,
508,
1227,
26,
1039,
3002,
5777,
14,
1955,
63,
22,
8,
2063,
9,
1128,
916,
671,
508,
1520,
26,
1039,
3002,
5777,
14,
1955,
63,
23,
8,
2063,
9,
1128,
916,
671,
508,
1695,
26,
1039,
3002,
5777,
14,
1955,
63,
24,
8,
2063,
9,
1128,
916,
671,
508,
1749,
26,
1039,
3002,
5777,
14,
1955,
63,
25,
8,
2063,
9,
2999,
199,
3,
7687,
4182,
1128,
340,
1687,
508,
413,
26,
1039,
1687,
275,
298,
5207,
1039,
3002,
5777,
14,
6666,
8,
2063,
9,
1039,
10234,
847,
413,
1128,
916,
1687,
508,
499,
26,
1039,
1687,
275,
17155,
1039,
3002,
5777,
14,
13084,
8,
2063,
9,
1039,
1007,
26137,
847,
413,
1128,
916,
1687,
508,
650,
26,
1039,
1687,
275,
22423,
1039,
3002,
5777,
14,
13710,
8,
2063,
9,
1039,
24638,
847,
413,
1128,
916,
1687,
508,
841,
26,
1039,
1687,
275,
10609,
1039,
3002,
5777,
14,
16081,
8,
2063,
9,
1039,
4629,
847,
413,
2999,
199,
3,
7687,
3499,
1329,
1128,
340,
612,
508,
378,
26,
1039,
3002,
5777,
14,
1955,
63,
16,
8,
2063,
9,
1128,
916,
612,
508,
413,
26,
1039,
3002,
5777,
14,
1955,
63,
17,
8,
2063,
9,
1128,
916,
612,
508,
499,
26,
1039,
3002,
5777,
14,
1955,
63,
18,
8,
2063,
9,
1128,
916,
612,
508,
650,
26,
1039,
3002,
5777,
14,
1955,
63,
19,
8,
2063,
9,
1128,
916,
612,
508,
841,
26,
1039,
3002,
5777,
14,
1955,
63,
20,
8,
2063,
9,
1128,
916,
612,
508,
959,
26,
1039,
3002,
5777,
14,
1955,
63,
21,
8,
2063,
9,
1128,
916,
612,
508,
1227,
26,
1039,
3002,
5777,
14,
1955,
63,
22,
8,
2063,
9,
1128,
916,
612,
508,
1520,
26,
1039,
3002,
5777,
14,
1955,
63,
23,
8,
2063,
9,
1128,
916,
612,
508,
1695,
26,
1039,
3002,
5777,
14,
1955,
63,
24,
8,
2063,
9,
1128,
916,
612,
508,
1749,
26,
1039,
3002,
5777,
14,
1955,
63,
25,
8,
2063,
9,
2999,
199,
3,
25525,
922,
367,
6385,
436,
1104,
6385,
1128,
340,
20921,
914,
508,
298,
889,
582,
1039,
1315,
275,
1109,
8,
1210,
480,
29,
26725,
1039,
340,
3002,
5777,
14,
1074,
63,
5934,
8,
88,
12,
612,
12,
1315,
12,
1687,
9,
508,
715,
26,
1675,
870,
480,
19993,
9124,
1675,
307,
3397,
847,
413,
1675,
340,
1687,
508,
7210,
582,
2628,
10234,
63,
3397,
847,
413,
1675,
340,
1687,
508,
30312,
2628,
1007,
26137,
63,
3397,
847,
413,
1675,
340,
1687,
508,
8969,
582,
2628,
24638,
63,
3397,
847,
413,
1675,
340,
1687,
508,
30681,
2628,
4629,
63,
3397,
847,
413,
1039,
587,
26,
1675,
870,
480,
27143,
12,
626,
1159,
440,
3211,
2685,
17554,
1128,
916,
20921,
914,
508,
298,
5066,
582,
1039,
1830,
715,
26,
1675,
1315,
275,
1109,
8,
1210,
480,
29,
26725,
1675,
340,
3002,
5777,
14,
1074,
63,
5934,
8,
88,
12,
612,
12,
1315,
12,
1687,
9,
508,
756,
26,
2628,
870,
480,
27143,
12,
626,
1159,
440,
3211,
2685,
2628,
340,
1687,
508,
7210,
582,
4906,
10234,
63,
3397,
847,
413,
2628,
340,
1687,
508,
30312,
4906,
1007,
26137,
63,
3397,
847,
413,
2628,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
jmehnle/ansible
|
lib/ansible/modules/cloud/rackspace/rax_cbs.py
|
70
|
7282
|
#!/usr/bin/python
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# This is a DOCUMENTATION stub specific to this module, it extends
# a documentation fragment located in ansible.utils.module_docs_fragments
ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: rax_cbs
short_description: Manipulate Rackspace Cloud Block Storage Volumes
description:
- Manipulate Rackspace Cloud Block Storage Volumes
version_added: 1.6
options:
description:
description:
- Description to give the volume being created
default: null
image:
description:
- image to use for bootable volumes. Can be an C(id), C(human_id) or
C(name). This option requires C(pyrax>=1.9.3)
default: null
version_added: 1.9
meta:
description:
- A hash of metadata to associate with the volume
default: null
name:
description:
- Name to give the volume being created
default: null
required: true
size:
description:
- Size of the volume to create in Gigabytes
default: 100
required: true
snapshot_id:
description:
- The id of the snapshot to create the volume from
default: null
state:
description:
- Indicate desired state of the resource
choices:
- present
- absent
default: present
required: true
volume_type:
description:
- Type of the volume being created
choices:
- SATA
- SSD
default: SATA
required: true
wait:
description:
- wait for the volume to be in state 'available' before returning
default: "no"
choices:
- "yes"
- "no"
wait_timeout:
description:
- how long before wait gives up, in seconds
default: 300
author:
- "Christopher H. Laco (@claco)"
- "Matt Martz (@sivel)"
extends_documentation_fragment: rackspace.openstack
'''
EXAMPLES = '''
- name: Build a Block Storage Volume
gather_facts: False
hosts: local
connection: local
tasks:
- name: Storage volume create request
local_action:
module: rax_cbs
credentials: ~/.raxpub
name: my-volume
description: My Volume
volume_type: SSD
size: 150
region: DFW
wait: yes
state: present
meta:
app: my-cool-app
register: my_volume
'''
from distutils.version import LooseVersion
try:
import pyrax
HAS_PYRAX = True
except ImportError:
HAS_PYRAX = False
def cloud_block_storage(module, state, name, description, meta, size,
snapshot_id, volume_type, wait, wait_timeout,
image):
changed = False
volume = None
instance = {}
cbs = pyrax.cloud_blockstorage
if cbs is None:
module.fail_json(msg='Failed to instantiate client. This '
'typically indicates an invalid region or an '
'incorrectly capitalized region name.')
if image:
# pyrax<1.9.3 did not have support for specifying an image when
# creating a volume which is required for bootable volumes
if LooseVersion(pyrax.version.version) < LooseVersion('1.9.3'):
module.fail_json(msg='Creating a bootable volume requires '
'pyrax>=1.9.3')
image = rax_find_image(module, pyrax, image)
volume = rax_find_volume(module, pyrax, name)
if state == 'present':
if not volume:
kwargs = dict()
if image:
kwargs['image'] = image
try:
volume = cbs.create(name, size=size, volume_type=volume_type,
description=description,
metadata=meta,
snapshot_id=snapshot_id, **kwargs)
changed = True
except Exception as e:
module.fail_json(msg='%s' % e.message)
else:
if wait:
attempts = wait_timeout / 5
pyrax.utils.wait_for_build(volume, interval=5,
attempts=attempts)
volume.get()
instance = rax_to_dict(volume)
result = dict(changed=changed, volume=instance)
if volume.status == 'error':
result['msg'] = '%s failed to build' % volume.id
elif wait and volume.status not in VOLUME_STATUS:
result['msg'] = 'Timeout waiting on %s' % volume.id
if 'msg' in result:
module.fail_json(**result)
else:
module.exit_json(**result)
elif state == 'absent':
if volume:
instance = rax_to_dict(volume)
try:
volume.delete()
changed = True
except Exception as e:
module.fail_json(msg='%s' % e.message)
module.exit_json(changed=changed, volume=instance)
def main():
argument_spec = rax_argument_spec()
argument_spec.update(
dict(
description=dict(type='str'),
image=dict(type='str'),
meta=dict(type='dict', default={}),
name=dict(required=True),
size=dict(type='int', default=100),
snapshot_id=dict(),
state=dict(default='present', choices=['present', 'absent']),
volume_type=dict(choices=['SSD', 'SATA'], default='SATA'),
wait=dict(type='bool', default=False),
wait_timeout=dict(type='int', default=300)
)
)
module = AnsibleModule(
argument_spec=argument_spec,
required_together=rax_required_together()
)
if not HAS_PYRAX:
module.fail_json(msg='pyrax is required for this module')
description = module.params.get('description')
image = module.params.get('image')
meta = module.params.get('meta')
name = module.params.get('name')
size = module.params.get('size')
snapshot_id = module.params.get('snapshot_id')
state = module.params.get('state')
volume_type = module.params.get('volume_type')
wait = module.params.get('wait')
wait_timeout = module.params.get('wait_timeout')
setup_rax_module(module, pyrax)
cloud_block_storage(module, state, name, description, meta, size,
snapshot_id, volume_type, wait, wait_timeout,
image)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.rax import *
# invoke the module
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
961,
365,
282,
29970,
2594,
10098,
2488,
370,
642,
859,
12,
652,
16879,
199,
3,
282,
3794,
7956,
16180,
315,
3242,
14,
1208,
14,
578,
63,
4757,
63,
18047,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
16,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
16937,
63,
67,
1533,
199,
3612,
63,
1802,
26,
4688,
711,
5434,
32679,
8142,
8651,
10533,
15018,
83,
199,
1802,
26,
1362,
446,
4688,
711,
5434,
32679,
8142,
8651,
10533,
15018,
83,
199,
1023,
63,
3270,
26,
413,
14,
22,
199,
1419,
26,
523,
1369,
26,
272,
1369,
26,
489,
446,
11994,
370,
8120,
314,
3301,
3769,
2737,
272,
849,
26,
2973,
523,
1834,
26,
272,
1369,
26,
489,
446,
1834,
370,
675,
367,
8498,
461,
12158,
14,
6855,
506,
376,
445,
8,
344,
395,
445,
8,
14864,
63,
344,
9,
503,
267,
445,
8,
354,
680,
961,
945,
5074,
445,
8,
647,
14495,
8119,
17,
14,
25,
14,
19,
9,
272,
849,
26,
2973,
272,
1015,
63,
3270,
26,
413,
14,
25,
523,
3404,
26,
272,
1369,
26,
489,
446,
437,
2631,
402,
3341,
370,
20133,
543,
314,
3301,
272,
849,
26,
2973,
523,
536,
26,
272,
1369,
26,
489,
446,
2812,
370,
8120,
314,
3301,
3769,
2737,
272,
849,
26,
2973,
272,
1415,
26,
2549,
523,
1568,
26,
272,
1369,
26,
489,
446,
14579,
402,
314,
3301,
370,
1218,
315,
598,
528,
27601,
272,
849,
26,
2948,
272,
1415,
26,
2549,
523,
5740,
63,
344,
26,
272,
1369,
26,
489,
446,
710,
1305,
402,
314,
5740,
370,
1218,
314,
3301,
687,
272,
849,
26,
2973,
523,
1174,
26,
272,
1369,
26,
489,
446,
1010,
10188,
6387,
1174,
402,
314,
2073,
272,
3415,
26,
489,
446,
3451,
489,
446,
9552,
272,
849,
26,
3451,
272,
1415,
26,
2549,
523,
3301,
63,
466,
26,
272,
1369,
26,
489,
446,
2434,
402,
314,
3301,
3769,
2737,
272,
3415,
26,
489,
446,
428,
2751,
489,
446,
428,
3693,
272,
849,
26,
428,
2751,
272,
1415,
26,
2549,
523,
3618,
26,
272,
1369,
26,
489,
446,
3618,
367,
314,
3301,
370,
506,
315,
1174,
283,
4561,
7,
2544,
8152,
272,
849,
26,
298,
889,
2,
272,
3415,
26,
489,
446,
298,
5066,
2,
489,
446,
298,
889,
2,
523,
3618,
63,
2593,
26,
272,
1369,
26,
489,
446,
4212,
1846,
2544,
3618,
10557,
1536,
12,
315,
4696,
272,
849,
26,
9601,
199,
2502,
26,
272,
446,
298,
1049,
322,
2379,
2523,
869,
14,
7964,
331,
8593,
3995,
331,
2924,
272,
446,
298,
45,
6796,
603,
28124,
8593,
338,
1090,
2924,
199,
11036,
63,
9970,
63,
7677,
26,
660,
346,
2638,
14,
8512,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
6516,
282,
8651,
10533,
15018,
523,
13082,
63,
5047,
26,
756,
523,
7057,
26,
2257,
523,
1950,
26,
2257,
523,
6527,
26,
272,
446,
536,
26,
10533,
3301,
1218,
1056,
489,
2257,
63,
1287,
26,
267,
859,
26,
16937,
63,
67,
1533,
267,
6235,
26,
25975,
14495,
5645,
267,
536,
26,
3002,
13,
2405,
267,
1369,
26,
4932,
15018,
267,
3301,
63,
466,
26,
428,
3693,
267,
1568,
26,
14711,
267,
4897,
26,
577,
19445,
267,
3618,
26,
9456,
267,
1174,
26,
3451,
267,
3404,
26,
881,
1145,
26,
3002,
13,
18499,
13,
571,
489,
2274,
26,
3002,
63,
2405,
199,
2344,
199,
199,
504,
7065,
14,
1023,
492,
18462,
199,
199,
893,
26,
272,
492,
23944,
272,
7509,
63,
4521,
2847,
56,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
4521,
2847,
56,
275,
756,
421,
199,
318,
8002,
63,
1457,
63,
3494,
8,
578,
12,
1174,
12,
536,
12,
1369,
12,
3404,
12,
1568,
12,
717,
5740,
63,
344,
12,
3301,
63,
466,
12,
3618,
12,
3618,
63,
2593,
12,
717,
1834,
304,
272,
2896,
275,
756,
272,
3301,
275,
488,
272,
1256,
275,
1052,
339,
286,
1533,
275,
23944,
14,
4091,
63,
1457,
3494,
339,
340,
286,
1533,
365,
488,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
4276,
370,
17321,
1890,
14,
961,
283,
2490,
283,
32251,
9126,
376,
3866,
4897,
503,
376,
283,
2490,
283,
15448,
590,
17094,
1759,
4897,
536,
2659,
339,
340,
1834,
26,
267,
327,
23944,
28,
17,
14,
25,
14,
19,
8103,
440,
1172,
2291,
367,
9176,
376,
1834,
1380,
267,
327,
6425,
282,
3301,
1314,
365,
1415,
367,
8498,
461,
12158,
267,
340,
18462,
8,
647,
14495,
14,
1023,
14,
1023,
9,
665,
18462,
360,
17,
14,
25,
14,
19,
735,
288,
859,
14,
1633,
63,
1001,
8,
1328,
534,
14380,
282,
8498,
461,
3301,
5074,
283,
639,
283,
647,
14495,
8119,
17,
14,
25,
14,
19,
358,
267,
1834,
275,
16937,
63,
1623,
63,
1569,
8,
578,
12,
23944,
12,
1834,
9,
339,
3301,
275,
16937,
63,
1623,
63,
2405,
8,
578,
12,
23944,
12,
536,
9,
339,
340,
1174,
508,
283,
1881,
356,
267,
340,
440,
3301,
26,
288,
2074,
275,
1211,
342,
288,
340,
1834,
26,
355,
2074,
459,
1569,
418,
275,
1834,
288,
862,
26,
355,
3301,
275,
286,
1533,
14,
981
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
961,
365,
282,
29970,
2594,
10098,
2488,
370,
642,
859,
12,
652,
16879,
199,
3,
282,
3794,
7956,
16180,
315,
3242,
14,
1208,
14,
578,
63,
4757,
63,
18047,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
16,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
16937,
63,
67,
1533,
199,
3612,
63,
1802,
26,
4688,
711,
5434,
32679,
8142,
8651,
10533,
15018,
83,
199,
1802,
26,
1362,
446,
4688,
711,
5434,
32679,
8142,
8651,
10533,
15018,
83,
199,
1023,
63,
3270,
26,
413,
14,
22,
199,
1419,
26,
523,
1369,
26,
272,
1369,
26,
489,
446,
11994,
370,
8120,
314,
3301,
3769,
2737,
272,
849,
26,
2973,
523,
1834,
26,
272,
1369,
26,
489,
446,
1834,
370,
675,
367,
8498,
461,
12158,
14,
6855,
506,
376,
445,
8,
344,
395,
445,
8,
14864,
63,
344,
9,
503,
267,
445,
8,
354,
680,
961,
945,
5074,
445,
8,
647,
14495,
8119,
17,
14,
25,
14,
19,
9,
272,
849,
26,
2973,
272,
1015,
63,
3270,
26,
413,
14,
25,
523,
3404,
26,
272,
1369,
26,
489,
446,
437,
2631,
402,
3341,
370,
20133,
543,
314,
3301,
272,
849,
26,
2973,
523,
536,
26,
272,
1369,
26,
489,
446,
2812,
370,
8120,
314,
3301,
3769,
2737,
272,
849,
26,
2973,
272,
1415,
26,
2549,
523,
1568,
26,
272,
1369,
26,
489,
446,
14579,
402,
314,
3301,
370,
1218,
315,
598,
528,
27601,
272,
849,
26,
2948,
272,
1415,
26,
2549,
523,
5740,
63,
344,
26,
272,
1369,
26,
489,
446,
710,
1305,
402,
314,
5740,
370,
1218,
314,
3301,
687,
272,
849,
26,
2973,
523,
1174,
26,
272,
1369,
26,
489,
446,
1010,
10188,
6387,
1174,
402,
314,
2073,
272,
3415,
26,
489,
446,
3451,
489,
446,
9552,
272,
849,
26,
3451,
272,
1415,
26,
2549,
523,
3301,
63,
466,
26,
272,
1369,
26,
489,
446,
2434,
402,
314,
3301,
3769,
2737,
272,
3415,
26,
489,
446,
428,
2751,
489,
446,
428,
3693,
272,
849,
26,
428,
2751,
272,
1415,
26,
2549,
523,
3618,
26,
272,
1369,
26,
489,
446,
3618,
367,
314,
3301,
370,
506,
315,
1174,
283,
4561,
7,
2544,
8152,
272,
849,
26,
298,
889,
2,
272,
3415,
26,
489,
446,
298,
5066,
2,
489,
446,
298,
889,
2,
523,
3618,
63,
2593,
26,
272,
1369,
26,
489,
446,
4212,
1846,
2544,
3618,
10557,
1536,
12,
315,
4696,
272,
849,
26,
9601,
199,
2502,
26,
272,
446,
298,
1049,
322,
2379,
2523,
869,
14,
7964,
331,
8593,
3995,
331,
2924,
272,
446,
298,
45,
6796,
603,
28124,
8593,
338,
1090,
2924,
199,
11036,
63,
9970,
63,
7677,
26,
660,
346,
2638,
14,
8512,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
6516,
282,
8651,
10533,
15018,
523,
13082,
63,
5047,
26,
756,
523,
7057,
26,
2257,
523,
1950,
26,
2257,
523,
6527,
26,
272,
446,
536,
26,
10533,
3301,
1218,
1056,
489,
2257,
63,
1287,
26,
267,
859,
26,
16937,
63,
67,
1533,
267,
6235,
26,
25975,
14495,
5645,
267,
536,
26,
3002,
13,
2405,
267,
1369,
26,
4932,
15018,
267,
3301,
63,
466,
26,
428,
3693,
267,
1568,
26,
14711,
267,
4897,
26,
577,
19445,
267,
3618,
26,
9456,
267,
1174,
26,
3451,
267,
3404,
26,
881,
1145,
26,
3002,
13,
18499,
13,
571,
489,
2274,
26,
3002,
63,
2405,
199,
2344,
199,
199,
504,
7065,
14,
1023,
492,
18462,
199,
199,
893,
26,
272,
492,
23944,
272,
7509,
63,
4521,
2847,
56,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
4521,
2847,
56,
275,
756,
421,
199,
318,
8002,
63,
1457,
63,
3494,
8,
578,
12,
1174,
12,
536,
12,
1369,
12,
3404,
12,
1568,
12,
717,
5740,
63,
344,
12,
3301,
63,
466,
12,
3618,
12,
3618,
63,
2593,
12,
717,
1834,
304,
272,
2896,
275,
756,
272,
3301,
275,
488,
272,
1256,
275,
1052,
339,
286,
1533,
275,
23944,
14,
4091,
63,
1457,
3494,
339,
340,
286,
1533,
365,
488,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
4276,
370,
17321,
1890,
14,
961,
283,
2490,
283,
32251,
9126,
376,
3866,
4897,
503,
376,
283,
2490,
283,
15448,
590,
17094,
1759,
4897,
536,
2659,
339,
340,
1834,
26,
267,
327,
23944,
28,
17,
14,
25,
14,
19,
8103,
440,
1172,
2291,
367,
9176,
376,
1834,
1380,
267,
327,
6425,
282,
3301,
1314,
365,
1415,
367,
8498,
461,
12158,
267,
340,
18462,
8,
647,
14495,
14,
1023,
14,
1023,
9,
665,
18462,
360,
17,
14,
25,
14,
19,
735,
288,
859,
14,
1633,
63,
1001,
8,
1328,
534,
14380,
282,
8498,
461,
3301,
5074,
283,
639,
283,
647,
14495,
8119,
17,
14,
25,
14,
19,
358,
267,
1834,
275,
16937,
63,
1623,
63,
1569,
8,
578,
12,
23944,
12,
1834,
9,
339,
3301,
275,
16937,
63,
1623,
63,
2405,
8,
578,
12,
23944,
12,
536,
9,
339,
340,
1174,
508,
283,
1881,
356,
267,
340,
440,
3301,
26,
288,
2074,
275,
1211,
342,
288,
340,
1834,
26,
355,
2074,
459,
1569,
418,
275,
1834,
288,
862,
26,
355,
3301,
275,
286,
1533,
14,
981,
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,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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
] |
DBHeise/fileid
|
runtests.py
|
1
|
2380
|
import requests, json, argparse, os, subprocess, xmltodict
envDict = {}
ignoreFiles = [".gitignore",".gitattributes","LICENSE"]
ignoreExt = [".md",".txt",".json",".ps1",".py"]
def findBinaries(basefolder):
testBinaries = []
fileidBinaries = []
for root, dirs, files in os.walk(basefolder):
for file in files:
if file.endswith("_test.exe") or file.endswith("_test"):
testBinaries.append(os.path.join(root,file))
elif file == "fileid.exe" or file == "fid" or file == "fileid":
fileidBinaries.append(os.path.join(root,file))
return fileidBinaries,testBinaries
def runTestBinary(file):
print("Running Test: " + file)
process = subprocess.Popen(file, shell=True, env=envDict)
process.wait()
return process.returncode == 0
def testfiles(fidbin, folder):
allgood = True
for root, dirs, files in os.walk(folder):
if ".git" in dirs:
dirs.remove('.git')
for file in files:
fullpath = os.path.join(root, file)
file_name, file_ext = os.path.splitext(file)
if not file_name in ignoreFiles and not file_ext in ignoreExt:
allgood &= testfile(fidbin, fullpath)
return allgood
def testfile(fid, file, format = "json"):
outputStr = subprocess.check_output([fid, file, format])
output = {}
if format == "json":
output = json.loads(outputStr)
elif format == "xml":
output = xmltodict.parse(outputStr)
actual_ext = [extension["extension"].lower() for extension in output["extensions"]]
filename, expected_ext = os.path.splitext(file)
if "_" in expected_ext:
expected_ext = expected_ext.replace(".","").replace("_",".").lower()
else:
expected_ext = expected_ext.replace(".","").lower()
if expected_ext not in actual_ext:
print("FAIL! (" + expected_ext + "!=" + ",".join(actual_ext) +") " + file)
return False
return True
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run FILEID tests")
parser.add_argument("--build", help="path to build output")
parser.add_argument("--files", help="path to directory containing test files")
args = parser.parse_args()
fileids, testbins = findBinaries(args.build)
envDict = dict(os.environ)
envDict["TESTFOLDER"] = args.files
allgood = True
## Run Unit Tests
for testBin in testbins:
allgood &= runTestBinary(testBin)
## Run Test Files
for fid in fileids:
allgood &= testfiles(fid, args.files)
if not allgood:
exit(-10)
|
mit
|
[
646,
4145,
12,
2022,
12,
7534,
12,
747,
12,
3873,
12,
2748,
475,
807,
199,
199,
1813,
2141,
275,
1052,
199,
4247,
5535,
275,
359,
1674,
71,
5277,
7160,
401,
1674,
3187,
2987,
2266,
3961,
937,
199,
4247,
4942,
275,
359,
1674,
1064,
401,
1674,
2424,
401,
1674,
1001,
401,
1674,
1190,
17,
401,
1674,
647,
937,
199,
199,
318,
2342,
13394,
3433,
8,
1095,
3741,
304,
199,
198,
396,
13394,
3433,
275,
942,
199,
198,
493,
344,
13394,
3433,
275,
942,
199,
198,
509,
1738,
12,
7606,
12,
1584,
315,
747,
14,
7757,
8,
1095,
3741,
304,
507,
198,
509,
570,
315,
1584,
26,
686,
198,
692,
570,
14,
4130,
11008,
396,
14,
5803,
531,
503,
570,
14,
4130,
11008,
396,
2349,
1585,
198,
396,
13394,
3433,
14,
740,
8,
736,
14,
515,
14,
904,
8,
1231,
12,
493,
430,
686,
198,
4164,
570,
508,
298,
493,
344,
14,
5803,
2,
503,
570,
508,
298,
9430,
2,
503,
570,
508,
298,
493,
344,
582,
1585,
198,
493,
344,
13394,
3433,
14,
740,
8,
736,
14,
515,
14,
904,
8,
1231,
12,
493,
430,
199,
198,
1107,
570,
344,
13394,
3433,
12,
396,
13394,
3433,
199,
199,
318,
29779,
6636,
8,
493,
304,
199,
198,
1361,
480,
9602,
1379,
26,
298,
435,
570,
9,
199,
198,
1412,
275,
3873,
14,
7942,
8,
493,
12,
5218,
29,
549,
12,
2589,
29,
1813,
2141,
9,
199,
198,
1412,
14,
2573,
342,
199,
198,
1107,
2112,
14,
9913,
508,
378,
199,
199,
318,
511,
1725,
8,
329,
697,
262,
12,
4922,
304,
199,
198,
452,
8302,
275,
715,
199,
198,
509,
1738,
12,
7606,
12,
1584,
315,
747,
14,
7757,
8,
3741,
304,
507,
198,
692,
3680,
3187,
2,
315,
7606,
26,
686,
198,
3220,
14,
2168,
5175,
3187,
358,
507,
198,
509,
570,
315,
1584,
26,
686,
198,
17943,
275,
747,
14,
515,
14,
904,
8,
1231,
12,
570,
9,
686,
198,
493,
63,
354,
12,
570,
63,
832,
275,
747,
14,
515,
14,
7973,
8,
493,
9,
686,
198,
692,
440,
570,
63,
354,
315,
3686,
5535,
436,
440,
570,
63,
832,
315,
3686,
4942,
26,
1585,
198,
452,
8302,
18415,
30530,
8,
329,
697,
262,
12,
26404,
9,
8299,
198,
1107,
1006,
8302,
199,
199,
318,
30530,
8,
9430,
12,
570,
12,
1475,
275,
298,
1001,
2349,
199,
198,
1199,
2848,
275,
3873,
14,
1074,
63,
1199,
779,
9430,
12,
570,
12,
1475,
566,
199,
198,
1199,
275,
1052,
8299,
198,
692,
1475,
508,
298,
1001,
582,
507,
198,
1199,
275,
2022,
14,
3640,
8,
1199,
2848,
9,
199,
198,
4164,
1475,
508,
298,
1652,
582,
507,
198,
1199,
275,
2748,
475,
807,
14,
1122,
8,
1199,
2848,
9,
8299,
198,
6514,
63,
832,
275,
359,
3435,
905,
3435,
4140,
2325,
342,
367,
3329,
315,
1072,
905,
5359,
15261,
8299,
198,
1501,
12,
1420,
63,
832,
275,
747,
14,
515,
14,
7973,
8,
493,
9,
8299,
198,
692,
14220,
315,
1420,
63,
832,
26,
507,
198,
2062,
63,
832,
275,
1420,
63,
832,
14,
1814,
30381,
341,
680,
1814,
11008,
401,
1674,
3471,
2325,
342,
199,
198,
2836,
26,
507,
198,
2062,
63,
832,
275,
1420,
63,
832,
14,
1814,
30381,
341,
680,
2325,
342,
421,
198,
692,
1420,
63,
832,
440,
315,
3503,
63,
832,
26,
507,
198,
1361,
480,
8784,
1,
1689,
435,
1420,
63,
832,
435,
19724,
628,
435,
19089,
904,
8,
6514,
63,
832,
9,
435,
531,
298,
435,
570,
9,
507,
198,
1107,
756,
8299,
198,
1107,
715,
18118,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
199,
198,
2087,
275,
7534,
14,
10730,
8,
1802,
628,
2540,
13024,
998,
2295,
531,
258,
199,
198,
2087,
14,
525,
63,
2094,
6739,
1506,
401,
1720,
628,
515,
370,
1900,
1072,
531,
199,
198,
2087,
14,
525,
63,
2094,
6739,
1725,
401,
1720,
628,
515,
370,
2082,
3035,
511,
1584,
531,
199,
198,
589,
275,
1798,
14,
1122,
63,
589,
342,
421,
198,
493,
1580,
12,
511,
11329,
275,
2342,
13394,
3433,
8,
589,
14,
1506,
9,
421,
198,
1813,
2141,
275,
1211,
8,
736,
14,
2314,
9,
199,
198,
1813,
2141,
905,
2864,
19041,
937,
275,
1249,
14,
1725,
421,
198,
452,
8302,
275,
715,
421,
198,
309,
3378,
12008,
6496,
199,
198,
509,
511,
13394,
315,
511,
11329,
26,
507,
198,
452,
8302,
18415,
29779,
6636,
8,
396,
13394,
9,
1057,
421,
198,
309,
3378,
1379,
16920,
199,
198,
509,
8289,
315,
570,
1580,
26,
507,
198,
452,
8302,
18415,
511,
1725,
8,
9430,
12,
1249,
14,
1725,
9,
4388,
198,
692,
440,
1006,
8302,
26,
507,
198,
2224,
2801,
709,
9,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4145,
12,
2022,
12,
7534,
12,
747,
12,
3873,
12,
2748,
475,
807,
199,
199,
1813,
2141,
275,
1052,
199,
4247,
5535,
275,
359,
1674,
71,
5277,
7160,
401,
1674,
3187,
2987,
2266,
3961,
937,
199,
4247,
4942,
275,
359,
1674,
1064,
401,
1674,
2424,
401,
1674,
1001,
401,
1674,
1190,
17,
401,
1674,
647,
937,
199,
199,
318,
2342,
13394,
3433,
8,
1095,
3741,
304,
199,
198,
396,
13394,
3433,
275,
942,
199,
198,
493,
344,
13394,
3433,
275,
942,
199,
198,
509,
1738,
12,
7606,
12,
1584,
315,
747,
14,
7757,
8,
1095,
3741,
304,
507,
198,
509,
570,
315,
1584,
26,
686,
198,
692,
570,
14,
4130,
11008,
396,
14,
5803,
531,
503,
570,
14,
4130,
11008,
396,
2349,
1585,
198,
396,
13394,
3433,
14,
740,
8,
736,
14,
515,
14,
904,
8,
1231,
12,
493,
430,
686,
198,
4164,
570,
508,
298,
493,
344,
14,
5803,
2,
503,
570,
508,
298,
9430,
2,
503,
570,
508,
298,
493,
344,
582,
1585,
198,
493,
344,
13394,
3433,
14,
740,
8,
736,
14,
515,
14,
904,
8,
1231,
12,
493,
430,
199,
198,
1107,
570,
344,
13394,
3433,
12,
396,
13394,
3433,
199,
199,
318,
29779,
6636,
8,
493,
304,
199,
198,
1361,
480,
9602,
1379,
26,
298,
435,
570,
9,
199,
198,
1412,
275,
3873,
14,
7942,
8,
493,
12,
5218,
29,
549,
12,
2589,
29,
1813,
2141,
9,
199,
198,
1412,
14,
2573,
342,
199,
198,
1107,
2112,
14,
9913,
508,
378,
199,
199,
318,
511,
1725,
8,
329,
697,
262,
12,
4922,
304,
199,
198,
452,
8302,
275,
715,
199,
198,
509,
1738,
12,
7606,
12,
1584,
315,
747,
14,
7757,
8,
3741,
304,
507,
198,
692,
3680,
3187,
2,
315,
7606,
26,
686,
198,
3220,
14,
2168,
5175,
3187,
358,
507,
198,
509,
570,
315,
1584,
26,
686,
198,
17943,
275,
747,
14,
515,
14,
904,
8,
1231,
12,
570,
9,
686,
198,
493,
63,
354,
12,
570,
63,
832,
275,
747,
14,
515,
14,
7973,
8,
493,
9,
686,
198,
692,
440,
570,
63,
354,
315,
3686,
5535,
436,
440,
570,
63,
832,
315,
3686,
4942,
26,
1585,
198,
452,
8302,
18415,
30530,
8,
329,
697,
262,
12,
26404,
9,
8299,
198,
1107,
1006,
8302,
199,
199,
318,
30530,
8,
9430,
12,
570,
12,
1475,
275,
298,
1001,
2349,
199,
198,
1199,
2848,
275,
3873,
14,
1074,
63,
1199,
779,
9430,
12,
570,
12,
1475,
566,
199,
198,
1199,
275,
1052,
8299,
198,
692,
1475,
508,
298,
1001,
582,
507,
198,
1199,
275,
2022,
14,
3640,
8,
1199,
2848,
9,
199,
198,
4164,
1475,
508,
298,
1652,
582,
507,
198,
1199,
275,
2748,
475,
807,
14,
1122,
8,
1199,
2848,
9,
8299,
198,
6514,
63,
832,
275,
359,
3435,
905,
3435,
4140,
2325,
342,
367,
3329,
315,
1072,
905,
5359,
15261,
8299,
198,
1501,
12,
1420,
63,
832,
275,
747,
14,
515,
14,
7973,
8,
493,
9,
8299,
198,
692,
14220,
315,
1420,
63,
832,
26,
507,
198,
2062,
63,
832,
275,
1420,
63,
832,
14,
1814,
30381,
341,
680,
1814,
11008,
401,
1674,
3471,
2325,
342,
199,
198,
2836,
26,
507,
198,
2062,
63,
832,
275,
1420,
63,
832,
14,
1814,
30381,
341,
680,
2325,
342,
421,
198,
692,
1420,
63,
832,
440,
315,
3503,
63,
832,
26,
507,
198,
1361,
480,
8784,
1,
1689,
435,
1420,
63,
832,
435,
19724,
628,
435,
19089,
904,
8,
6514,
63,
832,
9,
435,
531,
298,
435,
570,
9,
507,
198,
1107,
756,
8299,
198,
1107,
715,
18118,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
199,
198,
2087,
275,
7534,
14,
10730,
8,
1802,
628,
2540,
13024,
998,
2295,
531,
258,
199,
198,
2087,
14,
525,
63,
2094,
6739,
1506,
401,
1720,
628,
515,
370,
1900,
1072,
531,
199,
198,
2087,
14,
525,
63,
2094,
6739,
1725,
401,
1720,
628,
515,
370,
2082,
3035,
511,
1584,
531,
199,
198,
589,
275,
1798,
14,
1122,
63,
589,
342,
421,
198,
493,
1580,
12,
511,
11329,
275,
2342,
13394,
3433,
8,
589,
14,
1506,
9,
421,
198,
1813,
2141,
275,
1211,
8,
736,
14,
2314,
9,
199,
198,
1813,
2141,
905,
2864,
19041,
937,
275,
1249,
14,
1725,
421,
198,
452,
8302,
275,
715,
421,
198,
309,
3378,
12008,
6496,
199,
198,
509,
511,
13394,
315,
511,
11329,
26,
507,
198,
452,
8302,
18415,
29779,
6636,
8,
396,
13394,
9,
1057,
421,
198,
309,
3378,
1379,
16920,
199,
198,
509,
8289,
315,
570,
1580,
26,
507,
198,
452,
8302,
18415,
511,
1725,
8,
9430,
12,
1249,
14,
1725,
9,
4388,
198,
692,
440,
1006,
8302,
26,
507,
198,
2224,
2801,
709,
9,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
andfoy/margffoy-tuay-server
|
env/lib/python2.7/site-packages/tornado/iostream.py
|
38
|
64263
|
#!/usr/bin/env python
#
# Copyright 2009 Facebook
#
# 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.
"""Utility classes to write to and read from non-blocking files and sockets.
Contents:
* `BaseIOStream`: Generic interface for reading and writing.
* `IOStream`: Implementation of BaseIOStream using non-blocking sockets.
* `SSLIOStream`: SSL-aware version of IOStream.
* `PipeIOStream`: Pipe-based IOStream implementation.
"""
from __future__ import absolute_import, division, print_function, with_statement
import collections
import errno
import numbers
import os
import socket
import sys
import re
from tornado.concurrent import TracebackFuture
from tornado import ioloop
from tornado.log import gen_log, app_log
from tornado.netutil import ssl_wrap_socket, ssl_match_hostname, SSLCertificateError, _client_ssl_defaults, _server_ssl_defaults
from tornado import stack_context
from tornado.util import errno_from_exception
try:
from tornado.platform.posix import _set_nonblocking
except ImportError:
_set_nonblocking = None
try:
import ssl
except ImportError:
# ssl is not available on Google App Engine
ssl = None
# These errnos indicate that a non-blocking operation must be retried
# at a later time. On most platforms they're the same value, but on
# some they differ.
_ERRNO_WOULDBLOCK = (errno.EWOULDBLOCK, errno.EAGAIN)
if hasattr(errno, "WSAEWOULDBLOCK"):
_ERRNO_WOULDBLOCK += (errno.WSAEWOULDBLOCK,)
# These errnos indicate that a connection has been abruptly terminated.
# They should be caught and handled less noisily than other errors.
_ERRNO_CONNRESET = (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE,
errno.ETIMEDOUT)
if hasattr(errno, "WSAECONNRESET"):
_ERRNO_CONNRESET += (errno.WSAECONNRESET, errno.WSAECONNABORTED, errno.WSAETIMEDOUT)
if sys.platform == 'darwin':
# OSX appears to have a race condition that causes send(2) to return
# EPROTOTYPE if called while a socket is being torn down:
# http://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
# Since the socket is being closed anyway, treat this as an ECONNRESET
# instead of an unexpected error.
_ERRNO_CONNRESET += (errno.EPROTOTYPE,)
# More non-portable errnos:
_ERRNO_INPROGRESS = (errno.EINPROGRESS,)
if hasattr(errno, "WSAEINPROGRESS"):
_ERRNO_INPROGRESS += (errno.WSAEINPROGRESS,)
class StreamClosedError(IOError):
"""Exception raised by `IOStream` methods when the stream is closed.
Note that the close callback is scheduled to run *after* other
callbacks on the stream (to allow for buffered data to be processed),
so you may see this error before you see the close callback.
"""
pass
class UnsatisfiableReadError(Exception):
"""Exception raised when a read cannot be satisfied.
Raised by ``read_until`` and ``read_until_regex`` with a ``max_bytes``
argument.
"""
pass
class StreamBufferFullError(Exception):
"""Exception raised by `IOStream` methods when the buffer is full.
"""
class BaseIOStream(object):
"""A utility class to write to and read from a non-blocking file or socket.
We support a non-blocking ``write()`` and a family of ``read_*()`` methods.
All of the methods take an optional ``callback`` argument and return a
`.Future` only if no callback is given. When the operation completes,
the callback will be run or the `.Future` will resolve with the data
read (or ``None`` for ``write()``). All outstanding ``Futures`` will
resolve with a `StreamClosedError` when the stream is closed; users
of the callback interface will be notified via
`.BaseIOStream.set_close_callback` instead.
When a stream is closed due to an error, the IOStream's ``error``
attribute contains the exception object.
Subclasses must implement `fileno`, `close_fd`, `write_to_fd`,
`read_from_fd`, and optionally `get_fd_error`.
"""
def __init__(self, io_loop=None, max_buffer_size=None,
read_chunk_size=None, max_write_buffer_size=None):
"""`BaseIOStream` constructor.
:arg io_loop: The `.IOLoop` to use; defaults to `.IOLoop.current`.
Deprecated since Tornado 4.1.
:arg max_buffer_size: Maximum amount of incoming data to buffer;
defaults to 100MB.
:arg read_chunk_size: Amount of data to read at one time from the
underlying transport; defaults to 64KB.
:arg max_write_buffer_size: Amount of outgoing data to buffer;
defaults to unlimited.
.. versionchanged:: 4.0
Add the ``max_write_buffer_size`` parameter. Changed default
``read_chunk_size`` to 64KB.
"""
self.io_loop = io_loop or ioloop.IOLoop.current()
self.max_buffer_size = max_buffer_size or 104857600
# A chunk size that is too close to max_buffer_size can cause
# spurious failures.
self.read_chunk_size = min(read_chunk_size or 65536,
self.max_buffer_size // 2)
self.max_write_buffer_size = max_write_buffer_size
self.error = None
self._read_buffer = collections.deque()
self._write_buffer = collections.deque()
self._read_buffer_size = 0
self._write_buffer_size = 0
self._write_buffer_frozen = False
self._read_delimiter = None
self._read_regex = None
self._read_max_bytes = None
self._read_bytes = None
self._read_partial = False
self._read_until_close = False
self._read_callback = None
self._read_future = None
self._streaming_callback = None
self._write_callback = None
self._write_future = None
self._close_callback = None
self._connect_callback = None
self._connect_future = None
# _ssl_connect_future should be defined in SSLIOStream
# but it's here so we can clean it up in maybe_run_close_callback.
# TODO: refactor that so subclasses can add additional futures
# to be cancelled.
self._ssl_connect_future = None
self._connecting = False
self._state = None
self._pending_callbacks = 0
self._closed = False
def fileno(self):
"""Returns the file descriptor for this stream."""
raise NotImplementedError()
def close_fd(self):
"""Closes the file underlying this stream.
``close_fd`` is called by `BaseIOStream` and should not be called
elsewhere; other users should call `close` instead.
"""
raise NotImplementedError()
def write_to_fd(self, data):
"""Attempts to write ``data`` to the underlying file.
Returns the number of bytes written.
"""
raise NotImplementedError()
def read_from_fd(self):
"""Attempts to read from the underlying file.
Returns ``None`` if there was nothing to read (the socket
returned `~errno.EWOULDBLOCK` or equivalent), otherwise
returns the data. When possible, should return no more than
``self.read_chunk_size`` bytes at a time.
"""
raise NotImplementedError()
def get_fd_error(self):
"""Returns information about any error on the underlying file.
This method is called after the `.IOLoop` has signaled an error on the
file descriptor, and should return an Exception (such as `socket.error`
with additional information, or None if no such information is
available.
"""
return None
def read_until_regex(self, regex, callback=None, max_bytes=None):
"""Asynchronously read until we have matched the given regex.
The result includes the data that matches the regex and anything
that came before it. If a callback is given, it will be run
with the data as an argument; if not, this method returns a
`.Future`.
If ``max_bytes`` is not None, the connection will be closed
if more than ``max_bytes`` bytes have been read and the regex is
not satisfied.
.. versionchanged:: 4.0
Added the ``max_bytes`` argument. The ``callback`` argument is
now optional and a `.Future` will be returned if it is omitted.
"""
future = self._set_read_callback(callback)
self._read_regex = re.compile(regex)
self._read_max_bytes = max_bytes
try:
self._try_inline_read()
except UnsatisfiableReadError as e:
# Handle this the same way as in _handle_events.
gen_log.info("Unsatisfiable read, closing connection: %s" % e)
self.close(exc_info=True)
return future
except:
if future is not None:
# Ensure that the future doesn't log an error because its
# failure was never examined.
future.add_done_callback(lambda f: f.exception())
raise
return future
def read_until(self, delimiter, callback=None, max_bytes=None):
"""Asynchronously read until we have found the given delimiter.
The result includes all the data read including the delimiter.
If a callback is given, it will be run with the data as an argument;
if not, this method returns a `.Future`.
If ``max_bytes`` is not None, the connection will be closed
if more than ``max_bytes`` bytes have been read and the delimiter
is not found.
.. versionchanged:: 4.0
Added the ``max_bytes`` argument. The ``callback`` argument is
now optional and a `.Future` will be returned if it is omitted.
"""
future = self._set_read_callback(callback)
self._read_delimiter = delimiter
self._read_max_bytes = max_bytes
try:
self._try_inline_read()
except UnsatisfiableReadError as e:
# Handle this the same way as in _handle_events.
gen_log.info("Unsatisfiable read, closing connection: %s" % e)
self.close(exc_info=True)
return future
except:
if future is not None:
future.add_done_callback(lambda f: f.exception())
raise
return future
def read_bytes(self, num_bytes, callback=None, streaming_callback=None,
partial=False):
"""Asynchronously read a number of bytes.
If a ``streaming_callback`` is given, it will be called with chunks
of data as they become available, and the final result will be empty.
Otherwise, the result is all the data that was read.
If a callback is given, it will be run with the data as an argument;
if not, this method returns a `.Future`.
If ``partial`` is true, the callback is run as soon as we have
any bytes to return (but never more than ``num_bytes``)
.. versionchanged:: 4.0
Added the ``partial`` argument. The callback argument is now
optional and a `.Future` will be returned if it is omitted.
"""
future = self._set_read_callback(callback)
assert isinstance(num_bytes, numbers.Integral)
self._read_bytes = num_bytes
self._read_partial = partial
self._streaming_callback = stack_context.wrap(streaming_callback)
try:
self._try_inline_read()
except:
if future is not None:
future.add_done_callback(lambda f: f.exception())
raise
return future
def read_until_close(self, callback=None, streaming_callback=None):
"""Asynchronously reads all data from the socket until it is closed.
If a ``streaming_callback`` is given, it will be called with chunks
of data as they become available, and the final result will be empty.
Otherwise, the result is all the data that was read.
If a callback is given, it will be run with the data as an argument;
if not, this method returns a `.Future`.
Note that if a ``streaming_callback`` is used, data will be
read from the socket as quickly as it becomes available; there
is no way to apply backpressure or cancel the reads. If flow
control or cancellation are desired, use a loop with
`read_bytes(partial=True) <.read_bytes>` instead.
.. versionchanged:: 4.0
The callback argument is now optional and a `.Future` will
be returned if it is omitted.
"""
future = self._set_read_callback(callback)
self._streaming_callback = stack_context.wrap(streaming_callback)
if self.closed():
if self._streaming_callback is not None:
self._run_read_callback(self._read_buffer_size, True)
self._run_read_callback(self._read_buffer_size, False)
return future
self._read_until_close = True
try:
self._try_inline_read()
except:
future.add_done_callback(lambda f: f.exception())
raise
return future
def write(self, data, callback=None):
"""Asynchronously write the given data to this stream.
If ``callback`` is given, we call it when all of the buffered write
data has been successfully written to the stream. If there was
previously buffered write data and an old write callback, that
callback is simply overwritten with this new callback.
If no ``callback`` is given, this method returns a `.Future` that
resolves (with a result of ``None``) when the write has been
completed. If `write` is called again before that `.Future` has
resolved, the previous future will be orphaned and will never resolve.
.. versionchanged:: 4.0
Now returns a `.Future` if no callback is given.
"""
assert isinstance(data, bytes)
self._check_closed()
# We use bool(_write_buffer) as a proxy for write_buffer_size>0,
# so never put empty strings in the buffer.
if data:
if (self.max_write_buffer_size is not None and
self._write_buffer_size + len(data) > self.max_write_buffer_size):
raise StreamBufferFullError("Reached maximum write buffer size")
# Break up large contiguous strings before inserting them in the
# write buffer, so we don't have to recopy the entire thing
# as we slice off pieces to send to the socket.
WRITE_BUFFER_CHUNK_SIZE = 128 * 1024
for i in range(0, len(data), WRITE_BUFFER_CHUNK_SIZE):
self._write_buffer.append(data[i:i + WRITE_BUFFER_CHUNK_SIZE])
self._write_buffer_size += len(data)
if callback is not None:
self._write_callback = stack_context.wrap(callback)
future = None
else:
future = self._write_future = TracebackFuture()
future.add_done_callback(lambda f: f.exception())
if not self._connecting:
self._handle_write()
if self._write_buffer:
self._add_io_state(self.io_loop.WRITE)
self._maybe_add_error_listener()
return future
def set_close_callback(self, callback):
"""Call the given callback when the stream is closed.
This is not necessary for applications that use the `.Future`
interface; all outstanding ``Futures`` will resolve with a
`StreamClosedError` when the stream is closed.
"""
self._close_callback = stack_context.wrap(callback)
self._maybe_add_error_listener()
def close(self, exc_info=False):
"""Close this stream.
If ``exc_info`` is true, set the ``error`` attribute to the current
exception from `sys.exc_info` (or if ``exc_info`` is a tuple,
use that instead of `sys.exc_info`).
"""
if not self.closed():
if exc_info:
if not isinstance(exc_info, tuple):
exc_info = sys.exc_info()
if any(exc_info):
self.error = exc_info[1]
if self._read_until_close:
if (self._streaming_callback is not None and
self._read_buffer_size):
self._run_read_callback(self._read_buffer_size, True)
self._read_until_close = False
self._run_read_callback(self._read_buffer_size, False)
if self._state is not None:
self.io_loop.remove_handler(self.fileno())
self._state = None
self.close_fd()
self._closed = True
self._maybe_run_close_callback()
def _maybe_run_close_callback(self):
# If there are pending callbacks, don't run the close callback
# until they're done (see _maybe_add_error_handler)
if self.closed() and self._pending_callbacks == 0:
futures = []
if self._read_future is not None:
futures.append(self._read_future)
self._read_future = None
if self._write_future is not None:
futures.append(self._write_future)
self._write_future = None
if self._connect_future is not None:
futures.append(self._connect_future)
self._connect_future = None
if self._ssl_connect_future is not None:
futures.append(self._ssl_connect_future)
self._ssl_connect_future = None
for future in futures:
if self._is_connreset(self.error):
# Treat connection resets as closed connections so
# clients only have to catch one kind of exception
# to avoid logging.
future.set_exception(StreamClosedError())
else:
future.set_exception(self.error or StreamClosedError())
if self._close_callback is not None:
cb = self._close_callback
self._close_callback = None
self._run_callback(cb)
# Delete any unfinished callbacks to break up reference cycles.
self._read_callback = self._write_callback = None
# Clear the buffers so they can be cleared immediately even
# if the IOStream object is kept alive by a reference cycle.
# TODO: Clear the read buffer too; it currently breaks some tests.
self._write_buffer = None
def reading(self):
"""Returns true if we are currently reading from the stream."""
return self._read_callback is not None or self._read_future is not None
def writing(self):
"""Returns true if we are currently writing to the stream."""
return bool(self._write_buffer)
def closed(self):
"""Returns true if the stream has been closed."""
return self._closed
def set_nodelay(self, value):
"""Sets the no-delay flag for this stream.
By default, data written to TCP streams may be held for a time
to make the most efficient use of bandwidth (according to
Nagle's algorithm). The no-delay flag requests that data be
written as soon as possible, even if doing so would consume
additional bandwidth.
This flag is currently defined only for TCP-based ``IOStreams``.
.. versionadded:: 3.1
"""
pass
def _handle_events(self, fd, events):
if self.closed():
gen_log.warning("Got events for closed stream %s", fd)
return
try:
if self._connecting:
# Most IOLoops will report a write failed connect
# with the WRITE event, but SelectIOLoop reports a
# READ as well so we must check for connecting before
# either.
self._handle_connect()
if self.closed():
return
if events & self.io_loop.READ:
self._handle_read()
if self.closed():
return
if events & self.io_loop.WRITE:
self._handle_write()
if self.closed():
return
if events & self.io_loop.ERROR:
self.error = self.get_fd_error()
# We may have queued up a user callback in _handle_read or
# _handle_write, so don't close the IOStream until those
# callbacks have had a chance to run.
self.io_loop.add_callback(self.close)
return
state = self.io_loop.ERROR
if self.reading():
state |= self.io_loop.READ
if self.writing():
state |= self.io_loop.WRITE
if state == self.io_loop.ERROR and self._read_buffer_size == 0:
# If the connection is idle, listen for reads too so
# we can tell if the connection is closed. If there is
# data in the read buffer we won't run the close callback
# yet anyway, so we don't need to listen in this case.
state |= self.io_loop.READ
if state != self._state:
assert self._state is not None, \
"shouldn't happen: _handle_events without self._state"
self._state = state
self.io_loop.update_handler(self.fileno(), self._state)
except UnsatisfiableReadError as e:
gen_log.info("Unsatisfiable read, closing connection: %s" % e)
self.close(exc_info=True)
except Exception:
gen_log.error("Uncaught exception, closing connection.",
exc_info=True)
self.close(exc_info=True)
raise
def _run_callback(self, callback, *args):
def wrapper():
self._pending_callbacks -= 1
try:
return callback(*args)
except Exception:
app_log.error("Uncaught exception, closing connection.",
exc_info=True)
# Close the socket on an uncaught exception from a user callback
# (It would eventually get closed when the socket object is
# gc'd, but we don't want to rely on gc happening before we
# run out of file descriptors)
self.close(exc_info=True)
# Re-raise the exception so that IOLoop.handle_callback_exception
# can see it and log the error
raise
finally:
self._maybe_add_error_listener()
# We schedule callbacks to be run on the next IOLoop iteration
# rather than running them directly for several reasons:
# * Prevents unbounded stack growth when a callback calls an
# IOLoop operation that immediately runs another callback
# * Provides a predictable execution context for e.g.
# non-reentrant mutexes
# * Ensures that the try/except in wrapper() is run outside
# of the application's StackContexts
with stack_context.NullContext():
# stack_context was already captured in callback, we don't need to
# capture it again for IOStream's wrapper. This is especially
# important if the callback was pre-wrapped before entry to
# IOStream (as in HTTPConnection._header_callback), as we could
# capture and leak the wrong context here.
self._pending_callbacks += 1
self.io_loop.add_callback(wrapper)
def _read_to_buffer_loop(self):
# This method is called from _handle_read and _try_inline_read.
try:
if self._read_bytes is not None:
target_bytes = self._read_bytes
elif self._read_max_bytes is not None:
target_bytes = self._read_max_bytes
elif self.reading():
# For read_until without max_bytes, or
# read_until_close, read as much as we can before
# scanning for the delimiter.
target_bytes = None
else:
target_bytes = 0
next_find_pos = 0
# Pretend to have a pending callback so that an EOF in
# _read_to_buffer doesn't trigger an immediate close
# callback. At the end of this method we'll either
# establish a real pending callback via
# _read_from_buffer or run the close callback.
#
# We need two try statements here so that
# pending_callbacks is decremented before the `except`
# clause below (which calls `close` and does need to
# trigger the callback)
self._pending_callbacks += 1
while not self.closed():
# Read from the socket until we get EWOULDBLOCK or equivalent.
# SSL sockets do some internal buffering, and if the data is
# sitting in the SSL object's buffer select() and friends
# can't see it; the only way to find out if it's there is to
# try to read it.
if self._read_to_buffer() == 0:
break
self._run_streaming_callback()
# If we've read all the bytes we can use, break out of
# this loop. We can't just call read_from_buffer here
# because of subtle interactions with the
# pending_callback and error_listener mechanisms.
#
# If we've reached target_bytes, we know we're done.
if (target_bytes is not None and
self._read_buffer_size >= target_bytes):
break
# Otherwise, we need to call the more expensive find_read_pos.
# It's inefficient to do this on every read, so instead
# do it on the first read and whenever the read buffer
# size has doubled.
if self._read_buffer_size >= next_find_pos:
pos = self._find_read_pos()
if pos is not None:
return pos
next_find_pos = self._read_buffer_size * 2
return self._find_read_pos()
finally:
self._pending_callbacks -= 1
def _handle_read(self):
try:
pos = self._read_to_buffer_loop()
except UnsatisfiableReadError:
raise
except Exception:
gen_log.warning("error on read", exc_info=True)
self.close(exc_info=True)
return
if pos is not None:
self._read_from_buffer(pos)
return
else:
self._maybe_run_close_callback()
def _set_read_callback(self, callback):
assert self._read_callback is None, "Already reading"
assert self._read_future is None, "Already reading"
if callback is not None:
self._read_callback = stack_context.wrap(callback)
else:
self._read_future = TracebackFuture()
return self._read_future
def _run_read_callback(self, size, streaming):
if streaming:
callback = self._streaming_callback
else:
callback = self._read_callback
self._read_callback = self._streaming_callback = None
if self._read_future is not None:
assert callback is None
future = self._read_future
self._read_future = None
future.set_result(self._consume(size))
if callback is not None:
assert (self._read_future is None) or streaming
self._run_callback(callback, self._consume(size))
else:
# If we scheduled a callback, we will add the error listener
# afterwards. If we didn't, we have to do it now.
self._maybe_add_error_listener()
def _try_inline_read(self):
"""Attempt to complete the current read operation from buffered data.
If the read can be completed without blocking, schedules the
read callback on the next IOLoop iteration; otherwise starts
listening for reads on the socket.
"""
# See if we've already got the data from a previous read
self._run_streaming_callback()
pos = self._find_read_pos()
if pos is not None:
self._read_from_buffer(pos)
return
self._check_closed()
try:
pos = self._read_to_buffer_loop()
except Exception:
# If there was an in _read_to_buffer, we called close() already,
# but couldn't run the close callback because of _pending_callbacks.
# Before we escape from this function, run the close callback if
# applicable.
self._maybe_run_close_callback()
raise
if pos is not None:
self._read_from_buffer(pos)
return
# We couldn't satisfy the read inline, so either close the stream
# or listen for new data.
if self.closed():
self._maybe_run_close_callback()
else:
self._add_io_state(ioloop.IOLoop.READ)
def _read_to_buffer(self):
"""Reads from the socket and appends the result to the read buffer.
Returns the number of bytes read. Returns 0 if there is nothing
to read (i.e. the read returns EWOULDBLOCK or equivalent). On
error closes the socket and raises an exception.
"""
try:
chunk = self.read_from_fd()
except (socket.error, IOError, OSError) as e:
# ssl.SSLError is a subclass of socket.error
if self._is_connreset(e):
# Treat ECONNRESET as a connection close rather than
# an error to minimize log spam (the exception will
# be available on self.error for apps that care).
self.close(exc_info=True)
return
self.close(exc_info=True)
raise
if chunk is None:
return 0
self._read_buffer.append(chunk)
self._read_buffer_size += len(chunk)
if self._read_buffer_size > self.max_buffer_size:
gen_log.error("Reached maximum read buffer size")
self.close()
raise StreamBufferFullError("Reached maximum read buffer size")
return len(chunk)
def _run_streaming_callback(self):
if self._streaming_callback is not None and self._read_buffer_size:
bytes_to_consume = self._read_buffer_size
if self._read_bytes is not None:
bytes_to_consume = min(self._read_bytes, bytes_to_consume)
self._read_bytes -= bytes_to_consume
self._run_read_callback(bytes_to_consume, True)
def _read_from_buffer(self, pos):
"""Attempts to complete the currently-pending read from the buffer.
The argument is either a position in the read buffer or None,
as returned by _find_read_pos.
"""
self._read_bytes = self._read_delimiter = self._read_regex = None
self._read_partial = False
self._run_read_callback(pos, False)
def _find_read_pos(self):
"""Attempts to find a position in the read buffer that satisfies
the currently-pending read.
Returns a position in the buffer if the current read can be satisfied,
or None if it cannot.
"""
if (self._read_bytes is not None and
(self._read_buffer_size >= self._read_bytes or
(self._read_partial and self._read_buffer_size > 0))):
num_bytes = min(self._read_bytes, self._read_buffer_size)
return num_bytes
elif self._read_delimiter is not None:
# Multi-byte delimiters (e.g. '\r\n') may straddle two
# chunks in the read buffer, so we can't easily find them
# without collapsing the buffer. However, since protocols
# using delimited reads (as opposed to reads of a known
# length) tend to be "line" oriented, the delimiter is likely
# to be in the first few chunks. Merge the buffer gradually
# since large merges are relatively expensive and get undone in
# _consume().
if self._read_buffer:
while True:
loc = self._read_buffer[0].find(self._read_delimiter)
if loc != -1:
delimiter_len = len(self._read_delimiter)
self._check_max_bytes(self._read_delimiter,
loc + delimiter_len)
return loc + delimiter_len
if len(self._read_buffer) == 1:
break
_double_prefix(self._read_buffer)
self._check_max_bytes(self._read_delimiter,
len(self._read_buffer[0]))
elif self._read_regex is not None:
if self._read_buffer:
while True:
m = self._read_regex.search(self._read_buffer[0])
if m is not None:
self._check_max_bytes(self._read_regex, m.end())
return m.end()
if len(self._read_buffer) == 1:
break
_double_prefix(self._read_buffer)
self._check_max_bytes(self._read_regex,
len(self._read_buffer[0]))
return None
def _check_max_bytes(self, delimiter, size):
if (self._read_max_bytes is not None and
size > self._read_max_bytes):
raise UnsatisfiableReadError(
"delimiter %r not found within %d bytes" % (
delimiter, self._read_max_bytes))
def _handle_write(self):
while self._write_buffer:
try:
if not self._write_buffer_frozen:
# On windows, socket.send blows up if given a
# write buffer that's too large, instead of just
# returning the number of bytes it was able to
# process. Therefore we must not call socket.send
# with more than 128KB at a time.
_merge_prefix(self._write_buffer, 128 * 1024)
num_bytes = self.write_to_fd(self._write_buffer[0])
if num_bytes == 0:
# With OpenSSL, if we couldn't write the entire buffer,
# the very same string object must be used on the
# next call to send. Therefore we suppress
# merging the write buffer after an incomplete send.
# A cleaner solution would be to set
# SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER, but this is
# not yet accessible from python
# (http://bugs.python.org/issue8240)
self._write_buffer_frozen = True
break
self._write_buffer_frozen = False
_merge_prefix(self._write_buffer, num_bytes)
self._write_buffer.popleft()
self._write_buffer_size -= num_bytes
except (socket.error, IOError, OSError) as e:
if e.args[0] in _ERRNO_WOULDBLOCK:
self._write_buffer_frozen = True
break
else:
if not self._is_connreset(e):
# Broken pipe errors are usually caused by connection
# reset, and its better to not log EPIPE errors to
# minimize log spam
gen_log.warning("Write error on %s: %s",
self.fileno(), e)
self.close(exc_info=True)
return
if not self._write_buffer:
if self._write_callback:
callback = self._write_callback
self._write_callback = None
self._run_callback(callback)
if self._write_future:
future = self._write_future
self._write_future = None
future.set_result(None)
def _consume(self, loc):
if loc == 0:
return b""
_merge_prefix(self._read_buffer, loc)
self._read_buffer_size -= loc
return self._read_buffer.popleft()
def _check_closed(self):
if self.closed():
raise StreamClosedError("Stream is closed")
def _maybe_add_error_listener(self):
# This method is part of an optimization: to detect a connection that
# is closed when we're not actively reading or writing, we must listen
# for read events. However, it is inefficient to do this when the
# connection is first established because we are going to read or write
# immediately anyway. Instead, we insert checks at various times to
# see if the connection is idle and add the read listener then.
if self._pending_callbacks != 0:
return
if self._state is None or self._state == ioloop.IOLoop.ERROR:
if self.closed():
self._maybe_run_close_callback()
elif (self._read_buffer_size == 0 and
self._close_callback is not None):
self._add_io_state(ioloop.IOLoop.READ)
def _add_io_state(self, state):
"""Adds `state` (IOLoop.{READ,WRITE} flags) to our event handler.
Implementation notes: Reads and writes have a fast path and a
slow path. The fast path reads synchronously from socket
buffers, while the slow path uses `_add_io_state` to schedule
an IOLoop callback. Note that in both cases, the callback is
run asynchronously with `_run_callback`.
To detect closed connections, we must have called
`_add_io_state` at some point, but we want to delay this as
much as possible so we don't have to set an `IOLoop.ERROR`
listener that will be overwritten by the next slow-path
operation. As long as there are callbacks scheduled for
fast-path ops, those callbacks may do more reads.
If a sequence of fast-path ops do not end in a slow-path op,
(e.g. for an @asynchronous long-poll request), we must add
the error handler. This is done in `_run_callback` and `write`
(since the write callback is optional so we can have a
fast-path write with no `_run_callback`)
"""
if self.closed():
# connection has been closed, so there can be no future events
return
if self._state is None:
self._state = ioloop.IOLoop.ERROR | state
with stack_context.NullContext():
self.io_loop.add_handler(
self.fileno(), self._handle_events, self._state)
elif not self._state & state:
self._state = self._state | state
self.io_loop.update_handler(self.fileno(), self._state)
def _is_connreset(self, exc):
"""Return true if exc is ECONNRESET or equivalent.
May be overridden in subclasses.
"""
return (isinstance(exc, (socket.error, IOError)) and
errno_from_exception(exc) in _ERRNO_CONNRESET)
class IOStream(BaseIOStream):
r"""Socket-based `IOStream` implementation.
This class supports the read and write methods from `BaseIOStream`
plus a `connect` method.
The ``socket`` parameter may either be connected or unconnected.
For server operations the socket is the result of calling
`socket.accept <socket.socket.accept>`. For client operations the
socket is created with `socket.socket`, and may either be
connected before passing it to the `IOStream` or connected with
`IOStream.connect`.
A very simple (and broken) HTTP client using this class:
.. testcode::
import tornado.ioloop
import tornado.iostream
import socket
def send_request():
stream.write(b"GET / HTTP/1.0\r\nHost: friendfeed.com\r\n\r\n")
stream.read_until(b"\r\n\r\n", on_headers)
def on_headers(data):
headers = {}
for line in data.split(b"\r\n"):
parts = line.split(b":")
if len(parts) == 2:
headers[parts[0].strip()] = parts[1].strip()
stream.read_bytes(int(headers[b"Content-Length"]), on_body)
def on_body(data):
print(data)
stream.close()
tornado.ioloop.IOLoop.current().stop()
if __name__ == '__main__':
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
stream = tornado.iostream.IOStream(s)
stream.connect(("friendfeed.com", 80), send_request)
tornado.ioloop.IOLoop.current().start()
.. testoutput::
:hide:
"""
def __init__(self, socket, *args, **kwargs):
self.socket = socket
self.socket.setblocking(False)
super(IOStream, self).__init__(*args, **kwargs)
def fileno(self):
return self.socket
def close_fd(self):
self.socket.close()
self.socket = None
def get_fd_error(self):
errno = self.socket.getsockopt(socket.SOL_SOCKET,
socket.SO_ERROR)
return socket.error(errno, os.strerror(errno))
def read_from_fd(self):
try:
chunk = self.socket.recv(self.read_chunk_size)
except socket.error as e:
if e.args[0] in _ERRNO_WOULDBLOCK:
return None
else:
raise
if not chunk:
self.close()
return None
return chunk
def write_to_fd(self, data):
return self.socket.send(data)
def connect(self, address, callback=None, server_hostname=None):
"""Connects the socket to a remote address without blocking.
May only be called if the socket passed to the constructor was
not previously connected. The address parameter is in the
same format as for `socket.connect <socket.socket.connect>` for
the type of socket passed to the IOStream constructor,
e.g. an ``(ip, port)`` tuple. Hostnames are accepted here,
but will be resolved synchronously and block the IOLoop.
If you have a hostname instead of an IP address, the `.TCPClient`
class is recommended instead of calling this method directly.
`.TCPClient` will do asynchronous DNS resolution and handle
both IPv4 and IPv6.
If ``callback`` is specified, it will be called with no
arguments when the connection is completed; if not this method
returns a `.Future` (whose result after a successful
connection will be the stream itself).
In SSL mode, the ``server_hostname`` parameter will be used
for certificate validation (unless disabled in the
``ssl_options``) and SNI (if supported; requires Python
2.7.9+).
Note that it is safe to call `IOStream.write
<BaseIOStream.write>` while the connection is pending, in
which case the data will be written as soon as the connection
is ready. Calling `IOStream` read methods before the socket is
connected works on some platforms but is non-portable.
.. versionchanged:: 4.0
If no callback is given, returns a `.Future`.
.. versionchanged:: 4.2
SSL certificates are validated by default; pass
``ssl_options=dict(cert_reqs=ssl.CERT_NONE)`` or a
suitably-configured `ssl.SSLContext` to the
`SSLIOStream` constructor to disable.
"""
self._connecting = True
if callback is not None:
self._connect_callback = stack_context.wrap(callback)
future = None
else:
future = self._connect_future = TracebackFuture()
try:
self.socket.connect(address)
except socket.error as e:
# In non-blocking mode we expect connect() to raise an
# exception with EINPROGRESS or EWOULDBLOCK.
#
# On freebsd, other errors such as ECONNREFUSED may be
# returned immediately when attempting to connect to
# localhost, so handle them the same way as an error
# reported later in _handle_connect.
if (errno_from_exception(e) not in _ERRNO_INPROGRESS and
errno_from_exception(e) not in _ERRNO_WOULDBLOCK):
if future is None:
gen_log.warning("Connect error on fd %s: %s",
self.socket.fileno(), e)
self.close(exc_info=True)
return future
self._add_io_state(self.io_loop.WRITE)
return future
def start_tls(self, server_side, ssl_options=None, server_hostname=None):
"""Convert this `IOStream` to an `SSLIOStream`.
This enables protocols that begin in clear-text mode and
switch to SSL after some initial negotiation (such as the
``STARTTLS`` extension to SMTP and IMAP).
This method cannot be used if there are outstanding reads
or writes on the stream, or if there is any data in the
IOStream's buffer (data in the operating system's socket
buffer is allowed). This means it must generally be used
immediately after reading or writing the last clear-text
data. It can also be used immediately after connecting,
before any reads or writes.
The ``ssl_options`` argument may be either an `ssl.SSLContext`
object or a dictionary of keyword arguments for the
`ssl.wrap_socket` function. The ``server_hostname`` argument
will be used for certificate validation unless disabled
in the ``ssl_options``.
This method returns a `.Future` whose result is the new
`SSLIOStream`. After this method has been called,
any other operation on the original stream is undefined.
If a close callback is defined on this stream, it will be
transferred to the new stream.
.. versionadded:: 4.0
.. versionchanged:: 4.2
SSL certificates are validated by default; pass
``ssl_options=dict(cert_reqs=ssl.CERT_NONE)`` or a
suitably-configured `ssl.SSLContext` to disable.
"""
if (self._read_callback or self._read_future or
self._write_callback or self._write_future or
self._connect_callback or self._connect_future or
self._pending_callbacks or self._closed or
self._read_buffer or self._write_buffer):
raise ValueError("IOStream is not idle; cannot convert to SSL")
if ssl_options is None:
if server_side:
ssl_options = _server_ssl_defaults
else:
ssl_options = _client_ssl_defaults
socket = self.socket
self.io_loop.remove_handler(socket)
self.socket = None
socket = ssl_wrap_socket(socket, ssl_options,
server_hostname=server_hostname,
server_side=server_side,
do_handshake_on_connect=False)
orig_close_callback = self._close_callback
self._close_callback = None
future = TracebackFuture()
ssl_stream = SSLIOStream(socket, ssl_options=ssl_options,
io_loop=self.io_loop)
# Wrap the original close callback so we can fail our Future as well.
# If we had an "unwrap" counterpart to this method we would need
# to restore the original callback after our Future resolves
# so that repeated wrap/unwrap calls don't build up layers.
def close_callback():
if not future.done():
future.set_exception(ssl_stream.error or StreamClosedError())
if orig_close_callback is not None:
orig_close_callback()
ssl_stream.set_close_callback(close_callback)
ssl_stream._ssl_connect_callback = lambda: future.set_result(ssl_stream)
ssl_stream.max_buffer_size = self.max_buffer_size
ssl_stream.read_chunk_size = self.read_chunk_size
return future
def _handle_connect(self):
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
if err != 0:
self.error = socket.error(err, os.strerror(err))
# IOLoop implementations may vary: some of them return
# an error state before the socket becomes writable, so
# in that case a connection failure would be handled by the
# error path in _handle_events instead of here.
if self._connect_future is None:
gen_log.warning("Connect error on fd %s: %s",
self.socket.fileno(), errno.errorcode[err])
self.close()
return
if self._connect_callback is not None:
callback = self._connect_callback
self._connect_callback = None
self._run_callback(callback)
if self._connect_future is not None:
future = self._connect_future
self._connect_future = None
future.set_result(self)
self._connecting = False
def set_nodelay(self, value):
if (self.socket is not None and
self.socket.family in (socket.AF_INET, socket.AF_INET6)):
try:
self.socket.setsockopt(socket.IPPROTO_TCP,
socket.TCP_NODELAY, 1 if value else 0)
except socket.error as e:
# Sometimes setsockopt will fail if the socket is closed
# at the wrong time. This can happen with HTTPServer
# resetting the value to false between requests.
if e.errno != errno.EINVAL and not self._is_connreset(e):
raise
class SSLIOStream(IOStream):
"""A utility class to write to and read from a non-blocking SSL socket.
If the socket passed to the constructor is already connected,
it should be wrapped with::
ssl.wrap_socket(sock, do_handshake_on_connect=False, **kwargs)
before constructing the `SSLIOStream`. Unconnected sockets will be
wrapped when `IOStream.connect` is finished.
"""
def __init__(self, *args, **kwargs):
"""The ``ssl_options`` keyword argument may either be an
`ssl.SSLContext` object or a dictionary of keywords arguments
for `ssl.wrap_socket`
"""
self._ssl_options = kwargs.pop('ssl_options', _client_ssl_defaults)
super(SSLIOStream, self).__init__(*args, **kwargs)
self._ssl_accepting = True
self._handshake_reading = False
self._handshake_writing = False
self._ssl_connect_callback = None
self._server_hostname = None
# If the socket is already connected, attempt to start the handshake.
try:
self.socket.getpeername()
except socket.error:
pass
else:
# Indirectly start the handshake, which will run on the next
# IOLoop iteration and then the real IO state will be set in
# _handle_events.
self._add_io_state(self.io_loop.WRITE)
def reading(self):
return self._handshake_reading or super(SSLIOStream, self).reading()
def writing(self):
return self._handshake_writing or super(SSLIOStream, self).writing()
def _do_ssl_handshake(self):
# Based on code from test_ssl.py in the python stdlib
try:
self._handshake_reading = False
self._handshake_writing = False
self.socket.do_handshake()
except ssl.SSLError as err:
if err.args[0] == ssl.SSL_ERROR_WANT_READ:
self._handshake_reading = True
return
elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
self._handshake_writing = True
return
elif err.args[0] in (ssl.SSL_ERROR_EOF,
ssl.SSL_ERROR_ZERO_RETURN):
return self.close(exc_info=True)
elif err.args[0] == ssl.SSL_ERROR_SSL:
try:
peer = self.socket.getpeername()
except Exception:
peer = '(not connected)'
gen_log.warning("SSL Error on %s %s: %s",
self.socket.fileno(), peer, err)
return self.close(exc_info=True)
raise
except socket.error as err:
# Some port scans (e.g. nmap in -sT mode) have been known
# to cause do_handshake to raise EBADF, so make that error
# quiet as well.
# https://groups.google.com/forum/?fromgroups#!topic/python-tornado/ApucKJat1_0
if self._is_connreset(err) or err.args[0] == errno.EBADF:
return self.close(exc_info=True)
raise
except AttributeError:
# On Linux, if the connection was reset before the call to
# wrap_socket, do_handshake will fail with an
# AttributeError.
return self.close(exc_info=True)
else:
self._ssl_accepting = False
if not self._verify_cert(self.socket.getpeercert()):
self.close()
return
self._run_ssl_connect_callback()
def _run_ssl_connect_callback(self):
if self._ssl_connect_callback is not None:
callback = self._ssl_connect_callback
self._ssl_connect_callback = None
self._run_callback(callback)
if self._ssl_connect_future is not None:
future = self._ssl_connect_future
self._ssl_connect_future = None
future.set_result(self)
def _verify_cert(self, peercert):
"""Returns True if peercert is valid according to the configured
validation mode and hostname.
The ssl handshake already tested the certificate for a valid
CA signature; the only thing that remains is to check
the hostname.
"""
if isinstance(self._ssl_options, dict):
verify_mode = self._ssl_options.get('cert_reqs', ssl.CERT_NONE)
elif isinstance(self._ssl_options, ssl.SSLContext):
verify_mode = self._ssl_options.verify_mode
assert verify_mode in (ssl.CERT_NONE, ssl.CERT_REQUIRED, ssl.CERT_OPTIONAL)
if verify_mode == ssl.CERT_NONE or self._server_hostname is None:
return True
cert = self.socket.getpeercert()
if cert is None and verify_mode == ssl.CERT_REQUIRED:
gen_log.warning("No SSL certificate given")
return False
try:
ssl_match_hostname(peercert, self._server_hostname)
except SSLCertificateError:
gen_log.warning("Invalid SSL certificate", exc_info=True)
return False
else:
return True
def _handle_read(self):
if self._ssl_accepting:
self._do_ssl_handshake()
return
super(SSLIOStream, self)._handle_read()
def _handle_write(self):
if self._ssl_accepting:
self._do_ssl_handshake()
return
super(SSLIOStream, self)._handle_write()
def connect(self, address, callback=None, server_hostname=None):
self._server_hostname = server_hostname
# Pass a dummy callback to super.connect(), which is slightly
# more efficient than letting it return a Future we ignore.
super(SSLIOStream, self).connect(address, callback=lambda: None)
return self.wait_for_handshake(callback)
def _handle_connect(self):
# Call the superclass method to check for errors.
super(SSLIOStream, self)._handle_connect()
if self.closed():
return
# When the connection is complete, wrap the socket for SSL
# traffic. Note that we do this by overriding _handle_connect
# instead of by passing a callback to super().connect because
# user callbacks are enqueued asynchronously on the IOLoop,
# but since _handle_events calls _handle_connect immediately
# followed by _handle_write we need this to be synchronous.
#
# The IOLoop will get confused if we swap out self.socket while the
# fd is registered, so remove it now and re-register after
# wrap_socket().
self.io_loop.remove_handler(self.socket)
old_state = self._state
self._state = None
self.socket = ssl_wrap_socket(self.socket, self._ssl_options,
server_hostname=self._server_hostname,
do_handshake_on_connect=False)
self._add_io_state(old_state)
def wait_for_handshake(self, callback=None):
"""Wait for the initial SSL handshake to complete.
If a ``callback`` is given, it will be called with no
arguments once the handshake is complete; otherwise this
method returns a `.Future` which will resolve to the
stream itself after the handshake is complete.
Once the handshake is complete, information such as
the peer's certificate and NPN/ALPN selections may be
accessed on ``self.socket``.
This method is intended for use on server-side streams
or after using `IOStream.start_tls`; it should not be used
with `IOStream.connect` (which already waits for the
handshake to complete). It may only be called once per stream.
.. versionadded:: 4.2
"""
if (self._ssl_connect_callback is not None or
self._ssl_connect_future is not None):
raise RuntimeError("Already waiting")
if callback is not None:
self._ssl_connect_callback = stack_context.wrap(callback)
future = None
else:
future = self._ssl_connect_future = TracebackFuture()
if not self._ssl_accepting:
self._run_ssl_connect_callback()
return future
def write_to_fd(self, data):
try:
return self.socket.send(data)
except ssl.SSLError as e:
if e.args[0] == ssl.SSL_ERROR_WANT_WRITE:
# In Python 3.5+, SSLSocket.send raises a WANT_WRITE error if
# the socket is not writeable; we need to transform this into
# an EWOULDBLOCK socket.error or a zero return value,
# either of which will be recognized by the caller of this
# method. Prior to Python 3.5, an unwriteable socket would
# simply return 0 bytes written.
return 0
raise
def read_from_fd(self):
if self._ssl_accepting:
# If the handshake hasn't finished yet, there can't be anything
# to read (attempting to read may or may not raise an exception
# depending on the SSL version)
return None
try:
# SSLSocket objects have both a read() and recv() method,
# while regular sockets only have recv().
# The recv() method blocks (at least in python 2.6) if it is
# called when there is nothing to read, so we have to use
# read() instead.
chunk = self.socket.read(self.read_chunk_size)
except ssl.SSLError as e:
# SSLError is a subclass of socket.error, so this except
# block must come first.
if e.args[0] == ssl.SSL_ERROR_WANT_READ:
return None
else:
raise
except socket.error as e:
if e.args[0] in _ERRNO_WOULDBLOCK:
return None
else:
raise
if not chunk:
self.close()
return None
return chunk
def _is_connreset(self, e):
if isinstance(e, ssl.SSLError) and e.args[0] == ssl.SSL_ERROR_EOF:
return True
return super(SSLIOStream, self)._is_connreset(e)
class PipeIOStream(BaseIOStream):
"""Pipe-based `IOStream` implementation.
The constructor takes an integer file descriptor (such as one returned
by `os.pipe`) rather than an open file object. Pipes are generally
one-way, so a `PipeIOStream` can be used for reading or writing but not
both.
"""
def __init__(self, fd, *args, **kwargs):
self.fd = fd
_set_nonblocking(fd)
super(PipeIOStream, self).__init__(*args, **kwargs)
def fileno(self):
return self.fd
def close_fd(self):
os.close(self.fd)
def write_to_fd(self, data):
return os.write(self.fd, data)
def read_from_fd(self):
try:
chunk = os.read(self.fd, self.read_chunk_size)
except (IOError, OSError) as e:
if errno_from_exception(e) in _ERRNO_WOULDBLOCK:
return None
elif errno_from_exception(e) == errno.EBADF:
# If the writing half of a pipe is closed, select will
# report it as readable but reads will fail with EBADF.
self.close(exc_info=True)
return None
else:
raise
if not chunk:
self.close()
return None
return chunk
def _double_prefix(deque):
"""Grow by doubling, but don't split the second chunk just because the
first one is small.
"""
new_len = max(len(deque[0]) * 2,
(len(deque[0]) + len(deque[1])))
_merge_prefix(deque, new_len)
def _merge_prefix(deque, size):
"""Replace the first entries in a deque of strings with a single
string of up to size bytes.
>>> d = collections.deque(['abc', 'de', 'fghi', 'j'])
>>> _merge_prefix(d, 5); print(d)
deque(['abcde', 'fghi', 'j'])
Strings will be split as necessary to reach the desired size.
>>> _merge_prefix(d, 7); print(d)
deque(['abcdefg', 'hi', 'j'])
>>> _merge_prefix(d, 3); print(d)
deque(['abc', 'defg', 'hi', 'j'])
>>> _merge_prefix(d, 100); print(d)
deque(['abcdefghij'])
"""
if len(deque) == 1 and len(deque[0]) <= size:
return
prefix = []
remaining = size
while deque and remaining > 0:
chunk = deque.popleft()
if len(chunk) > remaining:
deque.appendleft(chunk[remaining:])
chunk = chunk[:remaining]
prefix.append(chunk)
remaining -= len(chunk)
# This data structure normally just contains byte strings, but
# the unittest gets messy if it doesn't use the default str() type,
# so do the merge based on the type of data that's actually present.
if prefix:
deque.appendleft(type(prefix[0])().join(prefix))
if not deque:
deque.appendleft(b"")
def doctests():
import doctest
return doctest.DocTestSuite()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
27107,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
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,
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,
624,
17505,
3992,
370,
2218,
370,
436,
1586,
687,
2222,
13,
13091,
1584,
436,
18772,
14,
199,
199,
11383,
26,
199,
199,
10,
658,
1563,
2090,
3296,
8340,
8307,
3217,
367,
7664,
436,
3575,
14,
199,
10,
658,
2090,
3296,
8340,
24425,
402,
3523,
2090,
3296,
1808,
2222,
13,
13091,
18772,
14,
199,
10,
658,
5413,
2090,
3296,
8340,
7799,
13,
14600,
1015,
402,
5004,
3296,
14,
199,
10,
658,
11867,
2090,
3296,
8340,
16850,
13,
6788,
5004,
3296,
4514,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
543,
63,
6242,
199,
199,
646,
5055,
199,
646,
7554,
199,
646,
5579,
199,
646,
747,
199,
646,
2838,
199,
646,
984,
199,
646,
295,
199,
199,
504,
12148,
14,
27237,
492,
15273,
14224,
199,
504,
12148,
492,
5890,
3813,
199,
504,
12148,
14,
793,
492,
3805,
63,
793,
12,
1145,
63,
793,
199,
504,
12148,
14,
846,
1974,
492,
6149,
63,
3823,
63,
3450,
12,
6149,
63,
1431,
63,
4269,
12,
7799,
11414,
547,
12,
485,
1258,
63,
4266,
63,
4322,
12,
485,
1000,
63,
4266,
63,
4322,
199,
504,
12148,
492,
3464,
63,
1100,
199,
504,
12148,
14,
1974,
492,
7554,
63,
504,
63,
1971,
199,
199,
893,
26,
272,
687,
12148,
14,
3246,
14,
9228,
492,
485,
409,
63,
2865,
13091,
199,
2590,
3545,
26,
272,
485,
409,
63,
2865,
13091,
275,
488,
199,
199,
893,
26,
272,
492,
6149,
199,
2590,
3545,
26,
272,
327,
6149,
365,
440,
2808,
641,
4475,
4693,
12580,
272,
6149,
275,
488,
199,
199,
3,
5723,
2329,
12712,
6623,
626,
282,
2222,
13,
13091,
3439,
1471,
506,
4444,
379,
199,
3,
737,
282,
2945,
900,
14,
221,
4068,
4750,
10677,
2985,
3984,
314,
2011,
574,
12,
1325,
641,
199,
3,
2005,
2985,
14460,
14,
199,
63,
2666,
2826,
63,
11325,
1293,
2846,
4406,
275,
334,
7931,
14,
37,
11325,
1293,
2846,
4406,
12,
7554,
14,
37,
1254,
9021,
9,
199,
199,
692,
2688,
8,
7931,
12,
298,
55,
4251,
37,
11325,
1293,
2846,
4406,
2349,
272,
485,
2666,
2826,
63,
11325,
1293,
2846,
4406,
847,
334,
7931,
14,
55,
4251,
37,
11325,
1293,
2846,
4406,
4258,
199,
199,
3,
5723,
2329,
12712,
6623,
626,
282,
1950,
965,
2757,
2236,
6987,
590,
15745,
14,
199,
3,
9322,
1077,
506,
15604,
436,
8860,
6656,
949,
29022,
590,
2419,
1163,
2552,
14,
199,
63,
2666,
2826,
63,
17489,
18066,
275,
334,
7931,
14,
37,
17489,
18066,
12,
7554,
14,
37,
17489,
27113,
1149,
12,
7554,
14,
37,
6089,
12,
490,
7554,
14,
775,
1469,
1149,
1877,
9,
199,
199,
692,
2688,
8,
7931,
12,
298,
55,
4251,
37,
17489,
18066,
2349,
272,
485,
2666,
2826,
63,
17489,
18066,
847,
334,
7931,
14,
55,
4251,
37,
17489,
18066,
12,
7554,
14,
55,
4251,
37,
17489,
27113,
1149,
12,
7554,
14,
55,
4251,
775,
1469,
1149,
1877,
9,
199,
199,
692,
984,
14,
3246,
508,
283,
13245,
356,
272,
327,
32144,
11337,
370,
1172,
282,
21209,
5558,
626,
14486,
3222,
8,
18,
9,
370,
372,
272,
327,
662,
2514,
14261,
4948,
340,
2797,
1830,
282,
2838,
365,
3769,
307,
6161,
3224,
26,
272,
327,
1455,
921,
281,
2000,
84,
14,
5031,
14,
2308,
15,
11486,
15,
7280,
15,
845,
15,
1167,
15,
350,
782,
1482,
13,
262,
13,
24913,
13,
65,
13,
24668,
13,
28197,
13,
4989,
13,
1266,
15,
272,
327,
9336,
314,
2838,
365,
3769,
6876,
15988,
12,
14312,
642,
465,
376,
662,
17489,
18066,
272,
327,
3140,
402,
376,
10537,
1125,
14,
272,
485,
2666,
2826,
63,
17489,
18066,
847,
334,
7931,
14,
37,
2514,
14261,
4948,
4258,
199,
199,
3,
16917,
2222,
13,
719,
461,
2329,
12712,
26,
199,
63,
2666,
2826,
63,
568,
24547,
275,
334,
7931,
14,
25652,
24547,
4258,
199,
199,
692,
2688,
8,
7931,
12,
298,
55,
4251,
25652,
24547,
2349,
272,
485,
2666,
2826,
63,
568,
24547,
847,
334,
7931,
14,
55,
4251,
25652,
24547,
4258,
421,
199,
533,
8271,
15190,
547,
8,
13760,
304,
272,
408,
1726,
4915,
701,
658,
2090,
3296,
64,
3102,
1380,
314,
2547,
365,
6876,
14,
339,
3390,
626,
314,
4002,
3233,
365,
18416,
370,
1255,
627,
4399,
10,
1163,
272,
13484,
641,
314,
2547,
334,
475,
2040,
367,
20224,
666,
370,
506,
7686,
395,
272,
880,
1265,
1443,
1937,
642,
1125,
2544,
1265,
1937,
314,
4002,
3233,
14,
272,
408,
272,
986,
421,
199,
533,
15254,
9369,
24183,
3284,
547,
8,
1726,
304,
272,
408,
1726,
4915,
1380,
282,
1586,
3913,
506,
23233,
14,
339,
24997,
701,
1124,
739,
63,
8111,
1040,
436,
1124,
739,
63,
8111,
63,
3821,
1040,
543,
282,
1124,
988,
63,
2394,
1040,
272,
1423,
14,
272,
408,
272,
986,
421,
199,
533,
8271,
3299,
9042,
547,
8,
1726,
304,
272,
408,
1726,
4915,
701,
658,
2090,
3296,
64,
3102,
1380,
314,
3335,
365,
2615,
14,
272,
408,
421,
199,
533,
3523,
2090,
3296,
8,
785,
304,
272,
408,
33,
11420,
1021,
370,
2218,
370,
436,
1586,
687,
282,
2222,
13,
13091,
570,
503,
2838,
14,
339,
2136,
2291,
282,
2222,
13,
13091,
1124,
952,
8497,
436,
282,
9614,
402,
1124,
739,
15192,
8497,
3102,
14,
272,
2900,
402,
314,
3102,
5452,
376,
2716,
1124,
3058,
1040,
1423,
436,
372,
282,
272,
19853,
14224
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
27107,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
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,
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,
624,
17505,
3992,
370,
2218,
370,
436,
1586,
687,
2222,
13,
13091,
1584,
436,
18772,
14,
199,
199,
11383,
26,
199,
199,
10,
658,
1563,
2090,
3296,
8340,
8307,
3217,
367,
7664,
436,
3575,
14,
199,
10,
658,
2090,
3296,
8340,
24425,
402,
3523,
2090,
3296,
1808,
2222,
13,
13091,
18772,
14,
199,
10,
658,
5413,
2090,
3296,
8340,
7799,
13,
14600,
1015,
402,
5004,
3296,
14,
199,
10,
658,
11867,
2090,
3296,
8340,
16850,
13,
6788,
5004,
3296,
4514,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
543,
63,
6242,
199,
199,
646,
5055,
199,
646,
7554,
199,
646,
5579,
199,
646,
747,
199,
646,
2838,
199,
646,
984,
199,
646,
295,
199,
199,
504,
12148,
14,
27237,
492,
15273,
14224,
199,
504,
12148,
492,
5890,
3813,
199,
504,
12148,
14,
793,
492,
3805,
63,
793,
12,
1145,
63,
793,
199,
504,
12148,
14,
846,
1974,
492,
6149,
63,
3823,
63,
3450,
12,
6149,
63,
1431,
63,
4269,
12,
7799,
11414,
547,
12,
485,
1258,
63,
4266,
63,
4322,
12,
485,
1000,
63,
4266,
63,
4322,
199,
504,
12148,
492,
3464,
63,
1100,
199,
504,
12148,
14,
1974,
492,
7554,
63,
504,
63,
1971,
199,
199,
893,
26,
272,
687,
12148,
14,
3246,
14,
9228,
492,
485,
409,
63,
2865,
13091,
199,
2590,
3545,
26,
272,
485,
409,
63,
2865,
13091,
275,
488,
199,
199,
893,
26,
272,
492,
6149,
199,
2590,
3545,
26,
272,
327,
6149,
365,
440,
2808,
641,
4475,
4693,
12580,
272,
6149,
275,
488,
199,
199,
3,
5723,
2329,
12712,
6623,
626,
282,
2222,
13,
13091,
3439,
1471,
506,
4444,
379,
199,
3,
737,
282,
2945,
900,
14,
221,
4068,
4750,
10677,
2985,
3984,
314,
2011,
574,
12,
1325,
641,
199,
3,
2005,
2985,
14460,
14,
199,
63,
2666,
2826,
63,
11325,
1293,
2846,
4406,
275,
334,
7931,
14,
37,
11325,
1293,
2846,
4406,
12,
7554,
14,
37,
1254,
9021,
9,
199,
199,
692,
2688,
8,
7931,
12,
298,
55,
4251,
37,
11325,
1293,
2846,
4406,
2349,
272,
485,
2666,
2826,
63,
11325,
1293,
2846,
4406,
847,
334,
7931,
14,
55,
4251,
37,
11325,
1293,
2846,
4406,
4258,
199,
199,
3,
5723,
2329,
12712,
6623,
626,
282,
1950,
965,
2757,
2236,
6987,
590,
15745,
14,
199,
3,
9322,
1077,
506,
15604,
436,
8860,
6656,
949,
29022,
590,
2419,
1163,
2552,
14,
199,
63,
2666,
2826,
63,
17489,
18066,
275,
334,
7931,
14,
37,
17489,
18066,
12,
7554,
14,
37,
17489,
27113,
1149,
12,
7554,
14,
37,
6089,
12,
490,
7554,
14,
775,
1469,
1149,
1877,
9,
199,
199,
692,
2688,
8,
7931,
12,
298,
55,
4251,
37,
17489,
18066,
2349,
272,
485,
2666,
2826,
63,
17489,
18066,
847,
334,
7931,
14,
55,
4251,
37,
17489,
18066,
12,
7554,
14,
55,
4251,
37,
17489,
27113,
1149,
12,
7554,
14,
55,
4251,
775,
1469,
1149,
1877,
9,
199,
199,
692,
984,
14,
3246,
508,
283,
13245,
356,
272,
327,
32144,
11337,
370,
1172,
282,
21209,
5558,
626,
14486,
3222,
8,
18,
9,
370,
372,
272,
327,
662,
2514,
14261,
4948,
340,
2797,
1830,
282,
2838,
365,
3769,
307,
6161,
3224,
26,
272,
327,
1455,
921,
281,
2000,
84,
14,
5031,
14,
2308,
15,
11486,
15,
7280,
15,
845,
15,
1167,
15,
350,
782,
1482,
13,
262,
13,
24913,
13,
65,
13,
24668,
13,
28197,
13,
4989,
13,
1266,
15,
272,
327,
9336,
314,
2838,
365,
3769,
6876,
15988,
12,
14312,
642,
465,
376,
662,
17489,
18066,
272,
327,
3140,
402,
376,
10537,
1125,
14,
272,
485,
2666,
2826,
63,
17489,
18066,
847,
334,
7931,
14,
37,
2514,
14261,
4948,
4258,
199,
199,
3,
16917,
2222,
13,
719,
461,
2329,
12712,
26,
199,
63,
2666,
2826,
63,
568,
24547,
275,
334,
7931,
14,
25652,
24547,
4258,
199,
199,
692,
2688,
8,
7931,
12,
298,
55,
4251,
25652,
24547,
2349,
272,
485,
2666,
2826,
63,
568,
24547,
847,
334,
7931,
14,
55,
4251,
25652,
24547,
4258,
421,
199,
533,
8271,
15190,
547,
8,
13760,
304,
272,
408,
1726,
4915,
701,
658,
2090,
3296,
64,
3102,
1380,
314,
2547,
365,
6876,
14,
339,
3390,
626,
314,
4002,
3233,
365,
18416,
370,
1255,
627,
4399,
10,
1163,
272,
13484,
641,
314,
2547,
334,
475,
2040,
367,
20224,
666,
370,
506,
7686,
395,
272,
880,
1265,
1443,
1937,
642,
1125,
2544,
1265,
1937,
314,
4002,
3233,
14,
272,
408,
272,
986,
421,
199,
533,
15254,
9369,
24183,
3284,
547,
8,
1726,
304,
272,
408,
1726,
4915,
1380,
282,
1586,
3913,
506,
23233,
14,
339,
24997,
701,
1124,
739,
63,
8111,
1040,
436,
1124,
739,
63,
8111,
63,
3821,
1040,
543,
282,
1124,
988,
63,
2394,
1040,
272,
1423,
14,
272,
408,
272,
986,
421,
199,
533,
8271,
3299,
9042,
547,
8,
1726,
304,
272,
408,
1726,
4915,
701,
658,
2090,
3296,
64,
3102,
1380,
314,
3335,
365,
2615,
14,
272,
408,
421,
199,
533,
3523,
2090,
3296,
8,
785,
304,
272,
408,
33,
11420,
1021,
370,
2218,
370,
436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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
] |
abagh0703/RetailTrail
|
flask/lib/python2.7/site-packages/whoosh/compat.py
|
22
|
5357
|
import array, sys
# Run time aliasing of Python2/3 differences
def htmlescape(s, quote=True):
# this is html.escape reimplemented with cgi.escape,
# so it works for python 2.x, 3.0 and 3.1
import cgi
s = cgi.escape(s, quote)
if quote:
# python 3.2 also replaces the single quotes:
s = s.replace("'", "'")
return s
if sys.version_info[0] < 3:
PY3 = False
def b(s):
return s
import cStringIO as StringIO
StringIO = BytesIO = StringIO.StringIO
callable = callable
integer_types = (int, long)
iteritems = lambda o: o.iteritems()
itervalues = lambda o: o.itervalues()
iterkeys = lambda o: o.iterkeys()
from itertools import izip
long_type = long
next = lambda o: o.next()
import cPickle as pickle
from cPickle import dumps, loads, dump, load
string_type = basestring
text_type = unicode
bytes_type = str
unichr = unichr
from urllib import urlretrieve
import Queue as queue
def byte(num):
return chr(num)
def u(s):
return unicode(s, "unicode_escape")
def with_metaclass(meta, base=object):
class _WhooshBase(base):
__metaclass__ = meta
return _WhooshBase
xrange = xrange
zip_ = zip
def memoryview_(source, offset=None, length=None):
if offset or length:
return buffer(source, offset, length)
else:
return buffer(source)
else:
PY3 = True
import collections
def b(s):
return s.encode("latin-1")
import io
BytesIO = io.BytesIO
callable = lambda o: isinstance(o, collections.Callable)
exec_ = eval("exec")
integer_types = (int,)
iteritems = lambda o: o.items()
itervalues = lambda o: o.values()
iterkeys = lambda o: iter(o.keys())
izip = zip
long_type = int
next = next
import pickle
from pickle import dumps, loads, dump, load
StringIO = io.StringIO
string_type = str
text_type = str
bytes_type = bytes
unichr = chr
from urllib.request import urlretrieve
import queue
def byte(num):
return bytes((num,))
def u(s):
if isinstance(s, bytes):
return s.decode("ascii")
return s
def with_metaclass(meta, base=object):
ns = dict(base=base, meta=meta)
exec_("""class _WhooshBase(base, metaclass=meta):
pass""", ns)
return ns["_WhooshBase"]
xrange = range
zip_ = lambda * args: list(zip(*args))
def memoryview_(source, offset=None, length=None):
mv = memoryview(source)
if offset or length:
return mv[offset:offset + length]
else:
return mv
try:
# for python >= 3.2, avoid DeprecationWarning for cgi.escape
from html import escape as htmlescape
except ImportError:
pass
if hasattr(array.array, "tobytes"):
def array_tobytes(arry):
return arry.tobytes()
def array_frombytes(arry, bs):
return arry.frombytes(bs)
else:
def array_tobytes(arry):
return arry.tostring()
def array_frombytes(arry, bs):
return arry.fromstring(bs)
# Implementations missing from older versions of Python
try:
from itertools import permutations # @UnusedImport
except ImportError:
# Python 2.5
def permutations(iterable, r=None):
pool = tuple(iterable)
n = len(pool)
r = n if r is None else r
if r > n:
return
indices = range(n)
cycles = range(n, n - r, -1)
yield tuple(pool[i] for i in indices[:r])
while n:
for i in reversed(range(r)):
cycles[i] -= 1
if cycles[i] == 0:
indices[i:] = indices[i + 1:] + indices[i:i + 1]
cycles[i] = n - i
else:
j = cycles[i]
indices[i], indices[-j] = indices[-j], indices[i]
yield tuple(pool[i] for i in indices[:r])
break
else:
return
try:
# Python 2.6-2.7
from itertools import izip_longest # @UnusedImport
except ImportError:
try:
# Python 3.0
from itertools import zip_longest as izip_longest # @UnusedImport
except ImportError:
# Python 2.5
from itertools import chain, izip, repeat
def izip_longest(*args, **kwds):
fillvalue = kwds.get('fillvalue')
def sentinel(counter=([fillvalue] * (len(args) - 1)).pop):
yield counter()
fillers = repeat(fillvalue)
iters = [chain(it, sentinel(), fillers) for it in args]
try:
for tup in izip(*iters):
yield tup
except IndexError:
pass
try:
from operator import methodcaller # @UnusedImport
except ImportError:
# Python 2.5
def methodcaller(name, *args, **kwargs):
def caller(obj):
return getattr(obj, name)(*args, **kwargs)
return caller
try:
from abc import abstractmethod # @UnusedImport
except ImportError:
# Python 2.5
def abstractmethod(funcobj):
"""A decorator indicating abstract methods.
"""
funcobj.__isabstractmethod__ = True
return funcobj
|
mit
|
[
646,
1625,
12,
984,
421,
199,
3,
3378,
900,
5162,
316,
402,
2018,
18,
15,
19,
15109,
199,
199,
318,
1243,
29198,
3588,
8,
83,
12,
6313,
29,
549,
304,
272,
327,
642,
365,
3517,
14,
3765,
295,
13825,
543,
16004,
14,
3765,
12,
272,
327,
880,
652,
5419,
367,
2366,
499,
14,
88,
12,
650,
14,
16,
436,
650,
14,
17,
272,
492,
16004,
272,
308,
275,
16004,
14,
3765,
8,
83,
12,
6313,
9,
272,
340,
6313,
26,
267,
327,
2366,
650,
14,
18,
2597,
19058,
314,
2849,
9344,
26,
267,
308,
275,
308,
14,
1814,
27769,
27720,
88,
1465,
15027,
272,
372,
308,
199,
199,
692,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
26,
272,
7843,
19,
275,
756,
339,
347,
330,
8,
83,
304,
267,
372,
308,
339,
492,
15073,
465,
5228,
272,
5228,
275,
11808,
275,
5228,
14,
6424,
272,
4550,
275,
4550,
272,
3000,
63,
1313,
275,
334,
442,
12,
1846,
9,
272,
10849,
275,
2400,
312,
26,
312,
14,
4611,
342,
272,
24451,
275,
2400,
312,
26,
312,
14,
13012,
342,
272,
25706,
275,
2400,
312,
26,
312,
14,
16007,
342,
272,
687,
7975,
492,
28697,
272,
1846,
63,
466,
275,
1846,
272,
2163,
275,
2400,
312,
26,
312,
14,
2184,
342,
272,
492,
17572,
465,
5927,
272,
687,
17572,
492,
16864,
12,
14404,
12,
5461,
12,
2248,
272,
1059,
63,
466,
275,
7116,
272,
1318,
63,
466,
275,
2649,
272,
2783,
63,
466,
275,
620,
272,
17742,
275,
17742,
272,
687,
4011,
492,
1166,
14270,
272,
492,
10703,
465,
4126,
339,
347,
3696,
8,
1507,
304,
267,
372,
8678,
8,
1507,
9,
339,
347,
399,
8,
83,
304,
267,
372,
2649,
8,
83,
12,
298,
2975,
63,
3765,
531,
339,
347,
543,
63,
6577,
8,
2024,
12,
1300,
29,
785,
304,
267,
1021,
485,
55,
19112,
609,
1563,
8,
1095,
304,
288,
636,
6577,
363,
275,
3404,
267,
372,
485,
55,
19112,
609,
1563,
339,
4945,
275,
4945,
272,
3482,
63,
275,
3482,
339,
347,
20228,
2531,
1365,
12,
3268,
29,
403,
12,
2582,
29,
403,
304,
267,
340,
3268,
503,
2582,
26,
288,
372,
3335,
8,
1365,
12,
3268,
12,
2582,
9,
267,
587,
26,
288,
372,
3335,
8,
1365,
9,
199,
199,
2836,
26,
272,
7843,
19,
275,
715,
272,
492,
5055,
339,
347,
330,
8,
83,
304,
267,
372,
308,
14,
2143,
480,
10378,
13,
17,
531,
339,
492,
5890,
272,
11808,
275,
5890,
14,
15466,
272,
4550,
275,
2400,
312,
26,
1228,
8,
79,
12,
5055,
14,
16410,
9,
272,
2146,
63,
275,
3468,
480,
1628,
531,
272,
3000,
63,
1313,
275,
334,
442,
4258,
272,
10849,
275,
2400,
312,
26,
312,
14,
1744,
342,
272,
24451,
275,
2400,
312,
26,
312,
14,
1459,
342,
272,
25706,
275,
2400,
312,
26,
2740,
8,
79,
14,
1612,
1012,
272,
28697,
275,
3482,
272,
1846,
63,
466,
275,
1109,
272,
2163,
275,
2163,
272,
492,
5927,
272,
687,
5927,
492,
16864,
12,
14404,
12,
5461,
12,
2248,
272,
5228,
275,
5890,
14,
6424,
272,
1059,
63,
466,
275,
620,
272,
1318,
63,
466,
275,
620,
272,
2783,
63,
466,
275,
2783,
272,
17742,
275,
8678,
272,
687,
4011,
14,
1069,
492,
1166,
14270,
272,
492,
4126,
339,
347,
3696,
8,
1507,
304,
267,
372,
2783,
1332,
1507,
4641,
339,
347,
399,
8,
83,
304,
267,
340,
1228,
8,
83,
12,
2783,
304,
288,
372,
308,
14,
2708,
480,
4371,
531,
267,
372,
308,
339,
347,
543,
63,
6577,
8,
2024,
12,
1300,
29,
785,
304,
267,
700,
275,
1211,
8,
1095,
29,
1095,
12,
3404,
29,
2024,
9,
267,
2146,
2531,
624,
533,
485,
55,
19112,
609,
1563,
8,
1095,
12,
17074,
29,
2024,
304,
272,
986,
7208,
700,
9,
267,
372,
700,
18524,
55,
19112,
609,
1563,
937,
339,
4945,
275,
1425,
272,
3482,
63,
275,
2400,
627,
1249,
26,
769,
8,
3065,
2031,
589,
430,
339,
347,
20228,
2531,
1365,
12,
3268,
29,
403,
12,
2582,
29,
403,
304,
267,
15413,
275,
20228,
8,
1365,
9,
267,
340,
3268,
503,
2582,
26,
288,
372,
15413,
59,
2743,
26,
2743,
435,
2582,
61,
267,
587,
26,
288,
372,
15413,
339,
862,
26,
267,
327,
367,
2366,
2356,
650,
14,
18,
12,
5126,
13413,
367,
16004,
14,
3765,
267,
687,
3517,
492,
4772,
465,
1243,
29198,
3588,
272,
871,
3545,
26,
267,
986,
421,
199,
692,
2688,
8,
1144,
14,
1144,
12,
298,
32557,
2349,
272,
347,
1625,
63,
32557,
8,
285,
651,
304,
267,
372,
601,
651,
14,
32557,
342,
339,
347,
1625,
63,
504,
2394,
8,
285,
651,
12,
9922,
304,
267,
372,
601,
651,
14,
504,
2394,
8,
1533,
9,
199,
2836,
26,
272,
347,
1625,
63,
32557,
8,
285,
651,
304,
267,
372,
601,
651,
14,
14028,
342,
339,
347,
1625,
63,
504,
2394,
8,
285,
651,
12,
9922,
304,
267,
372,
601,
651,
14,
13521,
8,
1533,
9,
421,
199,
3,
22467,
1298,
4124,
687,
12731,
5459,
402,
2018,
199,
199,
893,
26,
272,
687,
7975,
492,
26899,
221,
327,
768,
20782,
6295,
199,
2590,
3545,
26,
272,
327,
2018,
499,
14,
21,
272,
347,
26899,
8,
8147,
12,
519,
29,
403,
304,
267,
4203,
275,
2008,
8,
8147,
9,
267,
302,
275,
822,
8,
2293,
9,
267,
519,
275,
302,
340,
519,
365,
488,
587,
519,
267,
340,
519,
690,
302,
26,
288,
372,
267,
4918,
275,
1425,
8,
78,
9,
267,
19001,
275,
1425,
8,
78,
12,
302,
446,
519,
12,
446,
17,
9,
267,
1995,
2008,
8,
2293,
59,
73,
61,
367,
284,
315,
4918,
1491,
82,
566,
267,
1830,
302,
26,
288,
367,
284,
315,
10822,
8,
1842,
8,
82,
2298,
355,
19001,
59,
73,
61,
4862,
413,
355,
340,
19001,
59,
73,
61,
508,
378,
26,
490,
4918,
59,
73,
2938,
275,
4918,
59,
73,
435,
413,
2938,
435,
4918,
59,
73,
26,
73,
435,
413,
61,
490,
19001,
59,
73,
61,
275,
302,
446,
284,
355,
587,
26,
490,
1335,
275,
19001,
59,
73,
61,
490,
4918,
59,
73,
467,
4918,
1988,
74,
61,
275,
4918,
1988,
74,
467,
4918,
59,
73,
61,
490,
1995,
2008,
8,
2293,
59,
73
] |
[
1625,
12,
984,
421,
199,
3,
3378,
900,
5162,
316,
402,
2018,
18,
15,
19,
15109,
199,
199,
318,
1243,
29198,
3588,
8,
83,
12,
6313,
29,
549,
304,
272,
327,
642,
365,
3517,
14,
3765,
295,
13825,
543,
16004,
14,
3765,
12,
272,
327,
880,
652,
5419,
367,
2366,
499,
14,
88,
12,
650,
14,
16,
436,
650,
14,
17,
272,
492,
16004,
272,
308,
275,
16004,
14,
3765,
8,
83,
12,
6313,
9,
272,
340,
6313,
26,
267,
327,
2366,
650,
14,
18,
2597,
19058,
314,
2849,
9344,
26,
267,
308,
275,
308,
14,
1814,
27769,
27720,
88,
1465,
15027,
272,
372,
308,
199,
199,
692,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
26,
272,
7843,
19,
275,
756,
339,
347,
330,
8,
83,
304,
267,
372,
308,
339,
492,
15073,
465,
5228,
272,
5228,
275,
11808,
275,
5228,
14,
6424,
272,
4550,
275,
4550,
272,
3000,
63,
1313,
275,
334,
442,
12,
1846,
9,
272,
10849,
275,
2400,
312,
26,
312,
14,
4611,
342,
272,
24451,
275,
2400,
312,
26,
312,
14,
13012,
342,
272,
25706,
275,
2400,
312,
26,
312,
14,
16007,
342,
272,
687,
7975,
492,
28697,
272,
1846,
63,
466,
275,
1846,
272,
2163,
275,
2400,
312,
26,
312,
14,
2184,
342,
272,
492,
17572,
465,
5927,
272,
687,
17572,
492,
16864,
12,
14404,
12,
5461,
12,
2248,
272,
1059,
63,
466,
275,
7116,
272,
1318,
63,
466,
275,
2649,
272,
2783,
63,
466,
275,
620,
272,
17742,
275,
17742,
272,
687,
4011,
492,
1166,
14270,
272,
492,
10703,
465,
4126,
339,
347,
3696,
8,
1507,
304,
267,
372,
8678,
8,
1507,
9,
339,
347,
399,
8,
83,
304,
267,
372,
2649,
8,
83,
12,
298,
2975,
63,
3765,
531,
339,
347,
543,
63,
6577,
8,
2024,
12,
1300,
29,
785,
304,
267,
1021,
485,
55,
19112,
609,
1563,
8,
1095,
304,
288,
636,
6577,
363,
275,
3404,
267,
372,
485,
55,
19112,
609,
1563,
339,
4945,
275,
4945,
272,
3482,
63,
275,
3482,
339,
347,
20228,
2531,
1365,
12,
3268,
29,
403,
12,
2582,
29,
403,
304,
267,
340,
3268,
503,
2582,
26,
288,
372,
3335,
8,
1365,
12,
3268,
12,
2582,
9,
267,
587,
26,
288,
372,
3335,
8,
1365,
9,
199,
199,
2836,
26,
272,
7843,
19,
275,
715,
272,
492,
5055,
339,
347,
330,
8,
83,
304,
267,
372,
308,
14,
2143,
480,
10378,
13,
17,
531,
339,
492,
5890,
272,
11808,
275,
5890,
14,
15466,
272,
4550,
275,
2400,
312,
26,
1228,
8,
79,
12,
5055,
14,
16410,
9,
272,
2146,
63,
275,
3468,
480,
1628,
531,
272,
3000,
63,
1313,
275,
334,
442,
4258,
272,
10849,
275,
2400,
312,
26,
312,
14,
1744,
342,
272,
24451,
275,
2400,
312,
26,
312,
14,
1459,
342,
272,
25706,
275,
2400,
312,
26,
2740,
8,
79,
14,
1612,
1012,
272,
28697,
275,
3482,
272,
1846,
63,
466,
275,
1109,
272,
2163,
275,
2163,
272,
492,
5927,
272,
687,
5927,
492,
16864,
12,
14404,
12,
5461,
12,
2248,
272,
5228,
275,
5890,
14,
6424,
272,
1059,
63,
466,
275,
620,
272,
1318,
63,
466,
275,
620,
272,
2783,
63,
466,
275,
2783,
272,
17742,
275,
8678,
272,
687,
4011,
14,
1069,
492,
1166,
14270,
272,
492,
4126,
339,
347,
3696,
8,
1507,
304,
267,
372,
2783,
1332,
1507,
4641,
339,
347,
399,
8,
83,
304,
267,
340,
1228,
8,
83,
12,
2783,
304,
288,
372,
308,
14,
2708,
480,
4371,
531,
267,
372,
308,
339,
347,
543,
63,
6577,
8,
2024,
12,
1300,
29,
785,
304,
267,
700,
275,
1211,
8,
1095,
29,
1095,
12,
3404,
29,
2024,
9,
267,
2146,
2531,
624,
533,
485,
55,
19112,
609,
1563,
8,
1095,
12,
17074,
29,
2024,
304,
272,
986,
7208,
700,
9,
267,
372,
700,
18524,
55,
19112,
609,
1563,
937,
339,
4945,
275,
1425,
272,
3482,
63,
275,
2400,
627,
1249,
26,
769,
8,
3065,
2031,
589,
430,
339,
347,
20228,
2531,
1365,
12,
3268,
29,
403,
12,
2582,
29,
403,
304,
267,
15413,
275,
20228,
8,
1365,
9,
267,
340,
3268,
503,
2582,
26,
288,
372,
15413,
59,
2743,
26,
2743,
435,
2582,
61,
267,
587,
26,
288,
372,
15413,
339,
862,
26,
267,
327,
367,
2366,
2356,
650,
14,
18,
12,
5126,
13413,
367,
16004,
14,
3765,
267,
687,
3517,
492,
4772,
465,
1243,
29198,
3588,
272,
871,
3545,
26,
267,
986,
421,
199,
692,
2688,
8,
1144,
14,
1144,
12,
298,
32557,
2349,
272,
347,
1625,
63,
32557,
8,
285,
651,
304,
267,
372,
601,
651,
14,
32557,
342,
339,
347,
1625,
63,
504,
2394,
8,
285,
651,
12,
9922,
304,
267,
372,
601,
651,
14,
504,
2394,
8,
1533,
9,
199,
2836,
26,
272,
347,
1625,
63,
32557,
8,
285,
651,
304,
267,
372,
601,
651,
14,
14028,
342,
339,
347,
1625,
63,
504,
2394,
8,
285,
651,
12,
9922,
304,
267,
372,
601,
651,
14,
13521,
8,
1533,
9,
421,
199,
3,
22467,
1298,
4124,
687,
12731,
5459,
402,
2018,
199,
199,
893,
26,
272,
687,
7975,
492,
26899,
221,
327,
768,
20782,
6295,
199,
2590,
3545,
26,
272,
327,
2018,
499,
14,
21,
272,
347,
26899,
8,
8147,
12,
519,
29,
403,
304,
267,
4203,
275,
2008,
8,
8147,
9,
267,
302,
275,
822,
8,
2293,
9,
267,
519,
275,
302,
340,
519,
365,
488,
587,
519,
267,
340,
519,
690,
302,
26,
288,
372,
267,
4918,
275,
1425,
8,
78,
9,
267,
19001,
275,
1425,
8,
78,
12,
302,
446,
519,
12,
446,
17,
9,
267,
1995,
2008,
8,
2293,
59,
73,
61,
367,
284,
315,
4918,
1491,
82,
566,
267,
1830,
302,
26,
288,
367,
284,
315,
10822,
8,
1842,
8,
82,
2298,
355,
19001,
59,
73,
61,
4862,
413,
355,
340,
19001,
59,
73,
61,
508,
378,
26,
490,
4918,
59,
73,
2938,
275,
4918,
59,
73,
435,
413,
2938,
435,
4918,
59,
73,
26,
73,
435,
413,
61,
490,
19001,
59,
73,
61,
275,
302,
446,
284,
355,
587,
26,
490,
1335,
275,
19001,
59,
73,
61,
490,
4918,
59,
73,
467,
4918,
1988,
74,
61,
275,
4918,
1988,
74,
467,
4918,
59,
73,
61,
490,
1995,
2008,
8,
2293,
59,
73,
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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