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
|
|---|---|---|---|---|---|---|---|---|
vvv1559/intellij-community
|
python/lib/Lib/site-packages/django/core/serializers/pyyaml.py
|
108
|
2081
|
"""
YAML serializer.
Requires PyYaml (http://pyyaml.org/), but that's checked for in __init__.
"""
from StringIO import StringIO
import decimal
import yaml
from django.db import models
from django.core.serializers.python import Serializer as PythonSerializer
from django.core.serializers.python import Deserializer as PythonDeserializer
class DjangoSafeDumper(yaml.SafeDumper):
def represent_decimal(self, data):
return self.represent_scalar('tag:yaml.org,2002:str', str(data))
DjangoSafeDumper.add_representer(decimal.Decimal, DjangoSafeDumper.represent_decimal)
class Serializer(PythonSerializer):
"""
Convert a queryset to YAML.
"""
internal_use_only = False
def handle_field(self, obj, field):
# A nasty special case: base YAML doesn't support serialization of time
# types (as opposed to dates or datetimes, which it does support). Since
# we want to use the "safe" serializer for better interoperability, we
# need to do something with those pesky times. Converting 'em to strings
# isn't perfect, but it's better than a "!!python/time" type which would
# halt deserialization under any other language.
if isinstance(field, models.TimeField) and getattr(obj, field.name) is not None:
self._current[field.name] = str(getattr(obj, field.name))
else:
super(Serializer, self).handle_field(obj, field)
def end_serialization(self):
self.options.pop('stream', None)
self.options.pop('fields', None)
self.options.pop('use_natural_keys', None)
yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options)
def getvalue(self):
return self.stream.getvalue()
def Deserializer(stream_or_string, **options):
"""
Deserialize a stream or string of YAML data.
"""
if isinstance(stream_or_string, basestring):
stream = StringIO(stream_or_string)
else:
stream = stream_or_string
for obj in PythonDeserializer(yaml.load(stream), **options):
yield obj
|
apache-2.0
|
[
624,
199,
23103,
9146,
14,
199,
199,
18153,
1611,
57,
3935,
334,
1014,
921,
647,
5963,
14,
1308,
15,
395,
1325,
626,
1159,
7923,
367,
315,
636,
826,
4343,
199,
624,
199,
199,
504,
5228,
492,
5228,
199,
646,
6107,
199,
646,
8864,
199,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1018,
14,
12844,
14,
1548,
492,
25555,
465,
2018,
7299,
199,
504,
1639,
14,
1018,
14,
12844,
14,
1548,
492,
1487,
8349,
465,
2018,
872,
8349,
199,
199,
533,
5634,
11090,
28593,
8,
5963,
14,
11090,
28593,
304,
272,
347,
2954,
63,
6355,
8,
277,
12,
666,
304,
267,
372,
291,
14,
13063,
63,
7033,
360,
1450,
26,
5963,
14,
1308,
12,
15135,
26,
495,
297,
620,
8,
576,
430,
199,
199,
9323,
11090,
28593,
14,
525,
63,
264,
22682,
8,
6355,
14,
6745,
12,
5634,
11090,
28593,
14,
13063,
63,
6355,
9,
199,
199,
533,
25555,
8,
4718,
7299,
304,
272,
408,
272,
7905,
282,
7594,
370,
18916,
14,
272,
408,
339,
5007,
63,
1180,
63,
2118,
275,
756,
339,
347,
2429,
63,
698,
8,
277,
12,
1559,
12,
901,
304,
267,
327,
437,
302,
27352,
4539,
1930,
26,
1300,
18916,
3181,
1133,
2291,
16953,
402,
900,
267,
327,
2943,
334,
305,
25068,
370,
10831,
503,
29297,
12,
1314,
652,
1630,
2291,
680,
9336,
267,
327,
781,
2934,
370,
675,
314,
298,
3489,
2,
9146,
367,
8034,
4661,
9198,
3616,
12,
781,
267,
327,
1929,
370,
886,
6020,
543,
5204,
299,
397,
10562,
5431,
14,
23258,
283,
5633,
370,
3326,
267,
327,
5712,
1133,
23668,
12,
1325,
652,
1159,
8034,
2419,
282,
298,
3480,
1548,
15,
521,
2,
730,
1314,
3955,
267,
327,
394,
4478,
477,
12161,
1334,
1263,
1163,
2637,
14,
267,
340,
1228,
8,
698,
12,
1709,
14,
27115,
9,
436,
2519,
8,
1113,
12,
901,
14,
354,
9,
365,
440,
488,
26,
288,
291,
423,
1818,
59,
698,
14,
354,
61,
275,
620,
8,
5675,
8,
1113,
12,
901,
14,
354,
430,
267,
587,
26,
288,
1613,
8,
7299,
12,
291,
680,
2479,
63,
698,
8,
1113,
12,
901,
9,
339,
347,
1284,
63,
12161,
8,
277,
304,
267,
291,
14,
1419,
14,
1935,
360,
1745,
297,
488,
9,
267,
291,
14,
1419,
14,
1935,
360,
955,
297,
488,
9,
267,
291,
14,
1419,
14,
1935,
360,
1180,
63,
15759,
63,
1612,
297,
488,
9,
267,
8864,
14,
2724,
8,
277,
14,
1462,
12,
291,
14,
1745,
12,
19460,
281,
29,
9323,
11090,
28593,
12,
1011,
277,
14,
1419,
9,
339,
347,
664,
585,
8,
277,
304,
267,
372,
291,
14,
1745,
14,
7150,
342,
199,
199,
318,
1487,
8349,
8,
1745,
63,
269,
63,
875,
12,
1011,
1419,
304,
272,
408,
272,
1487,
3549,
282,
2547,
503,
1059,
402,
18916,
666,
14,
272,
408,
272,
340,
1228,
8,
1745,
63,
269,
63,
875,
12,
7116,
304,
267,
2547,
275,
5228,
8,
1745,
63,
269,
63,
875,
9,
272,
587,
26,
267,
2547,
275,
2547,
63,
269,
63,
875,
272,
367,
1559,
315,
2018,
872,
8349,
8,
5963,
14,
912,
8,
1745,
395,
1011,
1419,
304,
267,
1995,
1559,
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
] |
[
199,
23103,
9146,
14,
199,
199,
18153,
1611,
57,
3935,
334,
1014,
921,
647,
5963,
14,
1308,
15,
395,
1325,
626,
1159,
7923,
367,
315,
636,
826,
4343,
199,
624,
199,
199,
504,
5228,
492,
5228,
199,
646,
6107,
199,
646,
8864,
199,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1018,
14,
12844,
14,
1548,
492,
25555,
465,
2018,
7299,
199,
504,
1639,
14,
1018,
14,
12844,
14,
1548,
492,
1487,
8349,
465,
2018,
872,
8349,
199,
199,
533,
5634,
11090,
28593,
8,
5963,
14,
11090,
28593,
304,
272,
347,
2954,
63,
6355,
8,
277,
12,
666,
304,
267,
372,
291,
14,
13063,
63,
7033,
360,
1450,
26,
5963,
14,
1308,
12,
15135,
26,
495,
297,
620,
8,
576,
430,
199,
199,
9323,
11090,
28593,
14,
525,
63,
264,
22682,
8,
6355,
14,
6745,
12,
5634,
11090,
28593,
14,
13063,
63,
6355,
9,
199,
199,
533,
25555,
8,
4718,
7299,
304,
272,
408,
272,
7905,
282,
7594,
370,
18916,
14,
272,
408,
339,
5007,
63,
1180,
63,
2118,
275,
756,
339,
347,
2429,
63,
698,
8,
277,
12,
1559,
12,
901,
304,
267,
327,
437,
302,
27352,
4539,
1930,
26,
1300,
18916,
3181,
1133,
2291,
16953,
402,
900,
267,
327,
2943,
334,
305,
25068,
370,
10831,
503,
29297,
12,
1314,
652,
1630,
2291,
680,
9336,
267,
327,
781,
2934,
370,
675,
314,
298,
3489,
2,
9146,
367,
8034,
4661,
9198,
3616,
12,
781,
267,
327,
1929,
370,
886,
6020,
543,
5204,
299,
397,
10562,
5431,
14,
23258,
283,
5633,
370,
3326,
267,
327,
5712,
1133,
23668,
12,
1325,
652,
1159,
8034,
2419,
282,
298,
3480,
1548,
15,
521,
2,
730,
1314,
3955,
267,
327,
394,
4478,
477,
12161,
1334,
1263,
1163,
2637,
14,
267,
340,
1228,
8,
698,
12,
1709,
14,
27115,
9,
436,
2519,
8,
1113,
12,
901,
14,
354,
9,
365,
440,
488,
26,
288,
291,
423,
1818,
59,
698,
14,
354,
61,
275,
620,
8,
5675,
8,
1113,
12,
901,
14,
354,
430,
267,
587,
26,
288,
1613,
8,
7299,
12,
291,
680,
2479,
63,
698,
8,
1113,
12,
901,
9,
339,
347,
1284,
63,
12161,
8,
277,
304,
267,
291,
14,
1419,
14,
1935,
360,
1745,
297,
488,
9,
267,
291,
14,
1419,
14,
1935,
360,
955,
297,
488,
9,
267,
291,
14,
1419,
14,
1935,
360,
1180,
63,
15759,
63,
1612,
297,
488,
9,
267,
8864,
14,
2724,
8,
277,
14,
1462,
12,
291,
14,
1745,
12,
19460,
281,
29,
9323,
11090,
28593,
12,
1011,
277,
14,
1419,
9,
339,
347,
664,
585,
8,
277,
304,
267,
372,
291,
14,
1745,
14,
7150,
342,
199,
199,
318,
1487,
8349,
8,
1745,
63,
269,
63,
875,
12,
1011,
1419,
304,
272,
408,
272,
1487,
3549,
282,
2547,
503,
1059,
402,
18916,
666,
14,
272,
408,
272,
340,
1228,
8,
1745,
63,
269,
63,
875,
12,
7116,
304,
267,
2547,
275,
5228,
8,
1745,
63,
269,
63,
875,
9,
272,
587,
26,
267,
2547,
275,
2547,
63,
269,
63,
875,
272,
367,
1559,
315,
2018,
872,
8349,
8,
5963,
14,
912,
8,
1745,
395,
1011,
1419,
304,
267,
1995,
1559,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Trixter69/BookMarka
|
lib/cherrypy/lib/auth.py
|
68
|
3224
|
import cherrypy
from cherrypy.lib import httpauth
def check_auth(users, encrypt=None, realm=None):
"""If an authorization header contains credentials, return True or False.
"""
request = cherrypy.serving.request
if 'authorization' in request.headers:
# make sure the provided credentials are correctly set
ah = httpauth.parseAuthorization(request.headers['authorization'])
if ah is None:
raise cherrypy.HTTPError(400, 'Bad Request')
if not encrypt:
encrypt = httpauth.DIGEST_AUTH_ENCODERS[httpauth.MD5]
if hasattr(users, '__call__'):
try:
# backward compatibility
users = users() # expect it to return a dictionary
if not isinstance(users, dict):
raise ValueError(
"Authentication users must be a dictionary")
# fetch the user password
password = users.get(ah["username"], None)
except TypeError:
# returns a password (encrypted or clear text)
password = users(ah["username"])
else:
if not isinstance(users, dict):
raise ValueError("Authentication users must be a dictionary")
# fetch the user password
password = users.get(ah["username"], None)
# validate the authorization by re-computing it here
# and compare it with what the user-agent provided
if httpauth.checkResponse(ah, password, method=request.method,
encrypt=encrypt, realm=realm):
request.login = ah["username"]
return True
request.login = False
return False
def basic_auth(realm, users, encrypt=None, debug=False):
"""If auth fails, raise 401 with a basic authentication header.
realm
A string containing the authentication realm.
users
A dict of the form: {username: password} or a callable returning
a dict.
encrypt
callable used to encrypt the password returned from the user-agent.
if None it defaults to a md5 encryption.
"""
if check_auth(users, encrypt):
if debug:
cherrypy.log('Auth successful', 'TOOLS.BASIC_AUTH')
return
# inform the user-agent this path is protected
cherrypy.serving.response.headers[
'www-authenticate'] = httpauth.basicAuth(realm)
raise cherrypy.HTTPError(
401, "You are not authorized to access that resource")
def digest_auth(realm, users, debug=False):
"""If auth fails, raise 401 with a digest authentication header.
realm
A string containing the authentication realm.
users
A dict of the form: {username: password} or a callable returning
a dict.
"""
if check_auth(users, realm=realm):
if debug:
cherrypy.log('Auth successful', 'TOOLS.DIGEST_AUTH')
return
# inform the user-agent this path is protected
cherrypy.serving.response.headers[
'www-authenticate'] = httpauth.digestAuth(realm)
raise cherrypy.HTTPError(
401, "You are not authorized to access that resource")
|
gpl-3.0
|
[
646,
13397,
199,
504,
13397,
14,
773,
492,
22768,
387,
762,
421,
199,
318,
1104,
63,
1178,
8,
3707,
12,
14645,
29,
403,
12,
10482,
29,
403,
304,
272,
408,
3917,
376,
13448,
1406,
3509,
6235,
12,
372,
715,
503,
756,
14,
272,
408,
272,
1056,
275,
13397,
14,
14717,
14,
1069,
272,
340,
283,
15846,
7,
315,
1056,
14,
2139,
26,
267,
327,
1852,
3238,
314,
2741,
6235,
787,
6657,
663,
267,
282,
72,
275,
22768,
387,
762,
14,
1122,
11626,
8,
1069,
14,
2139,
459,
15846,
1105,
267,
340,
282,
72,
365,
488,
26,
288,
746,
13397,
14,
12815,
8,
5303,
12,
283,
5725,
4784,
358,
398,
340,
440,
14645,
26,
288,
14645,
275,
22768,
387,
762,
14,
22855,
1719,
63,
5580,
63,
742,
12592,
3960,
59,
16916,
387,
762,
14,
5127,
21,
61,
398,
340,
2688,
8,
3707,
12,
2560,
1250,
12168,
288,
862,
26,
355,
327,
13388,
7163,
355,
4390,
275,
4390,
342,
221,
327,
4282,
652,
370,
372,
282,
2600,
2234,
340,
440,
1228,
8,
3707,
12,
1211,
304,
490,
746,
1722,
8,
717,
298,
10348,
4390,
1471,
506,
282,
2600,
531,
2234,
327,
5267,
314,
922,
2505,
355,
2505,
275,
4390,
14,
362,
8,
11326,
905,
2473,
2255,
488,
9,
288,
871,
3146,
26,
355,
327,
2529,
282,
2505,
334,
15078,
503,
5436,
1318,
9,
355,
2505,
275,
4390,
8,
11326,
905,
2473,
3135,
267,
587,
26,
288,
340,
440,
1228,
8,
3707,
12,
1211,
304,
355,
746,
1722,
480,
10348,
4390,
1471,
506,
282,
2600,
531,
953,
327,
5267,
314,
922,
2505,
288,
2505,
275,
4390,
14,
362,
8,
11326,
905,
2473,
2255,
488,
9,
398,
327,
4107,
314,
13448,
701,
295,
13,
863,
4655,
652,
2348,
267,
327,
436,
6540,
652,
543,
4052,
314,
922,
13,
4054,
2741,
267,
340,
22768,
387,
762,
14,
1074,
2364,
8,
11326,
12,
2505,
12,
1083,
29,
1069,
14,
765,
12,
3303,
14645,
29,
11929,
12,
10482,
29,
7728,
304,
288,
1056,
14,
2886,
275,
282,
72,
905,
2473,
937,
288,
372,
715,
398,
1056,
14,
2886,
275,
756,
272,
372,
756,
421,
199,
318,
5678,
63,
1178,
8,
7728,
12,
4390,
12,
14645,
29,
403,
12,
3105,
29,
797,
304,
272,
408,
3917,
1790,
6918,
12,
746,
13952,
543,
282,
5678,
6299,
1406,
14,
339,
10482,
267,
437,
1059,
3035,
314,
6299,
10482,
14,
339,
4390,
267,
437,
1211,
402,
314,
1824,
26,
469,
2473,
26,
2505,
93,
503,
282,
4550,
8152,
267,
282,
1211,
14,
339,
14645,
267,
4550,
1202,
370,
14645,
314,
2505,
2138,
687,
314,
922,
13,
4054,
14,
267,
340,
488,
652,
4243,
370,
282,
6128,
21,
14396,
14,
339,
408,
272,
340,
1104,
63,
1178,
8,
3707,
12,
14645,
304,
267,
340,
3105,
26,
288,
13397,
14,
793,
360,
2817,
9512,
297,
283,
20261,
14,
27271,
63,
5580,
358,
267,
372,
339,
327,
315,
964,
314,
922,
13,
4054,
642,
931,
365,
17819,
272,
13397,
14,
14717,
14,
1310,
14,
2139,
59,
267,
283,
1544,
13,
13975,
418,
275,
22768,
387,
762,
14,
4316,
2817,
8,
7728,
9,
339,
746,
13397,
14,
12815,
8,
267,
13952,
12,
298,
5556,
787,
440,
18788,
370,
2879,
626,
2073,
531,
421,
199,
318,
10017,
63,
1178,
8,
7728,
12,
4390,
12,
3105,
29,
797,
304,
272,
408,
3917,
1790,
6918,
12,
746,
13952,
543,
282,
10017,
6299,
1406,
14,
339,
10482,
267,
437,
1059,
3035,
314,
6299,
10482,
14,
272,
4390,
267,
437,
1211,
402,
314,
1824,
26,
469,
2473,
26,
2505,
93,
503,
282,
4550,
8152,
267,
282,
1211,
14,
272,
408,
272,
340,
1104,
63,
1178,
8,
3707,
12,
10482,
29,
7728,
304,
267,
340,
3105,
26,
288,
13397,
14,
793,
360,
2817,
9512,
297,
283,
20261,
14,
22855,
1719,
63,
5580,
358,
267,
372,
339,
327,
315,
964,
314,
922,
13,
4054,
642,
931,
365,
17819,
272,
13397,
14,
14717,
14,
1310,
14,
2139,
59,
267,
283,
1544,
13,
13975,
418,
275,
22768,
387,
762,
14,
5671,
2817,
8,
7728,
9,
339,
746,
13397,
14,
12815,
8,
267,
13952,
12,
298,
5556,
787,
440,
18788,
370,
2879,
626,
2073,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
13397,
199,
504,
13397,
14,
773,
492,
22768,
387,
762,
421,
199,
318,
1104,
63,
1178,
8,
3707,
12,
14645,
29,
403,
12,
10482,
29,
403,
304,
272,
408,
3917,
376,
13448,
1406,
3509,
6235,
12,
372,
715,
503,
756,
14,
272,
408,
272,
1056,
275,
13397,
14,
14717,
14,
1069,
272,
340,
283,
15846,
7,
315,
1056,
14,
2139,
26,
267,
327,
1852,
3238,
314,
2741,
6235,
787,
6657,
663,
267,
282,
72,
275,
22768,
387,
762,
14,
1122,
11626,
8,
1069,
14,
2139,
459,
15846,
1105,
267,
340,
282,
72,
365,
488,
26,
288,
746,
13397,
14,
12815,
8,
5303,
12,
283,
5725,
4784,
358,
398,
340,
440,
14645,
26,
288,
14645,
275,
22768,
387,
762,
14,
22855,
1719,
63,
5580,
63,
742,
12592,
3960,
59,
16916,
387,
762,
14,
5127,
21,
61,
398,
340,
2688,
8,
3707,
12,
2560,
1250,
12168,
288,
862,
26,
355,
327,
13388,
7163,
355,
4390,
275,
4390,
342,
221,
327,
4282,
652,
370,
372,
282,
2600,
2234,
340,
440,
1228,
8,
3707,
12,
1211,
304,
490,
746,
1722,
8,
717,
298,
10348,
4390,
1471,
506,
282,
2600,
531,
2234,
327,
5267,
314,
922,
2505,
355,
2505,
275,
4390,
14,
362,
8,
11326,
905,
2473,
2255,
488,
9,
288,
871,
3146,
26,
355,
327,
2529,
282,
2505,
334,
15078,
503,
5436,
1318,
9,
355,
2505,
275,
4390,
8,
11326,
905,
2473,
3135,
267,
587,
26,
288,
340,
440,
1228,
8,
3707,
12,
1211,
304,
355,
746,
1722,
480,
10348,
4390,
1471,
506,
282,
2600,
531,
953,
327,
5267,
314,
922,
2505,
288,
2505,
275,
4390,
14,
362,
8,
11326,
905,
2473,
2255,
488,
9,
398,
327,
4107,
314,
13448,
701,
295,
13,
863,
4655,
652,
2348,
267,
327,
436,
6540,
652,
543,
4052,
314,
922,
13,
4054,
2741,
267,
340,
22768,
387,
762,
14,
1074,
2364,
8,
11326,
12,
2505,
12,
1083,
29,
1069,
14,
765,
12,
3303,
14645,
29,
11929,
12,
10482,
29,
7728,
304,
288,
1056,
14,
2886,
275,
282,
72,
905,
2473,
937,
288,
372,
715,
398,
1056,
14,
2886,
275,
756,
272,
372,
756,
421,
199,
318,
5678,
63,
1178,
8,
7728,
12,
4390,
12,
14645,
29,
403,
12,
3105,
29,
797,
304,
272,
408,
3917,
1790,
6918,
12,
746,
13952,
543,
282,
5678,
6299,
1406,
14,
339,
10482,
267,
437,
1059,
3035,
314,
6299,
10482,
14,
339,
4390,
267,
437,
1211,
402,
314,
1824,
26,
469,
2473,
26,
2505,
93,
503,
282,
4550,
8152,
267,
282,
1211,
14,
339,
14645,
267,
4550,
1202,
370,
14645,
314,
2505,
2138,
687,
314,
922,
13,
4054,
14,
267,
340,
488,
652,
4243,
370,
282,
6128,
21,
14396,
14,
339,
408,
272,
340,
1104,
63,
1178,
8,
3707,
12,
14645,
304,
267,
340,
3105,
26,
288,
13397,
14,
793,
360,
2817,
9512,
297,
283,
20261,
14,
27271,
63,
5580,
358,
267,
372,
339,
327,
315,
964,
314,
922,
13,
4054,
642,
931,
365,
17819,
272,
13397,
14,
14717,
14,
1310,
14,
2139,
59,
267,
283,
1544,
13,
13975,
418,
275,
22768,
387,
762,
14,
4316,
2817,
8,
7728,
9,
339,
746,
13397,
14,
12815,
8,
267,
13952,
12,
298,
5556,
787,
440,
18788,
370,
2879,
626,
2073,
531,
421,
199,
318,
10017,
63,
1178,
8,
7728,
12,
4390,
12,
3105,
29,
797,
304,
272,
408,
3917,
1790,
6918,
12,
746,
13952,
543,
282,
10017,
6299,
1406,
14,
339,
10482,
267,
437,
1059,
3035,
314,
6299,
10482,
14,
272,
4390,
267,
437,
1211,
402,
314,
1824,
26,
469,
2473,
26,
2505,
93,
503,
282,
4550,
8152,
267,
282,
1211,
14,
272,
408,
272,
340,
1104,
63,
1178,
8,
3707,
12,
10482,
29,
7728,
304,
267,
340,
3105,
26,
288,
13397,
14,
793,
360,
2817,
9512,
297,
283,
20261,
14,
22855,
1719,
63,
5580,
358,
267,
372,
339,
327,
315,
964,
314,
922,
13,
4054,
642,
931,
365,
17819,
272,
13397,
14,
14717,
14,
1310,
14,
2139,
59,
267,
283,
1544,
13,
13975,
418,
275,
22768,
387,
762,
14,
5671,
2817,
8,
7728,
9,
339,
746,
13397,
14,
12815,
8,
267,
13952,
12,
298,
5556,
787,
440,
18788,
370,
2879,
626,
2073,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
amarullz/libaroma
|
libs/freetype/src/tools/docmaker/tohtml.py
|
55
|
23387
|
#
# tohtml.py
#
# A sub-class container of the `Formatter' class to produce HTML.
#
# Copyright 2002-2015 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
# modified, and distributed under the terms of the FreeType project
# license, LICENSE.TXT. By continuing to use, modify, or distribute
# this file you indicate that you have read the license and
# understand and accept it fully.
# The parent class is contained in file `formatter.py'.
from sources import *
from content import *
from formatter import *
import time
# The following strings define the HTML header used by all generated pages.
html_header_1 = """\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>\
"""
html_header_2 = """\
API Reference</title>
<style type="text/css">
a:link { color: #0000EF; }
a:visited { color: #51188E; }
a:hover { color: #FF0000; }
body { font-family: Verdana, Geneva, Arial, Helvetica, serif;
color: #000000;
background: #FFFFFF;
width: 87%;
margin: auto; }
div.section { width: 75%;
margin: auto; }
div.section hr { margin: 4ex 0 1ex 0; }
div.section h4 { background-color: #EEEEFF;
font-size: medium;
font-style: oblique;
font-weight: bold;
margin: 3ex 0 1.5ex 9%;
padding: 0.3ex 0 0.3ex 1%; }
div.section p { margin: 1.5ex 0 1.5ex 10%; }
div.section pre { margin: 3ex 0 3ex 9%;
background-color: #D6E8FF;
padding: 2ex 0 2ex 1%; }
div.section table.fields { width: 90%;
margin: 1.5ex 0 1.5ex 10%; }
div.section table.toc { width: 95%;
margin: 1.5ex 0 1.5ex 5%; }
div.timestamp { text-align: center;
font-size: 69%;
margin: 1.5ex 0 1.5ex 0; }
h1 { text-align: center; }
h3 { font-size: medium;
margin: 4ex 0 1.5ex 0; }
p { text-align: justify; }
pre.colored { color: blue; }
span.keyword { font-family: monospace;
text-align: left;
white-space: pre;
color: darkblue; }
table.fields td.val { font-weight: bold;
text-align: right;
width: 30%;
vertical-align: baseline;
padding: 1ex 1em 1ex 0; }
table.fields td.desc { vertical-align: baseline;
padding: 1ex 0 1ex 1em; }
table.fields td.desc p:first-child { margin: 0; }
table.fields td.desc p { margin: 1.5ex 0 0 0; }
table.index { margin: 6ex auto 6ex auto;
border: 0;
border-collapse: separate;
border-spacing: 1em 0.3ex; }
table.index tr { padding: 0; }
table.index td { padding: 0; }
table.index-toc-link { width: 100%;
border: 0;
border-spacing: 0;
margin: 1ex 0 1ex 0; }
table.index-toc-link td.left { padding: 0 0.5em 0 0.5em;
font-size: 83%;
text-align: left; }
table.index-toc-link td.middle { padding: 0 0.5em 0 0.5em;
font-size: 83%;
text-align: center; }
table.index-toc-link td.right { padding: 0 0.5em 0 0.5em;
font-size: 83%;
text-align: right; }
table.synopsis { margin: 6ex auto 6ex auto;
border: 0;
border-collapse: separate;
border-spacing: 2em 0.6ex; }
table.synopsis tr { padding: 0; }
table.synopsis td { padding: 0; }
table.toc td.link { width: 30%;
text-align: right;
vertical-align: baseline;
padding: 1ex 1em 1ex 0; }
table.toc td.desc { vertical-align: baseline;
padding: 1ex 0 1ex 1em;
text-align: left; }
table.toc td.desc p:first-child { margin: 0;
text-align: left; }
table.toc td.desc p { margin: 1.5ex 0 0 0;
text-align: left; }
</style>
</head>
<body>
"""
html_header_3l = """
<table class="index-toc-link"><tr><td class="left">[<a href="\
"""
html_header_3r = """
<table class="index-toc-link"><tr><td class="right">[<a href="\
"""
html_header_4 = """\
">Index</a>]</td><td class="right">[<a href="\
"""
html_header_5t = """\
">TOC</a>]</td></tr></table>
<h1>\
"""
html_header_5i = """\
">Index</a>]</td></tr></table>
<h1>\
"""
html_header_6 = """\
API Reference</h1>
"""
# The HTML footer used by all generated pages.
html_footer = """\
</body>
</html>\
"""
# The header and footer used for each section.
section_title_header1 = '<h1 id="'
section_title_header2 = '">'
section_title_footer = "</h1>"
# The header and footer used for code segments.
code_header = '<pre class="colored">'
code_footer = '</pre>'
# Paragraph header and footer.
para_header = "<p>"
para_footer = "</p>"
# Block header and footer.
block_header = '<div class="section">'
block_footer_start = """\
<hr>
<table class="index-toc-link"><tr><td class="left">[<a href="\
"""
block_footer_middle = """\
">Index</a>]</td>\
<td class="middle">[<a href="#">Top</a>]</td>\
<td class="right">[<a href="\
"""
block_footer_end = """\
">TOC</a>]</td></tr></table></div>
"""
# Description header/footer.
description_header = ""
description_footer = ""
# Marker header/inter/footer combination.
marker_header = "<h4>"
marker_inter = "</h4>"
marker_footer = ""
# Header location header/footer.
header_location_header = "<p>"
header_location_footer = "</p>"
# Source code extracts header/footer.
source_header = "<pre>"
source_footer = "</pre>"
# Chapter header/inter/footer.
chapter_header = """\
<div class="section">
<h2>\
"""
chapter_inter = '</h2>'
chapter_footer = '</div>'
# Index footer.
index_footer_start = """\
<hr>
<table class="index-toc-link"><tr><td class="right">[<a href="\
"""
index_footer_end = """\
">TOC</a>]</td></tr></table>
"""
# TOC footer.
toc_footer_start = """\
<hr>
<table class="index-toc-link"><tr><td class="left">[<a href="\
"""
toc_footer_end = """\
">Index</a>]</td></tr></table>
"""
# Source language keyword coloration and styling.
keyword_prefix = '<span class="keyword">'
keyword_suffix = '</span>'
section_synopsis_header = '<h2>Synopsis</h2>'
section_synopsis_footer = ''
# Translate a single line of source to HTML. This converts `<', `>', and
# `&' into `<',`>', and `&'.
#
def html_quote( line ):
result = string.replace( line, "&", "&" )
result = string.replace( result, "<", "<" )
result = string.replace( result, ">", ">" )
return result
################################################################
##
## HTML FORMATTER CLASS
##
class HtmlFormatter( Formatter ):
def __init__( self, processor, project_title, file_prefix ):
Formatter.__init__( self, processor )
global html_header_1
global html_header_2
global html_header_3l, html_header_3r
global html_header_4
global html_header_5t, html_header_5i
global html_header_6
global html_footer
if file_prefix:
file_prefix = file_prefix + "-"
else:
file_prefix = ""
self.headers = processor.headers
self.project_title = project_title
self.file_prefix = file_prefix
self.html_header = (
html_header_1 + project_title
+ html_header_2
+ html_header_3l + file_prefix + "index.html"
+ html_header_4 + file_prefix + "toc.html"
+ html_header_5t + project_title
+ html_header_6 )
self.html_index_header = (
html_header_1 + project_title
+ html_header_2
+ html_header_3r + file_prefix + "toc.html"
+ html_header_5t + project_title
+ html_header_6 )
self.html_toc_header = (
html_header_1 + project_title
+ html_header_2
+ html_header_3l + file_prefix + "index.html"
+ html_header_5i + project_title
+ html_header_6 )
self.html_footer = (
'<div class="timestamp">generated on '
+ time.asctime( time.localtime( time.time() ) )
+ "</div>" + html_footer )
self.columns = 3
def make_section_url( self, section ):
return self.file_prefix + section.name + ".html"
def make_block_url( self, block, name = None ):
if name == None:
name = block.name
try:
section_url = self.make_section_url( block.section )
except:
# we already have a section
section_url = self.make_section_url( block )
return section_url + "#" + name
def make_html_word( self, word ):
"""Analyze a simple word to detect cross-references and markup."""
# handle cross-references
m = re_crossref.match( word )
if m:
try:
name = m.group( 'name' )
rest = m.group( 'rest' )
block = self.identifiers[name]
url = self.make_block_url( block )
# display `foo[bar]' as `foo'
name = re.sub( r'\[.*\]', '', name )
# normalize url, following RFC 3986
url = string.replace( url, "[", "(" )
url = string.replace( url, "]", ")" )
try:
# for sections, display title
url = ( '‘<a href="' + url + '">'
+ block.title + '</a>’'
+ rest )
except:
url = ( '<a href="' + url + '">'
+ name + '</a>'
+ rest )
return url
except:
# we detected a cross-reference to an unknown item
sys.stderr.write( "WARNING: undefined cross reference"
+ " '" + name + "'.\n" )
return '?' + name + '?' + rest
# handle markup for italic and bold
m = re_italic.match( word )
if m:
name = m.group( 1 )
rest = m.group( 2 )
return '<i>' + name + '</i>' + rest
m = re_bold.match( word )
if m:
name = m.group( 1 )
rest = m.group( 2 )
return '<b>' + name + '</b>' + rest
return html_quote( word )
def make_html_para( self, words ):
"""Convert words of a paragraph into tagged HTML text. Also handle
cross references."""
line = ""
if words:
line = self.make_html_word( words[0] )
for word in words[1:]:
line = line + " " + self.make_html_word( word )
# handle hyperlinks
line = re_url.sub( r'<a href="\1">\1</a>', line )
# convert `...' quotations into real left and right single quotes
line = re.sub( r"(^|\W)`(.*?)'(\W|$)",
r'\1‘\2’\3',
line )
# convert tilde into non-breakable space
line = string.replace( line, "~", " " )
return para_header + line + para_footer
def make_html_code( self, lines ):
"""Convert a code sequence to HTML."""
line = code_header + '\n'
for l in lines:
line = line + html_quote( l ) + '\n'
return line + code_footer
def make_html_items( self, items ):
"""Convert a field's content into HTML."""
lines = []
for item in items:
if item.lines:
lines.append( self.make_html_code( item.lines ) )
else:
lines.append( self.make_html_para( item.words ) )
return string.join( lines, '\n' )
def print_html_items( self, items ):
print self.make_html_items( items )
def print_html_field( self, field ):
if field.name:
print( '<table><tr valign="top"><td><b>'
+ field.name
+ "</b></td><td>" )
print self.make_html_items( field.items )
if field.name:
print "</td></tr></table>"
def html_source_quote( self, line, block_name = None ):
result = ""
while line:
m = re_source_crossref.match( line )
if m:
name = m.group( 2 )
prefix = html_quote( m.group( 1 ) )
length = len( m.group( 0 ) )
if name == block_name:
# this is the current block name, if any
result = result + prefix + '<b>' + name + '</b>'
elif re_source_keywords.match( name ):
# this is a C keyword
result = ( result + prefix
+ keyword_prefix + name + keyword_suffix )
elif name in self.identifiers:
# this is a known identifier
block = self.identifiers[name]
id = block.name
# link to a field ID if possible
try:
for markup in block.markups:
if markup.tag == 'values':
for field in markup.fields:
if field.name:
id = name
result = ( result + prefix
+ '<a href="'
+ self.make_block_url( block, id )
+ '">' + name + '</a>' )
except:
# sections don't have `markups'; however, we don't
# want references to sections here anyway
result = result + html_quote( line[:length] )
else:
result = result + html_quote( line[:length] )
line = line[length:]
else:
result = result + html_quote( line )
line = []
return result
def print_html_field_list( self, fields ):
print '<table class="fields">'
for field in fields:
print ( '<tr><td class="val" id="' + field.name + '">'
+ field.name
+ '</td><td class="desc">' )
self.print_html_items( field.items )
print "</td></tr>"
print "</table>"
def print_html_markup( self, markup ):
table_fields = []
for field in markup.fields:
if field.name:
# We begin a new series of field or value definitions. We
# record them in the `table_fields' list before outputting
# all of them as a single table.
table_fields.append( field )
else:
if table_fields:
self.print_html_field_list( table_fields )
table_fields = []
self.print_html_items( field.items )
if table_fields:
self.print_html_field_list( table_fields )
#
# formatting the index
#
def index_enter( self ):
print self.html_index_header
self.index_items = {}
def index_name_enter( self, name ):
block = self.identifiers[name]
url = self.make_block_url( block )
self.index_items[name] = url
def index_exit( self ):
# `block_index' already contains the sorted list of index names
count = len( self.block_index )
rows = ( count + self.columns - 1 ) // self.columns
print '<table class="index">'
for r in range( rows ):
line = "<tr>"
for c in range( self.columns ):
i = r + c * rows
if i < count:
bname = self.block_index[r + c * rows]
url = self.index_items[bname]
# display `foo[bar]' as `foo (bar)'
bname = string.replace( bname, "[", " (" )
bname = string.replace( bname, "]", ")" )
# normalize url, following RFC 3986
url = string.replace( url, "[", "(" )
url = string.replace( url, "]", ")" )
line = ( line + '<td><a href="' + url + '">'
+ bname + '</a></td>' )
else:
line = line + '<td></td>'
line = line + "</tr>"
print line
print "</table>"
print( index_footer_start
+ self.file_prefix + "toc.html"
+ index_footer_end )
print self.html_footer
self.index_items = {}
def index_dump( self, index_filename = None ):
if index_filename == None:
index_filename = self.file_prefix + "index.html"
Formatter.index_dump( self, index_filename )
#
# formatting the table of contents
#
def toc_enter( self ):
print self.html_toc_header
print "<h1>Table of Contents</h1>"
def toc_chapter_enter( self, chapter ):
print chapter_header + string.join( chapter.title ) + chapter_inter
print '<table class="toc">'
def toc_section_enter( self, section ):
print ( '<tr><td class="link">'
+ '<a href="' + self.make_section_url( section ) + '">'
+ section.title + '</a></td><td class="desc">' )
print self.make_html_para( section.abstract )
def toc_section_exit( self, section ):
print "</td></tr>"
def toc_chapter_exit( self, chapter ):
print "</table>"
print chapter_footer
def toc_index( self, index_filename ):
print( chapter_header
+ '<a href="' + index_filename + '">Global Index</a>'
+ chapter_inter + chapter_footer )
def toc_exit( self ):
print( toc_footer_start
+ self.file_prefix + "index.html"
+ toc_footer_end )
print self.html_footer
def toc_dump( self, toc_filename = None, index_filename = None ):
if toc_filename == None:
toc_filename = self.file_prefix + "toc.html"
if index_filename == None:
index_filename = self.file_prefix + "index.html"
Formatter.toc_dump( self, toc_filename, index_filename )
#
# formatting sections
#
def section_enter( self, section ):
print self.html_header
print ( section_title_header1 + section.name + section_title_header2
+ section.title
+ section_title_footer )
maxwidth = 0
for b in section.blocks.values():
if len( b.name ) > maxwidth:
maxwidth = len( b.name )
width = 70 # XXX magic number
if maxwidth > 0:
# print section synopsis
print section_synopsis_header
print '<table class="synopsis">'
columns = width // maxwidth
if columns < 1:
columns = 1
count = len( section.block_names )
# don't handle last entry if it is empty
if section.block_names[-1] == "/empty/":
count -= 1
rows = ( count + columns - 1 ) // columns
for r in range( rows ):
line = "<tr>"
for c in range( columns ):
i = r + c * rows
line = line + '<td>'
if i < count:
name = section.block_names[i]
if name == "/empty/":
# it can happen that a complete row is empty, and
# without a proper `filler' the browser might
# collapse the row to a much smaller height (or
# even omit it completely)
line = line + " "
else:
url = name
# display `foo[bar]' as `foo'
name = re.sub( r'\[.*\]', '', name )
# normalize url, following RFC 3986
url = string.replace( url, "[", "(" )
url = string.replace( url, "]", ")" )
line = ( line + '<a href="#' + url + '">'
+ name + '</a>' )
line = line + '</td>'
line = line + "</tr>"
print line
print "</table>"
print section_synopsis_footer
print description_header
print self.make_html_items( section.description )
print description_footer
def block_enter( self, block ):
print block_header
# place html anchor if needed
if block.name:
url = block.name
# display `foo[bar]' as `foo'
name = re.sub( r'\[.*\]', '', block.name )
# normalize url, following RFC 3986
url = string.replace( url, "[", "(" )
url = string.replace( url, "]", ")" )
print( '<h3 id="' + url + '">' + name + '</h3>' )
# dump the block C source lines now
if block.code:
header = ''
for f in self.headers.keys():
if block.source.filename.find( f ) >= 0:
header = self.headers[f] + ' (' + f + ')'
break
# if not header:
# sys.stderr.write(
# "WARNING: No header macro for"
# + " '" + block.source.filename + "'.\n" )
if header:
print ( header_location_header
+ 'Defined in ' + header + '.'
+ header_location_footer )
print source_header
for l in block.code:
print self.html_source_quote( l, block.name )
print source_footer
def markup_enter( self, markup, block ):
if markup.tag == "description":
print description_header
else:
print marker_header + markup.tag + marker_inter
self.print_html_markup( markup )
def markup_exit( self, markup, block ):
if markup.tag == "description":
print description_footer
else:
print marker_footer
def block_exit( self, block ):
print( block_footer_start + self.file_prefix + "index.html"
+ block_footer_middle + self.file_prefix + "toc.html"
+ block_footer_end )
def section_exit( self, section ):
print html_footer
def section_dump_all( self ):
for section in self.sections:
self.section_dump( section,
self.file_prefix + section.name + '.html' )
# eof
|
apache-2.0
|
[
3,
199,
3,
221,
370,
1360,
14,
647,
199,
3,
199,
3,
259,
437,
1007,
13,
533,
3970,
402,
314,
658,
7772,
7,
1021,
370,
7389,
4163,
14,
199,
3,
199,
3,
221,
1898,
14790,
13,
7806,
701,
199,
3,
221,
20232,
16147,
281,
14,
199,
3,
199,
3,
221,
961,
570,
365,
1777,
402,
314,
2868,
804,
2199,
12,
436,
1443,
1454,
506,
1202,
12,
199,
3,
221,
6042,
12,
436,
1854,
1334,
314,
2895,
402,
314,
2868,
804,
2199,
199,
3,
221,
4190,
12,
5113,
14,
17715,
14,
221,
4885,
32620,
370,
675,
12,
2811,
12,
503,
11207,
199,
3,
221,
642,
570,
1265,
6623,
626,
1265,
1172,
1586,
314,
4190,
436,
199,
3,
221,
20647,
436,
4729,
652,
9999,
14,
199,
199,
3,
710,
1676,
1021,
365,
10470,
315,
570,
658,
8911,
14,
647,
1370,
421,
199,
504,
5274,
492,
627,
199,
504,
1564,
492,
627,
199,
504,
9698,
492,
627,
199,
199,
646,
900,
421,
199,
3,
710,
2569,
3326,
5627,
314,
4163,
1406,
1202,
701,
1006,
4046,
6497,
14,
199,
1360,
63,
1291,
63,
17,
275,
9638,
199,
11230,
16556,
4163,
21755,
21486,
55,
19,
35,
501,
21156,
4163,
841,
14,
614,
19894,
1588,
279,
501,
742,
2,
199,
2,
1014,
921,
1544,
14,
87,
19,
14,
1308,
15,
1766,
15,
1360,
20,
15,
320,
3362,
14,
15662,
1743,
199,
28,
1360,
30,
199,
28,
2993,
30,
199,
28,
2024,
1455,
13,
20146,
628,
2714,
13,
804,
2,
1564,
628,
505,
15,
1360,
27,
5960,
29,
1624,
13,
24,
1743,
199,
28,
1213,
3072,
199,
624,
199,
199,
1360,
63,
1291,
63,
18,
275,
9638,
199,
3261,
10944,
1108,
1213,
30,
199,
28,
2487,
730,
628,
505,
15,
3919,
1743,
523,
282,
26,
1073,
469,
3164,
26,
327,
993,
14153,
27,
789,
523,
282,
26,
21736,
469,
3164,
26,
327,
27176,
1299,
37,
27,
789,
523,
282,
26,
22797,
469,
3164,
26,
327,
1665,
993,
27,
789,
819,
2396,
469,
5023,
13,
6606,
26,
5444,
68,
6738,
12,
598,
6349,
3042,
12,
437,
1383,
12,
869,
25911,
12,
542,
20546,
27,
268,
3164,
26,
327,
3273,
27,
268,
8020,
26,
327,
6968,
1665,
27,
268,
3462,
26,
10513,
5,
27,
268,
11042,
26,
2599,
27,
789,
819,
9073,
14,
2792,
469,
3462,
26,
13098,
5,
27,
355,
11042,
26,
2599,
27,
789,
523,
9073,
14,
2792,
16140,
469,
11042,
26,
841,
476,
378,
413,
476,
378,
27,
789,
523,
9073,
14,
2792,
394,
20,
469,
8020,
13,
2326,
26,
327,
8699,
8699,
1665,
27,
673,
5023,
13,
890,
26,
21576,
27,
673,
5023,
13,
2487,
26,
2607,
317,
544,
27,
673,
5023,
13,
3463,
26,
17268,
27,
673,
11042,
26,
650,
476,
378,
413,
14,
21,
476,
1749,
5,
27,
673,
6273,
26,
378,
14,
19,
476,
378,
378,
14,
19,
476,
413,
5,
27,
789,
523,
9073,
14,
2792,
299,
469,
11042,
26,
413,
14,
21,
476,
378,
413,
14,
21,
476,
1616,
5,
27,
789,
523,
9073,
14,
2792,
876,
469,
11042,
26,
650,
476,
378,
650,
476,
1749,
5,
27,
490,
8020,
13,
2326,
26,
327,
36,
22,
37,
24,
1665,
27,
490,
6273,
26,
499,
476,
378,
499,
476,
413,
5,
27,
789,
523,
9073,
14,
2792,
1817,
14,
955,
469,
3462,
26,
9137,
5,
27,
2490,
11042,
26,
413,
14,
21,
476,
378,
413,
14,
21,
476,
1616,
5,
27,
789,
523,
9073,
14,
2792,
1817,
14,
13255,
469,
3462,
26,
16102,
5,
27,
2079,
11042,
26,
413,
14,
21,
476,
378,
413,
14,
21,
476,
959,
5,
27,
789,
523,
9073,
14,
3954,
469,
1318,
13,
5743,
26,
8126,
27,
2116,
5023,
13,
890,
26,
14610,
5,
27,
2116,
11042,
26,
413,
14,
21,
476,
378,
413,
14,
21,
476,
378,
27,
789,
819,
394,
17,
469,
1318,
13,
5743,
26,
8126,
27,
789,
523,
394,
19,
469,
5023,
13,
890,
26,
21576,
27,
2126,
11042,
26,
841,
476,
378,
413,
14,
21,
476,
378,
27,
789,
819,
299,
469,
1318,
13,
5743,
26,
2951,
2021,
27,
789,
819,
876,
14,
331,
21252,
469,
3164,
26,
10030,
27,
789,
819,
13598,
14,
6691,
469,
5023,
13,
6606,
26,
3485,
17601,
27,
326,
1318,
13,
5743,
26,
3602,
27,
326,
10424,
13,
2638,
26,
876,
27,
326,
3164,
26,
23531,
6304,
27,
789,
819,
1817,
14,
955,
12749,
14,
637,
469,
5023,
13,
3463,
26,
17268,
27,
717,
1318,
13,
5743,
26,
2451,
27,
717,
3462,
26,
4233,
5,
27,
717,
13763,
13,
5743,
26,
18828,
27,
717,
6273,
26,
413,
476,
413,
5633,
413,
476,
378,
27,
789,
523,
1817,
14,
955,
12749,
14,
3257,
469,
13763,
13,
5743,
26,
18828,
27,
586,
6273,
26,
413,
476,
378,
413,
476,
413,
5633,
27,
789,
523,
1817,
14,
955,
12749,
14,
3257,
299,
26,
2246,
13,
1739,
469,
11042,
26,
378,
27,
789,
523,
1817,
14,
955,
12749,
14,
3257,
299,
469,
11042,
26,
413,
14,
21,
476,
378,
378,
378,
27,
789,
523,
1817,
14,
1080,
469,
11042,
26,
1227,
476,
2599,
1227,
476,
2599,
27,
355,
9162,
26,
378,
27,
355,
9162,
13,
20681,
26,
7396,
27,
355,
9162,
13,
15880,
26,
413,
5633,
378,
14,
19,
476,
27,
789,
523,
1817,
14,
1080,
5651,
469,
6273,
26,
378,
27,
789,
523,
1817,
14,
1080,
12749,
469,
6273,
26,
378,
27,
789,
523,
1817,
14,
1080,
13,
13255,
13,
1073,
469,
3462,
26,
2948,
5,
27,
586,
9162,
26,
378,
27,
586,
9162,
13,
15880,
26,
378,
27,
586,
11042,
26,
413,
476,
378,
413,
476,
378,
27,
789,
523,
1817,
14,
1080,
13,
13255,
13,
1073,
12749,
14,
3039,
469,
6273,
26,
378,
378,
14,
21,
5633,
378,
378,
14,
21,
5633,
27,
639,
5023,
13,
890,
26,
20582,
5,
27,
639,
1318,
13,
5743,
26,
3602,
27,
789,
523,
1817,
14,
1080,
13,
13255,
13,
1073,
12749,
14,
14885,
469,
6273,
26,
378,
378,
14,
21,
5633,
378,
378,
14,
21,
5633,
27,
3521,
5023,
13,
890,
26,
20582,
5,
27,
3521,
1318,
13,
5743,
26,
8126,
27,
789,
523,
1817,
14,
1080,
13,
13255,
13,
1073,
12749,
14,
1019,
469,
6273,
26,
378,
378,
14,
21,
5633,
378,
378
] |
[
199,
3,
221,
370,
1360,
14,
647,
199,
3,
199,
3,
259,
437,
1007,
13,
533,
3970,
402,
314,
658,
7772,
7,
1021,
370,
7389,
4163,
14,
199,
3,
199,
3,
221,
1898,
14790,
13,
7806,
701,
199,
3,
221,
20232,
16147,
281,
14,
199,
3,
199,
3,
221,
961,
570,
365,
1777,
402,
314,
2868,
804,
2199,
12,
436,
1443,
1454,
506,
1202,
12,
199,
3,
221,
6042,
12,
436,
1854,
1334,
314,
2895,
402,
314,
2868,
804,
2199,
199,
3,
221,
4190,
12,
5113,
14,
17715,
14,
221,
4885,
32620,
370,
675,
12,
2811,
12,
503,
11207,
199,
3,
221,
642,
570,
1265,
6623,
626,
1265,
1172,
1586,
314,
4190,
436,
199,
3,
221,
20647,
436,
4729,
652,
9999,
14,
199,
199,
3,
710,
1676,
1021,
365,
10470,
315,
570,
658,
8911,
14,
647,
1370,
421,
199,
504,
5274,
492,
627,
199,
504,
1564,
492,
627,
199,
504,
9698,
492,
627,
199,
199,
646,
900,
421,
199,
3,
710,
2569,
3326,
5627,
314,
4163,
1406,
1202,
701,
1006,
4046,
6497,
14,
199,
1360,
63,
1291,
63,
17,
275,
9638,
199,
11230,
16556,
4163,
21755,
21486,
55,
19,
35,
501,
21156,
4163,
841,
14,
614,
19894,
1588,
279,
501,
742,
2,
199,
2,
1014,
921,
1544,
14,
87,
19,
14,
1308,
15,
1766,
15,
1360,
20,
15,
320,
3362,
14,
15662,
1743,
199,
28,
1360,
30,
199,
28,
2993,
30,
199,
28,
2024,
1455,
13,
20146,
628,
2714,
13,
804,
2,
1564,
628,
505,
15,
1360,
27,
5960,
29,
1624,
13,
24,
1743,
199,
28,
1213,
3072,
199,
624,
199,
199,
1360,
63,
1291,
63,
18,
275,
9638,
199,
3261,
10944,
1108,
1213,
30,
199,
28,
2487,
730,
628,
505,
15,
3919,
1743,
523,
282,
26,
1073,
469,
3164,
26,
327,
993,
14153,
27,
789,
523,
282,
26,
21736,
469,
3164,
26,
327,
27176,
1299,
37,
27,
789,
523,
282,
26,
22797,
469,
3164,
26,
327,
1665,
993,
27,
789,
819,
2396,
469,
5023,
13,
6606,
26,
5444,
68,
6738,
12,
598,
6349,
3042,
12,
437,
1383,
12,
869,
25911,
12,
542,
20546,
27,
268,
3164,
26,
327,
3273,
27,
268,
8020,
26,
327,
6968,
1665,
27,
268,
3462,
26,
10513,
5,
27,
268,
11042,
26,
2599,
27,
789,
819,
9073,
14,
2792,
469,
3462,
26,
13098,
5,
27,
355,
11042,
26,
2599,
27,
789,
523,
9073,
14,
2792,
16140,
469,
11042,
26,
841,
476,
378,
413,
476,
378,
27,
789,
523,
9073,
14,
2792,
394,
20,
469,
8020,
13,
2326,
26,
327,
8699,
8699,
1665,
27,
673,
5023,
13,
890,
26,
21576,
27,
673,
5023,
13,
2487,
26,
2607,
317,
544,
27,
673,
5023,
13,
3463,
26,
17268,
27,
673,
11042,
26,
650,
476,
378,
413,
14,
21,
476,
1749,
5,
27,
673,
6273,
26,
378,
14,
19,
476,
378,
378,
14,
19,
476,
413,
5,
27,
789,
523,
9073,
14,
2792,
299,
469,
11042,
26,
413,
14,
21,
476,
378,
413,
14,
21,
476,
1616,
5,
27,
789,
523,
9073,
14,
2792,
876,
469,
11042,
26,
650,
476,
378,
650,
476,
1749,
5,
27,
490,
8020,
13,
2326,
26,
327,
36,
22,
37,
24,
1665,
27,
490,
6273,
26,
499,
476,
378,
499,
476,
413,
5,
27,
789,
523,
9073,
14,
2792,
1817,
14,
955,
469,
3462,
26,
9137,
5,
27,
2490,
11042,
26,
413,
14,
21,
476,
378,
413,
14,
21,
476,
1616,
5,
27,
789,
523,
9073,
14,
2792,
1817,
14,
13255,
469,
3462,
26,
16102,
5,
27,
2079,
11042,
26,
413,
14,
21,
476,
378,
413,
14,
21,
476,
959,
5,
27,
789,
523,
9073,
14,
3954,
469,
1318,
13,
5743,
26,
8126,
27,
2116,
5023,
13,
890,
26,
14610,
5,
27,
2116,
11042,
26,
413,
14,
21,
476,
378,
413,
14,
21,
476,
378,
27,
789,
819,
394,
17,
469,
1318,
13,
5743,
26,
8126,
27,
789,
523,
394,
19,
469,
5023,
13,
890,
26,
21576,
27,
2126,
11042,
26,
841,
476,
378,
413,
14,
21,
476,
378,
27,
789,
819,
299,
469,
1318,
13,
5743,
26,
2951,
2021,
27,
789,
819,
876,
14,
331,
21252,
469,
3164,
26,
10030,
27,
789,
819,
13598,
14,
6691,
469,
5023,
13,
6606,
26,
3485,
17601,
27,
326,
1318,
13,
5743,
26,
3602,
27,
326,
10424,
13,
2638,
26,
876,
27,
326,
3164,
26,
23531,
6304,
27,
789,
819,
1817,
14,
955,
12749,
14,
637,
469,
5023,
13,
3463,
26,
17268,
27,
717,
1318,
13,
5743,
26,
2451,
27,
717,
3462,
26,
4233,
5,
27,
717,
13763,
13,
5743,
26,
18828,
27,
717,
6273,
26,
413,
476,
413,
5633,
413,
476,
378,
27,
789,
523,
1817,
14,
955,
12749,
14,
3257,
469,
13763,
13,
5743,
26,
18828,
27,
586,
6273,
26,
413,
476,
378,
413,
476,
413,
5633,
27,
789,
523,
1817,
14,
955,
12749,
14,
3257,
299,
26,
2246,
13,
1739,
469,
11042,
26,
378,
27,
789,
523,
1817,
14,
955,
12749,
14,
3257,
299,
469,
11042,
26,
413,
14,
21,
476,
378,
378,
378,
27,
789,
523,
1817,
14,
1080,
469,
11042,
26,
1227,
476,
2599,
1227,
476,
2599,
27,
355,
9162,
26,
378,
27,
355,
9162,
13,
20681,
26,
7396,
27,
355,
9162,
13,
15880,
26,
413,
5633,
378,
14,
19,
476,
27,
789,
523,
1817,
14,
1080,
5651,
469,
6273,
26,
378,
27,
789,
523,
1817,
14,
1080,
12749,
469,
6273,
26,
378,
27,
789,
523,
1817,
14,
1080,
13,
13255,
13,
1073,
469,
3462,
26,
2948,
5,
27,
586,
9162,
26,
378,
27,
586,
9162,
13,
15880,
26,
378,
27,
586,
11042,
26,
413,
476,
378,
413,
476,
378,
27,
789,
523,
1817,
14,
1080,
13,
13255,
13,
1073,
12749,
14,
3039,
469,
6273,
26,
378,
378,
14,
21,
5633,
378,
378,
14,
21,
5633,
27,
639,
5023,
13,
890,
26,
20582,
5,
27,
639,
1318,
13,
5743,
26,
3602,
27,
789,
523,
1817,
14,
1080,
13,
13255,
13,
1073,
12749,
14,
14885,
469,
6273,
26,
378,
378,
14,
21,
5633,
378,
378,
14,
21,
5633,
27,
3521,
5023,
13,
890,
26,
20582,
5,
27,
3521,
1318,
13,
5743,
26,
8126,
27,
789,
523,
1817,
14,
1080,
13,
13255,
13,
1073,
12749,
14,
1019,
469,
6273,
26,
378,
378,
14,
21,
5633,
378,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
vntarasov/openpilot
|
selfdrive/crash.py
|
1
|
2009
|
"""Install exception handler for process crash."""
import os
import sys
import threading
import capnp
from selfdrive.version import version, dirty
from selfdrive.swaglog import cloudlog
from common.hardware import PC
if os.getenv("NOLOG") or os.getenv("NOCRASH") or PC:
def capture_exception(*args, **kwargs):
pass
def bind_user(**kwargs):
pass
def bind_extra(**kwargs):
pass
def install():
pass
else:
from raven import Client
from raven.transport.http import HTTPTransport
client = Client('https://1994756b5e6f41cf939a4c65de45f4f2:cefebaf3a8aa40d182609785f7189bd7@app.getsentry.com/77924',
install_sys_hook=False, transport=HTTPTransport, release=version, tags={'dirty': dirty})
def capture_exception(*args, **kwargs):
exc_info = sys.exc_info()
if not exc_info[0] is capnp.lib.capnp.KjException:
client.captureException(*args, **kwargs)
cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))
def bind_user(**kwargs):
client.user_context(kwargs)
def bind_extra(**kwargs):
client.extra_context(kwargs)
def install():
"""
Workaround for `sys.excepthook` thread bug from:
http://bugs.python.org/issue1230540
Call once from the main thread before creating any threads.
Source: https://stackoverflow.com/a/31622038
"""
# installs a sys.excepthook
__excepthook__ = sys.excepthook
def handle_exception(*exc_info):
if exc_info[0] not in (KeyboardInterrupt, SystemExit):
capture_exception()
__excepthook__(*exc_info)
sys.excepthook = handle_exception
init_original = threading.Thread.__init__
def init(self, *args, **kwargs):
init_original(self, *args, **kwargs)
run_original = self.run
def run_with_except_hook(*args2, **kwargs2):
try:
run_original(*args2, **kwargs2)
except Exception:
sys.excepthook(*sys.exc_info())
self.run = run_with_except_hook
threading.Thread.__init__ = init
|
mit
|
[
624,
8154,
1919,
3016,
367,
2112,
12420,
1041,
199,
646,
747,
199,
646,
984,
199,
646,
5796,
199,
646,
4021,
1590,
199,
504,
291,
9541,
14,
1023,
492,
1015,
12,
14650,
199,
199,
504,
291,
9541,
14,
3519,
643,
793,
492,
8002,
793,
199,
504,
2863,
14,
16529,
492,
510,
35,
199,
199,
692,
747,
14,
12959,
480,
31798,
531,
503,
747,
14,
12959,
480,
2826,
2944,
8100,
531,
503,
510,
35,
26,
523,
347,
12296,
63,
1971,
2031,
589,
12,
1011,
958,
304,
272,
986,
819,
347,
5398,
63,
751,
3682,
958,
304,
272,
986,
819,
347,
5398,
63,
2911,
3682,
958,
304,
272,
986,
819,
347,
3907,
837,
272,
986,
199,
2836,
26,
523,
687,
660,
1856,
492,
6810,
523,
687,
660,
1856,
14,
5545,
14,
1014,
492,
3101,
7836,
523,
1890,
275,
6810,
360,
2859,
921,
7155,
2417,
1367,
66,
21,
69,
22,
70,
2953,
2177,
31281,
65,
20,
67,
2182,
271,
2322,
70,
20,
70,
18,
26,
301,
771,
25485,
19,
65,
24,
2158,
2167,
68,
1085,
1479,
1643,
19312,
70,
23,
11370,
3691,
23,
32,
571,
14,
362,
3870,
14,
957,
15,
14580,
1194,
297,
2116,
3907,
63,
1274,
63,
3664,
29,
797,
12,
7773,
29,
2856,
7836,
12,
4683,
29,
1023,
12,
3762,
3713,
8799,
356,
14650,
1552,
819,
347,
12296,
63,
1971,
2031,
589,
12,
1011,
958,
304,
272,
3178,
63,
815,
275,
984,
14,
2804,
63,
815,
342,
272,
340,
440,
3178,
63,
815,
59,
16,
61,
365,
4021,
1590,
14,
773,
14,
2874,
1590,
14,
43,
74,
1726,
26,
489,
1890,
14,
12685,
1726,
2031,
589,
12,
1011,
958,
9,
272,
8002,
793,
14,
705,
480,
14807,
401,
3178,
63,
815,
29,
958,
14,
362,
360,
2804,
63,
815,
297,
413,
430,
819,
347,
5398,
63,
751,
3682,
958,
304,
272,
1890,
14,
751,
63,
1100,
8,
958,
9,
819,
347,
5398,
63,
2911,
3682,
958,
304,
272,
1890,
14,
2911,
63,
1100,
8,
958,
9,
819,
347,
3907,
837,
272,
408,
272,
9361,
11659,
367,
658,
1274,
14,
476,
301,
13316,
6992,
64,
2462,
6519,
687,
26,
272,
1455,
921,
13017,
14,
1548,
14,
1308,
15,
5237,
713,
1216,
17814,
272,
6523,
5403,
687,
314,
2446,
2462,
2544,
6425,
1263,
7183,
14,
272,
5800,
26,
4178,
921,
23153,
14,
957,
15,
65,
15,
21376,
1081,
14273,
272,
408,
272,
327,
25801,
282,
984,
14,
476,
301,
13316,
6992,
272,
636,
476,
301,
13316,
6992,
363,
275,
984,
14,
476,
301,
13316,
6992,
339,
347,
2429,
63,
1971,
2031,
2804,
63,
815,
304,
489,
340,
3178,
63,
815,
59,
16,
61,
440,
315,
334,
31538,
12,
14838,
304,
267,
12296,
63,
1971,
342,
489,
636,
476,
301,
13316,
6992,
9308,
2804,
63,
815,
9,
272,
984,
14,
476,
301,
13316,
6992,
275,
2429,
63,
1971,
339,
4205,
63,
5043,
275,
5796,
14,
4436,
855,
826,
363,
339,
347,
4205,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
489,
4205,
63,
5043,
8,
277,
12,
627,
589,
12,
1011,
958,
9,
489,
1255,
63,
5043,
275,
291,
14,
1065,
2541,
347,
1255,
63,
1045,
63,
2590,
63,
3664,
2031,
589,
18,
12,
1011,
958,
18,
304,
267,
862,
26,
881,
1255,
63,
5043,
2031,
589,
18,
12,
1011,
958,
18,
9,
267,
871,
2186,
26,
881,
984,
14,
476,
301,
13316,
6992,
2031,
1274,
14,
2804,
63,
815,
1012,
2541,
291,
14,
1065,
275,
1255,
63,
1045,
63,
2590,
63,
3664,
339,
5796,
14,
4436,
855,
826,
363,
275,
4205,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
8154,
1919,
3016,
367,
2112,
12420,
1041,
199,
646,
747,
199,
646,
984,
199,
646,
5796,
199,
646,
4021,
1590,
199,
504,
291,
9541,
14,
1023,
492,
1015,
12,
14650,
199,
199,
504,
291,
9541,
14,
3519,
643,
793,
492,
8002,
793,
199,
504,
2863,
14,
16529,
492,
510,
35,
199,
199,
692,
747,
14,
12959,
480,
31798,
531,
503,
747,
14,
12959,
480,
2826,
2944,
8100,
531,
503,
510,
35,
26,
523,
347,
12296,
63,
1971,
2031,
589,
12,
1011,
958,
304,
272,
986,
819,
347,
5398,
63,
751,
3682,
958,
304,
272,
986,
819,
347,
5398,
63,
2911,
3682,
958,
304,
272,
986,
819,
347,
3907,
837,
272,
986,
199,
2836,
26,
523,
687,
660,
1856,
492,
6810,
523,
687,
660,
1856,
14,
5545,
14,
1014,
492,
3101,
7836,
523,
1890,
275,
6810,
360,
2859,
921,
7155,
2417,
1367,
66,
21,
69,
22,
70,
2953,
2177,
31281,
65,
20,
67,
2182,
271,
2322,
70,
20,
70,
18,
26,
301,
771,
25485,
19,
65,
24,
2158,
2167,
68,
1085,
1479,
1643,
19312,
70,
23,
11370,
3691,
23,
32,
571,
14,
362,
3870,
14,
957,
15,
14580,
1194,
297,
2116,
3907,
63,
1274,
63,
3664,
29,
797,
12,
7773,
29,
2856,
7836,
12,
4683,
29,
1023,
12,
3762,
3713,
8799,
356,
14650,
1552,
819,
347,
12296,
63,
1971,
2031,
589,
12,
1011,
958,
304,
272,
3178,
63,
815,
275,
984,
14,
2804,
63,
815,
342,
272,
340,
440,
3178,
63,
815,
59,
16,
61,
365,
4021,
1590,
14,
773,
14,
2874,
1590,
14,
43,
74,
1726,
26,
489,
1890,
14,
12685,
1726,
2031,
589,
12,
1011,
958,
9,
272,
8002,
793,
14,
705,
480,
14807,
401,
3178,
63,
815,
29,
958,
14,
362,
360,
2804,
63,
815,
297,
413,
430,
819,
347,
5398,
63,
751,
3682,
958,
304,
272,
1890,
14,
751,
63,
1100,
8,
958,
9,
819,
347,
5398,
63,
2911,
3682,
958,
304,
272,
1890,
14,
2911,
63,
1100,
8,
958,
9,
819,
347,
3907,
837,
272,
408,
272,
9361,
11659,
367,
658,
1274,
14,
476,
301,
13316,
6992,
64,
2462,
6519,
687,
26,
272,
1455,
921,
13017,
14,
1548,
14,
1308,
15,
5237,
713,
1216,
17814,
272,
6523,
5403,
687,
314,
2446,
2462,
2544,
6425,
1263,
7183,
14,
272,
5800,
26,
4178,
921,
23153,
14,
957,
15,
65,
15,
21376,
1081,
14273,
272,
408,
272,
327,
25801,
282,
984,
14,
476,
301,
13316,
6992,
272,
636,
476,
301,
13316,
6992,
363,
275,
984,
14,
476,
301,
13316,
6992,
339,
347,
2429,
63,
1971,
2031,
2804,
63,
815,
304,
489,
340,
3178,
63,
815,
59,
16,
61,
440,
315,
334,
31538,
12,
14838,
304,
267,
12296,
63,
1971,
342,
489,
636,
476,
301,
13316,
6992,
9308,
2804,
63,
815,
9,
272,
984,
14,
476,
301,
13316,
6992,
275,
2429,
63,
1971,
339,
4205,
63,
5043,
275,
5796,
14,
4436,
855,
826,
363,
339,
347,
4205,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
489,
4205,
63,
5043,
8,
277,
12,
627,
589,
12,
1011,
958,
9,
489,
1255,
63,
5043,
275,
291,
14,
1065,
2541,
347,
1255,
63,
1045,
63,
2590,
63,
3664,
2031,
589,
18,
12,
1011,
958,
18,
304,
267,
862,
26,
881,
1255,
63,
5043,
2031,
589,
18,
12,
1011,
958,
18,
9,
267,
871,
2186,
26,
881,
984,
14,
476,
301,
13316,
6992,
2031,
1274,
14,
2804,
63,
815,
1012,
2541,
291,
14,
1065,
275,
1255,
63,
1045,
63,
2590,
63,
3664,
339,
5796,
14,
4436,
855,
826,
363,
275,
4205,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
netfoo/volatility
|
volatility/registry.py
|
57
|
6699
|
# Volatility
# Copyright (C) 2007-2013 Volatility Foundation
#
# Derived from source in PyFlag developed by:
# Copyright 2004: Commonwealth of Australia.
# Michael Cohen <scudette@users.sourceforge.net>
# David Collett <daveco@users.sourceforge.net>
#
# Subclassing plugin code developed by:
#
# Mike Auty <mike.auty@gmail.com>
#
# ******************************************************
# Version: FLAG $Version: 0.84RC4 Date: Wed May 30 20:48:31 EST 2007$
# ******************************************************
#
# * 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
# *****************************************************
#pylint: disable-msg=C0111
""" This module implements a class registry.
We scan the memory_plugins directory for all python files and add those
classes which should be registered into their own lookup tables. These
are then ordered as required. The rest of Volatility will then call onto the
registered classes when needed.
This mechanism allows us to reorganise the code according to
functionality. For example we may include a Scanner, Report and File
classes in the same plugin and have them all automatically loaded.
"""
import os, zipfile
import volatility.debug as debug
import volatility.plugins as plugins
class PluginImporter(object):
"""This class searches through a comma-separated list of plugins and
imports all classes found, based on their path and a fixed prefix.
"""
def __init__(self):
"""Gathers all the plugins from config.PLUGINS
Determines their namespaces and maintains a dictionary of modules to filepaths
Then imports all modules found
"""
self.modnames = {}
# Handle additional plugins
for path in plugins.__path__:
path = os.path.abspath(path)
for relfile in self.walkzip(path):
module_path, ext = os.path.splitext(relfile)
namespace = ".".join(['volatility.plugins'] + [ x for x in module_path.split(os.path.sep) if x ])
#Lose the extension for the module name
if ext in [".py", ".pyc", ".pyo"]:
filepath = os.path.join(path, relfile)
# Handle Init files
initstr = '.__init__'
if namespace.endswith(initstr):
self.modnames[namespace[:-len(initstr)]] = filepath
else:
self.modnames[namespace] = filepath
self.run_imports()
def walkzip(self, path):
"""Walks a path independent of whether it includes a zipfile or not"""
if os.path.exists(path) and os.path.isdir(path):
for dirpath, _dirnames, filenames in os.walk(path):
for filename in filenames:
# Run through files as we always used to
yield os.path.join(dirpath[len(path) + len(os.path.sep):], filename)
else:
index = -1
zippath = None
while path.find(os.path.sep, index + 1) > -1:
index = path.find(os.path.sep, index + 1)
if zipfile.is_zipfile(path[:index]):
zippath = path[:index]
break
else:
if zipfile.is_zipfile(path):
zippath = path
# Now yield the files
if zippath:
zipf = zipfile.ZipFile(zippath)
prefix = path[len(zippath):].strip(os.path.sep)
# If there's a prefix, ensure it ends in a slash
if len(prefix):
prefix += os.path.sep
for fn in zipf.namelist():
# Zipfiles seem to always list contents using / as their separator
fn = fn.replace('/', os.path.sep)
if fn.startswith(prefix) and not fn.endswith(os.path.sep):
# We're a file in the zipfile
yield fn[len(prefix):]
def run_imports(self):
"""Imports all the already found modules"""
for i in self.modnames.keys():
if self.modnames[i] is not None:
try:
__import__(i)
except Exception, e:
print "*** Failed to import " + i + " (" + str(e.__class__.__name__) + ": " + str(e) + ")"
# This is too early to have had the debug filter lowered to include debugging messages
debug.post_mortem(2)
def _get_subclasses(cls):
""" Run through subclasses of a particular class
This returns all classes descended from the main class,
_including_ the main class itself. If showall is set to
False (the default) then classes starting with Abstract
will not be returned.
"""
for i in cls.__subclasses__():
for c in _get_subclasses(i):
yield c
yield cls
def get_plugin_classes(cls, showall = False, lower = False):
"""Returns a dictionary of plugins"""
# Plugins all make use of the Abstract concept
result = {}
for plugin in set(_get_subclasses(cls)):
if showall or not (plugin.__name__.startswith("Abstract") or plugin == cls):
# FIXME: This is due to not having done things correctly at the start
if not showall and plugin.__name__ in ['BufferAddressSpace', 'HiveFileAddressSpace', 'HiveAddressSpace']:
continue
name = plugin.__name__.split('.')[-1]
if lower:
name = name.lower()
if name not in result:
result[name] = plugin
else:
raise Exception("Object {0} has already been defined by {1}".format(name, plugin))
return result
def register_global_options(config, cls):
## Register all register_options for the various classes
for m in get_plugin_classes(cls, True).values():
if hasattr(m, 'register_options'):
m.register_options(config)
|
gpl-2.0
|
[
3,
28367,
199,
3,
1898,
334,
35,
9,
10219,
13,
6965,
28367,
2752,
199,
3,
199,
3,
27731,
687,
1350,
315,
1611,
5318,
477,
27813,
701,
26,
199,
3,
1898,
8353,
26,
13964,
1129,
6130,
402,
437,
22306,
14,
199,
3,
16922,
1849,
16800,
665,
551,
3786,
14586,
32,
3707,
14,
22943,
14,
846,
30,
221,
199,
3,
20232,
3626,
22784,
665,
68,
811,
331,
32,
3707,
14,
22943,
14,
846,
30,
199,
3,
199,
3,
30184,
316,
3589,
1233,
477,
27813,
701,
26,
199,
3,
199,
3,
603,
7455,
437,
19974,
665,
2664,
415,
14,
6898,
89,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
1011,
5815,
3096,
1116,
199,
3,
221,
3394,
26,
11031,
2672,
3353,
26,
378,
14,
1349,
8205,
20,
6148,
26,
644,
379,
10162,
4233,
3388,
26,
2006,
26,
2192,
221,
1719,
10219,
4,
199,
3,
1011,
5815,
3096,
1116,
199,
3,
199,
3,
627,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
627,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
627,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
627,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
627,
199,
3,
627,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
627,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
627,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
627,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
627,
199,
3,
627,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
627,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
627,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
199,
3,
1011,
5815,
3096,
9153,
199,
199,
3,
26324,
26,
3507,
13,
1328,
29,
35,
28107,
199,
199,
624,
961,
859,
9031,
282,
1021,
7086,
14,
199,
199,
6004,
8000,
314,
4402,
63,
5265,
2082,
367,
1006,
2366,
1584,
436,
1050,
5204,
199,
2888,
1314,
1077,
506,
7264,
1901,
3932,
5705,
4237,
6716,
14,
5723,
199,
1530,
2066,
7741,
465,
1415,
14,
710,
4618,
402,
28367,
911,
2066,
1240,
14602,
314,
199,
11616,
3992,
1380,
4346,
14,
199,
199,
2765,
14729,
6127,
2739,
370,
295,
19916,
572,
314,
1233,
7182,
370,
199,
1593,
6712,
14,
2104,
2893,
781,
1443,
2387,
282,
28628,
12,
11774,
436,
3814,
199,
2888,
315,
314,
2011,
3589,
436,
1172,
3062,
1006,
5847,
6511,
14,
199,
624,
199,
199,
646,
747,
12,
10392,
199,
646,
5236,
18783,
14,
1757,
465,
3105,
199,
646,
5236,
18783,
14,
5265,
465,
8963,
199,
199,
533,
11349,
18484,
8,
785,
304,
272,
408,
2765,
1021,
21858,
4012,
282,
10029,
13,
12794,
769,
402,
8963,
436,
2126,
8925,
1006,
3992,
1911,
12,
4079,
641,
3932,
931,
436,
282,
6317,
2403,
14,
272,
408,
272,
347,
636,
826,
721,
277,
304,
267,
408,
39,
7404,
83,
1006,
314,
8963,
687,
1101,
14,
16483,
10789,
1779,
22391,
3932,
10747,
436,
11075,
83,
282,
2600,
402,
4621,
370,
570,
3771,
1779,
9442,
8925,
1006,
4621,
1911,
267,
408,
267,
291,
14,
1494,
1247,
275,
1052,
398,
327,
8690,
4722,
8963,
267,
367,
931,
315,
8963,
855,
515,
10651,
288,
931,
275,
747,
14,
515,
14,
4832,
8,
515,
9,
953,
367,
295,
12059,
315,
291,
14,
7757,
3065,
8,
515,
304,
355,
859,
63,
515,
12,
1599,
275,
747,
14,
515,
14,
7973,
8,
264,
12059,
9,
355,
3231,
275,
32443,
904,
2941,
5650,
18783,
14,
5265,
418,
435,
359,
671,
367,
671,
315,
859,
63,
515,
14,
1294,
8,
736,
14,
515,
14,
4127,
9,
340,
671,
4794,
355,
327,
2041,
261,
314,
3329,
367,
314,
859,
536,
355,
340,
1599,
315,
359,
1674,
647,
401,
3680,
11357,
401,
3680,
22345,
6229,
490,
9911,
275,
747,
14,
515,
14,
904,
8,
515,
12,
295,
12059,
9,
490,
327,
8690,
21026,
1584,
490,
4205,
495,
275,
283,
855,
826,
12217,
490,
340,
3231,
14,
4130,
8,
826,
495,
304,
717,
291,
14,
1494,
1247,
59,
3251,
4439,
552,
8,
826,
495,
1874,
61,
275,
9911,
490,
587,
26,
717,
291,
14,
1494,
1247,
59,
3251,
61,
275,
9911,
398,
291,
14,
1065,
63,
12775,
342,
339,
347,
12778,
3065,
8,
277,
12,
931,
304,
267,
408,
31491,
83,
282,
931,
12717,
402,
3775,
652,
6952,
282,
10392,
503,
440,
624,
267,
340,
747,
14,
515,
14,
2444,
8,
515,
9,
436,
747,
14,
515,
14,
6027,
8,
515,
304,
288,
367,
20648,
12,
485,
694,
1247,
12,
6203,
315,
747,
14,
7757,
8,
515,
304,
355,
367,
1788,
315,
6203,
26,
490,
327,
3378,
4012,
1584,
465,
781,
3544,
1202,
370,
490,
1995,
747,
14,
515,
14,
904,
8,
17254,
59,
552,
8,
515,
9,
435,
822,
8,
736,
14,
515,
14,
4127,
304,
467,
1788,
9,
267,
587,
26,
288,
1478,
275,
446,
17,
288,
3482,
515,
275,
488,
288,
1830,
931,
14,
1623,
8,
736,
14,
515,
14,
4127,
12,
1478,
435,
413,
9,
690,
446,
17,
26,
355,
1478,
275,
931,
14,
1623,
8,
736,
14,
515,
14,
4127,
12,
1478,
435,
413,
9,
355,
340,
10392,
14,
374,
63,
18717,
8,
515,
1491,
1080,
4682,
490,
3482,
515,
275,
931,
1491,
1080,
61,
490,
2059,
288,
587,
26,
355,
340,
10392,
14,
374,
63,
18717,
8,
515,
304,
490,
3482,
515,
275,
931,
953,
327,
7356,
1995,
314,
1584,
288,
340,
3482,
515,
26,
355,
3482,
70,
275,
10392,
14,
15016,
8,
3065,
515,
9,
355,
2403,
275,
931,
59,
552,
8,
3065,
515,
304,
1055,
1913,
8,
736,
14,
515,
14,
4127,
9,
355,
327,
982,
2337,
1159,
282,
2403,
12,
4868,
652,
11187,
315,
282,
14457,
355,
340,
822,
8,
1861,
304,
490,
2403,
847,
747,
14,
515,
14,
4127,
355,
367,
4325,
315,
3482,
70,
14,
23841,
837,
490,
327,
16688,
1725,
17021,
370,
3544,
769,
4072,
1808,
1182,
465,
3932,
9432,
490,
4325,
275,
4325,
14,
1814
] |
[
28367,
199,
3,
1898,
334,
35,
9,
10219,
13,
6965,
28367,
2752,
199,
3,
199,
3,
27731,
687,
1350,
315,
1611,
5318,
477,
27813,
701,
26,
199,
3,
1898,
8353,
26,
13964,
1129,
6130,
402,
437,
22306,
14,
199,
3,
16922,
1849,
16800,
665,
551,
3786,
14586,
32,
3707,
14,
22943,
14,
846,
30,
221,
199,
3,
20232,
3626,
22784,
665,
68,
811,
331,
32,
3707,
14,
22943,
14,
846,
30,
199,
3,
199,
3,
30184,
316,
3589,
1233,
477,
27813,
701,
26,
199,
3,
199,
3,
603,
7455,
437,
19974,
665,
2664,
415,
14,
6898,
89,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
1011,
5815,
3096,
1116,
199,
3,
221,
3394,
26,
11031,
2672,
3353,
26,
378,
14,
1349,
8205,
20,
6148,
26,
644,
379,
10162,
4233,
3388,
26,
2006,
26,
2192,
221,
1719,
10219,
4,
199,
3,
1011,
5815,
3096,
1116,
199,
3,
199,
3,
627,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
627,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
627,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
627,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
627,
199,
3,
627,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
627,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
627,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
627,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
627,
199,
3,
627,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
627,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
627,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
199,
3,
1011,
5815,
3096,
9153,
199,
199,
3,
26324,
26,
3507,
13,
1328,
29,
35,
28107,
199,
199,
624,
961,
859,
9031,
282,
1021,
7086,
14,
199,
199,
6004,
8000,
314,
4402,
63,
5265,
2082,
367,
1006,
2366,
1584,
436,
1050,
5204,
199,
2888,
1314,
1077,
506,
7264,
1901,
3932,
5705,
4237,
6716,
14,
5723,
199,
1530,
2066,
7741,
465,
1415,
14,
710,
4618,
402,
28367,
911,
2066,
1240,
14602,
314,
199,
11616,
3992,
1380,
4346,
14,
199,
199,
2765,
14729,
6127,
2739,
370,
295,
19916,
572,
314,
1233,
7182,
370,
199,
1593,
6712,
14,
2104,
2893,
781,
1443,
2387,
282,
28628,
12,
11774,
436,
3814,
199,
2888,
315,
314,
2011,
3589,
436,
1172,
3062,
1006,
5847,
6511,
14,
199,
624,
199,
199,
646,
747,
12,
10392,
199,
646,
5236,
18783,
14,
1757,
465,
3105,
199,
646,
5236,
18783,
14,
5265,
465,
8963,
199,
199,
533,
11349,
18484,
8,
785,
304,
272,
408,
2765,
1021,
21858,
4012,
282,
10029,
13,
12794,
769,
402,
8963,
436,
2126,
8925,
1006,
3992,
1911,
12,
4079,
641,
3932,
931,
436,
282,
6317,
2403,
14,
272,
408,
272,
347,
636,
826,
721,
277,
304,
267,
408,
39,
7404,
83,
1006,
314,
8963,
687,
1101,
14,
16483,
10789,
1779,
22391,
3932,
10747,
436,
11075,
83,
282,
2600,
402,
4621,
370,
570,
3771,
1779,
9442,
8925,
1006,
4621,
1911,
267,
408,
267,
291,
14,
1494,
1247,
275,
1052,
398,
327,
8690,
4722,
8963,
267,
367,
931,
315,
8963,
855,
515,
10651,
288,
931,
275,
747,
14,
515,
14,
4832,
8,
515,
9,
953,
367,
295,
12059,
315,
291,
14,
7757,
3065,
8,
515,
304,
355,
859,
63,
515,
12,
1599,
275,
747,
14,
515,
14,
7973,
8,
264,
12059,
9,
355,
3231,
275,
32443,
904,
2941,
5650,
18783,
14,
5265,
418,
435,
359,
671,
367,
671,
315,
859,
63,
515,
14,
1294,
8,
736,
14,
515,
14,
4127,
9,
340,
671,
4794,
355,
327,
2041,
261,
314,
3329,
367,
314,
859,
536,
355,
340,
1599,
315,
359,
1674,
647,
401,
3680,
11357,
401,
3680,
22345,
6229,
490,
9911,
275,
747,
14,
515,
14,
904,
8,
515,
12,
295,
12059,
9,
490,
327,
8690,
21026,
1584,
490,
4205,
495,
275,
283,
855,
826,
12217,
490,
340,
3231,
14,
4130,
8,
826,
495,
304,
717,
291,
14,
1494,
1247,
59,
3251,
4439,
552,
8,
826,
495,
1874,
61,
275,
9911,
490,
587,
26,
717,
291,
14,
1494,
1247,
59,
3251,
61,
275,
9911,
398,
291,
14,
1065,
63,
12775,
342,
339,
347,
12778,
3065,
8,
277,
12,
931,
304,
267,
408,
31491,
83,
282,
931,
12717,
402,
3775,
652,
6952,
282,
10392,
503,
440,
624,
267,
340,
747,
14,
515,
14,
2444,
8,
515,
9,
436,
747,
14,
515,
14,
6027,
8,
515,
304,
288,
367,
20648,
12,
485,
694,
1247,
12,
6203,
315,
747,
14,
7757,
8,
515,
304,
355,
367,
1788,
315,
6203,
26,
490,
327,
3378,
4012,
1584,
465,
781,
3544,
1202,
370,
490,
1995,
747,
14,
515,
14,
904,
8,
17254,
59,
552,
8,
515,
9,
435,
822,
8,
736,
14,
515,
14,
4127,
304,
467,
1788,
9,
267,
587,
26,
288,
1478,
275,
446,
17,
288,
3482,
515,
275,
488,
288,
1830,
931,
14,
1623,
8,
736,
14,
515,
14,
4127,
12,
1478,
435,
413,
9,
690,
446,
17,
26,
355,
1478,
275,
931,
14,
1623,
8,
736,
14,
515,
14,
4127,
12,
1478,
435,
413,
9,
355,
340,
10392,
14,
374,
63,
18717,
8,
515,
1491,
1080,
4682,
490,
3482,
515,
275,
931,
1491,
1080,
61,
490,
2059,
288,
587,
26,
355,
340,
10392,
14,
374,
63,
18717,
8,
515,
304,
490,
3482,
515,
275,
931,
953,
327,
7356,
1995,
314,
1584,
288,
340,
3482,
515,
26,
355,
3482,
70,
275,
10392,
14,
15016,
8,
3065,
515,
9,
355,
2403,
275,
931,
59,
552,
8,
3065,
515,
304,
1055,
1913,
8,
736,
14,
515,
14,
4127,
9,
355,
327,
982,
2337,
1159,
282,
2403,
12,
4868,
652,
11187,
315,
282,
14457,
355,
340,
822,
8,
1861,
304,
490,
2403,
847,
747,
14,
515,
14,
4127,
355,
367,
4325,
315,
3482,
70,
14,
23841,
837,
490,
327,
16688,
1725,
17021,
370,
3544,
769,
4072,
1808,
1182,
465,
3932,
9432,
490,
4325,
275,
4325,
14,
1814,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
gurneyalex/odoo
|
addons/website_slides/tests/test_security.py
|
7
|
12127
|
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.website_slides.tests import common
from odoo.exceptions import AccessError, UserError
from odoo.tests import tagged
from odoo.tests.common import users
from odoo.tools import mute_logger
@tagged('security')
class TestAccess(common.SlidesCase):
@mute_logger('odoo.models', 'odoo.addons.base.models.ir_rule')
def test_access_channel_invite(self):
""" Invite channels don't give enroll if not member """
self.channel.write({'enroll': 'invite'})
self.channel.with_user(self.user_publisher).read(['name'])
self.channel.with_user(self.user_emp).read(['name'])
self.channel.with_user(self.user_portal).read(['name'])
self.channel.with_user(self.user_public).read(['name'])
self.slide.with_user(self.user_publisher).read(['name'])
with self.assertRaises(AccessError):
self.slide.with_user(self.user_emp).read(['name'])
with self.assertRaises(AccessError):
self.slide.with_user(self.user_portal).read(['name'])
with self.assertRaises(AccessError):
self.slide.with_user(self.user_portal).read(['name'])
# if member -> can read
membership = self.env['slide.channel.partner'].create({
'channel_id': self.channel.id,
'partner_id': self.user_emp.partner_id.id,
})
self.channel.with_user(self.user_emp).read(['name'])
self.slide.with_user(self.user_emp).read(['name'])
# not member anymore -> cannot read
membership.unlink()
self.channel.with_user(self.user_emp).read(['name'])
with self.assertRaises(AccessError):
self.slide.with_user(self.user_emp).read(['name'])
@mute_logger('odoo.models', 'odoo.addons.base.models.ir_rule')
def test_access_channel_public(self):
""" Public channels don't give enroll if not member """
self.channel.write({'enroll': 'public'})
self.channel.with_user(self.user_publisher).read(['name'])
self.channel.with_user(self.user_emp).read(['name'])
self.channel.with_user(self.user_portal).read(['name'])
self.channel.with_user(self.user_public).read(['name'])
self.slide.with_user(self.user_publisher).read(['name'])
with self.assertRaises(AccessError):
self.slide.with_user(self.user_emp).read(['name'])
with self.assertRaises(AccessError):
self.slide.with_user(self.user_portal).read(['name'])
with self.assertRaises(AccessError):
self.slide.with_user(self.user_public).read(['name'])
@mute_logger('odoo.models', 'odoo.addons.base.models.ir_rule')
def test_access_channel_publish(self):
""" Unpublished channels and their content are visible only to website people """
self.channel.write({'is_published': False, 'enroll': 'public'})
self.channel.flush(['is_published', 'website_published', 'enroll'])
# channel available only to website
self.channel.invalidate_cache(['name'])
self.channel.with_user(self.user_publisher).read(['name'])
with self.assertRaises(AccessError):
self.channel.invalidate_cache(['name'])
self.channel.with_user(self.user_emp).read(['name'])
with self.assertRaises(AccessError):
self.channel.invalidate_cache(['name'])
self.channel.with_user(self.user_portal).read(['name'])
with self.assertRaises(AccessError):
self.channel.invalidate_cache(['name'])
self.channel.with_user(self.user_public).read(['name'])
# slide available only to website
self.channel.invalidate_cache(['name'])
self.slide.with_user(self.user_publisher).read(['name'])
with self.assertRaises(AccessError):
self.slide.invalidate_cache(['name'])
self.slide.with_user(self.user_emp).read(['name'])
with self.assertRaises(AccessError):
self.slide.invalidate_cache(['name'])
self.slide.with_user(self.user_portal).read(['name'])
with self.assertRaises(AccessError):
self.slide.invalidate_cache(['name'])
self.slide.with_user(self.user_public).read(['name'])
# even members cannot see unpublished content
self.env['slide.channel.partner'].create({
'channel_id': self.channel.id,
'partner_id': self.user_emp.partner_id.id,
})
with self.assertRaises(AccessError):
self.channel.invalidate_cache(['name'])
self.channel.with_user(self.user_emp).read(['name'])
with self.assertRaises(AccessError):
self.slide.invalidate_cache(['name'])
self.slide.with_user(self.user_emp).read(['name'])
# publish channel but content unpublished (even if can be previewed) still unavailable
self.channel.write({'is_published': True})
self.slide.write({
'is_preview': True,
'is_published': False,
})
self.channel.flush(['website_published'])
self.slide.flush(['is_preview', 'website_published'])
self.slide.invalidate_cache(['name'])
self.slide.with_user(self.user_publisher).read(['name'])
with self.assertRaises(AccessError):
self.slide.invalidate_cache(['name'])
self.slide.with_user(self.user_emp).read(['name'])
with self.assertRaises(AccessError):
self.slide.invalidate_cache(['name'])
self.slide.with_user(self.user_portal).read(['name'])
with self.assertRaises(AccessError):
self.slide.invalidate_cache(['name'])
self.slide.with_user(self.user_public).read(['name'])
@mute_logger('odoo.models', 'odoo.addons.base.models.ir_rule')
def test_access_slide_preview(self):
""" Slides with preview flag are always visible even to non members if published """
self.channel.write({'enroll': 'invite'})
self.slide.write({'is_preview': True})
self.slide.flush(['is_preview'])
self.slide.with_user(self.user_publisher).read(['name'])
self.slide.with_user(self.user_emp).read(['name'])
self.slide.with_user(self.user_portal).read(['name'])
self.slide.with_user(self.user_public).read(['name'])
@tagged('functional', 'security')
class TestRemoveMembership(common.SlidesCase):
def setUp(self):
super(TestRemoveMembership, self).setUp()
self.channel_partner = self.env['slide.channel.partner'].create({
'channel_id': self.channel.id,
'partner_id': self.customer.id,
})
self.slide_partner = self.env['slide.slide.partner'].create({
'slide_id': self.slide.id,
'channel_id': self.channel.id,
'partner_id': self.customer.id
})
def test_security_unlink(self):
# Only the publisher can unlink channel_partner (and slide_partner by extension)
with self.assertRaises(AccessError):
self.channel_partner.with_user(self.user_public).unlink()
with self.assertRaises(AccessError):
self.channel_partner.with_user(self.user_portal).unlink()
with self.assertRaises(AccessError):
self.channel_partner.with_user(self.user_emp).unlink()
def test_slide_partner_remove(self):
id_slide_partner = self.slide_partner.id
id_channel_partner = self.channel_partner.id
self.channel_partner.with_user(self.user_publisher).unlink()
self.assertFalse(self.env['slide.channel.partner'].search([('id', '=', '%d' % id_channel_partner)]))
# Slide(s) related to the channel and the partner is unlink too.
self.assertFalse(self.env['slide.slide.partner'].search([('id', '=', '%d' % id_slide_partner)]))
@tagged('functional')
class TestAccessFeatures(common.SlidesCase):
@mute_logger('odoo.models', 'odoo.addons.base.models.ir_rule')
def test_channel_auto_subscription(self):
user_employees = self.env['res.users'].search([('groups_id', 'in', self.ref('base.group_user'))])
channel = self.env['slide.channel'].with_user(self.user_publisher).create({
'name': 'Test',
'enroll': 'invite',
'is_published': True,
'enroll_group_ids': [(4, self.ref('base.group_user'))]
})
channel.invalidate_cache(['partner_ids'])
self.assertEqual(channel.partner_ids, user_employees.mapped('partner_id'))
new_user = self.env['res.users'].create({
'name': 'NewUser',
'login': 'NewUser',
'groups_id': [(6, 0, [self.ref('base.group_user')])]
})
channel.invalidate_cache()
self.assertEqual(channel.partner_ids, user_employees.mapped('partner_id') | new_user.partner_id)
new_user_2 = self.env['res.users'].create({
'name': 'NewUser2',
'login': 'NewUser2',
'groups_id': [(5, 0)]
})
channel.invalidate_cache()
self.assertEqual(channel.partner_ids, user_employees.mapped('partner_id') | new_user.partner_id)
new_user_2.write({'groups_id': [(4, self.ref('base.group_user'))]})
channel.invalidate_cache()
self.assertEqual(channel.partner_ids, user_employees.mapped('partner_id') | new_user.partner_id | new_user_2.partner_id)
new_user_3 = self.env['res.users'].create({
'name': 'NewUser3',
'login': 'NewUser3',
'groups_id': [(5, 0)]
})
channel.invalidate_cache()
self.assertEqual(channel.partner_ids, user_employees.mapped('partner_id') | new_user.partner_id | new_user_2.partner_id)
self.env.ref('base.group_user').write({'users': [(4, new_user_3.id)]})
channel.invalidate_cache()
self.assertEqual(channel.partner_ids, user_employees.mapped('partner_id') | new_user.partner_id | new_user_2.partner_id | new_user_3.partner_id)
@mute_logger('odoo.models', 'odoo.addons.base.models.ir_rule')
def test_channel_features(self):
channel_publisher = self.channel.with_user(self.user_publisher)
self.assertEqual(channel_publisher.user_id, self.user_publisher)
self.assertTrue(channel_publisher.can_upload)
self.assertTrue(channel_publisher.can_publish)
# test upload group limitation: member of group_system OR responsible
channel_publisher.write({'upload_group_ids': [(4, self.ref('base.group_system'))]})
self.assertTrue(channel_publisher.can_upload)
self.assertTrue(channel_publisher.can_publish)
channel_publisher.write({'user_id': self.env.user.id})
self.assertFalse(channel_publisher.can_upload)
self.assertFalse(channel_publisher.can_publish)
channel_publisher.write({'upload_group_ids': [(5, 0)]})
self.assertTrue(channel_publisher.can_upload)
self.assertTrue(channel_publisher.can_publish)
# share people cannot upload / publish if limited to employees
channel_publisher.write({'upload_group_ids': [(4, self.ref('base.group_user'))]})
channel_portal = self.channel.with_user(self.user_portal)
self.assertFalse(channel_portal.can_upload)
self.assertFalse(channel_portal.can_publish)
# standard people can upload if groups are ok but not publish
channel_emp = self.channel.with_user(self.user_emp)
self.assertTrue(channel_emp.can_upload)
self.assertFalse(channel_emp.can_publish)
# standard limitation is for publishers
channel_publisher.write({'upload_group_ids': [(5, 0)]})
self.assertFalse(channel_emp.can_upload)
self.assertFalse(channel_emp.can_publish)
# superuser should always be able to publish even if he's not the responsible
channel_superuser = self.channel.sudo()
channel_superuser.invalidate_cache(['can_upload', 'can_publish'])
self.assertTrue(channel_superuser.can_upload)
self.assertTrue(channel_superuser.can_publish)
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
14320,
402,
28935,
14,
1666,
5113,
570,
367,
2615,
4248,
436,
32572,
2436,
14,
199,
199,
504,
28811,
14,
10788,
14,
7360,
63,
23766,
3424,
14,
2219,
492,
2863,
199,
504,
28811,
14,
3924,
492,
11003,
547,
12,
29908,
199,
504,
28811,
14,
2219,
492,
20018,
199,
504,
28811,
14,
2219,
14,
2330,
492,
4390,
199,
504,
28811,
14,
2537,
492,
333,
938,
63,
2921,
421,
199,
32,
15679,
360,
4416,
358,
199,
533,
1379,
3946,
8,
2330,
14,
51,
317,
3424,
1538,
304,
339,
768,
12423,
63,
2921,
360,
22058,
14,
992,
297,
283,
22058,
14,
10788,
14,
1095,
14,
992,
14,
723,
63,
2200,
358,
272,
347,
511,
63,
2732,
63,
2775,
63,
19061,
8,
277,
304,
267,
408,
1010,
13187,
9245,
2793,
1133,
8120,
26361,
340,
440,
3653,
408,
267,
291,
14,
2775,
14,
952,
3252,
14695,
356,
283,
19061,
3071,
398,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
3455,
680,
739,
2941,
354,
1105,
398,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
398,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
398,
327,
340,
3653,
1035,
883,
1586,
267,
14616,
275,
291,
14,
1813,
459,
19968,
14,
2775,
14,
3899,
2278,
981,
2561,
288,
283,
2775,
63,
344,
356,
291,
14,
2775,
14,
344,
12,
288,
283,
3899,
63,
344,
356,
291,
14,
751,
63,
2109,
14,
3899,
63,
344,
14,
344,
12,
267,
3828,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
398,
327,
440,
3653,
20827,
1035,
3913,
1586,
267,
14616,
14,
7162,
342,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
339,
768,
12423,
63,
2921,
360,
22058,
14,
992,
297,
283,
22058,
14,
10788,
14,
1095,
14,
992,
14,
723,
63,
2200,
358,
272,
347,
511,
63,
2732,
63,
2775,
63,
3455,
8,
277,
304,
267,
408,
1684,
9245,
2793,
1133,
8120,
26361,
340,
440,
3653,
408,
267,
291,
14,
2775,
14,
952,
3252,
14695,
356,
283,
3455,
3071,
398,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
3455,
680,
739,
2941,
354,
1105,
398,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
398,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
3455,
680,
739,
2941,
354,
1105,
339,
768,
12423,
63,
2921,
360,
22058,
14,
992,
297,
283,
22058,
14,
10788,
14,
1095,
14,
992,
14,
723,
63,
2200,
358,
272,
347,
511,
63,
2732,
63,
2775,
63,
4763,
8,
277,
304,
267,
408,
738,
1590,
2091,
379,
9245,
436,
3932,
1564,
787,
8917,
1454,
370,
10691,
13135,
408,
267,
291,
14,
2775,
14,
952,
3252,
374,
63,
8987,
356,
756,
12,
283,
14695,
356,
283,
3455,
3071,
267,
291,
14,
2775,
14,
4939,
2941,
374,
63,
8987,
297,
283,
7360,
63,
8987,
297,
283,
14695,
1105,
398,
327,
3623,
2808,
1454,
370,
10691,
267,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
288,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
288,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
288,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
3455,
680,
739,
2941,
354,
1105,
398,
327,
27063,
2808,
1454,
370,
10691,
267,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
267,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
17197,
63,
1637,
2941,
354,
1105
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
14320,
402,
28935,
14,
1666,
5113,
570,
367,
2615,
4248,
436,
32572,
2436,
14,
199,
199,
504,
28811,
14,
10788,
14,
7360,
63,
23766,
3424,
14,
2219,
492,
2863,
199,
504,
28811,
14,
3924,
492,
11003,
547,
12,
29908,
199,
504,
28811,
14,
2219,
492,
20018,
199,
504,
28811,
14,
2219,
14,
2330,
492,
4390,
199,
504,
28811,
14,
2537,
492,
333,
938,
63,
2921,
421,
199,
32,
15679,
360,
4416,
358,
199,
533,
1379,
3946,
8,
2330,
14,
51,
317,
3424,
1538,
304,
339,
768,
12423,
63,
2921,
360,
22058,
14,
992,
297,
283,
22058,
14,
10788,
14,
1095,
14,
992,
14,
723,
63,
2200,
358,
272,
347,
511,
63,
2732,
63,
2775,
63,
19061,
8,
277,
304,
267,
408,
1010,
13187,
9245,
2793,
1133,
8120,
26361,
340,
440,
3653,
408,
267,
291,
14,
2775,
14,
952,
3252,
14695,
356,
283,
19061,
3071,
398,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
3455,
680,
739,
2941,
354,
1105,
398,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
398,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
398,
327,
340,
3653,
1035,
883,
1586,
267,
14616,
275,
291,
14,
1813,
459,
19968,
14,
2775,
14,
3899,
2278,
981,
2561,
288,
283,
2775,
63,
344,
356,
291,
14,
2775,
14,
344,
12,
288,
283,
3899,
63,
344,
356,
291,
14,
751,
63,
2109,
14,
3899,
63,
344,
14,
344,
12,
267,
3828,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
398,
327,
440,
3653,
20827,
1035,
3913,
1586,
267,
14616,
14,
7162,
342,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
339,
768,
12423,
63,
2921,
360,
22058,
14,
992,
297,
283,
22058,
14,
10788,
14,
1095,
14,
992,
14,
723,
63,
2200,
358,
272,
347,
511,
63,
2732,
63,
2775,
63,
3455,
8,
277,
304,
267,
408,
1684,
9245,
2793,
1133,
8120,
26361,
340,
440,
3653,
408,
267,
291,
14,
2775,
14,
952,
3252,
14695,
356,
283,
3455,
3071,
398,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
3455,
680,
739,
2941,
354,
1105,
398,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
398,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
3455,
680,
739,
2941,
354,
1105,
339,
768,
12423,
63,
2921,
360,
22058,
14,
992,
297,
283,
22058,
14,
10788,
14,
1095,
14,
992,
14,
723,
63,
2200,
358,
272,
347,
511,
63,
2732,
63,
2775,
63,
4763,
8,
277,
304,
267,
408,
738,
1590,
2091,
379,
9245,
436,
3932,
1564,
787,
8917,
1454,
370,
10691,
13135,
408,
267,
291,
14,
2775,
14,
952,
3252,
374,
63,
8987,
356,
756,
12,
283,
14695,
356,
283,
3455,
3071,
267,
291,
14,
2775,
14,
4939,
2941,
374,
63,
8987,
297,
283,
7360,
63,
8987,
297,
283,
14695,
1105,
398,
327,
3623,
2808,
1454,
370,
10691,
267,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
267,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
288,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
2109,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
288,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
8707,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
288,
291,
14,
2775,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
3455,
680,
739,
2941,
354,
1105,
398,
327,
27063,
2808,
1454,
370,
10691,
267,
291,
14,
2775,
14,
17197,
63,
1637,
2941,
354,
1105,
267,
291,
14,
19968,
14,
1045,
63,
751,
8,
277,
14,
751,
63,
12789,
680,
739,
2941,
354,
1105,
267,
543,
291,
14,
1855,
8,
3946,
547,
304,
288,
291,
14,
19968,
14,
17197,
63,
1637,
2941,
354,
1105,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
def-/commandergenius
|
project/jni/python/src/Lib/test/test_logging.py
|
48
|
29218
|
#!/usr/bin/env python
#
# Copyright 2001-2004 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution
# of the software without specific, written prior permission.
# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""Test harness for the logging module. Run all tests.
Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
"""
import logging
import logging.handlers
import logging.config
import codecs
import copy
import cPickle
import cStringIO
import gc
import os
import re
import select
import socket
from SocketServer import ThreadingTCPServer, StreamRequestHandler
import string
import struct
import sys
import tempfile
from test.test_support import captured_stdout, run_with_locale, run_unittest
import textwrap
import threading
import time
import types
import unittest
import weakref
class BaseTest(unittest.TestCase):
"""Base class for logging tests."""
log_format = "%(name)s -> %(levelname)s: %(message)s"
expected_log_pat = r"^([\w.]+) -> ([\w]+): ([\d]+)$"
message_num = 0
def setUp(self):
"""Setup the default logging stream to an internal StringIO instance,
so that we can examine log output as we want."""
logger_dict = logging.getLogger().manager.loggerDict
logging._acquireLock()
try:
self.saved_handlers = logging._handlers.copy()
self.saved_handler_list = logging._handlerList[:]
self.saved_loggers = logger_dict.copy()
self.saved_level_names = logging._levelNames.copy()
finally:
logging._releaseLock()
self.root_logger = logging.getLogger("")
self.original_logging_level = self.root_logger.getEffectiveLevel()
self.stream = cStringIO.StringIO()
self.root_logger.setLevel(logging.DEBUG)
self.root_hdlr = logging.StreamHandler(self.stream)
self.root_formatter = logging.Formatter(self.log_format)
self.root_hdlr.setFormatter(self.root_formatter)
self.root_logger.addHandler(self.root_hdlr)
def tearDown(self):
"""Remove our logging stream, and restore the original logging
level."""
self.stream.close()
self.root_logger.removeHandler(self.root_hdlr)
self.root_logger.setLevel(self.original_logging_level)
logging._acquireLock()
try:
logging._levelNames.clear()
logging._levelNames.update(self.saved_level_names)
logging._handlers.clear()
logging._handlers.update(self.saved_handlers)
logging._handlerList[:] = self.saved_handler_list
loggerDict = logging.getLogger().manager.loggerDict
loggerDict.clear()
loggerDict.update(self.saved_loggers)
finally:
logging._releaseLock()
def assert_log_lines(self, expected_values, stream=None):
"""Match the collected log lines against the regular expression
self.expected_log_pat, and compare the extracted group values to
the expected_values list of tuples."""
stream = stream or self.stream
pat = re.compile(self.expected_log_pat)
try:
stream.reset()
actual_lines = stream.readlines()
except AttributeError:
# StringIO.StringIO lacks a reset() method.
actual_lines = stream.getvalue().splitlines()
self.assertEquals(len(actual_lines), len(expected_values))
for actual, expected in zip(actual_lines, expected_values):
match = pat.search(actual)
if not match:
self.fail("Log line does not match expected pattern:\n" +
actual)
self.assertEquals(tuple(match.groups()), expected)
s = stream.read()
if s:
self.fail("Remaining output at end of log stream:\n" + s)
def next_message(self):
"""Generate a message consisting solely of an auto-incrementing
integer."""
self.message_num += 1
return "%d" % self.message_num
class BuiltinLevelsTest(BaseTest):
"""Test builtin levels and their inheritance."""
def test_flat(self):
#Logging levels in a flat logger namespace.
m = self.next_message
ERR = logging.getLogger("ERR")
ERR.setLevel(logging.ERROR)
INF = logging.getLogger("INF")
INF.setLevel(logging.INFO)
DEB = logging.getLogger("DEB")
DEB.setLevel(logging.DEBUG)
# These should log.
ERR.log(logging.CRITICAL, m())
ERR.error(m())
INF.log(logging.CRITICAL, m())
INF.error(m())
INF.warn(m())
INF.info(m())
DEB.log(logging.CRITICAL, m())
DEB.error(m())
DEB.warn (m())
DEB.info (m())
DEB.debug(m())
# These should not log.
ERR.warn(m())
ERR.info(m())
ERR.debug(m())
INF.debug(m())
self.assert_log_lines([
('ERR', 'CRITICAL', '1'),
('ERR', 'ERROR', '2'),
('INF', 'CRITICAL', '3'),
('INF', 'ERROR', '4'),
('INF', 'WARNING', '5'),
('INF', 'INFO', '6'),
('DEB', 'CRITICAL', '7'),
('DEB', 'ERROR', '8'),
('DEB', 'WARNING', '9'),
('DEB', 'INFO', '10'),
('DEB', 'DEBUG', '11'),
])
def test_nested_explicit(self):
# Logging levels in a nested namespace, all explicitly set.
m = self.next_message
INF = logging.getLogger("INF")
INF.setLevel(logging.INFO)
INF_ERR = logging.getLogger("INF.ERR")
INF_ERR.setLevel(logging.ERROR)
# These should log.
INF_ERR.log(logging.CRITICAL, m())
INF_ERR.error(m())
# These should not log.
INF_ERR.warn(m())
INF_ERR.info(m())
INF_ERR.debug(m())
self.assert_log_lines([
('INF.ERR', 'CRITICAL', '1'),
('INF.ERR', 'ERROR', '2'),
])
def test_nested_inherited(self):
#Logging levels in a nested namespace, inherited from parent loggers.
m = self.next_message
INF = logging.getLogger("INF")
INF.setLevel(logging.INFO)
INF_ERR = logging.getLogger("INF.ERR")
INF_ERR.setLevel(logging.ERROR)
INF_UNDEF = logging.getLogger("INF.UNDEF")
INF_ERR_UNDEF = logging.getLogger("INF.ERR.UNDEF")
UNDEF = logging.getLogger("UNDEF")
# These should log.
INF_UNDEF.log(logging.CRITICAL, m())
INF_UNDEF.error(m())
INF_UNDEF.warn(m())
INF_UNDEF.info(m())
INF_ERR_UNDEF.log(logging.CRITICAL, m())
INF_ERR_UNDEF.error(m())
# These should not log.
INF_UNDEF.debug(m())
INF_ERR_UNDEF.warn(m())
INF_ERR_UNDEF.info(m())
INF_ERR_UNDEF.debug(m())
self.assert_log_lines([
('INF.UNDEF', 'CRITICAL', '1'),
('INF.UNDEF', 'ERROR', '2'),
('INF.UNDEF', 'WARNING', '3'),
('INF.UNDEF', 'INFO', '4'),
('INF.ERR.UNDEF', 'CRITICAL', '5'),
('INF.ERR.UNDEF', 'ERROR', '6'),
])
def test_nested_with_virtual_parent(self):
# Logging levels when some parent does not exist yet.
m = self.next_message
INF = logging.getLogger("INF")
GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
CHILD = logging.getLogger("INF.BADPARENT")
INF.setLevel(logging.INFO)
# These should log.
GRANDCHILD.log(logging.FATAL, m())
GRANDCHILD.info(m())
CHILD.log(logging.FATAL, m())
CHILD.info(m())
# These should not log.
GRANDCHILD.debug(m())
CHILD.debug(m())
self.assert_log_lines([
('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
('INF.BADPARENT.UNDEF', 'INFO', '2'),
('INF.BADPARENT', 'CRITICAL', '3'),
('INF.BADPARENT', 'INFO', '4'),
])
class BasicFilterTest(BaseTest):
"""Test the bundled Filter class."""
def test_filter(self):
# Only messages satisfying the specified criteria pass through the
# filter.
filter_ = logging.Filter("spam.eggs")
handler = self.root_logger.handlers[0]
try:
handler.addFilter(filter_)
spam = logging.getLogger("spam")
spam_eggs = logging.getLogger("spam.eggs")
spam_eggs_fish = logging.getLogger("spam.eggs.fish")
spam_bakedbeans = logging.getLogger("spam.bakedbeans")
spam.info(self.next_message())
spam_eggs.info(self.next_message()) # Good.
spam_eggs_fish.info(self.next_message()) # Good.
spam_bakedbeans.info(self.next_message())
self.assert_log_lines([
('spam.eggs', 'INFO', '2'),
('spam.eggs.fish', 'INFO', '3'),
])
finally:
handler.removeFilter(filter_)
#
# First, we define our levels. There can be as many as you want - the only
# limitations are that they should be integers, the lowest should be > 0 and
# larger values mean less information being logged. If you need specific
# level values which do not fit into these limitations, you can use a
# mapping dictionary to convert between your application levels and the
# logging system.
#
SILENT = 120
TACITURN = 119
TERSE = 118
EFFUSIVE = 117
SOCIABLE = 116
VERBOSE = 115
TALKATIVE = 114
GARRULOUS = 113
CHATTERBOX = 112
BORING = 111
LEVEL_RANGE = range(BORING, SILENT + 1)
#
# Next, we define names for our levels. You don't need to do this - in which
# case the system will use "Level n" to denote the text for the level.
#
my_logging_levels = {
SILENT : 'Silent',
TACITURN : 'Taciturn',
TERSE : 'Terse',
EFFUSIVE : 'Effusive',
SOCIABLE : 'Sociable',
VERBOSE : 'Verbose',
TALKATIVE : 'Talkative',
GARRULOUS : 'Garrulous',
CHATTERBOX : 'Chatterbox',
BORING : 'Boring',
}
class GarrulousFilter(logging.Filter):
"""A filter which blocks garrulous messages."""
def filter(self, record):
return record.levelno != GARRULOUS
class VerySpecificFilter(logging.Filter):
"""A filter which blocks sociable and taciturn messages."""
def filter(self, record):
return record.levelno not in [SOCIABLE, TACITURN]
class CustomLevelsAndFiltersTest(BaseTest):
"""Test various filtering possibilities with custom logging levels."""
# Skip the logger name group.
expected_log_pat = r"^[\w.]+ -> ([\w]+): ([\d]+)$"
def setUp(self):
BaseTest.setUp(self)
for k, v in my_logging_levels.items():
logging.addLevelName(k, v)
def log_at_all_levels(self, logger):
for lvl in LEVEL_RANGE:
logger.log(lvl, self.next_message())
def test_logger_filter(self):
# Filter at logger level.
self.root_logger.setLevel(VERBOSE)
# Levels >= 'Verbose' are good.
self.log_at_all_levels(self.root_logger)
self.assert_log_lines([
('Verbose', '5'),
('Sociable', '6'),
('Effusive', '7'),
('Terse', '8'),
('Taciturn', '9'),
('Silent', '10'),
])
def test_handler_filter(self):
# Filter at handler level.
self.root_logger.handlers[0].setLevel(SOCIABLE)
try:
# Levels >= 'Sociable' are good.
self.log_at_all_levels(self.root_logger)
self.assert_log_lines([
('Sociable', '6'),
('Effusive', '7'),
('Terse', '8'),
('Taciturn', '9'),
('Silent', '10'),
])
finally:
self.root_logger.handlers[0].setLevel(logging.NOTSET)
def test_specific_filters(self):
# Set a specific filter object on the handler, and then add another
# filter object on the logger itself.
handler = self.root_logger.handlers[0]
specific_filter = None
garr = GarrulousFilter()
handler.addFilter(garr)
try:
self.log_at_all_levels(self.root_logger)
first_lines = [
# Notice how 'Garrulous' is missing
('Boring', '1'),
('Chatterbox', '2'),
('Talkative', '4'),
('Verbose', '5'),
('Sociable', '6'),
('Effusive', '7'),
('Terse', '8'),
('Taciturn', '9'),
('Silent', '10'),
]
self.assert_log_lines(first_lines)
specific_filter = VerySpecificFilter()
self.root_logger.addFilter(specific_filter)
self.log_at_all_levels(self.root_logger)
self.assert_log_lines(first_lines + [
# Not only 'Garrulous' is still missing, but also 'Sociable'
# and 'Taciturn'
('Boring', '11'),
('Chatterbox', '12'),
('Talkative', '14'),
('Verbose', '15'),
('Effusive', '17'),
('Terse', '18'),
('Silent', '20'),
])
finally:
if specific_filter:
self.root_logger.removeFilter(specific_filter)
handler.removeFilter(garr)
class MemoryHandlerTest(BaseTest):
"""Tests for the MemoryHandler."""
# Do not bother with a logger name group.
expected_log_pat = r"^[\w.]+ -> ([\w]+): ([\d]+)$"
def setUp(self):
BaseTest.setUp(self)
self.mem_hdlr = logging.handlers.MemoryHandler(10, logging.WARNING,
self.root_hdlr)
self.mem_logger = logging.getLogger('mem')
self.mem_logger.propagate = 0
self.mem_logger.addHandler(self.mem_hdlr)
def tearDown(self):
self.mem_hdlr.close()
BaseTest.tearDown(self)
def test_flush(self):
# The memory handler flushes to its target handler based on specific
# criteria (message count and message level).
self.mem_logger.debug(self.next_message())
self.assert_log_lines([])
self.mem_logger.info(self.next_message())
self.assert_log_lines([])
# This will flush because the level is >= logging.WARNING
self.mem_logger.warn(self.next_message())
lines = [
('DEBUG', '1'),
('INFO', '2'),
('WARNING', '3'),
]
self.assert_log_lines(lines)
for n in (4, 14):
for i in range(9):
self.mem_logger.debug(self.next_message())
self.assert_log_lines(lines)
# This will flush because it's the 10th message since the last
# flush.
self.mem_logger.debug(self.next_message())
lines = lines + [('DEBUG', str(i)) for i in range(n, n + 10)]
self.assert_log_lines(lines)
self.mem_logger.debug(self.next_message())
self.assert_log_lines(lines)
class ExceptionFormatter(logging.Formatter):
"""A special exception formatter."""
def formatException(self, ei):
return "Got a [%s]" % ei[0].__name__
class ConfigFileTest(BaseTest):
"""Reading logging config from a .ini-style config file."""
expected_log_pat = r"^([\w]+) \+\+ ([\w]+)$"
# config0 is a standard configuration.
config0 = """
[loggers]
keys=root
[handlers]
keys=hand1
[formatters]
keys=form1
[logger_root]
level=WARNING
handlers=hand1
[handler_hand1]
class=StreamHandler
level=NOTSET
formatter=form1
args=(sys.stdout,)
[formatter_form1]
format=%(levelname)s ++ %(message)s
datefmt=
"""
# config1 adds a little to the standard configuration.
config1 = """
[loggers]
keys=root,parser
[handlers]
keys=hand1
[formatters]
keys=form1
[logger_root]
level=WARNING
handlers=
[logger_parser]
level=DEBUG
handlers=hand1
propagate=1
qualname=compiler.parser
[handler_hand1]
class=StreamHandler
level=NOTSET
formatter=form1
args=(sys.stdout,)
[formatter_form1]
format=%(levelname)s ++ %(message)s
datefmt=
"""
# config2 has a subtle configuration error that should be reported
config2 = config1.replace("sys.stdout", "sys.stbout")
# config3 has a less subtle configuration error
config3 = config1.replace("formatter=form1", "formatter=misspelled_name")
# config4 specifies a custom formatter class to be loaded
config4 = """
[loggers]
keys=root
[handlers]
keys=hand1
[formatters]
keys=form1
[logger_root]
level=NOTSET
handlers=hand1
[handler_hand1]
class=StreamHandler
level=NOTSET
formatter=form1
args=(sys.stdout,)
[formatter_form1]
class=""" + __name__ + """.ExceptionFormatter
format=%(levelname)s:%(name)s:%(message)s
datefmt=
"""
# config5 specifies a custom handler class to be loaded
config5 = config1.replace('class=StreamHandler', 'class=logging.StreamHandler')
# config6 uses ', ' delimiters in the handlers and formatters sections
config6 = """
[loggers]
keys=root,parser
[handlers]
keys=hand1, hand2
[formatters]
keys=form1, form2
[logger_root]
level=WARNING
handlers=
[logger_parser]
level=DEBUG
handlers=hand1
propagate=1
qualname=compiler.parser
[handler_hand1]
class=StreamHandler
level=NOTSET
formatter=form1
args=(sys.stdout,)
[handler_hand2]
class=StreamHandler
level=NOTSET
formatter=form1
args=(sys.stderr,)
[formatter_form1]
format=%(levelname)s ++ %(message)s
datefmt=
[formatter_form2]
format=%(message)s
datefmt=
"""
def apply_config(self, conf):
try:
fn = tempfile.mktemp(".ini")
f = open(fn, "w")
f.write(textwrap.dedent(conf))
f.close()
logging.config.fileConfig(fn)
finally:
os.remove(fn)
def test_config0_ok(self):
# A simple config file which overrides the default settings.
with captured_stdout() as output:
self.apply_config(self.config0)
logger = logging.getLogger()
# Won't output anything
logger.info(self.next_message())
# Outputs a message
logger.error(self.next_message())
self.assert_log_lines([
('ERROR', '2'),
], stream=output)
# Original logger output is empty.
self.assert_log_lines([])
def test_config1_ok(self, config=config1):
# A config file defining a sub-parser as well.
with captured_stdout() as output:
self.apply_config(config)
logger = logging.getLogger("compiler.parser")
# Both will output a message
logger.info(self.next_message())
logger.error(self.next_message())
self.assert_log_lines([
('INFO', '1'),
('ERROR', '2'),
], stream=output)
# Original logger output is empty.
self.assert_log_lines([])
def test_config2_failure(self):
# A simple config file which overrides the default settings.
self.assertRaises(StandardError, self.apply_config, self.config2)
def test_config3_failure(self):
# A simple config file which overrides the default settings.
self.assertRaises(StandardError, self.apply_config, self.config3)
def test_config4_ok(self):
# A config file specifying a custom formatter class.
with captured_stdout() as output:
self.apply_config(self.config4)
logger = logging.getLogger()
try:
raise RuntimeError()
except RuntimeError:
logging.exception("just testing")
sys.stdout.seek(0)
self.assertEquals(output.getvalue(),
"ERROR:root:just testing\nGot a [RuntimeError]\n")
# Original logger output is empty
self.assert_log_lines([])
def test_config5_ok(self):
self.test_config1_ok(config=self.config5)
def test_config6_ok(self):
self.test_config1_ok(config=self.config6)
class LogRecordStreamHandler(StreamRequestHandler):
"""Handler for a streaming logging request. It saves the log message in the
TCP server's 'log_output' attribute."""
TCP_LOG_END = "!!!END!!!"
def handle(self):
"""Handle multiple requests - each expected to be of 4-byte length,
followed by the LogRecord in pickle format. Logs the record
according to whatever policy is configured locally."""
while True:
chunk = self.connection.recv(4)
if len(chunk) < 4:
break
slen = struct.unpack(">L", chunk)[0]
chunk = self.connection.recv(slen)
while len(chunk) < slen:
chunk = chunk + self.connection.recv(slen - len(chunk))
obj = self.unpickle(chunk)
record = logging.makeLogRecord(obj)
self.handle_log_record(record)
def unpickle(self, data):
return cPickle.loads(data)
def handle_log_record(self, record):
# If the end-of-messages sentinel is seen, tell the server to
# terminate.
if self.TCP_LOG_END in record.msg:
self.server.abort = 1
return
self.server.log_output += record.msg + "\n"
class LogRecordSocketReceiver(ThreadingTCPServer):
"""A simple-minded TCP socket-based logging receiver suitable for test
purposes."""
allow_reuse_address = 1
log_output = ""
def __init__(self, host='localhost',
port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
handler=LogRecordStreamHandler):
ThreadingTCPServer.__init__(self, (host, port), handler)
self.abort = False
self.timeout = 0.1
self.finished = threading.Event()
def serve_until_stopped(self):
while not self.abort:
rd, wr, ex = select.select([self.socket.fileno()], [], [],
self.timeout)
if rd:
self.handle_request()
# Notify the main thread that we're about to exit
self.finished.set()
# close the listen socket
self.server_close()
class SocketHandlerTest(BaseTest):
"""Test for SocketHandler objects."""
def setUp(self):
"""Set up a TCP server to receive log messages, and a SocketHandler
pointing to that server's address and port."""
BaseTest.setUp(self)
self.tcpserver = LogRecordSocketReceiver(port=0)
self.port = self.tcpserver.socket.getsockname()[1]
self.threads = [
threading.Thread(target=self.tcpserver.serve_until_stopped)]
for thread in self.threads:
thread.start()
self.sock_hdlr = logging.handlers.SocketHandler('localhost', self.port)
self.sock_hdlr.setFormatter(self.root_formatter)
self.root_logger.removeHandler(self.root_logger.handlers[0])
self.root_logger.addHandler(self.sock_hdlr)
def tearDown(self):
"""Shutdown the TCP server."""
try:
self.tcpserver.abort = True
del self.tcpserver
self.root_logger.removeHandler(self.sock_hdlr)
self.sock_hdlr.close()
for thread in self.threads:
thread.join(2.0)
finally:
BaseTest.tearDown(self)
def get_output(self):
"""Get the log output as received by the TCP server."""
# Signal the TCP receiver and wait for it to terminate.
self.root_logger.critical(LogRecordStreamHandler.TCP_LOG_END)
self.tcpserver.finished.wait(2.0)
return self.tcpserver.log_output
def test_output(self):
# The log message sent to the SocketHandler is properly received.
logger = logging.getLogger("tcp")
logger.error("spam")
logger.debug("eggs")
self.assertEquals(self.get_output(), "spam\neggs\n")
class MemoryTest(BaseTest):
"""Test memory persistence of logger objects."""
def setUp(self):
"""Create a dict to remember potentially destroyed objects."""
BaseTest.setUp(self)
self._survivors = {}
def _watch_for_survival(self, *args):
"""Watch the given objects for survival, by creating weakrefs to
them."""
for obj in args:
key = id(obj), repr(obj)
self._survivors[key] = weakref.ref(obj)
def _assert_survival(self):
"""Assert that all objects watched for survival have survived."""
# Trigger cycle breaking.
gc.collect()
dead = []
for (id_, repr_), ref in self._survivors.items():
if ref() is None:
dead.append(repr_)
if dead:
self.fail("%d objects should have survived "
"but have been destroyed: %s" % (len(dead), ", ".join(dead)))
def test_persistent_loggers(self):
# Logger objects are persistent and retain their configuration, even
# if visible references are destroyed.
self.root_logger.setLevel(logging.INFO)
foo = logging.getLogger("foo")
self._watch_for_survival(foo)
foo.setLevel(logging.DEBUG)
self.root_logger.debug(self.next_message())
foo.debug(self.next_message())
self.assert_log_lines([
('foo', 'DEBUG', '2'),
])
del foo
# foo has survived.
self._assert_survival()
# foo has retained its settings.
bar = logging.getLogger("foo")
bar.debug(self.next_message())
self.assert_log_lines([
('foo', 'DEBUG', '2'),
('foo', 'DEBUG', '3'),
])
class EncodingTest(BaseTest):
def test_encoding_plain_file(self):
# In Python 2.x, a plain file object is treated as having no encoding.
log = logging.getLogger("test")
fn = tempfile.mktemp(".log")
# the non-ascii data we write to the log.
data = "foo\x80"
try:
handler = logging.FileHandler(fn)
log.addHandler(handler)
try:
# write non-ascii data to the log.
log.warning(data)
finally:
log.removeHandler(handler)
handler.close()
# check we wrote exactly those bytes, ignoring trailing \n etc
f = open(fn)
try:
self.failUnlessEqual(f.read().rstrip(), data)
finally:
f.close()
finally:
if os.path.isfile(fn):
os.remove(fn)
def test_encoding_cyrillic_unicode(self):
log = logging.getLogger("test")
#Get a message in Unicode: Do svidanya in Cyrillic (meaning goodbye)
message = u'\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f'
#Ensure it's written in a Cyrillic encoding
writer_class = codecs.getwriter('cp1251')
stream = cStringIO.StringIO()
writer = writer_class(stream, 'strict')
handler = logging.StreamHandler(writer)
log.addHandler(handler)
try:
log.warning(message)
finally:
log.removeHandler(handler)
handler.close()
# check we wrote exactly those bytes, ignoring trailing \n etc
s = stream.getvalue()
#Compare against what the data should be when encoded in CP-1251
self.assertEqual(s, '\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n')
# Set the locale to the platform-dependent default. I have no idea
# why the test does this, but in any case we save the current locale
# first and restore it at the end.
@run_with_locale('LC_ALL', '')
def test_main():
run_unittest(BuiltinLevelsTest, BasicFilterTest,
CustomLevelsAndFiltersTest, MemoryHandlerTest,
ConfigFileTest, SocketHandlerTest, MemoryTest,
EncodingTest)
if __name__ == "__main__":
test_main()
|
lgpl-2.1
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
12521,
13,
15431,
701,
28882,
1187,
428,
9091,
711,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
8779,
370,
675,
12,
1331,
12,
2811,
12,
436,
11207,
642,
2032,
436,
2399,
199,
3,
3794,
367,
1263,
12016,
436,
1928,
14751,
365,
11882,
10009,
12,
199,
3,
2741,
626,
314,
3432,
4248,
4245,
7468,
315,
1006,
6866,
436,
626,
199,
3,
3865,
626,
4248,
4245,
436,
642,
4983,
4245,
7468,
315,
199,
3,
21038,
3794,
12,
436,
626,
314,
536,
402,
28882,
1187,
428,
9091,
711,
199,
3,
440,
506,
1202,
315,
19613,
1044,
503,
7974,
20976,
1126,
24522,
370,
4084,
199,
3,
402,
314,
2032,
1928,
2488,
12,
5313,
6791,
4983,
14,
199,
3,
812,
568,
3448,
13950,
42,
1772,
8990,
51,
11727,
2990,
1663,
14142,
7816,
2296,
5749,
4141,
12,
6931,
199,
3,
11727,
5292,
2990,
1634,
3169,
2401,
3092,
14,
1621,
4825,
6461,
7000,
199,
3,
812,
568,
3448,
13950,
42,
1772,
6262,
7024,
2381,
1821,
8820,
12,
9168,
1549,
9110,
6736,
1549,
199,
3,
1821,
6736,
28752,
4118,
27362,
20668,
1206,
4442,
9102,
1634,
4815,
12,
7126,
1549,
9206,
12,
7061,
199,
3,
1621,
1261,
9612,
1634,
7066,
12,
9254,
1549,
5010,
7056,
25657,
9612,
12,
7043,
5738,
199,
3,
1634,
1549,
1621,
11287,
1663,
2334,
4815,
1549,
13873,
30340,
1634,
5749,
4141,
14,
199,
199,
624,
774,
20458,
367,
314,
2050,
859,
14,
3378,
1006,
2295,
14,
199,
199,
7384,
334,
35,
9,
12521,
13,
15135,
28882,
1187,
428,
9091,
711,
14,
2900,
5924,
5702,
14,
199,
624,
199,
199,
646,
2050,
199,
646,
2050,
14,
5586,
199,
646,
2050,
14,
888,
199,
199,
646,
6010,
199,
646,
1331,
199,
646,
17572,
199,
646,
15073,
199,
646,
9486,
199,
646,
747,
199,
646,
295,
199,
646,
3504,
199,
646,
2838,
199,
504,
17766,
3120,
492,
11086,
316,
9735,
3120,
12,
8271,
11149,
199,
646,
1059,
199,
646,
2702,
199,
646,
984,
199,
646,
5549,
199,
504,
511,
14,
396,
63,
4058,
492,
17487,
63,
2703,
12,
1255,
63,
1045,
63,
5508,
12,
1255,
63,
2796,
199,
646,
13390,
199,
646,
5796,
199,
646,
900,
199,
646,
2943,
199,
646,
2882,
199,
646,
13852,
421,
199,
533,
3523,
774,
8,
2796,
14,
1746,
304,
339,
408,
1563,
1021,
367,
2050,
2295,
1041,
339,
943,
63,
908,
275,
11792,
354,
9,
83,
1035,
2818,
20056,
9,
83,
26,
2818,
1188,
9,
83,
2,
272,
1420,
63,
793,
63,
10853,
275,
519,
16136,
16510,
87,
14,
11896,
1035,
334,
7023,
87,
2807,
304,
334,
7023,
68,
11896,
17351,
272,
1245,
63,
1507,
275,
378,
339,
347,
3613,
8,
277,
304,
267,
408,
8555,
314,
849,
2050,
2547,
370,
376,
5007,
5228,
1256,
12,
267,
880,
626,
781,
883,
31758,
943,
1072,
465,
781,
2934,
1041,
267,
2512,
63,
807,
275,
2050,
14,
5572,
1252,
2609,
14,
2921,
2141,
267,
2050,
423,
8174,
6432,
342,
267,
862,
26,
288,
291,
14,
8420,
63,
5586,
275,
2050,
423,
5586,
14,
1574,
342,
288,
291,
14,
8420,
63,
2232,
63,
513,
275,
2050,
423,
2232,
1296,
5873,
288,
291,
14,
8420,
63,
22771,
275,
2512,
63,
807,
14,
1574,
342,
288,
291,
14,
8420,
63,
1896,
63,
1247,
275,
2050,
423,
1896,
5866,
14,
1574,
342,
267,
3753,
26,
288,
2050,
423,
3221,
6432,
342,
398,
291,
14,
1231,
63,
2921,
275,
2050,
14,
5572,
10804,
267,
291,
14,
5043,
63,
4806,
63,
1896,
275,
291,
14,
1231,
63,
2921,
14,
362,
30754,
4670,
342,
398,
291,
14,
1745,
275,
15073,
14,
6424,
342,
267,
291,
14,
1231,
63,
2921,
14,
13548,
8,
4806,
14,
5287,
9,
267,
291,
14,
1231,
63,
28738,
82,
275,
2050,
14,
22482,
8,
277,
14,
1745,
9,
267,
291,
14,
1231,
63,
8911,
275,
2050,
14,
7772,
8,
277,
14,
793,
63,
908,
9,
267,
291,
14,
1231,
63,
28738,
82,
14,
26076,
8,
277,
14,
1231,
63,
8911,
9,
267,
291,
14,
1231,
63,
2921,
14,
18826,
8,
277,
14,
1231,
63,
28738,
82,
9,
339,
347,
6766,
8,
277,
304,
267,
408,
5587,
4154,
2050,
2547,
12,
436,
9066,
314,
3379,
2050,
267,
2166,
1041,
267,
291,
14,
1745,
14,
1600,
342,
267,
291,
14,
1231,
63,
2921,
14,
2168,
2461,
8,
277,
14,
1231,
63,
28738,
82,
9,
267,
291,
14,
1231,
63,
2921,
14,
13548,
8,
277,
14,
5043,
63,
4806,
63,
1896,
9,
267,
2050,
423,
8174,
6432,
342,
267,
862,
26,
288,
2050,
423,
1896,
5866,
14,
3584,
342,
288,
2050,
423,
1896,
5866,
14,
873,
8,
277,
14,
8420,
63,
1896,
63,
1247,
9,
288,
2050,
423,
5586,
14,
3584,
342,
288,
2050,
423,
5586,
14,
873,
8,
277,
14,
8420,
63,
5586,
9,
288,
2050,
423,
2232,
1296,
5873,
275,
291,
14,
8420,
63,
2232,
63,
513,
288,
2512,
2141,
275,
2050,
14,
5572,
1252,
2609,
14,
2921,
2141,
288,
2512,
2141,
14,
3584,
342,
288,
2512,
2141,
14,
873,
8,
277,
14,
8420,
63,
22771,
9,
267,
3753,
26,
288,
2050,
423,
3221,
6432,
342,
339,
347,
702,
63,
793,
63,
1278,
8,
277,
12,
1420,
63,
1459,
12,
2547,
29,
403,
304,
267,
408,
4486,
314,
13736,
943,
2385,
6169,
314,
5578,
3965,
267,
291,
14,
2062,
63,
793,
63,
10853,
12,
436,
6540,
314,
12509,
1572,
1338,
370,
267,
314,
1420,
63,
1459,
769,
402,
6346,
1041,
267,
2547,
275,
2547,
503,
291,
14,
1745,
267,
12713,
275,
295,
14,
2014,
8,
277,
14,
2062,
63,
793,
63,
10853,
9,
267,
862,
26,
288,
2547,
14,
3958,
342,
288,
3503,
63,
1278,
275,
2547,
14,
9684,
342,
267,
871,
4281,
26,
288,
327,
5228,
14,
6424,
1127,
5618,
282,
5305,
342,
1083,
14,
288,
3503,
63,
1278,
275,
2547,
14,
7150,
1252,
7644,
342,
267,
291,
14,
2947,
8,
552,
8,
6514,
63,
1278,
395,
822,
8,
2062,
63,
1459,
430,
267,
367,
3503,
12,
1420,
315,
3482,
8,
6514,
63,
1278,
12,
1420,
63,
1459,
304,
288,
1336,
275,
12713,
14,
1733,
8,
6514,
9,
288,
340,
440,
1336,
26,
355,
291,
14,
1633,
480,
2445,
1004,
1630,
440,
1336,
1420,
3851,
3427,
78,
2
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
12521,
13,
15431,
701,
28882,
1187,
428,
9091,
711,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
8779,
370,
675,
12,
1331,
12,
2811,
12,
436,
11207,
642,
2032,
436,
2399,
199,
3,
3794,
367,
1263,
12016,
436,
1928,
14751,
365,
11882,
10009,
12,
199,
3,
2741,
626,
314,
3432,
4248,
4245,
7468,
315,
1006,
6866,
436,
626,
199,
3,
3865,
626,
4248,
4245,
436,
642,
4983,
4245,
7468,
315,
199,
3,
21038,
3794,
12,
436,
626,
314,
536,
402,
28882,
1187,
428,
9091,
711,
199,
3,
440,
506,
1202,
315,
19613,
1044,
503,
7974,
20976,
1126,
24522,
370,
4084,
199,
3,
402,
314,
2032,
1928,
2488,
12,
5313,
6791,
4983,
14,
199,
3,
812,
568,
3448,
13950,
42,
1772,
8990,
51,
11727,
2990,
1663,
14142,
7816,
2296,
5749,
4141,
12,
6931,
199,
3,
11727,
5292,
2990,
1634,
3169,
2401,
3092,
14,
1621,
4825,
6461,
7000,
199,
3,
812,
568,
3448,
13950,
42,
1772,
6262,
7024,
2381,
1821,
8820,
12,
9168,
1549,
9110,
6736,
1549,
199,
3,
1821,
6736,
28752,
4118,
27362,
20668,
1206,
4442,
9102,
1634,
4815,
12,
7126,
1549,
9206,
12,
7061,
199,
3,
1621,
1261,
9612,
1634,
7066,
12,
9254,
1549,
5010,
7056,
25657,
9612,
12,
7043,
5738,
199,
3,
1634,
1549,
1621,
11287,
1663,
2334,
4815,
1549,
13873,
30340,
1634,
5749,
4141,
14,
199,
199,
624,
774,
20458,
367,
314,
2050,
859,
14,
3378,
1006,
2295,
14,
199,
199,
7384,
334,
35,
9,
12521,
13,
15135,
28882,
1187,
428,
9091,
711,
14,
2900,
5924,
5702,
14,
199,
624,
199,
199,
646,
2050,
199,
646,
2050,
14,
5586,
199,
646,
2050,
14,
888,
199,
199,
646,
6010,
199,
646,
1331,
199,
646,
17572,
199,
646,
15073,
199,
646,
9486,
199,
646,
747,
199,
646,
295,
199,
646,
3504,
199,
646,
2838,
199,
504,
17766,
3120,
492,
11086,
316,
9735,
3120,
12,
8271,
11149,
199,
646,
1059,
199,
646,
2702,
199,
646,
984,
199,
646,
5549,
199,
504,
511,
14,
396,
63,
4058,
492,
17487,
63,
2703,
12,
1255,
63,
1045,
63,
5508,
12,
1255,
63,
2796,
199,
646,
13390,
199,
646,
5796,
199,
646,
900,
199,
646,
2943,
199,
646,
2882,
199,
646,
13852,
421,
199,
533,
3523,
774,
8,
2796,
14,
1746,
304,
339,
408,
1563,
1021,
367,
2050,
2295,
1041,
339,
943,
63,
908,
275,
11792,
354,
9,
83,
1035,
2818,
20056,
9,
83,
26,
2818,
1188,
9,
83,
2,
272,
1420,
63,
793,
63,
10853,
275,
519,
16136,
16510,
87,
14,
11896,
1035,
334,
7023,
87,
2807,
304,
334,
7023,
68,
11896,
17351,
272,
1245,
63,
1507,
275,
378,
339,
347,
3613,
8,
277,
304,
267,
408,
8555,
314,
849,
2050,
2547,
370,
376,
5007,
5228,
1256,
12,
267,
880,
626,
781,
883,
31758,
943,
1072,
465,
781,
2934,
1041,
267,
2512,
63,
807,
275,
2050,
14,
5572,
1252,
2609,
14,
2921,
2141,
267,
2050,
423,
8174,
6432,
342,
267,
862,
26,
288,
291,
14,
8420,
63,
5586,
275,
2050,
423,
5586,
14,
1574,
342,
288,
291,
14,
8420,
63,
2232,
63,
513,
275,
2050,
423,
2232,
1296,
5873,
288,
291,
14,
8420,
63,
22771,
275,
2512,
63,
807,
14,
1574,
342,
288,
291,
14,
8420,
63,
1896,
63,
1247,
275,
2050,
423,
1896,
5866,
14,
1574,
342,
267,
3753,
26,
288,
2050,
423,
3221,
6432,
342,
398,
291,
14,
1231,
63,
2921,
275,
2050,
14,
5572,
10804,
267,
291,
14,
5043,
63,
4806,
63,
1896,
275,
291,
14,
1231,
63,
2921,
14,
362,
30754,
4670,
342,
398,
291,
14,
1745,
275,
15073,
14,
6424,
342,
267,
291,
14,
1231,
63,
2921,
14,
13548,
8,
4806,
14,
5287,
9,
267,
291,
14,
1231,
63,
28738,
82,
275,
2050,
14,
22482,
8,
277,
14,
1745,
9,
267,
291,
14,
1231,
63,
8911,
275,
2050,
14,
7772,
8,
277,
14,
793,
63,
908,
9,
267,
291,
14,
1231,
63,
28738,
82,
14,
26076,
8,
277,
14,
1231,
63,
8911,
9,
267,
291,
14,
1231,
63,
2921,
14,
18826,
8,
277,
14,
1231,
63,
28738,
82,
9,
339,
347,
6766,
8,
277,
304,
267,
408,
5587,
4154,
2050,
2547,
12,
436,
9066,
314,
3379,
2050,
267,
2166,
1041,
267,
291,
14,
1745,
14,
1600,
342,
267,
291,
14,
1231,
63,
2921,
14,
2168,
2461,
8,
277,
14,
1231,
63,
28738,
82,
9,
267,
291,
14,
1231,
63,
2921,
14,
13548,
8,
277,
14,
5043,
63,
4806,
63,
1896,
9,
267,
2050,
423,
8174,
6432,
342,
267,
862,
26,
288,
2050,
423,
1896,
5866,
14,
3584,
342,
288,
2050,
423,
1896,
5866,
14,
873,
8,
277,
14,
8420,
63,
1896,
63,
1247,
9,
288,
2050,
423,
5586,
14,
3584,
342,
288,
2050,
423,
5586,
14,
873,
8,
277,
14,
8420,
63,
5586,
9,
288,
2050,
423,
2232,
1296,
5873,
275,
291,
14,
8420,
63,
2232,
63,
513,
288,
2512,
2141,
275,
2050,
14,
5572,
1252,
2609,
14,
2921,
2141,
288,
2512,
2141,
14,
3584,
342,
288,
2512,
2141,
14,
873,
8,
277,
14,
8420,
63,
22771,
9,
267,
3753,
26,
288,
2050,
423,
3221,
6432,
342,
339,
347,
702,
63,
793,
63,
1278,
8,
277,
12,
1420,
63,
1459,
12,
2547,
29,
403,
304,
267,
408,
4486,
314,
13736,
943,
2385,
6169,
314,
5578,
3965,
267,
291,
14,
2062,
63,
793,
63,
10853,
12,
436,
6540,
314,
12509,
1572,
1338,
370,
267,
314,
1420,
63,
1459,
769,
402,
6346,
1041,
267,
2547,
275,
2547,
503,
291,
14,
1745,
267,
12713,
275,
295,
14,
2014,
8,
277,
14,
2062,
63,
793,
63,
10853,
9,
267,
862,
26,
288,
2547,
14,
3958,
342,
288,
3503,
63,
1278,
275,
2547,
14,
9684,
342,
267,
871,
4281,
26,
288,
327,
5228,
14,
6424,
1127,
5618,
282,
5305,
342,
1083,
14,
288,
3503,
63,
1278,
275,
2547,
14,
7150,
1252,
7644,
342,
267,
291,
14,
2947,
8,
552,
8,
6514,
63,
1278,
395,
822,
8,
2062,
63,
1459,
430,
267,
367,
3503,
12,
1420,
315,
3482,
8,
6514,
63,
1278,
12,
1420,
63,
1459,
304,
288,
1336,
275,
12713,
14,
1733,
8,
6514,
9,
288,
340,
440,
1336,
26,
355,
291,
14,
1633,
480,
2445,
1004,
1630,
440,
1336,
1420,
3851,
3427,
78,
2,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Pokechu22/Burger
|
burger/toppings/objects.py
|
2
|
5569
|
#!/usr/bin/env python
# -*- coding: utf8 -*-
"""
Copyright (c) 2011 Tyler Kenendy <tk@tkte.ch>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import six
from copy import copy
from .topping import Topping
from jawa.constants import *
class ObjectTopping(Topping):
"""Gets most vehicle/object types."""
PROVIDES = [
"entities.object"
]
DEPENDS = [
"identify.nethandler.client",
"identify.entity.trackerentry",
"version.data",
"entities.entity",
"packets.classes"
]
@staticmethod
def act(aggregate, classloader, verbose=False):
if aggregate["version"]["data"] >= 1930: # 19w05a+
# Object IDs were removed in 19w05a, and entity IDs are now used instead. Skip this topping entirely.
return
if "entity.trackerentry" not in aggregate["classes"] or "nethandler.client" not in aggregate["classes"]:
return
entities = aggregate["entities"]
# Find the spawn object packet ID using EntityTrackerEntry.createSpawnPacket
# (which handles other spawn packets too, but the first item in it is correct)
entitytrackerentry = aggregate["classes"]["entity.trackerentry"]
entitytrackerentry_cf = classloader[entitytrackerentry]
createspawnpacket_method = entitytrackerentry_cf.methods.find_one(args="",
f=lambda x: x.access_flags.acc_private and not x.access_flags.acc_static and not x.returns.name == "void")
packet_class_name = None
# Handle capitalization changes from 1.11
item_entity_class = entities["entity"]["item"]["class"] if "item" in entities["entity"] else entities["entity"]["Item"]["class"]
will_be_spawn_object_packet = False
for ins in createspawnpacket_method.code.disassemble():
if ins == "instanceof":
# Check to make sure that it's a spawn packet for item entities
const = ins.operands[0]
if const.name == item_entity_class:
will_be_spawn_object_packet = True
elif ins == "new" and will_be_spawn_object_packet:
const = ins.operands[0]
packet_class_name = const.name.value
break
if packet_class_name is None:
if verbose:
print("Failed to find spawn object packet")
return
# Get the packet info for the spawn object packet - not required but it is helpful information
for key, packet in six.iteritems(aggregate["packets"]["packet"]):
if packet_class_name in packet["class"]:
# "in" is used because packet["class"] would have ".class" at the end
entities["info"]["spawn_object_packet"] = key
break
objects = entities.setdefault("object", {})
# Now find the spawn object packet handler and use it to figure out IDs
nethandler = aggregate["classes"]["nethandler.client"]
nethandler_cf = classloader[nethandler]
method = nethandler_cf.methods.find_one(args="L" + packet_class_name + ";")
potential_id = 0
current_id = 0
for ins in method.code.disassemble():
if ins == "if_icmpne":
current_id = potential_id
elif ins in ("bipush", "sipush"):
potential_id = ins.operands[0].value
elif ins == "new":
const = ins.operands[0]
tmp = {"id": current_id, "class": const.name.value}
objects[tmp["id"]] = tmp
entities_by_class = {entity["class"]: entity for entity in six.itervalues(entities["entity"])}
from .entities import EntityTopping
EntityTopping.compute_sizes(classloader, aggregate, objects) # Needed because some objects aren't in the entity list
for o in six.itervalues(objects):
if o["class"] in entities_by_class:
# If this object corresponds to a known entity, copy data from that
entity = entities_by_class[o["class"]]
if "id" in entity:
o["entity_id"] = entity["id"]
if "name" in entity:
o["name"] = entity["name"]
if "width" in entity:
o["width"] = entity["width"]
if "height" in entity:
o["height"] = entity["height"]
if "texture" in entity:
o["texture"] = entity["texture"]
entities["info"]["object_count"] = len(objects)
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
24,
1882,
199,
624,
199,
7384,
334,
67,
9,
7760,
377,
89,
1435,
1804,
287,
500,
89,
665,
2663,
32,
2663,
266,
14,
335,
30,
199,
199,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
1618,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
262,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
475,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
16847,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
70,
13399,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
199,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
452,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
38,
3061,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
5580,
4149,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
2673,
2477,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
1877,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
18061,
4141,
14,
199,
624,
199,
199,
646,
3816,
199,
504,
1331,
492,
1331,
199,
199,
504,
1275,
2119,
4073,
492,
14132,
4073,
199,
199,
504,
1335,
65,
758,
14,
5559,
492,
627,
199,
199,
533,
6935,
6105,
4073,
8,
6105,
4073,
304,
272,
408,
14426,
4750,
27616,
15,
785,
2943,
1041,
339,
6837,
654,
275,
359,
267,
298,
8327,
14,
785,
2,
272,
1622,
339,
30850,
20853,
275,
359,
267,
298,
22232,
14,
685,
273,
1221,
14,
1258,
401,
267,
298,
22232,
14,
4502,
14,
3885,
69,
640,
651,
401,
267,
298,
1023,
14,
576,
401,
267,
298,
8327,
14,
4502,
401,
267,
298,
18853,
14,
2888,
2,
272,
1622,
339,
768,
4639,
272,
347,
2454,
8,
7516,
12,
1021,
3422,
12,
3376,
29,
797,
304,
267,
340,
9531,
905,
1023,
6611,
576,
937,
2356,
5851,
1216,
26,
327,
5851,
87,
1717,
65,
11,
288,
327,
6935,
11449,
4898,
4829,
315,
5851,
87,
1717,
65,
12,
436,
4642,
11449,
787,
3063,
1202,
3140,
14,
221,
8232,
642,
370,
3637,
21926,
14,
288,
372,
267,
340,
298,
4502,
14,
3885,
69,
640,
651,
2,
440,
315,
9531,
905,
2888,
937,
503,
298,
685,
273,
1221,
14,
1258,
2,
440,
315,
9531,
905,
2888,
6229,
288,
372,
398,
9045,
275,
9531,
905,
8327,
937,
398,
327,
6668,
314,
15187,
909,
3644,
2870,
1808,
17680,
13652,
3900,
14,
981,
12739,
3501,
2726,
267,
327,
334,
6777,
10022,
1163,
15187,
14593,
4634,
12,
1325,
314,
1642,
1242,
315,
652,
365,
3211,
9,
267,
4642,
3885,
69,
640,
651,
275,
9531,
905,
2888,
6611,
4502,
14,
3885,
69,
640,
651,
937,
267,
4642,
3885,
69,
640,
651,
63,
2177,
275,
1021,
3422,
59,
4502,
3885,
69,
640,
651,
61,
398,
1218,
10212,
6253,
63,
765,
275,
4642,
3885,
69,
640,
651,
63,
2177,
14,
2474,
14,
1623,
63,
368,
8,
589,
8772,
355,
289,
29,
2734,
671,
26,
671,
14,
2732,
63,
2469,
14,
5470,
63,
4239,
436,
440,
671,
14,
2732,
63,
2469,
14,
5470,
63,
1986,
436,
440,
671,
14,
5808,
14,
354,
508,
298,
1647,
531,
398,
3644,
63,
533,
63,
354,
275,
488,
398,
327,
8690,
17094,
2072,
4493,
687,
413,
14,
845,
267,
1242,
63,
4502,
63,
533,
275,
9045,
905,
4502,
6611,
1053,
6611,
533,
937,
340,
298,
1053,
2,
315,
9045,
905,
4502,
937,
587,
9045,
905,
4502,
6611,
2081,
6611,
533,
937,
398,
911,
63,
1235,
63,
10212,
63,
785,
63,
6253,
275,
756,
267,
367,
5261,
315,
1218,
10212,
6253,
63,
765,
14,
600,
14,
2297,
21263,
837,
288,
340,
5261,
508,
298,
842,
1618,
582,
355,
327,
2670,
370,
1852,
3238,
626,
652,
1159,
282,
15187,
3644,
367,
1242,
9045,
355,
950,
275,
5261,
14,
21908,
59,
16,
61,
355,
340,
950,
14,
354,
508,
1242,
63,
4502,
63,
533,
26,
490,
911,
63,
1235,
63,
10212,
63,
785,
63,
6253,
275,
715,
288,
916,
5261,
508,
298,
1222,
2,
436,
911,
63,
1235,
63,
10212,
63,
785,
63,
6253,
26,
355,
950,
275,
5261,
14,
21908,
59,
16,
61,
355,
3644,
63,
533,
63,
354,
275,
950,
14,
354,
14,
585,
355,
2059,
398,
340,
3644,
63,
533,
63,
354,
365,
488,
26,
288,
340,
3376,
26,
355,
870,
480,
4276,
370,
2342,
15187,
909,
3644,
531,
288,
372,
398,
327,
2372,
314,
3644,
2256,
367,
314,
15187,
909,
3644,
446,
440,
1415,
1325,
652,
365,
24606,
2556,
267,
367,
790,
12,
3644,
315,
3816,
14,
4611,
8,
7516,
905,
18853,
6611,
6253,
21473,
288,
340,
3644,
63,
533,
63,
354,
315,
3644,
905,
533,
6229,
355,
327,
298,
262,
2,
365,
1202,
2952,
3644,
905,
533,
937,
3955,
1172,
3680,
533,
2,
737,
314,
1284,
355,
9045,
905,
815,
6611,
10212,
63,
785,
63,
6253,
937,
275,
790,
355,
2059,
398,
2251,
275,
9045,
14,
5486,
480,
785,
401,
5009,
398,
327,
7356,
2342,
314,
15187,
909,
3644,
3016,
436,
675,
652,
370,
9658,
734,
11449,
267,
1279,
273,
1221,
275,
9531,
905,
2888,
6611,
685,
273,
1221,
14,
1258,
937,
267,
1279,
273,
1221,
63,
2177,
275,
1021,
3422,
59,
685,
273,
1221,
61,
267,
1083,
275,
1279,
273,
1221,
63,
2177,
14,
2474,
14,
1623,
63,
368,
8,
589,
628,
44,
2,
435,
3644,
63,
533,
63,
354,
435,
298,
15027,
398,
12330,
63,
344,
275,
378,
267,
1453,
63,
344,
275,
378,
398,
367,
5261,
315,
1083,
14,
600,
14,
2297,
21263,
837,
288,
340,
5261,
508,
298,
692,
63,
18799,
685,
582,
355,
1453,
63,
344,
275,
12330,
63,
344,
288,
916,
5261,
315,
1689,
27566,
2084,
401,
298,
338,
5335,
2349,
355,
12330,
63,
344,
275,
5261,
14,
21908,
59
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
24,
1882,
199,
624,
199,
7384,
334,
67,
9,
7760,
377,
89,
1435,
1804,
287,
500,
89,
665,
2663,
32,
2663,
266,
14,
335,
30,
199,
199,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
1618,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
262,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
475,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
16847,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
70,
13399,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
199,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
452,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
38,
3061,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
5580,
4149,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
2673,
2477,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
1877,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
18061,
4141,
14,
199,
624,
199,
199,
646,
3816,
199,
504,
1331,
492,
1331,
199,
199,
504,
1275,
2119,
4073,
492,
14132,
4073,
199,
199,
504,
1335,
65,
758,
14,
5559,
492,
627,
199,
199,
533,
6935,
6105,
4073,
8,
6105,
4073,
304,
272,
408,
14426,
4750,
27616,
15,
785,
2943,
1041,
339,
6837,
654,
275,
359,
267,
298,
8327,
14,
785,
2,
272,
1622,
339,
30850,
20853,
275,
359,
267,
298,
22232,
14,
685,
273,
1221,
14,
1258,
401,
267,
298,
22232,
14,
4502,
14,
3885,
69,
640,
651,
401,
267,
298,
1023,
14,
576,
401,
267,
298,
8327,
14,
4502,
401,
267,
298,
18853,
14,
2888,
2,
272,
1622,
339,
768,
4639,
272,
347,
2454,
8,
7516,
12,
1021,
3422,
12,
3376,
29,
797,
304,
267,
340,
9531,
905,
1023,
6611,
576,
937,
2356,
5851,
1216,
26,
327,
5851,
87,
1717,
65,
11,
288,
327,
6935,
11449,
4898,
4829,
315,
5851,
87,
1717,
65,
12,
436,
4642,
11449,
787,
3063,
1202,
3140,
14,
221,
8232,
642,
370,
3637,
21926,
14,
288,
372,
267,
340,
298,
4502,
14,
3885,
69,
640,
651,
2,
440,
315,
9531,
905,
2888,
937,
503,
298,
685,
273,
1221,
14,
1258,
2,
440,
315,
9531,
905,
2888,
6229,
288,
372,
398,
9045,
275,
9531,
905,
8327,
937,
398,
327,
6668,
314,
15187,
909,
3644,
2870,
1808,
17680,
13652,
3900,
14,
981,
12739,
3501,
2726,
267,
327,
334,
6777,
10022,
1163,
15187,
14593,
4634,
12,
1325,
314,
1642,
1242,
315,
652,
365,
3211,
9,
267,
4642,
3885,
69,
640,
651,
275,
9531,
905,
2888,
6611,
4502,
14,
3885,
69,
640,
651,
937,
267,
4642,
3885,
69,
640,
651,
63,
2177,
275,
1021,
3422,
59,
4502,
3885,
69,
640,
651,
61,
398,
1218,
10212,
6253,
63,
765,
275,
4642,
3885,
69,
640,
651,
63,
2177,
14,
2474,
14,
1623,
63,
368,
8,
589,
8772,
355,
289,
29,
2734,
671,
26,
671,
14,
2732,
63,
2469,
14,
5470,
63,
4239,
436,
440,
671,
14,
2732,
63,
2469,
14,
5470,
63,
1986,
436,
440,
671,
14,
5808,
14,
354,
508,
298,
1647,
531,
398,
3644,
63,
533,
63,
354,
275,
488,
398,
327,
8690,
17094,
2072,
4493,
687,
413,
14,
845,
267,
1242,
63,
4502,
63,
533,
275,
9045,
905,
4502,
6611,
1053,
6611,
533,
937,
340,
298,
1053,
2,
315,
9045,
905,
4502,
937,
587,
9045,
905,
4502,
6611,
2081,
6611,
533,
937,
398,
911,
63,
1235,
63,
10212,
63,
785,
63,
6253,
275,
756,
267,
367,
5261,
315,
1218,
10212,
6253,
63,
765,
14,
600,
14,
2297,
21263,
837,
288,
340,
5261,
508,
298,
842,
1618,
582,
355,
327,
2670,
370,
1852,
3238,
626,
652,
1159,
282,
15187,
3644,
367,
1242,
9045,
355,
950,
275,
5261,
14,
21908,
59,
16,
61,
355,
340,
950,
14,
354,
508,
1242,
63,
4502,
63,
533,
26,
490,
911,
63,
1235,
63,
10212,
63,
785,
63,
6253,
275,
715,
288,
916,
5261,
508,
298,
1222,
2,
436,
911,
63,
1235,
63,
10212,
63,
785,
63,
6253,
26,
355,
950,
275,
5261,
14,
21908,
59,
16,
61,
355,
3644,
63,
533,
63,
354,
275,
950,
14,
354,
14,
585,
355,
2059,
398,
340,
3644,
63,
533,
63,
354,
365,
488,
26,
288,
340,
3376,
26,
355,
870,
480,
4276,
370,
2342,
15187,
909,
3644,
531,
288,
372,
398,
327,
2372,
314,
3644,
2256,
367,
314,
15187,
909,
3644,
446,
440,
1415,
1325,
652,
365,
24606,
2556,
267,
367,
790,
12,
3644,
315,
3816,
14,
4611,
8,
7516,
905,
18853,
6611,
6253,
21473,
288,
340,
3644,
63,
533,
63,
354,
315,
3644,
905,
533,
6229,
355,
327,
298,
262,
2,
365,
1202,
2952,
3644,
905,
533,
937,
3955,
1172,
3680,
533,
2,
737,
314,
1284,
355,
9045,
905,
815,
6611,
10212,
63,
785,
63,
6253,
937,
275,
790,
355,
2059,
398,
2251,
275,
9045,
14,
5486,
480,
785,
401,
5009,
398,
327,
7356,
2342,
314,
15187,
909,
3644,
3016,
436,
675,
652,
370,
9658,
734,
11449,
267,
1279,
273,
1221,
275,
9531,
905,
2888,
6611,
685,
273,
1221,
14,
1258,
937,
267,
1279,
273,
1221,
63,
2177,
275,
1021,
3422,
59,
685,
273,
1221,
61,
267,
1083,
275,
1279,
273,
1221,
63,
2177,
14,
2474,
14,
1623,
63,
368,
8,
589,
628,
44,
2,
435,
3644,
63,
533,
63,
354,
435,
298,
15027,
398,
12330,
63,
344,
275,
378,
267,
1453,
63,
344,
275,
378,
398,
367,
5261,
315,
1083,
14,
600,
14,
2297,
21263,
837,
288,
340,
5261,
508,
298,
692,
63,
18799,
685,
582,
355,
1453,
63,
344,
275,
12330,
63,
344,
288,
916,
5261,
315,
1689,
27566,
2084,
401,
298,
338,
5335,
2349,
355,
12330,
63,
344,
275,
5261,
14,
21908,
59,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jeonghoonkang/BerePi
|
apps/logger/berepi_logger.py
|
1
|
1372
|
# -*- coding: utf-8 -*-
# author : http://github.com/jeonghoonkang
import logging
#import logging.config
from logging.handlers import RotatingFileHandler
#logging.config.fileConfig('logging.conf')
LOG_FILENAME = "/home/pi/devel/BerePi/logs/berelogger.log"
logger = logging.getLogger('BereLogger')
logger.setLevel(logging.DEBUG)
# Choose TimeRoatatingFileHandler or RotatingFileHandler
#handler = logging.handlers.TimedRotatingFileHandler(filename=LOG_FILENAME, when="midnight", interval=1, encoding="utf-8")
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, mode='a', maxBytes=2000, backupCount=1)
handler.formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
logger.addHandler(handler)
def berelog(msg_name, value):
print LOG_FILENAME
logger.info(msg_name + ' ==> ' + value)
def berelog(msg):
print LOG_FILENAME
logger.info(msg)
if __name__ == "__main__":
berelog('sesnor type co2', '25')
# 'application' code
#logger.debug('debug message')
#logger.info('info message')
#logger.warn('warn message')
#logger.error('error message')
#logger.critical('critical message')
"""
if you want to use, this berepi_logger
import logging, and use berelog('*****')
"""
'''
To do:
LOG_FILENAME has to have sensor name on the file name
'''
|
bsd-2-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
4132,
520,
1455,
921,
5031,
14,
957,
15,
6532,
951,
526,
265,
75,
621,
199,
199,
646,
2050,
199,
3,
646,
2050,
14,
888,
199,
504,
2050,
14,
5586,
492,
20423,
1958,
21982,
199,
199,
3,
4806,
14,
888,
14,
493,
2028,
360,
4806,
14,
2190,
358,
199,
4947,
63,
15440,
275,
3286,
4219,
15,
1038,
15,
27870,
15,
3655,
264,
10542,
15,
7270,
15,
1235,
264,
2921,
14,
793,
2,
199,
199,
2921,
275,
2050,
14,
5572,
360,
3655,
264,
4455,
358,
199,
2921,
14,
13548,
8,
4806,
14,
5287,
9,
199,
199,
3,
29826,
4703,
3863,
292,
1958,
21982,
503,
20423,
1958,
21982,
221,
199,
3,
2232,
275,
2050,
14,
5586,
14,
28682,
14728,
1958,
21982,
8,
1501,
29,
4947,
63,
15440,
12,
1380,
628,
8523,
14873,
401,
6252,
29,
17,
12,
2644,
628,
1624,
13,
24,
531,
199,
2232,
275,
2050,
14,
5586,
14,
14728,
1958,
21982,
8,
4947,
63,
15440,
12,
818,
534,
65,
297,
1390,
5571,
29,
8269,
12,
6902,
2353,
29,
17,
9,
199,
2232,
14,
8911,
275,
2050,
14,
7772,
24713,
18331,
9,
83,
359,
2840,
20056,
9,
83,
61,
2818,
1188,
9,
83,
297,
1434,
5045,
9569,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
358,
199,
199,
2921,
14,
18826,
8,
2232,
9,
199,
199,
318,
506,
264,
793,
8,
1328,
63,
354,
12,
574,
304,
272,
870,
5051,
63,
15440,
272,
2512,
14,
815,
8,
1328,
63,
354,
435,
283,
25375,
283,
435,
574,
9,
199,
199,
318,
506,
264,
793,
8,
1328,
304,
272,
870,
5051,
63,
15440,
272,
2512,
14,
815,
8,
1328,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
339,
506,
264,
793,
360,
874,
6505,
730,
512,
18,
297,
283,
821,
358,
2286,
327,
283,
3578,
7,
1233,
272,
327,
2921,
14,
1757,
360,
1757,
1245,
358,
272,
327,
2921,
14,
815,
360,
815,
1245,
358,
272,
327,
2921,
14,
4050,
360,
4050,
1245,
358,
272,
327,
2921,
14,
705,
360,
705,
1245,
358,
272,
327,
2921,
14,
13138,
360,
13138,
1245,
358,
272,
408,
489,
340,
1265,
2934,
370,
675,
12,
642,
506,
264,
1038,
63,
2921,
489,
492,
2050,
12,
436,
675,
506,
264,
793,
360,
1116,
13418,
272,
408,
421,
199,
2344,
199,
1378,
886,
26,
272,
5051,
63,
15440,
965,
370,
1172,
8778,
536,
641,
314,
570,
536,
199,
199,
2344,
4388,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
4132,
520,
1455,
921,
5031,
14,
957,
15,
6532,
951,
526,
265,
75,
621,
199,
199,
646,
2050,
199,
3,
646,
2050,
14,
888,
199,
504,
2050,
14,
5586,
492,
20423,
1958,
21982,
199,
199,
3,
4806,
14,
888,
14,
493,
2028,
360,
4806,
14,
2190,
358,
199,
4947,
63,
15440,
275,
3286,
4219,
15,
1038,
15,
27870,
15,
3655,
264,
10542,
15,
7270,
15,
1235,
264,
2921,
14,
793,
2,
199,
199,
2921,
275,
2050,
14,
5572,
360,
3655,
264,
4455,
358,
199,
2921,
14,
13548,
8,
4806,
14,
5287,
9,
199,
199,
3,
29826,
4703,
3863,
292,
1958,
21982,
503,
20423,
1958,
21982,
221,
199,
3,
2232,
275,
2050,
14,
5586,
14,
28682,
14728,
1958,
21982,
8,
1501,
29,
4947,
63,
15440,
12,
1380,
628,
8523,
14873,
401,
6252,
29,
17,
12,
2644,
628,
1624,
13,
24,
531,
199,
2232,
275,
2050,
14,
5586,
14,
14728,
1958,
21982,
8,
4947,
63,
15440,
12,
818,
534,
65,
297,
1390,
5571,
29,
8269,
12,
6902,
2353,
29,
17,
9,
199,
2232,
14,
8911,
275,
2050,
14,
7772,
24713,
18331,
9,
83,
359,
2840,
20056,
9,
83,
61,
2818,
1188,
9,
83,
297,
1434,
5045,
9569,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
358,
199,
199,
2921,
14,
18826,
8,
2232,
9,
199,
199,
318,
506,
264,
793,
8,
1328,
63,
354,
12,
574,
304,
272,
870,
5051,
63,
15440,
272,
2512,
14,
815,
8,
1328,
63,
354,
435,
283,
25375,
283,
435,
574,
9,
199,
199,
318,
506,
264,
793,
8,
1328,
304,
272,
870,
5051,
63,
15440,
272,
2512,
14,
815,
8,
1328,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
339,
506,
264,
793,
360,
874,
6505,
730,
512,
18,
297,
283,
821,
358,
2286,
327,
283,
3578,
7,
1233,
272,
327,
2921,
14,
1757,
360,
1757,
1245,
358,
272,
327,
2921,
14,
815,
360,
815,
1245,
358,
272,
327,
2921,
14,
4050,
360,
4050,
1245,
358,
272,
327,
2921,
14,
705,
360,
705,
1245,
358,
272,
327,
2921,
14,
13138,
360,
13138,
1245,
358,
272,
408,
489,
340,
1265,
2934,
370,
675,
12,
642,
506,
264,
1038,
63,
2921,
489,
492,
2050,
12,
436,
675,
506,
264,
793,
360,
1116,
13418,
272,
408,
421,
199,
2344,
199,
1378,
886,
26,
272,
5051,
63,
15440,
965,
370,
1172,
8778,
536,
641,
314,
570,
536,
199,
199,
2344,
4388,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
kraja1/bfgminer-bfgminer
|
api-example.py
|
13
|
1510
|
#!/usr/bin/python
# Copyright 2013 Christian Berendt
# Copyright 2013 Luke Dashjr
#
# 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. See COPYING for more details.
import argparse
import json
import logging
import pprint
import socket
logging.basicConfig(
format='%(asctime)s %(levelname)s %(message)s',
level=logging.DEBUG
)
parser = argparse.ArgumentParser()
parser.add_argument("command", default="summary", nargs='?')
parser.add_argument("parameter", default="", nargs='?')
parser.add_argument("--hostname", default="localhost")
parser.add_argument("--port", type=int, default=4028)
args = parser.parse_args()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((args.hostname, args.port))
except socket.error, e:
logging.error(e)
try:
s.send("{\"command\" : \"%s\", \"parameter\" : \"%s\"}"
% (args.command, args.parameter)
)
except socket.error, e:
logging.error(e)
data = ''
while True:
try:
newdata = s.recv(1024)
if newdata:
data += newdata
else:
break
except socket.error, e:
break
try:
s.close()
except socket.error,e:
logging.error(e)
if data:
data = json.loads(data.replace('\x00', ''))
pp = pprint.PrettyPrinter()
pp.pprint(data)
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1898,
6171,
2799,
18824,
5653,
6423,
828,
3583,
199,
3,
1898,
6171,
30936,
415,
577,
1119,
32099,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
199,
3,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
27,
1902,
1015,
650,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
199,
3,
1015,
14,
221,
1666,
9685,
367,
1655,
2436,
14,
199,
199,
646,
7534,
199,
646,
2022,
199,
646,
2050,
199,
646,
10933,
199,
646,
2838,
199,
199,
4806,
14,
19602,
8,
268,
1475,
29342,
18331,
9,
83,
2818,
20056,
9,
83,
2818,
1188,
9,
83,
297,
268,
2166,
29,
4806,
14,
5287,
199,
9,
199,
199,
2087,
275,
7534,
14,
10730,
342,
199,
2087,
14,
525,
63,
2094,
480,
1531,
401,
849,
628,
4705,
401,
9237,
534,
18478,
199,
2087,
14,
525,
63,
2094,
480,
5329,
401,
849,
8772,
9237,
534,
18478,
199,
2087,
14,
525,
63,
2094,
6739,
4269,
401,
849,
628,
5967,
531,
199,
2087,
14,
525,
63,
2094,
6739,
719,
401,
730,
29,
442,
12,
849,
29,
13314,
24,
9,
199,
589,
275,
1798,
14,
1122,
63,
589,
342,
199,
199,
83,
275,
2838,
14,
3450,
8,
3450,
14,
5699,
63,
11367,
12,
2838,
14,
9469,
63,
9484,
9,
199,
199,
893,
26,
272,
308,
14,
2242,
1332,
589,
14,
4269,
12,
1249,
14,
719,
430,
199,
2590,
2838,
14,
705,
12,
325,
26,
272,
2050,
14,
705,
8,
69,
9,
199,
199,
893,
26,
272,
308,
14,
2254,
13076,
4451,
1531,
4451,
520,
18321,
83,
20756,
8441,
5329,
4451,
520,
18321,
83,
60,
3570,
2,
288,
450,
334,
589,
14,
1531,
12,
1249,
14,
5329,
9,
881,
776,
199,
2590,
2838,
14,
705,
12,
325,
26,
272,
2050,
14,
705,
8,
69,
9,
421,
199,
576,
275,
2125,
199,
6710,
715,
26,
272,
862,
26,
267,
892,
576,
275,
308,
14,
7637,
8,
7727,
9,
267,
340,
892,
576,
26,
288,
666,
847,
892,
576,
267,
587,
26,
288,
2059,
272,
871,
2838,
14,
705,
12,
325,
26,
267,
2059,
199,
199,
893,
26,
272,
308,
14,
1600,
342,
199,
2590,
2838,
14,
705,
12,
69,
26,
272,
2050,
14,
705,
8,
69,
9,
199,
199,
692,
666,
26,
272,
666,
275,
2022,
14,
3640,
8,
576,
14,
1814,
2258,
88,
383,
297,
12381,
272,
11618,
275,
10933,
14,
27153,
14131,
342,
272,
11618,
14,
15380,
8,
576,
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
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1898,
6171,
2799,
18824,
5653,
6423,
828,
3583,
199,
3,
1898,
6171,
30936,
415,
577,
1119,
32099,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
199,
3,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
27,
1902,
1015,
650,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
199,
3,
1015,
14,
221,
1666,
9685,
367,
1655,
2436,
14,
199,
199,
646,
7534,
199,
646,
2022,
199,
646,
2050,
199,
646,
10933,
199,
646,
2838,
199,
199,
4806,
14,
19602,
8,
268,
1475,
29342,
18331,
9,
83,
2818,
20056,
9,
83,
2818,
1188,
9,
83,
297,
268,
2166,
29,
4806,
14,
5287,
199,
9,
199,
199,
2087,
275,
7534,
14,
10730,
342,
199,
2087,
14,
525,
63,
2094,
480,
1531,
401,
849,
628,
4705,
401,
9237,
534,
18478,
199,
2087,
14,
525,
63,
2094,
480,
5329,
401,
849,
8772,
9237,
534,
18478,
199,
2087,
14,
525,
63,
2094,
6739,
4269,
401,
849,
628,
5967,
531,
199,
2087,
14,
525,
63,
2094,
6739,
719,
401,
730,
29,
442,
12,
849,
29,
13314,
24,
9,
199,
589,
275,
1798,
14,
1122,
63,
589,
342,
199,
199,
83,
275,
2838,
14,
3450,
8,
3450,
14,
5699,
63,
11367,
12,
2838,
14,
9469,
63,
9484,
9,
199,
199,
893,
26,
272,
308,
14,
2242,
1332,
589,
14,
4269,
12,
1249,
14,
719,
430,
199,
2590,
2838,
14,
705,
12,
325,
26,
272,
2050,
14,
705,
8,
69,
9,
199,
199,
893,
26,
272,
308,
14,
2254,
13076,
4451,
1531,
4451,
520,
18321,
83,
20756,
8441,
5329,
4451,
520,
18321,
83,
60,
3570,
2,
288,
450,
334,
589,
14,
1531,
12,
1249,
14,
5329,
9,
881,
776,
199,
2590,
2838,
14,
705,
12,
325,
26,
272,
2050,
14,
705,
8,
69,
9,
421,
199,
576,
275,
2125,
199,
6710,
715,
26,
272,
862,
26,
267,
892,
576,
275,
308,
14,
7637,
8,
7727,
9,
267,
340,
892,
576,
26,
288,
666,
847,
892,
576,
267,
587,
26,
288,
2059,
272,
871,
2838,
14,
705,
12,
325,
26,
267,
2059,
199,
199,
893,
26,
272,
308,
14,
1600,
342,
199,
2590,
2838,
14,
705,
12,
69,
26,
272,
2050,
14,
705,
8,
69,
9,
199,
199,
692,
666,
26,
272,
666,
275,
2022,
14,
3640,
8,
576,
14,
1814,
2258,
88,
383,
297,
12381,
272,
11618,
275,
10933,
14,
27153,
14131,
342,
272,
11618,
14,
15380,
8,
576,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
cvsuser-chromium/chromium
|
chrome/common/extensions/docs/examples/apps/hello-python/main.py
|
148
|
5230
|
#!/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.
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.api import users
from google.appengine.api import urlfetch
from google.appengine.ext.webapp import template
from google.appengine.api.urlfetch import DownloadError
import oauth2
import urllib
import logging
import os
import time
from django.utils import simplejson
# Configuration
CONFIG = {
'oauth_consumer_key': 'anonymous',
'oauth_consumer_secret': 'anonymous',
'license_server': 'https://www.googleapis.com',
'license_path': '%(server)s/chromewebstore/v1/licenses/%(appid)s/%(userid)s',
'oauth_token': 'INSERT OAUTH TOKEN HERE',
'oauth_token_secret': 'INSERT OAUTH TOKEN SECRET HERE',
'app_id': 'INSERT APPLICATION ID HERE',
}
# Check to see if the server has been deployed. In the dev server, this
# env variable will start with 'Development', in production, it will start with
# 'Google App Engine'
IS_PRODUCTION = os.environ['SERVER_SOFTWARE'].startswith('Google App Engine')
# Valid access levels that may be returned by the license server.
VALID_ACCESS_LEVELS = ['FREE_TRIAL', 'FULL']
def fetch_license_data(userid):
"""Fetches the license for a given user by making an OAuth signed request
to the license server.
Args:
userid OpenID of the user you are checking access for.
Returns:
The server's response as text.
"""
url = CONFIG['license_path'] % {
'server': CONFIG['license_server'],
'appid': CONFIG['app_id'],
'userid': urllib.quote_plus(userid),
}
oauth_token = oauth2.Token(**{
'key': CONFIG['oauth_token'],
'secret': CONFIG['oauth_token_secret']
})
oauth_consumer = oauth2.Consumer(**{
'key': CONFIG['oauth_consumer_key'],
'secret': CONFIG['oauth_consumer_secret']
})
logging.debug('Requesting %s' % url)
client = oauth2.Client(oauth_consumer, oauth_token)
resp, content = client.request(url, 'GET')
logging.debug('Got response code %s, content %s' % (resp, content))
return content
def parse_license_data(userid):
"""Returns the license for a given user as a structured object.
Args:
userid: The OpenID of the user to check.
Returns:
An object with the following parameters:
error: True if something went wrong, False otherwise.
message: A descriptive message if error is True.
access: One of 'NO', 'FREE_TRIAL', or 'FULL' depending on the access.
"""
license = {'error': False, 'message': '', 'access': 'NO'}
try:
response_text = fetch_license_data(userid)
try:
logging.debug('Attempting to JSON parse: %s' % response_text)
json = simplejson.loads(response_text)
logging.debug('Got license server response: %s' % json)
except ValueError:
logging.exception('Could not parse response as JSON: %s' % response_text)
license['error'] = True
license['message'] = 'Could not parse the license server response'
except DownloadError:
logging.exception('Could not fetch license data')
license['error'] = True
license['message'] = 'Could not fetch license data'
if json.has_key('error'):
license['error'] = True
license['message'] = json['error']['message']
elif json['result'] == 'YES' and json['accessLevel'] in VALID_ACCESS_LEVELS:
license['access'] = json['accessLevel']
return license
class MainHandler(webapp.RequestHandler):
"""Request handler class."""
def get(self):
"""Handler for GET requests."""
user = users.get_current_user()
if user:
if IS_PRODUCTION:
# We should use federated_identity in production, since the license
# server requires an OpenID
userid = user.federated_identity()
else:
# On the dev server, we won't have access to federated_identity, so
# just use a default OpenID which will never return YES.
# If you want to test different response values on the development
# server, just change this default value (e.g. append '-yes' or
# '-trial').
userid = ('https://www.google.com/accounts/o8/id?'
'id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
license_data = parse_license_data(userid)
template_data = {
'license': license_data,
'user_name': user.nickname(),
'user_id': userid,
'user_logout': users.create_logout_url(self.request.uri),
}
else:
# Force the OpenID login endpoint to be for Google accounts only, since
# the license server doesn't support any other type of OpenID provider.
login_url = users.create_login_url(dest_url='/',
federated_identity='google.com/accounts/o8/id')
template_data = {
'user_login': login_url,
}
# Render a simple template
path = os.path.join(os.path.dirname(__file__), 'templates', 'index.html')
self.response.out.write(template.render(path, template_data))
if __name__ == '__main__':
application = webapp.WSGIApplication([
('/', MainHandler),
], debug=False)
util.run_wsgi_app(application)
|
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,
504,
6233,
14,
15358,
14,
832,
492,
24812,
199,
504,
6233,
14,
15358,
14,
832,
14,
22632,
492,
4884,
199,
504,
6233,
14,
15358,
14,
1246,
492,
4390,
199,
504,
6233,
14,
15358,
14,
1246,
492,
7629,
29429,
199,
504,
6233,
14,
15358,
14,
832,
14,
22632,
492,
1978,
199,
504,
6233,
14,
15358,
14,
1246,
14,
300,
29429,
492,
17955,
547,
199,
646,
9725,
18,
199,
646,
4011,
199,
646,
2050,
199,
646,
747,
199,
646,
900,
199,
504,
1639,
14,
1208,
492,
13804,
199,
199,
3,
11595,
199,
199,
5569,
275,
469,
523,
283,
6126,
63,
8542,
63,
498,
356,
283,
12628,
297,
523,
283,
6126,
63,
8542,
63,
4731,
356,
283,
12628,
297,
523,
283,
1682,
63,
1000,
356,
283,
2859,
921,
1544,
14,
17533,
14,
957,
297,
523,
283,
1682,
63,
515,
356,
9487,
1000,
9,
83,
15,
9887,
2520,
1617,
15,
86,
17,
15,
2383,
21275,
571,
344,
9,
83,
21275,
19737,
9,
83,
297,
523,
283,
6126,
63,
1418,
356,
283,
10258,
593,
5580,
18243,
869,
28106,
297,
523,
283,
6126,
63,
1418,
63,
4731,
356,
283,
10258,
593,
5580,
18243,
5795,
11771,
869,
28106,
297,
523,
283,
571,
63,
344,
356,
283,
10258,
19525,
17939,
2870,
869,
28106,
297,
199,
93,
199,
199,
3,
2670,
370,
1937,
340,
314,
1654,
965,
2757,
26181,
14,
221,
1010,
314,
4866,
1654,
12,
642,
199,
3,
2589,
1750,
911,
1343,
543,
283,
23753,
297,
315,
9920,
12,
652,
911,
1343,
543,
199,
3,
283,
13266,
4693,
12580,
7,
199,
1311,
63,
2514,
4980,
5430,
275,
747,
14,
2314,
459,
6613,
63,
26734,
2278,
2460,
360,
13266,
4693,
12580,
358,
199,
199,
3,
4821,
2879,
11106,
626,
1443,
506,
2138,
701,
314,
4190,
1654,
14,
199,
5600,
63,
11074,
63,
906,
2524,
5296,
275,
788,
28170,
63,
1766,
4938,
297,
283,
14742,
418,
421,
199,
318,
5267,
63,
1682,
63,
576,
8,
19737,
304,
523,
408,
11135,
397,
314,
4190,
367,
282,
1627,
922,
701,
10663,
376,
11715,
10514,
1056,
523,
370,
314,
4190,
1654,
14,
819,
3033,
26,
272,
25580,
25463,
402,
314,
922,
1265,
787,
7907,
2879,
367,
14,
819,
1803,
26,
272,
710,
1654,
1159,
1177,
465,
1318,
14,
523,
408,
523,
1166,
275,
15869,
459,
1682,
63,
515,
418,
450,
469,
272,
283,
1000,
356,
15869,
459,
1682,
63,
1000,
995,
272,
283,
571,
344,
356,
15869,
459,
571,
63,
344,
995,
272,
283,
19737,
356,
4011,
14,
3513,
63,
6666,
8,
19737,
395,
523,
789,
819,
9725,
63,
1418,
275,
9725,
18,
14,
3264,
25679,
272,
283,
498,
356,
15869,
459,
6126,
63,
1418,
995,
272,
283,
4731,
356,
15869,
459,
6126,
63,
1418,
63,
4731,
418,
523,
3828,
819,
9725,
63,
8542,
275,
9725,
18,
14,
18186,
25679,
272,
283,
498,
356,
15869,
459,
6126,
63,
8542,
63,
498,
995,
272,
283,
4731,
356,
15869,
459,
6126,
63,
8542,
63,
4731,
418,
523,
3828,
819,
2050,
14,
1757,
360,
2017,
316,
450,
83,
7,
450,
1166,
9,
523,
1890,
275,
9725,
18,
14,
3041,
8,
6126,
63,
8542,
12,
9725,
63,
1418,
9,
523,
3085,
12,
1564,
275,
1890,
14,
1069,
8,
633,
12,
283,
2970,
358,
523,
2050,
14,
1757,
360,
13662,
1177,
1233,
450,
83,
12,
1564,
450,
83,
7,
450,
334,
4518,
12,
1564,
430,
523,
372,
1564,
421,
199,
318,
2198,
63,
1682,
63,
576,
8,
19737,
304,
523,
408,
3407,
314,
4190,
367,
282,
1627,
922,
465,
282,
21781,
909,
14,
819,
3033,
26,
272,
25580,
26,
710,
25463,
402,
314,
922,
370,
1104,
14,
819,
1803,
26,
272,
1626,
909,
543,
314,
2569,
2633,
26,
489,
1125,
26,
221,
715,
340,
6020,
22396,
6835,
12,
756,
4257,
14,
489,
1245,
26,
437,
30262,
1245,
340,
1125,
365,
715,
14,
489,
2879,
26,
7309,
402,
283,
2826,
297,
283,
28170,
63,
1766,
4938,
297,
503,
283,
14742,
7,
10298,
641,
314,
2879,
14,
523,
408,
523,
4190,
275,
791,
705,
356,
756,
12,
283,
1188,
356,
3260,
283,
2732,
356,
283,
2826,
936,
523,
862,
26,
272,
1177,
63,
505,
275,
5267,
63,
1682,
63,
576,
8,
19737,
9,
272,
862,
26,
489,
2050,
14,
1757,
360,
15322,
1337,
370,
4840,
2198,
26,
450,
83,
7,
450,
1177,
63,
505,
9,
489,
2022,
275,
13804,
14,
3640,
8,
1310,
63,
505,
9,
489,
2050,
14,
1757,
360,
13662,
4190,
1654,
1177,
26,
450,
83,
7,
450,
2022,
9,
272,
871,
1722,
26,
489,
2050,
14,
1971,
360,
6531,
440,
2198,
1177,
465,
4840,
26,
450,
83,
7,
450,
1177,
63,
505,
9,
489,
4190,
459,
705,
418,
275,
715,
489,
4190,
459,
1188,
418,
275,
283,
6531,
440,
2198,
314,
4190,
1654,
1177,
7,
523,
871,
17955,
547,
26,
272,
2050,
14,
1971,
360,
6531,
440,
5267,
4190,
666,
358,
272,
4190,
459,
705,
418,
275,
715,
272,
4190,
459,
1188,
418,
275,
283,
6531,
440,
5267,
4190,
666,
7,
819,
340,
2022,
14,
1989,
63,
498,
360,
705,
735,
272,
4190,
459,
705,
418,
275,
715,
272,
4190,
459,
1188,
418,
275,
2022,
459,
705,
2545,
1188,
418,
523,
916,
2022,
459,
1099,
418,
508,
283,
15641,
7,
436,
2022,
459,
2732,
4670,
418,
315,
22049,
63,
11074,
63,
906,
2524,
5296,
26,
272,
4190,
459,
2732,
418,
275,
2022,
459,
2732,
4670,
418,
819,
372,
4190,
421,
199,
533,
11298,
2461,
8,
22632,
14,
11149,
304,
523,
408,
2017,
3016,
1021,
1041,
523,
347,
664,
8,
277,
304,
272,
408,
2461,
367,
9576,
4145,
1041,
272,
922,
275,
4390,
14,
362,
63,
1818,
63,
751,
342,
272,
340,
922,
26,
489,
340,
2281,
63,
2514,
4980,
5430,
26,
267,
327,
2136,
1077,
675,
1964,
424,
972,
63,
5582,
315,
9920,
12,
3967,
314,
4190,
267,
327,
1654,
5074,
376,
25463,
267,
25580,
275,
922,
14,
771,
424,
972,
63,
5582,
342,
489,
587,
26,
267,
327,
4068,
314
] |
[
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,
504,
6233,
14,
15358,
14,
832,
492,
24812,
199,
504,
6233,
14,
15358,
14,
832,
14,
22632,
492,
4884,
199,
504,
6233,
14,
15358,
14,
1246,
492,
4390,
199,
504,
6233,
14,
15358,
14,
1246,
492,
7629,
29429,
199,
504,
6233,
14,
15358,
14,
832,
14,
22632,
492,
1978,
199,
504,
6233,
14,
15358,
14,
1246,
14,
300,
29429,
492,
17955,
547,
199,
646,
9725,
18,
199,
646,
4011,
199,
646,
2050,
199,
646,
747,
199,
646,
900,
199,
504,
1639,
14,
1208,
492,
13804,
199,
199,
3,
11595,
199,
199,
5569,
275,
469,
523,
283,
6126,
63,
8542,
63,
498,
356,
283,
12628,
297,
523,
283,
6126,
63,
8542,
63,
4731,
356,
283,
12628,
297,
523,
283,
1682,
63,
1000,
356,
283,
2859,
921,
1544,
14,
17533,
14,
957,
297,
523,
283,
1682,
63,
515,
356,
9487,
1000,
9,
83,
15,
9887,
2520,
1617,
15,
86,
17,
15,
2383,
21275,
571,
344,
9,
83,
21275,
19737,
9,
83,
297,
523,
283,
6126,
63,
1418,
356,
283,
10258,
593,
5580,
18243,
869,
28106,
297,
523,
283,
6126,
63,
1418,
63,
4731,
356,
283,
10258,
593,
5580,
18243,
5795,
11771,
869,
28106,
297,
523,
283,
571,
63,
344,
356,
283,
10258,
19525,
17939,
2870,
869,
28106,
297,
199,
93,
199,
199,
3,
2670,
370,
1937,
340,
314,
1654,
965,
2757,
26181,
14,
221,
1010,
314,
4866,
1654,
12,
642,
199,
3,
2589,
1750,
911,
1343,
543,
283,
23753,
297,
315,
9920,
12,
652,
911,
1343,
543,
199,
3,
283,
13266,
4693,
12580,
7,
199,
1311,
63,
2514,
4980,
5430,
275,
747,
14,
2314,
459,
6613,
63,
26734,
2278,
2460,
360,
13266,
4693,
12580,
358,
199,
199,
3,
4821,
2879,
11106,
626,
1443,
506,
2138,
701,
314,
4190,
1654,
14,
199,
5600,
63,
11074,
63,
906,
2524,
5296,
275,
788,
28170,
63,
1766,
4938,
297,
283,
14742,
418,
421,
199,
318,
5267,
63,
1682,
63,
576,
8,
19737,
304,
523,
408,
11135,
397,
314,
4190,
367,
282,
1627,
922,
701,
10663,
376,
11715,
10514,
1056,
523,
370,
314,
4190,
1654,
14,
819,
3033,
26,
272,
25580,
25463,
402,
314,
922,
1265,
787,
7907,
2879,
367,
14,
819,
1803,
26,
272,
710,
1654,
1159,
1177,
465,
1318,
14,
523,
408,
523,
1166,
275,
15869,
459,
1682,
63,
515,
418,
450,
469,
272,
283,
1000,
356,
15869,
459,
1682,
63,
1000,
995,
272,
283,
571,
344,
356,
15869,
459,
571,
63,
344,
995,
272,
283,
19737,
356,
4011,
14,
3513,
63,
6666,
8,
19737,
395,
523,
789,
819,
9725,
63,
1418,
275,
9725,
18,
14,
3264,
25679,
272,
283,
498,
356,
15869,
459,
6126,
63,
1418,
995,
272,
283,
4731,
356,
15869,
459,
6126,
63,
1418,
63,
4731,
418,
523,
3828,
819,
9725,
63,
8542,
275,
9725,
18,
14,
18186,
25679,
272,
283,
498,
356,
15869,
459,
6126,
63,
8542,
63,
498,
995,
272,
283,
4731,
356,
15869,
459,
6126,
63,
8542,
63,
4731,
418,
523,
3828,
819,
2050,
14,
1757,
360,
2017,
316,
450,
83,
7,
450,
1166,
9,
523,
1890,
275,
9725,
18,
14,
3041,
8,
6126,
63,
8542,
12,
9725,
63,
1418,
9,
523,
3085,
12,
1564,
275,
1890,
14,
1069,
8,
633,
12,
283,
2970,
358,
523,
2050,
14,
1757,
360,
13662,
1177,
1233,
450,
83,
12,
1564,
450,
83,
7,
450,
334,
4518,
12,
1564,
430,
523,
372,
1564,
421,
199,
318,
2198,
63,
1682,
63,
576,
8,
19737,
304,
523,
408,
3407,
314,
4190,
367,
282,
1627,
922,
465,
282,
21781,
909,
14,
819,
3033,
26,
272,
25580,
26,
710,
25463,
402,
314,
922,
370,
1104,
14,
819,
1803,
26,
272,
1626,
909,
543,
314,
2569,
2633,
26,
489,
1125,
26,
221,
715,
340,
6020,
22396,
6835,
12,
756,
4257,
14,
489,
1245,
26,
437,
30262,
1245,
340,
1125,
365,
715,
14,
489,
2879,
26,
7309,
402,
283,
2826,
297,
283,
28170,
63,
1766,
4938,
297,
503,
283,
14742,
7,
10298,
641,
314,
2879,
14,
523,
408,
523,
4190,
275,
791,
705,
356,
756,
12,
283,
1188,
356,
3260,
283,
2732,
356,
283,
2826,
936,
523,
862,
26,
272,
1177,
63,
505,
275,
5267,
63,
1682,
63,
576,
8,
19737,
9,
272,
862,
26,
489,
2050,
14,
1757,
360,
15322,
1337,
370,
4840,
2198,
26,
450,
83,
7,
450,
1177,
63,
505,
9,
489,
2022,
275,
13804,
14,
3640,
8,
1310,
63,
505,
9,
489,
2050,
14,
1757,
360,
13662,
4190,
1654,
1177,
26,
450,
83,
7,
450,
2022,
9,
272,
871,
1722,
26,
489,
2050,
14,
1971,
360,
6531,
440,
2198,
1177,
465,
4840,
26,
450,
83,
7,
450,
1177,
63,
505,
9,
489,
4190,
459,
705,
418,
275,
715,
489,
4190,
459,
1188,
418,
275,
283,
6531,
440,
2198,
314,
4190,
1654,
1177,
7,
523,
871,
17955,
547,
26,
272,
2050,
14,
1971,
360,
6531,
440,
5267,
4190,
666,
358,
272,
4190,
459,
705,
418,
275,
715,
272,
4190,
459,
1188,
418,
275,
283,
6531,
440,
5267,
4190,
666,
7,
819,
340,
2022,
14,
1989,
63,
498,
360,
705,
735,
272,
4190,
459,
705,
418,
275,
715,
272,
4190,
459,
1188,
418,
275,
2022,
459,
705,
2545,
1188,
418,
523,
916,
2022,
459,
1099,
418,
508,
283,
15641,
7,
436,
2022,
459,
2732,
4670,
418,
315,
22049,
63,
11074,
63,
906,
2524,
5296,
26,
272,
4190,
459,
2732,
418,
275,
2022,
459,
2732,
4670,
418,
819,
372,
4190,
421,
199,
533,
11298,
2461,
8,
22632,
14,
11149,
304,
523,
408,
2017,
3016,
1021,
1041,
523,
347,
664,
8,
277,
304,
272,
408,
2461,
367,
9576,
4145,
1041,
272,
922,
275,
4390,
14,
362,
63,
1818,
63,
751,
342,
272,
340,
922,
26,
489,
340,
2281,
63,
2514,
4980,
5430,
26,
267,
327,
2136,
1077,
675,
1964,
424,
972,
63,
5582,
315,
9920,
12,
3967,
314,
4190,
267,
327,
1654,
5074,
376,
25463,
267,
25580,
275,
922,
14,
771,
424,
972,
63,
5582,
342,
489,
587,
26,
267,
327,
4068,
314,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
beni55/django
|
django/conf/project_template/project_name/settings.py
|
31
|
2745
|
"""
Django settings for {{ project_name }} project.
Generated by 'django-admin startproject' using Django {{ django_version }}.
For more information on this file, see
https://docs.djangoproject.com/en/{{ docs_version }}/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{{ secret_key }}'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
]
ROOT_URLCONF = '{{ project_name }}.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
# Database
# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/{{ docs_version }}/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/{{ docs_version }}/howto/static-files/
STATIC_URL = '/static/'
|
bsd-3-clause
|
[
624,
199,
9323,
2202,
367,
8448,
2199,
63,
354,
3586,
2199,
14,
199,
199,
12706,
701,
283,
1176,
13,
2113,
1343,
1715,
7,
1808,
5634,
8448,
1639,
63,
1023,
3586,
14,
199,
199,
1858,
1655,
2556,
641,
642,
570,
12,
1937,
199,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
11299,
15,
1751,
15,
199,
199,
1858,
314,
2615,
769,
402,
2202,
436,
3932,
1338,
12,
1937,
199,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
1121,
15,
1751,
15,
199,
624,
199,
199,
646,
747,
199,
199,
3,
6516,
3792,
6272,
314,
2199,
2839,
642,
26,
747,
14,
515,
14,
904,
8,
5825,
63,
3022,
12,
19172,
199,
5825,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
29658,
421,
199,
3,
27534,
13,
928,
16367,
2202,
446,
625,
83,
10020,
367,
9920,
199,
3,
1666,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
21232,
15,
13605,
15,
1074,
513,
15,
199,
199,
3,
24143,
32712,
14750,
26,
4215,
314,
7565,
790,
1202,
315,
9920,
7565,
1,
199,
12961,
63,
3078,
275,
11400,
7565,
63,
498,
16339,
199,
199,
3,
24143,
32712,
14750,
26,
2793,
1133,
1255,
543,
3105,
19136,
641,
315,
9920,
1,
199,
5287,
275,
715,
199,
199,
17350,
63,
23775,
275,
942,
421,
199,
3,
13515,
5492,
199,
199,
15942,
63,
14219,
275,
359,
272,
283,
1176,
14,
2828,
14,
2113,
297,
272,
283,
1176,
14,
2828,
14,
1178,
297,
272,
283,
1176,
14,
2828,
14,
10778,
297,
272,
283,
1176,
14,
2828,
14,
11676,
297,
272,
283,
1176,
14,
2828,
14,
3431,
297,
272,
283,
1176,
14,
2828,
14,
18373,
297,
199,
61,
199,
199,
19987,
63,
13748,
275,
359,
272,
283,
1176,
14,
2828,
14,
11676,
14,
5754,
14,
4434,
6608,
297,
272,
283,
1176,
14,
5754,
14,
2330,
14,
7844,
6608,
297,
272,
283,
1176,
14,
5754,
14,
10088,
14,
13912,
25322,
297,
272,
283,
1176,
14,
2828,
14,
1178,
14,
5754,
14,
10348,
6608,
297,
272,
283,
1176,
14,
2828,
14,
1178,
14,
5754,
14,
4434,
10348,
6608,
297,
272,
283,
1176,
14,
2828,
14,
3431,
14,
5754,
14,
2209,
6608,
297,
272,
283,
1176,
14,
5754,
14,
4891,
19193,
316,
14,
56,
3160,
4558,
6608,
297,
272,
283,
1176,
14,
5754,
14,
4416,
14,
7676,
6608,
297,
199,
61,
199,
199,
5441,
63,
18125,
275,
11400,
2199,
63,
354,
3586,
14,
3603,
7,
199,
199,
25437,
275,
359,
272,
469,
267,
283,
18145,
356,
283,
1176,
14,
1160,
14,
7765,
14,
1176,
14,
9323,
17969,
297,
267,
283,
14455,
356,
990,
267,
283,
7121,
63,
14455,
356,
715,
12,
267,
283,
8808,
356,
469,
288,
283,
1100,
63,
10547,
356,
359,
355,
283,
1176,
14,
1160,
14,
1100,
63,
10547,
14,
1757,
297,
355,
283,
1176,
14,
1160,
14,
1100,
63,
10547,
14,
1069,
297,
355,
283,
1176,
14,
2828,
14,
1178,
14,
1100,
63,
10547,
14,
1178,
297,
355,
283,
1176,
14,
2828,
14,
3431,
14,
1100,
63,
10547,
14,
3431,
297,
288,
2156,
267,
1660,
272,
1660,
199,
61,
199,
199,
16828,
63,
24051,
275,
11400,
2199,
63,
354,
3586,
14,
6508,
14,
3578,
7,
421,
199,
3,
8692,
199,
3,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
1121,
15,
1751,
12645,
17439,
199,
199,
27260,
275,
469,
272,
283,
885,
356,
469,
267,
283,
15956,
356,
283,
1176,
14,
697,
14,
7765,
14,
10659,
19,
297,
267,
283,
2339,
356,
747,
14,
515,
14,
904,
8,
5825,
63,
3022,
12,
283,
697,
14,
10659,
19,
659,
272,
789,
199,
93,
421,
199,
3,
28220,
2072,
199,
3,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
11299,
15,
73,
1085,
78,
15,
199,
199,
13947,
63,
6012,
275,
283,
287,
13,
527,
7,
199,
199,
4961,
63,
15353,
275,
283,
11288,
7,
199,
199,
4701,
63,
41,
1085,
46,
275,
715,
199,
199,
4701,
63,
44,
709,
46,
275,
715,
199,
199,
4701,
63,
14226,
275,
715,
421,
199,
3,
13599,
1584,
334,
14391,
12,
15250,
12,
32658,
9,
199,
3,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
21232,
15,
1986,
13,
1725,
15,
199,
199,
10449,
63,
2632,
275,
1994,
1986,
4805,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
9323,
2202,
367,
8448,
2199,
63,
354,
3586,
2199,
14,
199,
199,
12706,
701,
283,
1176,
13,
2113,
1343,
1715,
7,
1808,
5634,
8448,
1639,
63,
1023,
3586,
14,
199,
199,
1858,
1655,
2556,
641,
642,
570,
12,
1937,
199,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
11299,
15,
1751,
15,
199,
199,
1858,
314,
2615,
769,
402,
2202,
436,
3932,
1338,
12,
1937,
199,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
1121,
15,
1751,
15,
199,
624,
199,
199,
646,
747,
199,
199,
3,
6516,
3792,
6272,
314,
2199,
2839,
642,
26,
747,
14,
515,
14,
904,
8,
5825,
63,
3022,
12,
19172,
199,
5825,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
29658,
421,
199,
3,
27534,
13,
928,
16367,
2202,
446,
625,
83,
10020,
367,
9920,
199,
3,
1666,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
21232,
15,
13605,
15,
1074,
513,
15,
199,
199,
3,
24143,
32712,
14750,
26,
4215,
314,
7565,
790,
1202,
315,
9920,
7565,
1,
199,
12961,
63,
3078,
275,
11400,
7565,
63,
498,
16339,
199,
199,
3,
24143,
32712,
14750,
26,
2793,
1133,
1255,
543,
3105,
19136,
641,
315,
9920,
1,
199,
5287,
275,
715,
199,
199,
17350,
63,
23775,
275,
942,
421,
199,
3,
13515,
5492,
199,
199,
15942,
63,
14219,
275,
359,
272,
283,
1176,
14,
2828,
14,
2113,
297,
272,
283,
1176,
14,
2828,
14,
1178,
297,
272,
283,
1176,
14,
2828,
14,
10778,
297,
272,
283,
1176,
14,
2828,
14,
11676,
297,
272,
283,
1176,
14,
2828,
14,
3431,
297,
272,
283,
1176,
14,
2828,
14,
18373,
297,
199,
61,
199,
199,
19987,
63,
13748,
275,
359,
272,
283,
1176,
14,
2828,
14,
11676,
14,
5754,
14,
4434,
6608,
297,
272,
283,
1176,
14,
5754,
14,
2330,
14,
7844,
6608,
297,
272,
283,
1176,
14,
5754,
14,
10088,
14,
13912,
25322,
297,
272,
283,
1176,
14,
2828,
14,
1178,
14,
5754,
14,
10348,
6608,
297,
272,
283,
1176,
14,
2828,
14,
1178,
14,
5754,
14,
4434,
10348,
6608,
297,
272,
283,
1176,
14,
2828,
14,
3431,
14,
5754,
14,
2209,
6608,
297,
272,
283,
1176,
14,
5754,
14,
4891,
19193,
316,
14,
56,
3160,
4558,
6608,
297,
272,
283,
1176,
14,
5754,
14,
4416,
14,
7676,
6608,
297,
199,
61,
199,
199,
5441,
63,
18125,
275,
11400,
2199,
63,
354,
3586,
14,
3603,
7,
199,
199,
25437,
275,
359,
272,
469,
267,
283,
18145,
356,
283,
1176,
14,
1160,
14,
7765,
14,
1176,
14,
9323,
17969,
297,
267,
283,
14455,
356,
990,
267,
283,
7121,
63,
14455,
356,
715,
12,
267,
283,
8808,
356,
469,
288,
283,
1100,
63,
10547,
356,
359,
355,
283,
1176,
14,
1160,
14,
1100,
63,
10547,
14,
1757,
297,
355,
283,
1176,
14,
1160,
14,
1100,
63,
10547,
14,
1069,
297,
355,
283,
1176,
14,
2828,
14,
1178,
14,
1100,
63,
10547,
14,
1178,
297,
355,
283,
1176,
14,
2828,
14,
3431,
14,
1100,
63,
10547,
14,
3431,
297,
288,
2156,
267,
1660,
272,
1660,
199,
61,
199,
199,
16828,
63,
24051,
275,
11400,
2199,
63,
354,
3586,
14,
6508,
14,
3578,
7,
421,
199,
3,
8692,
199,
3,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
1121,
15,
1751,
12645,
17439,
199,
199,
27260,
275,
469,
272,
283,
885,
356,
469,
267,
283,
15956,
356,
283,
1176,
14,
697,
14,
7765,
14,
10659,
19,
297,
267,
283,
2339,
356,
747,
14,
515,
14,
904,
8,
5825,
63,
3022,
12,
283,
697,
14,
10659,
19,
659,
272,
789,
199,
93,
421,
199,
3,
28220,
2072,
199,
3,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
11299,
15,
73,
1085,
78,
15,
199,
199,
13947,
63,
6012,
275,
283,
287,
13,
527,
7,
199,
199,
4961,
63,
15353,
275,
283,
11288,
7,
199,
199,
4701,
63,
41,
1085,
46,
275,
715,
199,
199,
4701,
63,
44,
709,
46,
275,
715,
199,
199,
4701,
63,
14226,
275,
715,
421,
199,
3,
13599,
1584,
334,
14391,
12,
15250,
12,
32658,
9,
199,
3,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
3638,
9149,
63,
1023,
3586,
15,
21232,
15,
1986,
13,
1725,
15,
199,
199,
10449,
63,
2632,
275,
1994,
1986,
4805,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
wanglongqi/sympy
|
sympy/geometry/point.py
|
33
|
28002
|
"""Geometrical Points.
Contains
========
Point
Point2D
Point3D
"""
from __future__ import division, print_function
from sympy.core import S, sympify
from sympy.core.compatibility import iterable, range
from sympy.core.containers import Tuple
from sympy.simplify import nsimplify, simplify
from sympy.geometry.exceptions import GeometryError
from sympy.functions.elementary.miscellaneous import sqrt
from sympy.functions.elementary.complexes import im
from sympy.matrices import Matrix
from sympy.core.numbers import Float
from sympy.core.evaluate import global_evaluate
from sympy.core.add import Add
from .entity import GeometryEntity
class Point(GeometryEntity):
"""A point in a n-dimensional Euclidean space.
Parameters
==========
coords : sequence of n-coordinate values. In the special
case where n=2 or 3, a Point2D or Point3D will be created
as appropriate.
Attributes
==========
length
origin: A `Point` representing the origin of the
appropriately-dimensioned space.
Raises
======
TypeError
When trying to add or subtract points with different dimensions.
When `intersection` is called with object other than a Point.
See Also
========
sympy.geometry.line.Segment : Connects two Points
Examples
========
>>> from sympy.geometry import Point
>>> from sympy.abc import x
>>> Point(1, 2, 3)
Point3D(1, 2, 3)
>>> Point([1, 2])
Point2D(1, 2)
>>> Point(0, x)
Point2D(0, x)
Floats are automatically converted to Rational unless the
evaluate flag is False:
>>> Point(0.5, 0.25)
Point2D(1/2, 1/4)
>>> Point(0.5, 0.25, evaluate=False)
Point2D(0.5, 0.25)
"""
def __new__(cls, *args, **kwargs):
evaluate = kwargs.get('evaluate', global_evaluate[0])
if iterable(args[0]):
if isinstance(args[0], Point) and not evaluate:
return args[0]
args = args[0]
# unpack the arguments into a friendly Tuple
# if we were already a Point, we're doing an excess
# iteration, but we'll worry about efficiency later
coords = Tuple(*args)
if any(a.is_number and im(a) for a in coords):
raise ValueError('Imaginary coordinates not permitted.')
# Turn any Floats into rationals and simplify
# any expressions before we instantiate
if evaluate:
coords = coords.xreplace(dict(
[(f, simplify(nsimplify(f, rational=True)))
for f in coords.atoms(Float)]))
if len(coords) == 2:
return Point2D(coords, **kwargs)
if len(coords) == 3:
return Point3D(coords, **kwargs)
return GeometryEntity.__new__(cls, *coords)
is_Point = True
def __contains__(self, item):
return item == self
def is_concyclic(*args):
# Coincident points are irrelevant and can confuse this algorithm.
# Use only unique points.
args = list(set(args))
if not all(isinstance(p, Point) for p in args):
raise TypeError('Must pass only Point objects')
return args[0].is_concyclic(*args[1:])
def is_collinear(*args):
"""Is a sequence of points collinear?
Test whether or not a set of points are collinear. Returns True if
the set of points are collinear, or False otherwise.
Parameters
==========
points : sequence of Point
Returns
=======
is_collinear : boolean
Notes
=====
Slope is preserved everywhere on a line, so the slope between
any two points on the line should be the same. Take the first
two points, p1 and p2, and create a translated point v1
with p1 as the origin. Now for every other point we create
a translated point, vi with p1 also as the origin. Note that
these translations preserve slope since everything is
consistently translated to a new origin of p1. Since slope
is preserved then we have the following equality:
* v1_slope = vi_slope
* v1.y/v1.x = vi.y/vi.x (due to translation)
* v1.y*vi.x = vi.y*v1.x
* v1.y*vi.x - vi.y*v1.x = 0 (*)
Hence, if we have a vi such that the equality in (*) is False
then the points are not collinear. We do this test for every
point in the list, and if all pass then they are collinear.
See Also
========
sympy.geometry.line.Line
Examples
========
>>> from sympy import Point
>>> from sympy.abc import x
>>> p1, p2 = Point(0, 0), Point(1, 1)
>>> p3, p4, p5 = Point(2, 2), Point(x, x), Point(1, 2)
>>> Point.is_collinear(p1, p2, p3, p4)
True
>>> Point.is_collinear(p1, p2, p3, p5)
False
"""
# Coincident points are irrelevant; use only unique points.
args = list(set(args))
if not all(isinstance(p, Point) for p in args):
raise TypeError('Must pass only Point objects')
if len(args) == 0:
return False
if len(args) <= 2:
return True
# translate our points
points = [p - args[0] for p in args[1:]]
for p in points[1:]:
if not Point.is_scalar_multiple(points[0], p):
return False
return True
def is_scalar_multiple(p1, p2):
"""Returns whether `p1` and `p2` are scalar multiples
of eachother.
"""
# if the vectors p1 and p2 are linearly dependent, then they must
# be scalar multiples of eachother
m = Matrix([p1.args, p2.args])
# XXX: issue #9480 we need `simplify=True` otherwise the
# rank may be computed incorrectly
return m.rank(simplify=True) < 2
@property
def length(self):
"""
Treating a Point as a Line, this returns 0 for the length of a Point.
Examples
========
>>> from sympy import Point
>>> p = Point(0, 1)
>>> p.length
0
"""
return S.Zero
@property
def origin(self):
"""A point of all zeros of the same ambient dimension
as the current point"""
return Point([0]*len(self))
@property
def is_zero(self):
"""True if every coordinate is zero, otherwise False."""
return all(x == S.Zero for x in self.args)
@property
def ambient_dimension(self):
"""The dimension of the ambient space the point is in.
I.e., if the point is in R^n, the ambient dimension
will be n"""
return len(self)
def distance(self, p):
"""The Euclidean distance from self to point p.
Parameters
==========
p : Point
Returns
=======
distance : number or symbolic expression.
See Also
========
sympy.geometry.line.Segment.length
Examples
========
>>> from sympy.geometry import Point
>>> p1, p2 = Point(1, 1), Point(4, 5)
>>> p1.distance(p2)
5
>>> from sympy.abc import x, y
>>> p3 = Point(x, y)
>>> p3.distance(Point(0, 0))
sqrt(x**2 + y**2)
"""
p = Point(p)
return sqrt(sum([(a - b)**2 for a, b in zip(self.args, p.args)]))
def midpoint(self, p):
"""The midpoint between self and point p.
Parameters
==========
p : Point
Returns
=======
midpoint : Point
See Also
========
sympy.geometry.line.Segment.midpoint
Examples
========
>>> from sympy.geometry import Point
>>> p1, p2 = Point(1, 1), Point(13, 5)
>>> p1.midpoint(p2)
Point2D(7, 3)
"""
return Point([simplify((a + b)*S.Half) for a, b in zip(self.args, p.args)])
def evalf(self, prec=None, **options):
"""Evaluate the coordinates of the point.
This method will, where possible, create and return a new Point
where the coordinates are evaluated as floating point numbers to
the precision indicated (default=15).
Returns
=======
point : Point
Examples
========
>>> from sympy import Point, Rational
>>> p1 = Point(Rational(1, 2), Rational(3, 2))
>>> p1
Point2D(1/2, 3/2)
>>> p1.evalf()
Point2D(0.5, 1.5)
"""
coords = [x.evalf(prec, **options) for x in self.args]
return Point(*coords, evaluate=False)
n = evalf
def intersection(self, o):
"""The intersection between this point and another point.
Parameters
==========
other : Point
Returns
=======
intersection : list of Points
Notes
=====
The return value will either be an empty list if there is no
intersection, otherwise it will contain this point.
Examples
========
>>> from sympy import Point
>>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(0, 0)
>>> p1.intersection(p2)
[]
>>> p1.intersection(p3)
[Point2D(0, 0)]
"""
if isinstance(o, Point):
if len(self) != len(o):
raise ValueError("Points must be of the same dimension to intersect")
if self == o:
return [self]
return []
return o.intersection(self)
def dot(self, p2):
"""Return dot product of self with another Point."""
p2 = Point(p2)
return Add(*[a*b for a,b in zip(self, p2)])
def equals(self, other):
"""Returns whether the coordinates of self and other agree."""
# a point is equal to another point if all its components are equal
if not isinstance(other, Point) or len(self.args) != len(other.args):
return False
return all(a.equals(b) for a,b in zip(self.args, other.args))
def __len__(self):
return len(self.args)
def __iter__(self):
return self.args.__iter__()
def __eq__(self, other):
if not isinstance(other, Point) or len(self.args) != len(other.args):
return False
return self.args == other.args
def __hash__(self):
return hash(self.args)
def __getitem__(self, key):
return self.args[key]
def __add__(self, other):
"""Add other to self by incrementing self's coordinates by those of other.
See Also
========
sympy.geometry.entity.translate
"""
if iterable(other) and len(other) == len(self):
return Point([simplify(a + b) for a, b in zip(self, other)])
else:
raise ValueError(
"Points must have the same number of dimensions")
def __sub__(self, other):
"""Subtract two points, or subtract a factor from this point's
coordinates."""
return self + (-other)
def __mul__(self, factor):
"""Multiply point's coordinates by a factor."""
factor = sympify(factor)
return Point([simplify(x*factor) for x in self.args])
def __div__(self, divisor):
"""Divide point's coordinates by a factor."""
divisor = sympify(divisor)
return Point([simplify(x/divisor) for x in self.args])
__truediv__ = __div__
def __neg__(self):
"""Negate the point."""
return Point([-x for x in self.args])
def __abs__(self):
"""Returns the distance between this point and the origin."""
origin = Point([0]*len(self))
return Point.distance(origin, self)
class Point2D(Point):
"""A point in a 2-dimensional Euclidean space.
Parameters
==========
coords : sequence of 2 coordinate values.
Attributes
==========
x
y
length
Raises
======
TypeError
When trying to add or subtract points with different dimensions.
When trying to create a point with more than two dimensions.
When `intersection` is called with object other than a Point.
See Also
========
sympy.geometry.line.Segment : Connects two Points
Examples
========
>>> from sympy.geometry import Point2D
>>> from sympy.abc import x
>>> Point2D(1, 2)
Point2D(1, 2)
>>> Point2D([1, 2])
Point2D(1, 2)
>>> Point2D(0, x)
Point2D(0, x)
Floats are automatically converted to Rational unless the
evaluate flag is False:
>>> Point2D(0.5, 0.25)
Point2D(1/2, 1/4)
>>> Point2D(0.5, 0.25, evaluate=False)
Point2D(0.5, 0.25)
"""
def __new__(cls, *args, **kwargs):
eval = kwargs.get('evaluate', global_evaluate[0])
check = True
if isinstance(args[0], Point2D):
if not eval:
return args[0]
args = args[0].args
check = False
else:
if iterable(args[0]):
args = args[0]
if len(args) != 2:
raise ValueError(
"Only two dimensional points currently supported")
coords = Tuple(*args)
if check:
if any(a.is_number and im(a) for a in coords):
raise ValueError('Imaginary args not permitted.')
if eval:
coords = coords.xreplace(dict(
[(f, simplify(nsimplify(f, rational=True)))
for f in coords.atoms(Float)]))
return GeometryEntity.__new__(cls, *coords)
def __contains__(self, item):
return item == self
@property
def x(self):
"""
Returns the X coordinate of the Point.
Examples
========
>>> from sympy import Point2D
>>> p = Point2D(0, 1)
>>> p.x
0
"""
return self.args[0]
@property
def y(self):
"""
Returns the Y coordinate of the Point.
Examples
========
>>> from sympy import Point2D
>>> p = Point2D(0, 1)
>>> p.y
1
"""
return self.args[1]
@property
def bounds(self):
"""Return a tuple (xmin, ymin, xmax, ymax) representing the bounding
rectangle for the geometric figure.
"""
return (self.x, self.y, self.x, self.y)
def is_concyclic(*points):
"""Is a sequence of points concyclic?
Test whether or not a sequence of points are concyclic (i.e., they lie
on a circle).
Parameters
==========
points : sequence of Points
Returns
=======
is_concyclic : boolean
True if points are concyclic, False otherwise.
See Also
========
sympy.geometry.ellipse.Circle
Notes
=====
No points are not considered to be concyclic. One or two points
are definitely concyclic and three points are conyclic iff they
are not collinear.
For more than three points, create a circle from the first three
points. If the circle cannot be created (i.e., they are collinear)
then all of the points cannot be concyclic. If the circle is created
successfully then simply check the remaining points for containment
in the circle.
Examples
========
>>> from sympy.geometry import Point
>>> p1, p2 = Point(-1, 0), Point(1, 0)
>>> p3, p4 = Point(0, 1), Point(-1, 2)
>>> Point.is_concyclic(p1, p2, p3)
True
>>> Point.is_concyclic(p1, p2, p3, p4)
False
"""
if len(points) == 0:
return False
if len(points) <= 2:
return True
points = [Point(p) for p in points]
if len(points) == 3:
return (not Point.is_collinear(*points))
try:
from .ellipse import Circle
c = Circle(points[0], points[1], points[2])
for point in points[3:]:
if point not in c:
return False
return True
except GeometryError:
# Circle could not be created, because of collinearity of the
# three points passed in, hence they are not concyclic.
return False
def rotate(self, angle, pt=None):
"""Rotate ``angle`` radians counterclockwise about Point ``pt``.
See Also
========
rotate, scale
Examples
========
>>> from sympy import Point2D, pi
>>> t = Point2D(1, 0)
>>> t.rotate(pi/2)
Point2D(0, 1)
>>> t.rotate(pi/2, (2, 0))
Point2D(2, -1)
"""
from sympy import cos, sin, Point
c = cos(angle)
s = sin(angle)
rv = self
if pt is not None:
pt = Point(pt)
rv -= pt
x, y = rv.args
rv = Point(c*x - s*y, s*x + c*y)
if pt is not None:
rv += pt
return rv
def scale(self, x=1, y=1, pt=None):
"""Scale the coordinates of the Point by multiplying by
``x`` and ``y`` after subtracting ``pt`` -- default is (0, 0) --
and then adding ``pt`` back again (i.e. ``pt`` is the point of
reference for the scaling).
See Also
========
rotate, translate
Examples
========
>>> from sympy import Point2D
>>> t = Point2D(1, 1)
>>> t.scale(2)
Point2D(2, 1)
>>> t.scale(2, 2)
Point2D(2, 2)
"""
if pt:
pt = Point(pt)
return self.translate(*(-pt).args).scale(x, y).translate(*pt.args)
return Point(self.x*x, self.y*y)
def translate(self, x=0, y=0):
"""Shift the Point by adding x and y to the coordinates of the Point.
See Also
========
rotate, scale
Examples
========
>>> from sympy import Point2D
>>> t = Point2D(0, 1)
>>> t.translate(2)
Point2D(2, 1)
>>> t.translate(2, 2)
Point2D(2, 3)
>>> t + Point2D(2, 2)
Point2D(2, 3)
"""
return Point(self.x + x, self.y + y)
def transform(self, matrix):
"""Return the point after applying the transformation described
by the 3x3 Matrix, ``matrix``.
See Also
========
geometry.entity.rotate
geometry.entity.scale
geometry.entity.translate
"""
try:
col, row = matrix.shape
valid_matrix = matrix.is_square and col == 3
except AttributeError:
# We hit this block if matrix argument is not actually a Matrix.
valid_matrix = False
if not valid_matrix:
raise ValueError("The argument to the transform function must be " \
+ "a 3x3 matrix")
x, y = self.args
return Point(*(Matrix(1, 3, [x, y, 1])*matrix).tolist()[0][:2])
class Point3D(Point):
"""A point in a 3-dimensional Euclidean space.
Parameters
==========
coords : sequence of 3 coordinate values.
Attributes
==========
x
y
z
length
Raises
======
TypeError
When trying to add or subtract points with different dimensions.
When `intersection` is called with object other than a Point.
Notes
=====
Currently only 2-dimensional and 3-dimensional points are supported.
Examples
========
>>> from sympy import Point3D
>>> from sympy.abc import x
>>> Point3D(1, 2, 3)
Point3D(1, 2, 3)
>>> Point3D([1, 2, 3])
Point3D(1, 2, 3)
>>> Point3D(0, x, 3)
Point3D(0, x, 3)
Floats are automatically converted to Rational unless the
evaluate flag is False:
>>> Point3D(0.5, 0.25, 2)
Point3D(1/2, 1/4, 2)
>>> Point3D(0.5, 0.25, 3, evaluate=False)
Point3D(0.5, 0.25, 3)
"""
def __new__(cls, *args, **kwargs):
eval = kwargs.get('evaluate', global_evaluate[0])
if isinstance(args[0], (Point, Point3D)):
if not eval:
return args[0]
args = args[0].args
else:
if iterable(args[0]):
args = args[0]
if len(args) not in (2, 3):
raise TypeError(
"Enter a 2 or 3 dimensional point")
coords = Tuple(*args)
if len(coords) == 2:
coords += (S.Zero,)
if eval:
coords = coords.xreplace(dict(
[(f, simplify(nsimplify(f, rational=True)))
for f in coords.atoms(Float)]))
return GeometryEntity.__new__(cls, *coords)
def __contains__(self, item):
return item == self
@property
def x(self):
"""
Returns the X coordinate of the Point.
Examples
========
>>> from sympy import Point3D
>>> p = Point3D(0, 1, 3)
>>> p.x
0
"""
return self.args[0]
@property
def y(self):
"""
Returns the Y coordinate of the Point.
Examples
========
>>> from sympy import Point3D
>>> p = Point3D(0, 1, 2)
>>> p.y
1
"""
return self.args[1]
@property
def z(self):
"""
Returns the Z coordinate of the Point.
Examples
========
>>> from sympy import Point3D
>>> p = Point3D(0, 1, 1)
>>> p.z
1
"""
return self.args[2]
def direction_ratio(self, point):
"""
Gives the direction ratio between 2 points
Parameters
==========
p : Point3D
Returns
=======
list
Examples
========
>>> from sympy import Point3D
>>> p1 = Point3D(1, 2, 3)
>>> p1.direction_ratio(Point3D(2, 3, 5))
[1, 1, 2]
"""
return [(point.x - self.x),(point.y - self.y),(point.z - self.z)]
def direction_cosine(self, point):
"""
Gives the direction cosine between 2 points
Parameters
==========
p : Point3D
Returns
=======
list
Examples
========
>>> from sympy import Point3D
>>> p1 = Point3D(1, 2, 3)
>>> p1.direction_cosine(Point3D(2, 3, 5))
[sqrt(6)/6, sqrt(6)/6, sqrt(6)/3]
"""
a = self.direction_ratio(point)
b = sqrt(sum(i**2 for i in a))
return [(point.x - self.x) / b,(point.y - self.y) / b,
(point.z - self.z) / b]
@staticmethod
def are_collinear(*points):
"""Is a sequence of points collinear?
Test whether or not a set of points are collinear. Returns True if
the set of points are collinear, or False otherwise.
Parameters
==========
points : sequence of Point
Returns
=======
are_collinear : boolean
See Also
========
sympy.geometry.line3d.Line3D
Examples
========
>>> from sympy import Point3D, Matrix
>>> from sympy.abc import x
>>> p1, p2 = Point3D(0, 0, 0), Point3D(1, 1, 1)
>>> p3, p4, p5 = Point3D(2, 2, 2), Point3D(x, x, x), Point3D(1, 2, 6)
>>> Point3D.are_collinear(p1, p2, p3, p4)
True
>>> Point3D.are_collinear(p1, p2, p3, p5)
False
"""
return Point.is_collinear(*points)
@staticmethod
def are_coplanar(*points):
"""
This function tests whether passed points are coplanar or not.
It uses the fact that the triple scalar product of three vectors
vanishes if the vectors are coplanar. Which means that the volume
of the solid described by them will have to be zero for coplanarity.
Parameters
==========
A set of points 3D points
Returns
=======
boolean
Examples
========
>>> from sympy import Point3D
>>> p1 = Point3D(1, 2, 2)
>>> p2 = Point3D(2, 7, 2)
>>> p3 = Point3D(0, 0, 2)
>>> p4 = Point3D(1, 1, 2)
>>> Point3D.are_coplanar(p1, p2, p3, p4)
True
>>> p5 = Point3D(0, 1, 3)
>>> Point3D.are_coplanar(p1, p2, p3, p5)
False
"""
from sympy.geometry.plane import Plane
points = list(set(points))
if len(points) < 3:
raise ValueError('At least 3 points are needed to define a plane.')
a, b = points[:2]
for i, c in enumerate(points[2:]):
try:
p = Plane(a, b, c)
for j in (0, 1, i):
points.pop(j)
return all(p.is_coplanar(i) for i in points)
except ValueError:
pass
raise ValueError('At least 3 non-collinear points needed to define plane.')
def intersection(self, o):
"""The intersection between this point and another point.
Parameters
==========
other : Point
Returns
=======
intersection : list of Points
Notes
=====
The return value will either be an empty list if there is no
intersection, otherwise it will contain this point.
Examples
========
>>> from sympy import Point3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, 0, 0)
>>> p1.intersection(p2)
[]
>>> p1.intersection(p3)
[Point3D(0, 0, 0)]
"""
if isinstance(o, Point3D):
if self == o:
return [self]
return []
return o.intersection(self)
def scale(self, x=1, y=1, z=1, pt=None):
"""Scale the coordinates of the Point by multiplying by
``x`` and ``y`` after subtracting ``pt`` -- default is (0, 0) --
and then adding ``pt`` back again (i.e. ``pt`` is the point of
reference for the scaling).
See Also
========
translate
Examples
========
>>> from sympy import Point3D
>>> t = Point3D(1, 1, 1)
>>> t.scale(2)
Point3D(2, 1, 1)
>>> t.scale(2, 2)
Point3D(2, 2, 1)
"""
if pt:
pt = Point3D(pt)
return self.translate(*(-pt).args).scale(x, y, z).translate(*pt.args)
return Point3D(self.x*x, self.y*y, self.z*z)
def translate(self, x=0, y=0, z=0):
"""Shift the Point by adding x and y to the coordinates of the Point.
See Also
========
rotate, scale
Examples
========
>>> from sympy import Point3D
>>> t = Point3D(0, 1, 1)
>>> t.translate(2)
Point3D(2, 1, 1)
>>> t.translate(2, 2)
Point3D(2, 3, 1)
>>> t + Point3D(2, 2, 2)
Point3D(2, 3, 3)
"""
return Point3D(self.x + x, self.y + y, self.z + z)
def transform(self, matrix):
"""Return the point after applying the transformation described
by the 4x4 Matrix, ``matrix``.
See Also
========
geometry.entity.rotate
geometry.entity.scale
geometry.entity.translate
"""
try:
col, row = matrix.shape
valid_matrix = matrix.is_square and col == 4
except AttributeError:
# We hit this block if matrix argument is not actually a Matrix.
valid_matrix = False
if not valid_matrix:
raise ValueError("The argument to the transform function must be " \
+ "a 4x4 matrix")
from sympy.matrices.expressions import Transpose
x, y, z = self.args
m = Transpose(matrix)
return Point3D(*(Matrix(1, 4, [x, y, z, 1])*m).tolist()[0][:3])
|
bsd-3-clause
|
[
624,
4240,
1377,
599,
915,
32598,
14,
199,
199,
6906,
199,
763,
199,
3428,
199,
3428,
18,
36,
199,
3428,
19,
36,
199,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
199,
199,
504,
5840,
14,
1018,
492,
428,
12,
25991,
199,
504,
5840,
14,
1018,
14,
15390,
492,
6076,
12,
1425,
199,
504,
5840,
14,
1018,
14,
13577,
492,
11634,
199,
504,
5840,
14,
19084,
492,
302,
19084,
12,
15037,
199,
504,
5840,
14,
7660,
14,
3924,
492,
10579,
547,
199,
504,
5840,
14,
5777,
14,
2108,
695,
14,
1292,
19549,
492,
7452,
199,
504,
5840,
14,
5777,
14,
2108,
695,
14,
5254,
397,
492,
3416,
199,
504,
5840,
14,
19032,
492,
8449,
199,
504,
5840,
14,
1018,
14,
10548,
492,
11140,
199,
504,
5840,
14,
1018,
14,
7383,
492,
2288,
63,
7383,
199,
504,
5840,
14,
1018,
14,
525,
492,
2654,
199,
199,
504,
1275,
4502,
492,
10579,
7302,
421,
199,
533,
7584,
8,
6831,
7302,
304,
272,
408,
33,
2376,
315,
282,
302,
13,
13014,
662,
24941,
4601,
14,
339,
3897,
272,
21938,
339,
13259,
520,
3414,
402,
302,
13,
20493,
1338,
14,
1010,
314,
4539,
272,
1930,
2382,
302,
29,
18,
503,
650,
12,
282,
7584,
18,
36,
503,
7584,
19,
36,
911,
506,
2737,
272,
465,
5827,
14,
339,
9382,
272,
21938,
339,
2582,
272,
6330,
26,
437,
658,
3428,
64,
6144,
314,
6330,
402,
314,
267,
22497,
13,
6091,
12308,
4601,
14,
339,
6218,
272,
9310,
29,
339,
3146,
267,
3979,
9936,
370,
1050,
503,
24129,
4501,
543,
3365,
7365,
14,
267,
3979,
658,
12569,
64,
365,
2797,
543,
909,
1163,
2419,
282,
7584,
14,
339,
1666,
6121,
272,
12655,
339,
5840,
14,
7660,
14,
604,
14,
12520,
520,
15175,
83,
2877,
32598,
339,
6058,
272,
12655,
339,
1306,
687,
5840,
14,
7660,
492,
7584,
272,
1306,
687,
5840,
14,
3175,
492,
671,
272,
1306,
7584,
8,
17,
12,
499,
12,
650,
9,
272,
7584,
19,
36,
8,
17,
12,
499,
12,
650,
9,
272,
1306,
7584,
779,
17,
12,
499,
566,
272,
7584,
18,
36,
8,
17,
12,
499,
9,
272,
1306,
7584,
8,
16,
12,
671,
9,
272,
7584,
18,
36,
8,
16,
12,
671,
9,
339,
11140,
83,
787,
5847,
6702,
370,
20164,
7444,
314,
272,
9352,
3305,
365,
756,
26,
339,
1306,
7584,
8,
16,
14,
21,
12,
378,
14,
821,
9,
272,
7584,
18,
36,
8,
17,
15,
18,
12,
413,
15,
20,
9,
272,
1306,
7584,
8,
16,
14,
21,
12,
378,
14,
821,
12,
9352,
29,
797,
9,
272,
7584,
18,
36,
8,
16,
14,
21,
12,
378,
14,
821,
9,
339,
408,
272,
347,
636,
1222,
721,
1886,
12,
627,
589,
12,
1011,
958,
304,
267,
9352,
275,
2074,
14,
362,
360,
7383,
297,
2288,
63,
7383,
59,
16,
566,
398,
340,
6076,
8,
589,
59,
16,
4682,
288,
340,
1228,
8,
589,
59,
16,
467,
7584,
9,
436,
440,
9352,
26,
355,
372,
1249,
59,
16,
61,
288,
1249,
275,
1249,
59,
16,
61,
398,
327,
7787,
314,
2368,
1901,
282,
21428,
11634,
267,
327,
340,
781,
4898,
2575,
282,
7584,
12,
781,
3984,
9689,
376,
444,
670,
267,
327,
8494,
12,
1325,
781,
7171,
30944,
3595,
25978,
2945,
267,
13259,
275,
11634,
2031,
589,
9,
267,
340,
1263,
8,
65,
14,
374,
63,
1955,
436,
3416,
8,
65,
9,
367,
282,
315,
13259,
304,
288,
746,
1722,
360,
32023,
17580,
8983,
440,
8211,
2659,
398,
327,
16147,
1263,
11140,
83,
1901,
660,
296,
2551,
436,
15037,
267,
327,
1263,
8455,
2544,
781,
17321,
267,
340,
9352,
26,
288,
13259,
275,
13259,
14,
88,
1814,
8,
807,
8,
355,
3842,
70,
12,
15037,
8,
78,
19084,
8,
70,
12,
30239,
29,
549,
1724,
355,
367,
289,
315,
13259,
14,
11521,
8,
5136,
19563,
267,
340,
822,
8,
8032,
9,
508,
499,
26,
288,
372,
7584,
18,
36,
8,
8032,
12,
1011,
958,
9,
267,
340,
822,
8,
8032,
9,
508,
650,
26,
288,
372,
7584,
19,
36,
8,
8032,
12,
1011,
958,
9,
398,
372,
10579,
7302,
855,
1222,
721,
1886,
12,
627,
8032,
9,
339,
365,
63,
3428,
275,
715,
339,
347,
636,
6134,
721,
277,
12,
1242,
304,
267,
372,
1242,
508,
291,
339,
347,
365,
63,
388,
31268,
2031,
589,
304,
267,
327,
1849,
29811,
4501,
787,
8190,
21906,
436,
883,
3743,
1180,
642,
5563,
14,
267,
327,
3645,
1454,
3747,
4501,
14,
267,
1249,
275,
769,
8,
409,
8,
589,
430,
267,
340,
440,
1006,
8,
6074,
8,
80,
12,
7584,
9,
367,
299,
315,
1249,
304,
288,
746,
3146,
360,
13757,
986,
1454,
7584,
2251,
358,
398,
372,
1249,
59,
16,
1055,
374,
63,
388,
31268,
2031,
589,
59,
17,
5728,
339,
347,
365,
63,
761,
6676,
2031,
589,
304,
267,
408,
1831,
282,
3414,
402,
4501,
1048,
6676,
31,
398,
1379,
3775,
503,
440,
282,
663,
402,
4501,
787,
1048,
6676,
14,
1803,
715,
340,
267,
314,
663,
402,
4501,
787,
1048,
6676,
12,
503,
756,
4257,
14,
398,
3897,
267,
21938,
398,
4501,
520,
3414,
402,
7584,
398,
1803,
267,
9310,
389,
398,
365,
63,
761,
6676,
520,
5046,
398,
8144,
267,
9310,
398,
428,
14363,
365,
17731,
4036,
4509,
641,
282,
1004,
12,
880,
314,
24140,
3382,
267,
1263,
2877,
4501,
641,
314,
1004,
1077,
506,
314,
2011,
14,
18146,
314,
1642,
267,
2877,
4501,
12,
299,
17,
436,
299,
18,
12,
436,
1218,
282,
14598,
2376,
373,
17,
267,
543,
299,
17,
465,
314,
6330,
14,
7356,
367,
4036,
1163,
2376,
781,
1218,
267,
282,
14598,
2376,
12,
1321,
543,
299,
17,
2597,
465,
314,
6330,
14,
3390,
626,
267,
3520,
15547,
11211,
24140,
3967,
8137,
365,
267,
12137,
590,
14598,
370,
282,
892,
6330,
402,
299,
17,
14,
9336,
24140,
267,
365,
17731,
2066,
781,
1172,
314,
2569,
16612,
26,
25841,
627,
373,
17,
63,
25278,
275,
1321,
63,
25278,
1598,
627,
373,
17,
14,
89,
15,
86,
17,
14,
88,
275,
1321,
14,
89,
15,
433,
14,
88,
334,
11933,
370,
7761,
9,
1598,
627,
373,
17,
14,
89,
10,
433,
14,
88,
275,
1321,
14,
89,
10,
86,
17,
14,
88
] |
[
4240,
1377,
599,
915,
32598,
14,
199,
199,
6906,
199,
763,
199,
3428,
199,
3428,
18,
36,
199,
3428,
19,
36,
199,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
199,
199,
504,
5840,
14,
1018,
492,
428,
12,
25991,
199,
504,
5840,
14,
1018,
14,
15390,
492,
6076,
12,
1425,
199,
504,
5840,
14,
1018,
14,
13577,
492,
11634,
199,
504,
5840,
14,
19084,
492,
302,
19084,
12,
15037,
199,
504,
5840,
14,
7660,
14,
3924,
492,
10579,
547,
199,
504,
5840,
14,
5777,
14,
2108,
695,
14,
1292,
19549,
492,
7452,
199,
504,
5840,
14,
5777,
14,
2108,
695,
14,
5254,
397,
492,
3416,
199,
504,
5840,
14,
19032,
492,
8449,
199,
504,
5840,
14,
1018,
14,
10548,
492,
11140,
199,
504,
5840,
14,
1018,
14,
7383,
492,
2288,
63,
7383,
199,
504,
5840,
14,
1018,
14,
525,
492,
2654,
199,
199,
504,
1275,
4502,
492,
10579,
7302,
421,
199,
533,
7584,
8,
6831,
7302,
304,
272,
408,
33,
2376,
315,
282,
302,
13,
13014,
662,
24941,
4601,
14,
339,
3897,
272,
21938,
339,
13259,
520,
3414,
402,
302,
13,
20493,
1338,
14,
1010,
314,
4539,
272,
1930,
2382,
302,
29,
18,
503,
650,
12,
282,
7584,
18,
36,
503,
7584,
19,
36,
911,
506,
2737,
272,
465,
5827,
14,
339,
9382,
272,
21938,
339,
2582,
272,
6330,
26,
437,
658,
3428,
64,
6144,
314,
6330,
402,
314,
267,
22497,
13,
6091,
12308,
4601,
14,
339,
6218,
272,
9310,
29,
339,
3146,
267,
3979,
9936,
370,
1050,
503,
24129,
4501,
543,
3365,
7365,
14,
267,
3979,
658,
12569,
64,
365,
2797,
543,
909,
1163,
2419,
282,
7584,
14,
339,
1666,
6121,
272,
12655,
339,
5840,
14,
7660,
14,
604,
14,
12520,
520,
15175,
83,
2877,
32598,
339,
6058,
272,
12655,
339,
1306,
687,
5840,
14,
7660,
492,
7584,
272,
1306,
687,
5840,
14,
3175,
492,
671,
272,
1306,
7584,
8,
17,
12,
499,
12,
650,
9,
272,
7584,
19,
36,
8,
17,
12,
499,
12,
650,
9,
272,
1306,
7584,
779,
17,
12,
499,
566,
272,
7584,
18,
36,
8,
17,
12,
499,
9,
272,
1306,
7584,
8,
16,
12,
671,
9,
272,
7584,
18,
36,
8,
16,
12,
671,
9,
339,
11140,
83,
787,
5847,
6702,
370,
20164,
7444,
314,
272,
9352,
3305,
365,
756,
26,
339,
1306,
7584,
8,
16,
14,
21,
12,
378,
14,
821,
9,
272,
7584,
18,
36,
8,
17,
15,
18,
12,
413,
15,
20,
9,
272,
1306,
7584,
8,
16,
14,
21,
12,
378,
14,
821,
12,
9352,
29,
797,
9,
272,
7584,
18,
36,
8,
16,
14,
21,
12,
378,
14,
821,
9,
339,
408,
272,
347,
636,
1222,
721,
1886,
12,
627,
589,
12,
1011,
958,
304,
267,
9352,
275,
2074,
14,
362,
360,
7383,
297,
2288,
63,
7383,
59,
16,
566,
398,
340,
6076,
8,
589,
59,
16,
4682,
288,
340,
1228,
8,
589,
59,
16,
467,
7584,
9,
436,
440,
9352,
26,
355,
372,
1249,
59,
16,
61,
288,
1249,
275,
1249,
59,
16,
61,
398,
327,
7787,
314,
2368,
1901,
282,
21428,
11634,
267,
327,
340,
781,
4898,
2575,
282,
7584,
12,
781,
3984,
9689,
376,
444,
670,
267,
327,
8494,
12,
1325,
781,
7171,
30944,
3595,
25978,
2945,
267,
13259,
275,
11634,
2031,
589,
9,
267,
340,
1263,
8,
65,
14,
374,
63,
1955,
436,
3416,
8,
65,
9,
367,
282,
315,
13259,
304,
288,
746,
1722,
360,
32023,
17580,
8983,
440,
8211,
2659,
398,
327,
16147,
1263,
11140,
83,
1901,
660,
296,
2551,
436,
15037,
267,
327,
1263,
8455,
2544,
781,
17321,
267,
340,
9352,
26,
288,
13259,
275,
13259,
14,
88,
1814,
8,
807,
8,
355,
3842,
70,
12,
15037,
8,
78,
19084,
8,
70,
12,
30239,
29,
549,
1724,
355,
367,
289,
315,
13259,
14,
11521,
8,
5136,
19563,
267,
340,
822,
8,
8032,
9,
508,
499,
26,
288,
372,
7584,
18,
36,
8,
8032,
12,
1011,
958,
9,
267,
340,
822,
8,
8032,
9,
508,
650,
26,
288,
372,
7584,
19,
36,
8,
8032,
12,
1011,
958,
9,
398,
372,
10579,
7302,
855,
1222,
721,
1886,
12,
627,
8032,
9,
339,
365,
63,
3428,
275,
715,
339,
347,
636,
6134,
721,
277,
12,
1242,
304,
267,
372,
1242,
508,
291,
339,
347,
365,
63,
388,
31268,
2031,
589,
304,
267,
327,
1849,
29811,
4501,
787,
8190,
21906,
436,
883,
3743,
1180,
642,
5563,
14,
267,
327,
3645,
1454,
3747,
4501,
14,
267,
1249,
275,
769,
8,
409,
8,
589,
430,
267,
340,
440,
1006,
8,
6074,
8,
80,
12,
7584,
9,
367,
299,
315,
1249,
304,
288,
746,
3146,
360,
13757,
986,
1454,
7584,
2251,
358,
398,
372,
1249,
59,
16,
1055,
374,
63,
388,
31268,
2031,
589,
59,
17,
5728,
339,
347,
365,
63,
761,
6676,
2031,
589,
304,
267,
408,
1831,
282,
3414,
402,
4501,
1048,
6676,
31,
398,
1379,
3775,
503,
440,
282,
663,
402,
4501,
787,
1048,
6676,
14,
1803,
715,
340,
267,
314,
663,
402,
4501,
787,
1048,
6676,
12,
503,
756,
4257,
14,
398,
3897,
267,
21938,
398,
4501,
520,
3414,
402,
7584,
398,
1803,
267,
9310,
389,
398,
365,
63,
761,
6676,
520,
5046,
398,
8144,
267,
9310,
398,
428,
14363,
365,
17731,
4036,
4509,
641,
282,
1004,
12,
880,
314,
24140,
3382,
267,
1263,
2877,
4501,
641,
314,
1004,
1077,
506,
314,
2011,
14,
18146,
314,
1642,
267,
2877,
4501,
12,
299,
17,
436,
299,
18,
12,
436,
1218,
282,
14598,
2376,
373,
17,
267,
543,
299,
17,
465,
314,
6330,
14,
7356,
367,
4036,
1163,
2376,
781,
1218,
267,
282,
14598,
2376,
12,
1321,
543,
299,
17,
2597,
465,
314,
6330,
14,
3390,
626,
267,
3520,
15547,
11211,
24140,
3967,
8137,
365,
267,
12137,
590,
14598,
370,
282,
892,
6330,
402,
299,
17,
14,
9336,
24140,
267,
365,
17731,
2066,
781,
1172,
314,
2569,
16612,
26,
25841,
627,
373,
17,
63,
25278,
275,
1321,
63,
25278,
1598,
627,
373,
17,
14,
89,
15,
86,
17,
14,
88,
275,
1321,
14,
89,
15,
433,
14,
88,
334,
11933,
370,
7761,
9,
1598,
627,
373,
17,
14,
89,
10,
433,
14,
88,
275,
1321,
14,
89,
10,
86,
17,
14,
88,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
fluxer/spm
|
nuitka/nuitka/codegen/IdCodes.py
|
1
|
1739
|
# Copyright 2016, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Part of "Nuitka", an optimizing Python compiler that is compatible and
# integrates with CPython, but also works on its own.
#
# 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.
#
""" Codes for id and hash
"""
from .PythonAPICodes import generateCAPIObjectCode
def generateBuiltinIdCode(to_name, expression, emit, context):
generateCAPIObjectCode(
to_name = to_name,
capi = "PyLong_FromVoidPtr",
arg_desc = (
("id_arg", expression.getValue()),
),
may_raise = expression.mayRaiseException(BaseException),
source_ref = expression.getCompatibleSourceReference(),
emit = emit,
context = context
)
def generateBuiltinHashCode(to_name, expression, emit, context):
generateCAPIObjectCode(
to_name = to_name,
capi = "BUILTIN_HASH",
arg_desc = (
("hash_arg", expression.getValue()),
),
may_raise = expression.mayRaiseException(BaseException),
source_ref = expression.getCompatibleSourceReference(),
emit = emit,
context = context
)
|
gpl-2.0
|
[
3,
258,
1898,
7800,
12,
1804,
1187,
869,
1187,
287,
12,
6016,
475,
26,
75,
1187,
14,
72,
1187,
287,
32,
6799,
14,
957,
199,
3,
199,
3,
258,
14320,
402,
298,
46,
4993,
7351,
401,
376,
5323,
9147,
2018,
6365,
626,
365,
9025,
436,
199,
3,
258,
21494,
83,
543,
25654,
12,
1325,
2597,
5419,
641,
2399,
5705,
14,
199,
3,
199,
3,
258,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
258,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
258,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
263,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
258,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
258,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
258,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
258,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
258,
4204,
1334,
314,
844,
14,
199,
3,
199,
624,
5495,
83,
367,
1305,
436,
2631,
199,
199,
624,
199,
199,
504,
1275,
4718,
1282,
948,
380,
83,
492,
3550,
35,
3735,
1692,
3034,
421,
199,
318,
3550,
12306,
1304,
3034,
8,
475,
63,
354,
12,
3965,
12,
8689,
12,
1067,
304,
272,
3550,
35,
3735,
1692,
3034,
8,
267,
370,
63,
354,
259,
275,
370,
63,
354,
12,
267,
13648,
755,
275,
298,
2713,
9551,
63,
2532,
29545,
2115,
401,
267,
1680,
63,
3257,
257,
275,
334,
288,
1689,
344,
63,
1273,
401,
3965,
14,
17186,
4000,
267,
2318,
267,
1443,
63,
3730,
221,
275,
3965,
14,
7551,
18111,
1726,
8,
29900,
395,
267,
1350,
63,
1121,
275,
3965,
14,
362,
25921,
2980,
5083,
1062,
267,
8689,
755,
275,
8689,
12,
267,
1067,
259,
275,
1067,
272,
776,
421,
199,
318,
3550,
12306,
3476,
3034,
8,
475,
63,
354,
12,
3965,
12,
8689,
12,
1067,
304,
272,
3550,
35,
3735,
1692,
3034,
8,
267,
370,
63,
354,
259,
275,
370,
63,
354,
12,
267,
13648,
755,
275,
298,
18637,
20012,
63,
14395,
401,
267,
1680,
63,
3257,
257,
275,
334,
288,
1689,
2227,
63,
1273,
401,
3965,
14,
17186,
4000,
267,
2318,
267,
1443,
63,
3730,
221,
275,
3965,
14,
7551,
18111,
1726,
8,
29900,
395,
267,
1350,
63,
1121,
275,
3965,
14,
362,
25921,
2980,
5083,
1062,
267,
8689,
755,
275,
8689,
12,
267,
1067,
259,
275,
1067,
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
] |
[
258,
1898,
7800,
12,
1804,
1187,
869,
1187,
287,
12,
6016,
475,
26,
75,
1187,
14,
72,
1187,
287,
32,
6799,
14,
957,
199,
3,
199,
3,
258,
14320,
402,
298,
46,
4993,
7351,
401,
376,
5323,
9147,
2018,
6365,
626,
365,
9025,
436,
199,
3,
258,
21494,
83,
543,
25654,
12,
1325,
2597,
5419,
641,
2399,
5705,
14,
199,
3,
199,
3,
258,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
258,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
258,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
263,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
258,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
258,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
258,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
258,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
258,
4204,
1334,
314,
844,
14,
199,
3,
199,
624,
5495,
83,
367,
1305,
436,
2631,
199,
199,
624,
199,
199,
504,
1275,
4718,
1282,
948,
380,
83,
492,
3550,
35,
3735,
1692,
3034,
421,
199,
318,
3550,
12306,
1304,
3034,
8,
475,
63,
354,
12,
3965,
12,
8689,
12,
1067,
304,
272,
3550,
35,
3735,
1692,
3034,
8,
267,
370,
63,
354,
259,
275,
370,
63,
354,
12,
267,
13648,
755,
275,
298,
2713,
9551,
63,
2532,
29545,
2115,
401,
267,
1680,
63,
3257,
257,
275,
334,
288,
1689,
344,
63,
1273,
401,
3965,
14,
17186,
4000,
267,
2318,
267,
1443,
63,
3730,
221,
275,
3965,
14,
7551,
18111,
1726,
8,
29900,
395,
267,
1350,
63,
1121,
275,
3965,
14,
362,
25921,
2980,
5083,
1062,
267,
8689,
755,
275,
8689,
12,
267,
1067,
259,
275,
1067,
272,
776,
421,
199,
318,
3550,
12306,
3476,
3034,
8,
475,
63,
354,
12,
3965,
12,
8689,
12,
1067,
304,
272,
3550,
35,
3735,
1692,
3034,
8,
267,
370,
63,
354,
259,
275,
370,
63,
354,
12,
267,
13648,
755,
275,
298,
18637,
20012,
63,
14395,
401,
267,
1680,
63,
3257,
257,
275,
334,
288,
1689,
2227,
63,
1273,
401,
3965,
14,
17186,
4000,
267,
2318,
267,
1443,
63,
3730,
221,
275,
3965,
14,
7551,
18111,
1726,
8,
29900,
395,
267,
1350,
63,
1121,
275,
3965,
14,
362,
25921,
2980,
5083,
1062,
267,
8689,
755,
275,
8689,
12,
267,
1067,
259,
275,
1067,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
koichi626/hadoop-gpu
|
hadoop-gpu-0.20.1/build/contrib/hod/hodlib/Hod/hod.py
|
182
|
29420
|
#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.
# -*- python -*-
import sys, os, getpass, pprint, re, cPickle, random, shutil, time, errno
import hodlib.Common.logger
from hodlib.ServiceRegistry.serviceRegistry import svcrgy
from hodlib.Common.xmlrpc import hodXRClient
from hodlib.Common.util import to_http_url, get_exception_string
from hodlib.Common.util import get_exception_error_string
from hodlib.Common.util import hodInterrupt, HodInterruptException
from hodlib.Common.util import HOD_INTERRUPTED_CODE
from hodlib.Common.nodepoolutil import NodePoolUtil
from hodlib.Hod.hadoop import hadoopCluster, hadoopScript
CLUSTER_DATA_FILE = 'clusters'
INVALID_STATE_FILE_MSGS = \
[
"Requested operation cannot be performed. Cannot read %s: " + \
"Permission denied.",
"Requested operation cannot be performed. " + \
"Cannot write to %s: Permission denied.",
"Requested operation cannot be performed. " + \
"Cannot read/write to %s: Permission denied.",
"Cannot update %s: Permission denied. " + \
"Cluster is deallocated, but info and list " + \
"operations might show incorrect information.",
]
class hodState:
def __init__(self, store):
self.__store = store
self.__stateFile = None
self.__init_store()
self.__STORE_EXT = ".state"
def __init_store(self):
if not os.path.exists(self.__store):
os.mkdir(self.__store)
def __set_state_file(self, id=None):
if id:
self.__stateFile = os.path.join(self.__store, "%s%s" % (id,
self.__STORE_EXT))
else:
for item in os.listdir(self.__store):
if item.endswith(self.__STORE_EXT):
self.__stateFile = os.path.join(self.__store, item)
def get_state_file(self):
return self.__stateFile
def checkStateFile(self, id=None, modes=(os.R_OK,)):
# is state file exists/readable/writable/both?
self.__set_state_file(id)
# return true if file doesn't exist, because HOD CAN create
# state file and so WILL have permissions to read and/or write
try:
os.stat(self.__stateFile)
except OSError, err:
if err.errno == errno.ENOENT: # error 2 (no such file)
return True
# file exists
ret = True
for mode in modes:
ret = ret and os.access(self.__stateFile, mode)
return ret
def read(self, id=None):
info = {}
self.__set_state_file(id)
if self.__stateFile:
if os.path.isfile(self.__stateFile):
stateFile = open(self.__stateFile, 'r')
try:
info = cPickle.load(stateFile)
except EOFError:
pass
stateFile.close()
return info
def write(self, id, info):
self.__set_state_file(id)
if not os.path.exists(self.__stateFile):
self.clear(id)
stateFile = open(self.__stateFile, 'w')
cPickle.dump(info, stateFile)
stateFile.close()
def clear(self, id=None):
self.__set_state_file(id)
if self.__stateFile and os.path.exists(self.__stateFile):
os.remove(self.__stateFile)
else:
for item in os.listdir(self.__store):
if item.endswith(self.__STORE_EXT):
os.remove(item)
class hodRunner:
def __init__(self, cfg, log=None, cluster=None):
self.__hodhelp = hodHelp()
self.__ops = self.__hodhelp.ops
self.__cfg = cfg
self.__npd = self.__cfg['nodepooldesc']
self.__opCode = 0
self.__user = getpass.getuser()
self.__registry = None
self.__baseLogger = None
# Allowing to pass in log object to help testing - a stub can be passed in
if log is None:
self.__setup_logger()
else:
self.__log = log
self.__userState = hodState(self.__cfg['hod']['user_state'])
self.__clusterState = None
self.__clusterStateInfo = { 'env' : None, 'hdfs' : None, 'mapred' : None }
# Allowing to pass in log object to help testing - a stib can be passed in
if cluster is None:
self.__cluster = hadoopCluster(self.__cfg, self.__log)
else:
self.__cluster = cluster
def __setup_logger(self):
self.__baseLogger = hodlib.Common.logger.hodLog('hod')
self.__log = self.__baseLogger.add_logger(self.__user )
if self.__cfg['hod']['stream']:
self.__baseLogger.add_stream(level=self.__cfg['hod']['debug'],
addToLoggerNames=(self.__user ,))
if self.__cfg['hod'].has_key('syslog-address'):
self.__baseLogger.add_syslog(self.__cfg['hod']['syslog-address'],
level=self.__cfg['hod']['debug'],
addToLoggerNames=(self.__user ,))
def get_logger(self):
return self.__log
def __setup_cluster_logger(self, directory):
self.__baseLogger.add_file(logDirectory=directory, level=4,
backupCount=self.__cfg['hod']['log-rollover-count'],
addToLoggerNames=(self.__user ,))
def __setup_cluster_state(self, directory):
self.__clusterState = hodState(directory)
def __norm_cluster_dir(self, directory):
directory = os.path.expanduser(directory)
if not os.path.isabs(directory):
directory = os.path.join(self.__cfg['hod']['original-dir'], directory)
directory = os.path.abspath(directory)
return directory
def __setup_service_registry(self):
cfg = self.__cfg['hod'].copy()
cfg['debug'] = 0
self.__registry = svcrgy(cfg, self.__log)
self.__registry.start()
self.__log.debug(self.__registry.getXMLRPCAddr())
self.__cfg['hod']['xrs-address'] = self.__registry.getXMLRPCAddr()
self.__cfg['ringmaster']['svcrgy-addr'] = self.__cfg['hod']['xrs-address']
def __set_cluster_state_info(self, env, hdfs, mapred, ring, jobid, min, max):
self.__clusterStateInfo['env'] = env
self.__clusterStateInfo['hdfs'] = "http://%s" % hdfs
self.__clusterStateInfo['mapred'] = "http://%s" % mapred
self.__clusterStateInfo['ring'] = ring
self.__clusterStateInfo['jobid'] = jobid
self.__clusterStateInfo['min'] = min
self.__clusterStateInfo['max'] = max
def __set_user_state_info(self, info):
userState = self.__userState.read(CLUSTER_DATA_FILE)
for key in info.keys():
userState[key] = info[key]
self.__userState.write(CLUSTER_DATA_FILE, userState)
def __remove_cluster(self, clusterDir):
clusterInfo = self.__userState.read(CLUSTER_DATA_FILE)
if clusterDir in clusterInfo:
del(clusterInfo[clusterDir])
self.__userState.write(CLUSTER_DATA_FILE, clusterInfo)
def __cleanup(self):
if self.__registry: self.__registry.stop()
def __check_operation(self, operation):
opList = operation.split()
if not opList[0] in self.__ops:
self.__log.critical("Invalid hod operation specified: %s" % operation)
self._op_help(None)
self.__opCode = 2
return opList
def __adjustMasterFailureCountConfig(self, nodeCount):
# This method adjusts the ringmaster.max-master-failures variable
# to a value that is bounded by the a function of the number of
# nodes.
maxFailures = self.__cfg['ringmaster']['max-master-failures']
# Count number of masters required - depends on which services
# are external
masters = 0
if not self.__cfg['gridservice-hdfs']['external']:
masters += 1
if not self.__cfg['gridservice-mapred']['external']:
masters += 1
# So, if there are n nodes and m masters, we look atleast for
# all masters to come up. Therefore, atleast m nodes should be
# good, which means a maximum of n-m master nodes can fail.
maxFailedNodes = nodeCount - masters
# The configured max number of failures is now bounded by this
# number.
self.__cfg['ringmaster']['max-master-failures'] = \
min(maxFailures, maxFailedNodes)
def _op_allocate(self, args):
operation = "allocate"
argLength = len(args)
min = 0
max = 0
errorFlag = False
errorMsgs = []
if argLength == 3:
nodes = args[2]
clusterDir = self.__norm_cluster_dir(args[1])
if not os.path.exists(clusterDir):
try:
os.makedirs(clusterDir)
except OSError, err:
errorFlag = True
errorMsgs.append("Could not create cluster directory. %s" \
% (str(err)))
elif not os.path.isdir(clusterDir):
errorFlag = True
errorMsgs.append( \
"Invalid cluster directory (--hod.clusterdir or -d) : " + \
clusterDir + " : Not a directory")
if int(nodes) < 3 :
errorFlag = True
errorMsgs.append("Invalid nodecount (--hod.nodecount or -n) : " + \
"Must be >= 3. Given nodes: %s" % nodes)
if errorFlag:
for msg in errorMsgs:
self.__log.critical(msg)
self.__opCode = 3
return
if not self.__userState.checkStateFile(CLUSTER_DATA_FILE, \
(os.R_OK, os.W_OK)):
self.__log.critical(INVALID_STATE_FILE_MSGS[2] % \
self.__userState.get_state_file())
self.__opCode = 1
return
clusterList = self.__userState.read(CLUSTER_DATA_FILE)
if clusterDir in clusterList.keys():
self.__setup_cluster_state(clusterDir)
clusterInfo = self.__clusterState.read()
# Check if the job is not running. Only then can we safely
# allocate another cluster. Otherwise the user would need
# to deallocate and free up resources himself.
if clusterInfo.has_key('jobid') and \
self.__cluster.is_cluster_deallocated(clusterInfo['jobid']):
self.__log.warn("Found a dead cluster at cluster directory '%s'. Deallocating it to allocate a new one." % (clusterDir))
self.__remove_cluster(clusterDir)
self.__clusterState.clear()
else:
self.__log.critical("Found a previously allocated cluster at cluster directory '%s'. HOD cannot determine if this cluster can be automatically deallocated. Deallocate the cluster if it is unused." % (clusterDir))
self.__opCode = 12
return
self.__setup_cluster_logger(clusterDir)
(status, message) = self.__cluster.is_valid_account()
if status is not 0:
if message:
for line in message:
self.__log.critical("verify-account output: %s" % line)
self.__log.critical("Cluster cannot be allocated because account verification failed. " \
+ "verify-account returned exit code: %s." % status)
self.__opCode = 4
return
else:
self.__log.debug("verify-account returned zero exit code.")
if message:
self.__log.debug("verify-account output: %s" % message)
if re.match('\d+-\d+', nodes):
(min, max) = nodes.split("-")
min = int(min)
max = int(max)
else:
try:
nodes = int(nodes)
min = nodes
max = nodes
except ValueError:
print self.__hodhelp.help(operation)
self.__log.critical(
"%s operation requires a pos_int value for n(nodecount)." %
operation)
self.__opCode = 3
else:
self.__setup_cluster_state(clusterDir)
clusterInfo = self.__clusterState.read()
self.__opCode = self.__cluster.check_cluster(clusterInfo)
if self.__opCode == 0 or self.__opCode == 15:
self.__setup_service_registry()
if hodInterrupt.isSet():
self.__cleanup()
raise HodInterruptException()
self.__log.debug("Service Registry started.")
self.__adjustMasterFailureCountConfig(nodes)
try:
allocateStatus = self.__cluster.allocate(clusterDir, min, max)
except HodInterruptException, h:
self.__cleanup()
raise h
# Allocation has gone through.
# Don't care about interrupts any more
try:
if allocateStatus == 0:
self.__set_cluster_state_info(os.environ,
self.__cluster.hdfsInfo,
self.__cluster.mapredInfo,
self.__cluster.ringmasterXRS,
self.__cluster.jobId,
min, max)
self.__setup_cluster_state(clusterDir)
self.__clusterState.write(self.__cluster.jobId,
self.__clusterStateInfo)
# Do we need to check for interrupts here ??
self.__set_user_state_info(
{ clusterDir : self.__cluster.jobId, } )
self.__opCode = allocateStatus
except Exception, e:
# Some unknown problem.
self.__cleanup()
self.__cluster.deallocate(clusterDir, self.__clusterStateInfo)
self.__opCode = 1
raise Exception(e)
elif self.__opCode == 12:
self.__log.critical("Cluster %s already allocated." % clusterDir)
elif self.__opCode == 10:
self.__log.critical("dead\t%s\t%s" % (clusterInfo['jobid'],
clusterDir))
elif self.__opCode == 13:
self.__log.warn("hdfs dead\t%s\t%s" % (clusterInfo['jobid'],
clusterDir))
elif self.__opCode == 14:
self.__log.warn("mapred dead\t%s\t%s" % (clusterInfo['jobid'],
clusterDir))
if self.__opCode > 0 and self.__opCode != 15:
self.__log.critical("Cannot allocate cluster %s" % clusterDir)
else:
print self.__hodhelp.help(operation)
self.__log.critical("%s operation requires two arguments. " % operation
+ "A cluster directory and a nodecount.")
self.__opCode = 3
def _is_cluster_allocated(self, clusterDir):
if os.path.isdir(clusterDir):
self.__setup_cluster_state(clusterDir)
clusterInfo = self.__clusterState.read()
if clusterInfo != {}:
return True
return False
def _op_deallocate(self, args):
operation = "deallocate"
argLength = len(args)
if argLength == 2:
clusterDir = self.__norm_cluster_dir(args[1])
if os.path.isdir(clusterDir):
self.__setup_cluster_state(clusterDir)
clusterInfo = self.__clusterState.read()
if clusterInfo == {}:
self.__handle_invalid_cluster_directory(clusterDir, cleanUp=True)
else:
self.__opCode = \
self.__cluster.deallocate(clusterDir, clusterInfo)
# irrespective of whether deallocate failed or not\
# remove the cluster state.
self.__clusterState.clear()
if not self.__userState.checkStateFile(CLUSTER_DATA_FILE, (os.W_OK,)):
self.__log.critical(INVALID_STATE_FILE_MSGS[3] % \
self.__userState.get_state_file())
self.__opCode = 1
return
self.__remove_cluster(clusterDir)
else:
self.__handle_invalid_cluster_directory(clusterDir, cleanUp=True)
else:
print self.__hodhelp.help(operation)
self.__log.critical("%s operation requires one argument. " % operation
+ "A cluster path.")
self.__opCode = 3
def _op_list(self, args):
operation = 'list'
clusterList = self.__userState.read(CLUSTER_DATA_FILE)
for path in clusterList.keys():
if not os.path.isdir(path):
self.__log.info("cluster state unknown\t%s\t%s" % (clusterList[path], path))
continue
self.__setup_cluster_state(path)
clusterInfo = self.__clusterState.read()
if clusterInfo == {}:
# something wrong with the cluster directory.
self.__log.info("cluster state unknown\t%s\t%s" % (clusterList[path], path))
continue
clusterStatus = self.__cluster.check_cluster(clusterInfo)
if clusterStatus == 12:
self.__log.info("alive\t%s\t%s" % (clusterList[path], path))
elif clusterStatus == 10:
self.__log.info("dead\t%s\t%s" % (clusterList[path], path))
elif clusterStatus == 13:
self.__log.info("hdfs dead\t%s\t%s" % (clusterList[path], path))
elif clusterStatus == 14:
self.__log.info("mapred dead\t%s\t%s" % (clusterList[path], path))
def _op_info(self, args):
operation = 'info'
argLength = len(args)
if argLength == 2:
clusterDir = self.__norm_cluster_dir(args[1])
if os.path.isdir(clusterDir):
self.__setup_cluster_state(clusterDir)
clusterInfo = self.__clusterState.read()
if clusterInfo == {}:
# something wrong with the cluster directory.
self.__handle_invalid_cluster_directory(clusterDir)
else:
clusterStatus = self.__cluster.check_cluster(clusterInfo)
if clusterStatus == 12:
self.__print_cluster_info(clusterInfo)
self.__log.info("hadoop-site.xml at %s" % clusterDir)
elif clusterStatus == 10:
self.__log.critical("%s cluster is dead" % clusterDir)
elif clusterStatus == 13:
self.__log.warn("%s cluster hdfs is dead" % clusterDir)
elif clusterStatus == 14:
self.__log.warn("%s cluster mapred is dead" % clusterDir)
if clusterStatus != 12:
if clusterStatus == 15:
self.__log.critical("Cluster %s not allocated." % clusterDir)
else:
self.__print_cluster_info(clusterInfo)
self.__log.info("hadoop-site.xml at %s" % clusterDir)
self.__opCode = clusterStatus
else:
self.__handle_invalid_cluster_directory(clusterDir)
else:
print self.__hodhelp.help(operation)
self.__log.critical("%s operation requires one argument. " % operation
+ "A cluster path.")
self.__opCode = 3
def __handle_invalid_cluster_directory(self, clusterDir, cleanUp=False):
if not self.__userState.checkStateFile(CLUSTER_DATA_FILE, (os.R_OK,)):
self.__log.critical(INVALID_STATE_FILE_MSGS[0] % \
self.__userState.get_state_file())
self.__opCode = 1
return
clusterList = self.__userState.read(CLUSTER_DATA_FILE)
if clusterDir in clusterList.keys():
# previously allocated cluster.
self.__log.critical("Cannot find information for cluster with id '%s' in previously allocated cluster directory '%s'." % (clusterList[clusterDir], clusterDir))
if cleanUp:
self.__cluster.delete_job(clusterList[clusterDir])
self.__log.critical("Freeing resources allocated to the cluster.")
if not self.__userState.checkStateFile(CLUSTER_DATA_FILE, (os.W_OK,)):
self.__log.critical(INVALID_STATE_FILE_MSGS[1] % \
self.__userState.get_state_file())
self.__opCode = 1
return
self.__remove_cluster(clusterDir)
self.__opCode = 3
else:
if not os.path.exists(clusterDir):
self.__log.critical( \
"Invalid hod.clusterdir(--hod.clusterdir or -d). " + \
clusterDir + " : No such directory")
elif not os.path.isdir(clusterDir):
self.__log.critical( \
"Invalid hod.clusterdir(--hod.clusterdir or -d). " + \
clusterDir + " : Not a directory")
else:
self.__log.critical( \
"Invalid hod.clusterdir(--hod.clusterdir or -d). " + \
clusterDir + " : Not tied to any allocated cluster.")
self.__opCode = 15
def __print_cluster_info(self, clusterInfo):
keys = clusterInfo.keys()
_dict = {
'jobid' : 'Cluster Id', 'min' : 'Nodecount',
'hdfs' : 'HDFS UI at' , 'mapred' : 'Mapred UI at'
}
for key in _dict.keys():
if clusterInfo.has_key(key):
self.__log.info("%s %s" % (_dict[key], clusterInfo[key]))
if clusterInfo.has_key('ring'):
self.__log.debug("%s\t%s" % ('Ringmaster at ', clusterInfo['ring']))
if self.__cfg['hod']['debug'] == 4:
for var in clusterInfo['env'].keys():
self.__log.debug("%s = %s" % (var, clusterInfo['env'][var]))
def _op_help(self, arg):
if arg == None or arg.__len__() != 2:
print "hod commands:\n"
for op in self.__ops:
print self.__hodhelp.help(op)
else:
if arg[1] not in self.__ops:
print self.__hodhelp.help('help')
self.__log.critical("Help requested for invalid operation : %s"%arg[1])
self.__opCode = 3
else: print self.__hodhelp.help(arg[1])
def operation(self):
operation = self.__cfg['hod']['operation']
try:
opList = self.__check_operation(operation)
if self.__opCode == 0:
if not self.__userState.checkStateFile(CLUSTER_DATA_FILE, (os.R_OK,)):
self.__log.critical(INVALID_STATE_FILE_MSGS[0] % \
self.__userState.get_state_file())
self.__opCode = 1
return self.__opCode
getattr(self, "_op_%s" % opList[0])(opList)
except HodInterruptException, h:
self.__log.critical("op: %s failed because of a process interrupt." \
% operation)
self.__opCode = HOD_INTERRUPTED_CODE
except:
self.__log.critical("op: %s failed: %s" % (operation,
get_exception_error_string()))
self.__log.debug(get_exception_string())
self.__cleanup()
self.__log.debug("return code: %s" % self.__opCode)
return self.__opCode
def script(self):
errorFlag = False
errorMsgs = []
scriptRet = 0 # return from the script, if run
script = self.__cfg['hod']['script']
nodes = self.__cfg['hod']['nodecount']
clusterDir = self.__cfg['hod']['clusterdir']
if not os.path.exists(script):
errorFlag = True
errorMsgs.append("Invalid script file (--hod.script or -s) : " + \
script + " : No such file")
elif not os.path.isfile(script):
errorFlag = True
errorMsgs.append("Invalid script file (--hod.script or -s) : " + \
script + " : Not a file.")
else:
isExecutable = os.access(script, os.X_OK)
if not isExecutable:
errorFlag = True
errorMsgs.append("Invalid script file (--hod.script or -s) : " + \
script + " : Not an executable.")
if not os.path.exists(clusterDir):
try:
os.makedirs(clusterDir)
except OSError, err:
errorFlag = True
errorMsgs.append("Could not create cluster directory. %s" % (str(err)))
elif not os.path.isdir(clusterDir):
errorFlag = True
errorMsgs.append( \
"Invalid cluster directory (--hod.clusterdir or -d) : " + \
clusterDir + " : Not a directory")
if int(self.__cfg['hod']['nodecount']) < 3 :
errorFlag = True
errorMsgs.append("Invalid nodecount (--hod.nodecount or -n) : " + \
"Must be >= 3. Given nodes: %s" % nodes)
if errorFlag:
for msg in errorMsgs:
self.__log.critical(msg)
self.handle_script_exit_code(scriptRet, clusterDir)
sys.exit(3)
try:
self._op_allocate(('allocate', clusterDir, str(nodes)))
if self.__opCode == 0:
if self.__cfg['hod'].has_key('script-wait-time'):
time.sleep(self.__cfg['hod']['script-wait-time'])
self.__log.debug('Slept for %d time. Now going to run the script' % self.__cfg['hod']['script-wait-time'])
if hodInterrupt.isSet():
self.__log.debug('Hod interrupted - not executing script')
else:
scriptRunner = hadoopScript(clusterDir,
self.__cfg['hod']['original-dir'])
self.__opCode = scriptRunner.run(script)
scriptRet = self.__opCode
self.__log.info("Exit code from running the script: %d" % self.__opCode)
else:
self.__log.critical("Error %d in allocating the cluster. Cannot run the script." % self.__opCode)
if hodInterrupt.isSet():
# Got interrupt while executing script. Unsetting it for deallocating
hodInterrupt.setFlag(False)
if self._is_cluster_allocated(clusterDir):
self._op_deallocate(('deallocate', clusterDir))
except HodInterruptException, h:
self.__log.critical("Script failed because of a process interrupt.")
self.__opCode = HOD_INTERRUPTED_CODE
except:
self.__log.critical("script: %s failed: %s" % (script,
get_exception_error_string()))
self.__log.debug(get_exception_string())
self.__cleanup()
self.handle_script_exit_code(scriptRet, clusterDir)
return self.__opCode
def handle_script_exit_code(self, scriptRet, clusterDir):
# We want to give importance to a failed script's exit code, and write out exit code to a file separately
# so users can easily get it if required. This way they can differentiate between the script's exit code
# and hod's exit code.
if os.path.exists(clusterDir):
exit_code_file_name = (os.path.join(clusterDir, 'script.exitcode'))
if scriptRet != 0:
exit_code_file = open(exit_code_file_name, 'w')
print >>exit_code_file, scriptRet
exit_code_file.close()
self.__opCode = scriptRet
else:
#ensure script exit code file is not there:
if (os.path.exists(exit_code_file_name)):
os.remove(exit_code_file_name)
class hodHelp:
def __init__(self):
self.ops = ['allocate', 'deallocate', 'info', 'list','script', 'help']
self.usage_strings = \
{
'allocate' : 'hod allocate -d <clusterdir> -n <nodecount> [OPTIONS]',
'deallocate' : 'hod deallocate -d <clusterdir> [OPTIONS]',
'list' : 'hod list [OPTIONS]',
'info' : 'hod info -d <clusterdir> [OPTIONS]',
'script' :
'hod script -d <clusterdir> -n <nodecount> -s <script> [OPTIONS]',
'help' : 'hod help <OPERATION>',
}
self.description_strings = \
{
'allocate' : "Allocates a cluster of n nodes using the specified \n" + \
" cluster directory to store cluster state \n" + \
" information. The Hadoop site XML is also stored \n" + \
" in this location.\n",
'deallocate' : "Deallocates a cluster using the specified \n" + \
" cluster directory. This operation is also \n" + \
" required to clean up a dead cluster.\n",
'list' : "List all clusters currently allocated by a user, \n" + \
" along with limited status information and the \n" + \
" cluster ID.\n",
'info' : "Provide detailed information on an allocated cluster.\n",
'script' : "Allocates a cluster of n nodes with the given \n" +\
" cluster directory, runs the specified script \n" + \
" using the allocated cluster, and then \n" + \
" deallocates the cluster.\n",
'help' : "Print help for the operation and exit.\n" + \
"Available operations : %s.\n" % self.ops,
}
def usage(self, op):
return "Usage : " + self.usage_strings[op] + "\n" + \
"For full description: hod help " + op + ".\n"
def help(self, op=None):
if op is None:
return "hod <operation> [ARGS] [OPTIONS]\n" + \
"Available operations : %s\n" % self.ops + \
"For help on a particular operation : hod help <operation>.\n" + \
"For all options : hod help options."
else:
return "Usage : " + self.usage_strings[op] + "\n" + \
"Description : " + self.description_strings[op] + \
"For all options : hod help options.\n"
|
apache-2.0
|
[
3,
31661,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
269,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
16832,
543,
642,
1736,
367,
4722,
2556,
199,
3,
1135,
1005,
316,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
475,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
23662,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
1045,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
3,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
3097,
1298,
1334,
314,
844,
14,
199,
3,
1882,
2366,
1882,
199,
199,
646,
984,
12,
747,
12,
18354,
12,
10933,
12,
295,
12,
17572,
12,
2196,
12,
5145,
12,
900,
12,
7554,
199,
199,
646,
394,
364,
773,
14,
7844,
14,
2921,
199,
199,
504,
394,
364,
773,
14,
3167,
10899,
14,
1364,
10899,
492,
19291,
1556,
4312,
199,
504,
394,
364,
773,
14,
7844,
14,
17596,
492,
394,
364,
12297,
3041,
199,
504,
394,
364,
773,
14,
7844,
14,
1974,
492,
370,
63,
1014,
63,
633,
12,
664,
63,
1971,
63,
875,
199,
504,
394,
364,
773,
14,
7844,
14,
1974,
492,
664,
63,
1971,
63,
705,
63,
875,
199,
504,
394,
364,
773,
14,
7844,
14,
1974,
492,
394,
364,
10647,
12,
869,
364,
10647,
1726,
199,
504,
394,
364,
773,
14,
7844,
14,
1974,
492,
7781,
36,
63,
3843,
9343,
1149,
63,
6012,
199,
199,
504,
394,
364,
773,
14,
7844,
14,
932,
2293,
1974,
492,
5013,
5453,
9562,
199,
504,
394,
364,
773,
14,
40,
364,
14,
15449,
492,
29252,
9581,
12,
29252,
5229,
199,
199,
26340,
63,
3998,
63,
3817,
275,
283,
9170,
7,
199,
9692,
63,
6689,
63,
3817,
63,
3053,
8021,
275,
971,
1598,
359,
2234,
298,
17935,
3439,
3913,
506,
10585,
14,
18435,
1586,
450,
83,
26,
298,
435,
971,
355,
298,
7980,
23355,
4765,
2234,
298,
17935,
3439,
3913,
506,
10585,
14,
298,
435,
971,
355,
298,
6612,
2218,
370,
450,
83,
26,
8779,
23355,
4765,
2234,
298,
17935,
3439,
3913,
506,
10585,
14,
298,
435,
971,
355,
298,
6612,
1586,
15,
952,
370,
450,
83,
26,
8779,
23355,
4765,
2234,
298,
6612,
1678,
450,
83,
26,
8779,
23355,
14,
298,
435,
971,
355,
298,
9581,
365,
7962,
13340,
12,
1325,
2256,
436,
769,
298,
435,
971,
355,
298,
8170,
5594,
2498,
8927,
2556,
4765,
25841,
1622,
199,
199,
533,
394,
364,
2223,
26,
523,
347,
636,
826,
721,
277,
12,
3877,
304,
272,
291,
855,
1617,
275,
3877,
272,
291,
855,
929,
1173,
275,
488,
272,
291,
855,
826,
63,
1617,
342,
272,
291,
855,
16169,
63,
2472,
275,
3680,
929,
2,
272,
523,
347,
636,
826,
63,
1617,
8,
277,
304,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
277,
855,
1617,
304,
489,
747,
14,
8215,
8,
277,
855,
1617,
9,
12244,
347,
636,
409,
63,
929,
63,
493,
8,
277,
12,
1305,
29,
403,
304,
272,
340,
1305,
26,
489,
291,
855,
929,
1173,
275,
747,
14,
515,
14,
904,
8,
277,
855,
1617,
12,
2071,
83,
5,
83,
2,
450,
334,
344,
12,
221,
4228,
291,
855,
16169,
63,
2472,
430,
272,
587,
26,
489,
367,
1242,
315,
747,
14,
7374,
8,
277,
855,
1617,
304,
267,
340,
1242,
14,
4130,
8,
277,
855,
16169,
63,
2472,
304,
257,
881,
291,
855,
929,
1173,
275,
747,
14,
515,
14,
904,
8,
277,
855,
1617,
12,
1242,
9,
3698,
819,
347,
664,
63,
929,
63,
493,
8,
277,
304,
272,
372,
291,
855,
929,
1173,
1779,
523,
347,
1104,
2223,
1173,
8,
277,
12,
1305,
29,
403,
12,
12404,
2687,
736,
14,
50,
63,
3593,
12,
2298,
272,
327,
365,
1174,
570,
3495,
15,
11875,
15,
15053,
15,
10727,
31,
272,
291,
855,
409,
63,
929,
63,
493,
8,
344,
9,
339,
327,
372,
2549,
340,
570,
3181,
1133,
2187,
12,
2952,
7781,
36,
29661,
1218,
272,
327,
1174,
570,
436,
880,
644,
14961,
1172,
3443,
370,
1586,
436,
15,
269,
2218,
272,
862,
26,
489,
747,
14,
3736,
8,
277,
855,
929,
1173,
9,
272,
871,
6440,
12,
2329,
26,
489,
340,
2329,
14,
7931,
508,
7554,
14,
20465,
26,
327,
1125,
499,
334,
889,
4066,
570,
9,
267,
372,
715,
339,
327,
570,
3495,
272,
2203,
275,
715,
272,
367,
818,
315,
12404,
26,
489,
2203,
275,
2203,
436,
747,
14,
2732,
8,
277,
855,
929,
1173,
12,
818,
9,
272,
372,
2203,
819,
347,
1586,
8,
277,
12,
1305,
29,
403,
304,
272,
2256,
275,
1052,
2286,
291,
855,
409,
63,
929,
63,
493,
8,
344,
9,
2043,
272,
340,
291,
855,
929,
1173,
26,
489,
340,
747,
14,
515,
14,
6292,
8,
277,
855,
929,
1173,
304,
267,
1174,
1173,
275,
1551,
8,
277,
855,
929,
1173,
12,
283,
82,
358,
267,
862,
26,
881,
2256,
275,
17572,
14,
912,
8,
929,
1173,
9,
267,
871,
21157,
26,
881,
986,
2728,
1174,
1173,
14,
1600,
342,
2286,
372,
2256,
288,
523,
347,
2218,
8,
277,
12,
1305,
12,
2256,
304,
272,
291,
855,
409,
63,
929,
63,
493,
8,
344,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
277,
855,
929,
1173,
304,
489,
291,
14,
3584,
8,
344,
9,
20950,
1174,
1173,
275,
1551,
8,
277,
855,
929,
1173,
12,
283,
87,
358,
272,
17572,
14,
2724,
8,
815,
12,
1174,
1173,
9,
272,
1174,
1173,
14,
1600,
342,
12244,
347,
5436,
8,
277,
12,
1305,
29,
403,
304,
272,
291,
855,
409,
63,
929,
63,
493,
8,
344,
9,
272,
340,
291,
855,
929,
1173,
436,
747,
14,
515,
14,
2444,
8,
277,
855,
929,
1173,
304,
489,
747,
14
] |
[
31661,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
269,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
16832,
543,
642,
1736,
367,
4722,
2556,
199,
3,
1135,
1005,
316,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
475,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
23662,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
1045,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
3,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
3097,
1298,
1334,
314,
844,
14,
199,
3,
1882,
2366,
1882,
199,
199,
646,
984,
12,
747,
12,
18354,
12,
10933,
12,
295,
12,
17572,
12,
2196,
12,
5145,
12,
900,
12,
7554,
199,
199,
646,
394,
364,
773,
14,
7844,
14,
2921,
199,
199,
504,
394,
364,
773,
14,
3167,
10899,
14,
1364,
10899,
492,
19291,
1556,
4312,
199,
504,
394,
364,
773,
14,
7844,
14,
17596,
492,
394,
364,
12297,
3041,
199,
504,
394,
364,
773,
14,
7844,
14,
1974,
492,
370,
63,
1014,
63,
633,
12,
664,
63,
1971,
63,
875,
199,
504,
394,
364,
773,
14,
7844,
14,
1974,
492,
664,
63,
1971,
63,
705,
63,
875,
199,
504,
394,
364,
773,
14,
7844,
14,
1974,
492,
394,
364,
10647,
12,
869,
364,
10647,
1726,
199,
504,
394,
364,
773,
14,
7844,
14,
1974,
492,
7781,
36,
63,
3843,
9343,
1149,
63,
6012,
199,
199,
504,
394,
364,
773,
14,
7844,
14,
932,
2293,
1974,
492,
5013,
5453,
9562,
199,
504,
394,
364,
773,
14,
40,
364,
14,
15449,
492,
29252,
9581,
12,
29252,
5229,
199,
199,
26340,
63,
3998,
63,
3817,
275,
283,
9170,
7,
199,
9692,
63,
6689,
63,
3817,
63,
3053,
8021,
275,
971,
1598,
359,
2234,
298,
17935,
3439,
3913,
506,
10585,
14,
18435,
1586,
450,
83,
26,
298,
435,
971,
355,
298,
7980,
23355,
4765,
2234,
298,
17935,
3439,
3913,
506,
10585,
14,
298,
435,
971,
355,
298,
6612,
2218,
370,
450,
83,
26,
8779,
23355,
4765,
2234,
298,
17935,
3439,
3913,
506,
10585,
14,
298,
435,
971,
355,
298,
6612,
1586,
15,
952,
370,
450,
83,
26,
8779,
23355,
4765,
2234,
298,
6612,
1678,
450,
83,
26,
8779,
23355,
14,
298,
435,
971,
355,
298,
9581,
365,
7962,
13340,
12,
1325,
2256,
436,
769,
298,
435,
971,
355,
298,
8170,
5594,
2498,
8927,
2556,
4765,
25841,
1622,
199,
199,
533,
394,
364,
2223,
26,
523,
347,
636,
826,
721,
277,
12,
3877,
304,
272,
291,
855,
1617,
275,
3877,
272,
291,
855,
929,
1173,
275,
488,
272,
291,
855,
826,
63,
1617,
342,
272,
291,
855,
16169,
63,
2472,
275,
3680,
929,
2,
272,
523,
347,
636,
826,
63,
1617,
8,
277,
304,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
277,
855,
1617,
304,
489,
747,
14,
8215,
8,
277,
855,
1617,
9,
12244,
347,
636,
409,
63,
929,
63,
493,
8,
277,
12,
1305,
29,
403,
304,
272,
340,
1305,
26,
489,
291,
855,
929,
1173,
275,
747,
14,
515,
14,
904,
8,
277,
855,
1617,
12,
2071,
83,
5,
83,
2,
450,
334,
344,
12,
221,
4228,
291,
855,
16169,
63,
2472,
430,
272,
587,
26,
489,
367,
1242,
315,
747,
14,
7374,
8,
277,
855,
1617,
304,
267,
340,
1242,
14,
4130,
8,
277,
855,
16169,
63,
2472,
304,
257,
881,
291,
855,
929,
1173,
275,
747,
14,
515,
14,
904,
8,
277,
855,
1617,
12,
1242,
9,
3698,
819,
347,
664,
63,
929,
63,
493,
8,
277,
304,
272,
372,
291,
855,
929,
1173,
1779,
523,
347,
1104,
2223,
1173,
8,
277,
12,
1305,
29,
403,
12,
12404,
2687,
736,
14,
50,
63,
3593,
12,
2298,
272,
327,
365,
1174,
570,
3495,
15,
11875,
15,
15053,
15,
10727,
31,
272,
291,
855,
409,
63,
929,
63,
493,
8,
344,
9,
339,
327,
372,
2549,
340,
570,
3181,
1133,
2187,
12,
2952,
7781,
36,
29661,
1218,
272,
327,
1174,
570,
436,
880,
644,
14961,
1172,
3443,
370,
1586,
436,
15,
269,
2218,
272,
862,
26,
489,
747,
14,
3736,
8,
277,
855,
929,
1173,
9,
272,
871,
6440,
12,
2329,
26,
489,
340,
2329,
14,
7931,
508,
7554,
14,
20465,
26,
327,
1125,
499,
334,
889,
4066,
570,
9,
267,
372,
715,
339,
327,
570,
3495,
272,
2203,
275,
715,
272,
367,
818,
315,
12404,
26,
489,
2203,
275,
2203,
436,
747,
14,
2732,
8,
277,
855,
929,
1173,
12,
818,
9,
272,
372,
2203,
819,
347,
1586,
8,
277,
12,
1305,
29,
403,
304,
272,
2256,
275,
1052,
2286,
291,
855,
409,
63,
929,
63,
493,
8,
344,
9,
2043,
272,
340,
291,
855,
929,
1173,
26,
489,
340,
747,
14,
515,
14,
6292,
8,
277,
855,
929,
1173,
304,
267,
1174,
1173,
275,
1551,
8,
277,
855,
929,
1173,
12,
283,
82,
358,
267,
862,
26,
881,
2256,
275,
17572,
14,
912,
8,
929,
1173,
9,
267,
871,
21157,
26,
881,
986,
2728,
1174,
1173,
14,
1600,
342,
2286,
372,
2256,
288,
523,
347,
2218,
8,
277,
12,
1305,
12,
2256,
304,
272,
291,
855,
409,
63,
929,
63,
493,
8,
344,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
277,
855,
929,
1173,
304,
489,
291,
14,
3584,
8,
344,
9,
20950,
1174,
1173,
275,
1551,
8,
277,
855,
929,
1173,
12,
283,
87,
358,
272,
17572,
14,
2724,
8,
815,
12,
1174,
1173,
9,
272,
1174,
1173,
14,
1600,
342,
12244,
347,
5436,
8,
277,
12,
1305,
29,
403,
304,
272,
291,
855,
409,
63,
929,
63,
493,
8,
344,
9,
272,
340,
291,
855,
929,
1173,
436,
747,
14,
515,
14,
2444,
8,
277,
855,
929,
1173,
304,
489,
747,
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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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
] |
tquilian/exeNext
|
exe/engine/error.py
|
15
|
1664
|
# ===========================================================================
# eXe
# Copyright 2004-2006, University of Auckland
#
# Config settings loaded from exe.conf
# Is responsible for the system-wide settings we use
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# ===========================================================================
"""
This module contains exception classes used for eXe specific errors
"""
import logging
log = logging.getLogger(__name__)
# ===========================================================================
class Error(Exception):
"""
Exception class used for eXe specific errors
"""
def __init__(self, value):
"""
Initialize
"""
Exception.__init__(self)
self.value = value
log.debug("init", self.value)
def __str__(self):
"""
return the error string
"""
return repr(self.value)
# ===========================================================================
|
gpl-2.0
|
[
3,
7819,
17575,
199,
3,
325,
56,
69,
199,
3,
1898,
8353,
13,
7968,
12,
15904,
402,
437,
10112,
9688,
199,
3,
199,
3,
4094,
2202,
6511,
687,
14778,
14,
2190,
199,
3,
6596,
17845,
367,
314,
2656,
13,
13062,
2202,
781,
675,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
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,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
221,
8217,
199,
3,
7819,
17575,
199,
624,
199,
2765,
859,
3509,
1919,
3992,
1202,
367,
325,
56,
69,
2488,
2552,
199,
624,
199,
199,
646,
2050,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
3,
7819,
17575,
199,
533,
4520,
8,
1726,
304,
272,
408,
272,
2186,
1021,
1202,
367,
325,
56,
69,
2488,
2552,
272,
408,
272,
347,
636,
826,
721,
277,
12,
574,
304,
267,
408,
267,
11578,
4960,
408,
267,
2186,
855,
826,
721,
277,
9,
267,
291,
14,
585,
275,
574,
267,
943,
14,
1757,
480,
826,
401,
291,
14,
585,
9,
339,
347,
636,
495,
721,
277,
304,
267,
408,
267,
372,
314,
1125,
1059,
267,
408,
267,
372,
4700,
8,
277,
14,
585,
9,
199,
199,
3,
7819,
17575,
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
] |
[
7819,
17575,
199,
3,
325,
56,
69,
199,
3,
1898,
8353,
13,
7968,
12,
15904,
402,
437,
10112,
9688,
199,
3,
199,
3,
4094,
2202,
6511,
687,
14778,
14,
2190,
199,
3,
6596,
17845,
367,
314,
2656,
13,
13062,
2202,
781,
675,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
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,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
221,
8217,
199,
3,
7819,
17575,
199,
624,
199,
2765,
859,
3509,
1919,
3992,
1202,
367,
325,
56,
69,
2488,
2552,
199,
624,
199,
199,
646,
2050,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
3,
7819,
17575,
199,
533,
4520,
8,
1726,
304,
272,
408,
272,
2186,
1021,
1202,
367,
325,
56,
69,
2488,
2552,
272,
408,
272,
347,
636,
826,
721,
277,
12,
574,
304,
267,
408,
267,
11578,
4960,
408,
267,
2186,
855,
826,
721,
277,
9,
267,
291,
14,
585,
275,
574,
267,
943,
14,
1757,
480,
826,
401,
291,
14,
585,
9,
339,
347,
636,
495,
721,
277,
304,
267,
408,
267,
372,
314,
1125,
1059,
267,
408,
267,
372,
4700,
8,
277,
14,
585,
9,
199,
199,
3,
7819,
17575,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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/common.py
|
81
|
4640
|
# -*- coding: utf-8 -*-
#
# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Common functionality shared by several modules."""
def bit_size(num):
"""
Number of bits needed to represent a integer excluding any prefix
0 bits.
As per definition from https://wiki.python.org/moin/BitManipulation and
to match the behavior of the Python 3 API.
Usage::
>>> bit_size(1023)
10
>>> bit_size(1024)
11
>>> bit_size(1025)
11
:param num:
Integer value. If num is 0, returns 0. Only the absolute value of the
number is considered. Therefore, signed integers will be abs(num)
before the number's bit length is determined.
:returns:
Returns the number of bits in the integer.
"""
if num == 0:
return 0
if num < 0:
num = -num
# Make sure this is an int and not a float.
num & 1
hex_num = "%x" % num
return ((len(hex_num) - 1) * 4) + {
'0': 0, '1': 1, '2': 2, '3': 2,
'4': 3, '5': 3, '6': 3, '7': 3,
'8': 4, '9': 4, 'a': 4, 'b': 4,
'c': 4, 'd': 4, 'e': 4, 'f': 4,
}[hex_num[0]]
def _bit_size(number):
"""
Returns the number of bits required to hold a specific long number.
"""
if number < 0:
raise ValueError('Only nonnegative numbers possible: %s' % number)
if number == 0:
return 0
# This works, even with very large numbers. When using math.log(number, 2),
# you'll get rounding errors and it'll fail.
bits = 0
while number:
bits += 1
number >>= 1
return bits
def byte_size(number):
"""
Returns the number of bytes required to hold a specific long number.
The number of bytes is rounded up.
Usage::
>>> byte_size(1 << 1023)
128
>>> byte_size((1 << 1024) - 1)
128
>>> byte_size(1 << 1024)
129
:param number:
An unsigned integer
:returns:
The number of bytes required to hold a specific long number.
"""
quanta, mod = divmod(bit_size(number), 8)
if mod or number == 0:
quanta += 1
return quanta
# return int(math.ceil(bit_size(number) / 8.0))
def extended_gcd(a, b):
"""Returns a tuple (r, i, j) such that r = gcd(a, b) = ia + jb
"""
# r = gcd(a,b) i = multiplicitive inverse of a mod b
# or j = multiplicitive inverse of b mod a
# Neg return values for i or j are made positive mod b or a respectively
# Iterateive Version is faster and uses much less stack space
x = 0
y = 1
lx = 1
ly = 0
oa = a # Remember original a/b to remove
ob = b # negative values from return results
while b != 0:
q = a // b
(a, b) = (b, a % b)
(x, lx) = ((lx - (q * x)), x)
(y, ly) = ((ly - (q * y)), y)
if lx < 0:
lx += ob # If neg wrap modulo orignal b
if ly < 0:
ly += oa # If neg wrap modulo orignal a
return a, lx, ly # Return only positive values
def inverse(x, n):
"""Returns x^-1 (mod n)
>>> inverse(7, 4)
3
>>> (inverse(143, 4) * 143) % 4
1
"""
(divider, inv, _) = extended_gcd(x, n)
if divider != 1:
raise ValueError("x (%d) and n (%d) are not relatively prime" % (x, n))
return inv
def crt(a_values, modulo_values):
"""Chinese Remainder Theorem.
Calculates x such that x = a[i] (mod m[i]) for each i.
:param a_values: the a-values of the above equation
:param modulo_values: the m-values of the above equation
:returns: x such that x = a[i] (mod m[i]) for each i
>>> crt([2, 3], [3, 5])
8
>>> crt([2, 3, 2], [3, 5, 7])
23
>>> crt([2, 3, 0], [7, 11, 15])
135
"""
m = 1
x = 0
for modulo in modulo_values:
m *= modulo
for (m_i, a_i) in zip(modulo_values, a_values):
M_i = m // m_i
inv = inverse(M_i, m_i)
x = (x + a_i * M_i * inv) % m
return x
if __name__ == '__main__':
import doctest
doctest.testmod()
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
221,
1898,
7760,
5515,
66,
828,
437,
14,
1933,
17709,
1090,
665,
1786,
66,
828,
32,
270,
85,
1090,
14,
16913,
30,
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,
420,
4178,
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,
199,
624,
7844,
9330,
5709,
701,
9978,
4621,
1041,
421,
199,
318,
4546,
63,
890,
8,
1507,
304,
272,
408,
272,
4860,
402,
5821,
4346,
370,
2954,
282,
3000,
28529,
1263,
2403,
272,
378,
5821,
14,
339,
3709,
1126,
5492,
687,
4178,
921,
6797,
14,
1548,
14,
1308,
15,
573,
262,
15,
4734,
2395,
711,
5332,
436,
272,
370,
1336,
314,
5953,
402,
314,
2018,
650,
3261,
14,
339,
11028,
447,
398,
1306,
4546,
63,
890,
8,
31923,
9,
267,
1616,
267,
1306,
4546,
63,
890,
8,
7727,
9,
267,
4119,
267,
1306,
4546,
63,
890,
8,
32105,
9,
267,
4119,
339,
520,
635,
1967,
26,
267,
7225,
574,
14,
982,
1967,
365,
378,
12,
2529,
378,
14,
5972,
314,
3679,
574,
402,
314,
267,
1329,
365,
8652,
14,
21039,
12,
10514,
9446,
911,
506,
2853,
8,
1507,
9,
267,
2544,
314,
1329,
1159,
4546,
2582,
365,
12037,
14,
272,
520,
5808,
26,
267,
1803,
314,
1329,
402,
5821,
315,
314,
3000,
14,
272,
408,
272,
340,
1967,
508,
378,
26,
267,
372,
378,
272,
340,
1967,
665,
378,
26,
267,
1967,
275,
446,
1507,
339,
327,
4155,
3238,
642,
365,
376,
1109,
436,
440,
282,
2069,
14,
272,
1967,
1253,
413,
339,
6318,
63,
1507,
275,
2071,
88,
2,
450,
1967,
272,
372,
3666,
552,
8,
4097,
63,
1507,
9,
446,
413,
9,
627,
841,
9,
435,
469,
267,
283,
16,
356,
378,
12,
283,
17,
356,
413,
12,
283,
18,
356,
499,
12,
283,
19,
356,
499,
12,
267,
283,
20,
356,
650,
12,
283,
21,
356,
650,
12,
283,
22,
356,
650,
12,
283,
23,
356,
650,
12,
267,
283,
24,
356,
841,
12,
283,
25,
356,
841,
12,
283,
65,
356,
841,
12,
283,
66,
356,
841,
12,
267,
283,
67,
356,
841,
12,
283,
68,
356,
841,
12,
283,
69,
356,
841,
12,
283,
70,
356,
841,
12,
272,
28439,
4097,
63,
1507,
59,
16,
2677,
421,
199,
318,
485,
2075,
63,
890,
8,
1955,
304,
272,
408,
272,
1803,
314,
1329,
402,
5821,
1415,
370,
10266,
282,
2488,
1846,
1329,
14,
272,
408,
272,
340,
1329,
665,
378,
26,
267,
746,
1722,
360,
5903,
2222,
7371,
5579,
3962,
26,
450,
83,
7,
450,
1329,
9,
339,
340,
1329,
508,
378,
26,
267,
372,
378,
339,
327,
961,
5419,
12,
2755,
543,
7437,
7031,
5579,
14,
3979,
1808,
3473,
14,
793,
8,
1955,
12,
499,
395,
272,
327,
1265,
7171,
664,
18100,
2552,
436,
652,
7171,
2449,
14,
272,
5821,
275,
378,
272,
1830,
1329,
26,
267,
5821,
847,
413,
267,
1329,
4331,
29,
413,
339,
372,
5821,
421,
199,
318,
3696,
63,
890,
8,
1955,
304,
272,
408,
272,
1803,
314,
1329,
402,
2783,
1415,
370,
10266,
282,
2488,
1846,
1329,
14,
339,
710,
1329,
402,
2783,
365,
24671,
1536,
14,
339,
11028,
447,
398,
1306,
3696,
63,
890,
8,
17,
5213,
12996,
19,
9,
267,
7960,
267,
1306,
3696,
63,
890,
1332,
17,
5213,
6619,
9,
446,
413,
9,
267,
7960,
267,
1306,
3696,
63,
890,
8,
17,
5213,
6619,
9,
267,
25454,
339,
520,
635,
1329,
26,
267,
1626,
7381,
3000,
272,
520,
5808,
26,
267,
710,
1329,
402,
2783,
1415,
370,
10266,
282,
2488,
1846,
1329,
14,
272,
408,
272,
2173,
290,
502,
12,
3413,
275,
16438,
8,
2075,
63,
890,
8,
1955,
395,
1695,
9,
272,
340,
3413,
503,
1329,
508,
378,
26,
267,
2173,
290,
502,
847,
413,
272,
372,
2173,
290,
502,
272,
327,
372,
1109,
8,
3442,
14,
14085,
8,
2075,
63,
890,
8,
1955,
9,
1182,
1695,
14,
16,
430,
421,
199,
318,
9243,
63,
22795,
8,
65,
12,
330,
304,
272,
408,
3407,
282,
2008,
334,
82,
12,
284,
12,
1335,
9,
4066,
626,
519,
275,
486,
2866,
8,
65,
12,
330,
9,
275,
284,
65,
435,
1335,
66,
272,
408,
272,
327,
519,
275,
486,
2866,
8,
65,
12,
66,
9,
284,
275,
8897,
317,
559,
857,
11484,
402,
282,
3413,
330,
272,
327,
420,
503,
420,
1335,
275,
8897,
317,
559,
857,
11484,
402,
330,
3413,
282,
272,
327,
5612,
71,
372,
1338,
367,
284,
503,
1335,
787,
6326,
7317,
3413,
330,
503,
282,
17342,
272,
327,
23989,
1912,
3394,
365,
12930,
436,
4440,
8298,
6656,
3464,
4601,
272,
671,
275,
378,
272,
612,
275,
413,
272,
634,
88,
275,
413,
272,
21559,
275,
378,
272,
312,
65,
275,
282,
221,
327,
31859,
3379,
282,
15,
66,
370,
2813,
272,
2607,
275,
330,
221,
327,
6946,
1338,
687,
372,
2058,
272,
1830,
330,
1137,
378,
26,
267,
1894,
275,
282,
5001,
330,
267,
334,
65,
12,
330,
9,
275,
334,
66,
12,
282,
450,
330,
9,
267,
334,
88,
12,
634,
88,
9,
275,
3666,
23605,
446,
334,
81,
627,
671,
1826,
671,
9,
267,
334,
89,
12,
21559,
9,
275,
3666,
590,
446,
334,
81,
627,
612,
1826,
612,
9,
272,
340,
634,
88,
665,
378,
26,
267,
634,
88,
847,
2607,
221,
327,
982,
14158,
4816,
27656,
503,
1030,
279,
330,
272,
340,
21559,
665,
378,
26,
267,
21559,
847,
312,
65,
221,
327,
982,
14158,
4816,
27656,
503,
1030,
279
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
221,
1898,
7760,
5515,
66,
828,
437,
14,
1933,
17709,
1090,
665,
1786,
66,
828,
32,
270,
85,
1090,
14,
16913,
30,
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,
420,
4178,
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,
199,
624,
7844,
9330,
5709,
701,
9978,
4621,
1041,
421,
199,
318,
4546,
63,
890,
8,
1507,
304,
272,
408,
272,
4860,
402,
5821,
4346,
370,
2954,
282,
3000,
28529,
1263,
2403,
272,
378,
5821,
14,
339,
3709,
1126,
5492,
687,
4178,
921,
6797,
14,
1548,
14,
1308,
15,
573,
262,
15,
4734,
2395,
711,
5332,
436,
272,
370,
1336,
314,
5953,
402,
314,
2018,
650,
3261,
14,
339,
11028,
447,
398,
1306,
4546,
63,
890,
8,
31923,
9,
267,
1616,
267,
1306,
4546,
63,
890,
8,
7727,
9,
267,
4119,
267,
1306,
4546,
63,
890,
8,
32105,
9,
267,
4119,
339,
520,
635,
1967,
26,
267,
7225,
574,
14,
982,
1967,
365,
378,
12,
2529,
378,
14,
5972,
314,
3679,
574,
402,
314,
267,
1329,
365,
8652,
14,
21039,
12,
10514,
9446,
911,
506,
2853,
8,
1507,
9,
267,
2544,
314,
1329,
1159,
4546,
2582,
365,
12037,
14,
272,
520,
5808,
26,
267,
1803,
314,
1329,
402,
5821,
315,
314,
3000,
14,
272,
408,
272,
340,
1967,
508,
378,
26,
267,
372,
378,
272,
340,
1967,
665,
378,
26,
267,
1967,
275,
446,
1507,
339,
327,
4155,
3238,
642,
365,
376,
1109,
436,
440,
282,
2069,
14,
272,
1967,
1253,
413,
339,
6318,
63,
1507,
275,
2071,
88,
2,
450,
1967,
272,
372,
3666,
552,
8,
4097,
63,
1507,
9,
446,
413,
9,
627,
841,
9,
435,
469,
267,
283,
16,
356,
378,
12,
283,
17,
356,
413,
12,
283,
18,
356,
499,
12,
283,
19,
356,
499,
12,
267,
283,
20,
356,
650,
12,
283,
21,
356,
650,
12,
283,
22,
356,
650,
12,
283,
23,
356,
650,
12,
267,
283,
24,
356,
841,
12,
283,
25,
356,
841,
12,
283,
65,
356,
841,
12,
283,
66,
356,
841,
12,
267,
283,
67,
356,
841,
12,
283,
68,
356,
841,
12,
283,
69,
356,
841,
12,
283,
70,
356,
841,
12,
272,
28439,
4097,
63,
1507,
59,
16,
2677,
421,
199,
318,
485,
2075,
63,
890,
8,
1955,
304,
272,
408,
272,
1803,
314,
1329,
402,
5821,
1415,
370,
10266,
282,
2488,
1846,
1329,
14,
272,
408,
272,
340,
1329,
665,
378,
26,
267,
746,
1722,
360,
5903,
2222,
7371,
5579,
3962,
26,
450,
83,
7,
450,
1329,
9,
339,
340,
1329,
508,
378,
26,
267,
372,
378,
339,
327,
961,
5419,
12,
2755,
543,
7437,
7031,
5579,
14,
3979,
1808,
3473,
14,
793,
8,
1955,
12,
499,
395,
272,
327,
1265,
7171,
664,
18100,
2552,
436,
652,
7171,
2449,
14,
272,
5821,
275,
378,
272,
1830,
1329,
26,
267,
5821,
847,
413,
267,
1329,
4331,
29,
413,
339,
372,
5821,
421,
199,
318,
3696,
63,
890,
8,
1955,
304,
272,
408,
272,
1803,
314,
1329,
402,
2783,
1415,
370,
10266,
282,
2488,
1846,
1329,
14,
339,
710,
1329,
402,
2783,
365,
24671,
1536,
14,
339,
11028,
447,
398,
1306,
3696,
63,
890,
8,
17,
5213,
12996,
19,
9,
267,
7960,
267,
1306,
3696,
63,
890,
1332,
17,
5213,
6619,
9,
446,
413,
9,
267,
7960,
267,
1306,
3696,
63,
890,
8,
17,
5213,
6619,
9,
267,
25454,
339,
520,
635,
1329,
26,
267,
1626,
7381,
3000,
272,
520,
5808,
26,
267,
710,
1329,
402,
2783,
1415,
370,
10266,
282,
2488,
1846,
1329,
14,
272,
408,
272,
2173,
290,
502,
12,
3413,
275,
16438,
8,
2075,
63,
890,
8,
1955,
395,
1695,
9,
272,
340,
3413,
503,
1329,
508,
378,
26,
267,
2173,
290,
502,
847,
413,
272,
372,
2173,
290,
502,
272,
327,
372,
1109,
8,
3442,
14,
14085,
8,
2075,
63,
890,
8,
1955,
9,
1182,
1695,
14,
16,
430,
421,
199,
318,
9243,
63,
22795,
8,
65,
12,
330,
304,
272,
408,
3407,
282,
2008,
334,
82,
12,
284,
12,
1335,
9,
4066,
626,
519,
275,
486,
2866,
8,
65,
12,
330,
9,
275,
284,
65,
435,
1335,
66,
272,
408,
272,
327,
519,
275,
486,
2866,
8,
65,
12,
66,
9,
284,
275,
8897,
317,
559,
857,
11484,
402,
282,
3413,
330,
272,
327,
420,
503,
420,
1335,
275,
8897,
317,
559,
857,
11484,
402,
330,
3413,
282,
272,
327,
5612,
71,
372,
1338,
367,
284,
503,
1335,
787,
6326,
7317,
3413,
330,
503,
282,
17342,
272,
327,
23989,
1912,
3394,
365,
12930,
436,
4440,
8298,
6656,
3464,
4601,
272,
671,
275,
378,
272,
612,
275,
413,
272,
634,
88,
275,
413,
272,
21559,
275,
378,
272,
312,
65,
275,
282,
221,
327,
31859,
3379,
282,
15,
66,
370,
2813,
272,
2607,
275,
330,
221,
327,
6946,
1338,
687,
372,
2058,
272,
1830,
330,
1137,
378,
26,
267,
1894,
275,
282,
5001,
330,
267,
334,
65,
12,
330,
9,
275,
334,
66,
12,
282,
450,
330,
9,
267,
334,
88,
12,
634,
88,
9,
275,
3666,
23605,
446,
334,
81,
627,
671,
1826,
671,
9,
267,
334,
89,
12,
21559,
9,
275,
3666,
590,
446,
334,
81,
627,
612,
1826,
612,
9,
272,
340,
634,
88,
665,
378,
26,
267,
634,
88,
847,
2607,
221,
327,
982,
14158,
4816,
27656,
503,
1030,
279,
330,
272,
340,
21559,
665,
378,
26,
267,
21559,
847,
312,
65,
221,
327,
982,
14158,
4816,
27656,
503,
1030,
279,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
mkret2/root
|
tutorials/pyroot/DynamicSlice.py
|
7
|
3847
|
## \file
## \ingroup tutorial_pyroot
## Example of function called when a mouse event occurs in a pad.
## When moving the mouse in the canvas, a second canvas shows the
## projection along X of the bin corresponding to the Y position
## of the mouse. The resulting histogram is fitted with a gaussian.
## A "dynamic" line shows the current bin position in Y.
## This more elaborated example can be used as a starting point
## to develop more powerful interactive applications exploiting CINT
## as a development engine.
##
## Note that a class is used to hold on to the canvas that display
## the selected slice.
##
## \macro_image
## \macro_code
##
## \author Rene Brun, Johann Cohen-Tanugi, Wim Lavrijsen
import sys
from ROOT import gRandom, gPad, gROOT, gVirtualX
from ROOT import kTRUE, kRed
from ROOT import TCanvas, TH2, TH2F, Double
class DynamicExec:
def __init__( self ):
self._cX = None
self._cY = None
self._old = None
def __call__( self ):
h = gPad.GetSelected();
if not h:
return
if not isinstance( h, TH2 ):
return
gPad.GetCanvas().FeedbackMode( kTRUE )
# erase old position and draw a line at current position
px = gPad.GetEventX()
py = gPad.GetEventY()
uxmin, uxmax = gPad.GetUxmin(), gPad.GetUxmax()
uymin, uymax = gPad.GetUymin(), gPad.GetUymax()
pxmin, pxmax = gPad.XtoAbsPixel( uxmin ), gPad.XtoAbsPixel( uxmax )
pymin, pymax = gPad.YtoAbsPixel( uymin ), gPad.YtoAbsPixel( uymax )
if self._old != None:
gVirtualX.DrawLine( pxmin, self._old[1], pxmax, self._old[1] )
gVirtualX.DrawLine( self._old[0], pymin, self._old[0], pymax )
gVirtualX.DrawLine( pxmin, py, pxmax, py )
gVirtualX.DrawLine( px, pymin, px, pymax )
self._old = px, py
upx = gPad.AbsPixeltoX( px )
x = gPad.PadtoX( upx )
upy = gPad.AbsPixeltoY( py )
y = gPad.PadtoY( upy )
padsav = gPad
# create or set the display canvases
if not self._cX:
self._cX = TCanvas( 'c2', 'Projection Canvas in X', 730, 10, 700, 500 )
else:
self._DestroyPrimitive( 'X' )
if not self._cY:
self._cY = TCanvas( 'c3', 'Projection Canvas in Y', 10, 550, 700, 500 )
else:
self._DestroyPrimitive( 'Y' )
self.DrawSlice( h, y, 'Y' )
self.DrawSlice( h, x, 'X' )
padsav.cd()
def _DestroyPrimitive( self, xy ):
proj = getattr( self, '_c'+xy ).GetPrimitive( 'Projection '+xy )
if proj:
proj.IsA().Destructor( proj )
def DrawSlice( self, histo, value, xy ):
yx = xy == 'X' and 'Y' or 'X'
# draw slice corresponding to mouse position
canvas = getattr( self, '_c'+xy )
canvas.SetGrid()
canvas.cd()
bin = getattr( histo, 'Get%saxis' % xy )().FindBin( value )
hp = getattr( histo, 'Projection' + yx )( '', bin, bin )
hp.SetFillColor( 38 )
hp.SetName( 'Projection ' + xy )
hp.SetTitle( xy + 'Projection of bin=%d' % bin )
hp.Fit( 'gaus', 'ql' )
hp.GetFunction( 'gaus' ).SetLineColor( kRed )
hp.GetFunction( 'gaus' ).SetLineWidth( 6 )
canvas.Update()
if __name__ == '__main__':
# create a new canvas.
c1 = TCanvas('c1', 'Dynamic Slice Example', 10, 10, 700, 500 )
c1.SetFillColor( 42 )
c1.SetFrameFillColor( 33 )
# create a 2-d histogram, fill and draw it
hpxpy = TH2F( 'hpxpy', 'py vs px', 40, -4, 4, 40, -4, 4 )
hpxpy.SetStats( 0 )
x, y = Double( 0.1 ), Double( 0.101 )
for i in xrange( 50000 ):
gRandom.Rannor( x, y )
hpxpy.Fill( x, y )
hpxpy.Draw( 'COL' )
# Add a TExec object to the canvas (explicit use of __main__ is for IPython)
import __main__
__main__.slicer = DynamicExec()
c1.AddExec( 'dynamic', 'TPython::Exec( "slicer()" );' )
c1.Update()
|
lgpl-2.1
|
[
309,
971,
493,
199,
309,
971,
316,
684,
307,
15888,
63,
647,
1231,
199,
309,
5679,
402,
805,
2797,
1380,
282,
12817,
1566,
11058,
315,
282,
6567,
14,
199,
309,
3979,
12876,
314,
12817,
315,
314,
10218,
12,
282,
3499,
10218,
13703,
314,
199,
309,
14777,
3180,
1323,
402,
314,
2517,
5226,
370,
314,
1488,
3421,
199,
309,
402,
314,
12817,
14,
710,
9183,
15379,
365,
26093,
543,
282,
28912,
14,
199,
309,
437,
298,
7764,
2,
1004,
13703,
314,
1453,
2517,
3421,
315,
1488,
14,
199,
309,
961,
1655,
579,
371,
269,
972,
2893,
883,
506,
1202,
465,
282,
6617,
2376,
199,
309,
370,
477,
7549,
1655,
7074,
1893,
12777,
13103,
15868,
390,
316,
445,
2919,
199,
309,
465,
282,
16367,
6869,
14,
199,
309,
199,
309,
3390,
626,
282,
1021,
365,
1202,
370,
10266,
641,
370,
314,
10218,
626,
2929,
199,
309,
314,
4895,
6014,
14,
199,
309,
199,
309,
971,
11300,
63,
1569,
199,
309,
971,
11300,
63,
600,
199,
309,
199,
309,
971,
2502,
820,
6349,
699,
1065,
12,
7135,
72,
1189,
1849,
16800,
13,
52,
290,
1518,
73,
12,
644,
1017,
491,
1214,
322,
74,
2464,
199,
199,
646,
984,
199,
199,
504,
16547,
492,
486,
3883,
12,
486,
18584,
12,
486,
5441,
12,
486,
8735,
56,
199,
504,
16547,
492,
1022,
15064,
12,
1022,
10858,
199,
504,
16547,
492,
377,
15174,
12,
4221,
18,
12,
4221,
18,
38,
12,
22945,
421,
199,
533,
21907,
4858,
26,
8410,
347,
636,
826,
721,
291,
3461,
489,
291,
423,
67,
56,
257,
275,
488,
489,
291,
423,
67,
57,
257,
275,
488,
489,
291,
423,
1753,
221,
275,
488,
8410,
347,
636,
1250,
721,
291,
3461,
2541,
394,
275,
486,
18584,
14,
1002,
12461,
7303,
489,
340,
440,
394,
26,
268,
372,
2541,
340,
440,
1228,
8,
394,
12,
4221,
18,
3461,
268,
372,
2541,
486,
18584,
14,
1002,
15174,
1252,
28687,
1385,
8,
1022,
15064,
776,
339,
327,
28343,
2269,
3421,
436,
5954,
282,
1004,
737,
1453,
3421,
489,
21162,
275,
486,
18584,
14,
1002,
2390,
56,
342,
489,
1134,
275,
486,
18584,
14,
1002,
2390,
57,
342,
2541,
399,
21601,
12,
399,
28961,
275,
486,
18584,
14,
1002,
53,
21601,
1062,
486,
18584,
14,
1002,
53,
28961,
342,
489,
399,
27429,
12,
399,
30036,
275,
486,
18584,
14,
1002,
53,
27429,
1062,
486,
18584,
14,
1002,
53,
30036,
342,
489,
21162,
827,
12,
21162,
988,
275,
486,
18584,
14,
56,
475,
15447,
14383,
8,
399,
21601,
2318,
486,
18584,
14,
56,
475,
15447,
14383,
8,
399,
28961,
776,
489,
1134,
827,
12,
1134,
988,
275,
486,
18584,
14,
57,
475,
15447,
14383,
8,
399,
27429,
2318,
486,
18584,
14,
57,
475,
15447,
14383,
8,
399,
30036,
776,
2541,
340,
291,
423,
1753,
1137,
488,
26,
268,
486,
8735,
56,
14,
9654,
3049,
8,
21162,
827,
12,
291,
423,
1753,
59,
17,
467,
21162,
988,
12,
291,
423,
1753,
59,
17,
61,
776,
268,
486,
8735,
56,
14,
9654,
3049,
8,
291,
423,
1753,
59,
16,
467,
1134,
827,
12,
291,
423,
1753,
59,
16,
467,
1134,
988,
776,
489,
486,
8735,
56,
14,
9654,
3049,
8,
21162,
827,
12,
1134,
12,
21162,
988,
12,
1134,
776,
489,
486,
8735,
56,
14,
9654,
3049,
8,
21162,
12,
1134,
827,
12,
21162,
12,
1134,
988,
776,
2541,
291,
423,
1753,
275,
21162,
12,
1134,
2541,
1536,
88,
275,
486,
18584,
14,
15447,
14383,
475,
56,
8,
21162,
776,
489,
671,
275,
486,
18584,
14,
18584,
475,
56,
8,
1536,
88,
776,
489,
1536,
89,
275,
486,
18584,
14,
15447,
14383,
475,
57,
8,
1134,
776,
489,
612,
275,
486,
18584,
14,
18584,
475,
57,
8,
1536,
89,
776,
2541,
6567,
23374,
275,
486,
18584,
339,
327,
1218,
503,
663,
314,
2929,
883,
86,
3274,
489,
340,
440,
291,
423,
67,
56,
26,
268,
291,
423,
67,
56,
275,
377,
15174,
8,
283,
67,
18,
297,
283,
23706,
29349,
315,
1323,
297,
1520,
1216,
12,
1616,
12,
30071,
12,
6891,
776,
489,
587,
26,
268,
291,
423,
14704,
22231,
8,
283,
56,
7,
776,
2541,
340,
440,
291,
423,
67,
57,
26,
268,
291,
423,
67,
57,
275,
377,
15174,
8,
283,
67,
19,
297,
283,
23706,
29349,
315,
1488,
297,
1616,
12,
959,
1400,
12,
30071,
12,
6891,
776,
489,
587,
26,
268,
291,
423,
14704,
22231,
8,
283,
57,
7,
776,
2541,
291,
14,
9654,
14034,
8,
394,
12,
612,
12,
283,
57,
7,
776,
489,
291,
14,
9654,
14034,
8,
394,
12,
671,
12,
283,
56,
7,
776,
2541,
6567,
23374,
14,
2866,
342,
8410,
347,
485,
14704,
22231,
8,
291,
12,
13222,
3461,
489,
13523,
275,
2519,
8,
291,
12,
2513,
67,
6828,
1702,
7092,
1002,
22231,
8,
283,
23706,
6681,
1702,
776,
489,
340,
13523,
26,
268,
13523,
14,
14104,
1252,
872,
1426,
8,
13523,
776,
8410,
347,
17813,
14034,
8,
291,
12,
394,
7133,
12,
574,
12,
13222,
3461,
489,
612,
88,
275,
13222,
508,
283,
56,
7,
436,
283,
57,
7,
503,
283,
56,
7,
339,
327,
5954,
6014,
5226,
370,
12817,
3421,
489,
10218,
275,
2519,
8,
291,
12,
2513,
67,
6828,
1702,
776,
489,
10218,
14,
1084,
7900,
342,
489,
10218,
14,
2866,
342,
2541,
2517,
275,
2519,
8,
394,
7133,
12,
283,
1002,
5,
83,
3127,
7,
450,
13222,
776,
1252,
6591,
13394,
8,
574,
776,
489,
20962,
275,
2519,
8,
394,
7133,
12,
283,
23706,
7,
435,
612,
88,
776,
8,
3260,
2517,
12,
2517,
776,
489,
20962,
14,
1084,
12914,
4117,
8,
10448,
776,
489,
20962,
14,
1084,
985,
8,
283,
23706,
283,
435,
13222,
776,
489,
20962,
14,
1084,
6888,
8,
13222,
435,
283,
23706,
402,
2517,
2458,
68,
7,
450,
2517,
776,
489,
20962,
14,
13776,
8,
283,
5294,
527,
297,
283,
1710,
7,
776,
489,
20962,
14,
1002,
3481,
8,
283,
5294,
527,
7,
7092,
1084,
3049,
4117,
8,
1022,
10858,
776,
489,
20962,
14,
1002,
3481,
8,
283,
5294,
527,
7,
7092,
1084,
3049,
6216,
8,
1227,
776,
489,
10218,
14,
4152,
342,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
199,
327,
1218,
282,
892,
10218,
14,
2043,
286,
17,
275,
377,
15174
] |
[
971,
493,
199,
309,
971,
316,
684,
307,
15888,
63,
647,
1231,
199,
309,
5679,
402,
805,
2797,
1380,
282,
12817,
1566,
11058,
315,
282,
6567,
14,
199,
309,
3979,
12876,
314,
12817,
315,
314,
10218,
12,
282,
3499,
10218,
13703,
314,
199,
309,
14777,
3180,
1323,
402,
314,
2517,
5226,
370,
314,
1488,
3421,
199,
309,
402,
314,
12817,
14,
710,
9183,
15379,
365,
26093,
543,
282,
28912,
14,
199,
309,
437,
298,
7764,
2,
1004,
13703,
314,
1453,
2517,
3421,
315,
1488,
14,
199,
309,
961,
1655,
579,
371,
269,
972,
2893,
883,
506,
1202,
465,
282,
6617,
2376,
199,
309,
370,
477,
7549,
1655,
7074,
1893,
12777,
13103,
15868,
390,
316,
445,
2919,
199,
309,
465,
282,
16367,
6869,
14,
199,
309,
199,
309,
3390,
626,
282,
1021,
365,
1202,
370,
10266,
641,
370,
314,
10218,
626,
2929,
199,
309,
314,
4895,
6014,
14,
199,
309,
199,
309,
971,
11300,
63,
1569,
199,
309,
971,
11300,
63,
600,
199,
309,
199,
309,
971,
2502,
820,
6349,
699,
1065,
12,
7135,
72,
1189,
1849,
16800,
13,
52,
290,
1518,
73,
12,
644,
1017,
491,
1214,
322,
74,
2464,
199,
199,
646,
984,
199,
199,
504,
16547,
492,
486,
3883,
12,
486,
18584,
12,
486,
5441,
12,
486,
8735,
56,
199,
504,
16547,
492,
1022,
15064,
12,
1022,
10858,
199,
504,
16547,
492,
377,
15174,
12,
4221,
18,
12,
4221,
18,
38,
12,
22945,
421,
199,
533,
21907,
4858,
26,
8410,
347,
636,
826,
721,
291,
3461,
489,
291,
423,
67,
56,
257,
275,
488,
489,
291,
423,
67,
57,
257,
275,
488,
489,
291,
423,
1753,
221,
275,
488,
8410,
347,
636,
1250,
721,
291,
3461,
2541,
394,
275,
486,
18584,
14,
1002,
12461,
7303,
489,
340,
440,
394,
26,
268,
372,
2541,
340,
440,
1228,
8,
394,
12,
4221,
18,
3461,
268,
372,
2541,
486,
18584,
14,
1002,
15174,
1252,
28687,
1385,
8,
1022,
15064,
776,
339,
327,
28343,
2269,
3421,
436,
5954,
282,
1004,
737,
1453,
3421,
489,
21162,
275,
486,
18584,
14,
1002,
2390,
56,
342,
489,
1134,
275,
486,
18584,
14,
1002,
2390,
57,
342,
2541,
399,
21601,
12,
399,
28961,
275,
486,
18584,
14,
1002,
53,
21601,
1062,
486,
18584,
14,
1002,
53,
28961,
342,
489,
399,
27429,
12,
399,
30036,
275,
486,
18584,
14,
1002,
53,
27429,
1062,
486,
18584,
14,
1002,
53,
30036,
342,
489,
21162,
827,
12,
21162,
988,
275,
486,
18584,
14,
56,
475,
15447,
14383,
8,
399,
21601,
2318,
486,
18584,
14,
56,
475,
15447,
14383,
8,
399,
28961,
776,
489,
1134,
827,
12,
1134,
988,
275,
486,
18584,
14,
57,
475,
15447,
14383,
8,
399,
27429,
2318,
486,
18584,
14,
57,
475,
15447,
14383,
8,
399,
30036,
776,
2541,
340,
291,
423,
1753,
1137,
488,
26,
268,
486,
8735,
56,
14,
9654,
3049,
8,
21162,
827,
12,
291,
423,
1753,
59,
17,
467,
21162,
988,
12,
291,
423,
1753,
59,
17,
61,
776,
268,
486,
8735,
56,
14,
9654,
3049,
8,
291,
423,
1753,
59,
16,
467,
1134,
827,
12,
291,
423,
1753,
59,
16,
467,
1134,
988,
776,
489,
486,
8735,
56,
14,
9654,
3049,
8,
21162,
827,
12,
1134,
12,
21162,
988,
12,
1134,
776,
489,
486,
8735,
56,
14,
9654,
3049,
8,
21162,
12,
1134,
827,
12,
21162,
12,
1134,
988,
776,
2541,
291,
423,
1753,
275,
21162,
12,
1134,
2541,
1536,
88,
275,
486,
18584,
14,
15447,
14383,
475,
56,
8,
21162,
776,
489,
671,
275,
486,
18584,
14,
18584,
475,
56,
8,
1536,
88,
776,
489,
1536,
89,
275,
486,
18584,
14,
15447,
14383,
475,
57,
8,
1134,
776,
489,
612,
275,
486,
18584,
14,
18584,
475,
57,
8,
1536,
89,
776,
2541,
6567,
23374,
275,
486,
18584,
339,
327,
1218,
503,
663,
314,
2929,
883,
86,
3274,
489,
340,
440,
291,
423,
67,
56,
26,
268,
291,
423,
67,
56,
275,
377,
15174,
8,
283,
67,
18,
297,
283,
23706,
29349,
315,
1323,
297,
1520,
1216,
12,
1616,
12,
30071,
12,
6891,
776,
489,
587,
26,
268,
291,
423,
14704,
22231,
8,
283,
56,
7,
776,
2541,
340,
440,
291,
423,
67,
57,
26,
268,
291,
423,
67,
57,
275,
377,
15174,
8,
283,
67,
19,
297,
283,
23706,
29349,
315,
1488,
297,
1616,
12,
959,
1400,
12,
30071,
12,
6891,
776,
489,
587,
26,
268,
291,
423,
14704,
22231,
8,
283,
57,
7,
776,
2541,
291,
14,
9654,
14034,
8,
394,
12,
612,
12,
283,
57,
7,
776,
489,
291,
14,
9654,
14034,
8,
394,
12,
671,
12,
283,
56,
7,
776,
2541,
6567,
23374,
14,
2866,
342,
8410,
347,
485,
14704,
22231,
8,
291,
12,
13222,
3461,
489,
13523,
275,
2519,
8,
291,
12,
2513,
67,
6828,
1702,
7092,
1002,
22231,
8,
283,
23706,
6681,
1702,
776,
489,
340,
13523,
26,
268,
13523,
14,
14104,
1252,
872,
1426,
8,
13523,
776,
8410,
347,
17813,
14034,
8,
291,
12,
394,
7133,
12,
574,
12,
13222,
3461,
489,
612,
88,
275,
13222,
508,
283,
56,
7,
436,
283,
57,
7,
503,
283,
56,
7,
339,
327,
5954,
6014,
5226,
370,
12817,
3421,
489,
10218,
275,
2519,
8,
291,
12,
2513,
67,
6828,
1702,
776,
489,
10218,
14,
1084,
7900,
342,
489,
10218,
14,
2866,
342,
2541,
2517,
275,
2519,
8,
394,
7133,
12,
283,
1002,
5,
83,
3127,
7,
450,
13222,
776,
1252,
6591,
13394,
8,
574,
776,
489,
20962,
275,
2519,
8,
394,
7133,
12,
283,
23706,
7,
435,
612,
88,
776,
8,
3260,
2517,
12,
2517,
776,
489,
20962,
14,
1084,
12914,
4117,
8,
10448,
776,
489,
20962,
14,
1084,
985,
8,
283,
23706,
283,
435,
13222,
776,
489,
20962,
14,
1084,
6888,
8,
13222,
435,
283,
23706,
402,
2517,
2458,
68,
7,
450,
2517,
776,
489,
20962,
14,
13776,
8,
283,
5294,
527,
297,
283,
1710,
7,
776,
489,
20962,
14,
1002,
3481,
8,
283,
5294,
527,
7,
7092,
1084,
3049,
4117,
8,
1022,
10858,
776,
489,
20962,
14,
1002,
3481,
8,
283,
5294,
527,
7,
7092,
1084,
3049,
6216,
8,
1227,
776,
489,
10218,
14,
4152,
342,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
199,
327,
1218,
282,
892,
10218,
14,
2043,
286,
17,
275,
377,
15174,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
|
3241
|
"""
Helper functions for dealing with Twisted deferreds
"""
from twisted.internet import defer, reactor, task
from twisted.python import failure
from scrapy.exceptions import IgnoreRequest
def defer_fail(_failure):
"""Same as twisted.internet.defer.fail, but delay calling errback until
next reactor loop
"""
d = defer.Deferred()
reactor.callLater(0, d.errback, _failure)
return d
def defer_succeed(result):
"""Same as twsited.internet.defer.succed, but delay calling callback until
next reactor loop
"""
d = defer.Deferred()
reactor.callLater(0, d.callback, result)
return d
def defer_result(result):
if isinstance(result, defer.Deferred):
return result
elif isinstance(result, failure.Failure):
return defer_fail(result)
else:
return defer_succeed(result)
def mustbe_deferred(f, *args, **kw):
"""Same as twisted.internet.defer.maybeDeferred, but delay calling
callback/errback to next reactor loop
"""
try:
result = f(*args, **kw)
# FIXME: Hack to avoid introspecting tracebacks. This to speed up
# processing of IgnoreRequest errors which are, by far, the most common
# exception in Scrapy - see #125
except IgnoreRequest as e:
return defer_fail(failure.Failure(e))
except:
return defer_fail(failure.Failure())
else:
return defer_result(result)
def parallel(iterable, count, callable, *args, **named):
"""Execute a callable over the objects in the given iterable, in parallel,
using no more than ``count`` concurrent calls.
Taken from: http://jcalderone.livejournal.com/24285.html
"""
coop = task.Cooperator()
work = (callable(elem, *args, **named) for elem in iterable)
return defer.DeferredList([coop.coiterate(work) for i in xrange(count)])
def process_chain(callbacks, input, *a, **kw):
"""Return a Deferred built by chaining the given callbacks"""
d = defer.Deferred()
for x in callbacks:
d.addCallback(x, *a, **kw)
d.callback(input)
return d
def process_chain_both(callbacks, errbacks, input, *a, **kw):
"""Return a Deferred built by chaining the given callbacks and errbacks"""
d = defer.Deferred()
for cb, eb in zip(callbacks, errbacks):
d.addCallbacks(cb, eb, callbackArgs=a, callbackKeywords=kw,
errbackArgs=a, errbackKeywords=kw)
if isinstance(input, failure.Failure):
d.errback(input)
else:
d.callback(input)
return d
def process_parallel(callbacks, input, *a, **kw):
"""Return a Deferred with the output of all successful calls to the given
callbacks
"""
dfds = [defer.succeed(input).addCallback(x, *a, **kw) for x in callbacks]
d = defer.DeferredList(dfds, fireOnOneErrback=1, consumeErrors=1)
d.addCallbacks(lambda r: [x[1] for x in r], lambda f: f.value.subFailure)
return d
def iter_errback(iterable, errback, *a, **kw):
"""Wraps an iterable calling an errback if an error is caught while
iterating it.
"""
it = iter(iterable)
while 1:
try:
yield next(it)
except StopIteration:
break
except:
errback(failure.Failure(), *a, **kw)
|
bsd-3-clause
|
[
624,
199,
4433,
3423,
367,
23654,
543,
17078,
12309,
83,
199,
624,
199,
199,
504,
7390,
14,
4901,
492,
10133,
12,
9655,
12,
2120,
199,
504,
7390,
14,
1548,
492,
5988,
199,
199,
504,
18918,
14,
3924,
492,
14092,
2017,
199,
199,
318,
10133,
63,
1633,
1547,
5328,
304,
272,
408,
8479,
465,
7390,
14,
4901,
14,
11610,
14,
1633,
12,
1325,
7339,
6358,
2329,
894,
5133,
272,
2163,
9655,
4438,
272,
408,
272,
366,
275,
10133,
14,
9937,
342,
272,
9655,
14,
1250,
22028,
8,
16,
12,
366,
14,
28940,
12,
485,
5328,
9,
272,
372,
366,
199,
199,
318,
10133,
63,
26622,
8,
1099,
304,
272,
408,
8479,
465,
8900,
11669,
14,
4901,
14,
11610,
14,
28251,
6867,
12,
1325,
7339,
6358,
3233,
5133,
272,
2163,
9655,
4438,
272,
408,
272,
366,
275,
10133,
14,
9937,
342,
272,
9655,
14,
1250,
22028,
8,
16,
12,
366,
14,
3058,
12,
754,
9,
272,
372,
366,
199,
199,
318,
10133,
63,
1099,
8,
1099,
304,
272,
340,
1228,
8,
1099,
12,
10133,
14,
9937,
304,
267,
372,
754,
272,
916,
1228,
8,
1099,
12,
5988,
14,
6782,
304,
267,
372,
10133,
63,
1633,
8,
1099,
9,
272,
587,
26,
267,
372,
10133,
63,
26622,
8,
1099,
9,
199,
199,
318,
1471,
1235,
63,
12116,
8,
70,
12,
627,
589,
12,
1011,
829,
304,
272,
408,
8479,
465,
7390,
14,
4901,
14,
11610,
14,
11853,
9937,
12,
1325,
7339,
6358,
272,
3233,
15,
28940,
370,
2163,
9655,
4438,
272,
408,
272,
862,
26,
267,
754,
275,
289,
2031,
589,
12,
1011,
829,
9,
272,
327,
7600,
26,
30802,
370,
5126,
1109,
21302,
316,
5190,
83,
14,
961,
370,
8112,
1536,
272,
327,
6661,
402,
14092,
2017,
2552,
1314,
787,
12,
701,
12474,
12,
314,
4750,
2863,
272,
327,
1919,
315,
13916,
345,
647,
446,
1937,
327,
6889,
272,
871,
14092,
2017,
465,
325,
26,
267,
372,
10133,
63,
1633,
8,
5328,
14,
6782,
8,
69,
430,
272,
871,
26,
267,
372,
10133,
63,
1633,
8,
5328,
14,
6782,
1012,
272,
587,
26,
267,
372,
10133,
63,
1099,
8,
1099,
9,
199,
199,
318,
9861,
8,
8147,
12,
2338,
12,
4550,
12,
627,
589,
12,
1011,
4579,
304,
272,
408,
12049,
282,
4550,
1806,
314,
2251,
315,
314,
1627,
6076,
12,
315,
9861,
12,
272,
1808,
949,
1655,
2419,
1124,
835,
1040,
23002,
4882,
14,
339,
32316,
917,
687,
26,
1455,
921,
74,
915,
424,
368,
14,
6442,
7067,
14,
957,
15,
1194,
14523,
14,
1360,
272,
408,
272,
512,
411,
275,
2120,
14,
967,
3856,
342,
272,
1736,
275,
334,
8296,
8,
6086,
12,
627,
589,
12,
1011,
4579,
9,
367,
6193,
315,
6076,
9,
272,
372,
10133,
14,
9937,
1296,
779,
331,
411,
14,
331,
20627,
8,
800,
9,
367,
284,
315,
4945,
8,
835,
3948,
199,
199,
318,
2112,
63,
4429,
8,
11948,
12,
1324,
12,
627,
65,
12,
1011,
829,
304,
272,
408,
1767,
282,
17448,
6137,
701,
6036,
316,
314,
1627,
13484,
624,
272,
366,
275,
10133,
14,
9937,
342,
272,
367,
671,
315,
13484,
26,
267,
366,
14,
10053,
8,
88,
12,
627,
65,
12,
1011,
829,
9,
272,
366,
14,
3058,
8,
1210,
9,
272,
372,
366,
199,
199,
318,
2112,
63,
4429,
63,
10727,
8,
11948,
12,
2329,
894,
83,
12,
1324,
12,
627,
65,
12,
1011,
829,
304,
272,
408,
1767,
282,
17448,
6137,
701,
6036,
316,
314,
1627,
13484,
436,
2329,
894,
83,
624,
272,
366,
275,
10133,
14,
9937,
342,
272,
367,
7434,
12,
26669,
315,
3482,
8,
11948,
12,
2329,
894,
83,
304,
267,
366,
14,
10053,
83,
8,
2894,
12,
26669,
12,
3233,
6213,
29,
65,
12,
3233,
23611,
29,
829,
12,
288,
2329,
894,
6213,
29,
65,
12,
2329,
894,
23611,
29,
829,
9,
272,
340,
1228,
8,
1210,
12,
5988,
14,
6782,
304,
267,
366,
14,
28940,
8,
1210,
9,
272,
587,
26,
267,
366,
14,
3058,
8,
1210,
9,
272,
372,
366,
199,
199,
318,
2112,
63,
11887,
8,
11948,
12,
1324,
12,
627,
65,
12,
1011,
829,
304,
272,
408,
1767,
282,
17448,
543,
314,
1072,
402,
1006,
9512,
4882,
370,
314,
1627,
272,
13484,
272,
408,
272,
4051,
795,
275,
359,
11610,
14,
26622,
8,
1210,
680,
10053,
8,
88,
12,
627,
65,
12,
1011,
829,
9,
367,
671,
315,
13484,
61,
272,
366,
275,
10133,
14,
9937,
1296,
8,
1587,
795,
12,
8344,
3314,
4395,
28245,
29,
17,
12,
9451,
9298,
29,
17,
9,
272,
366,
14,
10053,
83,
8,
2734,
519,
26,
359,
88,
59,
17,
61,
367,
671,
315,
519,
467,
2400,
289,
26,
289,
14,
585,
14,
954,
6782,
9,
272,
372,
366,
199,
199,
318,
2740,
63,
28940,
8,
8147,
12,
2329,
894,
12,
627,
65,
12,
1011,
829,
304,
272,
408,
55,
8146,
376,
6076,
6358,
376,
2329,
894,
340,
376,
1125,
365,
15604,
1830,
272,
25012,
652,
14,
272,
408,
272,
652,
275,
2740,
8,
8147,
9,
272,
1830,
413,
26,
267,
862,
26,
288,
1995,
2163,
8,
390,
9,
267,
871,
10852,
26,
288,
2059,
267,
871,
26,
288,
2329,
894,
8,
5328,
14,
6782,
1062,
627,
65,
12,
1011,
829,
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
] |
[
199,
4433,
3423,
367,
23654,
543,
17078,
12309,
83,
199,
624,
199,
199,
504,
7390,
14,
4901,
492,
10133,
12,
9655,
12,
2120,
199,
504,
7390,
14,
1548,
492,
5988,
199,
199,
504,
18918,
14,
3924,
492,
14092,
2017,
199,
199,
318,
10133,
63,
1633,
1547,
5328,
304,
272,
408,
8479,
465,
7390,
14,
4901,
14,
11610,
14,
1633,
12,
1325,
7339,
6358,
2329,
894,
5133,
272,
2163,
9655,
4438,
272,
408,
272,
366,
275,
10133,
14,
9937,
342,
272,
9655,
14,
1250,
22028,
8,
16,
12,
366,
14,
28940,
12,
485,
5328,
9,
272,
372,
366,
199,
199,
318,
10133,
63,
26622,
8,
1099,
304,
272,
408,
8479,
465,
8900,
11669,
14,
4901,
14,
11610,
14,
28251,
6867,
12,
1325,
7339,
6358,
3233,
5133,
272,
2163,
9655,
4438,
272,
408,
272,
366,
275,
10133,
14,
9937,
342,
272,
9655,
14,
1250,
22028,
8,
16,
12,
366,
14,
3058,
12,
754,
9,
272,
372,
366,
199,
199,
318,
10133,
63,
1099,
8,
1099,
304,
272,
340,
1228,
8,
1099,
12,
10133,
14,
9937,
304,
267,
372,
754,
272,
916,
1228,
8,
1099,
12,
5988,
14,
6782,
304,
267,
372,
10133,
63,
1633,
8,
1099,
9,
272,
587,
26,
267,
372,
10133,
63,
26622,
8,
1099,
9,
199,
199,
318,
1471,
1235,
63,
12116,
8,
70,
12,
627,
589,
12,
1011,
829,
304,
272,
408,
8479,
465,
7390,
14,
4901,
14,
11610,
14,
11853,
9937,
12,
1325,
7339,
6358,
272,
3233,
15,
28940,
370,
2163,
9655,
4438,
272,
408,
272,
862,
26,
267,
754,
275,
289,
2031,
589,
12,
1011,
829,
9,
272,
327,
7600,
26,
30802,
370,
5126,
1109,
21302,
316,
5190,
83,
14,
961,
370,
8112,
1536,
272,
327,
6661,
402,
14092,
2017,
2552,
1314,
787,
12,
701,
12474,
12,
314,
4750,
2863,
272,
327,
1919,
315,
13916,
345,
647,
446,
1937,
327,
6889,
272,
871,
14092,
2017,
465,
325,
26,
267,
372,
10133,
63,
1633,
8,
5328,
14,
6782,
8,
69,
430,
272,
871,
26,
267,
372,
10133,
63,
1633,
8,
5328,
14,
6782,
1012,
272,
587,
26,
267,
372,
10133,
63,
1099,
8,
1099,
9,
199,
199,
318,
9861,
8,
8147,
12,
2338,
12,
4550,
12,
627,
589,
12,
1011,
4579,
304,
272,
408,
12049,
282,
4550,
1806,
314,
2251,
315,
314,
1627,
6076,
12,
315,
9861,
12,
272,
1808,
949,
1655,
2419,
1124,
835,
1040,
23002,
4882,
14,
339,
32316,
917,
687,
26,
1455,
921,
74,
915,
424,
368,
14,
6442,
7067,
14,
957,
15,
1194,
14523,
14,
1360,
272,
408,
272,
512,
411,
275,
2120,
14,
967,
3856,
342,
272,
1736,
275,
334,
8296,
8,
6086,
12,
627,
589,
12,
1011,
4579,
9,
367,
6193,
315,
6076,
9,
272,
372,
10133,
14,
9937,
1296,
779,
331,
411,
14,
331,
20627,
8,
800,
9,
367,
284,
315,
4945,
8,
835,
3948,
199,
199,
318,
2112,
63,
4429,
8,
11948,
12,
1324,
12,
627,
65,
12,
1011,
829,
304,
272,
408,
1767,
282,
17448,
6137,
701,
6036,
316,
314,
1627,
13484,
624,
272,
366,
275,
10133,
14,
9937,
342,
272,
367,
671,
315,
13484,
26,
267,
366,
14,
10053,
8,
88,
12,
627,
65,
12,
1011,
829,
9,
272,
366,
14,
3058,
8,
1210,
9,
272,
372,
366,
199,
199,
318,
2112,
63,
4429,
63,
10727,
8,
11948,
12,
2329,
894,
83,
12,
1324,
12,
627,
65,
12,
1011,
829,
304,
272,
408,
1767,
282,
17448,
6137,
701,
6036,
316,
314,
1627,
13484,
436,
2329,
894,
83,
624,
272,
366,
275,
10133,
14,
9937,
342,
272,
367,
7434,
12,
26669,
315,
3482,
8,
11948,
12,
2329,
894,
83,
304,
267,
366,
14,
10053,
83,
8,
2894,
12,
26669,
12,
3233,
6213,
29,
65,
12,
3233,
23611,
29,
829,
12,
288,
2329,
894,
6213,
29,
65,
12,
2329,
894,
23611,
29,
829,
9,
272,
340,
1228,
8,
1210,
12,
5988,
14,
6782,
304,
267,
366,
14,
28940,
8,
1210,
9,
272,
587,
26,
267,
366,
14,
3058,
8,
1210,
9,
272,
372,
366,
199,
199,
318,
2112,
63,
11887,
8,
11948,
12,
1324,
12,
627,
65,
12,
1011,
829,
304,
272,
408,
1767,
282,
17448,
543,
314,
1072,
402,
1006,
9512,
4882,
370,
314,
1627,
272,
13484,
272,
408,
272,
4051,
795,
275,
359,
11610,
14,
26622,
8,
1210,
680,
10053,
8,
88,
12,
627,
65,
12,
1011,
829,
9,
367,
671,
315,
13484,
61,
272,
366,
275,
10133,
14,
9937,
1296,
8,
1587,
795,
12,
8344,
3314,
4395,
28245,
29,
17,
12,
9451,
9298,
29,
17,
9,
272,
366,
14,
10053,
83,
8,
2734,
519,
26,
359,
88,
59,
17,
61,
367,
671,
315,
519,
467,
2400,
289,
26,
289,
14,
585,
14,
954,
6782,
9,
272,
372,
366,
199,
199,
318,
2740,
63,
28940,
8,
8147,
12,
2329,
894,
12,
627,
65,
12,
1011,
829,
304,
272,
408,
55,
8146,
376,
6076,
6358,
376,
2329,
894,
340,
376,
1125,
365,
15604,
1830,
272,
25012,
652,
14,
272,
408,
272,
652,
275,
2740,
8,
8147,
9,
272,
1830,
413,
26,
267,
862,
26,
288,
1995,
2163,
8,
390,
9,
267,
871,
10852,
26,
288,
2059,
267,
871,
26,
288,
2329,
894,
8,
5328,
14,
6782,
1062,
627,
65,
12,
1011,
829,
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,
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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
] |
VimanyuAgg/Have_a_seat
|
nltk_data/taggers/universal_tagset/universal_tags.py
|
3
|
2883
|
'''
Interface for converting POS tags from various treebanks
to the universal tagset of Petrov, Das, & McDonald.
The tagset consists of the following 12 coarse tags:
VERB - verbs (all tenses and modes)
NOUN - nouns (common and proper)
PRON - pronouns
ADJ - adjectives
ADV - adverbs
ADP - adpositions (prepositions and postpositions)
CONJ - conjunctions
DET - determiners
NUM - cardinal numbers
PRT - particles or other function words
X - other: foreign words, typos, abbreviations
. - punctuation
@see: http://arxiv.org/abs/1104.2086 and http://code.google.com/p/universal-pos-tags/
@author: Nathan Schneider (nschneid)
@since: 2011-05-06
'''
# Strive towards Python 3 compatibility
from __future__ import print_function, unicode_literals, division
from future_builtins import map, filter
import re, glob
from collections import defaultdict
MAP_DIR = 'universal_pos_tags.1.01'
COARSE_TAGS = ('VERB','NOUN','PRON','ADJ','ADV','ADP','CONJ','DET','NUM','PRT','X','.')
_MAPS = defaultdict(dict)
def readme():
with open(MAP_DIR+'/README') as f:
return f.read()
def fileids(lang=''):
'''
Optionally given a two-letter ISO language code, returns names of files
containing mappings from a tagset from a treebank in that language to the
universal tagset.
>>> fileids('en')
[u'en-ptb']
>>> fileids('zh')
[u'zh-ctb6', u'zh-sinica']
'''
return [re.match(r'.*[/]([^/\\]+)[.]map', p).group(1) for p in glob.glob(MAP_DIR + '/{}-*.map'.format(lang.lower()))]
def _read(fileid):
with open(MAP_DIR+'/'+fileid+'.map') as f:
for ln in f:
ln = ln.strip()
if ln=='': continue
fine, coarse = ln.split('\t')
assert coarse in COARSE_TAGS,'Unexpected coarse tag: {}'.format(coarse)
assert fine not in _MAPS[fileid],'Multiple entries for original tag: {}'.format(fine)
_MAPS[fileid][fine] = coarse
def mapping(fileid):
'''
Retrieves the mapping from original tags to universal tags for the
treebank in question.
>>> mapping('ru-rnc')=={'!': '.', 'A': 'ADJ', 'AD': 'ADV', 'C': 'CONJ', 'COMP': 'CONJ', 'IJ': 'X', 'NC': 'NUM', 'NN': 'NOUN', 'P': 'PRON', 'PTCL': 'PRT', 'V': 'VERB', 'VG': 'VERB', 'VI': 'VERB', 'VP': 'VERB', 'YES_NO_SENT': 'X', 'Z': 'X'}
True
'''
if fileid not in _MAPS:
_read(fileid)
return _MAPS[fileid]
def convert(fileid, originalTag):
'''
Produces the (coarse) universal tag given an original POS tag from the
treebank in question.
>>> convert('en-ptb', 'VBZ')
u'VERB'
>>> convert('en-ptb', 'VBP')
u'VERB'
>>> convert('en-ptb', '``')
u'.'
'''
return mapping(fileid)[originalTag]
def test():
for fileid in fileids():
mapping(fileid)
import doctest
doctest.testmod()
if __name__=='__main__':
test()
|
apache-2.0
|
[
2344,
199,
4267,
367,
13806,
510,
3100,
3762,
687,
7750,
3123,
9860,
83,
221,
199,
475,
314,
17508,
1947,
409,
402,
31449,
293,
86,
12,
577,
305,
12,
1253,
22895,
36,
8125,
68,
14,
199,
199,
1918,
1947,
409,
18581,
402,
314,
2569,
3144,
512,
30672,
3762,
26,
199,
199,
2111,
34,
446,
809,
1533,
334,
452,
16685,
874,
436,
12404,
9,
199,
2826,
1734,
446,
949,
324,
83,
334,
2330,
436,
5576,
9,
199,
3311,
615,
446,
299,
2641,
79,
324,
83,
221,
199,
1554,
42,
446,
14510,
825,
7301,
199,
1554,
54,
446,
1503,
422,
1533,
199,
1554,
48,
446,
1503,
12658,
334,
657,
12658,
436,
2963,
12658,
9,
199,
1864,
42,
446,
22888,
83,
199,
17442,
446,
4563,
1192,
199,
7125,
446,
12564,
1582,
5579,
199,
3311,
52,
446,
26115,
503,
1163,
805,
5932,
199,
56,
446,
1163,
26,
11608,
5932,
12,
10284,
1712,
12,
2236,
23988,
1298,
199,
14,
446,
22929,
199,
199,
32,
3239,
26,
1455,
921,
27290,
14,
1308,
15,
2101,
15,
6019,
20,
14,
1165,
1184,
436,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
24866,
13,
1712,
13,
2969,
15,
199,
199,
32,
2502,
26,
653,
1619,
290,
22985,
685,
73,
424,
334,
561,
335,
685,
344,
9,
199,
32,
8585,
26,
7760,
13,
1717,
13,
1690,
199,
2344,
199,
199,
3,
31309,
432,
28354,
2018,
650,
7163,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
12,
2649,
63,
5955,
12,
4629,
199,
504,
6466,
63,
10372,
492,
2341,
12,
2457,
199,
199,
646,
295,
12,
5739,
199,
504,
5055,
492,
10018,
199,
199,
5443,
63,
3022,
275,
283,
24866,
63,
1712,
63,
2969,
14,
17,
14,
614,
7,
199,
199,
1439,
689,
899,
63,
17626,
275,
661,
2111,
34,
1673,
2826,
1734,
1673,
3311,
615,
1673,
1554,
42,
1673,
1554,
54,
1673,
1554,
48,
1673,
1864,
42,
1673,
17442,
1673,
7125,
1673,
3311,
52,
1673,
56,
26409,
358,
199,
199,
63,
5443,
51,
275,
10018,
8,
807,
9,
199,
199,
318,
1586,
278,
837,
272,
543,
1551,
8,
5443,
63,
3022,
23164,
18195,
358,
465,
289,
26,
267,
372,
289,
14,
739,
342,
199,
199,
318,
570,
1580,
8,
4159,
9280,
272,
1449,
272,
22383,
1627,
282,
2877,
13,
9269,
9055,
2637,
1233,
12,
2529,
1561,
402,
1584,
5591,
3035,
13546,
687,
282,
1947,
409,
687,
282,
3123,
9860,
315,
626,
2637,
370,
314,
5591,
17508,
1947,
409,
14,
2286,
1306,
570,
1580,
360,
287,
358,
272,
359,
85,
7,
287,
13,
541,
66,
418,
272,
1306,
570,
1580,
360,
3951,
358,
272,
359,
85,
7,
3951,
13,
319,
66,
22,
297,
399,
7,
3951,
13,
5911,
24027,
418,
272,
1449,
5591,
372,
359,
264,
14,
1431,
8,
82,
1370,
23033,
15,
61,
7059,
15,
1103,
2807,
2788,
19784,
1130,
297,
299,
680,
923,
8,
17,
9,
367,
299,
315,
5739,
14,
6463,
8,
5443,
63,
3022,
435,
1994,
2440,
13,
4856,
1130,
1370,
908,
8,
4159,
14,
2325,
4059,
61,
199,
199,
318,
485,
739,
8,
493,
344,
304,
272,
543,
1551,
8,
5443,
63,
3022,
4786,
19047,
493,
344,
18098,
1130,
358,
465,
289,
26,
267,
367,
10359,
315,
289,
26,
288,
10359,
275,
10359,
14,
1913,
342,
288,
340,
10359,
6803,
356,
1980,
288,
15701,
12,
512,
30672,
275,
10359,
14,
1294,
2258,
84,
358,
288,
702,
512,
30672,
315,
5099,
689,
899,
63,
17626,
2584,
8708,
512,
30672,
1947,
26,
9499,
908,
8,
331,
30672,
9,
288,
702,
15701,
440,
315,
485,
5443,
51,
59,
493,
344,
26801,
8433,
4811,
367,
3379,
1947,
26,
9499,
908,
8,
70,
1132,
9,
288,
485,
5443,
51,
59,
493,
344,
1527,
70,
1132,
61,
275,
512,
30672,
1467,
199,
318,
4412,
8,
493,
344,
304,
272,
1449,
272,
27940,
314,
4412,
687,
3379,
3762,
370,
17508,
3762,
367,
314,
5591,
3123,
9860,
315,
7894,
14,
2286,
1306,
4412,
360,
6558,
13,
82,
7966,
358,
389,
1445,
27676,
22608,
283,
33,
356,
283,
1554,
42,
297,
283,
1554,
356,
283,
1554,
54,
297,
283,
35,
356,
283,
1864,
42,
297,
283,
6790,
356,
283,
1864,
42,
297,
283,
41,
42,
356,
283,
56,
297,
283,
6389,
356,
283,
7125,
297,
283,
7178,
356,
283,
2826,
1734,
297,
283,
48,
356,
283,
3311,
615,
297,
283,
4189,
1981,
356,
283,
3311,
52,
297,
283,
54,
356,
283,
2111,
34,
297,
283,
29355,
356,
283,
2111,
34,
297,
283,
17655,
356,
283,
2111,
34,
297,
283,
14159,
356,
283,
2111,
34,
297,
283,
15641,
63,
2826,
63,
32173,
356,
283,
56,
297,
283,
58,
356,
283,
56,
936,
272,
715,
272,
1449,
272,
340,
570,
344,
440,
315,
485,
5443,
51,
26,
267,
485,
739,
8,
493,
344,
9,
272,
372,
485,
5443,
51,
59,
493,
344,
61,
199,
199,
318,
3957,
8,
493,
344,
12,
3379,
1931,
304,
272,
1449,
272,
2165,
10569,
314,
334,
331,
30672,
9,
17508,
1947,
1627,
376,
3379,
510,
3100,
1947,
687,
314,
5591,
3123,
9860,
315,
7894,
14,
2286,
1306,
3957,
360,
287,
13,
541,
66,
297,
283,
54,
21338,
358,
272,
399,
7,
2111,
34,
7,
272,
1306,
3957,
360,
287,
13,
541,
66,
297,
283,
54,
24408,
358,
272,
399,
7,
2111,
34,
7,
272,
1306,
3957,
360,
287,
13,
541,
66,
297,
283,
1040,
358,
272,
399,
30484,
272,
1449,
272,
372,
4412,
8,
493,
344,
2788,
5043,
1931,
61,
421,
199,
318,
511,
837,
272,
367,
570,
344,
315,
570,
1580,
837,
267,
4412,
8,
493,
344,
9,
272,
492,
8868,
272,
8868,
14,
29446,
342,
199,
199,
692,
636,
354,
363,
6803,
363,
973,
3706,
272,
511,
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
] |
[
199,
4267,
367,
13806,
510,
3100,
3762,
687,
7750,
3123,
9860,
83,
221,
199,
475,
314,
17508,
1947,
409,
402,
31449,
293,
86,
12,
577,
305,
12,
1253,
22895,
36,
8125,
68,
14,
199,
199,
1918,
1947,
409,
18581,
402,
314,
2569,
3144,
512,
30672,
3762,
26,
199,
199,
2111,
34,
446,
809,
1533,
334,
452,
16685,
874,
436,
12404,
9,
199,
2826,
1734,
446,
949,
324,
83,
334,
2330,
436,
5576,
9,
199,
3311,
615,
446,
299,
2641,
79,
324,
83,
221,
199,
1554,
42,
446,
14510,
825,
7301,
199,
1554,
54,
446,
1503,
422,
1533,
199,
1554,
48,
446,
1503,
12658,
334,
657,
12658,
436,
2963,
12658,
9,
199,
1864,
42,
446,
22888,
83,
199,
17442,
446,
4563,
1192,
199,
7125,
446,
12564,
1582,
5579,
199,
3311,
52,
446,
26115,
503,
1163,
805,
5932,
199,
56,
446,
1163,
26,
11608,
5932,
12,
10284,
1712,
12,
2236,
23988,
1298,
199,
14,
446,
22929,
199,
199,
32,
3239,
26,
1455,
921,
27290,
14,
1308,
15,
2101,
15,
6019,
20,
14,
1165,
1184,
436,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
24866,
13,
1712,
13,
2969,
15,
199,
199,
32,
2502,
26,
653,
1619,
290,
22985,
685,
73,
424,
334,
561,
335,
685,
344,
9,
199,
32,
8585,
26,
7760,
13,
1717,
13,
1690,
199,
2344,
199,
199,
3,
31309,
432,
28354,
2018,
650,
7163,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
12,
2649,
63,
5955,
12,
4629,
199,
504,
6466,
63,
10372,
492,
2341,
12,
2457,
199,
199,
646,
295,
12,
5739,
199,
504,
5055,
492,
10018,
199,
199,
5443,
63,
3022,
275,
283,
24866,
63,
1712,
63,
2969,
14,
17,
14,
614,
7,
199,
199,
1439,
689,
899,
63,
17626,
275,
661,
2111,
34,
1673,
2826,
1734,
1673,
3311,
615,
1673,
1554,
42,
1673,
1554,
54,
1673,
1554,
48,
1673,
1864,
42,
1673,
17442,
1673,
7125,
1673,
3311,
52,
1673,
56,
26409,
358,
199,
199,
63,
5443,
51,
275,
10018,
8,
807,
9,
199,
199,
318,
1586,
278,
837,
272,
543,
1551,
8,
5443,
63,
3022,
23164,
18195,
358,
465,
289,
26,
267,
372,
289,
14,
739,
342,
199,
199,
318,
570,
1580,
8,
4159,
9280,
272,
1449,
272,
22383,
1627,
282,
2877,
13,
9269,
9055,
2637,
1233,
12,
2529,
1561,
402,
1584,
5591,
3035,
13546,
687,
282,
1947,
409,
687,
282,
3123,
9860,
315,
626,
2637,
370,
314,
5591,
17508,
1947,
409,
14,
2286,
1306,
570,
1580,
360,
287,
358,
272,
359,
85,
7,
287,
13,
541,
66,
418,
272,
1306,
570,
1580,
360,
3951,
358,
272,
359,
85,
7,
3951,
13,
319,
66,
22,
297,
399,
7,
3951,
13,
5911,
24027,
418,
272,
1449,
5591,
372,
359,
264,
14,
1431,
8,
82,
1370,
23033,
15,
61,
7059,
15,
1103,
2807,
2788,
19784,
1130,
297,
299,
680,
923,
8,
17,
9,
367,
299,
315,
5739,
14,
6463,
8,
5443,
63,
3022,
435,
1994,
2440,
13,
4856,
1130,
1370,
908,
8,
4159,
14,
2325,
4059,
61,
199,
199,
318,
485,
739,
8,
493,
344,
304,
272,
543,
1551,
8,
5443,
63,
3022,
4786,
19047,
493,
344,
18098,
1130,
358,
465,
289,
26,
267,
367,
10359,
315,
289,
26,
288,
10359,
275,
10359,
14,
1913,
342,
288,
340,
10359,
6803,
356,
1980,
288,
15701,
12,
512,
30672,
275,
10359,
14,
1294,
2258,
84,
358,
288,
702,
512,
30672,
315,
5099,
689,
899,
63,
17626,
2584,
8708,
512,
30672,
1947,
26,
9499,
908,
8,
331,
30672,
9,
288,
702,
15701,
440,
315,
485,
5443,
51,
59,
493,
344,
26801,
8433,
4811,
367,
3379,
1947,
26,
9499,
908,
8,
70,
1132,
9,
288,
485,
5443,
51,
59,
493,
344,
1527,
70,
1132,
61,
275,
512,
30672,
1467,
199,
318,
4412,
8,
493,
344,
304,
272,
1449,
272,
27940,
314,
4412,
687,
3379,
3762,
370,
17508,
3762,
367,
314,
5591,
3123,
9860,
315,
7894,
14,
2286,
1306,
4412,
360,
6558,
13,
82,
7966,
358,
389,
1445,
27676,
22608,
283,
33,
356,
283,
1554,
42,
297,
283,
1554,
356,
283,
1554,
54,
297,
283,
35,
356,
283,
1864,
42,
297,
283,
6790,
356,
283,
1864,
42,
297,
283,
41,
42,
356,
283,
56,
297,
283,
6389,
356,
283,
7125,
297,
283,
7178,
356,
283,
2826,
1734,
297,
283,
48,
356,
283,
3311,
615,
297,
283,
4189,
1981,
356,
283,
3311,
52,
297,
283,
54,
356,
283,
2111,
34,
297,
283,
29355,
356,
283,
2111,
34,
297,
283,
17655,
356,
283,
2111,
34,
297,
283,
14159,
356,
283,
2111,
34,
297,
283,
15641,
63,
2826,
63,
32173,
356,
283,
56,
297,
283,
58,
356,
283,
56,
936,
272,
715,
272,
1449,
272,
340,
570,
344,
440,
315,
485,
5443,
51,
26,
267,
485,
739,
8,
493,
344,
9,
272,
372,
485,
5443,
51,
59,
493,
344,
61,
199,
199,
318,
3957,
8,
493,
344,
12,
3379,
1931,
304,
272,
1449,
272,
2165,
10569,
314,
334,
331,
30672,
9,
17508,
1947,
1627,
376,
3379,
510,
3100,
1947,
687,
314,
5591,
3123,
9860,
315,
7894,
14,
2286,
1306,
3957,
360,
287,
13,
541,
66,
297,
283,
54,
21338,
358,
272,
399,
7,
2111,
34,
7,
272,
1306,
3957,
360,
287,
13,
541,
66,
297,
283,
54,
24408,
358,
272,
399,
7,
2111,
34,
7,
272,
1306,
3957,
360,
287,
13,
541,
66,
297,
283,
1040,
358,
272,
399,
30484,
272,
1449,
272,
372,
4412,
8,
493,
344,
2788,
5043,
1931,
61,
421,
199,
318,
511,
837,
272,
367,
570,
344,
315,
570,
1580,
837,
267,
4412,
8,
493,
344,
9,
272,
492,
8868,
272,
8868,
14,
29446,
342,
199,
199,
692,
636,
354,
363,
6803,
363,
973,
3706,
272,
511,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
high5g/hospital
|
Highfive_Hospital/web/bundles/high5hospitalpatient/eternicode-bootstrap-datepicker-809a5c2/docs/conf.py
|
46
|
7918
|
# -*- coding: utf-8 -*-
#
# bootstrap-datepicker documentation build configuration file, created by
# sphinx-quickstart on Fri Aug 2 14:45:57 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
#version = ''
# The full version, including alpha/beta/rc tags.
#release = ''
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
primary_domain = 'js'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'bootstrap-datepicker'
copyright = u'2013, eternicode'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# 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'
highlight_language = 'javascript'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['_themes',]
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# 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'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'bootstrap-datepickerdoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'bootstrap-datepicker.tex', u'bootstrap-datepicker Documentation',
u'eternicode', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'bootstrap-datepicker', u'bootstrap-datepicker Documentation',
[u'eternicode'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'bootstrap-datepicker', u'bootstrap-datepicker Documentation',
u'eternicode', 'bootstrap-datepicker', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
15865,
13,
602,
4510,
281,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
31712,
25298,
221,
499,
4329,
26,
2322,
26,
1641,
6171,
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,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
12,
747,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
3,
1023,
275,
2125,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3,
3221,
275,
2125,
4388,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
9858,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3327,
63,
2261,
275,
283,
3596,
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,
832,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
942,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
399,
7,
11146,
13,
602,
4510,
281,
7,
199,
7307,
275,
399,
7,
6965,
12,
325,
1203,
1525,
7,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
4044,
1506,
418,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
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,
525,
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,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
14337,
63,
3671,
275,
283,
9554,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
9527,
2595,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
1360,
63,
7915,
275,
283,
8008,
63,
29048,
63,
7915,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
1360,
63,
7915,
63,
515,
275,
4044,
23900,
297,
61,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
2082,
9,
370,
4192,
737,
314,
2746,
199,
3,
402,
314,
18437,
14,
199,
3,
1360,
63,
9733,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
12541,
314,
2955,
931,
9,
370,
675,
465,
29139,
402,
314,
199,
3,
9149,
14,
221,
961,
570,
1077,
506,
282,
5417,
7016,
570,
17048,
12802,
9
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
15865,
13,
602,
4510,
281,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
31712,
25298,
221,
499,
4329,
26,
2322,
26,
1641,
6171,
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,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
12,
747,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
3,
1023,
275,
2125,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3,
3221,
275,
2125,
4388,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
9858,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3327,
63,
2261,
275,
283,
3596,
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,
832,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
942,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
399,
7,
11146,
13,
602,
4510,
281,
7,
199,
7307,
275,
399,
7,
6965,
12,
325,
1203,
1525,
7,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
4044,
1506,
418,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
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,
525,
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,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
14337,
63,
3671,
275,
283,
9554,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
9527,
2595,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
1360,
63,
7915,
275,
283,
8008,
63,
29048,
63,
7915,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
1360,
63,
7915,
63,
515,
275,
4044,
23900,
297,
61,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
2082,
9,
370,
4192,
737,
314,
2746,
199,
3,
402,
314,
18437,
14,
199,
3,
1360,
63,
9733,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
12541,
314,
2955,
931,
9,
370,
675,
465,
29139,
402,
314,
199,
3,
9149,
14,
221,
961,
570,
1077,
506,
282,
5417,
7016,
570,
17048,
12802,
9,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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D, see LICENSE for more details.
"""
import os
import sys
import tempfile
import shutil
import pytest
from jinja2 import Environment, loaders
from jinja2._compat import PYPY, PY2
from jinja2.loaders import split_template_path
from jinja2.exceptions import TemplateNotFound
@pytest.mark.loaders
class TestLoaders():
def test_dict_loader(self, dict_loader):
env = Environment(loader=dict_loader)
tmpl = env.get_template('justdict.html')
assert tmpl.render().strip() == 'FOO'
pytest.raises(TemplateNotFound, env.get_template, 'missing.html')
def test_package_loader(self, package_loader):
env = Environment(loader=package_loader)
tmpl = env.get_template('test.html')
assert tmpl.render().strip() == 'BAR'
pytest.raises(TemplateNotFound, env.get_template, 'missing.html')
def test_filesystem_loader(self, filesystem_loader):
env = Environment(loader=filesystem_loader)
tmpl = env.get_template('test.html')
assert tmpl.render().strip() == 'BAR'
tmpl = env.get_template('foo/test.html')
assert tmpl.render().strip() == 'FOO'
pytest.raises(TemplateNotFound, env.get_template, 'missing.html')
def test_choice_loader(self, choice_loader):
env = Environment(loader=choice_loader)
tmpl = env.get_template('justdict.html')
assert tmpl.render().strip() == 'FOO'
tmpl = env.get_template('test.html')
assert tmpl.render().strip() == 'BAR'
pytest.raises(TemplateNotFound, env.get_template, 'missing.html')
def test_function_loader(self, function_loader):
env = Environment(loader=function_loader)
tmpl = env.get_template('justfunction.html')
assert tmpl.render().strip() == 'FOO'
pytest.raises(TemplateNotFound, env.get_template, 'missing.html')
def test_prefix_loader(self, prefix_loader):
env = Environment(loader=prefix_loader)
tmpl = env.get_template('a/test.html')
assert tmpl.render().strip() == 'BAR'
tmpl = env.get_template('b/justdict.html')
assert tmpl.render().strip() == 'FOO'
pytest.raises(TemplateNotFound, env.get_template, 'missing')
def test_caching(self):
changed = False
class TestLoader(loaders.BaseLoader):
def get_source(self, environment, template):
return u'foo', None, lambda: not changed
env = Environment(loader=TestLoader(), cache_size=-1)
tmpl = env.get_template('template')
assert tmpl is env.get_template('template')
changed = True
assert tmpl is not env.get_template('template')
changed = False
env = Environment(loader=TestLoader(), cache_size=0)
assert env.get_template('template') \
is not env.get_template('template')
env = Environment(loader=TestLoader(), cache_size=2)
t1 = env.get_template('one')
t2 = env.get_template('two')
assert t2 is env.get_template('two')
assert t1 is env.get_template('one')
t3 = env.get_template('three')
assert 'one' in env.cache
assert 'two' not in env.cache
assert 'three' in env.cache
def test_dict_loader_cache_invalidates(self):
mapping = {'foo': "one"}
env = Environment(loader=loaders.DictLoader(mapping))
assert env.get_template('foo').render() == "one"
mapping['foo'] = "two"
assert env.get_template('foo').render() == "two"
def test_split_template_path(self):
assert split_template_path('foo/bar') == ['foo', 'bar']
assert split_template_path('./foo/bar') == ['foo', 'bar']
pytest.raises(TemplateNotFound, split_template_path, '../foo')
@pytest.mark.loaders
@pytest.mark.moduleloader
class TestModuleLoader():
archive = None
def compile_down(self, prefix_loader, zip='deflated', py_compile=False):
log = []
self.reg_env = Environment(loader=prefix_loader)
if zip is not None:
fd, self.archive = tempfile.mkstemp(suffix='.zip')
os.close(fd)
else:
self.archive = tempfile.mkdtemp()
self.reg_env.compile_templates(self.archive, zip=zip,
log_function=log.append,
py_compile=py_compile)
self.mod_env = Environment(loader=loaders.ModuleLoader(self.archive))
return ''.join(log)
def teardown(self):
if hasattr(self, 'mod_env'):
if os.path.isfile(self.archive):
os.remove(self.archive)
else:
shutil.rmtree(self.archive)
self.archive = None
def test_log(self, prefix_loader):
log = self.compile_down(prefix_loader)
assert 'Compiled "a/foo/test.html" as ' \
'tmpl_a790caf9d669e39ea4d280d597ec891c4ef0404a' in log
assert 'Finished compiling templates' in log
assert 'Could not compile "a/syntaxerror.html": ' \
'Encountered unknown tag \'endif\'' in log
def _test_common(self):
tmpl1 = self.reg_env.get_template('a/test.html')
tmpl2 = self.mod_env.get_template('a/test.html')
assert tmpl1.render() == tmpl2.render()
tmpl1 = self.reg_env.get_template('b/justdict.html')
tmpl2 = self.mod_env.get_template('b/justdict.html')
assert tmpl1.render() == tmpl2.render()
def test_deflated_zip_compile(self, prefix_loader):
self.compile_down(prefix_loader, zip='deflated')
self._test_common()
def test_stored_zip_compile(self, prefix_loader):
self.compile_down(prefix_loader, zip='stored')
self._test_common()
def test_filesystem_compile(self, prefix_loader):
self.compile_down(prefix_loader, zip=None)
self._test_common()
def test_weak_references(self, prefix_loader):
self.compile_down(prefix_loader)
tmpl = self.mod_env.get_template('a/test.html')
key = loaders.ModuleLoader.get_template_key('a/test.html')
name = self.mod_env.loader.module.__name__
assert hasattr(self.mod_env.loader.module, key)
assert name in sys.modules
# unset all, ensure the module is gone from sys.modules
self.mod_env = tmpl = None
try:
import gc
gc.collect()
except:
pass
assert name not in sys.modules
# This test only makes sense on non-pypy python 2
@pytest.mark.skipif(
not (PY2 and not PYPY),
reason='This test only makes sense on non-pypy python 2')
def test_byte_compilation(self, prefix_loader):
log = self.compile_down(prefix_loader, py_compile=True)
assert 'Byte-compiled "a/test.html"' in log
tmpl1 = self.mod_env.get_template('a/test.html')
mod = self.mod_env.loader.module. \
tmpl_3c4ddf650c1a73df961a6d3d2ce2752f1b8fd490
assert mod.__file__.endswith('.pyc')
def test_choice_loader(self, prefix_loader):
log = self.compile_down(prefix_loader)
self.mod_env.loader = loaders.ChoiceLoader([
self.mod_env.loader,
loaders.DictLoader({'DICT_SOURCE': 'DICT_TEMPLATE'})
])
tmpl1 = self.mod_env.get_template('a/test.html')
assert tmpl1.render() == 'BAR'
tmpl2 = self.mod_env.get_template('DICT_SOURCE')
assert tmpl2.render() == 'DICT_TEMPLATE'
def test_prefix_loader(self, prefix_loader):
log = self.compile_down(prefix_loader)
self.mod_env.loader = loaders.PrefixLoader({
'MOD': self.mod_env.loader,
'DICT': loaders.DictLoader({'test.html': 'DICT_TEMPLATE'})
})
tmpl1 = self.mod_env.get_template('MOD/a/test.html')
assert tmpl1.render() == 'BAR'
tmpl2 = self.mod_env.get_template('DICT/test.html')
assert tmpl2.render() == 'DICT_TEMPLATE'
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
14239,
14,
3422,
272,
18294,
2878,
23597,
339,
1379,
314,
25520,
14,
339,
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,
646,
747,
199,
646,
984,
199,
646,
5549,
199,
646,
5145,
199,
646,
4613,
199,
199,
504,
10321,
18,
492,
9711,
12,
25520,
199,
504,
10321,
18,
423,
5819,
492,
7843,
4521,
12,
7843,
18,
199,
504,
10321,
18,
14,
16370,
492,
3715,
63,
1160,
63,
515,
199,
504,
10321,
18,
14,
3924,
492,
5458,
4667,
421,
199,
32,
4462,
14,
1657,
14,
16370,
199,
533,
1379,
5455,
83,
837,
339,
347,
511,
63,
807,
63,
3422,
8,
277,
12,
1211,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
807,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
4764,
807,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
2491,
63,
3422,
8,
277,
12,
2559,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
2491,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13895,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
11381,
63,
3422,
8,
277,
12,
10036,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
11381,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13895,
7,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
1421,
15,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
5095,
63,
3422,
8,
277,
12,
7141,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
5095,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
4764,
807,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13895,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
1593,
63,
3422,
8,
277,
12,
805,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
1593,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
4764,
1593,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
1861,
63,
3422,
8,
277,
12,
2403,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
1861,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
65,
15,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13895,
7,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
66,
15,
4764,
807,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
358,
339,
347,
511,
63,
22738,
8,
277,
304,
267,
2896,
275,
756,
398,
1021,
1379,
5455,
8,
16370,
14,
1563,
5455,
304,
288,
347,
664,
63,
1365,
8,
277,
12,
3734,
12,
1978,
304,
355,
372,
399,
7,
1421,
297,
488,
12,
2400,
26,
440,
2896,
267,
2589,
275,
9711,
8,
3422,
29,
15824,
1062,
2581,
63,
890,
4022,
17,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
1160,
358,
267,
702,
9675,
365,
2589,
14,
362,
63,
1160,
360,
1160,
358,
267,
2896,
275,
715,
267,
702,
9675,
365,
440,
2589,
14,
362,
63,
1160,
360,
1160,
358,
267,
2896,
275,
756,
398,
2589,
275,
9711,
8,
3422,
29,
15824,
1062,
2581,
63,
890,
29,
16,
9,
267,
702,
2589,
14,
362,
63,
1160,
360,
1160,
358,
971,
288,
365,
440,
2589,
14,
362,
63,
1160,
360,
1160,
358,
398,
2589,
275,
9711,
8,
3422,
29,
15824,
1062,
2581,
63,
890,
29,
18,
9,
267,
307,
17,
275,
2589,
14,
362,
63,
1160,
360,
368,
358,
267,
307,
18,
275,
2589,
14,
362,
63,
1160,
360,
5601,
358,
267,
702,
307,
18,
365,
2589,
14,
362,
63,
1160,
360,
5601,
358,
267,
702,
307,
17,
365,
2589,
14,
362,
63,
1160,
360,
368,
358,
267,
307,
19,
275,
2589,
14,
362,
63,
1160,
360,
10480,
358,
267,
702,
283,
368,
7,
315,
2589,
14,
1637,
267,
702,
283,
5601,
7,
440,
315,
2589,
14,
1637,
267,
702,
283,
10480,
7,
315,
2589,
14,
1637,
339,
347,
511,
63,
807,
63,
3422,
63,
1637,
63,
3197,
2335,
8,
277,
304,
267,
4412,
275,
791,
1421,
356,
298,
368,
3570,
267,
2589,
275,
9711,
8,
3422,
29,
16370,
14,
2141,
5455,
8,
4745,
430,
267,
702,
2589,
14,
362,
63,
1160,
360,
1421,
1959,
3352,
342,
508,
298,
368,
2,
267,
4412,
459,
1421,
418,
275,
298,
5601,
2,
267,
702,
2589,
14,
362,
63,
1160,
360,
1421,
1959,
3352,
342,
508,
298,
5601,
2,
339,
347,
511,
63,
1294,
63,
1160,
63,
515,
8,
277,
304,
267,
702,
3715,
63,
1160,
63,
515,
360,
1421,
15,
1700,
358,
508,
788,
1421,
297,
283,
1700,
418,
267,
702,
3715,
63,
1160,
63,
515,
17371,
1421,
15,
1700,
358,
508,
788,
1421,
297,
283,
1700,
418,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
3715,
63,
1160,
63,
515,
12,
20644,
1421,
358,
421,
199,
32,
4462,
14,
1657,
14,
16370,
199,
32
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
14239,
14,
3422,
272,
18294,
2878,
23597,
339,
1379,
314,
25520,
14,
339,
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,
646,
747,
199,
646,
984,
199,
646,
5549,
199,
646,
5145,
199,
646,
4613,
199,
199,
504,
10321,
18,
492,
9711,
12,
25520,
199,
504,
10321,
18,
423,
5819,
492,
7843,
4521,
12,
7843,
18,
199,
504,
10321,
18,
14,
16370,
492,
3715,
63,
1160,
63,
515,
199,
504,
10321,
18,
14,
3924,
492,
5458,
4667,
421,
199,
32,
4462,
14,
1657,
14,
16370,
199,
533,
1379,
5455,
83,
837,
339,
347,
511,
63,
807,
63,
3422,
8,
277,
12,
1211,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
807,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
4764,
807,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
2491,
63,
3422,
8,
277,
12,
2559,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
2491,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13895,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
11381,
63,
3422,
8,
277,
12,
10036,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
11381,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13895,
7,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
1421,
15,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
5095,
63,
3422,
8,
277,
12,
7141,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
5095,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
4764,
807,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13895,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
1593,
63,
3422,
8,
277,
12,
805,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
1593,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
4764,
1593,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
14,
1360,
358,
339,
347,
511,
63,
1861,
63,
3422,
8,
277,
12,
2403,
63,
3422,
304,
267,
2589,
275,
9711,
8,
3422,
29,
1861,
63,
3422,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
65,
15,
396,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13895,
7,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
66,
15,
4764,
807,
14,
1360,
358,
267,
702,
9675,
14,
3352,
1252,
1913,
342,
508,
283,
13046,
7,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
2589,
14,
362,
63,
1160,
12,
283,
4752,
358,
339,
347,
511,
63,
22738,
8,
277,
304,
267,
2896,
275,
756,
398,
1021,
1379,
5455,
8,
16370,
14,
1563,
5455,
304,
288,
347,
664,
63,
1365,
8,
277,
12,
3734,
12,
1978,
304,
355,
372,
399,
7,
1421,
297,
488,
12,
2400,
26,
440,
2896,
267,
2589,
275,
9711,
8,
3422,
29,
15824,
1062,
2581,
63,
890,
4022,
17,
9,
267,
9675,
275,
2589,
14,
362,
63,
1160,
360,
1160,
358,
267,
702,
9675,
365,
2589,
14,
362,
63,
1160,
360,
1160,
358,
267,
2896,
275,
715,
267,
702,
9675,
365,
440,
2589,
14,
362,
63,
1160,
360,
1160,
358,
267,
2896,
275,
756,
398,
2589,
275,
9711,
8,
3422,
29,
15824,
1062,
2581,
63,
890,
29,
16,
9,
267,
702,
2589,
14,
362,
63,
1160,
360,
1160,
358,
971,
288,
365,
440,
2589,
14,
362,
63,
1160,
360,
1160,
358,
398,
2589,
275,
9711,
8,
3422,
29,
15824,
1062,
2581,
63,
890,
29,
18,
9,
267,
307,
17,
275,
2589,
14,
362,
63,
1160,
360,
368,
358,
267,
307,
18,
275,
2589,
14,
362,
63,
1160,
360,
5601,
358,
267,
702,
307,
18,
365,
2589,
14,
362,
63,
1160,
360,
5601,
358,
267,
702,
307,
17,
365,
2589,
14,
362,
63,
1160,
360,
368,
358,
267,
307,
19,
275,
2589,
14,
362,
63,
1160,
360,
10480,
358,
267,
702,
283,
368,
7,
315,
2589,
14,
1637,
267,
702,
283,
5601,
7,
440,
315,
2589,
14,
1637,
267,
702,
283,
10480,
7,
315,
2589,
14,
1637,
339,
347,
511,
63,
807,
63,
3422,
63,
1637,
63,
3197,
2335,
8,
277,
304,
267,
4412,
275,
791,
1421,
356,
298,
368,
3570,
267,
2589,
275,
9711,
8,
3422,
29,
16370,
14,
2141,
5455,
8,
4745,
430,
267,
702,
2589,
14,
362,
63,
1160,
360,
1421,
1959,
3352,
342,
508,
298,
368,
2,
267,
4412,
459,
1421,
418,
275,
298,
5601,
2,
267,
702,
2589,
14,
362,
63,
1160,
360,
1421,
1959,
3352,
342,
508,
298,
5601,
2,
339,
347,
511,
63,
1294,
63,
1160,
63,
515,
8,
277,
304,
267,
702,
3715,
63,
1160,
63,
515,
360,
1421,
15,
1700,
358,
508,
788,
1421,
297,
283,
1700,
418,
267,
702,
3715,
63,
1160,
63,
515,
17371,
1421,
15,
1700,
358,
508,
788,
1421,
297,
283,
1700,
418,
267,
4613,
14,
3536,
8,
4231,
4667,
12,
3715,
63,
1160,
63,
515,
12,
20644,
1421,
358,
421,
199,
32,
4462,
14,
1657,
14,
16370,
199,
32,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
andrewyoung1991/abjad
|
abjad/tools/pitchtools/test/test_pitchtools_PitchSet_from_selection.py
|
2
|
1108
|
# -*- encoding: utf-8 -*-
from abjad import *
def test_pitchtools_PitchSet_from_selection_01():
r'''Works with notes.
'''
note = Note(13, (1, 4))
pitch_set = pitchtools.PitchSet.from_selection(note)
assert len(pitch_set) == 1
def test_pitchtools_PitchSet_from_selection_02():
r'''Works with chords.
'''
chord = Chord([13, 14, 15], (1, 4))
pitch_set = pitchtools.PitchSet.from_selection(chord)
assert len(pitch_set) == 3
def test_pitchtools_PitchSet_from_selection_03():
r'''Works with chords with duplicate pitches.
'''
chord = Chord([13, 13, 13, 14], (1, 4))
pitch_set = pitchtools.PitchSet.from_selection(chord)
assert len(pitch_set) == 2
def test_pitchtools_PitchSet_from_selection_04():
r'''Works with empty chords.
'''
chord = Chord([], (1, 4))
pitch_set = pitchtools.PitchSet.from_selection(chord)
assert len(pitch_set) == 0
def test_pitchtools_PitchSet_from_selection_05():
r'''Works with chords.
'''
assert len(pitchtools.PitchSet.from_selection(
Chord([12, 14, 18, 19], (1, 4)))) == 4
|
gpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
282,
468,
350,
492,
627,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
614,
837,
272,
519,
2344,
25348,
543,
12681,
14,
272,
1449,
339,
5317,
275,
3390,
8,
969,
12,
334,
17,
12,
841,
430,
272,
20031,
63,
409,
275,
20031,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
4610,
9,
272,
702,
822,
8,
16966,
63,
409,
9,
508,
413,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
996,
837,
272,
519,
2344,
25348,
543,
682,
5630,
14,
272,
1449,
339,
682,
2181,
275,
2799,
2181,
779,
969,
12,
4329,
12,
4114,
467,
334,
17,
12,
841,
430,
272,
20031,
63,
409,
275,
20031,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
335,
2181,
9,
272,
702,
822,
8,
16966,
63,
409,
9,
508,
650,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
1644,
837,
272,
519,
2344,
25348,
543,
682,
5630,
543,
9250,
20031,
397,
14,
272,
1449,
339,
682,
2181,
275,
2799,
2181,
779,
969,
12,
4944,
12,
4944,
12,
4329,
467,
334,
17,
12,
841,
430,
272,
20031,
63,
409,
275,
20031,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
335,
2181,
9,
272,
702,
822,
8,
16966,
63,
409,
9,
508,
499,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
966,
837,
272,
519,
2344,
25348,
543,
2701,
682,
5630,
14,
272,
1449,
339,
682,
2181,
275,
2799,
2181,
8798,
334,
17,
12,
841,
430,
272,
20031,
63,
409,
275,
20031,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
335,
2181,
9,
272,
702,
822,
8,
16966,
63,
409,
9,
508,
378,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
1717,
837,
272,
519,
2344,
25348,
543,
682,
5630,
14,
272,
1449,
339,
702,
822,
8,
16966,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
267,
2799,
2181,
779,
713,
12,
4329,
12,
6155,
12,
5851,
467,
334,
17,
12,
841,
7845,
508,
841,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
282,
468,
350,
492,
627,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
614,
837,
272,
519,
2344,
25348,
543,
12681,
14,
272,
1449,
339,
5317,
275,
3390,
8,
969,
12,
334,
17,
12,
841,
430,
272,
20031,
63,
409,
275,
20031,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
4610,
9,
272,
702,
822,
8,
16966,
63,
409,
9,
508,
413,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
996,
837,
272,
519,
2344,
25348,
543,
682,
5630,
14,
272,
1449,
339,
682,
2181,
275,
2799,
2181,
779,
969,
12,
4329,
12,
4114,
467,
334,
17,
12,
841,
430,
272,
20031,
63,
409,
275,
20031,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
335,
2181,
9,
272,
702,
822,
8,
16966,
63,
409,
9,
508,
650,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
1644,
837,
272,
519,
2344,
25348,
543,
682,
5630,
543,
9250,
20031,
397,
14,
272,
1449,
339,
682,
2181,
275,
2799,
2181,
779,
969,
12,
4944,
12,
4944,
12,
4329,
467,
334,
17,
12,
841,
430,
272,
20031,
63,
409,
275,
20031,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
335,
2181,
9,
272,
702,
822,
8,
16966,
63,
409,
9,
508,
499,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
966,
837,
272,
519,
2344,
25348,
543,
2701,
682,
5630,
14,
272,
1449,
339,
682,
2181,
275,
2799,
2181,
8798,
334,
17,
12,
841,
430,
272,
20031,
63,
409,
275,
20031,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
335,
2181,
9,
272,
702,
822,
8,
16966,
63,
409,
9,
508,
378,
421,
199,
318,
511,
63,
16966,
2537,
63,
48,
9414,
1084,
63,
504,
63,
5592,
63,
1717,
837,
272,
519,
2344,
25348,
543,
682,
5630,
14,
272,
1449,
339,
702,
822,
8,
16966,
2537,
14,
48,
9414,
1084,
14,
504,
63,
5592,
8,
267,
2799,
2181,
779,
713,
12,
4329,
12,
6155,
12,
5851,
467,
334,
17,
12,
841,
7845,
508,
841,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
bjolivot/ansible
|
lib/ansible/playbook/task_include.py
|
92
|
2704
|
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.playbook.attribute import FieldAttribute
from ansible.playbook.task import Task
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
__all__ = ['TaskInclude']
class TaskInclude(Task):
"""
A task include is derived from a regular task to handle the special
circumstances related to the `- include: ...` task.
"""
# =================================================================================
# ATTRIBUTES
_static = FieldAttribute(isa='bool', default=None)
def __init__(self, block=None, role=None, task_include=None):
super(TaskInclude, self).__init__(block=block, role=role, task_include=task_include)
self.statically_loaded = False
@staticmethod
def load(data, block=None, role=None, task_include=None, variable_manager=None, loader=None):
t = TaskInclude(block=block, role=role, task_include=task_include)
return t.load_data(data, variable_manager=variable_manager, loader=loader)
def copy(self, exclude_parent=False, exclude_tasks=False):
new_me = super(TaskInclude, self).copy(exclude_parent=exclude_parent, exclude_tasks=exclude_tasks)
new_me.statically_loaded = self.statically_loaded
return new_me
def get_vars(self):
'''
We override the parent Task() classes get_vars here because
we need to include the args of the include into the vars as
they are params to the included tasks.
'''
all_vars = dict()
if self._parent:
all_vars.update(self._parent.get_vars())
all_vars.update(self.vars)
all_vars.update(self.args)
if 'tags' in all_vars:
del all_vars['tags']
if 'when' in all_vars:
del all_vars['when']
return all_vars
|
gpl-3.0
|
[
3,
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
14205,
14,
3215,
492,
5024,
1646,
199,
504,
3242,
14,
14205,
14,
1765,
492,
8495,
199,
199,
893,
26,
272,
687,
636,
973,
363,
492,
2929,
199,
2590,
3545,
26,
272,
687,
3242,
14,
1208,
14,
2918,
492,
12175,
272,
2929,
275,
12175,
342,
199,
199,
363,
452,
363,
275,
788,
4476,
7826,
418,
421,
199,
533,
8495,
7826,
8,
4476,
304,
339,
408,
272,
437,
2120,
2387,
365,
7131,
687,
282,
5578,
2120,
370,
2429,
314,
4539,
272,
27027,
611,
83,
4048,
370,
314,
658,
13,
2387,
26,
2263,
64,
2120,
14,
272,
408,
339,
327,
7819,
1280,
272,
327,
10762,
16883,
339,
485,
1986,
275,
5024,
1646,
8,
13655,
534,
2245,
297,
849,
29,
403,
9,
339,
347,
636,
826,
721,
277,
12,
1853,
29,
403,
12,
4719,
29,
403,
12,
2120,
63,
2613,
29,
403,
304,
267,
1613,
8,
4476,
7826,
12,
291,
2843,
826,
721,
1457,
29,
1457,
12,
4719,
29,
3756,
12,
2120,
63,
2613,
29,
1765,
63,
2613,
9,
267,
291,
14,
1986,
1183,
63,
4591,
275,
756,
339,
768,
4639,
272,
347,
2248,
8,
576,
12,
1853,
29,
403,
12,
4719,
29,
403,
12,
2120,
63,
2613,
29,
403,
12,
1750,
63,
2609,
29,
403,
12,
5077,
29,
403,
304,
267,
307,
275,
8495,
7826,
8,
1457,
29,
1457,
12,
4719,
29,
3756,
12,
2120,
63,
2613,
29,
1765,
63,
2613,
9,
267,
372,
307,
14,
912,
63,
576,
8,
576,
12,
1750,
63,
2609,
29,
1975,
63,
2609,
12,
5077,
29,
3422,
9,
339,
347,
1331,
8,
277,
12,
5760,
63,
1708,
29,
797,
12,
5760,
63,
5054,
29,
797,
304,
267,
892,
63,
278,
275,
1613,
8,
4476,
7826,
12,
291,
680,
1574,
8,
5473,
63,
1708,
29,
5473,
63,
1708,
12,
5760,
63,
5054,
29,
5473,
63,
5054,
9,
267,
892,
63,
278,
14,
1986,
1183,
63,
4591,
275,
291,
14,
1986,
1183,
63,
4591,
267,
372,
892,
63,
278,
339,
347,
664,
63,
2936,
8,
277,
304,
267,
1449,
267,
2136,
4278,
314,
1676,
8495,
342,
3992,
664,
63,
2936,
2348,
2952,
267,
781,
1929,
370,
2387,
314,
1249,
402,
314,
2387,
1901,
314,
6802,
465,
267,
2985,
787,
1862,
370,
314,
5120,
6527,
14,
267,
1449,
267,
1006,
63,
2936,
275,
1211,
342,
267,
340,
291,
423,
1708,
26,
288,
1006,
63,
2936,
14,
873,
8,
277,
423,
1708,
14,
362,
63,
2936,
1012,
398,
1006,
63,
2936,
14,
873,
8,
277,
14,
2936,
9,
267,
1006,
63,
2936,
14,
873,
8,
277,
14,
589,
9,
398,
340,
283,
2969,
7,
315,
1006,
63,
2936,
26,
288,
2150,
1006,
63,
2936,
459,
2969,
418,
267,
340,
283,
6526,
7,
315,
1006,
63,
2936,
26,
288,
2150,
1006,
63,
2936,
459,
6526,
418,
398,
372,
1006,
63,
2936,
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
] |
[
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
14205,
14,
3215,
492,
5024,
1646,
199,
504,
3242,
14,
14205,
14,
1765,
492,
8495,
199,
199,
893,
26,
272,
687,
636,
973,
363,
492,
2929,
199,
2590,
3545,
26,
272,
687,
3242,
14,
1208,
14,
2918,
492,
12175,
272,
2929,
275,
12175,
342,
199,
199,
363,
452,
363,
275,
788,
4476,
7826,
418,
421,
199,
533,
8495,
7826,
8,
4476,
304,
339,
408,
272,
437,
2120,
2387,
365,
7131,
687,
282,
5578,
2120,
370,
2429,
314,
4539,
272,
27027,
611,
83,
4048,
370,
314,
658,
13,
2387,
26,
2263,
64,
2120,
14,
272,
408,
339,
327,
7819,
1280,
272,
327,
10762,
16883,
339,
485,
1986,
275,
5024,
1646,
8,
13655,
534,
2245,
297,
849,
29,
403,
9,
339,
347,
636,
826,
721,
277,
12,
1853,
29,
403,
12,
4719,
29,
403,
12,
2120,
63,
2613,
29,
403,
304,
267,
1613,
8,
4476,
7826,
12,
291,
2843,
826,
721,
1457,
29,
1457,
12,
4719,
29,
3756,
12,
2120,
63,
2613,
29,
1765,
63,
2613,
9,
267,
291,
14,
1986,
1183,
63,
4591,
275,
756,
339,
768,
4639,
272,
347,
2248,
8,
576,
12,
1853,
29,
403,
12,
4719,
29,
403,
12,
2120,
63,
2613,
29,
403,
12,
1750,
63,
2609,
29,
403,
12,
5077,
29,
403,
304,
267,
307,
275,
8495,
7826,
8,
1457,
29,
1457,
12,
4719,
29,
3756,
12,
2120,
63,
2613,
29,
1765,
63,
2613,
9,
267,
372,
307,
14,
912,
63,
576,
8,
576,
12,
1750,
63,
2609,
29,
1975,
63,
2609,
12,
5077,
29,
3422,
9,
339,
347,
1331,
8,
277,
12,
5760,
63,
1708,
29,
797,
12,
5760,
63,
5054,
29,
797,
304,
267,
892,
63,
278,
275,
1613,
8,
4476,
7826,
12,
291,
680,
1574,
8,
5473,
63,
1708,
29,
5473,
63,
1708,
12,
5760,
63,
5054,
29,
5473,
63,
5054,
9,
267,
892,
63,
278,
14,
1986,
1183,
63,
4591,
275,
291,
14,
1986,
1183,
63,
4591,
267,
372,
892,
63,
278,
339,
347,
664,
63,
2936,
8,
277,
304,
267,
1449,
267,
2136,
4278,
314,
1676,
8495,
342,
3992,
664,
63,
2936,
2348,
2952,
267,
781,
1929,
370,
2387,
314,
1249,
402,
314,
2387,
1901,
314,
6802,
465,
267,
2985,
787,
1862,
370,
314,
5120,
6527,
14,
267,
1449,
267,
1006,
63,
2936,
275,
1211,
342,
267,
340,
291,
423,
1708,
26,
288,
1006,
63,
2936,
14,
873,
8,
277,
423,
1708,
14,
362,
63,
2936,
1012,
398,
1006,
63,
2936,
14,
873,
8,
277,
14,
2936,
9,
267,
1006,
63,
2936,
14,
873,
8,
277,
14,
589,
9,
398,
340,
283,
2969,
7,
315,
1006,
63,
2936,
26,
288,
2150,
1006,
63,
2936,
459,
2969,
418,
267,
340,
283,
6526,
7,
315,
1006,
63,
2936,
26,
288,
2150,
1006,
63,
2936,
459,
6526,
418,
398,
372,
1006,
63,
2936,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
pdellaert/ansible
|
lib/ansible/module_utils/connection.py
|
8
|
7622
|
#
# This code is part of Ansible, but is an independent component.
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete work.
#
# (c) 2017 Red Hat Inc.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import hashlib
import json
import socket
import struct
import traceback
import uuid
from functools import partial
from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils.common.json import AnsibleJSONEncoder
from ansible.module_utils.six import iteritems
from ansible.module_utils.six.moves import cPickle
def write_to_file_descriptor(fd, obj):
"""Handles making sure all data is properly written to file descriptor fd.
In particular, that data is encoded in a character stream-friendly way and
that all data gets written before returning.
"""
# Need to force a protocol that is compatible with both py2 and py3.
# That would be protocol=2 or less.
# Also need to force a protocol that excludes certain control chars as
# stdin in this case is a pty and control chars will cause problems.
# that means only protocol=0 will work.
src = cPickle.dumps(obj, protocol=0)
# raw \r characters will not survive pty round-trip
# They should be rehydrated on the receiving end
src = src.replace(b'\r', br'\r')
data_hash = to_bytes(hashlib.sha1(src).hexdigest())
os.write(fd, b'%d\n' % len(src))
os.write(fd, src)
os.write(fd, b'%s\n' % data_hash)
def send_data(s, data):
packed_len = struct.pack('!Q', len(data))
return s.sendall(packed_len + data)
def recv_data(s):
header_len = 8 # size of a packed unsigned long long
data = to_bytes("")
while len(data) < header_len:
d = s.recv(header_len - len(data))
if not d:
return None
data += d
data_len = struct.unpack('!Q', data[:header_len])[0]
data = data[header_len:]
while len(data) < data_len:
d = s.recv(data_len - len(data))
if not d:
return None
data += d
return data
def exec_command(module, command):
connection = Connection(module._socket_path)
try:
out = connection.exec_command(command)
except ConnectionError as exc:
code = getattr(exc, 'code', 1)
message = getattr(exc, 'err', exc)
return code, '', to_text(message, errors='surrogate_then_replace')
return 0, out, ''
def request_builder(method_, *args, **kwargs):
reqid = str(uuid.uuid4())
req = {'jsonrpc': '2.0', 'method': method_, 'id': reqid}
req['params'] = (args, kwargs)
return req
class ConnectionError(Exception):
def __init__(self, message, *args, **kwargs):
super(ConnectionError, self).__init__(message)
for k, v in iteritems(kwargs):
setattr(self, k, v)
class Connection(object):
def __init__(self, socket_path):
if socket_path is None:
raise AssertionError('socket_path must be a value')
self.socket_path = socket_path
def __getattr__(self, name):
try:
return self.__dict__[name]
except KeyError:
if name.startswith('_'):
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
return partial(self.__rpc__, name)
def _exec_jsonrpc(self, name, *args, **kwargs):
req = request_builder(name, *args, **kwargs)
reqid = req['id']
if not os.path.exists(self.socket_path):
raise ConnectionError('socket_path does not exist or cannot be found.'
'\nSee the socket_path issue category in Network Debug and Troubleshooting Guide')
try:
data = json.dumps(req, cls=AnsibleJSONEncoder)
except TypeError as exc:
raise ConnectionError(
"Failed to encode some variables as JSON for communication with ansible-connection. "
"The original exception was: %s" % to_text(exc)
)
try:
out = self.send(data)
except socket.error as e:
raise ConnectionError('unable to connect to socket. See the socket_path issue category in Network Debug and Troubleshooting Guide',
err=to_text(e, errors='surrogate_then_replace'), exception=traceback.format_exc())
try:
response = json.loads(out)
except ValueError:
params = list(args) + ['{0}={1}'.format(k, v) for k, v in iteritems(kwargs)]
params = ', '.join(params)
raise ConnectionError(
"Unable to decode JSON from response to {0}({1}). Received '{2}'.".format(name, params, out)
)
if response['id'] != reqid:
raise ConnectionError('invalid json-rpc id received')
return response
def __rpc__(self, name, *args, **kwargs):
"""Executes the json-rpc and returns the output received
from remote device.
:name: rpc method to be executed over connection plugin that implements jsonrpc 2.0
:args: Ordered list of params passed as arguments to rpc method
:kwargs: Dict of valid key, value pairs passed as arguments to rpc method
For usage refer the respective connection plugin docs.
"""
response = self._exec_jsonrpc(name, *args, **kwargs)
if 'error' in response:
err = response.get('error')
msg = err.get('data') or err['message']
code = err['code']
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
return response['result']
def send(self, data):
try:
sf = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sf.connect(self.socket_path)
send_data(sf, to_bytes(data))
response = recv_data(sf)
except socket.error as e:
sf.close()
raise ConnectionError('unable to connect to socket', err=to_text(e, errors='surrogate_then_replace'), exception=traceback.format_exc())
sf.close()
return to_text(response, errors='surrogate_or_strict')
|
gpl-3.0
|
[
3,
199,
3,
961,
1233,
365,
1777,
402,
2622,
12,
1325,
365,
376,
12717,
3931,
14,
199,
3,
961,
6770,
570,
17440,
12,
436,
642,
570,
17440,
1454,
12,
365,
6289,
18233,
14,
199,
3,
18167,
1265,
2218,
1808,
642,
17440,
12,
1314,
365,
12169,
18774,
701,
2622,
199,
3,
5139,
13511,
370,
314,
4132,
402,
314,
859,
12,
436,
1443,
5090,
3932,
5705,
4190,
199,
3,
370,
314,
4890,
1736,
14,
199,
3,
199,
3,
334,
67,
9,
9708,
9572,
13002,
3277,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
7100,
12,
199,
3,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
199,
3,
259,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
420,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
259,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
420,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
420,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
2401,
199,
3,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
5292,
199,
3,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
9315,
9706,
14,
199,
3,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
199,
3,
9716,
12,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
199,
3,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
199,
3,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
747,
199,
646,
8337,
199,
646,
2022,
199,
646,
2838,
199,
646,
2702,
199,
646,
5190,
199,
646,
5377,
199,
199,
504,
9143,
492,
7417,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
2394,
12,
370,
63,
505,
199,
504,
3242,
14,
578,
63,
1208,
14,
2330,
14,
1001,
492,
2622,
23069,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
10849,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
492,
17572,
421,
199,
318,
2218,
63,
475,
63,
493,
63,
4120,
8,
2592,
12,
1559,
304,
272,
408,
23555,
10663,
3238,
1006,
666,
365,
7684,
5313,
370,
570,
5872,
6111,
14,
339,
1010,
6770,
12,
626,
666,
365,
5737,
315,
282,
4528,
2547,
13,
17317,
4340,
436,
272,
626,
1006,
666,
7545,
5313,
2544,
8152,
14,
272,
408,
272,
327,
14012,
370,
3542,
282,
4113,
626,
365,
9025,
543,
3865,
1134,
18,
436,
1134,
19,
14,
272,
327,
10314,
3955,
506,
4113,
29,
18,
503,
6656,
14,
272,
327,
6121,
1929,
370,
3542,
282,
4113,
626,
23388,
9842,
3304,
8365,
465,
272,
327,
9009,
315,
642,
1930,
365,
282,
31237,
436,
3304,
8365,
911,
7675,
8826,
14,
272,
327,
626,
4910,
1454,
4113,
29,
16,
911,
1736,
14,
272,
2928,
275,
17572,
14,
4180,
8,
1113,
12,
4113,
29,
16,
9,
339,
327,
3066,
971,
82,
4110,
911,
440,
6296,
433,
432,
31237,
6168,
13,
7254,
272,
327,
9322,
1077,
506,
295,
3577,
5012,
972,
641,
314,
18390,
1284,
272,
2928,
275,
2928,
14,
1814,
8,
66,
1154,
82,
297,
11665,
1154,
82,
358,
272,
666,
63,
2227,
275,
370,
63,
2394,
8,
24722,
14,
4835,
17,
8,
2164,
680,
11453,
1012,
339,
747,
14,
952,
8,
2592,
12,
330,
5956,
68,
60,
78,
7,
450,
822,
8,
2164,
430,
272,
747,
14,
952,
8,
2592,
12,
2928,
9,
272,
747,
14,
952,
8,
2592,
12,
330,
5956,
83,
60,
78,
7,
450,
666,
63,
2227,
9,
421,
199,
318,
3222,
63,
576,
8,
83,
12,
666,
304,
272,
13170,
63,
552,
275,
2702,
14,
1389,
16157,
49,
297,
822,
8,
576,
430,
272,
372,
308,
14,
22695,
8,
12286,
63,
552,
435,
666,
9,
421,
199,
318,
11904,
63,
576,
8,
83,
304,
272,
1406,
63,
552,
275,
1695,
221,
327,
1568,
402,
282,
13170,
7381,
1846,
1846,
272,
666,
275,
370,
63,
2394,
10804,
272,
1830,
822,
8,
576,
9,
665,
1406,
63,
552,
26,
267,
366,
275,
308,
14,
7637,
8,
1291,
63,
552,
446,
822,
8,
576,
430,
267,
340,
440,
366,
26,
288,
372,
488,
267,
666,
847,
366,
272,
666,
63,
552,
275,
2702,
14,
5301,
16157,
49,
297,
666,
1491,
1291,
63,
552,
11057,
16,
61,
272,
666,
275,
666,
59,
1291,
63,
552,
2938,
272,
1830,
822,
8,
576,
9,
665,
666,
63,
552,
26,
267,
366,
275,
308,
14,
7637,
8,
576,
63,
552,
446,
822,
8,
576,
430,
267,
340,
440,
366,
26,
288,
372,
488,
267,
666,
847,
366,
272,
372,
666,
421,
199,
318,
2146,
63,
1531,
8,
578,
12,
1414,
304,
272,
1950,
275,
8113,
8,
578,
423,
3450,
63,
515,
9,
272,
862,
26,
267,
734,
275,
1950,
14,
1628,
63,
1531,
8,
1531,
9,
272,
871,
25417,
465,
3178,
26,
267,
1233,
275,
2519,
8,
2804,
12,
283,
600,
297,
413,
9,
267,
1245,
275,
2519,
8,
2804,
12,
283,
1508,
297,
3178,
9,
267,
372,
1233,
12,
3260,
370,
63,
505,
8,
1188,
12,
2552,
534,
16380,
63,
12726,
63,
1814,
358,
272,
372,
378,
12,
734,
12,
2125,
421,
199,
318,
1056,
63,
5649,
8,
765,
3131,
627,
589,
12,
1011,
958,
304,
272,
2648,
344,
275,
620,
8,
2580,
14,
2580,
20,
1012,
272,
2648,
275,
791,
31395,
356,
283,
18,
14,
16,
297,
283,
765,
356,
1083,
3131,
283,
344,
356,
2648,
344,
93,
272,
2648,
459,
1162,
418,
275,
334,
589,
12,
2074,
9,
339,
372,
2648,
421,
199,
533,
25417,
8,
1726,
304,
339,
347,
636,
826,
721,
277,
12,
1245,
12,
627,
589
] |
[
199,
3,
961,
1233,
365,
1777,
402,
2622,
12,
1325,
365,
376,
12717,
3931,
14,
199,
3,
961,
6770,
570,
17440,
12,
436,
642,
570,
17440,
1454,
12,
365,
6289,
18233,
14,
199,
3,
18167,
1265,
2218,
1808,
642,
17440,
12,
1314,
365,
12169,
18774,
701,
2622,
199,
3,
5139,
13511,
370,
314,
4132,
402,
314,
859,
12,
436,
1443,
5090,
3932,
5705,
4190,
199,
3,
370,
314,
4890,
1736,
14,
199,
3,
199,
3,
334,
67,
9,
9708,
9572,
13002,
3277,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
7100,
12,
199,
3,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
199,
3,
259,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
420,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
259,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
420,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
420,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
2401,
199,
3,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
5292,
199,
3,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
9315,
9706,
14,
199,
3,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
199,
3,
9716,
12,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
199,
3,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
199,
3,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
747,
199,
646,
8337,
199,
646,
2022,
199,
646,
2838,
199,
646,
2702,
199,
646,
5190,
199,
646,
5377,
199,
199,
504,
9143,
492,
7417,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
2394,
12,
370,
63,
505,
199,
504,
3242,
14,
578,
63,
1208,
14,
2330,
14,
1001,
492,
2622,
23069,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
10849,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
492,
17572,
421,
199,
318,
2218,
63,
475,
63,
493,
63,
4120,
8,
2592,
12,
1559,
304,
272,
408,
23555,
10663,
3238,
1006,
666,
365,
7684,
5313,
370,
570,
5872,
6111,
14,
339,
1010,
6770,
12,
626,
666,
365,
5737,
315,
282,
4528,
2547,
13,
17317,
4340,
436,
272,
626,
1006,
666,
7545,
5313,
2544,
8152,
14,
272,
408,
272,
327,
14012,
370,
3542,
282,
4113,
626,
365,
9025,
543,
3865,
1134,
18,
436,
1134,
19,
14,
272,
327,
10314,
3955,
506,
4113,
29,
18,
503,
6656,
14,
272,
327,
6121,
1929,
370,
3542,
282,
4113,
626,
23388,
9842,
3304,
8365,
465,
272,
327,
9009,
315,
642,
1930,
365,
282,
31237,
436,
3304,
8365,
911,
7675,
8826,
14,
272,
327,
626,
4910,
1454,
4113,
29,
16,
911,
1736,
14,
272,
2928,
275,
17572,
14,
4180,
8,
1113,
12,
4113,
29,
16,
9,
339,
327,
3066,
971,
82,
4110,
911,
440,
6296,
433,
432,
31237,
6168,
13,
7254,
272,
327,
9322,
1077,
506,
295,
3577,
5012,
972,
641,
314,
18390,
1284,
272,
2928,
275,
2928,
14,
1814,
8,
66,
1154,
82,
297,
11665,
1154,
82,
358,
272,
666,
63,
2227,
275,
370,
63,
2394,
8,
24722,
14,
4835,
17,
8,
2164,
680,
11453,
1012,
339,
747,
14,
952,
8,
2592,
12,
330,
5956,
68,
60,
78,
7,
450,
822,
8,
2164,
430,
272,
747,
14,
952,
8,
2592,
12,
2928,
9,
272,
747,
14,
952,
8,
2592,
12,
330,
5956,
83,
60,
78,
7,
450,
666,
63,
2227,
9,
421,
199,
318,
3222,
63,
576,
8,
83,
12,
666,
304,
272,
13170,
63,
552,
275,
2702,
14,
1389,
16157,
49,
297,
822,
8,
576,
430,
272,
372,
308,
14,
22695,
8,
12286,
63,
552,
435,
666,
9,
421,
199,
318,
11904,
63,
576,
8,
83,
304,
272,
1406,
63,
552,
275,
1695,
221,
327,
1568,
402,
282,
13170,
7381,
1846,
1846,
272,
666,
275,
370,
63,
2394,
10804,
272,
1830,
822,
8,
576,
9,
665,
1406,
63,
552,
26,
267,
366,
275,
308,
14,
7637,
8,
1291,
63,
552,
446,
822,
8,
576,
430,
267,
340,
440,
366,
26,
288,
372,
488,
267,
666,
847,
366,
272,
666,
63,
552,
275,
2702,
14,
5301,
16157,
49,
297,
666,
1491,
1291,
63,
552,
11057,
16,
61,
272,
666,
275,
666,
59,
1291,
63,
552,
2938,
272,
1830,
822,
8,
576,
9,
665,
666,
63,
552,
26,
267,
366,
275,
308,
14,
7637,
8,
576,
63,
552,
446,
822,
8,
576,
430,
267,
340,
440,
366,
26,
288,
372,
488,
267,
666,
847,
366,
272,
372,
666,
421,
199,
318,
2146,
63,
1531,
8,
578,
12,
1414,
304,
272,
1950,
275,
8113,
8,
578,
423,
3450,
63,
515,
9,
272,
862,
26,
267,
734,
275,
1950,
14,
1628,
63,
1531,
8,
1531,
9,
272,
871,
25417,
465,
3178,
26,
267,
1233,
275,
2519,
8,
2804,
12,
283,
600,
297,
413,
9,
267,
1245,
275,
2519,
8,
2804,
12,
283,
1508,
297,
3178,
9,
267,
372,
1233,
12,
3260,
370,
63,
505,
8,
1188,
12,
2552,
534,
16380,
63,
12726,
63,
1814,
358,
272,
372,
378,
12,
734,
12,
2125,
421,
199,
318,
1056,
63,
5649,
8,
765,
3131,
627,
589,
12,
1011,
958,
304,
272,
2648,
344,
275,
620,
8,
2580,
14,
2580,
20,
1012,
272,
2648,
275,
791,
31395,
356,
283,
18,
14,
16,
297,
283,
765,
356,
1083,
3131,
283,
344,
356,
2648,
344,
93,
272,
2648,
459,
1162,
418,
275,
334,
589,
12,
2074,
9,
339,
372,
2648,
421,
199,
533,
25417,
8,
1726,
304,
339,
347,
636,
826,
721,
277,
12,
1245,
12,
627,
589,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
darktears/chromium-crosswalk
|
chromecast/tools/build/chromecast_repack_locales.py
|
24
|
4485
|
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Helper script to repack paks for a list of locales.
Gyp doesn't have any built-in looping capability, so this just provides a way to
loop over a list of locales when repacking pak files, thus avoiding a
proliferation of mostly duplicate, cut-n-paste gyp actions.
"""
import optparse
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..',
'tools', 'grit'))
from grit.format import data_pack
# Some build paths defined by gyp.
GRIT_DIR = None
INT_DIR = None
CHROMECAST_BRANDING = None
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def calc_output(locale):
"""Determine the file that will be generated for the given locale."""
#e.g. '<(INTERMEDIATE_DIR)/repack/da.pak',
# For Fake Bidi, generate it at a fixed path so that tests can safely
# reference it.
if locale == 'fake-bidi':
return '%s/%s.pak' % (INT_DIR, locale)
return os.path.join(INT_DIR, locale + '.pak')
def calc_inputs(locale):
"""Determine the files that need processing for the given locale."""
inputs = []
if CHROMECAST_BRANDING != 'public':
inputs.append(os.path.join(GRIT_DIR, 'app_strings_%s.pak' % locale))
inputs.append(os.path.join(GRIT_DIR, 'chromecast_settings_%s.pak' % locale))
return inputs
def list_outputs(locales):
"""Returns the names of files that will be generated for the given locales.
This is to provide gyp the list of output files, so build targets can
properly track what needs to be built.
"""
outputs = []
for locale in locales:
outputs.append(calc_output(locale))
# Quote each element so filename spaces don't mess up gyp's attempt to parse
# it into a list.
return " ".join(['"%s"' % x for x in outputs])
def list_inputs(locales):
"""Returns the names of files that will be processed for the given locales.
This is to provide gyp the list of input files, so build targets can properly
track their prerequisites.
"""
inputs = []
for locale in locales:
inputs += calc_inputs(locale)
# Quote each element so filename spaces don't mess up gyp's attempt to parse
# it into a list.
return " ".join(['"%s"' % x for x in inputs])
def repack_locales(locales):
""" Loop over and repack the given locales."""
for locale in locales:
inputs = []
inputs += calc_inputs(locale)
output = calc_output(locale)
data_pack.DataPack.RePack(output, inputs)
def DoMain(argv):
global CHROMECAST_BRANDING
global GRIT_DIR
global INT_DIR
parser = optparse.OptionParser("usage: %prog [options] locales")
parser.add_option("-i", action="store_true", dest="inputs", default=False,
help="Print the expected input file list, then exit.")
parser.add_option("-o", action="store_true", dest="outputs", default=False,
help="Print the expected output file list, then exit.")
parser.add_option("-g", action="store", dest="grit_dir",
help="GRIT build files output directory.")
parser.add_option("-x", action="store", dest="int_dir",
help="Intermediate build files output directory.")
parser.add_option("-b", action="store", dest="chromecast_branding",
help="Chromecast branding " +
"('public', 'internal' or 'google').")
options, locales = parser.parse_args(argv)
if not locales:
parser.error('Please specificy at least one locale to process.\n')
print_inputs = options.inputs
print_outputs = options.outputs
GRIT_DIR = options.grit_dir
INT_DIR = options.int_dir
CHROMECAST_BRANDING = options.chromecast_branding
if (CHROMECAST_BRANDING != 'public' and
CHROMECAST_BRANDING != 'internal' and
CHROMECAST_BRANDING != 'google'):
parser.error('Chromecast branding (-b) must be ' +
'"public", "internal" or "google".\n')
if not (GRIT_DIR and INT_DIR):
parser.error('Please specify all of "-g" and "-x".\n')
if print_inputs and print_outputs:
parser.error('Please specify only one of "-i" or "-o".\n')
if print_inputs:
return list_inputs(locales)
if print_outputs:
return list_outputs(locales)
return repack_locales(locales)
if __name__ == '__main__':
results = DoMain(sys.argv[1:])
if results:
print results
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
4433,
2884,
370,
295,
1389,
691,
6080,
367,
282,
769,
402,
24847,
14,
199,
199,
13899,
3181,
1133,
1172,
1263,
6137,
13,
262,
4438,
316,
19854,
12,
880,
642,
2951,
6571,
282,
4340,
370,
199,
3813,
1806,
282,
769,
402,
24847,
1380,
295,
1389,
316,
691,
75,
1584,
12,
12850,
5126,
316,
282,
199,
496,
853,
281,
425,
402,
19762,
9250,
12,
10415,
13,
78,
13,
16586,
4902,
5445,
14,
199,
624,
199,
199,
646,
8691,
199,
646,
747,
199,
646,
984,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
19155,
19155,
19155,
2490,
283,
2537,
297,
283,
7928,
84,
1333,
199,
504,
486,
11133,
14,
908,
492,
666,
63,
1389,
199,
199,
3,
6601,
1900,
3792,
3247,
701,
4902,
14,
199,
3975,
649,
63,
3022,
275,
488,
199,
2919,
63,
3022,
275,
488,
199,
1244,
31364,
18898,
63,
7184,
3649,
1206,
275,
488,
199,
199,
533,
11028,
8,
1726,
304,
523,
347,
636,
826,
721,
277,
12,
1499,
304,
272,
291,
14,
1328,
275,
1499,
421,
199,
318,
12831,
63,
1199,
8,
5508,
304,
523,
408,
21767,
314,
570,
626,
911,
506,
4046,
367,
314,
1627,
5867,
1041,
523,
327,
69,
14,
71,
14,
2650,
8,
23227,
63,
3022,
2447,
264,
1389,
15,
983,
14,
22460,
297,
523,
327,
2104,
7777,
699,
9897,
12,
3550,
652,
737,
282,
6317,
931,
880,
626,
2295,
883,
19353,
523,
327,
3659,
652,
14,
523,
340,
5867,
508,
283,
3183,
13,
21555,
356,
272,
372,
1543,
83,
3149,
83,
14,
22460,
7,
450,
334,
2919,
63,
3022,
12,
5867,
9,
523,
372,
747,
14,
515,
14,
904,
8,
2919,
63,
3022,
12,
5867,
435,
1987,
22460,
358,
421,
199,
318,
12831,
63,
3711,
8,
5508,
304,
523,
408,
21767,
314,
1584,
626,
1929,
6661,
367,
314,
1627,
5867,
1041,
523,
4153,
275,
942,
523,
340,
6624,
31364,
18898,
63,
7184,
3649,
1206,
1137,
283,
3455,
356,
272,
4153,
14,
740,
8,
736,
14,
515,
14,
904,
8,
3975,
649,
63,
3022,
12,
283,
571,
63,
5465,
4970,
83,
14,
22460,
7,
450,
5867,
430,
523,
4153,
14,
740,
8,
736,
14,
515,
14,
904,
8,
3975,
649,
63,
3022,
12,
283,
9887,
2931,
63,
1751,
4970,
83,
14,
22460,
7,
450,
5867,
430,
523,
372,
4153,
421,
199,
318,
769,
63,
4467,
8,
24763,
304,
523,
408,
3407,
314,
1561,
402,
1584,
626,
911,
506,
4046,
367,
314,
1627,
24847,
14,
819,
961,
365,
370,
5647,
4902,
314,
769,
402,
1072,
1584,
12,
880,
1900,
4545,
883,
523,
7684,
4426,
4052,
4839,
370,
506,
6137,
14,
523,
408,
523,
4704,
275,
942,
523,
367,
5867,
315,
24847,
26,
272,
4704,
14,
740,
8,
8104,
63,
1199,
8,
5508,
430,
523,
327,
29335,
1924,
1819,
880,
1788,
7883,
2793,
1133,
15634,
1536,
4902,
1159,
7427,
370,
2198,
523,
327,
652,
1901,
282,
769,
14,
523,
372,
298,
3680,
904,
2941,
6808,
83,
4507,
450,
671,
367,
671,
315,
4704,
566,
421,
199,
318,
769,
63,
3711,
8,
24763,
304,
523,
408,
3407,
314,
1561,
402,
1584,
626,
911,
506,
7686,
367,
314,
1627,
24847,
14,
819,
961,
365,
370,
5647,
4902,
314,
769,
402,
1324,
1584,
12,
880,
1900,
4545,
883,
7684,
523,
4426,
3932,
876,
30140,
14,
523,
408,
523,
4153,
275,
942,
523,
367,
5867,
315,
24847,
26,
272,
4153,
847,
12831,
63,
3711,
8,
5508,
9,
523,
327,
29335,
1924,
1819,
880,
1788,
7883,
2793,
1133,
15634,
1536,
4902,
1159,
7427,
370,
2198,
523,
327,
652,
1901,
282,
769,
14,
523,
372,
298,
3680,
904,
2941,
6808,
83,
4507,
450,
671,
367,
671,
315,
4153,
566,
421,
199,
318,
295,
1389,
63,
24763,
8,
24763,
304,
523,
408,
18175,
1806,
436,
295,
1389,
314,
1627,
24847,
1041,
523,
367,
5867,
315,
24847,
26,
272,
4153,
275,
942,
272,
4153,
847,
12831,
63,
3711,
8,
5508,
9,
272,
1072,
275,
12831,
63,
1199,
8,
5508,
9,
272,
666,
63,
1389,
14,
1451,
2305,
14,
497,
2305,
8,
1199,
12,
4153,
9,
421,
199,
318,
4226,
6756,
8,
3020,
304,
523,
2288,
6624,
31364,
18898,
63,
7184,
3649,
1206,
523,
2288,
21772,
649,
63,
3022,
523,
2288,
16429,
63,
3022,
819,
1798,
275,
8691,
14,
14553,
480,
3807,
26,
450,
6595,
359,
1419,
61,
24847,
531,
523,
1798,
14,
525,
63,
1422,
6096,
73,
401,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
3711,
401,
849,
29,
797,
12,
490,
1720,
628,
5375,
314,
1420,
1324,
570,
769,
12,
2066,
4458,
2685,
523,
1798,
14,
525,
63,
1422,
6096,
79,
401,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
4467,
401,
849,
29,
797,
12,
490,
1720,
628,
5375,
314,
1420,
1072,
570,
769,
12,
2066,
4458,
2685,
523,
1798,
14,
525,
63,
1422,
6096,
71,
401,
1595,
628,
1617,
401,
2053,
628,
7928,
84,
63,
694,
401,
490,
1720,
628,
3975,
649,
1900,
1584,
1072,
2082,
2685,
523,
1798,
14,
525,
63,
1422,
6096,
88,
401,
1595,
628,
1617,
401,
2053,
628,
442,
63,
694,
401,
490,
1720,
628,
2620,
5050,
1900,
1584,
1072,
2082,
2685,
523,
1798,
14,
525,
63,
1422,
6096,
66,
401,
1595,
628,
1617,
401,
2053,
628,
9887,
2931,
63,
19026,
316,
401,
490,
1720,
628,
18083,
2931,
32159,
316,
298,
435,
586,
16111,
3455,
297,
283,
4672,
7,
503,
283,
3098,
1959,
531,
523,
1511,
12,
24847,
275,
1798,
14,
1122,
63,
589,
8,
3020,
9,
819,
340,
440,
24847,
26,
272,
1798,
14,
705,
360,
8254,
1106,
329,
1480,
737,
5210,
1373,
5867,
370,
2112,
3134,
78,
358,
819,
870,
63,
3711,
275,
1511,
14,
3711,
523,
870,
63,
4467,
275,
1511,
14,
4467,
523,
21772,
649,
63,
3022,
275,
1511,
14,
7928,
84,
63,
694,
523,
16429,
63,
3022,
275,
1511,
14,
442,
63,
694,
523,
6624,
31364,
18898,
63,
7184,
3649,
1206,
275,
1511,
14,
9887
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
4433,
2884,
370,
295,
1389,
691,
6080,
367,
282,
769,
402,
24847,
14,
199,
199,
13899,
3181,
1133,
1172,
1263,
6137,
13,
262,
4438,
316,
19854,
12,
880,
642,
2951,
6571,
282,
4340,
370,
199,
3813,
1806,
282,
769,
402,
24847,
1380,
295,
1389,
316,
691,
75,
1584,
12,
12850,
5126,
316,
282,
199,
496,
853,
281,
425,
402,
19762,
9250,
12,
10415,
13,
78,
13,
16586,
4902,
5445,
14,
199,
624,
199,
199,
646,
8691,
199,
646,
747,
199,
646,
984,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
19155,
19155,
19155,
2490,
283,
2537,
297,
283,
7928,
84,
1333,
199,
504,
486,
11133,
14,
908,
492,
666,
63,
1389,
199,
199,
3,
6601,
1900,
3792,
3247,
701,
4902,
14,
199,
3975,
649,
63,
3022,
275,
488,
199,
2919,
63,
3022,
275,
488,
199,
1244,
31364,
18898,
63,
7184,
3649,
1206,
275,
488,
199,
199,
533,
11028,
8,
1726,
304,
523,
347,
636,
826,
721,
277,
12,
1499,
304,
272,
291,
14,
1328,
275,
1499,
421,
199,
318,
12831,
63,
1199,
8,
5508,
304,
523,
408,
21767,
314,
570,
626,
911,
506,
4046,
367,
314,
1627,
5867,
1041,
523,
327,
69,
14,
71,
14,
2650,
8,
23227,
63,
3022,
2447,
264,
1389,
15,
983,
14,
22460,
297,
523,
327,
2104,
7777,
699,
9897,
12,
3550,
652,
737,
282,
6317,
931,
880,
626,
2295,
883,
19353,
523,
327,
3659,
652,
14,
523,
340,
5867,
508,
283,
3183,
13,
21555,
356,
272,
372,
1543,
83,
3149,
83,
14,
22460,
7,
450,
334,
2919,
63,
3022,
12,
5867,
9,
523,
372,
747,
14,
515,
14,
904,
8,
2919,
63,
3022,
12,
5867,
435,
1987,
22460,
358,
421,
199,
318,
12831,
63,
3711,
8,
5508,
304,
523,
408,
21767,
314,
1584,
626,
1929,
6661,
367,
314,
1627,
5867,
1041,
523,
4153,
275,
942,
523,
340,
6624,
31364,
18898,
63,
7184,
3649,
1206,
1137,
283,
3455,
356,
272,
4153,
14,
740,
8,
736,
14,
515,
14,
904,
8,
3975,
649,
63,
3022,
12,
283,
571,
63,
5465,
4970,
83,
14,
22460,
7,
450,
5867,
430,
523,
4153,
14,
740,
8,
736,
14,
515,
14,
904,
8,
3975,
649,
63,
3022,
12,
283,
9887,
2931,
63,
1751,
4970,
83,
14,
22460,
7,
450,
5867,
430,
523,
372,
4153,
421,
199,
318,
769,
63,
4467,
8,
24763,
304,
523,
408,
3407,
314,
1561,
402,
1584,
626,
911,
506,
4046,
367,
314,
1627,
24847,
14,
819,
961,
365,
370,
5647,
4902,
314,
769,
402,
1072,
1584,
12,
880,
1900,
4545,
883,
523,
7684,
4426,
4052,
4839,
370,
506,
6137,
14,
523,
408,
523,
4704,
275,
942,
523,
367,
5867,
315,
24847,
26,
272,
4704,
14,
740,
8,
8104,
63,
1199,
8,
5508,
430,
523,
327,
29335,
1924,
1819,
880,
1788,
7883,
2793,
1133,
15634,
1536,
4902,
1159,
7427,
370,
2198,
523,
327,
652,
1901,
282,
769,
14,
523,
372,
298,
3680,
904,
2941,
6808,
83,
4507,
450,
671,
367,
671,
315,
4704,
566,
421,
199,
318,
769,
63,
3711,
8,
24763,
304,
523,
408,
3407,
314,
1561,
402,
1584,
626,
911,
506,
7686,
367,
314,
1627,
24847,
14,
819,
961,
365,
370,
5647,
4902,
314,
769,
402,
1324,
1584,
12,
880,
1900,
4545,
883,
7684,
523,
4426,
3932,
876,
30140,
14,
523,
408,
523,
4153,
275,
942,
523,
367,
5867,
315,
24847,
26,
272,
4153,
847,
12831,
63,
3711,
8,
5508,
9,
523,
327,
29335,
1924,
1819,
880,
1788,
7883,
2793,
1133,
15634,
1536,
4902,
1159,
7427,
370,
2198,
523,
327,
652,
1901,
282,
769,
14,
523,
372,
298,
3680,
904,
2941,
6808,
83,
4507,
450,
671,
367,
671,
315,
4153,
566,
421,
199,
318,
295,
1389,
63,
24763,
8,
24763,
304,
523,
408,
18175,
1806,
436,
295,
1389,
314,
1627,
24847,
1041,
523,
367,
5867,
315,
24847,
26,
272,
4153,
275,
942,
272,
4153,
847,
12831,
63,
3711,
8,
5508,
9,
272,
1072,
275,
12831,
63,
1199,
8,
5508,
9,
272,
666,
63,
1389,
14,
1451,
2305,
14,
497,
2305,
8,
1199,
12,
4153,
9,
421,
199,
318,
4226,
6756,
8,
3020,
304,
523,
2288,
6624,
31364,
18898,
63,
7184,
3649,
1206,
523,
2288,
21772,
649,
63,
3022,
523,
2288,
16429,
63,
3022,
819,
1798,
275,
8691,
14,
14553,
480,
3807,
26,
450,
6595,
359,
1419,
61,
24847,
531,
523,
1798,
14,
525,
63,
1422,
6096,
73,
401,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
3711,
401,
849,
29,
797,
12,
490,
1720,
628,
5375,
314,
1420,
1324,
570,
769,
12,
2066,
4458,
2685,
523,
1798,
14,
525,
63,
1422,
6096,
79,
401,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
4467,
401,
849,
29,
797,
12,
490,
1720,
628,
5375,
314,
1420,
1072,
570,
769,
12,
2066,
4458,
2685,
523,
1798,
14,
525,
63,
1422,
6096,
71,
401,
1595,
628,
1617,
401,
2053,
628,
7928,
84,
63,
694,
401,
490,
1720,
628,
3975,
649,
1900,
1584,
1072,
2082,
2685,
523,
1798,
14,
525,
63,
1422,
6096,
88,
401,
1595,
628,
1617,
401,
2053,
628,
442,
63,
694,
401,
490,
1720,
628,
2620,
5050,
1900,
1584,
1072,
2082,
2685,
523,
1798,
14,
525,
63,
1422,
6096,
66,
401,
1595,
628,
1617,
401,
2053,
628,
9887,
2931,
63,
19026,
316,
401,
490,
1720,
628,
18083,
2931,
32159,
316,
298,
435,
586,
16111,
3455,
297,
283,
4672,
7,
503,
283,
3098,
1959,
531,
523,
1511,
12,
24847,
275,
1798,
14,
1122,
63,
589,
8,
3020,
9,
819,
340,
440,
24847,
26,
272,
1798,
14,
705,
360,
8254,
1106,
329,
1480,
737,
5210,
1373,
5867,
370,
2112,
3134,
78,
358,
819,
870,
63,
3711,
275,
1511,
14,
3711,
523,
870,
63,
4467,
275,
1511,
14,
4467,
523,
21772,
649,
63,
3022,
275,
1511,
14,
7928,
84,
63,
694,
523,
16429,
63,
3022,
275,
1511,
14,
442,
63,
694,
523,
6624,
31364,
18898,
63,
7184,
3649,
1206,
275,
1511,
14,
9887,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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ager with great worst-case behavior'
def __init__(self, data=''):
self.buf = collections.deque([data])
self.buf_len = len(data)
self.pos = 0
def __len__(self):
return self.buf_len - self.pos
def add(self, data):
self.buf.append(data)
self.buf_len += len(data)
def get(self, wants):
if self.buf_len - self.pos < wants:
raise IndexError('not enough data')
data = []
while wants:
seg = self.buf[0][self.pos:self.pos+wants]
self.pos += len(seg)
while self.buf and self.pos >= len(self.buf[0]):
x = self.buf.popleft()
self.buf_len -= len(x)
self.pos -= len(x)
data.append(seg)
wants -= len(seg)
return ''.join(data)
def _DataChunker(receiver):
wants = receiver.next()
buf = StringBuffer()
while True:
if len(buf) >= wants:
wants = receiver.send(buf.get(wants))
else:
buf.add((yield))
def DataChunker(receiver):
'''
Produces a function that accepts data that is input into a generator
(receiver) in response to the receiver yielding the size of data to wait on
'''
x = _DataChunker(receiver)
x.next()
return x.send
|
gpl-3.0
|
[
646,
5055,
199,
199,
533,
2624,
3299,
8,
785,
304,
272,
283,
3299,
5256,
543,
27254,
1319,
270,
13,
2546,
5953,
7,
2286,
347,
636,
826,
721,
277,
12,
666,
9280,
267,
291,
14,
1436,
275,
5055,
14,
22983,
779,
576,
566,
267,
291,
14,
1436,
63,
552,
275,
822,
8,
576,
9,
267,
291,
14,
1712,
275,
378,
2286,
347,
636,
552,
721,
277,
304,
267,
372,
291,
14,
1436,
63,
552,
446,
291,
14,
1712,
2286,
347,
1050,
8,
277,
12,
666,
304,
267,
291,
14,
1436,
14,
740,
8,
576,
9,
267,
291,
14,
1436,
63,
552,
847,
822,
8,
576,
9,
2286,
347,
664,
8,
277,
12,
15061,
304,
267,
340,
291,
14,
1436,
63,
552,
446,
291,
14,
1712,
665,
15061,
26,
288,
746,
7888,
360,
1397,
8321,
666,
358,
267,
666,
275,
942,
267,
1830,
15061,
26,
288,
8812,
275,
291,
14,
1436,
59,
16,
1527,
277,
14,
1712,
26,
277,
14,
1712,
11,
28789,
61,
288,
291,
14,
1712,
847,
822,
8,
8359,
9,
288,
1830,
291,
14,
1436,
436,
291,
14,
1712,
2356,
822,
8,
277,
14,
1436,
59,
16,
4682,
355,
671,
275,
291,
14,
1436,
14,
25704,
342,
355,
291,
14,
1436,
63,
552,
4862,
822,
8,
88,
9,
355,
291,
14,
1712,
4862,
822,
8,
88,
9,
7846,
666,
14,
740,
8,
8359,
9,
288,
15061,
4862,
822,
8,
8359,
9,
267,
372,
6522,
904,
8,
576,
9,
199,
199,
318,
485,
1451,
9856,
281,
8,
10244,
304,
272,
15061,
275,
13035,
14,
2184,
342,
272,
4123,
275,
2624,
3299,
342,
2286,
1830,
715,
26,
267,
340,
822,
8,
1436,
9,
2356,
15061,
26,
288,
15061,
275,
13035,
14,
2254,
8,
1436,
14,
362,
8,
28789,
430,
267,
587,
26,
288,
4123,
14,
525,
1332,
11481,
430,
199,
318,
3918,
9856,
281,
8,
10244,
304,
272,
1449,
272,
2165,
10569,
282,
805,
626,
11479,
666,
626,
365,
1324,
1901,
282,
4306,
272,
334,
10244,
9,
315,
1177,
370,
314,
13035,
32035,
314,
1568,
402,
666,
370,
3618,
641,
272,
1449,
272,
671,
275,
485,
1451,
9856,
281,
8,
10244,
9,
272,
671,
14,
2184,
342,
272,
372,
671,
14,
2254,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
5055,
199,
199,
533,
2624,
3299,
8,
785,
304,
272,
283,
3299,
5256,
543,
27254,
1319,
270,
13,
2546,
5953,
7,
2286,
347,
636,
826,
721,
277,
12,
666,
9280,
267,
291,
14,
1436,
275,
5055,
14,
22983,
779,
576,
566,
267,
291,
14,
1436,
63,
552,
275,
822,
8,
576,
9,
267,
291,
14,
1712,
275,
378,
2286,
347,
636,
552,
721,
277,
304,
267,
372,
291,
14,
1436,
63,
552,
446,
291,
14,
1712,
2286,
347,
1050,
8,
277,
12,
666,
304,
267,
291,
14,
1436,
14,
740,
8,
576,
9,
267,
291,
14,
1436,
63,
552,
847,
822,
8,
576,
9,
2286,
347,
664,
8,
277,
12,
15061,
304,
267,
340,
291,
14,
1436,
63,
552,
446,
291,
14,
1712,
665,
15061,
26,
288,
746,
7888,
360,
1397,
8321,
666,
358,
267,
666,
275,
942,
267,
1830,
15061,
26,
288,
8812,
275,
291,
14,
1436,
59,
16,
1527,
277,
14,
1712,
26,
277,
14,
1712,
11,
28789,
61,
288,
291,
14,
1712,
847,
822,
8,
8359,
9,
288,
1830,
291,
14,
1436,
436,
291,
14,
1712,
2356,
822,
8,
277,
14,
1436,
59,
16,
4682,
355,
671,
275,
291,
14,
1436,
14,
25704,
342,
355,
291,
14,
1436,
63,
552,
4862,
822,
8,
88,
9,
355,
291,
14,
1712,
4862,
822,
8,
88,
9,
7846,
666,
14,
740,
8,
8359,
9,
288,
15061,
4862,
822,
8,
8359,
9,
267,
372,
6522,
904,
8,
576,
9,
199,
199,
318,
485,
1451,
9856,
281,
8,
10244,
304,
272,
15061,
275,
13035,
14,
2184,
342,
272,
4123,
275,
2624,
3299,
342,
2286,
1830,
715,
26,
267,
340,
822,
8,
1436,
9,
2356,
15061,
26,
288,
15061,
275,
13035,
14,
2254,
8,
1436,
14,
362,
8,
28789,
430,
267,
587,
26,
288,
4123,
14,
525,
1332,
11481,
430,
199,
318,
3918,
9856,
281,
8,
10244,
304,
272,
1449,
272,
2165,
10569,
282,
805,
626,
11479,
666,
626,
365,
1324,
1901,
282,
4306,
272,
334,
10244,
9,
315,
1177,
370,
314,
13035,
32035,
314,
1568,
402,
666,
370,
3618,
641,
272,
1449,
272,
671,
275,
485,
1451,
9856,
281,
8,
10244,
9,
272,
671,
14,
2184,
342,
272,
372,
671,
14,
2254,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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your views here.
from .models import Book, Author, BookInstance, Genre, Language
def index(request):
"""
View function for home page of site.
"""
# Generate counts of some of the main objects
num_books=Book.objects.all().count()
num_instances=BookInstance.objects.all().count()
# Available books (status = 'a')
num_instances_available=BookInstance.objects.filter(status__exact='a').count()
num_authors=Author.objects.count() # The 'all()' is implied by default.
# Number of visits to this view, as counted in the session variable.
num_visits=request.session.get('num_visits', 0)
request.session['num_visits'] = num_visits+1
# Render the HTML template index.html with the data in the context variable
return render(
request,
'index.html',
context={'num_books':num_books,'num_instances':num_instances,'num_instances_available':num_instances_available,'num_authors':num_authors,
'num_visits':num_visits}, # num_visits appended
)
# Chapter 6, creating class based view for books web page
from django.views import generic
class BookListView(generic.ListView):
model = Book
paginate_by = 10 # sets the number of list entries per page
class BookDetailView(generic.DetailView):
model = Book
class AuthorListView(generic.ListView):
model = Author
paginate_by = 10 # sets the number of list entries per page
class AuthorDetailView(generic.DetailView):
model = Author
from django.contrib.auth.mixins import LoginRequiredMixin
class LoanedBooksByUserListView(LoginRequiredMixin,generic.ListView):
"""
Generic class-based view listing books on loan to current user.
"""
model = BookInstance
template_name ='catalog/bookinstance_list_borrowed_user.html'
paginate_by = 10
def get_queryset(self):
return BookInstance.objects.filter(borrower=self.request.user).filter(status__exact='o').order_by('due_back')
# Added as part of challenge!
from django.contrib.auth.mixins import PermissionRequiredMixin
class LoanedBooksAllListView(PermissionRequiredMixin,generic.ListView):
"""
Generic class-based view listing all books on loan. Only visible to users with can_mark_returned permission.
"""
model = BookInstance
permission_required = 'catalog.can_mark_returned'
template_name ='catalog/bookinstance_list_borrowed_all.html'
paginate_by = 10
def get_queryset(self):
return BookInstance.objects.filter(status__exact='o').order_by('due_back')
from django.shortcuts import get_object_or_404
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
import datetime
from django.contrib.auth.decorators import permission_required
from .forms import RenewBookForm
@permission_required('catalog.can_mark_returned')
def renew_book_librarian(request, pk):
"""
View function for renewing a specific BookInstance by librarian
"""
book_inst=get_object_or_404(BookInstance, pk = pk)
# If this is a POST request then process the Form data
if request.method == 'POST':
# Create a form instance and populate it with data from the request (binding):
form = RenewBookForm(request.POST)
# Check if the form is valid:
if form.is_valid():
# process the data in form.cleaned_data as required (here we just write it to the model due_back field)
book_inst.due_back = form.cleaned_data['renewal_date']
book_inst.save()
# redirect to a new URL:
#return HttpResponseRedirect(reverse('all-borrowed') )
return HttpResponseRedirect(reverse('all-borrowed') )
# If this is a GET (or any other method) create the default form.
else:
proposed_renewal_date = datetime.date.today() + datetime.timedelta(weeks=3)
form = RenewBookForm(initial={'renewal_date': proposed_renewal_date,})
return render(request, 'catalog/book_renew_librarian.html', {'form': form, 'bookinst':book_inst})
# Create for for editing author by using django models
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy
from .models import Author
class AuthorCreate(CreateView):
model = Author
fields = '__all__'
initial={'date_of_death':'12/10/2016',}
class AuthorUpdate(UpdateView):
model = Author
fields = ['first_name','last_name','date_of_birth','date_of_death']
class AuthorDelete(DeleteView):
model = Author
success_url = reverse_lazy('authors')
|
cc0-1.0
|
[
504,
1639,
14,
17469,
492,
3795,
199,
199,
3,
2790,
2195,
6858,
2348,
14,
199,
199,
504,
1275,
992,
492,
8944,
12,
6529,
12,
8944,
3244,
12,
18870,
264,
12,
8466,
199,
199,
318,
1478,
8,
1069,
304,
272,
408,
272,
10935,
805,
367,
5629,
2034,
402,
4770,
14,
272,
408,
272,
327,
7958,
8242,
402,
2005,
402,
314,
2446,
2251,
272,
1967,
63,
8858,
29,
8696,
14,
1462,
14,
452,
1252,
835,
342,
272,
1967,
63,
5990,
29,
8696,
3244,
14,
1462,
14,
452,
1252,
835,
342,
272,
327,
23840,
19040,
334,
1205,
275,
283,
65,
358,
272,
1967,
63,
5990,
63,
4561,
29,
8696,
3244,
14,
1462,
14,
1541,
8,
1205,
363,
7327,
534,
65,
1959,
835,
342,
272,
1967,
63,
8149,
29,
5949,
14,
1462,
14,
835,
342,
221,
327,
710,
283,
452,
11716,
365,
2478,
701,
849,
14,
16872,
198,
3,
4860,
402,
1321,
30066,
370,
642,
2455,
12,
465,
31662,
315,
314,
2351,
1750,
14,
272,
1967,
63,
433,
30066,
29,
1069,
14,
1730,
14,
362,
360,
1507,
63,
433,
30066,
297,
378,
9,
272,
1056,
14,
1730,
459,
1507,
63,
433,
30066,
418,
275,
1967,
63,
433,
30066,
11,
17,
507,
272,
327,
17769,
314,
4163,
1978,
1478,
14,
1360,
543,
314,
666,
315,
314,
1067,
1750,
272,
372,
3795,
8,
267,
1056,
12,
267,
283,
1080,
14,
1360,
297,
267,
1067,
3713,
1507,
63,
8858,
356,
1507,
63,
8858,
2584,
1507,
63,
5990,
356,
1507,
63,
5990,
2584,
1507,
63,
5990,
63,
4561,
356,
1507,
63,
5990,
63,
4561,
2584,
1507,
63,
8149,
356,
1507,
63,
8149,
12,
288,
283,
1507,
63,
433,
30066,
356,
1507,
63,
433,
30066,
1386,
327,
1967,
63,
433,
30066,
11544,
272,
776,
199,
199,
3,
2799,
4185,
1227,
12,
6425,
1021,
4079,
2455,
367,
19040,
3330,
2034,
199,
504,
1639,
14,
4196,
492,
7809,
199,
199,
533,
8944,
23239,
8,
6767,
14,
23239,
304,
1362,
1402,
275,
8944,
1362,
9881,
23043,
63,
991,
275,
1616,
3322,
327,
5951,
314,
1329,
402,
769,
4811,
1126,
2034,
523,
199,
533,
8944,
28539,
8,
6767,
14,
28539,
304,
272,
1402,
275,
8944,
199,
199,
533,
6529,
23239,
8,
6767,
14,
23239,
304,
272,
1402,
275,
6529,
272,
9881,
23043,
63,
991,
275,
1616,
3322,
327,
5951,
314,
1329,
402,
769,
4811,
1126,
2034,
199,
199,
533,
6529,
28539,
8,
6767,
14,
28539,
304,
272,
1402,
275,
6529,
199,
199,
504,
1639,
14,
2828,
14,
1178,
14,
30192,
492,
16430,
8030,
4256,
199,
199,
533,
3835,
290,
379,
8696,
83,
2175,
1899,
23239,
8,
8880,
8030,
4256,
12,
6767,
14,
23239,
304,
272,
408,
272,
8307,
1021,
13,
6788,
2455,
13778,
19040,
641,
560,
290,
370,
1453,
922,
14,
5591,
408,
272,
1402,
275,
8944,
3244,
272,
1978,
63,
354,
275,
7,
7959,
15,
2706,
842,
63,
513,
63,
66,
19598,
379,
63,
751,
14,
1360,
7,
272,
9881,
23043,
63,
991,
275,
1616,
2286,
347,
664,
63,
7924,
8,
277,
304,
267,
372,
8944,
3244,
14,
1462,
14,
1541,
8,
66,
19598,
281,
29,
277,
14,
1069,
14,
751,
680,
1541,
8,
1205,
363,
7327,
534,
79,
1959,
1648,
63,
991,
360,
11933,
63,
894,
358,
199,
199,
3,
16230,
465,
1777,
402,
14929,
1,
199,
504,
1639,
14,
2828,
14,
1178,
14,
30192,
492,
8779,
8030,
4256,
199,
199,
533,
3835,
290,
379,
8696,
83,
2422,
23239,
8,
7980,
8030,
4256,
12,
6767,
14,
23239,
304,
272,
408,
272,
8307,
1021,
13,
6788,
2455,
13778,
1006,
19040,
641,
560,
290,
14,
5972,
8917,
370,
4390,
543,
883,
63,
1657,
63,
19065,
4983,
14,
272,
408,
272,
1402,
275,
8944,
3244,
272,
4983,
63,
2427,
275,
283,
7959,
14,
2425,
63,
1657,
63,
19065,
7,
272,
1978,
63,
354,
275,
7,
7959,
15,
2706,
842,
63,
513,
63,
66,
19598,
379,
63,
452,
14,
1360,
7,
272,
9881,
23043,
63,
991,
275,
1616,
2286,
347,
664,
63,
7924,
8,
277,
304,
267,
372,
8944,
3244,
14,
1462,
14,
1541,
8,
1205,
363,
7327,
534,
79,
1959,
1648,
63,
991,
360,
11933,
63,
894,
358,
257,
421,
199,
504,
1639,
14,
17469,
492,
664,
63,
785,
63,
269,
63,
5188,
199,
504,
1639,
14,
1014,
492,
14935,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
646,
2197,
199,
504,
1639,
14,
2828,
14,
1178,
14,
11582,
492,
4983,
63,
2427,
199,
199,
504,
1275,
3351,
492,
10055,
546,
8696,
2821,
199,
199,
32,
5693,
63,
2427,
360,
7959,
14,
2425,
63,
1657,
63,
19065,
358,
199,
318,
295,
1222,
63,
2706,
63,
773,
82,
15289,
8,
1069,
12,
3803,
304,
272,
408,
272,
10935,
805,
367,
295,
1222,
316,
282,
2488,
8944,
3244,
701,
1973,
82,
15289,
272,
408,
272,
6719,
63,
3615,
29,
362,
63,
785,
63,
269,
63,
5188,
8,
8696,
3244,
12,
3803,
275,
3803,
9,
339,
327,
982,
642,
365,
282,
8761,
1056,
2066,
2112,
314,
8204,
666,
272,
340,
1056,
14,
765,
508,
283,
4030,
356,
398,
327,
2790,
282,
1824,
1256,
436,
13904,
652,
543,
666,
687,
314,
1056,
334,
9140,
304,
267,
1824,
275,
10055,
546,
8696,
2821,
8,
1069,
14,
4030,
9,
398,
327,
2670,
340,
314,
1824,
365,
1686,
26,
267,
340,
1824,
14,
374,
63,
1078,
837,
288,
327,
2112,
314,
666,
315,
1824,
14,
8275,
63,
576,
465,
1415,
334,
1681,
781,
2951,
2218,
652,
370,
314,
1402,
7037,
63,
894,
901,
9,
288,
6719,
63,
3615,
14,
11933,
63,
894,
275,
1824,
14,
8275,
63,
576,
459,
30766,
279,
63,
602,
418,
288,
6719,
63,
3615,
14,
2117,
342,
953,
327,
4660,
370,
282,
892,
2851,
26,
288,
327,
1107,
14935,
8,
4471,
360,
452,
13,
66,
19598,
379,
358,
776,
288,
372,
14935,
8,
4471,
360,
452,
13,
66,
19598,
379,
358,
776,
339,
327,
982,
642,
365,
282,
9576,
334,
269,
1263,
1163,
1083,
9,
1218,
314,
849,
1824,
14,
272,
587,
26,
267,
14075,
63,
30766,
279,
63,
602,
275,
2197,
14,
602,
14,
8136,
342,
435,
2197,
14,
7473,
8,
25287,
29,
19,
9,
267,
1824,
275,
10055,
546,
8696,
2821,
8,
2747,
3713,
30766,
279,
63,
602,
356,
14075,
63,
30766,
279,
63,
602,
12,
1552
] |
[
1639,
14,
17469,
492,
3795,
199,
199,
3,
2790,
2195,
6858,
2348,
14,
199,
199,
504,
1275,
992,
492,
8944,
12,
6529,
12,
8944,
3244,
12,
18870,
264,
12,
8466,
199,
199,
318,
1478,
8,
1069,
304,
272,
408,
272,
10935,
805,
367,
5629,
2034,
402,
4770,
14,
272,
408,
272,
327,
7958,
8242,
402,
2005,
402,
314,
2446,
2251,
272,
1967,
63,
8858,
29,
8696,
14,
1462,
14,
452,
1252,
835,
342,
272,
1967,
63,
5990,
29,
8696,
3244,
14,
1462,
14,
452,
1252,
835,
342,
272,
327,
23840,
19040,
334,
1205,
275,
283,
65,
358,
272,
1967,
63,
5990,
63,
4561,
29,
8696,
3244,
14,
1462,
14,
1541,
8,
1205,
363,
7327,
534,
65,
1959,
835,
342,
272,
1967,
63,
8149,
29,
5949,
14,
1462,
14,
835,
342,
221,
327,
710,
283,
452,
11716,
365,
2478,
701,
849,
14,
16872,
198,
3,
4860,
402,
1321,
30066,
370,
642,
2455,
12,
465,
31662,
315,
314,
2351,
1750,
14,
272,
1967,
63,
433,
30066,
29,
1069,
14,
1730,
14,
362,
360,
1507,
63,
433,
30066,
297,
378,
9,
272,
1056,
14,
1730,
459,
1507,
63,
433,
30066,
418,
275,
1967,
63,
433,
30066,
11,
17,
507,
272,
327,
17769,
314,
4163,
1978,
1478,
14,
1360,
543,
314,
666,
315,
314,
1067,
1750,
272,
372,
3795,
8,
267,
1056,
12,
267,
283,
1080,
14,
1360,
297,
267,
1067,
3713,
1507,
63,
8858,
356,
1507,
63,
8858,
2584,
1507,
63,
5990,
356,
1507,
63,
5990,
2584,
1507,
63,
5990,
63,
4561,
356,
1507,
63,
5990,
63,
4561,
2584,
1507,
63,
8149,
356,
1507,
63,
8149,
12,
288,
283,
1507,
63,
433,
30066,
356,
1507,
63,
433,
30066,
1386,
327,
1967,
63,
433,
30066,
11544,
272,
776,
199,
199,
3,
2799,
4185,
1227,
12,
6425,
1021,
4079,
2455,
367,
19040,
3330,
2034,
199,
504,
1639,
14,
4196,
492,
7809,
199,
199,
533,
8944,
23239,
8,
6767,
14,
23239,
304,
1362,
1402,
275,
8944,
1362,
9881,
23043,
63,
991,
275,
1616,
3322,
327,
5951,
314,
1329,
402,
769,
4811,
1126,
2034,
523,
199,
533,
8944,
28539,
8,
6767,
14,
28539,
304,
272,
1402,
275,
8944,
199,
199,
533,
6529,
23239,
8,
6767,
14,
23239,
304,
272,
1402,
275,
6529,
272,
9881,
23043,
63,
991,
275,
1616,
3322,
327,
5951,
314,
1329,
402,
769,
4811,
1126,
2034,
199,
199,
533,
6529,
28539,
8,
6767,
14,
28539,
304,
272,
1402,
275,
6529,
199,
199,
504,
1639,
14,
2828,
14,
1178,
14,
30192,
492,
16430,
8030,
4256,
199,
199,
533,
3835,
290,
379,
8696,
83,
2175,
1899,
23239,
8,
8880,
8030,
4256,
12,
6767,
14,
23239,
304,
272,
408,
272,
8307,
1021,
13,
6788,
2455,
13778,
19040,
641,
560,
290,
370,
1453,
922,
14,
5591,
408,
272,
1402,
275,
8944,
3244,
272,
1978,
63,
354,
275,
7,
7959,
15,
2706,
842,
63,
513,
63,
66,
19598,
379,
63,
751,
14,
1360,
7,
272,
9881,
23043,
63,
991,
275,
1616,
2286,
347,
664,
63,
7924,
8,
277,
304,
267,
372,
8944,
3244,
14,
1462,
14,
1541,
8,
66,
19598,
281,
29,
277,
14,
1069,
14,
751,
680,
1541,
8,
1205,
363,
7327,
534,
79,
1959,
1648,
63,
991,
360,
11933,
63,
894,
358,
199,
199,
3,
16230,
465,
1777,
402,
14929,
1,
199,
504,
1639,
14,
2828,
14,
1178,
14,
30192,
492,
8779,
8030,
4256,
199,
199,
533,
3835,
290,
379,
8696,
83,
2422,
23239,
8,
7980,
8030,
4256,
12,
6767,
14,
23239,
304,
272,
408,
272,
8307,
1021,
13,
6788,
2455,
13778,
1006,
19040,
641,
560,
290,
14,
5972,
8917,
370,
4390,
543,
883,
63,
1657,
63,
19065,
4983,
14,
272,
408,
272,
1402,
275,
8944,
3244,
272,
4983,
63,
2427,
275,
283,
7959,
14,
2425,
63,
1657,
63,
19065,
7,
272,
1978,
63,
354,
275,
7,
7959,
15,
2706,
842,
63,
513,
63,
66,
19598,
379,
63,
452,
14,
1360,
7,
272,
9881,
23043,
63,
991,
275,
1616,
2286,
347,
664,
63,
7924,
8,
277,
304,
267,
372,
8944,
3244,
14,
1462,
14,
1541,
8,
1205,
363,
7327,
534,
79,
1959,
1648,
63,
991,
360,
11933,
63,
894,
358,
257,
421,
199,
504,
1639,
14,
17469,
492,
664,
63,
785,
63,
269,
63,
5188,
199,
504,
1639,
14,
1014,
492,
14935,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
646,
2197,
199,
504,
1639,
14,
2828,
14,
1178,
14,
11582,
492,
4983,
63,
2427,
199,
199,
504,
1275,
3351,
492,
10055,
546,
8696,
2821,
199,
199,
32,
5693,
63,
2427,
360,
7959,
14,
2425,
63,
1657,
63,
19065,
358,
199,
318,
295,
1222,
63,
2706,
63,
773,
82,
15289,
8,
1069,
12,
3803,
304,
272,
408,
272,
10935,
805,
367,
295,
1222,
316,
282,
2488,
8944,
3244,
701,
1973,
82,
15289,
272,
408,
272,
6719,
63,
3615,
29,
362,
63,
785,
63,
269,
63,
5188,
8,
8696,
3244,
12,
3803,
275,
3803,
9,
339,
327,
982,
642,
365,
282,
8761,
1056,
2066,
2112,
314,
8204,
666,
272,
340,
1056,
14,
765,
508,
283,
4030,
356,
398,
327,
2790,
282,
1824,
1256,
436,
13904,
652,
543,
666,
687,
314,
1056,
334,
9140,
304,
267,
1824,
275,
10055,
546,
8696,
2821,
8,
1069,
14,
4030,
9,
398,
327,
2670,
340,
314,
1824,
365,
1686,
26,
267,
340,
1824,
14,
374,
63,
1078,
837,
288,
327,
2112,
314,
666,
315,
1824,
14,
8275,
63,
576,
465,
1415,
334,
1681,
781,
2951,
2218,
652,
370,
314,
1402,
7037,
63,
894,
901,
9,
288,
6719,
63,
3615,
14,
11933,
63,
894,
275,
1824,
14,
8275,
63,
576,
459,
30766,
279,
63,
602,
418,
288,
6719,
63,
3615,
14,
2117,
342,
953,
327,
4660,
370,
282,
892,
2851,
26,
288,
327,
1107,
14935,
8,
4471,
360,
452,
13,
66,
19598,
379,
358,
776,
288,
372,
14935,
8,
4471,
360,
452,
13,
66,
19598,
379,
358,
776,
339,
327,
982,
642,
365,
282,
9576,
334,
269,
1263,
1163,
1083,
9,
1218,
314,
849,
1824,
14,
272,
587,
26,
267,
14075,
63,
30766,
279,
63,
602,
275,
2197,
14,
602,
14,
8136,
342,
435,
2197,
14,
7473,
8,
25287,
29,
19,
9,
267,
1824,
275,
10055,
546,
8696,
2821,
8,
2747,
3713,
30766,
279,
63,
602,
356,
14075,
63,
30766,
279,
63,
602,
12,
1552,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
karyon/django
|
django/core/management/commands/squashmigrations.py
|
162
|
8767
|
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.db import DEFAULT_DB_ALIAS, connections, migrations
from django.db.migrations.loader import AmbiguityError, MigrationLoader
from django.db.migrations.migration import SwappableTuple
from django.db.migrations.optimizer import MigrationOptimizer
from django.db.migrations.writer import MigrationWriter
from django.utils import six
from django.utils.version import get_docs_version
class Command(BaseCommand):
help = "Squashes an existing set of migrations (from first until specified) into a single new one."
def add_arguments(self, parser):
parser.add_argument('app_label',
help='App label of the application to squash migrations for.')
parser.add_argument('start_migration_name', default=None, nargs='?',
help='Migrations will be squashed starting from and including this migration.')
parser.add_argument('migration_name',
help='Migrations will be squashed until and including this migration.')
parser.add_argument('--no-optimize', action='store_true', dest='no_optimize', default=False,
help='Do not try to optimize the squashed operations.')
parser.add_argument('--noinput', '--no-input',
action='store_false', dest='interactive', default=True,
help='Tells Django to NOT prompt the user for input of any kind.')
def handle(self, **options):
self.verbosity = options.get('verbosity')
self.interactive = options.get('interactive')
app_label = options['app_label']
start_migration_name = options['start_migration_name']
migration_name = options['migration_name']
no_optimize = options['no_optimize']
# Load the current graph state, check the app and migration they asked for exists
loader = MigrationLoader(connections[DEFAULT_DB_ALIAS])
if app_label not in loader.migrated_apps:
raise CommandError(
"App '%s' does not have migrations (so squashmigrations on "
"it makes no sense)" % app_label
)
migration = self.find_migration(loader, app_label, migration_name)
# Work out the list of predecessor migrations
migrations_to_squash = [
loader.get_migration(al, mn)
for al, mn in loader.graph.forwards_plan((migration.app_label, migration.name))
if al == migration.app_label
]
if start_migration_name:
start_migration = self.find_migration(loader, app_label, start_migration_name)
start = loader.get_migration(start_migration.app_label, start_migration.name)
try:
start_index = migrations_to_squash.index(start)
migrations_to_squash = migrations_to_squash[start_index:]
except ValueError:
raise CommandError(
"The migration '%s' cannot be found. Maybe it comes after "
"the migration '%s'?\n"
"Have a look at:\n"
" python manage.py showmigrations %s\n"
"to debug this issue." % (start_migration, migration, app_label)
)
# Tell them what we're doing and optionally ask if we should proceed
if self.verbosity > 0 or self.interactive:
self.stdout.write(self.style.MIGRATE_HEADING("Will squash the following migrations:"))
for migration in migrations_to_squash:
self.stdout.write(" - %s" % migration.name)
if self.interactive:
answer = None
while not answer or answer not in "yn":
answer = six.moves.input("Do you wish to proceed? [yN] ")
if not answer:
answer = "n"
break
else:
answer = answer[0].lower()
if answer != "y":
return
# Load the operations from all those migrations and concat together,
# along with collecting external dependencies and detecting
# double-squashing
operations = []
dependencies = set()
# We need to take all dependencies from the first migration in the list
# as it may be 0002 depending on 0001
first_migration = True
for smigration in migrations_to_squash:
if smigration.replaces:
raise CommandError(
"You cannot squash squashed migrations! Please transition "
"it to a normal migration first: "
"https://docs.djangoproject.com/en/%s/topics/migrations/#squashing-migrations" % get_docs_version()
)
operations.extend(smigration.operations)
for dependency in smigration.dependencies:
if isinstance(dependency, SwappableTuple):
if settings.AUTH_USER_MODEL == dependency.setting:
dependencies.add(("__setting__", "AUTH_USER_MODEL"))
else:
dependencies.add(dependency)
elif dependency[0] != smigration.app_label or first_migration:
dependencies.add(dependency)
first_migration = False
if no_optimize:
if self.verbosity > 0:
self.stdout.write(self.style.MIGRATE_HEADING("(Skipping optimization.)"))
new_operations = operations
else:
if self.verbosity > 0:
self.stdout.write(self.style.MIGRATE_HEADING("Optimizing..."))
optimizer = MigrationOptimizer()
new_operations = optimizer.optimize(operations, migration.app_label)
if self.verbosity > 0:
if len(new_operations) == len(operations):
self.stdout.write(" No optimizations possible.")
else:
self.stdout.write(
" Optimized from %s operations to %s operations." %
(len(operations), len(new_operations))
)
# Work out the value of replaces (any squashed ones we're re-squashing)
# need to feed their replaces into ours
replaces = []
for migration in migrations_to_squash:
if migration.replaces:
replaces.extend(migration.replaces)
else:
replaces.append((migration.app_label, migration.name))
# Make a new migration with those operations
subclass = type("Migration", (migrations.Migration, ), {
"dependencies": dependencies,
"operations": new_operations,
"replaces": replaces,
})
if start_migration_name:
new_migration = subclass("%s_squashed_%s" % (start_migration.name, migration.name), app_label)
else:
new_migration = subclass("0001_squashed_%s" % migration.name, app_label)
new_migration.initial = True
# Write out the new migration file
writer = MigrationWriter(new_migration)
with open(writer.path, "wb") as fh:
fh.write(writer.as_string())
if self.verbosity > 0:
self.stdout.write(self.style.MIGRATE_HEADING("Created new squashed migration %s" % writer.path))
self.stdout.write(" You should commit this migration but leave the old ones in place;")
self.stdout.write(" the new migration will be used for new installs. Once you are sure")
self.stdout.write(" all instances of the codebase have applied the migrations you squashed,")
self.stdout.write(" you can delete them.")
if writer.needs_manual_porting:
self.stdout.write(self.style.MIGRATE_HEADING("Manual porting required"))
self.stdout.write(" Your migrations contained functions that must be manually copied over,")
self.stdout.write(" as we could not safely copy their implementation.")
self.stdout.write(" See the comment at the top of the squashed migration for details.")
def find_migration(self, loader, app_label, name):
try:
return loader.get_migration_by_prefix(app_label, name)
except AmbiguityError:
raise CommandError(
"More than one migration matches '%s' in app '%s'. Please be "
"more specific." % (name, app_label)
)
except KeyError:
raise CommandError(
"Cannot find a migration matching '%s' from app '%s'." %
(name, app_label)
)
|
bsd-3-clause
|
[
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
12,
14393,
199,
504,
1639,
14,
697,
492,
6186,
63,
2846,
63,
12644,
12,
6947,
12,
6180,
199,
504,
1639,
14,
697,
14,
7685,
14,
3422,
492,
437,
887,
528,
24180,
547,
12,
12090,
5455,
199,
504,
1639,
14,
697,
14,
7685,
14,
8998,
492,
16666,
20846,
7075,
199,
504,
1639,
14,
697,
14,
7685,
14,
12290,
492,
12090,
13946,
199,
504,
1639,
14,
697,
14,
7685,
14,
5491,
492,
12090,
6261,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
1023,
492,
664,
63,
4757,
63,
1023,
421,
199,
533,
5817,
8,
25150,
304,
272,
1720,
275,
298,
51,
392,
9030,
376,
3411,
663,
402,
6180,
334,
504,
1642,
5133,
2013,
9,
1901,
282,
2849,
892,
1373,
2122,
339,
347,
1050,
63,
4958,
8,
277,
12,
1798,
304,
267,
1798,
14,
525,
63,
2094,
360,
571,
63,
1302,
297,
288,
1720,
534,
2640,
1768,
402,
314,
4223,
370,
12345,
1119,
6180,
367,
2659,
267,
1798,
14,
525,
63,
2094,
360,
928,
63,
8998,
63,
354,
297,
849,
29,
403,
12,
9237,
31468,
288,
1720,
534,
19322,
3801,
911,
506,
12345,
21189,
6617,
687,
436,
5893,
642,
8367,
2659,
267,
1798,
14,
525,
63,
2094,
360,
8998,
63,
354,
297,
288,
1720,
534,
19322,
3801,
911,
506,
12345,
21189,
5133,
436,
5893,
642,
8367,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
889,
13,
13416,
297,
1595,
534,
1617,
63,
2052,
297,
2053,
534,
889,
63,
13416,
297,
849,
29,
797,
12,
288,
1720,
534,
2585,
440,
862,
370,
13497,
314,
12345,
21189,
5331,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
889,
1210,
297,
2850,
889,
13,
1210,
297,
288,
1595,
534,
1617,
63,
3910,
297,
2053,
534,
13543,
297,
849,
29,
549,
12,
288,
1720,
534,
52,
6840,
5634,
370,
2845,
8457,
314,
922,
367,
1324,
402,
1263,
4928,
2659,
339,
347,
2429,
8,
277,
12,
1011,
1419,
304,
398,
291,
14,
9833,
275,
1511,
14,
362,
360,
9833,
358,
267,
291,
14,
13543,
275,
1511,
14,
362,
360,
13543,
358,
267,
1145,
63,
1302,
275,
1511,
459,
571,
63,
1302,
418,
267,
1343,
63,
8998,
63,
354,
275,
1511,
459,
928,
63,
8998,
63,
354,
418,
267,
8367,
63,
354,
275,
1511,
459,
8998,
63,
354,
418,
267,
949,
63,
13416,
275,
1511,
459,
889,
63,
13416,
418,
398,
327,
7190,
314,
1453,
3343,
1174,
12,
1104,
314,
1145,
436,
8367,
2985,
20864,
367,
3495,
267,
5077,
275,
12090,
5455,
8,
7995,
59,
3472,
63,
2846,
63,
12644,
566,
267,
340,
1145,
63,
1302,
440,
315,
5077,
14,
31544,
63,
5181,
26,
288,
746,
14393,
8,
355,
298,
2640,
1543,
83,
7,
1630,
440,
1172,
6180,
334,
1152,
12345,
1119,
7685,
641,
298,
355,
298,
390,
7704,
949,
12249,
2924,
450,
1145,
63,
1302,
288,
776,
398,
8367,
275,
291,
14,
1623,
63,
8998,
8,
3422,
12,
1145,
63,
1302,
12,
8367,
63,
354,
9,
398,
327,
9361,
734,
314,
769,
402,
876,
27914,
269,
6180,
267,
6180,
63,
475,
63,
8471,
1119,
275,
359,
288,
5077,
14,
362,
63,
8998,
8,
279,
12,
21945,
9,
288,
367,
741,
12,
21945,
315,
5077,
14,
2180,
14,
19159,
63,
5140,
1332,
8998,
14,
571,
63,
1302,
12,
8367,
14,
354,
430,
288,
340,
741,
508,
8367,
14,
571,
63,
1302,
267,
1622,
398,
340,
1343,
63,
8998,
63,
354,
26,
288,
1343,
63,
8998,
275,
291,
14,
1623,
63,
8998,
8,
3422,
12,
1145,
63,
1302,
12,
1343,
63,
8998,
63,
354,
9,
288,
1343,
275,
5077,
14,
362,
63,
8998,
8,
928,
63,
8998,
14,
571,
63,
1302,
12,
1343,
63,
8998,
14,
354,
9,
288,
862,
26,
355,
1343,
63,
1080,
275,
6180,
63,
475,
63,
8471,
1119,
14,
1080,
8,
928,
9,
355,
6180,
63,
475,
63,
8471,
1119,
275,
6180,
63,
475,
63,
8471,
1119,
59,
928,
63,
1080,
2938,
288,
871,
1722,
26,
355,
746,
14393,
8,
490,
298,
1918,
8367,
1543,
83,
7,
3913,
506,
1911,
14,
23038,
652,
12477,
2410,
298,
490,
298,
1589,
8367,
1543,
83,
7,
8995,
78,
2,
490,
298,
40,
811,
282,
3648,
737,
3427,
78,
2,
490,
298,
221,
2366,
9635,
14,
647,
2498,
7685,
450,
83,
60,
78,
2,
490,
298,
475,
3105,
642,
4976,
2122,
450,
334,
928,
63,
8998,
12,
8367,
12,
1145,
63,
1302,
9,
355,
776,
398,
327,
30528,
3062,
4052,
781,
3984,
9689,
436,
14190,
7198,
340,
781,
1077,
20320,
267,
340,
291,
14,
9833,
690,
378,
503,
291,
14,
13543,
26,
288,
291,
14,
2703,
14,
952,
8,
277,
14,
2487,
14,
22487,
16553,
63,
5211,
1206,
480,
20326,
12345,
1119,
314,
2569,
6180,
26,
2237,
288,
367,
8367,
315,
6180,
63,
475,
63,
8471,
1119,
26,
355,
291,
14,
2703,
14,
952,
480,
446,
450,
83,
2,
450,
8367,
14,
354,
9,
953,
340,
291,
14,
13543,
26,
355,
6385,
275,
488,
355,
1830,
440,
6385,
503,
6385,
440,
315,
298,
1236,
582,
490,
6385,
275,
3816,
14,
4912,
14,
1210,
480,
2585,
1265,
13809,
370,
20320,
31,
359,
89,
46,
61,
6099,
490,
340,
440,
6385,
26,
717,
6385,
275,
298,
78,
2,
717,
2059,
490,
587,
26,
717,
6385,
275,
6385,
59,
16,
1055,
2325,
342,
355,
340,
6385,
1137,
298,
89,
582,
490,
372,
398,
327,
7190,
314,
5331,
687,
1006,
5204,
6180,
436,
17159,
10451,
12,
267,
327,
3180,
543,
32223,
5957,
5124,
436,
9696,
316,
267,
327,
4270,
13,
8471,
1119,
316,
267,
5331,
275,
942,
267,
5124,
275,
663,
342,
267,
327,
2136,
1929,
370,
5452,
1006,
5124,
687,
314,
1642,
8367,
315,
314,
769,
267,
327,
465,
652,
1443,
506,
378,
7432,
10298,
641,
378,
4587,
267,
1642,
63,
8998,
275,
715,
267,
367,
308,
8998,
315,
6180,
63,
475,
63,
8471,
1119,
26,
288,
340,
308,
8998,
14,
1155,
5862,
26,
355,
746,
14393,
8,
490,
298,
5556,
3913,
12345,
1119,
12345,
21189,
6180,
1,
7754,
14116,
298,
490,
298,
390,
370,
282,
3293,
8367,
1642,
26,
298,
490,
298,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
3149,
83,
15,
11299
] |
[
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
12,
14393,
199,
504,
1639,
14,
697,
492,
6186,
63,
2846,
63,
12644,
12,
6947,
12,
6180,
199,
504,
1639,
14,
697,
14,
7685,
14,
3422,
492,
437,
887,
528,
24180,
547,
12,
12090,
5455,
199,
504,
1639,
14,
697,
14,
7685,
14,
8998,
492,
16666,
20846,
7075,
199,
504,
1639,
14,
697,
14,
7685,
14,
12290,
492,
12090,
13946,
199,
504,
1639,
14,
697,
14,
7685,
14,
5491,
492,
12090,
6261,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
1023,
492,
664,
63,
4757,
63,
1023,
421,
199,
533,
5817,
8,
25150,
304,
272,
1720,
275,
298,
51,
392,
9030,
376,
3411,
663,
402,
6180,
334,
504,
1642,
5133,
2013,
9,
1901,
282,
2849,
892,
1373,
2122,
339,
347,
1050,
63,
4958,
8,
277,
12,
1798,
304,
267,
1798,
14,
525,
63,
2094,
360,
571,
63,
1302,
297,
288,
1720,
534,
2640,
1768,
402,
314,
4223,
370,
12345,
1119,
6180,
367,
2659,
267,
1798,
14,
525,
63,
2094,
360,
928,
63,
8998,
63,
354,
297,
849,
29,
403,
12,
9237,
31468,
288,
1720,
534,
19322,
3801,
911,
506,
12345,
21189,
6617,
687,
436,
5893,
642,
8367,
2659,
267,
1798,
14,
525,
63,
2094,
360,
8998,
63,
354,
297,
288,
1720,
534,
19322,
3801,
911,
506,
12345,
21189,
5133,
436,
5893,
642,
8367,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
889,
13,
13416,
297,
1595,
534,
1617,
63,
2052,
297,
2053,
534,
889,
63,
13416,
297,
849,
29,
797,
12,
288,
1720,
534,
2585,
440,
862,
370,
13497,
314,
12345,
21189,
5331,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
889,
1210,
297,
2850,
889,
13,
1210,
297,
288,
1595,
534,
1617,
63,
3910,
297,
2053,
534,
13543,
297,
849,
29,
549,
12,
288,
1720,
534,
52,
6840,
5634,
370,
2845,
8457,
314,
922,
367,
1324,
402,
1263,
4928,
2659,
339,
347,
2429,
8,
277,
12,
1011,
1419,
304,
398,
291,
14,
9833,
275,
1511,
14,
362,
360,
9833,
358,
267,
291,
14,
13543,
275,
1511,
14,
362,
360,
13543,
358,
267,
1145,
63,
1302,
275,
1511,
459,
571,
63,
1302,
418,
267,
1343,
63,
8998,
63,
354,
275,
1511,
459,
928,
63,
8998,
63,
354,
418,
267,
8367,
63,
354,
275,
1511,
459,
8998,
63,
354,
418,
267,
949,
63,
13416,
275,
1511,
459,
889,
63,
13416,
418,
398,
327,
7190,
314,
1453,
3343,
1174,
12,
1104,
314,
1145,
436,
8367,
2985,
20864,
367,
3495,
267,
5077,
275,
12090,
5455,
8,
7995,
59,
3472,
63,
2846,
63,
12644,
566,
267,
340,
1145,
63,
1302,
440,
315,
5077,
14,
31544,
63,
5181,
26,
288,
746,
14393,
8,
355,
298,
2640,
1543,
83,
7,
1630,
440,
1172,
6180,
334,
1152,
12345,
1119,
7685,
641,
298,
355,
298,
390,
7704,
949,
12249,
2924,
450,
1145,
63,
1302,
288,
776,
398,
8367,
275,
291,
14,
1623,
63,
8998,
8,
3422,
12,
1145,
63,
1302,
12,
8367,
63,
354,
9,
398,
327,
9361,
734,
314,
769,
402,
876,
27914,
269,
6180,
267,
6180,
63,
475,
63,
8471,
1119,
275,
359,
288,
5077,
14,
362,
63,
8998,
8,
279,
12,
21945,
9,
288,
367,
741,
12,
21945,
315,
5077,
14,
2180,
14,
19159,
63,
5140,
1332,
8998,
14,
571,
63,
1302,
12,
8367,
14,
354,
430,
288,
340,
741,
508,
8367,
14,
571,
63,
1302,
267,
1622,
398,
340,
1343,
63,
8998,
63,
354,
26,
288,
1343,
63,
8998,
275,
291,
14,
1623,
63,
8998,
8,
3422,
12,
1145,
63,
1302,
12,
1343,
63,
8998,
63,
354,
9,
288,
1343,
275,
5077,
14,
362,
63,
8998,
8,
928,
63,
8998,
14,
571,
63,
1302,
12,
1343,
63,
8998,
14,
354,
9,
288,
862,
26,
355,
1343,
63,
1080,
275,
6180,
63,
475,
63,
8471,
1119,
14,
1080,
8,
928,
9,
355,
6180,
63,
475,
63,
8471,
1119,
275,
6180,
63,
475,
63,
8471,
1119,
59,
928,
63,
1080,
2938,
288,
871,
1722,
26,
355,
746,
14393,
8,
490,
298,
1918,
8367,
1543,
83,
7,
3913,
506,
1911,
14,
23038,
652,
12477,
2410,
298,
490,
298,
1589,
8367,
1543,
83,
7,
8995,
78,
2,
490,
298,
40,
811,
282,
3648,
737,
3427,
78,
2,
490,
298,
221,
2366,
9635,
14,
647,
2498,
7685,
450,
83,
60,
78,
2,
490,
298,
475,
3105,
642,
4976,
2122,
450,
334,
928,
63,
8998,
12,
8367,
12,
1145,
63,
1302,
9,
355,
776,
398,
327,
30528,
3062,
4052,
781,
3984,
9689,
436,
14190,
7198,
340,
781,
1077,
20320,
267,
340,
291,
14,
9833,
690,
378,
503,
291,
14,
13543,
26,
288,
291,
14,
2703,
14,
952,
8,
277,
14,
2487,
14,
22487,
16553,
63,
5211,
1206,
480,
20326,
12345,
1119,
314,
2569,
6180,
26,
2237,
288,
367,
8367,
315,
6180,
63,
475,
63,
8471,
1119,
26,
355,
291,
14,
2703,
14,
952,
480,
446,
450,
83,
2,
450,
8367,
14,
354,
9,
953,
340,
291,
14,
13543,
26,
355,
6385,
275,
488,
355,
1830,
440,
6385,
503,
6385,
440,
315,
298,
1236,
582,
490,
6385,
275,
3816,
14,
4912,
14,
1210,
480,
2585,
1265,
13809,
370,
20320,
31,
359,
89,
46,
61,
6099,
490,
340,
440,
6385,
26,
717,
6385,
275,
298,
78,
2,
717,
2059,
490,
587,
26,
717,
6385,
275,
6385,
59,
16,
1055,
2325,
342,
355,
340,
6385,
1137,
298,
89,
582,
490,
372,
398,
327,
7190,
314,
5331,
687,
1006,
5204,
6180,
436,
17159,
10451,
12,
267,
327,
3180,
543,
32223,
5957,
5124,
436,
9696,
316,
267,
327,
4270,
13,
8471,
1119,
316,
267,
5331,
275,
942,
267,
5124,
275,
663,
342,
267,
327,
2136,
1929,
370,
5452,
1006,
5124,
687,
314,
1642,
8367,
315,
314,
769,
267,
327,
465,
652,
1443,
506,
378,
7432,
10298,
641,
378,
4587,
267,
1642,
63,
8998,
275,
715,
267,
367,
308,
8998,
315,
6180,
63,
475,
63,
8471,
1119,
26,
288,
340,
308,
8998,
14,
1155,
5862,
26,
355,
746,
14393,
8,
490,
298,
5556,
3913,
12345,
1119,
12345,
21189,
6180,
1,
7754,
14116,
298,
490,
298,
390,
370,
282,
3293,
8367,
1642,
26,
298,
490,
298,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
3149,
83,
15,
11299,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
berguner/svmap
|
assemble.py
|
1
|
6568
|
import sys
import shutil
import subprocess
import argparse
import os
import commands
from multiprocessing import Pool
parser = argparse.ArgumentParser(description='Assemble reads extracted from each region')
parser.add_argument('--bed', help='.bed file of SV regions', type=str)
parser.add_argument('--dipspades', help='Path of dipspades.py', type=str)
parser.add_argument('--velvetg', help='Path of velvetg executable', type=str)
parser.add_argument('--velveth', help='Path of velveth executable', type=str)
parser.add_argument('--abyss', help='Path of abyss-pe executable', type=str, default=1)
parser.add_argument('-t', help='# of threads', type=int)
parser.add_argument('-o', help='Path for working folder', default=os.getcwd(), type=str)
args = parser.parse_args()
def assemble(line):
array = line.rstrip('\n').split('\t')
title = '_'.join(array)
try:
folder = os.path.join(args.o, array[4], array[5], title)
sys.stderr.write(folder + "\n")
if os.path.exists(os.path.join(folder, "unpaired.fq.gz")) and args.dipspades:
sys.stderr.write("Running dipspades\n")
ps = subprocess.Popen(('python', args.dipspades, '-1', os.path.join(folder, 'read1.fq.gz'), '-2',
os.path.join(folder, 'read2.fq.gz'),
'-s', os.path.join(folder, 'unpaired.fq.gz'), '--expect-rearrangements', '--cov-cutoff', '3',
'-o', os.path.join(folder, 'dipspades')),
stdout=open(os.path.join(folder, 'dipspades.log'), 'w'),
stderr=open(os.path.join(folder, 'dipspades.err'), 'w'))
result = ps.wait()
if result != 0: sys.stderr.write("Couldn't run dipspades\n")
else:
os.rename(os.path.join(folder, 'dipspades/dipspades/consensus_contigs.fasta'),os.path.join(folder, 'dipspades.fasta'))
os.rename(os.path.join(folder, 'dipspades/spades/scaffolds.fasta'),os.path.join(folder, 'spades.fasta'))
shutil.rmtree(os.path.join(folder, 'dipspades'))
elif args.dipspades:
sys.stderr.write("Running dipspades\n")
ps = subprocess.Popen(('python', args.dipspades, '-1', os.path.join(folder, 'read1.fq.gz'), '-2',
os.path.join(folder, 'read2.fq.gz'),
'--expect-rearrangements', '--cov-cutoff', '3', '-o', os.path.join(folder, 'dipspades')),
stdout=open(os.path.join(folder, 'dipspades.log'), 'w'),
stderr=open(os.path.join(folder, 'dipspades.err'), 'w'))
result = ps.wait()
if result != 0: sys.stderr.write("Couldn't run dipspades\n")
else:
os.rename(os.path.join(folder, 'dipspades/dipspades/consensus_contigs.fasta'),os.path.join(folder, 'dipspades.fasta'))
os.rename(os.path.join(folder, 'dipspades/spades/scaffolds.fasta'),os.path.join(folder, 'spades.fasta'))
shutil.rmtree(os.path.join(folder, 'dipspades'))
if args.velvetg and args.velveth:
sys.stderr.write("Running velveth\n")
ps = subprocess.Popen(
(args.velveth, os.path.join(folder, 'velvet'), '31', '-shortPaired', '-separate', '-fastq.gz',
os.path.join(folder, 'read1.fq.gz'), os.path.join(folder, 'read2.fq.gz')),
stdout=open(os.path.join(folder, 'velveth.log'), 'w'),
stderr=open(os.path.join(folder, 'velveth.err'), 'w'))
result = ps.wait()
if result != 0: sys.stderr.write("Couldn't run velveth\n")
sys.stderr.write("Running velvetg\n")
ps = subprocess.Popen(
(args.velvetg, os.path.join(folder, 'velvet'), '-scaffolding', 'yes', '-very_clean', 'yes'),
stdout=open(os.path.join(folder, 'velveth.log'), 'w'),
stderr=open(os.path.join(folder, 'velveth.err'), 'w'))
result = ps.wait()
if result != 0: sys.stderr.write("Couldn't run velvetg\n")
else:
os.rename(os.path.join(folder, 'velvet/contigs.fa'), os.path.join(folder, 'velvet.fasta'))
if os.path.exists(os.path.join(folder, "unpaired.fq.gz")) and args.abyss:
if os.path.exists(os.path.join(folder, 'abyss')):
shutil.rmtree(os.path.join(folder, 'abyss'))
os.mkdir(os.path.join(folder, 'abyss'))
else:
os.mkdir(os.path.join(folder, 'abyss'))
sys.stderr.write("Running abyss\n")
cmd = args.abyss + ' name=' + title + ' k=64 in=\'../read1.fq.gz ../read2.fq.gz\' se=\'../unpaired.fq.gz\' --directory=' + os.path.join(
folder, 'abyss')
logfile = open(os.path.join(folder, 'abyss.log'), 'w')
result = commands.getstatusoutput(cmd)
logfile.write(result[1])
if result[0] != 0: sys.stderr.write("Couldn't run abyss\n")
else:
shutil.copy2(os.path.join(folder, 'abyss/' + title + '-scaffolds.fa'), os.path.join(folder, 'abyss.fasta'))
shutil.rmtree(os.path.join(folder, 'abyss'))
elif args.abyss:
if os.path.exists(os.path.join(folder, 'abyss')):
shutil.rmtree(os.path.join(folder, 'abyss'))
os.mkdir(os.path.join(folder, 'abyss'))
else:
os.mkdir(os.path.join(folder, 'abyss'))
sys.stderr.write("Running abyss\n")
cmd = args.abyss + ' name=' + title + ' k=64 in=\'../read1.fq.gz ../read2.fq.gz\' --directory=' + os.path.join(
folder, 'abyss')
logfile = open(os.path.join(folder, 'abyss.log'), 'w')
result = commands.getstatusoutput(cmd)
logfile.write(result[1])
if result[0] != 0: sys.stderr.write("Couldn't run abyss\n")
else:
shutil.copy2(os.path.join(folder, 'abyss/' + title + '-scaffolds.fa'), os.path.join(folder, 'abyss.fasta'))
shutil.rmtree(os.path.join(folder, 'abyss'))
except:
sys.stderr.write("failed this region " + title +"\n")
def main():
bed = open(args.bed, 'r')
header = bed.readline()
lines = []
line = bed.readline()
while len(line) > 3:
lines.append(line)
#assemble(line)
line = bed.readline()
pool = Pool(args.t)
pool.map(assemble,lines)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
646,
984,
199,
646,
5145,
199,
646,
3873,
199,
646,
7534,
199,
646,
747,
199,
646,
3718,
199,
504,
12866,
492,
15553,
199,
199,
2087,
275,
7534,
14,
10730,
8,
1802,
534,
31054,
11597,
12509,
687,
1924,
4897,
358,
199,
2087,
14,
525,
63,
2094,
4517,
6123,
297,
1720,
15637,
6123,
570,
402,
14056,
16150,
297,
730,
29,
495,
9,
199,
2087,
14,
525,
63,
2094,
4517,
328,
1190,
387,
3424,
297,
1720,
534,
2042,
402,
487,
1190,
387,
3424,
14,
647,
297,
730,
29,
495,
9,
199,
2087,
14,
525,
63,
2094,
4517,
1090,
28350,
71,
297,
1720,
534,
2042,
402,
373,
352,
28350,
71,
7286,
297,
730,
29,
495,
9,
199,
2087,
14,
525,
63,
2094,
4517,
1090,
432,
273,
297,
1720,
534,
2042,
402,
373,
15320,
273,
7286,
297,
730,
29,
495,
9,
199,
2087,
14,
525,
63,
2094,
4517,
17585,
385,
297,
1720,
534,
2042,
402,
282,
991,
385,
13,
321,
7286,
297,
730,
29,
495,
12,
849,
29,
17,
9,
199,
2087,
14,
525,
63,
2094,
3654,
84,
297,
1720,
26431,
402,
7183,
297,
730,
29,
442,
9,
199,
2087,
14,
525,
63,
2094,
3654,
79,
297,
1720,
534,
2042,
367,
6449,
4922,
297,
849,
29,
736,
14,
9458,
1062,
730,
29,
495,
9,
199,
199,
589,
275,
1798,
14,
1122,
63,
589,
342,
199,
199,
318,
22931,
8,
604,
304,
272,
1625,
275,
1004,
14,
6735,
2258,
78,
1959,
1294,
2258,
84,
358,
272,
2538,
275,
2513,
1370,
904,
8,
1144,
9,
272,
862,
26,
267,
4922,
275,
747,
14,
515,
14,
904,
8,
589,
14,
79,
12,
1625,
59,
20,
467,
1625,
59,
21,
467,
2538,
9,
267,
984,
14,
3083,
14,
952,
8,
3741,
435,
1867,
78,
531,
267,
340,
747,
14,
515,
14,
2444,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
298,
324,
29796,
14,
11878,
14,
6838,
2237,
436,
1249,
14,
328,
1190,
387,
3424,
26,
288,
984,
14,
3083,
14,
952,
480,
9602,
487,
1190,
387,
3424,
60,
78,
531,
288,
7347,
275,
3873,
14,
7942,
4725,
1548,
297,
1249,
14,
328,
1190,
387,
3424,
12,
2475,
17,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
17,
14,
11878,
14,
6838,
659,
2475,
18,
297,
3521,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
18,
14,
11878,
14,
6838,
659,
3521,
2475,
83,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
324,
29796,
14,
11878,
14,
6838,
659,
2850,
4921,
13,
264,
285,
1842,
1470,
297,
2850,
8695,
13,
17708,
297,
283,
19,
297,
3521,
2475,
79,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
3855,
3303,
3839,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
793,
659,
283,
87,
659,
3303,
4635,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
1508,
659,
283,
87,
1333,
288,
754,
275,
7347,
14,
2573,
342,
288,
340,
754,
1137,
378,
26,
984,
14,
3083,
14,
952,
480,
20485,
1133,
1255,
487,
1190,
387,
3424,
60,
78,
531,
288,
587,
26,
355,
747,
14,
8165,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
15,
328,
1190,
387,
3424,
15,
388,
31664,
63,
388,
280,
458,
14,
20309,
659,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
20309,
1333,
355,
747,
14,
8165,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
15,
3770,
3424,
15,
7101,
556,
8250,
14,
20309,
659,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
3770,
3424,
14,
20309,
1333,
355,
5145,
14,
9242,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
1333,
267,
916,
1249,
14,
328,
1190,
387,
3424,
26,
288,
984,
14,
3083,
14,
952,
480,
9602,
487,
1190,
387,
3424,
60,
78,
531,
288,
7347,
275,
3873,
14,
7942,
4725,
1548,
297,
1249,
14,
328,
1190,
387,
3424,
12,
2475,
17,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
17,
14,
11878,
14,
6838,
659,
2475,
18,
297,
3521,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
18,
14,
11878,
14,
6838,
659,
3521,
2850,
4921,
13,
264,
285,
1842,
1470,
297,
2850,
8695,
13,
17708,
297,
283,
19,
297,
2475,
79,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
3855,
3303,
3839,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
793,
659,
283,
87,
659,
3303,
4635,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
1508,
659,
283,
87,
1333,
288,
754,
275,
7347,
14,
2573,
342,
288,
340,
754,
1137,
378,
26,
984,
14,
3083,
14,
952,
480,
20485,
1133,
1255,
487,
1190,
387,
3424,
60,
78,
531,
288,
587,
26,
355,
747,
14,
8165,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
15,
328,
1190,
387,
3424,
15,
388,
31664,
63,
388,
280,
458,
14,
20309,
659,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
20309,
1333,
355,
747,
14,
8165,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
15,
3770,
3424,
15,
7101,
556,
8250,
14,
20309,
659,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
3770,
3424,
14,
20309,
1333,
355,
5145,
14,
9242,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
1333,
267,
340,
1249,
14,
1090,
28350,
71,
436,
1249,
14,
1090,
432,
273,
26,
288,
984,
14,
3083,
14,
952,
480,
9602,
373,
15320,
273,
60,
78,
531,
288,
7347,
275,
3873,
14,
7942,
8,
355,
334,
589,
14,
1090,
432,
273,
12,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
1090,
28350,
659,
283,
2192,
297,
2475,
3612,
4232,
16139,
297,
2475,
24904,
297,
2475,
26423,
14,
6838,
297,
326,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
17,
14,
11878,
14,
6838,
659,
747
] |
[
984,
199,
646,
5145,
199,
646,
3873,
199,
646,
7534,
199,
646,
747,
199,
646,
3718,
199,
504,
12866,
492,
15553,
199,
199,
2087,
275,
7534,
14,
10730,
8,
1802,
534,
31054,
11597,
12509,
687,
1924,
4897,
358,
199,
2087,
14,
525,
63,
2094,
4517,
6123,
297,
1720,
15637,
6123,
570,
402,
14056,
16150,
297,
730,
29,
495,
9,
199,
2087,
14,
525,
63,
2094,
4517,
328,
1190,
387,
3424,
297,
1720,
534,
2042,
402,
487,
1190,
387,
3424,
14,
647,
297,
730,
29,
495,
9,
199,
2087,
14,
525,
63,
2094,
4517,
1090,
28350,
71,
297,
1720,
534,
2042,
402,
373,
352,
28350,
71,
7286,
297,
730,
29,
495,
9,
199,
2087,
14,
525,
63,
2094,
4517,
1090,
432,
273,
297,
1720,
534,
2042,
402,
373,
15320,
273,
7286,
297,
730,
29,
495,
9,
199,
2087,
14,
525,
63,
2094,
4517,
17585,
385,
297,
1720,
534,
2042,
402,
282,
991,
385,
13,
321,
7286,
297,
730,
29,
495,
12,
849,
29,
17,
9,
199,
2087,
14,
525,
63,
2094,
3654,
84,
297,
1720,
26431,
402,
7183,
297,
730,
29,
442,
9,
199,
2087,
14,
525,
63,
2094,
3654,
79,
297,
1720,
534,
2042,
367,
6449,
4922,
297,
849,
29,
736,
14,
9458,
1062,
730,
29,
495,
9,
199,
199,
589,
275,
1798,
14,
1122,
63,
589,
342,
199,
199,
318,
22931,
8,
604,
304,
272,
1625,
275,
1004,
14,
6735,
2258,
78,
1959,
1294,
2258,
84,
358,
272,
2538,
275,
2513,
1370,
904,
8,
1144,
9,
272,
862,
26,
267,
4922,
275,
747,
14,
515,
14,
904,
8,
589,
14,
79,
12,
1625,
59,
20,
467,
1625,
59,
21,
467,
2538,
9,
267,
984,
14,
3083,
14,
952,
8,
3741,
435,
1867,
78,
531,
267,
340,
747,
14,
515,
14,
2444,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
298,
324,
29796,
14,
11878,
14,
6838,
2237,
436,
1249,
14,
328,
1190,
387,
3424,
26,
288,
984,
14,
3083,
14,
952,
480,
9602,
487,
1190,
387,
3424,
60,
78,
531,
288,
7347,
275,
3873,
14,
7942,
4725,
1548,
297,
1249,
14,
328,
1190,
387,
3424,
12,
2475,
17,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
17,
14,
11878,
14,
6838,
659,
2475,
18,
297,
3521,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
18,
14,
11878,
14,
6838,
659,
3521,
2475,
83,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
324,
29796,
14,
11878,
14,
6838,
659,
2850,
4921,
13,
264,
285,
1842,
1470,
297,
2850,
8695,
13,
17708,
297,
283,
19,
297,
3521,
2475,
79,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
3855,
3303,
3839,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
793,
659,
283,
87,
659,
3303,
4635,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
1508,
659,
283,
87,
1333,
288,
754,
275,
7347,
14,
2573,
342,
288,
340,
754,
1137,
378,
26,
984,
14,
3083,
14,
952,
480,
20485,
1133,
1255,
487,
1190,
387,
3424,
60,
78,
531,
288,
587,
26,
355,
747,
14,
8165,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
15,
328,
1190,
387,
3424,
15,
388,
31664,
63,
388,
280,
458,
14,
20309,
659,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
20309,
1333,
355,
747,
14,
8165,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
15,
3770,
3424,
15,
7101,
556,
8250,
14,
20309,
659,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
3770,
3424,
14,
20309,
1333,
355,
5145,
14,
9242,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
1333,
267,
916,
1249,
14,
328,
1190,
387,
3424,
26,
288,
984,
14,
3083,
14,
952,
480,
9602,
487,
1190,
387,
3424,
60,
78,
531,
288,
7347,
275,
3873,
14,
7942,
4725,
1548,
297,
1249,
14,
328,
1190,
387,
3424,
12,
2475,
17,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
17,
14,
11878,
14,
6838,
659,
2475,
18,
297,
3521,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
18,
14,
11878,
14,
6838,
659,
3521,
2850,
4921,
13,
264,
285,
1842,
1470,
297,
2850,
8695,
13,
17708,
297,
283,
19,
297,
2475,
79,
297,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
3855,
3303,
3839,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
793,
659,
283,
87,
659,
3303,
4635,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
1508,
659,
283,
87,
1333,
288,
754,
275,
7347,
14,
2573,
342,
288,
340,
754,
1137,
378,
26,
984,
14,
3083,
14,
952,
480,
20485,
1133,
1255,
487,
1190,
387,
3424,
60,
78,
531,
288,
587,
26,
355,
747,
14,
8165,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
15,
328,
1190,
387,
3424,
15,
388,
31664,
63,
388,
280,
458,
14,
20309,
659,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
14,
20309,
1333,
355,
747,
14,
8165,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
15,
3770,
3424,
15,
7101,
556,
8250,
14,
20309,
659,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
3770,
3424,
14,
20309,
1333,
355,
5145,
14,
9242,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
283,
328,
1190,
387,
3424,
1333,
267,
340,
1249,
14,
1090,
28350,
71,
436,
1249,
14,
1090,
432,
273,
26,
288,
984,
14,
3083,
14,
952,
480,
9602,
373,
15320,
273,
60,
78,
531,
288,
7347,
275,
3873,
14,
7942,
8,
355,
334,
589,
14,
1090,
432,
273,
12,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
1090,
28350,
659,
283,
2192,
297,
2475,
3612,
4232,
16139,
297,
2475,
24904,
297,
2475,
26423,
14,
6838,
297,
326,
747,
14,
515,
14,
904,
8,
3741,
12,
283,
739,
17,
14,
11878,
14,
6838,
659,
747,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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ceptions import ImproperlyConfigured
from django.http import HttpResponse
from django.test import TestCase, RequestFactory
from django.utils import unittest
from django.views.generic import View, TemplateView, RedirectView
from . import views
class SimpleView(View):
"""
A simple view with a docstring.
"""
def get(self, request):
return HttpResponse('This is a simple view')
class SimplePostView(SimpleView):
post = SimpleView.get
class PostOnlyView(View):
def post(self, request):
return HttpResponse('This view only accepts POST')
class CustomizableView(SimpleView):
parameter = {}
def decorator(view):
view.is_decorated = True
return view
class DecoratedDispatchView(SimpleView):
@decorator
def dispatch(self, request, *args, **kwargs):
return super(DecoratedDispatchView, self).dispatch(request, *args, **kwargs)
class AboutTemplateView(TemplateView):
def get(self, request):
return self.render_to_response({})
def get_template_names(self):
return ['generic_views/about.html']
class AboutTemplateAttributeView(TemplateView):
template_name = 'generic_views/about.html'
def get(self, request):
return self.render_to_response(context={})
class InstanceView(View):
def get(self, request):
return self
class ViewTest(unittest.TestCase):
rf = RequestFactory()
def _assert_simple(self, response):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, b'This is a simple view')
def test_no_init_kwargs(self):
"""
Test that a view can't be accidentally instantiated before deployment
"""
try:
view = SimpleView(key='value').as_view()
self.fail('Should not be able to instantiate a view')
except AttributeError:
pass
def test_no_init_args(self):
"""
Test that a view can't be accidentally instantiated before deployment
"""
try:
view = SimpleView.as_view('value')
self.fail('Should not be able to use non-keyword arguments instantiating a view')
except TypeError:
pass
def test_pathological_http_method(self):
"""
The edge case of a http request that spoofs an existing method name is caught.
"""
self.assertEqual(SimpleView.as_view()(
self.rf.get('/', REQUEST_METHOD='DISPATCH')
).status_code, 405)
def test_get_only(self):
"""
Test a view which only allows GET doesn't allow other methods.
"""
self._assert_simple(SimpleView.as_view()(self.rf.get('/')))
self.assertEqual(SimpleView.as_view()(self.rf.post('/')).status_code, 405)
self.assertEqual(SimpleView.as_view()(
self.rf.get('/', REQUEST_METHOD='FAKE')
).status_code, 405)
def test_get_and_head(self):
"""
Test a view which supplies a GET method also responds correctly to HEAD.
"""
self._assert_simple(SimpleView.as_view()(self.rf.get('/')))
response = SimpleView.as_view()(self.rf.head('/'))
self.assertEqual(response.status_code, 200)
def test_head_no_get(self):
"""
Test a view which supplies no GET method responds to HEAD with HTTP 405.
"""
response = PostOnlyView.as_view()(self.rf.head('/'))
self.assertEqual(response.status_code, 405)
def test_get_and_post(self):
"""
Test a view which only allows both GET and POST.
"""
self._assert_simple(SimplePostView.as_view()(self.rf.get('/')))
self._assert_simple(SimplePostView.as_view()(self.rf.post('/')))
self.assertEqual(SimplePostView.as_view()(
self.rf.get('/', REQUEST_METHOD='FAKE')
).status_code, 405)
def test_invalid_keyword_argument(self):
"""
Test that view arguments must be predefined on the class and can't
be named like a HTTP method.
"""
# Check each of the allowed method names
for method in SimpleView.http_method_names:
kwargs = dict(((method, "value"),))
self.assertRaises(TypeError, SimpleView.as_view, **kwargs)
# Check the case view argument is ok if predefined on the class...
CustomizableView.as_view(parameter="value")
# ...but raises errors otherwise.
self.assertRaises(TypeError, CustomizableView.as_view, foobar="value")
def test_calling_more_than_once(self):
"""
Test a view can only be called once.
"""
request = self.rf.get('/')
view = InstanceView.as_view()
self.assertNotEqual(view(request), view(request))
def test_class_attributes(self):
"""
Test that the callable returned from as_view() has proper
docstring, name and module.
"""
self.assertEqual(SimpleView.__doc__, SimpleView.as_view().__doc__)
self.assertEqual(SimpleView.__name__, SimpleView.as_view().__name__)
self.assertEqual(SimpleView.__module__, SimpleView.as_view().__module__)
def test_dispatch_decoration(self):
"""
Test that attributes set by decorators on the dispatch method
are also present on the closure.
"""
self.assertTrue(DecoratedDispatchView.as_view().is_decorated)
def test_options(self):
"""
Test that views respond to HTTP OPTIONS requests with an Allow header
appropriate for the methods implemented by the view class.
"""
request = self.rf.options('/')
view = SimpleView.as_view()
response = view(request)
self.assertEqual(200, response.status_code)
self.assertTrue(response['Allow'])
def test_options_for_get_view(self):
"""
Test that a view implementing GET allows GET and HEAD.
"""
request = self.rf.options('/')
view = SimpleView.as_view()
response = view(request)
self._assert_allows(response, 'GET', 'HEAD')
def test_options_for_get_and_post_view(self):
"""
Test that a view implementing GET and POST allows GET, HEAD, and POST.
"""
request = self.rf.options('/')
view = SimplePostView.as_view()
response = view(request)
self._assert_allows(response, 'GET', 'HEAD', 'POST')
def test_options_for_post_view(self):
"""
Test that a view implementing POST allows POST.
"""
request = self.rf.options('/')
view = PostOnlyView.as_view()
response = view(request)
self._assert_allows(response, 'POST')
def _assert_allows(self, response, *expected_methods):
"Assert allowed HTTP methods reported in the Allow response header"
response_allows = set(response['Allow'].split(', '))
self.assertEqual(set(expected_methods + ('OPTIONS',)), response_allows)
def test_args_kwargs_request_on_self(self):
"""
Test a view only has args, kwargs & request once `as_view`
has been called.
"""
bare_view = InstanceView()
view = InstanceView.as_view()(self.rf.get('/'))
for attribute in ('args', 'kwargs', 'request'):
self.assertNotIn(attribute, dir(bare_view))
self.assertIn(attribute, dir(view))
class TemplateViewTest(TestCase):
urls = 'regressiontests.generic_views.urls'
rf = RequestFactory()
def _assert_about(self, response):
response.render()
self.assertEqual(response.status_code, 200)
self.assertContains(response, '<h1>About</h1>')
def test_get(self):
"""
Test a view that simply renders a template on GET
"""
self._assert_about(AboutTemplateView.as_view()(self.rf.get('/about/')))
def test_head(self):
"""
Test a TemplateView responds correctly to HEAD
"""
response = AboutTemplateView.as_view()(self.rf.head('/about/'))
self.assertEqual(response.status_code, 200)
def test_get_template_attribute(self):
"""
Test a view that renders a template on GET with the template name as
an attribute on the class.
"""
self._assert_about(AboutTemplateAttributeView.as_view()(self.rf.get('/about/')))
def test_get_generic_template(self):
"""
Test a completely generic view that renders a template on GET
with the template name as an argument at instantiation.
"""
self._assert_about(TemplateView.as_view(template_name='generic_views/about.html')(self.rf.get('/about/')))
def test_template_name_required(self):
"""
A template view must provide a template name
"""
self.assertRaises(ImproperlyConfigured, self.client.get, '/template/no_template/')
def test_template_params(self):
"""
A generic template view passes kwargs as context.
"""
response = self.client.get('/template/simple/bar/')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['foo'], 'bar')
self.assertTrue(isinstance(response.context['view'], View))
def test_extra_template_params(self):
"""
A template view can be customized to return extra context.
"""
response = self.client.get('/template/custom/bar/')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['foo'], 'bar')
self.assertEqual(response.context['key'], 'value')
self.assertTrue(isinstance(response.context['view'], View))
def test_cached_views(self):
"""
A template view can be cached
"""
response = self.client.get('/template/cached/bar/')
self.assertEqual(response.status_code, 200)
time.sleep(1.0)
response2 = self.client.get('/template/cached/bar/')
self.assertEqual(response2.status_code, 200)
self.assertEqual(response.content, response2.content)
time.sleep(2.0)
# Let the cache expire and test again
response2 = self.client.get('/template/cached/bar/')
self.assertEqual(response2.status_code, 200)
self.assertNotEqual(response.content, response2.content)
def test_content_type(self):
response = self.client.get('/template/content_type/')
self.assertEqual(response['Content-Type'], 'text/plain')
class RedirectViewTest(unittest.TestCase):
rf = RequestFactory()
def test_no_url(self):
"Without any configuration, returns HTTP 410 GONE"
response = RedirectView.as_view()(self.rf.get('/foo/'))
self.assertEqual(response.status_code, 410)
def test_permanent_redirect(self):
"Default is a permanent redirect"
response = RedirectView.as_view(url='/bar/')(self.rf.get('/foo/'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/')
def test_temporary_redirect(self):
"Permanent redirects are an option"
response = RedirectView.as_view(url='/bar/', permanent=False)(self.rf.get('/foo/'))
self.assertEqual(response.status_code, 302)
self.assertEqual(response['Location'], '/bar/')
def test_include_args(self):
"GET arguments can be included in the redirected URL"
response = RedirectView.as_view(url='/bar/')(self.rf.get('/foo/'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/')
response = RedirectView.as_view(url='/bar/', query_string=True)(self.rf.get('/foo/?pork=spam'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/?pork=spam')
def test_include_urlencoded_args(self):
"GET arguments can be URL-encoded when included in the redirected URL"
response = RedirectView.as_view(url='/bar/', query_string=True)(
self.rf.get('/foo/?unicode=%E2%9C%93'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/?unicode=%E2%9C%93')
def test_parameter_substitution(self):
"Redirection URLs can be parameterized"
response = RedirectView.as_view(url='/bar/%(object_id)d/')(self.rf.get('/foo/42/'), object_id=42)
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/42/')
def test_redirect_POST(self):
"Default is a permanent redirect"
response = RedirectView.as_view(url='/bar/')(self.rf.post('/foo/'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/')
def test_redirect_HEAD(self):
"Default is a permanent redirect"
response = RedirectView.as_view(url='/bar/')(self.rf.head('/foo/'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/')
def test_redirect_OPTIONS(self):
"Default is a permanent redirect"
response = RedirectView.as_view(url='/bar/')(self.rf.options('/foo/'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/')
def test_redirect_PUT(self):
"Default is a permanent redirect"
response = RedirectView.as_view(url='/bar/')(self.rf.put('/foo/'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/')
def test_redirect_DELETE(self):
"Default is a permanent redirect"
response = RedirectView.as_view(url='/bar/')(self.rf.delete('/foo/'))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['Location'], '/bar/')
def test_redirect_when_meta_contains_no_query_string(self):
"regression for #16705"
# we can't use self.rf.get because it always sets QUERY_STRING
response = RedirectView.as_view(url='/bar/')(self.rf.request(PATH_INFO='/foo/'))
self.assertEqual(response.status_code, 301)
class GetContextDataTest(unittest.TestCase):
def test_get_context_data_super(self):
test_view = views.CustomContextView()
context = test_view.get_context_data(kwarg_test='kwarg_value')
# the test_name key is inserted by the test classes parent
self.assertTrue('test_name' in context)
self.assertEqual(context['kwarg_test'], 'kwarg_value')
self.assertEqual(context['custom_key'], 'custom_value')
# test that kwarg overrides values assigned higher up
context = test_view.get_context_data(test_name='test_value')
self.assertEqual(context['test_name'], 'test_value')
|
lgpl-3.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
900,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1014,
492,
6183,
199,
504,
1639,
14,
396,
492,
7640,
12,
18638,
199,
504,
1639,
14,
1208,
492,
2882,
199,
504,
1639,
14,
4196,
14,
6767,
492,
10935,
12,
5458,
2768,
12,
18532,
2768,
199,
199,
504,
1275,
492,
6858,
199,
199,
533,
5870,
2768,
8,
2768,
304,
272,
408,
272,
437,
3486,
2455,
543,
282,
9214,
14,
272,
408,
272,
347,
664,
8,
277,
12,
1056,
304,
267,
372,
6183,
360,
2765,
365,
282,
3486,
2455,
358,
421,
199,
533,
5870,
6564,
2768,
8,
3184,
2768,
304,
272,
2963,
275,
5870,
2768,
14,
362,
421,
199,
533,
7711,
5903,
2768,
8,
2768,
304,
272,
347,
2963,
8,
277,
12,
1056,
304,
267,
372,
6183,
360,
2765,
2455,
1454,
11479,
8761,
358,
421,
199,
533,
8388,
14065,
2768,
8,
3184,
2768,
304,
272,
2725,
275,
1052,
421,
199,
318,
7531,
8,
1345,
304,
272,
2455,
14,
374,
63,
29299,
275,
715,
272,
372,
2455,
421,
199,
533,
13966,
269,
972,
20628,
2768,
8,
3184,
2768,
304,
339,
768,
11547,
272,
347,
7634,
8,
277,
12,
1056,
12,
627,
589,
12,
1011,
958,
304,
267,
372,
1613,
8,
8584,
269,
972,
20628,
2768,
12,
291,
680,
6052,
8,
1069,
12,
627,
589,
12,
1011,
958,
9,
421,
199,
533,
25225,
4231,
2768,
8,
4231,
2768,
304,
272,
347,
664,
8,
277,
12,
1056,
304,
267,
372,
291,
14,
3352,
63,
475,
63,
1310,
14079,
339,
347,
664,
63,
1160,
63,
1247,
8,
277,
304,
267,
372,
788,
6767,
63,
4196,
15,
10254,
14,
1360,
418,
421,
199,
533,
25225,
4231,
1646,
2768,
8,
4231,
2768,
304,
272,
1978,
63,
354,
275,
283,
6767,
63,
4196,
15,
10254,
14,
1360,
7,
339,
347,
664,
8,
277,
12,
1056,
304,
267,
372,
291,
14,
3352,
63,
475,
63,
1310,
8,
1100,
21146,
421,
199,
533,
10066,
2768,
8,
2768,
304,
339,
347,
664,
8,
277,
12,
1056,
304,
267,
372,
291,
421,
199,
533,
10935,
774,
8,
2796,
14,
1746,
304,
272,
17781,
275,
18638,
342,
339,
347,
485,
479,
63,
4129,
8,
277,
12,
1177,
304,
267,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
267,
291,
14,
629,
8,
1310,
14,
1317,
12,
330,
7,
2765,
365,
282,
3486,
2455,
358,
339,
347,
511,
63,
889,
63,
826,
63,
958,
8,
277,
304,
267,
408,
267,
1379,
626,
282,
2455,
883,
1133,
506,
24634,
1183,
17544,
2544,
14295,
267,
408,
267,
862,
26,
288,
2455,
275,
5870,
2768,
8,
498,
534,
585,
1959,
305,
63,
1345,
342,
288,
291,
14,
1633,
360,
11408,
440,
506,
7688,
370,
17321,
282,
2455,
358,
267,
871,
4281,
26,
288,
986,
339,
347,
511,
63,
889,
63,
826,
63,
589,
8,
277,
304,
267,
408,
267,
1379,
626,
282,
2455,
883,
1133,
506,
24634,
1183,
17544,
2544,
14295,
267,
408,
267,
862,
26,
288,
2455,
275,
5870,
2768,
14,
305,
63,
1345,
360,
585,
358,
288,
291,
14,
1633,
360,
11408,
440,
506,
7688,
370,
675,
2222,
13,
6691,
2368,
9034,
1958,
282,
2455,
358,
267,
871,
3146,
26,
288,
986,
339,
347,
511,
63,
515,
79,
7954,
63,
1014,
63,
765,
8,
277,
304,
267,
408,
267,
710,
6275,
1930,
402,
282,
1455,
1056,
626,
25664,
14105,
376,
3411,
1083,
536,
365,
15604,
14,
267,
408,
267,
291,
14,
629,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
288,
291,
14,
3941,
14,
362,
10998,
31325,
63,
9977,
534,
32550,
358,
267,
7092,
1205,
63,
600,
12,
25766,
9,
339,
347,
511,
63,
362,
63,
2118,
8,
277,
304,
267,
408,
267,
1379,
282,
2455,
1314,
1454,
6127,
9576,
3181,
1133,
2040,
1163,
3102,
14,
267,
408,
267,
291,
423,
479,
63,
4129,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
362,
2336,
7058,
267,
291,
14,
629,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
1932,
7825,
680,
1205,
63,
600,
12,
25766,
9,
267,
291,
14,
629,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
288,
291,
14,
3941,
14,
362,
10998,
31325,
63,
9977,
534,
14623,
358,
267,
7092,
1205,
63,
600,
12,
25766,
9,
339,
347,
511,
63,
362,
63,
460,
63,
2993,
8,
277,
304,
267,
408,
267,
1379,
282,
2455,
1314,
4973,
6528,
282,
9576,
1083,
2597,
9163,
795,
6657,
370,
13053,
14,
267,
408,
267,
291,
423,
479,
63,
4129,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
362,
2336,
7058,
267,
1177,
275,
5870,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
2993,
28684,
267,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
339,
347,
511,
63,
2993,
63,
889,
63,
362,
8,
277,
304,
267,
408,
267,
1379,
282,
2455,
1314,
4973,
6528,
949,
9576,
1083,
9163,
795,
370,
13053,
543,
3101,
25766,
14,
267,
408,
267,
1177,
275,
7711,
5903,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
2993,
28684,
267,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
25766,
9,
339,
347,
511,
63,
362,
63,
460,
63,
1932,
8,
277,
304,
267,
408,
267,
1379,
282,
2455,
1314,
1454,
6127,
3865,
9576,
436,
8761,
14,
267,
408,
267,
291,
423,
479,
63,
4129,
8,
3184,
6564,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
362,
2336,
7058,
267,
291,
423,
479,
63,
4129,
8,
3184,
6564,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
1932,
2336,
7058,
267,
291,
14,
629,
8,
3184,
6564,
2768,
14,
305,
63,
1345,
24851,
288,
291,
14,
3941,
14,
362,
10998,
31325,
63,
9977,
534,
14623,
358,
267,
7092,
1205,
63,
600,
12,
25766,
9,
339,
347,
511,
63,
3197,
63,
6691,
63,
2094,
8,
277,
304,
267,
408,
267,
1379,
626,
2455,
2368,
1471,
506,
27684,
641,
314,
1021,
436,
883,
1133,
267,
506,
4310,
2839,
282,
3101,
1083,
14,
267,
408,
267,
327,
2670,
1924,
402,
314,
4370,
1083,
1561,
267,
367,
1083,
315,
5870,
2768,
14,
1014,
63,
765,
63,
1247
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
900,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1014,
492,
6183,
199,
504,
1639,
14,
396,
492,
7640,
12,
18638,
199,
504,
1639,
14,
1208,
492,
2882,
199,
504,
1639,
14,
4196,
14,
6767,
492,
10935,
12,
5458,
2768,
12,
18532,
2768,
199,
199,
504,
1275,
492,
6858,
199,
199,
533,
5870,
2768,
8,
2768,
304,
272,
408,
272,
437,
3486,
2455,
543,
282,
9214,
14,
272,
408,
272,
347,
664,
8,
277,
12,
1056,
304,
267,
372,
6183,
360,
2765,
365,
282,
3486,
2455,
358,
421,
199,
533,
5870,
6564,
2768,
8,
3184,
2768,
304,
272,
2963,
275,
5870,
2768,
14,
362,
421,
199,
533,
7711,
5903,
2768,
8,
2768,
304,
272,
347,
2963,
8,
277,
12,
1056,
304,
267,
372,
6183,
360,
2765,
2455,
1454,
11479,
8761,
358,
421,
199,
533,
8388,
14065,
2768,
8,
3184,
2768,
304,
272,
2725,
275,
1052,
421,
199,
318,
7531,
8,
1345,
304,
272,
2455,
14,
374,
63,
29299,
275,
715,
272,
372,
2455,
421,
199,
533,
13966,
269,
972,
20628,
2768,
8,
3184,
2768,
304,
339,
768,
11547,
272,
347,
7634,
8,
277,
12,
1056,
12,
627,
589,
12,
1011,
958,
304,
267,
372,
1613,
8,
8584,
269,
972,
20628,
2768,
12,
291,
680,
6052,
8,
1069,
12,
627,
589,
12,
1011,
958,
9,
421,
199,
533,
25225,
4231,
2768,
8,
4231,
2768,
304,
272,
347,
664,
8,
277,
12,
1056,
304,
267,
372,
291,
14,
3352,
63,
475,
63,
1310,
14079,
339,
347,
664,
63,
1160,
63,
1247,
8,
277,
304,
267,
372,
788,
6767,
63,
4196,
15,
10254,
14,
1360,
418,
421,
199,
533,
25225,
4231,
1646,
2768,
8,
4231,
2768,
304,
272,
1978,
63,
354,
275,
283,
6767,
63,
4196,
15,
10254,
14,
1360,
7,
339,
347,
664,
8,
277,
12,
1056,
304,
267,
372,
291,
14,
3352,
63,
475,
63,
1310,
8,
1100,
21146,
421,
199,
533,
10066,
2768,
8,
2768,
304,
339,
347,
664,
8,
277,
12,
1056,
304,
267,
372,
291,
421,
199,
533,
10935,
774,
8,
2796,
14,
1746,
304,
272,
17781,
275,
18638,
342,
339,
347,
485,
479,
63,
4129,
8,
277,
12,
1177,
304,
267,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
267,
291,
14,
629,
8,
1310,
14,
1317,
12,
330,
7,
2765,
365,
282,
3486,
2455,
358,
339,
347,
511,
63,
889,
63,
826,
63,
958,
8,
277,
304,
267,
408,
267,
1379,
626,
282,
2455,
883,
1133,
506,
24634,
1183,
17544,
2544,
14295,
267,
408,
267,
862,
26,
288,
2455,
275,
5870,
2768,
8,
498,
534,
585,
1959,
305,
63,
1345,
342,
288,
291,
14,
1633,
360,
11408,
440,
506,
7688,
370,
17321,
282,
2455,
358,
267,
871,
4281,
26,
288,
986,
339,
347,
511,
63,
889,
63,
826,
63,
589,
8,
277,
304,
267,
408,
267,
1379,
626,
282,
2455,
883,
1133,
506,
24634,
1183,
17544,
2544,
14295,
267,
408,
267,
862,
26,
288,
2455,
275,
5870,
2768,
14,
305,
63,
1345,
360,
585,
358,
288,
291,
14,
1633,
360,
11408,
440,
506,
7688,
370,
675,
2222,
13,
6691,
2368,
9034,
1958,
282,
2455,
358,
267,
871,
3146,
26,
288,
986,
339,
347,
511,
63,
515,
79,
7954,
63,
1014,
63,
765,
8,
277,
304,
267,
408,
267,
710,
6275,
1930,
402,
282,
1455,
1056,
626,
25664,
14105,
376,
3411,
1083,
536,
365,
15604,
14,
267,
408,
267,
291,
14,
629,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
288,
291,
14,
3941,
14,
362,
10998,
31325,
63,
9977,
534,
32550,
358,
267,
7092,
1205,
63,
600,
12,
25766,
9,
339,
347,
511,
63,
362,
63,
2118,
8,
277,
304,
267,
408,
267,
1379,
282,
2455,
1314,
1454,
6127,
9576,
3181,
1133,
2040,
1163,
3102,
14,
267,
408,
267,
291,
423,
479,
63,
4129,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
362,
2336,
7058,
267,
291,
14,
629,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
1932,
7825,
680,
1205,
63,
600,
12,
25766,
9,
267,
291,
14,
629,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
288,
291,
14,
3941,
14,
362,
10998,
31325,
63,
9977,
534,
14623,
358,
267,
7092,
1205,
63,
600,
12,
25766,
9,
339,
347,
511,
63,
362,
63,
460,
63,
2993,
8,
277,
304,
267,
408,
267,
1379,
282,
2455,
1314,
4973,
6528,
282,
9576,
1083,
2597,
9163,
795,
6657,
370,
13053,
14,
267,
408,
267,
291,
423,
479,
63,
4129,
8,
3184,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
362,
2336,
7058,
267,
1177,
275,
5870,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
2993,
28684,
267,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
339,
347,
511,
63,
2993,
63,
889,
63,
362,
8,
277,
304,
267,
408,
267,
1379,
282,
2455,
1314,
4973,
6528,
949,
9576,
1083,
9163,
795,
370,
13053,
543,
3101,
25766,
14,
267,
408,
267,
1177,
275,
7711,
5903,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
2993,
28684,
267,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
25766,
9,
339,
347,
511,
63,
362,
63,
460,
63,
1932,
8,
277,
304,
267,
408,
267,
1379,
282,
2455,
1314,
1454,
6127,
3865,
9576,
436,
8761,
14,
267,
408,
267,
291,
423,
479,
63,
4129,
8,
3184,
6564,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
362,
2336,
7058,
267,
291,
423,
479,
63,
4129,
8,
3184,
6564,
2768,
14,
305,
63,
1345,
24851,
277,
14,
3941,
14,
1932,
2336,
7058,
267,
291,
14,
629,
8,
3184,
6564,
2768,
14,
305,
63,
1345,
24851,
288,
291,
14,
3941,
14,
362,
10998,
31325,
63,
9977,
534,
14623,
358,
267,
7092,
1205,
63,
600,
12,
25766,
9,
339,
347,
511,
63,
3197,
63,
6691,
63,
2094,
8,
277,
304,
267,
408,
267,
1379,
626,
2455,
2368,
1471,
506,
27684,
641,
314,
1021,
436,
883,
1133,
267,
506,
4310,
2839,
282,
3101,
1083,
14,
267,
408,
267,
327,
2670,
1924,
402,
314,
4370,
1083,
1561,
267,
367,
1083,
315,
5870,
2768,
14,
1014,
63,
765,
63,
1247,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
rwakulszowa/servo
|
tests/wpt/css-tests/tools/py/testing/io_/test_saferepr.py
|
162
|
2388
|
# -*- coding: utf-8 -*-
from __future__ import generators
import py
import sys
saferepr = py.io.saferepr
class TestSafeRepr:
def test_simple_repr(self):
assert saferepr(1) == '1'
assert saferepr(None) == 'None'
def test_maxsize(self):
s = saferepr('x'*50, maxsize=25)
assert len(s) == 25
expected = repr('x'*10 + '...' + 'x'*10)
assert s == expected
def test_maxsize_error_on_instance(self):
class A:
def __repr__(self):
raise ValueError('...')
s = saferepr(('*'*50, A()), maxsize=25)
assert len(s) == 25
assert s[0] == '(' and s[-1] == ')'
def test_exceptions(self):
class BrokenRepr:
def __init__(self, ex):
self.ex = ex
foo = 0
def __repr__(self):
raise self.ex
class BrokenReprException(Exception):
__str__ = None
__repr__ = None
assert 'Exception' in saferepr(BrokenRepr(Exception("broken")))
s = saferepr(BrokenReprException("really broken"))
assert 'TypeError' in s
if py.std.sys.version_info < (2,6):
assert 'unknown' in saferepr(BrokenRepr("string"))
else:
assert 'TypeError' in saferepr(BrokenRepr("string"))
s2 = saferepr(BrokenRepr(BrokenReprException('omg even worse')))
assert 'NameError' not in s2
assert 'unknown' in s2
def test_big_repr(self):
from py._io.saferepr import SafeRepr
assert len(saferepr(range(1000))) <= \
len('[' + SafeRepr().maxlist * "1000" + ']')
def test_repr_on_newstyle(self):
class Function(object):
def __repr__(self):
return "<%s>" %(self.name)
try:
s = saferepr(Function())
except Exception:
py.test.fail("saferepr failed for newstyle class")
def test_unicode(self):
val = py.builtin._totext('£€', 'utf-8')
reprval = py.builtin._totext("'£€'", 'utf-8')
assert saferepr(val) == reprval
def test_unicode_handling():
value = py.builtin._totext('\xc4\x85\xc4\x87\n', 'utf-8').encode('utf8')
def f():
raise Exception(value)
excinfo = py.test.raises(Exception, f)
s = str(excinfo)
if sys.version_info[0] < 3:
u = unicode(excinfo)
|
mpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
16952,
199,
646,
1134,
199,
646,
984,
199,
199,
3489,
2722,
275,
1134,
14,
2308,
14,
3489,
2722,
199,
199,
533,
1379,
11090,
15713,
26,
272,
347,
511,
63,
4129,
63,
2722,
8,
277,
304,
267,
702,
5048,
2722,
8,
17,
9,
508,
283,
17,
7,
267,
702,
5048,
2722,
8,
403,
9,
508,
283,
403,
7,
339,
347,
511,
63,
13634,
8,
277,
304,
267,
308,
275,
5048,
2722,
360,
88,
16804,
1400,
12,
19791,
29,
821,
9,
267,
702,
822,
8,
83,
9,
508,
5661,
267,
1420,
275,
4700,
360,
88,
16804,
709,
435,
28044,
435,
283,
88,
16804,
709,
9,
267,
702,
308,
508,
1420,
339,
347,
511,
63,
13634,
63,
705,
63,
265,
63,
842,
8,
277,
304,
267,
1021,
437,
26,
288,
347,
636,
2722,
721,
277,
304,
355,
746,
1722,
360,
15103,
398,
308,
275,
5048,
2722,
4725,
10223,
10,
1400,
12,
437,
4000,
19791,
29,
821,
9,
267,
702,
822,
8,
83,
9,
508,
5661,
267,
702,
308,
59,
16,
61,
508,
16746,
436,
308,
1988,
17,
61,
508,
16107,
339,
347,
511,
63,
3924,
8,
277,
304,
267,
1021,
23804,
15713,
26,
288,
347,
636,
826,
721,
277,
12,
444,
304,
355,
291,
14,
476,
275,
444,
355,
3925,
275,
378,
288,
347,
636,
2722,
721,
277,
304,
355,
746,
291,
14,
476,
267,
1021,
23804,
15713,
1726,
8,
1726,
304,
288,
636,
495,
363,
275,
488,
288,
636,
2722,
363,
275,
488,
267,
702,
283,
1726,
7,
315,
5048,
2722,
8,
30509,
15713,
8,
1726,
480,
15697,
13324,
267,
308,
275,
5048,
2722,
8,
30509,
15713,
1726,
480,
29428,
10529,
2237,
267,
702,
283,
4333,
7,
315,
308,
267,
340,
1134,
14,
1516,
14,
1274,
14,
1023,
63,
815,
665,
334,
18,
12,
22,
304,
288,
702,
283,
5187,
7,
315,
5048,
2722,
8,
30509,
15713,
480,
875,
2237,
267,
587,
26,
288,
702,
283,
4333,
7,
315,
5048,
2722,
8,
30509,
15713,
480,
875,
2237,
398,
308,
18,
275,
5048,
2722,
8,
30509,
15713,
8,
30509,
15713,
1726,
360,
676,
71,
2755,
1319,
261,
7058,
267,
702,
283,
985,
547,
7,
440,
315,
308,
18,
267,
702,
283,
5187,
7,
315,
308,
18,
339,
347,
511,
63,
5076,
63,
2722,
8,
277,
304,
267,
687,
1134,
423,
2308,
14,
3489,
2722,
492,
14969,
15713,
267,
702,
822,
8,
3489,
2722,
8,
1842,
8,
5279,
1724,
2695,
971,
2049,
822,
360,
459,
435,
14969,
15713,
1252,
988,
513,
627,
298,
5279,
2,
435,
283,
10374,
339,
347,
511,
63,
2722,
63,
265,
63,
1222,
2487,
8,
277,
304,
267,
1021,
6801,
8,
785,
304,
288,
347,
636,
2722,
721,
277,
304,
355,
372,
23054,
83,
4335,
2818,
277,
14,
354,
9,
267,
862,
26,
288,
308,
275,
5048,
2722,
8,
3481,
1012,
267,
871,
2186,
26,
288,
1134,
14,
396,
14,
1633,
480,
3489,
2722,
3405,
367,
892,
2487,
1021,
531,
339,
347,
511,
63,
2975,
8,
277,
304,
267,
1139,
275,
1134,
14,
5351,
423,
475,
505,
360,
127,
97,
28268,
106,
297,
283,
1624,
13,
24,
358,
267,
4700,
637,
275,
1134,
14,
5351,
423,
475,
505,
15587,
127,
97,
28268,
106,
4662,
283,
1624,
13,
24,
358,
267,
702,
5048,
2722,
8,
637,
9,
508,
4700,
637,
199,
199,
318,
511,
63,
2975,
63,
22273,
837,
272,
574,
275,
1134,
14,
5351,
423,
475,
505,
2258,
1812,
20,
60,
88,
2426,
60,
1812,
20,
60,
88,
1555,
60,
78,
297,
283,
1624,
13,
24,
1959,
2143,
360,
1624,
24,
358,
272,
347,
289,
837,
267,
746,
2186,
8,
585,
9,
272,
21596,
275,
1134,
14,
396,
14,
3536,
8,
1726,
12,
289,
9,
272,
308,
275,
620,
8,
27447,
9,
272,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
26,
267,
399,
275,
2649,
8,
27447,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
16952,
199,
646,
1134,
199,
646,
984,
199,
199,
3489,
2722,
275,
1134,
14,
2308,
14,
3489,
2722,
199,
199,
533,
1379,
11090,
15713,
26,
272,
347,
511,
63,
4129,
63,
2722,
8,
277,
304,
267,
702,
5048,
2722,
8,
17,
9,
508,
283,
17,
7,
267,
702,
5048,
2722,
8,
403,
9,
508,
283,
403,
7,
339,
347,
511,
63,
13634,
8,
277,
304,
267,
308,
275,
5048,
2722,
360,
88,
16804,
1400,
12,
19791,
29,
821,
9,
267,
702,
822,
8,
83,
9,
508,
5661,
267,
1420,
275,
4700,
360,
88,
16804,
709,
435,
28044,
435,
283,
88,
16804,
709,
9,
267,
702,
308,
508,
1420,
339,
347,
511,
63,
13634,
63,
705,
63,
265,
63,
842,
8,
277,
304,
267,
1021,
437,
26,
288,
347,
636,
2722,
721,
277,
304,
355,
746,
1722,
360,
15103,
398,
308,
275,
5048,
2722,
4725,
10223,
10,
1400,
12,
437,
4000,
19791,
29,
821,
9,
267,
702,
822,
8,
83,
9,
508,
5661,
267,
702,
308,
59,
16,
61,
508,
16746,
436,
308,
1988,
17,
61,
508,
16107,
339,
347,
511,
63,
3924,
8,
277,
304,
267,
1021,
23804,
15713,
26,
288,
347,
636,
826,
721,
277,
12,
444,
304,
355,
291,
14,
476,
275,
444,
355,
3925,
275,
378,
288,
347,
636,
2722,
721,
277,
304,
355,
746,
291,
14,
476,
267,
1021,
23804,
15713,
1726,
8,
1726,
304,
288,
636,
495,
363,
275,
488,
288,
636,
2722,
363,
275,
488,
267,
702,
283,
1726,
7,
315,
5048,
2722,
8,
30509,
15713,
8,
1726,
480,
15697,
13324,
267,
308,
275,
5048,
2722,
8,
30509,
15713,
1726,
480,
29428,
10529,
2237,
267,
702,
283,
4333,
7,
315,
308,
267,
340,
1134,
14,
1516,
14,
1274,
14,
1023,
63,
815,
665,
334,
18,
12,
22,
304,
288,
702,
283,
5187,
7,
315,
5048,
2722,
8,
30509,
15713,
480,
875,
2237,
267,
587,
26,
288,
702,
283,
4333,
7,
315,
5048,
2722,
8,
30509,
15713,
480,
875,
2237,
398,
308,
18,
275,
5048,
2722,
8,
30509,
15713,
8,
30509,
15713,
1726,
360,
676,
71,
2755,
1319,
261,
7058,
267,
702,
283,
985,
547,
7,
440,
315,
308,
18,
267,
702,
283,
5187,
7,
315,
308,
18,
339,
347,
511,
63,
5076,
63,
2722,
8,
277,
304,
267,
687,
1134,
423,
2308,
14,
3489,
2722,
492,
14969,
15713,
267,
702,
822,
8,
3489,
2722,
8,
1842,
8,
5279,
1724,
2695,
971,
2049,
822,
360,
459,
435,
14969,
15713,
1252,
988,
513,
627,
298,
5279,
2,
435,
283,
10374,
339,
347,
511,
63,
2722,
63,
265,
63,
1222,
2487,
8,
277,
304,
267,
1021,
6801,
8,
785,
304,
288,
347,
636,
2722,
721,
277,
304,
355,
372,
23054,
83,
4335,
2818,
277,
14,
354,
9,
267,
862,
26,
288,
308,
275,
5048,
2722,
8,
3481,
1012,
267,
871,
2186,
26,
288,
1134,
14,
396,
14,
1633,
480,
3489,
2722,
3405,
367,
892,
2487,
1021,
531,
339,
347,
511,
63,
2975,
8,
277,
304,
267,
1139,
275,
1134,
14,
5351,
423,
475,
505,
360,
127,
97,
28268,
106,
297,
283,
1624,
13,
24,
358,
267,
4700,
637,
275,
1134,
14,
5351,
423,
475,
505,
15587,
127,
97,
28268,
106,
4662,
283,
1624,
13,
24,
358,
267,
702,
5048,
2722,
8,
637,
9,
508,
4700,
637,
199,
199,
318,
511,
63,
2975,
63,
22273,
837,
272,
574,
275,
1134,
14,
5351,
423,
475,
505,
2258,
1812,
20,
60,
88,
2426,
60,
1812,
20,
60,
88,
1555,
60,
78,
297,
283,
1624,
13,
24,
1959,
2143,
360,
1624,
24,
358,
272,
347,
289,
837,
267,
746,
2186,
8,
585,
9,
272,
21596,
275,
1134,
14,
396,
14,
3536,
8,
1726,
12,
289,
9,
272,
308,
275,
620,
8,
27447,
9,
272,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
26,
267,
399,
275,
2649,
8,
27447,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
marrow/WebCore
|
example/annotation.py
|
1
|
2204
|
# encoding: utf-8
"""Python 3 function annotation and AnnotationExtension example."""
from json import dumps
class Root:
def __init__(self, context):
self._ctx = context
def tmpl(self) -> 'mako:./template.html':
return dict()
def mul(self, a: int = None, b: int = None) -> 'json':
"""Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to execute this method:
* POST http://localhost:8080/mul
* GET http://localhost:8080/mul?a=27&b=42
* GET http://localhost:8080/mul/27/42
The latter relies on the fact we can't descend past a callable method so the remaining path elements are
used as positional arguments, whereas the others rely on keyword argument assignment from a form-encoded
request body or query string arguments. (Security note: any data in the request body takes presidence over
query string arguments!)
You can easily test these on the command line using cURL:
curl http://localhost:8080/mul/27/42 # HTTP GET
curl -d a=27 -d b=42 http://localhost:8080/mul # HTTP POST
"""
if not a or not b:
return dict(message="Pass arguments a and b to multiply them together!")
return dict(answer=a * b)
class SampleExtension:
"""Here's an example of how to catch an annotation like this as a view handler."""
def start(self, context):
context.view.register(tuple, self.render_json)
def render_json(self, context, result):
# Bail out if this isn't a 2-tuple, or isn't intended for JSON serialization.
# This is an informal protocol shared with the more complete `web.template` package and possibly others.
if len(result) != 2 or result[0] != 'json':
return
resp = context.response
resp.content_type = 'application/json'
resp.encoding = 'utf-8'
resp.text = dumps(result[1])
return True
if __name__ == '__main__':
from web.core import Application
from web.ext.annotation import AnnotationExtension
Application(Root, extensions=[SampleExtension(), AnnotationExtension()]).serve('wsgiref')
|
mit
|
[
3,
2644,
26,
2774,
13,
24,
199,
199,
624,
4718,
650,
805,
11262,
436,
30793,
6382,
2893,
1041,
199,
199,
504,
2022,
492,
16864,
421,
199,
533,
12826,
26,
199,
198,
318,
636,
826,
721,
277,
12,
1067,
304,
507,
198,
277,
423,
3799,
275,
1067,
8299,
198,
318,
9675,
8,
277,
9,
1035,
283,
19491,
26,
13186,
1160,
14,
1360,
356,
507,
198,
1107,
1211,
342,
8299,
198,
318,
19207,
8,
277,
12,
282,
26,
1109,
275,
488,
12,
330,
26,
1109,
275,
488,
9,
1035,
283,
1001,
356,
507,
198,
624,
25314,
590,
2877,
1338,
10451,
436,
372,
314,
754,
4799,
4840,
14,
9068,
198,
4718,
650,
805,
15538,
787,
1202,
370,
4868,
626,
314,
2368,
787,
9446,
14,
961,
5074,
314,
507,
198,
1593,
6712,
402,
658,
2520,
14,
832,
14,
9340,
26,
16768,
6382,
2313,
9068,
198,
10924,
787,
9978,
15217,
370,
5341,
642,
1083,
26,
9068,
198,
10,
8761,
1455,
921,
5967,
26,
15844,
15,
3703,
507,
198,
10,
9576,
1455,
921,
5967,
26,
15844,
15,
3703,
31,
65,
29,
1465,
6,
66,
29,
2260,
507,
198,
10,
9576,
1455,
921,
5967,
26,
15844,
15,
3703,
15,
1465,
15,
2260,
9068,
198,
1918,
19045,
25749,
641,
314,
10572,
781,
883,
1133,
16336,
13541,
282,
4550,
1083,
880,
314,
7971,
931,
4008,
787,
507,
198,
2972,
465,
11333,
2368,
12,
29781,
314,
11789,
19687,
641,
4252,
1423,
9801,
687,
282,
1824,
13,
8167,
507,
198,
1069,
2396,
503,
1827,
1059,
2368,
14,
221,
334,
7676,
5317,
26,
1263,
666,
315,
314,
1056,
2396,
6181,
876,
338,
5606,
1806,
507,
198,
1131,
1059,
2368,
21866,
9068,
198,
5556,
883,
16174,
511,
3520,
641,
314,
1414,
1004,
1808,
286,
2632,
26,
686,
686,
198,
17096,
1455,
921,
5967,
26,
15844,
15,
3703,
15,
1465,
15,
2260,
221,
327,
3101,
9576,
26140,
198,
17096,
446,
68,
282,
29,
1465,
446,
68,
330,
29,
2260,
1455,
921,
5967,
26,
15844,
15,
3703,
221,
327,
3101,
8761,
507,
198,
624,
9068,
198,
692,
440,
282,
503,
440,
330,
26,
686,
198,
1107,
1211,
8,
1188,
628,
4986,
2368,
282,
436,
330,
370,
21699,
3062,
10451,
9124,
9068,
198,
1107,
1211,
8,
5934,
29,
65,
627,
330,
9,
421,
199,
533,
15227,
6382,
26,
199,
198,
624,
21741,
1159,
376,
2893,
402,
4212,
370,
8579,
376,
11262,
2839,
642,
465,
282,
2455,
3016,
1041,
8299,
198,
318,
1343,
8,
277,
12,
1067,
304,
507,
198,
1100,
14,
1345,
14,
2683,
8,
2960,
12,
291,
14,
3352,
63,
1001,
9,
8299,
198,
318,
3795,
63,
1001,
8,
277,
12,
1067,
12,
754,
304,
507,
198,
3,
699,
1054,
734,
340,
642,
5712,
1133,
282,
499,
13,
2960,
12,
503,
5712,
1133,
11619,
367,
4840,
16953,
14,
507,
198,
3,
961,
365,
376,
315,
964,
279,
4113,
5709,
543,
314,
1655,
4890,
658,
2520,
14,
1160,
64,
2559,
436,
12570,
11789,
14,
507,
198,
692,
822,
8,
1099,
9,
1137,
499,
503,
754,
59,
16,
61,
1137,
283,
1001,
356,
686,
198,
1107,
9068,
198,
4518,
275,
1067,
14,
1310,
507,
198,
4518,
14,
1317,
63,
466,
275,
283,
3578,
15,
1001,
7,
507,
198,
4518,
14,
2991,
275,
283,
1624,
13,
24,
7,
507,
198,
4518,
14,
505,
275,
16864,
8,
1099,
59,
17,
566,
9068,
198,
1107,
715,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
199,
198,
504,
3330,
14,
1018,
492,
13515,
199,
198,
504,
3330,
14,
832,
14,
9340,
492,
30793,
6382,
8299,
198,
5039,
8,
6405,
12,
5478,
1524,
8176,
6382,
1062,
30793,
6382,
342,
6575,
4909,
360,
6508,
1121,
358,
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
] |
[
2644,
26,
2774,
13,
24,
199,
199,
624,
4718,
650,
805,
11262,
436,
30793,
6382,
2893,
1041,
199,
199,
504,
2022,
492,
16864,
421,
199,
533,
12826,
26,
199,
198,
318,
636,
826,
721,
277,
12,
1067,
304,
507,
198,
277,
423,
3799,
275,
1067,
8299,
198,
318,
9675,
8,
277,
9,
1035,
283,
19491,
26,
13186,
1160,
14,
1360,
356,
507,
198,
1107,
1211,
342,
8299,
198,
318,
19207,
8,
277,
12,
282,
26,
1109,
275,
488,
12,
330,
26,
1109,
275,
488,
9,
1035,
283,
1001,
356,
507,
198,
624,
25314,
590,
2877,
1338,
10451,
436,
372,
314,
754,
4799,
4840,
14,
9068,
198,
4718,
650,
805,
15538,
787,
1202,
370,
4868,
626,
314,
2368,
787,
9446,
14,
961,
5074,
314,
507,
198,
1593,
6712,
402,
658,
2520,
14,
832,
14,
9340,
26,
16768,
6382,
2313,
9068,
198,
10924,
787,
9978,
15217,
370,
5341,
642,
1083,
26,
9068,
198,
10,
8761,
1455,
921,
5967,
26,
15844,
15,
3703,
507,
198,
10,
9576,
1455,
921,
5967,
26,
15844,
15,
3703,
31,
65,
29,
1465,
6,
66,
29,
2260,
507,
198,
10,
9576,
1455,
921,
5967,
26,
15844,
15,
3703,
15,
1465,
15,
2260,
9068,
198,
1918,
19045,
25749,
641,
314,
10572,
781,
883,
1133,
16336,
13541,
282,
4550,
1083,
880,
314,
7971,
931,
4008,
787,
507,
198,
2972,
465,
11333,
2368,
12,
29781,
314,
11789,
19687,
641,
4252,
1423,
9801,
687,
282,
1824,
13,
8167,
507,
198,
1069,
2396,
503,
1827,
1059,
2368,
14,
221,
334,
7676,
5317,
26,
1263,
666,
315,
314,
1056,
2396,
6181,
876,
338,
5606,
1806,
507,
198,
1131,
1059,
2368,
21866,
9068,
198,
5556,
883,
16174,
511,
3520,
641,
314,
1414,
1004,
1808,
286,
2632,
26,
686,
686,
198,
17096,
1455,
921,
5967,
26,
15844,
15,
3703,
15,
1465,
15,
2260,
221,
327,
3101,
9576,
26140,
198,
17096,
446,
68,
282,
29,
1465,
446,
68,
330,
29,
2260,
1455,
921,
5967,
26,
15844,
15,
3703,
221,
327,
3101,
8761,
507,
198,
624,
9068,
198,
692,
440,
282,
503,
440,
330,
26,
686,
198,
1107,
1211,
8,
1188,
628,
4986,
2368,
282,
436,
330,
370,
21699,
3062,
10451,
9124,
9068,
198,
1107,
1211,
8,
5934,
29,
65,
627,
330,
9,
421,
199,
533,
15227,
6382,
26,
199,
198,
624,
21741,
1159,
376,
2893,
402,
4212,
370,
8579,
376,
11262,
2839,
642,
465,
282,
2455,
3016,
1041,
8299,
198,
318,
1343,
8,
277,
12,
1067,
304,
507,
198,
1100,
14,
1345,
14,
2683,
8,
2960,
12,
291,
14,
3352,
63,
1001,
9,
8299,
198,
318,
3795,
63,
1001,
8,
277,
12,
1067,
12,
754,
304,
507,
198,
3,
699,
1054,
734,
340,
642,
5712,
1133,
282,
499,
13,
2960,
12,
503,
5712,
1133,
11619,
367,
4840,
16953,
14,
507,
198,
3,
961,
365,
376,
315,
964,
279,
4113,
5709,
543,
314,
1655,
4890,
658,
2520,
14,
1160,
64,
2559,
436,
12570,
11789,
14,
507,
198,
692,
822,
8,
1099,
9,
1137,
499,
503,
754,
59,
16,
61,
1137,
283,
1001,
356,
686,
198,
1107,
9068,
198,
4518,
275,
1067,
14,
1310,
507,
198,
4518,
14,
1317,
63,
466,
275,
283,
3578,
15,
1001,
7,
507,
198,
4518,
14,
2991,
275,
283,
1624,
13,
24,
7,
507,
198,
4518,
14,
505,
275,
16864,
8,
1099,
59,
17,
566,
9068,
198,
1107,
715,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
199,
198,
504,
3330,
14,
1018,
492,
13515,
199,
198,
504,
3330,
14,
832,
14,
9340,
492,
30793,
6382,
8299,
198,
5039,
8,
6405,
12,
5478,
1524,
8176,
6382,
1062,
30793,
6382,
342,
6575,
4909,
360,
6508,
1121,
358,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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T License.
"""
This module contains the object used to describe the possible bonded atoms based on a Voronoi analysis.
"""
__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__credits__ = "Geoffroy Hautier"
__version__ = "2.0"
__maintainer__ = "David Waroquiers"
__email__ = "david.waroquiers@gmail.com"
__date__ = "Feb 20, 2016"
import logging
import time
import numpy as np
from monty.json import MSONable
from scipy.spatial import Voronoi
from pymatgen.analysis.chemenv.utils.coordination_geometry_utils import (
get_lower_and_upper_f,
my_solid_angle,
rectangle_surface_intersection,
)
from pymatgen.analysis.chemenv.utils.defs_utils import AdditionalConditions
from pymatgen.analysis.chemenv.utils.math_utils import normal_cdf_step
from pymatgen.core.sites import PeriodicSite
from pymatgen.core.structure import Structure
def from_bson_voronoi_list2(bson_nb_voro_list2, structure):
"""
Returns the voronoi_list needed for the VoronoiContainer object from a bson-encoded voronoi_list.
Args:
bson_nb_voro_list2: List of periodic sites involved in the Voronoi.
structure: Structure object.
Returns:
The voronoi_list needed for the VoronoiContainer (with PeriodicSites as keys of the dictionary - not
allowed in the BSON format).
"""
voronoi_list = [None] * len(bson_nb_voro_list2)
for isite, voro in enumerate(bson_nb_voro_list2):
if voro is None or voro == "None":
continue
voronoi_list[isite] = []
for psd, dd in voro:
struct_site = structure[dd["index"]]
periodic_site = PeriodicSite(
struct_site._species,
struct_site.frac_coords + psd[1],
struct_site._lattice,
properties=struct_site.properties,
)
dd["site"] = periodic_site
voronoi_list[isite].append(dd)
return voronoi_list
class DetailedVoronoiContainer(MSONable):
"""
Class used to store the full Voronoi of a given structure.
"""
AC = AdditionalConditions()
default_voronoi_cutoff = 10.0
default_normalized_distance_tolerance = 1e-5
default_normalized_angle_tolerance = 1e-3
def __init__(
self,
structure=None,
voronoi_list2=None,
voronoi_cutoff=default_voronoi_cutoff,
isites=None,
normalized_distance_tolerance=default_normalized_distance_tolerance,
normalized_angle_tolerance=default_normalized_angle_tolerance,
additional_conditions=None,
valences=None,
maximum_distance_factor=None,
minimum_angle_factor=None,
):
"""
Constructor for the VoronoiContainer object. Either a structure is given, in which case the Voronoi is
computed, or the different components of the VoronoiContainer are given (used in the from_dict method).
Args:
structure: Structure for which the Voronoi is computed.
voronoi_list2: List of voronoi polyhedrons for each site.
voronoi_cutoff: cutoff used for the voronoi.
isites: indices of sites for which the Voronoi has to be computed.
normalized_distance_tolerance: Tolerance for two normalized distances to be considered equal.
normalized_angle_tolerance:Tolerance for two normalized angles to be considered equal.
additional_conditions: Additional conditions to be used.
valences: Valences of all the sites in the structure (used when additional conditions require it).
maximum_distance_factor: The maximum distance factor to be considered.
minimum_angle_factor: The minimum angle factor to be considered.
Raises:
RuntimeError if the Voronoi cannot be constructed.
"""
self.normalized_distance_tolerance = normalized_distance_tolerance
self.normalized_angle_tolerance = normalized_angle_tolerance
if additional_conditions is None:
self.additional_conditions = [self.AC.NONE, self.AC.ONLY_ACB]
else:
self.additional_conditions = additional_conditions
self.valences = valences
self.maximum_distance_factor = maximum_distance_factor
self.minimum_angle_factor = minimum_angle_factor
if isites is None:
indices = list(range(len(structure)))
else:
indices = isites
self.structure = structure
logging.debug("Setting Voronoi list")
if voronoi_list2 is not None:
self.voronoi_list2 = voronoi_list2
else:
self.setup_voronoi_list(indices=indices, voronoi_cutoff=voronoi_cutoff)
logging.debug("Setting neighbors distances and angles")
t1 = time.process_time()
self.setup_neighbors_distances_and_angles(indices=indices)
t2 = time.process_time()
logging.debug("Neighbors distances and angles set up in {:.2f} seconds".format(t2 - t1))
def setup_voronoi_list(self, indices, voronoi_cutoff):
"""
Set up of the voronoi list of neighbours by calling qhull.
Args:
indices: indices of the sites for which the Voronoi is needed.
voronoi_cutoff: Voronoi cutoff for the search of neighbours.
Raises:
RuntimeError: If an infinite vertex is found in the voronoi construction.
"""
self.voronoi_list2 = [None] * len(self.structure)
self.voronoi_list_coords = [None] * len(self.structure)
logging.debug("Getting all neighbors in structure")
struct_neighbors = self.structure.get_all_neighbors(voronoi_cutoff, include_index=True)
t1 = time.process_time()
logging.debug("Setting up Voronoi list :")
for jj, isite in enumerate(indices):
logging.debug(" - Voronoi analysis for site #{:d} ({:d}/{:d})".format(isite, jj + 1, len(indices)))
site = self.structure[isite]
neighbors1 = [(site, 0.0, isite)]
neighbors1.extend(struct_neighbors[isite])
distances = [i[1] for i in sorted(neighbors1, key=lambda s: s[1])]
neighbors = [i[0] for i in sorted(neighbors1, key=lambda s: s[1])]
qvoronoi_input = [s.coords for s in neighbors]
voro = Voronoi(points=qvoronoi_input, qhull_options="o Fv")
all_vertices = voro.vertices
results2 = []
maxangle = 0.0
mindist = 10000.0
for iridge, ridge_points in enumerate(voro.ridge_points):
if 0 in ridge_points:
ridge_vertices_indices = voro.ridge_vertices[iridge]
if -1 in ridge_vertices_indices:
raise RuntimeError(
"This structure is pathological," " infinite vertex in the voronoi " "construction"
)
ridge_point2 = max(ridge_points)
facets = [all_vertices[i] for i in ridge_vertices_indices]
sa = my_solid_angle(site.coords, facets)
maxangle = max([sa, maxangle])
mindist = min([mindist, distances[ridge_point2]])
for iii, sss in enumerate(self.structure):
if neighbors[ridge_point2].is_periodic_image(sss, tolerance=1.0e-6):
myindex = iii
break
results2.append(
{
"site": neighbors[ridge_point2],
"angle": sa,
"distance": distances[ridge_point2],
"index": myindex,
}
)
for dd in results2:
dd["normalized_angle"] = dd["angle"] / maxangle
dd["normalized_distance"] = dd["distance"] / mindist
self.voronoi_list2[isite] = results2
self.voronoi_list_coords[isite] = np.array([dd["site"].coords for dd in results2])
t2 = time.process_time()
logging.debug("Voronoi list set up in {:.2f} seconds".format(t2 - t1))
def setup_neighbors_distances_and_angles(self, indices):
"""
Initializes the angle and distance separations.
Args:
indices: Indices of the sites for which the Voronoi is needed.
"""
self.neighbors_distances = [None] * len(self.structure)
self.neighbors_normalized_distances = [None] * len(self.structure)
self.neighbors_angles = [None] * len(self.structure)
self.neighbors_normalized_angles = [None] * len(self.structure)
for isite in indices:
results = self.voronoi_list2[isite]
if results is None:
continue
# Initializes neighbors distances and normalized distances groups
self.neighbors_distances[isite] = []
self.neighbors_normalized_distances[isite] = []
normalized_distances = [nb_dict["normalized_distance"] for nb_dict in results]
isorted_distances = np.argsort(normalized_distances)
self.neighbors_normalized_distances[isite].append(
{
"min": normalized_distances[isorted_distances[0]],
"max": normalized_distances[isorted_distances[0]],
}
)
self.neighbors_distances[isite].append(
{
"min": results[isorted_distances[0]]["distance"],
"max": results[isorted_distances[0]]["distance"],
}
)
icurrent = 0
nb_indices = {int(isorted_distances[0])}
dnb_indices = {int(isorted_distances[0])}
for idist in iter(isorted_distances):
wd = normalized_distances[idist]
if self.maximum_distance_factor is not None:
if wd > self.maximum_distance_factor:
self.neighbors_normalized_distances[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_distances[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_normalized_distances[isite][icurrent]["dnb_indices"] = list(dnb_indices)
self.neighbors_distances[isite][icurrent]["dnb_indices"] = list(dnb_indices)
break
if np.isclose(
wd,
self.neighbors_normalized_distances[isite][icurrent]["max"],
rtol=0.0,
atol=self.normalized_distance_tolerance,
):
self.neighbors_normalized_distances[isite][icurrent]["max"] = wd
self.neighbors_distances[isite][icurrent]["max"] = results[idist]["distance"]
dnb_indices.add(int(idist))
else:
self.neighbors_normalized_distances[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_distances[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_normalized_distances[isite][icurrent]["dnb_indices"] = list(dnb_indices)
self.neighbors_distances[isite][icurrent]["dnb_indices"] = list(dnb_indices)
dnb_indices = {int(idist)}
self.neighbors_normalized_distances[isite].append({"min": wd, "max": wd})
self.neighbors_distances[isite].append(
{
"min": results[idist]["distance"],
"max": results[idist]["distance"],
}
)
icurrent += 1
nb_indices.add(int(idist))
else:
self.neighbors_normalized_distances[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_distances[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_normalized_distances[isite][icurrent]["dnb_indices"] = list(dnb_indices)
self.neighbors_distances[isite][icurrent]["dnb_indices"] = list(dnb_indices)
for idist in range(len(self.neighbors_distances[isite]) - 1):
dist_dict = self.neighbors_distances[isite][idist]
dist_dict_next = self.neighbors_distances[isite][idist + 1]
dist_dict["next"] = dist_dict_next["min"]
ndist_dict = self.neighbors_normalized_distances[isite][idist]
ndist_dict_next = self.neighbors_normalized_distances[isite][idist + 1]
ndist_dict["next"] = ndist_dict_next["min"]
if self.maximum_distance_factor is not None:
dfact = self.maximum_distance_factor
else:
dfact = self.default_voronoi_cutoff / self.neighbors_distances[isite][0]["min"]
self.neighbors_normalized_distances[isite][-1]["next"] = dfact
self.neighbors_distances[isite][-1]["next"] = dfact * self.neighbors_distances[isite][0]["min"]
# Initializes neighbors angles and normalized angles groups
self.neighbors_angles[isite] = []
self.neighbors_normalized_angles[isite] = []
normalized_angles = [nb_dict["normalized_angle"] for nb_dict in results]
isorted_angles = np.argsort(normalized_angles)[::-1]
self.neighbors_normalized_angles[isite].append(
{
"max": normalized_angles[isorted_angles[0]],
"min": normalized_angles[isorted_angles[0]],
}
)
self.neighbors_angles[isite].append(
{
"max": results[isorted_angles[0]]["angle"],
"min": results[isorted_angles[0]]["angle"],
}
)
icurrent = 0
nb_indices = {int(isorted_angles[0])}
dnb_indices = {int(isorted_angles[0])}
for iang in iter(isorted_angles):
wa = normalized_angles[iang]
if self.minimum_angle_factor is not None:
if wa < self.minimum_angle_factor:
self.neighbors_normalized_angles[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_angles[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_normalized_angles[isite][icurrent]["dnb_indices"] = list(dnb_indices)
self.neighbors_angles[isite][icurrent]["dnb_indices"] = list(dnb_indices)
break
if np.isclose(
wa,
self.neighbors_normalized_angles[isite][icurrent]["min"],
rtol=0.0,
atol=self.normalized_angle_tolerance,
):
self.neighbors_normalized_angles[isite][icurrent]["min"] = wa
self.neighbors_angles[isite][icurrent]["min"] = results[iang]["angle"]
dnb_indices.add(int(iang))
else:
self.neighbors_normalized_angles[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_angles[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_normalized_angles[isite][icurrent]["dnb_indices"] = list(dnb_indices)
self.neighbors_angles[isite][icurrent]["dnb_indices"] = list(dnb_indices)
dnb_indices = {int(iang)}
self.neighbors_normalized_angles[isite].append({"max": wa, "min": wa})
self.neighbors_angles[isite].append({"max": results[iang]["angle"], "min": results[iang]["angle"]})
icurrent += 1
nb_indices.add(int(iang))
else:
self.neighbors_normalized_angles[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_angles[isite][icurrent]["nb_indices"] = list(nb_indices)
self.neighbors_normalized_angles[isite][icurrent]["dnb_indices"] = list(dnb_indices)
self.neighbors_angles[isite][icurrent]["dnb_indices"] = list(dnb_indices)
for iang in range(len(self.neighbors_angles[isite]) - 1):
ang_dict = self.neighbors_angles[isite][iang]
ang_dict_next = self.neighbors_angles[isite][iang + 1]
ang_dict["next"] = ang_dict_next["max"]
nang_dict = self.neighbors_normalized_angles[isite][iang]
nang_dict_next = self.neighbors_normalized_angles[isite][iang + 1]
nang_dict["next"] = nang_dict_next["max"]
if self.minimum_angle_factor is not None:
afact = self.minimum_angle_factor
else:
afact = 0.0
self.neighbors_normalized_angles[isite][-1]["next"] = afact
self.neighbors_angles[isite][-1]["next"] = afact * self.neighbors_angles[isite][0]["max"]
def _precompute_additional_conditions(self, ivoronoi, voronoi, valences):
additional_conditions = {ac: [] for ac in self.additional_conditions}
for ips, (ps, vals) in enumerate(voronoi):
for ac in self.additional_conditions:
additional_conditions[ac].append(
self.AC.check_condition(
condition=ac,
structure=self.structure,
parameters={
"valences": valences,
"neighbor_index": vals["index"],
"site_index": ivoronoi,
},
)
)
return additional_conditions
def _precompute_distance_conditions(self, ivoronoi, voronoi):
distance_conditions = []
for idp, dp_dict in enumerate(self.neighbors_normalized_distances[ivoronoi]):
distance_conditions.append([])
dp = dp_dict["max"]
for ips, (ps, vals) in enumerate(voronoi):
distance_conditions[idp].append(
vals["normalized_distance"] <= dp
or np.isclose(
vals["normalized_distance"],
dp,
rtol=0.0,
atol=self.normalized_distance_tolerance / 2.0,
)
)
return distance_conditions
def _precompute_angle_conditions(self, ivoronoi, voronoi):
angle_conditions = []
for iap, ap_dict in enumerate(self.neighbors_normalized_angles[ivoronoi]):
angle_conditions.append([])
ap = ap_dict["max"]
for ips, (ps, vals) in enumerate(voronoi):
angle_conditions[iap].append(
vals["normalized_angle"] >= ap
or np.isclose(
vals["normalized_angle"],
ap,
rtol=0.0,
atol=self.normalized_angle_tolerance / 2.0,
)
)
return angle_conditions
# def neighbors_map(self, isite, distfactor, angfactor, additional_condition):
# if self.neighbors_normalized_distances[isite] is None:
# return None
# dist_where = np.argwhere(
# np.array([wd['min'] for wd in self.neighbors_normalized_distances[isite]]) <= distfactor)
# if len(dist_where) == 0:
# return None
# idist = dist_where[-1][0]
# ang_where = np.argwhere(np.array([wa['max'] for wa in self.neighbors_normalized_angles[isite]]) >= angfactor)
# if len(ang_where) == 0:
# return None
# iang = ang_where[0][0]
# if self.additional_conditions.count(additional_condition) != 1:
# return None
# i_additional_condition = self.additional_conditions.index(additional_condition)
# return {'i_distfactor': idist, 'i_angfactor': iang, 'i_additional_condition': i_additional_condition}
def neighbors_surfaces(self, isite, surface_calculation_type=None, max_dist=2.0):
"""
Get the different surfaces corresponding to the different distance-angle cutoffs for a given site.
Args:
isite: Index of the site
surface_calculation_type: How to compute the surface.
max_dist: The maximum distance factor to be considered.
Returns:
Surfaces for each distance-angle cutoff.
"""
if self.voronoi_list2[isite] is None:
return None
bounds_and_limits = self.voronoi_parameters_bounds_and_limits(isite, surface_calculation_type, max_dist)
distance_bounds = bounds_and_limits["distance_bounds"]
angle_bounds = bounds_and_limits["angle_bounds"]
surfaces = np.zeros((len(distance_bounds), len(angle_bounds)), np.float_)
for idp in range(len(distance_bounds) - 1):
this_dist_plateau = distance_bounds[idp + 1] - distance_bounds[idp]
for iap in range(len(angle_bounds) - 1):
this_ang_plateau = angle_bounds[iap + 1] - angle_bounds[iap]
surfaces[idp][iap] = np.absolute(this_dist_plateau * this_ang_plateau)
return surfaces
def neighbors_surfaces_bounded(self, isite, surface_calculation_options=None):
"""
Get the different surfaces (using boundaries) corresponding to the different distance-angle cutoffs
for a given site.
Args:
isite: Index of the site.
surface_calculation_options: Options for the boundaries.
Returns:
Surfaces for each distance-angle cutoff.
"""
if self.voronoi_list2[isite] is None:
return None
if surface_calculation_options is None:
surface_calculation_options = {
"type": "standard_elliptic",
"distance_bounds": {"lower": 1.2, "upper": 1.8},
"angle_bounds": {"lower": 0.1, "upper": 0.8},
}
if surface_calculation_options["type"] in [
"standard_elliptic",
"standard_diamond",
"standard_spline",
]:
plot_type = {
"distance_parameter": ("initial_normalized", None),
"angle_parameter": ("initial_normalized", None),
}
else:
raise ValueError(
'Type "{}" for the surface calculation in DetailedVoronoiContainer '
"is invalid".format(surface_calculation_options["type"])
)
max_dist = surface_calculation_options["distance_bounds"]["upper"] + 0.1
bounds_and_limits = self.voronoi_parameters_bounds_and_limits(
isite=isite, plot_type=plot_type, max_dist=max_dist
)
distance_bounds = bounds_and_limits["distance_bounds"]
angle_bounds = bounds_and_limits["angle_bounds"]
lower_and_upper_functions = get_lower_and_upper_f(surface_calculation_options=surface_calculation_options)
mindist = surface_calculation_options["distance_bounds"]["lower"]
maxdist = surface_calculation_options["distance_bounds"]["upper"]
minang = surface_calculation_options["angle_bounds"]["lower"]
maxang = surface_calculation_options["angle_bounds"]["upper"]
f_lower = lower_and_upper_functions["lower"]
f_upper = lower_and_upper_functions["upper"]
surfaces = np.zeros((len(distance_bounds), len(angle_bounds)), np.float_)
for idp in range(len(distance_bounds) - 1):
dp1 = distance_bounds[idp]
dp2 = distance_bounds[idp + 1]
if dp2 < mindist or dp1 > maxdist:
continue
if dp1 < mindist:
d1 = mindist
else:
d1 = dp1
if dp2 > maxdist:
d2 = maxdist
else:
d2 = dp2
for iap in range(len(angle_bounds) - 1):
ap1 = angle_bounds[iap]
ap2 = angle_bounds[iap + 1]
if ap1 > ap2:
ap1 = angle_bounds[iap + 1]
ap2 = angle_bounds[iap]
if ap2 < minang or ap1 > maxang:
continue
intersection, interror = rectangle_surface_intersection(
rectangle=((d1, d2), (ap1, ap2)),
f_lower=f_lower,
f_upper=f_upper,
bounds_lower=[mindist, maxdist],
bounds_upper=[mindist, maxdist],
check=False,
)
surfaces[idp][iap] = intersection
return surfaces
@staticmethod
def _get_vertices_dist_ang_indices(parameter_indices_list):
pp0 = [pp[0] for pp in parameter_indices_list]
pp1 = [pp[1] for pp in parameter_indices_list]
min_idist = min(pp0)
min_iang = min(pp1)
max_idist = max(pp0)
max_iang = max(pp1)
i_min_angs = np.argwhere(np.array(pp1) == min_iang)
i_max_dists = np.argwhere(np.array(pp0) == max_idist)
pp0_at_min_iang = [pp0[ii[0]] for ii in i_min_angs]
pp1_at_max_idist = [pp1[ii[0]] for ii in i_max_dists]
max_idist_at_min_iang = max(pp0_at_min_iang)
min_iang_at_max_idist = min(pp1_at_max_idist)
p1 = (min_idist, min_iang)
p2 = (max_idist_at_min_iang, min_iang)
p3 = (max_idist_at_min_iang, min_iang_at_max_idist)
p4 = (max_idist, min_iang_at_max_idist)
p5 = (max_idist, max_iang)
p6 = (min_idist, max_iang)
return [p1, p2, p3, p4, p5, p6]
def maps_and_surfaces(
self,
isite,
surface_calculation_type=None,
max_dist=2.0,
additional_conditions=None,
):
"""
Get the different surfaces and their cn_map corresponding to the different distance-angle cutoffs
for a given site.
Args:
isite: Index of the site
surface_calculation_type: How to compute the surface.
max_dist: The maximum distance factor to be considered.
additional_conditions: If additional conditions have to be considered.
Returns:
Surfaces and cn_map's for each distance-angle cutoff.
"""
if self.voronoi_list2[isite] is None:
return None
if additional_conditions is None:
additional_conditions = [self.AC.ONLY_ACB]
surfaces = self.neighbors_surfaces(
isite=isite,
surface_calculation_type=surface_calculation_type,
max_dist=max_dist,
)
maps_and_surfaces = []
for cn, value in self._unique_coordinated_neighbors_parameters_indices[isite].items(): # pylint: disable=E1101
for imap, list_parameters_indices in enumerate(value):
thissurf = 0.0
for (idp, iap, iacb) in list_parameters_indices:
if iacb in additional_conditions:
thissurf += surfaces[idp, iap]
maps_and_surfaces.append(
{
"map": (cn, imap),
"surface": thissurf,
"parameters_indices": list_parameters_indices,
}
)
return maps_and_surfaces
def maps_and_surfaces_bounded(self, isite, surface_calculation_options=None, additional_conditions=None):
"""
Get the different surfaces (using boundaries) and their cn_map corresponding to the different
distance-angle cutoffs for a given site.
Args:
isite: Index of the site
surface_calculation_options: Options for the boundaries.
additional_conditions: If additional conditions have to be considered.
Returns:
Surfaces and cn_map's for each distance-angle cutoff.
"""
if self.voronoi_list2[isite] is None:
return None
if additional_conditions is None:
additional_conditions = [self.AC.ONLY_ACB]
surfaces = self.neighbors_surfaces_bounded(isite=isite, surface_calculation_options=surface_calculation_options)
maps_and_surfaces = []
for cn, value in self._unique_coordinated_neighbors_parameters_indices[isite].items(): # pylint: disable=E1101
for imap, list_parameters_indices in enumerate(value):
thissurf = 0.0
for (idp, iap, iacb) in list_parameters_indices:
if iacb in additional_conditions:
thissurf += surfaces[idp, iap]
maps_and_surfaces.append(
{
"map": (cn, imap),
"surface": thissurf,
"parameters_indices": list_parameters_indices,
}
)
return maps_and_surfaces
def neighbors(self, isite, distfactor, angfactor, additional_condition=None):
"""
Get the neighbors of a given site corresponding to a given distance and angle factor.
Args:
isite: Index of the site.
distfactor: Distance factor.
angfactor: Angle factor.
additional_condition: Additional condition to be used (currently not implemented).
Returns:
List of neighbors of the given site for the given distance and angle factors.
"""
idist = None
dfact = None
for iwd, wd in enumerate(self.neighbors_normalized_distances[isite]):
if distfactor >= wd["min"]:
idist = iwd
dfact = wd["max"]
else:
break
iang = None
afact = None
for iwa, wa in enumerate(self.neighbors_normalized_angles[isite]):
if angfactor <= wa["max"]:
iang = iwa
afact = wa["min"]
else:
break
if idist is None or iang is None:
raise ValueError("Distance or angle parameter not found ...")
return [
nb
for nb in self.voronoi_list2[isite]
if nb["normalized_distance"] <= dfact and nb["normalized_angle"] >= afact
]
def voronoi_parameters_bounds_and_limits(self, isite, plot_type, max_dist):
"""
Get the different boundaries and limits of the distance and angle factors for the given site.
Args:
isite: Index of the site.
plot_type: Types of distance/angle parameters to get.
max_dist: Maximum distance factor.
Returns:
Distance and angle bounds and limits.
"""
# Initializes the distance and angle parameters
if self.voronoi_list2[isite] is None:
return None
if plot_type is None:
plot_type = {
"distance_parameter": ("initial_inverse_opposite", None),
"angle_parameter": ("initial_opposite", None),
}
dd = [dist["min"] for dist in self.neighbors_normalized_distances[isite]]
dd[0] = 1.0
if plot_type["distance_parameter"][0] == "initial_normalized":
dd.append(max_dist)
distance_bounds = np.array(dd)
dist_limits = [1.0, max_dist]
elif plot_type["distance_parameter"][0] == "initial_inverse_opposite":
ddinv = [1.0 / dist for dist in dd]
ddinv.append(0.0)
distance_bounds = np.array([1.0 - invdist for invdist in ddinv])
dist_limits = [0.0, 1.0]
elif plot_type["distance_parameter"][0] == "initial_inverse3_opposite":
ddinv = [1.0 / dist ** 3.0 for dist in dd]
ddinv.append(0.0)
distance_bounds = np.array([1.0 - invdist for invdist in ddinv])
dist_limits = [0.0, 1.0]
else:
raise NotImplementedError(
'Plotting type "{}" ' "for the distance is not implemented".format(plot_type["distance_parameter"])
)
if plot_type["angle_parameter"][0] == "initial_normalized":
aa = [0.0]
aa.extend([ang["max"] for ang in self.neighbors_normalized_angles[isite]])
angle_bounds = np.array(aa)
elif plot_type["angle_parameter"][0] == "initial_opposite":
aa = [0.0]
aa.extend([ang["max"] for ang in self.neighbors_normalized_angles[isite]])
aa = [1.0 - ang for ang in aa]
angle_bounds = np.array(aa)
else:
raise NotImplementedError(
'Plotting type "{}" ' "for the angle is not implemented".format(plot_type["angle_parameter"])
)
ang_limits = [0.0, 1.0]
return {
"distance_bounds": distance_bounds,
"distance_limits": dist_limits,
"angle_bounds": angle_bounds,
"angle_limits": ang_limits,
}
def is_close_to(self, other, rtol=0.0, atol=1e-8):
"""
Whether two DetailedVoronoiContainer objects are close to each other.
Args:
other: Another DetailedVoronoiContainer to be compared with.
rtol: Relative tolerance to compare values.
atol: Absolute tolerance to compare values.
Returns:
True if the two DetailedVoronoiContainer are close to each other.
"""
isclose = (
np.isclose(
self.normalized_angle_tolerance,
other.normalized_angle_tolerance,
rtol=rtol,
atol=atol,
)
and np.isclose(
self.normalized_distance_tolerance,
other.normalized_distance_tolerance,
rtol=rtol,
atol=atol,
)
and self.additional_conditions == other.additional_conditions
and self.valences == other.valences
)
if not isclose:
return isclose
for isite, site_voronoi in enumerate(self.voronoi_list2):
self_to_other_nbs = {}
for inb, nb in enumerate(site_voronoi):
if nb is None:
if other.voronoi_list2[isite] is None:
continue
return False
if other.voronoi_list2[isite] is None:
return False
nb_other = None
for inb2, nb2 in enumerate(other.voronoi_list2[isite]):
if nb["site"] == nb2["site"]:
self_to_other_nbs[inb] = inb2
nb_other = nb2
break
if nb_other is None:
return False
if not np.isclose(nb["distance"], nb_other["distance"], rtol=rtol, atol=atol):
return False
if not np.isclose(nb["angle"], nb_other["angle"], rtol=rtol, atol=atol):
return False
if not np.isclose(
nb["normalized_distance"],
nb_other["normalized_distance"],
rtol=rtol,
atol=atol,
):
return False
if not np.isclose(
nb["normalized_angle"],
nb_other["normalized_angle"],
rtol=rtol,
atol=atol,
):
return False
if nb["index"] != nb_other["index"]:
return False
if nb["site"] != nb_other["site"]:
return False
return True
def get_rdf_figure(self, isite, normalized=True, figsize=None, step_function=None):
"""
Get the Radial Distribution Figure for a given site.
Args:
isite: Index of the site.
normalized: Whether to normalize distances.
figsize: Size of the figure.
step_function: Type of step function to be used for the RDF.
Returns:
Matplotlib figure.
"""
def dp_func(dp):
return 1.0 - 1.0 / np.power(dp, 3.0)
import matplotlib.pyplot as plt
if step_function is None:
step_function = {"type": "normal_cdf", "scale": 0.0001}
# Initializes the figure
if figsize is None:
fig = plt.figure()
else:
fig = plt.figure(figsize=figsize)
subplot = fig.add_subplot(111)
if normalized:
dists = self.neighbors_normalized_distances[isite]
else:
dists = self.neighbors_distances[isite]
if step_function["type"] == "step_function":
isorted = np.argsort([dd["min"] for dd in dists])
sorted_dists = [dists[ii]["min"] for ii in isorted]
dnb_dists = [len(dists[ii]["dnb_indices"]) for ii in isorted]
xx = [0.0]
yy = [0.0]
for idist, dist in enumerate(sorted_dists):
xx.append(dist)
xx.append(dist)
yy.append(yy[-1])
yy.append(yy[-1] + dnb_dists[idist])
xx.append(1.1 * xx[-1])
yy.append(yy[-1])
elif step_function["type"] == "normal_cdf":
scale = step_function["scale"]
mydists = [dp_func(dd["min"]) for dd in dists]
mydcns = [len(dd["dnb_indices"]) for dd in dists]
xx = np.linspace(0.0, 1.1 * max(mydists), num=500)
yy = np.zeros_like(xx)
for idist, dist in enumerate(mydists):
yy += mydcns[idist] * normal_cdf_step(xx, mean=dist, scale=scale)
else:
raise ValueError('Step function of type "{}" is not allowed'.format(step_function["type"]))
subplot.plot(xx, yy)
return fig
def get_sadf_figure(self, isite, normalized=True, figsize=None, step_function=None):
"""
Get the Solid Angle Distribution Figure for a given site.
Args:
isite: Index of the site.
normalized: Whether to normalize angles.
figsize: Size of the figure.
step_function: Type of step function to be used for the SADF.
Returns:
Matplotlib figure.
"""
def ap_func(ap):
return np.power(ap, -0.1)
import matplotlib.pyplot as plt
if step_function is None:
step_function = {"type": "step_function", "scale": 0.0001}
# Initializes the figure
if figsize is None:
fig = plt.figure()
else:
fig = plt.figure(figsize=figsize)
subplot = fig.add_subplot(111)
if normalized:
angs = self.neighbors_normalized_angles[isite]
else:
angs = self.neighbors_angles[isite]
if step_function["type"] == "step_function":
isorted = np.argsort([ap_func(aa["min"]) for aa in angs])
sorted_angs = [ap_func(angs[ii]["min"]) for ii in isorted]
dnb_angs = [len(angs[ii]["dnb_indices"]) for ii in isorted]
xx = [0.0]
yy = [0.0]
for iang, ang in enumerate(sorted_angs):
xx.append(ang)
xx.append(ang)
yy.append(yy[-1])
yy.append(yy[-1] + dnb_angs[iang])
xx.append(1.1 * xx[-1])
yy.append(yy[-1])
elif step_function["type"] == "normal_cdf":
scale = step_function["scale"]
myangs = [ap_func(aa["min"]) for aa in angs]
mydcns = [len(dd["dnb_indices"]) for dd in angs]
xx = np.linspace(0.0, 1.1 * max(myangs), num=500)
yy = np.zeros_like(xx)
for iang, ang in enumerate(myangs):
yy += mydcns[iang] * normal_cdf_step(xx, mean=ang, scale=scale)
else:
raise ValueError('Step function of type "{}" is not allowed'.format(step_function["type"]))
subplot.plot(xx, yy)
return fig
def __eq__(self, other):
return (
self.normalized_angle_tolerance == other.normalized_angle_tolerance
and self.normalized_distance_tolerance == other.normalized_distance_tolerance
and self.additional_conditions == other.additional_conditions
and self.valences == other.valences
and self.voronoi_list2 == other.voronoi_list2
and self.structure == other.structure
)
def __ne__(self, other):
return not self == other
def to_bson_voronoi_list2(self):
"""
Transforms the voronoi_list into a vlist + bson_nb_voro_list, that are BSON-encodable.
Returns:
[vlist, bson_nb_voro_list], to be used in the as_dict method.
"""
bson_nb_voro_list2 = [None] * len(self.voronoi_list2)
for ivoro, voro in enumerate(self.voronoi_list2):
if voro is None or voro == "None":
continue
site_voro = []
# {'site': neighbors[nn[1]],
# 'angle': sa,
# 'distance': distances[nn[1]],
# 'index': myindex}
for nb_dict in voro:
site = nb_dict["site"]
site_dict = {key: val for key, val in nb_dict.items() if key not in ["site"]}
# site_voro.append([ps.as_dict(), dd]) [float(c) for c in self.frac_coords]
diff = site.frac_coords - self.structure[nb_dict["index"]].frac_coords
site_voro.append([[nb_dict["index"], [float(c) for c in diff]], site_dict])
bson_nb_voro_list2[ivoro] = site_voro
return bson_nb_voro_list2
def as_dict(self):
"""
Bson-serializable dict representation of the VoronoiContainer.
Returns:
dictionary that is BSON-encodable.
"""
bson_nb_voro_list2 = self.to_bson_voronoi_list2()
return {
"@module": self.__class__.__module__,
"@class": self.__class__.__name__,
"bson_nb_voro_list2": bson_nb_voro_list2,
# "neighbors_lists": self.neighbors_lists,
"structure": self.structure.as_dict(),
"normalized_angle_tolerance": self.normalized_angle_tolerance,
"normalized_distance_tolerance": self.normalized_distance_tolerance,
"additional_conditions": self.additional_conditions,
"valences": self.valences,
"maximum_distance_factor": self.maximum_distance_factor,
"minimum_angle_factor": self.minimum_angle_factor,
}
@classmethod
def from_dict(cls, d):
"""
Reconstructs the VoronoiContainer object from a dict representation of the VoronoiContainer created using
the as_dict method.
Args:
d: dict representation of the VoronoiContainer object.
Returns:
VoronoiContainer object.
"""
structure = Structure.from_dict(d["structure"])
voronoi_list2 = from_bson_voronoi_list2(d["bson_nb_voro_list2"], structure)
maximum_distance_factor = d["maximum_distance_factor"] if "maximum_distance_factor" in d else None
minimum_angle_factor = d["minimum_angle_factor"] if "minimum_angle_factor" in d else None
return cls(
structure=structure,
voronoi_list2=voronoi_list2,
# neighbors_lists=neighbors_lists,
normalized_angle_tolerance=d["normalized_angle_tolerance"],
normalized_distance_tolerance=d["normalized_distance_tolerance"],
additional_conditions=d["additional_conditions"],
valences=d["valences"],
maximum_distance_factor=maximum_distance_factor,
minimum_angle_factor=minimum_angle_factor,
)
|
mit
|
[
3,
2803,
26,
2774,
13,
24,
199,
3,
1898,
334,
67,
9,
1611,
30649,
15290,
11682,
14,
199,
3,
17484,
1334,
314,
2895,
402,
314,
10697,
844,
14,
421,
199,
624,
199,
2765,
859,
3509,
314,
909,
1202,
370,
13743,
314,
3962,
23672,
770,
14503,
4079,
641,
282,
812,
269,
265,
16142,
11284,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
298,
36,
17204,
644,
285,
79,
783,
1192,
2,
199,
363,
7307,
363,
275,
298,
7384,
6029,
12,
710,
26570,
83,
7290,
2,
199,
363,
22461,
363,
275,
298,
4240,
1997,
4813,
869,
65,
935,
281,
2,
199,
363,
1023,
363,
275,
298,
18,
14,
16,
2,
199,
363,
26665,
363,
275,
298,
36,
17204,
644,
285,
79,
783,
1192,
2,
199,
363,
2123,
363,
275,
298,
983,
5017,
14,
3281,
79,
783,
1192,
32,
6799,
14,
957,
2,
199,
363,
602,
363,
275,
298,
27717,
3388,
12,
7800,
2,
199,
199,
646,
2050,
199,
646,
900,
199,
199,
646,
2680,
465,
980,
199,
504,
3485,
369,
14,
1001,
492,
603,
3377,
461,
199,
504,
7026,
14,
11679,
492,
812,
269,
265,
16142,
199,
199,
504,
1134,
30649,
14,
10466,
14,
595,
1410,
86,
14,
1208,
14,
7988,
3155,
63,
7660,
63,
1208,
492,
334,
272,
664,
63,
2325,
63,
460,
63,
4142,
63,
70,
12,
272,
3002,
63,
18533,
63,
4593,
12,
272,
20412,
63,
10992,
63,
12569,
12,
199,
9,
199,
504,
1134,
30649,
14,
10466,
14,
595,
1410,
86,
14,
1208,
14,
8710,
63,
1208,
492,
10961,
23107,
199,
504,
1134,
30649,
14,
10466,
14,
595,
1410,
86,
14,
1208,
14,
3442,
63,
1208,
492,
3293,
63,
10790,
63,
2926,
199,
504,
1134,
30649,
14,
1018,
14,
8619,
492,
3492,
11273,
8972,
199,
504,
1134,
30649,
14,
1018,
14,
6976,
492,
21730,
421,
199,
318,
687,
63,
66,
834,
63,
14419,
265,
16142,
63,
513,
18,
8,
66,
834,
63,
4994,
63,
14419,
79,
63,
513,
18,
12,
5523,
304,
272,
408,
272,
1803,
314,
373,
269,
265,
16142,
63,
513,
4346,
367,
314,
812,
269,
265,
16142,
4076,
909,
687,
282,
330,
834,
13,
8167,
373,
269,
265,
16142,
63,
513,
14,
339,
3033,
26,
267,
330,
834,
63,
4994,
63,
14419,
79,
63,
513,
18,
26,
3820,
402,
18745,
15424,
28244,
315,
314,
812,
269,
265,
16142,
14,
267,
5523,
26,
21730,
909,
14,
339,
1803,
26,
267,
710,
373,
269,
265,
16142,
63,
513,
4346,
367,
314,
812,
269,
265,
16142,
4076,
334,
1045,
3492,
11273,
51,
4033,
465,
2883,
402,
314,
2600,
446,
440,
267,
4370,
315,
314,
699,
3377,
1475,
680,
272,
408,
272,
373,
269,
265,
16142,
63,
513,
275,
359,
403,
61,
627,
822,
8,
66,
834,
63,
4994,
63,
14419,
79,
63,
513,
18,
9,
272,
367,
284,
2124,
12,
373,
269,
79,
315,
3874,
8,
66,
834,
63,
4994,
63,
14419,
79,
63,
513,
18,
304,
267,
340,
373,
269,
79,
365,
488,
503,
373,
269,
79,
508,
298,
403,
582,
288,
1980,
267,
373,
269,
265,
16142,
63,
513,
59,
73,
2124,
61,
275,
942,
267,
367,
299,
3893,
12,
13972,
315,
373,
269,
79,
26,
288,
2702,
63,
2124,
275,
5523,
59,
617,
905,
1080,
15261,
288,
18745,
63,
2124,
275,
3492,
11273,
8972,
8,
355,
2702,
63,
2124,
423,
17168,
12,
355,
2702,
63,
2124,
14,
10865,
63,
8032,
435,
299,
3893,
59,
17,
467,
355,
2702,
63,
2124,
423,
25553,
12,
355,
4382,
29,
1820,
63,
2124,
14,
3282,
12,
288,
776,
288,
13972,
905,
2124,
937,
275,
18745,
63,
2124,
288,
373,
269,
265,
16142,
63,
513,
59,
73,
2124,
1055,
740,
8,
617,
9,
272,
372,
373,
269,
265,
16142,
63,
513,
421,
199,
533,
577,
1841,
1672,
54,
269,
265,
16142,
4076,
8,
3053,
615,
461,
304,
272,
408,
272,
8089,
1202,
370,
3877,
314,
2615,
812,
269,
265,
16142,
402,
282,
1627,
5523,
14,
272,
408,
339,
6570,
275,
10961,
23107,
342,
272,
849,
63,
14419,
265,
16142,
63,
17708,
275,
1616,
14,
16,
272,
849,
63,
12916,
63,
5590,
63,
16312,
275,
413,
69,
13,
21,
272,
849,
63,
12916,
63,
4593,
63,
16312,
275,
413,
69,
13,
19,
339,
347,
636,
826,
721,
267,
291,
12,
267,
5523,
29,
403,
12,
267,
373,
269,
265,
16142,
63,
513,
18,
29,
403,
12,
267,
373,
269,
265,
16142,
63,
17708,
29,
885,
63,
14419,
265,
16142,
63,
17708,
12,
267,
284,
8619,
29,
403,
12,
267,
9657,
63,
5590,
63,
16312,
29,
885,
63,
12916,
63,
5590,
63,
16312,
12,
267,
9657,
63,
4593,
63,
16312,
29,
885,
63,
12916,
63,
4593,
63,
16312,
12,
267,
4722,
63,
9855,
29,
403,
12,
267,
373,
20634,
823,
29,
403,
12,
267,
5696,
63,
5590,
63,
4778,
29,
403,
12,
267,
7481,
63,
4593,
63,
4778,
29,
403,
12,
272,
3461,
267,
408,
267,
20297,
367,
314,
812,
269,
265,
16142,
4076,
909,
14,
13083,
282,
5523,
365,
1627,
12,
315,
1314,
1930,
314,
812,
269,
265,
16142,
365,
267,
9235,
12,
503,
314,
3365,
7323,
402,
314,
812,
269,
265,
16142,
4076,
787,
1627,
334,
2972,
315,
314,
687,
63,
807,
1083,
680,
398,
3033,
26,
288,
5523,
26,
21730,
367,
1314,
314,
812,
269,
265,
16142,
365,
9235,
14,
288,
373,
269,
265,
16142,
63,
513,
18,
26,
3820,
402,
373,
269,
265,
16142,
8446,
19985,
2641,
83,
367,
1924,
4770,
14,
288,
373,
269,
265,
16142,
63,
17708,
26,
17875,
1202,
367,
314,
373,
269,
265,
16142,
14,
288,
284,
8619,
26,
4918,
402,
15424,
367,
1314,
314,
812,
269,
265,
16142,
965,
370,
506,
9235,
14,
288,
9657,
63,
5590,
63,
16312,
26,
4005,
8807,
367,
2877,
9657,
15108,
370,
506,
8652,
4472,
14,
288,
9657,
63,
4593,
63,
16312,
26,
1378,
8807,
367,
2877,
9657,
22597,
370,
506,
8652,
4472,
14,
288,
4722,
63,
9855,
26,
10961,
3704,
370,
506,
1202,
14,
288,
373,
20634,
823,
26,
812,
20634,
823,
402,
1006,
314,
15424,
315,
314,
5523,
334,
2972,
1380,
4722,
3704,
4409,
652,
680,
288,
5696,
63,
5590,
63,
4778,
26,
710,
5696,
6033,
6535,
370,
506,
8652,
14,
288,
7481,
63,
4593,
63,
4778,
26,
710
] |
[
2803,
26,
2774,
13,
24,
199,
3,
1898,
334,
67,
9,
1611,
30649,
15290,
11682,
14,
199,
3,
17484,
1334,
314,
2895,
402,
314,
10697,
844,
14,
421,
199,
624,
199,
2765,
859,
3509,
314,
909,
1202,
370,
13743,
314,
3962,
23672,
770,
14503,
4079,
641,
282,
812,
269,
265,
16142,
11284,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
298,
36,
17204,
644,
285,
79,
783,
1192,
2,
199,
363,
7307,
363,
275,
298,
7384,
6029,
12,
710,
26570,
83,
7290,
2,
199,
363,
22461,
363,
275,
298,
4240,
1997,
4813,
869,
65,
935,
281,
2,
199,
363,
1023,
363,
275,
298,
18,
14,
16,
2,
199,
363,
26665,
363,
275,
298,
36,
17204,
644,
285,
79,
783,
1192,
2,
199,
363,
2123,
363,
275,
298,
983,
5017,
14,
3281,
79,
783,
1192,
32,
6799,
14,
957,
2,
199,
363,
602,
363,
275,
298,
27717,
3388,
12,
7800,
2,
199,
199,
646,
2050,
199,
646,
900,
199,
199,
646,
2680,
465,
980,
199,
504,
3485,
369,
14,
1001,
492,
603,
3377,
461,
199,
504,
7026,
14,
11679,
492,
812,
269,
265,
16142,
199,
199,
504,
1134,
30649,
14,
10466,
14,
595,
1410,
86,
14,
1208,
14,
7988,
3155,
63,
7660,
63,
1208,
492,
334,
272,
664,
63,
2325,
63,
460,
63,
4142,
63,
70,
12,
272,
3002,
63,
18533,
63,
4593,
12,
272,
20412,
63,
10992,
63,
12569,
12,
199,
9,
199,
504,
1134,
30649,
14,
10466,
14,
595,
1410,
86,
14,
1208,
14,
8710,
63,
1208,
492,
10961,
23107,
199,
504,
1134,
30649,
14,
10466,
14,
595,
1410,
86,
14,
1208,
14,
3442,
63,
1208,
492,
3293,
63,
10790,
63,
2926,
199,
504,
1134,
30649,
14,
1018,
14,
8619,
492,
3492,
11273,
8972,
199,
504,
1134,
30649,
14,
1018,
14,
6976,
492,
21730,
421,
199,
318,
687,
63,
66,
834,
63,
14419,
265,
16142,
63,
513,
18,
8,
66,
834,
63,
4994,
63,
14419,
79,
63,
513,
18,
12,
5523,
304,
272,
408,
272,
1803,
314,
373,
269,
265,
16142,
63,
513,
4346,
367,
314,
812,
269,
265,
16142,
4076,
909,
687,
282,
330,
834,
13,
8167,
373,
269,
265,
16142,
63,
513,
14,
339,
3033,
26,
267,
330,
834,
63,
4994,
63,
14419,
79,
63,
513,
18,
26,
3820,
402,
18745,
15424,
28244,
315,
314,
812,
269,
265,
16142,
14,
267,
5523,
26,
21730,
909,
14,
339,
1803,
26,
267,
710,
373,
269,
265,
16142,
63,
513,
4346,
367,
314,
812,
269,
265,
16142,
4076,
334,
1045,
3492,
11273,
51,
4033,
465,
2883,
402,
314,
2600,
446,
440,
267,
4370,
315,
314,
699,
3377,
1475,
680,
272,
408,
272,
373,
269,
265,
16142,
63,
513,
275,
359,
403,
61,
627,
822,
8,
66,
834,
63,
4994,
63,
14419,
79,
63,
513,
18,
9,
272,
367,
284,
2124,
12,
373,
269,
79,
315,
3874,
8,
66,
834,
63,
4994,
63,
14419,
79,
63,
513,
18,
304,
267,
340,
373,
269,
79,
365,
488,
503,
373,
269,
79,
508,
298,
403,
582,
288,
1980,
267,
373,
269,
265,
16142,
63,
513,
59,
73,
2124,
61,
275,
942,
267,
367,
299,
3893,
12,
13972,
315,
373,
269,
79,
26,
288,
2702,
63,
2124,
275,
5523,
59,
617,
905,
1080,
15261,
288,
18745,
63,
2124,
275,
3492,
11273,
8972,
8,
355,
2702,
63,
2124,
423,
17168,
12,
355,
2702,
63,
2124,
14,
10865,
63,
8032,
435,
299,
3893,
59,
17,
467,
355,
2702,
63,
2124,
423,
25553,
12,
355,
4382,
29,
1820,
63,
2124,
14,
3282,
12,
288,
776,
288,
13972,
905,
2124,
937,
275,
18745,
63,
2124,
288,
373,
269,
265,
16142,
63,
513,
59,
73,
2124,
1055,
740,
8,
617,
9,
272,
372,
373,
269,
265,
16142,
63,
513,
421,
199,
533,
577,
1841,
1672,
54,
269,
265,
16142,
4076,
8,
3053,
615,
461,
304,
272,
408,
272,
8089,
1202,
370,
3877,
314,
2615,
812,
269,
265,
16142,
402,
282,
1627,
5523,
14,
272,
408,
339,
6570,
275,
10961,
23107,
342,
272,
849,
63,
14419,
265,
16142,
63,
17708,
275,
1616,
14,
16,
272,
849,
63,
12916,
63,
5590,
63,
16312,
275,
413,
69,
13,
21,
272,
849,
63,
12916,
63,
4593,
63,
16312,
275,
413,
69,
13,
19,
339,
347,
636,
826,
721,
267,
291,
12,
267,
5523,
29,
403,
12,
267,
373,
269,
265,
16142,
63,
513,
18,
29,
403,
12,
267,
373,
269,
265,
16142,
63,
17708,
29,
885,
63,
14419,
265,
16142,
63,
17708,
12,
267,
284,
8619,
29,
403,
12,
267,
9657,
63,
5590,
63,
16312,
29,
885,
63,
12916,
63,
5590,
63,
16312,
12,
267,
9657,
63,
4593,
63,
16312,
29,
885,
63,
12916,
63,
4593,
63,
16312,
12,
267,
4722,
63,
9855,
29,
403,
12,
267,
373,
20634,
823,
29,
403,
12,
267,
5696,
63,
5590,
63,
4778,
29,
403,
12,
267,
7481,
63,
4593,
63,
4778,
29,
403,
12,
272,
3461,
267,
408,
267,
20297,
367,
314,
812,
269,
265,
16142,
4076,
909,
14,
13083,
282,
5523,
365,
1627,
12,
315,
1314,
1930,
314,
812,
269,
265,
16142,
365,
267,
9235,
12,
503,
314,
3365,
7323,
402,
314,
812,
269,
265,
16142,
4076,
787,
1627,
334,
2972,
315,
314,
687,
63,
807,
1083,
680,
398,
3033,
26,
288,
5523,
26,
21730,
367,
1314,
314,
812,
269,
265,
16142,
365,
9235,
14,
288,
373,
269,
265,
16142,
63,
513,
18,
26,
3820,
402,
373,
269,
265,
16142,
8446,
19985,
2641,
83,
367,
1924,
4770,
14,
288,
373,
269,
265,
16142,
63,
17708,
26,
17875,
1202,
367,
314,
373,
269,
265,
16142,
14,
288,
284,
8619,
26,
4918,
402,
15424,
367,
1314,
314,
812,
269,
265,
16142,
965,
370,
506,
9235,
14,
288,
9657,
63,
5590,
63,
16312,
26,
4005,
8807,
367,
2877,
9657,
15108,
370,
506,
8652,
4472,
14,
288,
9657,
63,
4593,
63,
16312,
26,
1378,
8807,
367,
2877,
9657,
22597,
370,
506,
8652,
4472,
14,
288,
4722,
63,
9855,
26,
10961,
3704,
370,
506,
1202,
14,
288,
373,
20634,
823,
26,
812,
20634,
823,
402,
1006,
314,
15424,
315,
314,
5523,
334,
2972,
1380,
4722,
3704,
4409,
652,
680,
288,
5696,
63,
5590,
63,
4778,
26,
710,
5696,
6033,
6535,
370,
506,
8652,
14,
288,
7481,
63,
4593,
63,
4778,
26,
710,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
abesto/fig
|
tests/unit/split_buffer_test.py
|
3
|
1474
|
from __future__ import unicode_literals
from __future__ import absolute_import
from compose.cli.utils import split_buffer
from .. import unittest
class SplitBufferTest(unittest.TestCase):
def test_single_line_chunks(self):
def reader():
yield b'abc\n'
yield b'def\n'
yield b'ghi\n'
self.assert_produces(reader, [b'abc\n', b'def\n', b'ghi\n'])
def test_no_end_separator(self):
def reader():
yield b'abc\n'
yield b'def\n'
yield b'ghi'
self.assert_produces(reader, [b'abc\n', b'def\n', b'ghi'])
def test_multiple_line_chunk(self):
def reader():
yield b'abc\ndef\nghi'
self.assert_produces(reader, [b'abc\n', b'def\n', b'ghi'])
def test_chunked_line(self):
def reader():
yield b'a'
yield b'b'
yield b'c'
yield b'\n'
yield b'd'
self.assert_produces(reader, [b'abc\n', b'd'])
def test_preserves_unicode_sequences_within_lines(self):
string = u"a\u2022c\n".encode('utf-8')
def reader():
yield string
self.assert_produces(reader, [string])
def assert_produces(self, reader, expectations):
split = split_buffer(reader(), b'\n')
for (actual, expected) in zip(split, expectations):
self.assertEqual(type(actual), type(expected))
self.assertEqual(actual, expected)
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
23366,
14,
2764,
14,
1208,
492,
3715,
63,
2738,
199,
504,
2508,
492,
2882,
199,
199,
533,
11740,
3299,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
4780,
63,
604,
63,
10660,
8,
277,
304,
267,
347,
7002,
837,
288,
1995,
330,
7,
3175,
60,
78,
7,
288,
1995,
330,
5121,
2829,
60,
78,
7,
288,
1995,
330,
7,
3561,
73,
60,
78,
7,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
66,
7,
3175,
60,
78,
297,
330,
5121,
2829,
60,
78,
297,
330,
7,
3561,
73,
60,
78,
1105,
339,
347,
511,
63,
889,
63,
500,
63,
9896,
8,
277,
304,
267,
347,
7002,
837,
288,
1995,
330,
7,
3175,
60,
78,
7,
288,
1995,
330,
5121,
2829,
60,
78,
7,
288,
1995,
330,
7,
3561,
73,
7,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
66,
7,
3175,
60,
78,
297,
330,
5121,
2829,
60,
78,
297,
330,
7,
3561,
73,
1105,
339,
347,
511,
63,
6048,
63,
604,
63,
4604,
8,
277,
304,
267,
347,
7002,
837,
288,
1995,
330,
7,
3175,
60,
18467,
60,
2753,
5812,
7,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
66,
7,
3175,
60,
78,
297,
330,
5121,
2829,
60,
78,
297,
330,
7,
3561,
73,
1105,
339,
347,
511,
63,
19955,
63,
604,
8,
277,
304,
267,
347,
7002,
837,
288,
1995,
330,
7,
65,
7,
288,
1995,
330,
7,
66,
7,
288,
1995,
330,
7,
67,
7,
288,
1995,
330,
1154,
78,
7,
288,
1995,
330,
5121,
7,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
66,
7,
3175,
60,
78,
297,
330,
5121,
1105,
339,
347,
511,
63,
657,
20603,
63,
2975,
63,
13436,
63,
12541,
63,
1278,
8,
277,
304,
267,
1059,
275,
399,
2,
65,
60,
85,
13859,
67,
60,
78,
1674,
2143,
360,
1624,
13,
24,
358,
398,
347,
7002,
837,
288,
1995,
1059,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
875,
566,
339,
347,
702,
63,
24658,
8,
277,
12,
7002,
12,
21851,
304,
267,
3715,
275,
3715,
63,
2738,
8,
5503,
1062,
330,
1154,
78,
358,
398,
367,
334,
6514,
12,
1420,
9,
315,
3482,
8,
1294,
12,
21851,
304,
288,
291,
14,
629,
8,
466,
8,
6514,
395,
730,
8,
2062,
430,
288,
291,
14,
629,
8,
6514,
12,
1420,
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
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
23366,
14,
2764,
14,
1208,
492,
3715,
63,
2738,
199,
504,
2508,
492,
2882,
199,
199,
533,
11740,
3299,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
4780,
63,
604,
63,
10660,
8,
277,
304,
267,
347,
7002,
837,
288,
1995,
330,
7,
3175,
60,
78,
7,
288,
1995,
330,
5121,
2829,
60,
78,
7,
288,
1995,
330,
7,
3561,
73,
60,
78,
7,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
66,
7,
3175,
60,
78,
297,
330,
5121,
2829,
60,
78,
297,
330,
7,
3561,
73,
60,
78,
1105,
339,
347,
511,
63,
889,
63,
500,
63,
9896,
8,
277,
304,
267,
347,
7002,
837,
288,
1995,
330,
7,
3175,
60,
78,
7,
288,
1995,
330,
5121,
2829,
60,
78,
7,
288,
1995,
330,
7,
3561,
73,
7,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
66,
7,
3175,
60,
78,
297,
330,
5121,
2829,
60,
78,
297,
330,
7,
3561,
73,
1105,
339,
347,
511,
63,
6048,
63,
604,
63,
4604,
8,
277,
304,
267,
347,
7002,
837,
288,
1995,
330,
7,
3175,
60,
18467,
60,
2753,
5812,
7,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
66,
7,
3175,
60,
78,
297,
330,
5121,
2829,
60,
78,
297,
330,
7,
3561,
73,
1105,
339,
347,
511,
63,
19955,
63,
604,
8,
277,
304,
267,
347,
7002,
837,
288,
1995,
330,
7,
65,
7,
288,
1995,
330,
7,
66,
7,
288,
1995,
330,
7,
67,
7,
288,
1995,
330,
1154,
78,
7,
288,
1995,
330,
5121,
7,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
66,
7,
3175,
60,
78,
297,
330,
5121,
1105,
339,
347,
511,
63,
657,
20603,
63,
2975,
63,
13436,
63,
12541,
63,
1278,
8,
277,
304,
267,
1059,
275,
399,
2,
65,
60,
85,
13859,
67,
60,
78,
1674,
2143,
360,
1624,
13,
24,
358,
398,
347,
7002,
837,
288,
1995,
1059,
398,
291,
14,
479,
63,
24658,
8,
5503,
12,
359,
875,
566,
339,
347,
702,
63,
24658,
8,
277,
12,
7002,
12,
21851,
304,
267,
3715,
275,
3715,
63,
2738,
8,
5503,
1062,
330,
1154,
78,
358,
398,
367,
334,
6514,
12,
1420,
9,
315,
3482,
8,
1294,
12,
21851,
304,
288,
291,
14,
629,
8,
466,
8,
6514,
395,
730,
8,
2062,
430,
288,
291,
14,
629,
8,
6514,
12,
1420,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
havard024/prego
|
crm/lib/python2.7/site-packages/sphinx/domains/rst.py
|
11
|
4254
|
# -*- coding: utf-8 -*-
"""
sphinx.domains.rst
~~~~~~~~~~~~~~~~~~
The reStructuredText domain.
:copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
from sphinx import addnodes
from sphinx.domains import Domain, ObjType
from sphinx.locale import l_, _
from sphinx.directives import ObjectDescription
from sphinx.roles import XRefRole
from sphinx.util.nodes import make_refnode
dir_sig_re = re.compile(r'\.\. (.+?)::(.*)$')
class ReSTMarkup(ObjectDescription):
"""
Description of generic reST markup.
"""
def add_target_and_index(self, name, sig, signode):
targetname = self.objtype + '-' + name
if targetname not in self.state.document.ids:
signode['names'].append(targetname)
signode['ids'].append(targetname)
signode['first'] = (not self.names)
self.state.document.note_explicit_target(signode)
objects = self.env.domaindata['rst']['objects']
key = (self.objtype, name)
if key in objects:
self.state_machine.reporter.warning(
'duplicate description of %s %s, ' % (self.objtype, name) +
'other instance in ' + self.env.doc2path(objects[key]),
line=self.lineno)
objects[key] = self.env.docname
indextext = self.get_index_text(self.objtype, name)
if indextext:
self.indexnode['entries'].append(('single', indextext,
targetname, ''))
def get_index_text(self, objectname, name):
if self.objtype == 'directive':
return _('%s (directive)') % name
elif self.objtype == 'role':
return _('%s (role)') % name
return ''
def parse_directive(d):
"""Parse a directive signature.
Returns (directive, arguments) string tuple. If no arguments are given,
returns (directive, '').
"""
dir = d.strip()
if not dir.startswith('.'):
# Assume it is a directive without syntax
return (dir, '')
m = dir_sig_re.match(dir)
if not m:
return (dir, '')
parsed_dir, parsed_args = m.groups()
return (parsed_dir.strip(), ' ' + parsed_args.strip())
class ReSTDirective(ReSTMarkup):
"""
Description of a reST directive.
"""
def handle_signature(self, sig, signode):
name, args = parse_directive(sig)
desc_name = '.. %s::' % name
signode += addnodes.desc_name(desc_name, desc_name)
if len(args) > 0:
signode += addnodes.desc_addname(args, args)
return name
class ReSTRole(ReSTMarkup):
"""
Description of a reST role.
"""
def handle_signature(self, sig, signode):
signode += addnodes.desc_name(':%s:' % sig, ':%s:' % sig)
return sig
class ReSTDomain(Domain):
"""ReStructuredText domain."""
name = 'rst'
label = 'reStructuredText'
object_types = {
'directive': ObjType(l_('directive'), 'dir'),
'role': ObjType(l_('role'), 'role'),
}
directives = {
'directive': ReSTDirective,
'role': ReSTRole,
}
roles = {
'dir': XRefRole(),
'role': XRefRole(),
}
initial_data = {
'objects': {}, # fullname -> docname, objtype
}
def clear_doc(self, docname):
for (typ, name), doc in self.data['objects'].items():
if doc == docname:
del self.data['objects'][typ, name]
def resolve_xref(self, env, fromdocname, builder, typ, target, node,
contnode):
objects = self.data['objects']
objtypes = self.objtypes_for_role(typ)
for objtype in objtypes:
if (objtype, target) in objects:
return make_refnode(builder, fromdocname,
objects[objtype, target],
objtype + '-' + target,
contnode, target + ' ' + objtype)
def get_objects(self):
for (typ, name), docname in self.data['objects'].iteritems():
yield name, name, typ, docname, typ + '-' + name, 1
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
15882,
14,
9756,
14,
8332,
272,
18294,
1714,
339,
710,
295,
27486,
1872,
2881,
14,
339,
520,
7307,
26,
1898,
10219,
13,
7280,
701,
314,
10229,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
646,
295,
199,
199,
504,
15882,
492,
1050,
2415,
199,
504,
15882,
14,
9756,
492,
14061,
12,
24921,
804,
199,
504,
15882,
14,
5508,
492,
634,
3131,
485,
199,
504,
15882,
14,
23216,
492,
6935,
5831,
199,
504,
15882,
14,
8050,
492,
1323,
2891,
7422,
199,
504,
15882,
14,
1974,
14,
2415,
492,
1852,
63,
1121,
932,
421,
199,
694,
63,
4093,
63,
264,
275,
295,
14,
2014,
8,
82,
1154,
3134,
14,
334,
11198,
304,
20334,
12432,
9988,
421,
199,
533,
799,
840,
23393,
8,
1692,
5831,
304,
272,
408,
272,
11994,
402,
7809,
20883,
9189,
14,
272,
408,
339,
347,
1050,
63,
1375,
63,
460,
63,
1080,
8,
277,
12,
536,
12,
5259,
12,
5259,
932,
304,
267,
1347,
354,
275,
291,
14,
1113,
466,
435,
10791,
435,
536,
267,
340,
1347,
354,
440,
315,
291,
14,
929,
14,
3554,
14,
1580,
26,
288,
5259,
932,
459,
1247,
2278,
740,
8,
1375,
354,
9,
288,
5259,
932,
459,
1580,
2278,
740,
8,
1375,
354,
9,
288,
5259,
932,
459,
2246,
418,
275,
334,
1397,
291,
14,
1247,
9,
288,
291,
14,
929,
14,
3554,
14,
4610,
63,
10306,
63,
1375,
8,
1037,
380,
9,
953,
2251,
275,
291,
14,
1813,
14,
2261,
576,
459,
8332,
2545,
1462,
418,
288,
790,
275,
334,
277,
14,
1113,
466,
12,
536,
9,
288,
340,
790,
315,
2251,
26,
355,
291,
14,
929,
63,
6744,
14,
12222,
14,
3764,
8,
490,
283,
11081,
1369,
402,
450,
83,
450,
83,
12,
283,
450,
334,
277,
14,
1113,
466,
12,
536,
9,
435,
490,
283,
1848,
1256,
315,
283,
435,
291,
14,
1813,
14,
1301,
18,
515,
8,
1462,
59,
498,
2522,
490,
1004,
29,
277,
14,
3469,
9,
288,
2251,
59,
498,
61,
275,
291,
14,
1813,
14,
21828,
267,
1478,
505,
275,
291,
14,
362,
63,
1080,
63,
505,
8,
277,
14,
1113,
466,
12,
536,
9,
267,
340,
1478,
505,
26,
288,
291,
14,
1080,
932,
459,
3189,
2278,
740,
4725,
4780,
297,
1478,
505,
12,
6343,
1347,
354,
12,
12381,
339,
347,
664,
63,
1080,
63,
505,
8,
277,
12,
909,
354,
12,
536,
304,
267,
340,
291,
14,
1113,
466,
508,
283,
15047,
356,
288,
372,
485,
3508,
83,
334,
15047,
5942,
450,
536,
267,
916,
291,
14,
1113,
466,
508,
283,
3756,
356,
288,
372,
485,
3508,
83,
334,
3756,
5942,
450,
536,
267,
372,
2125,
421,
199,
318,
2198,
63,
15047,
8,
68,
304,
272,
408,
4003,
282,
13613,
4955,
14,
339,
1803,
334,
15047,
12,
2368,
9,
1059,
2008,
14,
221,
982,
949,
2368,
787,
1627,
12,
272,
2529,
334,
15047,
12,
12548,
272,
408,
272,
2935,
275,
366,
14,
1913,
342,
272,
340,
440,
2935,
14,
2460,
26461,
267,
327,
16269,
652,
365,
282,
13613,
1928,
6302,
267,
372,
334,
694,
12,
4074,
272,
333,
275,
2935,
63,
4093,
63,
264,
14,
1431,
8,
694,
9,
272,
340,
440,
333,
26,
267,
372,
334,
694,
12,
4074,
272,
4565,
63,
694,
12,
4565,
63,
589,
275,
333,
14,
2634,
342,
272,
372,
334,
6751,
63,
694,
14,
1913,
1062,
283,
283,
435,
4565,
63,
589,
14,
1913,
1012,
421,
199,
533,
799,
840,
29489,
8,
497,
840,
23393,
304,
272,
408,
272,
11994,
402,
282,
20883,
13613,
14,
272,
408,
272,
347,
2429,
63,
5233,
8,
277,
12,
5259,
12,
5259,
932,
304,
267,
536,
12,
1249,
275,
2198,
63,
15047,
8,
4093,
9,
267,
4328,
63,
354,
275,
11541,
450,
83,
447,
7,
450,
536,
267,
5259,
932,
847,
1050,
2415,
14,
3257,
63,
354,
8,
3257,
63,
354,
12,
4328,
63,
354,
9,
267,
340,
822,
8,
589,
9,
690,
378,
26,
288,
5259,
932,
847,
1050,
2415,
14,
3257,
63,
525,
354,
8,
589,
12,
1249,
9,
267,
372,
536,
421,
199,
533,
799,
3027,
16721,
8,
497,
840,
23393,
304,
272,
408,
272,
11994,
402,
282,
20883,
4719,
14,
272,
408,
272,
347,
2429,
63,
5233,
8,
277,
12,
5259,
12,
5259,
932,
304,
267,
5259,
932,
847,
1050,
2415,
14,
3257,
63,
354,
6176,
5,
83,
4881,
450,
5259,
12,
283,
2689,
83,
4881,
450,
5259,
9,
267,
372,
5259,
421,
199,
533,
799,
840,
7705,
8,
7705,
304,
272,
408,
497,
27486,
1872,
2881,
1041,
272,
536,
275,
283,
8332,
7,
272,
1768,
275,
283,
264,
27486,
1872,
7,
339,
909,
63,
1313,
275,
469,
267,
283,
15047,
356,
24921,
804,
8,
76,
11252,
15047,
659,
283,
694,
659,
267,
283,
3756,
356,
420,
24921,
804,
8,
76,
11252,
3756,
659,
420,
283,
3756,
659,
272,
789,
272,
13502,
275,
469,
267,
283,
15047,
356,
799,
840,
29489,
12,
267,
283,
3756,
356,
420,
799,
3027,
16721,
12,
272,
789,
272,
11689,
275,
469,
267,
283,
694,
356,
221,
1323,
2891,
7422,
1062,
267,
283,
3756,
356,
1323,
2891,
7422,
1062,
272,
789,
272,
2536,
63,
576,
275,
469,
267,
283,
1462,
356,
5479,
221,
327,
11064,
1035,
24686,
12,
1559,
466,
272,
789,
339,
347,
5436,
63,
1301,
8,
277,
12,
24686,
304,
267,
367,
334,
9749,
12,
536,
395,
1382,
315,
291,
14,
576,
459,
1462,
2278,
1744,
837,
288,
340,
1382,
508,
24686,
26,
355,
2150,
291,
14,
576,
459,
1462,
3488,
9749,
12,
536,
61,
339,
347,
7512,
63,
31332,
8,
277,
12,
2589,
12,
687,
21828,
12,
6545,
12,
6211,
12,
1347,
12,
1031,
12,
2151,
13770,
932,
304,
267,
2251,
275,
291,
14,
576,
459,
1462,
418,
267,
1559,
1313,
275,
291,
14,
1113,
1313,
63,
509,
63,
3756,
8,
9749,
9,
267,
367,
1559,
466,
315,
1559,
1313,
26,
288,
340,
334,
1113,
466,
12,
1347,
9,
315,
2251,
26,
355,
372,
1852,
63,
1121,
932,
8,
5649,
12,
687,
21828,
12,
2511,
2251,
59,
1113,
466,
12,
1347,
467,
2511,
1559,
466,
435,
10791,
435,
1347,
12,
2511
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
15882,
14,
9756,
14,
8332,
272,
18294,
1714,
339,
710,
295,
27486,
1872,
2881,
14,
339,
520,
7307,
26,
1898,
10219,
13,
7280,
701,
314,
10229,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
646,
295,
199,
199,
504,
15882,
492,
1050,
2415,
199,
504,
15882,
14,
9756,
492,
14061,
12,
24921,
804,
199,
504,
15882,
14,
5508,
492,
634,
3131,
485,
199,
504,
15882,
14,
23216,
492,
6935,
5831,
199,
504,
15882,
14,
8050,
492,
1323,
2891,
7422,
199,
504,
15882,
14,
1974,
14,
2415,
492,
1852,
63,
1121,
932,
421,
199,
694,
63,
4093,
63,
264,
275,
295,
14,
2014,
8,
82,
1154,
3134,
14,
334,
11198,
304,
20334,
12432,
9988,
421,
199,
533,
799,
840,
23393,
8,
1692,
5831,
304,
272,
408,
272,
11994,
402,
7809,
20883,
9189,
14,
272,
408,
339,
347,
1050,
63,
1375,
63,
460,
63,
1080,
8,
277,
12,
536,
12,
5259,
12,
5259,
932,
304,
267,
1347,
354,
275,
291,
14,
1113,
466,
435,
10791,
435,
536,
267,
340,
1347,
354,
440,
315,
291,
14,
929,
14,
3554,
14,
1580,
26,
288,
5259,
932,
459,
1247,
2278,
740,
8,
1375,
354,
9,
288,
5259,
932,
459,
1580,
2278,
740,
8,
1375,
354,
9,
288,
5259,
932,
459,
2246,
418,
275,
334,
1397,
291,
14,
1247,
9,
288,
291,
14,
929,
14,
3554,
14,
4610,
63,
10306,
63,
1375,
8,
1037,
380,
9,
953,
2251,
275,
291,
14,
1813,
14,
2261,
576,
459,
8332,
2545,
1462,
418,
288,
790,
275,
334,
277,
14,
1113,
466,
12,
536,
9,
288,
340,
790,
315,
2251,
26,
355,
291,
14,
929,
63,
6744,
14,
12222,
14,
3764,
8,
490,
283,
11081,
1369,
402,
450,
83,
450,
83,
12,
283,
450,
334,
277,
14,
1113,
466,
12,
536,
9,
435,
490,
283,
1848,
1256,
315,
283,
435,
291,
14,
1813,
14,
1301,
18,
515,
8,
1462,
59,
498,
2522,
490,
1004,
29,
277,
14,
3469,
9,
288,
2251,
59,
498,
61,
275,
291,
14,
1813,
14,
21828,
267,
1478,
505,
275,
291,
14,
362,
63,
1080,
63,
505,
8,
277,
14,
1113,
466,
12,
536,
9,
267,
340,
1478,
505,
26,
288,
291,
14,
1080,
932,
459,
3189,
2278,
740,
4725,
4780,
297,
1478,
505,
12,
6343,
1347,
354,
12,
12381,
339,
347,
664,
63,
1080,
63,
505,
8,
277,
12,
909,
354,
12,
536,
304,
267,
340,
291,
14,
1113,
466,
508,
283,
15047,
356,
288,
372,
485,
3508,
83,
334,
15047,
5942,
450,
536,
267,
916,
291,
14,
1113,
466,
508,
283,
3756,
356,
288,
372,
485,
3508,
83,
334,
3756,
5942,
450,
536,
267,
372,
2125,
421,
199,
318,
2198,
63,
15047,
8,
68,
304,
272,
408,
4003,
282,
13613,
4955,
14,
339,
1803,
334,
15047,
12,
2368,
9,
1059,
2008,
14,
221,
982,
949,
2368,
787,
1627,
12,
272,
2529,
334,
15047,
12,
12548,
272,
408,
272,
2935,
275,
366,
14,
1913,
342,
272,
340,
440,
2935,
14,
2460,
26461,
267,
327,
16269,
652,
365,
282,
13613,
1928,
6302,
267,
372,
334,
694,
12,
4074,
272,
333,
275,
2935,
63,
4093,
63,
264,
14,
1431,
8,
694,
9,
272,
340,
440,
333,
26,
267,
372,
334,
694,
12,
4074,
272,
4565,
63,
694,
12,
4565,
63,
589,
275,
333,
14,
2634,
342,
272,
372,
334,
6751,
63,
694,
14,
1913,
1062,
283,
283,
435,
4565,
63,
589,
14,
1913,
1012,
421,
199,
533,
799,
840,
29489,
8,
497,
840,
23393,
304,
272,
408,
272,
11994,
402,
282,
20883,
13613,
14,
272,
408,
272,
347,
2429,
63,
5233,
8,
277,
12,
5259,
12,
5259,
932,
304,
267,
536,
12,
1249,
275,
2198,
63,
15047,
8,
4093,
9,
267,
4328,
63,
354,
275,
11541,
450,
83,
447,
7,
450,
536,
267,
5259,
932,
847,
1050,
2415,
14,
3257,
63,
354,
8,
3257,
63,
354,
12,
4328,
63,
354,
9,
267,
340,
822,
8,
589,
9,
690,
378,
26,
288,
5259,
932,
847,
1050,
2415,
14,
3257,
63,
525,
354,
8,
589,
12,
1249,
9,
267,
372,
536,
421,
199,
533,
799,
3027,
16721,
8,
497,
840,
23393,
304,
272,
408,
272,
11994,
402,
282,
20883,
4719,
14,
272,
408,
272,
347,
2429,
63,
5233,
8,
277,
12,
5259,
12,
5259,
932,
304,
267,
5259,
932,
847,
1050,
2415,
14,
3257,
63,
354,
6176,
5,
83,
4881,
450,
5259,
12,
283,
2689,
83,
4881,
450,
5259,
9,
267,
372,
5259,
421,
199,
533,
799,
840,
7705,
8,
7705,
304,
272,
408,
497,
27486,
1872,
2881,
1041,
272,
536,
275,
283,
8332,
7,
272,
1768,
275,
283,
264,
27486,
1872,
7,
339,
909,
63,
1313,
275,
469,
267,
283,
15047,
356,
24921,
804,
8,
76,
11252,
15047,
659,
283,
694,
659,
267,
283,
3756,
356,
420,
24921,
804,
8,
76,
11252,
3756,
659,
420,
283,
3756,
659,
272,
789,
272,
13502,
275,
469,
267,
283,
15047,
356,
799,
840,
29489,
12,
267,
283,
3756,
356,
420,
799,
3027,
16721,
12,
272,
789,
272,
11689,
275,
469,
267,
283,
694,
356,
221,
1323,
2891,
7422,
1062,
267,
283,
3756,
356,
1323,
2891,
7422,
1062,
272,
789,
272,
2536,
63,
576,
275,
469,
267,
283,
1462,
356,
5479,
221,
327,
11064,
1035,
24686,
12,
1559,
466,
272,
789,
339,
347,
5436,
63,
1301,
8,
277,
12,
24686,
304,
267,
367,
334,
9749,
12,
536,
395,
1382,
315,
291,
14,
576,
459,
1462,
2278,
1744,
837,
288,
340,
1382,
508,
24686,
26,
355,
2150,
291,
14,
576,
459,
1462,
3488,
9749,
12,
536,
61,
339,
347,
7512,
63,
31332,
8,
277,
12,
2589,
12,
687,
21828,
12,
6545,
12,
6211,
12,
1347,
12,
1031,
12,
2151,
13770,
932,
304,
267,
2251,
275,
291,
14,
576,
459,
1462,
418,
267,
1559,
1313,
275,
291,
14,
1113,
1313,
63,
509,
63,
3756,
8,
9749,
9,
267,
367,
1559,
466,
315,
1559,
1313,
26,
288,
340,
334,
1113,
466,
12,
1347,
9,
315,
2251,
26,
355,
372,
1852,
63,
1121,
932,
8,
5649,
12,
687,
21828,
12,
2511,
2251,
59,
1113,
466,
12,
1347,
467,
2511,
1559,
466,
435,
10791,
435,
1347,
12,
2511,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
gautamkmr/incubator-mxnet
|
tools/caffe_converter/caffe_parser.py
|
31
|
2767
|
# 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.
"""Parse caffe's protobuf
"""
import re
try:
import caffe
from caffe.proto import caffe_pb2
use_caffe = True
except ImportError:
try:
import caffe_pb2
except ImportError:
raise ImportError('You used to compile with protoc --python_out=./ ./caffe.proto')
use_caffe = False
from google.protobuf import text_format # pylint: disable=relative-import
def read_prototxt(fname):
"""Return a caffe_pb2.NetParameter object that defined in a prototxt file
"""
proto = caffe_pb2.NetParameter()
with open(fname, 'r') as f:
text_format.Merge(str(f.read()), proto)
return proto
def get_layers(proto):
"""Returns layers in a caffe_pb2.NetParameter object
"""
if len(proto.layer):
return proto.layer
elif len(proto.layers):
return proto.layers
else:
raise ValueError('Invalid proto file.')
def read_caffemodel(prototxt_fname, caffemodel_fname):
"""Return a caffe_pb2.NetParameter object that defined in a binary
caffemodel file
"""
if use_caffe:
caffe.set_mode_cpu()
net = caffe.Net(prototxt_fname, caffemodel_fname, caffe.TEST)
layer_names = net._layer_names
layers = net.layers
return (layers, layer_names)
else:
proto = caffe_pb2.NetParameter()
with open(caffemodel_fname, 'rb') as f:
proto.ParseFromString(f.read())
return (get_layers(proto), None)
def layer_iter(layers, layer_names):
if use_caffe:
for layer_idx, layer in enumerate(layers):
layer_name = re.sub('[-/]', '_', layer_names[layer_idx])
layer_type = layer.type
layer_blobs = layer.blobs
yield (layer_name, layer_type, layer_blobs)
else:
for layer in layers:
layer_name = re.sub('[-/]', '_', layer.name)
layer_type = layer.type
layer_blobs = layer.blobs
yield (layer_name, layer_type, layer_blobs)
|
apache-2.0
|
[
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
257,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
199,
3,
2032,
1854,
1334,
314,
844,
365,
1854,
641,
376,
199,
3,
298,
1179,
2281,
2,
4207,
12,
2428,
2990,
1549,
4217,
1634,
1821,
199,
3,
3826,
12,
1902,
4056,
503,
2478,
14,
221,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
624,
4003,
1704,
2026,
1159,
25886,
199,
624,
199,
646,
295,
199,
893,
26,
272,
492,
1704,
2026,
272,
687,
1704,
2026,
14,
2625,
492,
1704,
2026,
63,
3317,
18,
272,
675,
63,
18260,
275,
715,
199,
2590,
3545,
26,
272,
862,
26,
267,
492,
1704,
2026,
63,
3317,
18,
272,
871,
3545,
26,
267,
746,
3545,
360,
5556,
1202,
370,
6555,
543,
4104,
67,
1553,
1548,
63,
548,
29,
13186,
16605,
18260,
14,
2625,
358,
272,
675,
63,
18260,
275,
756,
199,
199,
504,
6233,
14,
7204,
492,
1318,
63,
908,
327,
4287,
26,
3507,
29,
6188,
13,
646,
199,
199,
318,
1586,
63,
2745,
357,
400,
8,
5252,
304,
272,
408,
1767,
282,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
909,
626,
3247,
315,
282,
557,
13280,
400,
570,
272,
408,
272,
4104,
275,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
342,
272,
543,
1551,
8,
5252,
12,
283,
82,
358,
465,
289,
26,
267,
1318,
63,
908,
14,
11359,
8,
495,
8,
70,
14,
739,
4000,
4104,
9,
272,
372,
4104,
199,
199,
318,
664,
63,
4359,
8,
2625,
304,
272,
408,
3407,
9393,
315,
282,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
909,
272,
408,
272,
340,
822,
8,
2625,
14,
1897,
304,
267,
372,
4104,
14,
1897,
272,
916,
822,
8,
2625,
14,
4359,
304,
267,
372,
4104,
14,
4359,
272,
587,
26,
267,
746,
1722,
360,
3364,
4104,
570,
2659,
199,
199,
318,
1586,
63,
18260,
1238,
8,
2745,
357,
400,
63,
5252,
12,
1704,
2026,
1238,
63,
5252,
304,
272,
408,
1767,
282,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
909,
626,
3247,
315,
282,
3366,
272,
1704,
2026,
1238,
570,
272,
408,
272,
340,
675,
63,
18260,
26,
267,
1704,
2026,
14,
409,
63,
632,
63,
3541,
342,
267,
1851,
275,
1704,
2026,
14,
2480,
8,
2745,
357,
400,
63,
5252,
12,
1704,
2026,
1238,
63,
5252,
12,
1704,
2026,
14,
2864,
9,
267,
4045,
63,
1247,
275,
1851,
423,
1897,
63,
1247,
267,
9393,
275,
1851,
14,
4359,
267,
372,
334,
4359,
12,
4045,
63,
1247,
9,
272,
587,
26,
267,
4104,
275,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
342,
267,
543,
1551,
8,
18260,
1238,
63,
5252,
12,
283,
4848,
358,
465,
289,
26,
288,
4104,
14,
28685,
8,
70,
14,
739,
1012,
267,
372,
334,
362,
63,
4359,
8,
2625,
395,
488,
9,
199,
199,
318,
4045,
63,
1661,
8,
4359,
12,
4045,
63,
1247,
304,
272,
340,
675,
63,
18260,
26,
267,
367,
4045,
63,
2996,
12,
4045,
315,
3874,
8,
4359,
304,
288,
4045,
63,
354,
275,
295,
14,
954,
360,
1988,
15,
4300,
25469,
4045,
63,
1247,
59,
1897,
63,
2996,
566,
288,
4045,
63,
466,
275,
4045,
14,
466,
288,
4045,
63,
21893,
275,
4045,
14,
21893,
288,
1995,
334,
1897,
63,
354,
12,
4045,
63,
466,
12,
4045,
63,
21893,
9,
272,
587,
26,
267,
367,
4045,
315,
9393,
26,
288,
4045,
63,
354,
275,
295,
14,
954,
360,
1988,
15,
4300,
25469,
4045,
14,
354,
9,
288,
4045,
63,
466,
275,
4045,
14,
466,
288,
4045,
63,
21893,
275,
4045,
14,
21893,
288,
1995,
334,
1897,
63,
354,
12,
4045,
63,
466,
12,
4045,
63,
21893,
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
] |
[
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
257,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
199,
3,
2032,
1854,
1334,
314,
844,
365,
1854,
641,
376,
199,
3,
298,
1179,
2281,
2,
4207,
12,
2428,
2990,
1549,
4217,
1634,
1821,
199,
3,
3826,
12,
1902,
4056,
503,
2478,
14,
221,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
624,
4003,
1704,
2026,
1159,
25886,
199,
624,
199,
646,
295,
199,
893,
26,
272,
492,
1704,
2026,
272,
687,
1704,
2026,
14,
2625,
492,
1704,
2026,
63,
3317,
18,
272,
675,
63,
18260,
275,
715,
199,
2590,
3545,
26,
272,
862,
26,
267,
492,
1704,
2026,
63,
3317,
18,
272,
871,
3545,
26,
267,
746,
3545,
360,
5556,
1202,
370,
6555,
543,
4104,
67,
1553,
1548,
63,
548,
29,
13186,
16605,
18260,
14,
2625,
358,
272,
675,
63,
18260,
275,
756,
199,
199,
504,
6233,
14,
7204,
492,
1318,
63,
908,
327,
4287,
26,
3507,
29,
6188,
13,
646,
199,
199,
318,
1586,
63,
2745,
357,
400,
8,
5252,
304,
272,
408,
1767,
282,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
909,
626,
3247,
315,
282,
557,
13280,
400,
570,
272,
408,
272,
4104,
275,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
342,
272,
543,
1551,
8,
5252,
12,
283,
82,
358,
465,
289,
26,
267,
1318,
63,
908,
14,
11359,
8,
495,
8,
70,
14,
739,
4000,
4104,
9,
272,
372,
4104,
199,
199,
318,
664,
63,
4359,
8,
2625,
304,
272,
408,
3407,
9393,
315,
282,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
909,
272,
408,
272,
340,
822,
8,
2625,
14,
1897,
304,
267,
372,
4104,
14,
1897,
272,
916,
822,
8,
2625,
14,
4359,
304,
267,
372,
4104,
14,
4359,
272,
587,
26,
267,
746,
1722,
360,
3364,
4104,
570,
2659,
199,
199,
318,
1586,
63,
18260,
1238,
8,
2745,
357,
400,
63,
5252,
12,
1704,
2026,
1238,
63,
5252,
304,
272,
408,
1767,
282,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
909,
626,
3247,
315,
282,
3366,
272,
1704,
2026,
1238,
570,
272,
408,
272,
340,
675,
63,
18260,
26,
267,
1704,
2026,
14,
409,
63,
632,
63,
3541,
342,
267,
1851,
275,
1704,
2026,
14,
2480,
8,
2745,
357,
400,
63,
5252,
12,
1704,
2026,
1238,
63,
5252,
12,
1704,
2026,
14,
2864,
9,
267,
4045,
63,
1247,
275,
1851,
423,
1897,
63,
1247,
267,
9393,
275,
1851,
14,
4359,
267,
372,
334,
4359,
12,
4045,
63,
1247,
9,
272,
587,
26,
267,
4104,
275,
1704,
2026,
63,
3317,
18,
14,
2480,
4720,
342,
267,
543,
1551,
8,
18260,
1238,
63,
5252,
12,
283,
4848,
358,
465,
289,
26,
288,
4104,
14,
28685,
8,
70,
14,
739,
1012,
267,
372,
334,
362,
63,
4359,
8,
2625,
395,
488,
9,
199,
199,
318,
4045,
63,
1661,
8,
4359,
12,
4045,
63,
1247,
304,
272,
340,
675,
63,
18260,
26,
267,
367,
4045,
63,
2996,
12,
4045,
315,
3874,
8,
4359,
304,
288,
4045,
63,
354,
275,
295,
14,
954,
360,
1988,
15,
4300,
25469,
4045,
63,
1247,
59,
1897,
63,
2996,
566,
288,
4045,
63,
466,
275,
4045,
14,
466,
288,
4045,
63,
21893,
275,
4045,
14,
21893,
288,
1995,
334,
1897,
63,
354,
12,
4045,
63,
466,
12,
4045,
63,
21893,
9,
272,
587,
26,
267,
367,
4045,
315,
9393,
26,
288,
4045,
63,
354,
275,
295,
14,
954,
360,
1988,
15,
4300,
25469,
4045,
14,
354,
9,
288,
4045,
63,
466,
275,
4045,
14,
466,
288,
4045,
63,
21893,
275,
4045,
14,
21893,
288,
1995,
334,
1897,
63,
354,
12,
4045,
63,
466,
12,
4045,
63,
21893,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
wattad169/sportbuddy_server
|
lib/django/core/serializers/json.py
|
320
|
3782
|
"""
Serialize data to/from JSON
"""
# Avoid shadowing the standard library json module
from __future__ import absolute_import, unicode_literals
import datetime
import decimal
import json
import sys
import uuid
from django.core.serializers.base import DeserializationError
from django.core.serializers.python import (
Deserializer as PythonDeserializer, Serializer as PythonSerializer,
)
from django.utils import six
from django.utils.timezone import is_aware
class Serializer(PythonSerializer):
"""
Convert a queryset to JSON.
"""
internal_use_only = False
def _init_options(self):
if json.__version__.split('.') >= ['2', '1', '3']:
# Use JS strings to represent Python Decimal instances (ticket #16850)
self.options.update({'use_decimal': False})
self._current = None
self.json_kwargs = self.options.copy()
self.json_kwargs.pop('stream', None)
self.json_kwargs.pop('fields', None)
if self.options.get('indent'):
# Prevent trailing spaces
self.json_kwargs['separators'] = (',', ': ')
def start_serialization(self):
self._init_options()
self.stream.write("[")
def end_serialization(self):
if self.options.get("indent"):
self.stream.write("\n")
self.stream.write("]")
if self.options.get("indent"):
self.stream.write("\n")
def end_object(self, obj):
# self._current has the field data
indent = self.options.get("indent")
if not self.first:
self.stream.write(",")
if not indent:
self.stream.write(" ")
if indent:
self.stream.write("\n")
json.dump(self.get_dump_object(obj), self.stream,
cls=DjangoJSONEncoder, **self.json_kwargs)
self._current = None
def getvalue(self):
# Grand-parent super
return super(PythonSerializer, self).getvalue()
def Deserializer(stream_or_string, **options):
"""
Deserialize a stream or string of JSON data.
"""
if not isinstance(stream_or_string, (bytes, six.string_types)):
stream_or_string = stream_or_string.read()
if isinstance(stream_or_string, bytes):
stream_or_string = stream_or_string.decode('utf-8')
try:
objects = json.loads(stream_or_string)
for obj in PythonDeserializer(objects, **options):
yield obj
except GeneratorExit:
raise
except Exception as e:
# Map to deserializer error
six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
class DjangoJSONEncoder(json.JSONEncoder):
"""
JSONEncoder subclass that knows how to encode date/time, decimal types and UUIDs.
"""
def default(self, o):
# See "Date Time String Format" in the ECMA-262 specification.
if isinstance(o, datetime.datetime):
r = o.isoformat()
if o.microsecond:
r = r[:23] + r[26:]
if r.endswith('+00:00'):
r = r[:-6] + 'Z'
return r
elif isinstance(o, datetime.date):
return o.isoformat()
elif isinstance(o, datetime.time):
if is_aware(o):
raise ValueError("JSON can't represent timezone-aware times.")
r = o.isoformat()
if o.microsecond:
r = r[:12]
return r
elif isinstance(o, decimal.Decimal):
return str(o)
elif isinstance(o, uuid.UUID):
return str(o)
else:
return super(DjangoJSONEncoder, self).default(o)
# Older, deprecated class name (for backwards compatibility purposes).
DateTimeAwareJSONEncoder = DjangoJSONEncoder
|
bsd-3-clause
|
[
624,
199,
6383,
666,
370,
15,
504,
4840,
199,
624,
199,
199,
3,
19503,
15084,
316,
314,
4465,
3555,
2022,
859,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
199,
199,
646,
2197,
199,
646,
6107,
199,
646,
2022,
199,
646,
984,
199,
646,
5377,
199,
199,
504,
1639,
14,
1018,
14,
12844,
14,
1095,
492,
1487,
12161,
547,
199,
504,
1639,
14,
1018,
14,
12844,
14,
1548,
492,
334,
272,
1487,
8349,
465,
2018,
872,
8349,
12,
25555,
465,
2018,
7299,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
7145,
492,
365,
63,
14600,
421,
199,
533,
25555,
8,
4718,
7299,
304,
272,
408,
272,
7905,
282,
7594,
370,
4840,
14,
272,
408,
272,
5007,
63,
1180,
63,
2118,
275,
756,
339,
347,
485,
826,
63,
1419,
8,
277,
304,
267,
340,
2022,
855,
1023,
4343,
1294,
7563,
2356,
788,
18,
297,
283,
17,
297,
283,
19,
2565,
288,
327,
3645,
18001,
3326,
370,
2954,
2018,
6345,
4454,
334,
9201,
327,
6568,
1400,
9,
288,
291,
14,
1419,
14,
873,
3252,
1180,
63,
6355,
356,
756,
1552,
267,
291,
423,
1818,
275,
488,
267,
291,
14,
1001,
63,
958,
275,
291,
14,
1419,
14,
1574,
342,
267,
291,
14,
1001,
63,
958,
14,
1935,
360,
1745,
297,
488,
9,
267,
291,
14,
1001,
63,
958,
14,
1935,
360,
955,
297,
488,
9,
267,
340,
291,
14,
1419,
14,
362,
360,
3724,
735,
288,
327,
29861,
8520,
7883,
288,
291,
14,
1001,
63,
958,
459,
29862,
418,
275,
334,
23324,
7596,
5320,
339,
347,
1343,
63,
12161,
8,
277,
304,
267,
291,
423,
826,
63,
1419,
342,
267,
291,
14,
1745,
14,
952,
10994,
531,
339,
347,
1284,
63,
12161,
8,
277,
304,
267,
340,
291,
14,
1419,
14,
362,
480,
3724,
2349,
288,
291,
14,
1745,
14,
952,
4582,
78,
531,
267,
291,
14,
1745,
14,
952,
480,
12523,
267,
340,
291,
14,
1419,
14,
362,
480,
3724,
2349,
288,
291,
14,
1745,
14,
952,
4582,
78,
531,
339,
347,
1284,
63,
785,
8,
277,
12,
1559,
304,
267,
327,
291,
423,
1818,
965,
314,
901,
666,
267,
4363,
275,
291,
14,
1419,
14,
362,
480,
3724,
531,
267,
340,
440,
291,
14,
2246,
26,
288,
291,
14,
1745,
14,
952,
20324,
288,
340,
440,
4363,
26,
355,
291,
14,
1745,
14,
952,
480,
6099,
267,
340,
4363,
26,
288,
291,
14,
1745,
14,
952,
4582,
78,
531,
267,
2022,
14,
2724,
8,
277,
14,
362,
63,
2724,
63,
785,
8,
1113,
395,
291,
14,
1745,
12,
2116,
843,
29,
9323,
23069,
12,
1011,
277,
14,
1001,
63,
958,
9,
267,
291,
423,
1818,
275,
488,
339,
347,
664,
585,
8,
277,
304,
267,
327,
598,
3759,
13,
1708,
1613,
267,
372,
1613,
8,
4718,
7299,
12,
291,
680,
7150,
342,
421,
199,
318,
1487,
8349,
8,
1745,
63,
269,
63,
875,
12,
1011,
1419,
304,
272,
408,
272,
1487,
3549,
282,
2547,
503,
1059,
402,
4840,
666,
14,
272,
408,
272,
340,
440,
1228,
8,
1745,
63,
269,
63,
875,
12,
334,
2394,
12,
3816,
14,
875,
63,
1313,
2298,
267,
2547,
63,
269,
63,
875,
275,
2547,
63,
269,
63,
875,
14,
739,
342,
272,
340,
1228,
8,
1745,
63,
269,
63,
875,
12,
2783,
304,
267,
2547,
63,
269,
63,
875,
275,
2547,
63,
269,
63,
875,
14,
2708,
360,
1624,
13,
24,
358,
272,
862,
26,
267,
2251,
275,
2022,
14,
3640,
8,
1745,
63,
269,
63,
875,
9,
267,
367,
1559,
315,
2018,
872,
8349,
8,
1462,
12,
1011,
1419,
304,
288,
1995,
1559,
272,
871,
15042,
6699,
26,
267,
746,
272,
871,
2186,
465,
325,
26,
267,
327,
9672,
370,
30237,
1125,
267,
3816,
14,
20614,
8,
872,
12161,
547,
12,
1487,
12161,
547,
8,
69,
395,
984,
14,
2804,
63,
815,
3430,
18,
566,
421,
199,
533,
5634,
23069,
8,
1001,
14,
23069,
304,
272,
408,
272,
4840,
6679,
5516,
626,
19428,
4212,
370,
3752,
1434,
15,
521,
12,
6107,
2943,
436,
11134,
83,
14,
272,
408,
272,
347,
849,
8,
277,
12,
312,
304,
267,
327,
1666,
298,
2506,
4703,
2624,
9701,
2,
315,
314,
15352,
2054,
13,
14820,
8929,
14,
267,
340,
1228,
8,
79,
12,
2197,
14,
2083,
304,
288,
519,
275,
312,
14,
17070,
342,
288,
340,
312,
14,
16627,
26,
355,
519,
275,
519,
1491,
1789,
61,
435,
519,
59,
1479,
2938,
288,
340,
519,
14,
4130,
19975,
383,
26,
383,
735,
355,
519,
275,
519,
4439,
22,
61,
435,
283,
58,
7,
288,
372,
519,
267,
916,
1228,
8,
79,
12,
2197,
14,
602,
304,
288,
372,
312,
14,
17070,
342,
267,
916,
1228,
8,
79,
12,
2197,
14,
521,
304,
288,
340,
365,
63,
14600,
8,
79,
304,
355,
746,
1722,
480,
6243,
883,
1133,
2954,
7137,
13,
14600,
5431,
2685,
288,
519,
275,
312,
14,
17070,
342,
288,
340,
312,
14,
16627,
26,
355,
519,
275,
519,
1491,
713,
61,
288,
372,
519,
267,
916,
1228,
8,
79,
12,
6107,
14,
6745,
304,
288,
372,
620,
8,
79,
9,
267,
916,
1228,
8,
79,
12,
5377,
14,
8757,
304,
288,
372,
620,
8,
79,
9,
267,
587,
26,
288,
372,
1613,
8,
9323,
23069,
12,
291,
680,
885,
8,
79,
9,
199,
199,
3,
593,
76,
424,
12,
5906,
1021,
536,
334,
509,
8552,
7163,
12901,
680,
199,
3926,
24290,
23069,
275,
5634,
23069,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
6383,
666,
370,
15,
504,
4840,
199,
624,
199,
199,
3,
19503,
15084,
316,
314,
4465,
3555,
2022,
859,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
199,
199,
646,
2197,
199,
646,
6107,
199,
646,
2022,
199,
646,
984,
199,
646,
5377,
199,
199,
504,
1639,
14,
1018,
14,
12844,
14,
1095,
492,
1487,
12161,
547,
199,
504,
1639,
14,
1018,
14,
12844,
14,
1548,
492,
334,
272,
1487,
8349,
465,
2018,
872,
8349,
12,
25555,
465,
2018,
7299,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
7145,
492,
365,
63,
14600,
421,
199,
533,
25555,
8,
4718,
7299,
304,
272,
408,
272,
7905,
282,
7594,
370,
4840,
14,
272,
408,
272,
5007,
63,
1180,
63,
2118,
275,
756,
339,
347,
485,
826,
63,
1419,
8,
277,
304,
267,
340,
2022,
855,
1023,
4343,
1294,
7563,
2356,
788,
18,
297,
283,
17,
297,
283,
19,
2565,
288,
327,
3645,
18001,
3326,
370,
2954,
2018,
6345,
4454,
334,
9201,
327,
6568,
1400,
9,
288,
291,
14,
1419,
14,
873,
3252,
1180,
63,
6355,
356,
756,
1552,
267,
291,
423,
1818,
275,
488,
267,
291,
14,
1001,
63,
958,
275,
291,
14,
1419,
14,
1574,
342,
267,
291,
14,
1001,
63,
958,
14,
1935,
360,
1745,
297,
488,
9,
267,
291,
14,
1001,
63,
958,
14,
1935,
360,
955,
297,
488,
9,
267,
340,
291,
14,
1419,
14,
362,
360,
3724,
735,
288,
327,
29861,
8520,
7883,
288,
291,
14,
1001,
63,
958,
459,
29862,
418,
275,
334,
23324,
7596,
5320,
339,
347,
1343,
63,
12161,
8,
277,
304,
267,
291,
423,
826,
63,
1419,
342,
267,
291,
14,
1745,
14,
952,
10994,
531,
339,
347,
1284,
63,
12161,
8,
277,
304,
267,
340,
291,
14,
1419,
14,
362,
480,
3724,
2349,
288,
291,
14,
1745,
14,
952,
4582,
78,
531,
267,
291,
14,
1745,
14,
952,
480,
12523,
267,
340,
291,
14,
1419,
14,
362,
480,
3724,
2349,
288,
291,
14,
1745,
14,
952,
4582,
78,
531,
339,
347,
1284,
63,
785,
8,
277,
12,
1559,
304,
267,
327,
291,
423,
1818,
965,
314,
901,
666,
267,
4363,
275,
291,
14,
1419,
14,
362,
480,
3724,
531,
267,
340,
440,
291,
14,
2246,
26,
288,
291,
14,
1745,
14,
952,
20324,
288,
340,
440,
4363,
26,
355,
291,
14,
1745,
14,
952,
480,
6099,
267,
340,
4363,
26,
288,
291,
14,
1745,
14,
952,
4582,
78,
531,
267,
2022,
14,
2724,
8,
277,
14,
362,
63,
2724,
63,
785,
8,
1113,
395,
291,
14,
1745,
12,
2116,
843,
29,
9323,
23069,
12,
1011,
277,
14,
1001,
63,
958,
9,
267,
291,
423,
1818,
275,
488,
339,
347,
664,
585,
8,
277,
304,
267,
327,
598,
3759,
13,
1708,
1613,
267,
372,
1613,
8,
4718,
7299,
12,
291,
680,
7150,
342,
421,
199,
318,
1487,
8349,
8,
1745,
63,
269,
63,
875,
12,
1011,
1419,
304,
272,
408,
272,
1487,
3549,
282,
2547,
503,
1059,
402,
4840,
666,
14,
272,
408,
272,
340,
440,
1228,
8,
1745,
63,
269,
63,
875,
12,
334,
2394,
12,
3816,
14,
875,
63,
1313,
2298,
267,
2547,
63,
269,
63,
875,
275,
2547,
63,
269,
63,
875,
14,
739,
342,
272,
340,
1228,
8,
1745,
63,
269,
63,
875,
12,
2783,
304,
267,
2547,
63,
269,
63,
875,
275,
2547,
63,
269,
63,
875,
14,
2708,
360,
1624,
13,
24,
358,
272,
862,
26,
267,
2251,
275,
2022,
14,
3640,
8,
1745,
63,
269,
63,
875,
9,
267,
367,
1559,
315,
2018,
872,
8349,
8,
1462,
12,
1011,
1419,
304,
288,
1995,
1559,
272,
871,
15042,
6699,
26,
267,
746,
272,
871,
2186,
465,
325,
26,
267,
327,
9672,
370,
30237,
1125,
267,
3816,
14,
20614,
8,
872,
12161,
547,
12,
1487,
12161,
547,
8,
69,
395,
984,
14,
2804,
63,
815,
3430,
18,
566,
421,
199,
533,
5634,
23069,
8,
1001,
14,
23069,
304,
272,
408,
272,
4840,
6679,
5516,
626,
19428,
4212,
370,
3752,
1434,
15,
521,
12,
6107,
2943,
436,
11134,
83,
14,
272,
408,
272,
347,
849,
8,
277,
12,
312,
304,
267,
327,
1666,
298,
2506,
4703,
2624,
9701,
2,
315,
314,
15352,
2054,
13,
14820,
8929,
14,
267,
340,
1228,
8,
79,
12,
2197,
14,
2083,
304,
288,
519,
275,
312,
14,
17070,
342,
288,
340,
312,
14,
16627,
26,
355,
519,
275,
519,
1491,
1789,
61,
435,
519,
59,
1479,
2938,
288,
340,
519,
14,
4130,
19975,
383,
26,
383,
735,
355,
519,
275,
519,
4439,
22,
61,
435,
283,
58,
7,
288,
372,
519,
267,
916,
1228,
8,
79,
12,
2197,
14,
602,
304,
288,
372,
312,
14,
17070,
342,
267,
916,
1228,
8,
79,
12,
2197,
14,
521,
304,
288,
340,
365,
63,
14600,
8,
79,
304,
355,
746,
1722,
480,
6243,
883,
1133,
2954,
7137,
13,
14600,
5431,
2685,
288,
519,
275,
312,
14,
17070,
342,
288,
340,
312,
14,
16627,
26,
355,
519,
275,
519,
1491,
713,
61,
288,
372,
519,
267,
916,
1228,
8,
79,
12,
6107,
14,
6745,
304,
288,
372,
620,
8,
79,
9,
267,
916,
1228,
8,
79,
12,
5377,
14,
8757,
304,
288,
372,
620,
8,
79,
9,
267,
587,
26,
288,
372,
1613,
8,
9323,
23069,
12,
291,
680,
885,
8,
79,
9,
199,
199,
3,
593,
76,
424,
12,
5906,
1021,
536,
334,
509,
8552,
7163,
12901,
680,
199,
3926,
24290,
23069,
275,
5634,
23069,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tedder/ansible
|
lib/ansible/plugins/doc_fragments/onyx.py
|
44
|
3063
|
# -*- coding: utf-8 -*-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
class ModuleDocFragment(object):
# Standard files documentation fragment
DOCUMENTATION = r'''
options:
provider:
description:
- A dict object containing connection details.
type: dict
suboptions:
host:
description:
- Specifies the DNS host name or address for connecting to the remote
device over the specified transport. The value of host is used as
the destination address for the transport.
type: str
required: true
port:
description:
- Specifies the port to use when building the connection to the remote device.
type: int
default: 22
username:
description:
- Configures the username to use to authenticate the connection to
the remote device. This value is used to authenticate
the SSH session. If the value is not specified in the task, the
value of environment variable C(ANSIBLE_NET_USERNAME) will be used instead.
type: str
password:
description:
- Specifies the password to use to authenticate the connection to
the remote device. This value is used to authenticate
the SSH session. If the value is not specified in the task, the
value of environment variable C(ANSIBLE_NET_PASSWORD) will be used instead.
type: str
timeout:
description:
- Specifies the timeout in seconds for communicating with the network device
for either connecting or sending commands. If the timeout is
exceeded before the operation is completed, the module will error.
type: int
default: 10
ssh_keyfile:
description:
- Specifies the SSH key to use to authenticate the connection to
the remote device. This value is the path to the
key used to authenticate the SSH session. If the value is not specified
in the task, the value of environment variable C(ANSIBLE_NET_SSH_KEYFILE)
will be used instead.
type: path
authorize:
description:
- Instructs the module to enter privileged mode on the remote device
before sending any commands. If not specified, the device will
attempt to execute all commands in non-privileged mode. If the value
is not specified in the task, the value of environment variable
C(ANSIBLE_NET_AUTHORIZE) will be used instead.
type: bool
default: no
auth_pass:
description:
- Specifies the password to use if required to enter privileged mode
on the remote device. If I(authorize) is false, then this argument
does nothing. If the value is not specified in the task, the value of
environment variable C(ANSIBLE_NET_AUTH_PASS) will be used instead.
type: str
'''
|
gpl-3.0
|
[
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,
421,
199,
533,
5673,
3768,
11080,
8,
785,
304,
339,
327,
9739,
1584,
3794,
7956,
272,
29970,
2594,
275,
519,
2344,
199,
1419,
26,
523,
5022,
26,
272,
1369,
26,
489,
446,
437,
1211,
909,
3035,
1950,
2436,
14,
272,
730,
26,
1211,
272,
26265,
26,
489,
1591,
26,
267,
1369,
26,
881,
446,
11015,
314,
10237,
1591,
536,
503,
2287,
367,
18170,
370,
314,
3982,
288,
2243,
1806,
314,
2013,
7773,
14,
221,
710,
574,
402,
1591,
365,
1202,
465,
288,
314,
5724,
2287,
367,
314,
7773,
14,
267,
730,
26,
620,
267,
1415,
26,
2549,
489,
1844,
26,
267,
1369,
26,
881,
446,
11015,
314,
1844,
370,
675,
1380,
10015,
314,
1950,
370,
314,
3982,
2243,
14,
267,
730,
26,
1109,
267,
849,
26,
6928,
489,
3434,
26,
267,
1369,
26,
881,
446,
4094,
1482,
314,
3434,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
221,
961,
574,
365,
1202,
370,
12895,
288,
314,
12027,
2351,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
288,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
11958,
9,
911,
506,
1202,
3140,
14,
267,
730,
26,
620,
489,
2505,
26,
267,
1369,
26,
881,
446,
11015,
314,
2505,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
257,
961,
574,
365,
1202,
370,
12895,
288,
314,
12027,
2351,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
288,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
9032,
9,
911,
506,
1202,
3140,
14,
267,
730,
26,
620,
489,
2653,
26,
267,
1369,
26,
881,
446,
11015,
314,
2653,
315,
4696,
367,
13882,
1958,
543,
314,
2784,
2243,
288,
367,
1902,
18170,
503,
10209,
3718,
14,
221,
982,
314,
2653,
365,
288,
22007,
2544,
314,
3439,
365,
9709,
12,
314,
859,
911,
1125,
14,
267,
730,
26,
1109,
267,
849,
26,
1616,
489,
8635,
63,
21856,
26,
267,
1369,
26,
881,
446,
11015,
314,
12027,
790,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
257,
961,
574,
365,
314,
931,
370,
314,
288,
790,
1202,
370,
12895,
314,
12027,
2351,
14,
982,
314,
574,
365,
440,
2013,
288,
315,
314,
2120,
12,
314,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
13716,
63,
3078,
3817,
9,
288,
911,
506,
1202,
3140,
14,
267,
730,
26,
931,
489,
20210,
26,
267,
1369,
26,
881,
446,
1010,
23253,
314,
859,
370,
9509,
1979,
21744,
818,
641,
314,
3982,
2243,
288,
2544,
10209,
1263,
3718,
14,
221,
982,
440,
2013,
12,
314,
2243,
911,
288,
7427,
370,
5341,
1006,
3718,
315,
2222,
13,
27672,
818,
14,
982,
314,
574,
288,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
3734,
1750,
288,
445,
8,
8490,
63,
7278,
63,
27938,
11025,
9,
911,
506,
1202,
3140,
14,
267,
730,
26,
2155,
267,
849,
26,
949,
489,
1790,
63,
1529,
26,
267,
1369,
26,
881,
446,
11015,
314,
2505,
370,
675,
340,
1415,
370,
9509,
1979,
21744,
818,
288,
641,
314,
3982,
2243,
14,
221,
982,
473,
8,
14204,
9,
365,
3055,
12,
2066,
642,
1423,
288,
1630,
6548,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
288,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
5580,
63,
6909,
9,
911,
506,
1202,
3140,
14,
267,
730,
26,
620,
199,
2344,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
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,
421,
199,
533,
5673,
3768,
11080,
8,
785,
304,
339,
327,
9739,
1584,
3794,
7956,
272,
29970,
2594,
275,
519,
2344,
199,
1419,
26,
523,
5022,
26,
272,
1369,
26,
489,
446,
437,
1211,
909,
3035,
1950,
2436,
14,
272,
730,
26,
1211,
272,
26265,
26,
489,
1591,
26,
267,
1369,
26,
881,
446,
11015,
314,
10237,
1591,
536,
503,
2287,
367,
18170,
370,
314,
3982,
288,
2243,
1806,
314,
2013,
7773,
14,
221,
710,
574,
402,
1591,
365,
1202,
465,
288,
314,
5724,
2287,
367,
314,
7773,
14,
267,
730,
26,
620,
267,
1415,
26,
2549,
489,
1844,
26,
267,
1369,
26,
881,
446,
11015,
314,
1844,
370,
675,
1380,
10015,
314,
1950,
370,
314,
3982,
2243,
14,
267,
730,
26,
1109,
267,
849,
26,
6928,
489,
3434,
26,
267,
1369,
26,
881,
446,
4094,
1482,
314,
3434,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
221,
961,
574,
365,
1202,
370,
12895,
288,
314,
12027,
2351,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
288,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
11958,
9,
911,
506,
1202,
3140,
14,
267,
730,
26,
620,
489,
2505,
26,
267,
1369,
26,
881,
446,
11015,
314,
2505,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
257,
961,
574,
365,
1202,
370,
12895,
288,
314,
12027,
2351,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
288,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
9032,
9,
911,
506,
1202,
3140,
14,
267,
730,
26,
620,
489,
2653,
26,
267,
1369,
26,
881,
446,
11015,
314,
2653,
315,
4696,
367,
13882,
1958,
543,
314,
2784,
2243,
288,
367,
1902,
18170,
503,
10209,
3718,
14,
221,
982,
314,
2653,
365,
288,
22007,
2544,
314,
3439,
365,
9709,
12,
314,
859,
911,
1125,
14,
267,
730,
26,
1109,
267,
849,
26,
1616,
489,
8635,
63,
21856,
26,
267,
1369,
26,
881,
446,
11015,
314,
12027,
790,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
257,
961,
574,
365,
314,
931,
370,
314,
288,
790,
1202,
370,
12895,
314,
12027,
2351,
14,
982,
314,
574,
365,
440,
2013,
288,
315,
314,
2120,
12,
314,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
13716,
63,
3078,
3817,
9,
288,
911,
506,
1202,
3140,
14,
267,
730,
26,
931,
489,
20210,
26,
267,
1369,
26,
881,
446,
1010,
23253,
314,
859,
370,
9509,
1979,
21744,
818,
641,
314,
3982,
2243,
288,
2544,
10209,
1263,
3718,
14,
221,
982,
440,
2013,
12,
314,
2243,
911,
288,
7427,
370,
5341,
1006,
3718,
315,
2222,
13,
27672,
818,
14,
982,
314,
574,
288,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
3734,
1750,
288,
445,
8,
8490,
63,
7278,
63,
27938,
11025,
9,
911,
506,
1202,
3140,
14,
267,
730,
26,
2155,
267,
849,
26,
949,
489,
1790,
63,
1529,
26,
267,
1369,
26,
881,
446,
11015,
314,
2505,
370,
675,
340,
1415,
370,
9509,
1979,
21744,
818,
288,
641,
314,
3982,
2243,
14,
221,
982,
473,
8,
14204,
9,
365,
3055,
12,
2066,
642,
1423,
288,
1630,
6548,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
288,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
5580,
63,
6909,
9,
911,
506,
1202,
3140,
14,
267,
730,
26,
620,
199,
2344,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
FNCS/ns-3.26
|
src/mpi/bindings/modulegen__gcc_LP64.py
|
38
|
220836
|
from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
import pybindgen.settings
import warnings
class ErrorHandler(pybindgen.settings.ErrorHandler):
def handle_error(self, wrapper, exception, traceback_):
warnings.warn("exception %r in wrapper %s" % (exception, wrapper))
return True
pybindgen.settings.error_handler = ErrorHandler()
import sys
def module_init():
root_module = Module('ns.mpi', cpp_namespace='::ns3')
return root_module
def register_types(module):
root_module = module.get_root()
## address.h (module 'network'): ns3::Address [class]
module.add_class('Address', import_from_module='ns.network')
## address.h (module 'network'): ns3::Address::MaxSize_e [enumeration]
module.add_enum('MaxSize_e', ['MAX_SIZE'], outer_class=root_module['ns3::Address'], import_from_module='ns.network')
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList [class]
module.add_class('AttributeConstructionList', import_from_module='ns.core')
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::Item [struct]
module.add_class('Item', import_from_module='ns.core', outer_class=root_module['ns3::AttributeConstructionList'])
## buffer.h (module 'network'): ns3::Buffer [class]
module.add_class('Buffer', import_from_module='ns.network')
## buffer.h (module 'network'): ns3::Buffer::Iterator [class]
module.add_class('Iterator', import_from_module='ns.network', outer_class=root_module['ns3::Buffer'])
## packet.h (module 'network'): ns3::ByteTagIterator [class]
module.add_class('ByteTagIterator', import_from_module='ns.network')
## packet.h (module 'network'): ns3::ByteTagIterator::Item [class]
module.add_class('Item', import_from_module='ns.network', outer_class=root_module['ns3::ByteTagIterator'])
## byte-tag-list.h (module 'network'): ns3::ByteTagList [class]
module.add_class('ByteTagList', import_from_module='ns.network')
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator [class]
module.add_class('Iterator', import_from_module='ns.network', outer_class=root_module['ns3::ByteTagList'])
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item [struct]
module.add_class('Item', import_from_module='ns.network', outer_class=root_module['ns3::ByteTagList::Iterator'])
## callback.h (module 'core'): ns3::CallbackBase [class]
module.add_class('CallbackBase', import_from_module='ns.core')
## hash.h (module 'core'): ns3::Hasher [class]
module.add_class('Hasher', import_from_module='ns.core')
## ipv4-address.h (module 'network'): ns3::Ipv4Address [class]
module.add_class('Ipv4Address', import_from_module='ns.network')
## ipv4-address.h (module 'network'): ns3::Ipv4Address [class]
root_module['ns3::Ipv4Address'].implicitly_converts_to(root_module['ns3::Address'])
## ipv4-address.h (module 'network'): ns3::Ipv4Mask [class]
module.add_class('Ipv4Mask', import_from_module='ns.network')
## ipv6-address.h (module 'network'): ns3::Ipv6Address [class]
module.add_class('Ipv6Address', import_from_module='ns.network')
## ipv6-address.h (module 'network'): ns3::Ipv6Address [class]
root_module['ns3::Ipv6Address'].implicitly_converts_to(root_module['ns3::Address'])
## ipv6-address.h (module 'network'): ns3::Ipv6Prefix [class]
module.add_class('Ipv6Prefix', import_from_module='ns.network')
## mac48-address.h (module 'network'): ns3::Mac48Address [class]
module.add_class('Mac48Address', import_from_module='ns.network')
## mac48-address.h (module 'network'): ns3::Mac48Address [class]
root_module['ns3::Mac48Address'].implicitly_converts_to(root_module['ns3::Address'])
## mpi-interface.h (module 'mpi'): ns3::MpiInterface [class]
module.add_class('MpiInterface')
## object-base.h (module 'core'): ns3::ObjectBase [class]
module.add_class('ObjectBase', allow_subclassing=True, import_from_module='ns.core')
## object.h (module 'core'): ns3::ObjectDeleter [struct]
module.add_class('ObjectDeleter', import_from_module='ns.core')
## packet-metadata.h (module 'network'): ns3::PacketMetadata [class]
module.add_class('PacketMetadata', import_from_module='ns.network')
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item [struct]
module.add_class('Item', import_from_module='ns.network', outer_class=root_module['ns3::PacketMetadata'])
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item [enumeration]
module.add_enum('', ['PAYLOAD', 'HEADER', 'TRAILER'], outer_class=root_module['ns3::PacketMetadata::Item'], import_from_module='ns.network')
## packet-metadata.h (module 'network'): ns3::PacketMetadata::ItemIterator [class]
module.add_class('ItemIterator', import_from_module='ns.network', outer_class=root_module['ns3::PacketMetadata'])
## packet.h (module 'network'): ns3::PacketTagIterator [class]
module.add_class('PacketTagIterator', import_from_module='ns.network')
## packet.h (module 'network'): ns3::PacketTagIterator::Item [class]
module.add_class('Item', import_from_module='ns.network', outer_class=root_module['ns3::PacketTagIterator'])
## packet-tag-list.h (module 'network'): ns3::PacketTagList [class]
module.add_class('PacketTagList', import_from_module='ns.network')
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData [struct]
module.add_class('TagData', import_from_module='ns.network', outer_class=root_module['ns3::PacketTagList'])
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData::TagData_e [enumeration]
module.add_enum('TagData_e', ['MAX_SIZE'], outer_class=root_module['ns3::PacketTagList::TagData'], import_from_module='ns.network')
## parallel-communication-interface.h (module 'mpi'): ns3::ParallelCommunicationInterface [class]
module.add_class('ParallelCommunicationInterface', allow_subclassing=True)
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter> [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::Object', 'ns3::ObjectBase', 'ns3::ObjectDeleter'], parent=root_module['ns3::ObjectBase'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## tag.h (module 'network'): ns3::Tag [class]
module.add_class('Tag', import_from_module='ns.network', parent=root_module['ns3::ObjectBase'])
## tag-buffer.h (module 'network'): ns3::TagBuffer [class]
module.add_class('TagBuffer', import_from_module='ns.network')
## nstime.h (module 'core'): ns3::TimeWithUnit [class]
module.add_class('TimeWithUnit', import_from_module='ns.core')
## type-id.h (module 'core'): ns3::TypeId [class]
module.add_class('TypeId', import_from_module='ns.core')
## type-id.h (module 'core'): ns3::TypeId::AttributeFlag [enumeration]
module.add_enum('AttributeFlag', ['ATTR_GET', 'ATTR_SET', 'ATTR_CONSTRUCT', 'ATTR_SGC'], outer_class=root_module['ns3::TypeId'], import_from_module='ns.core')
## type-id.h (module 'core'): ns3::TypeId::SupportLevel [enumeration]
module.add_enum('SupportLevel', ['SUPPORTED', 'DEPRECATED', 'OBSOLETE'], outer_class=root_module['ns3::TypeId'], import_from_module='ns.core')
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation [struct]
module.add_class('AttributeInformation', import_from_module='ns.core', outer_class=root_module['ns3::TypeId'])
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation [struct]
module.add_class('TraceSourceInformation', import_from_module='ns.core', outer_class=root_module['ns3::TypeId'])
## empty.h (module 'core'): ns3::empty [class]
module.add_class('empty', import_from_module='ns.core')
## int64x64-double.h (module 'core'): ns3::int64x64_t [class]
module.add_class('int64x64_t', import_from_module='ns.core')
## int64x64-double.h (module 'core'): ns3::int64x64_t::impl_type [enumeration]
module.add_enum('impl_type', ['int128_impl', 'cairo_impl', 'ld_impl'], outer_class=root_module['ns3::int64x64_t'], import_from_module='ns.core')
## chunk.h (module 'network'): ns3::Chunk [class]
module.add_class('Chunk', import_from_module='ns.network', parent=root_module['ns3::ObjectBase'])
## header.h (module 'network'): ns3::Header [class]
module.add_class('Header', import_from_module='ns.network', parent=root_module['ns3::Chunk'])
## object.h (module 'core'): ns3::Object [class]
module.add_class('Object', import_from_module='ns.core', parent=root_module['ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter >'])
## object.h (module 'core'): ns3::Object::AggregateIterator [class]
module.add_class('AggregateIterator', import_from_module='ns.core', outer_class=root_module['ns3::Object'])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::AttributeAccessor', 'ns3::empty', 'ns3::DefaultDeleter<ns3::AttributeAccessor>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::AttributeChecker', 'ns3::empty', 'ns3::DefaultDeleter<ns3::AttributeChecker>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::AttributeValue', 'ns3::empty', 'ns3::DefaultDeleter<ns3::AttributeValue>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::CallbackImplBase', 'ns3::empty', 'ns3::DefaultDeleter<ns3::CallbackImplBase>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::Hash::Implementation', 'ns3::empty', 'ns3::DefaultDeleter<ns3::Hash::Implementation>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::NixVector', 'ns3::empty', 'ns3::DefaultDeleter<ns3::NixVector>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::Packet', 'ns3::empty', 'ns3::DefaultDeleter<ns3::Packet>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::TraceSourceAccessor', 'ns3::empty', 'ns3::DefaultDeleter<ns3::TraceSourceAccessor>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## nstime.h (module 'core'): ns3::Time [class]
module.add_class('Time', import_from_module='ns.core')
## nstime.h (module 'core'): ns3::Time::Unit [enumeration]
module.add_enum('Unit', ['Y', 'D', 'H', 'MIN', 'S', 'MS', 'US', 'NS', 'PS', 'FS', 'LAST'], outer_class=root_module['ns3::Time'], import_from_module='ns.core')
## nstime.h (module 'core'): ns3::Time [class]
root_module['ns3::Time'].implicitly_converts_to(root_module['ns3::int64x64_t'])
## trace-source-accessor.h (module 'core'): ns3::TraceSourceAccessor [class]
module.add_class('TraceSourceAccessor', import_from_module='ns.core', parent=root_module['ns3::SimpleRefCount< ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> >'])
## trailer.h (module 'network'): ns3::Trailer [class]
module.add_class('Trailer', import_from_module='ns.network', parent=root_module['ns3::Chunk'])
## attribute.h (module 'core'): ns3::AttributeAccessor [class]
module.add_class('AttributeAccessor', import_from_module='ns.core', parent=root_module['ns3::SimpleRefCount< ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> >'])
## attribute.h (module 'core'): ns3::AttributeChecker [class]
module.add_class('AttributeChecker', allow_subclassing=False, automatic_type_narrowing=True, import_from_module='ns.core', parent=root_module['ns3::SimpleRefCount< ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> >'])
## attribute.h (module 'core'): ns3::AttributeValue [class]
module.add_class('AttributeValue', allow_subclassing=False, automatic_type_narrowing=True, import_from_module='ns.core', parent=root_module['ns3::SimpleRefCount< ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> >'])
## callback.h (module 'core'): ns3::CallbackChecker [class]
module.add_class('CallbackChecker', import_from_module='ns.core', parent=root_module['ns3::AttributeChecker'])
## callback.h (module 'core'): ns3::CallbackImplBase [class]
module.add_class('CallbackImplBase', import_from_module='ns.core', parent=root_module['ns3::SimpleRefCount< ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> >'])
## callback.h (module 'core'): ns3::CallbackValue [class]
module.add_class('CallbackValue', import_from_module='ns.core', parent=root_module['ns3::AttributeValue'])
## attribute.h (module 'core'): ns3::EmptyAttributeAccessor [class]
module.add_class('EmptyAttributeAccessor', import_from_module='ns.core', parent=root_module['ns3::AttributeAccessor'])
## attribute.h (module 'core'): ns3::EmptyAttributeChecker [class]
module.add_class('EmptyAttributeChecker', import_from_module='ns.core', parent=root_module['ns3::AttributeChecker'])
## attribute.h (module 'core'): ns3::EmptyAttributeValue [class]
module.add_class('EmptyAttributeValue', import_from_module='ns.core', parent=root_module['ns3::AttributeValue'])
## ipv4-address.h (module 'network'): ns3::Ipv4AddressChecker [class]
module.add_class('Ipv4AddressChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker'])
## ipv4-address.h (module 'network'): ns3::Ipv4AddressValue [class]
module.add_class('Ipv4AddressValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue'])
## ipv4-address.h (module 'network'): ns3::Ipv4MaskChecker [class]
module.add_class('Ipv4MaskChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker'])
## ipv4-address.h (module 'network'): ns3::Ipv4MaskValue [class]
module.add_class('Ipv4MaskValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue'])
## ipv6-address.h (module 'network'): ns3::Ipv6AddressChecker [class]
module.add_class('Ipv6AddressChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker'])
## ipv6-address.h (module 'network'): ns3::Ipv6AddressValue [class]
module.add_class('Ipv6AddressValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue'])
## ipv6-address.h (module 'network'): ns3::Ipv6PrefixChecker [class]
module.add_class('Ipv6PrefixChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker'])
## ipv6-address.h (module 'network'): ns3::Ipv6PrefixValue [class]
module.add_class('Ipv6PrefixValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue'])
## mac48-address.h (module 'network'): ns3::Mac48AddressChecker [class]
module.add_class('Mac48AddressChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker'])
## mac48-address.h (module 'network'): ns3::Mac48AddressValue [class]
module.add_class('Mac48AddressValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue'])
## mpi-receiver.h (module 'mpi'): ns3::MpiReceiver [class]
module.add_class('MpiReceiver', parent=root_module['ns3::Object'])
## nix-vector.h (module 'network'): ns3::NixVector [class]
module.add_class('NixVector', import_from_module='ns.network', parent=root_module['ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >'])
## packet.h (module 'network'): ns3::Packet [class]
module.add_class('Packet', import_from_module='ns.network', parent=root_module['ns3::SimpleRefCount< ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >'])
## nstime.h (module 'core'): ns3::TimeValue [class]
module.add_class('TimeValue', import_from_module='ns.core', parent=root_module['ns3::AttributeValue'])
## type-id.h (module 'core'): ns3::TypeIdChecker [class]
module.add_class('TypeIdChecker', import_from_module='ns.core', parent=root_module['ns3::AttributeChecker'])
## type-id.h (module 'core'): ns3::TypeIdValue [class]
module.add_class('TypeIdValue', import_from_module='ns.core', parent=root_module['ns3::AttributeValue'])
## address.h (module 'network'): ns3::AddressChecker [class]
module.add_class('AddressChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker'])
## address.h (module 'network'): ns3::AddressValue [class]
module.add_class('AddressValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue'])
## Register a nested module for the namespace FatalImpl
nested_module = module.add_cpp_namespace('FatalImpl')
register_types_ns3_FatalImpl(nested_module)
## Register a nested module for the namespace Hash
nested_module = module.add_cpp_namespace('Hash')
register_types_ns3_Hash(nested_module)
## Register a nested module for the namespace TracedValueCallback
nested_module = module.add_cpp_namespace('TracedValueCallback')
register_types_ns3_TracedValueCallback(nested_module)
def register_types_ns3_FatalImpl(module):
root_module = module.get_root()
def register_types_ns3_Hash(module):
root_module = module.get_root()
## hash-function.h (module 'core'): ns3::Hash::Implementation [class]
module.add_class('Implementation', import_from_module='ns.core', parent=root_module['ns3::SimpleRefCount< ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> >'])
typehandlers.add_type_alias(u'uint32_t ( * ) ( char const *, size_t ) *', u'ns3::Hash::Hash32Function_ptr')
typehandlers.add_type_alias(u'uint32_t ( * ) ( char const *, size_t ) **', u'ns3::Hash::Hash32Function_ptr*')
typehandlers.add_type_alias(u'uint32_t ( * ) ( char const *, size_t ) *&', u'ns3::Hash::Hash32Function_ptr&')
typehandlers.add_type_alias(u'uint64_t ( * ) ( char const *, size_t ) *', u'ns3::Hash::Hash64Function_ptr')
typehandlers.add_type_alias(u'uint64_t ( * ) ( char const *, size_t ) **', u'ns3::Hash::Hash64Function_ptr*')
typehandlers.add_type_alias(u'uint64_t ( * ) ( char const *, size_t ) *&', u'ns3::Hash::Hash64Function_ptr&')
## Register a nested module for the namespace Function
nested_module = module.add_cpp_namespace('Function')
register_types_ns3_Hash_Function(nested_module)
def register_types_ns3_Hash_Function(module):
root_module = module.get_root()
## hash-fnv.h (module 'core'): ns3::Hash::Function::Fnv1a [class]
module.add_class('Fnv1a', import_from_module='ns.core', parent=root_module['ns3::Hash::Implementation'])
## hash-function.h (module 'core'): ns3::Hash::Function::Hash32 [class]
module.add_class('Hash32', import_from_module='ns.core', parent=root_module['ns3::Hash::Implementation'])
## hash-function.h (module 'core'): ns3::Hash::Function::Hash64 [class]
module.add_class('Hash64', import_from_module='ns.core', parent=root_module['ns3::Hash::Implementation'])
## hash-murmur3.h (module 'core'): ns3::Hash::Function::Murmur3 [class]
module.add_class('Murmur3', import_from_module='ns.core', parent=root_module['ns3::Hash::Implementation'])
def register_types_ns3_TracedValueCallback(module):
root_module = module.get_root()
typehandlers.add_type_alias(u'void ( * ) ( ns3::Time, ns3::Time ) *', u'ns3::TracedValueCallback::Time')
typehandlers.add_type_alias(u'void ( * ) ( ns3::Time, ns3::Time ) **', u'ns3::TracedValueCallback::Time*')
typehandlers.add_type_alias(u'void ( * ) ( ns3::Time, ns3::Time ) *&', u'ns3::TracedValueCallback::Time&')
def register_methods(root_module):
register_Ns3Address_methods(root_module, root_module['ns3::Address'])
register_Ns3AttributeConstructionList_methods(root_module, root_module['ns3::AttributeConstructionList'])
register_Ns3AttributeConstructionListItem_methods(root_module, root_module['ns3::AttributeConstructionList::Item'])
register_Ns3Buffer_methods(root_module, root_module['ns3::Buffer'])
register_Ns3BufferIterator_methods(root_module, root_module['ns3::Buffer::Iterator'])
register_Ns3ByteTagIterator_methods(root_module, root_module['ns3::ByteTagIterator'])
register_Ns3ByteTagIteratorItem_methods(root_module, root_module['ns3::ByteTagIterator::Item'])
register_Ns3ByteTagList_methods(root_module, root_module['ns3::ByteTagList'])
register_Ns3ByteTagListIterator_methods(root_module, root_module['ns3::ByteTagList::Iterator'])
register_Ns3ByteTagListIteratorItem_methods(root_module, root_module['ns3::ByteTagList::Iterator::Item'])
register_Ns3CallbackBase_methods(root_module, root_module['ns3::CallbackBase'])
register_Ns3Hasher_methods(root_module, root_module['ns3::Hasher'])
register_Ns3Ipv4Address_methods(root_module, root_module['ns3::Ipv4Address'])
register_Ns3Ipv4Mask_methods(root_module, root_module['ns3::Ipv4Mask'])
register_Ns3Ipv6Address_methods(root_module, root_module['ns3::Ipv6Address'])
register_Ns3Ipv6Prefix_methods(root_module, root_module['ns3::Ipv6Prefix'])
register_Ns3Mac48Address_methods(root_module, root_module['ns3::Mac48Address'])
register_Ns3MpiInterface_methods(root_module, root_module['ns3::MpiInterface'])
register_Ns3ObjectBase_methods(root_module, root_module['ns3::ObjectBase'])
register_Ns3ObjectDeleter_methods(root_module, root_module['ns3::ObjectDeleter'])
register_Ns3PacketMetadata_methods(root_module, root_module['ns3::PacketMetadata'])
register_Ns3PacketMetadataItem_methods(root_module, root_module['ns3::PacketMetadata::Item'])
register_Ns3PacketMetadataItemIterator_methods(root_module, root_module['ns3::PacketMetadata::ItemIterator'])
register_Ns3PacketTagIterator_methods(root_module, root_module['ns3::PacketTagIterator'])
register_Ns3PacketTagIteratorItem_methods(root_module, root_module['ns3::PacketTagIterator::Item'])
register_Ns3PacketTagList_methods(root_module, root_module['ns3::PacketTagList'])
register_Ns3PacketTagListTagData_methods(root_module, root_module['ns3::PacketTagList::TagData'])
register_Ns3ParallelCommunicationInterface_methods(root_module, root_module['ns3::ParallelCommunicationInterface'])
register_Ns3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_methods(root_module, root_module['ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter >'])
register_Ns3Tag_methods(root_module, root_module['ns3::Tag'])
register_Ns3TagBuffer_methods(root_module, root_module['ns3::TagBuffer'])
register_Ns3TimeWithUnit_methods(root_module, root_module['ns3::TimeWithUnit'])
register_Ns3TypeId_methods(root_module, root_module['ns3::TypeId'])
register_Ns3TypeIdAttributeInformation_methods(root_module, root_module['ns3::TypeId::AttributeInformation'])
register_Ns3TypeIdTraceSourceInformation_methods(root_module, root_module['ns3::TypeId::TraceSourceInformation'])
register_Ns3Empty_methods(root_module, root_module['ns3::empty'])
register_Ns3Int64x64_t_methods(root_module, root_module['ns3::int64x64_t'])
register_Ns3Chunk_methods(root_module, root_module['ns3::Chunk'])
register_Ns3Header_methods(root_module, root_module['ns3::Header'])
register_Ns3Object_methods(root_module, root_module['ns3::Object'])
register_Ns3ObjectAggregateIterator_methods(root_module, root_module['ns3::Object::AggregateIterator'])
register_Ns3SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> >'])
register_Ns3SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> >'])
register_Ns3SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> >'])
register_Ns3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> >'])
register_Ns3SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> >'])
register_Ns3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >'])
register_Ns3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >'])
register_Ns3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> >'])
register_Ns3Time_methods(root_module, root_module['ns3::Time'])
register_Ns3TraceSourceAccessor_methods(root_module, root_module['ns3::TraceSourceAccessor'])
register_Ns3Trailer_methods(root_module, root_module['ns3::Trailer'])
register_Ns3AttributeAccessor_methods(root_module, root_module['ns3::AttributeAccessor'])
register_Ns3AttributeChecker_methods(root_module, root_module['ns3::AttributeChecker'])
register_Ns3AttributeValue_methods(root_module, root_module['ns3::AttributeValue'])
register_Ns3CallbackChecker_methods(root_module, root_module['ns3::CallbackChecker'])
register_Ns3CallbackImplBase_methods(root_module, root_module['ns3::CallbackImplBase'])
register_Ns3CallbackValue_methods(root_module, root_module['ns3::CallbackValue'])
register_Ns3EmptyAttributeAccessor_methods(root_module, root_module['ns3::EmptyAttributeAccessor'])
register_Ns3EmptyAttributeChecker_methods(root_module, root_module['ns3::EmptyAttributeChecker'])
register_Ns3EmptyAttributeValue_methods(root_module, root_module['ns3::EmptyAttributeValue'])
register_Ns3Ipv4AddressChecker_methods(root_module, root_module['ns3::Ipv4AddressChecker'])
register_Ns3Ipv4AddressValue_methods(root_module, root_module['ns3::Ipv4AddressValue'])
register_Ns3Ipv4MaskChecker_methods(root_module, root_module['ns3::Ipv4MaskChecker'])
register_Ns3Ipv4MaskValue_methods(root_module, root_module['ns3::Ipv4MaskValue'])
register_Ns3Ipv6AddressChecker_methods(root_module, root_module['ns3::Ipv6AddressChecker'])
register_Ns3Ipv6AddressValue_methods(root_module, root_module['ns3::Ipv6AddressValue'])
register_Ns3Ipv6PrefixChecker_methods(root_module, root_module['ns3::Ipv6PrefixChecker'])
register_Ns3Ipv6PrefixValue_methods(root_module, root_module['ns3::Ipv6PrefixValue'])
register_Ns3Mac48AddressChecker_methods(root_module, root_module['ns3::Mac48AddressChecker'])
register_Ns3Mac48AddressValue_methods(root_module, root_module['ns3::Mac48AddressValue'])
register_Ns3MpiReceiver_methods(root_module, root_module['ns3::MpiReceiver'])
register_Ns3NixVector_methods(root_module, root_module['ns3::NixVector'])
register_Ns3Packet_methods(root_module, root_module['ns3::Packet'])
register_Ns3TimeValue_methods(root_module, root_module['ns3::TimeValue'])
register_Ns3TypeIdChecker_methods(root_module, root_module['ns3::TypeIdChecker'])
register_Ns3TypeIdValue_methods(root_module, root_module['ns3::TypeIdValue'])
register_Ns3AddressChecker_methods(root_module, root_module['ns3::AddressChecker'])
register_Ns3AddressValue_methods(root_module, root_module['ns3::AddressValue'])
register_Ns3HashImplementation_methods(root_module, root_module['ns3::Hash::Implementation'])
register_Ns3HashFunctionFnv1a_methods(root_module, root_module['ns3::Hash::Function::Fnv1a'])
register_Ns3HashFunctionHash32_methods(root_module, root_module['ns3::Hash::Function::Hash32'])
register_Ns3HashFunctionHash64_methods(root_module, root_module['ns3::Hash::Function::Hash64'])
register_Ns3HashFunctionMurmur3_methods(root_module, root_module['ns3::Hash::Function::Murmur3'])
return
def register_Ns3Address_methods(root_module, cls):
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('!=')
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('==')
## address.h (module 'network'): ns3::Address::Address() [constructor]
cls.add_constructor([])
## address.h (module 'network'): ns3::Address::Address(uint8_t type, uint8_t const * buffer, uint8_t len) [constructor]
cls.add_constructor([param('uint8_t', 'type'), param('uint8_t const *', 'buffer'), param('uint8_t', 'len')])
## address.h (module 'network'): ns3::Address::Address(ns3::Address const & address) [copy constructor]
cls.add_constructor([param('ns3::Address const &', 'address')])
## address.h (module 'network'): bool ns3::Address::CheckCompatible(uint8_t type, uint8_t len) const [member function]
cls.add_method('CheckCompatible',
'bool',
[param('uint8_t', 'type'), param('uint8_t', 'len')],
is_const=True)
## address.h (module 'network'): uint32_t ns3::Address::CopyAllFrom(uint8_t const * buffer, uint8_t len) [member function]
cls.add_method('CopyAllFrom',
'uint32_t',
[param('uint8_t const *', 'buffer'), param('uint8_t', 'len')])
## address.h (module 'network'): uint32_t ns3::Address::CopyAllTo(uint8_t * buffer, uint8_t len) const [member function]
cls.add_method('CopyAllTo',
'uint32_t',
[param('uint8_t *', 'buffer'), param('uint8_t', 'len')],
is_const=True)
## address.h (module 'network'): uint32_t ns3::Address::CopyFrom(uint8_t const * buffer, uint8_t len) [member function]
cls.add_method('CopyFrom',
'uint32_t',
[param('uint8_t const *', 'buffer'), param('uint8_t', 'len')])
## address.h (module 'network'): uint32_t ns3::Address::CopyTo(uint8_t * buffer) const [member function]
cls.add_method('CopyTo',
'uint32_t',
[param('uint8_t *', 'buffer')],
is_const=True)
## address.h (module 'network'): void ns3::Address::Deserialize(ns3::TagBuffer buffer) [member function]
cls.add_method('Deserialize',
'void',
[param('ns3::TagBuffer', 'buffer')])
## address.h (module 'network'): uint8_t ns3::Address::GetLength() const [member function]
cls.add_method('GetLength',
'uint8_t',
[],
is_const=True)
## address.h (module 'network'): uint32_t ns3::Address::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_const=True)
## address.h (module 'network'): bool ns3::Address::IsInvalid() const [member function]
cls.add_method('IsInvalid',
'bool',
[],
is_const=True)
## address.h (module 'network'): bool ns3::Address::IsMatchingType(uint8_t type) const [member function]
cls.add_method('IsMatchingType',
'bool',
[param('uint8_t', 'type')],
is_const=True)
## address.h (module 'network'): static uint8_t ns3::Address::Register() [member function]
cls.add_method('Register',
'uint8_t',
[],
is_static=True)
## address.h (module 'network'): void ns3::Address::Serialize(ns3::TagBuffer buffer) const [member function]
cls.add_method('Serialize',
'void',
[param('ns3::TagBuffer', 'buffer')],
is_const=True)
return
def register_Ns3AttributeConstructionList_methods(root_module, cls):
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::AttributeConstructionList(ns3::AttributeConstructionList const & arg0) [copy constructor]
cls.add_constructor([param('ns3::AttributeConstructionList const &', 'arg0')])
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::AttributeConstructionList() [constructor]
cls.add_constructor([])
## attribute-construction-list.h (module 'core'): void ns3::AttributeConstructionList::Add(std::string name, ns3::Ptr<ns3::AttributeChecker const> checker, ns3::Ptr<ns3::AttributeValue> value) [member function]
cls.add_method('Add',
'void',
[param('std::string', 'name'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker'), param('ns3::Ptr< ns3::AttributeValue >', 'value')])
## attribute-construction-list.h (module 'core'): std::_List_const_iterator<ns3::AttributeConstructionList::Item> ns3::AttributeConstructionList::Begin() const [member function]
cls.add_method('Begin',
'std::_List_const_iterator< ns3::AttributeConstructionList::Item >',
[],
is_const=True)
## attribute-construction-list.h (module 'core'): std::_List_const_iterator<ns3::AttributeConstructionList::Item> ns3::AttributeConstructionList::End() const [member function]
cls.add_method('End',
'std::_List_const_iterator< ns3::AttributeConstructionList::Item >',
[],
is_const=True)
## attribute-construction-list.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::AttributeConstructionList::Find(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('Find',
'ns3::Ptr< ns3::AttributeValue >',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True)
return
def register_Ns3AttributeConstructionListItem_methods(root_module, cls):
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::Item::Item() [constructor]
cls.add_constructor([])
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::Item::Item(ns3::AttributeConstructionList::Item const & arg0) [copy constructor]
cls.add_constructor([param('ns3::AttributeConstructionList::Item const &', 'arg0')])
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::Item::checker [variable]
cls.add_instance_attribute('checker', 'ns3::Ptr< ns3::AttributeChecker const >', is_const=False)
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::Item::name [variable]
cls.add_instance_attribute('name', 'std::string', is_const=False)
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::Item::value [variable]
cls.add_instance_attribute('value', 'ns3::Ptr< ns3::AttributeValue >', is_const=False)
return
def register_Ns3Buffer_methods(root_module, cls):
## buffer.h (module 'network'): ns3::Buffer::Buffer() [constructor]
cls.add_constructor([])
## buffer.h (module 'network'): ns3::Buffer::Buffer(uint32_t dataSize) [constructor]
cls.add_constructor([param('uint32_t', 'dataSize')])
## buffer.h (module 'network'): ns3::Buffer::Buffer(uint32_t dataSize, bool initialize) [constructor]
cls.add_constructor([param('uint32_t', 'dataSize'), param('bool', 'initialize')])
## buffer.h (module 'network'): ns3::Buffer::Buffer(ns3::Buffer const & o) [copy constructor]
cls.add_constructor([param('ns3::Buffer const &', 'o')])
## buffer.h (module 'network'): void ns3::Buffer::AddAtEnd(uint32_t end) [member function]
cls.add_method('AddAtEnd',
'void',
[param('uint32_t', 'end')])
## buffer.h (module 'network'): void ns3::Buffer::AddAtEnd(ns3::Buffer const & o) [member function]
cls.add_method('AddAtEnd',
'void',
[param('ns3::Buffer const &', 'o')])
## buffer.h (module 'network'): void ns3::Buffer::AddAtStart(uint32_t start) [member function]
cls.add_method('AddAtStart',
'void',
[param('uint32_t', 'start')])
## buffer.h (module 'network'): ns3::Buffer::Iterator ns3::Buffer::Begin() const [member function]
cls.add_method('Begin',
'ns3::Buffer::Iterator',
[],
is_const=True)
## buffer.h (module 'network'): void ns3::Buffer::CopyData(std::ostream * os, uint32_t size) const [member function]
cls.add_method('CopyData',
'void',
[param('std::ostream *', 'os'), param('uint32_t', 'size')],
is_const=True)
## buffer.h (module 'network'): uint32_t ns3::Buffer::CopyData(uint8_t * buffer, uint32_t size) const [member function]
cls.add_method('CopyData',
'uint32_t',
[param('uint8_t *', 'buffer'), param('uint32_t', 'size')],
is_const=True)
## buffer.h (module 'network'): ns3::Buffer ns3::Buffer::CreateFragment(uint32_t start, uint32_t length) const [member function]
cls.add_method('CreateFragment',
'ns3::Buffer',
[param('uint32_t', 'start'), param('uint32_t', 'length')],
is_const=True)
## buffer.h (module 'network'): uint32_t ns3::Buffer::Deserialize(uint8_t const * buffer, uint32_t size) [member function]
cls.add_method('Deserialize',
'uint32_t',
[param('uint8_t const *', 'buffer'), param('uint32_t', 'size')])
## buffer.h (module 'network'): ns3::Buffer::Iterator ns3::Buffer::End() const [member function]
cls.add_method('End',
'ns3::Buffer::Iterator',
[],
is_const=True)
## buffer.h (module 'network'): uint32_t ns3::Buffer::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_const=True)
## buffer.h (module 'network'): uint32_t ns3::Buffer::GetSize() const [member function]
cls.add_method('GetSize',
'uint32_t',
[],
is_const=True)
## buffer.h (module 'network'): uint8_t const * ns3::Buffer::PeekData() const [member function]
cls.add_method('PeekData',
'uint8_t const *',
[],
is_const=True)
## buffer.h (module 'network'): void ns3::Buffer::RemoveAtEnd(uint32_t end) [member function]
cls.add_method('RemoveAtEnd',
'void',
[param('uint32_t', 'end')])
## buffer.h (module 'network'): void ns3::Buffer::RemoveAtStart(uint32_t start) [member function]
cls.add_method('RemoveAtStart',
'void',
[param('uint32_t', 'start')])
## buffer.h (module 'network'): uint32_t ns3::Buffer::Serialize(uint8_t * buffer, uint32_t maxSize) const [member function]
cls.add_method('Serialize',
'uint32_t',
[param('uint8_t *', 'buffer'), param('uint32_t', 'maxSize')],
is_const=True)
return
def register_Ns3BufferIterator_methods(root_module, cls):
## buffer.h (module 'network'): ns3::Buffer::Iterator::Iterator(ns3::Buffer::Iterator const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Buffer::Iterator const &', 'arg0')])
## buffer.h (module 'network'): ns3::Buffer::Iterator::Iterator() [constructor]
cls.add_constructor([])
## buffer.h (module 'network'): uint16_t ns3::Buffer::Iterator::CalculateIpChecksum(uint16_t size) [member function]
cls.add_method('CalculateIpChecksum',
'uint16_t',
[param('uint16_t', 'size')])
## buffer.h (module 'network'): uint16_t ns3::Buffer::Iterator::CalculateIpChecksum(uint16_t size, uint32_t initialChecksum) [member function]
cls.add_method('CalculateIpChecksum',
'uint16_t',
[param('uint16_t', 'size'), param('uint32_t', 'initialChecksum')])
## buffer.h (module 'network'): uint32_t ns3::Buffer::Iterator::GetDistanceFrom(ns3::Buffer::Iterator const & o) const [member function]
cls.add_method('GetDistanceFrom',
'uint32_t',
[param('ns3::Buffer::Iterator const &', 'o')],
is_const=True)
## buffer.h (module 'network'): uint32_t ns3::Buffer::Iterator::GetRemainingSize() const [member function]
cls.add_method('GetRemainingSize',
'uint32_t',
[],
is_const=True)
## buffer.h (module 'network'): uint32_t ns3::Buffer::Iterator::GetSize() const [member function]
cls.add_method('GetSize',
'uint32_t',
[],
is_const=True)
## buffer.h (module 'network'): bool ns3::Buffer::Iterator::IsEnd() const [member function]
cls.add_method('IsEnd',
'bool',
[],
is_const=True)
## buffer.h (module 'network'): bool ns3::Buffer::Iterator::IsStart() const [member function]
cls.add_method('IsStart',
'bool',
[],
is_const=True)
## buffer.h (module 'network'): void ns3::Buffer::Iterator::Next() [member function]
cls.add_method('Next',
'void',
[])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::Next(uint32_t delta) [member function]
cls.add_method('Next',
'void',
[param('uint32_t', 'delta')])
## buffer.h (module 'network'): uint8_t ns3::Buffer::Iterator::PeekU8() [member function]
cls.add_method('PeekU8',
'uint8_t',
[])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::Prev() [member function]
cls.add_method('Prev',
'void',
[])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::Prev(uint32_t delta) [member function]
cls.add_method('Prev',
'void',
[param('uint32_t', 'delta')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::Read(uint8_t * buffer, uint32_t size) [member function]
cls.add_method('Read',
'void',
[param('uint8_t *', 'buffer'), param('uint32_t', 'size')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::Read(ns3::Buffer::Iterator start, uint32_t size) [member function]
cls.add_method('Read',
'void',
[param('ns3::Buffer::Iterator', 'start'), param('uint32_t', 'size')])
## buffer.h (module 'network'): uint16_t ns3::Buffer::Iterator::ReadLsbtohU16() [member function]
cls.add_method('ReadLsbtohU16',
'uint16_t',
[])
## buffer.h (module 'network'): uint32_t ns3::Buffer::Iterator::ReadLsbtohU32() [member function]
cls.add_method('ReadLsbtohU32',
'uint32_t',
[])
## buffer.h (module 'network'): uint64_t ns3::Buffer::Iterator::ReadLsbtohU64() [member function]
cls.add_method('ReadLsbtohU64',
'uint64_t',
[])
## buffer.h (module 'network'): uint16_t ns3::Buffer::Iterator::ReadNtohU16() [member function]
cls.add_method('ReadNtohU16',
'uint16_t',
[])
## buffer.h (module 'network'): uint32_t ns3::Buffer::Iterator::ReadNtohU32() [member function]
cls.add_method('ReadNtohU32',
'uint32_t',
[])
## buffer.h (module 'network'): uint64_t ns3::Buffer::Iterator::ReadNtohU64() [member function]
cls.add_method('ReadNtohU64',
'uint64_t',
[])
## buffer.h (module 'network'): uint16_t ns3::Buffer::Iterator::ReadU16() [member function]
cls.add_method('ReadU16',
'uint16_t',
[])
## buffer.h (module 'network'): uint32_t ns3::Buffer::Iterator::ReadU32() [member function]
cls.add_method('ReadU32',
'uint32_t',
[])
## buffer.h (module 'network'): uint64_t ns3::Buffer::Iterator::ReadU64() [member function]
cls.add_method('ReadU64',
'uint64_t',
[])
## buffer.h (module 'network'): uint8_t ns3::Buffer::Iterator::ReadU8() [member function]
cls.add_method('ReadU8',
'uint8_t',
[])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::Write(uint8_t const * buffer, uint32_t size) [member function]
cls.add_method('Write',
'void',
[param('uint8_t const *', 'buffer'), param('uint32_t', 'size')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::Write(ns3::Buffer::Iterator start, ns3::Buffer::Iterator end) [member function]
cls.add_method('Write',
'void',
[param('ns3::Buffer::Iterator', 'start'), param('ns3::Buffer::Iterator', 'end')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteHtolsbU16(uint16_t data) [member function]
cls.add_method('WriteHtolsbU16',
'void',
[param('uint16_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteHtolsbU32(uint32_t data) [member function]
cls.add_method('WriteHtolsbU32',
'void',
[param('uint32_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteHtolsbU64(uint64_t data) [member function]
cls.add_method('WriteHtolsbU64',
'void',
[param('uint64_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteHtonU16(uint16_t data) [member function]
cls.add_method('WriteHtonU16',
'void',
[param('uint16_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteHtonU32(uint32_t data) [member function]
cls.add_method('WriteHtonU32',
'void',
[param('uint32_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteHtonU64(uint64_t data) [member function]
cls.add_method('WriteHtonU64',
'void',
[param('uint64_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteU16(uint16_t data) [member function]
cls.add_method('WriteU16',
'void',
[param('uint16_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteU32(uint32_t data) [member function]
cls.add_method('WriteU32',
'void',
[param('uint32_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteU64(uint64_t data) [member function]
cls.add_method('WriteU64',
'void',
[param('uint64_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteU8(uint8_t data) [member function]
cls.add_method('WriteU8',
'void',
[param('uint8_t', 'data')])
## buffer.h (module 'network'): void ns3::Buffer::Iterator::WriteU8(uint8_t data, uint32_t len) [member function]
cls.add_method('WriteU8',
'void',
[param('uint8_t', 'data'), param('uint32_t', 'len')])
return
def register_Ns3ByteTagIterator_methods(root_module, cls):
## packet.h (module 'network'): ns3::ByteTagIterator::ByteTagIterator(ns3::ByteTagIterator const & arg0) [copy constructor]
cls.add_constructor([param('ns3::ByteTagIterator const &', 'arg0')])
## packet.h (module 'network'): bool ns3::ByteTagIterator::HasNext() const [member function]
cls.add_method('HasNext',
'bool',
[],
is_const=True)
## packet.h (module 'network'): ns3::ByteTagIterator::Item ns3::ByteTagIterator::Next() [member function]
cls.add_method('Next',
'ns3::ByteTagIterator::Item',
[])
return
def register_Ns3ByteTagIteratorItem_methods(root_module, cls):
## packet.h (module 'network'): ns3::ByteTagIterator::Item::Item(ns3::ByteTagIterator::Item const & arg0) [copy constructor]
cls.add_constructor([param('ns3::ByteTagIterator::Item const &', 'arg0')])
## packet.h (module 'network'): uint32_t ns3::ByteTagIterator::Item::GetEnd() const [member function]
cls.add_method('GetEnd',
'uint32_t',
[],
is_const=True)
## packet.h (module 'network'): uint32_t ns3::ByteTagIterator::Item::GetStart() const [member function]
cls.add_method('GetStart',
'uint32_t',
[],
is_const=True)
## packet.h (module 'network'): void ns3::ByteTagIterator::Item::GetTag(ns3::Tag & tag) const [member function]
cls.add_method('GetTag',
'void',
[param('ns3::Tag &', 'tag')],
is_const=True)
## packet.h (module 'network'): ns3::TypeId ns3::ByteTagIterator::Item::GetTypeId() const [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_const=True)
return
def register_Ns3ByteTagList_methods(root_module, cls):
## byte-tag-list.h (module 'network'): ns3::ByteTagList::ByteTagList() [constructor]
cls.add_constructor([])
## byte-tag-list.h (module 'network'): ns3::ByteTagList::ByteTagList(ns3::ByteTagList const & o) [copy constructor]
cls.add_constructor([param('ns3::ByteTagList const &', 'o')])
## byte-tag-list.h (module 'network'): ns3::TagBuffer ns3::ByteTagList::Add(ns3::TypeId tid, uint32_t bufferSize, int32_t start, int32_t end) [member function]
cls.add_method('Add',
'ns3::TagBuffer',
[param('ns3::TypeId', 'tid'), param('uint32_t', 'bufferSize'), param('int32_t', 'start'), param('int32_t', 'end')])
## byte-tag-list.h (module 'network'): void ns3::ByteTagList::Add(ns3::ByteTagList const & o) [member function]
cls.add_method('Add',
'void',
[param('ns3::ByteTagList const &', 'o')])
## byte-tag-list.h (module 'network'): void ns3::ByteTagList::AddAtEnd(int32_t appendOffset) [member function]
cls.add_method('AddAtEnd',
'void',
[param('int32_t', 'appendOffset')])
## byte-tag-list.h (module 'network'): void ns3::ByteTagList::AddAtStart(int32_t prependOffset) [member function]
cls.add_method('AddAtStart',
'void',
[param('int32_t', 'prependOffset')])
## byte-tag-list.h (module 'network'): void ns3::ByteTagList::Adjust(int32_t adjustment) [member function]
cls.add_method('Adjust',
'void',
[param('int32_t', 'adjustment')])
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator ns3::ByteTagList::Begin(int32_t offsetStart, int32_t offsetEnd) const [member function]
cls.add_method('Begin',
'ns3::ByteTagList::Iterator',
[param('int32_t', 'offsetStart'), param('int32_t', 'offsetEnd')],
is_const=True)
## byte-tag-list.h (module 'network'): void ns3::ByteTagList::RemoveAll() [member function]
cls.add_method('RemoveAll',
'void',
[])
return
def register_Ns3ByteTagListIterator_methods(root_module, cls):
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Iterator(ns3::ByteTagList::Iterator const & arg0) [copy constructor]
cls.add_constructor([param('ns3::ByteTagList::Iterator const &', 'arg0')])
## byte-tag-list.h (module 'network'): uint32_t ns3::ByteTagList::Iterator::GetOffsetStart() const [member function]
cls.add_method('GetOffsetStart',
'uint32_t',
[],
is_const=True)
## byte-tag-list.h (module 'network'): bool ns3::ByteTagList::Iterator::HasNext() const [member function]
cls.add_method('HasNext',
'bool',
[],
is_const=True)
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item ns3::ByteTagList::Iterator::Next() [member function]
cls.add_method('Next',
'ns3::ByteTagList::Iterator::Item',
[])
return
def register_Ns3ByteTagListIteratorItem_methods(root_module, cls):
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item::Item(ns3::ByteTagList::Iterator::Item const & arg0) [copy constructor]
cls.add_constructor([param('ns3::ByteTagList::Iterator::Item const &', 'arg0')])
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item::Item(ns3::TagBuffer buf) [constructor]
cls.add_constructor([param('ns3::TagBuffer', 'buf')])
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item::buf [variable]
cls.add_instance_attribute('buf', 'ns3::TagBuffer', is_const=False)
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item::end [variable]
cls.add_instance_attribute('end', 'int32_t', is_const=False)
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item::size [variable]
cls.add_instance_attribute('size', 'uint32_t', is_const=False)
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item::start [variable]
cls.add_instance_attribute('start', 'int32_t', is_const=False)
## byte-tag-list.h (module 'network'): ns3::ByteTagList::Iterator::Item::tid [variable]
cls.add_instance_attribute('tid', 'ns3::TypeId', is_const=False)
return
def register_Ns3CallbackBase_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackBase::CallbackBase(ns3::CallbackBase const & arg0) [copy constructor]
cls.add_constructor([param('ns3::CallbackBase const &', 'arg0')])
## callback.h (module 'core'): ns3::CallbackBase::CallbackBase() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::Ptr<ns3::CallbackImplBase> ns3::CallbackBase::GetImpl() const [member function]
cls.add_method('GetImpl',
'ns3::Ptr< ns3::CallbackImplBase >',
[],
is_const=True)
## callback.h (module 'core'): ns3::CallbackBase::CallbackBase(ns3::Ptr<ns3::CallbackImplBase> impl) [constructor]
cls.add_constructor([param('ns3::Ptr< ns3::CallbackImplBase >', 'impl')],
visibility='protected')
return
def register_Ns3Hasher_methods(root_module, cls):
## hash.h (module 'core'): ns3::Hasher::Hasher(ns3::Hasher const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Hasher const &', 'arg0')])
## hash.h (module 'core'): ns3::Hasher::Hasher() [constructor]
cls.add_constructor([])
## hash.h (module 'core'): ns3::Hasher::Hasher(ns3::Ptr<ns3::Hash::Implementation> hp) [constructor]
cls.add_constructor([param('ns3::Ptr< ns3::Hash::Implementation >', 'hp')])
## hash.h (module 'core'): uint32_t ns3::Hasher::GetHash32(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash32',
'uint32_t',
[param('char const *', 'buffer'), param('size_t const', 'size')])
## hash.h (module 'core'): uint32_t ns3::Hasher::GetHash32(std::string const s) [member function]
cls.add_method('GetHash32',
'uint32_t',
[param('std::string const', 's')])
## hash.h (module 'core'): uint64_t ns3::Hasher::GetHash64(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash64',
'uint64_t',
[param('char const *', 'buffer'), param('size_t const', 'size')])
## hash.h (module 'core'): uint64_t ns3::Hasher::GetHash64(std::string const s) [member function]
cls.add_method('GetHash64',
'uint64_t',
[param('std::string const', 's')])
## hash.h (module 'core'): ns3::Hasher & ns3::Hasher::clear() [member function]
cls.add_method('clear',
'ns3::Hasher &',
[])
return
def register_Ns3Ipv4Address_methods(root_module, cls):
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('!=')
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('==')
## ipv4-address.h (module 'network'): ns3::Ipv4Address::Ipv4Address(ns3::Ipv4Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4Address const &', 'arg0')])
## ipv4-address.h (module 'network'): ns3::Ipv4Address::Ipv4Address() [constructor]
cls.add_constructor([])
## ipv4-address.h (module 'network'): ns3::Ipv4Address::Ipv4Address(uint32_t address) [constructor]
cls.add_constructor([param('uint32_t', 'address')])
## ipv4-address.h (module 'network'): ns3::Ipv4Address::Ipv4Address(char const * address) [constructor]
cls.add_constructor([param('char const *', 'address')])
## ipv4-address.h (module 'network'): ns3::Ipv4Address ns3::Ipv4Address::CombineMask(ns3::Ipv4Mask const & mask) const [member function]
cls.add_method('CombineMask',
'ns3::Ipv4Address',
[param('ns3::Ipv4Mask const &', 'mask')],
is_const=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Address ns3::Ipv4Address::ConvertFrom(ns3::Address const & address) [member function]
cls.add_method('ConvertFrom',
'ns3::Ipv4Address',
[param('ns3::Address const &', 'address')],
is_static=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Address ns3::Ipv4Address::Deserialize(uint8_t const * buf) [member function]
cls.add_method('Deserialize',
'ns3::Ipv4Address',
[param('uint8_t const *', 'buf')],
is_static=True)
## ipv4-address.h (module 'network'): uint32_t ns3::Ipv4Address::Get() const [member function]
cls.add_method('Get',
'uint32_t',
[],
is_const=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Address ns3::Ipv4Address::GetAny() [member function]
cls.add_method('GetAny',
'ns3::Ipv4Address',
[],
is_static=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Address ns3::Ipv4Address::GetBroadcast() [member function]
cls.add_method('GetBroadcast',
'ns3::Ipv4Address',
[],
is_static=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Address ns3::Ipv4Address::GetLoopback() [member function]
cls.add_method('GetLoopback',
'ns3::Ipv4Address',
[],
is_static=True)
## ipv4-address.h (module 'network'): ns3::Ipv4Address ns3::Ipv4Address::GetSubnetDirectedBroadcast(ns3::Ipv4Mask const & mask) const [member function]
cls.add_method('GetSubnetDirectedBroadcast',
'ns3::Ipv4Address',
[param('ns3::Ipv4Mask const &', 'mask')],
is_const=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Address ns3::Ipv4Address::GetZero() [member function]
cls.add_method('GetZero',
'ns3::Ipv4Address',
[],
is_static=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsAny() const [member function]
cls.add_method('IsAny',
'bool',
[],
is_const=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsBroadcast() const [member function]
cls.add_method('IsBroadcast',
'bool',
[],
is_const=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsEqual(ns3::Ipv4Address const & other) const [member function]
cls.add_method('IsEqual',
'bool',
[param('ns3::Ipv4Address const &', 'other')],
is_const=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsLocalMulticast() const [member function]
cls.add_method('IsLocalMulticast',
'bool',
[],
is_const=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsLocalhost() const [member function]
cls.add_method('IsLocalhost',
'bool',
[],
is_const=True)
## ipv4-address.h (module 'network'): static bool ns3::Ipv4Address::IsMatchingType(ns3::Address const & address) [member function]
cls.add_method('IsMatchingType',
'bool',
[param('ns3::Address const &', 'address')],
is_static=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsMulticast() const [member function]
cls.add_method('IsMulticast',
'bool',
[],
is_const=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsSubnetDirectedBroadcast(ns3::Ipv4Mask const & mask) const [member function]
cls.add_method('IsSubnetDirectedBroadcast',
'bool',
[param('ns3::Ipv4Mask const &', 'mask')],
is_const=True)
## ipv4-address.h (module 'network'): void ns3::Ipv4Address::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_const=True)
## ipv4-address.h (module 'network'): void ns3::Ipv4Address::Serialize(uint8_t * buf) const [member function]
cls.add_method('Serialize',
'void',
[param('uint8_t *', 'buf')],
is_const=True)
## ipv4-address.h (module 'network'): void ns3::Ipv4Address::Set(uint32_t address) [member function]
cls.add_method('Set',
'void',
[param('uint32_t', 'address')])
## ipv4-address.h (module 'network'): void ns3::Ipv4Address::Set(char const * address) [member function]
cls.add_method('Set',
'void',
[param('char const *', 'address')])
return
def register_Ns3Ipv4Mask_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('==')
## ipv4-address.h (module 'network'): ns3::Ipv4Mask::Ipv4Mask(ns3::Ipv4Mask const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4Mask const &', 'arg0')])
## ipv4-address.h (module 'network'): ns3::Ipv4Mask::Ipv4Mask() [constructor]
cls.add_constructor([])
## ipv4-address.h (module 'network'): ns3::Ipv4Mask::Ipv4Mask(uint32_t mask) [constructor]
cls.add_constructor([param('uint32_t', 'mask')])
## ipv4-address.h (module 'network'): ns3::Ipv4Mask::Ipv4Mask(char const * mask) [constructor]
cls.add_constructor([param('char const *', 'mask')])
## ipv4-address.h (module 'network'): uint32_t ns3::Ipv4Mask::Get() const [member function]
cls.add_method('Get',
'uint32_t',
[],
is_const=True)
## ipv4-address.h (module 'network'): uint32_t ns3::Ipv4Mask::GetInverse() const [member function]
cls.add_method('GetInverse',
'uint32_t',
[],
is_const=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Mask ns3::Ipv4Mask::GetLoopback() [member function]
cls.add_method('GetLoopback',
'ns3::Ipv4Mask',
[],
is_static=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Mask ns3::Ipv4Mask::GetOnes() [member function]
cls.add_method('GetOnes',
'ns3::Ipv4Mask',
[],
is_static=True)
## ipv4-address.h (module 'network'): uint16_t ns3::Ipv4Mask::GetPrefixLength() const [member function]
cls.add_method('GetPrefixLength',
'uint16_t',
[],
is_const=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Mask ns3::Ipv4Mask::GetZero() [member function]
cls.add_method('GetZero',
'ns3::Ipv4Mask',
[],
is_static=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Mask::IsEqual(ns3::Ipv4Mask other) const [member function]
cls.add_method('IsEqual',
'bool',
[param('ns3::Ipv4Mask', 'other')],
is_const=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4Mask::IsMatch(ns3::Ipv4Address a, ns3::Ipv4Address b) const [member function]
cls.add_method('IsMatch',
'bool',
[param('ns3::Ipv4Address', 'a'), param('ns3::Ipv4Address', 'b')],
is_const=True)
## ipv4-address.h (module 'network'): void ns3::Ipv4Mask::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_const=True)
## ipv4-address.h (module 'network'): void ns3::Ipv4Mask::Set(uint32_t mask) [member function]
cls.add_method('Set',
'void',
[param('uint32_t', 'mask')])
return
def register_Ns3Ipv6Address_methods(root_module, cls):
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('!=')
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('==')
## ipv6-address.h (module 'network'): ns3::Ipv6Address::Ipv6Address() [constructor]
cls.add_constructor([])
## ipv6-address.h (module 'network'): ns3::Ipv6Address::Ipv6Address(char const * address) [constructor]
cls.add_constructor([param('char const *', 'address')])
## ipv6-address.h (module 'network'): ns3::Ipv6Address::Ipv6Address(uint8_t * address) [constructor]
cls.add_constructor([param('uint8_t *', 'address')])
## ipv6-address.h (module 'network'): ns3::Ipv6Address::Ipv6Address(ns3::Ipv6Address const & addr) [copy constructor]
cls.add_constructor([param('ns3::Ipv6Address const &', 'addr')])
## ipv6-address.h (module 'network'): ns3::Ipv6Address::Ipv6Address(ns3::Ipv6Address const * addr) [constructor]
cls.add_constructor([param('ns3::Ipv6Address const *', 'addr')])
## ipv6-address.h (module 'network'): ns3::Ipv6Address ns3::Ipv6Address::CombinePrefix(ns3::Ipv6Prefix const & prefix) [member function]
cls.add_method('CombinePrefix',
'ns3::Ipv6Address',
[param('ns3::Ipv6Prefix const &', 'prefix')])
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::ConvertFrom(ns3::Address const & address) [member function]
cls.add_method('ConvertFrom',
'ns3::Ipv6Address',
[param('ns3::Address const &', 'address')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::Deserialize(uint8_t const * buf) [member function]
cls.add_method('Deserialize',
'ns3::Ipv6Address',
[param('uint8_t const *', 'buf')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::GetAllHostsMulticast() [member function]
cls.add_method('GetAllHostsMulticast',
'ns3::Ipv6Address',
[],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::GetAllNodesMulticast() [member function]
cls.add_method('GetAllNodesMulticast',
'ns3::Ipv6Address',
[],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::GetAllRoutersMulticast() [member function]
cls.add_method('GetAllRoutersMulticast',
'ns3::Ipv6Address',
[],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::GetAny() [member function]
cls.add_method('GetAny',
'ns3::Ipv6Address',
[],
is_static=True)
## ipv6-address.h (module 'network'): void ns3::Ipv6Address::GetBytes(uint8_t * buf) const [member function]
cls.add_method('GetBytes',
'void',
[param('uint8_t *', 'buf')],
is_const=True)
## ipv6-address.h (module 'network'): ns3::Ipv4Address ns3::Ipv6Address::GetIpv4MappedAddress() const [member function]
cls.add_method('GetIpv4MappedAddress',
'ns3::Ipv4Address',
[],
is_const=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::GetLoopback() [member function]
cls.add_method('GetLoopback',
'ns3::Ipv6Address',
[],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::GetOnes() [member function]
cls.add_method('GetOnes',
'ns3::Ipv6Address',
[],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::GetZero() [member function]
cls.add_method('GetZero',
'ns3::Ipv6Address',
[],
is_static=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsAllHostsMulticast() const [member function]
cls.add_method('IsAllHostsMulticast',
'bool',
[],
deprecated=True, is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsAllNodesMulticast() const [member function]
cls.add_method('IsAllNodesMulticast',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsAllRoutersMulticast() const [member function]
cls.add_method('IsAllRoutersMulticast',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsAny() const [member function]
cls.add_method('IsAny',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsDocumentation() const [member function]
cls.add_method('IsDocumentation',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsEqual(ns3::Ipv6Address const & other) const [member function]
cls.add_method('IsEqual',
'bool',
[param('ns3::Ipv6Address const &', 'other')],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsIpv4MappedAddress() const [member function]
cls.add_method('IsIpv4MappedAddress',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsLinkLocal() const [member function]
cls.add_method('IsLinkLocal',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsLinkLocalMulticast() const [member function]
cls.add_method('IsLinkLocalMulticast',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsLocalhost() const [member function]
cls.add_method('IsLocalhost',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): static bool ns3::Ipv6Address::IsMatchingType(ns3::Address const & address) [member function]
cls.add_method('IsMatchingType',
'bool',
[param('ns3::Address const &', 'address')],
is_static=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsMulticast() const [member function]
cls.add_method('IsMulticast',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsSolicitedMulticast() const [member function]
cls.add_method('IsSolicitedMulticast',
'bool',
[],
is_const=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::MakeAutoconfiguredAddress(ns3::Mac16Address addr, ns3::Ipv6Address prefix) [member function]
cls.add_method('MakeAutoconfiguredAddress',
'ns3::Ipv6Address',
[param('ns3::Mac16Address', 'addr'), param('ns3::Ipv6Address', 'prefix')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::MakeAutoconfiguredAddress(ns3::Mac48Address addr, ns3::Ipv6Address prefix) [member function]
cls.add_method('MakeAutoconfiguredAddress',
'ns3::Ipv6Address',
[param('ns3::Mac48Address', 'addr'), param('ns3::Ipv6Address', 'prefix')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::MakeAutoconfiguredAddress(ns3::Mac64Address addr, ns3::Ipv6Address prefix) [member function]
cls.add_method('MakeAutoconfiguredAddress',
'ns3::Ipv6Address',
[param('ns3::Mac64Address', 'addr'), param('ns3::Ipv6Address', 'prefix')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(ns3::Mac16Address mac) [member function]
cls.add_method('MakeAutoconfiguredLinkLocalAddress',
'ns3::Ipv6Address',
[param('ns3::Mac16Address', 'mac')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(ns3::Mac48Address mac) [member function]
cls.add_method('MakeAutoconfiguredLinkLocalAddress',
'ns3::Ipv6Address',
[param('ns3::Mac48Address', 'mac')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(ns3::Mac64Address mac) [member function]
cls.add_method('MakeAutoconfiguredLinkLocalAddress',
'ns3::Ipv6Address',
[param('ns3::Mac64Address', 'mac')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::MakeIpv4MappedAddress(ns3::Ipv4Address addr) [member function]
cls.add_method('MakeIpv4MappedAddress',
'ns3::Ipv6Address',
[param('ns3::Ipv4Address', 'addr')],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Address ns3::Ipv6Address::MakeSolicitedAddress(ns3::Ipv6Address addr) [member function]
cls.add_method('MakeSolicitedAddress',
'ns3::Ipv6Address',
[param('ns3::Ipv6Address', 'addr')],
is_static=True)
## ipv6-address.h (module 'network'): void ns3::Ipv6Address::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_const=True)
## ipv6-address.h (module 'network'): void ns3::Ipv6Address::Serialize(uint8_t * buf) const [member function]
cls.add_method('Serialize',
'void',
[param('uint8_t *', 'buf')],
is_const=True)
## ipv6-address.h (module 'network'): void ns3::Ipv6Address::Set(char const * address) [member function]
cls.add_method('Set',
'void',
[param('char const *', 'address')])
## ipv6-address.h (module 'network'): void ns3::Ipv6Address::Set(uint8_t * address) [member function]
cls.add_method('Set',
'void',
[param('uint8_t *', 'address')])
return
def register_Ns3Ipv6Prefix_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('==')
## ipv6-address.h (module 'network'): ns3::Ipv6Prefix::Ipv6Prefix() [constructor]
cls.add_constructor([])
## ipv6-address.h (module 'network'): ns3::Ipv6Prefix::Ipv6Prefix(uint8_t * prefix) [constructor]
cls.add_constructor([param('uint8_t *', 'prefix')])
## ipv6-address.h (module 'network'): ns3::Ipv6Prefix::Ipv6Prefix(char const * prefix) [constructor]
cls.add_constructor([param('char const *', 'prefix')])
## ipv6-address.h (module 'network'): ns3::Ipv6Prefix::Ipv6Prefix(uint8_t prefix) [constructor]
cls.add_constructor([param('uint8_t', 'prefix')])
## ipv6-address.h (module 'network'): ns3::Ipv6Prefix::Ipv6Prefix(ns3::Ipv6Prefix const & prefix) [copy constructor]
cls.add_constructor([param('ns3::Ipv6Prefix const &', 'prefix')])
## ipv6-address.h (module 'network'): ns3::Ipv6Prefix::Ipv6Prefix(ns3::Ipv6Prefix const * prefix) [constructor]
cls.add_constructor([param('ns3::Ipv6Prefix const *', 'prefix')])
## ipv6-address.h (module 'network'): void ns3::Ipv6Prefix::GetBytes(uint8_t * buf) const [member function]
cls.add_method('GetBytes',
'void',
[param('uint8_t *', 'buf')],
is_const=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Prefix ns3::Ipv6Prefix::GetLoopback() [member function]
cls.add_method('GetLoopback',
'ns3::Ipv6Prefix',
[],
is_static=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Prefix ns3::Ipv6Prefix::GetOnes() [member function]
cls.add_method('GetOnes',
'ns3::Ipv6Prefix',
[],
is_static=True)
## ipv6-address.h (module 'network'): uint8_t ns3::Ipv6Prefix::GetPrefixLength() const [member function]
cls.add_method('GetPrefixLength',
'uint8_t',
[],
is_const=True)
## ipv6-address.h (module 'network'): static ns3::Ipv6Prefix ns3::Ipv6Prefix::GetZero() [member function]
cls.add_method('GetZero',
'ns3::Ipv6Prefix',
[],
is_static=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Prefix::IsEqual(ns3::Ipv6Prefix const & other) const [member function]
cls.add_method('IsEqual',
'bool',
[param('ns3::Ipv6Prefix const &', 'other')],
is_const=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6Prefix::IsMatch(ns3::Ipv6Address a, ns3::Ipv6Address b) const [member function]
cls.add_method('IsMatch',
'bool',
[param('ns3::Ipv6Address', 'a'), param('ns3::Ipv6Address', 'b')],
is_const=True)
## ipv6-address.h (module 'network'): void ns3::Ipv6Prefix::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_const=True)
return
def register_Ns3Mac48Address_methods(root_module, cls):
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('!=')
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('==')
## mac48-address.h (module 'network'): ns3::Mac48Address::Mac48Address(ns3::Mac48Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac48Address const &', 'arg0')])
## mac48-address.h (module 'network'): ns3::Mac48Address::Mac48Address() [constructor]
cls.add_constructor([])
## mac48-address.h (module 'network'): ns3::Mac48Address::Mac48Address(char const * str) [constructor]
cls.add_constructor([param('char const *', 'str')])
## mac48-address.h (module 'network'): static ns3::Mac48Address ns3::Mac48Address::Allocate() [member function]
cls.add_method('Allocate',
'ns3::Mac48Address',
[],
is_static=True)
## mac48-address.h (module 'network'): static ns3::Mac48Address ns3::Mac48Address::ConvertFrom(ns3::Address const & address) [member function]
cls.add_method('ConvertFrom',
'ns3::Mac48Address',
[param('ns3::Address const &', 'address')],
is_static=True)
## mac48-address.h (module 'network'): void ns3::Mac48Address::CopyFrom(uint8_t const * buffer) [member function]
cls.add_method('CopyFrom',
'void',
[param('uint8_t const *', 'buffer')])
## mac48-address.h (module 'network'): void ns3::Mac48Address::CopyTo(uint8_t * buffer) const [member function]
cls.add_method('CopyTo',
'void',
[param('uint8_t *', 'buffer')],
is_const=True)
## mac48-address.h (module 'network'): static ns3::Mac48Address ns3::Mac48Address::GetBroadcast() [member function]
cls.add_method('GetBroadcast',
'ns3::Mac48Address',
[],
is_static=True)
## mac48-address.h (module 'network'): static ns3::Mac48Address ns3::Mac48Address::GetMulticast(ns3::Ipv4Address address) [member function]
cls.add_method('GetMulticast',
'ns3::Mac48Address',
[param('ns3::Ipv4Address', 'address')],
is_static=True)
## mac48-address.h (module 'network'): static ns3::Mac48Address ns3::Mac48Address::GetMulticast(ns3::Ipv6Address address) [member function]
cls.add_method('GetMulticast',
'ns3::Mac48Address',
[param('ns3::Ipv6Address', 'address')],
is_static=True)
## mac48-address.h (module 'network'): static ns3::Mac48Address ns3::Mac48Address::GetMulticast6Prefix() [member function]
cls.add_method('GetMulticast6Prefix',
'ns3::Mac48Address',
[],
is_static=True)
## mac48-address.h (module 'network'): static ns3::Mac48Address ns3::Mac48Address::GetMulticastPrefix() [member function]
cls.add_method('GetMulticastPrefix',
'ns3::Mac48Address',
[],
is_static=True)
## mac48-address.h (module 'network'): bool ns3::Mac48Address::IsBroadcast() const [member function]
cls.add_method('IsBroadcast',
'bool',
[],
is_const=True)
## mac48-address.h (module 'network'): bool ns3::Mac48Address::IsGroup() const [member function]
cls.add_method('IsGroup',
'bool',
[],
is_const=True)
## mac48-address.h (module 'network'): static bool ns3::Mac48Address::IsMatchingType(ns3::Address const & address) [member function]
cls.add_method('IsMatchingType',
'bool',
[param('ns3::Address const &', 'address')],
is_static=True)
return
def register_Ns3MpiInterface_methods(root_module, cls):
## mpi-interface.h (module 'mpi'): ns3::MpiInterface::MpiInterface() [constructor]
cls.add_constructor([])
## mpi-interface.h (module 'mpi'): ns3::MpiInterface::MpiInterface(ns3::MpiInterface const & arg0) [copy constructor]
cls.add_constructor([param('ns3::MpiInterface const &', 'arg0')])
## mpi-interface.h (module 'mpi'): static void ns3::MpiInterface::Destroy() [member function]
cls.add_method('Destroy',
'void',
[],
is_static=True)
## mpi-interface.h (module 'mpi'): static void ns3::MpiInterface::Disable() [member function]
cls.add_method('Disable',
'void',
[],
is_static=True)
## mpi-interface.h (module 'mpi'): static void ns3::MpiInterface::Enable(int * pargc, char * * * pargv) [member function]
cls.add_method('Enable',
'void',
[param('int *', 'pargc'), param('char * * *', 'pargv')],
is_static=True)
## mpi-interface.h (module 'mpi'): static uint32_t ns3::MpiInterface::GetSize() [member function]
cls.add_method('GetSize',
'uint32_t',
[],
is_static=True)
## mpi-interface.h (module 'mpi'): static uint32_t ns3::MpiInterface::GetSystemId() [member function]
cls.add_method('GetSystemId',
'uint32_t',
[],
is_static=True)
## mpi-interface.h (module 'mpi'): static bool ns3::MpiInterface::IsEnabled() [member function]
cls.add_method('IsEnabled',
'bool',
[],
is_static=True)
## mpi-interface.h (module 'mpi'): static void ns3::MpiInterface::SendPacket(ns3::Ptr<ns3::Packet> p, ns3::Time const & rxTime, uint32_t node, uint32_t dev) [member function]
cls.add_method('SendPacket',
'void',
[param('ns3::Ptr< ns3::Packet >', 'p'), param('ns3::Time const &', 'rxTime'), param('uint32_t', 'node'), param('uint32_t', 'dev')],
is_static=True)
return
def register_Ns3ObjectBase_methods(root_module, cls):
## object-base.h (module 'core'): ns3::ObjectBase::ObjectBase() [constructor]
cls.add_constructor([])
## object-base.h (module 'core'): ns3::ObjectBase::ObjectBase(ns3::ObjectBase const & arg0) [copy constructor]
cls.add_constructor([param('ns3::ObjectBase const &', 'arg0')])
## object-base.h (module 'core'): void ns3::ObjectBase::GetAttribute(std::string name, ns3::AttributeValue & value) const [member function]
cls.add_method('GetAttribute',
'void',
[param('std::string', 'name'), param('ns3::AttributeValue &', 'value')],
is_const=True)
## object-base.h (module 'core'): bool ns3::ObjectBase::GetAttributeFailSafe(std::string name, ns3::AttributeValue & value) const [member function]
cls.add_method('GetAttributeFailSafe',
'bool',
[param('std::string', 'name'), param('ns3::AttributeValue &', 'value')],
is_const=True)
## object-base.h (module 'core'): ns3::TypeId ns3::ObjectBase::GetInstanceTypeId() const [member function]
cls.add_method('GetInstanceTypeId',
'ns3::TypeId',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## object-base.h (module 'core'): static ns3::TypeId ns3::ObjectBase::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## object-base.h (module 'core'): void ns3::ObjectBase::SetAttribute(std::string name, ns3::AttributeValue const & value) [member function]
cls.add_method('SetAttribute',
'void',
[param('std::string', 'name'), param('ns3::AttributeValue const &', 'value')])
## object-base.h (module 'core'): bool ns3::ObjectBase::SetAttributeFailSafe(std::string name, ns3::AttributeValue const & value) [member function]
cls.add_method('SetAttributeFailSafe',
'bool',
[param('std::string', 'name'), param('ns3::AttributeValue const &', 'value')])
## object-base.h (module 'core'): bool ns3::ObjectBase::TraceConnect(std::string name, std::string context, ns3::CallbackBase const & cb) [member function]
cls.add_method('TraceConnect',
'bool',
[param('std::string', 'name'), param('std::string', 'context'), param('ns3::CallbackBase const &', 'cb')])
## object-base.h (module 'core'): bool ns3::ObjectBase::TraceConnectWithoutContext(std::string name, ns3::CallbackBase const & cb) [member function]
cls.add_method('TraceConnectWithoutContext',
'bool',
[param('std::string', 'name'), param('ns3::CallbackBase const &', 'cb')])
## object-base.h (module 'core'): bool ns3::ObjectBase::TraceDisconnect(std::string name, std::string context, ns3::CallbackBase const & cb) [member function]
cls.add_method('TraceDisconnect',
'bool',
[param('std::string', 'name'), param('std::string', 'context'), param('ns3::CallbackBase const &', 'cb')])
## object-base.h (module 'core'): bool ns3::ObjectBase::TraceDisconnectWithoutContext(std::string name, ns3::CallbackBase const & cb) [member function]
cls.add_method('TraceDisconnectWithoutContext',
'bool',
[param('std::string', 'name'), param('ns3::CallbackBase const &', 'cb')])
## object-base.h (module 'core'): void ns3::ObjectBase::ConstructSelf(ns3::AttributeConstructionList const & attributes) [member function]
cls.add_method('ConstructSelf',
'void',
[param('ns3::AttributeConstructionList const &', 'attributes')],
visibility='protected')
## object-base.h (module 'core'): void ns3::ObjectBase::NotifyConstructionCompleted() [member function]
cls.add_method('NotifyConstructionCompleted',
'void',
[],
visibility='protected', is_virtual=True)
return
def register_Ns3ObjectDeleter_methods(root_module, cls):
## object.h (module 'core'): ns3::ObjectDeleter::ObjectDeleter() [constructor]
cls.add_constructor([])
## object.h (module 'core'): ns3::ObjectDeleter::ObjectDeleter(ns3::ObjectDeleter const & arg0) [copy constructor]
cls.add_constructor([param('ns3::ObjectDeleter const &', 'arg0')])
## object.h (module 'core'): static void ns3::ObjectDeleter::Delete(ns3::Object * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::Object *', 'object')],
is_static=True)
return
def register_Ns3PacketMetadata_methods(root_module, cls):
## packet-metadata.h (module 'network'): ns3::PacketMetadata::PacketMetadata(uint64_t uid, uint32_t size) [constructor]
cls.add_constructor([param('uint64_t', 'uid'), param('uint32_t', 'size')])
## packet-metadata.h (module 'network'): ns3::PacketMetadata::PacketMetadata(ns3::PacketMetadata const & o) [copy constructor]
cls.add_constructor([param('ns3::PacketMetadata const &', 'o')])
## packet-metadata.h (module 'network'): void ns3::PacketMetadata::AddAtEnd(ns3::PacketMetadata const & o) [member function]
cls.add_method('AddAtEnd',
'void',
[param('ns3::PacketMetadata const &', 'o')])
## packet-metadata.h (module 'network'): void ns3::PacketMetadata::AddHeader(ns3::Header const & header, uint32_t size) [member function]
cls.add_method('AddHeader',
'void',
[param('ns3::Header const &', 'header'), param('uint32_t', 'size')])
## packet-metadata.h (module 'network'): void ns3::PacketMetadata::AddPaddingAtEnd(uint32_t end) [member function]
cls.add_method('AddPaddingAtEnd',
'void',
[param('uint32_t', 'end')])
## packet-metadata.h (module 'network'): void ns3::PacketMetadata::AddTrailer(ns3::Trailer const & trailer, uint32_t size) [member function]
cls.add_method('AddTrailer',
'void',
[param('ns3::Trailer const &', 'trailer'), param('uint32_t', 'size')])
## packet-metadata.h (module 'network'): ns3::PacketMetadata::ItemIterator ns3::PacketMetadata::BeginItem(ns3::Buffer buffer) const [member function]
cls.add_method('BeginItem',
'ns3::PacketMetadata::ItemIterator',
[param('ns3::Buffer', 'buffer')],
is_const=True)
## packet-metadata.h (module 'network'): ns3::PacketMetadata ns3::PacketMetadata::CreateFragment(uint32_t start, uint32_t end) const [member function]
cls.add_method('CreateFragment',
'ns3::PacketMetadata',
[param('uint32_t', 'start'), param('uint32_t', 'end')],
is_const=True)
## packet-metadata.h (module 'network'): uint32_t ns3::PacketMetadata::Deserialize(uint8_t const * buffer, uint32_t size) [member function]
cls.add_method('Deserialize',
'uint32_t',
[param('uint8_t const *', 'buffer'), param('uint32_t', 'size')])
## packet-metadata.h (module 'network'): static void ns3::PacketMetadata::Enable() [member function]
cls.add_method('Enable',
'void',
[],
is_static=True)
## packet-metadata.h (module 'network'): static void ns3::PacketMetadata::EnableChecking() [member function]
cls.add_method('EnableChecking',
'void',
[],
is_static=True)
## packet-metadata.h (module 'network'): uint32_t ns3::PacketMetadata::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_const=True)
## packet-metadata.h (module 'network'): uint64_t ns3::PacketMetadata::GetUid() const [member function]
cls.add_method('GetUid',
'uint64_t',
[],
is_const=True)
## packet-metadata.h (module 'network'): void ns3::PacketMetadata::RemoveAtEnd(uint32_t end) [member function]
cls.add_method('RemoveAtEnd',
'void',
[param('uint32_t', 'end')])
## packet-metadata.h (module 'network'): void ns3::PacketMetadata::RemoveAtStart(uint32_t start) [member function]
cls.add_method('RemoveAtStart',
'void',
[param('uint32_t', 'start')])
## packet-metadata.h (module 'network'): void ns3::PacketMetadata::RemoveHeader(ns3::Header const & header, uint32_t size) [member function]
cls.add_method('RemoveHeader',
'void',
[param('ns3::Header const &', 'header'), param('uint32_t', 'size')])
## packet-metadata.h (module 'network'): void ns3::PacketMetadata::RemoveTrailer(ns3::Trailer const & trailer, uint32_t size) [member function]
cls.add_method('RemoveTrailer',
'void',
[param('ns3::Trailer const &', 'trailer'), param('uint32_t', 'size')])
## packet-metadata.h (module 'network'): uint32_t ns3::PacketMetadata::Serialize(uint8_t * buffer, uint32_t maxSize) const [member function]
cls.add_method('Serialize',
'uint32_t',
[param('uint8_t *', 'buffer'), param('uint32_t', 'maxSize')],
is_const=True)
return
def register_Ns3PacketMetadataItem_methods(root_module, cls):
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::Item() [constructor]
cls.add_constructor([])
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::Item(ns3::PacketMetadata::Item const & arg0) [copy constructor]
cls.add_constructor([param('ns3::PacketMetadata::Item const &', 'arg0')])
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::current [variable]
cls.add_instance_attribute('current', 'ns3::Buffer::Iterator', is_const=False)
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::currentSize [variable]
cls.add_instance_attribute('currentSize', 'uint32_t', is_const=False)
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::currentTrimedFromEnd [variable]
cls.add_instance_attribute('currentTrimedFromEnd', 'uint32_t', is_const=False)
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::currentTrimedFromStart [variable]
cls.add_instance_attribute('currentTrimedFromStart', 'uint32_t', is_const=False)
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::isFragment [variable]
cls.add_instance_attribute('isFragment', 'bool', is_const=False)
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::tid [variable]
cls.add_instance_attribute('tid', 'ns3::TypeId', is_const=False)
return
def register_Ns3PacketMetadataItemIterator_methods(root_module, cls):
## packet-metadata.h (module 'network'): ns3::PacketMetadata::ItemIterator::ItemIterator(ns3::PacketMetadata::ItemIterator const & arg0) [copy constructor]
cls.add_constructor([param('ns3::PacketMetadata::ItemIterator const &', 'arg0')])
## packet-metadata.h (module 'network'): ns3::PacketMetadata::ItemIterator::ItemIterator(ns3::PacketMetadata const * metadata, ns3::Buffer buffer) [constructor]
cls.add_constructor([param('ns3::PacketMetadata const *', 'metadata'), param('ns3::Buffer', 'buffer')])
## packet-metadata.h (module 'network'): bool ns3::PacketMetadata::ItemIterator::HasNext() const [member function]
cls.add_method('HasNext',
'bool',
[],
is_const=True)
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item ns3::PacketMetadata::ItemIterator::Next() [member function]
cls.add_method('Next',
'ns3::PacketMetadata::Item',
[])
return
def register_Ns3PacketTagIterator_methods(root_module, cls):
## packet.h (module 'network'): ns3::PacketTagIterator::PacketTagIterator(ns3::PacketTagIterator const & arg0) [copy constructor]
cls.add_constructor([param('ns3::PacketTagIterator const &', 'arg0')])
## packet.h (module 'network'): bool ns3::PacketTagIterator::HasNext() const [member function]
cls.add_method('HasNext',
'bool',
[],
is_const=True)
## packet.h (module 'network'): ns3::PacketTagIterator::Item ns3::PacketTagIterator::Next() [member function]
cls.add_method('Next',
'ns3::PacketTagIterator::Item',
[])
return
def register_Ns3PacketTagIteratorItem_methods(root_module, cls):
## packet.h (module 'network'): ns3::PacketTagIterator::Item::Item(ns3::PacketTagIterator::Item const & arg0) [copy constructor]
cls.add_constructor([param('ns3::PacketTagIterator::Item const &', 'arg0')])
## packet.h (module 'network'): void ns3::PacketTagIterator::Item::GetTag(ns3::Tag & tag) const [member function]
cls.add_method('GetTag',
'void',
[param('ns3::Tag &', 'tag')],
is_const=True)
## packet.h (module 'network'): ns3::TypeId ns3::PacketTagIterator::Item::GetTypeId() const [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_const=True)
return
def register_Ns3PacketTagList_methods(root_module, cls):
## packet-tag-list.h (module 'network'): ns3::PacketTagList::PacketTagList() [constructor]
cls.add_constructor([])
## packet-tag-list.h (module 'network'): ns3::PacketTagList::PacketTagList(ns3::PacketTagList const & o) [copy constructor]
cls.add_constructor([param('ns3::PacketTagList const &', 'o')])
## packet-tag-list.h (module 'network'): void ns3::PacketTagList::Add(ns3::Tag const & tag) const [member function]
cls.add_method('Add',
'void',
[param('ns3::Tag const &', 'tag')],
is_const=True)
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData const * ns3::PacketTagList::Head() const [member function]
cls.add_method('Head',
'ns3::PacketTagList::TagData const *',
[],
is_const=True)
## packet-tag-list.h (module 'network'): bool ns3::PacketTagList::Peek(ns3::Tag & tag) const [member function]
cls.add_method('Peek',
'bool',
[param('ns3::Tag &', 'tag')],
is_const=True)
## packet-tag-list.h (module 'network'): bool ns3::PacketTagList::Remove(ns3::Tag & tag) [member function]
cls.add_method('Remove',
'bool',
[param('ns3::Tag &', 'tag')])
## packet-tag-list.h (module 'network'): void ns3::PacketTagList::RemoveAll() [member function]
cls.add_method('RemoveAll',
'void',
[])
## packet-tag-list.h (module 'network'): bool ns3::PacketTagList::Replace(ns3::Tag & tag) [member function]
cls.add_method('Replace',
'bool',
[param('ns3::Tag &', 'tag')])
return
def register_Ns3PacketTagListTagData_methods(root_module, cls):
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData::TagData() [constructor]
cls.add_constructor([])
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData::TagData(ns3::PacketTagList::TagData const & arg0) [copy constructor]
cls.add_constructor([param('ns3::PacketTagList::TagData const &', 'arg0')])
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData::count [variable]
cls.add_instance_attribute('count', 'uint32_t', is_const=False)
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData::data [variable]
cls.add_instance_attribute('data', 'uint8_t [ 21 ]', is_const=False)
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData::next [variable]
cls.add_instance_attribute('next', 'ns3::PacketTagList::TagData *', is_const=False)
## packet-tag-list.h (module 'network'): ns3::PacketTagList::TagData::tid [variable]
cls.add_instance_attribute('tid', 'ns3::TypeId', is_const=False)
return
def register_Ns3ParallelCommunicationInterface_methods(root_module, cls):
## parallel-communication-interface.h (module 'mpi'): ns3::ParallelCommunicationInterface::ParallelCommunicationInterface() [constructor]
cls.add_constructor([])
## parallel-communication-interface.h (module 'mpi'): ns3::ParallelCommunicationInterface::ParallelCommunicationInterface(ns3::ParallelCommunicationInterface const & arg0) [copy constructor]
cls.add_constructor([param('ns3::ParallelCommunicationInterface const &', 'arg0')])
## parallel-communication-interface.h (module 'mpi'): void ns3::ParallelCommunicationInterface::Destroy() [member function]
cls.add_method('Destroy',
'void',
[],
is_pure_virtual=True, is_virtual=True)
## parallel-communication-interface.h (module 'mpi'): void ns3::ParallelCommunicationInterface::Disable() [member function]
cls.add_method('Disable',
'void',
[],
is_pure_virtual=True, is_virtual=True)
## parallel-communication-interface.h (module 'mpi'): void ns3::ParallelCommunicationInterface::Enable(int * pargc, char * * * pargv) [member function]
cls.add_method('Enable',
'void',
[param('int *', 'pargc'), param('char * * *', 'pargv')],
is_pure_virtual=True, is_virtual=True)
## parallel-communication-interface.h (module 'mpi'): uint32_t ns3::ParallelCommunicationInterface::GetSize() [member function]
cls.add_method('GetSize',
'uint32_t',
[],
is_pure_virtual=True, is_virtual=True)
## parallel-communication-interface.h (module 'mpi'): uint32_t ns3::ParallelCommunicationInterface::GetSystemId() [member function]
cls.add_method('GetSystemId',
'uint32_t',
[],
is_pure_virtual=True, is_virtual=True)
## parallel-communication-interface.h (module 'mpi'): bool ns3::ParallelCommunicationInterface::IsEnabled() [member function]
cls.add_method('IsEnabled',
'bool',
[],
is_pure_virtual=True, is_virtual=True)
## parallel-communication-interface.h (module 'mpi'): void ns3::ParallelCommunicationInterface::SendPacket(ns3::Ptr<ns3::Packet> p, ns3::Time const & rxTime, uint32_t node, uint32_t dev) [member function]
cls.add_method('SendPacket',
'void',
[param('ns3::Ptr< ns3::Packet >', 'p'), param('ns3::Time const &', 'rxTime'), param('uint32_t', 'node'), param('uint32_t', 'dev')],
is_pure_virtual=True, is_virtual=True)
return
def register_Ns3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::SimpleRefCount(ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter> const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3Tag_methods(root_module, cls):
## tag.h (module 'network'): ns3::Tag::Tag() [constructor]
cls.add_constructor([])
## tag.h (module 'network'): ns3::Tag::Tag(ns3::Tag const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Tag const &', 'arg0')])
## tag.h (module 'network'): void ns3::Tag::Deserialize(ns3::TagBuffer i) [member function]
cls.add_method('Deserialize',
'void',
[param('ns3::TagBuffer', 'i')],
is_pure_virtual=True, is_virtual=True)
## tag.h (module 'network'): uint32_t ns3::Tag::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## tag.h (module 'network'): static ns3::TypeId ns3::Tag::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## tag.h (module 'network'): void ns3::Tag::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## tag.h (module 'network'): void ns3::Tag::Serialize(ns3::TagBuffer i) const [member function]
cls.add_method('Serialize',
'void',
[param('ns3::TagBuffer', 'i')],
is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3TagBuffer_methods(root_module, cls):
## tag-buffer.h (module 'network'): ns3::TagBuffer::TagBuffer(ns3::TagBuffer const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TagBuffer const &', 'arg0')])
## tag-buffer.h (module 'network'): ns3::TagBuffer::TagBuffer(uint8_t * start, uint8_t * end) [constructor]
cls.add_constructor([param('uint8_t *', 'start'), param('uint8_t *', 'end')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::CopyFrom(ns3::TagBuffer o) [member function]
cls.add_method('CopyFrom',
'void',
[param('ns3::TagBuffer', 'o')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::Read(uint8_t * buffer, uint32_t size) [member function]
cls.add_method('Read',
'void',
[param('uint8_t *', 'buffer'), param('uint32_t', 'size')])
## tag-buffer.h (module 'network'): double ns3::TagBuffer::ReadDouble() [member function]
cls.add_method('ReadDouble',
'double',
[])
## tag-buffer.h (module 'network'): uint16_t ns3::TagBuffer::ReadU16() [member function]
cls.add_method('ReadU16',
'uint16_t',
[])
## tag-buffer.h (module 'network'): uint32_t ns3::TagBuffer::ReadU32() [member function]
cls.add_method('ReadU32',
'uint32_t',
[])
## tag-buffer.h (module 'network'): uint64_t ns3::TagBuffer::ReadU64() [member function]
cls.add_method('ReadU64',
'uint64_t',
[])
## tag-buffer.h (module 'network'): uint8_t ns3::TagBuffer::ReadU8() [member function]
cls.add_method('ReadU8',
'uint8_t',
[])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::TrimAtEnd(uint32_t trim) [member function]
cls.add_method('TrimAtEnd',
'void',
[param('uint32_t', 'trim')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::Write(uint8_t const * buffer, uint32_t size) [member function]
cls.add_method('Write',
'void',
[param('uint8_t const *', 'buffer'), param('uint32_t', 'size')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::WriteDouble(double v) [member function]
cls.add_method('WriteDouble',
'void',
[param('double', 'v')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::WriteU16(uint16_t data) [member function]
cls.add_method('WriteU16',
'void',
[param('uint16_t', 'data')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::WriteU32(uint32_t data) [member function]
cls.add_method('WriteU32',
'void',
[param('uint32_t', 'data')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::WriteU64(uint64_t v) [member function]
cls.add_method('WriteU64',
'void',
[param('uint64_t', 'v')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::WriteU8(uint8_t v) [member function]
cls.add_method('WriteU8',
'void',
[param('uint8_t', 'v')])
return
def register_Ns3TimeWithUnit_methods(root_module, cls):
cls.add_output_stream_operator()
## nstime.h (module 'core'): ns3::TimeWithUnit::TimeWithUnit(ns3::TimeWithUnit const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TimeWithUnit const &', 'arg0')])
## nstime.h (module 'core'): ns3::TimeWithUnit::TimeWithUnit(ns3::Time const time, ns3::Time::Unit const unit) [constructor]
cls.add_constructor([param('ns3::Time const', 'time'), param('ns3::Time::Unit const', 'unit')])
return
def register_Ns3TypeId_methods(root_module, cls):
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('!=')
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('==')
## type-id.h (module 'core'): ns3::TypeId::TypeId(char const * name) [constructor]
cls.add_constructor([param('char const *', 'name')])
## type-id.h (module 'core'): ns3::TypeId::TypeId() [constructor]
cls.add_constructor([])
## type-id.h (module 'core'): ns3::TypeId::TypeId(ns3::TypeId const & o) [copy constructor]
cls.add_constructor([param('ns3::TypeId const &', 'o')])
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::AddAttribute(std::string name, std::string help, ns3::AttributeValue const & initialValue, ns3::Ptr<ns3::AttributeAccessor const> accessor, ns3::Ptr<ns3::AttributeChecker const> checker, ns3::TypeId::SupportLevel supportLevel=::ns3::TypeId::SUPPORTED, std::string const & supportMsg="") [member function]
cls.add_method('AddAttribute',
'ns3::TypeId',
[param('std::string', 'name'), param('std::string', 'help'), param('ns3::AttributeValue const &', 'initialValue'), param('ns3::Ptr< ns3::AttributeAccessor const >', 'accessor'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker'), param('ns3::TypeId::SupportLevel', 'supportLevel', default_value='::ns3::TypeId::SUPPORTED'), param('std::string const &', 'supportMsg', default_value='""')])
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::AddAttribute(std::string name, std::string help, uint32_t flags, ns3::AttributeValue const & initialValue, ns3::Ptr<ns3::AttributeAccessor const> accessor, ns3::Ptr<ns3::AttributeChecker const> checker, ns3::TypeId::SupportLevel supportLevel=::ns3::TypeId::SUPPORTED, std::string const & supportMsg="") [member function]
cls.add_method('AddAttribute',
'ns3::TypeId',
[param('std::string', 'name'), param('std::string', 'help'), param('uint32_t', 'flags'), param('ns3::AttributeValue const &', 'initialValue'), param('ns3::Ptr< ns3::AttributeAccessor const >', 'accessor'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker'), param('ns3::TypeId::SupportLevel', 'supportLevel', default_value='::ns3::TypeId::SUPPORTED'), param('std::string const &', 'supportMsg', default_value='""')])
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::AddTraceSource(std::string name, std::string help, ns3::Ptr<ns3::TraceSourceAccessor const> accessor) [member function]
cls.add_method('AddTraceSource',
'ns3::TypeId',
[param('std::string', 'name'), param('std::string', 'help'), param('ns3::Ptr< ns3::TraceSourceAccessor const >', 'accessor')],
deprecated=True)
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::AddTraceSource(std::string name, std::string help, ns3::Ptr<ns3::TraceSourceAccessor const> accessor, std::string callback, ns3::TypeId::SupportLevel supportLevel=::ns3::TypeId::SUPPORTED, std::string const & supportMsg="") [member function]
cls.add_method('AddTraceSource',
'ns3::TypeId',
[param('std::string', 'name'), param('std::string', 'help'), param('ns3::Ptr< ns3::TraceSourceAccessor const >', 'accessor'), param('std::string', 'callback'), param('ns3::TypeId::SupportLevel', 'supportLevel', default_value='::ns3::TypeId::SUPPORTED'), param('std::string const &', 'supportMsg', default_value='""')])
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation ns3::TypeId::GetAttribute(uint32_t i) const [member function]
cls.add_method('GetAttribute',
'ns3::TypeId::AttributeInformation',
[param('uint32_t', 'i')],
is_const=True)
## type-id.h (module 'core'): std::string ns3::TypeId::GetAttributeFullName(uint32_t i) const [member function]
cls.add_method('GetAttributeFullName',
'std::string',
[param('uint32_t', 'i')],
is_const=True)
## type-id.h (module 'core'): uint32_t ns3::TypeId::GetAttributeN() const [member function]
cls.add_method('GetAttributeN',
'uint32_t',
[],
is_const=True)
## type-id.h (module 'core'): ns3::Callback<ns3::ObjectBase*,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ns3::TypeId::GetConstructor() const [member function]
cls.add_method('GetConstructor',
'ns3::Callback< ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >',
[],
is_const=True)
## type-id.h (module 'core'): std::string ns3::TypeId::GetGroupName() const [member function]
cls.add_method('GetGroupName',
'std::string',
[],
is_const=True)
## type-id.h (module 'core'): uint32_t ns3::TypeId::GetHash() const [member function]
cls.add_method('GetHash',
'uint32_t',
[],
is_const=True)
## type-id.h (module 'core'): std::string ns3::TypeId::GetName() const [member function]
cls.add_method('GetName',
'std::string',
[],
is_const=True)
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::GetParent() const [member function]
cls.add_method('GetParent',
'ns3::TypeId',
[],
is_const=True)
## type-id.h (module 'core'): static ns3::TypeId ns3::TypeId::GetRegistered(uint32_t i) [member function]
cls.add_method('GetRegistered',
'ns3::TypeId',
[param('uint32_t', 'i')],
is_static=True)
## type-id.h (module 'core'): static uint32_t ns3::TypeId::GetRegisteredN() [member function]
cls.add_method('GetRegisteredN',
'uint32_t',
[],
is_static=True)
## type-id.h (module 'core'): std::size_t ns3::TypeId::GetSize() const [member function]
cls.add_method('GetSize',
'std::size_t',
[],
is_const=True)
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation ns3::TypeId::GetTraceSource(uint32_t i) const [member function]
cls.add_method('GetTraceSource',
'ns3::TypeId::TraceSourceInformation',
[param('uint32_t', 'i')],
is_const=True)
## type-id.h (module 'core'): uint32_t ns3::TypeId::GetTraceSourceN() const [member function]
cls.add_method('GetTraceSourceN',
'uint32_t',
[],
is_const=True)
## type-id.h (module 'core'): uint16_t ns3::TypeId::GetUid() const [member function]
cls.add_method('GetUid',
'uint16_t',
[],
is_const=True)
## type-id.h (module 'core'): bool ns3::TypeId::HasConstructor() const [member function]
cls.add_method('HasConstructor',
'bool',
[],
is_const=True)
## type-id.h (module 'core'): bool ns3::TypeId::HasParent() const [member function]
cls.add_method('HasParent',
'bool',
[],
is_const=True)
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::HideFromDocumentation() [member function]
cls.add_method('HideFromDocumentation',
'ns3::TypeId',
[])
## type-id.h (module 'core'): bool ns3::TypeId::IsChildOf(ns3::TypeId other) const [member function]
cls.add_method('IsChildOf',
'bool',
[param('ns3::TypeId', 'other')],
is_const=True)
## type-id.h (module 'core'): bool ns3::TypeId::LookupAttributeByName(std::string name, ns3::TypeId::AttributeInformation * info) const [member function]
cls.add_method('LookupAttributeByName',
'bool',
[param('std::string', 'name'), param('ns3::TypeId::AttributeInformation *', 'info', transfer_ownership=False)],
is_const=True)
## type-id.h (module 'core'): static ns3::TypeId ns3::TypeId::LookupByHash(uint32_t hash) [member function]
cls.add_method('LookupByHash',
'ns3::TypeId',
[param('uint32_t', 'hash')],
is_static=True)
## type-id.h (module 'core'): static bool ns3::TypeId::LookupByHashFailSafe(uint32_t hash, ns3::TypeId * tid) [member function]
cls.add_method('LookupByHashFailSafe',
'bool',
[param('uint32_t', 'hash'), param('ns3::TypeId *', 'tid')],
is_static=True)
## type-id.h (module 'core'): static ns3::TypeId ns3::TypeId::LookupByName(std::string name) [member function]
cls.add_method('LookupByName',
'ns3::TypeId',
[param('std::string', 'name')],
is_static=True)
## type-id.h (module 'core'): ns3::Ptr<ns3::TraceSourceAccessor const> ns3::TypeId::LookupTraceSourceByName(std::string name) const [member function]
cls.add_method('LookupTraceSourceByName',
'ns3::Ptr< ns3::TraceSourceAccessor const >',
[param('std::string', 'name')],
is_const=True)
## type-id.h (module 'core'): ns3::Ptr<ns3::TraceSourceAccessor const> ns3::TypeId::LookupTraceSourceByName(std::string name, ns3::TypeId::TraceSourceInformation * info) const [member function]
cls.add_method('LookupTraceSourceByName',
'ns3::Ptr< ns3::TraceSourceAccessor const >',
[param('std::string', 'name'), param('ns3::TypeId::TraceSourceInformation *', 'info')],
is_const=True)
## type-id.h (module 'core'): bool ns3::TypeId::MustHideFromDocumentation() const [member function]
cls.add_method('MustHideFromDocumentation',
'bool',
[],
is_const=True)
## type-id.h (module 'core'): bool ns3::TypeId::SetAttributeInitialValue(uint32_t i, ns3::Ptr<ns3::AttributeValue const> initialValue) [member function]
cls.add_method('SetAttributeInitialValue',
'bool',
[param('uint32_t', 'i'), param('ns3::Ptr< ns3::AttributeValue const >', 'initialValue')])
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::SetGroupName(std::string groupName) [member function]
cls.add_method('SetGroupName',
'ns3::TypeId',
[param('std::string', 'groupName')])
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::SetParent(ns3::TypeId tid) [member function]
cls.add_method('SetParent',
'ns3::TypeId',
[param('ns3::TypeId', 'tid')])
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::SetSize(std::size_t size) [member function]
cls.add_method('SetSize',
'ns3::TypeId',
[param('std::size_t', 'size')])
## type-id.h (module 'core'): void ns3::TypeId::SetUid(uint16_t uid) [member function]
cls.add_method('SetUid',
'void',
[param('uint16_t', 'uid')])
return
def register_Ns3TypeIdAttributeInformation_methods(root_module, cls):
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::AttributeInformation() [constructor]
cls.add_constructor([])
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::AttributeInformation(ns3::TypeId::AttributeInformation const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TypeId::AttributeInformation const &', 'arg0')])
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::accessor [variable]
cls.add_instance_attribute('accessor', 'ns3::Ptr< ns3::AttributeAccessor const >', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::checker [variable]
cls.add_instance_attribute('checker', 'ns3::Ptr< ns3::AttributeChecker const >', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::flags [variable]
cls.add_instance_attribute('flags', 'uint32_t', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::help [variable]
cls.add_instance_attribute('help', 'std::string', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::initialValue [variable]
cls.add_instance_attribute('initialValue', 'ns3::Ptr< ns3::AttributeValue const >', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::name [variable]
cls.add_instance_attribute('name', 'std::string', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::originalInitialValue [variable]
cls.add_instance_attribute('originalInitialValue', 'ns3::Ptr< ns3::AttributeValue const >', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::supportLevel [variable]
cls.add_instance_attribute('supportLevel', 'ns3::TypeId::SupportLevel', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::AttributeInformation::supportMsg [variable]
cls.add_instance_attribute('supportMsg', 'std::string', is_const=False)
return
def register_Ns3TypeIdTraceSourceInformation_methods(root_module, cls):
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation::TraceSourceInformation() [constructor]
cls.add_constructor([])
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation::TraceSourceInformation(ns3::TypeId::TraceSourceInformation const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TypeId::TraceSourceInformation const &', 'arg0')])
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation::accessor [variable]
cls.add_instance_attribute('accessor', 'ns3::Ptr< ns3::TraceSourceAccessor const >', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation::callback [variable]
cls.add_instance_attribute('callback', 'std::string', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation::help [variable]
cls.add_instance_attribute('help', 'std::string', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation::name [variable]
cls.add_instance_attribute('name', 'std::string', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation::supportLevel [variable]
cls.add_instance_attribute('supportLevel', 'ns3::TypeId::SupportLevel', is_const=False)
## type-id.h (module 'core'): ns3::TypeId::TraceSourceInformation::supportMsg [variable]
cls.add_instance_attribute('supportMsg', 'std::string', is_const=False)
return
def register_Ns3Empty_methods(root_module, cls):
## empty.h (module 'core'): ns3::empty::empty() [constructor]
cls.add_constructor([])
## empty.h (module 'core'): ns3::empty::empty(ns3::empty const & arg0) [copy constructor]
cls.add_constructor([param('ns3::empty const &', 'arg0')])
return
def register_Ns3Int64x64_t_methods(root_module, cls):
cls.add_binary_numeric_operator('*', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
cls.add_binary_numeric_operator('+', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
cls.add_binary_numeric_operator('-', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
cls.add_unary_numeric_operator('-')
cls.add_binary_numeric_operator('/', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('>')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('*=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('+=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('-=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('/=', param('ns3::int64x64_t const &', u'right'))
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t() [constructor]
cls.add_constructor([])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(double v) [constructor]
cls.add_constructor([param('double', 'v')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(long double v) [constructor]
cls.add_constructor([param('long double', 'v')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(int v) [constructor]
cls.add_constructor([param('int', 'v')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(long int v) [constructor]
cls.add_constructor([param('long int', 'v')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(long long int v) [constructor]
cls.add_constructor([param('long long int', 'v')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(unsigned int v) [constructor]
cls.add_constructor([param('unsigned int', 'v')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(long unsigned int v) [constructor]
cls.add_constructor([param('long unsigned int', 'v')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(long long unsigned int v) [constructor]
cls.add_constructor([param('long long unsigned int', 'v')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(int64_t hi, uint64_t lo) [constructor]
cls.add_constructor([param('int64_t', 'hi'), param('uint64_t', 'lo')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t(ns3::int64x64_t const & o) [copy constructor]
cls.add_constructor([param('ns3::int64x64_t const &', 'o')])
## int64x64-double.h (module 'core'): double ns3::int64x64_t::GetDouble() const [member function]
cls.add_method('GetDouble',
'double',
[],
is_const=True)
## int64x64-double.h (module 'core'): int64_t ns3::int64x64_t::GetHigh() const [member function]
cls.add_method('GetHigh',
'int64_t',
[],
is_const=True)
## int64x64-double.h (module 'core'): uint64_t ns3::int64x64_t::GetLow() const [member function]
cls.add_method('GetLow',
'uint64_t',
[],
is_const=True)
## int64x64-double.h (module 'core'): static ns3::int64x64_t ns3::int64x64_t::Invert(uint64_t v) [member function]
cls.add_method('Invert',
'ns3::int64x64_t',
[param('uint64_t', 'v')],
is_static=True)
## int64x64-double.h (module 'core'): void ns3::int64x64_t::MulByInvert(ns3::int64x64_t const & o) [member function]
cls.add_method('MulByInvert',
'void',
[param('ns3::int64x64_t const &', 'o')])
## int64x64-double.h (module 'core'): ns3::int64x64_t::implementation [variable]
cls.add_static_attribute('implementation', 'ns3::int64x64_t::impl_type const', is_const=True)
return
def register_Ns3Chunk_methods(root_module, cls):
## chunk.h (module 'network'): ns3::Chunk::Chunk() [constructor]
cls.add_constructor([])
## chunk.h (module 'network'): ns3::Chunk::Chunk(ns3::Chunk const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Chunk const &', 'arg0')])
## chunk.h (module 'network'): uint32_t ns3::Chunk::Deserialize(ns3::Buffer::Iterator start) [member function]
cls.add_method('Deserialize',
'uint32_t',
[param('ns3::Buffer::Iterator', 'start')],
is_pure_virtual=True, is_virtual=True)
## chunk.h (module 'network'): static ns3::TypeId ns3::Chunk::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## chunk.h (module 'network'): void ns3::Chunk::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3Header_methods(root_module, cls):
cls.add_output_stream_operator()
## header.h (module 'network'): ns3::Header::Header() [constructor]
cls.add_constructor([])
## header.h (module 'network'): ns3::Header::Header(ns3::Header const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Header const &', 'arg0')])
## header.h (module 'network'): uint32_t ns3::Header::Deserialize(ns3::Buffer::Iterator start) [member function]
cls.add_method('Deserialize',
'uint32_t',
[param('ns3::Buffer::Iterator', 'start')],
is_pure_virtual=True, is_virtual=True)
## header.h (module 'network'): uint32_t ns3::Header::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## header.h (module 'network'): static ns3::TypeId ns3::Header::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## header.h (module 'network'): void ns3::Header::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## header.h (module 'network'): void ns3::Header::Serialize(ns3::Buffer::Iterator start) const [member function]
cls.add_method('Serialize',
'void',
[param('ns3::Buffer::Iterator', 'start')],
is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3Object_methods(root_module, cls):
## object.h (module 'core'): ns3::Object::Object() [constructor]
cls.add_constructor([])
## object.h (module 'core'): void ns3::Object::AggregateObject(ns3::Ptr<ns3::Object> other) [member function]
cls.add_method('AggregateObject',
'void',
[param('ns3::Ptr< ns3::Object >', 'other')])
## object.h (module 'core'): void ns3::Object::Dispose() [member function]
cls.add_method('Dispose',
'void',
[])
## object.h (module 'core'): ns3::Object::AggregateIterator ns3::Object::GetAggregateIterator() const [member function]
cls.add_method('GetAggregateIterator',
'ns3::Object::AggregateIterator',
[],
is_const=True)
## object.h (module 'core'): ns3::TypeId ns3::Object::GetInstanceTypeId() const [member function]
cls.add_method('GetInstanceTypeId',
'ns3::TypeId',
[],
is_const=True, is_virtual=True)
## object.h (module 'core'): static ns3::TypeId ns3::Object::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## object.h (module 'core'): void ns3::Object::Initialize() [member function]
cls.add_method('Initialize',
'void',
[])
## object.h (module 'core'): bool ns3::Object::IsInitialized() const [member function]
cls.add_method('IsInitialized',
'bool',
[],
is_const=True)
## object.h (module 'core'): ns3::Object::Object(ns3::Object const & o) [copy constructor]
cls.add_constructor([param('ns3::Object const &', 'o')],
visibility='protected')
## object.h (module 'core'): void ns3::Object::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
[],
visibility='protected', is_virtual=True)
## object.h (module 'core'): void ns3::Object::DoInitialize() [member function]
cls.add_method('DoInitialize',
'void',
[],
visibility='protected', is_virtual=True)
## object.h (module 'core'): void ns3::Object::NotifyNewAggregate() [member function]
cls.add_method('NotifyNewAggregate',
'void',
[],
visibility='protected', is_virtual=True)
return
def register_Ns3ObjectAggregateIterator_methods(root_module, cls):
## object.h (module 'core'): ns3::Object::AggregateIterator::AggregateIterator(ns3::Object::AggregateIterator const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Object::AggregateIterator const &', 'arg0')])
## object.h (module 'core'): ns3::Object::AggregateIterator::AggregateIterator() [constructor]
cls.add_constructor([])
## object.h (module 'core'): bool ns3::Object::AggregateIterator::HasNext() const [member function]
cls.add_method('HasNext',
'bool',
[],
is_const=True)
## object.h (module 'core'): ns3::Ptr<ns3::Object const> ns3::Object::AggregateIterator::Next() [member function]
cls.add_method('Next',
'ns3::Ptr< ns3::Object const >',
[])
return
def register_Ns3SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> >::SimpleRefCount(ns3::SimpleRefCount<ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> > const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter< ns3::AttributeAccessor > > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> >::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> >::SimpleRefCount(ns3::SimpleRefCount<ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> > const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter< ns3::AttributeChecker > > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> >::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> >::SimpleRefCount(ns3::SimpleRefCount<ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> > const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter< ns3::AttributeValue > > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> >::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> >::SimpleRefCount(ns3::SimpleRefCount<ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> > const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter< ns3::CallbackImplBase > > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> >::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> >::SimpleRefCount(ns3::SimpleRefCount<ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> > const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter< ns3::Hash::Implementation > > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> >::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::SimpleRefCount(ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> > const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter< ns3::NixVector > > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >::SimpleRefCount(ns3::SimpleRefCount<ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> > const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::Packet, ns3::empty, ns3::DefaultDeleter< ns3::Packet > > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> >::SimpleRefCount(ns3::SimpleRefCount<ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> > const & o) [copy constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter< ns3::TraceSourceAccessor > > const &', 'o')])
## simple-ref-count.h (module 'core'): static void ns3::SimpleRefCount<ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> >::Cleanup() [member function]
cls.add_method('Cleanup',
'void',
[],
is_static=True)
return
def register_Ns3Time_methods(root_module, cls):
cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
cls.add_binary_numeric_operator('+', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Time const &', u'right'))
cls.add_binary_numeric_operator('-', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Time const &', u'right'))
cls.add_binary_numeric_operator('/', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('>')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::Time const &', u'right'))
cls.add_inplace_numeric_operator('-=', param('ns3::Time const &', u'right'))
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## nstime.h (module 'core'): ns3::Time::Time() [constructor]
cls.add_constructor([])
## nstime.h (module 'core'): ns3::Time::Time(ns3::Time const & o) [copy constructor]
cls.add_constructor([param('ns3::Time const &', 'o')])
## nstime.h (module 'core'): ns3::Time::Time(double v) [constructor]
cls.add_constructor([param('double', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(int v) [constructor]
cls.add_constructor([param('int', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(long int v) [constructor]
cls.add_constructor([param('long int', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(long long int v) [constructor]
cls.add_constructor([param('long long int', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(unsigned int v) [constructor]
cls.add_constructor([param('unsigned int', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(long unsigned int v) [constructor]
cls.add_constructor([param('long unsigned int', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(long long unsigned int v) [constructor]
cls.add_constructor([param('long long unsigned int', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(ns3::int64x64_t const & v) [constructor]
cls.add_constructor([param('ns3::int64x64_t const &', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(std::string const & s) [constructor]
cls.add_constructor([param('std::string const &', 's')])
## nstime.h (module 'core'): ns3::TimeWithUnit ns3::Time::As(ns3::Time::Unit const unit) const [member function]
cls.add_method('As',
'ns3::TimeWithUnit',
[param('ns3::Time::Unit const', 'unit')],
is_const=True)
## nstime.h (module 'core'): int ns3::Time::Compare(ns3::Time const & o) const [member function]
cls.add_method('Compare',
'int',
[param('ns3::Time const &', 'o')],
is_const=True)
## nstime.h (module 'core'): static ns3::Time ns3::Time::From(ns3::int64x64_t const & value) [member function]
cls.add_method('From',
'ns3::Time',
[param('ns3::int64x64_t const &', 'value')],
is_static=True)
## nstime.h (module 'core'): static ns3::Time ns3::Time::From(ns3::int64x64_t const & value, ns3::Time::Unit unit) [member function]
cls.add_method('From',
'ns3::Time',
[param('ns3::int64x64_t const &', 'value'), param('ns3::Time::Unit', 'unit')],
is_static=True)
## nstime.h (module 'core'): static ns3::Time ns3::Time::FromDouble(double value, ns3::Time::Unit unit) [member function]
cls.add_method('FromDouble',
'ns3::Time',
[param('double', 'value'), param('ns3::Time::Unit', 'unit')],
is_static=True)
## nstime.h (module 'core'): static ns3::Time ns3::Time::FromInteger(uint64_t value, ns3::Time::Unit unit) [member function]
cls.add_method('FromInteger',
'ns3::Time',
[param('uint64_t', 'value'), param('ns3::Time::Unit', 'unit')],
is_static=True)
## nstime.h (module 'core'): double ns3::Time::GetDays() const [member function]
cls.add_method('GetDays',
'double',
[],
is_const=True)
## nstime.h (module 'core'): double ns3::Time::GetDouble() const [member function]
cls.add_method('GetDouble',
'double',
[],
is_const=True)
## nstime.h (module 'core'): int64_t ns3::Time::GetFemtoSeconds() const [member function]
cls.add_method('GetFemtoSeconds',
'int64_t',
[],
is_const=True)
## nstime.h (module 'core'): double ns3::Time::GetHours() const [member function]
cls.add_method('GetHours',
'double',
[],
is_const=True)
## nstime.h (module 'core'): int64_t ns3::Time::GetInteger() const [member function]
cls.add_method('GetInteger',
'int64_t',
[],
is_const=True)
## nstime.h (module 'core'): int64_t ns3::Time::GetMicroSeconds() const [member function]
cls.add_method('GetMicroSeconds',
'int64_t',
[],
is_const=True)
## nstime.h (module 'core'): int64_t ns3::Time::GetMilliSeconds() const [member function]
cls.add_method('GetMilliSeconds',
'int64_t',
[],
is_const=True)
## nstime.h (module 'core'): double ns3::Time::GetMinutes() const [member function]
cls.add_method('GetMinutes',
'double',
[],
is_const=True)
## nstime.h (module 'core'): int64_t ns3::Time::GetNanoSeconds() const [member function]
cls.add_method('GetNanoSeconds',
'int64_t',
[],
is_const=True)
## nstime.h (module 'core'): int64_t ns3::Time::GetPicoSeconds() const [member function]
cls.add_method('GetPicoSeconds',
'int64_t',
[],
is_const=True)
## nstime.h (module 'core'): static ns3::Time::Unit ns3::Time::GetResolution() [member function]
cls.add_method('GetResolution',
'ns3::Time::Unit',
[],
is_static=True)
## nstime.h (module 'core'): double ns3::Time::GetSeconds() const [member function]
cls.add_method('GetSeconds',
'double',
[],
is_const=True)
## nstime.h (module 'core'): int64_t ns3::Time::GetTimeStep() const [member function]
cls.add_method('GetTimeStep',
'int64_t',
[],
is_const=True)
## nstime.h (module 'core'): double ns3::Time::GetYears() const [member function]
cls.add_method('GetYears',
'double',
[],
is_const=True)
## nstime.h (module 'core'): bool ns3::Time::IsNegative() const [member function]
cls.add_method('IsNegative',
'bool',
[],
is_const=True)
## nstime.h (module 'core'): bool ns3::Time::IsPositive() const [member function]
cls.add_method('IsPositive',
'bool',
[],
is_const=True)
## nstime.h (module 'core'): bool ns3::Time::IsStrictlyNegative() const [member function]
cls.add_method('IsStrictlyNegative',
'bool',
[],
is_const=True)
## nstime.h (module 'core'): bool ns3::Time::IsStrictlyPositive() const [member function]
cls.add_method('IsStrictlyPositive',
'bool',
[],
is_const=True)
## nstime.h (module 'core'): bool ns3::Time::IsZero() const [member function]
cls.add_method('IsZero',
'bool',
[],
is_const=True)
## nstime.h (module 'core'): static ns3::Time ns3::Time::Max() [member function]
cls.add_method('Max',
'ns3::Time',
[],
is_static=True)
## nstime.h (module 'core'): static ns3::Time ns3::Time::Min() [member function]
cls.add_method('Min',
'ns3::Time',
[],
is_static=True)
## nstime.h (module 'core'): static void ns3::Time::SetResolution(ns3::Time::Unit resolution) [member function]
cls.add_method('SetResolution',
'void',
[param('ns3::Time::Unit', 'resolution')],
is_static=True)
## nstime.h (module 'core'): static bool ns3::Time::StaticInit() [member function]
cls.add_method('StaticInit',
'bool',
[],
is_static=True)
## nstime.h (module 'core'): ns3::int64x64_t ns3::Time::To(ns3::Time::Unit unit) const [member function]
cls.add_method('To',
'ns3::int64x64_t',
[param('ns3::Time::Unit', 'unit')],
is_const=True)
## nstime.h (module 'core'): double ns3::Time::ToDouble(ns3::Time::Unit unit) const [member function]
cls.add_method('ToDouble',
'double',
[param('ns3::Time::Unit', 'unit')],
is_const=True)
## nstime.h (module 'core'): int64_t ns3::Time::ToInteger(ns3::Time::Unit unit) const [member function]
cls.add_method('ToInteger',
'int64_t',
[param('ns3::Time::Unit', 'unit')],
is_const=True)
return
def register_Ns3TraceSourceAccessor_methods(root_module, cls):
## trace-source-accessor.h (module 'core'): ns3::TraceSourceAccessor::TraceSourceAccessor(ns3::TraceSourceAccessor const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TraceSourceAccessor const &', 'arg0')])
## trace-source-accessor.h (module 'core'): ns3::TraceSourceAccessor::TraceSourceAccessor() [constructor]
cls.add_constructor([])
## trace-source-accessor.h (module 'core'): bool ns3::TraceSourceAccessor::Connect(ns3::ObjectBase * obj, std::string context, ns3::CallbackBase const & cb) const [member function]
cls.add_method('Connect',
'bool',
[param('ns3::ObjectBase *', 'obj', transfer_ownership=False), param('std::string', 'context'), param('ns3::CallbackBase const &', 'cb')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## trace-source-accessor.h (module 'core'): bool ns3::TraceSourceAccessor::ConnectWithoutContext(ns3::ObjectBase * obj, ns3::CallbackBase const & cb) const [member function]
cls.add_method('ConnectWithoutContext',
'bool',
[param('ns3::ObjectBase *', 'obj', transfer_ownership=False), param('ns3::CallbackBase const &', 'cb')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## trace-source-accessor.h (module 'core'): bool ns3::TraceSourceAccessor::Disconnect(ns3::ObjectBase * obj, std::string context, ns3::CallbackBase const & cb) const [member function]
cls.add_method('Disconnect',
'bool',
[param('ns3::ObjectBase *', 'obj', transfer_ownership=False), param('std::string', 'context'), param('ns3::CallbackBase const &', 'cb')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## trace-source-accessor.h (module 'core'): bool ns3::TraceSourceAccessor::DisconnectWithoutContext(ns3::ObjectBase * obj, ns3::CallbackBase const & cb) const [member function]
cls.add_method('DisconnectWithoutContext',
'bool',
[param('ns3::ObjectBase *', 'obj', transfer_ownership=False), param('ns3::CallbackBase const &', 'cb')],
is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3Trailer_methods(root_module, cls):
cls.add_output_stream_operator()
## trailer.h (module 'network'): ns3::Trailer::Trailer() [constructor]
cls.add_constructor([])
## trailer.h (module 'network'): ns3::Trailer::Trailer(ns3::Trailer const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Trailer const &', 'arg0')])
## trailer.h (module 'network'): uint32_t ns3::Trailer::Deserialize(ns3::Buffer::Iterator end) [member function]
cls.add_method('Deserialize',
'uint32_t',
[param('ns3::Buffer::Iterator', 'end')],
is_pure_virtual=True, is_virtual=True)
## trailer.h (module 'network'): uint32_t ns3::Trailer::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## trailer.h (module 'network'): static ns3::TypeId ns3::Trailer::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## trailer.h (module 'network'): void ns3::Trailer::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## trailer.h (module 'network'): void ns3::Trailer::Serialize(ns3::Buffer::Iterator start) const [member function]
cls.add_method('Serialize',
'void',
[param('ns3::Buffer::Iterator', 'start')],
is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3AttributeAccessor_methods(root_module, cls):
## attribute.h (module 'core'): ns3::AttributeAccessor::AttributeAccessor(ns3::AttributeAccessor const & arg0) [copy constructor]
cls.add_constructor([param('ns3::AttributeAccessor const &', 'arg0')])
## attribute.h (module 'core'): ns3::AttributeAccessor::AttributeAccessor() [constructor]
cls.add_constructor([])
## attribute.h (module 'core'): bool ns3::AttributeAccessor::Get(ns3::ObjectBase const * object, ns3::AttributeValue & attribute) const [member function]
cls.add_method('Get',
'bool',
[param('ns3::ObjectBase const *', 'object'), param('ns3::AttributeValue &', 'attribute')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::AttributeAccessor::HasGetter() const [member function]
cls.add_method('HasGetter',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::AttributeAccessor::HasSetter() const [member function]
cls.add_method('HasSetter',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::AttributeAccessor::Set(ns3::ObjectBase * object, ns3::AttributeValue const & value) const [member function]
cls.add_method('Set',
'bool',
[param('ns3::ObjectBase *', 'object', transfer_ownership=False), param('ns3::AttributeValue const &', 'value')],
is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3AttributeChecker_methods(root_module, cls):
## attribute.h (module 'core'): ns3::AttributeChecker::AttributeChecker(ns3::AttributeChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::AttributeChecker const &', 'arg0')])
## attribute.h (module 'core'): ns3::AttributeChecker::AttributeChecker() [constructor]
cls.add_constructor([])
## attribute.h (module 'core'): bool ns3::AttributeChecker::Check(ns3::AttributeValue const & value) const [member function]
cls.add_method('Check',
'bool',
[param('ns3::AttributeValue const &', 'value')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::AttributeChecker::Copy(ns3::AttributeValue const & source, ns3::AttributeValue & destination) const [member function]
cls.add_method('Copy',
'bool',
[param('ns3::AttributeValue const &', 'source'), param('ns3::AttributeValue &', 'destination')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::AttributeChecker::Create() const [member function]
cls.add_method('Create',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::AttributeChecker::CreateValidValue(ns3::AttributeValue const & value) const [member function]
cls.add_method('CreateValidValue',
'ns3::Ptr< ns3::AttributeValue >',
[param('ns3::AttributeValue const &', 'value')],
is_const=True)
## attribute.h (module 'core'): std::string ns3::AttributeChecker::GetUnderlyingTypeInformation() const [member function]
cls.add_method('GetUnderlyingTypeInformation',
'std::string',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): std::string ns3::AttributeChecker::GetValueTypeName() const [member function]
cls.add_method('GetValueTypeName',
'std::string',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::AttributeChecker::HasUnderlyingTypeInformation() const [member function]
cls.add_method('HasUnderlyingTypeInformation',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3AttributeValue_methods(root_module, cls):
## attribute.h (module 'core'): ns3::AttributeValue::AttributeValue(ns3::AttributeValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::AttributeValue const &', 'arg0')])
## attribute.h (module 'core'): ns3::AttributeValue::AttributeValue() [constructor]
cls.add_constructor([])
## attribute.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::AttributeValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::AttributeValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_pure_virtual=True, is_virtual=True)
## attribute.h (module 'core'): std::string ns3::AttributeValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3CallbackChecker_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackChecker::CallbackChecker() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackChecker::CallbackChecker(ns3::CallbackChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::CallbackChecker const &', 'arg0')])
return
def register_Ns3CallbackImplBase_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImplBase::CallbackImplBase() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImplBase::CallbackImplBase(ns3::CallbackImplBase const & arg0) [copy constructor]
cls.add_constructor([param('ns3::CallbackImplBase const &', 'arg0')])
## callback.h (module 'core'): std::string ns3::CallbackImplBase::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## callback.h (module 'core'): bool ns3::CallbackImplBase::IsEqual(ns3::Ptr<ns3::CallbackImplBase const> other) const [member function]
cls.add_method('IsEqual',
'bool',
[param('ns3::Ptr< ns3::CallbackImplBase const >', 'other')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::Demangle(std::string const & mangled) [member function]
cls.add_method('Demangle',
'std::string',
[param('std::string const &', 'mangled')],
is_static=True, visibility='protected')
return
def register_Ns3CallbackValue_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackValue::CallbackValue(ns3::CallbackValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::CallbackValue const &', 'arg0')])
## callback.h (module 'core'): ns3::CallbackValue::CallbackValue() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackValue::CallbackValue(ns3::CallbackBase const & base) [constructor]
cls.add_constructor([param('ns3::CallbackBase const &', 'base')])
## callback.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::CallbackValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): bool ns3::CallbackValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## callback.h (module 'core'): std::string ns3::CallbackValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackValue::Set(ns3::CallbackBase base) [member function]
cls.add_method('Set',
'void',
[param('ns3::CallbackBase', 'base')])
return
def register_Ns3EmptyAttributeAccessor_methods(root_module, cls):
## attribute.h (module 'core'): ns3::EmptyAttributeAccessor::EmptyAttributeAccessor(ns3::EmptyAttributeAccessor const & arg0) [copy constructor]
cls.add_constructor([param('ns3::EmptyAttributeAccessor const &', 'arg0')])
## attribute.h (module 'core'): ns3::EmptyAttributeAccessor::EmptyAttributeAccessor() [constructor]
cls.add_constructor([])
## attribute.h (module 'core'): bool ns3::EmptyAttributeAccessor::Get(ns3::ObjectBase const * object, ns3::AttributeValue & attribute) const [member function]
cls.add_method('Get',
'bool',
[param('ns3::ObjectBase const *', 'object'), param('ns3::AttributeValue &', 'attribute')],
is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::EmptyAttributeAccessor::HasGetter() const [member function]
cls.add_method('HasGetter',
'bool',
[],
is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::EmptyAttributeAccessor::HasSetter() const [member function]
cls.add_method('HasSetter',
'bool',
[],
is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::EmptyAttributeAccessor::Set(ns3::ObjectBase * object, ns3::AttributeValue const & value) const [member function]
cls.add_method('Set',
'bool',
[param('ns3::ObjectBase *', 'object'), param('ns3::AttributeValue const &', 'value')],
is_const=True, is_virtual=True)
return
def register_Ns3EmptyAttributeChecker_methods(root_module, cls):
## attribute.h (module 'core'): ns3::EmptyAttributeChecker::EmptyAttributeChecker(ns3::EmptyAttributeChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::EmptyAttributeChecker const &', 'arg0')])
## attribute.h (module 'core'): ns3::EmptyAttributeChecker::EmptyAttributeChecker() [constructor]
cls.add_constructor([])
## attribute.h (module 'core'): bool ns3::EmptyAttributeChecker::Check(ns3::AttributeValue const & value) const [member function]
cls.add_method('Check',
'bool',
[param('ns3::AttributeValue const &', 'value')],
is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::EmptyAttributeChecker::Copy(ns3::AttributeValue const & source, ns3::AttributeValue & destination) const [member function]
cls.add_method('Copy',
'bool',
[param('ns3::AttributeValue const &', 'source'), param('ns3::AttributeValue &', 'destination')],
is_const=True, is_virtual=True)
## attribute.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::EmptyAttributeChecker::Create() const [member function]
cls.add_method('Create',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## attribute.h (module 'core'): std::string ns3::EmptyAttributeChecker::GetUnderlyingTypeInformation() const [member function]
cls.add_method('GetUnderlyingTypeInformation',
'std::string',
[],
is_const=True, is_virtual=True)
## attribute.h (module 'core'): std::string ns3::EmptyAttributeChecker::GetValueTypeName() const [member function]
cls.add_method('GetValueTypeName',
'std::string',
[],
is_const=True, is_virtual=True)
## attribute.h (module 'core'): bool ns3::EmptyAttributeChecker::HasUnderlyingTypeInformation() const [member function]
cls.add_method('HasUnderlyingTypeInformation',
'bool',
[],
is_const=True, is_virtual=True)
return
def register_Ns3EmptyAttributeValue_methods(root_module, cls):
## attribute.h (module 'core'): ns3::EmptyAttributeValue::EmptyAttributeValue(ns3::EmptyAttributeValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::EmptyAttributeValue const &', 'arg0')])
## attribute.h (module 'core'): ns3::EmptyAttributeValue::EmptyAttributeValue() [constructor]
cls.add_constructor([])
## attribute.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::EmptyAttributeValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, visibility='private', is_virtual=True)
## attribute.h (module 'core'): bool ns3::EmptyAttributeValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
visibility='private', is_virtual=True)
## attribute.h (module 'core'): std::string ns3::EmptyAttributeValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, visibility='private', is_virtual=True)
return
def register_Ns3Ipv4AddressChecker_methods(root_module, cls):
## ipv4-address.h (module 'network'): ns3::Ipv4AddressChecker::Ipv4AddressChecker() [constructor]
cls.add_constructor([])
## ipv4-address.h (module 'network'): ns3::Ipv4AddressChecker::Ipv4AddressChecker(ns3::Ipv4AddressChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4AddressChecker const &', 'arg0')])
return
def register_Ns3Ipv4AddressValue_methods(root_module, cls):
## ipv4-address.h (module 'network'): ns3::Ipv4AddressValue::Ipv4AddressValue() [constructor]
cls.add_constructor([])
## ipv4-address.h (module 'network'): ns3::Ipv4AddressValue::Ipv4AddressValue(ns3::Ipv4AddressValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4AddressValue const &', 'arg0')])
## ipv4-address.h (module 'network'): ns3::Ipv4AddressValue::Ipv4AddressValue(ns3::Ipv4Address const & value) [constructor]
cls.add_constructor([param('ns3::Ipv4Address const &', 'value')])
## ipv4-address.h (module 'network'): ns3::Ptr<ns3::AttributeValue> ns3::Ipv4AddressValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4AddressValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## ipv4-address.h (module 'network'): ns3::Ipv4Address ns3::Ipv4AddressValue::Get() const [member function]
cls.add_method('Get',
'ns3::Ipv4Address',
[],
is_const=True)
## ipv4-address.h (module 'network'): std::string ns3::Ipv4AddressValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## ipv4-address.h (module 'network'): void ns3::Ipv4AddressValue::Set(ns3::Ipv4Address const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Ipv4Address const &', 'value')])
return
def register_Ns3Ipv4MaskChecker_methods(root_module, cls):
## ipv4-address.h (module 'network'): ns3::Ipv4MaskChecker::Ipv4MaskChecker() [constructor]
cls.add_constructor([])
## ipv4-address.h (module 'network'): ns3::Ipv4MaskChecker::Ipv4MaskChecker(ns3::Ipv4MaskChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4MaskChecker const &', 'arg0')])
return
def register_Ns3Ipv4MaskValue_methods(root_module, cls):
## ipv4-address.h (module 'network'): ns3::Ipv4MaskValue::Ipv4MaskValue() [constructor]
cls.add_constructor([])
## ipv4-address.h (module 'network'): ns3::Ipv4MaskValue::Ipv4MaskValue(ns3::Ipv4MaskValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4MaskValue const &', 'arg0')])
## ipv4-address.h (module 'network'): ns3::Ipv4MaskValue::Ipv4MaskValue(ns3::Ipv4Mask const & value) [constructor]
cls.add_constructor([param('ns3::Ipv4Mask const &', 'value')])
## ipv4-address.h (module 'network'): ns3::Ptr<ns3::AttributeValue> ns3::Ipv4MaskValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## ipv4-address.h (module 'network'): bool ns3::Ipv4MaskValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## ipv4-address.h (module 'network'): ns3::Ipv4Mask ns3::Ipv4MaskValue::Get() const [member function]
cls.add_method('Get',
'ns3::Ipv4Mask',
[],
is_const=True)
## ipv4-address.h (module 'network'): std::string ns3::Ipv4MaskValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## ipv4-address.h (module 'network'): void ns3::Ipv4MaskValue::Set(ns3::Ipv4Mask const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Ipv4Mask const &', 'value')])
return
def register_Ns3Ipv6AddressChecker_methods(root_module, cls):
## ipv6-address.h (module 'network'): ns3::Ipv6AddressChecker::Ipv6AddressChecker() [constructor]
cls.add_constructor([])
## ipv6-address.h (module 'network'): ns3::Ipv6AddressChecker::Ipv6AddressChecker(ns3::Ipv6AddressChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv6AddressChecker const &', 'arg0')])
return
def register_Ns3Ipv6AddressValue_methods(root_module, cls):
## ipv6-address.h (module 'network'): ns3::Ipv6AddressValue::Ipv6AddressValue() [constructor]
cls.add_constructor([])
## ipv6-address.h (module 'network'): ns3::Ipv6AddressValue::Ipv6AddressValue(ns3::Ipv6AddressValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv6AddressValue const &', 'arg0')])
## ipv6-address.h (module 'network'): ns3::Ipv6AddressValue::Ipv6AddressValue(ns3::Ipv6Address const & value) [constructor]
cls.add_constructor([param('ns3::Ipv6Address const &', 'value')])
## ipv6-address.h (module 'network'): ns3::Ptr<ns3::AttributeValue> ns3::Ipv6AddressValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6AddressValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## ipv6-address.h (module 'network'): ns3::Ipv6Address ns3::Ipv6AddressValue::Get() const [member function]
cls.add_method('Get',
'ns3::Ipv6Address',
[],
is_const=True)
## ipv6-address.h (module 'network'): std::string ns3::Ipv6AddressValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## ipv6-address.h (module 'network'): void ns3::Ipv6AddressValue::Set(ns3::Ipv6Address const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Ipv6Address const &', 'value')])
return
def register_Ns3Ipv6PrefixChecker_methods(root_module, cls):
## ipv6-address.h (module 'network'): ns3::Ipv6PrefixChecker::Ipv6PrefixChecker() [constructor]
cls.add_constructor([])
## ipv6-address.h (module 'network'): ns3::Ipv6PrefixChecker::Ipv6PrefixChecker(ns3::Ipv6PrefixChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv6PrefixChecker const &', 'arg0')])
return
def register_Ns3Ipv6PrefixValue_methods(root_module, cls):
## ipv6-address.h (module 'network'): ns3::Ipv6PrefixValue::Ipv6PrefixValue() [constructor]
cls.add_constructor([])
## ipv6-address.h (module 'network'): ns3::Ipv6PrefixValue::Ipv6PrefixValue(ns3::Ipv6PrefixValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv6PrefixValue const &', 'arg0')])
## ipv6-address.h (module 'network'): ns3::Ipv6PrefixValue::Ipv6PrefixValue(ns3::Ipv6Prefix const & value) [constructor]
cls.add_constructor([param('ns3::Ipv6Prefix const &', 'value')])
## ipv6-address.h (module 'network'): ns3::Ptr<ns3::AttributeValue> ns3::Ipv6PrefixValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## ipv6-address.h (module 'network'): bool ns3::Ipv6PrefixValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## ipv6-address.h (module 'network'): ns3::Ipv6Prefix ns3::Ipv6PrefixValue::Get() const [member function]
cls.add_method('Get',
'ns3::Ipv6Prefix',
[],
is_const=True)
## ipv6-address.h (module 'network'): std::string ns3::Ipv6PrefixValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## ipv6-address.h (module 'network'): void ns3::Ipv6PrefixValue::Set(ns3::Ipv6Prefix const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Ipv6Prefix const &', 'value')])
return
def register_Ns3Mac48AddressChecker_methods(root_module, cls):
## mac48-address.h (module 'network'): ns3::Mac48AddressChecker::Mac48AddressChecker() [constructor]
cls.add_constructor([])
## mac48-address.h (module 'network'): ns3::Mac48AddressChecker::Mac48AddressChecker(ns3::Mac48AddressChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac48AddressChecker const &', 'arg0')])
return
def register_Ns3Mac48AddressValue_methods(root_module, cls):
## mac48-address.h (module 'network'): ns3::Mac48AddressValue::Mac48AddressValue() [constructor]
cls.add_constructor([])
## mac48-address.h (module 'network'): ns3::Mac48AddressValue::Mac48AddressValue(ns3::Mac48AddressValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac48AddressValue const &', 'arg0')])
## mac48-address.h (module 'network'): ns3::Mac48AddressValue::Mac48AddressValue(ns3::Mac48Address const & value) [constructor]
cls.add_constructor([param('ns3::Mac48Address const &', 'value')])
## mac48-address.h (module 'network'): ns3::Ptr<ns3::AttributeValue> ns3::Mac48AddressValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## mac48-address.h (module 'network'): bool ns3::Mac48AddressValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## mac48-address.h (module 'network'): ns3::Mac48Address ns3::Mac48AddressValue::Get() const [member function]
cls.add_method('Get',
'ns3::Mac48Address',
[],
is_const=True)
## mac48-address.h (module 'network'): std::string ns3::Mac48AddressValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## mac48-address.h (module 'network'): void ns3::Mac48AddressValue::Set(ns3::Mac48Address const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Mac48Address const &', 'value')])
return
def register_Ns3MpiReceiver_methods(root_module, cls):
## mpi-receiver.h (module 'mpi'): ns3::MpiReceiver::MpiReceiver() [constructor]
cls.add_constructor([])
## mpi-receiver.h (module 'mpi'): ns3::MpiReceiver::MpiReceiver(ns3::MpiReceiver const & arg0) [copy constructor]
cls.add_constructor([param('ns3::MpiReceiver const &', 'arg0')])
## mpi-receiver.h (module 'mpi'): static ns3::TypeId ns3::MpiReceiver::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## mpi-receiver.h (module 'mpi'): void ns3::MpiReceiver::Receive(ns3::Ptr<ns3::Packet> p) [member function]
cls.add_method('Receive',
'void',
[param('ns3::Ptr< ns3::Packet >', 'p')])
## mpi-receiver.h (module 'mpi'): void ns3::MpiReceiver::SetReceiveCallback(ns3::Callback<void, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> callback) [member function]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< void, ns3::Ptr< ns3::Packet >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')])
## mpi-receiver.h (module 'mpi'): void ns3::MpiReceiver::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
[],
visibility='private', is_virtual=True)
return
def register_Ns3NixVector_methods(root_module, cls):
cls.add_output_stream_operator()
## nix-vector.h (module 'network'): ns3::NixVector::NixVector() [constructor]
cls.add_constructor([])
## nix-vector.h (module 'network'): ns3::NixVector::NixVector(ns3::NixVector const & o) [copy constructor]
cls.add_constructor([param('ns3::NixVector const &', 'o')])
## nix-vector.h (module 'network'): void ns3::NixVector::AddNeighborIndex(uint32_t newBits, uint32_t numberOfBits) [member function]
cls.add_method('AddNeighborIndex',
'void',
[param('uint32_t', 'newBits'), param('uint32_t', 'numberOfBits')])
## nix-vector.h (module 'network'): uint32_t ns3::NixVector::BitCount(uint32_t numberOfNeighbors) const [member function]
cls.add_method('BitCount',
'uint32_t',
[param('uint32_t', 'numberOfNeighbors')],
is_const=True)
## nix-vector.h (module 'network'): ns3::Ptr<ns3::NixVector> ns3::NixVector::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::NixVector >',
[],
is_const=True)
## nix-vector.h (module 'network'): uint32_t ns3::NixVector::Deserialize(uint32_t const * buffer, uint32_t size) [member function]
cls.add_method('Deserialize',
'uint32_t',
[param('uint32_t const *', 'buffer'), param('uint32_t', 'size')])
## nix-vector.h (module 'network'): uint32_t ns3::NixVector::ExtractNeighborIndex(uint32_t numberOfBits) [member function]
cls.add_method('ExtractNeighborIndex',
'uint32_t',
[param('uint32_t', 'numberOfBits')])
## nix-vector.h (module 'network'): uint32_t ns3::NixVector::GetRemainingBits() [member function]
cls.add_method('GetRemainingBits',
'uint32_t',
[])
## nix-vector.h (module 'network'): uint32_t ns3::NixVector::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_const=True)
## nix-vector.h (module 'network'): uint32_t ns3::NixVector::Serialize(uint32_t * buffer, uint32_t maxSize) const [member function]
cls.add_method('Serialize',
'uint32_t',
[param('uint32_t *', 'buffer'), param('uint32_t', 'maxSize')],
is_const=True)
return
def register_Ns3Packet_methods(root_module, cls):
cls.add_output_stream_operator()
## packet.h (module 'network'): ns3::Packet::Packet() [constructor]
cls.add_constructor([])
## packet.h (module 'network'): ns3::Packet::Packet(ns3::Packet const & o) [copy constructor]
cls.add_constructor([param('ns3::Packet const &', 'o')])
## packet.h (module 'network'): ns3::Packet::Packet(uint32_t size) [constructor]
cls.add_constructor([param('uint32_t', 'size')])
## packet.h (module 'network'): ns3::Packet::Packet(uint8_t const * buffer, uint32_t size, bool magic) [constructor]
cls.add_constructor([param('uint8_t const *', 'buffer'), param('uint32_t', 'size'), param('bool', 'magic')])
## packet.h (module 'network'): ns3::Packet::Packet(uint8_t const * buffer, uint32_t size) [constructor]
cls.add_constructor([param('uint8_t const *', 'buffer'), param('uint32_t', 'size')])
## packet.h (module 'network'): void ns3::Packet::AddAtEnd(ns3::Ptr<const ns3::Packet> packet) [member function]
cls.add_method('AddAtEnd',
'void',
[param('ns3::Ptr< ns3::Packet const >', 'packet')])
## packet.h (module 'network'): void ns3::Packet::AddByteTag(ns3::Tag const & tag) const [member function]
cls.add_method('AddByteTag',
'void',
[param('ns3::Tag const &', 'tag')],
is_const=True)
## packet.h (module 'network'): void ns3::Packet::AddHeader(ns3::Header const & header) [member function]
cls.add_method('AddHeader',
'void',
[param('ns3::Header const &', 'header')])
## packet.h (module 'network'): void ns3::Packet::AddPacketTag(ns3::Tag const & tag) const [member function]
cls.add_method('AddPacketTag',
'void',
[param('ns3::Tag const &', 'tag')],
is_const=True)
## packet.h (module 'network'): void ns3::Packet::AddPaddingAtEnd(uint32_t size) [member function]
cls.add_method('AddPaddingAtEnd',
'void',
[param('uint32_t', 'size')])
## packet.h (module 'network'): void ns3::Packet::AddTrailer(ns3::Trailer const & trailer) [member function]
cls.add_method('AddTrailer',
'void',
[param('ns3::Trailer const &', 'trailer')])
## packet.h (module 'network'): ns3::PacketMetadata::ItemIterator ns3::Packet::BeginItem() const [member function]
cls.add_method('BeginItem',
'ns3::PacketMetadata::ItemIterator',
[],
is_const=True)
## packet.h (module 'network'): ns3::Ptr<ns3::Packet> ns3::Packet::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::Packet >',
[],
is_const=True)
## packet.h (module 'network'): uint32_t ns3::Packet::CopyData(uint8_t * buffer, uint32_t size) const [member function]
cls.add_method('CopyData',
'uint32_t',
[param('uint8_t *', 'buffer'), param('uint32_t', 'size')],
is_const=True)
## packet.h (module 'network'): void ns3::Packet::CopyData(std::ostream * os, uint32_t size) const [member function]
cls.add_method('CopyData',
'void',
[param('std::ostream *', 'os'), param('uint32_t', 'size')],
is_const=True)
## packet.h (module 'network'): ns3::Ptr<ns3::Packet> ns3::Packet::CreateFragment(uint32_t start, uint32_t length) const [member function]
cls.add_method('CreateFragment',
'ns3::Ptr< ns3::Packet >',
[param('uint32_t', 'start'), param('uint32_t', 'length')],
is_const=True)
## packet.h (module 'network'): static void ns3::Packet::EnableChecking() [member function]
cls.add_method('EnableChecking',
'void',
[],
is_static=True)
## packet.h (module 'network'): static void ns3::Packet::EnablePrinting() [member function]
cls.add_method('EnablePrinting',
'void',
[],
is_static=True)
## packet.h (module 'network'): bool ns3::Packet::FindFirstMatchingByteTag(ns3::Tag & tag) const [member function]
cls.add_method('FindFirstMatchingByteTag',
'bool',
[param('ns3::Tag &', 'tag')],
is_const=True)
## packet.h (module 'network'): ns3::ByteTagIterator ns3::Packet::GetByteTagIterator() const [member function]
cls.add_method('GetByteTagIterator',
'ns3::ByteTagIterator',
[],
is_const=True)
## packet.h (module 'network'): ns3::Ptr<ns3::NixVector> ns3::Packet::GetNixVector() const [member function]
cls.add_method('GetNixVector',
'ns3::Ptr< ns3::NixVector >',
[],
is_const=True)
## packet.h (module 'network'): ns3::PacketTagIterator ns3::Packet::GetPacketTagIterator() const [member function]
cls.add_method('GetPacketTagIterator',
'ns3::PacketTagIterator',
[],
is_const=True)
## packet.h (module 'network'): uint32_t ns3::Packet::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_const=True)
## packet.h (module 'network'): uint32_t ns3::Packet::GetSize() const [member function]
cls.add_method('GetSize',
'uint32_t',
[],
is_const=True)
## packet.h (module 'network'): uint64_t ns3::Packet::GetUid() const [member function]
cls.add_method('GetUid',
'uint64_t',
[],
is_const=True)
## packet.h (module 'network'): uint32_t ns3::Packet::PeekHeader(ns3::Header & header) const [member function]
cls.add_method('PeekHeader',
'uint32_t',
[param('ns3::Header &', 'header')],
is_const=True)
## packet.h (module 'network'): bool ns3::Packet::PeekPacketTag(ns3::Tag & tag) const [member function]
cls.add_method('PeekPacketTag',
'bool',
[param('ns3::Tag &', 'tag')],
is_const=True)
## packet.h (module 'network'): uint32_t ns3::Packet::PeekTrailer(ns3::Trailer & trailer) [member function]
cls.add_method('PeekTrailer',
'uint32_t',
[param('ns3::Trailer &', 'trailer')])
## packet.h (module 'network'): void ns3::Packet::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_const=True)
## packet.h (module 'network'): void ns3::Packet::PrintByteTags(std::ostream & os) const [member function]
cls.add_method('PrintByteTags',
'void',
[param('std::ostream &', 'os')],
is_const=True)
## packet.h (module 'network'): void ns3::Packet::PrintPacketTags(std::ostream & os) const [member function]
cls.add_method('PrintPacketTags',
'void',
[param('std::ostream &', 'os')],
is_const=True)
## packet.h (module 'network'): void ns3::Packet::RemoveAllByteTags() [member function]
cls.add_method('RemoveAllByteTags',
'void',
[])
## packet.h (module 'network'): void ns3::Packet::RemoveAllPacketTags() [member function]
cls.add_method('RemoveAllPacketTags',
'void',
[])
## packet.h (module 'network'): void ns3::Packet::RemoveAtEnd(uint32_t size) [member function]
cls.add_method('RemoveAtEnd',
'void',
[param('uint32_t', 'size')])
## packet.h (module 'network'): void ns3::Packet::RemoveAtStart(uint32_t size) [member function]
cls.add_method('RemoveAtStart',
'void',
[param('uint32_t', 'size')])
## packet.h (module 'network'): uint32_t ns3::Packet::RemoveHeader(ns3::Header & header) [member function]
cls.add_method('RemoveHeader',
'uint32_t',
[param('ns3::Header &', 'header')])
## packet.h (module 'network'): bool ns3::Packet::RemovePacketTag(ns3::Tag & tag) [member function]
cls.add_method('RemovePacketTag',
'bool',
[param('ns3::Tag &', 'tag')])
## packet.h (module 'network'): uint32_t ns3::Packet::RemoveTrailer(ns3::Trailer & trailer) [member function]
cls.add_method('RemoveTrailer',
'uint32_t',
[param('ns3::Trailer &', 'trailer')])
## packet.h (module 'network'): bool ns3::Packet::ReplacePacketTag(ns3::Tag & tag) [member function]
cls.add_method('ReplacePacketTag',
'bool',
[param('ns3::Tag &', 'tag')])
## packet.h (module 'network'): uint32_t ns3::Packet::Serialize(uint8_t * buffer, uint32_t maxSize) const [member function]
cls.add_method('Serialize',
'uint32_t',
[param('uint8_t *', 'buffer'), param('uint32_t', 'maxSize')],
is_const=True)
## packet.h (module 'network'): void ns3::Packet::SetNixVector(ns3::Ptr<ns3::NixVector> nixVector) [member function]
cls.add_method('SetNixVector',
'void',
[param('ns3::Ptr< ns3::NixVector >', 'nixVector')])
## packet.h (module 'network'): std::string ns3::Packet::ToString() const [member function]
cls.add_method('ToString',
'std::string',
[],
is_const=True)
return
def register_Ns3TimeValue_methods(root_module, cls):
## nstime.h (module 'core'): ns3::TimeValue::TimeValue() [constructor]
cls.add_constructor([])
## nstime.h (module 'core'): ns3::TimeValue::TimeValue(ns3::TimeValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TimeValue const &', 'arg0')])
## nstime.h (module 'core'): ns3::TimeValue::TimeValue(ns3::Time const & value) [constructor]
cls.add_constructor([param('ns3::Time const &', 'value')])
## nstime.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::TimeValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## nstime.h (module 'core'): bool ns3::TimeValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## nstime.h (module 'core'): ns3::Time ns3::TimeValue::Get() const [member function]
cls.add_method('Get',
'ns3::Time',
[],
is_const=True)
## nstime.h (module 'core'): std::string ns3::TimeValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## nstime.h (module 'core'): void ns3::TimeValue::Set(ns3::Time const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Time const &', 'value')])
return
def register_Ns3TypeIdChecker_methods(root_module, cls):
## type-id.h (module 'core'): ns3::TypeIdChecker::TypeIdChecker() [constructor]
cls.add_constructor([])
## type-id.h (module 'core'): ns3::TypeIdChecker::TypeIdChecker(ns3::TypeIdChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TypeIdChecker const &', 'arg0')])
return
def register_Ns3TypeIdValue_methods(root_module, cls):
## type-id.h (module 'core'): ns3::TypeIdValue::TypeIdValue() [constructor]
cls.add_constructor([])
## type-id.h (module 'core'): ns3::TypeIdValue::TypeIdValue(ns3::TypeIdValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TypeIdValue const &', 'arg0')])
## type-id.h (module 'core'): ns3::TypeIdValue::TypeIdValue(ns3::TypeId const & value) [constructor]
cls.add_constructor([param('ns3::TypeId const &', 'value')])
## type-id.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::TypeIdValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## type-id.h (module 'core'): bool ns3::TypeIdValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## type-id.h (module 'core'): ns3::TypeId ns3::TypeIdValue::Get() const [member function]
cls.add_method('Get',
'ns3::TypeId',
[],
is_const=True)
## type-id.h (module 'core'): std::string ns3::TypeIdValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## type-id.h (module 'core'): void ns3::TypeIdValue::Set(ns3::TypeId const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::TypeId const &', 'value')])
return
def register_Ns3AddressChecker_methods(root_module, cls):
## address.h (module 'network'): ns3::AddressChecker::AddressChecker() [constructor]
cls.add_constructor([])
## address.h (module 'network'): ns3::AddressChecker::AddressChecker(ns3::AddressChecker const & arg0) [copy constructor]
cls.add_constructor([param('ns3::AddressChecker const &', 'arg0')])
return
def register_Ns3AddressValue_methods(root_module, cls):
## address.h (module 'network'): ns3::AddressValue::AddressValue() [constructor]
cls.add_constructor([])
## address.h (module 'network'): ns3::AddressValue::AddressValue(ns3::AddressValue const & arg0) [copy constructor]
cls.add_constructor([param('ns3::AddressValue const &', 'arg0')])
## address.h (module 'network'): ns3::AddressValue::AddressValue(ns3::Address const & value) [constructor]
cls.add_constructor([param('ns3::Address const &', 'value')])
## address.h (module 'network'): ns3::Ptr<ns3::AttributeValue> ns3::AddressValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## address.h (module 'network'): bool ns3::AddressValue::DeserializeFromString(std::string value, ns3::Ptr<ns3::AttributeChecker const> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## address.h (module 'network'): ns3::Address ns3::AddressValue::Get() const [member function]
cls.add_method('Get',
'ns3::Address',
[],
is_const=True)
## address.h (module 'network'): std::string ns3::AddressValue::SerializeToString(ns3::Ptr<ns3::AttributeChecker const> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## address.h (module 'network'): void ns3::AddressValue::Set(ns3::Address const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Address const &', 'value')])
return
def register_Ns3HashImplementation_methods(root_module, cls):
## hash-function.h (module 'core'): ns3::Hash::Implementation::Implementation(ns3::Hash::Implementation const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Hash::Implementation const &', 'arg0')])
## hash-function.h (module 'core'): ns3::Hash::Implementation::Implementation() [constructor]
cls.add_constructor([])
## hash-function.h (module 'core'): uint32_t ns3::Hash::Implementation::GetHash32(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash32',
'uint32_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_pure_virtual=True, is_virtual=True)
## hash-function.h (module 'core'): uint64_t ns3::Hash::Implementation::GetHash64(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash64',
'uint64_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_virtual=True)
## hash-function.h (module 'core'): void ns3::Hash::Implementation::clear() [member function]
cls.add_method('clear',
'void',
[],
is_pure_virtual=True, is_virtual=True)
return
def register_Ns3HashFunctionFnv1a_methods(root_module, cls):
## hash-fnv.h (module 'core'): ns3::Hash::Function::Fnv1a::Fnv1a(ns3::Hash::Function::Fnv1a const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Hash::Function::Fnv1a const &', 'arg0')])
## hash-fnv.h (module 'core'): ns3::Hash::Function::Fnv1a::Fnv1a() [constructor]
cls.add_constructor([])
## hash-fnv.h (module 'core'): uint32_t ns3::Hash::Function::Fnv1a::GetHash32(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash32',
'uint32_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_virtual=True)
## hash-fnv.h (module 'core'): uint64_t ns3::Hash::Function::Fnv1a::GetHash64(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash64',
'uint64_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_virtual=True)
## hash-fnv.h (module 'core'): void ns3::Hash::Function::Fnv1a::clear() [member function]
cls.add_method('clear',
'void',
[],
is_virtual=True)
return
def register_Ns3HashFunctionHash32_methods(root_module, cls):
## hash-function.h (module 'core'): ns3::Hash::Function::Hash32::Hash32(ns3::Hash::Function::Hash32 const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Hash::Function::Hash32 const &', 'arg0')])
## hash-function.h (module 'core'): ns3::Hash::Function::Hash32::Hash32(ns3::Hash::Hash32Function_ptr hp) [constructor]
cls.add_constructor([param('ns3::Hash::Hash32Function_ptr', 'hp')])
## hash-function.h (module 'core'): uint32_t ns3::Hash::Function::Hash32::GetHash32(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash32',
'uint32_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_virtual=True)
## hash-function.h (module 'core'): void ns3::Hash::Function::Hash32::clear() [member function]
cls.add_method('clear',
'void',
[],
is_virtual=True)
return
def register_Ns3HashFunctionHash64_methods(root_module, cls):
## hash-function.h (module 'core'): ns3::Hash::Function::Hash64::Hash64(ns3::Hash::Function::Hash64 const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Hash::Function::Hash64 const &', 'arg0')])
## hash-function.h (module 'core'): ns3::Hash::Function::Hash64::Hash64(ns3::Hash::Hash64Function_ptr hp) [constructor]
cls.add_constructor([param('ns3::Hash::Hash64Function_ptr', 'hp')])
## hash-function.h (module 'core'): uint32_t ns3::Hash::Function::Hash64::GetHash32(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash32',
'uint32_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_virtual=True)
## hash-function.h (module 'core'): uint64_t ns3::Hash::Function::Hash64::GetHash64(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash64',
'uint64_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_virtual=True)
## hash-function.h (module 'core'): void ns3::Hash::Function::Hash64::clear() [member function]
cls.add_method('clear',
'void',
[],
is_virtual=True)
return
def register_Ns3HashFunctionMurmur3_methods(root_module, cls):
## hash-murmur3.h (module 'core'): ns3::Hash::Function::Murmur3::Murmur3(ns3::Hash::Function::Murmur3 const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Hash::Function::Murmur3 const &', 'arg0')])
## hash-murmur3.h (module 'core'): ns3::Hash::Function::Murmur3::Murmur3() [constructor]
cls.add_constructor([])
## hash-murmur3.h (module 'core'): uint32_t ns3::Hash::Function::Murmur3::GetHash32(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash32',
'uint32_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_virtual=True)
## hash-murmur3.h (module 'core'): uint64_t ns3::Hash::Function::Murmur3::GetHash64(char const * buffer, size_t const size) [member function]
cls.add_method('GetHash64',
'uint64_t',
[param('char const *', 'buffer'), param('size_t const', 'size')],
is_virtual=True)
## hash-murmur3.h (module 'core'): void ns3::Hash::Function::Murmur3::clear() [member function]
cls.add_method('clear',
'void',
[],
is_virtual=True)
return
def register_functions(root_module):
module = root_module
register_functions_ns3_FatalImpl(module.get_submodule('FatalImpl'), root_module)
register_functions_ns3_Hash(module.get_submodule('Hash'), root_module)
register_functions_ns3_TracedValueCallback(module.get_submodule('TracedValueCallback'), root_module)
return
def register_functions_ns3_FatalImpl(module, root_module):
return
def register_functions_ns3_Hash(module, root_module):
register_functions_ns3_Hash_Function(module.get_submodule('Function'), root_module)
return
def register_functions_ns3_Hash_Function(module, root_module):
return
def register_functions_ns3_TracedValueCallback(module, root_module):
return
def main():
out = FileCodeSink(sys.stdout)
root_module = module_init()
register_types(root_module)
register_methods(root_module)
register_functions(root_module)
root_module.generate(out)
if __name__ == '__main__':
main()
|
gpl-2.0
|
[
504,
1134,
31297,
492,
5673,
12,
3814,
3034,
17111,
12,
1215,
12,
9151,
12,
7246,
533,
12,
14330,
421,
199,
646,
1134,
31297,
14,
1751,
199,
646,
3598,
199,
199,
533,
4520,
2461,
8,
647,
31297,
14,
1751,
14,
25933,
304,
272,
347,
2429,
63,
705,
8,
277,
12,
4975,
12,
1919,
12,
5190,
7822,
267,
3598,
14,
4050,
480,
1971,
450,
82,
315,
4975,
450,
83,
2,
450,
334,
1971,
12,
4975,
430,
267,
372,
715,
199,
647,
31297,
14,
1751,
14,
705,
63,
2232,
275,
4520,
2461,
342,
421,
199,
646,
984,
199,
199,
318,
859,
63,
826,
837,
272,
1738,
63,
578,
275,
5673,
360,
561,
14,
13213,
297,
7246,
63,
3251,
18749,
26,
561,
19,
358,
272,
372,
1738,
63,
578,
199,
199,
318,
2274,
63,
1313,
8,
578,
304,
272,
1738,
63,
578,
275,
859,
14,
362,
63,
1231,
342,
2286,
925,
2287,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1476,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1476,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
2287,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1476,
447,
4261,
2320,
63,
69,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
4261,
2320,
63,
69,
297,
788,
4283,
63,
4305,
995,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
1476,
995,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
2225,
13,
12708,
13,
513,
14,
72,
334,
578,
283,
1018,
735,
700,
19,
447,
11120,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
11120,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1018,
358,
272,
925,
2225,
13,
12708,
13,
513,
14,
72,
334,
578,
283,
1018,
735,
700,
19,
447,
11120,
447,
2081,
359,
1820,
61,
272,
859,
14,
525,
63,
533,
360,
2081,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1018,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
11120,
1105,
272,
925,
3335,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
3299,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
3299,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3335,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
3299,
447,
3585,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
3585,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
3299,
1105,
272,
925,
3644,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
14420,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
14420,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3644,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
14420,
447,
2081,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
2081,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
14420,
1105,
272,
925,
3696,
13,
1450,
13,
513,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
10499,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
10499,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3696,
13,
1450,
13,
513,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
10499,
447,
3585,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
3585,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
10499,
1105,
272,
925,
3696,
13,
1450,
13,
513,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
10499,
447,
3585,
447,
2081,
359,
1820,
61,
272,
859,
14,
525,
63,
533,
360,
2081,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
10499,
447,
3585,
1105,
272,
925,
3233,
14,
72,
334,
578,
283,
1018,
735,
700,
19,
447,
9822,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
9822,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1018,
358,
272,
925,
2631,
14,
72,
334,
578,
283,
1018,
735,
700,
19,
447,
13415,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
13415,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1018,
358,
272,
925,
3278,
20,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
20,
1476,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1762,
20,
1476,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3278,
20,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
20,
1476,
359,
533,
61,
272,
1738,
63,
578,
459,
561,
19,
447,
1762,
20,
1476,
2278,
31120,
63,
28392,
63,
475,
8,
1231,
63,
578,
459,
561,
19,
447,
1476,
1105,
272,
925,
3278,
20,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
20,
5144,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1762,
20,
5144,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3278,
22,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
22,
1476,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1762,
22,
1476,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3278,
22,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
22,
1476,
359,
533,
61,
272,
1738,
63,
578,
459,
561,
19,
447,
1762,
22,
1476,
2278,
31120,
63,
28392,
63,
475,
8,
1231,
63,
578,
459,
561,
19,
447,
1476,
1105,
272,
925,
3278,
22,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
22,
4793,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1762,
22,
4793,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
4497,
2006,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447
] |
[
1134,
31297,
492,
5673,
12,
3814,
3034,
17111,
12,
1215,
12,
9151,
12,
7246,
533,
12,
14330,
421,
199,
646,
1134,
31297,
14,
1751,
199,
646,
3598,
199,
199,
533,
4520,
2461,
8,
647,
31297,
14,
1751,
14,
25933,
304,
272,
347,
2429,
63,
705,
8,
277,
12,
4975,
12,
1919,
12,
5190,
7822,
267,
3598,
14,
4050,
480,
1971,
450,
82,
315,
4975,
450,
83,
2,
450,
334,
1971,
12,
4975,
430,
267,
372,
715,
199,
647,
31297,
14,
1751,
14,
705,
63,
2232,
275,
4520,
2461,
342,
421,
199,
646,
984,
199,
199,
318,
859,
63,
826,
837,
272,
1738,
63,
578,
275,
5673,
360,
561,
14,
13213,
297,
7246,
63,
3251,
18749,
26,
561,
19,
358,
272,
372,
1738,
63,
578,
199,
199,
318,
2274,
63,
1313,
8,
578,
304,
272,
1738,
63,
578,
275,
859,
14,
362,
63,
1231,
342,
2286,
925,
2287,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1476,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1476,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
2287,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1476,
447,
4261,
2320,
63,
69,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
4261,
2320,
63,
69,
297,
788,
4283,
63,
4305,
995,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
1476,
995,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
2225,
13,
12708,
13,
513,
14,
72,
334,
578,
283,
1018,
735,
700,
19,
447,
11120,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
11120,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1018,
358,
272,
925,
2225,
13,
12708,
13,
513,
14,
72,
334,
578,
283,
1018,
735,
700,
19,
447,
11120,
447,
2081,
359,
1820,
61,
272,
859,
14,
525,
63,
533,
360,
2081,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1018,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
11120,
1105,
272,
925,
3335,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
3299,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
3299,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3335,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
3299,
447,
3585,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
3585,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
3299,
1105,
272,
925,
3644,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
14420,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
14420,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3644,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
14420,
447,
2081,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
2081,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
14420,
1105,
272,
925,
3696,
13,
1450,
13,
513,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
10499,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
10499,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3696,
13,
1450,
13,
513,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
10499,
447,
3585,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
3585,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
10499,
1105,
272,
925,
3696,
13,
1450,
13,
513,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
10499,
447,
3585,
447,
2081,
359,
1820,
61,
272,
859,
14,
525,
63,
533,
360,
2081,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
297,
6890,
63,
533,
29,
1231,
63,
578,
459,
561,
19,
447,
10499,
447,
3585,
1105,
272,
925,
3233,
14,
72,
334,
578,
283,
1018,
735,
700,
19,
447,
9822,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
9822,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1018,
358,
272,
925,
2631,
14,
72,
334,
578,
283,
1018,
735,
700,
19,
447,
13415,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
13415,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1018,
358,
272,
925,
3278,
20,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
20,
1476,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1762,
20,
1476,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3278,
20,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
20,
1476,
359,
533,
61,
272,
1738,
63,
578,
459,
561,
19,
447,
1762,
20,
1476,
2278,
31120,
63,
28392,
63,
475,
8,
1231,
63,
578,
459,
561,
19,
447,
1476,
1105,
272,
925,
3278,
20,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
20,
5144,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1762,
20,
5144,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3278,
22,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
22,
1476,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1762,
22,
1476,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
3278,
22,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
22,
1476,
359,
533,
61,
272,
1738,
63,
578,
459,
561,
19,
447,
1762,
22,
1476,
2278,
31120,
63,
28392,
63,
475,
8,
1231,
63,
578,
459,
561,
19,
447,
1476,
1105,
272,
925,
3278,
22,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
1762,
22,
4793,
359,
533,
61,
272,
859,
14,
525,
63,
533,
360,
1762,
22,
4793,
297,
492,
63,
504,
63,
578,
534,
561,
14,
1200,
358,
272,
925,
4497,
2006,
13,
1562,
14,
72,
334,
578,
283,
1200,
735,
700,
19,
447,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sgraham/nope
|
third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer_unittest.py
|
45
|
3916
|
# Copyright (C) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import optparse
import unittest
from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.controllers.test_result_writer import write_test_result
from webkitpy.layout_tests.port.driver import DriverOutput
from webkitpy.layout_tests.port.test import TestPort
from webkitpy.layout_tests.models import test_failures
class TestResultWriterTests(unittest.TestCase):
def run_test(self, failures=None, files=None):
failures = failures or []
host = MockSystemHost()
host.filesystem.files = files or {}
port = TestPort(host=host, port_name='test-mac-snowleopard', options=optparse.Values())
actual_output = DriverOutput(text='', image=None, image_hash=None, audio=None)
expected_output = DriverOutput(text='', image=None, image_hash=None, audio=None)
write_test_result(host.filesystem, port, '/tmp', 'foo.html', actual_output, expected_output, failures)
return host.filesystem.written_files
def test_success(self):
# Nothing is written when the test passes.
written_files = self.run_test(failures=[])
self.assertEqual(written_files, {})
def test_reference_exists(self):
failure = test_failures.FailureReftestMismatch()
failure.reference_filename = '/src/exists-expected.html'
files = {'/src/exists-expected.html': 'yup'}
written_files = self.run_test(failures=[failure], files=files)
self.assertEqual(written_files, {'/tmp/exists-expected.html': 'yup'})
failure = test_failures.FailureReftestMismatchDidNotOccur()
failure.reference_filename = '/src/exists-expected-mismatch.html'
files = {'/src/exists-expected-mismatch.html': 'yup'}
written_files = self.run_test(failures=[failure], files=files)
self.assertEqual(written_files, {'/tmp/exists-expected-mismatch.html': 'yup'})
def test_reference_is_missing(self):
failure = test_failures.FailureReftestMismatch()
failure.reference_filename = 'notfound.html'
written_files = self.run_test(failures=[failure], files={})
self.assertEqual(written_files, {})
failure = test_failures.FailureReftestMismatchDidNotOccur()
failure.reference_filename = 'notfound.html'
written_files = self.run_test(failures=[failure], files={})
self.assertEqual(written_files, {})
|
bsd-3-clause
|
[
3,
1898,
334,
35,
9,
6171,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
8691,
199,
646,
2882,
199,
199,
504,
18007,
14,
2330,
14,
2253,
14,
2253,
1102,
63,
1805,
492,
4420,
3989,
4965,
199,
504,
18007,
14,
4209,
63,
2219,
14,
20531,
14,
396,
63,
1099,
63,
5491,
492,
2218,
63,
396,
63,
1099,
199,
504,
18007,
14,
4209,
63,
2219,
14,
719,
14,
3090,
492,
19447,
2959,
199,
504,
18007,
14,
4209,
63,
2219,
14,
719,
14,
396,
492,
1379,
4313,
199,
504,
18007,
14,
4209,
63,
2219,
14,
992,
492,
511,
63,
9968,
421,
199,
533,
23795,
6261,
2925,
8,
2796,
14,
1746,
304,
272,
347,
1255,
63,
396,
8,
277,
12,
9081,
29,
403,
12,
1584,
29,
403,
304,
267,
9081,
275,
9081,
503,
942,
267,
1591,
275,
4420,
3989,
4965,
342,
267,
1591,
14,
11381,
14,
1725,
275,
1584,
503,
1052,
267,
1844,
275,
1379,
4313,
8,
1102,
29,
1102,
12,
1844,
63,
354,
534,
396,
13,
3088,
13,
27765,
274,
411,
1005,
297,
1511,
29,
2992,
1122,
14,
6550,
1012,
267,
3503,
63,
1199,
275,
19447,
2959,
8,
505,
4581,
1834,
29,
403,
12,
1834,
63,
2227,
29,
403,
12,
10491,
29,
403,
9,
267,
1420,
63,
1199,
275,
19447,
2959,
8,
505,
4581,
1834,
29,
403,
12,
1834,
63,
2227,
29,
403,
12,
10491,
29,
403,
9,
267,
2218,
63,
396,
63,
1099,
8,
1102,
14,
11381,
12,
1844,
12,
1994,
2791,
297,
283,
1421,
14,
1360,
297,
3503,
63,
1199,
12,
1420,
63,
1199,
12,
9081,
9,
267,
372,
1591,
14,
11381,
14,
8938,
63,
1725,
339,
347,
511,
63,
3742,
8,
277,
304,
267,
327,
20550,
365,
5313,
1380,
314,
511,
14933,
14,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
14285,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
5009,
339,
347,
511,
63,
4443,
63,
2444,
8,
277,
304,
267,
5988,
275,
511,
63,
9968,
14,
6782,
2891,
396,
23055,
342,
267,
5988,
14,
4443,
63,
1501,
275,
1994,
2164,
15,
2444,
13,
2062,
14,
1360,
7,
267,
1584,
275,
791,
15,
2164,
15,
2444,
13,
2062,
14,
1360,
356,
283,
89,
384,
936,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
1524,
5328,
467,
1584,
29,
1725,
9,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
791,
15,
2791,
15,
2444,
13,
2062,
14,
1360,
356,
283,
89,
384,
3071,
398,
5988,
275,
511,
63,
9968,
14,
6782,
2891,
396,
23055,
17366,
1763,
16184,
895,
342,
267,
5988,
14,
4443,
63,
1501,
275,
1994,
2164,
15,
2444,
13,
2062,
13,
20759,
14,
1360,
7,
267,
1584,
275,
791,
15,
2164,
15,
2444,
13,
2062,
13,
20759,
14,
1360,
356,
283,
89,
384,
936,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
1524,
5328,
467,
1584,
29,
1725,
9,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
791,
15,
2791,
15,
2444,
13,
2062,
13,
20759,
14,
1360,
356,
283,
89,
384,
3071,
339,
347,
511,
63,
4443,
63,
374,
63,
4752,
8,
277,
304,
267,
5988,
275,
511,
63,
9968,
14,
6782,
2891,
396,
23055,
342,
267,
5988,
14,
4443,
63,
1501,
275,
283,
32353,
14,
1360,
7,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
1524,
5328,
467,
1584,
21146,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
5009,
398,
5988,
275,
511,
63,
9968,
14,
6782,
2891,
396,
23055,
17366,
1763,
16184,
895,
342,
267,
5988,
14,
4443,
63,
1501,
275,
283,
32353,
14,
1360,
7,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
1524,
5328,
467,
1584,
21146,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
5009,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
6171,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
8691,
199,
646,
2882,
199,
199,
504,
18007,
14,
2330,
14,
2253,
14,
2253,
1102,
63,
1805,
492,
4420,
3989,
4965,
199,
504,
18007,
14,
4209,
63,
2219,
14,
20531,
14,
396,
63,
1099,
63,
5491,
492,
2218,
63,
396,
63,
1099,
199,
504,
18007,
14,
4209,
63,
2219,
14,
719,
14,
3090,
492,
19447,
2959,
199,
504,
18007,
14,
4209,
63,
2219,
14,
719,
14,
396,
492,
1379,
4313,
199,
504,
18007,
14,
4209,
63,
2219,
14,
992,
492,
511,
63,
9968,
421,
199,
533,
23795,
6261,
2925,
8,
2796,
14,
1746,
304,
272,
347,
1255,
63,
396,
8,
277,
12,
9081,
29,
403,
12,
1584,
29,
403,
304,
267,
9081,
275,
9081,
503,
942,
267,
1591,
275,
4420,
3989,
4965,
342,
267,
1591,
14,
11381,
14,
1725,
275,
1584,
503,
1052,
267,
1844,
275,
1379,
4313,
8,
1102,
29,
1102,
12,
1844,
63,
354,
534,
396,
13,
3088,
13,
27765,
274,
411,
1005,
297,
1511,
29,
2992,
1122,
14,
6550,
1012,
267,
3503,
63,
1199,
275,
19447,
2959,
8,
505,
4581,
1834,
29,
403,
12,
1834,
63,
2227,
29,
403,
12,
10491,
29,
403,
9,
267,
1420,
63,
1199,
275,
19447,
2959,
8,
505,
4581,
1834,
29,
403,
12,
1834,
63,
2227,
29,
403,
12,
10491,
29,
403,
9,
267,
2218,
63,
396,
63,
1099,
8,
1102,
14,
11381,
12,
1844,
12,
1994,
2791,
297,
283,
1421,
14,
1360,
297,
3503,
63,
1199,
12,
1420,
63,
1199,
12,
9081,
9,
267,
372,
1591,
14,
11381,
14,
8938,
63,
1725,
339,
347,
511,
63,
3742,
8,
277,
304,
267,
327,
20550,
365,
5313,
1380,
314,
511,
14933,
14,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
14285,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
5009,
339,
347,
511,
63,
4443,
63,
2444,
8,
277,
304,
267,
5988,
275,
511,
63,
9968,
14,
6782,
2891,
396,
23055,
342,
267,
5988,
14,
4443,
63,
1501,
275,
1994,
2164,
15,
2444,
13,
2062,
14,
1360,
7,
267,
1584,
275,
791,
15,
2164,
15,
2444,
13,
2062,
14,
1360,
356,
283,
89,
384,
936,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
1524,
5328,
467,
1584,
29,
1725,
9,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
791,
15,
2791,
15,
2444,
13,
2062,
14,
1360,
356,
283,
89,
384,
3071,
398,
5988,
275,
511,
63,
9968,
14,
6782,
2891,
396,
23055,
17366,
1763,
16184,
895,
342,
267,
5988,
14,
4443,
63,
1501,
275,
1994,
2164,
15,
2444,
13,
2062,
13,
20759,
14,
1360,
7,
267,
1584,
275,
791,
15,
2164,
15,
2444,
13,
2062,
13,
20759,
14,
1360,
356,
283,
89,
384,
936,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
1524,
5328,
467,
1584,
29,
1725,
9,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
791,
15,
2791,
15,
2444,
13,
2062,
13,
20759,
14,
1360,
356,
283,
89,
384,
3071,
339,
347,
511,
63,
4443,
63,
374,
63,
4752,
8,
277,
304,
267,
5988,
275,
511,
63,
9968,
14,
6782,
2891,
396,
23055,
342,
267,
5988,
14,
4443,
63,
1501,
275,
283,
32353,
14,
1360,
7,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
1524,
5328,
467,
1584,
21146,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
5009,
398,
5988,
275,
511,
63,
9968,
14,
6782,
2891,
396,
23055,
17366,
1763,
16184,
895,
342,
267,
5988,
14,
4443,
63,
1501,
275,
283,
32353,
14,
1360,
7,
267,
5313,
63,
1725,
275,
291,
14,
1065,
63,
396,
8,
9968,
1524,
5328,
467,
1584,
21146,
267,
291,
14,
629,
8,
8938,
63,
1725,
12,
5009,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
avedaee/DIRAC
|
Interfaces/scripts/dirac-admin-add-user.py
|
15
|
2988
|
#!/usr/bin/env python
########################################################################
# $HeadURL$
########################################################################
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script
userName = None
userDN = None
userMail = None
userGroups = []
def setUserName( arg ):
global userName
if userName or not arg:
Script.showHelp()
DIRAC.exit( -1 )
userName = arg
def setUserDN( arg ):
global userDN
if userDN or not arg:
Script.showHelp()
DIRAC.exit( -1 )
userDN = arg
def setUserMail( arg ):
global userMail
if userMail or not arg:
Script.showHelp()
DIRAC.exit( -1 )
if not arg.find( '@' ) > 0:
Script.gLogger.error( 'Not a valid mail address', arg )
DIRAC.exit( -1 )
userMail = arg
def addUserGroup( arg ):
global userGroups
if not arg:
Script.showHelp()
DIRAC.exit( -1 )
if not arg in userGroups:
userGroups.append( arg )
Script.setUsageMessage( '\n'.join( ['Add or Modify a User info in DIRAC',
'Usage:',
'%s [option|cfgfile] ... Property=<Value> ...' % Script.scriptName,
'Arguments:',
' Property=<Value>: Properties to be added to the User like (Phone=XXXX)', ] ) )
Script.registerSwitch( 'N:', 'UserName:', 'Short Name of the User (Mandatory)', setUserName )
Script.registerSwitch( 'D:', 'UserDN:', 'DN of the User Certificate (Mandatory)', setUserDN )
Script.registerSwitch( 'M:', 'UserMail:', 'eMail of the user (Mandatory)', setUserMail )
Script.registerSwitch( 'G:', 'UserGroup:', 'Name of the Group for the User (Allow Multiple instances or None)', addUserGroup )
Script.parseCommandLine( ignoreErrors = True )
if userName == None or userDN == None or userMail == None:
Script.showHelp()
DIRAC.exit( -1 )
args = Script.getPositionalArgs()
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
diracAdmin = DiracAdmin()
exitCode = 0
errorList = []
userProps = {'DN': userDN, 'Email': userMail}
if userGroups:
userProps['Groups' ] = userGroups
for prop in args:
pl = prop.split( "=" )
if len( pl ) < 2:
errorList.append( ( "in arguments", "Property %s has to include a '=' to separate name from value" % prop ) )
exitCode = 255
else:
pName = pl[0]
pValue = "=".join( pl[1:] )
Script.gLogger.info( "Setting property %s to %s" % ( pName, pValue ) )
userProps[ pName ] = pValue
if not diracAdmin.csModifyUser( userName, userProps, createIfNonExistant = True )['OK']:
errorList.append( ( "add user", "Cannot register user %s" % userName ) )
exitCode = 255
else:
result = diracAdmin.csCommitChanges()
if not result[ 'OK' ]:
errorList.append( ( "commit", result[ 'Message' ] ) )
exitCode = 255
for error in errorList:
Script.gLogger.error( "%s: %s" % error )
DIRAC.exit( exitCode )
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3949,
199,
3,
2672,
11664,
2632,
4,
199,
3949,
199,
363,
50,
3298,
998,
363,
275,
7880,
1304,
17351,
199,
646,
26565,
199,
504,
26565,
14,
5402,
14,
1563,
15530,
492,
14914,
199,
199,
751,
985,
275,
488,
199,
751,
10872,
275,
488,
199,
751,
13681,
275,
488,
199,
751,
10177,
275,
942,
199,
199,
318,
663,
25108,
8,
1680,
3461,
523,
2288,
922,
985,
523,
340,
922,
985,
503,
440,
1680,
26,
272,
14914,
14,
2384,
8673,
342,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
922,
985,
275,
1680,
199,
199,
318,
663,
1899,
10872,
8,
1680,
3461,
523,
2288,
922,
10872,
523,
340,
922,
10872,
503,
440,
1680,
26,
272,
14914,
14,
2384,
8673,
342,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
922,
10872,
275,
1680,
199,
199,
318,
663,
1899,
13681,
8,
1680,
3461,
523,
2288,
922,
13681,
523,
340,
922,
13681,
503,
440,
1680,
26,
272,
14914,
14,
2384,
8673,
342,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
340,
440,
1680,
14,
1623,
8,
22143,
776,
690,
378,
26,
272,
14914,
14,
71,
4455,
14,
705,
8,
283,
1763,
282,
1686,
6016,
2287,
297,
1680,
776,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
922,
13681,
275,
1680,
199,
199,
318,
1050,
1899,
2448,
8,
1680,
3461,
523,
2288,
922,
10177,
523,
340,
440,
1680,
26,
272,
14914,
14,
2384,
8673,
342,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
340,
440,
1680,
315,
922,
10177,
26,
272,
922,
10177,
14,
740,
8,
1680,
776,
199,
199,
5229,
14,
409,
7692,
2209,
8,
1557,
78,
1370,
904,
8,
788,
1123,
503,
22520,
282,
2876,
2256,
315,
26565,
297,
2511,
283,
7692,
6536,
2511,
1543,
83,
359,
1422,
92,
4128,
493,
61,
2263,
16158,
18987,
1110,
30,
2263,
7,
450,
14914,
14,
1579,
985,
12,
2511,
283,
14517,
6536,
2511,
283,
16158,
18987,
1110,
20020,
19329,
370,
506,
3483,
370,
314,
2876,
2839,
334,
15199,
29,
6873,
3196,
1622,
776,
776,
199,
199,
5229,
14,
2683,
10167,
8,
283,
46,
6536,
283,
25108,
6536,
283,
10039,
2812,
402,
314,
2876,
334,
45,
13530,
3196,
663,
25108,
776,
199,
5229,
14,
2683,
10167,
8,
283,
36,
6536,
283,
1899,
10872,
6536,
283,
10872,
402,
314,
2876,
12904,
334,
45,
13530,
3196,
663,
1899,
10872,
776,
199,
5229,
14,
2683,
10167,
8,
283,
45,
6536,
283,
1899,
13681,
6536,
283,
69,
13681,
402,
314,
922,
334,
45,
13530,
3196,
663,
1899,
13681,
776,
199,
5229,
14,
2683,
10167,
8,
283,
39,
6536,
283,
1899,
2448,
6536,
283,
985,
402,
314,
5611,
367,
314,
2876,
334,
7852,
14326,
4454,
503,
488,
3196,
1050,
1899,
2448,
776,
199,
199,
5229,
14,
1122,
16926,
8,
3686,
9298,
275,
715,
776,
199,
199,
692,
922,
985,
508,
488,
503,
922,
10872,
508,
488,
503,
922,
13681,
508,
488,
26,
523,
14914,
14,
2384,
8673,
342,
523,
26565,
14,
2224,
8,
446,
17,
776,
199,
199,
589,
275,
14914,
14,
362,
5625,
279,
6213,
342,
199,
199,
504,
26565,
14,
18680,
14,
3735,
14,
1341,
6457,
4880,
12793,
492,
3757,
6457,
4880,
199,
328,
6457,
4880,
275,
3757,
6457,
4880,
342,
199,
2224,
3034,
275,
378,
199,
705,
1296,
275,
942,
199,
199,
751,
24188,
275,
791,
10872,
356,
922,
10872,
12,
283,
7035,
356,
922,
13681,
93,
199,
692,
922,
10177,
26,
523,
922,
24188,
459,
10177,
7,
1622,
275,
922,
10177,
199,
509,
5931,
315,
1249,
26,
523,
1620,
275,
5931,
14,
1294,
8,
22250,
776,
523,
340,
822,
8,
1620,
776,
665,
499,
26,
272,
1125,
1296,
14,
740,
8,
334,
298,
262,
2368,
401,
298,
3697,
450,
83,
965,
370,
2387,
282,
14051,
370,
7396,
536,
687,
574,
2,
450,
5931,
776,
776,
272,
4458,
3034,
275,
5450,
523,
587,
26,
272,
299,
985,
275,
1620,
59,
16,
61,
272,
299,
1110,
275,
22250,
14,
904,
8,
1620,
59,
17,
2938,
776,
272,
14914,
14,
71,
4455,
14,
815,
8,
298,
7776,
3324,
450,
83,
370,
450,
83,
2,
450,
334,
299,
985,
12,
299,
1110,
776,
776,
272,
922,
24188,
59,
299,
985,
1622,
275,
299,
1110,
199,
199,
692,
440,
487,
6457,
4880,
14,
1259,
18357,
1899,
8,
922,
985,
12,
922,
24188,
12,
1218,
3917,
6932,
6439,
867,
275,
715,
776,
459,
3593,
2565,
523,
1125,
1296,
14,
740,
8,
334,
298,
525,
922,
401,
298,
6612,
2274,
922,
450,
83,
2,
450,
922,
985,
776,
776,
523,
4458,
3034,
275,
5450,
199,
2836,
26,
523,
754,
275,
487,
6457,
4880,
14,
1259,
11421,
13907,
342,
523,
340,
440,
754,
59,
283,
3593,
7,
16246,
272,
1125,
1296,
14,
740,
8,
334,
298,
3543,
401,
754,
59,
283,
2209,
7,
1622,
776,
776,
272,
4458,
3034,
275,
5450,
199,
199,
509,
1125,
315,
1125,
1296,
26,
523,
14914,
14,
71,
4455,
14,
705,
8,
2071,
83,
26,
450,
83,
2,
450,
1125,
776,
199,
199,
3022,
1348,
14,
2224,
8,
4458,
3034,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3949,
199,
3,
2672,
11664,
2632,
4,
199,
3949,
199,
363,
50,
3298,
998,
363,
275,
7880,
1304,
17351,
199,
646,
26565,
199,
504,
26565,
14,
5402,
14,
1563,
15530,
492,
14914,
199,
199,
751,
985,
275,
488,
199,
751,
10872,
275,
488,
199,
751,
13681,
275,
488,
199,
751,
10177,
275,
942,
199,
199,
318,
663,
25108,
8,
1680,
3461,
523,
2288,
922,
985,
523,
340,
922,
985,
503,
440,
1680,
26,
272,
14914,
14,
2384,
8673,
342,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
922,
985,
275,
1680,
199,
199,
318,
663,
1899,
10872,
8,
1680,
3461,
523,
2288,
922,
10872,
523,
340,
922,
10872,
503,
440,
1680,
26,
272,
14914,
14,
2384,
8673,
342,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
922,
10872,
275,
1680,
199,
199,
318,
663,
1899,
13681,
8,
1680,
3461,
523,
2288,
922,
13681,
523,
340,
922,
13681,
503,
440,
1680,
26,
272,
14914,
14,
2384,
8673,
342,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
340,
440,
1680,
14,
1623,
8,
22143,
776,
690,
378,
26,
272,
14914,
14,
71,
4455,
14,
705,
8,
283,
1763,
282,
1686,
6016,
2287,
297,
1680,
776,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
922,
13681,
275,
1680,
199,
199,
318,
1050,
1899,
2448,
8,
1680,
3461,
523,
2288,
922,
10177,
523,
340,
440,
1680,
26,
272,
14914,
14,
2384,
8673,
342,
272,
26565,
14,
2224,
8,
446,
17,
776,
523,
340,
440,
1680,
315,
922,
10177,
26,
272,
922,
10177,
14,
740,
8,
1680,
776,
199,
199,
5229,
14,
409,
7692,
2209,
8,
1557,
78,
1370,
904,
8,
788,
1123,
503,
22520,
282,
2876,
2256,
315,
26565,
297,
2511,
283,
7692,
6536,
2511,
1543,
83,
359,
1422,
92,
4128,
493,
61,
2263,
16158,
18987,
1110,
30,
2263,
7,
450,
14914,
14,
1579,
985,
12,
2511,
283,
14517,
6536,
2511,
283,
16158,
18987,
1110,
20020,
19329,
370,
506,
3483,
370,
314,
2876,
2839,
334,
15199,
29,
6873,
3196,
1622,
776,
776,
199,
199,
5229,
14,
2683,
10167,
8,
283,
46,
6536,
283,
25108,
6536,
283,
10039,
2812,
402,
314,
2876,
334,
45,
13530,
3196,
663,
25108,
776,
199,
5229,
14,
2683,
10167,
8,
283,
36,
6536,
283,
1899,
10872,
6536,
283,
10872,
402,
314,
2876,
12904,
334,
45,
13530,
3196,
663,
1899,
10872,
776,
199,
5229,
14,
2683,
10167,
8,
283,
45,
6536,
283,
1899,
13681,
6536,
283,
69,
13681,
402,
314,
922,
334,
45,
13530,
3196,
663,
1899,
13681,
776,
199,
5229,
14,
2683,
10167,
8,
283,
39,
6536,
283,
1899,
2448,
6536,
283,
985,
402,
314,
5611,
367,
314,
2876,
334,
7852,
14326,
4454,
503,
488,
3196,
1050,
1899,
2448,
776,
199,
199,
5229,
14,
1122,
16926,
8,
3686,
9298,
275,
715,
776,
199,
199,
692,
922,
985,
508,
488,
503,
922,
10872,
508,
488,
503,
922,
13681,
508,
488,
26,
523,
14914,
14,
2384,
8673,
342,
523,
26565,
14,
2224,
8,
446,
17,
776,
199,
199,
589,
275,
14914,
14,
362,
5625,
279,
6213,
342,
199,
199,
504,
26565,
14,
18680,
14,
3735,
14,
1341,
6457,
4880,
12793,
492,
3757,
6457,
4880,
199,
328,
6457,
4880,
275,
3757,
6457,
4880,
342,
199,
2224,
3034,
275,
378,
199,
705,
1296,
275,
942,
199,
199,
751,
24188,
275,
791,
10872,
356,
922,
10872,
12,
283,
7035,
356,
922,
13681,
93,
199,
692,
922,
10177,
26,
523,
922,
24188,
459,
10177,
7,
1622,
275,
922,
10177,
199,
509,
5931,
315,
1249,
26,
523,
1620,
275,
5931,
14,
1294,
8,
22250,
776,
523,
340,
822,
8,
1620,
776,
665,
499,
26,
272,
1125,
1296,
14,
740,
8,
334,
298,
262,
2368,
401,
298,
3697,
450,
83,
965,
370,
2387,
282,
14051,
370,
7396,
536,
687,
574,
2,
450,
5931,
776,
776,
272,
4458,
3034,
275,
5450,
523,
587,
26,
272,
299,
985,
275,
1620,
59,
16,
61,
272,
299,
1110,
275,
22250,
14,
904,
8,
1620,
59,
17,
2938,
776,
272,
14914,
14,
71,
4455,
14,
815,
8,
298,
7776,
3324,
450,
83,
370,
450,
83,
2,
450,
334,
299,
985,
12,
299,
1110,
776,
776,
272,
922,
24188,
59,
299,
985,
1622,
275,
299,
1110,
199,
199,
692,
440,
487,
6457,
4880,
14,
1259,
18357,
1899,
8,
922,
985,
12,
922,
24188,
12,
1218,
3917,
6932,
6439,
867,
275,
715,
776,
459,
3593,
2565,
523,
1125,
1296,
14,
740,
8,
334,
298,
525,
922,
401,
298,
6612,
2274,
922,
450,
83,
2,
450,
922,
985,
776,
776,
523,
4458,
3034,
275,
5450,
199,
2836,
26,
523,
754,
275,
487,
6457,
4880,
14,
1259,
11421,
13907,
342,
523,
340,
440,
754,
59,
283,
3593,
7,
16246,
272,
1125,
1296,
14,
740,
8,
334,
298,
3543,
401,
754,
59,
283,
2209,
7,
1622,
776,
776,
272,
4458,
3034,
275,
5450,
199,
199,
509,
1125,
315,
1125,
1296,
26,
523,
14914,
14,
71,
4455,
14,
705,
8,
2071,
83,
26,
450,
83,
2,
450,
1125,
776,
199,
199,
3022,
1348,
14,
2224,
8,
4458,
3034,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
leighpauls/k2cro4
|
native_client_sdk/src/build_tools/sdk_tools/sdk_update_main.py
|
2
|
11039
|
#!/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.
# CMD code copied from git_cl.py in depot_tools.
import config
import cStringIO
import download
import json
import logging
import optparse
import os
import re
import sdk_update_common
from sdk_update_common import Error
import sys
import urllib2
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
PARENT_DIR = os.path.dirname(SCRIPT_DIR)
sys.path.append(os.path.dirname(SCRIPT_DIR))
import manifest_util
# Import late so each command script can find our imports
import command.info
import command.list
import command.sources
import command.update
# This revision number is autogenerated from the Chrome revision.
REVISION = '{REVISION}'
GSTORE_URL = 'https://commondatastorage.googleapis.com/nativeclient-mirror'
CONFIG_FILENAME = 'naclsdk_config.json'
MANIFEST_FILENAME = 'naclsdk_manifest2.json'
DEFAULT_SDK_ROOT = os.path.abspath(PARENT_DIR)
USER_DATA_DIR = os.path.join(DEFAULT_SDK_ROOT, 'sdk_cache')
def usage(more):
def hook(fn):
fn.usage_more = more
return fn
return hook
def hide(fn):
fn.hide = True
return fn
def LoadConfig(raise_on_error=False):
path = os.path.join(USER_DATA_DIR, CONFIG_FILENAME)
if not os.path.exists(path):
return config.Config()
try:
try:
with open(path) as f:
return config.Config(json.loads(f.read()))
except IOError as e:
raise Error('Unable to read config from "%s".\n %s' % (path, e))
except Exception as e:
raise Error('Parsing config file from "%s" failed.\n %s' % (path, e))
except Error as e:
if raise_on_error:
raise
else:
logging.warn(str(e))
return config.Config()
def WriteConfig(cfg):
path = os.path.join(USER_DATA_DIR, CONFIG_FILENAME)
try:
sdk_update_common.MakeDirs(USER_DATA_DIR)
except Exception as e:
raise Error('Unable to create directory "%s".\n %s' % (USER_DATA_DIR, e))
try:
cfg_json = cfg.ToJson()
except Exception as e:
raise Error('Json encoding error writing config "%s".\n %s' % (path, e))
try:
with open(path, 'w') as f:
f.write(cfg_json)
except IOError as e:
raise Error('Unable to write config to "%s".\n %s' % (path, e))
def LoadLocalManifest(raise_on_error=False):
path = os.path.join(USER_DATA_DIR, MANIFEST_FILENAME)
manifest = manifest_util.SDKManifest()
try:
try:
with open(path) as f:
manifest_string = f.read()
except IOError as e:
raise Error('Unable to read manifest from "%s".\n %s' % (path, e))
try:
manifest.LoadDataFromString(manifest_string)
except Exception as e:
raise Error('Parsing local manifest "%s" failed.\n %s' % (path, e))
except Error as e:
if raise_on_error:
raise
else:
logging.warn(str(e))
return manifest
def WriteLocalManifest(manifest):
path = os.path.join(USER_DATA_DIR, MANIFEST_FILENAME)
try:
sdk_update_common.MakeDirs(USER_DATA_DIR)
except Exception as e:
raise Error('Unable to create directory "%s".\n %s' % (USER_DATA_DIR, e))
try:
manifest_json = manifest.GetDataAsString()
except Exception as e:
raise Error('Error encoding manifest "%s" to JSON.\n %s' % (path, e))
try:
with open(path, 'w') as f:
f.write(manifest_json)
except IOError as e:
raise Error('Unable to write manifest to "%s".\n %s' % (path, e))
def LoadRemoteManifest(url):
manifest = manifest_util.SDKManifest()
url_stream = None
try:
manifest_stream = cStringIO.StringIO()
url_stream = download.UrlOpen(url)
download.DownloadAndComputeHash(url_stream, manifest_stream)
except urllib2.URLError as e:
raise Error('Unable to read remote manifest from URL "%s".\n %s' % (
url, e))
finally:
if url_stream:
url_stream.close()
try:
manifest.LoadDataFromString(manifest_stream.getvalue())
return manifest
except manifest_util.Error as e:
raise Error('Parsing remote manifest from URL "%s" failed.\n %s' % (
url, e,))
def LoadCombinedRemoteManifest(default_manifest_url, cfg):
manifest = LoadRemoteManifest(default_manifest_url)
for source in cfg.sources:
manifest.MergeManifest(LoadRemoteManifest(source))
return manifest
# Commands #####################################################################
@usage('<bundle names...>')
def CMDinfo(parser, args):
"""display information about a bundle"""
options, args = parser.parse_args(args)
if len(args) == 0:
parser.error('No bundles given')
return 0
cfg = LoadConfig()
remote_manifest = LoadCombinedRemoteManifest(options.manifest_url, cfg)
command.info.Info(remote_manifest, args)
return 0
def CMDlist(parser, args):
"""list all available bundles"""
parser.add_option('-r', '--revision', action='store_true',
help='display revision numbers')
options, args = parser.parse_args(args)
if args:
parser.error('Unsupported argument(s): %s' % ', '.join(args))
local_manifest = LoadLocalManifest()
cfg = LoadConfig()
remote_manifest = LoadCombinedRemoteManifest(options.manifest_url, cfg)
command.list.List(remote_manifest, local_manifest, options.revision)
return 0
@usage('<bundle names...>')
def CMDupdate(parser, args):
"""update a bundle in the SDK to the latest version"""
parser.add_option(
'-F', '--force', action='store_true',
help='Force updating existing components that already exist')
options, args = parser.parse_args(args)
local_manifest = LoadLocalManifest()
cfg = LoadConfig()
remote_manifest = LoadCombinedRemoteManifest(options.manifest_url, cfg)
if not args:
args = [command.update.RECOMMENDED]
try:
delegate = command.update.RealUpdateDelegate(USER_DATA_DIR,
DEFAULT_SDK_ROOT)
command.update.Update(delegate, remote_manifest, local_manifest, args,
options.force)
finally:
# Always write out the local manifest, we may have successfully updated one
# or more bundles before failing.
try:
WriteLocalManifest(local_manifest)
except Error as e:
# Log the error writing to the manifest, but propagate the original
# exception.
logging.error(str(e))
return 0
def CMDinstall(parser, args):
"""install a bundle in the SDK"""
# For now, forward to CMDupdate. We may want different behavior for this
# in the future, though...
return CMDupdate(parser, args)
def CMDsources(parser, args):
"""manage external package sources"""
parser.add_option('-a', '--add', dest='url_to_add',
help='Add an additional package source')
parser.add_option(
'-r', '--remove', dest='url_to_remove',
help='Remove package source (use \'all\' for all additional sources)')
parser.add_option('-l', '--list', dest='do_list', action='store_true',
help='List additional package sources')
options, args = parser.parse_args(args)
cfg = LoadConfig(True)
write_config = False
if options.url_to_add:
command.sources.AddSource(cfg, options.url_to_add)
write_config = True
elif options.url_to_remove:
command.sources.RemoveSource(cfg, options.url_to_remove)
write_config = True
elif options.do_list:
command.sources.ListSources(cfg)
else:
parser.print_help()
if write_config:
WriteConfig(cfg)
return 0
def CMDversion(parser, args):
"""display version information"""
_, _ = parser.parse_args(args)
print "Native Client SDK Updater, version r%s" % REVISION
return 0
def CMDhelp(parser, args):
"""print list of commands or help for a specific command"""
_, args = parser.parse_args(args)
if len(args) == 1:
return main(args + ['--help'])
parser.print_help()
return 0
def Command(name):
return globals().get('CMD' + name, None)
def GenUsage(parser, cmd):
"""Modify an OptParse object with the function's documentation."""
obj = Command(cmd)
more = getattr(obj, 'usage_more', '')
if cmd == 'help':
cmd = '<command>'
else:
# OptParser.description prefer nicely non-formatted strings.
parser.description = re.sub('[\r\n ]{2,}', ' ', obj.__doc__)
parser.set_usage('usage: %%prog %s [options] %s' % (cmd, more))
def UpdateSDKTools(options, args):
"""update the sdk_tools bundle"""
local_manifest = LoadLocalManifest()
cfg = LoadConfig()
remote_manifest = LoadCombinedRemoteManifest(options.manifest_url, cfg)
try:
delegate = command.update.RealUpdateDelegate(USER_DATA_DIR,
DEFAULT_SDK_ROOT)
command.update.UpdateBundleIfNeeded(
delegate,
remote_manifest,
local_manifest,
command.update.SDK_TOOLS,
force=True)
finally:
# Always write out the local manifest, we may have successfully updated one
# or more bundles before failing.
WriteLocalManifest(local_manifest)
return 0
def main(argv):
# Get all commands...
cmds = [fn[3:] for fn in dir(sys.modules[__name__]) if fn.startswith('CMD')]
# Remove hidden commands...
cmds = filter(lambda fn: not getattr(Command(fn), 'hide', 0), cmds)
# Format for CMDhelp usage.
CMDhelp.usage_more = ('\n\nCommands are:\n' + '\n'.join([
' %-10s %s' % (fn, Command(fn).__doc__.split('\n')[0].strip())
for fn in cmds]))
# Create the option parse and add --verbose support.
parser = optparse.OptionParser()
parser.add_option(
'-v', '--verbose', action='count', default=0,
help='Use 2 times for more debugging info')
parser.add_option('-U', '--manifest-url', dest='manifest_url',
default=GSTORE_URL + '/nacl/nacl_sdk/' + MANIFEST_FILENAME,
metavar='URL', help='override the default URL for the NaCl manifest file')
parser.add_option('--update-sdk-tools', action='store_true',
dest='update_sdk_tools', help=optparse.SUPPRESS_HELP)
old_parser_args = parser.parse_args
def Parse(args):
options, args = old_parser_args(args)
if options.verbose >= 2:
loglevel = logging.DEBUG
elif options.verbose:
loglevel = logging.INFO
else:
loglevel = logging.WARNING
fmt = '%(levelname)s:%(message)s'
logging.basicConfig(stream=sys.stdout, level=loglevel, format=fmt)
# If --update-sdk-tools is passed, circumvent any other command running.
if options.update_sdk_tools:
UpdateSDKTools(options, args)
sys.exit(1)
return options, args
parser.parse_args = Parse
if argv:
cmd = Command(argv[0])
if cmd:
# "fix" the usage and the description now that we know the subcommand.
GenUsage(parser, argv[0])
return cmd(parser, argv[1:])
# Not a known command. Default to help.
GenUsage(parser, 'help')
return CMDhelp(parser, argv)
if __name__ == '__main__':
try:
sys.exit(main(sys.argv[1:]))
except Error as e:
logging.error(str(e))
sys.exit(1)
|
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,
3,
25548,
1233,
8876,
687,
6135,
63,
429,
14,
647,
315,
32544,
63,
2537,
14,
199,
199,
646,
1101,
199,
646,
15073,
199,
646,
5235,
199,
646,
2022,
199,
646,
2050,
199,
646,
8691,
199,
646,
747,
199,
646,
295,
199,
646,
13628,
63,
873,
63,
2330,
199,
504,
13628,
63,
873,
63,
2330,
492,
4520,
199,
646,
984,
199,
646,
4011,
18,
199,
199,
10484,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
199,
20562,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
10484,
63,
3022,
9,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
3475,
8,
10484,
63,
3022,
430,
199,
646,
7712,
63,
1974,
421,
199,
3,
3161,
2465,
880,
1924,
1414,
2884,
883,
2342,
4154,
8925,
199,
646,
1414,
14,
815,
199,
646,
1414,
14,
513,
199,
646,
1414,
14,
4553,
199,
646,
1414,
14,
873,
199,
199,
3,
961,
6974,
1329,
365,
18392,
687,
314,
16776,
6974,
14,
199,
907,
18775,
275,
5041,
907,
18775,
6834,
199,
199,
39,
16169,
63,
2632,
275,
283,
2859,
921,
2330,
576,
3494,
14,
17533,
14,
957,
15,
6106,
1258,
13,
12324,
7,
199,
5569,
63,
15440,
275,
283,
3540,
1886,
6341,
63,
888,
14,
1001,
7,
199,
24067,
63,
15440,
275,
283,
3540,
1886,
6341,
63,
6418,
18,
14,
1001,
7,
199,
3472,
63,
14939,
63,
5441,
275,
747,
14,
515,
14,
4832,
8,
20562,
63,
3022,
9,
199,
3791,
63,
3998,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
3472,
63,
14939,
63,
5441,
12,
283,
9277,
63,
1637,
358,
421,
199,
318,
4503,
8,
6878,
304,
523,
347,
5759,
8,
2324,
304,
272,
4325,
14,
3807,
63,
6878,
275,
1655,
272,
372,
4325,
523,
372,
5759,
421,
199,
318,
13714,
8,
2324,
304,
523,
4325,
14,
8191,
275,
715,
523,
372,
4325,
421,
199,
318,
7190,
2028,
8,
3730,
63,
265,
63,
705,
29,
797,
304,
523,
931,
275,
747,
14,
515,
14,
904,
8,
3791,
63,
3998,
63,
3022,
12,
15869,
63,
15440,
9,
523,
340,
440,
747,
14,
515,
14,
2444,
8,
515,
304,
272,
372,
1101,
14,
2028,
342,
819,
862,
26,
272,
862,
26,
489,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
372,
1101,
14,
2028,
8,
1001,
14,
3640,
8,
70,
14,
739,
4059,
272,
871,
5925,
465,
325,
26,
489,
746,
4520,
360,
6005,
370,
1586,
1101,
687,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
272,
871,
2186,
465,
325,
26,
489,
746,
4520,
360,
17412,
1101,
570,
687,
2071,
83,
2,
3405,
3134,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
523,
871,
4520,
465,
325,
26,
272,
340,
746,
63,
265,
63,
705,
26,
489,
746,
272,
587,
26,
489,
2050,
14,
4050,
8,
495,
8,
69,
430,
523,
372,
1101,
14,
2028,
342,
421,
199,
318,
6990,
2028,
8,
4128,
304,
523,
931,
275,
747,
14,
515,
14,
904,
8,
3791,
63,
3998,
63,
3022,
12,
15869,
63,
15440,
9,
523,
862,
26,
272,
13628,
63,
873,
63,
2330,
14,
5483,
17051,
8,
3791,
63,
3998,
63,
3022,
9,
523,
871,
2186,
465,
325,
26,
272,
746,
4520,
360,
6005,
370,
1218,
2082,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
3791,
63,
3998,
63,
3022,
12,
325,
430,
819,
862,
26,
272,
4810,
63,
1001,
275,
4810,
14,
1378,
9653,
342,
523,
871,
2186,
465,
325,
26,
272,
746,
4520,
360,
9653,
2644,
1125,
3575,
1101,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
819,
862,
26,
272,
543,
1551,
8,
515,
12,
283,
87,
358,
465,
289,
26,
489,
289,
14,
952,
8,
4128,
63,
1001,
9,
523,
871,
5925,
465,
325,
26,
272,
746,
4520,
360,
6005,
370,
2218,
1101,
370,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
421,
199,
318,
7190,
5339,
11038,
8,
3730,
63,
265,
63,
705,
29,
797,
304,
523,
931,
275,
747,
14,
515,
14,
904,
8,
3791,
63,
3998,
63,
3022,
12,
26688,
20649,
63,
15440,
9,
523,
7712,
275,
7712,
63,
1974,
14,
14939,
11038,
342,
523,
862,
26,
272,
862,
26,
489,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
7712,
63,
875,
275,
289,
14,
739,
342,
272,
871,
5925,
465,
325,
26,
489,
746,
4520,
360,
6005,
370,
1586,
7712,
687,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
339,
862,
26,
489,
7712,
14,
6200,
1451,
7671,
8,
6418,
63,
875,
9,
272,
871,
2186,
465,
325,
26,
489,
746,
4520,
360,
17412,
2257,
7712,
2071,
83,
2,
3405,
3134,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
523,
871,
4520,
465,
325,
26,
272,
340,
746,
63,
265,
63,
705,
26,
489,
746,
272,
587,
26,
489,
2050,
14,
4050,
8,
495,
8,
69,
430,
523,
372,
7712,
421,
199,
318,
6990,
5339,
11038,
8,
6418,
304,
523,
931,
275,
747,
14,
515,
14,
904,
8,
3791,
63,
3998,
63,
3022,
12,
26688,
20649,
63,
15440,
9,
523,
862,
26,
272,
13628,
63,
873,
63,
2330,
14,
5483,
17051,
8,
3791,
63,
3998,
63,
3022,
9,
523,
871,
2186,
465,
325,
26,
272,
746,
4520,
360,
6005,
370,
1218,
2082,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
3791,
63,
3998,
63,
3022,
12,
325,
430,
819,
862,
26,
272,
7712,
63,
1001,
275,
7712,
14,
25702,
2822,
1558,
342,
523,
871,
2186,
465,
325,
26,
272,
746,
4520,
360,
547,
2644,
7712,
2071,
83,
2,
370,
4840,
3134,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
819,
862,
26,
272,
543,
1551,
8,
515,
12,
283,
87,
358,
465,
289,
26,
489
] |
[
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,
3,
25548,
1233,
8876,
687,
6135,
63,
429,
14,
647,
315,
32544,
63,
2537,
14,
199,
199,
646,
1101,
199,
646,
15073,
199,
646,
5235,
199,
646,
2022,
199,
646,
2050,
199,
646,
8691,
199,
646,
747,
199,
646,
295,
199,
646,
13628,
63,
873,
63,
2330,
199,
504,
13628,
63,
873,
63,
2330,
492,
4520,
199,
646,
984,
199,
646,
4011,
18,
199,
199,
10484,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
199,
20562,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
10484,
63,
3022,
9,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
3475,
8,
10484,
63,
3022,
430,
199,
646,
7712,
63,
1974,
421,
199,
3,
3161,
2465,
880,
1924,
1414,
2884,
883,
2342,
4154,
8925,
199,
646,
1414,
14,
815,
199,
646,
1414,
14,
513,
199,
646,
1414,
14,
4553,
199,
646,
1414,
14,
873,
199,
199,
3,
961,
6974,
1329,
365,
18392,
687,
314,
16776,
6974,
14,
199,
907,
18775,
275,
5041,
907,
18775,
6834,
199,
199,
39,
16169,
63,
2632,
275,
283,
2859,
921,
2330,
576,
3494,
14,
17533,
14,
957,
15,
6106,
1258,
13,
12324,
7,
199,
5569,
63,
15440,
275,
283,
3540,
1886,
6341,
63,
888,
14,
1001,
7,
199,
24067,
63,
15440,
275,
283,
3540,
1886,
6341,
63,
6418,
18,
14,
1001,
7,
199,
3472,
63,
14939,
63,
5441,
275,
747,
14,
515,
14,
4832,
8,
20562,
63,
3022,
9,
199,
3791,
63,
3998,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
3472,
63,
14939,
63,
5441,
12,
283,
9277,
63,
1637,
358,
421,
199,
318,
4503,
8,
6878,
304,
523,
347,
5759,
8,
2324,
304,
272,
4325,
14,
3807,
63,
6878,
275,
1655,
272,
372,
4325,
523,
372,
5759,
421,
199,
318,
13714,
8,
2324,
304,
523,
4325,
14,
8191,
275,
715,
523,
372,
4325,
421,
199,
318,
7190,
2028,
8,
3730,
63,
265,
63,
705,
29,
797,
304,
523,
931,
275,
747,
14,
515,
14,
904,
8,
3791,
63,
3998,
63,
3022,
12,
15869,
63,
15440,
9,
523,
340,
440,
747,
14,
515,
14,
2444,
8,
515,
304,
272,
372,
1101,
14,
2028,
342,
819,
862,
26,
272,
862,
26,
489,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
372,
1101,
14,
2028,
8,
1001,
14,
3640,
8,
70,
14,
739,
4059,
272,
871,
5925,
465,
325,
26,
489,
746,
4520,
360,
6005,
370,
1586,
1101,
687,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
272,
871,
2186,
465,
325,
26,
489,
746,
4520,
360,
17412,
1101,
570,
687,
2071,
83,
2,
3405,
3134,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
523,
871,
4520,
465,
325,
26,
272,
340,
746,
63,
265,
63,
705,
26,
489,
746,
272,
587,
26,
489,
2050,
14,
4050,
8,
495,
8,
69,
430,
523,
372,
1101,
14,
2028,
342,
421,
199,
318,
6990,
2028,
8,
4128,
304,
523,
931,
275,
747,
14,
515,
14,
904,
8,
3791,
63,
3998,
63,
3022,
12,
15869,
63,
15440,
9,
523,
862,
26,
272,
13628,
63,
873,
63,
2330,
14,
5483,
17051,
8,
3791,
63,
3998,
63,
3022,
9,
523,
871,
2186,
465,
325,
26,
272,
746,
4520,
360,
6005,
370,
1218,
2082,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
3791,
63,
3998,
63,
3022,
12,
325,
430,
819,
862,
26,
272,
4810,
63,
1001,
275,
4810,
14,
1378,
9653,
342,
523,
871,
2186,
465,
325,
26,
272,
746,
4520,
360,
9653,
2644,
1125,
3575,
1101,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
819,
862,
26,
272,
543,
1551,
8,
515,
12,
283,
87,
358,
465,
289,
26,
489,
289,
14,
952,
8,
4128,
63,
1001,
9,
523,
871,
5925,
465,
325,
26,
272,
746,
4520,
360,
6005,
370,
2218,
1101,
370,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
421,
199,
318,
7190,
5339,
11038,
8,
3730,
63,
265,
63,
705,
29,
797,
304,
523,
931,
275,
747,
14,
515,
14,
904,
8,
3791,
63,
3998,
63,
3022,
12,
26688,
20649,
63,
15440,
9,
523,
7712,
275,
7712,
63,
1974,
14,
14939,
11038,
342,
523,
862,
26,
272,
862,
26,
489,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
7712,
63,
875,
275,
289,
14,
739,
342,
272,
871,
5925,
465,
325,
26,
489,
746,
4520,
360,
6005,
370,
1586,
7712,
687,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
339,
862,
26,
489,
7712,
14,
6200,
1451,
7671,
8,
6418,
63,
875,
9,
272,
871,
2186,
465,
325,
26,
489,
746,
4520,
360,
17412,
2257,
7712,
2071,
83,
2,
3405,
3134,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
523,
871,
4520,
465,
325,
26,
272,
340,
746,
63,
265,
63,
705,
26,
489,
746,
272,
587,
26,
489,
2050,
14,
4050,
8,
495,
8,
69,
430,
523,
372,
7712,
421,
199,
318,
6990,
5339,
11038,
8,
6418,
304,
523,
931,
275,
747,
14,
515,
14,
904,
8,
3791,
63,
3998,
63,
3022,
12,
26688,
20649,
63,
15440,
9,
523,
862,
26,
272,
13628,
63,
873,
63,
2330,
14,
5483,
17051,
8,
3791,
63,
3998,
63,
3022,
9,
523,
871,
2186,
465,
325,
26,
272,
746,
4520,
360,
6005,
370,
1218,
2082,
2071,
83,
1674,
60,
78,
221,
450,
83,
7,
450,
334,
3791,
63,
3998,
63,
3022,
12,
325,
430,
819,
862,
26,
272,
7712,
63,
1001,
275,
7712,
14,
25702,
2822,
1558,
342,
523,
871,
2186,
465,
325,
26,
272,
746,
4520,
360,
547,
2644,
7712,
2071,
83,
2,
370,
4840,
3134,
78,
221,
450,
83,
7,
450,
334,
515,
12,
325,
430,
819,
862,
26,
272,
543,
1551,
8,
515,
12,
283,
87,
358,
465,
289,
26,
489,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tchernomax/ansible
|
lib/ansible/modules/network/f5/bigip_software_image.py
|
6
|
14441
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright: (c) 2018, F5 Networks Inc.
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = r'''
---
module: bigip_software_image
short_description: Manage software images on a BIG-IP
description:
- Manages software images on a BIG-IP. These images may include both base images
and hotfix images.
version_added: 2.7
options:
force:
description:
- When C(yes), will upload the file every time and replace the file on the
device.
- When C(no), the file will only be uploaded if it does not already
exist.
- Generally should be C(yes) only in cases where you have reason
to believe that the image was corrupted during upload.
default: no
type: bool
state:
description:
- When C(present), ensures that the image is uploaded.
- When C(absent), ensures that the image is removed.
default: present
choices:
- absent
- present
image:
description:
- The image to put on the remote device.
- This may be an absolute or relative location on the Ansible controller.
- Image names, whether they are base ISOs or hotfix ISOs, B(must) be unique.
extends_documentation_fragment: f5
author:
- Tim Rupp (@caphrim007)
'''
EXAMPLES = r'''
- name: Upload relative image to the BIG-IP
bigip_software_image:
image: BIGIP-13.0.0.0.0.1645.iso
provider:
password: secret
server: lb.mydomain.com
user: admin
delegate_to: localhost
- name: Upload absolute image to the BIG-IP
bigip_software_image:
image: /path/to/images/BIGIP-13.0.0.0.0.1645.iso
provider:
password: secret
server: lb.mydomain.com
user: admin
delegate_to: localhost
- name: Upload image in a role to the BIG-IP
bigip_software_image:
image: "{{ role_path }}/files/BIGIP-13.0.0.0.0.1645.iso"
provider:
password: secret
server: lb.mydomain.com
user: admin
delegate_to: localhost
'''
RETURN = r'''
image_type:
description: Whether the image is a release or hotfix image
returned: changed
type: string
sample: release
version:
description: Version of the software contained in the image.
returned: changed
type: string
sample: 13.1.0.8
build:
description: Build version of the software contained in the image.
returned: changed
type: string
sample: 0.0.3
checksum:
description: MD5 checksum of the ISO.
returned: changed
type: string
sample: 8cdbd094195fab4b2b47ff4285577b70
file_size:
description: Size of the uploaded image in MB.
returned: changed
type: int
sample: 1948
'''
import os
import time
from ansible.module_utils.basic import AnsibleModule
try:
from library.module_utils.network.f5.bigip import F5RestClient
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import cleanup_tokens
from library.module_utils.network.f5.common import f5_argument_spec
from library.module_utils.network.f5.common import exit_json
from library.module_utils.network.f5.common import fail_json
from library.module_utils.network.f5.icontrol import upload_file
except ImportError:
from ansible.module_utils.network.f5.bigip import F5RestClient
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import cleanup_tokens
from ansible.module_utils.network.f5.common import f5_argument_spec
from ansible.module_utils.network.f5.common import exit_json
from ansible.module_utils.network.f5.common import fail_json
from ansible.module_utils.network.f5.icontrol import upload_file
class Parameters(AnsibleF5Parameters):
api_map = {
'fileSize': 'file_size'
}
api_attributes = [
]
returnables = [
'image_type',
'version',
'build',
'checksum',
'file_size',
]
updatables = [
]
class ApiParameters(Parameters):
@property
def file_size(self):
if self._values['file_size'] is None:
return None
tmp = self._values['file_size'].split(' ')
return int(tmp[0])
class ModuleParameters(Parameters):
@property
def filename(self):
return os.path.basename(self.image)
class Changes(Parameters):
def to_return(self):
result = {}
try:
for returnable in self.returnables:
result[returnable] = getattr(self, returnable)
result = self._filter_params(result)
except Exception:
pass
return result
class UsableChanges(Changes):
pass
class ReportableChanges(Changes):
pass
class Difference(object):
def __init__(self, want, have=None):
self.want = want
self.have = have
def compare(self, param):
try:
result = getattr(self, param)
return result
except AttributeError:
return self.__default(param)
def __default(self, param):
attr1 = getattr(self.want, param)
try:
attr2 = getattr(self.have, param)
if attr1 != attr2:
return attr1
except AttributeError:
return attr1
class ModuleManager(object):
def __init__(self, *args, **kwargs):
self.module = kwargs.get('module', None)
self.client = kwargs.get('client', None)
self.want = ModuleParameters(params=self.module.params)
self.have = ApiParameters()
self.changes = UsableChanges()
self.image_type = None
def _set_changed_options(self):
changed = {}
for key in Parameters.returnables:
if getattr(self.want, key) is not None:
changed[key] = getattr(self.want, key)
if changed:
self.changes = UsableChanges(params=changed)
def _update_changed_options(self):
diff = Difference(self.want, self.have)
updatables = Parameters.updatables
changed = dict()
for k in updatables:
change = diff.compare(k)
if change is None:
continue
else:
if isinstance(change, dict):
changed.update(change)
else:
changed[k] = change
if changed:
self.changes = UsableChanges(params=changed)
return True
return False
def should_update(self):
result = self._update_changed_options()
if result:
return True
return False
def exec_module(self):
changed = False
result = dict()
state = self.want.state
if state == "present":
changed = self.present()
elif state == "absent":
changed = self.absent()
reportable = ReportableChanges(params=self.changes.to_return())
changes = reportable.to_return()
result.update(**changes)
result.update(dict(changed=changed))
self._announce_deprecations(result)
return result
def _announce_deprecations(self, result):
warnings = result.pop('__warnings', [])
for warning in warnings:
self.client.module.deprecate(
msg=warning['msg'],
version=warning['version']
)
def present(self):
if self.exists():
return self.update()
else:
return self.create()
def exists(self):
if self.image_exists() or self.hotfix_exists():
return True
return False
def image_exists(self):
result = False
uri = "https://{0}:{1}/mgmt/tm/sys/software/image/{2}".format(
self.client.provider['server'],
self.client.provider['server_port'],
self.want.filename
)
resp = self.client.api.get(uri)
try:
response = resp.json()
if resp.status == 404 or 'code' in response and response['code'] == 404:
result = False
else:
self.image_type = 'release'
result = True
except ValueError:
pass
return result
def hotfix_exists(self):
result = False
uri = "https://{0}:{1}/mgmt/tm/sys/software/hotfix/{2}".format(
self.client.provider['server'],
self.client.provider['server_port'],
self.want.filename
)
resp = self.client.api.get(uri)
try:
response = resp.json()
if resp.status == 404 or 'code' in response and response['code'] == 404:
result = False
else:
self.image_type = 'hotfix'
result = True
except ValueError:
pass
return result
def update(self):
if self.module.check_mode:
return True
if self.want.force:
# The process of updating is a forced re-creation.
self.remove_from_device()
self.create_on_device()
return True
return False
def remove(self):
if self.module.check_mode:
return True
self.remove_from_device()
# Deleting images involves a short period of inconsistency in the REST
# API due to needing to remove files from disk and update MCPD.
#
# This should not (realistically) take more than 30 seconds.
for x in range(0, 30):
if not self.exists():
return True
time.sleep(1)
raise F5ModuleError("Failed to delete the resource.")
def create(self):
self._set_changed_options()
if self.module.check_mode:
return True
self.create_on_device()
# Creating images involves a short period of inconsistency in the REST
# API likely due to having to move files into appropriate places on disk
# and update MCPD with information.
#
# This should not (realistically) take more than 30 seconds.
for x in range(0, 30):
if self.exists():
# We want to return some information about the image that was just uploaded
#
# This must appear after the creation process because the information
# does not exist on the device (has been parsed by BIG-IP) until the
# ISO is uploaded.
self.want = self.read_current_from_device()
self._set_changed_options()
return True
time.sleep(1)
raise F5ModuleError("Failed to create the resource.")
def create_on_device(self):
url = 'https://{0}:{1}/mgmt/cm/autodeploy/software-image-uploads'.format(
self.client.provider['server'],
self.client.provider['server_port']
)
try:
upload_file(self.client, url, self.want.image)
except F5ModuleError:
raise F5ModuleError(
"Failed to upload the file."
)
def read_current_from_device(self):
if self.image_exists():
return self.read_iso_from_device('image')
elif self.hotfix_exists():
return self.read_iso_from_device('hotfix')
def read_iso_from_device(self, type):
uri = "https://{0}:{1}/mgmt/tm/sys/software/{2}/{3}".format(
self.client.provider['server'],
self.client.provider['server_port'],
type,
self.want.filename
)
resp = self.client.api.get(uri)
try:
response = resp.json()
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
raise F5ModuleError(resp.content)
result = ApiParameters(params=response)
result.update({'image_type': self.image_type})
return result
def absent(self):
if self.exists():
return self.remove()
return False
def remove_from_device(self):
if self.image_exists():
self.remove_iso_from_device('image')
elif self.hotfix_exists():
self.remove_iso_from_device('hotfix')
def remove_iso_from_device(self, type):
uri = "https://{0}:{1}/mgmt/tm/sys/software/{2}/{3}".format(
self.client.provider['server'],
self.client.provider['server_port'],
type,
self.want.filename
)
response = self.client.api.delete(uri)
if response.status == 200:
return True
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
raise F5ModuleError(response.content)
class ArgumentSpec(object):
def __init__(self):
self.supports_check_mode = True
argument_spec = dict(
force=dict(type='bool'),
image=dict(required=True),
state=dict(
default='present',
choices=['present', 'absent']
),
)
self.argument_spec = {}
self.argument_spec.update(f5_argument_spec)
self.argument_spec.update(argument_spec)
def main():
spec = ArgumentSpec()
module = AnsibleModule(
argument_spec=spec.argument_spec,
supports_check_mode=spec.supports_check_mode
)
try:
client = F5RestClient(**module.params)
mm = ModuleManager(module=module, client=client)
results = mm.exec_module()
cleanup_tokens(client)
exit_json(module, results, client)
except F5ModuleError as ex:
cleanup_tokens(client)
fail_json(module, ex, client)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
481,
21,
17138,
3277,
14,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
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,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
27281,
63,
15619,
63,
1569,
199,
3612,
63,
1802,
26,
14944,
2032,
5935,
641,
282,
16524,
13,
1772,
199,
1802,
26,
523,
446,
21612,
2032,
5935,
641,
282,
16524,
13,
1772,
14,
5723,
5935,
1443,
2387,
3865,
1300,
5935,
272,
436,
18469,
970,
5935,
14,
199,
1023,
63,
3270,
26,
499,
14,
23,
199,
1419,
26,
523,
3542,
26,
272,
1369,
26,
489,
446,
3979,
445,
8,
5066,
395,
911,
5802,
314,
570,
4036,
900,
436,
3350,
314,
570,
641,
314,
267,
2243,
14,
489,
446,
3979,
445,
8,
889,
395,
314,
570,
911,
1454,
506,
14238,
340,
652,
1630,
440,
2575,
267,
2187,
14,
489,
446,
1464,
1183,
1077,
506,
445,
8,
5066,
9,
1454,
315,
5560,
2382,
1265,
1172,
4499,
267,
370,
506,
317,
4754,
626,
314,
1834,
1990,
1970,
15692,
5309,
5802,
14,
272,
849,
26,
949,
272,
730,
26,
2155,
523,
1174,
26,
272,
1369,
26,
489,
446,
3979,
445,
8,
1881,
395,
15620,
626,
314,
1834,
365,
14238,
14,
489,
446,
3979,
445,
8,
5575,
395,
15620,
626,
314,
1834,
365,
4829,
14,
272,
849,
26,
3451,
272,
3415,
26,
489,
446,
9552,
489,
446,
3451,
523,
1834,
26,
272,
1369,
26,
489,
446,
710,
1834,
370,
5324,
641,
314,
3982,
2243,
14,
489,
446,
961,
1443,
506,
376,
3679,
503,
3847,
2909,
641,
314,
2622,
7614,
14,
489,
446,
6047,
1561,
12,
3775,
2985,
787,
1300,
9055,
83,
503,
18469,
970,
9055,
83,
12,
699,
8,
7790,
9,
506,
3747,
14,
199,
11036,
63,
9970,
63,
7677,
26,
289,
21,
199,
2502,
26,
523,
446,
26244,
820,
384,
80,
8593,
2874,
72,
31898,
8255,
9,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
19149,
3847,
1834,
370,
314,
16524,
13,
1772,
523,
27281,
63,
15619,
63,
1569,
26,
272,
1834,
26,
16524,
1772,
13,
969,
14,
16,
14,
16,
14,
16,
14,
16,
14,
8982,
21,
14,
4595,
272,
5022,
26,
489,
2505,
26,
7565,
489,
1654,
26,
11104,
14,
30945,
14,
957,
489,
922,
26,
4628,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
536,
26,
19149,
3679,
1834,
370,
314,
16524,
13,
1772,
523,
27281,
63,
15619,
63,
1569,
26,
272,
1834,
26,
1182,
515,
15,
475,
15,
4782,
15,
18643,
1772,
13,
969,
14,
16,
14,
16,
14,
16,
14,
16,
14,
8982,
21,
14,
4595,
272,
5022,
26,
489,
2505,
26,
7565,
489,
1654,
26,
11104,
14,
30945,
14,
957,
489,
922,
26,
4628,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
536,
26,
19149,
1834,
315,
282,
4719,
370,
314,
16524,
13,
1772,
523,
27281,
63,
15619,
63,
1569,
26,
272,
1834,
26,
7370,
4719,
63,
515,
3586,
15,
1725,
15,
18643,
1772,
13,
969,
14,
16,
14,
16,
14,
16,
14,
16,
14,
8982,
21,
14,
4595,
2,
272,
5022,
26,
489,
2505,
26,
7565,
489,
1654,
26,
11104,
14,
30945,
14,
957,
489,
922,
26,
4628,
523,
13080,
63,
475,
26,
11667,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
1569,
63,
466,
26,
523,
1369,
26,
7480,
314,
1834,
365,
282,
4683,
503,
18469,
970,
1834,
523,
2138,
26,
2896,
523,
730,
26,
1059,
523,
2690,
26,
4683,
199,
1023,
26,
523,
1369,
26,
3394,
402,
314,
2032,
10470,
315,
314,
1834,
14,
523,
2138,
26,
2896,
523,
730,
26,
1059,
523,
2690,
26,
4944,
14,
17,
14,
16,
14,
24,
199,
1506,
26,
523,
1369,
26,
6516,
1015,
402,
314,
2032,
10470,
315,
314,
1834,
14,
523,
2138,
26,
2896,
523,
730,
26,
1059,
523,
2690,
26,
378,
14,
16,
14,
19,
199,
8928,
26,
523,
1369,
26,
15830,
21,
9040,
402,
314,
9055,
14,
523,
2138,
26,
2896,
523,
730,
26,
1059,
523,
2690,
26,
1695,
24035,
68,
16285,
11874,
21159,
20,
66,
18,
66,
2417,
556,
27302,
1229,
1138,
66,
2760,
199,
493,
63,
890,
26,
523,
1369,
26,
14579,
402,
314,
14238,
1834,
315,
19487,
14,
523,
2138,
26,
2896,
523,
730,
26,
1109,
523,
2690,
26,
5851,
2006,
199,
2344,
199,
199,
646,
747,
199,
646,
900,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
199,
893,
26,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
17833,
492,
481,
21,
13726,
3041,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
481,
21,
12232,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
2622,
38,
21,
5976,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
9058,
63,
4504,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
289,
21,
63,
2094,
63,
1650,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
4458,
63,
1001,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
2449,
63,
1001,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
73,
2785,
492,
5802,
63,
493,
199,
2590,
3545,
26,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
17833,
492,
481,
21,
13726,
3041,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
481,
21,
12232,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
2622
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
481,
21,
17138,
3277,
14,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
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,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
27281,
63,
15619,
63,
1569,
199,
3612,
63,
1802,
26,
14944,
2032,
5935,
641,
282,
16524,
13,
1772,
199,
1802,
26,
523,
446,
21612,
2032,
5935,
641,
282,
16524,
13,
1772,
14,
5723,
5935,
1443,
2387,
3865,
1300,
5935,
272,
436,
18469,
970,
5935,
14,
199,
1023,
63,
3270,
26,
499,
14,
23,
199,
1419,
26,
523,
3542,
26,
272,
1369,
26,
489,
446,
3979,
445,
8,
5066,
395,
911,
5802,
314,
570,
4036,
900,
436,
3350,
314,
570,
641,
314,
267,
2243,
14,
489,
446,
3979,
445,
8,
889,
395,
314,
570,
911,
1454,
506,
14238,
340,
652,
1630,
440,
2575,
267,
2187,
14,
489,
446,
1464,
1183,
1077,
506,
445,
8,
5066,
9,
1454,
315,
5560,
2382,
1265,
1172,
4499,
267,
370,
506,
317,
4754,
626,
314,
1834,
1990,
1970,
15692,
5309,
5802,
14,
272,
849,
26,
949,
272,
730,
26,
2155,
523,
1174,
26,
272,
1369,
26,
489,
446,
3979,
445,
8,
1881,
395,
15620,
626,
314,
1834,
365,
14238,
14,
489,
446,
3979,
445,
8,
5575,
395,
15620,
626,
314,
1834,
365,
4829,
14,
272,
849,
26,
3451,
272,
3415,
26,
489,
446,
9552,
489,
446,
3451,
523,
1834,
26,
272,
1369,
26,
489,
446,
710,
1834,
370,
5324,
641,
314,
3982,
2243,
14,
489,
446,
961,
1443,
506,
376,
3679,
503,
3847,
2909,
641,
314,
2622,
7614,
14,
489,
446,
6047,
1561,
12,
3775,
2985,
787,
1300,
9055,
83,
503,
18469,
970,
9055,
83,
12,
699,
8,
7790,
9,
506,
3747,
14,
199,
11036,
63,
9970,
63,
7677,
26,
289,
21,
199,
2502,
26,
523,
446,
26244,
820,
384,
80,
8593,
2874,
72,
31898,
8255,
9,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
19149,
3847,
1834,
370,
314,
16524,
13,
1772,
523,
27281,
63,
15619,
63,
1569,
26,
272,
1834,
26,
16524,
1772,
13,
969,
14,
16,
14,
16,
14,
16,
14,
16,
14,
8982,
21,
14,
4595,
272,
5022,
26,
489,
2505,
26,
7565,
489,
1654,
26,
11104,
14,
30945,
14,
957,
489,
922,
26,
4628,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
536,
26,
19149,
3679,
1834,
370,
314,
16524,
13,
1772,
523,
27281,
63,
15619,
63,
1569,
26,
272,
1834,
26,
1182,
515,
15,
475,
15,
4782,
15,
18643,
1772,
13,
969,
14,
16,
14,
16,
14,
16,
14,
16,
14,
8982,
21,
14,
4595,
272,
5022,
26,
489,
2505,
26,
7565,
489,
1654,
26,
11104,
14,
30945,
14,
957,
489,
922,
26,
4628,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
536,
26,
19149,
1834,
315,
282,
4719,
370,
314,
16524,
13,
1772,
523,
27281,
63,
15619,
63,
1569,
26,
272,
1834,
26,
7370,
4719,
63,
515,
3586,
15,
1725,
15,
18643,
1772,
13,
969,
14,
16,
14,
16,
14,
16,
14,
16,
14,
8982,
21,
14,
4595,
2,
272,
5022,
26,
489,
2505,
26,
7565,
489,
1654,
26,
11104,
14,
30945,
14,
957,
489,
922,
26,
4628,
523,
13080,
63,
475,
26,
11667,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
1569,
63,
466,
26,
523,
1369,
26,
7480,
314,
1834,
365,
282,
4683,
503,
18469,
970,
1834,
523,
2138,
26,
2896,
523,
730,
26,
1059,
523,
2690,
26,
4683,
199,
1023,
26,
523,
1369,
26,
3394,
402,
314,
2032,
10470,
315,
314,
1834,
14,
523,
2138,
26,
2896,
523,
730,
26,
1059,
523,
2690,
26,
4944,
14,
17,
14,
16,
14,
24,
199,
1506,
26,
523,
1369,
26,
6516,
1015,
402,
314,
2032,
10470,
315,
314,
1834,
14,
523,
2138,
26,
2896,
523,
730,
26,
1059,
523,
2690,
26,
378,
14,
16,
14,
19,
199,
8928,
26,
523,
1369,
26,
15830,
21,
9040,
402,
314,
9055,
14,
523,
2138,
26,
2896,
523,
730,
26,
1059,
523,
2690,
26,
1695,
24035,
68,
16285,
11874,
21159,
20,
66,
18,
66,
2417,
556,
27302,
1229,
1138,
66,
2760,
199,
493,
63,
890,
26,
523,
1369,
26,
14579,
402,
314,
14238,
1834,
315,
19487,
14,
523,
2138,
26,
2896,
523,
730,
26,
1109,
523,
2690,
26,
5851,
2006,
199,
2344,
199,
199,
646,
747,
199,
646,
900,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
199,
893,
26,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
17833,
492,
481,
21,
13726,
3041,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
481,
21,
12232,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
2622,
38,
21,
5976,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
9058,
63,
4504,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
289,
21,
63,
2094,
63,
1650,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
4458,
63,
1001,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
2449,
63,
1001,
272,
687,
3555,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
73,
2785,
492,
5802,
63,
493,
199,
2590,
3545,
26,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
17833,
492,
481,
21,
13726,
3041,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
481,
21,
12232,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
70,
21,
14,
2330,
492,
2622,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
yungyuc/solvcon
|
ftests/gasplus/test_tube_2d_triangle_regular.py
|
2
|
11859
|
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright (c) 2017, Yung-Yu Chen <yyc@solvcon.net>
#
# 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 the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""
Validate C++-based ``gasplus`` solver.
"""
# Beware, it's full of hacks.
import os
import math
import collections
from unittest import TestCase
import numpy as np
import solvcon as sc
from solvcon.parcel import gasplus as gp
class TriangularMesher(object):
"""
Representation of a rectangle and the Gmsh meshing helper.
:ivar lowerleft: (x0, y0) of the rectangle.
:type lowerleft: tuple
:ivar upperright: (x1, y1) of the rectangle.
:type upperright: tuple
:ivar edgelength: Length of each mesh cell edge.
:type edgelength: float
"""
def __init__(self, lowerleft, upperright, edgelength):
assert 2 == len(lowerleft)
self.lowerleft = tuple(float(val) for val in lowerleft)
assert 2 == len(upperright)
self.upperright = tuple(float(val) for val in upperright)
self.edgelength = float(edgelength)
def __call__(self, cse):
x0, y0 = self.lowerleft
x1, y1 = self.upperright
ndx = int(math.ceil((x1 - x0) / (self.edgelength*2)))
ndy = int(math.ceil((y1 - y0) / (self.edgelength*2)))
dx = (x1 - x0) / ndx
dy = (y1 - y0) / ndy
# mesh numbers.
nnode = (ndx*2+1)*ndy + ndx+1
nface = 6 * ndx * ndy + ndx + ndy
ncell = 4 * ndx * ndy
nbound = 2 * (ndx + ndy)
blk = sc.Block(ndim=2, nnode=nnode, nface=0, ncell=ncell, nbound=3)
# create nodes.
nodes = []
for iy, yloc in enumerate(np.arange(y0, y1+dy/4, dy/2)):
if iy % 2 == 0:
meshx = np.arange(x0, x1+dx/4, dx, dtype='float64')
else:
meshx = np.arange(x0+dx/2, x1-dx/4, dx, dtype='float64')
nodes.append(np.vstack([meshx, np.full_like(meshx, yloc)]).T)
nodes = np.vstack(nodes)
assert nodes.shape[0] == nnode
blk.ndcrd[:,:] = nodes
assert (blk.ndcrd == nodes).all()
# create cells.
skip_bottom = ndx + 1
skip_middle = ndx
skip_full = skip_bottom + skip_middle
for ilayer in range(ndy):
inref = ilayer * skip_full
icref = ilayer * 4 * ndx
for ic in range(ndx):
ictr = inref + skip_bottom + ic
ill = inref + ic+0
ilr = inref + ic+1
iul = inref + skip_full + ic+0
iur = inref + skip_full + ic+1
blk.clnds[icref+ic*4 ,:4] = (3, ictr, ill, ilr)
blk.clnds[icref+ic*4+1,:4] = (3, ictr, ilr, iur)
blk.clnds[icref+ic*4+2,:4] = (3, ictr, iur, iul)
blk.clnds[icref+ic*4+3,:4] = (3, ictr, iul, ill)
narr = np.unique(blk.clnds[:ncell,1:4].flatten())
narr.sort()
assert (narr == np.arange(nnode, dtype='int32')).all()
# build block.
blk.cltpn[:] = 3
blk.build_interior()
assert blk.nface == nface
assert (abs(blk.clvol - dx * dy / 4) < 1.e-10).all()
# build boundary
boundaries = dict(
left=np.arange(nface, dtype='int32')[blk.fccnd[:,0] == x0],
right=np.arange(nface, dtype='int32')[blk.fccnd[:,0] == x1],
lower=np.arange(nface, dtype='int32')[blk.fccnd[:,1] == y0],
upper=np.arange(nface, dtype='int32')[blk.fccnd[:,1] == y1],
)
for name in boundaries:
bndfcs = boundaries[name]
nameb = name.encode()
bct, vdict = cse.condition.bcmap.get(nameb, (sc.BC, dict()))
bc = bct(fpdtype=blk.fpdtype)
bc.name = name
bc.facn = np.empty((len(bndfcs), 3), dtype='int32')
bc.facn.fill(-1)
bc.facn[:,0] = bndfcs
bc.feedValue(vdict)
bc.sern = len(blk.bclist)
bc.blk = blk
blk.bclist.append(bc)
blk.build_boundary()
blk.build_ghost()
return blk
class XDiaphragmAnchor(sc.march.gas.CommonAnchor):
"""
Set different density and pressure across a diaphragm along the x axis.
"""
def __init__(self, svr, **kw):
sc.march.gas.CommonAnchor.__init__(self, svr)
self.xloc = float(kw.pop('xloc'))
self.gamma = float(kw.pop('gamma'))
self.rho1 = float(kw.pop('rho1'))
self.rho2 = float(kw.pop('rho2'))
self.p1 = float(kw.pop('p1'))
self.p2 = float(kw.pop('p2'))
def provide(self):
gamma = self.gamma
svr = self.solver
so0n = svr.sol.so0n.F
so0n[:,0].fill(self.rho1)
so0n[:,1].fill(0.0)
so0n[:,2].fill(0.0)
if svr.block.ndim == 3:
so0n[:,3].fill(0.0)
so0n[:,svr.block.ndim+1].fill(self.p1/(gamma-1))
# set.
slct = svr.block.tbclcnd.F[:,0] > self.xloc
so0n[slct,0] = self.rho2
so0n[slct,svr.block.ndim+1] = self.p2
# update.
svr.sol.so0c.F[:] = so0n[:]
_HeterogeneityData = collections.namedtuple(
"_HeterogeneityData",
("step_current", "substep_current", "so0nidx", "xloc",
"vmean", "vcov", "cov_threshold"))
class YHomogeneityCheck(sc.march.gas.CommonAnchor):
def __init__(self, svr, **kw):
sc.march.gas.CommonAnchor.__init__(self, svr)
# coefficient of variation
self.instant_fail = kw.pop('instant_fail', False)
self.cov_threshold = kw.pop('cov_threshold')
self.columns = None
self.hdata = list()
def provide(self):
svr = self.solver
self.hdata = list()
# get rid of rounding error with 10 digits.
roundx = svr.block.clcnd[:,0].round(decimals=10) # rounded x
indices = np.arange(svr.block.ncell, dtype='int32')
xlocs = np.unique(roundx)
xlocs.sort()
# scan the X coordinates and fill indices.
self.columns = collections.OrderedDict()
for xloc in xlocs:
self.columns[xloc] = indices[roundx==xloc]
# sanity check.
rebuilt = np.concatenate([self.columns[k] for k in self.columns])
rebuilt.sort()
assert (indices == rebuilt).all()
def _check(self):
so0n = self.solver.sol.so0n.B
for xloc in self.columns:
column = self.columns[xloc]
for it in range(so0n.shape[1]):
val = so0n[column,it]
cov_threshold = self.cov_threshold[it]
if cov_threshold:
vmean = abs(np.mean(val))
vamean = abs(vmean)
vstd = np.std(val)
vcov = vstd if vamean < 1.e-10 else vstd/vamean
if vcov >= cov_threshold:
hdatum = _HeterogeneityData(
self.solver.state.step_current,
self.solver.state.substep_current,
it, xloc, vmean, vcov, cov_threshold)
if self.instant_fail:
raise AssertionError(hdatum)
else:
self.hdata.append(hdatum)
def prefull(self):
self._check()
def postloop(self):
self._check()
if self.hdata:
raise AssertionError(self.hdata)
def create_case(
casename=None, ssteps=None, psteps=None, instant_fail=False,
gamma=1.4, rho1=1.0, p1=1.0, rho2=0.125, p2=0.25,
**kw
):
if ssteps is not None and psteps is not None:
basedir = os.path.abspath(os.path.join(os.getcwd(), casename))
else:
basedir = None
# Set up case.
mesher = TriangularMesher(lowerleft=(0,0), upperright=(4,1),
edgelength=0.1)
bcmap = {
b'upper': (sc.bctregy.GasPlusSlipWall, {},),
b'left': (sc.bctregy.GasPlusNonRefl, {},),
b'right': (sc.bctregy.GasPlusNonRefl, {},),
b'lower': (sc.bctregy.GasPlusSlipWall, {},),
}
cse = gp.GasPlusCase(
# Mesh generator.
mesher=mesher,
# Mapping boundary-condition treatments.
bcmap=bcmap,
# Use the case name to be the basename for all generated files.
basefn=casename,
basedir=basedir,
# Runstep.
time_increment=30.e-3, steps_run=30,
report_interval=psteps if psteps else 0,
# Debug and capture-all.
debug=False, **kw)
# Field initialization and derived calculations.
cse.defer(gp.FillAnchor,
mappers={'sol.so0n': sc.march.gas.Solver2D.ALMOST_ZERO,
'sol.so1n': 0.0, 'sol.gamma': gamma})
cse.defer(XDiaphragmAnchor,
xloc=(mesher.lowerleft[0]+mesher.upperright[0])/2,
gamma=gamma, rho1=rho1, p1=p1, rho2=rho2, p2=p2)
cse.defer(YHomogeneityCheck,
instant_fail=instant_fail,
cov_threshold=[
# FIXME: everything is too large for a robust solver. I
# tolerate it so that we can move on. There must be something
# wrong and we have to fix it later.
0.027, # density
0.63, # X velocity FIXME: way too large!
0.035, # Y velocity isn't as bad as X velocity
0.037, # total energy
])
if ssteps is not None and psteps is not None:
# Report information while calculating.
cse.defer(gp.ProgressHook, linewidth=ssteps/psteps, psteps=psteps)
cse.defer(gp.CflHook, fullstop=False, cflmax=10.0, psteps=ssteps)
cse.defer(gp.MeshInfoHook, psteps=ssteps)
# Store data.
cse.defer(
gp.PMarchSave,
anames=[
('so0n', False, -4),
],
psteps=ssteps)
return cse
class TestTube2dTriangleRegularCaseRun(TestCase):
def test_run(self, **kw):
cse = create_case('tube_2d_triangle_regular_run')
cse.init()
cse.run()
# This section is for debugging purpose.
if __name__ == '__main__':
def tube_2d_triangle_regular_run(casename, **kw):
return create_case(casename, ssteps=1, psteps=1, instant_fail=True,
**kw)
gp.register_arrangement(tube_2d_triangle_regular_run)
sc.go()
# vim: set ff=unix fenc=utf8 ft=python sw=4 ts=4 tw=79:
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
9094,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
9708,
12,
1488,
10335,
13,
24388,
2799,
287,
665,
7566,
67,
32,
7873,
86,
388,
14,
846,
30,
199,
3,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
199,
3,
446,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
4245,
12,
642,
199,
3,
257,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
446,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
257,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
257,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
446,
11443,
314,
536,
402,
314,
4248,
16712,
6590,
314,
1561,
402,
2399,
8417,
199,
3,
257,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
642,
2032,
199,
3,
257,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
199,
3,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
199,
3,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
199,
3,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
199,
3,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
199,
3,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
199,
3,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
199,
3,
9726,
1634,
9712,
9784,
14,
421,
199,
624,
199,
12584,
445,
4176,
13,
6788,
1124,
24364,
6666,
1040,
10196,
14,
199,
624,
199,
199,
3,
699,
546,
1530,
12,
652,
1159,
2615,
402,
11176,
83,
14,
421,
199,
646,
747,
199,
646,
3473,
199,
646,
5055,
199,
504,
2882,
492,
7640,
199,
199,
646,
2680,
465,
980,
199,
199,
646,
8597,
86,
388,
465,
4061,
199,
504,
8597,
86,
388,
14,
462,
6067,
492,
486,
305,
6666,
465,
15852,
421,
199,
533,
12480,
11572,
45,
397,
2523,
8,
785,
304,
272,
408,
272,
17634,
425,
402,
282,
20412,
436,
314,
598,
77,
609,
9364,
316,
5922,
14,
339,
520,
7725,
5117,
3039,
26,
334,
88,
16,
12,
612,
16,
9,
402,
314,
20412,
14,
272,
520,
466,
5117,
3039,
26,
2008,
272,
520,
7725,
7008,
1019,
26,
334,
88,
17,
12,
612,
17,
9,
402,
314,
20412,
14,
272,
520,
466,
7008,
1019,
26,
2008,
272,
520,
7725,
6275,
1267,
26,
19893,
402,
1924,
9364,
4917,
6275,
14,
272,
520,
466,
6275,
1267,
26,
2069,
272,
408,
339,
347,
636,
826,
721,
277,
12,
5117,
3039,
12,
7008,
1019,
12,
6275,
1267,
304,
267,
702,
499,
508,
822,
8,
2325,
3039,
9,
267,
291,
14,
2325,
3039,
275,
2008,
8,
1609,
8,
637,
9,
367,
1139,
315,
5117,
3039,
9,
267,
702,
499,
508,
822,
8,
4142,
1019,
9,
267,
291,
14,
4142,
1019,
275,
2008,
8,
1609,
8,
637,
9,
367,
1139,
315,
7008,
1019,
9,
267,
291,
14,
5173,
1267,
275,
2069,
8,
5173,
1267,
9,
339,
347,
636,
1250,
721,
277,
12,
286,
261,
304,
267,
671,
16,
12,
612,
16,
275,
291,
14,
2325,
3039,
267,
671,
17,
12,
612,
17,
275,
291,
14,
4142,
1019,
267,
5222,
88,
275,
1109,
8,
3442,
14,
14085,
1332,
88,
17,
446,
671,
16,
9,
1182,
334,
277,
14,
5173,
1267,
10,
18,
1724,
267,
5222,
89,
275,
1109,
8,
3442,
14,
14085,
1332,
89,
17,
446,
612,
16,
9,
1182,
334,
277,
14,
5173,
1267,
10,
18,
1724,
267,
11868,
275,
334,
88,
17,
446,
671,
16,
9,
1182,
5222,
88,
267,
13119,
275,
334,
89,
17,
446,
612,
16,
9,
1182,
5222,
89,
267,
327,
9364,
5579,
14,
267,
302,
932,
275,
334,
31818,
10,
18,
11,
17,
3342,
977,
89,
435,
5222,
88,
11,
17,
267,
302,
1409,
275,
1227,
627,
5222,
88,
627,
5222,
89,
435,
5222,
88,
435,
5222,
89,
267,
302,
3890,
275,
841,
627,
5222,
88,
627,
5222,
89,
267,
302,
3556,
275,
499,
627,
334,
31818,
435,
5222,
89,
9,
267,
22742,
275,
4061,
14,
3142,
8,
8322,
29,
18,
12,
302,
932,
29,
78,
932,
12,
302,
1409,
29,
16,
12,
302,
3890,
29,
78,
3890,
12,
302,
3556,
29,
19,
9,
267,
327,
1218,
3380,
14,
267,
3380,
275,
942,
267,
367,
284,
89,
12,
612,
2102,
315,
3874,
8,
1590,
14,
5605,
8,
89,
16,
12,
612,
17,
11,
8161,
15,
20,
12,
13119,
15,
18,
2298,
288,
340,
284,
89,
450,
499,
508,
378,
26,
355,
9364,
88,
275,
980,
14,
5605,
8,
88,
16,
12,
671,
17,
11,
8373,
15,
20,
12,
11868,
12,
2152,
534,
1609,
772,
358,
288,
587,
26,
355,
9364,
88,
275,
980,
14,
5605,
8,
88,
16,
11,
8373,
15,
18,
12,
671,
17,
13,
8373,
15,
20,
12,
11868,
12,
2152,
534,
1609,
772,
358,
288,
3380,
14,
740,
8,
1590,
14,
20221,
779,
6480,
88,
12,
980,
14,
2861,
63,
2930,
8,
6480,
88,
12,
612,
2102,
3948,
14,
52,
9,
267,
3380,
275,
980,
14,
20221,
8,
2415,
9,
267,
702,
3380,
14,
1392,
59,
16,
61,
508,
302,
932,
267,
22742,
14,
977,
1556,
68,
3981,
2938,
275,
3380,
267,
702,
334,
14023,
14,
977,
1556,
68,
508,
3380,
680,
452,
342,
267,
327,
1218,
10106,
14,
267,
3372,
63,
8305,
275,
5222,
88,
435,
413,
267,
3372,
63,
14885,
275,
5222,
88,
267,
3372,
63,
2861,
275,
3372,
63,
8305,
435,
3372,
63,
14885,
267,
367,
284,
1897,
315,
1425
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
9094,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
9708,
12,
1488,
10335,
13,
24388,
2799,
287,
665,
7566,
67,
32,
7873,
86,
388,
14,
846,
30,
199,
3,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
199,
3,
446,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
4245,
12,
642,
199,
3,
257,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
446,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
257,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
257,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
446,
11443,
314,
536,
402,
314,
4248,
16712,
6590,
314,
1561,
402,
2399,
8417,
199,
3,
257,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
642,
2032,
199,
3,
257,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
199,
3,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
199,
3,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
199,
3,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
199,
3,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
199,
3,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
199,
3,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
199,
3,
9726,
1634,
9712,
9784,
14,
421,
199,
624,
199,
12584,
445,
4176,
13,
6788,
1124,
24364,
6666,
1040,
10196,
14,
199,
624,
199,
199,
3,
699,
546,
1530,
12,
652,
1159,
2615,
402,
11176,
83,
14,
421,
199,
646,
747,
199,
646,
3473,
199,
646,
5055,
199,
504,
2882,
492,
7640,
199,
199,
646,
2680,
465,
980,
199,
199,
646,
8597,
86,
388,
465,
4061,
199,
504,
8597,
86,
388,
14,
462,
6067,
492,
486,
305,
6666,
465,
15852,
421,
199,
533,
12480,
11572,
45,
397,
2523,
8,
785,
304,
272,
408,
272,
17634,
425,
402,
282,
20412,
436,
314,
598,
77,
609,
9364,
316,
5922,
14,
339,
520,
7725,
5117,
3039,
26,
334,
88,
16,
12,
612,
16,
9,
402,
314,
20412,
14,
272,
520,
466,
5117,
3039,
26,
2008,
272,
520,
7725,
7008,
1019,
26,
334,
88,
17,
12,
612,
17,
9,
402,
314,
20412,
14,
272,
520,
466,
7008,
1019,
26,
2008,
272,
520,
7725,
6275,
1267,
26,
19893,
402,
1924,
9364,
4917,
6275,
14,
272,
520,
466,
6275,
1267,
26,
2069,
272,
408,
339,
347,
636,
826,
721,
277,
12,
5117,
3039,
12,
7008,
1019,
12,
6275,
1267,
304,
267,
702,
499,
508,
822,
8,
2325,
3039,
9,
267,
291,
14,
2325,
3039,
275,
2008,
8,
1609,
8,
637,
9,
367,
1139,
315,
5117,
3039,
9,
267,
702,
499,
508,
822,
8,
4142,
1019,
9,
267,
291,
14,
4142,
1019,
275,
2008,
8,
1609,
8,
637,
9,
367,
1139,
315,
7008,
1019,
9,
267,
291,
14,
5173,
1267,
275,
2069,
8,
5173,
1267,
9,
339,
347,
636,
1250,
721,
277,
12,
286,
261,
304,
267,
671,
16,
12,
612,
16,
275,
291,
14,
2325,
3039,
267,
671,
17,
12,
612,
17,
275,
291,
14,
4142,
1019,
267,
5222,
88,
275,
1109,
8,
3442,
14,
14085,
1332,
88,
17,
446,
671,
16,
9,
1182,
334,
277,
14,
5173,
1267,
10,
18,
1724,
267,
5222,
89,
275,
1109,
8,
3442,
14,
14085,
1332,
89,
17,
446,
612,
16,
9,
1182,
334,
277,
14,
5173,
1267,
10,
18,
1724,
267,
11868,
275,
334,
88,
17,
446,
671,
16,
9,
1182,
5222,
88,
267,
13119,
275,
334,
89,
17,
446,
612,
16,
9,
1182,
5222,
89,
267,
327,
9364,
5579,
14,
267,
302,
932,
275,
334,
31818,
10,
18,
11,
17,
3342,
977,
89,
435,
5222,
88,
11,
17,
267,
302,
1409,
275,
1227,
627,
5222,
88,
627,
5222,
89,
435,
5222,
88,
435,
5222,
89,
267,
302,
3890,
275,
841,
627,
5222,
88,
627,
5222,
89,
267,
302,
3556,
275,
499,
627,
334,
31818,
435,
5222,
89,
9,
267,
22742,
275,
4061,
14,
3142,
8,
8322,
29,
18,
12,
302,
932,
29,
78,
932,
12,
302,
1409,
29,
16,
12,
302,
3890,
29,
78,
3890,
12,
302,
3556,
29,
19,
9,
267,
327,
1218,
3380,
14,
267,
3380,
275,
942,
267,
367,
284,
89,
12,
612,
2102,
315,
3874,
8,
1590,
14,
5605,
8,
89,
16,
12,
612,
17,
11,
8161,
15,
20,
12,
13119,
15,
18,
2298,
288,
340,
284,
89,
450,
499,
508,
378,
26,
355,
9364,
88,
275,
980,
14,
5605,
8,
88,
16,
12,
671,
17,
11,
8373,
15,
20,
12,
11868,
12,
2152,
534,
1609,
772,
358,
288,
587,
26,
355,
9364,
88,
275,
980,
14,
5605,
8,
88,
16,
11,
8373,
15,
18,
12,
671,
17,
13,
8373,
15,
20,
12,
11868,
12,
2152,
534,
1609,
772,
358,
288,
3380,
14,
740,
8,
1590,
14,
20221,
779,
6480,
88,
12,
980,
14,
2861,
63,
2930,
8,
6480,
88,
12,
612,
2102,
3948,
14,
52,
9,
267,
3380,
275,
980,
14,
20221,
8,
2415,
9,
267,
702,
3380,
14,
1392,
59,
16,
61,
508,
302,
932,
267,
22742,
14,
977,
1556,
68,
3981,
2938,
275,
3380,
267,
702,
334,
14023,
14,
977,
1556,
68,
508,
3380,
680,
452,
342,
267,
327,
1218,
10106,
14,
267,
3372,
63,
8305,
275,
5222,
88,
435,
413,
267,
3372,
63,
14885,
275,
5222,
88,
267,
3372,
63,
2861,
275,
3372,
63,
8305,
435,
3372,
63,
14885,
267,
367,
284,
1897,
315,
1425,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
kblomqvist/yasha
|
yasha/cli.py
|
1
|
9767
|
"""
The MIT License (MIT)
Copyright (c) 2015-2021 Kim Blomqvist
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import os
import encodings
import click
from click import ClickException
from jinja2.exceptions import UndefinedError as JinjaUndefinedError
from . import yasha
from .tests import TESTS
from .filters import FILTERS
from .classes import CLASSES
from .parsers import PARSERS
def print_version(ctx, param, value):
if not value or ctx.resilient_parsing:
return
click.echo(yasha.__version__)
ctx.exit()
def parse_variable_file(file):
try:
file_extension = os.path.splitext(file.name)[1]
return PARSERS[file_extension](file)
except AttributeError:
return dict()
except KeyError:
error = "Unkown variable file extension '{}'"
raise ClickException(error.format(file_extension))
def load_python_module(file):
try:
from importlib.machinery import SourceFileLoader
loader = SourceFileLoader('yasha_extensions', file.name)
module = loader.load_module()
except ImportError: # Fallback to Python2
import imp
with open(file.name) as f:
desc = (".py", "rb", imp.PY_SOURCE)
module = imp.load_module('yasha_extensions', f, file.name, desc)
pass
return module
def load_extensions(file):
from jinja2.ext import Extension
import inspect
tests = dict()
filters = dict()
parsers = dict()
classes = []
try:
module = load_python_module(file)
except NameError as e:
msg = 'Unable to load extensions, {}'
raise ClickException(msg.format(e))
except SyntaxError as e:
msg = "Unable to load extensions\n{} ({}, line {})"
error = e.msg[0].upper() + e.msg[1:]
filename = os.path.relpath(e.filename)
raise ClickException(msg.format(error, filename, e.lineno))
for attr in [getattr(module, x) for x in dir(module)]:
if inspect.isfunction(attr):
if attr.__name__.startswith('test_'):
name = attr.__name__[5:]
tests[name] = attr
if attr.__name__.startswith('filter_'):
name = attr.__name__[7:]
filters[name] = attr
if attr.__name__.startswith('parse_'):
name = attr.__name__[6:]
parsers['.' + name] = attr
if inspect.isclass(attr):
if issubclass(attr, Extension):
classes.append(attr)
import jinja2.defaults
for name, obj in inspect.getmembers(module):
if name in tuple(x for x in dir(jinja2.defaults) if x.isupper()):
setattr(jinja2.defaults, name, obj)
try:
TESTS.update(module.TESTS)
except AttributeError:
TESTS.update(tests)
try:
FILTERS.update(module.FILTERS)
except AttributeError:
FILTERS.update(filters)
try:
PARSERS.update(module.PARSERS)
except AttributeError:
PARSERS.update(parsers)
try:
CLASSES.extend(module.CLASSES)
except AttributeError:
CLASSES.extend(classes)
@click.command(context_settings=dict(
help_option_names=["-h", "--help"],
ignore_unknown_options=True,
))
@click.argument("template_variables", nargs=-1, type=click.UNPROCESSED)
@click.argument("template", type=click.File("rb"))
@click.option("--output", "-o", type=click.File("wb"), help="Place the rendered template into FILENAME.")
@click.option("--variables", "-v", type=click.File("rb"), multiple=True, help="Read template variables from FILENAME. Built-in parsers are JSON, YAML, TOML and XML.")
@click.option("--extensions", "-e", envvar='YASHA_EXTENSIONS', type=click.File("rb"), help="Read template extensions from FILENAME. A Python file is expected.")
@click.option("--encoding", "-c", default=yasha.ENCODING, help="Default is UTF-8.")
@click.option("--include_path", "-I", type=click.Path(exists=True, file_okay=False), multiple=True, help="Add DIRECTORY to the list of directories to be searched for the referenced templates.")
@click.option("--no-variable-file", is_flag=True, help="Omit template variable file.")
@click.option("--no-extension-file", is_flag=True, help="Omit template extension file.")
@click.option("--no-trim-blocks", is_flag=True, help="Load Jinja with trim_blocks=False.")
@click.option("--no-lstrip-blocks", is_flag=True, help="Load Jinja with lstrip_blocks=False.")
@click.option("--remove-trailing-newline", is_flag=True, help="Load Jinja with keep_trailing_newline=False.")
@click.option("--mode", type=click.Choice(['pedantic', 'debug']), help="In pedantic mode Yasha becomes extremely picky on templates, e.g. undefined variables will raise an error. In debug mode undefined variables will print as is.")
@click.option("-M", is_flag=True, help="Outputs Makefile compatible list of dependencies. Doesn't render the template.")
@click.option("-MD", is_flag=True, help="Creates Makefile compatible .d file alongside the rendered template.")
@click.option('--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True, help="Print version and exit.")
def cli(
template_variables, template, output, variables, extensions,
encoding, include_path, no_variable_file, no_extension_file,
no_trim_blocks, no_lstrip_blocks, remove_trailing_newline,
mode, m, md):
"""Reads the given Jinja TEMPLATE and renders its content
into a new file. For example, a template called 'foo.c.j2'
will be written into 'foo.c' in case the output file is not
explicitly given.
Template variables can be defined in a separate file or
given as part of the command-line call, e.g.
yasha --hello=world -o output.txt template.j2
defines a variable 'hello' for a template like:
Hello {{ hello }} !
"""
# Set the encoding of the template file
if encodings.search_function(encoding) is None:
msg = "Unrecognized encoding name '{}'"
raise ClickException(msg.format(encoding))
yasha.ENCODING = encoding
# Append include path of referenced templates
include_path = [os.path.dirname(template.name)] + list(include_path)
if not extensions or not variables:
template_companion = yasha.find_template_companion(template.name)
template_companion = list(template_companion)
if not extensions and not no_extension_file:
for file in template_companion:
if file.endswith(yasha.EXTENSION_FILE_FORMATS):
extensions = click.open_file(file, "rb")
break
if extensions:
load_extensions(extensions)
if not variables and not no_variable_file:
for file in template_companion:
if file.endswith(tuple(PARSERS.keys())):
variables = (click.open_file(file, "rb"),)
break
if not output:
if template.name == "<stdin>":
output = click.open_file("-", "wb")
else:
output = os.path.splitext(template.name)[0]
output = click.open_file(output, "wb", lazy=True)
if m or md:
deps = [os.path.relpath(template.name)]
for file in variables:
deps.append(os.path.relpath(file.name))
if extensions:
deps.append(os.path.relpath(extensions.name))
for d in yasha.find_referenced_templates(template, include_path):
deps.append(os.path.relpath(d))
deps = os.path.relpath(output.name) + ": " + " ".join(deps)
if m:
click.echo(deps)
return # Template won't be rendered
if md:
deps += os.linesep
output_d = click.open_file(output.name + ".d", "wb")
output_d.write(deps.encode(yasha.ENCODING))
# Load Jinja
jinja = yasha.load_jinja(
path=include_path,
tests=TESTS,
filters=FILTERS,
classes=CLASSES,
mode=mode,
trim_blocks=not no_trim_blocks,
lstrip_blocks=not no_lstrip_blocks,
keep_trailing_newline=not remove_trailing_newline
)
# Get template
if template.name == "<stdin>":
stdin = template.read()
t = jinja.from_string(stdin.decode(yasha.ENCODING))
else:
t = jinja.get_template(os.path.basename(template.name))
# Parse variables
context = dict()
for file in variables:
context.update(parse_variable_file(file))
context.update(yasha.parse_cli_variables(template_variables))
# Finally render template and save it
try:
t_stream = t.stream(context)
t_stream.enable_buffering(size=5)
t_stream.dump(output, encoding=yasha.ENCODING)
except JinjaUndefinedError as e:
raise ClickException("Variable {}".format(e))
|
mit
|
[
624,
199,
1918,
10697,
844,
334,
13965,
9,
199,
199,
7384,
334,
67,
9,
6900,
13,
22150,
1804,
1017,
699,
320,
8334,
433,
270,
199,
199,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
1618,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
262,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
475,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
16847,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
70,
13399,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
199,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
452,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
38,
3061,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
5580,
4149,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
2673,
2477,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
1877,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
18061,
4141,
14,
199,
199,
624,
199,
199,
646,
747,
199,
646,
14134,
199,
199,
646,
8968,
199,
504,
8968,
492,
26147,
1726,
199,
504,
10321,
18,
14,
3924,
492,
25868,
547,
465,
17300,
16283,
547,
199,
199,
504,
1275,
492,
612,
1119,
65,
199,
504,
1275,
2219,
492,
7393,
51,
199,
504,
1275,
4273,
492,
23244,
51,
199,
504,
1275,
2888,
492,
24221,
654,
199,
504,
1275,
11531,
492,
10263,
3279,
51,
199,
199,
318,
870,
63,
1023,
8,
3799,
12,
1215,
12,
574,
304,
272,
340,
440,
574,
503,
4027,
14,
20807,
864,
63,
11059,
26,
267,
372,
272,
8968,
14,
7878,
8,
89,
1119,
65,
855,
1023,
3368,
272,
4027,
14,
2224,
342,
199,
199,
318,
2198,
63,
1975,
63,
493,
8,
493,
304,
272,
862,
26,
267,
570,
63,
3435,
275,
747,
14,
515,
14,
7973,
8,
493,
14,
354,
2788,
17,
61,
267,
372,
10263,
3279,
51,
59,
493,
63,
3435,
8738,
493,
9,
272,
871,
4281,
26,
267,
372,
1211,
342,
272,
871,
4067,
26,
267,
1125,
275,
298,
1358,
75,
944,
1750,
570,
3329,
9005,
4065,
267,
746,
26147,
1726,
8,
705,
14,
908,
8,
493,
63,
3435,
430,
199,
199,
318,
2248,
63,
1548,
63,
578,
8,
493,
304,
272,
862,
26,
267,
687,
14802,
14,
14121,
20067,
492,
5800,
1173,
5455,
267,
5077,
275,
5800,
1173,
5455,
360,
89,
1119,
65,
63,
5359,
297,
570,
14,
354,
9,
267,
859,
275,
5077,
14,
912,
63,
578,
342,
272,
871,
3545,
26,
221,
327,
481,
5421,
370,
2018,
18,
267,
492,
1742,
267,
543,
1551,
8,
493,
14,
354,
9,
465,
289,
26,
288,
4328,
275,
334,
1674,
647,
401,
298,
4848,
401,
1742,
14,
4521,
63,
10187,
9,
288,
859,
275,
1742,
14,
912,
63,
578,
360,
89,
1119,
65,
63,
5359,
297,
289,
12,
570,
14,
354,
12,
4328,
9,
267,
986,
272,
372,
859,
199,
199,
318,
2248,
63,
5359,
8,
493,
304,
272,
687,
10321,
18,
14,
832,
492,
13282,
272,
492,
6485,
339,
2295,
257,
275,
1211,
342,
272,
4766,
275,
1211,
342,
272,
21295,
275,
1211,
342,
272,
3992,
275,
942,
339,
862,
26,
267,
859,
275,
2248,
63,
1548,
63,
578,
8,
493,
9,
272,
871,
12746,
465,
325,
26,
267,
1499,
275,
283,
6005,
370,
2248,
5478,
12,
1052,
7,
267,
746,
26147,
1726,
8,
1328,
14,
908,
8,
69,
430,
272,
871,
12053,
465,
325,
26,
267,
1499,
275,
298,
6005,
370,
2248,
5478,
60,
78,
2440,
11459,
1386,
1004,
1052,
2924,
267,
1125,
275,
325,
14,
1328,
59,
16,
1055,
4142,
342,
435,
325,
14,
1328,
59,
17,
2938,
267,
1788,
275,
747,
14,
515,
14,
12405,
8,
69,
14,
1501,
9,
267,
746,
26147,
1726,
8,
1328,
14,
908,
8,
705,
12,
1788,
12,
325,
14,
3469,
430,
339,
367,
1921,
315,
359,
5675,
8,
578,
12,
671,
9,
367,
671,
315,
2935,
8,
578,
19532,
267,
340,
6485,
14,
374,
1593,
8,
962,
304,
288,
340,
1921,
855,
354,
4343,
2460,
360,
396,
25865,
355,
536,
275,
1921,
855,
354,
12298,
21,
2938,
355,
2295,
59,
354,
61,
275,
1921,
288,
340,
1921,
855,
354,
4343,
2460,
360,
1541,
25865,
355,
536,
275,
1921,
855,
354,
12298,
23,
2938,
355,
4766,
59,
354,
61,
275,
1921,
288,
340,
1921,
855,
354,
4343,
2460,
360,
1122,
25865,
355,
536,
275,
1921,
855,
354,
12298,
22,
2938,
355,
21295,
459,
3530,
435,
536,
61,
275,
1921,
267,
340,
6485,
14,
28450,
8,
962,
304,
288,
340,
11602,
8,
962,
12,
13282,
304,
355,
3992,
14,
740,
8,
962,
9,
339,
492,
10321,
18,
14,
4322,
272,
367,
536,
12,
1559,
315,
6485,
14,
28719,
8,
578,
304,
267,
340,
536,
315,
2008,
8,
88,
367,
671,
315,
2935,
8,
12264,
18,
14,
4322,
9,
340,
671,
14,
374,
4142,
5109,
288,
5371,
8,
12264,
18,
14,
4322,
12,
536,
12,
1559,
9,
339,
862,
26,
267,
7393,
51,
14,
873,
8,
578,
14,
7569,
9,
272,
871,
4281,
26,
267,
7393,
51,
14,
873,
8,
2219,
9,
339,
862,
26,
267,
23244,
51,
14,
873,
8,
578,
14,
9905,
51,
9,
272,
871,
4281,
26,
267,
23244,
51,
14,
873,
8,
4273,
9,
339,
862,
26,
267,
10263,
3279,
51,
14,
873,
8,
578,
14,
26078,
51,
9,
272,
871,
4281,
26,
267,
10263,
3279,
51,
14,
873,
8,
11531,
9,
339,
862,
26,
267,
24221,
654,
14,
2880,
8,
578,
14,
13748,
9,
272,
871,
4281,
26,
267,
24221,
654,
14,
2880,
8,
2888,
9,
421,
199,
32,
4891,
14,
1531,
8,
1100,
63,
1751,
29,
807,
8,
272,
1720,
63,
1422,
63,
1247,
6270,
13,
72,
401,
4320,
3437,
2255,
272,
3686,
63,
5187,
63,
1419,
29
] |
[
199,
1918,
10697,
844,
334,
13965,
9,
199,
199,
7384,
334,
67,
9,
6900,
13,
22150,
1804,
1017,
699,
320,
8334,
433,
270,
199,
199,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
1618,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
262,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
475,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
16847,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
70,
13399,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
199,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
452,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
38,
3061,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
5580,
4149,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
2673,
2477,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
1877,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
18061,
4141,
14,
199,
199,
624,
199,
199,
646,
747,
199,
646,
14134,
199,
199,
646,
8968,
199,
504,
8968,
492,
26147,
1726,
199,
504,
10321,
18,
14,
3924,
492,
25868,
547,
465,
17300,
16283,
547,
199,
199,
504,
1275,
492,
612,
1119,
65,
199,
504,
1275,
2219,
492,
7393,
51,
199,
504,
1275,
4273,
492,
23244,
51,
199,
504,
1275,
2888,
492,
24221,
654,
199,
504,
1275,
11531,
492,
10263,
3279,
51,
199,
199,
318,
870,
63,
1023,
8,
3799,
12,
1215,
12,
574,
304,
272,
340,
440,
574,
503,
4027,
14,
20807,
864,
63,
11059,
26,
267,
372,
272,
8968,
14,
7878,
8,
89,
1119,
65,
855,
1023,
3368,
272,
4027,
14,
2224,
342,
199,
199,
318,
2198,
63,
1975,
63,
493,
8,
493,
304,
272,
862,
26,
267,
570,
63,
3435,
275,
747,
14,
515,
14,
7973,
8,
493,
14,
354,
2788,
17,
61,
267,
372,
10263,
3279,
51,
59,
493,
63,
3435,
8738,
493,
9,
272,
871,
4281,
26,
267,
372,
1211,
342,
272,
871,
4067,
26,
267,
1125,
275,
298,
1358,
75,
944,
1750,
570,
3329,
9005,
4065,
267,
746,
26147,
1726,
8,
705,
14,
908,
8,
493,
63,
3435,
430,
199,
199,
318,
2248,
63,
1548,
63,
578,
8,
493,
304,
272,
862,
26,
267,
687,
14802,
14,
14121,
20067,
492,
5800,
1173,
5455,
267,
5077,
275,
5800,
1173,
5455,
360,
89,
1119,
65,
63,
5359,
297,
570,
14,
354,
9,
267,
859,
275,
5077,
14,
912,
63,
578,
342,
272,
871,
3545,
26,
221,
327,
481,
5421,
370,
2018,
18,
267,
492,
1742,
267,
543,
1551,
8,
493,
14,
354,
9,
465,
289,
26,
288,
4328,
275,
334,
1674,
647,
401,
298,
4848,
401,
1742,
14,
4521,
63,
10187,
9,
288,
859,
275,
1742,
14,
912,
63,
578,
360,
89,
1119,
65,
63,
5359,
297,
289,
12,
570,
14,
354,
12,
4328,
9,
267,
986,
272,
372,
859,
199,
199,
318,
2248,
63,
5359,
8,
493,
304,
272,
687,
10321,
18,
14,
832,
492,
13282,
272,
492,
6485,
339,
2295,
257,
275,
1211,
342,
272,
4766,
275,
1211,
342,
272,
21295,
275,
1211,
342,
272,
3992,
275,
942,
339,
862,
26,
267,
859,
275,
2248,
63,
1548,
63,
578,
8,
493,
9,
272,
871,
12746,
465,
325,
26,
267,
1499,
275,
283,
6005,
370,
2248,
5478,
12,
1052,
7,
267,
746,
26147,
1726,
8,
1328,
14,
908,
8,
69,
430,
272,
871,
12053,
465,
325,
26,
267,
1499,
275,
298,
6005,
370,
2248,
5478,
60,
78,
2440,
11459,
1386,
1004,
1052,
2924,
267,
1125,
275,
325,
14,
1328,
59,
16,
1055,
4142,
342,
435,
325,
14,
1328,
59,
17,
2938,
267,
1788,
275,
747,
14,
515,
14,
12405,
8,
69,
14,
1501,
9,
267,
746,
26147,
1726,
8,
1328,
14,
908,
8,
705,
12,
1788,
12,
325,
14,
3469,
430,
339,
367,
1921,
315,
359,
5675,
8,
578,
12,
671,
9,
367,
671,
315,
2935,
8,
578,
19532,
267,
340,
6485,
14,
374,
1593,
8,
962,
304,
288,
340,
1921,
855,
354,
4343,
2460,
360,
396,
25865,
355,
536,
275,
1921,
855,
354,
12298,
21,
2938,
355,
2295,
59,
354,
61,
275,
1921,
288,
340,
1921,
855,
354,
4343,
2460,
360,
1541,
25865,
355,
536,
275,
1921,
855,
354,
12298,
23,
2938,
355,
4766,
59,
354,
61,
275,
1921,
288,
340,
1921,
855,
354,
4343,
2460,
360,
1122,
25865,
355,
536,
275,
1921,
855,
354,
12298,
22,
2938,
355,
21295,
459,
3530,
435,
536,
61,
275,
1921,
267,
340,
6485,
14,
28450,
8,
962,
304,
288,
340,
11602,
8,
962,
12,
13282,
304,
355,
3992,
14,
740,
8,
962,
9,
339,
492,
10321,
18,
14,
4322,
272,
367,
536,
12,
1559,
315,
6485,
14,
28719,
8,
578,
304,
267,
340,
536,
315,
2008,
8,
88,
367,
671,
315,
2935,
8,
12264,
18,
14,
4322,
9,
340,
671,
14,
374,
4142,
5109,
288,
5371,
8,
12264,
18,
14,
4322,
12,
536,
12,
1559,
9,
339,
862,
26,
267,
7393,
51,
14,
873,
8,
578,
14,
7569,
9,
272,
871,
4281,
26,
267,
7393,
51,
14,
873,
8,
2219,
9,
339,
862,
26,
267,
23244,
51,
14,
873,
8,
578,
14,
9905,
51,
9,
272,
871,
4281,
26,
267,
23244,
51,
14,
873,
8,
4273,
9,
339,
862,
26,
267,
10263,
3279,
51,
14,
873,
8,
578,
14,
26078,
51,
9,
272,
871,
4281,
26,
267,
10263,
3279,
51,
14,
873,
8,
11531,
9,
339,
862,
26,
267,
24221,
654,
14,
2880,
8,
578,
14,
13748,
9,
272,
871,
4281,
26,
267,
24221,
654,
14,
2880,
8,
2888,
9,
421,
199,
32,
4891,
14,
1531,
8,
1100,
63,
1751,
29,
807,
8,
272,
1720,
63,
1422,
63,
1247,
6270,
13,
72,
401,
4320,
3437,
2255,
272,
3686,
63,
5187,
63,
1419,
29,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
compmetagen/micca
|
micca/tp/muscle.py
|
1
|
1664
|
## Copyright 2016 Davide Albanese <davide.albanese@gmail.com>
## Copyright 2016 Fondazione Edmund Mach (FEM)
## This file is part of micca.
##
## micca 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.
##
## micca 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 micca. If not, see <http://www.gnu.org/licenses/>.
import subprocess
import os
import sys
from micca import THIRDPARTY_BIN_PATH
__all__ = ["MUSCLEError", "muscle", "maketree"]
class MUSCLEError(Exception):
pass
def _muscle_cmd(params):
muscle_bin = os.path.join(THIRDPARTY_BIN_PATH, "muscle")
params.insert(0, muscle_bin)
proc = subprocess.Popen(params, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc_stdout, proc_stderr = proc.communicate()
if proc.returncode:
raise MUSCLEError(proc_stderr)
def muscle(input_fn, output_fn, maxiters=16):
params = ["-in", input_fn, "-out", output_fn, "-maxiters", str(maxiters)]
_muscle_cmd(params)
def maketree(input_fn, output_fn, cluster="upgmb"):
params = ["-maketree", "-in", input_fn, "-out", output_fn, "-cluster",
cluster]
_muscle_cmd(params)
|
gpl-3.0
|
[
309,
259,
1898,
7800,
577,
65,
5624,
4580,
66,
24452,
665,
983,
5624,
14,
279,
66,
24452,
32,
6799,
14,
957,
30,
199,
309,
259,
1898,
7800,
481,
265,
983,
16079,
368,
662,
6428,
725,
30611,
334,
38,
2769,
9,
199,
199,
309,
259,
961,
570,
365,
1777,
402,
333,
530,
696,
14,
199,
309,
199,
309,
259,
333,
530,
696,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
309,
259,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
309,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
309,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
199,
309,
259,
333,
530,
696,
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,
199,
309,
259,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
199,
309,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
309,
259,
3180,
543,
333,
530,
696,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
646,
3873,
199,
646,
747,
199,
646,
984,
199,
199,
504,
333,
530,
696,
492,
4221,
3927,
36,
4014,
2099,
63,
9431,
63,
3243,
199,
199,
363,
452,
363,
275,
2097,
45,
1668,
12507,
547,
401,
298,
77,
527,
2265,
401,
298,
22191,
9464,
937,
421,
199,
533,
603,
1668,
12507,
547,
8,
1726,
304,
272,
986,
421,
199,
318,
485,
77,
527,
2265,
63,
1760,
8,
1162,
304,
272,
333,
527,
2265,
63,
1393,
275,
747,
14,
515,
14,
904,
8,
2080,
3927,
36,
4014,
2099,
63,
9431,
63,
3243,
12,
298,
77,
527,
2265,
531,
2286,
1862,
14,
3176,
8,
16,
12,
333,
527,
2265,
63,
1393,
9,
272,
6499,
275,
3873,
14,
7942,
8,
1162,
12,
3839,
29,
5781,
14,
6089,
12,
1169,
4635,
29,
5781,
14,
6089,
9,
272,
6499,
63,
2703,
12,
6499,
63,
3083,
275,
6499,
14,
10664,
342,
272,
340,
6499,
14,
9913,
26,
267,
746,
603,
1668,
12507,
547,
8,
4687,
63,
3083,
9,
10813,
199,
318,
333,
527,
2265,
8,
1210,
63,
2324,
12,
1072,
63,
2324,
12,
1390,
15266,
29,
975,
304,
272,
1862,
275,
221,
16984,
262,
401,
1324,
63,
2324,
12,
3905,
548,
401,
1072,
63,
2324,
12,
3905,
988,
15266,
401,
620,
8,
988,
15266,
1874,
272,
485,
77,
527,
2265,
63,
1760,
8,
1162,
9,
10813,
199,
318,
5475,
9464,
8,
1210,
63,
2324,
12,
1072,
63,
2324,
12,
4350,
628,
384,
71,
887,
2349,
272,
1862,
275,
221,
16984,
22191,
9464,
401,
3905,
262,
401,
1324,
63,
2324,
12,
3905,
548,
401,
1072,
63,
2324,
12,
3905,
4201,
401,
19056,
4350,
61,
272,
485,
77,
527,
2265,
63,
1760,
8,
1162,
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
] |
[
259,
1898,
7800,
577,
65,
5624,
4580,
66,
24452,
665,
983,
5624,
14,
279,
66,
24452,
32,
6799,
14,
957,
30,
199,
309,
259,
1898,
7800,
481,
265,
983,
16079,
368,
662,
6428,
725,
30611,
334,
38,
2769,
9,
199,
199,
309,
259,
961,
570,
365,
1777,
402,
333,
530,
696,
14,
199,
309,
199,
309,
259,
333,
530,
696,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
309,
259,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
309,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
309,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
199,
309,
259,
333,
530,
696,
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,
199,
309,
259,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
199,
309,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
309,
259,
3180,
543,
333,
530,
696,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
646,
3873,
199,
646,
747,
199,
646,
984,
199,
199,
504,
333,
530,
696,
492,
4221,
3927,
36,
4014,
2099,
63,
9431,
63,
3243,
199,
199,
363,
452,
363,
275,
2097,
45,
1668,
12507,
547,
401,
298,
77,
527,
2265,
401,
298,
22191,
9464,
937,
421,
199,
533,
603,
1668,
12507,
547,
8,
1726,
304,
272,
986,
421,
199,
318,
485,
77,
527,
2265,
63,
1760,
8,
1162,
304,
272,
333,
527,
2265,
63,
1393,
275,
747,
14,
515,
14,
904,
8,
2080,
3927,
36,
4014,
2099,
63,
9431,
63,
3243,
12,
298,
77,
527,
2265,
531,
2286,
1862,
14,
3176,
8,
16,
12,
333,
527,
2265,
63,
1393,
9,
272,
6499,
275,
3873,
14,
7942,
8,
1162,
12,
3839,
29,
5781,
14,
6089,
12,
1169,
4635,
29,
5781,
14,
6089,
9,
272,
6499,
63,
2703,
12,
6499,
63,
3083,
275,
6499,
14,
10664,
342,
272,
340,
6499,
14,
9913,
26,
267,
746,
603,
1668,
12507,
547,
8,
4687,
63,
3083,
9,
10813,
199,
318,
333,
527,
2265,
8,
1210,
63,
2324,
12,
1072,
63,
2324,
12,
1390,
15266,
29,
975,
304,
272,
1862,
275,
221,
16984,
262,
401,
1324,
63,
2324,
12,
3905,
548,
401,
1072,
63,
2324,
12,
3905,
988,
15266,
401,
620,
8,
988,
15266,
1874,
272,
485,
77,
527,
2265,
63,
1760,
8,
1162,
9,
10813,
199,
318,
5475,
9464,
8,
1210,
63,
2324,
12,
1072,
63,
2324,
12,
4350,
628,
384,
71,
887,
2349,
272,
1862,
275,
221,
16984,
22191,
9464,
401,
3905,
262,
401,
1324,
63,
2324,
12,
3905,
548,
401,
1072,
63,
2324,
12,
3905,
4201,
401,
19056,
4350,
61,
272,
485,
77,
527,
2265,
63,
1760,
8,
1162,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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: utf-8 -*-
"""
Ansible module to add authorized_keys for ssh logins.
(c) 2012, Brad Olson <brado@movedbylight.com>
This file is part of Ansible
Ansible is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Ansible is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Ansible. If not, see <http://www.gnu.org/licenses/>.
"""
DOCUMENTATION = '''
---
module: authorized_key
short_description: Adds or removes an SSH authorized key
description:
- Adds or removes an SSH authorized key for a user from a remote host.
version_added: "0.5"
options:
user:
description:
- The username on the remote host whose authorized_keys file will be modified
required: true
default: null
key:
description:
- The SSH public key(s), as a string or (since 1.9) url (https://github.com/username.keys)
required: true
default: null
path:
description:
- Alternate path to the authorized_keys file
required: false
default: "(homedir)+/.ssh/authorized_keys"
version_added: "1.2"
manage_dir:
description:
- Whether this module should manage the directory of the authorized key file. If
set, the module will create the directory, as well as set the owner and permissions
of an existing directory. Be sure to
set C(manage_dir=no) if you are using an alternate directory for
authorized_keys, as set with C(path), since you could lock yourself out of
SSH access. See the example below.
required: false
choices: [ "yes", "no" ]
default: "yes"
version_added: "1.2"
state:
description:
- Whether the given key (with the given key_options) should or should not be in the file
required: false
choices: [ "present", "absent" ]
default: "present"
key_options:
description:
- A string of ssh key options to be prepended to the key in the authorized_keys file
required: false
default: null
version_added: "1.4"
exclusive:
description:
- Whether to remove all other non-specified keys from the authorized_keys file. Multiple keys
can be specified in a single C(key) string value by separating them by newlines.
- This option is not loop aware, so if you use C(with_) , it will be exclusive per iteration
of the loop, if you want multiple keys in the file you need to pass them all to C(key) in a
single batch as mentioned above.
required: false
choices: [ "yes", "no" ]
default: "no"
version_added: "1.9"
description:
- "Adds or removes authorized keys for particular user accounts"
author: "Brad Olson (@bradobro)"
'''
EXAMPLES = '''
# Example using key data from a local file on the management machine
- authorized_key: user=charlie key="{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
# Using github url as key source
- authorized_key: user=charlie key=https://github.com/charlie.keys
# Using alternate directory locations:
- authorized_key: user=charlie
key="{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
path='/etc/ssh/authorized_keys/charlie'
manage_dir=no
# Using with_file
- name: Set up authorized_keys for the deploy user
authorized_key: user=deploy
key="{{ item }}"
with_file:
- public_keys/doe-jane
- public_keys/doe-john
# Using key_options:
- authorized_key: user=charlie
key="{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
key_options='no-port-forwarding,from="10.0.1.1"'
# Set up authorized_keys exclusively with one key
- authorized_key: user=root key="{{ item }}" state=present
exclusive=yes
with_file:
- public_keys/doe-jane
'''
# Makes sure the public key line is present or absent in the user's .ssh/authorized_keys.
#
# Arguments
# =========
# user = username
# key = line to add to authorized_keys for user
# path = path to the user's authorized_keys file (default: ~/.ssh/authorized_keys)
# manage_dir = whether to create, and control ownership of the directory (default: true)
# state = absent|present (default: present)
#
# see example in examples/playbooks
import sys
import os
import pwd
import os.path
import tempfile
import re
import shlex
class keydict(dict):
""" a dictionary that maintains the order of keys as they are added """
# http://stackoverflow.com/questions/2328235/pythonextend-the-dict-class
def __init__(self, *args, **kw):
super(keydict,self).__init__(*args, **kw)
self.itemlist = super(keydict,self).keys()
def __setitem__(self, key, value):
self.itemlist.append(key)
super(keydict,self).__setitem__(key, value)
def __iter__(self):
return iter(self.itemlist)
def keys(self):
return self.itemlist
def values(self):
return [self[key] for key in self]
def itervalues(self):
return (self[key] for key in self)
def keyfile(module, user, write=False, path=None, manage_dir=True):
"""
Calculate name of authorized keys file, optionally creating the
directories and file, properly setting permissions.
:param str user: name of user in passwd file
:param bool write: if True, write changes to authorized_keys file (creating directories if needed)
:param str path: if not None, use provided path rather than default of '~user/.ssh/authorized_keys'
:param bool manage_dir: if True, create and set ownership of the parent dir of the authorized_keys file
:return: full path string to authorized_keys for user
"""
if module.check_mode and path is not None:
keysfile = path
return keysfile
try:
user_entry = pwd.getpwnam(user)
except KeyError, e:
if module.check_mode and path is None:
module.fail_json(msg="Either user must exist or you must provide full path to key file in check mode")
module.fail_json(msg="Failed to lookup user %s: %s" % (user, str(e)))
if path is None:
homedir = user_entry.pw_dir
sshdir = os.path.join(homedir, ".ssh")
keysfile = os.path.join(sshdir, "authorized_keys")
else:
sshdir = os.path.dirname(path)
keysfile = path
if not write:
return keysfile
uid = user_entry.pw_uid
gid = user_entry.pw_gid
if manage_dir:
if not os.path.exists(sshdir):
os.mkdir(sshdir, 0700)
if module.selinux_enabled():
module.set_default_selinux_context(sshdir, False)
os.chown(sshdir, uid, gid)
os.chmod(sshdir, 0700)
if not os.path.exists(keysfile):
basedir = os.path.dirname(keysfile)
if not os.path.exists(basedir):
os.makedirs(basedir)
try:
f = open(keysfile, "w") #touches file so we can set ownership and perms
finally:
f.close()
if module.selinux_enabled():
module.set_default_selinux_context(keysfile, False)
try:
os.chown(keysfile, uid, gid)
os.chmod(keysfile, 0600)
except OSError:
pass
return keysfile
def parseoptions(module, options):
'''
reads a string containing ssh-key options
and returns a dictionary of those options
'''
options_dict = keydict() #ordered dict
if options:
try:
# the following regex will split on commas while
# ignoring those commas that fall within quotes
regex = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''')
parts = regex.split(options)[1:-1]
for part in parts:
if "=" in part:
(key, value) = part.split("=", 1)
options_dict[key] = value
elif part != ",":
options_dict[part] = None
except:
module.fail_json(msg="invalid option string: %s" % options)
return options_dict
def parsekey(module, raw_key):
'''
parses a key, which may or may not contain a list
of ssh-key options at the beginning
'''
VALID_SSH2_KEY_TYPES = [
'ssh-ed25519',
'ecdsa-sha2-nistp256',
'ecdsa-sha2-nistp384',
'ecdsa-sha2-nistp521',
'ssh-dss',
'ssh-rsa',
]
options = None # connection options
key = None # encrypted key string
key_type = None # type of ssh key
type_index = None # index of keytype in key string|list
# remove comment yaml escapes
raw_key = raw_key.replace('\#', '#')
# split key safely
lex = shlex.shlex(raw_key)
lex.quotes = []
lex.commenters = '' #keep comment hashes
lex.whitespace_split = True
key_parts = list(lex)
for i in range(0, len(key_parts)):
if key_parts[i] in VALID_SSH2_KEY_TYPES:
type_index = i
key_type = key_parts[i]
break
# check for options
if type_index is None:
return None
elif type_index > 0:
options = " ".join(key_parts[:type_index])
# parse the options (if any)
options = parseoptions(module, options)
# get key after the type index
key = key_parts[(type_index + 1)]
# set comment to everything after the key
if len(key_parts) > (type_index + 1):
comment = " ".join(key_parts[(type_index + 2):])
return (key, key_type, options, comment)
def readkeys(module, filename):
if not os.path.isfile(filename):
return {}
keys = {}
f = open(filename)
for line in f.readlines():
key_data = parsekey(module, line)
if key_data:
# use key as identifier
keys[key_data[0]] = key_data
else:
# for an invalid line, just append the line
# to the array so it will be re-output later
keys[line] = line
f.close()
return keys
def writekeys(module, filename, keys):
fd, tmp_path = tempfile.mkstemp('', 'tmp', os.path.dirname(filename))
f = open(tmp_path,"w")
try:
for index, key in keys.items():
try:
(keyhash,type,options,comment) = key
option_str = ""
if options:
option_strings = []
for option_key in options.keys():
if options[option_key]:
option_strings.append("%s=%s" % (option_key, options[option_key]))
else:
option_strings.append("%s" % option_key)
option_str = ",".join(option_strings)
option_str += " "
key_line = "%s%s %s %s\n" % (option_str, type, keyhash, comment)
except:
key_line = key
f.writelines(key_line)
except IOError, e:
module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, str(e)))
f.close()
module.atomic_move(tmp_path, filename)
def enforce_state(module, params):
"""
Add or remove key.
"""
user = params["user"]
key = params["key"]
path = params.get("path", None)
manage_dir = params.get("manage_dir", True)
state = params.get("state", "present")
key_options = params.get("key_options", None)
exclusive = params.get("exclusive", False)
error_msg = "Error getting key from: %s"
# if the key is a url, request it and use it as key source
if key.startswith("http"):
try:
resp, info = fetch_url(module, key)
if info['status'] != 200:
module.fail_json(msg=error_msg % key)
else:
key = resp.read()
except Exception:
module.fail_json(msg=error_msg % key)
# extract individual keys into an array, skipping blank lines and comments
key = [s for s in key.splitlines() if s and not s.startswith('#')]
# check current state -- just get the filename, don't create file
do_write = False
params["keyfile"] = keyfile(module, user, do_write, path, manage_dir)
existing_keys = readkeys(module, params["keyfile"])
# Add a place holder for keys that should exist in the state=present and
# exclusive=true case
keys_to_exist = []
# Check our new keys, if any of them exist we'll continue.
for new_key in key:
parsed_new_key = parsekey(module, new_key)
if not parsed_new_key:
module.fail_json(msg="invalid key specified: %s" % new_key)
if key_options is not None:
parsed_options = parseoptions(module, key_options)
parsed_new_key = (parsed_new_key[0], parsed_new_key[1], parsed_options, parsed_new_key[3])
present = False
matched = False
non_matching_keys = []
if parsed_new_key[0] in existing_keys:
present = True
# Then we check if everything matches, including
# the key type and options. If not, we append this
# existing key to the non-matching list
# We only want it to match everything when the state
# is present
if parsed_new_key != existing_keys[parsed_new_key[0]] and state == "present":
non_matching_keys.append(existing_keys[parsed_new_key[0]])
else:
matched = True
# handle idempotent state=present
if state=="present":
keys_to_exist.append(parsed_new_key[0])
if len(non_matching_keys) > 0:
for non_matching_key in non_matching_keys:
if non_matching_key[0] in existing_keys:
del existing_keys[non_matching_key[0]]
do_write = True
if not matched:
existing_keys[parsed_new_key[0]] = parsed_new_key
do_write = True
elif state=="absent":
if not matched:
continue
del existing_keys[parsed_new_key[0]]
do_write = True
# remove all other keys to honor exclusive
if state == "present" and exclusive:
to_remove = frozenset(existing_keys).difference(keys_to_exist)
for key in to_remove:
del existing_keys[key]
do_write = True
if do_write:
if module.check_mode:
module.exit_json(changed=True)
writekeys(module, keyfile(module, user, do_write, path, manage_dir), existing_keys)
params['changed'] = True
else:
if module.check_mode:
module.exit_json(changed=False)
return params
def main():
module = AnsibleModule(
argument_spec = dict(
user = dict(required=True, type='str'),
key = dict(required=True, type='str'),
path = dict(required=False, type='str'),
manage_dir = dict(required=False, type='bool', default=True),
state = dict(default='present', choices=['absent','present']),
key_options = dict(required=False, type='str'),
unique = dict(default=False, type='bool'),
exclusive = dict(default=False, type='bool'),
),
supports_check_mode=True
)
results = enforce_state(module, module.params)
module.exit_json(**results)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.urls import *
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
10047,
859,
370,
1050,
18788,
63,
1612,
367,
8635,
4676,
83,
14,
199,
8,
67,
9,
6029,
12,
699,
9525,
593,
478,
265,
665,
7828,
1117,
32,
3539,
991,
4040,
14,
957,
30,
199,
199,
2765,
570,
365,
1777,
402,
2622,
199,
199,
10047,
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,
10047,
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,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
624,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
18788,
63,
498,
199,
3612,
63,
1802,
26,
15747,
503,
14185,
376,
12027,
18788,
790,
199,
1802,
26,
1362,
446,
15747,
503,
14185,
376,
12027,
18788,
790,
367,
282,
922,
687,
282,
3982,
1591,
14,
199,
1023,
63,
3270,
26,
298,
16,
14,
21,
2,
199,
1419,
26,
523,
922,
26,
272,
1369,
26,
489,
446,
710,
3434,
641,
314,
3982,
1591,
7447,
18788,
63,
1612,
570,
911,
506,
6042,
272,
1415,
26,
2549,
272,
849,
26,
2973,
523,
790,
26,
272,
1369,
26,
489,
446,
710,
12027,
4575,
790,
8,
83,
395,
465,
282,
1059,
503,
334,
8585,
413,
14,
25,
9,
1166,
334,
2859,
921,
5031,
14,
957,
15,
2473,
14,
1612,
9,
272,
1415,
26,
2549,
272,
849,
26,
2973,
523,
931,
26,
272,
1369,
26,
489,
446,
17669,
323,
931,
370,
314,
18788,
63,
1612,
570,
272,
1415,
26,
3055,
272,
849,
26,
7340,
4219,
694,
6393,
8083,
5510,
15,
11497,
63,
1612,
2,
272,
1015,
63,
3270,
26,
298,
17,
14,
18,
2,
523,
9635,
63,
694,
26,
272,
1369,
26,
489,
446,
7480,
642,
859,
1077,
9635,
314,
2082,
402,
314,
18788,
790,
570,
14,
221,
982,
267,
663,
12,
314,
859,
911,
1218,
314,
2082,
12,
465,
5521,
465,
663,
314,
5771,
436,
3443,
267,
402,
376,
3411,
2082,
14,
6423,
3238,
370,
267,
663,
445,
8,
9053,
63,
694,
29,
889,
9,
340,
1265,
787,
1808,
376,
18034,
2082,
367,
267,
18788,
63,
1612,
12,
465,
663,
543,
445,
8,
515,
395,
3967,
1265,
4293,
4650,
28225,
734,
402,
267,
12027,
2879,
14,
1666,
314,
2893,
5084,
14,
272,
1415,
26,
3055,
272,
3415,
26,
359,
298,
5066,
401,
298,
889,
2,
1622,
272,
849,
26,
298,
5066,
2,
272,
1015,
63,
3270,
26,
298,
17,
14,
18,
2,
523,
1174,
26,
272,
1369,
26,
489,
446,
7480,
314,
1627,
790,
334,
1045,
314,
1627,
790,
63,
1419,
9,
1077,
503,
1077,
440,
506,
315,
314,
570,
272,
1415,
26,
3055,
272,
3415,
26,
359,
298,
1881,
401,
298,
5575,
2,
1622,
272,
849,
26,
298,
1881,
2,
523,
790,
63,
1419,
26,
272,
1369,
26,
489,
446,
437,
1059,
402,
8635,
790,
1511,
370,
506,
20247,
370,
314,
790,
315,
314,
18788,
63,
1612,
570,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
1015,
63,
3270,
26,
298,
17,
14,
20,
2,
523,
13914,
26,
272,
1369,
26,
489,
446,
7480,
370,
2813,
1006,
1163,
2222,
13,
10085,
2883,
687,
314,
18788,
63,
1612,
570,
14,
14326,
2883,
267,
883,
506,
2013,
315,
282,
2849,
445,
8,
498,
9,
1059,
574,
701,
4216,
1958,
3062,
701,
14930,
14,
489,
446,
961,
945,
365,
440,
4438,
20381,
12,
880,
340,
1265,
675,
445,
8,
1045,
4602,
2360,
652,
911,
506,
13914,
1126,
8494,
267,
402,
314,
4438,
12,
340,
1265,
2934,
3663,
2883,
315,
314,
570,
1265,
1929,
370,
986,
3062,
1006,
370,
445,
8,
498,
9,
315,
282,
267,
2849,
3522,
465,
26239,
3432,
14,
272,
1415,
26,
3055,
272,
3415,
26,
359,
298,
5066,
401,
298,
889,
2,
1622,
272,
849,
26,
298,
889,
2,
272,
1015,
63,
3270,
26,
298,
17,
14,
25,
2,
199,
1802,
26,
272,
446,
298,
14995,
503,
14185,
18788,
2883,
367,
6770,
922,
12639,
2,
199,
2502,
26,
298,
34,
9525,
593,
478,
265,
8593,
7828,
1117,
20670,
2924,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5679,
1808,
790,
666,
687,
282,
2257,
570,
641,
314,
10041,
6844,
199,
13,
18788,
63,
498,
26,
922,
29,
1560,
21530,
790,
628,
3638,
4237,
360,
493,
297,
1994,
4219,
15,
1560,
21530,
8083,
5510,
15,
344,
63,
13487,
14,
5645,
358,
7820,
199,
199,
3,
11719,
12869,
1166,
465,
790,
1350,
199,
13,
18788,
63,
498,
26,
922,
29,
1560,
21530,
790,
29,
2859,
921,
5031,
14,
957,
15,
1560,
21530,
14,
1612,
199,
199,
3,
11719,
18034,
2082,
9918,
26,
199,
13,
18788,
63,
498,
26,
922,
29,
1560,
21530,
2116,
790,
628,
3638,
4237,
360,
493,
297,
1994,
4219,
15,
1560,
21530,
8083,
5510,
15,
344,
63,
13487,
14,
5645,
358,
7820,
2116,
931,
8805,
6839,
15,
5510,
15,
11497,
63,
1612,
15,
1560,
21530,
7,
2116,
9635,
63,
694,
29,
889,
199,
199,
3,
11719,
543,
63,
493,
199,
13,
536,
26,
2494,
1536,
18788,
63,
1612,
367,
314,
12287,
922,
523,
18788,
63,
498,
26,
922,
29,
11060,
2116,
790,
628,
3638,
1242,
7820,
523,
543,
63,
493,
26,
272,
446,
4575,
63,
1612,
15,
1117,
69,
13,
74,
5865,
272,
446,
4575,
63,
1612,
15,
1117,
69,
13,
20216,
199,
199,
3,
11719,
790,
63,
1419,
26,
199,
13,
18788,
63,
498,
26,
922,
29,
1560,
21530,
2116,
790,
628,
3638,
4237,
360,
493,
297,
1994,
4219,
15,
1560,
21530,
8083,
5510,
15,
344,
63,
13487,
14,
5645,
358,
7820,
2116,
790,
63,
1419,
534,
889,
13,
719,
13,
21513,
12,
504,
628,
709,
14
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
10047,
859,
370,
1050,
18788,
63,
1612,
367,
8635,
4676,
83,
14,
199,
8,
67,
9,
6029,
12,
699,
9525,
593,
478,
265,
665,
7828,
1117,
32,
3539,
991,
4040,
14,
957,
30,
199,
199,
2765,
570,
365,
1777,
402,
2622,
199,
199,
10047,
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,
10047,
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,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
624,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
18788,
63,
498,
199,
3612,
63,
1802,
26,
15747,
503,
14185,
376,
12027,
18788,
790,
199,
1802,
26,
1362,
446,
15747,
503,
14185,
376,
12027,
18788,
790,
367,
282,
922,
687,
282,
3982,
1591,
14,
199,
1023,
63,
3270,
26,
298,
16,
14,
21,
2,
199,
1419,
26,
523,
922,
26,
272,
1369,
26,
489,
446,
710,
3434,
641,
314,
3982,
1591,
7447,
18788,
63,
1612,
570,
911,
506,
6042,
272,
1415,
26,
2549,
272,
849,
26,
2973,
523,
790,
26,
272,
1369,
26,
489,
446,
710,
12027,
4575,
790,
8,
83,
395,
465,
282,
1059,
503,
334,
8585,
413,
14,
25,
9,
1166,
334,
2859,
921,
5031,
14,
957,
15,
2473,
14,
1612,
9,
272,
1415,
26,
2549,
272,
849,
26,
2973,
523,
931,
26,
272,
1369,
26,
489,
446,
17669,
323,
931,
370,
314,
18788,
63,
1612,
570,
272,
1415,
26,
3055,
272,
849,
26,
7340,
4219,
694,
6393,
8083,
5510,
15,
11497,
63,
1612,
2,
272,
1015,
63,
3270,
26,
298,
17,
14,
18,
2,
523,
9635,
63,
694,
26,
272,
1369,
26,
489,
446,
7480,
642,
859,
1077,
9635,
314,
2082,
402,
314,
18788,
790,
570,
14,
221,
982,
267,
663,
12,
314,
859,
911,
1218,
314,
2082,
12,
465,
5521,
465,
663,
314,
5771,
436,
3443,
267,
402,
376,
3411,
2082,
14,
6423,
3238,
370,
267,
663,
445,
8,
9053,
63,
694,
29,
889,
9,
340,
1265,
787,
1808,
376,
18034,
2082,
367,
267,
18788,
63,
1612,
12,
465,
663,
543,
445,
8,
515,
395,
3967,
1265,
4293,
4650,
28225,
734,
402,
267,
12027,
2879,
14,
1666,
314,
2893,
5084,
14,
272,
1415,
26,
3055,
272,
3415,
26,
359,
298,
5066,
401,
298,
889,
2,
1622,
272,
849,
26,
298,
5066,
2,
272,
1015,
63,
3270,
26,
298,
17,
14,
18,
2,
523,
1174,
26,
272,
1369,
26,
489,
446,
7480,
314,
1627,
790,
334,
1045,
314,
1627,
790,
63,
1419,
9,
1077,
503,
1077,
440,
506,
315,
314,
570,
272,
1415,
26,
3055,
272,
3415,
26,
359,
298,
1881,
401,
298,
5575,
2,
1622,
272,
849,
26,
298,
1881,
2,
523,
790,
63,
1419,
26,
272,
1369,
26,
489,
446,
437,
1059,
402,
8635,
790,
1511,
370,
506,
20247,
370,
314,
790,
315,
314,
18788,
63,
1612,
570,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
1015,
63,
3270,
26,
298,
17,
14,
20,
2,
523,
13914,
26,
272,
1369,
26,
489,
446,
7480,
370,
2813,
1006,
1163,
2222,
13,
10085,
2883,
687,
314,
18788,
63,
1612,
570,
14,
14326,
2883,
267,
883,
506,
2013,
315,
282,
2849,
445,
8,
498,
9,
1059,
574,
701,
4216,
1958,
3062,
701,
14930,
14,
489,
446,
961,
945,
365,
440,
4438,
20381,
12,
880,
340,
1265,
675,
445,
8,
1045,
4602,
2360,
652,
911,
506,
13914,
1126,
8494,
267,
402,
314,
4438,
12,
340,
1265,
2934,
3663,
2883,
315,
314,
570,
1265,
1929,
370,
986,
3062,
1006,
370,
445,
8,
498,
9,
315,
282,
267,
2849,
3522,
465,
26239,
3432,
14,
272,
1415,
26,
3055,
272,
3415,
26,
359,
298,
5066,
401,
298,
889,
2,
1622,
272,
849,
26,
298,
889,
2,
272,
1015,
63,
3270,
26,
298,
17,
14,
25,
2,
199,
1802,
26,
272,
446,
298,
14995,
503,
14185,
18788,
2883,
367,
6770,
922,
12639,
2,
199,
2502,
26,
298,
34,
9525,
593,
478,
265,
8593,
7828,
1117,
20670,
2924,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5679,
1808,
790,
666,
687,
282,
2257,
570,
641,
314,
10041,
6844,
199,
13,
18788,
63,
498,
26,
922,
29,
1560,
21530,
790,
628,
3638,
4237,
360,
493,
297,
1994,
4219,
15,
1560,
21530,
8083,
5510,
15,
344,
63,
13487,
14,
5645,
358,
7820,
199,
199,
3,
11719,
12869,
1166,
465,
790,
1350,
199,
13,
18788,
63,
498,
26,
922,
29,
1560,
21530,
790,
29,
2859,
921,
5031,
14,
957,
15,
1560,
21530,
14,
1612,
199,
199,
3,
11719,
18034,
2082,
9918,
26,
199,
13,
18788,
63,
498,
26,
922,
29,
1560,
21530,
2116,
790,
628,
3638,
4237,
360,
493,
297,
1994,
4219,
15,
1560,
21530,
8083,
5510,
15,
344,
63,
13487,
14,
5645,
358,
7820,
2116,
931,
8805,
6839,
15,
5510,
15,
11497,
63,
1612,
15,
1560,
21530,
7,
2116,
9635,
63,
694,
29,
889,
199,
199,
3,
11719,
543,
63,
493,
199,
13,
536,
26,
2494,
1536,
18788,
63,
1612,
367,
314,
12287,
922,
523,
18788,
63,
498,
26,
922,
29,
11060,
2116,
790,
628,
3638,
1242,
7820,
523,
543,
63,
493,
26,
272,
446,
4575,
63,
1612,
15,
1117,
69,
13,
74,
5865,
272,
446,
4575,
63,
1612,
15,
1117,
69,
13,
20216,
199,
199,
3,
11719,
790,
63,
1419,
26,
199,
13,
18788,
63,
498,
26,
922,
29,
1560,
21530,
2116,
790,
628,
3638,
4237,
360,
493,
297,
1994,
4219,
15,
1560,
21530,
8083,
5510,
15,
344,
63,
13487,
14,
5645,
358,
7820,
2116,
790,
63,
1419,
534,
889,
13,
719,
13,
21513,
12,
504,
628,
709,
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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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
] |
zanderle/django
|
tests/basic/tests.py
|
97
|
29877
|
from __future__ import unicode_literals
import threading
import warnings
from datetime import datetime, timedelta
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections
from django.db.models.fields import Field
from django.db.models.fields.related import ForeignObjectRel
from django.db.models.manager import BaseManager
from django.db.models.query import EmptyQuerySet, QuerySet
from django.test import (
SimpleTestCase, TestCase, TransactionTestCase, skipIfDBFeature,
skipUnlessDBFeature,
)
from django.utils import six
from django.utils.translation import ugettext_lazy
from .models import Article, ArticleSelectOnSave, SelfRef
class ModelInstanceCreationTests(TestCase):
def test_object_is_not_written_to_database_until_save_was_called(self):
a = Article(
id=None,
headline='Parrot programs in Python',
pub_date=datetime(2005, 7, 28),
)
self.assertIsNone(a.id)
self.assertEqual(Article.objects.all().count(), 0)
# Save it into the database. You have to call save() explicitly.
a.save()
self.assertIsNotNone(a.id)
self.assertEqual(Article.objects.all().count(), 1)
def test_can_initialize_model_instance_using_positional_arguments(self):
"""
You can initialize a model instance using positional arguments,
which should match the field order as defined in the model.
"""
a = Article(None, 'Second article', datetime(2005, 7, 29))
a.save()
self.assertEqual(a.headline, 'Second article')
self.assertEqual(a.pub_date, datetime(2005, 7, 29, 0, 0))
def test_can_create_instance_using_kwargs(self):
a = Article(
id=None,
headline='Third article',
pub_date=datetime(2005, 7, 30),
)
a.save()
self.assertEqual(a.headline, 'Third article')
self.assertEqual(a.pub_date, datetime(2005, 7, 30, 0, 0))
def test_autofields_generate_different_values_for_each_instance(self):
a1 = Article.objects.create(headline='First', pub_date=datetime(2005, 7, 30, 0, 0))
a2 = Article.objects.create(headline='First', pub_date=datetime(2005, 7, 30, 0, 0))
a3 = Article.objects.create(headline='First', pub_date=datetime(2005, 7, 30, 0, 0))
self.assertNotEqual(a3.id, a1.id)
self.assertNotEqual(a3.id, a2.id)
def test_can_mix_and_match_position_and_kwargs(self):
# You can also mix and match position and keyword arguments, but
# be sure not to duplicate field information.
a = Article(None, 'Fourth article', pub_date=datetime(2005, 7, 31))
a.save()
self.assertEqual(a.headline, 'Fourth article')
def test_cannot_create_instance_with_invalid_kwargs(self):
six.assertRaisesRegex(
self,
TypeError,
"'foo' is an invalid keyword argument for this function",
Article,
id=None,
headline='Some headline',
pub_date=datetime(2005, 7, 31),
foo='bar',
)
def test_can_leave_off_value_for_autofield_and_it_gets_value_on_save(self):
"""
You can leave off the value for an AutoField when creating an
object, because it'll get filled in automatically when you save().
"""
a = Article(headline='Article 5', pub_date=datetime(2005, 7, 31))
a.save()
self.assertEqual(a.headline, 'Article 5')
self.assertNotEqual(a.id, None)
def test_leaving_off_a_field_with_default_set_the_default_will_be_saved(self):
a = Article(pub_date=datetime(2005, 7, 31))
a.save()
self.assertEqual(a.headline, 'Default headline')
def test_for_datetimefields_saves_as_much_precision_as_was_given(self):
"""as much precision in *seconds*"""
a1 = Article(
headline='Article 7',
pub_date=datetime(2005, 7, 31, 12, 30),
)
a1.save()
self.assertEqual(Article.objects.get(id__exact=a1.id).pub_date,
datetime(2005, 7, 31, 12, 30))
a2 = Article(
headline='Article 8',
pub_date=datetime(2005, 7, 31, 12, 30, 45),
)
a2.save()
self.assertEqual(Article.objects.get(id__exact=a2.id).pub_date,
datetime(2005, 7, 31, 12, 30, 45))
def test_saving_an_object_again_does_not_create_a_new_object(self):
a = Article(headline='original', pub_date=datetime(2014, 5, 16))
a.save()
current_id = a.id
a.save()
self.assertEqual(a.id, current_id)
a.headline = 'Updated headline'
a.save()
self.assertEqual(a.id, current_id)
def test_querysets_checking_for_membership(self):
headlines = [
'Parrot programs in Python', 'Second article', 'Third article']
some_pub_date = datetime(2014, 5, 16, 12, 1)
for headline in headlines:
Article(headline=headline, pub_date=some_pub_date).save()
a = Article(headline='Some headline', pub_date=some_pub_date)
a.save()
# You can use 'in' to test for membership...
self.assertIn(a, Article.objects.all())
# ... but there will often be more efficient ways if that is all you need:
self.assertTrue(Article.objects.filter(id=a.id).exists())
class ModelTest(TestCase):
def test_objects_attribute_is_only_available_on_the_class_itself(self):
six.assertRaisesRegex(
self,
AttributeError,
"Manager isn't accessible via Article instances",
getattr,
Article(),
"objects",
)
self.assertFalse(hasattr(Article(), 'objects'))
self.assertTrue(hasattr(Article, 'objects'))
def test_queryset_delete_removes_all_items_in_that_queryset(self):
headlines = [
'An article', 'Article One', 'Amazing article', 'Boring article']
some_pub_date = datetime(2014, 5, 16, 12, 1)
for headline in headlines:
Article(headline=headline, pub_date=some_pub_date).save()
self.assertQuerysetEqual(Article.objects.all().order_by('headline'),
["<Article: Amazing article>",
"<Article: An article>",
"<Article: Article One>",
"<Article: Boring article>"])
Article.objects.filter(headline__startswith='A').delete()
self.assertQuerysetEqual(Article.objects.all().order_by('headline'),
["<Article: Boring article>"])
def test_not_equal_and_equal_operators_behave_as_expected_on_instances(self):
some_pub_date = datetime(2014, 5, 16, 12, 1)
a1 = Article.objects.create(headline='First', pub_date=some_pub_date)
a2 = Article.objects.create(headline='Second', pub_date=some_pub_date)
self.assertNotEqual(a1, a2)
self.assertEqual(a1, Article.objects.get(id__exact=a1.id))
self.assertNotEqual(Article.objects.get(id__exact=a1.id), Article.objects.get(id__exact=a2.id))
@skipUnlessDBFeature('supports_microsecond_precision')
def test_microsecond_precision(self):
# In PostgreSQL, microsecond-level precision is available.
a9 = Article(
headline='Article 9',
pub_date=datetime(2005, 7, 31, 12, 30, 45, 180),
)
a9.save()
self.assertEqual(Article.objects.get(pk=a9.pk).pub_date,
datetime(2005, 7, 31, 12, 30, 45, 180))
@skipIfDBFeature('supports_microsecond_precision')
def test_microsecond_precision_not_supported(self):
# In MySQL, microsecond-level precision isn't always available. You'll
# lose microsecond-level precision once the data is saved.
a9 = Article(
headline='Article 9',
pub_date=datetime(2005, 7, 31, 12, 30, 45, 180),
)
a9.save()
self.assertEqual(
Article.objects.get(id__exact=a9.id).pub_date,
datetime(2005, 7, 31, 12, 30, 45),
)
@skipIfDBFeature('supports_microsecond_precision')
def test_microsecond_precision_not_supported_edge_case(self):
# In MySQL, microsecond-level precision isn't always available. You'll
# lose microsecond-level precision once the data is saved.
a = Article.objects.create(
headline='Article',
pub_date=datetime(2008, 12, 31, 23, 59, 59, 999999),
)
self.assertEqual(
Article.objects.get(pk=a.pk).pub_date,
datetime(2008, 12, 31, 23, 59, 59),
)
def test_manually_specify_primary_key(self):
# You can manually specify the primary key when creating a new object.
a101 = Article(
id=101,
headline='Article 101',
pub_date=datetime(2005, 7, 31, 12, 30, 45),
)
a101.save()
a101 = Article.objects.get(pk=101)
self.assertEqual(a101.headline, 'Article 101')
def test_create_method(self):
# You can create saved objects in a single step
a10 = Article.objects.create(
headline="Article 10",
pub_date=datetime(2005, 7, 31, 12, 30, 45),
)
self.assertEqual(Article.objects.get(headline="Article 10"), a10)
def test_year_lookup_edge_case(self):
# Edge-case test: A year lookup should retrieve all objects in
# the given year, including Jan. 1 and Dec. 31.
Article.objects.create(
headline='Article 11',
pub_date=datetime(2008, 1, 1),
)
Article.objects.create(
headline='Article 12',
pub_date=datetime(2008, 12, 31, 23, 59, 59, 999999),
)
self.assertQuerysetEqual(Article.objects.filter(pub_date__year=2008),
["<Article: Article 11>", "<Article: Article 12>"])
def test_unicode_data(self):
# Unicode data works, too.
a = Article(
headline='\u6797\u539f \u3081\u3050\u307f',
pub_date=datetime(2005, 7, 28),
)
a.save()
self.assertEqual(Article.objects.get(pk=a.id).headline,
'\u6797\u539f \u3081\u3050\u307f')
def test_hash_function(self):
# Model instances have a hash function, so they can be used in sets
# or as dictionary keys. Two models compare as equal if their primary
# keys are equal.
a10 = Article.objects.create(
headline="Article 10",
pub_date=datetime(2005, 7, 31, 12, 30, 45),
)
a11 = Article.objects.create(
headline='Article 11',
pub_date=datetime(2008, 1, 1),
)
a12 = Article.objects.create(
headline='Article 12',
pub_date=datetime(2008, 12, 31, 23, 59, 59, 999999),
)
s = {a10, a11, a12}
self.assertIn(Article.objects.get(headline='Article 11'), s)
def test_field_ordering(self):
"""
Field instances have a `__lt__` comparison function to define an
ordering based on their creation. Prior to #17851 this ordering
comparison relied on the now unsupported `__cmp__` and was assuming
compared objects were both Field instances raising `AttributeError`
when it should have returned `NotImplemented`.
"""
f1 = Field()
f2 = Field(auto_created=True)
f3 = Field()
self.assertLess(f2, f1)
self.assertGreater(f3, f1)
self.assertIsNotNone(f1)
self.assertNotIn(f2, (None, 1, ''))
def test_extra_method_select_argument_with_dashes_and_values(self):
# The 'select' argument to extra() supports names with dashes in
# them, as long as you use values().
Article.objects.create(
headline="Article 10",
pub_date=datetime(2005, 7, 31, 12, 30, 45),
)
Article.objects.create(
headline='Article 11',
pub_date=datetime(2008, 1, 1),
)
Article.objects.create(
headline='Article 12',
pub_date=datetime(2008, 12, 31, 23, 59, 59, 999999),
)
dicts = Article.objects.filter(
pub_date__year=2008).extra(
select={'dashed-value': '1'}).values('headline', 'dashed-value')
self.assertEqual([sorted(d.items()) for d in dicts],
[[('dashed-value', 1), ('headline', 'Article 11')], [('dashed-value', 1), ('headline', 'Article 12')]])
def test_extra_method_select_argument_with_dashes(self):
# If you use 'select' with extra() and names containing dashes on a
# query that's *not* a values() query, those extra 'select' values
# will silently be ignored.
Article.objects.create(
headline="Article 10",
pub_date=datetime(2005, 7, 31, 12, 30, 45),
)
Article.objects.create(
headline='Article 11',
pub_date=datetime(2008, 1, 1),
)
Article.objects.create(
headline='Article 12',
pub_date=datetime(2008, 12, 31, 23, 59, 59, 999999),
)
articles = Article.objects.filter(
pub_date__year=2008).extra(select={'dashed-value': '1', 'undashedvalue': '2'})
self.assertEqual(articles[0].undashedvalue, 2)
def test_create_relation_with_ugettext_lazy(self):
"""
Test that ugettext_lazy objects work when saving model instances
through various methods. Refs #10498.
"""
notlazy = 'test'
lazy = ugettext_lazy(notlazy)
Article.objects.create(headline=lazy, pub_date=datetime.now())
article = Article.objects.get()
self.assertEqual(article.headline, notlazy)
# test that assign + save works with Promise objects
article.headline = lazy
article.save()
self.assertEqual(article.headline, notlazy)
# test .update()
Article.objects.update(headline=lazy)
article = Article.objects.get()
self.assertEqual(article.headline, notlazy)
# still test bulk_create()
Article.objects.all().delete()
Article.objects.bulk_create([Article(headline=lazy, pub_date=datetime.now())])
article = Article.objects.get()
self.assertEqual(article.headline, notlazy)
def test_emptyqs(self):
# Can't be instantiated
with self.assertRaises(TypeError):
EmptyQuerySet()
self.assertIsInstance(Article.objects.none(), EmptyQuerySet)
def test_emptyqs_values(self):
# test for #15959
Article.objects.create(headline='foo', pub_date=datetime.now())
with self.assertNumQueries(0):
qs = Article.objects.none().values_list('pk')
self.assertIsInstance(qs, EmptyQuerySet)
self.assertEqual(len(qs), 0)
def test_emptyqs_customqs(self):
# A hacky test for custom QuerySet subclass - refs #17271
Article.objects.create(headline='foo', pub_date=datetime.now())
class CustomQuerySet(QuerySet):
def do_something(self):
return 'did something'
qs = Article.objects.all()
qs.__class__ = CustomQuerySet
qs = qs.none()
with self.assertNumQueries(0):
self.assertEqual(len(qs), 0)
self.assertIsInstance(qs, EmptyQuerySet)
self.assertEqual(qs.do_something(), 'did something')
def test_emptyqs_values_order(self):
# Tests for ticket #17712
Article.objects.create(headline='foo', pub_date=datetime.now())
with self.assertNumQueries(0):
self.assertEqual(len(Article.objects.none().values_list('id').order_by('id')), 0)
with self.assertNumQueries(0):
self.assertEqual(len(Article.objects.none().filter(
id__in=Article.objects.values_list('id', flat=True))), 0)
@skipUnlessDBFeature('can_distinct_on_fields')
def test_emptyqs_distinct(self):
# Tests for #19426
Article.objects.create(headline='foo', pub_date=datetime.now())
with self.assertNumQueries(0):
self.assertEqual(len(Article.objects.none().distinct('headline', 'pub_date')), 0)
def test_ticket_20278(self):
sr = SelfRef.objects.create()
with self.assertRaises(ObjectDoesNotExist):
SelfRef.objects.get(selfref=sr)
def test_eq(self):
self.assertEqual(Article(id=1), Article(id=1))
self.assertNotEqual(Article(id=1), object())
self.assertNotEqual(object(), Article(id=1))
a = Article()
self.assertEqual(a, a)
self.assertNotEqual(Article(), a)
def test_hash(self):
# Value based on PK
self.assertEqual(hash(Article(id=1)), hash(1))
with self.assertRaises(TypeError):
# No PK value -> unhashable (because save() would then change
# hash)
hash(Article())
class ModelLookupTest(TestCase):
def setUp(self):
# Create an Article.
self.a = Article(
id=None,
headline='Swallow programs in Python',
pub_date=datetime(2005, 7, 28),
)
# Save it into the database. You have to call save() explicitly.
self.a.save()
def test_all_lookup(self):
# Change values by changing the attributes, then calling save().
self.a.headline = 'Parrot programs in Python'
self.a.save()
# Article.objects.all() returns all the articles in the database.
self.assertQuerysetEqual(Article.objects.all(),
['<Article: Parrot programs in Python>'])
def test_rich_lookup(self):
# Django provides a rich database lookup API.
self.assertEqual(Article.objects.get(id__exact=self.a.id), self.a)
self.assertEqual(Article.objects.get(headline__startswith='Swallow'), self.a)
self.assertEqual(Article.objects.get(pub_date__year=2005), self.a)
self.assertEqual(Article.objects.get(pub_date__year=2005, pub_date__month=7), self.a)
self.assertEqual(Article.objects.get(pub_date__year=2005, pub_date__month=7, pub_date__day=28), self.a)
self.assertEqual(Article.objects.get(pub_date__week_day=5), self.a)
def test_equal_lookup(self):
# The "__exact" lookup type can be omitted, as a shortcut.
self.assertEqual(Article.objects.get(id=self.a.id), self.a)
self.assertEqual(Article.objects.get(headline='Swallow programs in Python'), self.a)
self.assertQuerysetEqual(
Article.objects.filter(pub_date__year=2005),
['<Article: Swallow programs in Python>'],
)
self.assertQuerysetEqual(
Article.objects.filter(pub_date__year=2004),
[],
)
self.assertQuerysetEqual(
Article.objects.filter(pub_date__year=2005, pub_date__month=7),
['<Article: Swallow programs in Python>'],
)
self.assertQuerysetEqual(
Article.objects.filter(pub_date__week_day=5),
['<Article: Swallow programs in Python>'],
)
self.assertQuerysetEqual(
Article.objects.filter(pub_date__week_day=6),
[],
)
def test_does_not_exist(self):
# Django raises an Article.DoesNotExist exception for get() if the
# parameters don't match any object.
six.assertRaisesRegex(
self,
ObjectDoesNotExist,
"Article matching query does not exist.",
Article.objects.get,
id__exact=2000,
)
# To avoid dict-ordering related errors check only one lookup
# in single assert.
self.assertRaises(
ObjectDoesNotExist,
Article.objects.get,
pub_date__year=2005,
pub_date__month=8,
)
six.assertRaisesRegex(
self,
ObjectDoesNotExist,
"Article matching query does not exist.",
Article.objects.get,
pub_date__week_day=6,
)
def test_lookup_by_primary_key(self):
# Lookup by a primary key is the most common case, so Django
# provides a shortcut for primary-key exact lookups.
# The following is identical to articles.get(id=a.id).
self.assertEqual(Article.objects.get(pk=self.a.id), self.a)
# pk can be used as a shortcut for the primary key name in any query.
self.assertQuerysetEqual(Article.objects.filter(pk__in=[self.a.id]),
["<Article: Swallow programs in Python>"])
# Model instances of the same type and same ID are considered equal.
a = Article.objects.get(pk=self.a.id)
b = Article.objects.get(pk=self.a.id)
self.assertEqual(a, b)
def test_too_many(self):
# Create a very similar object
a = Article(
id=None,
headline='Swallow bites Python',
pub_date=datetime(2005, 7, 28),
)
a.save()
self.assertEqual(Article.objects.count(), 2)
# Django raises an Article.MultipleObjectsReturned exception if the
# lookup matches more than one object
six.assertRaisesRegex(
self,
MultipleObjectsReturned,
"get\(\) returned more than one Article -- it returned 2!",
Article.objects.get,
headline__startswith='Swallow',
)
six.assertRaisesRegex(
self,
MultipleObjectsReturned,
"get\(\) returned more than one Article -- it returned 2!",
Article.objects.get,
pub_date__year=2005,
)
six.assertRaisesRegex(
self,
MultipleObjectsReturned,
"get\(\) returned more than one Article -- it returned 2!",
Article.objects.get,
pub_date__year=2005,
pub_date__month=7,
)
class ConcurrentSaveTests(TransactionTestCase):
available_apps = ['basic']
@skipUnlessDBFeature('test_db_allows_multiple_connections')
def test_concurrent_delete_with_save(self):
"""
Test fetching, deleting and finally saving an object - we should get
an insert in this case.
"""
a = Article.objects.create(headline='foo', pub_date=datetime.now())
exceptions = []
def deleter():
try:
# Do not delete a directly - doing so alters its state.
Article.objects.filter(pk=a.pk).delete()
except Exception as e:
exceptions.append(e)
finally:
connections[DEFAULT_DB_ALIAS].close()
self.assertEqual(len(exceptions), 0)
t = threading.Thread(target=deleter)
t.start()
t.join()
a.save()
self.assertEqual(Article.objects.get(pk=a.pk).headline, 'foo')
class ManagerTest(SimpleTestCase):
QUERYSET_PROXY_METHODS = [
'none',
'count',
'dates',
'datetimes',
'distinct',
'extra',
'get',
'get_or_create',
'update_or_create',
'create',
'bulk_create',
'filter',
'aggregate',
'annotate',
'complex_filter',
'exclude',
'in_bulk',
'iterator',
'earliest',
'latest',
'first',
'last',
'order_by',
'select_for_update',
'select_related',
'prefetch_related',
'values',
'values_list',
'update',
'reverse',
'defer',
'only',
'using',
'exists',
'_insert',
'_update',
'raw',
]
def test_manager_methods(self):
"""
This test ensures that the correct set of methods from `QuerySet`
are copied onto `Manager`.
It's particularly useful to prevent accidentally leaking new methods
into `Manager`. New `QuerySet` methods that should also be copied onto
`Manager` will need to be added to `ManagerTest.QUERYSET_PROXY_METHODS`.
"""
self.assertEqual(
sorted(BaseManager._get_queryset_methods(QuerySet).keys()),
sorted(self.QUERYSET_PROXY_METHODS),
)
class SelectOnSaveTests(TestCase):
def test_select_on_save(self):
a1 = Article.objects.create(pub_date=datetime.now())
with self.assertNumQueries(1):
a1.save()
asos = ArticleSelectOnSave.objects.create(pub_date=datetime.now())
with self.assertNumQueries(2):
asos.save()
with self.assertNumQueries(1):
asos.save(force_update=True)
Article.objects.all().delete()
with self.assertRaises(DatabaseError):
with self.assertNumQueries(1):
asos.save(force_update=True)
def test_select_on_save_lying_update(self):
"""
Test that select_on_save works correctly if the database
doesn't return correct information about matched rows from
UPDATE.
"""
# Change the manager to not return "row matched" for update().
# We are going to change the Article's _base_manager class
# dynamically. This is a bit of a hack, but it seems hard to
# test this properly otherwise. Article's manager, because
# proxy models use their parent model's _base_manager.
orig_class = Article._base_manager.__class__
class FakeQuerySet(QuerySet):
# Make sure the _update method below is in fact called.
called = False
def _update(self, *args, **kwargs):
FakeQuerySet.called = True
super(FakeQuerySet, self)._update(*args, **kwargs)
return 0
class FakeManager(orig_class):
def get_queryset(self):
return FakeQuerySet(self.model)
try:
Article._base_manager.__class__ = FakeManager
asos = ArticleSelectOnSave.objects.create(pub_date=datetime.now())
with self.assertNumQueries(3):
asos.save()
self.assertTrue(FakeQuerySet.called)
# This is not wanted behavior, but this is how Django has always
# behaved for databases that do not return correct information
# about matched rows for UPDATE.
with self.assertRaises(DatabaseError):
asos.save(force_update=True)
with self.assertRaises(DatabaseError):
asos.save(update_fields=['pub_date'])
finally:
Article._base_manager.__class__ = orig_class
class ModelRefreshTests(TestCase):
def _truncate_ms(self, val):
# MySQL < 5.6.4 removes microseconds from the datetimes which can cause
# problems when comparing the original value to that loaded from DB
return val - timedelta(microseconds=val.microsecond)
def test_refresh(self):
a = Article.objects.create(pub_date=self._truncate_ms(datetime.now()))
Article.objects.create(pub_date=self._truncate_ms(datetime.now()))
Article.objects.filter(pk=a.pk).update(headline='new headline')
with self.assertNumQueries(1):
a.refresh_from_db()
self.assertEqual(a.headline, 'new headline')
orig_pub_date = a.pub_date
new_pub_date = a.pub_date + timedelta(10)
Article.objects.update(headline='new headline 2', pub_date=new_pub_date)
with self.assertNumQueries(1):
a.refresh_from_db(fields=['headline'])
self.assertEqual(a.headline, 'new headline 2')
self.assertEqual(a.pub_date, orig_pub_date)
with self.assertNumQueries(1):
a.refresh_from_db()
self.assertEqual(a.pub_date, new_pub_date)
def test_refresh_fk(self):
s1 = SelfRef.objects.create()
s2 = SelfRef.objects.create()
s3 = SelfRef.objects.create(selfref=s1)
s3_copy = SelfRef.objects.get(pk=s3.pk)
s3_copy.selfref.touched = True
s3.selfref = s2
s3.save()
with self.assertNumQueries(1):
s3_copy.refresh_from_db()
with self.assertNumQueries(1):
# The old related instance was thrown away (the selfref_id has
# changed). It needs to be reloaded on access, so one query
# executed.
self.assertFalse(hasattr(s3_copy.selfref, 'touched'))
self.assertEqual(s3_copy.selfref, s2)
def test_refresh_null_fk(self):
s1 = SelfRef.objects.create()
s2 = SelfRef.objects.create(selfref=s1)
s2.selfref = None
s2.refresh_from_db()
self.assertEqual(s2.selfref, s1)
def test_refresh_unsaved(self):
pub_date = self._truncate_ms(datetime.now())
a = Article.objects.create(pub_date=pub_date)
a2 = Article(id=a.pk)
with self.assertNumQueries(1):
a2.refresh_from_db()
self.assertEqual(a2.pub_date, pub_date)
self.assertEqual(a2._state.db, "default")
def test_refresh_no_fields(self):
a = Article.objects.create(pub_date=self._truncate_ms(datetime.now()))
with self.assertNumQueries(0):
a.refresh_from_db(fields=[])
class TestRelatedObjectDeprecation(SimpleTestCase):
def test_field_related_deprecation(self):
field = SelfRef._meta.get_field('selfref')
with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter('always')
self.assertIsInstance(field.related, ForeignObjectRel)
self.assertEqual(len(warns), 1)
self.assertEqual(
str(warns.pop().message),
'Usage of field.related has been deprecated. Use field.remote_field instead.'
)
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
5796,
199,
646,
3598,
199,
504,
2197,
492,
2197,
12,
6871,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
14326,
11188,
28239,
12,
24803,
199,
504,
1639,
14,
697,
492,
6186,
63,
2846,
63,
12644,
12,
27728,
12,
6947,
199,
504,
1639,
14,
697,
14,
992,
14,
955,
492,
5024,
199,
504,
1639,
14,
697,
14,
992,
14,
955,
14,
2407,
492,
481,
2692,
1692,
5640,
199,
504,
1639,
14,
697,
14,
992,
14,
2609,
492,
3523,
2988,
199,
504,
1639,
14,
697,
14,
992,
14,
1131,
492,
9630,
13689,
12,
18397,
199,
504,
1639,
14,
396,
492,
334,
272,
24424,
12,
7640,
12,
18244,
1746,
12,
3372,
3917,
18093,
12,
272,
3372,
5524,
18093,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
199,
199,
504,
1275,
992,
492,
8281,
12,
8281,
5446,
3314,
8229,
12,
23820,
2891,
421,
199,
533,
5822,
3244,
13921,
2925,
8,
1746,
304,
339,
347,
511,
63,
785,
63,
374,
63,
1397,
63,
8938,
63,
475,
63,
4659,
63,
8111,
63,
2117,
63,
10274,
63,
3527,
8,
277,
304,
267,
282,
275,
8281,
8,
288,
1305,
29,
403,
12,
288,
21250,
534,
1262,
4571,
18572,
315,
2018,
297,
288,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7294,
395,
267,
776,
267,
291,
14,
7702,
8,
65,
14,
344,
9,
267,
291,
14,
629,
8,
7221,
14,
1462,
14,
452,
1252,
835,
1062,
378,
9,
398,
327,
11063,
652,
1901,
314,
3050,
14,
2047,
1172,
370,
1240,
3354,
342,
7662,
14,
267,
282,
14,
2117,
342,
267,
291,
14,
10389,
8,
65,
14,
344,
9,
267,
291,
14,
629,
8,
7221,
14,
1462,
14,
452,
1252,
835,
1062,
413,
9,
339,
347,
511,
63,
2425,
63,
8489,
63,
1238,
63,
842,
63,
4941,
63,
17867,
63,
4958,
8,
277,
304,
267,
408,
267,
2047,
883,
8265,
282,
1402,
1256,
1808,
11333,
2368,
12,
267,
1314,
1077,
1336,
314,
901,
1865,
465,
3247,
315,
314,
1402,
14,
267,
408,
267,
282,
275,
8281,
8,
403,
12,
283,
11906,
9772,
297,
2197,
8,
9397,
12,
1520,
12,
7349,
430,
267,
282,
14,
2117,
342,
398,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
11906,
9772,
358,
267,
291,
14,
629,
8,
65,
14,
5645,
63,
602,
12,
2197,
8,
9397,
12,
1520,
12,
7349,
12,
378,
12,
378,
430,
339,
347,
511,
63,
2425,
63,
981,
63,
842,
63,
4941,
63,
958,
8,
277,
304,
267,
282,
275,
8281,
8,
288,
1305,
29,
403,
12,
288,
21250,
534,
28611,
9772,
297,
288,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
4233,
395,
267,
776,
267,
282,
14,
2117,
342,
267,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
28611,
9772,
358,
267,
291,
14,
629,
8,
65,
14,
5645,
63,
602,
12,
2197,
8,
9397,
12,
1520,
12,
4233,
12,
378,
12,
378,
430,
339,
347,
511,
63,
2495,
955,
63,
4208,
63,
14020,
63,
1459,
63,
509,
63,
10885,
63,
842,
8,
277,
304,
267,
282,
17,
275,
8281,
14,
1462,
14,
981,
8,
11268,
534,
7147,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
4233,
12,
378,
12,
378,
430,
267,
282,
18,
275,
8281,
14,
1462,
14,
981,
8,
11268,
534,
7147,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
4233,
12,
378,
12,
378,
430,
267,
282,
19,
275,
8281,
14,
1462,
14,
981,
8,
11268,
534,
7147,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
4233,
12,
378,
12,
378,
430,
267,
291,
14,
7418,
8,
65,
19,
14,
344,
12,
282,
17,
14,
344,
9,
267,
291,
14,
7418,
8,
65,
19,
14,
344,
12,
282,
18,
14,
344,
9,
339,
347,
511,
63,
2425,
63,
13979,
63,
460,
63,
1431,
63,
3124,
63,
460,
63,
958,
8,
277,
304,
267,
327,
2047,
883,
2597,
13667,
436,
1336,
3421,
436,
4252,
2368,
12,
1325,
267,
327,
506,
3238,
440,
370,
9250,
901,
2556,
14,
267,
282,
275,
8281,
8,
403,
12,
283,
24766,
273,
9772,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7105,
430,
267,
282,
14,
2117,
342,
267,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
24766,
273,
9772,
358,
339,
347,
511,
63,
11250,
63,
981,
63,
842,
63,
1045,
63,
3197,
63,
958,
8,
277,
304,
267,
3816,
14,
16499,
8,
288,
291,
12,
288,
3146,
12,
288,
3546,
1421,
7,
365,
376,
3866,
4252,
1423,
367,
642,
805,
401,
288,
8281,
12,
288,
1305,
29,
403,
12,
288,
21250,
534,
7700,
21250,
297,
288,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7105,
395,
288,
3925,
534,
1700,
297,
267,
776,
339,
347,
511,
63,
2425,
63,
12422,
63,
1997,
63,
585,
63,
509,
63,
2495,
698,
63,
460,
63,
390,
63,
24894,
63,
585,
63,
265,
63,
2117,
8,
277,
304,
267,
408,
267,
2047,
883,
10137,
2331,
314,
574,
367,
376,
9195,
792,
1380,
6425,
376,
267,
909,
12,
2952,
652,
7171,
664,
13457,
315,
5847,
1380,
1265,
3354,
1252,
267,
408,
267,
282,
275,
8281,
8,
11268,
534,
7221,
959,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7105,
430,
267,
282,
14,
2117,
342,
267,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
7221,
959,
358,
267,
291,
14,
7418,
8,
65,
14,
344,
12,
488,
9,
339,
347,
511,
63,
274,
5519,
63,
1997,
63,
65,
63,
698,
63,
1045,
63,
885,
63,
409,
63,
1589,
63,
885,
63,
14117,
63,
1235,
63,
8420,
8,
277,
304,
267,
282,
275,
8281,
8,
5645,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7105,
430,
267,
282,
14,
2117,
342,
267,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
2698,
21250,
358,
339,
347,
511,
63,
509,
63,
2083,
955,
63,
83,
7047,
63,
305,
63,
77,
2133,
63,
6833,
63,
305,
63,
10274,
63,
11809,
8,
277,
304,
267,
408,
305,
8298,
7151,
315,
627,
4515,
10,
624,
267,
282,
17,
275,
8281
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
5796,
199,
646,
3598,
199,
504,
2197,
492,
2197,
12,
6871,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
14326,
11188,
28239,
12,
24803,
199,
504,
1639,
14,
697,
492,
6186,
63,
2846,
63,
12644,
12,
27728,
12,
6947,
199,
504,
1639,
14,
697,
14,
992,
14,
955,
492,
5024,
199,
504,
1639,
14,
697,
14,
992,
14,
955,
14,
2407,
492,
481,
2692,
1692,
5640,
199,
504,
1639,
14,
697,
14,
992,
14,
2609,
492,
3523,
2988,
199,
504,
1639,
14,
697,
14,
992,
14,
1131,
492,
9630,
13689,
12,
18397,
199,
504,
1639,
14,
396,
492,
334,
272,
24424,
12,
7640,
12,
18244,
1746,
12,
3372,
3917,
18093,
12,
272,
3372,
5524,
18093,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
199,
199,
504,
1275,
992,
492,
8281,
12,
8281,
5446,
3314,
8229,
12,
23820,
2891,
421,
199,
533,
5822,
3244,
13921,
2925,
8,
1746,
304,
339,
347,
511,
63,
785,
63,
374,
63,
1397,
63,
8938,
63,
475,
63,
4659,
63,
8111,
63,
2117,
63,
10274,
63,
3527,
8,
277,
304,
267,
282,
275,
8281,
8,
288,
1305,
29,
403,
12,
288,
21250,
534,
1262,
4571,
18572,
315,
2018,
297,
288,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7294,
395,
267,
776,
267,
291,
14,
7702,
8,
65,
14,
344,
9,
267,
291,
14,
629,
8,
7221,
14,
1462,
14,
452,
1252,
835,
1062,
378,
9,
398,
327,
11063,
652,
1901,
314,
3050,
14,
2047,
1172,
370,
1240,
3354,
342,
7662,
14,
267,
282,
14,
2117,
342,
267,
291,
14,
10389,
8,
65,
14,
344,
9,
267,
291,
14,
629,
8,
7221,
14,
1462,
14,
452,
1252,
835,
1062,
413,
9,
339,
347,
511,
63,
2425,
63,
8489,
63,
1238,
63,
842,
63,
4941,
63,
17867,
63,
4958,
8,
277,
304,
267,
408,
267,
2047,
883,
8265,
282,
1402,
1256,
1808,
11333,
2368,
12,
267,
1314,
1077,
1336,
314,
901,
1865,
465,
3247,
315,
314,
1402,
14,
267,
408,
267,
282,
275,
8281,
8,
403,
12,
283,
11906,
9772,
297,
2197,
8,
9397,
12,
1520,
12,
7349,
430,
267,
282,
14,
2117,
342,
398,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
11906,
9772,
358,
267,
291,
14,
629,
8,
65,
14,
5645,
63,
602,
12,
2197,
8,
9397,
12,
1520,
12,
7349,
12,
378,
12,
378,
430,
339,
347,
511,
63,
2425,
63,
981,
63,
842,
63,
4941,
63,
958,
8,
277,
304,
267,
282,
275,
8281,
8,
288,
1305,
29,
403,
12,
288,
21250,
534,
28611,
9772,
297,
288,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
4233,
395,
267,
776,
267,
282,
14,
2117,
342,
267,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
28611,
9772,
358,
267,
291,
14,
629,
8,
65,
14,
5645,
63,
602,
12,
2197,
8,
9397,
12,
1520,
12,
4233,
12,
378,
12,
378,
430,
339,
347,
511,
63,
2495,
955,
63,
4208,
63,
14020,
63,
1459,
63,
509,
63,
10885,
63,
842,
8,
277,
304,
267,
282,
17,
275,
8281,
14,
1462,
14,
981,
8,
11268,
534,
7147,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
4233,
12,
378,
12,
378,
430,
267,
282,
18,
275,
8281,
14,
1462,
14,
981,
8,
11268,
534,
7147,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
4233,
12,
378,
12,
378,
430,
267,
282,
19,
275,
8281,
14,
1462,
14,
981,
8,
11268,
534,
7147,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
4233,
12,
378,
12,
378,
430,
267,
291,
14,
7418,
8,
65,
19,
14,
344,
12,
282,
17,
14,
344,
9,
267,
291,
14,
7418,
8,
65,
19,
14,
344,
12,
282,
18,
14,
344,
9,
339,
347,
511,
63,
2425,
63,
13979,
63,
460,
63,
1431,
63,
3124,
63,
460,
63,
958,
8,
277,
304,
267,
327,
2047,
883,
2597,
13667,
436,
1336,
3421,
436,
4252,
2368,
12,
1325,
267,
327,
506,
3238,
440,
370,
9250,
901,
2556,
14,
267,
282,
275,
8281,
8,
403,
12,
283,
24766,
273,
9772,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7105,
430,
267,
282,
14,
2117,
342,
267,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
24766,
273,
9772,
358,
339,
347,
511,
63,
11250,
63,
981,
63,
842,
63,
1045,
63,
3197,
63,
958,
8,
277,
304,
267,
3816,
14,
16499,
8,
288,
291,
12,
288,
3146,
12,
288,
3546,
1421,
7,
365,
376,
3866,
4252,
1423,
367,
642,
805,
401,
288,
8281,
12,
288,
1305,
29,
403,
12,
288,
21250,
534,
7700,
21250,
297,
288,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7105,
395,
288,
3925,
534,
1700,
297,
267,
776,
339,
347,
511,
63,
2425,
63,
12422,
63,
1997,
63,
585,
63,
509,
63,
2495,
698,
63,
460,
63,
390,
63,
24894,
63,
585,
63,
265,
63,
2117,
8,
277,
304,
267,
408,
267,
2047,
883,
10137,
2331,
314,
574,
367,
376,
9195,
792,
1380,
6425,
376,
267,
909,
12,
2952,
652,
7171,
664,
13457,
315,
5847,
1380,
1265,
3354,
1252,
267,
408,
267,
282,
275,
8281,
8,
11268,
534,
7221,
959,
297,
7974,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7105,
430,
267,
282,
14,
2117,
342,
267,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
7221,
959,
358,
267,
291,
14,
7418,
8,
65,
14,
344,
12,
488,
9,
339,
347,
511,
63,
274,
5519,
63,
1997,
63,
65,
63,
698,
63,
1045,
63,
885,
63,
409,
63,
1589,
63,
885,
63,
14117,
63,
1235,
63,
8420,
8,
277,
304,
267,
282,
275,
8281,
8,
5645,
63,
602,
29,
2083,
8,
9397,
12,
1520,
12,
7105,
430,
267,
282,
14,
2117,
342,
267,
291,
14,
629,
8,
65,
14,
11268,
12,
283,
2698,
21250,
358,
339,
347,
511,
63,
509,
63,
2083,
955,
63,
83,
7047,
63,
305,
63,
77,
2133,
63,
6833,
63,
305,
63,
10274,
63,
11809,
8,
277,
304,
267,
408,
305,
8298,
7151,
315,
627,
4515,
10,
624,
267,
282,
17,
275,
8281,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ChenJunor/hue
|
desktop/core/ext-py/tablib-0.10.0/tablib/packages/xlrd3/biffh.py
|
54
|
17755
|
# Support module for the xlrd3 package.
#
# Portions copyright (c) 2005-2008 Stephen John Machin, Lingfo Pty Ltd
# This module is part of the xlrd package, which is released under a
# BSD-style licence.
#
# 2010-12-08 mozman refactoring for python 3
# 2008-02-10 SJM BIFF2 BLANK record
# 2008-02-08 SJM Preparation for Excel 2.0 support
# 2008-02-02 SJM Added suffixes (_B2, _B2_ONLY, etc) on record names for
# biff_dump & biff_count
# 2007-12-04 SJM Added support for Excel 2.x (BIFF2) files.
# 2007-09-08 SJM Avoid crash when zero-length Unicode string missing options byte.
# 2007-04-22 SJM Remove experimental "trimming" facility.
import sys
from struct import unpack
encoding_from_codepage = {
1200 : 'utf_16_le',
10000: 'mac_roman',
10006: 'mac_greek', # guess
10007: 'mac_cyrillic', # guess
10029: 'mac_latin2', # guess
10079: 'mac_iceland', # guess
10081: 'mac_turkish', # guess
32768: 'mac_roman',
32769: 'cp1252',
}
# some more guessing, for Indic scripts
# codepage 57000 range:
# 2 Devanagari [0]
# 3 Bengali [1]
# 4 Tamil [5]
# 5 Telegu [6]
# 6 Assamese [1] c.f. Bengali
# 7 Oriya [4]
# 8 Kannada [7]
# 9 Malayalam [8]
# 10 Gujarati [3]
# 11 Gurmukhi [2]
FUN = 0 # unknown
FDT = 1 # date
FNU = 2 # number
FGE = 3 # general
FTX = 4 # text
DATEFORMAT = FDT
NUMBERFORMAT = FNU
XL_CELL_EMPTY = 0
XL_CELL_TEXT = 1
XL_CELL_NUMBER = 2
XL_CELL_DATE = 3
XL_CELL_BOOLEAN = 4
XL_CELL_ERROR = 5
XL_CELL_BLANK = 6 # for use in debugging, gathering stats, etc
biff_text_from_num = {
0: "(not BIFF)",
20: "2.0",
21: "2.1",
30: "3",
40: "4S",
45: "4W",
50: "5",
70: "7",
80: "8",
85: "8X",
}
# This dictionary can be used to produce a text version of the internal codes
# that Excel uses for error cells. Here are its contents:
error_text_from_code = {
0x00: '#NULL!', # Intersection of two cell ranges is empty
0x07: '#DIV/0!', # Division by zero
0x0F: '#VALUE!', # Wrong type of operand
0x17: '#REF!', # Illegal or deleted cell reference
0x1D: '#NAME?', # Wrong function or range name
0x24: '#NUM!', # Value range overflow
0x2A: '#N/A!', # Argument or function not available
}
BIFF_FIRST_UNICODE = 80
XL_WORKBOOK_GLOBALS = WBKBLOBAL = 0x5
XL_WORKBOOK_GLOBALS_4W = 0x100
XL_WORKSHEET = WRKSHEET = 0x10
XL_BOUNDSHEET_WORKSHEET = 0x00
XL_BOUNDSHEET_CHART = 0x02
XL_BOUNDSHEET_VB_MODULE = 0x06
# XL_RK2 = 0x7e
XL_ARRAY = 0x0221
XL_ARRAY2 = 0x0021
XL_BLANK = 0x0201
XL_BLANK_B2 = 0x01
XL_BOF = 0x809
XL_BOOLERR = 0x205
XL_BOOLERR_B2 = 0x5
XL_BOUNDSHEET = 0x85
XL_BUILTINFMTCOUNT = 0x56
XL_CF = 0x01B1
XL_CODEPAGE = 0x42
XL_COLINFO = 0x7D
XL_COLUMNDEFAULT = 0x20 # BIFF2 only
XL_COLWIDTH = 0x24 # BIFF2 only
XL_CONDFMT = 0x01B0
XL_CONTINUE = 0x3c
XL_COUNTRY = 0x8C
XL_DATEMODE = 0x22
XL_DEFAULTROWHEIGHT = 0x0225
XL_DEFCOLWIDTH = 0x55
XL_DIMENSION = 0x200
XL_DIMENSION2 = 0x0
XL_EFONT = 0x45
XL_EOF = 0x0a
XL_EXTERNNAME = 0x23
XL_EXTERNSHEET = 0x17
XL_EXTSST = 0xff
XL_FEAT11 = 0x872
XL_FILEPASS = 0x2f
XL_FONT = 0x31
XL_FONT_B3B4 = 0x231
XL_FORMAT = 0x41e
XL_FORMAT2 = 0x1E # BIFF2, BIFF3
XL_FORMULA = 0x6
XL_FORMULA3 = 0x206
XL_FORMULA4 = 0x406
XL_GCW = 0xab
XL_INDEX = 0x20b
XL_INTEGER = 0x2 # BIFF2 only
XL_IXFE = 0x44 # BIFF2 only
XL_LABEL = 0x204
XL_LABEL_B2 = 0x04
XL_LABELRANGES = 0x15f
XL_LABELSST = 0xfd
XL_MERGEDCELLS = 0xE5
XL_MSO_DRAWING = 0x00EC
XL_MSO_DRAWING_GROUP = 0x00EB
XL_MSO_DRAWING_SELECTION = 0x00ED
XL_MULRK = 0xbd
XL_MULBLANK = 0xbe
XL_NAME = 0x18
XL_NOTE = 0x1c
XL_NUMBER = 0x203
XL_NUMBER_B2 = 0x3
XL_OBJ = 0x5D
XL_PALETTE = 0x92
XL_RK = 0x27e
XL_ROW = 0x208
XL_ROW_B2 = 0x08
XL_RSTRING = 0xd6
XL_SHEETHDR = 0x8F # BIFF4W only
XL_SHEETSOFFSET = 0x8E # BIFF4W only
XL_SHRFMLA = 0x04bc
XL_SST = 0xfc
XL_STANDARDWIDTH = 0x99
XL_STRING = 0x207
XL_STRING_B2 = 0x7
XL_STYLE = 0x293
XL_SUPBOOK = 0x1AE
XL_TABLEOP = 0x236
XL_TABLEOP2 = 0x37
XL_TABLEOP_B2 = 0x36
XL_TXO = 0x1b6
XL_UNCALCED = 0x5e
XL_UNKNOWN = 0xffff
XL_WINDOW2 = 0x023E
XL_WRITEACCESS = 0x5C
XL_XF = 0xe0
XL_XF2 = 0x0043 # BIFF2 version of XF record
XL_XF3 = 0x0243 # BIFF3 version of XF record
XL_XF4 = 0x0443 # BIFF4 version of XF record
boflen = {
0x0809: 8,
0x0409: 6,
0x0209: 6,
0x0009: 4,
}
bofcodes = (0x0809, 0x0409, 0x0209, 0x0009)
XL_FORMULA_OPCODES = (0x0006, 0x0406, 0x0206)
_cell_opcode_list = (
XL_BOOLERR,
XL_FORMULA,
XL_FORMULA3,
XL_FORMULA4,
XL_LABEL,
XL_LABELSST,
XL_MULRK,
XL_NUMBER,
XL_RK,
XL_RSTRING,
)
biff_rec_name_dict = {
0x0000: 'DIMENSIONS_B2',
0x0001: 'BLANK_B2',
0x0002: 'INTEGER_B2_ONLY',
0x0003: 'NUMBER_B2',
0x0004: 'LABEL_B2',
0x0005: 'BOOLERR_B2',
0x0006: 'FORMULA',
0x0007: 'STRING_B2',
0x0008: 'ROW_B2',
0x0009: 'BOF_B2',
0x000A: 'EOF',
0x000B: 'INDEX_B2_ONLY',
0x000C: 'CALCCOUNT',
0x000D: 'CALCMODE',
0x000E: 'PRECISION',
0x000F: 'REFMODE',
0x0010: 'DELTA',
0x0011: 'ITERATION',
0x0012: 'PROTECT',
0x0013: 'PASSWORD',
0x0014: 'HEADER',
0x0015: 'FOOTER',
0x0016: 'EXTERNCOUNT',
0x0017: 'EXTERNSHEET',
0x0018: 'NAME_B2,5+',
0x0019: 'WINDOWPROTECT',
0x001A: 'VERTICALPAGEBREAKS',
0x001B: 'HORIZONTALPAGEBREAKS',
0x001C: 'NOTE',
0x001D: 'SELECTION',
0x001E: 'FORMAT_B2-3',
0x001F: 'BUILTINFMTCOUNT_B2',
0x0020: 'COLUMNDEFAULT_B2_ONLY',
0x0021: 'ARRAY_B2_ONLY',
0x0022: 'DATEMODE',
0x0023: 'EXTERNNAME',
0x0024: 'COLWIDTH_B2_ONLY',
0x0025: 'DEFAULTROWHEIGHT_B2_ONLY',
0x0026: 'LEFTMARGIN',
0x0027: 'RIGHTMARGIN',
0x0028: 'TOPMARGIN',
0x0029: 'BOTTOMMARGIN',
0x002A: 'PRINTHEADERS',
0x002B: 'PRINTGRIDLINES',
0x002F: 'FILEPASS',
0x0031: 'FONT',
0x0032: 'FONT2_B2_ONLY',
0x0036: 'TABLEOP_B2',
0x0037: 'TABLEOP2_B2',
0x003C: 'CONTINUE',
0x003D: 'WINDOW1',
0x003E: 'WINDOW2_B2',
0x0040: 'BACKUP',
0x0041: 'PANE',
0x0042: 'CODEPAGE',
0x0043: 'XF_B2',
0x0044: 'IXFE_B2_ONLY',
0x0045: 'EFONT_B2_ONLY',
0x004D: 'PLS',
0x0051: 'DCONREF',
0x0055: 'DEFCOLWIDTH',
0x0056: 'BUILTINFMTCOUNT_B3-4',
0x0059: 'XCT',
0x005A: 'CRN',
0x005B: 'FILESHARING',
0x005C: 'WRITEACCESS',
0x005D: 'OBJECT',
0x005E: 'UNCALCED',
0x005F: 'SAVERECALC',
0x0063: 'OBJECTPROTECT',
0x007D: 'COLINFO',
0x007E: 'RK2_mythical_?',
0x0080: 'GUTS',
0x0081: 'WSBOOL',
0x0082: 'GRIDSET',
0x0083: 'HCENTER',
0x0084: 'VCENTER',
0x0085: 'BOUNDSHEET',
0x0086: 'WRITEPROT',
0x008C: 'COUNTRY',
0x008D: 'HIDEOBJ',
0x008E: 'SHEETSOFFSET',
0x008F: 'SHEETHDR',
0x0090: 'SORT',
0x0092: 'PALETTE',
0x0099: 'STANDARDWIDTH',
0x009B: 'FILTERMODE',
0x009C: 'FNGROUPCOUNT',
0x009D: 'AUTOFILTERINFO',
0x009E: 'AUTOFILTER',
0x00A0: 'SCL',
0x00A1: 'SETUP',
0x00AB: 'GCW',
0x00BD: 'MULRK',
0x00BE: 'MULBLANK',
0x00C1: 'MMS',
0x00D6: 'RSTRING',
0x00D7: 'DBCELL',
0x00DA: 'BOOKBOOL',
0x00DD: 'SCENPROTECT',
0x00E0: 'XF',
0x00E1: 'INTERFACEHDR',
0x00E2: 'INTERFACEEND',
0x00E5: 'MERGEDCELLS',
0x00E9: 'BITMAP',
0x00EB: 'MSO_DRAWING_GROUP',
0x00EC: 'MSO_DRAWING',
0x00ED: 'MSO_DRAWING_SELECTION',
0x00EF: 'PHONETIC',
0x00FC: 'SST',
0x00FD: 'LABELSST',
0x00FF: 'EXTSST',
0x013D: 'TABID',
0x015F: 'LABELRANGES',
0x0160: 'USESELFS',
0x0161: 'DSF',
0x01AE: 'SUPBOOK',
0x01AF: 'PROTECTIONREV4',
0x01B0: 'CONDFMT',
0x01B1: 'CF',
0x01B2: 'DVAL',
0x01B6: 'TXO',
0x01B7: 'REFRESHALL',
0x01B8: 'HLINK',
0x01BC: 'PASSWORDREV4',
0x01BE: 'DV',
0x01C0: 'XL9FILE',
0x01C1: 'RECALCID',
0x0200: 'DIMENSIONS',
0x0201: 'BLANK',
0x0203: 'NUMBER',
0x0204: 'LABEL',
0x0205: 'BOOLERR',
0x0206: 'FORMULA_B3',
0x0207: 'STRING',
0x0208: 'ROW',
0x0209: 'BOF',
0x020B: 'INDEX_B3+',
0x0218: 'NAME',
0x0221: 'ARRAY',
0x0223: 'EXTERNNAME_B3-4',
0x0225: 'DEFAULTROWHEIGHT',
0x0231: 'FONT_B3B4',
0x0236: 'TABLEOP',
0x023E: 'WINDOW2',
0x0243: 'XF_B3',
0x027E: 'RK',
0x0293: 'STYLE',
0x0406: 'FORMULA_B4',
0x0409: 'BOF',
0x041E: 'FORMAT',
0x0443: 'XF_B4',
0x04BC: 'SHRFMLA',
0x0800: 'QUICKTIP',
0x0809: 'BOF',
0x0862: 'SHEETLAYOUT',
0x0867: 'SHEETPROTECTION',
0x0868: 'RANGEPROTECTION',
}
class XLRDError(Exception):
pass
class BaseObject:
"""
Parent of almost all other classes in the package. Defines a common
'dump' method for debugging.
"""
_repr_these = []
def dump(self, f=None, header=None, footer=None, indent=0):
"""
:param f: open file object, to which the dump is written
:param header: text to write before the dump
:param footer: text to write after the dump
:param indent: number of leading spaces (for recursive calls)
"""
if f is None:
f = sys.stderr
pad = " " * indent
if header is not None:
print(header, file=f)
for attr, value in sorted(self.__dict__.items()):
if getattr(value, 'dump', None) and attr != 'book':
value.dump(f,
header="%s%s (%s object):" % (pad, attr, value.__class__.__name__),
indent=indent+4)
elif attr not in self._repr_these and \
(isinstance(value, list) or
isinstance(value, dict)):
print("%s%s: %s, len = %d" % (pad, attr, type(value), len(value)), file=f)
else:
print("%s%s: %r" % (pad, attr, value), file=f)
if footer is not None:
print(footer, file=f)
def fprintf(f, fmt, *vargs):
print(fmt.rstrip('\n') % vargs, file=f)
def upkbits(tgt_obj, src, manifest, local_setattr=setattr):
for n, mask, attr in manifest:
local_setattr(tgt_obj, attr, (src & mask) >> n)
def upkbitsL(tgt_obj, src, manifest, local_setattr=setattr, local_int=int):
for n, mask, attr in manifest:
local_setattr(tgt_obj, attr, local_int((src & mask) >> n))
def unpack_string(data, pos, encoding, lenlen=1):
nchars = unpack('<' + 'BH'[lenlen-1], data[pos:pos+lenlen])[0]
pos += lenlen
return str(data[pos:pos+nchars], encoding)
def unpack_string_update_pos(data, pos, encoding, lenlen=1, known_len=None):
if known_len is not None:
# On a NAME record, the length byte is detached from the front of the string.
nchars = known_len
else:
nchars = unpack('<' + 'BH'[lenlen-1], data[pos:pos+lenlen])[0]
pos += lenlen
newpos = pos + nchars
return (str(data[pos:newpos], encoding), newpos)
def unpack_unicode(data, pos, lenlen=2):
""" Return unicode_strg """
nchars = unpack('<' + 'BH'[lenlen-1], data[pos:pos+lenlen])[0]
if not nchars:
# Ambiguous whether 0-length string should have an "options" byte.
# Avoid crash if missing.
return ""
pos += lenlen
options = data[pos]
pos += 1
if options & 0x08: # richtext
pos += 2
if options & 0x04: # phonetic
pos += 4
if options & 0x01:
# Uncompressed UTF-16-LE
rawstrg = data[pos:pos+2*nchars]
strg = str(rawstrg, 'utf_16_le')
else:
# Note: this is COMPRESSED (not ASCII!) encoding!!!
# Merely returning the raw bytes would work OK 99.99% of the time
# if the local codepage was cp1252 -- however this would rapidly go pear-shaped
# for other codepages so we grit our Anglocentric teeth and return Unicode :-)
strg = str(data[pos:pos+nchars], "latin_1")
return strg
def unpack_unicode_update_pos(data, pos, lenlen=2, known_len=None):
""" Return (unicode_strg, updated value of pos) """
if known_len is not None:
# On a NAME record, the length byte is detached from the front of the string.
nchars = known_len
else:
nchars = unpack('<' + 'BH'[lenlen-1], data[pos:pos+lenlen])[0]
pos += lenlen
if not nchars and not data[pos:]:
# Zero-length string with no options byte
return ("", pos)
options = data[pos]
pos += 1
phonetic = options & 0x04
richtext = options & 0x08
if richtext:
rt = unpack('<H', data[pos:pos+2])[0]
pos += 2
if phonetic:
sz = unpack('<i', data[pos:pos+4])[0]
pos += 4
if options & 0x01:
# Uncompressed UTF-16-LE
strg = str(data[pos:pos+2*nchars], 'utf_16_le')
pos += 2*nchars
else:
# Note: this is COMPRESSED (not ASCII!) encoding!!!
strg = str(data[pos:pos+nchars], "latin_1")
pos += nchars
if richtext:
pos += 4 * rt
if phonetic:
pos += sz
return (strg, pos)
def unpack_cell_range_address_list_update_pos(
output_list, data, pos, biff_version, addr_size=6):
# output_list is updated in situ
if biff_version < 80:
assert addr_size == 6
else:
assert addr_size in (6, 8)
n, = unpack("<H", data[pos:pos+2])
pos += 2
if n:
fmt = "<HHBB" if addr_size == 6 else "<HHHH"
for _unused in range(n):
ra, rb, ca, cb = unpack(fmt, data[pos:pos+addr_size])
output_list.append((ra, rb+1, ca, cb+1))
pos += addr_size
return pos
def hex_char_dump(strg, ofs, dlen, base=0, fout=sys.stdout, unnumbered=False):
endpos = min(ofs + dlen, len(strg))
pos = ofs
numbered = not unnumbered
num_prefix = ''
while pos < endpos:
endsub = min(pos + 16, endpos)
substrg = strg[pos:endsub]
lensub = endsub - pos
if lensub <= 0 or lensub != len(substrg):
fprintf(
sys.stdout,
'??? hex_char_dump: ofs=%d dlen=%d base=%d -> endpos=%d pos=%d endsub=%d substrg=%r\n',
ofs, dlen, base, endpos, pos, endsub, substrg)
break
hexd = ''.join(["%02x " % c for c in substrg])
chard = ''
for c in substrg:
if c == ord('\0'):
c = '~'
elif not (' ' <= chr(c) <= '~'):
c = '?'
if isinstance(c, int):
c = chr(c)
chard += c
if numbered:
num_prefix = "%5d: " % (base+pos-ofs)
fprintf(fout, "%s %-48s %s\n", num_prefix, hexd, chard)
pos = endsub
def biff_dump(mem, stream_offset, stream_len, base=0, fout=sys.stdout,
unnumbered=False):
pos = stream_offset
stream_end = stream_offset + stream_len
adj = base - stream_offset
dummies = 0
numbered = not unnumbered
num_prefix = ''
while stream_end - pos >= 4:
rc, length = unpack('<HH', mem[pos:pos+4])
if rc == 0 and length == 0:
if mem[pos:] == '\0' * (stream_end - pos):
dummies = stream_end - pos
savpos = pos
pos = stream_end
break
if dummies:
dummies += 4
else:
savpos = pos
dummies = 4
pos += 4
else:
if dummies:
if numbered:
num_prefix = "%5d: " % (adj + savpos)
fprintf(fout, "%s---- %d zero bytes skipped ----\n",
num_prefix, dummies)
dummies = 0
recname = biff_rec_name_dict.get(rc, '<UNKNOWN>')
if numbered:
num_prefix = "%5d: " % (adj + pos)
fprintf(fout, "%s%04x %s len = %04x (%d)\n",
num_prefix, rc, recname, length, length)
pos += 4
hex_char_dump(mem, pos, length, adj+pos, fout, unnumbered)
pos += length
if dummies:
if numbered:
num_prefix = "%5d: " % (adj + savpos)
fprintf(fout, "%s---- %d zero bytes skipped ----\n", num_prefix, dummies)
if pos < stream_end:
if numbered:
num_prefix = "%5d: " % (adj + pos)
fprintf(fout, "%s---- Misc bytes at end ----\n", num_prefix)
hex_char_dump(mem, pos, stream_end-pos, adj + pos, fout, unnumbered)
elif pos > stream_end:
fprintf(fout, "Last dumped record has length (%d) that is too large\n", length)
def biff_count_records(mem, stream_offset, stream_len, fout=sys.stdout):
pos = stream_offset
stream_end = stream_offset + stream_len
tally = {}
while stream_end - pos >= 4:
rc, length = unpack('<HH', mem[pos:pos+4])
if rc == 0 and length == 0:
if mem[pos:] == '\0' * (stream_end - pos):
break
recname = "<Dummy (zero)>"
else:
recname = biff_rec_name_dict.get(rc, None)
if recname is None:
recname = "Unknown_0x%04X" % rc
if recname in tally:
tally[recname] += 1
else:
tally[recname] = 1
pos += length + 4
for recname, count in sorted(tally.items()):
fprintf(fout, "%8d %s", count, recname)
|
apache-2.0
|
[
3,
12502,
859,
367,
314,
25077,
6883,
19,
2559,
14,
202,
199,
3,
202,
199,
3,
20825,
4248,
334,
67,
9,
11811,
13,
9300,
17854,
17579,
17815,
30611,
262,
12,
491,
316,
545,
510,
369,
12126,
202,
199,
3,
961,
859,
365,
1777,
402,
314,
25077,
6883,
2559,
12,
1314,
365,
14286,
1334,
282,
202,
199,
3,
6289,
13,
2487,
23854,
4894,
14,
202,
199,
3,
202,
199,
3,
7129,
13,
713,
13,
2036,
1303,
90,
1237,
24200,
316,
367,
2366,
650,
202,
199,
3,
9079,
13,
996,
13,
709,
428,
42,
45,
699,
24150,
18,
699,
10825,
43,
2777,
202,
199,
3,
9079,
13,
996,
13,
2036,
428,
42,
45,
5543,
462,
425,
367,
27832,
499,
14,
16,
2291,
202,
199,
3,
9079,
13,
996,
13,
996,
428,
42,
45,
16230,
19475,
6110,
34,
18,
12,
485,
34,
18,
63,
10452,
12,
5423,
9,
641,
2777,
1561,
367,
202,
199,
3,
4483,
12111,
556,
63,
2724,
1253,
12111,
556,
63,
835,
202,
199,
3,
10219,
13,
713,
13,
966,
428,
42,
45,
16230,
2291,
367,
27832,
499,
14,
88,
334,
19419,
1665,
18,
9,
1584,
14,
202,
199,
3,
10219,
13,
1643,
13,
2036,
428,
42,
45,
19503,
12420,
1380,
4697,
13,
1267,
6140,
1059,
4124,
1511,
3696,
14,
202,
199,
3,
10219,
13,
966,
13,
1081,
428,
42,
45,
5852,
22820,
298,
599,
596,
316,
2,
21395,
14,
2999,
199,
646,
984,
202,
199,
504,
2702,
492,
7787,
2999,
199,
2991,
63,
504,
63,
600,
1606,
275,
469,
1128,
413,
1840,
520,
283,
1624,
63,
975,
63,
274,
297,
1128,
11630,
26,
283,
3088,
63,
20971,
297,
1128,
5198,
22,
26,
283,
3088,
63,
32007,
297,
327,
9519,
1128,
5198,
23,
26,
283,
3088,
63,
17405,
297,
327,
9519,
1128,
2948,
1398,
26,
283,
3088,
63,
10378,
18,
297,
327,
9519,
1128,
2948,
1965,
26,
283,
3088,
63,
1885,
9688,
297,
327,
9519,
1128,
2948,
2835,
26,
283,
3088,
63,
16218,
75,
2453,
297,
327,
9519,
1128,
20939,
2333,
26,
283,
3088,
63,
20971,
297,
1128,
20939,
1876,
26,
283,
1850,
19364,
297,
1128,
789,
2999,
199,
3,
2005,
1655,
9519,
316,
12,
367,
1010,
5000,
10554,
202,
199,
3,
1233,
1606,
12699,
1493,
1425,
26,
202,
199,
3,
499,
1487,
20662,
643,
759,
359,
16,
61,
202,
199,
3,
650,
699,
22329,
359,
17,
61,
202,
199,
3,
841,
377,
455,
382,
359,
21,
61,
202,
199,
3,
959,
5773,
4170,
85,
359,
22,
61,
202,
199,
3,
1227,
10829,
313,
261,
359,
17,
61,
286,
14,
70,
14,
699,
22329,
202,
199,
3,
1520,
593,
322,
11552,
359,
20,
61,
202,
199,
3,
1695,
1804,
1189,
10641,
359,
23,
61,
202,
199,
3,
1749,
29936,
1187,
279,
455,
359,
24,
61,
202,
199,
3,
1616,
12436,
23757,
359,
19,
61,
202,
199,
3,
4119,
598,
24538,
359,
18,
61,
2999,
199,
9309,
275,
378,
327,
5809,
202,
199,
38,
7438,
275,
413,
327,
1434,
202,
199,
38,
1440,
275,
499,
327,
1329,
202,
199,
38,
4962,
275,
650,
327,
8605,
202,
199,
2161,
56,
275,
841,
327,
1318,
2999,
199,
5390,
4807,
275,
481,
7438,
202,
199,
9190,
4807,
275,
481,
1440,
2999,
199,
25774,
63,
26474,
63,
13993,
275,
378,
202,
199,
25774,
63,
26474,
63,
3876,
275,
413,
202,
199,
25774,
63,
26474,
63,
9190,
275,
499,
202,
199,
25774,
63,
26474,
63,
5390,
275,
650,
202,
199,
25774,
63,
26474,
63,
25312,
275,
841,
202,
199,
25774,
63,
26474,
63,
3170,
275,
959,
202,
199,
25774,
63,
26474,
63,
20438,
275,
1227,
327,
367,
675,
315,
10201,
12,
13082,
316,
5020,
12,
5423,
2999,
199,
4492,
556,
63,
505,
63,
504,
63,
1507,
275,
469,
1128,
378,
26,
221,
7340,
1397,
699,
24150,
4186,
1128,
3388,
26,
298,
18,
14,
16,
401,
1128,
7829,
26,
298,
18,
14,
17,
401,
1128,
4233,
26,
298,
19,
401,
1128,
6335,
26,
298,
20,
51,
401,
1128,
10416,
26,
298,
20,
55,
401,
1128,
5238,
26,
298,
21,
401,
1128,
10045,
26,
298,
23,
401,
1128,
5939,
26,
298,
24,
401,
1128,
16412,
26,
298,
24,
56,
401,
202,
199,
93,
2999,
199,
3,
961,
2600,
883,
506,
1202,
370,
7389,
282,
1318,
1015,
402,
314,
5007,
9479,
202,
199,
3,
626,
27832,
4440,
367,
1125,
10106,
14,
11842,
787,
2399,
4072,
26,
202,
199,
705,
63,
505,
63,
504,
63,
600,
275,
469,
1128,
378,
88,
383,
26,
3943,
8084,
12389,
221,
327,
6551,
2792,
402,
2877,
4917,
12271,
365,
2701,
1128,
378,
88,
1780,
26,
3943,
27051,
15,
16,
12389,
327,
3757,
2317,
701,
4697,
1128,
378,
88,
16,
38,
26,
3943,
7041,
12389,
327,
30801,
730,
402,
14888,
1128,
378,
88,
1196,
26,
3943,
8279,
12389,
257,
327,
473,
13486,
503,
5463,
4917,
3659,
1128,
378,
88,
17,
36,
26,
3943,
2339,
7044,
221,
327,
30801,
805,
503,
1425,
536,
1128,
378,
88,
1194,
26,
3943,
7125,
12389,
257,
327,
1594,
1425,
15784,
1128,
378,
88,
18,
33,
26,
3943,
46,
15,
33,
12389,
257,
327,
5886,
503,
805,
440,
2808,
202,
199,
93,
2999,
199,
19419,
1665,
63,
12903,
63,
12819,
275,
5939,
2999,
199,
25774,
63,
8406,
21155,
63,
13808,
51,
275,
644,
34,
12780,
12667,
275,
378,
88,
21,
202,
199,
25774,
63,
8406,
21155,
63,
13808,
51,
63,
20,
55,
275,
378,
88,
1960,
202,
199,
25774,
63,
8406,
20255,
775,
275,
16573,
19982,
1645,
775,
275,
378,
88,
709,
2999,
199,
25774,
63,
3973,
1734,
3177,
1645,
775,
63,
8406,
20255,
775,
275,
378,
88,
383,
202,
199,
25774,
63,
3973,
1734,
3177,
1645,
775,
63,
32110,
258,
275,
378,
88,
996,
202,
199,
25774,
63,
3973,
1734,
3177,
1645,
775,
63,
27966,
63,
10001,
275,
378,
88,
1690,
2999,
199,
3,
1323,
44,
63,
50,
43,
18,
275,
378,
88,
23,
69,
202,
199,
25774,
63,
12322,
221,
275,
378,
88,
996,
2025,
202,
199,
25774,
63,
12322,
18,
275,
378,
88,
383,
2025,
202,
199,
25774,
63,
20438,
275,
378,
88,
996,
614,
202,
199,
25774,
63,
20438,
63,
34,
18,
275,
378,
88,
614,
202,
199,
25774,
63,
34,
3359,
275,
378,
88,
11782,
202,
199,
25774,
63,
16026
] |
[
12502,
859,
367,
314,
25077,
6883,
19,
2559,
14,
202,
199,
3,
202,
199,
3,
20825,
4248,
334,
67,
9,
11811,
13,
9300,
17854,
17579,
17815,
30611,
262,
12,
491,
316,
545,
510,
369,
12126,
202,
199,
3,
961,
859,
365,
1777,
402,
314,
25077,
6883,
2559,
12,
1314,
365,
14286,
1334,
282,
202,
199,
3,
6289,
13,
2487,
23854,
4894,
14,
202,
199,
3,
202,
199,
3,
7129,
13,
713,
13,
2036,
1303,
90,
1237,
24200,
316,
367,
2366,
650,
202,
199,
3,
9079,
13,
996,
13,
709,
428,
42,
45,
699,
24150,
18,
699,
10825,
43,
2777,
202,
199,
3,
9079,
13,
996,
13,
2036,
428,
42,
45,
5543,
462,
425,
367,
27832,
499,
14,
16,
2291,
202,
199,
3,
9079,
13,
996,
13,
996,
428,
42,
45,
16230,
19475,
6110,
34,
18,
12,
485,
34,
18,
63,
10452,
12,
5423,
9,
641,
2777,
1561,
367,
202,
199,
3,
4483,
12111,
556,
63,
2724,
1253,
12111,
556,
63,
835,
202,
199,
3,
10219,
13,
713,
13,
966,
428,
42,
45,
16230,
2291,
367,
27832,
499,
14,
88,
334,
19419,
1665,
18,
9,
1584,
14,
202,
199,
3,
10219,
13,
1643,
13,
2036,
428,
42,
45,
19503,
12420,
1380,
4697,
13,
1267,
6140,
1059,
4124,
1511,
3696,
14,
202,
199,
3,
10219,
13,
966,
13,
1081,
428,
42,
45,
5852,
22820,
298,
599,
596,
316,
2,
21395,
14,
2999,
199,
646,
984,
202,
199,
504,
2702,
492,
7787,
2999,
199,
2991,
63,
504,
63,
600,
1606,
275,
469,
1128,
413,
1840,
520,
283,
1624,
63,
975,
63,
274,
297,
1128,
11630,
26,
283,
3088,
63,
20971,
297,
1128,
5198,
22,
26,
283,
3088,
63,
32007,
297,
327,
9519,
1128,
5198,
23,
26,
283,
3088,
63,
17405,
297,
327,
9519,
1128,
2948,
1398,
26,
283,
3088,
63,
10378,
18,
297,
327,
9519,
1128,
2948,
1965,
26,
283,
3088,
63,
1885,
9688,
297,
327,
9519,
1128,
2948,
2835,
26,
283,
3088,
63,
16218,
75,
2453,
297,
327,
9519,
1128,
20939,
2333,
26,
283,
3088,
63,
20971,
297,
1128,
20939,
1876,
26,
283,
1850,
19364,
297,
1128,
789,
2999,
199,
3,
2005,
1655,
9519,
316,
12,
367,
1010,
5000,
10554,
202,
199,
3,
1233,
1606,
12699,
1493,
1425,
26,
202,
199,
3,
499,
1487,
20662,
643,
759,
359,
16,
61,
202,
199,
3,
650,
699,
22329,
359,
17,
61,
202,
199,
3,
841,
377,
455,
382,
359,
21,
61,
202,
199,
3,
959,
5773,
4170,
85,
359,
22,
61,
202,
199,
3,
1227,
10829,
313,
261,
359,
17,
61,
286,
14,
70,
14,
699,
22329,
202,
199,
3,
1520,
593,
322,
11552,
359,
20,
61,
202,
199,
3,
1695,
1804,
1189,
10641,
359,
23,
61,
202,
199,
3,
1749,
29936,
1187,
279,
455,
359,
24,
61,
202,
199,
3,
1616,
12436,
23757,
359,
19,
61,
202,
199,
3,
4119,
598,
24538,
359,
18,
61,
2999,
199,
9309,
275,
378,
327,
5809,
202,
199,
38,
7438,
275,
413,
327,
1434,
202,
199,
38,
1440,
275,
499,
327,
1329,
202,
199,
38,
4962,
275,
650,
327,
8605,
202,
199,
2161,
56,
275,
841,
327,
1318,
2999,
199,
5390,
4807,
275,
481,
7438,
202,
199,
9190,
4807,
275,
481,
1440,
2999,
199,
25774,
63,
26474,
63,
13993,
275,
378,
202,
199,
25774,
63,
26474,
63,
3876,
275,
413,
202,
199,
25774,
63,
26474,
63,
9190,
275,
499,
202,
199,
25774,
63,
26474,
63,
5390,
275,
650,
202,
199,
25774,
63,
26474,
63,
25312,
275,
841,
202,
199,
25774,
63,
26474,
63,
3170,
275,
959,
202,
199,
25774,
63,
26474,
63,
20438,
275,
1227,
327,
367,
675,
315,
10201,
12,
13082,
316,
5020,
12,
5423,
2999,
199,
4492,
556,
63,
505,
63,
504,
63,
1507,
275,
469,
1128,
378,
26,
221,
7340,
1397,
699,
24150,
4186,
1128,
3388,
26,
298,
18,
14,
16,
401,
1128,
7829,
26,
298,
18,
14,
17,
401,
1128,
4233,
26,
298,
19,
401,
1128,
6335,
26,
298,
20,
51,
401,
1128,
10416,
26,
298,
20,
55,
401,
1128,
5238,
26,
298,
21,
401,
1128,
10045,
26,
298,
23,
401,
1128,
5939,
26,
298,
24,
401,
1128,
16412,
26,
298,
24,
56,
401,
202,
199,
93,
2999,
199,
3,
961,
2600,
883,
506,
1202,
370,
7389,
282,
1318,
1015,
402,
314,
5007,
9479,
202,
199,
3,
626,
27832,
4440,
367,
1125,
10106,
14,
11842,
787,
2399,
4072,
26,
202,
199,
705,
63,
505,
63,
504,
63,
600,
275,
469,
1128,
378,
88,
383,
26,
3943,
8084,
12389,
221,
327,
6551,
2792,
402,
2877,
4917,
12271,
365,
2701,
1128,
378,
88,
1780,
26,
3943,
27051,
15,
16,
12389,
327,
3757,
2317,
701,
4697,
1128,
378,
88,
16,
38,
26,
3943,
7041,
12389,
327,
30801,
730,
402,
14888,
1128,
378,
88,
1196,
26,
3943,
8279,
12389,
257,
327,
473,
13486,
503,
5463,
4917,
3659,
1128,
378,
88,
17,
36,
26,
3943,
2339,
7044,
221,
327,
30801,
805,
503,
1425,
536,
1128,
378,
88,
1194,
26,
3943,
7125,
12389,
257,
327,
1594,
1425,
15784,
1128,
378,
88,
18,
33,
26,
3943,
46,
15,
33,
12389,
257,
327,
5886,
503,
805,
440,
2808,
202,
199,
93,
2999,
199,
19419,
1665,
63,
12903,
63,
12819,
275,
5939,
2999,
199,
25774,
63,
8406,
21155,
63,
13808,
51,
275,
644,
34,
12780,
12667,
275,
378,
88,
21,
202,
199,
25774,
63,
8406,
21155,
63,
13808,
51,
63,
20,
55,
275,
378,
88,
1960,
202,
199,
25774,
63,
8406,
20255,
775,
275,
16573,
19982,
1645,
775,
275,
378,
88,
709,
2999,
199,
25774,
63,
3973,
1734,
3177,
1645,
775,
63,
8406,
20255,
775,
275,
378,
88,
383,
202,
199,
25774,
63,
3973,
1734,
3177,
1645,
775,
63,
32110,
258,
275,
378,
88,
996,
202,
199,
25774,
63,
3973,
1734,
3177,
1645,
775,
63,
27966,
63,
10001,
275,
378,
88,
1690,
2999,
199,
3,
1323,
44,
63,
50,
43,
18,
275,
378,
88,
23,
69,
202,
199,
25774,
63,
12322,
221,
275,
378,
88,
996,
2025,
202,
199,
25774,
63,
12322,
18,
275,
378,
88,
383,
2025,
202,
199,
25774,
63,
20438,
275,
378,
88,
996,
614,
202,
199,
25774,
63,
20438,
63,
34,
18,
275,
378,
88,
614,
202,
199,
25774,
63,
34,
3359,
275,
378,
88,
11782,
202,
199,
25774,
63,
16026,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
wuga214/Django-Wuga
|
env/lib/python2.7/site-packages/django/db/migrations/writer.py
|
58
|
11569
|
from __future__ import unicode_literals
import os
import re
from importlib import import_module
from django import get_version
from django.apps import apps
from django.db import migrations
from django.db.migrations.loader import MigrationLoader
from django.db.migrations.serializer import serializer_factory
from django.utils._os import upath
from django.utils.encoding import force_text
from django.utils.inspect import get_func_args
from django.utils.module_loading import module_dir
from django.utils.timezone import now
try:
import enum
except ImportError:
# No support on Python 2 if enum34 isn't installed.
enum = None
class SettingsReference(str):
"""
Special subclass of string which actually references a current settings
value. It's treated as the value in memory, but serializes out to a
settings.NAME attribute reference.
"""
def __new__(self, value, setting_name):
return str.__new__(self, value)
def __init__(self, value, setting_name):
self.setting_name = setting_name
class OperationWriter(object):
def __init__(self, operation, indentation=2):
self.operation = operation
self.buff = []
self.indentation = indentation
def serialize(self):
def _write(_arg_name, _arg_value):
if (_arg_name in self.operation.serialization_expand_args and
isinstance(_arg_value, (list, tuple, dict))):
if isinstance(_arg_value, dict):
self.feed('%s={' % _arg_name)
self.indent()
for key, value in _arg_value.items():
key_string, key_imports = MigrationWriter.serialize(key)
arg_string, arg_imports = MigrationWriter.serialize(value)
args = arg_string.splitlines()
if len(args) > 1:
self.feed('%s: %s' % (key_string, args[0]))
for arg in args[1:-1]:
self.feed(arg)
self.feed('%s,' % args[-1])
else:
self.feed('%s: %s,' % (key_string, arg_string))
imports.update(key_imports)
imports.update(arg_imports)
self.unindent()
self.feed('},')
else:
self.feed('%s=[' % _arg_name)
self.indent()
for item in _arg_value:
arg_string, arg_imports = MigrationWriter.serialize(item)
args = arg_string.splitlines()
if len(args) > 1:
for arg in args[:-1]:
self.feed(arg)
self.feed('%s,' % args[-1])
else:
self.feed('%s,' % arg_string)
imports.update(arg_imports)
self.unindent()
self.feed('],')
else:
arg_string, arg_imports = MigrationWriter.serialize(_arg_value)
args = arg_string.splitlines()
if len(args) > 1:
self.feed('%s=%s' % (_arg_name, args[0]))
for arg in args[1:-1]:
self.feed(arg)
self.feed('%s,' % args[-1])
else:
self.feed('%s=%s,' % (_arg_name, arg_string))
imports.update(arg_imports)
imports = set()
name, args, kwargs = self.operation.deconstruct()
operation_args = get_func_args(self.operation.__init__)
# See if this operation is in django.db.migrations. If it is,
# We can just use the fact we already have that imported,
# otherwise, we need to add an import for the operation class.
if getattr(migrations, name, None) == self.operation.__class__:
self.feed('migrations.%s(' % name)
else:
imports.add('import %s' % (self.operation.__class__.__module__))
self.feed('%s.%s(' % (self.operation.__class__.__module__, name))
self.indent()
for i, arg in enumerate(args):
arg_value = arg
arg_name = operation_args[i]
_write(arg_name, arg_value)
i = len(args)
# Only iterate over remaining arguments
for arg_name in operation_args[i:]:
if arg_name in kwargs: # Don't sort to maintain signature order
arg_value = kwargs[arg_name]
_write(arg_name, arg_value)
self.unindent()
self.feed('),')
return self.render(), imports
def indent(self):
self.indentation += 1
def unindent(self):
self.indentation -= 1
def feed(self, line):
self.buff.append(' ' * (self.indentation * 4) + line)
def render(self):
return '\n'.join(self.buff)
class MigrationWriter(object):
"""
Takes a Migration instance and is able to produce the contents
of the migration file from it.
"""
def __init__(self, migration):
self.migration = migration
self.needs_manual_porting = False
def as_string(self):
"""
Returns a string of the file contents.
"""
items = {
"replaces_str": "",
"initial_str": "",
}
imports = set()
# Deconstruct operations
operations = []
for operation in self.migration.operations:
operation_string, operation_imports = OperationWriter(operation).serialize()
imports.update(operation_imports)
operations.append(operation_string)
items["operations"] = "\n".join(operations) + "\n" if operations else ""
# Format dependencies and write out swappable dependencies right
dependencies = []
for dependency in self.migration.dependencies:
if dependency[0] == "__setting__":
dependencies.append(" migrations.swappable_dependency(settings.%s)," % dependency[1])
imports.add("from django.conf import settings")
else:
# No need to output bytestrings for dependencies
dependency = tuple(force_text(s) for s in dependency)
dependencies.append(" %s," % self.serialize(dependency)[0])
items["dependencies"] = "\n".join(dependencies) + "\n" if dependencies else ""
# Format imports nicely, swapping imports of functions from migration files
# for comments
migration_imports = set()
for line in list(imports):
if re.match(r"^import (.*)\.\d+[^\s]*$", line):
migration_imports.add(line.split("import")[1].strip())
imports.remove(line)
self.needs_manual_porting = True
# django.db.migrations is always used, but models import may not be.
# If models import exists, merge it with migrations import.
if "from django.db import models" in imports:
imports.discard("from django.db import models")
imports.add("from django.db import migrations, models")
else:
imports.add("from django.db import migrations")
# Sort imports by the package / module to be imported (the part after
# "from" in "from ... import ..." or after "import" in "import ...").
sorted_imports = sorted(imports, key=lambda i: i.split()[1])
items["imports"] = "\n".join(sorted_imports) + "\n" if imports else ""
if migration_imports:
items["imports"] += (
"\n\n# Functions from the following migrations need manual "
"copying.\n# Move them and any dependencies into this file, "
"then update the\n# RunPython operations to refer to the local "
"versions:\n# %s"
) % "\n# ".join(sorted(migration_imports))
# If there's a replaces, make a string for it
if self.migration.replaces:
items['replaces_str'] = "\n replaces = %s\n" % self.serialize(self.migration.replaces)[0]
# Hinting that goes into comment
items.update(
version=get_version(),
timestamp=now().strftime("%Y-%m-%d %H:%M"),
)
if self.migration.initial:
items['initial_str'] = "\n initial = True\n"
return MIGRATION_TEMPLATE % items
@property
def basedir(self):
migrations_package_name, _ = MigrationLoader.migrations_module(self.migration.app_label)
if migrations_package_name is None:
raise ValueError(
"Django can't create migrations for app '%s' because "
"migrations have been disabled via the MIGRATION_MODULES "
"setting." % self.migration.app_label
)
# See if we can import the migrations module directly
try:
migrations_module = import_module(migrations_package_name)
except ImportError:
pass
else:
try:
return upath(module_dir(migrations_module))
except ValueError:
pass
# Alright, see if it's a direct submodule of the app
app_config = apps.get_app_config(self.migration.app_label)
maybe_app_name, _, migrations_package_basename = migrations_package_name.rpartition(".")
if app_config.name == maybe_app_name:
return os.path.join(app_config.path, migrations_package_basename)
# In case of using MIGRATION_MODULES setting and the custom package
# doesn't exist, create one, starting from an existing package
existing_dirs, missing_dirs = migrations_package_name.split("."), []
while existing_dirs:
missing_dirs.insert(0, existing_dirs.pop(-1))
try:
base_module = import_module(".".join(existing_dirs))
except ImportError:
continue
else:
try:
base_dir = upath(module_dir(base_module))
except ValueError:
continue
else:
break
else:
raise ValueError(
"Could not locate an appropriate location to create "
"migrations package %s. Make sure the toplevel "
"package exists and can be imported." %
migrations_package_name)
final_dir = os.path.join(base_dir, *missing_dirs)
if not os.path.isdir(final_dir):
os.makedirs(final_dir)
for missing_dir in missing_dirs:
base_dir = os.path.join(base_dir, missing_dir)
with open(os.path.join(base_dir, "__init__.py"), "w"):
pass
return final_dir
@property
def filename(self):
return "%s.py" % self.migration.name
@property
def path(self):
return os.path.join(self.basedir, self.filename)
@classmethod
def serialize(cls, value):
return serializer_factory(value).serialize()
MIGRATION_TEMPLATE = """\
# -*- coding: utf-8 -*-
# Generated by Django %(version)s on %(timestamp)s
from __future__ import unicode_literals
%(imports)s
class Migration(migrations.Migration):
%(replaces_str)s%(initial_str)s
dependencies = [
%(dependencies)s\
]
operations = [
%(operations)s\
]
"""
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
747,
199,
646,
295,
199,
504,
14802,
492,
492,
63,
578,
199,
199,
504,
1639,
492,
664,
63,
1023,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
697,
492,
6180,
199,
504,
1639,
14,
697,
14,
7685,
14,
3422,
492,
12090,
5455,
199,
504,
1639,
14,
697,
14,
7685,
14,
8349,
492,
9146,
63,
3702,
199,
504,
1639,
14,
1208,
423,
736,
492,
1536,
1619,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
10955,
492,
664,
63,
1532,
63,
589,
199,
504,
1639,
14,
1208,
14,
578,
63,
8786,
492,
859,
63,
694,
199,
504,
1639,
14,
1208,
14,
7145,
492,
3063,
199,
199,
893,
26,
272,
492,
4952,
199,
2590,
3545,
26,
272,
327,
3091,
2291,
641,
2018,
499,
340,
4952,
1082,
5712,
1133,
4903,
14,
272,
4952,
275,
488,
421,
199,
533,
13303,
5083,
8,
495,
304,
272,
408,
272,
12568,
5516,
402,
1059,
1314,
5965,
6941,
282,
1453,
2202,
272,
574,
14,
2779,
1159,
10184,
465,
314,
574,
315,
4402,
12,
1325,
3012,
6491,
734,
370,
282,
272,
2202,
14,
2339,
2225,
3659,
14,
272,
408,
339,
347,
636,
1222,
721,
277,
12,
574,
12,
4260,
63,
354,
304,
267,
372,
620,
855,
1222,
721,
277,
12,
574,
9,
339,
347,
636,
826,
721,
277,
12,
574,
12,
4260,
63,
354,
304,
267,
291,
14,
6031,
63,
354,
275,
4260,
63,
354,
421,
199,
533,
17954,
6261,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
3439,
12,
14311,
29,
18,
304,
267,
291,
14,
5735,
275,
3439,
267,
291,
14,
16830,
275,
942,
267,
291,
14,
25152,
275,
14311,
339,
347,
8437,
8,
277,
304,
398,
347,
485,
952,
1547,
1273,
63,
354,
12,
485,
1273,
63,
585,
304,
288,
340,
6110,
1273,
63,
354,
315,
291,
14,
5735,
14,
12161,
63,
4441,
63,
589,
436,
490,
1228,
1547,
1273,
63,
585,
12,
334,
513,
12,
2008,
12,
1211,
15206,
355,
340,
1228,
1547,
1273,
63,
585,
12,
1211,
304,
490,
291,
14,
3871,
3508,
83,
3713,
450,
485,
1273,
63,
354,
9,
490,
291,
14,
3724,
342,
490,
367,
790,
12,
574,
315,
485,
1273,
63,
585,
14,
1744,
837,
717,
790,
63,
875,
12,
790,
63,
12775,
275,
12090,
6261,
14,
3549,
8,
498,
9,
717,
1680,
63,
875,
12,
1680,
63,
12775,
275,
12090,
6261,
14,
3549,
8,
585,
9,
717,
1249,
275,
1680,
63,
875,
14,
7644,
342,
717,
340,
822,
8,
589,
9,
690,
413,
26,
1169,
291,
14,
3871,
3508,
83,
26,
450,
83,
7,
450,
334,
498,
63,
875,
12,
1249,
59,
16,
2459,
1169,
367,
1680,
315,
1249,
59,
17,
6809,
17,
2189,
1816,
291,
14,
3871,
8,
1273,
9,
1169,
291,
14,
3871,
3508,
83,
2584,
450,
1249,
1988,
17,
566,
717,
587,
26,
1169,
291,
14,
3871,
3508,
83,
26,
450,
83,
2584,
450,
334,
498,
63,
875,
12,
1680,
63,
875,
430,
717,
8925,
14,
873,
8,
498,
63,
12775,
9,
717,
8925,
14,
873,
8,
1273,
63,
12775,
9,
490,
291,
14,
324,
3724,
342,
490,
291,
14,
3871,
360,
1386,
358,
355,
587,
26,
490,
291,
14,
3871,
3508,
83,
2968,
450,
485,
1273,
63,
354,
9,
490,
291,
14,
3724,
342,
490,
367,
1242,
315,
485,
1273,
63,
585,
26,
717,
1680,
63,
875,
12,
1680,
63,
12775,
275,
12090,
6261,
14,
3549,
8,
1053,
9,
717,
1249,
275,
1680,
63,
875,
14,
7644,
342,
717,
340,
822,
8,
589,
9,
690,
413,
26,
1169,
367,
1680,
315,
1249,
4439,
17,
2189,
1816,
291,
14,
3871,
8,
1273,
9,
1169,
291,
14,
3871,
3508,
83,
2584,
450,
1249,
1988,
17,
566,
717,
587,
26,
1169,
291,
14,
3871,
3508,
83,
2584,
450,
1680,
63,
875,
9,
717,
8925,
14,
873,
8,
1273,
63,
12775,
9,
490,
291,
14,
324,
3724,
342,
490,
291,
14,
3871,
360,
467,
358,
288,
587,
26,
355,
1680,
63,
875,
12,
1680,
63,
12775,
275,
12090,
6261,
14,
3549,
1547,
1273,
63,
585,
9,
355,
1249,
275,
1680,
63,
875,
14,
7644,
342,
355,
340,
822,
8,
589,
9,
690,
413,
26,
490,
291,
14,
3871,
3508,
83,
2458,
83,
7,
450,
6110,
1273,
63,
354,
12,
1249,
59,
16,
2459,
490,
367,
1680,
315,
1249,
59,
17,
6809,
17,
2189,
717,
291,
14,
3871,
8,
1273,
9,
490,
291,
14,
3871,
3508,
83,
2584,
450,
1249,
1988,
17,
566,
355,
587,
26,
490,
291,
14,
3871,
3508,
83,
2458,
83,
2584,
450,
6110,
1273,
63,
354,
12,
1680,
63,
875,
430,
355,
8925,
14,
873,
8,
1273,
63,
12775,
9,
398,
8925,
275,
663,
342,
267,
536,
12,
1249,
12,
2074,
275,
291,
14,
5735,
14,
23693,
342,
267,
3439,
63,
589,
275,
664,
63,
1532,
63,
589,
8,
277,
14,
5735,
855,
826,
3368,
398,
327,
1666,
340,
642,
3439,
365,
315,
1639,
14,
697,
14,
7685,
14,
982,
652,
365,
12,
267,
327,
2136,
883,
2951,
675,
314,
10572,
781,
2575,
1172,
626,
8439,
12,
267,
327,
4257,
12,
781,
1929,
370,
1050,
376,
492,
367,
314,
3439,
1021,
14,
267,
340,
2519,
8,
7685,
12,
536,
12,
488,
9,
508,
291,
14,
5735,
855,
533,
10651,
288,
291,
14,
3871,
360,
7685,
4111,
83,
360,
450,
536,
9,
267,
587,
26,
288,
8925,
14,
525,
360,
646,
450,
83,
7,
450,
334,
277,
14,
5735,
855,
533,
4914,
578,
8964,
288,
291,
14,
3871,
3508,
83,
4111,
83,
360,
450,
334,
277,
14,
5735,
855,
533,
4914,
578,
3108,
536,
430,
398,
291,
14,
3724,
342,
398,
367,
284,
12,
1680,
315,
3874,
8,
589,
304,
288,
1680,
63,
585,
275,
1680,
288,
1680,
63,
354,
275,
3439,
63,
589,
59,
73,
61,
288,
485,
952,
8,
1273,
63,
354,
12,
1680,
63,
585,
9,
398,
284,
275,
822,
8,
589,
9,
267,
327,
5972,
13974,
1806,
7971,
2368,
267,
367,
1680,
63,
354,
315,
3439,
63,
589,
59,
73,
10688,
288,
340,
1680,
63,
354,
315,
2074,
26,
221,
327,
7529,
1133,
4069,
370,
11075,
4955,
1865,
355,
1680,
63,
585,
275
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
747,
199,
646,
295,
199,
504,
14802,
492,
492,
63,
578,
199,
199,
504,
1639,
492,
664,
63,
1023,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
697,
492,
6180,
199,
504,
1639,
14,
697,
14,
7685,
14,
3422,
492,
12090,
5455,
199,
504,
1639,
14,
697,
14,
7685,
14,
8349,
492,
9146,
63,
3702,
199,
504,
1639,
14,
1208,
423,
736,
492,
1536,
1619,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
10955,
492,
664,
63,
1532,
63,
589,
199,
504,
1639,
14,
1208,
14,
578,
63,
8786,
492,
859,
63,
694,
199,
504,
1639,
14,
1208,
14,
7145,
492,
3063,
199,
199,
893,
26,
272,
492,
4952,
199,
2590,
3545,
26,
272,
327,
3091,
2291,
641,
2018,
499,
340,
4952,
1082,
5712,
1133,
4903,
14,
272,
4952,
275,
488,
421,
199,
533,
13303,
5083,
8,
495,
304,
272,
408,
272,
12568,
5516,
402,
1059,
1314,
5965,
6941,
282,
1453,
2202,
272,
574,
14,
2779,
1159,
10184,
465,
314,
574,
315,
4402,
12,
1325,
3012,
6491,
734,
370,
282,
272,
2202,
14,
2339,
2225,
3659,
14,
272,
408,
339,
347,
636,
1222,
721,
277,
12,
574,
12,
4260,
63,
354,
304,
267,
372,
620,
855,
1222,
721,
277,
12,
574,
9,
339,
347,
636,
826,
721,
277,
12,
574,
12,
4260,
63,
354,
304,
267,
291,
14,
6031,
63,
354,
275,
4260,
63,
354,
421,
199,
533,
17954,
6261,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
3439,
12,
14311,
29,
18,
304,
267,
291,
14,
5735,
275,
3439,
267,
291,
14,
16830,
275,
942,
267,
291,
14,
25152,
275,
14311,
339,
347,
8437,
8,
277,
304,
398,
347,
485,
952,
1547,
1273,
63,
354,
12,
485,
1273,
63,
585,
304,
288,
340,
6110,
1273,
63,
354,
315,
291,
14,
5735,
14,
12161,
63,
4441,
63,
589,
436,
490,
1228,
1547,
1273,
63,
585,
12,
334,
513,
12,
2008,
12,
1211,
15206,
355,
340,
1228,
1547,
1273,
63,
585,
12,
1211,
304,
490,
291,
14,
3871,
3508,
83,
3713,
450,
485,
1273,
63,
354,
9,
490,
291,
14,
3724,
342,
490,
367,
790,
12,
574,
315,
485,
1273,
63,
585,
14,
1744,
837,
717,
790,
63,
875,
12,
790,
63,
12775,
275,
12090,
6261,
14,
3549,
8,
498,
9,
717,
1680,
63,
875,
12,
1680,
63,
12775,
275,
12090,
6261,
14,
3549,
8,
585,
9,
717,
1249,
275,
1680,
63,
875,
14,
7644,
342,
717,
340,
822,
8,
589,
9,
690,
413,
26,
1169,
291,
14,
3871,
3508,
83,
26,
450,
83,
7,
450,
334,
498,
63,
875,
12,
1249,
59,
16,
2459,
1169,
367,
1680,
315,
1249,
59,
17,
6809,
17,
2189,
1816,
291,
14,
3871,
8,
1273,
9,
1169,
291,
14,
3871,
3508,
83,
2584,
450,
1249,
1988,
17,
566,
717,
587,
26,
1169,
291,
14,
3871,
3508,
83,
26,
450,
83,
2584,
450,
334,
498,
63,
875,
12,
1680,
63,
875,
430,
717,
8925,
14,
873,
8,
498,
63,
12775,
9,
717,
8925,
14,
873,
8,
1273,
63,
12775,
9,
490,
291,
14,
324,
3724,
342,
490,
291,
14,
3871,
360,
1386,
358,
355,
587,
26,
490,
291,
14,
3871,
3508,
83,
2968,
450,
485,
1273,
63,
354,
9,
490,
291,
14,
3724,
342,
490,
367,
1242,
315,
485,
1273,
63,
585,
26,
717,
1680,
63,
875,
12,
1680,
63,
12775,
275,
12090,
6261,
14,
3549,
8,
1053,
9,
717,
1249,
275,
1680,
63,
875,
14,
7644,
342,
717,
340,
822,
8,
589,
9,
690,
413,
26,
1169,
367,
1680,
315,
1249,
4439,
17,
2189,
1816,
291,
14,
3871,
8,
1273,
9,
1169,
291,
14,
3871,
3508,
83,
2584,
450,
1249,
1988,
17,
566,
717,
587,
26,
1169,
291,
14,
3871,
3508,
83,
2584,
450,
1680,
63,
875,
9,
717,
8925,
14,
873,
8,
1273,
63,
12775,
9,
490,
291,
14,
324,
3724,
342,
490,
291,
14,
3871,
360,
467,
358,
288,
587,
26,
355,
1680,
63,
875,
12,
1680,
63,
12775,
275,
12090,
6261,
14,
3549,
1547,
1273,
63,
585,
9,
355,
1249,
275,
1680,
63,
875,
14,
7644,
342,
355,
340,
822,
8,
589,
9,
690,
413,
26,
490,
291,
14,
3871,
3508,
83,
2458,
83,
7,
450,
6110,
1273,
63,
354,
12,
1249,
59,
16,
2459,
490,
367,
1680,
315,
1249,
59,
17,
6809,
17,
2189,
717,
291,
14,
3871,
8,
1273,
9,
490,
291,
14,
3871,
3508,
83,
2584,
450,
1249,
1988,
17,
566,
355,
587,
26,
490,
291,
14,
3871,
3508,
83,
2458,
83,
2584,
450,
6110,
1273,
63,
354,
12,
1680,
63,
875,
430,
355,
8925,
14,
873,
8,
1273,
63,
12775,
9,
398,
8925,
275,
663,
342,
267,
536,
12,
1249,
12,
2074,
275,
291,
14,
5735,
14,
23693,
342,
267,
3439,
63,
589,
275,
664,
63,
1532,
63,
589,
8,
277,
14,
5735,
855,
826,
3368,
398,
327,
1666,
340,
642,
3439,
365,
315,
1639,
14,
697,
14,
7685,
14,
982,
652,
365,
12,
267,
327,
2136,
883,
2951,
675,
314,
10572,
781,
2575,
1172,
626,
8439,
12,
267,
327,
4257,
12,
781,
1929,
370,
1050,
376,
492,
367,
314,
3439,
1021,
14,
267,
340,
2519,
8,
7685,
12,
536,
12,
488,
9,
508,
291,
14,
5735,
855,
533,
10651,
288,
291,
14,
3871,
360,
7685,
4111,
83,
360,
450,
536,
9,
267,
587,
26,
288,
8925,
14,
525,
360,
646,
450,
83,
7,
450,
334,
277,
14,
5735,
855,
533,
4914,
578,
8964,
288,
291,
14,
3871,
3508,
83,
4111,
83,
360,
450,
334,
277,
14,
5735,
855,
533,
4914,
578,
3108,
536,
430,
398,
291,
14,
3724,
342,
398,
367,
284,
12,
1680,
315,
3874,
8,
589,
304,
288,
1680,
63,
585,
275,
1680,
288,
1680,
63,
354,
275,
3439,
63,
589,
59,
73,
61,
288,
485,
952,
8,
1273,
63,
354,
12,
1680,
63,
585,
9,
398,
284,
275,
822,
8,
589,
9,
267,
327,
5972,
13974,
1806,
7971,
2368,
267,
367,
1680,
63,
354,
315,
3439,
63,
589,
59,
73,
10688,
288,
340,
1680,
63,
354,
315,
2074,
26,
221,
327,
7529,
1133,
4069,
370,
11075,
4955,
1865,
355,
1680,
63,
585,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
eptmp3/Sick-Beard
|
lib/requests/packages/chardet/langbulgarianmodel.py
|
235
|
12820
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
import constants
# 255: Control characters that usually does not exist in any text
# 254: Carriage/Return
# 253: symbol (punctuation) that does not belong to word
# 252: 0 - 9
# Character Mapping Table:
# this table is modified base on win1251BulgarianCharToOrderMap, so
# only number <64 is sure valid
Latin5_BulgarianCharToOrderMap = ( \
255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 40
110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 50
253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 60
116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 70
194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, # 80
210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225, # 90
81,226,227,228,229,230,105,231,232,233,234,235,236, 45,237,238, # a0
31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # b0
39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,239, 67,240, 60, 56, # c0
1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # d0
7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,241, 42, 16, # e0
62,242,243,244, 58,245, 98,246,247,248,249,250,251, 91,252,253, # f0
)
win1251BulgarianCharToOrderMap = ( \
255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 40
110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 50
253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 60
116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 70
206,207,208,209,210,211,212,213,120,214,215,216,217,218,219,220, # 80
221, 78, 64, 83,121, 98,117,105,222,223,224,225,226,227,228,229, # 90
88,230,231,232,233,122, 89,106,234,235,236,237,238, 45,239,240, # a0
73, 80,118,114,241,242,243,244,245, 62, 58,246,247,248,249,250, # b0
31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # c0
39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,251, 67,252, 60, 56, # d0
1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # e0
7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,253, 42, 16, # f0
)
# Model Table:
# total sequences: 100%
# first 512 sequences: 96.9392%
# first 1024 sequences:3.0618%
# rest sequences: 0.2992%
# negative sequences: 0.0020%
BulgarianLangModel = ( \
0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,3,3,3,3,3,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,2,2,3,2,2,1,2,2,
3,1,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,0,1,
0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,3,3,3,3,3,3,3,0,3,1,0,
0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0,
0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
3,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0,
0,0,0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,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,
1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,2,0,0,2,0,1,0,0,1,0,0,1,
1,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,
1,1,1,1,1,1,1,2,0,0,0,0,0,0,2,1,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1,0,1,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
)
Latin5BulgarianModel = { \
'charToOrderMap': Latin5_BulgarianCharToOrderMap,
'precedenceMatrix': BulgarianLangModel,
'mTypicalPositiveRatio': 0.969392,
'keepEnglishLetter': constants.False,
'charsetName': "ISO-8859-5"
}
Win1251BulgarianModel = { \
'charToOrderMap': win1251BulgarianCharToOrderMap,
'precedenceMatrix': BulgarianLangModel,
'mTypicalPositiveRatio': 0.969392,
'keepEnglishLetter': constants.False,
'charsetName': "windows-1251"
}
|
gpl-3.0
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
13338,
707,
1890,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
646,
5262,
199,
199,
3,
5450,
26,
8612,
4110,
626,
9987,
1630,
440,
2187,
315,
1263,
1318,
199,
3,
22540,
26,
14243,
25220,
15,
1767,
199,
3,
26727,
26,
5272,
334,
25181,
9,
626,
1630,
440,
13511,
370,
4349,
199,
3,
27210,
26,
378,
446,
1749,
199,
199,
3,
17660,
12340,
6957,
26,
199,
3,
642,
1817,
365,
6042,
1300,
641,
4747,
21381,
34,
27092,
15289,
24516,
12,
880,
221,
199,
3,
1454,
1329,
665,
772,
365,
3238,
1686,
199,
199,
27317,
21,
63,
34,
27092,
15289,
24516,
275,
334,
971,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
221,
327,
8733,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
221,
327,
1616,
199,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
3388,
199,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
4233,
199,
3781,
12,
8375,
12,
9137,
12,
8806,
12,
1960,
12,
15323,
12,
6996,
12,
7555,
12,
4893,
12,
13734,
12,
10233,
12,
19071,
12,
7759,
12,
14646,
12,
18729,
12,
18051,
12,
221,
327,
6335,
199,
6019,
12,
11656,
12,
8079,
12,
21358,
12,
9720,
12,
7119,
12,
8264,
12,
15580,
12,
6673,
12,
11775,
12,
7680,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
5238,
199,
3781,
12,
11738,
12,
14610,
12,
10045,
12,
14157,
12,
13668,
12,
10851,
12,
6094,
12,
8845,
12,
20140,
12,
10860,
12,
6785,
12,
16102,
12,
10300,
12,
10513,
12,
17245,
12,
221,
327,
5212,
199,
7524,
12,
11874,
12,
16412,
12,
18969,
12,
15997,
12,
9225,
12,
10800,
12,
11165,
12,
10905,
12,
7155,
12,
1840,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
10045,
199,
10860,
12,
11874,
12,
10800,
12,
11165,
12,
10905,
12,
7155,
12,
1840,
12,
1797,
12,
4999,
12,
11341,
12,
6686,
12,
10629,
12,
11089,
12,
10744,
12,
10630,
12,
11303,
12,
221,
327,
5939,
199,
12725,
12,
12832,
12,
11722,
12,
14271,
12,
6886,
12,
7842,
12,
9669,
12,
9335,
12,
9252,
12,
8867,
12,
11174,
12,
11564,
12,
9485,
12,
11583,
12,
8731,
12,
10932,
12,
221,
327,
9137,
199,
19071,
12,
11085,
12,
11385,
12,
12048,
12,
11182,
12,
9687,
12,
7320,
12,
11921,
12,
8001,
12,
10034,
12,
5533,
12,
8276,
12,
10008,
12,
10416,
12,
10638,
12,
12332,
12,
221,
327,
282,
16,
199,
7105,
12,
4337,
12,
8685,
12,
11851,
12,
6877,
12,
10868,
12,
12766,
12,
10954,
12,
6335,
12,
8155,
12,
9404,
12,
12426,
12,
10448,
12,
8780,
12,
13385,
12,
4233,
12,
221,
327,
330,
16,
199,
10551,
12,
7294,
12,
8177,
12,
8026,
12,
9615,
12,
12260,
12,
13564,
12,
5238,
12,
13470,
12,
12699,
12,
17017,
12,
9803,
12,
13296,
12,
9873,
12,
5212,
12,
12001,
12,
221,
327,
286,
16,
523,
413,
12,
6155,
12,
221,
1749,
12,
3388,
12,
4119,
12,
221,
650,
12,
6546,
12,
4114,
12,
221,
499,
12,
7875,
12,
3144,
12,
1616,
12,
4329,
12,
221,
1227,
12,
221,
841,
12,
4944,
12,
221,
327,
366,
16,
523,
1520,
12,
221,
1695,
12,
221,
959,
12,
5851,
12,
7349,
12,
5661,
12,
6928,
12,
7829,
12,
8087,
12,
5504,
12,
5557,
12,
13098,
12,
14589,
12,
13571,
12,
5685,
12,
3193,
12,
221,
327,
325,
16,
199,
16202,
12,
13212,
12,
13440,
12,
11603,
12,
13713,
12,
11677,
12,
16096,
12,
11440,
12,
11717,
12,
11242,
12,
11032,
12,
7991,
12,
12140,
12,
21358,
12,
6390,
12,
3781,
12,
221,
327,
289,
16,
199,
9,
199,
199,
2676,
21381,
34,
27092,
15289,
24516,
275,
334,
971,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
221,
327,
8733,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
221,
327,
1616,
199,
3781
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
13338,
707,
1890,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
646,
5262,
199,
199,
3,
5450,
26,
8612,
4110,
626,
9987,
1630,
440,
2187,
315,
1263,
1318,
199,
3,
22540,
26,
14243,
25220,
15,
1767,
199,
3,
26727,
26,
5272,
334,
25181,
9,
626,
1630,
440,
13511,
370,
4349,
199,
3,
27210,
26,
378,
446,
1749,
199,
199,
3,
17660,
12340,
6957,
26,
199,
3,
642,
1817,
365,
6042,
1300,
641,
4747,
21381,
34,
27092,
15289,
24516,
12,
880,
221,
199,
3,
1454,
1329,
665,
772,
365,
3238,
1686,
199,
199,
27317,
21,
63,
34,
27092,
15289,
24516,
275,
334,
971,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
221,
327,
8733,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
221,
327,
1616,
199,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
3388,
199,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
4233,
199,
3781,
12,
8375,
12,
9137,
12,
8806,
12,
1960,
12,
15323,
12,
6996,
12,
7555,
12,
4893,
12,
13734,
12,
10233,
12,
19071,
12,
7759,
12,
14646,
12,
18729,
12,
18051,
12,
221,
327,
6335,
199,
6019,
12,
11656,
12,
8079,
12,
21358,
12,
9720,
12,
7119,
12,
8264,
12,
15580,
12,
6673,
12,
11775,
12,
7680,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
5238,
199,
3781,
12,
11738,
12,
14610,
12,
10045,
12,
14157,
12,
13668,
12,
10851,
12,
6094,
12,
8845,
12,
20140,
12,
10860,
12,
6785,
12,
16102,
12,
10300,
12,
10513,
12,
17245,
12,
221,
327,
5212,
199,
7524,
12,
11874,
12,
16412,
12,
18969,
12,
15997,
12,
9225,
12,
10800,
12,
11165,
12,
10905,
12,
7155,
12,
1840,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
10045,
199,
10860,
12,
11874,
12,
10800,
12,
11165,
12,
10905,
12,
7155,
12,
1840,
12,
1797,
12,
4999,
12,
11341,
12,
6686,
12,
10629,
12,
11089,
12,
10744,
12,
10630,
12,
11303,
12,
221,
327,
5939,
199,
12725,
12,
12832,
12,
11722,
12,
14271,
12,
6886,
12,
7842,
12,
9669,
12,
9335,
12,
9252,
12,
8867,
12,
11174,
12,
11564,
12,
9485,
12,
11583,
12,
8731,
12,
10932,
12,
221,
327,
9137,
199,
19071,
12,
11085,
12,
11385,
12,
12048,
12,
11182,
12,
9687,
12,
7320,
12,
11921,
12,
8001,
12,
10034,
12,
5533,
12,
8276,
12,
10008,
12,
10416,
12,
10638,
12,
12332,
12,
221,
327,
282,
16,
199,
7105,
12,
4337,
12,
8685,
12,
11851,
12,
6877,
12,
10868,
12,
12766,
12,
10954,
12,
6335,
12,
8155,
12,
9404,
12,
12426,
12,
10448,
12,
8780,
12,
13385,
12,
4233,
12,
221,
327,
330,
16,
199,
10551,
12,
7294,
12,
8177,
12,
8026,
12,
9615,
12,
12260,
12,
13564,
12,
5238,
12,
13470,
12,
12699,
12,
17017,
12,
9803,
12,
13296,
12,
9873,
12,
5212,
12,
12001,
12,
221,
327,
286,
16,
523,
413,
12,
6155,
12,
221,
1749,
12,
3388,
12,
4119,
12,
221,
650,
12,
6546,
12,
4114,
12,
221,
499,
12,
7875,
12,
3144,
12,
1616,
12,
4329,
12,
221,
1227,
12,
221,
841,
12,
4944,
12,
221,
327,
366,
16,
523,
1520,
12,
221,
1695,
12,
221,
959,
12,
5851,
12,
7349,
12,
5661,
12,
6928,
12,
7829,
12,
8087,
12,
5504,
12,
5557,
12,
13098,
12,
14589,
12,
13571,
12,
5685,
12,
3193,
12,
221,
327,
325,
16,
199,
16202,
12,
13212,
12,
13440,
12,
11603,
12,
13713,
12,
11677,
12,
16096,
12,
11440,
12,
11717,
12,
11242,
12,
11032,
12,
7991,
12,
12140,
12,
21358,
12,
6390,
12,
3781,
12,
221,
327,
289,
16,
199,
9,
199,
199,
2676,
21381,
34,
27092,
15289,
24516,
275,
334,
971,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
221,
327,
8733,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
221,
327,
1616,
199,
3781,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sdarji/lpthw
|
Lib/encodings/cp864.py
|
593
|
33919
|
""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP864.TXT' with gencodec.py.
"""#"
import codecs
### Codec APIs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
return codecs.charmap_encode(input,errors,encoding_map)
def decode(self,input,errors='strict'):
return codecs.charmap_decode(input,errors,decoding_table)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
class StreamWriter(Codec,codecs.StreamWriter):
pass
class StreamReader(Codec,codecs.StreamReader):
pass
### encodings module API
def getregentry():
return codecs.CodecInfo(
name='cp864',
encode=Codec().encode,
decode=Codec().decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamreader=StreamReader,
streamwriter=StreamWriter,
)
### Decoding Map
decoding_map = codecs.make_identity_dict(range(256))
decoding_map.update({
0x0025: 0x066a, # ARABIC PERCENT SIGN
0x0080: 0x00b0, # DEGREE SIGN
0x0081: 0x00b7, # MIDDLE DOT
0x0082: 0x2219, # BULLET OPERATOR
0x0083: 0x221a, # SQUARE ROOT
0x0084: 0x2592, # MEDIUM SHADE
0x0085: 0x2500, # FORMS LIGHT HORIZONTAL
0x0086: 0x2502, # FORMS LIGHT VERTICAL
0x0087: 0x253c, # FORMS LIGHT VERTICAL AND HORIZONTAL
0x0088: 0x2524, # FORMS LIGHT VERTICAL AND LEFT
0x0089: 0x252c, # FORMS LIGHT DOWN AND HORIZONTAL
0x008a: 0x251c, # FORMS LIGHT VERTICAL AND RIGHT
0x008b: 0x2534, # FORMS LIGHT UP AND HORIZONTAL
0x008c: 0x2510, # FORMS LIGHT DOWN AND LEFT
0x008d: 0x250c, # FORMS LIGHT DOWN AND RIGHT
0x008e: 0x2514, # FORMS LIGHT UP AND RIGHT
0x008f: 0x2518, # FORMS LIGHT UP AND LEFT
0x0090: 0x03b2, # GREEK SMALL BETA
0x0091: 0x221e, # INFINITY
0x0092: 0x03c6, # GREEK SMALL PHI
0x0093: 0x00b1, # PLUS-OR-MINUS SIGN
0x0094: 0x00bd, # FRACTION 1/2
0x0095: 0x00bc, # FRACTION 1/4
0x0096: 0x2248, # ALMOST EQUAL TO
0x0097: 0x00ab, # LEFT POINTING GUILLEMET
0x0098: 0x00bb, # RIGHT POINTING GUILLEMET
0x0099: 0xfef7, # ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
0x009a: 0xfef8, # ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
0x009b: None, # UNDEFINED
0x009c: None, # UNDEFINED
0x009d: 0xfefb, # ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
0x009e: 0xfefc, # ARABIC LIGATURE LAM WITH ALEF FINAL FORM
0x009f: None, # UNDEFINED
0x00a1: 0x00ad, # SOFT HYPHEN
0x00a2: 0xfe82, # ARABIC LETTER ALEF WITH MADDA ABOVE FINAL FORM
0x00a5: 0xfe84, # ARABIC LETTER ALEF WITH HAMZA ABOVE FINAL FORM
0x00a6: None, # UNDEFINED
0x00a7: None, # UNDEFINED
0x00a8: 0xfe8e, # ARABIC LETTER ALEF FINAL FORM
0x00a9: 0xfe8f, # ARABIC LETTER BEH ISOLATED FORM
0x00aa: 0xfe95, # ARABIC LETTER TEH ISOLATED FORM
0x00ab: 0xfe99, # ARABIC LETTER THEH ISOLATED FORM
0x00ac: 0x060c, # ARABIC COMMA
0x00ad: 0xfe9d, # ARABIC LETTER JEEM ISOLATED FORM
0x00ae: 0xfea1, # ARABIC LETTER HAH ISOLATED FORM
0x00af: 0xfea5, # ARABIC LETTER KHAH ISOLATED FORM
0x00b0: 0x0660, # ARABIC-INDIC DIGIT ZERO
0x00b1: 0x0661, # ARABIC-INDIC DIGIT ONE
0x00b2: 0x0662, # ARABIC-INDIC DIGIT TWO
0x00b3: 0x0663, # ARABIC-INDIC DIGIT THREE
0x00b4: 0x0664, # ARABIC-INDIC DIGIT FOUR
0x00b5: 0x0665, # ARABIC-INDIC DIGIT FIVE
0x00b6: 0x0666, # ARABIC-INDIC DIGIT SIX
0x00b7: 0x0667, # ARABIC-INDIC DIGIT SEVEN
0x00b8: 0x0668, # ARABIC-INDIC DIGIT EIGHT
0x00b9: 0x0669, # ARABIC-INDIC DIGIT NINE
0x00ba: 0xfed1, # ARABIC LETTER FEH ISOLATED FORM
0x00bb: 0x061b, # ARABIC SEMICOLON
0x00bc: 0xfeb1, # ARABIC LETTER SEEN ISOLATED FORM
0x00bd: 0xfeb5, # ARABIC LETTER SHEEN ISOLATED FORM
0x00be: 0xfeb9, # ARABIC LETTER SAD ISOLATED FORM
0x00bf: 0x061f, # ARABIC QUESTION MARK
0x00c0: 0x00a2, # CENT SIGN
0x00c1: 0xfe80, # ARABIC LETTER HAMZA ISOLATED FORM
0x00c2: 0xfe81, # ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM
0x00c3: 0xfe83, # ARABIC LETTER ALEF WITH HAMZA ABOVE ISOLATED FORM
0x00c4: 0xfe85, # ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM
0x00c5: 0xfeca, # ARABIC LETTER AIN FINAL FORM
0x00c6: 0xfe8b, # ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM
0x00c7: 0xfe8d, # ARABIC LETTER ALEF ISOLATED FORM
0x00c8: 0xfe91, # ARABIC LETTER BEH INITIAL FORM
0x00c9: 0xfe93, # ARABIC LETTER TEH MARBUTA ISOLATED FORM
0x00ca: 0xfe97, # ARABIC LETTER TEH INITIAL FORM
0x00cb: 0xfe9b, # ARABIC LETTER THEH INITIAL FORM
0x00cc: 0xfe9f, # ARABIC LETTER JEEM INITIAL FORM
0x00cd: 0xfea3, # ARABIC LETTER HAH INITIAL FORM
0x00ce: 0xfea7, # ARABIC LETTER KHAH INITIAL FORM
0x00cf: 0xfea9, # ARABIC LETTER DAL ISOLATED FORM
0x00d0: 0xfeab, # ARABIC LETTER THAL ISOLATED FORM
0x00d1: 0xfead, # ARABIC LETTER REH ISOLATED FORM
0x00d2: 0xfeaf, # ARABIC LETTER ZAIN ISOLATED FORM
0x00d3: 0xfeb3, # ARABIC LETTER SEEN INITIAL FORM
0x00d4: 0xfeb7, # ARABIC LETTER SHEEN INITIAL FORM
0x00d5: 0xfebb, # ARABIC LETTER SAD INITIAL FORM
0x00d6: 0xfebf, # ARABIC LETTER DAD INITIAL FORM
0x00d7: 0xfec1, # ARABIC LETTER TAH ISOLATED FORM
0x00d8: 0xfec5, # ARABIC LETTER ZAH ISOLATED FORM
0x00d9: 0xfecb, # ARABIC LETTER AIN INITIAL FORM
0x00da: 0xfecf, # ARABIC LETTER GHAIN INITIAL FORM
0x00db: 0x00a6, # BROKEN VERTICAL BAR
0x00dc: 0x00ac, # NOT SIGN
0x00dd: 0x00f7, # DIVISION SIGN
0x00de: 0x00d7, # MULTIPLICATION SIGN
0x00df: 0xfec9, # ARABIC LETTER AIN ISOLATED FORM
0x00e0: 0x0640, # ARABIC TATWEEL
0x00e1: 0xfed3, # ARABIC LETTER FEH INITIAL FORM
0x00e2: 0xfed7, # ARABIC LETTER QAF INITIAL FORM
0x00e3: 0xfedb, # ARABIC LETTER KAF INITIAL FORM
0x00e4: 0xfedf, # ARABIC LETTER LAM INITIAL FORM
0x00e5: 0xfee3, # ARABIC LETTER MEEM INITIAL FORM
0x00e6: 0xfee7, # ARABIC LETTER NOON INITIAL FORM
0x00e7: 0xfeeb, # ARABIC LETTER HEH INITIAL FORM
0x00e8: 0xfeed, # ARABIC LETTER WAW ISOLATED FORM
0x00e9: 0xfeef, # ARABIC LETTER ALEF MAKSURA ISOLATED FORM
0x00ea: 0xfef3, # ARABIC LETTER YEH INITIAL FORM
0x00eb: 0xfebd, # ARABIC LETTER DAD ISOLATED FORM
0x00ec: 0xfecc, # ARABIC LETTER AIN MEDIAL FORM
0x00ed: 0xfece, # ARABIC LETTER GHAIN FINAL FORM
0x00ee: 0xfecd, # ARABIC LETTER GHAIN ISOLATED FORM
0x00ef: 0xfee1, # ARABIC LETTER MEEM ISOLATED FORM
0x00f0: 0xfe7d, # ARABIC SHADDA MEDIAL FORM
0x00f1: 0x0651, # ARABIC SHADDAH
0x00f2: 0xfee5, # ARABIC LETTER NOON ISOLATED FORM
0x00f3: 0xfee9, # ARABIC LETTER HEH ISOLATED FORM
0x00f4: 0xfeec, # ARABIC LETTER HEH MEDIAL FORM
0x00f5: 0xfef0, # ARABIC LETTER ALEF MAKSURA FINAL FORM
0x00f6: 0xfef2, # ARABIC LETTER YEH FINAL FORM
0x00f7: 0xfed0, # ARABIC LETTER GHAIN MEDIAL FORM
0x00f8: 0xfed5, # ARABIC LETTER QAF ISOLATED FORM
0x00f9: 0xfef5, # ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
0x00fa: 0xfef6, # ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
0x00fb: 0xfedd, # ARABIC LETTER LAM ISOLATED FORM
0x00fc: 0xfed9, # ARABIC LETTER KAF ISOLATED FORM
0x00fd: 0xfef1, # ARABIC LETTER YEH ISOLATED FORM
0x00fe: 0x25a0, # BLACK SQUARE
0x00ff: None, # UNDEFINED
})
### Decoding Table
decoding_table = (
u'\x00' # 0x0000 -> NULL
u'\x01' # 0x0001 -> START OF HEADING
u'\x02' # 0x0002 -> START OF TEXT
u'\x03' # 0x0003 -> END OF TEXT
u'\x04' # 0x0004 -> END OF TRANSMISSION
u'\x05' # 0x0005 -> ENQUIRY
u'\x06' # 0x0006 -> ACKNOWLEDGE
u'\x07' # 0x0007 -> BELL
u'\x08' # 0x0008 -> BACKSPACE
u'\t' # 0x0009 -> HORIZONTAL TABULATION
u'\n' # 0x000a -> LINE FEED
u'\x0b' # 0x000b -> VERTICAL TABULATION
u'\x0c' # 0x000c -> FORM FEED
u'\r' # 0x000d -> CARRIAGE RETURN
u'\x0e' # 0x000e -> SHIFT OUT
u'\x0f' # 0x000f -> SHIFT IN
u'\x10' # 0x0010 -> DATA LINK ESCAPE
u'\x11' # 0x0011 -> DEVICE CONTROL ONE
u'\x12' # 0x0012 -> DEVICE CONTROL TWO
u'\x13' # 0x0013 -> DEVICE CONTROL THREE
u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
u'\x18' # 0x0018 -> CANCEL
u'\x19' # 0x0019 -> END OF MEDIUM
u'\x1a' # 0x001a -> SUBSTITUTE
u'\x1b' # 0x001b -> ESCAPE
u'\x1c' # 0x001c -> FILE SEPARATOR
u'\x1d' # 0x001d -> GROUP SEPARATOR
u'\x1e' # 0x001e -> RECORD SEPARATOR
u'\x1f' # 0x001f -> UNIT SEPARATOR
u' ' # 0x0020 -> SPACE
u'!' # 0x0021 -> EXCLAMATION MARK
u'"' # 0x0022 -> QUOTATION MARK
u'#' # 0x0023 -> NUMBER SIGN
u'$' # 0x0024 -> DOLLAR SIGN
u'\u066a' # 0x0025 -> ARABIC PERCENT SIGN
u'&' # 0x0026 -> AMPERSAND
u"'" # 0x0027 -> APOSTROPHE
u'(' # 0x0028 -> LEFT PARENTHESIS
u')' # 0x0029 -> RIGHT PARENTHESIS
u'*' # 0x002a -> ASTERISK
u'+' # 0x002b -> PLUS SIGN
u',' # 0x002c -> COMMA
u'-' # 0x002d -> HYPHEN-MINUS
u'.' # 0x002e -> FULL STOP
u'/' # 0x002f -> SOLIDUS
u'0' # 0x0030 -> DIGIT ZERO
u'1' # 0x0031 -> DIGIT ONE
u'2' # 0x0032 -> DIGIT TWO
u'3' # 0x0033 -> DIGIT THREE
u'4' # 0x0034 -> DIGIT FOUR
u'5' # 0x0035 -> DIGIT FIVE
u'6' # 0x0036 -> DIGIT SIX
u'7' # 0x0037 -> DIGIT SEVEN
u'8' # 0x0038 -> DIGIT EIGHT
u'9' # 0x0039 -> DIGIT NINE
u':' # 0x003a -> COLON
u';' # 0x003b -> SEMICOLON
u'<' # 0x003c -> LESS-THAN SIGN
u'=' # 0x003d -> EQUALS SIGN
u'>' # 0x003e -> GREATER-THAN SIGN
u'?' # 0x003f -> QUESTION MARK
u'@' # 0x0040 -> COMMERCIAL AT
u'A' # 0x0041 -> LATIN CAPITAL LETTER A
u'B' # 0x0042 -> LATIN CAPITAL LETTER B
u'C' # 0x0043 -> LATIN CAPITAL LETTER C
u'D' # 0x0044 -> LATIN CAPITAL LETTER D
u'E' # 0x0045 -> LATIN CAPITAL LETTER E
u'F' # 0x0046 -> LATIN CAPITAL LETTER F
u'G' # 0x0047 -> LATIN CAPITAL LETTER G
u'H' # 0x0048 -> LATIN CAPITAL LETTER H
u'I' # 0x0049 -> LATIN CAPITAL LETTER I
u'J' # 0x004a -> LATIN CAPITAL LETTER J
u'K' # 0x004b -> LATIN CAPITAL LETTER K
u'L' # 0x004c -> LATIN CAPITAL LETTER L
u'M' # 0x004d -> LATIN CAPITAL LETTER M
u'N' # 0x004e -> LATIN CAPITAL LETTER N
u'O' # 0x004f -> LATIN CAPITAL LETTER O
u'P' # 0x0050 -> LATIN CAPITAL LETTER P
u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
u'R' # 0x0052 -> LATIN CAPITAL LETTER R
u'S' # 0x0053 -> LATIN CAPITAL LETTER S
u'T' # 0x0054 -> LATIN CAPITAL LETTER T
u'U' # 0x0055 -> LATIN CAPITAL LETTER U
u'V' # 0x0056 -> LATIN CAPITAL LETTER V
u'W' # 0x0057 -> LATIN CAPITAL LETTER W
u'X' # 0x0058 -> LATIN CAPITAL LETTER X
u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
u'[' # 0x005b -> LEFT SQUARE BRACKET
u'\\' # 0x005c -> REVERSE SOLIDUS
u']' # 0x005d -> RIGHT SQUARE BRACKET
u'^' # 0x005e -> CIRCUMFLEX ACCENT
u'_' # 0x005f -> LOW LINE
u'`' # 0x0060 -> GRAVE ACCENT
u'a' # 0x0061 -> LATIN SMALL LETTER A
u'b' # 0x0062 -> LATIN SMALL LETTER B
u'c' # 0x0063 -> LATIN SMALL LETTER C
u'd' # 0x0064 -> LATIN SMALL LETTER D
u'e' # 0x0065 -> LATIN SMALL LETTER E
u'f' # 0x0066 -> LATIN SMALL LETTER F
u'g' # 0x0067 -> LATIN SMALL LETTER G
u'h' # 0x0068 -> LATIN SMALL LETTER H
u'i' # 0x0069 -> LATIN SMALL LETTER I
u'j' # 0x006a -> LATIN SMALL LETTER J
u'k' # 0x006b -> LATIN SMALL LETTER K
u'l' # 0x006c -> LATIN SMALL LETTER L
u'm' # 0x006d -> LATIN SMALL LETTER M
u'n' # 0x006e -> LATIN SMALL LETTER N
u'o' # 0x006f -> LATIN SMALL LETTER O
u'p' # 0x0070 -> LATIN SMALL LETTER P
u'q' # 0x0071 -> LATIN SMALL LETTER Q
u'r' # 0x0072 -> LATIN SMALL LETTER R
u's' # 0x0073 -> LATIN SMALL LETTER S
u't' # 0x0074 -> LATIN SMALL LETTER T
u'u' # 0x0075 -> LATIN SMALL LETTER U
u'v' # 0x0076 -> LATIN SMALL LETTER V
u'w' # 0x0077 -> LATIN SMALL LETTER W
u'x' # 0x0078 -> LATIN SMALL LETTER X
u'y' # 0x0079 -> LATIN SMALL LETTER Y
u'z' # 0x007a -> LATIN SMALL LETTER Z
u'{' # 0x007b -> LEFT CURLY BRACKET
u'|' # 0x007c -> VERTICAL LINE
u'}' # 0x007d -> RIGHT CURLY BRACKET
u'~' # 0x007e -> TILDE
u'\x7f' # 0x007f -> DELETE
u'\xb0' # 0x0080 -> DEGREE SIGN
u'\xb7' # 0x0081 -> MIDDLE DOT
u'\u2219' # 0x0082 -> BULLET OPERATOR
u'\u221a' # 0x0083 -> SQUARE ROOT
u'\u2592' # 0x0084 -> MEDIUM SHADE
u'\u2500' # 0x0085 -> FORMS LIGHT HORIZONTAL
u'\u2502' # 0x0086 -> FORMS LIGHT VERTICAL
u'\u253c' # 0x0087 -> FORMS LIGHT VERTICAL AND HORIZONTAL
u'\u2524' # 0x0088 -> FORMS LIGHT VERTICAL AND LEFT
u'\u252c' # 0x0089 -> FORMS LIGHT DOWN AND HORIZONTAL
u'\u251c' # 0x008a -> FORMS LIGHT VERTICAL AND RIGHT
u'\u2534' # 0x008b -> FORMS LIGHT UP AND HORIZONTAL
u'\u2510' # 0x008c -> FORMS LIGHT DOWN AND LEFT
u'\u250c' # 0x008d -> FORMS LIGHT DOWN AND RIGHT
u'\u2514' # 0x008e -> FORMS LIGHT UP AND RIGHT
u'\u2518' # 0x008f -> FORMS LIGHT UP AND LEFT
u'\u03b2' # 0x0090 -> GREEK SMALL BETA
u'\u221e' # 0x0091 -> INFINITY
u'\u03c6' # 0x0092 -> GREEK SMALL PHI
u'\xb1' # 0x0093 -> PLUS-OR-MINUS SIGN
u'\xbd' # 0x0094 -> FRACTION 1/2
u'\xbc' # 0x0095 -> FRACTION 1/4
u'\u2248' # 0x0096 -> ALMOST EQUAL TO
u'\xab' # 0x0097 -> LEFT POINTING GUILLEMET
u'\xbb' # 0x0098 -> RIGHT POINTING GUILLEMET
u'\ufef7' # 0x0099 -> ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
u'\ufef8' # 0x009a -> ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
u'\ufffe' # 0x009b -> UNDEFINED
u'\ufffe' # 0x009c -> UNDEFINED
u'\ufefb' # 0x009d -> ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
u'\ufefc' # 0x009e -> ARABIC LIGATURE LAM WITH ALEF FINAL FORM
u'\ufffe' # 0x009f -> UNDEFINED
u'\xa0' # 0x00a0 -> NON-BREAKING SPACE
u'\xad' # 0x00a1 -> SOFT HYPHEN
u'\ufe82' # 0x00a2 -> ARABIC LETTER ALEF WITH MADDA ABOVE FINAL FORM
u'\xa3' # 0x00a3 -> POUND SIGN
u'\xa4' # 0x00a4 -> CURRENCY SIGN
u'\ufe84' # 0x00a5 -> ARABIC LETTER ALEF WITH HAMZA ABOVE FINAL FORM
u'\ufffe' # 0x00a6 -> UNDEFINED
u'\ufffe' # 0x00a7 -> UNDEFINED
u'\ufe8e' # 0x00a8 -> ARABIC LETTER ALEF FINAL FORM
u'\ufe8f' # 0x00a9 -> ARABIC LETTER BEH ISOLATED FORM
u'\ufe95' # 0x00aa -> ARABIC LETTER TEH ISOLATED FORM
u'\ufe99' # 0x00ab -> ARABIC LETTER THEH ISOLATED FORM
u'\u060c' # 0x00ac -> ARABIC COMMA
u'\ufe9d' # 0x00ad -> ARABIC LETTER JEEM ISOLATED FORM
u'\ufea1' # 0x00ae -> ARABIC LETTER HAH ISOLATED FORM
u'\ufea5' # 0x00af -> ARABIC LETTER KHAH ISOLATED FORM
u'\u0660' # 0x00b0 -> ARABIC-INDIC DIGIT ZERO
u'\u0661' # 0x00b1 -> ARABIC-INDIC DIGIT ONE
u'\u0662' # 0x00b2 -> ARABIC-INDIC DIGIT TWO
u'\u0663' # 0x00b3 -> ARABIC-INDIC DIGIT THREE
u'\u0664' # 0x00b4 -> ARABIC-INDIC DIGIT FOUR
u'\u0665' # 0x00b5 -> ARABIC-INDIC DIGIT FIVE
u'\u0666' # 0x00b6 -> ARABIC-INDIC DIGIT SIX
u'\u0667' # 0x00b7 -> ARABIC-INDIC DIGIT SEVEN
u'\u0668' # 0x00b8 -> ARABIC-INDIC DIGIT EIGHT
u'\u0669' # 0x00b9 -> ARABIC-INDIC DIGIT NINE
u'\ufed1' # 0x00ba -> ARABIC LETTER FEH ISOLATED FORM
u'\u061b' # 0x00bb -> ARABIC SEMICOLON
u'\ufeb1' # 0x00bc -> ARABIC LETTER SEEN ISOLATED FORM
u'\ufeb5' # 0x00bd -> ARABIC LETTER SHEEN ISOLATED FORM
u'\ufeb9' # 0x00be -> ARABIC LETTER SAD ISOLATED FORM
u'\u061f' # 0x00bf -> ARABIC QUESTION MARK
u'\xa2' # 0x00c0 -> CENT SIGN
u'\ufe80' # 0x00c1 -> ARABIC LETTER HAMZA ISOLATED FORM
u'\ufe81' # 0x00c2 -> ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM
u'\ufe83' # 0x00c3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE ISOLATED FORM
u'\ufe85' # 0x00c4 -> ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM
u'\ufeca' # 0x00c5 -> ARABIC LETTER AIN FINAL FORM
u'\ufe8b' # 0x00c6 -> ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM
u'\ufe8d' # 0x00c7 -> ARABIC LETTER ALEF ISOLATED FORM
u'\ufe91' # 0x00c8 -> ARABIC LETTER BEH INITIAL FORM
u'\ufe93' # 0x00c9 -> ARABIC LETTER TEH MARBUTA ISOLATED FORM
u'\ufe97' # 0x00ca -> ARABIC LETTER TEH INITIAL FORM
u'\ufe9b' # 0x00cb -> ARABIC LETTER THEH INITIAL FORM
u'\ufe9f' # 0x00cc -> ARABIC LETTER JEEM INITIAL FORM
u'\ufea3' # 0x00cd -> ARABIC LETTER HAH INITIAL FORM
u'\ufea7' # 0x00ce -> ARABIC LETTER KHAH INITIAL FORM
u'\ufea9' # 0x00cf -> ARABIC LETTER DAL ISOLATED FORM
u'\ufeab' # 0x00d0 -> ARABIC LETTER THAL ISOLATED FORM
u'\ufead' # 0x00d1 -> ARABIC LETTER REH ISOLATED FORM
u'\ufeaf' # 0x00d2 -> ARABIC LETTER ZAIN ISOLATED FORM
u'\ufeb3' # 0x00d3 -> ARABIC LETTER SEEN INITIAL FORM
u'\ufeb7' # 0x00d4 -> ARABIC LETTER SHEEN INITIAL FORM
u'\ufebb' # 0x00d5 -> ARABIC LETTER SAD INITIAL FORM
u'\ufebf' # 0x00d6 -> ARABIC LETTER DAD INITIAL FORM
u'\ufec1' # 0x00d7 -> ARABIC LETTER TAH ISOLATED FORM
u'\ufec5' # 0x00d8 -> ARABIC LETTER ZAH ISOLATED FORM
u'\ufecb' # 0x00d9 -> ARABIC LETTER AIN INITIAL FORM
u'\ufecf' # 0x00da -> ARABIC LETTER GHAIN INITIAL FORM
u'\xa6' # 0x00db -> BROKEN VERTICAL BAR
u'\xac' # 0x00dc -> NOT SIGN
u'\xf7' # 0x00dd -> DIVISION SIGN
u'\xd7' # 0x00de -> MULTIPLICATION SIGN
u'\ufec9' # 0x00df -> ARABIC LETTER AIN ISOLATED FORM
u'\u0640' # 0x00e0 -> ARABIC TATWEEL
u'\ufed3' # 0x00e1 -> ARABIC LETTER FEH INITIAL FORM
u'\ufed7' # 0x00e2 -> ARABIC LETTER QAF INITIAL FORM
u'\ufedb' # 0x00e3 -> ARABIC LETTER KAF INITIAL FORM
u'\ufedf' # 0x00e4 -> ARABIC LETTER LAM INITIAL FORM
u'\ufee3' # 0x00e5 -> ARABIC LETTER MEEM INITIAL FORM
u'\ufee7' # 0x00e6 -> ARABIC LETTER NOON INITIAL FORM
u'\ufeeb' # 0x00e7 -> ARABIC LETTER HEH INITIAL FORM
u'\ufeed' # 0x00e8 -> ARABIC LETTER WAW ISOLATED FORM
u'\ufeef' # 0x00e9 -> ARABIC LETTER ALEF MAKSURA ISOLATED FORM
u'\ufef3' # 0x00ea -> ARABIC LETTER YEH INITIAL FORM
u'\ufebd' # 0x00eb -> ARABIC LETTER DAD ISOLATED FORM
u'\ufecc' # 0x00ec -> ARABIC LETTER AIN MEDIAL FORM
u'\ufece' # 0x00ed -> ARABIC LETTER GHAIN FINAL FORM
u'\ufecd' # 0x00ee -> ARABIC LETTER GHAIN ISOLATED FORM
u'\ufee1' # 0x00ef -> ARABIC LETTER MEEM ISOLATED FORM
u'\ufe7d' # 0x00f0 -> ARABIC SHADDA MEDIAL FORM
u'\u0651' # 0x00f1 -> ARABIC SHADDAH
u'\ufee5' # 0x00f2 -> ARABIC LETTER NOON ISOLATED FORM
u'\ufee9' # 0x00f3 -> ARABIC LETTER HEH ISOLATED FORM
u'\ufeec' # 0x00f4 -> ARABIC LETTER HEH MEDIAL FORM
u'\ufef0' # 0x00f5 -> ARABIC LETTER ALEF MAKSURA FINAL FORM
u'\ufef2' # 0x00f6 -> ARABIC LETTER YEH FINAL FORM
u'\ufed0' # 0x00f7 -> ARABIC LETTER GHAIN MEDIAL FORM
u'\ufed5' # 0x00f8 -> ARABIC LETTER QAF ISOLATED FORM
u'\ufef5' # 0x00f9 -> ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
u'\ufef6' # 0x00fa -> ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
u'\ufedd' # 0x00fb -> ARABIC LETTER LAM ISOLATED FORM
u'\ufed9' # 0x00fc -> ARABIC LETTER KAF ISOLATED FORM
u'\ufef1' # 0x00fd -> ARABIC LETTER YEH ISOLATED FORM
u'\u25a0' # 0x00fe -> BLACK SQUARE
u'\ufffe' # 0x00ff -> UNDEFINED
)
### Encoding Map
encoding_map = {
0x0000: 0x0000, # NULL
0x0001: 0x0001, # START OF HEADING
0x0002: 0x0002, # START OF TEXT
0x0003: 0x0003, # END OF TEXT
0x0004: 0x0004, # END OF TRANSMISSION
0x0005: 0x0005, # ENQUIRY
0x0006: 0x0006, # ACKNOWLEDGE
0x0007: 0x0007, # BELL
0x0008: 0x0008, # BACKSPACE
0x0009: 0x0009, # HORIZONTAL TABULATION
0x000a: 0x000a, # LINE FEED
0x000b: 0x000b, # VERTICAL TABULATION
0x000c: 0x000c, # FORM FEED
0x000d: 0x000d, # CARRIAGE RETURN
0x000e: 0x000e, # SHIFT OUT
0x000f: 0x000f, # SHIFT IN
0x0010: 0x0010, # DATA LINK ESCAPE
0x0011: 0x0011, # DEVICE CONTROL ONE
0x0012: 0x0012, # DEVICE CONTROL TWO
0x0013: 0x0013, # DEVICE CONTROL THREE
0x0014: 0x0014, # DEVICE CONTROL FOUR
0x0015: 0x0015, # NEGATIVE ACKNOWLEDGE
0x0016: 0x0016, # SYNCHRONOUS IDLE
0x0017: 0x0017, # END OF TRANSMISSION BLOCK
0x0018: 0x0018, # CANCEL
0x0019: 0x0019, # END OF MEDIUM
0x001a: 0x001a, # SUBSTITUTE
0x001b: 0x001b, # ESCAPE
0x001c: 0x001c, # FILE SEPARATOR
0x001d: 0x001d, # GROUP SEPARATOR
0x001e: 0x001e, # RECORD SEPARATOR
0x001f: 0x001f, # UNIT SEPARATOR
0x0020: 0x0020, # SPACE
0x0021: 0x0021, # EXCLAMATION MARK
0x0022: 0x0022, # QUOTATION MARK
0x0023: 0x0023, # NUMBER SIGN
0x0024: 0x0024, # DOLLAR SIGN
0x0026: 0x0026, # AMPERSAND
0x0027: 0x0027, # APOSTROPHE
0x0028: 0x0028, # LEFT PARENTHESIS
0x0029: 0x0029, # RIGHT PARENTHESIS
0x002a: 0x002a, # ASTERISK
0x002b: 0x002b, # PLUS SIGN
0x002c: 0x002c, # COMMA
0x002d: 0x002d, # HYPHEN-MINUS
0x002e: 0x002e, # FULL STOP
0x002f: 0x002f, # SOLIDUS
0x0030: 0x0030, # DIGIT ZERO
0x0031: 0x0031, # DIGIT ONE
0x0032: 0x0032, # DIGIT TWO
0x0033: 0x0033, # DIGIT THREE
0x0034: 0x0034, # DIGIT FOUR
0x0035: 0x0035, # DIGIT FIVE
0x0036: 0x0036, # DIGIT SIX
0x0037: 0x0037, # DIGIT SEVEN
0x0038: 0x0038, # DIGIT EIGHT
0x0039: 0x0039, # DIGIT NINE
0x003a: 0x003a, # COLON
0x003b: 0x003b, # SEMICOLON
0x003c: 0x003c, # LESS-THAN SIGN
0x003d: 0x003d, # EQUALS SIGN
0x003e: 0x003e, # GREATER-THAN SIGN
0x003f: 0x003f, # QUESTION MARK
0x0040: 0x0040, # COMMERCIAL AT
0x0041: 0x0041, # LATIN CAPITAL LETTER A
0x0042: 0x0042, # LATIN CAPITAL LETTER B
0x0043: 0x0043, # LATIN CAPITAL LETTER C
0x0044: 0x0044, # LATIN CAPITAL LETTER D
0x0045: 0x0045, # LATIN CAPITAL LETTER E
0x0046: 0x0046, # LATIN CAPITAL LETTER F
0x0047: 0x0047, # LATIN CAPITAL LETTER G
0x0048: 0x0048, # LATIN CAPITAL LETTER H
0x0049: 0x0049, # LATIN CAPITAL LETTER I
0x004a: 0x004a, # LATIN CAPITAL LETTER J
0x004b: 0x004b, # LATIN CAPITAL LETTER K
0x004c: 0x004c, # LATIN CAPITAL LETTER L
0x004d: 0x004d, # LATIN CAPITAL LETTER M
0x004e: 0x004e, # LATIN CAPITAL LETTER N
0x004f: 0x004f, # LATIN CAPITAL LETTER O
0x0050: 0x0050, # LATIN CAPITAL LETTER P
0x0051: 0x0051, # LATIN CAPITAL LETTER Q
0x0052: 0x0052, # LATIN CAPITAL LETTER R
0x0053: 0x0053, # LATIN CAPITAL LETTER S
0x0054: 0x0054, # LATIN CAPITAL LETTER T
0x0055: 0x0055, # LATIN CAPITAL LETTER U
0x0056: 0x0056, # LATIN CAPITAL LETTER V
0x0057: 0x0057, # LATIN CAPITAL LETTER W
0x0058: 0x0058, # LATIN CAPITAL LETTER X
0x0059: 0x0059, # LATIN CAPITAL LETTER Y
0x005a: 0x005a, # LATIN CAPITAL LETTER Z
0x005b: 0x005b, # LEFT SQUARE BRACKET
0x005c: 0x005c, # REVERSE SOLIDUS
0x005d: 0x005d, # RIGHT SQUARE BRACKET
0x005e: 0x005e, # CIRCUMFLEX ACCENT
0x005f: 0x005f, # LOW LINE
0x0060: 0x0060, # GRAVE ACCENT
0x0061: 0x0061, # LATIN SMALL LETTER A
0x0062: 0x0062, # LATIN SMALL LETTER B
0x0063: 0x0063, # LATIN SMALL LETTER C
0x0064: 0x0064, # LATIN SMALL LETTER D
0x0065: 0x0065, # LATIN SMALL LETTER E
0x0066: 0x0066, # LATIN SMALL LETTER F
0x0067: 0x0067, # LATIN SMALL LETTER G
0x0068: 0x0068, # LATIN SMALL LETTER H
0x0069: 0x0069, # LATIN SMALL LETTER I
0x006a: 0x006a, # LATIN SMALL LETTER J
0x006b: 0x006b, # LATIN SMALL LETTER K
0x006c: 0x006c, # LATIN SMALL LETTER L
0x006d: 0x006d, # LATIN SMALL LETTER M
0x006e: 0x006e, # LATIN SMALL LETTER N
0x006f: 0x006f, # LATIN SMALL LETTER O
0x0070: 0x0070, # LATIN SMALL LETTER P
0x0071: 0x0071, # LATIN SMALL LETTER Q
0x0072: 0x0072, # LATIN SMALL LETTER R
0x0073: 0x0073, # LATIN SMALL LETTER S
0x0074: 0x0074, # LATIN SMALL LETTER T
0x0075: 0x0075, # LATIN SMALL LETTER U
0x0076: 0x0076, # LATIN SMALL LETTER V
0x0077: 0x0077, # LATIN SMALL LETTER W
0x0078: 0x0078, # LATIN SMALL LETTER X
0x0079: 0x0079, # LATIN SMALL LETTER Y
0x007a: 0x007a, # LATIN SMALL LETTER Z
0x007b: 0x007b, # LEFT CURLY BRACKET
0x007c: 0x007c, # VERTICAL LINE
0x007d: 0x007d, # RIGHT CURLY BRACKET
0x007e: 0x007e, # TILDE
0x007f: 0x007f, # DELETE
0x00a0: 0x00a0, # NON-BREAKING SPACE
0x00a2: 0x00c0, # CENT SIGN
0x00a3: 0x00a3, # POUND SIGN
0x00a4: 0x00a4, # CURRENCY SIGN
0x00a6: 0x00db, # BROKEN VERTICAL BAR
0x00ab: 0x0097, # LEFT POINTING GUILLEMET
0x00ac: 0x00dc, # NOT SIGN
0x00ad: 0x00a1, # SOFT HYPHEN
0x00b0: 0x0080, # DEGREE SIGN
0x00b1: 0x0093, # PLUS-OR-MINUS SIGN
0x00b7: 0x0081, # MIDDLE DOT
0x00bb: 0x0098, # RIGHT POINTING GUILLEMET
0x00bc: 0x0095, # FRACTION 1/4
0x00bd: 0x0094, # FRACTION 1/2
0x00d7: 0x00de, # MULTIPLICATION SIGN
0x00f7: 0x00dd, # DIVISION SIGN
0x03b2: 0x0090, # GREEK SMALL BETA
0x03c6: 0x0092, # GREEK SMALL PHI
0x060c: 0x00ac, # ARABIC COMMA
0x061b: 0x00bb, # ARABIC SEMICOLON
0x061f: 0x00bf, # ARABIC QUESTION MARK
0x0640: 0x00e0, # ARABIC TATWEEL
0x0651: 0x00f1, # ARABIC SHADDAH
0x0660: 0x00b0, # ARABIC-INDIC DIGIT ZERO
0x0661: 0x00b1, # ARABIC-INDIC DIGIT ONE
0x0662: 0x00b2, # ARABIC-INDIC DIGIT TWO
0x0663: 0x00b3, # ARABIC-INDIC DIGIT THREE
0x0664: 0x00b4, # ARABIC-INDIC DIGIT FOUR
0x0665: 0x00b5, # ARABIC-INDIC DIGIT FIVE
0x0666: 0x00b6, # ARABIC-INDIC DIGIT SIX
0x0667: 0x00b7, # ARABIC-INDIC DIGIT SEVEN
0x0668: 0x00b8, # ARABIC-INDIC DIGIT EIGHT
0x0669: 0x00b9, # ARABIC-INDIC DIGIT NINE
0x066a: 0x0025, # ARABIC PERCENT SIGN
0x2219: 0x0082, # BULLET OPERATOR
0x221a: 0x0083, # SQUARE ROOT
0x221e: 0x0091, # INFINITY
0x2248: 0x0096, # ALMOST EQUAL TO
0x2500: 0x0085, # FORMS LIGHT HORIZONTAL
0x2502: 0x0086, # FORMS LIGHT VERTICAL
0x250c: 0x008d, # FORMS LIGHT DOWN AND RIGHT
0x2510: 0x008c, # FORMS LIGHT DOWN AND LEFT
0x2514: 0x008e, # FORMS LIGHT UP AND RIGHT
0x2518: 0x008f, # FORMS LIGHT UP AND LEFT
0x251c: 0x008a, # FORMS LIGHT VERTICAL AND RIGHT
0x2524: 0x0088, # FORMS LIGHT VERTICAL AND LEFT
0x252c: 0x0089, # FORMS LIGHT DOWN AND HORIZONTAL
0x2534: 0x008b, # FORMS LIGHT UP AND HORIZONTAL
0x253c: 0x0087, # FORMS LIGHT VERTICAL AND HORIZONTAL
0x2592: 0x0084, # MEDIUM SHADE
0x25a0: 0x00fe, # BLACK SQUARE
0xfe7d: 0x00f0, # ARABIC SHADDA MEDIAL FORM
0xfe80: 0x00c1, # ARABIC LETTER HAMZA ISOLATED FORM
0xfe81: 0x00c2, # ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM
0xfe82: 0x00a2, # ARABIC LETTER ALEF WITH MADDA ABOVE FINAL FORM
0xfe83: 0x00c3, # ARABIC LETTER ALEF WITH HAMZA ABOVE ISOLATED FORM
0xfe84: 0x00a5, # ARABIC LETTER ALEF WITH HAMZA ABOVE FINAL FORM
0xfe85: 0x00c4, # ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM
0xfe8b: 0x00c6, # ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM
0xfe8d: 0x00c7, # ARABIC LETTER ALEF ISOLATED FORM
0xfe8e: 0x00a8, # ARABIC LETTER ALEF FINAL FORM
0xfe8f: 0x00a9, # ARABIC LETTER BEH ISOLATED FORM
0xfe91: 0x00c8, # ARABIC LETTER BEH INITIAL FORM
0xfe93: 0x00c9, # ARABIC LETTER TEH MARBUTA ISOLATED FORM
0xfe95: 0x00aa, # ARABIC LETTER TEH ISOLATED FORM
0xfe97: 0x00ca, # ARABIC LETTER TEH INITIAL FORM
0xfe99: 0x00ab, # ARABIC LETTER THEH ISOLATED FORM
0xfe9b: 0x00cb, # ARABIC LETTER THEH INITIAL FORM
0xfe9d: 0x00ad, # ARABIC LETTER JEEM ISOLATED FORM
0xfe9f: 0x00cc, # ARABIC LETTER JEEM INITIAL FORM
0xfea1: 0x00ae, # ARABIC LETTER HAH ISOLATED FORM
0xfea3: 0x00cd, # ARABIC LETTER HAH INITIAL FORM
0xfea5: 0x00af, # ARABIC LETTER KHAH ISOLATED FORM
0xfea7: 0x00ce, # ARABIC LETTER KHAH INITIAL FORM
0xfea9: 0x00cf, # ARABIC LETTER DAL ISOLATED FORM
0xfeab: 0x00d0, # ARABIC LETTER THAL ISOLATED FORM
0xfead: 0x00d1, # ARABIC LETTER REH ISOLATED FORM
0xfeaf: 0x00d2, # ARABIC LETTER ZAIN ISOLATED FORM
0xfeb1: 0x00bc, # ARABIC LETTER SEEN ISOLATED FORM
0xfeb3: 0x00d3, # ARABIC LETTER SEEN INITIAL FORM
0xfeb5: 0x00bd, # ARABIC LETTER SHEEN ISOLATED FORM
0xfeb7: 0x00d4, # ARABIC LETTER SHEEN INITIAL FORM
0xfeb9: 0x00be, # ARABIC LETTER SAD ISOLATED FORM
0xfebb: 0x00d5, # ARABIC LETTER SAD INITIAL FORM
0xfebd: 0x00eb, # ARABIC LETTER DAD ISOLATED FORM
0xfebf: 0x00d6, # ARABIC LETTER DAD INITIAL FORM
0xfec1: 0x00d7, # ARABIC LETTER TAH ISOLATED FORM
0xfec5: 0x00d8, # ARABIC LETTER ZAH ISOLATED FORM
0xfec9: 0x00df, # ARABIC LETTER AIN ISOLATED FORM
0xfeca: 0x00c5, # ARABIC LETTER AIN FINAL FORM
0xfecb: 0x00d9, # ARABIC LETTER AIN INITIAL FORM
0xfecc: 0x00ec, # ARABIC LETTER AIN MEDIAL FORM
0xfecd: 0x00ee, # ARABIC LETTER GHAIN ISOLATED FORM
0xfece: 0x00ed, # ARABIC LETTER GHAIN FINAL FORM
0xfecf: 0x00da, # ARABIC LETTER GHAIN INITIAL FORM
0xfed0: 0x00f7, # ARABIC LETTER GHAIN MEDIAL FORM
0xfed1: 0x00ba, # ARABIC LETTER FEH ISOLATED FORM
0xfed3: 0x00e1, # ARABIC LETTER FEH INITIAL FORM
0xfed5: 0x00f8, # ARABIC LETTER QAF ISOLATED FORM
0xfed7: 0x00e2, # ARABIC LETTER QAF INITIAL FORM
0xfed9: 0x00fc, # ARABIC LETTER KAF ISOLATED FORM
0xfedb: 0x00e3, # ARABIC LETTER KAF INITIAL FORM
0xfedd: 0x00fb, # ARABIC LETTER LAM ISOLATED FORM
0xfedf: 0x00e4, # ARABIC LETTER LAM INITIAL FORM
0xfee1: 0x00ef, # ARABIC LETTER MEEM ISOLATED FORM
0xfee3: 0x00e5, # ARABIC LETTER MEEM INITIAL FORM
0xfee5: 0x00f2, # ARABIC LETTER NOON ISOLATED FORM
0xfee7: 0x00e6, # ARABIC LETTER NOON INITIAL FORM
0xfee9: 0x00f3, # ARABIC LETTER HEH ISOLATED FORM
0xfeeb: 0x00e7, # ARABIC LETTER HEH INITIAL FORM
0xfeec: 0x00f4, # ARABIC LETTER HEH MEDIAL FORM
0xfeed: 0x00e8, # ARABIC LETTER WAW ISOLATED FORM
0xfeef: 0x00e9, # ARABIC LETTER ALEF MAKSURA ISOLATED FORM
0xfef0: 0x00f5, # ARABIC LETTER ALEF MAKSURA FINAL FORM
0xfef1: 0x00fd, # ARABIC LETTER YEH ISOLATED FORM
0xfef2: 0x00f6, # ARABIC LETTER YEH FINAL FORM
0xfef3: 0x00ea, # ARABIC LETTER YEH INITIAL FORM
0xfef5: 0x00f9, # ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
0xfef6: 0x00fa, # ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
0xfef7: 0x0099, # ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
0xfef8: 0x009a, # ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
0xfefb: 0x009d, # ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
0xfefc: 0x009e, # ARABIC LIGATURE LAM WITH ALEF FINAL FORM
}
|
unlicense
|
[
624,
2018,
17660,
12340,
13732,
4046,
687,
283,
27839,
4149,
15,
17233,
51,
2161,
15,
4222,
15,
2890,
27141,
14,
17715,
7,
543,
486,
2143,
67,
14,
647,
14,
199,
199,
624,
23662,
199,
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,
372,
6010,
14,
13391,
63,
2143,
8,
1210,
12,
2550,
12,
2991,
63,
1130,
9,
339,
347,
4849,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
372,
6010,
14,
13391,
63,
2708,
8,
1210,
12,
2550,
12,
12796,
63,
1224,
9,
199,
199,
533,
24350,
8,
8933,
14,
17016,
304,
272,
347,
3752,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
13391,
63,
2143,
8,
1210,
12,
277,
14,
2550,
12,
2991,
63,
1130,
2788,
16,
61,
199,
199,
533,
24385,
8,
8933,
14,
16703,
304,
272,
347,
4849,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
13391,
63,
2708,
8,
1210,
12,
277,
14,
2550,
12,
12796,
63,
1224,
2788,
16,
61,
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,
1850,
27141,
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,
199,
5680,
27368,
9672,
199,
199,
12796,
63,
1130,
275,
6010,
14,
1875,
63,
5582,
63,
807,
8,
1842,
8,
3912,
430,
199,
12796,
63,
1130,
14,
873,
2561,
272,
378,
88,
29445,
26,
378,
88,
14045,
65,
12,
258,
327,
221,
9175,
26684,
5056,
272,
378,
88,
23686,
26,
378,
88,
383,
66,
16,
12,
258,
327,
221,
29740,
5056,
272,
378,
88,
383,
2835,
26,
378,
88,
383,
66,
23,
12,
258,
327,
221,
30041,
15854,
272,
378,
88,
383,
2564,
26,
378,
88,
1081,
1167,
12,
258,
327,
221,
699,
32243,
29771,
6467,
272,
378,
88,
383,
2658,
26,
378,
88,
11564,
65,
12,
258,
327,
221,
15300,
16547,
272,
378,
88,
30935,
26,
378,
88,
28318,
12,
258,
327,
221,
22650,
21487,
272,
378,
88,
383,
2426,
26,
378,
88,
21962,
12,
258,
327,
221,
2381,
3053,
9024,
8724,
272,
378,
88,
31743,
26,
378,
88,
27874,
12,
258,
327,
221,
2381,
3053,
9024,
8267,
272,
378,
88,
383,
1555,
26,
378,
88,
3781,
67,
12,
258,
327,
221,
2381,
3053,
9024,
8267,
2401,
8724,
272,
378,
88,
31419,
26,
378,
88,
27752,
12,
258,
327,
221,
2381,
3053,
9024,
8267,
2401,
6578,
272,
378,
88,
383,
1407,
26,
378,
88,
6390,
67,
12,
258,
327,
221,
2381,
3053,
9024,
10163,
2401,
8724,
272,
378,
88,
8662,
65,
26,
378,
88,
12140,
67,
12,
258,
327,
221,
2381,
3053,
9024,
8267,
2401,
7052,
272,
378,
88,
8662,
66,
26,
378,
88,
28047,
12,
258,
327,
221,
2381,
3053,
9024,
7215,
2401,
8724,
272,
378,
88,
8662,
67,
26,
378,
88,
27873,
12,
258,
327,
221,
2381,
3053,
9024,
10163,
2401,
6578,
272,
378,
88,
8662,
68,
26,
378,
88,
7991,
67,
12,
258,
327,
221,
2381,
3053,
9024,
10163,
2401,
7052,
272,
378,
88,
8662,
69,
26,
378,
88,
27223,
12,
258,
327,
221,
2381,
3053,
9024,
7215,
2401,
7052,
272,
378,
88,
8662,
70,
26,
378,
88,
27977,
12,
258,
327,
221,
2381,
3053,
9024,
7215,
2401,
6578,
272,
378,
88,
28875,
26,
378,
88,
1644,
66,
18,
12,
258,
327,
221,
7571,
2516,
699,
15808,
272,
378,
88,
383,
3328,
26,
378,
88,
11564,
69,
12,
258,
327,
221,
1621,
17383,
1922,
272,
378,
88,
383,
2942,
26,
378,
88,
1644,
67,
22,
12,
258,
327,
221,
7571,
2516,
510,
11183,
272,
378,
88,
383,
3129,
26,
378,
88,
383,
66,
17,
12,
258,
327,
221,
18807,
13,
726,
13,
18004,
5056,
272,
378,
88,
383,
2635,
26,
378,
88,
383,
3691,
12,
258,
327,
221,
21616,
413,
15,
18,
272,
378,
88,
383,
2720,
26,
378,
88,
383,
3776,
12,
258,
327,
221,
21616,
413,
15,
20,
272,
378,
88,
383,
2534,
26,
378,
88,
29899,
12,
258,
327,
221,
12112,
2679,
840,
17152,
2296,
272,
378,
88,
383,
2576,
26,
378,
88,
383,
371,
12,
258,
327,
221,
6578,
3625,
2919,
1206,
598,
53,
1193,
906,
3940,
272,
378,
88,
383,
2905,
26,
378,
88,
383,
2501,
12,
258,
327,
221,
7052,
3625,
2919,
1206,
598,
53,
1193,
906,
3940,
272,
378,
88,
29660,
26,
378,
8371,
70,
23,
12,
258,
327,
221,
9175,
27427,
29935,
1663,
32282,
1663,
869,
1156,
21959,
16054,
22139,
11295,
272,
378,
88,
8581,
65,
26,
378,
8371,
70,
24,
12,
258,
327,
221,
9175,
27427,
29935,
1663,
32282,
1663,
869,
1156,
21959,
16054,
24745,
11295,
272,
378,
88,
8581,
66,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
8581,
67,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
8581,
68,
26,
378,
8371,
4675,
12,
258,
327,
221,
9175,
27427,
29935,
1663,
32282,
22139,
11295,
272,
378,
88,
8581,
69,
26,
378,
8371,
3003,
12,
258,
327,
221,
9175,
27427,
29935,
1663,
32282,
24745,
11295,
272,
378,
88,
8581,
70,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
383,
65,
17,
26,
378,
88,
383,
350,
12,
258,
327,
221,
29064,
22553,
272,
378,
88,
383,
65,
18,
26,
378,
8371,
2564,
12,
258,
327,
221,
9175,
1578,
32282,
1663,
603,
1554,
8980,
16054,
24745,
11295,
272,
378,
88,
383,
65,
21,
26,
378,
8371,
1349,
12,
258,
327,
221,
9175,
1578,
32282,
1663,
869,
1156,
21959,
16054,
24745,
11295,
272,
378,
88,
383,
65,
22,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
383,
65,
23,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
383,
65,
24,
26,
378,
8371,
24,
69,
12,
258,
327,
221,
9175,
1578,
32282,
24745,
11295,
272,
378,
88
] |
[
2018,
17660,
12340,
13732,
4046,
687,
283,
27839,
4149,
15,
17233,
51,
2161,
15,
4222,
15,
2890,
27141,
14,
17715,
7,
543,
486,
2143,
67,
14,
647,
14,
199,
199,
624,
23662,
199,
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,
372,
6010,
14,
13391,
63,
2143,
8,
1210,
12,
2550,
12,
2991,
63,
1130,
9,
339,
347,
4849,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
372,
6010,
14,
13391,
63,
2708,
8,
1210,
12,
2550,
12,
12796,
63,
1224,
9,
199,
199,
533,
24350,
8,
8933,
14,
17016,
304,
272,
347,
3752,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
13391,
63,
2143,
8,
1210,
12,
277,
14,
2550,
12,
2991,
63,
1130,
2788,
16,
61,
199,
199,
533,
24385,
8,
8933,
14,
16703,
304,
272,
347,
4849,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
13391,
63,
2708,
8,
1210,
12,
277,
14,
2550,
12,
12796,
63,
1224,
2788,
16,
61,
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,
1850,
27141,
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,
199,
5680,
27368,
9672,
199,
199,
12796,
63,
1130,
275,
6010,
14,
1875,
63,
5582,
63,
807,
8,
1842,
8,
3912,
430,
199,
12796,
63,
1130,
14,
873,
2561,
272,
378,
88,
29445,
26,
378,
88,
14045,
65,
12,
258,
327,
221,
9175,
26684,
5056,
272,
378,
88,
23686,
26,
378,
88,
383,
66,
16,
12,
258,
327,
221,
29740,
5056,
272,
378,
88,
383,
2835,
26,
378,
88,
383,
66,
23,
12,
258,
327,
221,
30041,
15854,
272,
378,
88,
383,
2564,
26,
378,
88,
1081,
1167,
12,
258,
327,
221,
699,
32243,
29771,
6467,
272,
378,
88,
383,
2658,
26,
378,
88,
11564,
65,
12,
258,
327,
221,
15300,
16547,
272,
378,
88,
30935,
26,
378,
88,
28318,
12,
258,
327,
221,
22650,
21487,
272,
378,
88,
383,
2426,
26,
378,
88,
21962,
12,
258,
327,
221,
2381,
3053,
9024,
8724,
272,
378,
88,
31743,
26,
378,
88,
27874,
12,
258,
327,
221,
2381,
3053,
9024,
8267,
272,
378,
88,
383,
1555,
26,
378,
88,
3781,
67,
12,
258,
327,
221,
2381,
3053,
9024,
8267,
2401,
8724,
272,
378,
88,
31419,
26,
378,
88,
27752,
12,
258,
327,
221,
2381,
3053,
9024,
8267,
2401,
6578,
272,
378,
88,
383,
1407,
26,
378,
88,
6390,
67,
12,
258,
327,
221,
2381,
3053,
9024,
10163,
2401,
8724,
272,
378,
88,
8662,
65,
26,
378,
88,
12140,
67,
12,
258,
327,
221,
2381,
3053,
9024,
8267,
2401,
7052,
272,
378,
88,
8662,
66,
26,
378,
88,
28047,
12,
258,
327,
221,
2381,
3053,
9024,
7215,
2401,
8724,
272,
378,
88,
8662,
67,
26,
378,
88,
27873,
12,
258,
327,
221,
2381,
3053,
9024,
10163,
2401,
6578,
272,
378,
88,
8662,
68,
26,
378,
88,
7991,
67,
12,
258,
327,
221,
2381,
3053,
9024,
10163,
2401,
7052,
272,
378,
88,
8662,
69,
26,
378,
88,
27223,
12,
258,
327,
221,
2381,
3053,
9024,
7215,
2401,
7052,
272,
378,
88,
8662,
70,
26,
378,
88,
27977,
12,
258,
327,
221,
2381,
3053,
9024,
7215,
2401,
6578,
272,
378,
88,
28875,
26,
378,
88,
1644,
66,
18,
12,
258,
327,
221,
7571,
2516,
699,
15808,
272,
378,
88,
383,
3328,
26,
378,
88,
11564,
69,
12,
258,
327,
221,
1621,
17383,
1922,
272,
378,
88,
383,
2942,
26,
378,
88,
1644,
67,
22,
12,
258,
327,
221,
7571,
2516,
510,
11183,
272,
378,
88,
383,
3129,
26,
378,
88,
383,
66,
17,
12,
258,
327,
221,
18807,
13,
726,
13,
18004,
5056,
272,
378,
88,
383,
2635,
26,
378,
88,
383,
3691,
12,
258,
327,
221,
21616,
413,
15,
18,
272,
378,
88,
383,
2720,
26,
378,
88,
383,
3776,
12,
258,
327,
221,
21616,
413,
15,
20,
272,
378,
88,
383,
2534,
26,
378,
88,
29899,
12,
258,
327,
221,
12112,
2679,
840,
17152,
2296,
272,
378,
88,
383,
2576,
26,
378,
88,
383,
371,
12,
258,
327,
221,
6578,
3625,
2919,
1206,
598,
53,
1193,
906,
3940,
272,
378,
88,
383,
2905,
26,
378,
88,
383,
2501,
12,
258,
327,
221,
7052,
3625,
2919,
1206,
598,
53,
1193,
906,
3940,
272,
378,
88,
29660,
26,
378,
8371,
70,
23,
12,
258,
327,
221,
9175,
27427,
29935,
1663,
32282,
1663,
869,
1156,
21959,
16054,
22139,
11295,
272,
378,
88,
8581,
65,
26,
378,
8371,
70,
24,
12,
258,
327,
221,
9175,
27427,
29935,
1663,
32282,
1663,
869,
1156,
21959,
16054,
24745,
11295,
272,
378,
88,
8581,
66,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
8581,
67,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
8581,
68,
26,
378,
8371,
4675,
12,
258,
327,
221,
9175,
27427,
29935,
1663,
32282,
22139,
11295,
272,
378,
88,
8581,
69,
26,
378,
8371,
3003,
12,
258,
327,
221,
9175,
27427,
29935,
1663,
32282,
24745,
11295,
272,
378,
88,
8581,
70,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
383,
65,
17,
26,
378,
88,
383,
350,
12,
258,
327,
221,
29064,
22553,
272,
378,
88,
383,
65,
18,
26,
378,
8371,
2564,
12,
258,
327,
221,
9175,
1578,
32282,
1663,
603,
1554,
8980,
16054,
24745,
11295,
272,
378,
88,
383,
65,
21,
26,
378,
8371,
1349,
12,
258,
327,
221,
9175,
1578,
32282,
1663,
869,
1156,
21959,
16054,
24745,
11295,
272,
378,
88,
383,
65,
22,
26,
488,
12,
755,
327,
221,
14518,
272,
378,
88,
383,
65,
23,
26,
488,
12,
755,
327,
221,
14518,
272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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
] |
elmerdpadilla/iv
|
addons/account/wizard/account_report_account_balance.py
|
378
|
1741
|
# -*- 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/>.
#
##############################################################################
from openerp.osv import fields, osv
class account_balance_report(osv.osv_memory):
_inherit = "account.common.account.report"
_name = 'account.balance.report'
_description = 'Trial Balance Report'
_columns = {
'journal_ids': fields.many2many('account.journal', 'account_balance_report_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
}
_defaults = {
'journal_ids': [],
}
def _print_report(self, cr, uid, ids, data, context=None):
data = self.pre_print_report(cr, uid, ids, data, context=context)
return self.pool['report'].get_action(cr, uid, [], 'account.report_trialbalance', data=data, context=context)
# 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,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
421,
199,
533,
2933,
63,
7358,
63,
3070,
8,
4795,
14,
4795,
63,
4844,
304,
272,
485,
6486,
275,
298,
2048,
14,
2330,
14,
2048,
14,
3070,
2,
272,
485,
354,
275,
283,
2048,
14,
7358,
14,
3070,
7,
272,
485,
1802,
275,
283,
52,
1383,
23928,
554,
11774,
7,
339,
485,
3406,
275,
469,
267,
283,
7067,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
2048,
14,
7067,
297,
283,
2048,
63,
7358,
63,
3070,
63,
7067,
63,
3369,
297,
283,
2048,
63,
344,
297,
283,
7067,
63,
344,
297,
283,
5691,
31212,
297,
1415,
29,
549,
395,
272,
789,
339,
485,
4322,
275,
469,
267,
283,
7067,
63,
1580,
356,
990,
272,
789,
339,
347,
485,
1361,
63,
3070,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
666,
12,
1067,
29,
403,
304,
267,
666,
275,
291,
14,
657,
63,
1361,
63,
3070,
8,
1556,
12,
1747,
12,
2762,
12,
666,
12,
1067,
29,
1100,
9,
267,
372,
291,
14,
2293,
459,
3070,
2278,
362,
63,
1287,
8,
1556,
12,
1747,
12,
990,
283,
2048,
14,
3070,
63,
14443,
7358,
297,
666,
29,
576,
12,
1067,
29,
1100,
9,
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
] |
[
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,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
421,
199,
533,
2933,
63,
7358,
63,
3070,
8,
4795,
14,
4795,
63,
4844,
304,
272,
485,
6486,
275,
298,
2048,
14,
2330,
14,
2048,
14,
3070,
2,
272,
485,
354,
275,
283,
2048,
14,
7358,
14,
3070,
7,
272,
485,
1802,
275,
283,
52,
1383,
23928,
554,
11774,
7,
339,
485,
3406,
275,
469,
267,
283,
7067,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
2048,
14,
7067,
297,
283,
2048,
63,
7358,
63,
3070,
63,
7067,
63,
3369,
297,
283,
2048,
63,
344,
297,
283,
7067,
63,
344,
297,
283,
5691,
31212,
297,
1415,
29,
549,
395,
272,
789,
339,
485,
4322,
275,
469,
267,
283,
7067,
63,
1580,
356,
990,
272,
789,
339,
347,
485,
1361,
63,
3070,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
666,
12,
1067,
29,
403,
304,
267,
666,
275,
291,
14,
657,
63,
1361,
63,
3070,
8,
1556,
12,
1747,
12,
2762,
12,
666,
12,
1067,
29,
1100,
9,
267,
372,
291,
14,
2293,
459,
3070,
2278,
362,
63,
1287,
8,
1556,
12,
1747,
12,
990,
283,
2048,
14,
3070,
63,
14443,
7358,
297,
666,
29,
576,
12,
1067,
29,
1100,
9,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
cuongnv23/ansible
|
lib/ansible/modules/cloud/ovirt/ovirt_datacenter.py
|
18
|
7530
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: ovirt_datacenter
short_description: Module to manage data centers in oVirt/RHV
version_added: "2.3"
author: "Ondra Machacek (@machacekondra)"
description:
- "Module to manage data centers in oVirt/RHV"
options:
name:
description:
- "Name of the data center to manage."
required: true
state:
description:
- "Should the data center be present or absent"
choices: ['present', 'absent']
default: present
description:
description:
- "Description of the data center."
comment:
description:
- "Comment of the data center."
local:
description:
- "I(True) if the data center should be local, I(False) if should be shared."
- "Default value is set by engine."
compatibility_version:
description:
- "Compatibility version of the data center."
quota_mode:
description:
- "Quota mode of the data center. One of I(disabled), I(audit) or I(enabled)"
choices: ['disabled', 'audit', 'enabled']
mac_pool:
description:
- "MAC pool to be used by this datacenter."
- "IMPORTANT: This option is deprecated in oVirt/RHV 4.1. You should
use C(mac_pool) in C(ovirt_clusters) module, as MAC pools are
set per cluster since 4.1."
extends_documentation_fragment: ovirt
'''
EXAMPLES = '''
# Examples don't contain auth parameter for simplicity,
# look at ovirt_auth module to see how to reuse authentication:
# Create datacenter
- ovirt_datacenter:
name: mydatacenter
local: True
compatibility_version: 4.0
quota_mode: enabled
# Remove datacenter
- ovirt_datacenter:
state: absent
name: mydatacenter
'''
RETURN = '''
id:
description: "ID of the managed datacenter"
returned: "On success if datacenter is found."
type: str
sample: 7de90f31-222c-436c-a1ca-7e655bd5b60c
data_center:
description: "Dictionary of all the datacenter attributes. Datacenter attributes can be found on your oVirt/RHV instance
at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/datacenter."
returned: "On success if datacenter is found."
type: dict
'''
import traceback
try:
import ovirtsdk4.types as otypes
except ImportError:
pass
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ovirt import (
BaseModule,
check_sdk,
check_params,
create_connection,
equal,
ovirt_full_argument_spec,
search_by_name,
)
class DatacentersModule(BaseModule):
def __get_major(self, full_version):
if full_version is None:
return None
if isinstance(full_version, otypes.Version):
return full_version.major
return int(full_version.split('.')[0])
def __get_minor(self, full_version):
if full_version is None:
return None
if isinstance(full_version, otypes.Version):
return full_version.minor
return int(full_version.split('.')[1])
def _get_mac_pool(self):
mac_pool = None
if self._module.params.get('mac_pool'):
mac_pool = search_by_name(
self._connection.system_service().mac_pools_service(),
self._module.params.get('mac_pool'),
)
return mac_pool
def build_entity(self):
return otypes.DataCenter(
name=self._module.params['name'],
comment=self._module.params['comment'],
description=self._module.params['description'],
mac_pool=otypes.MacPool(
id=getattr(self._get_mac_pool(), 'id', None),
) if self._module.params.get('mac_pool') else None,
quota_mode=otypes.QuotaModeType(
self._module.params['quota_mode']
) if self._module.params['quota_mode'] else None,
local=self._module.params['local'],
version=otypes.Version(
major=self.__get_major(self._module.params['compatibility_version']),
minor=self.__get_minor(self._module.params['compatibility_version']),
) if self._module.params['compatibility_version'] else None,
)
def update_check(self, entity):
minor = self.__get_minor(self._module.params.get('compatibility_version'))
major = self.__get_major(self._module.params.get('compatibility_version'))
return (
equal(getattr(self._get_mac_pool(), 'id', None), getattr(entity.mac_pool, 'id', None)) and
equal(self._module.params.get('comment'), entity.comment) and
equal(self._module.params.get('description'), entity.description) and
equal(self._module.params.get('quota_mode'), str(entity.quota_mode)) and
equal(self._module.params.get('local'), entity.local) and
equal(minor, self.__get_minor(entity.version)) and
equal(major, self.__get_major(entity.version))
)
def main():
argument_spec = ovirt_full_argument_spec(
state=dict(
choices=['present', 'absent'],
default='present',
),
name=dict(default=None, required=True),
description=dict(default=None),
local=dict(type='bool'),
compatibility_version=dict(default=None),
quota_mode=dict(choices=['disabled', 'audit', 'enabled']),
comment=dict(default=None),
mac_pool=dict(default=None),
)
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
)
if module._name == 'ovirt_datacenters':
module.deprecate("The 'ovirt_datacenters' module is being renamed 'ovirt_datacenter'", version=2.8)
check_sdk(module)
check_params(module)
try:
auth = module.params.pop('auth')
connection = create_connection(auth)
data_centers_service = connection.system_service().data_centers_service()
clusters_module = DatacentersModule(
connection=connection,
module=module,
service=data_centers_service,
)
state = module.params['state']
if state == 'present':
ret = clusters_module.create()
elif state == 'absent':
ret = clusters_module.remove()
module.exit_json(**ret)
except Exception as e:
module.fail_json(msg=str(e), exception=traceback.format_exc())
finally:
connection.close(logout=auth.get('token') is None)
if __name__ == "__main__":
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
7800,
9572,
13002,
12,
3277,
14,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
21353,
63,
17770,
199,
3612,
63,
1802,
26,
5673,
370,
9635,
666,
19190,
315,
312,
17146,
15,
50,
16566,
199,
1023,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
2502,
26,
298,
47,
977,
345,
30611,
7984,
75,
8593,
14121,
7984,
75,
7835,
345,
2924,
199,
1802,
26,
272,
446,
298,
2377,
370,
9635,
666,
19190,
315,
312,
17146,
15,
50,
16566,
2,
199,
1419,
26,
272,
536,
26,
267,
1369,
26,
288,
446,
298,
985,
402,
314,
666,
8126,
370,
9635,
2122,
267,
1415,
26,
2549,
272,
1174,
26,
267,
1369,
26,
288,
446,
298,
11408,
314,
666,
8126,
506,
3451,
503,
9552,
2,
267,
3415,
26,
788,
1881,
297,
283,
5575,
418,
267,
849,
26,
3451,
272,
1369,
26,
267,
1369,
26,
288,
446,
298,
5831,
402,
314,
666,
8126,
2122,
272,
3721,
26,
267,
1369,
26,
288,
446,
298,
7488,
402,
314,
666,
8126,
2122,
272,
2257,
26,
267,
1369,
26,
288,
446,
298,
41,
8,
549,
9,
340,
314,
666,
8126,
1077,
506,
2257,
12,
473,
8,
797,
9,
340,
1077,
506,
5709,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
272,
7163,
63,
1023,
26,
267,
1369,
26,
288,
446,
298,
2404,
5880,
1015,
402,
314,
666,
8126,
2122,
272,
12132,
63,
632,
26,
267,
1369,
26,
288,
446,
298,
17610,
818,
402,
314,
666,
8126,
14,
7309,
402,
473,
8,
7011,
395,
473,
8,
14274,
9,
503,
473,
8,
3827,
2924,
267,
3415,
26,
788,
7011,
297,
283,
14274,
297,
283,
3827,
418,
272,
4497,
63,
2293,
26,
267,
1369,
26,
288,
446,
298,
9410,
4203,
370,
506,
1202,
701,
642,
16606,
2122,
288,
446,
298,
17576,
1441,
26,
961,
945,
365,
5906,
315,
312,
17146,
15,
50,
16566,
841,
14,
17,
14,
2047,
1077,
2049,
675,
445,
8,
3088,
63,
2293,
9,
315,
445,
8,
23334,
63,
9170,
9,
859,
12,
465,
13347,
20092,
787,
2049,
663,
1126,
4350,
3967,
841,
14,
17,
2122,
199,
11036,
63,
9970,
63,
7677,
26,
21353,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
6058,
2793,
1133,
1395,
1790,
2725,
367,
17553,
3690,
12,
199,
3,
3648,
737,
21353,
63,
1178,
859,
370,
1937,
4212,
370,
12598,
6299,
26,
199,
199,
3,
2790,
16606,
199,
13,
21353,
63,
17770,
26,
272,
536,
26,
3002,
17770,
272,
2257,
26,
715,
272,
7163,
63,
1023,
26,
841,
14,
16,
272,
12132,
63,
632,
26,
5223,
199,
199,
3,
5852,
16606,
199,
13,
21353,
63,
17770,
26,
272,
1174,
26,
9552,
272,
536,
26,
3002,
17770,
199,
2344,
199,
199,
9677,
275,
1449,
199,
344,
26,
272,
1369,
26,
298,
998,
402,
314,
12883,
16606,
2,
272,
2138,
26,
298,
3314,
3182,
340,
16606,
365,
1911,
2122,
272,
730,
26,
620,
272,
2690,
26,
1520,
271,
2710,
70,
2192,
13,
9485,
67,
13,
26319,
67,
13,
65,
17,
696,
13,
23,
69,
10027,
3691,
21,
66,
2259,
67,
199,
576,
63,
4218,
26,
272,
1369,
26,
298,
11728,
402,
1006,
314,
16606,
3004,
14,
3918,
4218,
3004,
883,
506,
1911,
641,
2195,
312,
17146,
15,
50,
16566,
1256,
2116,
737,
2569,
1166,
26,
1455,
921,
23334,
14,
5031,
14,
2308,
15,
23334,
13,
3908,
13,
1246,
13,
1238,
15,
4133,
12645,
1313,
15,
17770,
2122,
272,
2138,
26,
298,
3314,
3182,
340,
16606,
365,
1911,
2122,
272,
730,
26,
1211,
199,
2344,
199,
199,
646,
5190,
199,
199,
893,
26,
272,
492,
312,
1042,
1086,
6341,
20,
14,
1313,
465,
312,
1313,
199,
2590,
3545,
26,
272,
986,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
23334,
492,
334,
272,
3523,
2377,
12,
272,
1104,
63,
9277,
12,
272,
1104,
63,
1162,
12,
272,
1218,
63,
2105,
12,
272,
4472,
12,
272,
21353,
63,
2861,
63,
2094,
63,
1650,
12,
272,
2754,
63,
991,
63,
354,
12,
199,
9,
421,
199,
533,
3918,
15660,
2377,
8,
1563,
2377,
304,
339,
347,
636,
362,
63,
8452,
8,
277,
12,
2615,
63,
1023,
304,
267,
340,
2615,
63,
1023,
365,
488,
26,
288,
372,
488,
267,
340,
1228,
8,
2861,
63,
1023,
12,
312,
1313,
14,
3353,
304,
288,
372,
2615,
63,
1023,
14,
8452,
267,
372,
1109,
8,
2861,
63,
1023,
14,
1294,
19237,
16,
566,
339,
347,
636,
362,
63,
11067,
8,
277,
12,
2615,
63,
1023,
304,
267,
340,
2615,
63,
1023,
365,
488,
26,
288,
372,
488,
267,
340,
1228,
8,
2861,
63,
1023,
12,
312,
1313,
14,
3353,
304,
288,
372,
2615,
63,
1023,
14,
11067,
267,
372,
1109,
8,
2861,
63,
1023,
14,
1294,
19237,
17,
566,
339,
347,
485,
362,
63,
3088,
63,
2293,
8,
277,
304,
267,
4497,
63,
2293,
275,
488,
267,
340,
291,
423,
578,
14,
1162,
14
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
7800,
9572,
13002,
12,
3277,
14,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
21353,
63,
17770,
199,
3612,
63,
1802,
26,
5673,
370,
9635,
666,
19190,
315,
312,
17146,
15,
50,
16566,
199,
1023,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
2502,
26,
298,
47,
977,
345,
30611,
7984,
75,
8593,
14121,
7984,
75,
7835,
345,
2924,
199,
1802,
26,
272,
446,
298,
2377,
370,
9635,
666,
19190,
315,
312,
17146,
15,
50,
16566,
2,
199,
1419,
26,
272,
536,
26,
267,
1369,
26,
288,
446,
298,
985,
402,
314,
666,
8126,
370,
9635,
2122,
267,
1415,
26,
2549,
272,
1174,
26,
267,
1369,
26,
288,
446,
298,
11408,
314,
666,
8126,
506,
3451,
503,
9552,
2,
267,
3415,
26,
788,
1881,
297,
283,
5575,
418,
267,
849,
26,
3451,
272,
1369,
26,
267,
1369,
26,
288,
446,
298,
5831,
402,
314,
666,
8126,
2122,
272,
3721,
26,
267,
1369,
26,
288,
446,
298,
7488,
402,
314,
666,
8126,
2122,
272,
2257,
26,
267,
1369,
26,
288,
446,
298,
41,
8,
549,
9,
340,
314,
666,
8126,
1077,
506,
2257,
12,
473,
8,
797,
9,
340,
1077,
506,
5709,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
272,
7163,
63,
1023,
26,
267,
1369,
26,
288,
446,
298,
2404,
5880,
1015,
402,
314,
666,
8126,
2122,
272,
12132,
63,
632,
26,
267,
1369,
26,
288,
446,
298,
17610,
818,
402,
314,
666,
8126,
14,
7309,
402,
473,
8,
7011,
395,
473,
8,
14274,
9,
503,
473,
8,
3827,
2924,
267,
3415,
26,
788,
7011,
297,
283,
14274,
297,
283,
3827,
418,
272,
4497,
63,
2293,
26,
267,
1369,
26,
288,
446,
298,
9410,
4203,
370,
506,
1202,
701,
642,
16606,
2122,
288,
446,
298,
17576,
1441,
26,
961,
945,
365,
5906,
315,
312,
17146,
15,
50,
16566,
841,
14,
17,
14,
2047,
1077,
2049,
675,
445,
8,
3088,
63,
2293,
9,
315,
445,
8,
23334,
63,
9170,
9,
859,
12,
465,
13347,
20092,
787,
2049,
663,
1126,
4350,
3967,
841,
14,
17,
2122,
199,
11036,
63,
9970,
63,
7677,
26,
21353,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
6058,
2793,
1133,
1395,
1790,
2725,
367,
17553,
3690,
12,
199,
3,
3648,
737,
21353,
63,
1178,
859,
370,
1937,
4212,
370,
12598,
6299,
26,
199,
199,
3,
2790,
16606,
199,
13,
21353,
63,
17770,
26,
272,
536,
26,
3002,
17770,
272,
2257,
26,
715,
272,
7163,
63,
1023,
26,
841,
14,
16,
272,
12132,
63,
632,
26,
5223,
199,
199,
3,
5852,
16606,
199,
13,
21353,
63,
17770,
26,
272,
1174,
26,
9552,
272,
536,
26,
3002,
17770,
199,
2344,
199,
199,
9677,
275,
1449,
199,
344,
26,
272,
1369,
26,
298,
998,
402,
314,
12883,
16606,
2,
272,
2138,
26,
298,
3314,
3182,
340,
16606,
365,
1911,
2122,
272,
730,
26,
620,
272,
2690,
26,
1520,
271,
2710,
70,
2192,
13,
9485,
67,
13,
26319,
67,
13,
65,
17,
696,
13,
23,
69,
10027,
3691,
21,
66,
2259,
67,
199,
576,
63,
4218,
26,
272,
1369,
26,
298,
11728,
402,
1006,
314,
16606,
3004,
14,
3918,
4218,
3004,
883,
506,
1911,
641,
2195,
312,
17146,
15,
50,
16566,
1256,
2116,
737,
2569,
1166,
26,
1455,
921,
23334,
14,
5031,
14,
2308,
15,
23334,
13,
3908,
13,
1246,
13,
1238,
15,
4133,
12645,
1313,
15,
17770,
2122,
272,
2138,
26,
298,
3314,
3182,
340,
16606,
365,
1911,
2122,
272,
730,
26,
1211,
199,
2344,
199,
199,
646,
5190,
199,
199,
893,
26,
272,
492,
312,
1042,
1086,
6341,
20,
14,
1313,
465,
312,
1313,
199,
2590,
3545,
26,
272,
986,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
23334,
492,
334,
272,
3523,
2377,
12,
272,
1104,
63,
9277,
12,
272,
1104,
63,
1162,
12,
272,
1218,
63,
2105,
12,
272,
4472,
12,
272,
21353,
63,
2861,
63,
2094,
63,
1650,
12,
272,
2754,
63,
991,
63,
354,
12,
199,
9,
421,
199,
533,
3918,
15660,
2377,
8,
1563,
2377,
304,
339,
347,
636,
362,
63,
8452,
8,
277,
12,
2615,
63,
1023,
304,
267,
340,
2615,
63,
1023,
365,
488,
26,
288,
372,
488,
267,
340,
1228,
8,
2861,
63,
1023,
12,
312,
1313,
14,
3353,
304,
288,
372,
2615,
63,
1023,
14,
8452,
267,
372,
1109,
8,
2861,
63,
1023,
14,
1294,
19237,
16,
566,
339,
347,
636,
362,
63,
11067,
8,
277,
12,
2615,
63,
1023,
304,
267,
340,
2615,
63,
1023,
365,
488,
26,
288,
372,
488,
267,
340,
1228,
8,
2861,
63,
1023,
12,
312,
1313,
14,
3353,
304,
288,
372,
2615,
63,
1023,
14,
11067,
267,
372,
1109,
8,
2861,
63,
1023,
14,
1294,
19237,
17,
566,
339,
347,
485,
362,
63,
3088,
63,
2293,
8,
277,
304,
267,
4497,
63,
2293,
275,
488,
267,
340,
291,
423,
578,
14,
1162,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
djgagne/scikit-learn
|
sklearn/linear_model/tests/test_randomized_l1.py
|
214
|
4690
|
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# License: BSD 3 clause
import numpy as np
from scipy import sparse
from sklearn.utils.testing import assert_equal
from sklearn.utils.testing import assert_array_equal
from sklearn.utils.testing import assert_raises
from sklearn.linear_model.randomized_l1 import (lasso_stability_path,
RandomizedLasso,
RandomizedLogisticRegression)
from sklearn.datasets import load_diabetes, load_iris
from sklearn.feature_selection import f_regression, f_classif
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model.base import center_data
diabetes = load_diabetes()
X = diabetes.data
y = diabetes.target
X = StandardScaler().fit_transform(X)
X = X[:, [2, 3, 6, 7, 8]]
# test that the feature score of the best features
F, _ = f_regression(X, y)
def test_lasso_stability_path():
# Check lasso stability path
# Load diabetes data and add noisy features
scaling = 0.3
coef_grid, scores_path = lasso_stability_path(X, y, scaling=scaling,
random_state=42,
n_resampling=30)
assert_array_equal(np.argsort(F)[-3:],
np.argsort(np.sum(scores_path, axis=1))[-3:])
def test_randomized_lasso():
# Check randomized lasso
scaling = 0.3
selection_threshold = 0.5
# or with 1 alpha
clf = RandomizedLasso(verbose=False, alpha=1, random_state=42,
scaling=scaling,
selection_threshold=selection_threshold)
feature_scores = clf.fit(X, y).scores_
assert_array_equal(np.argsort(F)[-3:], np.argsort(feature_scores)[-3:])
# or with many alphas
clf = RandomizedLasso(verbose=False, alpha=[1, 0.8], random_state=42,
scaling=scaling,
selection_threshold=selection_threshold)
feature_scores = clf.fit(X, y).scores_
assert_equal(clf.all_scores_.shape, (X.shape[1], 2))
assert_array_equal(np.argsort(F)[-3:], np.argsort(feature_scores)[-3:])
X_r = clf.transform(X)
X_full = clf.inverse_transform(X_r)
assert_equal(X_r.shape[1], np.sum(feature_scores > selection_threshold))
assert_equal(X_full.shape, X.shape)
clf = RandomizedLasso(verbose=False, alpha='aic', random_state=42,
scaling=scaling)
feature_scores = clf.fit(X, y).scores_
assert_array_equal(feature_scores, X.shape[1] * [1.])
clf = RandomizedLasso(verbose=False, scaling=-0.1)
assert_raises(ValueError, clf.fit, X, y)
clf = RandomizedLasso(verbose=False, scaling=1.1)
assert_raises(ValueError, clf.fit, X, y)
def test_randomized_logistic():
# Check randomized sparse logistic regression
iris = load_iris()
X = iris.data[:, [0, 2]]
y = iris.target
X = X[y != 2]
y = y[y != 2]
F, _ = f_classif(X, y)
scaling = 0.3
clf = RandomizedLogisticRegression(verbose=False, C=1., random_state=42,
scaling=scaling, n_resampling=50,
tol=1e-3)
X_orig = X.copy()
feature_scores = clf.fit(X, y).scores_
assert_array_equal(X, X_orig) # fit does not modify X
assert_array_equal(np.argsort(F), np.argsort(feature_scores))
clf = RandomizedLogisticRegression(verbose=False, C=[1., 0.5],
random_state=42, scaling=scaling,
n_resampling=50, tol=1e-3)
feature_scores = clf.fit(X, y).scores_
assert_array_equal(np.argsort(F), np.argsort(feature_scores))
def test_randomized_logistic_sparse():
# Check randomized sparse logistic regression on sparse data
iris = load_iris()
X = iris.data[:, [0, 2]]
y = iris.target
X = X[y != 2]
y = y[y != 2]
# center here because sparse matrices are usually not centered
X, y, _, _, _ = center_data(X, y, True, True)
X_sp = sparse.csr_matrix(X)
F, _ = f_classif(X, y)
scaling = 0.3
clf = RandomizedLogisticRegression(verbose=False, C=1., random_state=42,
scaling=scaling, n_resampling=50,
tol=1e-3)
feature_scores = clf.fit(X, y).scores_
clf = RandomizedLogisticRegression(verbose=False, C=1., random_state=42,
scaling=scaling, n_resampling=50,
tol=1e-3)
feature_scores_sp = clf.fit(X_sp, y).scores_
assert_array_equal(feature_scores, feature_scores_sp)
|
bsd-3-clause
|
[
3,
6642,
26,
22986,
28547,
27211,
10279,
665,
24421,
28547,
14,
1679,
10279,
32,
262,
23714,
14,
4391,
30,
199,
3,
844,
26,
6289,
650,
8502,
199,
199,
646,
2680,
465,
980,
199,
504,
7026,
492,
5178,
199,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
3536,
199,
199,
504,
6357,
14,
6676,
63,
1238,
14,
2355,
1759,
63,
76,
17,
492,
334,
18412,
63,
270,
3616,
63,
515,
12,
6059,
9571,
1759,
27537,
12,
6059,
9571,
1759,
2445,
23032,
9,
199,
504,
6357,
14,
12281,
492,
2248,
63,
328,
26290,
12,
2248,
63,
11885,
199,
504,
6357,
14,
4445,
63,
5592,
492,
289,
63,
12513,
12,
289,
63,
12334,
70,
199,
504,
6357,
14,
21402,
492,
9739,
24274,
199,
504,
6357,
14,
6676,
63,
1238,
14,
1095,
492,
8126,
63,
576,
199,
199,
328,
26290,
275,
2248,
63,
328,
26290,
342,
199,
56,
275,
487,
26290,
14,
576,
199,
89,
275,
487,
26290,
14,
1375,
199,
56,
275,
9739,
24274,
1252,
3269,
63,
4711,
8,
56,
9,
199,
56,
275,
1323,
3981,
359,
18,
12,
650,
12,
1227,
12,
1520,
12,
1695,
2677,
199,
199,
3,
511,
626,
314,
3878,
5396,
402,
314,
5526,
4534,
199,
38,
12,
485,
275,
289,
63,
12513,
8,
56,
12,
612,
9,
421,
199,
318,
511,
63,
18412,
63,
270,
3616,
63,
515,
837,
272,
327,
2670,
634,
15923,
410,
3616,
931,
272,
327,
7190,
487,
26290,
666,
436,
1050,
949,
19765,
4534,
272,
13690,
275,
378,
14,
19,
272,
7355,
63,
3825,
12,
9342,
63,
515,
275,
634,
15923,
63,
270,
3616,
63,
515,
8,
56,
12,
612,
12,
13690,
29,
12153,
12,
8179,
2196,
63,
929,
29,
2260,
12,
8179,
302,
63,
470,
23144,
29,
1216,
9,
339,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
15786,
19,
8429,
2432,
980,
14,
20188,
8,
1590,
14,
1838,
8,
7107,
63,
515,
12,
3114,
29,
17,
430,
1988,
19,
5728,
421,
199,
318,
511,
63,
2355,
1759,
63,
18412,
837,
272,
327,
2670,
2196,
1759,
634,
15923,
272,
13690,
275,
378,
14,
19,
272,
7267,
63,
7227,
275,
378,
14,
21,
339,
327,
503,
543,
413,
5131,
272,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
5131,
29,
17,
12,
2196,
63,
929,
29,
2260,
12,
2079,
13690,
29,
12153,
12,
2079,
7267,
63,
7227,
29,
5592,
63,
7227,
9,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
15786,
19,
8429,
980,
14,
20188,
8,
4445,
63,
7107,
15786,
19,
5728,
339,
327,
503,
543,
5002,
25363,
272,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
5131,
1524,
17,
12,
378,
14,
24,
467,
2196,
63,
929,
29,
2260,
12,
2079,
13690,
29,
12153,
12,
2079,
7267,
63,
7227,
29,
5592,
63,
7227,
9,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1452,
8,
9694,
14,
452,
63,
7107,
3754,
1392,
12,
334,
56,
14,
1392,
59,
17,
467,
499,
430,
272,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
15786,
19,
8429,
980,
14,
20188,
8,
4445,
63,
7107,
15786,
19,
5728,
339,
1323,
63,
82,
275,
6975,
14,
4711,
8,
56,
9,
272,
1323,
63,
2861,
275,
6975,
14,
11668,
63,
4711,
8,
56,
63,
82,
9,
272,
702,
63,
1452,
8,
56,
63,
82,
14,
1392,
59,
17,
467,
980,
14,
1838,
8,
4445,
63,
7107,
690,
7267,
63,
7227,
430,
272,
702,
63,
1452,
8,
56,
63,
2861,
14,
1392,
12,
1323,
14,
1392,
9,
339,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
5131,
534,
65,
530,
297,
2196,
63,
929,
29,
2260,
12,
2079,
13690,
29,
12153,
9,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1144,
63,
1452,
8,
4445,
63,
7107,
12,
1323,
14,
1392,
59,
17,
61,
627,
359,
17,
14444,
339,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
13690,
4022,
16,
14,
17,
9,
272,
702,
63,
3536,
8,
3393,
12,
6975,
14,
3269,
12,
1323,
12,
612,
9,
339,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
13690,
29,
17,
14,
17,
9,
272,
702,
63,
3536,
8,
3393,
12,
6975,
14,
3269,
12,
1323,
12,
612,
9,
421,
199,
318,
511,
63,
2355,
1759,
63,
23452,
837,
272,
327,
2670,
2196,
1759,
5178,
30360,
10864,
272,
12192,
275,
2248,
63,
11885,
342,
272,
1323,
275,
12192,
14,
576,
3981,
359,
16,
12,
499,
2677,
272,
612,
275,
12192,
14,
1375,
272,
1323,
275,
1323,
59,
89,
1137,
499,
61,
272,
612,
275,
612,
59,
89,
1137,
499,
61,
339,
481,
12,
485,
275,
289,
63,
12334,
70,
8,
56,
12,
612,
9,
339,
13690,
275,
378,
14,
19,
272,
6975,
275,
9571,
1759,
2445,
23032,
8,
3832,
29,
797,
12,
445,
29,
17,
2020,
2196,
63,
929,
29,
2260,
12,
4318,
13690,
29,
12153,
12,
302,
63,
470,
23144,
29,
1400,
12,
4318,
9561,
29,
17,
69,
13,
19,
9,
272,
1323,
63,
2981,
275,
1323,
14,
1574,
342,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1144,
63,
1452,
8,
56,
12,
1323,
63,
2981,
9,
257,
327,
5542,
1630,
440,
2811,
1323,
272,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
395,
980,
14,
20188,
8,
4445,
63,
7107,
430,
339,
6975,
275,
9571,
1759,
2445,
23032,
8,
3832,
29,
797,
12,
445,
1524,
17,
2020,
378,
14,
21,
467,
4318,
2196,
63,
929,
29,
2260,
12,
13690,
29,
12153,
12,
4318,
302,
63,
470,
23144,
29,
1400,
12,
9561,
29,
17,
69,
13,
19,
9,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
395,
980,
14,
20188
] |
[
6642,
26,
22986,
28547,
27211,
10279,
665,
24421,
28547,
14,
1679,
10279,
32,
262,
23714,
14,
4391,
30,
199,
3,
844,
26,
6289,
650,
8502,
199,
199,
646,
2680,
465,
980,
199,
504,
7026,
492,
5178,
199,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
3536,
199,
199,
504,
6357,
14,
6676,
63,
1238,
14,
2355,
1759,
63,
76,
17,
492,
334,
18412,
63,
270,
3616,
63,
515,
12,
6059,
9571,
1759,
27537,
12,
6059,
9571,
1759,
2445,
23032,
9,
199,
504,
6357,
14,
12281,
492,
2248,
63,
328,
26290,
12,
2248,
63,
11885,
199,
504,
6357,
14,
4445,
63,
5592,
492,
289,
63,
12513,
12,
289,
63,
12334,
70,
199,
504,
6357,
14,
21402,
492,
9739,
24274,
199,
504,
6357,
14,
6676,
63,
1238,
14,
1095,
492,
8126,
63,
576,
199,
199,
328,
26290,
275,
2248,
63,
328,
26290,
342,
199,
56,
275,
487,
26290,
14,
576,
199,
89,
275,
487,
26290,
14,
1375,
199,
56,
275,
9739,
24274,
1252,
3269,
63,
4711,
8,
56,
9,
199,
56,
275,
1323,
3981,
359,
18,
12,
650,
12,
1227,
12,
1520,
12,
1695,
2677,
199,
199,
3,
511,
626,
314,
3878,
5396,
402,
314,
5526,
4534,
199,
38,
12,
485,
275,
289,
63,
12513,
8,
56,
12,
612,
9,
421,
199,
318,
511,
63,
18412,
63,
270,
3616,
63,
515,
837,
272,
327,
2670,
634,
15923,
410,
3616,
931,
272,
327,
7190,
487,
26290,
666,
436,
1050,
949,
19765,
4534,
272,
13690,
275,
378,
14,
19,
272,
7355,
63,
3825,
12,
9342,
63,
515,
275,
634,
15923,
63,
270,
3616,
63,
515,
8,
56,
12,
612,
12,
13690,
29,
12153,
12,
8179,
2196,
63,
929,
29,
2260,
12,
8179,
302,
63,
470,
23144,
29,
1216,
9,
339,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
15786,
19,
8429,
2432,
980,
14,
20188,
8,
1590,
14,
1838,
8,
7107,
63,
515,
12,
3114,
29,
17,
430,
1988,
19,
5728,
421,
199,
318,
511,
63,
2355,
1759,
63,
18412,
837,
272,
327,
2670,
2196,
1759,
634,
15923,
272,
13690,
275,
378,
14,
19,
272,
7267,
63,
7227,
275,
378,
14,
21,
339,
327,
503,
543,
413,
5131,
272,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
5131,
29,
17,
12,
2196,
63,
929,
29,
2260,
12,
2079,
13690,
29,
12153,
12,
2079,
7267,
63,
7227,
29,
5592,
63,
7227,
9,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
15786,
19,
8429,
980,
14,
20188,
8,
4445,
63,
7107,
15786,
19,
5728,
339,
327,
503,
543,
5002,
25363,
272,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
5131,
1524,
17,
12,
378,
14,
24,
467,
2196,
63,
929,
29,
2260,
12,
2079,
13690,
29,
12153,
12,
2079,
7267,
63,
7227,
29,
5592,
63,
7227,
9,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1452,
8,
9694,
14,
452,
63,
7107,
3754,
1392,
12,
334,
56,
14,
1392,
59,
17,
467,
499,
430,
272,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
15786,
19,
8429,
980,
14,
20188,
8,
4445,
63,
7107,
15786,
19,
5728,
339,
1323,
63,
82,
275,
6975,
14,
4711,
8,
56,
9,
272,
1323,
63,
2861,
275,
6975,
14,
11668,
63,
4711,
8,
56,
63,
82,
9,
272,
702,
63,
1452,
8,
56,
63,
82,
14,
1392,
59,
17,
467,
980,
14,
1838,
8,
4445,
63,
7107,
690,
7267,
63,
7227,
430,
272,
702,
63,
1452,
8,
56,
63,
2861,
14,
1392,
12,
1323,
14,
1392,
9,
339,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
5131,
534,
65,
530,
297,
2196,
63,
929,
29,
2260,
12,
2079,
13690,
29,
12153,
9,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1144,
63,
1452,
8,
4445,
63,
7107,
12,
1323,
14,
1392,
59,
17,
61,
627,
359,
17,
14444,
339,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
13690,
4022,
16,
14,
17,
9,
272,
702,
63,
3536,
8,
3393,
12,
6975,
14,
3269,
12,
1323,
12,
612,
9,
339,
6975,
275,
9571,
1759,
27537,
8,
3832,
29,
797,
12,
13690,
29,
17,
14,
17,
9,
272,
702,
63,
3536,
8,
3393,
12,
6975,
14,
3269,
12,
1323,
12,
612,
9,
421,
199,
318,
511,
63,
2355,
1759,
63,
23452,
837,
272,
327,
2670,
2196,
1759,
5178,
30360,
10864,
272,
12192,
275,
2248,
63,
11885,
342,
272,
1323,
275,
12192,
14,
576,
3981,
359,
16,
12,
499,
2677,
272,
612,
275,
12192,
14,
1375,
272,
1323,
275,
1323,
59,
89,
1137,
499,
61,
272,
612,
275,
612,
59,
89,
1137,
499,
61,
339,
481,
12,
485,
275,
289,
63,
12334,
70,
8,
56,
12,
612,
9,
339,
13690,
275,
378,
14,
19,
272,
6975,
275,
9571,
1759,
2445,
23032,
8,
3832,
29,
797,
12,
445,
29,
17,
2020,
2196,
63,
929,
29,
2260,
12,
4318,
13690,
29,
12153,
12,
302,
63,
470,
23144,
29,
1400,
12,
4318,
9561,
29,
17,
69,
13,
19,
9,
272,
1323,
63,
2981,
275,
1323,
14,
1574,
342,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1144,
63,
1452,
8,
56,
12,
1323,
63,
2981,
9,
257,
327,
5542,
1630,
440,
2811,
1323,
272,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20188,
8,
38,
395,
980,
14,
20188,
8,
4445,
63,
7107,
430,
339,
6975,
275,
9571,
1759,
2445,
23032,
8,
3832,
29,
797,
12,
445,
1524,
17,
2020,
378,
14,
21,
467,
4318,
2196,
63,
929,
29,
2260,
12,
13690,
29,
12153,
12,
4318,
302,
63,
470,
23144,
29,
1400,
12,
9561,
29,
17,
69,
13,
19,
9,
272,
3878,
63,
7107,
275,
6975,
14,
3269,
8,
56,
12,
612,
680,
7107,
63,
272,
702,
63,
1144,
63,
1452,
8,
1590,
14,
20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,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
i5on9i/echoserver
|
lib/markupsafe/tests.py
|
674
|
6107
|
# -*- coding: utf-8 -*-
import gc
import sys
import unittest
from markupsafe import Markup, escape, escape_silent
from markupsafe._compat import text_type
class MarkupTestCase(unittest.TestCase):
def test_adding(self):
# adding two strings should escape the unsafe one
unsafe = '<script type="application/x-some-script">alert("foo");</script>'
safe = Markup('<em>username</em>')
assert unsafe + safe == text_type(escape(unsafe)) + text_type(safe)
def test_string_interpolation(self):
# string interpolations are safe to use too
assert Markup('<em>%s</em>') % '<bad user>' == \
'<em><bad user></em>'
assert Markup('<em>%(username)s</em>') % {
'username': '<bad user>'
} == '<em><bad user></em>'
assert Markup('%i') % 3.14 == '3'
assert Markup('%.2f') % 3.14 == '3.14'
def test_type_behavior(self):
# an escaped object is markup too
assert type(Markup('foo') + 'bar') is Markup
# and it implements __html__ by returning itself
x = Markup("foo")
assert x.__html__() is x
def test_html_interop(self):
# it also knows how to treat __html__ objects
class Foo(object):
def __html__(self):
return '<em>awesome</em>'
def __unicode__(self):
return 'awesome'
__str__ = __unicode__
assert Markup(Foo()) == '<em>awesome</em>'
assert Markup('<strong>%s</strong>') % Foo() == \
'<strong><em>awesome</em></strong>'
def test_tuple_interpol(self):
self.assertEqual(Markup('<em>%s:%s</em>') % (
'<foo>',
'<bar>',
), Markup(u'<em><foo>:<bar></em>'))
def test_dict_interpol(self):
self.assertEqual(Markup('<em>%(foo)s</em>') % {
'foo': '<foo>',
}, Markup(u'<em><foo></em>'))
self.assertEqual(Markup('<em>%(foo)s:%(bar)s</em>') % {
'foo': '<foo>',
'bar': '<bar>',
}, Markup(u'<em><foo>:<bar></em>'))
def test_escaping(self):
# escaping and unescaping
assert escape('"<>&\'') == '"<>&''
assert Markup("<em>Foo & Bar</em>").striptags() == "Foo & Bar"
assert Markup("<test>").unescape() == "<test>"
def test_formatting(self):
for actual, expected in (
(Markup('%i') % 3.14, '3'),
(Markup('%.2f') % 3.14159, '3.14'),
(Markup('%s %s %s') % ('<', 123, '>'), '< 123 >'),
(Markup('<em>{awesome}</em>').format(awesome='<awesome>'),
'<em><awesome></em>'),
(Markup('{0[1][bar]}').format([0, {'bar': '<bar/>'}]),
'<bar/>'),
(Markup('{0[1][bar]}').format([0, {'bar': Markup('<bar/>')}]),
'<bar/>')):
assert actual == expected, "%r should be %r!" % (actual, expected)
# This is new in 2.7
if sys.version_info >= (2, 7):
def test_formatting_empty(self):
formatted = Markup('{}').format(0)
assert formatted == Markup('0')
def test_custom_formatting(self):
class HasHTMLOnly(object):
def __html__(self):
return Markup('<foo>')
class HasHTMLAndFormat(object):
def __html__(self):
return Markup('<foo>')
def __html_format__(self, spec):
return Markup('<FORMAT>')
assert Markup('{0}').format(HasHTMLOnly()) == Markup('<foo>')
assert Markup('{0}').format(HasHTMLAndFormat()) == Markup('<FORMAT>')
def test_complex_custom_formatting(self):
class User(object):
def __init__(self, id, username):
self.id = id
self.username = username
def __html_format__(self, format_spec):
if format_spec == 'link':
return Markup('<a href="/user/{0}">{1}</a>').format(
self.id,
self.__html__(),
)
elif format_spec:
raise ValueError('Invalid format spec')
return self.__html__()
def __html__(self):
return Markup('<span class=user>{0}</span>').format(self.username)
user = User(1, 'foo')
assert Markup('<p>User: {0:link}').format(user) == \
Markup('<p>User: <a href="/user/1"><span class=user>foo</span></a>')
def test_all_set(self):
import markupsafe as markup
for item in markup.__all__:
getattr(markup, item)
def test_escape_silent(self):
assert escape_silent(None) == Markup()
assert escape(None) == Markup(None)
assert escape_silent('<foo>') == Markup(u'<foo>')
def test_splitting(self):
self.assertEqual(Markup('a b').split(), [
Markup('a'),
Markup('b')
])
self.assertEqual(Markup('a b').rsplit(), [
Markup('a'),
Markup('b')
])
self.assertEqual(Markup('a\nb').splitlines(), [
Markup('a'),
Markup('b')
])
def test_mul(self):
self.assertEqual(Markup('a') * 3, Markup('aaa'))
class MarkupLeakTestCase(unittest.TestCase):
def test_markup_leaks(self):
counts = set()
for count in range(20):
for item in range(1000):
escape("foo")
escape("<foo>")
escape(u"foo")
escape(u"<foo>")
counts.add(len(gc.get_objects()))
assert len(counts) == 1, 'ouch, c extension seems to leak objects'
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MarkupTestCase))
# this test only tests the c extension
if not hasattr(escape, 'func_code'):
suite.addTest(unittest.makeSuite(MarkupLeakTestCase))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')
# vim:sts=4:sw=4:et:
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
9486,
199,
646,
984,
199,
646,
2882,
199,
504,
9189,
3489,
492,
17504,
12,
4772,
12,
4772,
63,
14434,
199,
504,
9189,
3489,
423,
5819,
492,
1318,
63,
466,
421,
199,
533,
17504,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
4095,
8,
277,
304,
267,
327,
7791,
2877,
3326,
1077,
4772,
314,
19293,
1373,
267,
19293,
275,
2650,
1579,
730,
628,
3578,
15,
88,
13,
3972,
13,
1579,
1743,
9241,
480,
1421,
3547,
1108,
1579,
3524,
267,
5048,
275,
17504,
4827,
5633,
30,
2473,
1108,
5633,
5971,
267,
702,
19293,
435,
5048,
508,
1318,
63,
466,
8,
3765,
8,
14242,
430,
435,
1318,
63,
466,
8,
3489,
9,
339,
347,
511,
63,
875,
63,
21080,
8,
277,
304,
267,
327,
1059,
23005,
1298,
787,
5048,
370,
675,
4634,
267,
702,
17504,
4827,
5633,
6598,
83,
1108,
5633,
5971,
450,
2650,
4087,
922,
3524,
508,
971,
2049,
2650,
5633,
18181,
4116,
27,
4087,
922,
6,
3308,
12279,
5633,
3524,
267,
702,
17504,
4827,
5633,
19418,
2473,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
2473,
356,
2650,
4087,
922,
3524,
267,
789,
508,
2650,
5633,
18181,
4116,
27,
4087,
922,
6,
3308,
12279,
5633,
3524,
398,
702,
17504,
3508,
73,
358,
450,
650,
14,
1079,
508,
283,
19,
7,
267,
702,
17504,
3508,
14,
18,
70,
358,
450,
650,
14,
1079,
508,
283,
19,
14,
1079,
7,
339,
347,
511,
63,
466,
63,
17537,
8,
277,
304,
267,
327,
376,
11077,
909,
365,
9189,
4634,
267,
702,
730,
8,
23393,
360,
1421,
358,
435,
283,
1700,
358,
365,
17504,
398,
327,
436,
652,
9031,
636,
1360,
363,
701,
8152,
6337,
267,
671,
275,
17504,
480,
1421,
531,
267,
702,
671,
855,
1360,
4533,
365,
671,
339,
347,
511,
63,
1360,
63,
5707,
2675,
8,
277,
304,
267,
327,
652,
2597,
19428,
4212,
370,
14312,
636,
1360,
363,
2251,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
2650,
5633,
30,
10084,
22666,
1108,
5633,
3524,
288,
347,
636,
2975,
721,
277,
304,
355,
372,
283,
10084,
22666,
7,
288,
636,
495,
363,
275,
636,
2975,
363,
267,
702,
17504,
8,
5686,
1012,
508,
2650,
5633,
30,
10084,
22666,
1108,
5633,
3524,
267,
702,
17504,
4827,
9370,
6598,
83,
1108,
9370,
5971,
450,
8024,
342,
508,
971,
288,
2650,
9370,
2535,
5633,
30,
10084,
22666,
1108,
5633,
2957,
9370,
3524,
339,
347,
511,
63,
2960,
63,
29690,
8,
277,
304,
267,
291,
14,
629,
8,
23393,
4827,
5633,
6598,
83,
2689,
83,
1108,
5633,
5971,
450,
334,
288,
2650,
1421,
4206,
288,
2650,
1700,
4206,
267,
2318,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
27,
26,
6,
4116,
27,
1700,
6,
3308,
12279,
5633,
30,
1333,
339,
347,
511,
63,
807,
63,
29690,
8,
277,
304,
267,
291,
14,
629,
8,
23393,
4827,
5633,
19418,
1421,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
1421,
356,
2650,
1421,
4206,
267,
1660,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
12279,
5633,
30,
1333,
267,
291,
14,
629,
8,
23393,
4827,
5633,
19418,
1421,
9,
83,
19648,
1700,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
1421,
356,
2650,
1421,
4206,
288,
283,
1700,
356,
2650,
1700,
4206,
267,
1660,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
27,
26,
6,
4116,
27,
1700,
6,
3308,
12279,
5633,
30,
1333,
339,
347,
511,
63,
26306,
8,
277,
304,
267,
327,
21375,
436,
625,
26306,
267,
702,
4772,
14088,
16137,
6,
3985,
358,
508,
7673,
3,
1082,
15337,
4116,
15337,
3308,
15337,
5282,
14328,
1355,
8942,
267,
702,
17504,
6757,
5633,
30,
5686,
1253,
5282,
27,
12377,
1108,
5633,
30,
3471,
1913,
2969,
342,
508,
298,
5686,
1253,
12377,
2,
267,
702,
17504,
22077,
4116,
27,
396,
6,
3308,
27,
3471,
22726,
342,
508,
3886,
396,
4335,
339,
347,
511,
63,
20034,
8,
277,
304,
267,
367,
3503,
12,
1420,
315,
334,
288,
334,
23393,
3508,
73,
358,
450,
650,
14,
1079,
12,
283,
19,
659,
288,
334,
23393,
3508,
14,
18,
70,
358,
450,
650,
14,
1079,
9327,
12,
283,
19,
14,
1079,
659,
288,
334,
23393,
3508,
83,
450,
83,
450,
83,
358,
450,
19990,
297,
11869,
12,
12696,
659,
7673,
4116,
27,
11869,
1253,
3308,
27,
659,
288,
334,
23393,
4827,
5633,
22266,
10084,
22666,
17890,
5633,
30,
1959,
908,
8,
10084,
22666,
15829,
10084,
22666,
25642,
1467,
2650,
5633,
18181,
4116,
27,
10084,
22666,
6,
3308,
12279,
5633,
25642,
288,
334,
23393,
11117,
16,
59,
17,
1527,
1700,
9420,
1959,
908,
779,
16,
12,
791,
1700,
356,
2650,
1700,
3133,
936,
2522,
1467,
7673,
4116,
27,
1700,
15,
6,
3308,
27,
659,
288,
334,
23393,
11117,
16,
59,
17,
1527,
1700,
9420,
1959,
908,
779,
16,
12,
791,
1700,
356,
17504,
4827,
1700,
3133,
21004,
2522,
1467,
2650,
1700,
3133,
8109,
288,
702,
3503,
508,
1420,
12,
2071,
82,
1077,
506,
450,
82,
9539,
450,
334,
6514,
12,
1420,
9,
339,
327,
961,
365,
892,
315,
499,
14,
23,
272,
340,
984,
14,
1023,
63,
815,
2356,
334,
18,
12,
1520,
304,
267,
347,
511,
63,
20034,
63,
1667,
8,
277,
304,
288,
7871,
275,
17504,
17519,
1959,
908,
8,
16,
9,
288,
702,
7871,
508,
17504,
360,
16,
358,
339,
347,
511,
63,
4229,
63,
20034,
8,
277,
304,
267,
1021,
13481,
2148,
45,
1484,
78,
590,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
17504,
4827,
1421,
5971,
398,
1021,
13481,
4943,
3325,
3484,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
17504,
4827,
1421,
5971,
288,
347,
636,
1360,
63,
908,
721,
277,
12,
3158,
304,
355,
372,
17504,
4827,
4807,
5971,
398,
702,
17504,
11117,
16,
93,
1959,
908,
8,
6362,
2148,
45,
1484,
78,
590,
1012,
508,
17504,
4827,
1421,
5971,
267,
702,
17504,
11117,
16,
93,
1959,
908,
8,
6362,
4943,
3325,
3484,
1012,
508,
17504,
4827,
4807,
5971,
339,
347,
511,
63,
5254,
63,
4229,
63,
20034,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
9486,
199,
646,
984,
199,
646,
2882,
199,
504,
9189,
3489,
492,
17504,
12,
4772,
12,
4772,
63,
14434,
199,
504,
9189,
3489,
423,
5819,
492,
1318,
63,
466,
421,
199,
533,
17504,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
4095,
8,
277,
304,
267,
327,
7791,
2877,
3326,
1077,
4772,
314,
19293,
1373,
267,
19293,
275,
2650,
1579,
730,
628,
3578,
15,
88,
13,
3972,
13,
1579,
1743,
9241,
480,
1421,
3547,
1108,
1579,
3524,
267,
5048,
275,
17504,
4827,
5633,
30,
2473,
1108,
5633,
5971,
267,
702,
19293,
435,
5048,
508,
1318,
63,
466,
8,
3765,
8,
14242,
430,
435,
1318,
63,
466,
8,
3489,
9,
339,
347,
511,
63,
875,
63,
21080,
8,
277,
304,
267,
327,
1059,
23005,
1298,
787,
5048,
370,
675,
4634,
267,
702,
17504,
4827,
5633,
6598,
83,
1108,
5633,
5971,
450,
2650,
4087,
922,
3524,
508,
971,
2049,
2650,
5633,
18181,
4116,
27,
4087,
922,
6,
3308,
12279,
5633,
3524,
267,
702,
17504,
4827,
5633,
19418,
2473,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
2473,
356,
2650,
4087,
922,
3524,
267,
789,
508,
2650,
5633,
18181,
4116,
27,
4087,
922,
6,
3308,
12279,
5633,
3524,
398,
702,
17504,
3508,
73,
358,
450,
650,
14,
1079,
508,
283,
19,
7,
267,
702,
17504,
3508,
14,
18,
70,
358,
450,
650,
14,
1079,
508,
283,
19,
14,
1079,
7,
339,
347,
511,
63,
466,
63,
17537,
8,
277,
304,
267,
327,
376,
11077,
909,
365,
9189,
4634,
267,
702,
730,
8,
23393,
360,
1421,
358,
435,
283,
1700,
358,
365,
17504,
398,
327,
436,
652,
9031,
636,
1360,
363,
701,
8152,
6337,
267,
671,
275,
17504,
480,
1421,
531,
267,
702,
671,
855,
1360,
4533,
365,
671,
339,
347,
511,
63,
1360,
63,
5707,
2675,
8,
277,
304,
267,
327,
652,
2597,
19428,
4212,
370,
14312,
636,
1360,
363,
2251,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
2650,
5633,
30,
10084,
22666,
1108,
5633,
3524,
288,
347,
636,
2975,
721,
277,
304,
355,
372,
283,
10084,
22666,
7,
288,
636,
495,
363,
275,
636,
2975,
363,
267,
702,
17504,
8,
5686,
1012,
508,
2650,
5633,
30,
10084,
22666,
1108,
5633,
3524,
267,
702,
17504,
4827,
9370,
6598,
83,
1108,
9370,
5971,
450,
8024,
342,
508,
971,
288,
2650,
9370,
2535,
5633,
30,
10084,
22666,
1108,
5633,
2957,
9370,
3524,
339,
347,
511,
63,
2960,
63,
29690,
8,
277,
304,
267,
291,
14,
629,
8,
23393,
4827,
5633,
6598,
83,
2689,
83,
1108,
5633,
5971,
450,
334,
288,
2650,
1421,
4206,
288,
2650,
1700,
4206,
267,
2318,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
27,
26,
6,
4116,
27,
1700,
6,
3308,
12279,
5633,
30,
1333,
339,
347,
511,
63,
807,
63,
29690,
8,
277,
304,
267,
291,
14,
629,
8,
23393,
4827,
5633,
19418,
1421,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
1421,
356,
2650,
1421,
4206,
267,
1660,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
12279,
5633,
30,
1333,
267,
291,
14,
629,
8,
23393,
4827,
5633,
19418,
1421,
9,
83,
19648,
1700,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
1421,
356,
2650,
1421,
4206,
288,
283,
1700,
356,
2650,
1700,
4206,
267,
1660,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
27,
26,
6,
4116,
27,
1700,
6,
3308,
12279,
5633,
30,
1333,
339,
347,
511,
63,
26306,
8,
277,
304,
267,
327,
21375,
436,
625,
26306,
267,
702,
4772,
14088,
16137,
6,
3985,
358,
508,
7673,
3,
1082,
15337,
4116,
15337,
3308,
15337,
5282,
14328,
1355,
8942,
267,
702,
17504,
6757,
5633,
30,
5686,
1253,
5282,
27,
12377,
1108,
5633,
30,
3471,
1913,
2969,
342,
508,
298,
5686,
1253,
12377,
2,
267,
702,
17504,
22077,
4116,
27,
396,
6,
3308,
27,
3471,
22726,
342,
508,
3886,
396,
4335,
339,
347,
511,
63,
20034,
8,
277,
304,
267,
367,
3503,
12,
1420,
315,
334,
288,
334,
23393,
3508,
73,
358,
450,
650,
14,
1079,
12,
283,
19,
659,
288,
334,
23393,
3508,
14,
18,
70,
358,
450,
650,
14,
1079,
9327,
12,
283,
19,
14,
1079,
659,
288,
334,
23393,
3508,
83,
450,
83,
450,
83,
358,
450,
19990,
297,
11869,
12,
12696,
659,
7673,
4116,
27,
11869,
1253,
3308,
27,
659,
288,
334,
23393,
4827,
5633,
22266,
10084,
22666,
17890,
5633,
30,
1959,
908,
8,
10084,
22666,
15829,
10084,
22666,
25642,
1467,
2650,
5633,
18181,
4116,
27,
10084,
22666,
6,
3308,
12279,
5633,
25642,
288,
334,
23393,
11117,
16,
59,
17,
1527,
1700,
9420,
1959,
908,
779,
16,
12,
791,
1700,
356,
2650,
1700,
3133,
936,
2522,
1467,
7673,
4116,
27,
1700,
15,
6,
3308,
27,
659,
288,
334,
23393,
11117,
16,
59,
17,
1527,
1700,
9420,
1959,
908,
779,
16,
12,
791,
1700,
356,
17504,
4827,
1700,
3133,
21004,
2522,
1467,
2650,
1700,
3133,
8109,
288,
702,
3503,
508,
1420,
12,
2071,
82,
1077,
506,
450,
82,
9539,
450,
334,
6514,
12,
1420,
9,
339,
327,
961,
365,
892,
315,
499,
14,
23,
272,
340,
984,
14,
1023,
63,
815,
2356,
334,
18,
12,
1520,
304,
267,
347,
511,
63,
20034,
63,
1667,
8,
277,
304,
288,
7871,
275,
17504,
17519,
1959,
908,
8,
16,
9,
288,
702,
7871,
508,
17504,
360,
16,
358,
339,
347,
511,
63,
4229,
63,
20034,
8,
277,
304,
267,
1021,
13481,
2148,
45,
1484,
78,
590,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
17504,
4827,
1421,
5971,
398,
1021,
13481,
4943,
3325,
3484,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
17504,
4827,
1421,
5971,
288,
347,
636,
1360,
63,
908,
721,
277,
12,
3158,
304,
355,
372,
17504,
4827,
4807,
5971,
398,
702,
17504,
11117,
16,
93,
1959,
908,
8,
6362,
2148,
45,
1484,
78,
590,
1012,
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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
] |
mat650/metagoofil
|
hachoir_parser/audio/modplug.py
|
95
|
10655
|
"""
Modplug metadata inserted into module files.
Doc:
- http://modplug.svn.sourceforge.net/viewvc/modplug/trunk/modplug/soundlib/
Author: Christophe GISQUET <christophe.gisquet@free.fr>
Creation: 10th February 2007
"""
from hachoir_core.field import (FieldSet,
UInt32, UInt16, UInt8, Int8, Float32,
RawBytes, String, GenericVector, ParserError)
from hachoir_core.endian import LITTLE_ENDIAN
from hachoir_core.text_handler import textHandler, hexadecimal
MAX_ENVPOINTS = 32
def parseComments(parser):
size = parser["block_size"].value
if size > 0:
yield String(parser, "comment", size)
class MidiOut(FieldSet):
static_size = 9*32*8
def createFields(self):
for name in ("start", "stop", "tick", "noteon", "noteoff",
"volume", "pan", "banksel", "program"):
yield String(self, name, 32, strip='\0')
class Command(FieldSet):
static_size = 32*8
def createFields(self):
start = self.absolute_address
size = self.stream.searchBytesLength("\0", False, start)
if size > 0:
self.info("Command: %s" % self.stream.readBytes(start, size))
yield String(self, "command", size, strip='\0')
yield RawBytes(self, "parameter", (self._size//8)-size)
class MidiSFXExt(FieldSet):
static_size = 16*32*8
def createFields(self):
for index in xrange(16):
yield Command(self, "command[]")
class MidiZXXExt(FieldSet):
static_size = 128*32*8
def createFields(self):
for index in xrange(128):
yield Command(self, "command[]")
def parseMidiConfig(parser):
yield MidiOut(parser, "midi_out")
yield MidiSFXExt(parser, "sfx_ext")
yield MidiZXXExt(parser, "zxx_ext")
def parseChannelSettings(parser):
size = parser["block_size"].value//4
if size > 0:
yield GenericVector(parser, "settings", size, UInt32, "mix_plugin")
def parseEQBands(parser):
size = parser["block_size"].value//4
if size > 0:
yield GenericVector(parser, "gains", size, UInt32, "band")
class SoundMixPluginInfo(FieldSet):
static_size = 128*8
def createFields(self):
yield textHandler(UInt32(self, "plugin_id1"), hexadecimal)
yield textHandler(UInt32(self, "plugin_id2"), hexadecimal)
yield UInt32(self, "input_routing")
yield UInt32(self, "output_routing")
yield GenericVector(self, "routing_info", 4, UInt32, "reserved")
yield String(self, "name", 32, strip='\0')
yield String(self, "dll_name", 64, desc="Original DLL name", strip='\0')
class ExtraData(FieldSet):
def __init__(self, parent, name, desc=None):
FieldSet.__init__(self, parent, name, desc)
self._size = (4+self["size"].value)*8
def createFields(self):
yield UInt32(self, "size")
size = self["size"].value
if size:
yield RawBytes(self, "data", size)
class XPlugData(FieldSet):
def __init__(self, parent, name, desc=None):
FieldSet.__init__(self, parent, name, desc)
self._size = (4+self["size"].value)*8
def createFields(self):
yield UInt32(self, "size")
while not self.eof:
yield UInt32(self, "marker")
if self["marker"].value == 'DWRT':
yield Float32(self, "dry_ratio")
elif self["marker"].value == 'PORG':
yield UInt32(self, "default_program")
def parsePlugin(parser):
yield SoundMixPluginInfo(parser, "info")
# Check if VST setchunk present
size = parser.stream.readBits(parser.absolute_address+parser.current_size, 32, LITTLE_ENDIAN)
if 0 < size < parser.current_size + parser._size:
yield ExtraData(parser, "extra_data")
# Check if XPlugData is present
size = parser.stream.readBits(parser.absolute_address+parser.current_size, 32, LITTLE_ENDIAN)
if 0 < size < parser.current_size + parser._size:
yield XPlugData(parser, "xplug_data")
# Format: "XXXX": (type, count, name)
EXTENSIONS = {
# WriteInstrumentHeaderStruct@Sndfile.cpp
"XTPM": {
"..Fd": (UInt32, 1, "Flags"),
"..OF": (UInt32, 1, "Fade out"),
"..VG": (UInt32, 1, "Global Volume"),
"...P": (UInt32, 1, "Panning"),
"..EV": (UInt32, 1, "Volume Envelope"),
"..EP": (UInt32, 1, "Panning Envelope"),
".EiP": (UInt32, 1, "Pitch Envelope"),
".SLV": (UInt8, 1, "Volume Loop Start"),
".ELV": (UInt8, 1, "Volume Loop End"),
".BSV": (UInt8, 1, "Volume Sustain Begin"),
".ESV": (UInt8, 1, "Volume Sustain End"),
".SLP": (UInt8, 1, "Panning Loop Start"),
".ELP": (UInt8, 1, "Panning Loop End"),
".BSP": (UInt8, 1, "Panning Substain Begin"),
".ESP": (UInt8, 1, "Padding Substain End"),
"SLiP": (UInt8, 1, "Pitch Loop Start"),
"ELiP": (UInt8, 1, "Pitch Loop End"),
"BSiP": (UInt8, 1, "Pitch Substain Begin"),
"ESiP": (UInt8, 1, "Pitch Substain End"),
".ANN": (UInt8, 1, "NNA"),
".TCD": (UInt8, 1, "DCT"),
".AND": (UInt8, 1, "DNA"),
"..SP": (UInt8, 1, "Panning Swing"),
"..SV": (UInt8, 1, "Volume Swing"),
".CFI": (UInt8, 1, "IFC"),
".RFI": (UInt8, 1, "IFR"),
"..BM": (UInt32, 1, "Midi Bank"),
"..PM": (UInt8, 1, "Midi Program"),
"..CM": (UInt8, 1, "Midi Channel"),
".KDM": (UInt8, 1, "Midi Drum Key"),
".SPP": (Int8, 1, "PPS"),
".CPP": (UInt8, 1, "PPC"),
".[PV": (UInt32, MAX_ENVPOINTS, "Volume Points"),
".[PP": (UInt32, MAX_ENVPOINTS, "Panning Points"),
"[PiP": (UInt32, MAX_ENVPOINTS, "Pitch Points"),
".[EV": (UInt8, MAX_ENVPOINTS, "Volume Enveloppe"),
".[EP": (UInt8, MAX_ENVPOINTS, "Panning Enveloppe"),
"[EiP": (UInt8, MAX_ENVPOINTS, "Pitch Enveloppe"),
".[MN": (UInt8, 128, "Note Mapping"),
"..[K": (UInt32, 128, "Keyboard"),
"..[n": (String, 32, "Name"),
".[nf": (String, 12, "Filename"),
".PiM": (UInt8, 1, "MixPlug"),
"..RV": (UInt16, 1, "Volume Ramping"),
"...R": (UInt16, 1, "Resampling"),
"..SC": (UInt8, 1, "Cut Swing"),
"..SR": (UInt8, 1, "Res Swing"),
"..MF": (UInt8, 1, "Filter Mode"),
},
# See after "CODE tag dictionary", same place, elements with [EXT]
"STPM": {
"...C": (UInt32, 1, "Channels"),
".VWC": (None, 0, "CreatedWith version"),
".VGD": (None, 0, "Default global volume"),
"..TD": (None, 0, "Default tempo"),
"HIBE": (None, 0, "Embedded instrument header"),
"VWSL": (None, 0, "LastSavedWith version"),
".MMP": (None, 0, "Plugin Mix mode"),
".BPR": (None, 0, "Rows per beat"),
".MPR": (None, 0, "Rows per measure"),
"@PES": (None, 0, "Chunk separator"),
".APS": (None, 0, "Song Pre-amplification"),
"..MT": (None, 0, "Tempo mode"),
"VTSV": (None, 0, "VSTi volume"),
}
}
class MPField(FieldSet):
def __init__(self, parent, name, ext, desc=None):
FieldSet.__init__(self, parent, name, desc)
self.ext = ext
self.info(self.createDescription())
self._size = (6+self["data_size"].value)*8
def createFields(self):
# Identify tag
code = self.stream.readBytes(self.absolute_address, 4)
if code in self.ext:
cls, count, comment = self.ext[code]
else:
cls, count, comment = RawBytes, 1, "Unknown tag"
# Header
yield String(self, "code", 4, comment)
yield UInt16(self, "data_size")
# Data
if not cls:
size = self["data_size"].value
if size > 0:
yield RawBytes(self, "data", size)
elif cls in (String, RawBytes):
yield cls(self, "value", count)
else:
if count > 1:
yield GenericVector(self, "values", count, cls, "item")
else:
yield cls(self, "value")
def createDescription(self):
return "Element '%s', size %i" % \
(self["code"]._description, self["data_size"].value)
def parseFields(parser):
# Determine field names
ext = EXTENSIONS[parser["block_type"].value]
if ext == None:
raise ParserError("Unknown parent '%s'" % parser["block_type"].value)
# Parse fields
addr = parser.absolute_address + parser.current_size
while not parser.eof and parser.stream.readBytes(addr, 4) in ext:
field = MPField(parser, "field[]", ext)
yield field
addr += field._size
# Abort on unknown codes
parser.info("End of extension '%s' when finding '%s'" %
(parser["block_type"].value, parser.stream.readBytes(addr, 4)))
class ModplugBlock(FieldSet):
BLOCK_INFO = {
"TEXT": ("comment", True, "Comment", parseComments),
"MIDI": ("midi_config", True, "Midi configuration", parseMidiConfig),
"XFHC": ("channel_settings", True, "Channel settings", parseChannelSettings),
"XTPM": ("instrument_ext", False, "Instrument extensions", parseFields),
"STPM": ("song_ext", False, "Song extensions", parseFields),
}
def __init__(self, parent, name, desc=None):
FieldSet.__init__(self, parent, name, desc)
self.parseBlock = parsePlugin
t = self["block_type"].value
self.has_size = False
if t in self.BLOCK_INFO:
self._name, self.has_size, desc, parseBlock = self.BLOCK_INFO[t]
if callable(desc):
self.createDescription = lambda: desc(self)
if parseBlock:
self.parseBlock = lambda: parseBlock(self)
if self.has_size:
self._size = 8*(self["block_size"].value + 8)
def createFields(self):
yield String(self, "block_type", 4)
if self.has_size:
yield UInt32(self, "block_size")
if self.parseBlock:
for field in self.parseBlock():
yield field
if self.has_size:
size = self["block_size"].value - (self.current_size//8)
if size > 0:
yield RawBytes(self, "data", size, "Unknown data")
def ParseModplugMetadata(parser):
while not parser.eof:
block = ModplugBlock(parser, "block[]")
yield block
if block["block_type"].value == "STPM":
break
# More undocumented stuff: date ?
size = (parser._size - parser.absolute_address - parser.current_size)//8
if size > 0:
yield RawBytes(parser, "info", size)
|
gpl-2.0
|
[
624,
199,
9871,
13963,
3341,
11788,
1901,
859,
1584,
14,
199,
199,
3768,
26,
199,
13,
1455,
921,
1494,
13963,
14,
6836,
14,
22943,
14,
846,
15,
1345,
6737,
15,
1494,
13963,
15,
13409,
15,
1494,
13963,
15,
14990,
773,
15,
199,
199,
5949,
26,
2799,
322,
2379,
426,
598,
1311,
2328,
775,
665,
335,
322,
2379,
426,
14,
5668,
17917,
32,
4624,
14,
4391,
30,
199,
13921,
26,
1616,
273,
21141,
26709,
10219,
199,
624,
199,
199,
504,
394,
21301,
63,
1018,
14,
698,
492,
334,
23532,
12,
272,
10666,
708,
12,
10666,
975,
12,
10666,
24,
12,
9805,
24,
12,
11140,
708,
12,
272,
13480,
5571,
12,
2624,
12,
8307,
3646,
12,
10191,
547,
9,
199,
504,
394,
21301,
63,
1018,
14,
15009,
492,
491,
31783,
63,
21046,
199,
504,
394,
21301,
63,
1018,
14,
505,
63,
2232,
492,
1318,
2461,
12,
20379,
199,
199,
4283,
63,
9984,
7217,
51,
275,
4337,
199,
199,
318,
2198,
18929,
8,
2087,
304,
272,
1568,
275,
1798,
905,
1457,
63,
890,
4140,
585,
272,
340,
1568,
690,
378,
26,
267,
1995,
2624,
8,
2087,
12,
298,
3349,
401,
1568,
9,
199,
199,
533,
603,
9897,
2204,
8,
23532,
304,
272,
2955,
63,
890,
275,
1749,
10,
708,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
367,
536,
315,
1689,
928,
401,
298,
2379,
401,
298,
8284,
401,
298,
4610,
265,
401,
298,
4610,
1997,
401,
2151,
298,
2405,
401,
298,
10384,
401,
298,
9860,
5891,
401,
298,
6815,
2349,
288,
1995,
2624,
8,
277,
12,
536,
12,
4337,
12,
6202,
17115,
16,
358,
199,
199,
533,
5817,
8,
23532,
304,
272,
2955,
63,
890,
275,
4337,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
1343,
275,
291,
14,
6116,
63,
1562,
267,
1568,
275,
291,
14,
1745,
14,
1733,
5571,
4625,
4582,
16,
401,
756,
12,
1343,
9,
267,
340,
1568,
690,
378,
26,
288,
291,
14,
815,
480,
3110,
26,
450,
83,
2,
450,
291,
14,
1745,
14,
739,
5571,
8,
928,
12,
1568,
430,
288,
1995,
2624,
8,
277,
12,
298,
1531,
401,
1568,
12,
6202,
17115,
16,
358,
267,
1995,
13480,
5571,
8,
277,
12,
298,
5329,
401,
334,
277,
423,
890,
501,
24,
7216,
890,
9,
199,
199,
533,
603,
9897,
13107,
56,
4942,
8,
23532,
304,
272,
2955,
63,
890,
275,
3193,
10,
708,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
367,
1478,
315,
4945,
8,
975,
304,
288,
1995,
5817,
8,
277,
12,
298,
1531,
31346,
199,
199,
533,
603,
9897,
58,
2483,
4942,
8,
23532,
304,
272,
2955,
63,
890,
275,
7960,
10,
708,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
367,
1478,
315,
4945,
8,
3933,
304,
288,
1995,
5817,
8,
277,
12,
298,
1531,
31346,
199,
199,
318,
2198,
45,
9897,
2028,
8,
2087,
304,
272,
1995,
603,
9897,
2204,
8,
2087,
12,
298,
26859,
63,
548,
531,
272,
1995,
603,
9897,
13107,
56,
4942,
8,
2087,
12,
298,
7646,
88,
63,
832,
531,
272,
1995,
603,
9897,
58,
2483,
4942,
8,
2087,
12,
298,
90,
2154,
63,
832,
531,
199,
199,
318,
2198,
5358,
5268,
8,
2087,
304,
272,
1568,
275,
1798,
905,
1457,
63,
890,
4140,
585,
501,
20,
272,
340,
1568,
690,
378,
26,
267,
1995,
8307,
3646,
8,
2087,
12,
298,
1751,
401,
1568,
12,
10666,
708,
12,
298,
13979,
63,
2718,
531,
199,
199,
318,
2198,
17420,
34,
5915,
8,
2087,
304,
272,
1568,
275,
1798,
905,
1457,
63,
890,
4140,
585,
501,
20,
272,
340,
1568,
690,
378,
26,
267,
1995,
8307,
3646,
8,
2087,
12,
298,
13020,
83,
401,
1568,
12,
10666,
708,
12,
298,
7877,
531,
199,
199,
533,
428,
1034,
18854,
5061,
2354,
8,
23532,
304,
272,
2955,
63,
890,
275,
7960,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
1995,
1318,
2461,
8,
13304,
708,
8,
277,
12,
298,
2718,
63,
344,
17,
1288,
20379,
9,
267,
1995,
1318,
2461,
8,
13304,
708,
8,
277,
12,
298,
2718,
63,
344,
18,
1288,
20379,
9,
267,
1995,
10666,
708,
8,
277,
12,
298,
1210,
63,
9492,
531,
267,
1995,
10666,
708,
8,
277,
12,
298,
1199,
63,
9492,
531,
267,
1995,
8307,
3646,
8,
277,
12,
298,
9492,
63,
815,
401,
841,
12,
10666,
708,
12,
298,
10421,
531,
267,
1995,
2624,
8,
277,
12,
298,
354,
401,
4337,
12,
6202,
17115,
16,
358,
267,
1995,
2624,
8,
277,
12,
298,
9259,
63,
354,
401,
5049,
12,
4328,
628,
17286,
577,
4464,
536,
401,
6202,
17115,
16,
358,
199,
199,
533,
11177,
1451,
8,
23532,
304,
272,
347,
636,
826,
721,
277,
12,
1676,
12,
536,
12,
4328,
29,
403,
304,
267,
5024,
1084,
855,
826,
721,
277,
12,
1676,
12,
536,
12,
4328,
9,
267,
291,
423,
890,
275,
334,
20,
11,
277,
905,
890,
4140,
585,
3342,
24,
339,
347,
24828,
8,
277,
304,
267,
1995,
10666,
708,
8,
277,
12,
298,
890,
531,
267,
1568,
275,
291,
905,
890,
4140,
585,
267,
340,
1568,
26,
288,
1995,
13480,
5571,
8,
277,
12,
298,
576,
401,
1568,
9,
199,
199,
533,
1323,
19173,
1451,
8,
23532,
304,
272,
347,
636,
826,
721,
277,
12,
1676,
12,
536,
12,
4328,
29,
403,
304,
267,
5024,
1084,
855,
826,
721,
277,
12,
1676,
12,
536,
12,
4328,
9,
267,
291,
423,
890,
275,
334,
20,
11,
277,
905,
890,
4140,
585,
3342,
24,
339,
347,
24828,
8,
277,
304,
267,
1995,
10666,
708,
8,
277,
12,
298,
890,
531,
267,
1830,
440,
291,
14,
11670,
26,
288,
1995,
10666,
708,
8,
277,
12,
298,
4211,
531,
288,
340,
291,
905,
4211,
4140,
585,
508,
283,
36,
6524,
52,
356,
355,
1995,
11140,
708,
8,
277,
12,
298,
10481,
63,
6884,
531,
288,
916,
291,
905,
4211,
4140,
585,
508,
283,
48,
25797,
356,
355,
1995,
10666,
708,
8,
277,
12,
298,
885,
63,
6815,
531,
199,
199,
318,
2198,
5061,
8,
2087,
304,
272,
1995,
428,
1034,
18854,
5061,
2354,
8,
2087,
12,
298,
815,
531,
339,
327,
2670,
340,
812,
840,
663,
4604,
3451,
272,
1568,
275,
1798,
14,
1745,
14,
739,
10787,
8,
2087,
14,
6116,
63,
1562
] |
[
199,
9871,
13963,
3341,
11788,
1901,
859,
1584,
14,
199,
199,
3768,
26,
199,
13,
1455,
921,
1494,
13963,
14,
6836,
14,
22943,
14,
846,
15,
1345,
6737,
15,
1494,
13963,
15,
13409,
15,
1494,
13963,
15,
14990,
773,
15,
199,
199,
5949,
26,
2799,
322,
2379,
426,
598,
1311,
2328,
775,
665,
335,
322,
2379,
426,
14,
5668,
17917,
32,
4624,
14,
4391,
30,
199,
13921,
26,
1616,
273,
21141,
26709,
10219,
199,
624,
199,
199,
504,
394,
21301,
63,
1018,
14,
698,
492,
334,
23532,
12,
272,
10666,
708,
12,
10666,
975,
12,
10666,
24,
12,
9805,
24,
12,
11140,
708,
12,
272,
13480,
5571,
12,
2624,
12,
8307,
3646,
12,
10191,
547,
9,
199,
504,
394,
21301,
63,
1018,
14,
15009,
492,
491,
31783,
63,
21046,
199,
504,
394,
21301,
63,
1018,
14,
505,
63,
2232,
492,
1318,
2461,
12,
20379,
199,
199,
4283,
63,
9984,
7217,
51,
275,
4337,
199,
199,
318,
2198,
18929,
8,
2087,
304,
272,
1568,
275,
1798,
905,
1457,
63,
890,
4140,
585,
272,
340,
1568,
690,
378,
26,
267,
1995,
2624,
8,
2087,
12,
298,
3349,
401,
1568,
9,
199,
199,
533,
603,
9897,
2204,
8,
23532,
304,
272,
2955,
63,
890,
275,
1749,
10,
708,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
367,
536,
315,
1689,
928,
401,
298,
2379,
401,
298,
8284,
401,
298,
4610,
265,
401,
298,
4610,
1997,
401,
2151,
298,
2405,
401,
298,
10384,
401,
298,
9860,
5891,
401,
298,
6815,
2349,
288,
1995,
2624,
8,
277,
12,
536,
12,
4337,
12,
6202,
17115,
16,
358,
199,
199,
533,
5817,
8,
23532,
304,
272,
2955,
63,
890,
275,
4337,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
1343,
275,
291,
14,
6116,
63,
1562,
267,
1568,
275,
291,
14,
1745,
14,
1733,
5571,
4625,
4582,
16,
401,
756,
12,
1343,
9,
267,
340,
1568,
690,
378,
26,
288,
291,
14,
815,
480,
3110,
26,
450,
83,
2,
450,
291,
14,
1745,
14,
739,
5571,
8,
928,
12,
1568,
430,
288,
1995,
2624,
8,
277,
12,
298,
1531,
401,
1568,
12,
6202,
17115,
16,
358,
267,
1995,
13480,
5571,
8,
277,
12,
298,
5329,
401,
334,
277,
423,
890,
501,
24,
7216,
890,
9,
199,
199,
533,
603,
9897,
13107,
56,
4942,
8,
23532,
304,
272,
2955,
63,
890,
275,
3193,
10,
708,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
367,
1478,
315,
4945,
8,
975,
304,
288,
1995,
5817,
8,
277,
12,
298,
1531,
31346,
199,
199,
533,
603,
9897,
58,
2483,
4942,
8,
23532,
304,
272,
2955,
63,
890,
275,
7960,
10,
708,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
367,
1478,
315,
4945,
8,
3933,
304,
288,
1995,
5817,
8,
277,
12,
298,
1531,
31346,
199,
199,
318,
2198,
45,
9897,
2028,
8,
2087,
304,
272,
1995,
603,
9897,
2204,
8,
2087,
12,
298,
26859,
63,
548,
531,
272,
1995,
603,
9897,
13107,
56,
4942,
8,
2087,
12,
298,
7646,
88,
63,
832,
531,
272,
1995,
603,
9897,
58,
2483,
4942,
8,
2087,
12,
298,
90,
2154,
63,
832,
531,
199,
199,
318,
2198,
5358,
5268,
8,
2087,
304,
272,
1568,
275,
1798,
905,
1457,
63,
890,
4140,
585,
501,
20,
272,
340,
1568,
690,
378,
26,
267,
1995,
8307,
3646,
8,
2087,
12,
298,
1751,
401,
1568,
12,
10666,
708,
12,
298,
13979,
63,
2718,
531,
199,
199,
318,
2198,
17420,
34,
5915,
8,
2087,
304,
272,
1568,
275,
1798,
905,
1457,
63,
890,
4140,
585,
501,
20,
272,
340,
1568,
690,
378,
26,
267,
1995,
8307,
3646,
8,
2087,
12,
298,
13020,
83,
401,
1568,
12,
10666,
708,
12,
298,
7877,
531,
199,
199,
533,
428,
1034,
18854,
5061,
2354,
8,
23532,
304,
272,
2955,
63,
890,
275,
7960,
10,
24,
272,
347,
24828,
8,
277,
304,
267,
1995,
1318,
2461,
8,
13304,
708,
8,
277,
12,
298,
2718,
63,
344,
17,
1288,
20379,
9,
267,
1995,
1318,
2461,
8,
13304,
708,
8,
277,
12,
298,
2718,
63,
344,
18,
1288,
20379,
9,
267,
1995,
10666,
708,
8,
277,
12,
298,
1210,
63,
9492,
531,
267,
1995,
10666,
708,
8,
277,
12,
298,
1199,
63,
9492,
531,
267,
1995,
8307,
3646,
8,
277,
12,
298,
9492,
63,
815,
401,
841,
12,
10666,
708,
12,
298,
10421,
531,
267,
1995,
2624,
8,
277,
12,
298,
354,
401,
4337,
12,
6202,
17115,
16,
358,
267,
1995,
2624,
8,
277,
12,
298,
9259,
63,
354,
401,
5049,
12,
4328,
628,
17286,
577,
4464,
536,
401,
6202,
17115,
16,
358,
199,
199,
533,
11177,
1451,
8,
23532,
304,
272,
347,
636,
826,
721,
277,
12,
1676,
12,
536,
12,
4328,
29,
403,
304,
267,
5024,
1084,
855,
826,
721,
277,
12,
1676,
12,
536,
12,
4328,
9,
267,
291,
423,
890,
275,
334,
20,
11,
277,
905,
890,
4140,
585,
3342,
24,
339,
347,
24828,
8,
277,
304,
267,
1995,
10666,
708,
8,
277,
12,
298,
890,
531,
267,
1568,
275,
291,
905,
890,
4140,
585,
267,
340,
1568,
26,
288,
1995,
13480,
5571,
8,
277,
12,
298,
576,
401,
1568,
9,
199,
199,
533,
1323,
19173,
1451,
8,
23532,
304,
272,
347,
636,
826,
721,
277,
12,
1676,
12,
536,
12,
4328,
29,
403,
304,
267,
5024,
1084,
855,
826,
721,
277,
12,
1676,
12,
536,
12,
4328,
9,
267,
291,
423,
890,
275,
334,
20,
11,
277,
905,
890,
4140,
585,
3342,
24,
339,
347,
24828,
8,
277,
304,
267,
1995,
10666,
708,
8,
277,
12,
298,
890,
531,
267,
1830,
440,
291,
14,
11670,
26,
288,
1995,
10666,
708,
8,
277,
12,
298,
4211,
531,
288,
340,
291,
905,
4211,
4140,
585,
508,
283,
36,
6524,
52,
356,
355,
1995,
11140,
708,
8,
277,
12,
298,
10481,
63,
6884,
531,
288,
916,
291,
905,
4211,
4140,
585,
508,
283,
48,
25797,
356,
355,
1995,
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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
] |
adit-chandra/tensorflow
|
tensorflow/lite/experimental/micro/examples/micro_speech/apollo3/compare_1k.py
|
11
|
5011
|
# Copyright 2018 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.
# ==============================================================================
"""Debugging script for checking calculation values."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import struct
import matplotlib.pyplot as plt
import numpy as np
# import soundfile as sf
def new_data_to_array(fn, datatype='int16'):
"""Converts file information to an in-memory array."""
vals = []
with open(fn) as f:
for n, line in enumerate(f):
if n != 0:
vals.extend([int(v, 16) for v in line.split()])
b = ''.join(map(chr, vals))
if datatype == 'int8':
typestr = 'b'
arraylen = int(len(b))
elif datatype == 'int16':
typestr = 'h'
arraylen = int(len(b) // 2)
elif datatype == 'int32':
typestr = 'i'
arraylen = int(len(b) // 4)
if datatype == 'uint8':
typestr = 'B'
arraylen = int(len(b))
elif datatype == 'uint16':
typestr = 'H'
arraylen = int(len(b) // 2)
elif datatype == 'uint32':
typestr = 'I'
arraylen = int(len(b) // 4)
y = np.array(struct.unpack('<' + typestr * arraylen, b))
return y
# x is the fixed-point input in Qm.n format
def to_float(x, n):
return x.astype(float) * 2**(-n)
micro_windowed_input = new_data_to_array(
'micro_windowed_input.txt', datatype='int32')
cmsis_windowed_input = new_data_to_array(
'cmsis_windowed_input.txt', datatype='int16')
micro_dft = new_data_to_array('micro_dft.txt', datatype='int32')
cmsis_dft = new_data_to_array('cmsis_dft.txt', datatype='int16')
py_dft = np.fft.rfft(to_float(cmsis_windowed_input, 15), n=512)
py_result = np.empty((2 * py_dft.size), dtype=np.float)
py_result[0::2] = np.real(py_dft)
py_result[1::2] = np.imag(py_dft)
micro_power = new_data_to_array('micro_power.txt', datatype='int32')
cmsis_power = new_data_to_array('cmsis_power.txt', datatype='int16')
py_power = np.square(np.abs(py_dft))
micro_power_avg = new_data_to_array('micro_power_avg.txt', datatype='uint8')
cmsis_power_avg = new_data_to_array('cmsis_power_avg.txt', datatype='uint8')
plt.figure(1)
plt.subplot(311)
plt.plot(micro_windowed_input, label='Micro fixed')
plt.legend()
plt.subplot(312)
plt.plot(cmsis_windowed_input, label='CMSIS fixed')
plt.legend()
plt.subplot(313)
plt.plot(to_float(micro_windowed_input, 30), label='Micro to float')
plt.plot(to_float(cmsis_windowed_input, 15), label='CMSIS to float')
plt.legend()
plt.figure(2)
plt.subplot(311)
plt.plot(micro_dft, label='Micro fixed')
plt.legend()
plt.subplot(312)
plt.plot(cmsis_dft, label='CMSIS fixed')
plt.legend()
plt.subplot(313)
plt.plot(to_float(micro_dft, 22), label='Micro to float')
# CMSIS result has 6 fractionanl bits (not 7) due to documentation error (see
# README.md)
plt.plot(to_float(cmsis_dft, 6), label='CMSIS to float')
plt.plot(py_result, label='Python result')
plt.legend()
plt.figure(3)
plt.subplot(311)
plt.plot(micro_power, label='Micro fixed')
plt.legend()
plt.subplot(312)
plt.plot(cmsis_power[0:256], label='CMSIS fixed')
plt.legend()
plt.subplot(313)
plt.plot(to_float(micro_power, 22), label='Micro to float')
plt.plot(to_float(cmsis_power[0:256], 6), label='CMSIS to float')
plt.plot(py_power, label='Python result')
plt.legend()
plt.figure(4)
plt.plot(micro_power_avg, label='Micro fixed')
plt.plot(cmsis_power_avg, label='CMSIS fixed')
plt.legend()
plt.show()
# t = np.arange(16000.*0.03)/16000.
# # Factor of 10 because micro preprocessing overflows otherwise
# sin1k = 0.1*np.sin(2*np.pi*1000*t)
#
# plt.figure(1)
# plt.subplot(511)
# plt.plot(sin1k)
# plt.title('Input sine')
#
# plt.subplot(512)
# plt.plot(to_float(micro_windowed_input, 30), label='Micro-Lite')
# plt.plot(to_float(cmsis_windowed_input, 15), label='CMSIS')
# plt.title('Windowed sine')
# plt.legend(loc='center right')
#
# plt.subplot(513)
# plt.plot(to_float(micro_dft, 22), label='Micro-Lite')
# plt.plot(to_float(cmsis_dft, 6), label='CMSIS')
# plt.title('FFT')
# plt.legend(loc='center')
#
# plt.subplot(514)
# plt.plot(to_float(micro_power, 22), label='Micro-Lite')
# plt.plot(to_float(cmsis_power[0:256], 6), label='CMSIS')
# plt.title('|FFT|^2')
# plt.legend(loc='center right')
#
# plt.subplot(515)
# plt.plot(micro_power_avg, label='Micro-Lite')
# plt.plot(cmsis_power_avg, label='CMSIS')
# plt.title('Averaged |FFT|^2')
# plt.legend(loc='center right')
#
# plt.tight_layout(pad=0, w_pad=0.2, h_pad=0.2)
#
# plt.show()
#
|
apache-2.0
|
[
3,
1898,
14894,
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,
7084,
1540,
2884,
367,
7907,
15232,
1338,
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,
2702,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
2680,
465,
980,
199,
199,
3,
492,
20453,
493,
465,
13330,
421,
199,
318,
892,
63,
576,
63,
475,
63,
1144,
8,
2324,
12,
16048,
534,
442,
975,
735,
523,
408,
17729,
570,
2556,
370,
376,
315,
13,
4844,
1625,
1041,
523,
5322,
275,
942,
523,
543,
1551,
8,
2324,
9,
465,
289,
26,
272,
367,
302,
12,
1004,
315,
3874,
8,
70,
304,
489,
340,
302,
1137,
378,
26,
267,
5322,
14,
2880,
779,
442,
8,
86,
12,
3193,
9,
367,
373,
315,
1004,
14,
1294,
9383,
523,
330,
275,
6522,
904,
8,
1130,
8,
10194,
12,
5322,
430,
819,
340,
16048,
508,
283,
442,
24,
356,
272,
730,
495,
275,
283,
66,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
430,
523,
916,
16048,
508,
283,
442,
975,
356,
272,
730,
495,
275,
283,
72,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
9,
5001,
499,
9,
523,
916,
16048,
508,
283,
442,
708,
356,
272,
730,
495,
275,
283,
73,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
9,
5001,
841,
9,
523,
340,
16048,
508,
283,
1635,
24,
356,
272,
730,
495,
275,
283,
34,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
430,
523,
916,
16048,
508,
283,
1635,
975,
356,
272,
730,
495,
275,
283,
40,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
9,
5001,
499,
9,
523,
916,
16048,
508,
283,
1635,
708,
356,
272,
730,
495,
275,
283,
41,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
9,
5001,
841,
9,
819,
612,
275,
980,
14,
1144,
8,
1820,
14,
5301,
4827,
7,
435,
730,
495,
627,
1625,
552,
12,
330,
430,
819,
372,
612,
421,
199,
3,
671,
365,
314,
6317,
13,
1403,
1324,
315,
1413,
77,
14,
78,
1475,
199,
318,
370,
63,
1609,
8,
88,
12,
302,
304,
523,
372,
671,
14,
6041,
8,
1609,
9,
627,
499,
31339,
78,
9,
421,
199,
6453,
63,
3806,
379,
63,
1210,
275,
892,
63,
576,
63,
475,
63,
1144,
8,
272,
283,
6453,
63,
3806,
379,
63,
1210,
14,
2424,
297,
16048,
534,
442,
708,
358,
199,
4400,
2316,
63,
3806,
379,
63,
1210,
275,
892,
63,
576,
63,
475,
63,
1144,
8,
272,
283,
4400,
2316,
63,
3806,
379,
63,
1210,
14,
2424,
297,
16048,
534,
442,
975,
358,
199,
199,
6453,
63,
68,
856,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
6453,
63,
68,
856,
14,
2424,
297,
16048,
534,
442,
708,
358,
199,
4400,
2316,
63,
68,
856,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
4400,
2316,
63,
68,
856,
14,
2424,
297,
16048,
534,
442,
975,
358,
199,
647,
63,
68,
856,
275,
980,
14,
9996,
14,
82,
9996,
8,
475,
63,
1609,
8,
4400,
2316,
63,
3806,
379,
63,
1210,
12,
4114,
395,
302,
29,
7736,
9,
199,
647,
63,
1099,
275,
980,
14,
1667,
1332,
18,
627,
1134,
63,
68,
856,
14,
890,
395,
2152,
29,
1590,
14,
1609,
9,
199,
647,
63,
1099,
59,
16,
447,
18,
61,
275,
980,
14,
3093,
8,
647,
63,
68,
856,
9,
199,
647,
63,
1099,
59,
17,
447,
18,
61,
275,
980,
14,
14688,
8,
647,
63,
68,
856,
9,
199,
199,
6453,
63,
5652,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
6453,
63,
5652,
14,
2424,
297,
16048,
534,
442,
708,
358,
199,
4400,
2316,
63,
5652,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
4400,
2316,
63,
5652,
14,
2424,
297,
16048,
534,
442,
975,
358,
199,
647,
63,
5652,
275,
980,
14,
9646,
8,
1590,
14,
2101,
8,
647,
63,
68,
856,
430,
199,
199,
6453,
63,
5652,
63,
8595,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
6453,
63,
5652,
63,
8595,
14,
2424,
297,
16048,
534,
1635,
24,
358,
199,
4400,
2316,
63,
5652,
63,
8595,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
4400,
2316,
63,
5652,
63,
8595,
14,
2424,
297,
16048,
534,
1635,
24,
358,
199,
199,
6003,
14,
8941,
8,
17,
9,
199,
6003,
14,
13334,
8,
17539,
9,
199,
6003,
14,
2798,
8,
6453,
63,
3806,
379,
63,
1210,
12,
1768,
534,
23990,
6317,
358,
199,
6003,
14,
10231,
342,
199,
6003,
14,
13334,
8,
16683,
9,
199,
6003,
14,
2798,
8,
4400,
2316,
63,
3806,
379,
63,
1210,
12,
1768,
534,
17834,
1311,
6317,
358,
199,
6003,
14,
10231,
342,
199,
6003,
14,
13334,
8,
19455,
9,
199,
6003,
14,
2798,
8,
475,
63,
1609,
8,
6453,
63,
3806,
379,
63,
1210,
12,
4233,
395,
1768,
534,
23990,
370,
2069,
358,
199,
6003,
14,
2798,
8,
475,
63,
1609,
8,
4400,
2316,
63,
3806,
379,
63,
1210,
12,
4114,
395,
1768,
534,
17834,
1311,
370,
2069,
358,
199,
6003,
14,
10231,
342,
199,
199,
6003,
14,
8941,
8,
18,
9,
199,
6003,
14,
13334,
8,
17539,
9,
199,
6003,
14,
2798,
8,
6453,
63,
68,
856,
12,
1768,
534,
23990,
6317,
358,
199,
6003
] |
[
1898,
14894,
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,
7084,
1540,
2884,
367,
7907,
15232,
1338,
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,
2702,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
2680,
465,
980,
199,
199,
3,
492,
20453,
493,
465,
13330,
421,
199,
318,
892,
63,
576,
63,
475,
63,
1144,
8,
2324,
12,
16048,
534,
442,
975,
735,
523,
408,
17729,
570,
2556,
370,
376,
315,
13,
4844,
1625,
1041,
523,
5322,
275,
942,
523,
543,
1551,
8,
2324,
9,
465,
289,
26,
272,
367,
302,
12,
1004,
315,
3874,
8,
70,
304,
489,
340,
302,
1137,
378,
26,
267,
5322,
14,
2880,
779,
442,
8,
86,
12,
3193,
9,
367,
373,
315,
1004,
14,
1294,
9383,
523,
330,
275,
6522,
904,
8,
1130,
8,
10194,
12,
5322,
430,
819,
340,
16048,
508,
283,
442,
24,
356,
272,
730,
495,
275,
283,
66,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
430,
523,
916,
16048,
508,
283,
442,
975,
356,
272,
730,
495,
275,
283,
72,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
9,
5001,
499,
9,
523,
916,
16048,
508,
283,
442,
708,
356,
272,
730,
495,
275,
283,
73,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
9,
5001,
841,
9,
523,
340,
16048,
508,
283,
1635,
24,
356,
272,
730,
495,
275,
283,
34,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
430,
523,
916,
16048,
508,
283,
1635,
975,
356,
272,
730,
495,
275,
283,
40,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
9,
5001,
499,
9,
523,
916,
16048,
508,
283,
1635,
708,
356,
272,
730,
495,
275,
283,
41,
7,
272,
1625,
552,
275,
1109,
8,
552,
8,
66,
9,
5001,
841,
9,
819,
612,
275,
980,
14,
1144,
8,
1820,
14,
5301,
4827,
7,
435,
730,
495,
627,
1625,
552,
12,
330,
430,
819,
372,
612,
421,
199,
3,
671,
365,
314,
6317,
13,
1403,
1324,
315,
1413,
77,
14,
78,
1475,
199,
318,
370,
63,
1609,
8,
88,
12,
302,
304,
523,
372,
671,
14,
6041,
8,
1609,
9,
627,
499,
31339,
78,
9,
421,
199,
6453,
63,
3806,
379,
63,
1210,
275,
892,
63,
576,
63,
475,
63,
1144,
8,
272,
283,
6453,
63,
3806,
379,
63,
1210,
14,
2424,
297,
16048,
534,
442,
708,
358,
199,
4400,
2316,
63,
3806,
379,
63,
1210,
275,
892,
63,
576,
63,
475,
63,
1144,
8,
272,
283,
4400,
2316,
63,
3806,
379,
63,
1210,
14,
2424,
297,
16048,
534,
442,
975,
358,
199,
199,
6453,
63,
68,
856,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
6453,
63,
68,
856,
14,
2424,
297,
16048,
534,
442,
708,
358,
199,
4400,
2316,
63,
68,
856,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
4400,
2316,
63,
68,
856,
14,
2424,
297,
16048,
534,
442,
975,
358,
199,
647,
63,
68,
856,
275,
980,
14,
9996,
14,
82,
9996,
8,
475,
63,
1609,
8,
4400,
2316,
63,
3806,
379,
63,
1210,
12,
4114,
395,
302,
29,
7736,
9,
199,
647,
63,
1099,
275,
980,
14,
1667,
1332,
18,
627,
1134,
63,
68,
856,
14,
890,
395,
2152,
29,
1590,
14,
1609,
9,
199,
647,
63,
1099,
59,
16,
447,
18,
61,
275,
980,
14,
3093,
8,
647,
63,
68,
856,
9,
199,
647,
63,
1099,
59,
17,
447,
18,
61,
275,
980,
14,
14688,
8,
647,
63,
68,
856,
9,
199,
199,
6453,
63,
5652,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
6453,
63,
5652,
14,
2424,
297,
16048,
534,
442,
708,
358,
199,
4400,
2316,
63,
5652,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
4400,
2316,
63,
5652,
14,
2424,
297,
16048,
534,
442,
975,
358,
199,
647,
63,
5652,
275,
980,
14,
9646,
8,
1590,
14,
2101,
8,
647,
63,
68,
856,
430,
199,
199,
6453,
63,
5652,
63,
8595,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
6453,
63,
5652,
63,
8595,
14,
2424,
297,
16048,
534,
1635,
24,
358,
199,
4400,
2316,
63,
5652,
63,
8595,
275,
892,
63,
576,
63,
475,
63,
1144,
360,
4400,
2316,
63,
5652,
63,
8595,
14,
2424,
297,
16048,
534,
1635,
24,
358,
199,
199,
6003,
14,
8941,
8,
17,
9,
199,
6003,
14,
13334,
8,
17539,
9,
199,
6003,
14,
2798,
8,
6453,
63,
3806,
379,
63,
1210,
12,
1768,
534,
23990,
6317,
358,
199,
6003,
14,
10231,
342,
199,
6003,
14,
13334,
8,
16683,
9,
199,
6003,
14,
2798,
8,
4400,
2316,
63,
3806,
379,
63,
1210,
12,
1768,
534,
17834,
1311,
6317,
358,
199,
6003,
14,
10231,
342,
199,
6003,
14,
13334,
8,
19455,
9,
199,
6003,
14,
2798,
8,
475,
63,
1609,
8,
6453,
63,
3806,
379,
63,
1210,
12,
4233,
395,
1768,
534,
23990,
370,
2069,
358,
199,
6003,
14,
2798,
8,
475,
63,
1609,
8,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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
costypetrisor/scikit-learn
|
sklearn/gaussian_process/tests/test_gaussian_process.py
|
267
|
6813
|
"""
Testing for Gaussian Process module (sklearn.gaussian_process)
"""
# Author: Vincent Dubourg <vincent.dubourg@gmail.com>
# Licence: BSD 3 clause
from nose.tools import raises
from nose.tools import assert_true
import numpy as np
from sklearn.gaussian_process import GaussianProcess
from sklearn.gaussian_process import regression_models as regression
from sklearn.gaussian_process import correlation_models as correlation
from sklearn.datasets import make_regression
from sklearn.utils.testing import assert_greater
f = lambda x: x * np.sin(x)
X = np.atleast_2d([1., 3., 5., 6., 7., 8.]).T
X2 = np.atleast_2d([2., 4., 5.5, 6.5, 7.5]).T
y = f(X).ravel()
def test_1d(regr=regression.constant, corr=correlation.squared_exponential,
random_start=10, beta0=None):
# MLE estimation of a one-dimensional Gaussian Process model.
# Check random start optimization.
# Test the interpolating property.
gp = GaussianProcess(regr=regr, corr=corr, beta0=beta0,
theta0=1e-2, thetaL=1e-4, thetaU=1e-1,
random_start=random_start, verbose=False).fit(X, y)
y_pred, MSE = gp.predict(X, eval_MSE=True)
y2_pred, MSE2 = gp.predict(X2, eval_MSE=True)
assert_true(np.allclose(y_pred, y) and np.allclose(MSE, 0.)
and np.allclose(MSE2, 0., atol=10))
def test_2d(regr=regression.constant, corr=correlation.squared_exponential,
random_start=10, beta0=None):
# MLE estimation of a two-dimensional Gaussian Process model accounting for
# anisotropy. Check random start optimization.
# Test the interpolating property.
b, kappa, e = 5., .5, .1
g = lambda x: b - x[:, 1] - kappa * (x[:, 0] - e) ** 2.
X = np.array([[-4.61611719, -6.00099547],
[4.10469096, 5.32782448],
[0.00000000, -0.50000000],
[-6.17289014, -4.6984743],
[1.3109306, -6.93271427],
[-5.03823144, 3.10584743],
[-2.87600388, 6.74310541],
[5.21301203, 4.26386883]])
y = g(X).ravel()
thetaL = [1e-4] * 2
thetaU = [1e-1] * 2
gp = GaussianProcess(regr=regr, corr=corr, beta0=beta0,
theta0=[1e-2] * 2, thetaL=thetaL,
thetaU=thetaU,
random_start=random_start, verbose=False)
gp.fit(X, y)
y_pred, MSE = gp.predict(X, eval_MSE=True)
assert_true(np.allclose(y_pred, y) and np.allclose(MSE, 0.))
eps = np.finfo(gp.theta_.dtype).eps
assert_true(np.all(gp.theta_ >= thetaL - eps)) # Lower bounds of hyperparameters
assert_true(np.all(gp.theta_ <= thetaU + eps)) # Upper bounds of hyperparameters
def test_2d_2d(regr=regression.constant, corr=correlation.squared_exponential,
random_start=10, beta0=None):
# MLE estimation of a two-dimensional Gaussian Process model accounting for
# anisotropy. Check random start optimization.
# Test the GP interpolation for 2D output
b, kappa, e = 5., .5, .1
g = lambda x: b - x[:, 1] - kappa * (x[:, 0] - e) ** 2.
f = lambda x: np.vstack((g(x), g(x))).T
X = np.array([[-4.61611719, -6.00099547],
[4.10469096, 5.32782448],
[0.00000000, -0.50000000],
[-6.17289014, -4.6984743],
[1.3109306, -6.93271427],
[-5.03823144, 3.10584743],
[-2.87600388, 6.74310541],
[5.21301203, 4.26386883]])
y = f(X)
gp = GaussianProcess(regr=regr, corr=corr, beta0=beta0,
theta0=[1e-2] * 2, thetaL=[1e-4] * 2,
thetaU=[1e-1] * 2,
random_start=random_start, verbose=False)
gp.fit(X, y)
y_pred, MSE = gp.predict(X, eval_MSE=True)
assert_true(np.allclose(y_pred, y) and np.allclose(MSE, 0.))
@raises(ValueError)
def test_wrong_number_of_outputs():
gp = GaussianProcess()
gp.fit([[1, 2, 3], [4, 5, 6]], [1, 2, 3])
def test_more_builtin_correlation_models(random_start=1):
# Repeat test_1d and test_2d for several built-in correlation
# models specified as strings.
all_corr = ['absolute_exponential', 'squared_exponential', 'cubic',
'linear']
for corr in all_corr:
test_1d(regr='constant', corr=corr, random_start=random_start)
test_2d(regr='constant', corr=corr, random_start=random_start)
test_2d_2d(regr='constant', corr=corr, random_start=random_start)
def test_ordinary_kriging():
# Repeat test_1d and test_2d with given regression weights (beta0) for
# different regression models (Ordinary Kriging).
test_1d(regr='linear', beta0=[0., 0.5])
test_1d(regr='quadratic', beta0=[0., 0.5, 0.5])
test_2d(regr='linear', beta0=[0., 0.5, 0.5])
test_2d(regr='quadratic', beta0=[0., 0.5, 0.5, 0.5, 0.5, 0.5])
test_2d_2d(regr='linear', beta0=[0., 0.5, 0.5])
test_2d_2d(regr='quadratic', beta0=[0., 0.5, 0.5, 0.5, 0.5, 0.5])
def test_no_normalize():
gp = GaussianProcess(normalize=False).fit(X, y)
y_pred = gp.predict(X)
assert_true(np.allclose(y_pred, y))
def test_random_starts():
# Test that an increasing number of random-starts of GP fitting only
# increases the reduced likelihood function of the optimal theta.
n_samples, n_features = 50, 3
np.random.seed(0)
rng = np.random.RandomState(0)
X = rng.randn(n_samples, n_features) * 2 - 1
y = np.sin(X).sum(axis=1) + np.sin(3 * X).sum(axis=1)
best_likelihood = -np.inf
for random_start in range(1, 5):
gp = GaussianProcess(regr="constant", corr="squared_exponential",
theta0=[1e-0] * n_features,
thetaL=[1e-4] * n_features,
thetaU=[1e+1] * n_features,
random_start=random_start, random_state=0,
verbose=False).fit(X, y)
rlf = gp.reduced_likelihood_function()[0]
assert_greater(rlf, best_likelihood - np.finfo(np.float32).eps)
best_likelihood = rlf
def test_mse_solving():
# test the MSE estimate to be sane.
# non-regression test for ignoring off-diagonals of feature covariance,
# testing with nugget that renders covariance useless, only
# using the mean function, with low effective rank of data
gp = GaussianProcess(corr='absolute_exponential', theta0=1e-4,
thetaL=1e-12, thetaU=1e-2, nugget=1e-2,
optimizer='Welch', regr="linear", random_state=0)
X, y = make_regression(n_informative=3, n_features=60, noise=50,
random_state=0, effective_rank=1)
gp.fit(X, y)
assert_greater(1000, gp.predict(X, eval_MSE=True)[1].mean())
|
bsd-3-clause
|
[
624,
199,
9029,
367,
17131,
7132,
859,
334,
27993,
14,
22911,
63,
1412,
9,
199,
624,
199,
199,
3,
6529,
26,
28882,
2946,
577,
456,
567,
71,
665,
11908,
2946,
14,
68,
456,
567,
71,
32,
6799,
14,
957,
30,
199,
3,
491,
530,
4894,
26,
6289,
650,
8502,
199,
199,
504,
11354,
14,
2537,
492,
6534,
199,
504,
11354,
14,
2537,
492,
702,
63,
2052,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
6357,
14,
22911,
63,
1412,
492,
17131,
3498,
199,
504,
6357,
14,
22911,
63,
1412,
492,
10864,
63,
992,
465,
10864,
199,
504,
6357,
14,
22911,
63,
1412,
492,
21280,
63,
992,
465,
21280,
199,
504,
6357,
14,
12281,
492,
1852,
63,
12513,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
13154,
421,
199,
70,
275,
2400,
671,
26,
671,
627,
980,
14,
5911,
8,
88,
9,
199,
56,
275,
980,
14,
22900,
63,
18,
68,
779,
17,
2020,
650,
2020,
959,
2020,
1227,
2020,
1520,
2020,
1695,
14,
6575,
52,
199,
56,
18,
275,
980,
14,
22900,
63,
18,
68,
779,
18,
2020,
841,
2020,
959,
14,
21,
12,
1227,
14,
21,
12,
1520,
14,
21,
6575,
52,
199,
89,
275,
289,
8,
56,
680,
11186,
342,
421,
199,
318,
511,
63,
17,
68,
8,
1135,
82,
29,
12513,
14,
4083,
12,
25948,
29,
26487,
14,
12973,
63,
27093,
12,
288,
2196,
63,
928,
29,
709,
12,
8201,
16,
29,
403,
304,
272,
327,
603,
906,
27156,
402,
282,
1373,
13,
13014,
17131,
7132,
1402,
14,
272,
327,
2670,
2196,
1343,
13712,
14,
272,
327,
1379,
314,
23005,
1958,
3324,
14,
272,
15852,
275,
17131,
3498,
8,
1135,
82,
29,
1135,
82,
12,
25948,
29,
16742,
12,
8201,
16,
29,
5683,
16,
12,
586,
12724,
16,
29,
17,
69,
13,
18,
12,
12724,
44,
29,
17,
69,
13,
20,
12,
12724,
53,
29,
17,
69,
13,
17,
12,
586,
2196,
63,
928,
29,
2355,
63,
928,
12,
3376,
29,
797,
680,
3269,
8,
56,
12,
612,
9,
272,
612,
63,
5991,
12,
603,
899,
275,
15852,
14,
6892,
8,
56,
12,
3468,
63,
45,
899,
29,
549,
9,
272,
612,
18,
63,
5991,
12,
603,
899,
18,
275,
15852,
14,
6892,
8,
56,
18,
12,
3468,
63,
45,
899,
29,
549,
9,
339,
702,
63,
2052,
8,
1590,
14,
7520,
8,
89,
63,
5991,
12,
612,
9,
436,
980,
14,
7520,
8,
45,
899,
12,
378,
4959,
355,
436,
980,
14,
7520,
8,
45,
899,
18,
12,
378,
2020,
9543,
29,
709,
430,
421,
199,
318,
511,
63,
18,
68,
8,
1135,
82,
29,
12513,
14,
4083,
12,
25948,
29,
26487,
14,
12973,
63,
27093,
12,
288,
2196,
63,
928,
29,
709,
12,
8201,
16,
29,
403,
304,
272,
327,
603,
906,
27156,
402,
282,
2877,
13,
13014,
17131,
7132,
1402,
24772,
367,
272,
327,
376,
374,
357,
7537,
14,
2670,
2196,
1343,
13712,
14,
272,
327,
1379,
314,
23005,
1958,
3324,
14,
272,
330,
12,
1022,
15999,
12,
325,
275,
959,
2020,
1275,
21,
12,
1275,
17,
272,
486,
275,
2400,
671,
26,
330,
446,
671,
3981,
413,
61,
446,
1022,
15999,
627,
334,
88,
3981,
378,
61,
446,
325,
9,
1011,
499,
14,
272,
1323,
275,
980,
14,
1144,
22844,
20,
14,
26666,
7362,
1167,
12,
446,
22,
14,
1493,
1020,
16710,
467,
2116,
359,
20,
14,
6785,
1876,
9211,
12,
959,
14,
708,
2277,
1194,
2006,
467,
2116,
359,
16,
14,
3607,
12,
446,
16,
14,
21,
9084,
467,
2116,
5243,
22,
14,
10419,
1407,
10752,
12,
446,
20,
14,
1876,
1349,
21712,
467,
2116,
359,
17,
14,
19,
6996,
11363,
12,
446,
22,
14,
25,
11754,
1079,
1465,
467,
2116,
5243,
21,
14,
14273,
1789,
9862,
12,
650,
14,
7320,
1349,
21712,
467,
2116,
5243,
18,
14,
1555,
6683,
11403,
12,
1227,
14,
1342,
18035,
21278,
467,
2116,
359,
21,
14,
18,
10067,
11341,
12,
841,
14,
1479,
8040,
16456,
3934,
272,
612,
275,
486,
8,
56,
680,
11186,
342,
339,
12724,
44,
275,
359,
17,
69,
13,
20,
61,
627,
499,
272,
12724,
53,
275,
359,
17,
69,
13,
17,
61,
627,
499,
272,
15852,
275,
17131,
3498,
8,
1135,
82,
29,
1135,
82,
12,
25948,
29,
16742,
12,
8201,
16,
29,
5683,
16,
12,
586,
12724,
16,
1524,
17,
69,
13,
18,
61,
627,
499,
12,
12724,
44,
29,
9337,
44,
12,
586,
12724,
53,
29,
9337,
53,
12,
586,
2196,
63,
928,
29,
2355,
63,
928,
12,
3376,
29,
797,
9,
272,
15852,
14,
3269,
8,
56,
12,
612,
9,
272,
612,
63,
5991,
12,
603,
899,
275,
15852,
14,
6892,
8,
56,
12,
3468,
63,
45,
899,
29,
549,
9,
339,
702,
63,
2052,
8,
1590,
14,
7520,
8,
89,
63,
5991,
12,
612,
9,
436,
980,
14,
7520,
8,
45,
899,
12,
378,
26273,
339,
10245,
275,
980,
14,
23087,
8,
4927,
14,
9337,
3754,
2271,
680,
8277,
272,
702,
63,
2052,
8,
1590,
14,
452,
8,
4927,
14,
9337,
63,
2356,
12724,
44,
446,
10245,
430,
221,
327,
29893,
10461,
402,
10342,
3214,
272,
702,
63,
2052,
8,
1590,
14,
452,
8,
4927,
14,
9337,
63,
2695,
12724,
53,
435,
10245,
430,
221,
327,
4949,
529,
10461,
402,
10342,
3214,
421,
199,
318,
511,
63,
18,
68,
63,
18,
68,
8,
1135,
82,
29,
12513,
14,
4083,
12,
25948,
29,
26487,
14,
12973,
63,
27093,
12,
2049,
2196,
63,
928,
29,
709,
12,
8201,
16,
29,
403,
304,
272,
327,
603,
906,
27156,
402,
282,
2877,
13,
13014,
17131,
7132,
1402,
24772,
367,
272,
327,
376,
374,
357,
7537,
14,
2670,
2196,
1343,
13712,
14,
272,
327,
1379,
314,
17346,
14046,
367,
499,
36,
1072,
272,
330,
12,
1022,
15999,
12,
325,
275,
959,
2020,
1275,
21,
12,
1275,
17,
272,
486,
275,
2400,
671,
26,
330,
446,
671,
3981,
413,
61,
446,
1022,
15999,
627,
334,
88,
3981,
378,
61,
446,
325,
9,
1011,
499,
14,
272,
289,
275,
2400,
671,
26,
980,
14,
20221,
1332,
71,
8,
88,
395,
486,
8,
88,
23261,
52,
272,
1323,
275,
980,
14,
1144,
22844,
20,
14,
26666,
7362,
1167,
12,
446,
22,
14,
1493,
1020,
16710,
467
] |
[
199,
9029,
367,
17131,
7132,
859,
334,
27993,
14,
22911,
63,
1412,
9,
199,
624,
199,
199,
3,
6529,
26,
28882,
2946,
577,
456,
567,
71,
665,
11908,
2946,
14,
68,
456,
567,
71,
32,
6799,
14,
957,
30,
199,
3,
491,
530,
4894,
26,
6289,
650,
8502,
199,
199,
504,
11354,
14,
2537,
492,
6534,
199,
504,
11354,
14,
2537,
492,
702,
63,
2052,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
6357,
14,
22911,
63,
1412,
492,
17131,
3498,
199,
504,
6357,
14,
22911,
63,
1412,
492,
10864,
63,
992,
465,
10864,
199,
504,
6357,
14,
22911,
63,
1412,
492,
21280,
63,
992,
465,
21280,
199,
504,
6357,
14,
12281,
492,
1852,
63,
12513,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
13154,
421,
199,
70,
275,
2400,
671,
26,
671,
627,
980,
14,
5911,
8,
88,
9,
199,
56,
275,
980,
14,
22900,
63,
18,
68,
779,
17,
2020,
650,
2020,
959,
2020,
1227,
2020,
1520,
2020,
1695,
14,
6575,
52,
199,
56,
18,
275,
980,
14,
22900,
63,
18,
68,
779,
18,
2020,
841,
2020,
959,
14,
21,
12,
1227,
14,
21,
12,
1520,
14,
21,
6575,
52,
199,
89,
275,
289,
8,
56,
680,
11186,
342,
421,
199,
318,
511,
63,
17,
68,
8,
1135,
82,
29,
12513,
14,
4083,
12,
25948,
29,
26487,
14,
12973,
63,
27093,
12,
288,
2196,
63,
928,
29,
709,
12,
8201,
16,
29,
403,
304,
272,
327,
603,
906,
27156,
402,
282,
1373,
13,
13014,
17131,
7132,
1402,
14,
272,
327,
2670,
2196,
1343,
13712,
14,
272,
327,
1379,
314,
23005,
1958,
3324,
14,
272,
15852,
275,
17131,
3498,
8,
1135,
82,
29,
1135,
82,
12,
25948,
29,
16742,
12,
8201,
16,
29,
5683,
16,
12,
586,
12724,
16,
29,
17,
69,
13,
18,
12,
12724,
44,
29,
17,
69,
13,
20,
12,
12724,
53,
29,
17,
69,
13,
17,
12,
586,
2196,
63,
928,
29,
2355,
63,
928,
12,
3376,
29,
797,
680,
3269,
8,
56,
12,
612,
9,
272,
612,
63,
5991,
12,
603,
899,
275,
15852,
14,
6892,
8,
56,
12,
3468,
63,
45,
899,
29,
549,
9,
272,
612,
18,
63,
5991,
12,
603,
899,
18,
275,
15852,
14,
6892,
8,
56,
18,
12,
3468,
63,
45,
899,
29,
549,
9,
339,
702,
63,
2052,
8,
1590,
14,
7520,
8,
89,
63,
5991,
12,
612,
9,
436,
980,
14,
7520,
8,
45,
899,
12,
378,
4959,
355,
436,
980,
14,
7520,
8,
45,
899,
18,
12,
378,
2020,
9543,
29,
709,
430,
421,
199,
318,
511,
63,
18,
68,
8,
1135,
82,
29,
12513,
14,
4083,
12,
25948,
29,
26487,
14,
12973,
63,
27093,
12,
288,
2196,
63,
928,
29,
709,
12,
8201,
16,
29,
403,
304,
272,
327,
603,
906,
27156,
402,
282,
2877,
13,
13014,
17131,
7132,
1402,
24772,
367,
272,
327,
376,
374,
357,
7537,
14,
2670,
2196,
1343,
13712,
14,
272,
327,
1379,
314,
23005,
1958,
3324,
14,
272,
330,
12,
1022,
15999,
12,
325,
275,
959,
2020,
1275,
21,
12,
1275,
17,
272,
486,
275,
2400,
671,
26,
330,
446,
671,
3981,
413,
61,
446,
1022,
15999,
627,
334,
88,
3981,
378,
61,
446,
325,
9,
1011,
499,
14,
272,
1323,
275,
980,
14,
1144,
22844,
20,
14,
26666,
7362,
1167,
12,
446,
22,
14,
1493,
1020,
16710,
467,
2116,
359,
20,
14,
6785,
1876,
9211,
12,
959,
14,
708,
2277,
1194,
2006,
467,
2116,
359,
16,
14,
3607,
12,
446,
16,
14,
21,
9084,
467,
2116,
5243,
22,
14,
10419,
1407,
10752,
12,
446,
20,
14,
1876,
1349,
21712,
467,
2116,
359,
17,
14,
19,
6996,
11363,
12,
446,
22,
14,
25,
11754,
1079,
1465,
467,
2116,
5243,
21,
14,
14273,
1789,
9862,
12,
650,
14,
7320,
1349,
21712,
467,
2116,
5243,
18,
14,
1555,
6683,
11403,
12,
1227,
14,
1342,
18035,
21278,
467,
2116,
359,
21,
14,
18,
10067,
11341,
12,
841,
14,
1479,
8040,
16456,
3934,
272,
612,
275,
486,
8,
56,
680,
11186,
342,
339,
12724,
44,
275,
359,
17,
69,
13,
20,
61,
627,
499,
272,
12724,
53,
275,
359,
17,
69,
13,
17,
61,
627,
499,
272,
15852,
275,
17131,
3498,
8,
1135,
82,
29,
1135,
82,
12,
25948,
29,
16742,
12,
8201,
16,
29,
5683,
16,
12,
586,
12724,
16,
1524,
17,
69,
13,
18,
61,
627,
499,
12,
12724,
44,
29,
9337,
44,
12,
586,
12724,
53,
29,
9337,
53,
12,
586,
2196,
63,
928,
29,
2355,
63,
928,
12,
3376,
29,
797,
9,
272,
15852,
14,
3269,
8,
56,
12,
612,
9,
272,
612,
63,
5991,
12,
603,
899,
275,
15852,
14,
6892,
8,
56,
12,
3468,
63,
45,
899,
29,
549,
9,
339,
702,
63,
2052,
8,
1590,
14,
7520,
8,
89,
63,
5991,
12,
612,
9,
436,
980,
14,
7520,
8,
45,
899,
12,
378,
26273,
339,
10245,
275,
980,
14,
23087,
8,
4927,
14,
9337,
3754,
2271,
680,
8277,
272,
702,
63,
2052,
8,
1590,
14,
452,
8,
4927,
14,
9337,
63,
2356,
12724,
44,
446,
10245,
430,
221,
327,
29893,
10461,
402,
10342,
3214,
272,
702,
63,
2052,
8,
1590,
14,
452,
8,
4927,
14,
9337,
63,
2695,
12724,
53,
435,
10245,
430,
221,
327,
4949,
529,
10461,
402,
10342,
3214,
421,
199,
318,
511,
63,
18,
68,
63,
18,
68,
8,
1135,
82,
29,
12513,
14,
4083,
12,
25948,
29,
26487,
14,
12973,
63,
27093,
12,
2049,
2196,
63,
928,
29,
709,
12,
8201,
16,
29,
403,
304,
272,
327,
603,
906,
27156,
402,
282,
2877,
13,
13014,
17131,
7132,
1402,
24772,
367,
272,
327,
376,
374,
357,
7537,
14,
2670,
2196,
1343,
13712,
14,
272,
327,
1379,
314,
17346,
14046,
367,
499,
36,
1072,
272,
330,
12,
1022,
15999,
12,
325,
275,
959,
2020,
1275,
21,
12,
1275,
17,
272,
486,
275,
2400,
671,
26,
330,
446,
671,
3981,
413,
61,
446,
1022,
15999,
627,
334,
88,
3981,
378,
61,
446,
325,
9,
1011,
499,
14,
272,
289,
275,
2400,
671,
26,
980,
14,
20221,
1332,
71,
8,
88,
395,
486,
8,
88,
23261,
52,
272,
1323,
275,
980,
14,
1144,
22844,
20,
14,
26666,
7362,
1167,
12,
446,
22,
14,
1493,
1020,
16710,
467,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
nhippenmeyer/django
|
django/template/backends/base.py
|
584
|
2894
|
# Since this package contains a "django" module, this is required on Python 2.
from __future__ import absolute_import
from django.core.exceptions import (
ImproperlyConfigured, SuspiciousFileOperation,
)
from django.template.utils import get_app_template_dirs
from django.utils._os import safe_join
from django.utils.functional import cached_property
class BaseEngine(object):
# Core methods: engines have to provide their own implementation
# (except for from_string which is optional).
def __init__(self, params):
"""
Initializes the template engine.
Receives the configuration settings as a dict.
"""
params = params.copy()
self.name = params.pop('NAME')
self.dirs = list(params.pop('DIRS'))
self.app_dirs = bool(params.pop('APP_DIRS'))
if params:
raise ImproperlyConfigured(
"Unknown parameters: {}".format(", ".join(params)))
@property
def app_dirname(self):
raise ImproperlyConfigured(
"{} doesn't support loading templates from installed "
"applications.".format(self.__class__.__name__))
def from_string(self, template_code):
"""
Creates and returns a template for the given source code.
This method is optional.
"""
raise NotImplementedError(
"subclasses of BaseEngine should provide "
"a from_string() method")
def get_template(self, template_name):
"""
Loads and returns a template for the given name.
Raises TemplateDoesNotExist if no such template exists.
"""
raise NotImplementedError(
"subclasses of BaseEngine must provide "
"a get_template() method")
# Utility methods: they are provided to minimize code duplication and
# security issues in third-party backends.
@cached_property
def template_dirs(self):
"""
Returns a list of directories to search for templates.
"""
# Immutable return value because it's cached and shared by callers.
template_dirs = tuple(self.dirs)
if self.app_dirs:
template_dirs += get_app_template_dirs(self.app_dirname)
return template_dirs
def iter_template_filenames(self, template_name):
"""
Iterates over candidate files for template_name.
Ignores files that don't lie inside configured template dirs to avoid
directory traversal attacks.
"""
for template_dir in self.template_dirs:
try:
yield safe_join(template_dir, template_name)
except SuspiciousFileOperation:
# The joined path was located outside of this template_dir
# (it might be inside another one, so this isn't fatal).
pass
|
bsd-3-clause
|
[
3,
9336,
642,
2559,
3509,
282,
298,
1176,
2,
859,
12,
642,
365,
1415,
641,
2018,
499,
14,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
334,
272,
11897,
12,
428,
28651,
1173,
6044,
12,
199,
9,
199,
504,
1639,
14,
1160,
14,
1208,
492,
664,
63,
571,
63,
1160,
63,
3220,
199,
504,
1639,
14,
1208,
423,
736,
492,
5048,
63,
904,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
421,
199,
533,
3523,
8524,
8,
785,
304,
339,
327,
11672,
3102,
26,
28156,
1172,
370,
5647,
3932,
5705,
4514,
272,
327,
5185,
334,
2590,
367,
687,
63,
875,
1314,
365,
2716,
680,
339,
347,
636,
826,
721,
277,
12,
1862,
304,
267,
408,
267,
6026,
6491,
314,
1978,
6869,
14,
398,
799,
2375,
397,
314,
2897,
2202,
465,
282,
1211,
14,
267,
408,
267,
1862,
275,
1862,
14,
1574,
342,
267,
291,
14,
354,
275,
1862,
14,
1935,
360,
2339,
358,
267,
291,
14,
3220,
275,
769,
8,
1162,
14,
1935,
360,
14455,
1333,
267,
291,
14,
571,
63,
3220,
275,
2155,
8,
1162,
14,
1935,
360,
7121,
63,
14455,
1333,
267,
340,
1862,
26,
288,
746,
11897,
8,
355,
298,
5912,
2633,
26,
8352,
908,
11854,
3680,
904,
8,
1162,
1724,
339,
768,
1829,
272,
347,
1145,
63,
3475,
8,
277,
304,
267,
746,
11897,
8,
288,
11491,
3181,
1133,
2291,
8697,
7009,
687,
4903,
298,
288,
298,
15853,
15848,
908,
8,
277,
855,
533,
4914,
354,
8964,
339,
347,
687,
63,
875,
8,
277,
12,
1978,
63,
600,
304,
267,
408,
267,
10560,
436,
2529,
282,
1978,
367,
314,
1627,
1350,
1233,
14,
398,
961,
1083,
365,
2716,
14,
267,
408,
267,
746,
4279,
8,
288,
298,
19094,
402,
3523,
8524,
1077,
5647,
298,
288,
298,
65,
687,
63,
875,
342,
1083,
531,
339,
347,
664,
63,
1160,
8,
277,
12,
1978,
63,
354,
304,
267,
408,
267,
30367,
436,
2529,
282,
1978,
367,
314,
1627,
536,
14,
398,
6218,
27193,
340,
949,
4066,
1978,
3495,
14,
267,
408,
267,
746,
4279,
8,
288,
298,
19094,
402,
3523,
8524,
1471,
5647,
298,
288,
298,
65,
664,
63,
1160,
342,
1083,
531,
339,
327,
20511,
3102,
26,
2985,
787,
2741,
370,
24720,
1233,
11866,
1863,
436,
272,
327,
8295,
6391,
10876,
315,
10919,
13,
7522,
14745,
14,
339,
768,
5245,
63,
1829,
272,
347,
1978,
63,
3220,
8,
277,
304,
267,
408,
267,
1803,
282,
769,
402,
6602,
370,
2754,
367,
7009,
14,
267,
408,
267,
327,
25609,
372,
574,
2952,
652,
1159,
6328,
436,
5709,
701,
24194,
14,
267,
1978,
63,
3220,
275,
2008,
8,
277,
14,
3220,
9,
267,
340,
291,
14,
571,
63,
3220,
26,
288,
1978,
63,
3220,
847,
664,
63,
571,
63,
1160,
63,
3220,
8,
277,
14,
571,
63,
3475,
9,
267,
372,
1978,
63,
3220,
339,
347,
2740,
63,
1160,
63,
10309,
8,
277,
12,
1978,
63,
354,
304,
267,
408,
267,
11953,
2335,
1806,
7627,
1584,
367,
1978,
63,
354,
14,
398,
20489,
7944,
1584,
626,
2793,
1133,
1212,
69,
6272,
7526,
1978,
7606,
370,
5126,
267,
2082,
27773,
28140,
14,
267,
408,
267,
367,
1978,
63,
694,
315,
291,
14,
1160,
63,
3220,
26,
288,
862,
26,
355,
1995,
5048,
63,
904,
8,
1160,
63,
694,
12,
1978,
63,
354,
9,
288,
871,
428,
28651,
1173,
6044,
26,
355,
327,
710,
16538,
931,
1990,
16180,
9682,
402,
642,
1978,
63,
694,
355,
327,
334,
390,
5594,
506,
6272,
4573,
1373,
12,
880,
642,
5712,
1133,
14294,
680,
355,
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
] |
[
9336,
642,
2559,
3509,
282,
298,
1176,
2,
859,
12,
642,
365,
1415,
641,
2018,
499,
14,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
334,
272,
11897,
12,
428,
28651,
1173,
6044,
12,
199,
9,
199,
504,
1639,
14,
1160,
14,
1208,
492,
664,
63,
571,
63,
1160,
63,
3220,
199,
504,
1639,
14,
1208,
423,
736,
492,
5048,
63,
904,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
421,
199,
533,
3523,
8524,
8,
785,
304,
339,
327,
11672,
3102,
26,
28156,
1172,
370,
5647,
3932,
5705,
4514,
272,
327,
5185,
334,
2590,
367,
687,
63,
875,
1314,
365,
2716,
680,
339,
347,
636,
826,
721,
277,
12,
1862,
304,
267,
408,
267,
6026,
6491,
314,
1978,
6869,
14,
398,
799,
2375,
397,
314,
2897,
2202,
465,
282,
1211,
14,
267,
408,
267,
1862,
275,
1862,
14,
1574,
342,
267,
291,
14,
354,
275,
1862,
14,
1935,
360,
2339,
358,
267,
291,
14,
3220,
275,
769,
8,
1162,
14,
1935,
360,
14455,
1333,
267,
291,
14,
571,
63,
3220,
275,
2155,
8,
1162,
14,
1935,
360,
7121,
63,
14455,
1333,
267,
340,
1862,
26,
288,
746,
11897,
8,
355,
298,
5912,
2633,
26,
8352,
908,
11854,
3680,
904,
8,
1162,
1724,
339,
768,
1829,
272,
347,
1145,
63,
3475,
8,
277,
304,
267,
746,
11897,
8,
288,
11491,
3181,
1133,
2291,
8697,
7009,
687,
4903,
298,
288,
298,
15853,
15848,
908,
8,
277,
855,
533,
4914,
354,
8964,
339,
347,
687,
63,
875,
8,
277,
12,
1978,
63,
600,
304,
267,
408,
267,
10560,
436,
2529,
282,
1978,
367,
314,
1627,
1350,
1233,
14,
398,
961,
1083,
365,
2716,
14,
267,
408,
267,
746,
4279,
8,
288,
298,
19094,
402,
3523,
8524,
1077,
5647,
298,
288,
298,
65,
687,
63,
875,
342,
1083,
531,
339,
347,
664,
63,
1160,
8,
277,
12,
1978,
63,
354,
304,
267,
408,
267,
30367,
436,
2529,
282,
1978,
367,
314,
1627,
536,
14,
398,
6218,
27193,
340,
949,
4066,
1978,
3495,
14,
267,
408,
267,
746,
4279,
8,
288,
298,
19094,
402,
3523,
8524,
1471,
5647,
298,
288,
298,
65,
664,
63,
1160,
342,
1083,
531,
339,
327,
20511,
3102,
26,
2985,
787,
2741,
370,
24720,
1233,
11866,
1863,
436,
272,
327,
8295,
6391,
10876,
315,
10919,
13,
7522,
14745,
14,
339,
768,
5245,
63,
1829,
272,
347,
1978,
63,
3220,
8,
277,
304,
267,
408,
267,
1803,
282,
769,
402,
6602,
370,
2754,
367,
7009,
14,
267,
408,
267,
327,
25609,
372,
574,
2952,
652,
1159,
6328,
436,
5709,
701,
24194,
14,
267,
1978,
63,
3220,
275,
2008,
8,
277,
14,
3220,
9,
267,
340,
291,
14,
571,
63,
3220,
26,
288,
1978,
63,
3220,
847,
664,
63,
571,
63,
1160,
63,
3220,
8,
277,
14,
571,
63,
3475,
9,
267,
372,
1978,
63,
3220,
339,
347,
2740,
63,
1160,
63,
10309,
8,
277,
12,
1978,
63,
354,
304,
267,
408,
267,
11953,
2335,
1806,
7627,
1584,
367,
1978,
63,
354,
14,
398,
20489,
7944,
1584,
626,
2793,
1133,
1212,
69,
6272,
7526,
1978,
7606,
370,
5126,
267,
2082,
27773,
28140,
14,
267,
408,
267,
367,
1978,
63,
694,
315,
291,
14,
1160,
63,
3220,
26,
288,
862,
26,
355,
1995,
5048,
63,
904,
8,
1160,
63,
694,
12,
1978,
63,
354,
9,
288,
871,
428,
28651,
1173,
6044,
26,
355,
327,
710,
16538,
931,
1990,
16180,
9682,
402,
642,
1978,
63,
694,
355,
327,
334,
390,
5594,
506,
6272,
4573,
1373,
12,
880,
642,
5712,
1133,
14294,
680,
355,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
gerald-yang/ubuntu-iotivity-demo
|
grovepi/pygrovepi/grove_oled/grove_i2c_oled_96x96_hello_world.py
|
9
|
1970
|
#!/usr/bin/env python
#
# GrovePi Example for using the Grove OLED Display 96*96 (http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_1.12%22)
#
# The GrovePi connects the Raspberry Pi and Grove sensors. You can learn more about GrovePi here: http://www.dexterindustries.com/GrovePi
#
# Have a question about this example? Ask on the forums here: http://www.dexterindustries.com/forum/?forum=grovepi
#
'''
## License
The MIT License (MIT)
GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi.
Copyright (C) 2015 Dexter Industries
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.
'''
# Connect the OLED to any I2C port eg. I2C-1
# Can be found at I2C address 0x3c
import grove_oled
import time
grove_oled.oled_init()
grove_oled.oled_clearDisplay()
grove_oled.oled_setNormalDisplay()
grove_oled.oled_setVerticalMode()
time.sleep(.1)
for i in range(0,12):
grove_oled.oled_setTextXY(i,0)
grove_oled.oled_putString("Hello World")
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
598,
11750,
10542,
5679,
367,
1808,
314,
598,
11750,
593,
5290,
12175,
15580,
10,
2534,
334,
1014,
921,
1544,
14,
3239,
379,
19806,
14,
957,
15,
6797,
15,
39,
11750,
32069,
63,
47,
5290,
63,
7687,
63,
17,
14,
713,
5,
1081,
9,
199,
3,
199,
3,
710,
598,
11750,
10542,
4907,
83,
314,
820,
20222,
605,
651,
19835,
436,
598,
11750,
19678,
14,
221,
2047,
883,
12537,
1655,
3595,
598,
11750,
10542,
2348,
26,
221,
1455,
921,
1544,
14,
731,
351,
688,
85,
816,
397,
14,
957,
15,
39,
11750,
10542,
199,
3,
199,
3,
26858,
282,
7894,
3595,
642,
2893,
31,
221,
30481,
641,
314,
21575,
83,
2348,
26,
221,
1455,
921,
1544,
14,
731,
351,
688,
85,
816,
397,
14,
957,
15,
10044,
10197,
10044,
29,
71,
11750,
1038,
199,
3,
199,
2344,
199,
309,
844,
199,
199,
1918,
10697,
844,
334,
13965,
9,
199,
199,
39,
11750,
10542,
367,
314,
820,
20222,
605,
651,
19835,
26,
376,
1551,
1350,
4298,
367,
18170,
598,
11750,
428,
17564,
370,
314,
820,
20222,
605,
651,
19835,
14,
199,
7384,
334,
35,
9,
6900,
221,
577,
476,
351,
473,
977,
85,
816,
397,
199,
199,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
1618,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
262,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
475,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
16847,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
70,
13399,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
199,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
452,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
38,
3061,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
5580,
4149,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
2673,
2477,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
1877,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
18061,
4141,
14,
199,
2344,
199,
199,
3,
15175,
314,
593,
5290,
370,
1263,
473,
18,
35,
1844,
11837,
14,
473,
18,
35,
13,
17,
199,
3,
6855,
506,
1911,
737,
473,
18,
35,
2287,
378,
88,
19,
67,
199,
199,
646,
486,
11750,
63,
26509,
199,
646,
900,
199,
199,
71,
11750,
63,
26509,
14,
26509,
63,
826,
342,
199,
71,
11750,
63,
26509,
14,
26509,
63,
3584,
7687,
342,
199,
71,
11750,
63,
26509,
14,
26509,
63,
409,
6241,
7687,
342,
199,
71,
11750,
63,
26509,
14,
26509,
63,
409,
19462,
1385,
342,
199,
521,
14,
4532,
13417,
17,
9,
199,
199,
509,
284,
315,
1425,
8,
16,
12,
713,
304,
272,
486,
11750,
63,
26509,
14,
26509,
63,
8341,
8195,
8,
73,
12,
16,
9,
272,
486,
11750,
63,
26509,
14,
26509,
63,
524,
1558,
480,
6257,
13064,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
598,
11750,
10542,
5679,
367,
1808,
314,
598,
11750,
593,
5290,
12175,
15580,
10,
2534,
334,
1014,
921,
1544,
14,
3239,
379,
19806,
14,
957,
15,
6797,
15,
39,
11750,
32069,
63,
47,
5290,
63,
7687,
63,
17,
14,
713,
5,
1081,
9,
199,
3,
199,
3,
710,
598,
11750,
10542,
4907,
83,
314,
820,
20222,
605,
651,
19835,
436,
598,
11750,
19678,
14,
221,
2047,
883,
12537,
1655,
3595,
598,
11750,
10542,
2348,
26,
221,
1455,
921,
1544,
14,
731,
351,
688,
85,
816,
397,
14,
957,
15,
39,
11750,
10542,
199,
3,
199,
3,
26858,
282,
7894,
3595,
642,
2893,
31,
221,
30481,
641,
314,
21575,
83,
2348,
26,
221,
1455,
921,
1544,
14,
731,
351,
688,
85,
816,
397,
14,
957,
15,
10044,
10197,
10044,
29,
71,
11750,
1038,
199,
3,
199,
2344,
199,
309,
844,
199,
199,
1918,
10697,
844,
334,
13965,
9,
199,
199,
39,
11750,
10542,
367,
314,
820,
20222,
605,
651,
19835,
26,
376,
1551,
1350,
4298,
367,
18170,
598,
11750,
428,
17564,
370,
314,
820,
20222,
605,
651,
19835,
14,
199,
7384,
334,
35,
9,
6900,
221,
577,
476,
351,
473,
977,
85,
816,
397,
199,
199,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
1618,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
262,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
475,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
16847,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
70,
13399,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
199,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
452,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
38,
3061,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
5580,
4149,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
2673,
2477,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
1877,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
18061,
4141,
14,
199,
2344,
199,
199,
3,
15175,
314,
593,
5290,
370,
1263,
473,
18,
35,
1844,
11837,
14,
473,
18,
35,
13,
17,
199,
3,
6855,
506,
1911,
737,
473,
18,
35,
2287,
378,
88,
19,
67,
199,
199,
646,
486,
11750,
63,
26509,
199,
646,
900,
199,
199,
71,
11750,
63,
26509,
14,
26509,
63,
826,
342,
199,
71,
11750,
63,
26509,
14,
26509,
63,
3584,
7687,
342,
199,
71,
11750,
63,
26509,
14,
26509,
63,
409,
6241,
7687,
342,
199,
71,
11750,
63,
26509,
14,
26509,
63,
409,
19462,
1385,
342,
199,
521,
14,
4532,
13417,
17,
9,
199,
199,
509,
284,
315,
1425,
8,
16,
12,
713,
304,
272,
486,
11750,
63,
26509,
14,
26509,
63,
8341,
8195,
8,
73,
12,
16,
9,
272,
486,
11750,
63,
26509,
14,
26509,
63,
524,
1558,
480,
6257,
13064,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
thechampanurag/django-oscar
|
src/oscar/apps/address/forms.py
|
28
|
1105
|
from django.conf import settings
from django import forms
from oscar.core.loading import get_model
from oscar.views.generic import PhoneNumberMixin
UserAddress = get_model('address', 'useraddress')
class AbstractAddressForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
"""
Set fields in OSCAR_REQUIRED_ADDRESS_FIELDS as required.
"""
super(AbstractAddressForm, self).__init__(*args, **kwargs)
field_names = (set(self.fields) &
set(settings.OSCAR_REQUIRED_ADDRESS_FIELDS))
for field_name in field_names:
self.fields[field_name].required = True
class UserAddressForm(PhoneNumberMixin, AbstractAddressForm):
class Meta:
model = UserAddress
fields = [
'title', 'first_name', 'last_name',
'line1', 'line2', 'line3', 'line4',
'state', 'postcode', 'country',
'phone_number', 'notes',
]
def __init__(self, user, *args, **kwargs):
super(UserAddressForm, self).__init__(*args, **kwargs)
self.instance.user = user
|
bsd-3-clause
|
[
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
492,
4513,
199,
199,
504,
312,
22707,
14,
1018,
14,
8786,
492,
664,
63,
1238,
199,
504,
312,
22707,
14,
4196,
14,
6767,
492,
27585,
3259,
4256,
199,
199,
1899,
1476,
275,
664,
63,
1238,
360,
1562,
297,
283,
751,
1562,
358,
421,
199,
533,
11836,
1476,
2821,
8,
3351,
14,
15937,
304,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
2494,
1504,
315,
4403,
28395,
63,
12496,
63,
12368,
63,
12767,
465,
1415,
14,
267,
408,
267,
1613,
8,
8458,
1476,
2821,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
901,
63,
1247,
275,
334,
409,
8,
277,
14,
955,
9,
1253,
2432,
663,
8,
1751,
14,
3100,
28395,
63,
12496,
63,
12368,
63,
12767,
430,
267,
367,
901,
63,
354,
315,
901,
63,
1247,
26,
288,
291,
14,
955,
59,
698,
63,
354,
1055,
2427,
275,
715,
421,
199,
533,
2876,
1476,
2821,
8,
25640,
4256,
12,
11836,
1476,
2821,
304,
339,
1021,
6288,
26,
267,
1402,
275,
2876,
1476,
267,
1504,
275,
359,
288,
283,
1213,
297,
283,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
288,
283,
604,
17,
297,
283,
604,
18,
297,
283,
604,
19,
297,
283,
604,
20,
297,
288,
283,
929,
297,
283,
1932,
600,
297,
283,
6063,
297,
288,
283,
9339,
63,
1955,
297,
283,
5983,
297,
267,
1622,
339,
347,
636,
826,
721,
277,
12,
922,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
1899,
1476,
2821,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
14,
842,
14,
751,
275,
922,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
2190,
492,
2202,
199,
504,
1639,
492,
4513,
199,
199,
504,
312,
22707,
14,
1018,
14,
8786,
492,
664,
63,
1238,
199,
504,
312,
22707,
14,
4196,
14,
6767,
492,
27585,
3259,
4256,
199,
199,
1899,
1476,
275,
664,
63,
1238,
360,
1562,
297,
283,
751,
1562,
358,
421,
199,
533,
11836,
1476,
2821,
8,
3351,
14,
15937,
304,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
2494,
1504,
315,
4403,
28395,
63,
12496,
63,
12368,
63,
12767,
465,
1415,
14,
267,
408,
267,
1613,
8,
8458,
1476,
2821,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
901,
63,
1247,
275,
334,
409,
8,
277,
14,
955,
9,
1253,
2432,
663,
8,
1751,
14,
3100,
28395,
63,
12496,
63,
12368,
63,
12767,
430,
267,
367,
901,
63,
354,
315,
901,
63,
1247,
26,
288,
291,
14,
955,
59,
698,
63,
354,
1055,
2427,
275,
715,
421,
199,
533,
2876,
1476,
2821,
8,
25640,
4256,
12,
11836,
1476,
2821,
304,
339,
1021,
6288,
26,
267,
1402,
275,
2876,
1476,
267,
1504,
275,
359,
288,
283,
1213,
297,
283,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
288,
283,
604,
17,
297,
283,
604,
18,
297,
283,
604,
19,
297,
283,
604,
20,
297,
288,
283,
929,
297,
283,
1932,
600,
297,
283,
6063,
297,
288,
283,
9339,
63,
1955,
297,
283,
5983,
297,
267,
1622,
339,
347,
636,
826,
721,
277,
12,
922,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
1899,
1476,
2821,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
14,
842,
14,
751,
275,
922,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
AOSP-S4-KK/platform_external_chromium_org
|
native_client_sdk/src/build_tools/sdk_tools/command/list.py
|
152
|
1736
|
# 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.
def List(remote_manifest, local_manifest, display_revisions):
any_bundles_need_update = False
print 'Bundles:'
print ' I: installed\n *: update available\n'
for bundle in remote_manifest.GetBundles():
local_bundle = local_manifest.GetBundle(bundle.name)
needs_update = local_bundle and local_manifest.BundleNeedsUpdate(bundle)
if needs_update:
any_bundles_need_update = True
_PrintBundle(local_bundle, bundle, needs_update, display_revisions)
if not any_bundles_need_update:
print '\nAll installed bundles are up-to-date.'
local_only_bundles = set([b.name for b in local_manifest.GetBundles()])
local_only_bundles -= set([b.name for b in remote_manifest.GetBundles()])
if local_only_bundles:
print '\nBundles installed locally that are not available remotely:'
for bundle_name in local_only_bundles:
local_bundle = local_manifest.GetBundle(bundle_name)
_PrintBundle(local_bundle, None, False, display_revisions)
def _PrintBundle(local_bundle, bundle, needs_update, display_revisions):
installed = local_bundle is not None
# If bundle is None, there is no longer a remote bundle with this name.
if bundle is None:
bundle = local_bundle
if display_revisions:
if needs_update:
revision = ' (r%s -> r%s)' % (local_bundle.revision, bundle.revision)
else:
revision = ' (r%s)' % (bundle.revision,)
else:
revision = ''
print (' %s%s %s (%s)%s' % (
'I' if installed else ' ',
'*' if needs_update else ' ',
bundle.name,
bundle.stability,
revision))
|
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,
318,
3820,
8,
3846,
63,
6418,
12,
2257,
63,
6418,
12,
2929,
63,
23449,
304,
523,
1263,
63,
66,
18793,
63,
9321,
63,
873,
275,
756,
523,
870,
283,
34,
18793,
4881,
523,
870,
283,
473,
26,
4903,
60,
78,
627,
26,
1678,
2808,
60,
78,
7,
523,
367,
8844,
315,
3982,
63,
6418,
14,
1002,
34,
18793,
837,
272,
2257,
63,
6469,
275,
2257,
63,
6418,
14,
1002,
12320,
8,
6469,
14,
354,
9,
272,
4839,
63,
873,
275,
2257,
63,
6469,
436,
2257,
63,
6418,
14,
12320,
28390,
4152,
8,
6469,
9,
272,
340,
4839,
63,
873,
26,
489,
1263,
63,
66,
18793,
63,
9321,
63,
873,
275,
715,
339,
485,
5375,
12320,
8,
1832,
63,
6469,
12,
8844,
12,
4839,
63,
873,
12,
2929,
63,
23449,
9,
819,
340,
440,
1263,
63,
66,
18793,
63,
9321,
63,
873,
26,
272,
870,
1557,
78,
2422,
4903,
27206,
787,
1536,
13,
475,
13,
602,
3530,
819,
2257,
63,
2118,
63,
66,
18793,
275,
663,
779,
66,
14,
354,
367,
330,
315,
2257,
63,
6418,
14,
1002,
34,
18793,
9383,
523,
2257,
63,
2118,
63,
66,
18793,
4862,
663,
779,
66,
14,
354,
367,
330,
315,
3982,
63,
6418,
14,
1002,
34,
18793,
9383,
523,
340,
2257,
63,
2118,
63,
66,
18793,
26,
272,
870,
1557,
78,
34,
18793,
4903,
17738,
626,
787,
440,
2808,
3982,
590,
4881,
272,
367,
8844,
63,
354,
315,
2257,
63,
2118,
63,
66,
18793,
26,
489,
2257,
63,
6469,
275,
2257,
63,
6418,
14,
1002,
12320,
8,
6469,
63,
354,
9,
489,
485,
5375,
12320,
8,
1832,
63,
6469,
12,
488,
12,
756,
12,
2929,
63,
23449,
9,
421,
199,
318,
485,
5375,
12320,
8,
1832,
63,
6469,
12,
8844,
12,
4839,
63,
873,
12,
2929,
63,
23449,
304,
523,
4903,
275,
2257,
63,
6469,
365,
440,
488,
523,
327,
982,
8844,
365,
488,
12,
2337,
365,
949,
8088,
282,
3982,
8844,
543,
642,
536,
14,
523,
340,
8844,
365,
488,
26,
272,
8844,
275,
2257,
63,
6469,
819,
340,
2929,
63,
23449,
26,
272,
340,
4839,
63,
873,
26,
489,
6974,
275,
283,
334,
82,
5,
83,
1035,
519,
5,
83,
3171,
450,
334,
1832,
63,
6469,
14,
5792,
12,
8844,
14,
5792,
9,
272,
587,
26,
489,
6974,
275,
283,
334,
82,
5,
83,
3171,
450,
334,
6469,
14,
5792,
4258,
523,
587,
26,
272,
6974,
275,
2125,
819,
870,
661,
221,
450,
83,
5,
83,
450,
83,
4366,
83,
19656,
83,
7,
450,
334,
272,
283,
41,
7,
340,
4903,
587,
283,
1656,
272,
13626,
340,
4839,
63,
873,
587,
283,
1656,
272,
8844,
14,
354,
12,
272,
8844,
14,
270,
3616,
12,
272,
6974,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
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,
318,
3820,
8,
3846,
63,
6418,
12,
2257,
63,
6418,
12,
2929,
63,
23449,
304,
523,
1263,
63,
66,
18793,
63,
9321,
63,
873,
275,
756,
523,
870,
283,
34,
18793,
4881,
523,
870,
283,
473,
26,
4903,
60,
78,
627,
26,
1678,
2808,
60,
78,
7,
523,
367,
8844,
315,
3982,
63,
6418,
14,
1002,
34,
18793,
837,
272,
2257,
63,
6469,
275,
2257,
63,
6418,
14,
1002,
12320,
8,
6469,
14,
354,
9,
272,
4839,
63,
873,
275,
2257,
63,
6469,
436,
2257,
63,
6418,
14,
12320,
28390,
4152,
8,
6469,
9,
272,
340,
4839,
63,
873,
26,
489,
1263,
63,
66,
18793,
63,
9321,
63,
873,
275,
715,
339,
485,
5375,
12320,
8,
1832,
63,
6469,
12,
8844,
12,
4839,
63,
873,
12,
2929,
63,
23449,
9,
819,
340,
440,
1263,
63,
66,
18793,
63,
9321,
63,
873,
26,
272,
870,
1557,
78,
2422,
4903,
27206,
787,
1536,
13,
475,
13,
602,
3530,
819,
2257,
63,
2118,
63,
66,
18793,
275,
663,
779,
66,
14,
354,
367,
330,
315,
2257,
63,
6418,
14,
1002,
34,
18793,
9383,
523,
2257,
63,
2118,
63,
66,
18793,
4862,
663,
779,
66,
14,
354,
367,
330,
315,
3982,
63,
6418,
14,
1002,
34,
18793,
9383,
523,
340,
2257,
63,
2118,
63,
66,
18793,
26,
272,
870,
1557,
78,
34,
18793,
4903,
17738,
626,
787,
440,
2808,
3982,
590,
4881,
272,
367,
8844,
63,
354,
315,
2257,
63,
2118,
63,
66,
18793,
26,
489,
2257,
63,
6469,
275,
2257,
63,
6418,
14,
1002,
12320,
8,
6469,
63,
354,
9,
489,
485,
5375,
12320,
8,
1832,
63,
6469,
12,
488,
12,
756,
12,
2929,
63,
23449,
9,
421,
199,
318,
485,
5375,
12320,
8,
1832,
63,
6469,
12,
8844,
12,
4839,
63,
873,
12,
2929,
63,
23449,
304,
523,
4903,
275,
2257,
63,
6469,
365,
440,
488,
523,
327,
982,
8844,
365,
488,
12,
2337,
365,
949,
8088,
282,
3982,
8844,
543,
642,
536,
14,
523,
340,
8844,
365,
488,
26,
272,
8844,
275,
2257,
63,
6469,
819,
340,
2929,
63,
23449,
26,
272,
340,
4839,
63,
873,
26,
489,
6974,
275,
283,
334,
82,
5,
83,
1035,
519,
5,
83,
3171,
450,
334,
1832,
63,
6469,
14,
5792,
12,
8844,
14,
5792,
9,
272,
587,
26,
489,
6974,
275,
283,
334,
82,
5,
83,
3171,
450,
334,
6469,
14,
5792,
4258,
523,
587,
26,
272,
6974,
275,
2125,
819,
870,
661,
221,
450,
83,
5,
83,
450,
83,
4366,
83,
19656,
83,
7,
450,
334,
272,
283,
41,
7,
340,
4903,
587,
283,
1656,
272,
13626,
340,
4839,
63,
873,
587,
283,
1656,
272,
8844,
14,
354,
12,
272,
8844,
14,
270,
3616,
12,
272,
6974,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
JioCloud/cinder
|
cinder/quota.py
|
7
|
40237
|
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# 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.
"""Quotas for volumes."""
import datetime
from oslo_config import cfg
from oslo_log import log as logging
from oslo_log import versionutils
from oslo_utils import importutils
from oslo_utils import timeutils
import six
from cinder import context
from cinder import db
from cinder import exception
from cinder.i18n import _, _LE
LOG = logging.getLogger(__name__)
quota_opts = [
cfg.IntOpt('quota_volumes',
default=10,
help='Number of volumes allowed per project'),
cfg.IntOpt('quota_snapshots',
default=10,
help='Number of volume snapshots allowed per project'),
cfg.IntOpt('quota_consistencygroups',
default=10,
help='Number of consistencygroups allowed per project'),
cfg.IntOpt('quota_gigabytes',
default=1000,
help='Total amount of storage, in gigabytes, allowed '
'for volumes and snapshots per project'),
cfg.IntOpt('quota_backups',
default=10,
help='Number of volume backups allowed per project'),
cfg.IntOpt('quota_backup_gigabytes',
default=1000,
help='Total amount of storage, in gigabytes, allowed '
'for backups per project'),
cfg.IntOpt('reservation_expire',
default=86400,
help='Number of seconds until a reservation expires'),
cfg.IntOpt('until_refresh',
default=0,
help='Count of reservations until usage is refreshed'),
cfg.IntOpt('max_age',
default=0,
help='Number of seconds between subsequent usage refreshes'),
cfg.StrOpt('quota_driver',
default='cinder.quota.DbQuotaDriver',
help='Default driver to use for quota checks'),
cfg.BoolOpt('use_default_quota_class',
default=True,
help='Enables or disables use of default quota class '
'with default quota.'),
cfg.IntOpt('per_volume_size_limit',
default=-1,
help='Max size allowed per volume, in gigabytes'), ]
CONF = cfg.CONF
CONF.register_opts(quota_opts)
class DbQuotaDriver(object):
"""Driver to perform check to enforcement of quotas.
Also allows to obtain quota information.
The default driver utilizes the local database.
"""
def get_by_project(self, context, project_id, resource_name):
"""Get a specific quota by project."""
return db.quota_get(context, project_id, resource_name)
def get_by_class(self, context, quota_class, resource_name):
"""Get a specific quota by quota class."""
return db.quota_class_get(context, quota_class, resource_name)
def get_default(self, context, resource, parent_project_id=None):
"""Get a specific default quota for a resource.
:param parent_project_id: The id of the current project's parent,
if any.
"""
default_quotas = db.quota_class_get_default(context)
default_quota_value = 0 if parent_project_id else resource.default
return default_quotas.get(resource.name, default_quota_value)
def get_defaults(self, context, resources, parent_project_id=None):
"""Given a list of resources, retrieve the default quotas.
Use the class quotas named `_DEFAULT_QUOTA_NAME` as default quotas,
if it exists.
:param context: The request context, for access checks.
:param resources: A dictionary of the registered resources.
:param parent_project_id: The id of the current project's parent,
if any.
"""
quotas = {}
default_quotas = {}
if CONF.use_default_quota_class and not parent_project_id:
default_quotas = db.quota_class_get_default(context)
for resource in resources.values():
if default_quotas:
if resource.name not in default_quotas:
versionutils.report_deprecated_feature(LOG, _(
"Default quota for resource: %(res)s is set "
"by the default quota flag: quota_%(res)s, "
"it is now deprecated. Please use the "
"default quota class for default "
"quota.") % {'res': resource.name})
quotas[resource.name] = default_quotas.get(resource.name,
(0 if parent_project_id
else resource.default))
return quotas
def get_class_quotas(self, context, resources, quota_class,
defaults=True):
"""Given list of resources, retrieve the quotas for given quota class.
:param context: The request context, for access checks.
:param resources: A dictionary of the registered resources.
:param quota_class: The name of the quota class to return
quotas for.
:param defaults: If True, the default value will be reported
if there is no specific value for the
resource.
"""
quotas = {}
default_quotas = {}
class_quotas = db.quota_class_get_all_by_name(context, quota_class)
if defaults:
default_quotas = db.quota_class_get_default(context)
for resource in resources.values():
if resource.name in class_quotas:
quotas[resource.name] = class_quotas[resource.name]
continue
if defaults:
quotas[resource.name] = default_quotas.get(resource.name,
resource.default)
return quotas
def get_project_quotas(self, context, resources, project_id,
quota_class=None, defaults=True,
usages=True, parent_project_id=None):
"""Retrieve quotas for a project.
Given a list of resources, retrieve the quotas for the given
project.
:param context: The request context, for access checks.
:param resources: A dictionary of the registered resources.
:param project_id: The ID of the project to return quotas for.
:param quota_class: If project_id != context.project_id, the
quota class cannot be determined. This
parameter allows it to be specified. It
will be ignored if project_id ==
context.project_id.
:param defaults: If True, the quota class value (or the
default value, if there is no value from the
quota class) will be reported if there is no
specific value for the resource.
:param usages: If True, the current in_use and reserved counts
will also be returned.
:param parent_project_id: The id of the current project's parent,
if any.
"""
quotas = {}
project_quotas = db.quota_get_all_by_project(context, project_id)
if usages:
project_usages = db.quota_usage_get_all_by_project(context,
project_id)
# Get the quotas for the appropriate class. If the project ID
# matches the one in the context, we use the quota_class from
# the context, otherwise, we use the provided quota_class (if
# any)
if project_id == context.project_id:
quota_class = context.quota_class
if quota_class:
class_quotas = db.quota_class_get_all_by_name(context, quota_class)
else:
class_quotas = {}
default_quotas = self.get_defaults(context, resources,
parent_project_id=parent_project_id)
for resource in resources.values():
# Omit default/quota class values
if not defaults and resource.name not in project_quotas:
continue
quotas[resource.name] = dict(
limit=project_quotas.get(
resource.name,
class_quotas.get(resource.name,
default_quotas[resource.name])),
)
# Include usages if desired. This is optional because one
# internal consumer of this interface wants to access the
# usages directly from inside a transaction.
if usages:
usage = project_usages.get(resource.name, {})
quotas[resource.name].update(
in_use=usage.get('in_use', 0),
reserved=usage.get('reserved', 0), )
return quotas
def _get_quotas(self, context, resources, keys, has_sync, project_id=None,
parent_project_id=None):
"""A helper method which retrieves the quotas for specific resources.
This specific resource is identified by keys, and which apply to the
current context.
:param context: The request context, for access checks.
:param resources: A dictionary of the registered resources.
:param keys: A list of the desired quotas to retrieve.
:param has_sync: If True, indicates that the resource must
have a sync attribute; if False, indicates
that the resource must NOT have a sync
attribute.
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
:param parent_project_id: The id of the current project's parent,
if any.
"""
# Filter resources
if has_sync:
sync_filt = lambda x: hasattr(x, 'sync')
else:
sync_filt = lambda x: not hasattr(x, 'sync')
desired = set(keys)
sub_resources = {k: v for k, v in resources.items()
if k in desired and sync_filt(v)}
# Make sure we accounted for all of them...
if len(keys) != len(sub_resources):
unknown = desired - set(sub_resources.keys())
raise exception.QuotaResourceUnknown(unknown=sorted(unknown))
# Grab and return the quotas (without usages)
quotas = self.get_project_quotas(context, sub_resources,
project_id,
context.quota_class, usages=False,
parent_project_id=parent_project_id)
return {k: v['limit'] for k, v in quotas.items()}
def limit_check(self, context, resources, values, project_id=None):
"""Check simple quota limits.
For limits--those quotas for which there is no usage
synchronization function--this method checks that a set of
proposed values are permitted by the limit restriction.
This method will raise a QuotaResourceUnknown exception if a
given resource is unknown or if it is not a simple limit
resource.
If any of the proposed values is over the defined quota, an
OverQuota exception will be raised with the sorted list of the
resources which are too high. Otherwise, the method returns
nothing.
:param context: The request context, for access checks.
:param resources: A dictionary of the registered resources.
:param values: A dictionary of the values to check against the
quota.
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
"""
# Ensure no value is less than zero
unders = [key for key, val in values.items() if val < 0]
if unders:
raise exception.InvalidQuotaValue(unders=sorted(unders))
# If project_id is None, then we use the project_id in context
if project_id is None:
project_id = context.project_id
# Get the applicable quotas
quotas = self._get_quotas(context, resources, values.keys(),
has_sync=False, project_id=project_id)
# Check the quotas and construct a list of the resources that
# would be put over limit by the desired values
overs = [key for key, val in values.items()
if quotas[key] >= 0 and quotas[key] < val]
if overs:
raise exception.OverQuota(overs=sorted(overs), quotas=quotas,
usages={})
def reserve(self, context, resources, deltas, expire=None,
project_id=None):
"""Check quotas and reserve resources.
For counting quotas--those quotas for which there is a usage
synchronization function--this method checks quotas against
current usage and the desired deltas.
This method will raise a QuotaResourceUnknown exception if a
given resource is unknown or if it does not have a usage
synchronization function.
If any of the proposed values is over the defined quota, an
OverQuota exception will be raised with the sorted list of the
resources which are too high. Otherwise, the method returns a
list of reservation UUIDs which were created.
:param context: The request context, for access checks.
:param resources: A dictionary of the registered resources.
:param deltas: A dictionary of the proposed delta changes.
:param expire: An optional parameter specifying an expiration
time for the reservations. If it is a simple
number, it is interpreted as a number of
seconds and added to the current time; if it is
a datetime.timedelta object, it will also be
added to the current time. A datetime.datetime
object will be interpreted as the absolute
expiration time. If None is specified, the
default expiration time set by
--default-reservation-expire will be used (this
value will be treated as a number of seconds).
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
"""
# Set up the reservation expiration
if expire is None:
expire = CONF.reservation_expire
if isinstance(expire, six.integer_types):
expire = datetime.timedelta(seconds=expire)
if isinstance(expire, datetime.timedelta):
expire = timeutils.utcnow() + expire
if not isinstance(expire, datetime.datetime):
raise exception.InvalidReservationExpiration(expire=expire)
# If project_id is None, then we use the project_id in context
if project_id is None:
project_id = context.project_id
# Get the applicable quotas.
# NOTE(Vek): We're not worried about races at this point.
# Yes, the admin may be in the process of reducing
# quotas, but that's a pretty rare thing.
quotas = self._get_quotas(context, resources, deltas.keys(),
has_sync=True, project_id=project_id)
# NOTE(Vek): Most of the work here has to be done in the DB
# API, because we have to do it in a transaction,
# which means access to the session. Since the
# session isn't available outside the DBAPI, we
# have to do the work there.
return db.quota_reserve(context, resources, quotas, deltas, expire,
CONF.until_refresh, CONF.max_age,
project_id=project_id)
def commit(self, context, reservations, project_id=None):
"""Commit reservations.
:param context: The request context, for access checks.
:param reservations: A list of the reservation UUIDs, as
returned by the reserve() method.
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
"""
# If project_id is None, then we use the project_id in context
if project_id is None:
project_id = context.project_id
db.reservation_commit(context, reservations, project_id=project_id)
def rollback(self, context, reservations, project_id=None):
"""Roll back reservations.
:param context: The request context, for access checks.
:param reservations: A list of the reservation UUIDs, as
returned by the reserve() method.
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
"""
# If project_id is None, then we use the project_id in context
if project_id is None:
project_id = context.project_id
db.reservation_rollback(context, reservations, project_id=project_id)
def destroy_by_project(self, context, project_id):
"""Destroy all limit quotas associated with a project.
Leave usage and reservation quotas intact.
:param context: The request context, for access checks.
:param project_id: The ID of the project being deleted.
"""
db.quota_destroy_by_project(context, project_id)
def expire(self, context):
"""Expire reservations.
Explores all currently existing reservations and rolls back
any that have expired.
:param context: The request context, for access checks.
"""
db.reservation_expire(context)
class BaseResource(object):
"""Describe a single resource for quota checking."""
def __init__(self, name, flag=None, parent_project_id=None):
"""Initializes a Resource.
:param name: The name of the resource, i.e., "volumes".
:param flag: The name of the flag or configuration option
which specifies the default value of the quota
for this resource.
:param parent_project_id: The id of the current project's parent,
if any.
"""
self.name = name
self.flag = flag
self.parent_project_id = parent_project_id
def quota(self, driver, context, **kwargs):
"""Given a driver and context, obtain the quota for this resource.
:param driver: A quota driver.
:param context: The request context.
:param project_id: The project to obtain the quota value for.
If not provided, it is taken from the
context. If it is given as None, no
project-specific quota will be searched
for.
:param quota_class: The quota class corresponding to the
project, or for which the quota is to be
looked up. If not provided, it is taken
from the context. If it is given as None,
no quota class-specific quota will be
searched for. Note that the quota class
defaults to the value in the context,
which may not correspond to the project if
project_id is not the same as the one in
the context.
"""
# Get the project ID
project_id = kwargs.get('project_id', context.project_id)
# Ditto for the quota class
quota_class = kwargs.get('quota_class', context.quota_class)
# Look up the quota for the project
if project_id:
try:
return driver.get_by_project(context, project_id, self.name)
except exception.ProjectQuotaNotFound:
pass
# Try for the quota class
if quota_class:
try:
return driver.get_by_class(context, quota_class, self.name)
except exception.QuotaClassNotFound:
pass
# OK, return the default
return driver.get_default(context, self,
parent_project_id=self.parent_project_id)
@property
def default(self):
"""Return the default value of the quota."""
if self.parent_project_id:
return 0
return CONF[self.flag] if self.flag else -1
class ReservableResource(BaseResource):
"""Describe a reservable resource."""
def __init__(self, name, sync, flag=None):
"""Initializes a ReservableResource.
Reservable resources are those resources which directly
correspond to objects in the database, i.e., volumes, gigabytes,
etc. A ReservableResource must be constructed with a usage
synchronization function, which will be called to determine the
current counts of one or more resources.
The usage synchronization function will be passed three
arguments: an admin context, the project ID, and an opaque
session object, which should in turn be passed to the
underlying database function. Synchronization functions
should return a dictionary mapping resource names to the
current in_use count for those resources; more than one
resource and resource count may be returned. Note that
synchronization functions may be associated with more than one
ReservableResource.
:param name: The name of the resource, i.e., "volumes".
:param sync: A dbapi methods name which returns a dictionary
to resynchronize the in_use count for one or more
resources, as described above.
:param flag: The name of the flag or configuration option
which specifies the default value of the quota
for this resource.
"""
super(ReservableResource, self).__init__(name, flag=flag)
if sync:
self.sync = sync
class AbsoluteResource(BaseResource):
"""Describe a non-reservable resource."""
pass
class CountableResource(AbsoluteResource):
"""Describe a resource where counts aren't based only on the project ID."""
def __init__(self, name, count, flag=None):
"""Initializes a CountableResource.
Countable resources are those resources which directly
correspond to objects in the database, i.e., volumes, gigabytes,
etc., but for which a count by project ID is inappropriate. A
CountableResource must be constructed with a counting
function, which will be called to determine the current counts
of the resource.
The counting function will be passed the context, along with
the extra positional and keyword arguments that are passed to
Quota.count(). It should return an integer specifying the
count.
Note that this counting is not performed in a transaction-safe
manner. This resource class is a temporary measure to provide
required functionality, until a better approach to solving
this problem can be evolved.
:param name: The name of the resource, i.e., "volumes".
:param count: A callable which returns the count of the
resource. The arguments passed are as described
above.
:param flag: The name of the flag or configuration option
which specifies the default value of the quota
for this resource.
"""
super(CountableResource, self).__init__(name, flag=flag)
self.count = count
class VolumeTypeResource(ReservableResource):
"""ReservableResource for a specific volume type."""
def __init__(self, part_name, volume_type):
"""Initializes a VolumeTypeResource.
:param part_name: The kind of resource, i.e., "volumes".
:param volume_type: The volume type for this resource.
"""
self.volume_type_name = volume_type['name']
self.volume_type_id = volume_type['id']
name = "%s_%s" % (part_name, self.volume_type_name)
super(VolumeTypeResource, self).__init__(name, "_sync_%s" % part_name)
class QuotaEngine(object):
"""Represent the set of recognized quotas."""
def __init__(self, quota_driver_class=None):
"""Initialize a Quota object."""
if not quota_driver_class:
quota_driver_class = CONF.quota_driver
if isinstance(quota_driver_class, six.string_types):
quota_driver_class = importutils.import_object(quota_driver_class)
self._resources = {}
self._driver = quota_driver_class
def __contains__(self, resource):
return resource in self.resources
def register_resource(self, resource):
"""Register a resource."""
self._resources[resource.name] = resource
def register_resources(self, resources):
"""Register a list of resources."""
for resource in resources:
self.register_resource(resource)
def get_by_project(self, context, project_id, resource_name):
"""Get a specific quota by project."""
return self._driver.get_by_project(context, project_id, resource_name)
def get_by_class(self, context, quota_class, resource_name):
"""Get a specific quota by quota class."""
return self._driver.get_by_class(context, quota_class, resource_name)
def get_default(self, context, resource, parent_project_id=None):
"""Get a specific default quota for a resource.
:param parent_project_id: The id of the current project's parent,
if any.
"""
return self._driver.get_default(context, resource,
parent_project_id=parent_project_id)
def get_defaults(self, context, parent_project_id=None):
"""Retrieve the default quotas.
:param context: The request context, for access checks.
:param parent_project_id: The id of the current project's parent,
if any.
"""
return self._driver.get_defaults(context, self.resources,
parent_project_id)
def get_class_quotas(self, context, quota_class, defaults=True):
"""Retrieve the quotas for the given quota class.
:param context: The request context, for access checks.
:param quota_class: The name of the quota class to return
quotas for.
:param defaults: If True, the default value will be reported
if there is no specific value for the
resource.
"""
return self._driver.get_class_quotas(context, self.resources,
quota_class, defaults=defaults)
def get_project_quotas(self, context, project_id, quota_class=None,
defaults=True, usages=True, parent_project_id=None):
"""Retrieve the quotas for the given project.
:param context: The request context, for access checks.
:param project_id: The ID of the project to return quotas for.
:param quota_class: If project_id != context.project_id, the
quota class cannot be determined. This
parameter allows it to be specified.
:param defaults: If True, the quota class value (or the
default value, if there is no value from the
quota class) will be reported if there is no
specific value for the resource.
:param usages: If True, the current in_use and reserved counts
will also be returned.
:param parent_project_id: The id of the current project's parent,
if any.
"""
return self._driver.get_project_quotas(context, self.resources,
project_id,
quota_class=quota_class,
defaults=defaults,
usages=usages,
parent_project_id=
parent_project_id)
def count(self, context, resource, *args, **kwargs):
"""Count a resource.
For countable resources, invokes the count() function and
returns its result. Arguments following the context and
resource are passed directly to the count function declared by
the resource.
:param context: The request context, for access checks.
:param resource: The name of the resource, as a string.
"""
# Get the resource
res = self.resources.get(resource)
if not res or not hasattr(res, 'count'):
raise exception.QuotaResourceUnknown(unknown=[resource])
return res.count(context, *args, **kwargs)
def limit_check(self, context, project_id=None, **values):
"""Check simple quota limits.
For limits--those quotas for which there is no usage
synchronization function--this method checks that a set of
proposed values are permitted by the limit restriction. The
values to check are given as keyword arguments, where the key
identifies the specific quota limit to check, and the value is
the proposed value.
This method will raise a QuotaResourceUnknown exception if a
given resource is unknown or if it is not a simple limit
resource.
If any of the proposed values is over the defined quota, an
OverQuota exception will be raised with the sorted list of the
resources which are too high. Otherwise, the method returns
nothing.
:param context: The request context, for access checks.
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
"""
return self._driver.limit_check(context, self.resources, values,
project_id=project_id)
def reserve(self, context, expire=None, project_id=None, **deltas):
"""Check quotas and reserve resources.
For counting quotas--those quotas for which there is a usage
synchronization function--this method checks quotas against
current usage and the desired deltas. The deltas are given as
keyword arguments, and current usage and other reservations
are factored into the quota check.
This method will raise a QuotaResourceUnknown exception if a
given resource is unknown or if it does not have a usage
synchronization function.
If any of the proposed values is over the defined quota, an
OverQuota exception will be raised with the sorted list of the
resources which are too high. Otherwise, the method returns a
list of reservation UUIDs which were created.
:param context: The request context, for access checks.
:param expire: An optional parameter specifying an expiration
time for the reservations. If it is a simple
number, it is interpreted as a number of
seconds and added to the current time; if it is
a datetime.timedelta object, it will also be
added to the current time. A datetime.datetime
object will be interpreted as the absolute
expiration time. If None is specified, the
default expiration time set by
--default-reservation-expire will be used (this
value will be treated as a number of seconds).
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
"""
reservations = self._driver.reserve(context, self.resources, deltas,
expire=expire,
project_id=project_id)
LOG.debug("Created reservations %s", reservations)
return reservations
def commit(self, context, reservations, project_id=None):
"""Commit reservations.
:param context: The request context, for access checks.
:param reservations: A list of the reservation UUIDs, as
returned by the reserve() method.
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
"""
try:
self._driver.commit(context, reservations, project_id=project_id)
except Exception:
# NOTE(Vek): Ignoring exceptions here is safe, because the
# usage resynchronization and the reservation expiration
# mechanisms will resolve the issue. The exception is
# logged, however, because this is less than optimal.
LOG.exception(_LE("Failed to commit "
"reservations %s"), reservations)
def rollback(self, context, reservations, project_id=None):
"""Roll back reservations.
:param context: The request context, for access checks.
:param reservations: A list of the reservation UUIDs, as
returned by the reserve() method.
:param project_id: Specify the project_id if current context
is admin and admin wants to impact on
common user's tenant.
"""
try:
self._driver.rollback(context, reservations, project_id=project_id)
except Exception:
# NOTE(Vek): Ignoring exceptions here is safe, because the
# usage resynchronization and the reservation expiration
# mechanisms will resolve the issue. The exception is
# logged, however, because this is less than optimal.
LOG.exception(_LE("Failed to roll back reservations "
"%s"), reservations)
def destroy_by_project(self, context, project_id):
"""Destroy all quota limits associated with a project.
:param context: The request context, for access checks.
:param project_id: The ID of the project being deleted.
"""
self._driver.destroy_by_project(context, project_id)
def expire(self, context):
"""Expire reservations.
Explores all currently existing reservations and rolls back
any that have expired.
:param context: The request context, for access checks.
"""
self._driver.expire(context)
def add_volume_type_opts(self, context, opts, volume_type_id):
"""Add volume type resource options.
Adds elements to the opts hash for volume type quotas.
If a resource is being reserved ('gigabytes', etc) and the volume
type is set up for its own quotas, these reservations are copied
into keys for 'gigabytes_<volume type name>', etc.
:param context: The request context, for access checks.
:param opts: The reservations options hash.
:param volume_type_id: The volume type id for this reservation.
"""
if not volume_type_id:
return
# NOTE(jdg): set inactive to True in volume_type_get, as we
# may be operating on a volume that was created with a type
# that has since been deleted.
volume_type = db.volume_type_get(context, volume_type_id, True)
for quota in ('volumes', 'gigabytes', 'snapshots'):
if quota in opts:
vtype_quota = "%s_%s" % (quota, volume_type['name'])
opts[vtype_quota] = opts[quota]
@property
def resource_names(self):
return sorted(self.resources.keys())
@property
def resources(self):
return self._resources
class VolumeTypeQuotaEngine(QuotaEngine):
"""Represent the set of all quotas."""
@property
def resources(self):
"""Fetches all possible quota resources."""
result = {}
# Global quotas.
argses = [('volumes', '_sync_volumes', 'quota_volumes'),
('per_volume_gigabytes', None, 'per_volume_size_limit'),
('snapshots', '_sync_snapshots', 'quota_snapshots'),
('gigabytes', '_sync_gigabytes', 'quota_gigabytes'),
('backups', '_sync_backups', 'quota_backups'),
('backup_gigabytes', '_sync_backup_gigabytes',
'quota_backup_gigabytes')]
for args in argses:
resource = ReservableResource(*args)
result[resource.name] = resource
# Volume type quotas.
volume_types = db.volume_type_get_all(context.get_admin_context(),
False)
for volume_type in volume_types.values():
for part_name in ('volumes', 'gigabytes', 'snapshots'):
resource = VolumeTypeResource(part_name, volume_type)
result[resource.name] = resource
return result
def register_resource(self, resource):
raise NotImplementedError(_("Cannot register resource"))
def register_resources(self, resources):
raise NotImplementedError(_("Cannot register resources"))
class CGQuotaEngine(QuotaEngine):
"""Represent the consistencygroup quotas."""
@property
def resources(self):
"""Fetches all possible quota resources."""
result = {}
# Global quotas.
argses = [('consistencygroups', '_sync_consistencygroups',
'quota_consistencygroups'), ]
for args in argses:
resource = ReservableResource(*args)
result[resource.name] = resource
return result
def register_resource(self, resource):
raise NotImplementedError(_("Cannot register resource"))
def register_resources(self, resources):
raise NotImplementedError(_("Cannot register resources"))
QUOTAS = VolumeTypeQuotaEngine()
CGQUOTAS = CGQuotaEngine()
|
apache-2.0
|
[
3,
1898,
7129,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
624,
2371,
357,
305,
367,
12158,
1041,
421,
199,
646,
2197,
199,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
11258,
63,
793,
492,
1015,
1208,
199,
504,
11258,
63,
1208,
492,
492,
1208,
199,
504,
11258,
63,
1208,
492,
23011,
199,
646,
3816,
199,
199,
504,
13069,
492,
1067,
199,
504,
13069,
492,
1592,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
73,
1085,
78,
492,
5501,
485,
906,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
8848,
63,
3291,
275,
359,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
8838,
297,
2049,
849,
29,
709,
12,
2049,
1720,
534,
3259,
402,
12158,
4370,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
15331,
297,
2049,
849,
29,
709,
12,
2049,
1720,
534,
3259,
402,
3301,
19076,
4370,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
20249,
2634,
297,
2049,
849,
29,
709,
12,
2049,
1720,
534,
3259,
402,
17754,
2634,
4370,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
71,
528,
27601,
297,
2049,
849,
29,
5279,
12,
2049,
1720,
534,
7316,
5982,
402,
4887,
12,
315,
486,
528,
27601,
12,
4370,
283,
490,
283,
509,
12158,
436,
19076,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
27376,
297,
2049,
849,
29,
709,
12,
2049,
1720,
534,
3259,
402,
3301,
6902,
83,
4370,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
5751,
63,
71,
528,
27601,
297,
2049,
849,
29,
5279,
12,
2049,
1720,
534,
7316,
5982,
402,
4887,
12,
315,
486,
528,
27601,
12,
4370,
283,
490,
283,
509,
6902,
83,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
20522,
63,
14691,
297,
2049,
849,
29,
24,
20543,
12,
2049,
1720,
534,
3259,
402,
4696,
5133,
282,
25476,
12261,
659,
272,
4810,
14,
3241,
9985,
360,
8111,
63,
6635,
297,
2049,
849,
29,
16,
12,
2049,
1720,
534,
2353,
402,
31494,
5133,
4503,
365,
9236,
379,
659,
272,
4810,
14,
3241,
9985,
360,
988,
63,
474,
297,
2049,
849,
29,
16,
12,
2049,
1720,
534,
3259,
402,
4696,
3382,
13372,
4503,
9236,
397,
659,
272,
4810,
14,
19340,
360,
8848,
63,
3090,
297,
2049,
849,
534,
12372,
14,
8848,
14,
8882,
17610,
6158,
297,
2049,
1720,
534,
2698,
5253,
370,
675,
367,
12132,
5920,
659,
272,
4810,
14,
10349,
9985,
360,
1180,
63,
885,
63,
8848,
63,
533,
297,
355,
849,
29,
549,
12,
355,
1720,
534,
1327,
5921,
503,
28421,
675,
402,
849,
12132,
1021,
283,
2151,
283,
1045,
849,
12132,
8038,
272,
4810,
14,
3241,
9985,
360,
529,
63,
2405,
63,
890,
63,
3097,
297,
2049,
849,
4022,
17,
12,
2049,
1720,
534,
4261,
1568,
4370,
1126,
3301,
12,
315,
486,
528,
27601,
659,
1622,
199,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
2683,
63,
3291,
8,
8848,
63,
3291,
9,
421,
199,
533,
28822,
17610,
6158,
8,
785,
304,
339,
408,
6158,
370,
5147,
1104,
370,
15814,
434,
402,
22874,
14,
339,
6121,
6127,
370,
3332,
12132,
2556,
14,
272,
710,
849,
5253,
7678,
19030,
397,
314,
2257,
3050,
14,
272,
408,
339,
347,
664,
63,
991,
63,
1715,
8,
277,
12,
1067,
12,
2199,
63,
344,
12,
2073,
63,
354,
304,
267,
408,
1002,
282,
2488,
12132,
701,
2199,
1041,
398,
372,
1592,
14,
8848,
63,
362,
8,
1100,
12,
2199,
63,
344,
12,
2073,
63,
354,
9,
339,
347,
664,
63,
991,
63,
533,
8,
277,
12,
1067,
12,
12132,
63,
533,
12,
2073,
63,
354,
304,
267,
408,
1002,
282,
2488,
12132,
701,
12132,
1021,
1041,
398,
372,
1592,
14,
8848,
63,
533,
63,
362,
8,
1100,
12,
12132,
63,
533,
12,
2073,
63,
354,
9,
339,
347,
664,
63,
885,
8,
277,
12,
1067,
12,
2073,
12,
1676,
63,
1715,
63,
344,
29,
403,
304,
267,
408,
1002,
282,
2488,
849,
12132,
367,
282,
2073,
14,
398,
520,
635,
1676,
63,
1715,
63,
344,
26,
710,
1305,
402,
314,
1453,
2199,
1159,
1676,
12,
3303,
340,
1263,
14,
267,
408,
398,
849,
63,
17056,
275,
1592,
14,
8848,
63,
533,
63,
362,
63,
885,
8,
1100,
9,
267,
849,
63,
8848,
63,
585,
275,
378,
340,
1676,
63,
1715,
63,
344,
587,
2073,
14,
885,
267,
372,
849,
63,
17056,
14,
362,
8,
1927,
14,
354,
12,
849,
63,
8848,
63,
585,
9,
339,
347,
664,
63,
4322,
8,
277,
12,
1067,
12,
5944,
12,
1676,
63,
1715,
63,
344,
29,
403,
304,
267,
408,
13735,
282,
769,
402,
5944,
12,
8044,
314,
849,
22874,
14,
398,
3645,
314,
1021,
22874,
4310,
18494,
3472,
63,
18654,
33,
63,
2339,
64,
465,
849,
22874,
12,
267,
340,
652,
3495,
14,
398,
520,
635,
1067,
26,
710,
1056,
1067,
12,
367,
2879,
5920,
14,
267,
520,
635,
5944,
26,
437,
2600,
402,
314,
7264,
5944,
14,
267,
520,
635,
1676,
63,
1715,
63,
344,
26,
710,
1305,
402,
314,
1453,
2199,
1159,
1676,
12,
3303,
340,
1263,
14,
267,
408,
398,
22874,
275,
1052,
267,
849,
63,
17056,
275
] |
[
1898,
7129,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
624,
2371,
357,
305,
367,
12158,
1041,
421,
199,
646,
2197,
199,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
11258,
63,
793,
492,
1015,
1208,
199,
504,
11258,
63,
1208,
492,
492,
1208,
199,
504,
11258,
63,
1208,
492,
23011,
199,
646,
3816,
199,
199,
504,
13069,
492,
1067,
199,
504,
13069,
492,
1592,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
73,
1085,
78,
492,
5501,
485,
906,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
8848,
63,
3291,
275,
359,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
8838,
297,
2049,
849,
29,
709,
12,
2049,
1720,
534,
3259,
402,
12158,
4370,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
15331,
297,
2049,
849,
29,
709,
12,
2049,
1720,
534,
3259,
402,
3301,
19076,
4370,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
20249,
2634,
297,
2049,
849,
29,
709,
12,
2049,
1720,
534,
3259,
402,
17754,
2634,
4370,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
71,
528,
27601,
297,
2049,
849,
29,
5279,
12,
2049,
1720,
534,
7316,
5982,
402,
4887,
12,
315,
486,
528,
27601,
12,
4370,
283,
490,
283,
509,
12158,
436,
19076,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
27376,
297,
2049,
849,
29,
709,
12,
2049,
1720,
534,
3259,
402,
3301,
6902,
83,
4370,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
8848,
63,
5751,
63,
71,
528,
27601,
297,
2049,
849,
29,
5279,
12,
2049,
1720,
534,
7316,
5982,
402,
4887,
12,
315,
486,
528,
27601,
12,
4370,
283,
490,
283,
509,
6902,
83,
1126,
2199,
659,
272,
4810,
14,
3241,
9985,
360,
20522,
63,
14691,
297,
2049,
849,
29,
24,
20543,
12,
2049,
1720,
534,
3259,
402,
4696,
5133,
282,
25476,
12261,
659,
272,
4810,
14,
3241,
9985,
360,
8111,
63,
6635,
297,
2049,
849,
29,
16,
12,
2049,
1720,
534,
2353,
402,
31494,
5133,
4503,
365,
9236,
379,
659,
272,
4810,
14,
3241,
9985,
360,
988,
63,
474,
297,
2049,
849,
29,
16,
12,
2049,
1720,
534,
3259,
402,
4696,
3382,
13372,
4503,
9236,
397,
659,
272,
4810,
14,
19340,
360,
8848,
63,
3090,
297,
2049,
849,
534,
12372,
14,
8848,
14,
8882,
17610,
6158,
297,
2049,
1720,
534,
2698,
5253,
370,
675,
367,
12132,
5920,
659,
272,
4810,
14,
10349,
9985,
360,
1180,
63,
885,
63,
8848,
63,
533,
297,
355,
849,
29,
549,
12,
355,
1720,
534,
1327,
5921,
503,
28421,
675,
402,
849,
12132,
1021,
283,
2151,
283,
1045,
849,
12132,
8038,
272,
4810,
14,
3241,
9985,
360,
529,
63,
2405,
63,
890,
63,
3097,
297,
2049,
849,
4022,
17,
12,
2049,
1720,
534,
4261,
1568,
4370,
1126,
3301,
12,
315,
486,
528,
27601,
659,
1622,
199,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
2683,
63,
3291,
8,
8848,
63,
3291,
9,
421,
199,
533,
28822,
17610,
6158,
8,
785,
304,
339,
408,
6158,
370,
5147,
1104,
370,
15814,
434,
402,
22874,
14,
339,
6121,
6127,
370,
3332,
12132,
2556,
14,
272,
710,
849,
5253,
7678,
19030,
397,
314,
2257,
3050,
14,
272,
408,
339,
347,
664,
63,
991,
63,
1715,
8,
277,
12,
1067,
12,
2199,
63,
344,
12,
2073,
63,
354,
304,
267,
408,
1002,
282,
2488,
12132,
701,
2199,
1041,
398,
372,
1592,
14,
8848,
63,
362,
8,
1100,
12,
2199,
63,
344,
12,
2073,
63,
354,
9,
339,
347,
664,
63,
991,
63,
533,
8,
277,
12,
1067,
12,
12132,
63,
533,
12,
2073,
63,
354,
304,
267,
408,
1002,
282,
2488,
12132,
701,
12132,
1021,
1041,
398,
372,
1592,
14,
8848,
63,
533,
63,
362,
8,
1100,
12,
12132,
63,
533,
12,
2073,
63,
354,
9,
339,
347,
664,
63,
885,
8,
277,
12,
1067,
12,
2073,
12,
1676,
63,
1715,
63,
344,
29,
403,
304,
267,
408,
1002,
282,
2488,
849,
12132,
367,
282,
2073,
14,
398,
520,
635,
1676,
63,
1715,
63,
344,
26,
710,
1305,
402,
314,
1453,
2199,
1159,
1676,
12,
3303,
340,
1263,
14,
267,
408,
398,
849,
63,
17056,
275,
1592,
14,
8848,
63,
533,
63,
362,
63,
885,
8,
1100,
9,
267,
849,
63,
8848,
63,
585,
275,
378,
340,
1676,
63,
1715,
63,
344,
587,
2073,
14,
885,
267,
372,
849,
63,
17056,
14,
362,
8,
1927,
14,
354,
12,
849,
63,
8848,
63,
585,
9,
339,
347,
664,
63,
4322,
8,
277,
12,
1067,
12,
5944,
12,
1676,
63,
1715,
63,
344,
29,
403,
304,
267,
408,
13735,
282,
769,
402,
5944,
12,
8044,
314,
849,
22874,
14,
398,
3645,
314,
1021,
22874,
4310,
18494,
3472,
63,
18654,
33,
63,
2339,
64,
465,
849,
22874,
12,
267,
340,
652,
3495,
14,
398,
520,
635,
1067,
26,
710,
1056,
1067,
12,
367,
2879,
5920,
14,
267,
520,
635,
5944,
26,
437,
2600,
402,
314,
7264,
5944,
14,
267,
520,
635,
1676,
63,
1715,
63,
344,
26,
710,
1305,
402,
314,
1453,
2199,
1159,
1676,
12,
3303,
340,
1263,
14,
267,
408,
398,
22874,
275,
1052,
267,
849,
63,
17056,
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,
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
# pylint: disable=protected-access
# pylint: disable=invalid-name
# TODO(user): Move common APIs to parent class.
class Mapper(shard_life_cycle._ShardLifeCycle):
"""Interface user's mapper should implement.
Each shard initiates one instance. The instance is pickled
and unpickled if a shard can't finish within the boundary of a single
task (a.k.a a slice of the shard).
Upon shard retry, a new instance will be used.
Upon slice retry, the instance is unpickled from its state
at the end of last slice.
Be wary of the size of your mapper instances. They have to be persisted
across slices.
"""
def __init__(self):
"""Init.
Init must not take additional arguments.
"""
pass
def __call__(self, slice_ctx, val):
"""Called for every value yielded by input reader.
Normal case:
This method is invoked exactly once on each input value. If an
output writer is provided, this method can repeated call ctx.emit to
write to output writer.
On retries:
Upon slice retry, some input value may have been processed by
the previous attempt. This should not be a problem if your logic
is idempotent (e.g write to datastore by key) but could be a
problem otherwise (e.g write to cloud storage) and may result
in duplicates.
Advanced usage:
Implementation can mimic combiner by tallying in-memory and
and emit when memory is filling up or when end_slice() is called.
CAUTION! Carefully tune to not to exceed memory limit or request deadline.
Args:
slice_ctx: map_job_context.SliceContext object.
val: a single value yielded by your input reader. The type
depends on the input reader. For example, some may yield a single
datastore entity, others may yield a (int, str) tuple.
"""
pass
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
624,
4267,
367,
922,
3247,
7796,
1041,
199,
199,
504,
2341,
5270,
492,
11814,
63,
13602,
63,
7612,
199,
199,
3,
4287,
26,
3507,
29,
6798,
13,
2732,
199,
3,
4287,
26,
3507,
29,
3197,
13,
354,
421,
199,
3,
3254,
8,
751,
304,
14171,
2863,
15913,
370,
1676,
1021,
14,
199,
533,
9672,
529,
8,
10810,
63,
13602,
63,
7612,
423,
20019,
22637,
15302,
304,
523,
408,
4267,
922,
1159,
7796,
1077,
5669,
14,
819,
7048,
11814,
11023,
2335,
1373,
1256,
14,
710,
1256,
365,
18731,
523,
436,
625,
20428,
340,
282,
11814,
883,
1133,
9578,
4453,
314,
8424,
402,
282,
2849,
523,
2120,
334,
65,
14,
75,
14,
65,
282,
6014,
402,
314,
11814,
680,
819,
738,
678,
11814,
7269,
12,
282,
892,
1256,
911,
506,
1202,
14,
819,
738,
678,
6014,
7269,
12,
314,
1256,
365,
625,
20428,
687,
2399,
1174,
523,
737,
314,
1284,
402,
2061,
6014,
14,
819,
6423,
336,
695,
402,
314,
1568,
402,
2195,
7796,
4454,
14,
9322,
1172,
370,
506,
1126,
24925,
523,
9371,
17184,
14,
523,
408,
819,
347,
636,
826,
721,
277,
304,
272,
408,
9346,
14,
339,
21026,
1471,
440,
5452,
4722,
2368,
14,
272,
408,
272,
986,
819,
347,
636,
1250,
721,
277,
12,
6014,
63,
3799,
12,
1139,
304,
272,
408,
10474,
367,
4036,
574,
28653,
701,
1324,
7002,
14,
339,
11514,
1930,
26,
272,
961,
1083,
365,
10302,
8840,
5403,
641,
1924,
1324,
574,
14,
982,
376,
272,
1072,
7060,
365,
2741,
12,
642,
1083,
883,
10877,
1240,
4027,
14,
8159,
370,
272,
2218,
370,
1072,
7060,
14,
339,
4068,
10086,
26,
272,
738,
678,
6014,
7269,
12,
2005,
1324,
574,
1443,
1172,
2757,
7686,
701,
272,
314,
4136,
7427,
14,
961,
1077,
440,
506,
282,
5160,
340,
2195,
9661,
272,
365,
32122,
334,
69,
14,
71,
2218,
370,
12007,
701,
790,
9,
1325,
4293,
506,
282,
272,
5160,
4257,
334,
69,
14,
71,
2218,
370,
8002,
4887,
9,
436,
1443,
754,
272,
315,
15755,
14,
339,
32445,
4503,
26,
272,
24425,
883,
24102,
530,
5300,
16187,
701,
307,
1183,
316,
315,
13,
4844,
436,
272,
436,
8689,
1380,
4402,
365,
32499,
1536,
503,
1380,
1284,
63,
5224,
342,
365,
2797,
14,
272,
7240,
27129,
1,
8790,
1121,
8525,
307,
11474,
370,
440,
370,
24068,
4402,
2304,
503,
1056,
23081,
14,
339,
3033,
26,
489,
6014,
63,
3799,
26,
2341,
63,
2423,
63,
1100,
14,
14034,
2998,
909,
14,
489,
1139,
26,
282,
2849,
574,
28653,
701,
2195,
1324,
7002,
14,
710,
730,
267,
8350,
641,
314,
1324,
7002,
14,
2104,
2893,
12,
2005,
1443,
1995,
282,
2849,
267,
12007,
4642,
12,
11789,
1443,
1995,
282,
334,
442,
12,
620,
9,
2008,
14,
272,
408,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
624,
4267,
367,
922,
3247,
7796,
1041,
199,
199,
504,
2341,
5270,
492,
11814,
63,
13602,
63,
7612,
199,
199,
3,
4287,
26,
3507,
29,
6798,
13,
2732,
199,
3,
4287,
26,
3507,
29,
3197,
13,
354,
421,
199,
3,
3254,
8,
751,
304,
14171,
2863,
15913,
370,
1676,
1021,
14,
199,
533,
9672,
529,
8,
10810,
63,
13602,
63,
7612,
423,
20019,
22637,
15302,
304,
523,
408,
4267,
922,
1159,
7796,
1077,
5669,
14,
819,
7048,
11814,
11023,
2335,
1373,
1256,
14,
710,
1256,
365,
18731,
523,
436,
625,
20428,
340,
282,
11814,
883,
1133,
9578,
4453,
314,
8424,
402,
282,
2849,
523,
2120,
334,
65,
14,
75,
14,
65,
282,
6014,
402,
314,
11814,
680,
819,
738,
678,
11814,
7269,
12,
282,
892,
1256,
911,
506,
1202,
14,
819,
738,
678,
6014,
7269,
12,
314,
1256,
365,
625,
20428,
687,
2399,
1174,
523,
737,
314,
1284,
402,
2061,
6014,
14,
819,
6423,
336,
695,
402,
314,
1568,
402,
2195,
7796,
4454,
14,
9322,
1172,
370,
506,
1126,
24925,
523,
9371,
17184,
14,
523,
408,
819,
347,
636,
826,
721,
277,
304,
272,
408,
9346,
14,
339,
21026,
1471,
440,
5452,
4722,
2368,
14,
272,
408,
272,
986,
819,
347,
636,
1250,
721,
277,
12,
6014,
63,
3799,
12,
1139,
304,
272,
408,
10474,
367,
4036,
574,
28653,
701,
1324,
7002,
14,
339,
11514,
1930,
26,
272,
961,
1083,
365,
10302,
8840,
5403,
641,
1924,
1324,
574,
14,
982,
376,
272,
1072,
7060,
365,
2741,
12,
642,
1083,
883,
10877,
1240,
4027,
14,
8159,
370,
272,
2218,
370,
1072,
7060,
14,
339,
4068,
10086,
26,
272,
738,
678,
6014,
7269,
12,
2005,
1324,
574,
1443,
1172,
2757,
7686,
701,
272,
314,
4136,
7427,
14,
961,
1077,
440,
506,
282,
5160,
340,
2195,
9661,
272,
365,
32122,
334,
69,
14,
71,
2218,
370,
12007,
701,
790,
9,
1325,
4293,
506,
282,
272,
5160,
4257,
334,
69,
14,
71,
2218,
370,
8002,
4887,
9,
436,
1443,
754,
272,
315,
15755,
14,
339,
32445,
4503,
26,
272,
24425,
883,
24102,
530,
5300,
16187,
701,
307,
1183,
316,
315,
13,
4844,
436,
272,
436,
8689,
1380,
4402,
365,
32499,
1536,
503,
1380,
1284,
63,
5224,
342,
365,
2797,
14,
272,
7240,
27129,
1,
8790,
1121,
8525,
307,
11474,
370,
440,
370,
24068,
4402,
2304,
503,
1056,
23081,
14,
339,
3033,
26,
489,
6014,
63,
3799,
26,
2341,
63,
2423,
63,
1100,
14,
14034,
2998,
909,
14,
489,
1139,
26,
282,
2849,
574,
28653,
701,
2195,
1324,
7002,
14,
710,
730,
267,
8350,
641,
314,
1324,
7002,
14,
2104,
2893,
12,
2005,
1443,
1995,
282,
2849,
267,
12007,
4642,
12,
11789,
1443,
1995,
282,
334,
442,
12,
620,
9,
2008,
14,
272,
408,
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,
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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
] |
youprofit/phantomjs
|
src/qt/qtwebkit/Tools/Scripts/webkitpy/common/thread/messagepump.py
|
151
|
2482
|
# Copyright (c) 2010 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.
class MessagePumpDelegate(object):
def schedule(self, interval, callback):
raise NotImplementedError, "subclasses must implement"
def message_available(self, message):
raise NotImplementedError, "subclasses must implement"
def final_message_delivered(self):
raise NotImplementedError, "subclasses must implement"
class MessagePump(object):
interval = 10 # seconds
def __init__(self, delegate, message_queue):
self._delegate = delegate
self._message_queue = message_queue
self._schedule()
def _schedule(self):
self._delegate.schedule(self.interval, self._callback)
def _callback(self):
(messages, is_running) = self._message_queue.take_all()
for message in messages:
self._delegate.message_available(message)
if not is_running:
self._delegate.final_message_delivered()
return
self._schedule()
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
7129,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
533,
6430,
48,
1220,
21553,
8,
785,
304,
272,
347,
8732,
8,
277,
12,
6252,
12,
3233,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
339,
347,
1245,
63,
4561,
8,
277,
12,
1245,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
339,
347,
4242,
63,
1188,
63,
30480,
8,
277,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
421,
199,
533,
6430,
48,
1220,
8,
785,
304,
272,
6252,
275,
1616,
327,
4696,
339,
347,
636,
826,
721,
277,
12,
13080,
12,
1245,
63,
1825,
304,
267,
291,
423,
15286,
275,
13080,
267,
291,
423,
1188,
63,
1825,
275,
1245,
63,
1825,
267,
291,
423,
7211,
342,
339,
347,
485,
7211,
8,
277,
304,
267,
291,
423,
15286,
14,
7211,
8,
277,
14,
4284,
12,
291,
423,
3058,
9,
339,
347,
485,
3058,
8,
277,
304,
267,
334,
3431,
12,
365,
63,
5720,
9,
275,
291,
423,
1188,
63,
1825,
14,
11066,
63,
452,
342,
267,
367,
1245,
315,
3788,
26,
288,
291,
423,
15286,
14,
1188,
63,
4561,
8,
1188,
9,
267,
340,
440,
365,
63,
5720,
26,
288,
291,
423,
15286,
14,
5094,
63,
1188,
63,
30480,
342,
288,
372,
267,
291,
423,
7211,
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
] |
[
1898,
334,
67,
9,
7129,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
533,
6430,
48,
1220,
21553,
8,
785,
304,
272,
347,
8732,
8,
277,
12,
6252,
12,
3233,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
339,
347,
1245,
63,
4561,
8,
277,
12,
1245,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
339,
347,
4242,
63,
1188,
63,
30480,
8,
277,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
421,
199,
533,
6430,
48,
1220,
8,
785,
304,
272,
6252,
275,
1616,
327,
4696,
339,
347,
636,
826,
721,
277,
12,
13080,
12,
1245,
63,
1825,
304,
267,
291,
423,
15286,
275,
13080,
267,
291,
423,
1188,
63,
1825,
275,
1245,
63,
1825,
267,
291,
423,
7211,
342,
339,
347,
485,
7211,
8,
277,
304,
267,
291,
423,
15286,
14,
7211,
8,
277,
14,
4284,
12,
291,
423,
3058,
9,
339,
347,
485,
3058,
8,
277,
304,
267,
334,
3431,
12,
365,
63,
5720,
9,
275,
291,
423,
1188,
63,
1825,
14,
11066,
63,
452,
342,
267,
367,
1245,
315,
3788,
26,
288,
291,
423,
15286,
14,
1188,
63,
4561,
8,
1188,
9,
267,
340,
440,
365,
63,
5720,
26,
288,
291,
423,
15286,
14,
5094,
63,
1188,
63,
30480,
342,
288,
372,
267,
291,
423,
7211,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sinergatis/pathagar
|
accounts/migrations/0002_auto_20160222_1003.py
|
2
|
2599
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='profile',
name='favourite_snack',
),
migrations.AlterField(
model_name='profile',
name='language',
field=models.CharField(default=b'fr', help_text='Default language.', max_length=5, verbose_name='language', choices=[(b'af', b'Afrikaans'), (b'ar', b'Arabic'), (b'ast', b'Asturian'), (b'az', b'Azerbaijani'), (b'bg', b'Bulgarian'), (b'be', b'Belarusian'), (b'bn', b'Bengali'), (b'br', b'Breton'), (b'bs', b'Bosnian'), (b'ca', b'Catalan'), (b'cs', b'Czech'), (b'cy', b'Welsh'), (b'da', b'Danish'), (b'de', b'German'), (b'el', b'Greek'), (b'en', b'English'), (b'en-au', b'Australian English'), (b'en-gb', b'British English'), (b'eo', b'Esperanto'), (b'es', b'Spanish'), (b'es-ar', b'Argentinian Spanish'), (b'es-mx', b'Mexican Spanish'), (b'es-ni', b'Nicaraguan Spanish'), (b'es-ve', b'Venezuelan Spanish'), (b'et', b'Estonian'), (b'eu', b'Basque'), (b'fa', b'Persian'), (b'fi', b'Finnish'), (b'fr', b'French'), (b'fy', b'Frisian'), (b'ga', b'Irish'), (b'gl', b'Galician'), (b'he', b'Hebrew'), (b'hi', b'Hindi'), (b'hr', b'Croatian'), (b'hu', b'Hungarian'), (b'ia', b'Interlingua'), (b'id', b'Indonesian'), (b'io', b'Ido'), (b'is', b'Icelandic'), (b'it', b'Italian'), (b'ja', b'Japanese'), (b'ka', b'Georgian'), (b'kk', b'Kazakh'), (b'km', b'Khmer'), (b'kn', b'Kannada'), (b'ko', b'Korean'), (b'lb', b'Luxembourgish'), (b'lt', b'Lithuanian'), (b'lv', b'Latvian'), (b'mk', b'Macedonian'), (b'ml', b'Malayalam'), (b'mn', b'Mongolian'), (b'mr', b'Marathi'), (b'my', b'Burmese'), (b'nb', b'Norwegian Bokmal'), (b'ne', b'Nepali'), (b'nl', b'Dutch'), (b'nn', b'Norwegian Nynorsk'), (b'os', b'Ossetic'), (b'pa', b'Punjabi'), (b'pl', b'Polish'), (b'pt', b'Portuguese'), (b'pt-br', b'Brazilian Portuguese'), (b'ro', b'Romanian'), (b'ru', b'Russian'), (b'sk', b'Slovak'), (b'sl', b'Slovenian'), (b'sq', b'Albanian'), (b'sr', b'Serbian'), (b'sr-latn', b'Serbian Latin'), (b'sv', b'Swedish'), (b'sw', b'Swahili'), (b'ta', b'Tamil'), (b'te', b'Telugu'), (b'th', b'Thai'), (b'tr', b'Turkish'), (b'tt', b'Tatar'), (b'udm', b'Udmurt'), (b'uk', b'Ukrainian'), (b'ur', b'Urdu'), (b'vi', b'Vietnamese'), (b'zh-cn', b'Simplified Chinese'), (b'zh-hans', b'Simplified Chinese'), (b'zh-hant', b'Traditional Chinese'), (b'zh-tw', b'Traditional Chinese')]),
),
]
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
697,
492,
6180,
12,
1709,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
8370,
297,
283,
4183,
63,
2747,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
5587,
792,
8,
288,
1402,
63,
354,
534,
2913,
297,
288,
536,
534,
30763,
567,
1175,
63,
5167,
564,
297,
267,
2318,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
2913,
297,
288,
536,
534,
3671,
297,
288,
901,
29,
992,
14,
2183,
8,
885,
29,
66,
7,
4391,
297,
1720,
63,
505,
534,
2698,
2637,
3130,
1390,
63,
1267,
29,
21,
12,
3376,
63,
354,
534,
3671,
297,
3415,
17497,
66,
7,
2756,
297,
330,
7,
14799,
322,
7351,
796,
659,
334,
66,
7,
285,
297,
330,
7,
33,
24176,
659,
334,
66,
7,
1810,
297,
330,
7,
33,
270,
2302,
290,
659,
334,
66,
7,
4651,
297,
330,
7,
33,
2282,
2470,
7879,
26455,
659,
334,
66,
7,
6856,
297,
330,
7,
34,
27092,
15289,
659,
334,
66,
7,
1235,
297,
330,
7,
34,
352,
285,
85,
6214,
659,
334,
66,
7,
10472,
297,
330,
7,
34,
22329,
659,
334,
66,
7,
3289,
297,
330,
7,
34,
264,
1860,
659,
334,
66,
7,
1533,
297,
330,
7,
34,
736,
78,
5653,
659,
334,
66,
7,
696,
297,
330,
7,
35,
7539,
290,
659,
334,
66,
7,
1259,
297,
330,
7,
35,
806,
335,
659,
334,
66,
7,
1480,
297,
330,
7,
55,
352,
609,
659,
334,
66,
5121,
65,
297,
330,
7,
29336,
2453,
659,
334,
66,
5121,
69,
297,
330,
7,
27866,
1237,
659,
334,
66,
7,
352,
297,
330,
7,
29480,
659,
334,
66,
7,
287,
297,
330,
7,
19410,
659,
334,
66,
7,
287,
13,
3844,
297,
330,
7,
33,
11409,
25861,
20144,
659,
334,
66,
7,
287,
13,
4908,
297,
330,
7,
34,
322,
23184,
20144,
659,
334,
66,
7,
20805,
297,
330,
7,
21658,
529,
290,
475,
659,
334,
66,
7,
397,
297,
330,
7,
23717,
2453,
659,
334,
66,
7,
397,
13,
285,
297,
330,
7,
6373,
484,
2730,
290,
32091,
2453,
659,
334,
66,
7,
397,
13,
9457,
297,
330,
7,
45,
476,
530,
290,
32091,
2453,
659,
334,
66,
7,
397,
13,
8445,
297,
330,
7,
46,
530,
285,
643,
7856,
32091,
2453,
659,
334,
66,
7,
397,
13,
432,
297,
330,
7,
54,
6349,
90,
310,
1502,
32091,
2453,
659,
334,
66,
7,
386,
297,
330,
7,
9169,
265,
5653,
659,
334,
66,
7,
16913,
297,
330,
7,
34,
305,
544,
659,
334,
66,
7,
667,
297,
330,
7,
2623,
6214,
659,
334,
66,
7,
329,
297,
330,
7,
8694,
78,
2453,
659,
334,
66,
7,
4391,
297,
330,
7,
38,
15148,
659,
334,
66,
7,
1399,
297,
330,
7,
22533,
6214,
659,
334,
66,
7,
5294,
297,
330,
7,
41,
322,
609,
659,
334,
66,
7,
3528,
297,
330,
7,
39,
17999,
5653,
659,
334,
66,
7,
426,
297,
330,
7,
1966,
15850,
659,
334,
66,
7,
5812,
297,
330,
7,
40,
3558,
659,
334,
66,
7,
6271,
297,
330,
7,
35,
293,
2159,
290,
659,
334,
66,
7,
10616,
297,
330,
7,
40,
25364,
659,
334,
66,
7,
4674,
297,
330,
7,
2620,
2983,
1458,
659,
334,
66,
7,
344,
297,
330,
7,
607,
4456,
6214,
659,
334,
66,
7,
2308,
297,
330,
7,
41,
1117,
659,
334,
66,
7,
374,
297,
330,
7,
41,
301,
1502,
5000,
659,
334,
66,
7,
390,
297,
330,
7,
7940,
25861,
659,
334,
66,
7,
3387,
297,
330,
7,
42,
30699,
659,
334,
66,
7,
7351,
297,
330,
7,
4240,
1308,
5653,
659,
334,
66,
7,
16247,
297,
330,
7,
43,
4651,
1151,
72,
659,
334,
66,
7,
14595,
297,
330,
7,
43,
72,
2626,
659,
334,
66,
7,
18974,
297,
330,
7,
43,
1189,
10641,
659,
334,
66,
7,
7697,
297,
330,
7,
43,
16293,
659,
334,
66,
7,
6374,
297,
330,
7,
18176,
1845,
887,
567,
71,
2453,
659,
334,
66,
7,
4116,
297,
330,
7,
44,
448,
7856,
5653,
659,
334,
66,
7,
6371,
297,
330,
7,
22510,
433,
290,
659,
334,
66,
6704,
75,
297,
330,
7,
11903,
6867,
265,
5653,
659,
334,
66,
6704,
76,
297,
330,
7,
31147,
1187,
279,
455,
659,
334,
66,
6704,
78,
297,
330,
7,
20393,
317,
290,
659,
334,
66,
6704,
82,
297,
330,
7,
10570,
1619,
73,
659,
334,
66,
6704,
89,
297,
330,
7,
34,
300,
278,
261,
659,
334,
66,
7,
4994,
297,
330,
7,
23008,
1129,
71,
5653,
699,
745,
2174,
659,
334,
66,
7,
685,
297,
330,
7,
46,
1545,
10874,
659,
334,
66,
7,
7530,
297,
330,
7,
36,
337,
335,
659,
334,
66,
7,
4411,
297,
330,
7,
23008,
1129,
71,
5653,
653,
1236,
269,
1339,
659,
334,
66,
7,
736,
297,
330,
7,
24351,
261,
764,
659,
334,
66,
7,
387,
297,
330,
7,
48,
324,
74,
14677,
659,
334,
66,
7,
1168,
297,
330,
7,
1575,
1891,
659,
334,
66,
7,
541,
297,
330,
7,
4313,
1518,
310,
261,
659,
334,
66,
7,
541,
13,
3289,
297,
330,
7,
17171,
90,
1638,
290,
10977,
1518,
310,
261,
659,
334,
66,
7,
293,
297,
330,
7,
50,
21604,
5653,
659,
334,
66,
7,
6558,
297,
330,
7,
50,
8630,
659,
334,
66,
1159,
75,
297,
330,
7,
51,
32555,
1151,
659,
334,
66,
1159,
76,
297,
330,
7,
51,
320,
1856,
5653,
659,
334,
66,
1159,
81,
297,
330,
7,
2439,
13206,
5653,
659,
334,
66,
1159,
82,
297,
330,
7,
1505,
9662,
659,
334,
66,
1159,
82,
13,
4452,
78,
297,
330,
7,
1505,
9662,
23864,
659,
334,
66,
1159,
86,
297,
330,
7,
51,
1129,
29159,
659,
334,
66,
1159,
87,
297,
330,
7,
51,
758,
72,
1638,
659,
334,
66,
1133,
65,
297,
330,
7,
52,
455,
382,
659,
334,
66,
1133,
69,
297,
330,
7,
52,
352,
1518,
85,
659,
334,
66,
1133,
72,
297,
330,
7,
52,
17945,
659,
334,
66,
1133,
82,
297,
330,
7,
27438,
75,
2453,
659
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
697,
492,
6180,
12,
1709,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
8370,
297,
283,
4183,
63,
2747,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
5587,
792,
8,
288,
1402,
63,
354,
534,
2913,
297,
288,
536,
534,
30763,
567,
1175,
63,
5167,
564,
297,
267,
2318,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
2913,
297,
288,
536,
534,
3671,
297,
288,
901,
29,
992,
14,
2183,
8,
885,
29,
66,
7,
4391,
297,
1720,
63,
505,
534,
2698,
2637,
3130,
1390,
63,
1267,
29,
21,
12,
3376,
63,
354,
534,
3671,
297,
3415,
17497,
66,
7,
2756,
297,
330,
7,
14799,
322,
7351,
796,
659,
334,
66,
7,
285,
297,
330,
7,
33,
24176,
659,
334,
66,
7,
1810,
297,
330,
7,
33,
270,
2302,
290,
659,
334,
66,
7,
4651,
297,
330,
7,
33,
2282,
2470,
7879,
26455,
659,
334,
66,
7,
6856,
297,
330,
7,
34,
27092,
15289,
659,
334,
66,
7,
1235,
297,
330,
7,
34,
352,
285,
85,
6214,
659,
334,
66,
7,
10472,
297,
330,
7,
34,
22329,
659,
334,
66,
7,
3289,
297,
330,
7,
34,
264,
1860,
659,
334,
66,
7,
1533,
297,
330,
7,
34,
736,
78,
5653,
659,
334,
66,
7,
696,
297,
330,
7,
35,
7539,
290,
659,
334,
66,
7,
1259,
297,
330,
7,
35,
806,
335,
659,
334,
66,
7,
1480,
297,
330,
7,
55,
352,
609,
659,
334,
66,
5121,
65,
297,
330,
7,
29336,
2453,
659,
334,
66,
5121,
69,
297,
330,
7,
27866,
1237,
659,
334,
66,
7,
352,
297,
330,
7,
29480,
659,
334,
66,
7,
287,
297,
330,
7,
19410,
659,
334,
66,
7,
287,
13,
3844,
297,
330,
7,
33,
11409,
25861,
20144,
659,
334,
66,
7,
287,
13,
4908,
297,
330,
7,
34,
322,
23184,
20144,
659,
334,
66,
7,
20805,
297,
330,
7,
21658,
529,
290,
475,
659,
334,
66,
7,
397,
297,
330,
7,
23717,
2453,
659,
334,
66,
7,
397,
13,
285,
297,
330,
7,
6373,
484,
2730,
290,
32091,
2453,
659,
334,
66,
7,
397,
13,
9457,
297,
330,
7,
45,
476,
530,
290,
32091,
2453,
659,
334,
66,
7,
397,
13,
8445,
297,
330,
7,
46,
530,
285,
643,
7856,
32091,
2453,
659,
334,
66,
7,
397,
13,
432,
297,
330,
7,
54,
6349,
90,
310,
1502,
32091,
2453,
659,
334,
66,
7,
386,
297,
330,
7,
9169,
265,
5653,
659,
334,
66,
7,
16913,
297,
330,
7,
34,
305,
544,
659,
334,
66,
7,
667,
297,
330,
7,
2623,
6214,
659,
334,
66,
7,
329,
297,
330,
7,
8694,
78,
2453,
659,
334,
66,
7,
4391,
297,
330,
7,
38,
15148,
659,
334,
66,
7,
1399,
297,
330,
7,
22533,
6214,
659,
334,
66,
7,
5294,
297,
330,
7,
41,
322,
609,
659,
334,
66,
7,
3528,
297,
330,
7,
39,
17999,
5653,
659,
334,
66,
7,
426,
297,
330,
7,
1966,
15850,
659,
334,
66,
7,
5812,
297,
330,
7,
40,
3558,
659,
334,
66,
7,
6271,
297,
330,
7,
35,
293,
2159,
290,
659,
334,
66,
7,
10616,
297,
330,
7,
40,
25364,
659,
334,
66,
7,
4674,
297,
330,
7,
2620,
2983,
1458,
659,
334,
66,
7,
344,
297,
330,
7,
607,
4456,
6214,
659,
334,
66,
7,
2308,
297,
330,
7,
41,
1117,
659,
334,
66,
7,
374,
297,
330,
7,
41,
301,
1502,
5000,
659,
334,
66,
7,
390,
297,
330,
7,
7940,
25861,
659,
334,
66,
7,
3387,
297,
330,
7,
42,
30699,
659,
334,
66,
7,
7351,
297,
330,
7,
4240,
1308,
5653,
659,
334,
66,
7,
16247,
297,
330,
7,
43,
4651,
1151,
72,
659,
334,
66,
7,
14595,
297,
330,
7,
43,
72,
2626,
659,
334,
66,
7,
18974,
297,
330,
7,
43,
1189,
10641,
659,
334,
66,
7,
7697,
297,
330,
7,
43,
16293,
659,
334,
66,
7,
6374,
297,
330,
7,
18176,
1845,
887,
567,
71,
2453,
659,
334,
66,
7,
4116,
297,
330,
7,
44,
448,
7856,
5653,
659,
334,
66,
7,
6371,
297,
330,
7,
22510,
433,
290,
659,
334,
66,
6704,
75,
297,
330,
7,
11903,
6867,
265,
5653,
659,
334,
66,
6704,
76,
297,
330,
7,
31147,
1187,
279,
455,
659,
334,
66,
6704,
78,
297,
330,
7,
20393,
317,
290,
659,
334,
66,
6704,
82,
297,
330,
7,
10570,
1619,
73,
659,
334,
66,
6704,
89,
297,
330,
7,
34,
300,
278,
261,
659,
334,
66,
7,
4994,
297,
330,
7,
23008,
1129,
71,
5653,
699,
745,
2174,
659,
334,
66,
7,
685,
297,
330,
7,
46,
1545,
10874,
659,
334,
66,
7,
7530,
297,
330,
7,
36,
337,
335,
659,
334,
66,
7,
4411,
297,
330,
7,
23008,
1129,
71,
5653,
653,
1236,
269,
1339,
659,
334,
66,
7,
736,
297,
330,
7,
24351,
261,
764,
659,
334,
66,
7,
387,
297,
330,
7,
48,
324,
74,
14677,
659,
334,
66,
7,
1168,
297,
330,
7,
1575,
1891,
659,
334,
66,
7,
541,
297,
330,
7,
4313,
1518,
310,
261,
659,
334,
66,
7,
541,
13,
3289,
297,
330,
7,
17171,
90,
1638,
290,
10977,
1518,
310,
261,
659,
334,
66,
7,
293,
297,
330,
7,
50,
21604,
5653,
659,
334,
66,
7,
6558,
297,
330,
7,
50,
8630,
659,
334,
66,
1159,
75,
297,
330,
7,
51,
32555,
1151,
659,
334,
66,
1159,
76,
297,
330,
7,
51,
320,
1856,
5653,
659,
334,
66,
1159,
81,
297,
330,
7,
2439,
13206,
5653,
659,
334,
66,
1159,
82,
297,
330,
7,
1505,
9662,
659,
334,
66,
1159,
82,
13,
4452,
78,
297,
330,
7,
1505,
9662,
23864,
659,
334,
66,
1159,
86,
297,
330,
7,
51,
1129,
29159,
659,
334,
66,
1159,
87,
297,
330,
7,
51,
758,
72,
1638,
659,
334,
66,
1133,
65,
297,
330,
7,
52,
455,
382,
659,
334,
66,
1133,
69,
297,
330,
7,
52,
352,
1518,
85,
659,
334,
66,
1133,
72,
297,
330,
7,
52,
17945,
659,
334,
66,
1133,
82,
297,
330,
7,
27438,
75,
2453,
659,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
marcmo/delegates
|
.ycm_extra_conf.py
|
2
|
6345
|
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# 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 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.
#
# For more information, please refer to <http://unlicense.org/>
import os
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall',
'-Wextra',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
# You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM
# source code needs it.
'-DUSE_CLANG_COMPLETER',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=c++11',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x',
'c++',
'-isystem',
# This path will only work on OS X, but extra paths that don't exist are not
# harmful
'/System/Library/Frameworks/Python.framework/Headers',
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I',
'.',
'-I',
'include',
'-I',
'./ClangCompleter',
'-isystem',
'./tests/gmock/gtest',
'-isystem',
'./tests/gmock/gtest/include',
'-isystem',
'./tests/gmock',
'-isystem',
'./tests/gmock/include',
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break
if new_flag:
new_flags.append( new_flag )
return new_flags
def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile(
replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )
def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return {
'flags': final_flags,
'do_cache': True
}
|
mit
|
[
3,
961,
570,
365,
2845,
18233,
1334,
314,
14629,
86,
19,
12,
1314,
365,
314,
4190,
367,
314,
4618,
199,
3,
402,
2047,
14175,
1352,
14,
199,
3,
199,
3,
11842,
1159,
314,
4190,
1318,
367,
642,
570,
26,
199,
3,
199,
3,
961,
365,
2867,
436,
625,
10945,
453,
18897,
2032,
14286,
1901,
314,
4575,
2881,
14,
199,
3,
199,
3,
6184,
368,
365,
2867,
370,
1331,
12,
2811,
12,
2780,
12,
675,
12,
6555,
12,
12743,
12,
503,
199,
3,
11207,
642,
2032,
12,
1902,
315,
1350,
1233,
1824,
503,
465,
282,
10311,
199,
3,
3366,
12,
367,
1263,
12016,
12,
2414,
23012,
503,
2222,
13,
957,
23012,
12,
436,
701,
1263,
199,
3,
4910,
14,
199,
3,
199,
3,
1010,
1335,
17656,
328,
2452,
626,
27159,
4248,
1127,
3569,
12,
314,
4132,
503,
11462,
199,
3,
402,
642,
2032,
477,
10188,
1263,
436,
1006,
4248,
13518,
315,
314,
199,
3,
2032,
370,
314,
4575,
2881,
14,
2136,
1852,
642,
477,
21171,
367,
314,
22477,
3269,
199,
3,
402,
314,
4575,
737,
7031,
436,
370,
314,
477,
599,
434,
402,
4154,
946,
32030,
436,
199,
3,
3182,
1384,
14,
2136,
315,
7169,
642,
477,
21171,
370,
506,
376,
1806,
84,
2454,
402,
199,
3,
295,
472,
392,
2453,
434,
315,
1126,
8096,
24180,
402,
1006,
3451,
436,
6466,
4481,
370,
642,
199,
3,
2032,
1334,
4248,
4179,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
199,
3,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
199,
3,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
199,
3,
1621,
4825,
6461,
7000,
2334,
10610,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
199,
3,
5010,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
199,
3,
7043,
4442,
12,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
199,
3,
5010,
13198,
1621,
2334,
4141,
14,
199,
3,
199,
3,
2104,
1655,
2556,
12,
8749,
10618,
370,
665,
1014,
921,
324,
1682,
14,
1308,
3133,
199,
199,
646,
747,
199,
646,
612,
4400,
63,
1018,
199,
199,
3,
5723,
787,
314,
18653,
3285,
626,
911,
506,
1202,
315,
1930,
2337,
1159,
949,
199,
3,
18653,
3050,
663,
334,
991,
849,
12,
1373,
365,
440,
663,
680,
199,
3,
6624,
9011,
5749,
21716,
1634,
12846,
14,
1488,
654,
12,
5749,
2281,
2334,
577,
22045,
1488,
22050,
25227,
6262,
742,
3412,
3593,
1206,
2381,
14,
199,
2469,
275,
359,
199,
12418,
18018,
297,
199,
12418,
55,
2911,
297,
199,
12418,
55,
67,
4176,
2905,
13,
5819,
297,
199,
12418,
55,
889,
13,
2809,
13,
2809,
297,
199,
12418,
55,
889,
13,
3808,
31764,
13,
16358,
297,
199,
12418,
70,
3924,
297,
199,
12418,
10872,
5287,
297,
199,
3,
2047,
2948,
5,
886,
2845,
1929,
446,
36,
4701,
63,
1981,
3986,
63,
12558,
775,
540,
315,
2195,
3285,
27,
1454,
314,
1488,
9249,
199,
3,
1350,
1233,
4839,
652,
14,
199,
12418,
36,
4701,
63,
1981,
3986,
63,
12558,
775,
540,
297,
199,
3,
5749,
2281,
5025,
2596,
1441,
1,
23952,
282,
3905,
1516,
18987,
10297,
4335,
3305,
12,
25444,
7859,
1133,
5715,
1314,
199,
3,
2637,
370,
675,
1380,
1013,
5662,
2323,
14,
2002,
652,
911,
9519,
14,
8857,
590,
14,
2002,
445,
4176,
199,
3,
2323,
911,
506,
10311,
465,
445,
2323,
14,
2047,
2793,
1133,
2934,
626,
880,
12112,
26194,
4165,
199,
3,
282,
3905,
1516,
18987,
10297,
23167,
199,
3,
2104,
282,
445,
2199,
12,
1265,
3955,
663,
642,
370,
6020,
2839,
283,
67,
1020,
7,
3140,
402,
199,
3,
283,
67,
4176,
845,
1370,
199,
12418,
1516,
29,
67,
4176,
845,
297,
199,
3,
2263,
460,
314,
2011,
8377,
13538,
367,
314,
10628,
446,
88,
945,
1314,
9314,
314,
199,
3,
2637,
626,
314,
1584,
370,
506,
10311,
787,
5313,
315,
14,
961,
365,
19762,
199,
3,
12082,
367,
286,
4176,
2323,
14,
199,
3,
2104,
282,
445,
2199,
12,
1265,
3955,
663,
642,
370,
283,
67,
7,
3140,
402,
283,
67,
4176,
1370,
199,
12418,
88,
297,
199,
7,
67,
31249,
199,
12418,
374,
3045,
297,
199,
3,
961,
931,
911,
1454,
1736,
641,
4403,
1323,
12,
1325,
2402,
3792,
626,
2793,
1133,
2187,
787,
440,
199,
3,
394,
5362,
1893,
199,
9807,
3989,
15,
7424,
15,
30052,
15,
4718,
14,
4857,
15,
9883,
297,
199,
12418,
374,
3045,
297,
199,
7,
5093,
29257,
15,
2613,
297,
199,
12418,
374,
3045,
297,
199,
7,
5093,
29257,
15,
2537,
15,
16066,
15,
2613,
297,
199,
12418,
41,
297,
199,
1370,
297,
199,
12418,
41,
297,
199,
7,
2613,
297,
199,
12418,
41,
297,
199,
1370,
15,
1968,
621,
6600,
351,
297,
199,
12418,
374,
3045,
297,
199,
1370,
15,
2219,
15,
71,
1805,
15,
8385,
297,
199,
12418,
374,
3045,
297,
199,
1370,
15,
2219,
15,
71,
1805,
15,
8385,
15,
2613,
297,
199,
12418,
374,
3045,
297,
199,
1370,
15,
2219,
15,
71,
1805,
297,
199,
12418,
374,
3045,
297,
199,
1370,
15,
2219,
15,
71,
1805,
15,
2613,
297,
199,
61,
421,
199,
3,
2494,
642,
370,
314,
3679,
931,
370,
314,
4922,
334,
4609,
314,
570,
21866,
3035,
314,
199,
3,
6555,
63,
4405,
14,
1001,
570,
370,
675,
626,
3140,
402,
283,
2469,
1370,
1666,
2348,
367,
199,
3,
1655,
2436,
26,
1455,
921,
16066,
14,
29257,
14,
1308,
15,
4757,
15,
6243,
2404,
13696,
7243,
14,
1360,
199,
3,
199,
3,
2047,
883,
664,
21355,
370,
3550,
642,
570,
367,
1265,
701,
7791,
26,
199,
3,
257,
663,
8,
445,
18421,
63,
18341,
63,
29911,
63,
28442,
413,
776,
199,
3,
370,
2195,
21355,
15116,
14,
2424,
570,
14,
199,
3,
199,
3,
17536,
11336,
911,
2845,
1929,
370,
663,
642,
370,
7003,
27,
1265,
883,
2951,
1570,
314,
199,
3,
283,
2469,
7,
769,
402,
18653,
3285,
14,
3091,
3548,
626,
1488,
9249,
6337,
4440,
626,
18140,
14,
199,
863,
13696,
63,
4659,
63,
3741,
275,
2125,
199,
199,
692,
747,
14,
515,
14,
2444,
8,
18653,
63,
4659,
63,
3741,
3461,
523,
3050,
275,
612,
4400,
63,
1018,
14,
2404
] |
[
961,
570,
365,
2845,
18233,
1334,
314,
14629,
86,
19,
12,
1314,
365,
314,
4190,
367,
314,
4618,
199,
3,
402,
2047,
14175,
1352,
14,
199,
3,
199,
3,
11842,
1159,
314,
4190,
1318,
367,
642,
570,
26,
199,
3,
199,
3,
961,
365,
2867,
436,
625,
10945,
453,
18897,
2032,
14286,
1901,
314,
4575,
2881,
14,
199,
3,
199,
3,
6184,
368,
365,
2867,
370,
1331,
12,
2811,
12,
2780,
12,
675,
12,
6555,
12,
12743,
12,
503,
199,
3,
11207,
642,
2032,
12,
1902,
315,
1350,
1233,
1824,
503,
465,
282,
10311,
199,
3,
3366,
12,
367,
1263,
12016,
12,
2414,
23012,
503,
2222,
13,
957,
23012,
12,
436,
701,
1263,
199,
3,
4910,
14,
199,
3,
199,
3,
1010,
1335,
17656,
328,
2452,
626,
27159,
4248,
1127,
3569,
12,
314,
4132,
503,
11462,
199,
3,
402,
642,
2032,
477,
10188,
1263,
436,
1006,
4248,
13518,
315,
314,
199,
3,
2032,
370,
314,
4575,
2881,
14,
2136,
1852,
642,
477,
21171,
367,
314,
22477,
3269,
199,
3,
402,
314,
4575,
737,
7031,
436,
370,
314,
477,
599,
434,
402,
4154,
946,
32030,
436,
199,
3,
3182,
1384,
14,
2136,
315,
7169,
642,
477,
21171,
370,
506,
376,
1806,
84,
2454,
402,
199,
3,
295,
472,
392,
2453,
434,
315,
1126,
8096,
24180,
402,
1006,
3451,
436,
6466,
4481,
370,
642,
199,
3,
2032,
1334,
4248,
4179,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
199,
3,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
199,
3,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
199,
3,
1621,
4825,
6461,
7000,
2334,
10610,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
199,
3,
5010,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
199,
3,
7043,
4442,
12,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
199,
3,
5010,
13198,
1621,
2334,
4141,
14,
199,
3,
199,
3,
2104,
1655,
2556,
12,
8749,
10618,
370,
665,
1014,
921,
324,
1682,
14,
1308,
3133,
199,
199,
646,
747,
199,
646,
612,
4400,
63,
1018,
199,
199,
3,
5723,
787,
314,
18653,
3285,
626,
911,
506,
1202,
315,
1930,
2337,
1159,
949,
199,
3,
18653,
3050,
663,
334,
991,
849,
12,
1373,
365,
440,
663,
680,
199,
3,
6624,
9011,
5749,
21716,
1634,
12846,
14,
1488,
654,
12,
5749,
2281,
2334,
577,
22045,
1488,
22050,
25227,
6262,
742,
3412,
3593,
1206,
2381,
14,
199,
2469,
275,
359,
199,
12418,
18018,
297,
199,
12418,
55,
2911,
297,
199,
12418,
55,
67,
4176,
2905,
13,
5819,
297,
199,
12418,
55,
889,
13,
2809,
13,
2809,
297,
199,
12418,
55,
889,
13,
3808,
31764,
13,
16358,
297,
199,
12418,
70,
3924,
297,
199,
12418,
10872,
5287,
297,
199,
3,
2047,
2948,
5,
886,
2845,
1929,
446,
36,
4701,
63,
1981,
3986,
63,
12558,
775,
540,
315,
2195,
3285,
27,
1454,
314,
1488,
9249,
199,
3,
1350,
1233,
4839,
652,
14,
199,
12418,
36,
4701,
63,
1981,
3986,
63,
12558,
775,
540,
297,
199,
3,
5749,
2281,
5025,
2596,
1441,
1,
23952,
282,
3905,
1516,
18987,
10297,
4335,
3305,
12,
25444,
7859,
1133,
5715,
1314,
199,
3,
2637,
370,
675,
1380,
1013,
5662,
2323,
14,
2002,
652,
911,
9519,
14,
8857,
590,
14,
2002,
445,
4176,
199,
3,
2323,
911,
506,
10311,
465,
445,
2323,
14,
2047,
2793,
1133,
2934,
626,
880,
12112,
26194,
4165,
199,
3,
282,
3905,
1516,
18987,
10297,
23167,
199,
3,
2104,
282,
445,
2199,
12,
1265,
3955,
663,
642,
370,
6020,
2839,
283,
67,
1020,
7,
3140,
402,
199,
3,
283,
67,
4176,
845,
1370,
199,
12418,
1516,
29,
67,
4176,
845,
297,
199,
3,
2263,
460,
314,
2011,
8377,
13538,
367,
314,
10628,
446,
88,
945,
1314,
9314,
314,
199,
3,
2637,
626,
314,
1584,
370,
506,
10311,
787,
5313,
315,
14,
961,
365,
19762,
199,
3,
12082,
367,
286,
4176,
2323,
14,
199,
3,
2104,
282,
445,
2199,
12,
1265,
3955,
663,
642,
370,
283,
67,
7,
3140,
402,
283,
67,
4176,
1370,
199,
12418,
88,
297,
199,
7,
67,
31249,
199,
12418,
374,
3045,
297,
199,
3,
961,
931,
911,
1454,
1736,
641,
4403,
1323,
12,
1325,
2402,
3792,
626,
2793,
1133,
2187,
787,
440,
199,
3,
394,
5362,
1893,
199,
9807,
3989,
15,
7424,
15,
30052,
15,
4718,
14,
4857,
15,
9883,
297,
199,
12418,
374,
3045,
297,
199,
7,
5093,
29257,
15,
2613,
297,
199,
12418,
374,
3045,
297,
199,
7,
5093,
29257,
15,
2537,
15,
16066,
15,
2613,
297,
199,
12418,
41,
297,
199,
1370,
297,
199,
12418,
41,
297,
199,
7,
2613,
297,
199,
12418,
41,
297,
199,
1370,
15,
1968,
621,
6600,
351,
297,
199,
12418,
374,
3045,
297,
199,
1370,
15,
2219,
15,
71,
1805,
15,
8385,
297,
199,
12418,
374,
3045,
297,
199,
1370,
15,
2219,
15,
71,
1805,
15,
8385,
15,
2613,
297,
199,
12418,
374,
3045,
297,
199,
1370,
15,
2219,
15,
71,
1805,
297,
199,
12418,
374,
3045,
297,
199,
1370,
15,
2219,
15,
71,
1805,
15,
2613,
297,
199,
61,
421,
199,
3,
2494,
642,
370,
314,
3679,
931,
370,
314,
4922,
334,
4609,
314,
570,
21866,
3035,
314,
199,
3,
6555,
63,
4405,
14,
1001,
570,
370,
675,
626,
3140,
402,
283,
2469,
1370,
1666,
2348,
367,
199,
3,
1655,
2436,
26,
1455,
921,
16066,
14,
29257,
14,
1308,
15,
4757,
15,
6243,
2404,
13696,
7243,
14,
1360,
199,
3,
199,
3,
2047,
883,
664,
21355,
370,
3550,
642,
570,
367,
1265,
701,
7791,
26,
199,
3,
257,
663,
8,
445,
18421,
63,
18341,
63,
29911,
63,
28442,
413,
776,
199,
3,
370,
2195,
21355,
15116,
14,
2424,
570,
14,
199,
3,
199,
3,
17536,
11336,
911,
2845,
1929,
370,
663,
642,
370,
7003,
27,
1265,
883,
2951,
1570,
314,
199,
3,
283,
2469,
7,
769,
402,
18653,
3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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
] |
mpetyx/palmdrop
|
venv/lib/python2.7/site-packages/cms/plugins/text/migrations/0002_freeze.py
|
30
|
2475
|
# -*- coding: utf-8 -*-
from south.db import db
from django.db import models
from cms.plugins.text.models import *
class Migration:
def forwards(self, orm):
"Write your forwards migration here"
def backwards(self, orm):
"Write your backwards migration here"
models = {
'cms.cmsplugin': {
'Meta': {'object_name': 'CMSPlugin'},
'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
},
'cms.placeholder': {
'Meta': {'object_name': 'Placeholder'},
'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
},
'text.text': {
'Meta': {'object_name': 'Text', 'db_table': "'cmsplugin_text'"},
'body': ('django.db.models.fields.TextField', [], {}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'})
}
}
complete_apps = ['text']
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
19240,
14,
5265,
14,
505,
14,
992,
492,
627,
199,
199,
533,
12090,
26,
2286,
347,
17465,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
17465,
8367,
2348,
2,
17635,
347,
8552,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
8552,
8367,
2348,
2,
17635,
1709,
275,
469,
267,
283,
10781,
14,
4400,
30873,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
17834,
5061,
2267,
288,
283,
2489,
63,
602,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
2495,
63,
2131,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
8782,
63,
602,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
3671,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1046,
297,
283,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
1896,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
791,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
32462,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
791,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
1708,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10781,
14,
17834,
5061,
6256,
283,
2307,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
6199,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10781,
14,
20185,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
2718,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
297,
283,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
3124,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
25197,
297,
990,
791,
2307,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
82,
913,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
791,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
2350,
63,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
791,
697,
63,
1080,
356,
283,
549,
3071,
267,
1660,
267,
283,
10781,
14,
6199,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
20185,
2267,
288,
283,
885,
63,
2063,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
25197,
297,
990,
791,
2307,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
7998,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
297,
283,
697,
63,
1080,
356,
283,
549,
3071,
267,
1660,
267,
283,
505,
14,
505,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1872,
297,
283,
697,
63,
1224,
356,
3546,
4400,
30873,
63,
505,
15208,
288,
283,
2030,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
8613,
288,
283,
4400,
30873,
63,
4695,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
14298,
297,
990,
791,
475,
356,
298,
1025,
459,
10781,
14,
17834,
5061,
6256,
283,
3235,
356,
283,
549,
297,
283,
3327,
63,
498,
356,
283,
549,
3071,
267,
789,
272,
789,
339,
4890,
63,
5181,
275,
788,
505,
418,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
19240,
14,
5265,
14,
505,
14,
992,
492,
627,
199,
199,
533,
12090,
26,
2286,
347,
17465,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
17465,
8367,
2348,
2,
17635,
347,
8552,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
8552,
8367,
2348,
2,
17635,
1709,
275,
469,
267,
283,
10781,
14,
4400,
30873,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
17834,
5061,
2267,
288,
283,
2489,
63,
602,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
2495,
63,
2131,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
8782,
63,
602,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
3671,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1046,
297,
283,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
1896,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
791,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
32462,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
791,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
1708,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10781,
14,
17834,
5061,
6256,
283,
2307,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
6199,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10781,
14,
20185,
6256,
283,
2307,
356,
283,
549,
1604,
288,
283,
2718,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
297,
283,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
3124,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
25197,
297,
990,
791,
2307,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
82,
913,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
791,
697,
63,
1080,
356,
283,
549,
1604,
288,
283,
2350,
63,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
8591,
297,
990,
791,
697,
63,
1080,
356,
283,
549,
3071,
267,
1660,
267,
283,
10781,
14,
6199,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
20185,
2267,
288,
283,
885,
63,
2063,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
25197,
297,
990,
791,
2307,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
7998,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
297,
283,
697,
63,
1080,
356,
283,
549,
3071,
267,
1660,
267,
283,
505,
14,
505,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1872,
297,
283,
697,
63,
1224,
356,
3546,
4400,
30873,
63,
505,
15208,
288,
283,
2030,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
8613,
288,
283,
4400,
30873,
63,
4695,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
14298,
297,
990,
791,
475,
356,
298,
1025,
459,
10781,
14,
17834,
5061,
6256,
283,
3235,
356,
283,
549,
297,
283,
3327,
63,
498,
356,
283,
549,
3071,
267,
789,
272,
789,
339,
4890,
63,
5181,
275,
788,
505,
418,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
TeamTwisted/external_chromium_org
|
third_party/protobuf/python/google/protobuf/internal/reflection_cpp_generated_test.py
|
215
|
4054
|
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# http://code.google.com/p/protobuf/
#
# 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.
"""Unittest for reflection.py, which tests the generated C++ implementation."""
__author__ = 'jasonh@google.com (Jason Hsueh)'
import os
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp'
import unittest
from google.protobuf.internal import api_implementation
from google.protobuf.internal import more_extensions_dynamic_pb2
from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal.reflection_test import *
class ReflectionCppTest(unittest.TestCase):
def testImplementationSetting(self):
self.assertEqual('cpp', api_implementation.Type())
def testExtensionOfGeneratedTypeInDynamicFile(self):
"""Tests that a file built dynamically can extend a generated C++ type.
The C++ implementation uses a DescriptorPool that has the generated
DescriptorPool as an underlay. Typically, a type can only find
extensions in its own pool. With the python C-extension, the generated C++
extendee may be available, but not the extension. This tests that the
C-extension implements the correct special handling to make such extensions
available.
"""
pb1 = more_extensions_pb2.ExtendedMessage()
# Test that basic accessors work.
self.assertFalse(
pb1.HasExtension(more_extensions_dynamic_pb2.dynamic_int32_extension))
self.assertFalse(
pb1.HasExtension(more_extensions_dynamic_pb2.dynamic_message_extension))
pb1.Extensions[more_extensions_dynamic_pb2.dynamic_int32_extension] = 17
pb1.Extensions[more_extensions_dynamic_pb2.dynamic_message_extension].a = 24
self.assertTrue(
pb1.HasExtension(more_extensions_dynamic_pb2.dynamic_int32_extension))
self.assertTrue(
pb1.HasExtension(more_extensions_dynamic_pb2.dynamic_message_extension))
# Now serialize the data and parse to a new message.
pb2 = more_extensions_pb2.ExtendedMessage()
pb2.MergeFromString(pb1.SerializeToString())
self.assertTrue(
pb2.HasExtension(more_extensions_dynamic_pb2.dynamic_int32_extension))
self.assertTrue(
pb2.HasExtension(more_extensions_dynamic_pb2.dynamic_message_extension))
self.assertEqual(
17, pb2.Extensions[more_extensions_dynamic_pb2.dynamic_int32_extension])
self.assertEqual(
24,
pb2.Extensions[more_extensions_dynamic_pb2.dynamic_message_extension].a)
if __name__ == '__main__':
unittest.main()
|
bsd-3-clause
|
[
3168,
1182,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
11557,
699,
3043,
1192,
446,
4475,
1159,
666,
1640,
1461,
1475,
199,
3,
1898,
9079,
4475,
3277,
14,
221,
2900,
4481,
4644,
14,
199,
3,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
7204,
15,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
1358,
1770,
367,
25572,
14,
647,
12,
1314,
2295,
314,
4046,
445,
4176,
4514,
1041,
199,
199,
363,
2502,
363,
275,
283,
74,
2660,
72,
32,
3098,
14,
957,
334,
42,
2660,
869,
3309,
72,
3171,
199,
199,
646,
747,
199,
736,
14,
2314,
459,
9583,
63,
10255,
3960,
63,
11720,
63,
8947,
10320,
2594,
418,
275,
283,
5910,
7,
199,
199,
646,
2882,
199,
504,
6233,
14,
7204,
14,
4672,
492,
2986,
63,
12236,
199,
504,
6233,
14,
7204,
14,
4672,
492,
1655,
63,
5359,
63,
7764,
63,
3317,
18,
199,
504,
6233,
14,
7204,
14,
4672,
492,
1655,
63,
5359,
63,
3317,
18,
199,
504,
6233,
14,
7204,
14,
4672,
14,
14906,
63,
396,
492,
627,
421,
199,
533,
15397,
1486,
19705,
774,
8,
2796,
14,
1746,
304,
523,
347,
511,
7921,
7776,
8,
277,
304,
272,
291,
14,
629,
360,
5910,
297,
2986,
63,
12236,
14,
804,
1012,
819,
347,
511,
6382,
3466,
12706,
804,
607,
14451,
1173,
8,
277,
304,
272,
408,
2925,
626,
282,
570,
6137,
18774,
883,
12247,
282,
4046,
445,
4176,
730,
14,
339,
710,
445,
4176,
4514,
4440,
282,
28131,
5453,
626,
965,
314,
4046,
272,
28131,
5453,
465,
376,
1334,
817,
14,
26914,
12,
282,
730,
883,
1454,
2342,
272,
5478,
315,
2399,
5705,
4203,
14,
8777,
314,
2366,
445,
13,
3435,
12,
314,
4046,
445,
4176,
272,
2178,
11192,
1443,
506,
2808,
12,
1325,
440,
314,
3329,
14,
961,
2295,
626,
314,
272,
445,
13,
3435,
9031,
314,
3211,
4539,
7252,
370,
1852,
4066,
5478,
272,
2808,
14,
272,
408,
272,
10446,
17,
275,
1655,
63,
5359,
63,
3317,
18,
14,
14107,
2209,
342,
272,
327,
1379,
626,
5678,
31908,
1736,
14,
272,
291,
14,
3334,
8,
267,
10446,
17,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
430,
272,
291,
14,
3334,
8,
267,
10446,
17,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
430,
272,
10446,
17,
14,
10597,
59,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
61,
275,
5557,
272,
10446,
17,
14,
10597,
59,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
1055,
65,
275,
5504,
272,
291,
14,
1815,
8,
267,
10446,
17,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
430,
272,
291,
14,
1815,
8,
267,
10446,
17,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
430,
339,
327,
7356,
8437,
314,
666,
436,
2198,
370,
282,
892,
1245,
14,
272,
10446,
18,
275,
1655,
63,
5359,
63,
3317,
18,
14,
14107,
2209,
342,
272,
10446,
18,
14,
11359,
7671,
8,
3317,
17,
14,
9436,
1012,
339,
291,
14,
1815,
8,
267,
10446,
18,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
430,
272,
291,
14,
1815,
8,
267,
10446,
18,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
430,
272,
291,
14,
629,
8,
267,
5557,
12,
10446,
18,
14,
10597,
59,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
566,
272,
291,
14,
629,
8,
267,
5504,
12,
267,
10446,
18,
14,
10597,
59,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
1055,
65,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1182,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
11557,
699,
3043,
1192,
446,
4475,
1159,
666,
1640,
1461,
1475,
199,
3,
1898,
9079,
4475,
3277,
14,
221,
2900,
4481,
4644,
14,
199,
3,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
7204,
15,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
1358,
1770,
367,
25572,
14,
647,
12,
1314,
2295,
314,
4046,
445,
4176,
4514,
1041,
199,
199,
363,
2502,
363,
275,
283,
74,
2660,
72,
32,
3098,
14,
957,
334,
42,
2660,
869,
3309,
72,
3171,
199,
199,
646,
747,
199,
736,
14,
2314,
459,
9583,
63,
10255,
3960,
63,
11720,
63,
8947,
10320,
2594,
418,
275,
283,
5910,
7,
199,
199,
646,
2882,
199,
504,
6233,
14,
7204,
14,
4672,
492,
2986,
63,
12236,
199,
504,
6233,
14,
7204,
14,
4672,
492,
1655,
63,
5359,
63,
7764,
63,
3317,
18,
199,
504,
6233,
14,
7204,
14,
4672,
492,
1655,
63,
5359,
63,
3317,
18,
199,
504,
6233,
14,
7204,
14,
4672,
14,
14906,
63,
396,
492,
627,
421,
199,
533,
15397,
1486,
19705,
774,
8,
2796,
14,
1746,
304,
523,
347,
511,
7921,
7776,
8,
277,
304,
272,
291,
14,
629,
360,
5910,
297,
2986,
63,
12236,
14,
804,
1012,
819,
347,
511,
6382,
3466,
12706,
804,
607,
14451,
1173,
8,
277,
304,
272,
408,
2925,
626,
282,
570,
6137,
18774,
883,
12247,
282,
4046,
445,
4176,
730,
14,
339,
710,
445,
4176,
4514,
4440,
282,
28131,
5453,
626,
965,
314,
4046,
272,
28131,
5453,
465,
376,
1334,
817,
14,
26914,
12,
282,
730,
883,
1454,
2342,
272,
5478,
315,
2399,
5705,
4203,
14,
8777,
314,
2366,
445,
13,
3435,
12,
314,
4046,
445,
4176,
272,
2178,
11192,
1443,
506,
2808,
12,
1325,
440,
314,
3329,
14,
961,
2295,
626,
314,
272,
445,
13,
3435,
9031,
314,
3211,
4539,
7252,
370,
1852,
4066,
5478,
272,
2808,
14,
272,
408,
272,
10446,
17,
275,
1655,
63,
5359,
63,
3317,
18,
14,
14107,
2209,
342,
272,
327,
1379,
626,
5678,
31908,
1736,
14,
272,
291,
14,
3334,
8,
267,
10446,
17,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
430,
272,
291,
14,
3334,
8,
267,
10446,
17,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
430,
272,
10446,
17,
14,
10597,
59,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
61,
275,
5557,
272,
10446,
17,
14,
10597,
59,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
1055,
65,
275,
5504,
272,
291,
14,
1815,
8,
267,
10446,
17,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
430,
272,
291,
14,
1815,
8,
267,
10446,
17,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
430,
339,
327,
7356,
8437,
314,
666,
436,
2198,
370,
282,
892,
1245,
14,
272,
10446,
18,
275,
1655,
63,
5359,
63,
3317,
18,
14,
14107,
2209,
342,
272,
10446,
18,
14,
11359,
7671,
8,
3317,
17,
14,
9436,
1012,
339,
291,
14,
1815,
8,
267,
10446,
18,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
430,
272,
291,
14,
1815,
8,
267,
10446,
18,
14,
6362,
6382,
8,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
430,
272,
291,
14,
629,
8,
267,
5557,
12,
10446,
18,
14,
10597,
59,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
442,
708,
63,
3435,
566,
272,
291,
14,
629,
8,
267,
5504,
12,
267,
10446,
18,
14,
10597,
59,
6878,
63,
5359,
63,
7764,
63,
3317,
18,
14,
7764,
63,
1188,
63,
3435,
1055,
65,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768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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
] |
drxaero/calibre
|
src/calibre/ebooks/oeb/writer.py
|
24
|
2728
|
'''
Directory output OEBBook writer.
'''
from __future__ import with_statement
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
import os
from calibre.ebooks.oeb.base import OPF_MIME, xml2str
from calibre.ebooks.oeb.base import DirContainer, OEBError
__all__ = ['OEBWriter']
class OEBWriter(object):
DEFAULT_PROFILE = 'PRS505'
"""Default renderer profile for content written with this Writer."""
TRANSFORMS = []
"""List of transforms to apply to content written with this Writer."""
def __init__(self, version='2.0', page_map=False, pretty_print=False):
self.version = version
self.page_map = page_map
self.pretty_print = pretty_print
@classmethod
def config(cls, cfg):
"""Add any book-writing options to the :class:`Config` object
:param:`cfg`.
"""
oeb = cfg.add_group('oeb', _('OPF/NCX/etc. generation options.'))
versions = ['1.2', '2.0']
oeb('opf_version', ['--opf-version'], default='2.0', choices=versions,
help=_('OPF version to generate. Default is %default.'))
oeb('adobe_page_map', ['--adobe-page-map'], default=False,
help=_('Generate an Adobe "page-map" file if pagination '
'information is available.'))
return cfg
@classmethod
def generate(cls, opts):
"""Generate a Writer instance from command-line options."""
version = opts.opf_version
page_map = opts.adobe_page_map
pretty_print = opts.pretty_print
return cls(version=version, page_map=page_map,
pretty_print=pretty_print)
def __call__(self, oeb, path):
"""
Write the book in the :class:`OEBBook` object :param:`oeb` to a folder
at :param:`path`.
"""
version = int(self.version[0])
opfname = None
if os.path.splitext(path)[1].lower() == '.opf':
opfname = os.path.basename(path)
path = os.path.dirname(path)
if not os.path.isdir(path):
os.mkdir(path)
output = DirContainer(path, oeb.log)
for item in oeb.manifest.values():
output.write(item.href, str(item))
if version == 1:
metadata = oeb.to_opf1()
elif version == 2:
metadata = oeb.to_opf2(page_map=self.page_map)
else:
raise OEBError("Unrecognized OPF version %r" % self.version)
pretty_print = self.pretty_print
for mime, (href, data) in metadata.items():
if opfname and mime == OPF_MIME:
href = opfname
output.write(href, xml2str(data, pretty_print=pretty_print))
return
|
gpl-3.0
|
[
2344,
199,
6231,
1072,
593,
14138,
8696,
7060,
14,
199,
2344,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
363,
1682,
363,
257,
275,
283,
12006,
373,
19,
7,
199,
363,
7307,
363,
275,
283,
9300,
12,
16794,
609,
452,
377,
14,
812,
290,
6458,
6501,
665,
914,
305,
5975,
32,
6799,
14,
957,
3524,
199,
199,
646,
747,
199,
504,
19238,
14,
69,
8858,
14,
79,
2871,
14,
1095,
492,
9827,
38,
63,
17057,
12,
2748,
18,
495,
199,
504,
19238,
14,
69,
8858,
14,
79,
2871,
14,
1095,
492,
25866,
4076,
12,
593,
14138,
547,
199,
199,
363,
452,
363,
275,
788,
47,
14138,
6261,
418,
199,
199,
533,
593,
14138,
6261,
8,
785,
304,
272,
6186,
63,
16632,
275,
283,
3311,
51,
13938,
7,
272,
408,
2698,
11889,
4690,
367,
1564,
5313,
543,
642,
24441,
1041,
339,
9074,
5622,
11518,
275,
942,
272,
408,
1296,
402,
18501,
370,
4838,
370,
1564,
5313,
543,
642,
24441,
1041,
339,
347,
636,
826,
721,
277,
12,
1015,
534,
18,
14,
16,
297,
2034,
63,
1130,
29,
797,
12,
7268,
63,
1361,
29,
797,
304,
267,
291,
14,
1023,
275,
1015,
267,
291,
14,
1606,
63,
1130,
275,
2034,
63,
1130,
267,
291,
14,
9118,
63,
1361,
275,
7268,
63,
1361,
339,
768,
3744,
272,
347,
1101,
8,
1886,
12,
4810,
304,
267,
408,
1123,
1263,
6719,
13,
14827,
1511,
370,
314,
520,
533,
1705,
2028,
64,
909,
267,
520,
635,
1705,
4128,
2313,
267,
408,
267,
312,
2871,
275,
4810,
14,
525,
63,
923,
360,
79,
2871,
297,
4018,
1938,
38,
15,
6389,
56,
15,
6839,
14,
10152,
1511,
12459,
267,
5459,
275,
788,
17,
14,
18,
297,
283,
18,
14,
16,
418,
267,
312,
2871,
360,
16893,
63,
1023,
297,
14574,
16893,
13,
1023,
995,
849,
534,
18,
14,
16,
297,
3415,
29,
6234,
12,
288,
1720,
12397,
1938,
38,
1015,
370,
3550,
14,
3758,
365,
450,
885,
12459,
267,
312,
2871,
360,
5129,
1235,
63,
1606,
63,
1130,
297,
14574,
5129,
1235,
13,
1606,
13,
1130,
995,
849,
29,
797,
12,
288,
1720,
12397,
6864,
376,
437,
1117,
1235,
298,
1606,
13,
1130,
2,
570,
340,
21192,
283,
673,
283,
11697,
365,
2808,
12459,
267,
372,
4810,
339,
768,
3744,
272,
347,
3550,
8,
1886,
12,
3999,
304,
267,
408,
6864,
282,
24441,
1256,
687,
1414,
13,
604,
1511,
1041,
267,
1015,
275,
3999,
14,
16893,
63,
1023,
267,
2034,
63,
1130,
275,
3999,
14,
5129,
1235,
63,
1606,
63,
1130,
267,
7268,
63,
1361,
275,
3999,
14,
9118,
63,
1361,
267,
372,
843,
8,
1023,
29,
1023,
12,
2034,
63,
1130,
29,
1606,
63,
1130,
12,
673,
7268,
63,
1361,
29,
9118,
63,
1361,
9,
339,
347,
636,
1250,
721,
277,
12,
312,
2871,
12,
931,
304,
267,
408,
267,
6990,
314,
6719,
315,
314,
520,
533,
1705,
47,
14138,
8696,
64,
909,
520,
635,
1705,
79,
2871,
64,
370,
282,
4922,
267,
737,
520,
635,
1705,
515,
2313,
267,
408,
267,
1015,
275,
1109,
8,
277,
14,
1023,
59,
16,
566,
267,
1687,
5252,
275,
488,
267,
340,
747,
14,
515,
14,
7973,
8,
515,
2788,
17,
1055,
2325,
342,
508,
1987,
16893,
356,
288,
1687,
5252,
275,
747,
14,
515,
14,
4846,
8,
515,
9,
288,
931,
275,
747,
14,
515,
14,
3475,
8,
515,
9,
267,
340,
440,
747,
14,
515,
14,
6027,
8,
515,
304,
288,
747,
14,
8215,
8,
515,
9,
267,
1072,
275,
25866,
4076,
8,
515,
12,
312,
2871,
14,
793,
9,
267,
367,
1242,
315,
312,
2871,
14,
6418,
14,
1459,
837,
288,
1072,
14,
952,
8,
1053,
14,
6399,
12,
620,
8,
1053,
430,
398,
340,
1015,
508,
413,
26,
288,
3341,
275,
312,
2871,
14,
475,
63,
16893,
17,
342,
267,
916,
1015,
508,
499,
26,
288,
3341,
275,
312,
2871,
14,
475,
63,
16893,
18,
8,
1606,
63,
1130,
29,
277,
14,
1606,
63,
1130,
9,
267,
587,
26,
288,
746,
593,
14138,
547,
480,
22517,
9827,
38,
1015,
450,
82,
2,
450,
291,
14,
1023,
9,
267,
7268,
63,
1361,
275,
291,
14,
9118,
63,
1361,
267,
367,
6660,
12,
334,
6399,
12,
666,
9,
315,
3341,
14,
1744,
837,
288,
340,
1687,
5252,
436,
6660,
508,
9827,
38,
63,
17057,
26,
355,
4369,
275,
1687,
5252,
288,
1072,
14,
952,
8,
6399,
12,
2748,
18,
495,
8,
576,
12,
7268,
63,
1361,
29,
9118,
63,
1361,
430,
267,
372,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
6231,
1072,
593,
14138,
8696,
7060,
14,
199,
2344,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
363,
1682,
363,
257,
275,
283,
12006,
373,
19,
7,
199,
363,
7307,
363,
275,
283,
9300,
12,
16794,
609,
452,
377,
14,
812,
290,
6458,
6501,
665,
914,
305,
5975,
32,
6799,
14,
957,
3524,
199,
199,
646,
747,
199,
504,
19238,
14,
69,
8858,
14,
79,
2871,
14,
1095,
492,
9827,
38,
63,
17057,
12,
2748,
18,
495,
199,
504,
19238,
14,
69,
8858,
14,
79,
2871,
14,
1095,
492,
25866,
4076,
12,
593,
14138,
547,
199,
199,
363,
452,
363,
275,
788,
47,
14138,
6261,
418,
199,
199,
533,
593,
14138,
6261,
8,
785,
304,
272,
6186,
63,
16632,
275,
283,
3311,
51,
13938,
7,
272,
408,
2698,
11889,
4690,
367,
1564,
5313,
543,
642,
24441,
1041,
339,
9074,
5622,
11518,
275,
942,
272,
408,
1296,
402,
18501,
370,
4838,
370,
1564,
5313,
543,
642,
24441,
1041,
339,
347,
636,
826,
721,
277,
12,
1015,
534,
18,
14,
16,
297,
2034,
63,
1130,
29,
797,
12,
7268,
63,
1361,
29,
797,
304,
267,
291,
14,
1023,
275,
1015,
267,
291,
14,
1606,
63,
1130,
275,
2034,
63,
1130,
267,
291,
14,
9118,
63,
1361,
275,
7268,
63,
1361,
339,
768,
3744,
272,
347,
1101,
8,
1886,
12,
4810,
304,
267,
408,
1123,
1263,
6719,
13,
14827,
1511,
370,
314,
520,
533,
1705,
2028,
64,
909,
267,
520,
635,
1705,
4128,
2313,
267,
408,
267,
312,
2871,
275,
4810,
14,
525,
63,
923,
360,
79,
2871,
297,
4018,
1938,
38,
15,
6389,
56,
15,
6839,
14,
10152,
1511,
12459,
267,
5459,
275,
788,
17,
14,
18,
297,
283,
18,
14,
16,
418,
267,
312,
2871,
360,
16893,
63,
1023,
297,
14574,
16893,
13,
1023,
995,
849,
534,
18,
14,
16,
297,
3415,
29,
6234,
12,
288,
1720,
12397,
1938,
38,
1015,
370,
3550,
14,
3758,
365,
450,
885,
12459,
267,
312,
2871,
360,
5129,
1235,
63,
1606,
63,
1130,
297,
14574,
5129,
1235,
13,
1606,
13,
1130,
995,
849,
29,
797,
12,
288,
1720,
12397,
6864,
376,
437,
1117,
1235,
298,
1606,
13,
1130,
2,
570,
340,
21192,
283,
673,
283,
11697,
365,
2808,
12459,
267,
372,
4810,
339,
768,
3744,
272,
347,
3550,
8,
1886,
12,
3999,
304,
267,
408,
6864,
282,
24441,
1256,
687,
1414,
13,
604,
1511,
1041,
267,
1015,
275,
3999,
14,
16893,
63,
1023,
267,
2034,
63,
1130,
275,
3999,
14,
5129,
1235,
63,
1606,
63,
1130,
267,
7268,
63,
1361,
275,
3999,
14,
9118,
63,
1361,
267,
372,
843,
8,
1023,
29,
1023,
12,
2034,
63,
1130,
29,
1606,
63,
1130,
12,
673,
7268,
63,
1361,
29,
9118,
63,
1361,
9,
339,
347,
636,
1250,
721,
277,
12,
312,
2871,
12,
931,
304,
267,
408,
267,
6990,
314,
6719,
315,
314,
520,
533,
1705,
47,
14138,
8696,
64,
909,
520,
635,
1705,
79,
2871,
64,
370,
282,
4922,
267,
737,
520,
635,
1705,
515,
2313,
267,
408,
267,
1015,
275,
1109,
8,
277,
14,
1023,
59,
16,
566,
267,
1687,
5252,
275,
488,
267,
340,
747,
14,
515,
14,
7973,
8,
515,
2788,
17,
1055,
2325,
342,
508,
1987,
16893,
356,
288,
1687,
5252,
275,
747,
14,
515,
14,
4846,
8,
515,
9,
288,
931,
275,
747,
14,
515,
14,
3475,
8,
515,
9,
267,
340,
440,
747,
14,
515,
14,
6027,
8,
515,
304,
288,
747,
14,
8215,
8,
515,
9,
267,
1072,
275,
25866,
4076,
8,
515,
12,
312,
2871,
14,
793,
9,
267,
367,
1242,
315,
312,
2871,
14,
6418,
14,
1459,
837,
288,
1072,
14,
952,
8,
1053,
14,
6399,
12,
620,
8,
1053,
430,
398,
340,
1015,
508,
413,
26,
288,
3341,
275,
312,
2871,
14,
475,
63,
16893,
17,
342,
267,
916,
1015,
508,
499,
26,
288,
3341,
275,
312,
2871,
14,
475,
63,
16893,
18,
8,
1606,
63,
1130,
29,
277,
14,
1606,
63,
1130,
9,
267,
587,
26,
288,
746,
593,
14138,
547,
480,
22517,
9827,
38,
1015,
450,
82,
2,
450,
291,
14,
1023,
9,
267,
7268,
63,
1361,
275,
291,
14,
9118,
63,
1361,
267,
367,
6660,
12,
334,
6399,
12,
666,
9,
315,
3341,
14,
1744,
837,
288,
340,
1687,
5252,
436,
6660,
508,
9827,
38,
63,
17057,
26,
355,
4369,
275,
1687,
5252,
288,
1072,
14,
952,
8,
6399,
12,
2748,
18,
495,
8,
576,
12,
7268,
63,
1361,
29,
9118,
63,
1361,
430,
267,
372,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
samthor/intellij-community
|
python/helpers/pydev/tests_runfiles/test_pydevd_property.py
|
56
|
4121
|
'''
Created on Aug 22, 2011
@author: hussain.bohra
@author: fabioz
'''
import os
import sys
import unittest
#=======================================================================================================================
# Test
#=======================================================================================================================
class Test(unittest.TestCase):
"""Test cases to validate custom property implementation in pydevd
"""
def setUp(self, nused=None):
self.tempdir = os.path.join(os.path.dirname(os.path.dirname(__file__)))
sys.path.insert(0, self.tempdir)
import pydevd_traceproperty
self.old = pydevd_traceproperty.replace_builtin_property()
def tearDown(self, unused=None):
import pydevd_traceproperty
pydevd_traceproperty.replace_builtin_property(self.old)
sys.path.remove(self.tempdir)
def testProperty(self):
"""Test case to validate custom property
"""
import pydevd_traceproperty
class TestProperty(object):
def __init__(self):
self._get = 0
self._set = 0
self._del = 0
def get_name(self):
self._get += 1
return self.__name
def set_name(self, value):
self._set += 1
self.__name = value
def del_name(self):
self._del += 1
del self.__name
name = property(get_name, set_name, del_name, "name's docstring")
self.assertEqual(name.__class__, pydevd_traceproperty.DebugProperty)
testObj = TestProperty()
self._check(testObj)
def testProperty2(self):
"""Test case to validate custom property
"""
class TestProperty(object):
def __init__(self):
self._get = 0
self._set = 0
self._del = 0
def name(self):
self._get += 1
return self.__name
name = property(name)
def set_name(self, value):
self._set += 1
self.__name = value
name.setter(set_name)
def del_name(self):
self._del += 1
del self.__name
name.deleter(del_name)
testObj = TestProperty()
self._check(testObj)
def testProperty3(self):
"""Test case to validate custom property
"""
class TestProperty(object):
def __init__(self):
self._name = 'foo'
def name(self):
return self._name
name = property(name)
testObj = TestProperty()
self.assertRaises(AttributeError, setattr, testObj, 'name', 'bar')
self.assertRaises(AttributeError, delattr, testObj, 'name')
def _check(self, testObj):
testObj.name = "Custom"
self.assertEqual(1, testObj._set)
self.assertEqual(testObj.name, "Custom")
self.assertEqual(1, testObj._get)
self.assert_(hasattr(testObj, 'name'))
del testObj.name
self.assertEqual(1, testObj._del)
self.assert_(not hasattr(testObj, 'name'))
testObj.name = "Custom2"
self.assertEqual(testObj.name, "Custom2")
#=======================================================================================================================
# main
#=======================================================================================================================
if __name__ == '__main__':
#this is so that we can run it from the jython tests -- because we don't actually have an __main__ module
#(so, it won't try importing the __main__ module)
unittest.TextTestRunner().run(unittest.makeSuite(Test))
|
apache-2.0
|
[
2344,
199,
10502,
641,
25298,
6928,
12,
7760,
199,
199,
32,
2502,
26,
394,
27678,
1581,
14,
656,
72,
345,
199,
32,
2502,
26,
31507,
2308,
90,
199,
2344,
199,
199,
646,
747,
199,
646,
984,
199,
646,
2882,
199,
199,
14813,
12813,
18673,
199,
3,
1379,
199,
14813,
12813,
18673,
199,
533,
1379,
8,
2796,
14,
1746,
304,
272,
408,
774,
5560,
370,
4107,
3537,
3324,
4514,
315,
29240,
68,
5591,
408,
2286,
347,
3613,
8,
277,
12,
302,
2972,
29,
403,
304,
267,
291,
14,
11567,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
3460,
493,
29658,
267,
984,
14,
515,
14,
3176,
8,
16,
12,
291,
14,
11567,
9,
267,
492,
29240,
68,
63,
3446,
1829,
267,
291,
14,
1753,
275,
29240,
68,
63,
3446,
1829,
14,
1814,
63,
5351,
63,
1829,
342,
17635,
347,
6766,
8,
277,
12,
9563,
29,
403,
304,
267,
492,
29240,
68,
63,
3446,
1829,
267,
29240,
68,
63,
3446,
1829,
14,
1814,
63,
5351,
63,
1829,
8,
277,
14,
1753,
9,
267,
984,
14,
515,
14,
2168,
8,
277,
14,
11567,
9,
2378,
347,
511,
3697,
8,
277,
304,
267,
408,
774,
1930,
370,
4107,
3537,
3324,
267,
408,
2728,
492,
29240,
68,
63,
3446,
1829,
267,
1021,
1379,
3697,
8,
785,
304,
7846,
347,
636,
826,
721,
277,
304,
355,
291,
423,
362,
275,
378,
355,
291,
423,
409,
275,
378,
355,
291,
423,
2264,
275,
378,
24850,
347,
664,
63,
354,
8,
277,
304,
355,
291,
423,
362,
847,
413,
355,
372,
291,
855,
354,
7846,
347,
663,
63,
354,
8,
277,
12,
574,
304,
355,
291,
423,
409,
847,
413,
355,
291,
855,
354,
275,
574,
24850,
347,
2150,
63,
354,
8,
277,
304,
355,
291,
423,
2264,
847,
413,
355,
2150,
291,
855,
354,
288,
536,
275,
3324,
8,
362,
63,
354,
12,
663,
63,
354,
12,
2150,
63,
354,
12,
298,
354,
1159,
9214,
531,
288,
291,
14,
629,
8,
354,
855,
533,
3108,
29240,
68,
63,
3446,
1829,
14,
7084,
3697,
9,
10631,
511,
5665,
275,
1379,
3697,
342,
267,
291,
423,
1074,
8,
396,
5665,
9,
268,
5493,
347,
511,
3697,
18,
8,
277,
304,
267,
408,
774,
1930,
370,
4107,
3537,
3324,
267,
408,
2728,
1021,
1379,
3697,
8,
785,
304,
7846,
347,
636,
826,
721,
277,
304,
355,
291,
423,
362,
275,
378,
355,
291,
423,
409,
275,
378,
355,
291,
423,
2264,
275,
378,
7846,
347,
536,
8,
277,
304,
355,
291,
423,
362,
847,
413,
355,
372,
291,
855,
354,
288,
536,
275,
3324,
8,
354,
9,
7846,
347,
663,
63,
354,
8,
277,
12,
574,
304,
355,
291,
423,
409,
847,
413,
355,
291,
855,
354,
275,
574,
288,
536,
14,
8345,
8,
409,
63,
354,
9,
24850,
347,
2150,
63,
354,
8,
277,
304,
355,
291,
423,
2264,
847,
413,
355,
2150,
291,
855,
354,
288,
536,
14,
7346,
351,
8,
2264,
63,
354,
9,
398,
511,
5665,
275,
1379,
3697,
342,
267,
291,
423,
1074,
8,
396,
5665,
9,
268,
5493,
347,
511,
3697,
19,
8,
277,
304,
267,
408,
774,
1930,
370,
4107,
3537,
3324,
267,
408,
2728,
1021,
1379,
3697,
8,
785,
304,
7846,
347,
636,
826,
721,
277,
304,
355,
291,
423,
354,
275,
283,
1421,
7,
7846,
347,
536,
8,
277,
304,
355,
372,
291,
423,
354,
288,
536,
275,
3324,
8,
354,
9,
398,
511,
5665,
275,
1379,
3697,
342,
267,
291,
14,
1855,
8,
10227,
12,
5371,
12,
511,
5665,
12,
283,
354,
297,
283,
1700,
358,
267,
291,
14,
1855,
8,
10227,
12,
24358,
12,
511,
5665,
12,
283,
354,
358,
268,
5493,
347,
485,
1074,
8,
277,
12,
511,
5665,
304,
267,
511,
5665,
14,
354,
275,
298,
7223,
2,
267,
291,
14,
629,
8,
17,
12,
511,
5665,
423,
409,
9,
2728,
291,
14,
629,
8,
396,
5665,
14,
354,
12,
298,
7223,
531,
267,
291,
14,
629,
8,
17,
12,
511,
5665,
423,
362,
9,
2728,
291,
14,
479,
2531,
11161,
8,
396,
5665,
12,
283,
354,
1333,
267,
2150,
511,
5665,
14,
354,
267,
291,
14,
629,
8,
17,
12,
511,
5665,
423,
2264,
9,
2728,
291,
14,
479,
2531,
1397,
2688,
8,
396,
5665,
12,
283,
354,
1333,
267,
511,
5665,
14,
354,
275,
298,
7223,
18,
2,
267,
291,
14,
629,
8,
396,
5665,
14,
354,
12,
298,
7223,
18,
531,
421,
268,
199,
14813,
12813,
18673,
199,
3,
2446,
199,
14813,
12813,
18673,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
327,
3749,
365,
880,
626,
781,
883,
1255,
652,
687,
314,
1335,
11361,
2295,
1553,
2952,
781,
2793,
1133,
5965,
1172,
376,
636,
973,
363,
859,
272,
21571,
1152,
12,
652,
7859,
1133,
862,
16306,
314,
636,
973,
363,
859,
9,
272,
2882,
14,
24285,
1252,
1065,
8,
2796,
14,
18275,
8,
774,
430,
16872,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
10502,
641,
25298,
6928,
12,
7760,
199,
199,
32,
2502,
26,
394,
27678,
1581,
14,
656,
72,
345,
199,
32,
2502,
26,
31507,
2308,
90,
199,
2344,
199,
199,
646,
747,
199,
646,
984,
199,
646,
2882,
199,
199,
14813,
12813,
18673,
199,
3,
1379,
199,
14813,
12813,
18673,
199,
533,
1379,
8,
2796,
14,
1746,
304,
272,
408,
774,
5560,
370,
4107,
3537,
3324,
4514,
315,
29240,
68,
5591,
408,
2286,
347,
3613,
8,
277,
12,
302,
2972,
29,
403,
304,
267,
291,
14,
11567,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
3460,
493,
29658,
267,
984,
14,
515,
14,
3176,
8,
16,
12,
291,
14,
11567,
9,
267,
492,
29240,
68,
63,
3446,
1829,
267,
291,
14,
1753,
275,
29240,
68,
63,
3446,
1829,
14,
1814,
63,
5351,
63,
1829,
342,
17635,
347,
6766,
8,
277,
12,
9563,
29,
403,
304,
267,
492,
29240,
68,
63,
3446,
1829,
267,
29240,
68,
63,
3446,
1829,
14,
1814,
63,
5351,
63,
1829,
8,
277,
14,
1753,
9,
267,
984,
14,
515,
14,
2168,
8,
277,
14,
11567,
9,
2378,
347,
511,
3697,
8,
277,
304,
267,
408,
774,
1930,
370,
4107,
3537,
3324,
267,
408,
2728,
492,
29240,
68,
63,
3446,
1829,
267,
1021,
1379,
3697,
8,
785,
304,
7846,
347,
636,
826,
721,
277,
304,
355,
291,
423,
362,
275,
378,
355,
291,
423,
409,
275,
378,
355,
291,
423,
2264,
275,
378,
24850,
347,
664,
63,
354,
8,
277,
304,
355,
291,
423,
362,
847,
413,
355,
372,
291,
855,
354,
7846,
347,
663,
63,
354,
8,
277,
12,
574,
304,
355,
291,
423,
409,
847,
413,
355,
291,
855,
354,
275,
574,
24850,
347,
2150,
63,
354,
8,
277,
304,
355,
291,
423,
2264,
847,
413,
355,
2150,
291,
855,
354,
288,
536,
275,
3324,
8,
362,
63,
354,
12,
663,
63,
354,
12,
2150,
63,
354,
12,
298,
354,
1159,
9214,
531,
288,
291,
14,
629,
8,
354,
855,
533,
3108,
29240,
68,
63,
3446,
1829,
14,
7084,
3697,
9,
10631,
511,
5665,
275,
1379,
3697,
342,
267,
291,
423,
1074,
8,
396,
5665,
9,
268,
5493,
347,
511,
3697,
18,
8,
277,
304,
267,
408,
774,
1930,
370,
4107,
3537,
3324,
267,
408,
2728,
1021,
1379,
3697,
8,
785,
304,
7846,
347,
636,
826,
721,
277,
304,
355,
291,
423,
362,
275,
378,
355,
291,
423,
409,
275,
378,
355,
291,
423,
2264,
275,
378,
7846,
347,
536,
8,
277,
304,
355,
291,
423,
362,
847,
413,
355,
372,
291,
855,
354,
288,
536,
275,
3324,
8,
354,
9,
7846,
347,
663,
63,
354,
8,
277,
12,
574,
304,
355,
291,
423,
409,
847,
413,
355,
291,
855,
354,
275,
574,
288,
536,
14,
8345,
8,
409,
63,
354,
9,
24850,
347,
2150,
63,
354,
8,
277,
304,
355,
291,
423,
2264,
847,
413,
355,
2150,
291,
855,
354,
288,
536,
14,
7346,
351,
8,
2264,
63,
354,
9,
398,
511,
5665,
275,
1379,
3697,
342,
267,
291,
423,
1074,
8,
396,
5665,
9,
268,
5493,
347,
511,
3697,
19,
8,
277,
304,
267,
408,
774,
1930,
370,
4107,
3537,
3324,
267,
408,
2728,
1021,
1379,
3697,
8,
785,
304,
7846,
347,
636,
826,
721,
277,
304,
355,
291,
423,
354,
275,
283,
1421,
7,
7846,
347,
536,
8,
277,
304,
355,
372,
291,
423,
354,
288,
536,
275,
3324,
8,
354,
9,
398,
511,
5665,
275,
1379,
3697,
342,
267,
291,
14,
1855,
8,
10227,
12,
5371,
12,
511,
5665,
12,
283,
354,
297,
283,
1700,
358,
267,
291,
14,
1855,
8,
10227,
12,
24358,
12,
511,
5665,
12,
283,
354,
358,
268,
5493,
347,
485,
1074,
8,
277,
12,
511,
5665,
304,
267,
511,
5665,
14,
354,
275,
298,
7223,
2,
267,
291,
14,
629,
8,
17,
12,
511,
5665,
423,
409,
9,
2728,
291,
14,
629,
8,
396,
5665,
14,
354,
12,
298,
7223,
531,
267,
291,
14,
629,
8,
17,
12,
511,
5665,
423,
362,
9,
2728,
291,
14,
479,
2531,
11161,
8,
396,
5665,
12,
283,
354,
1333,
267,
2150,
511,
5665,
14,
354,
267,
291,
14,
629,
8,
17,
12,
511,
5665,
423,
2264,
9,
2728,
291,
14,
479,
2531,
1397,
2688,
8,
396,
5665,
12,
283,
354,
1333,
267,
511,
5665,
14,
354,
275,
298,
7223,
18,
2,
267,
291,
14,
629,
8,
396,
5665,
14,
354,
12,
298,
7223,
18,
531,
421,
268,
199,
14813,
12813,
18673,
199,
3,
2446,
199,
14813,
12813,
18673,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
327,
3749,
365,
880,
626,
781,
883,
1255,
652,
687,
314,
1335,
11361,
2295,
1553,
2952,
781,
2793,
1133,
5965,
1172,
376,
636,
973,
363,
859,
272,
21571,
1152,
12,
652,
7859,
1133,
862,
16306,
314,
636,
973,
363,
859,
9,
272,
2882,
14,
24285,
1252,
1065,
8,
2796,
14,
18275,
8,
774,
430,
16872,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768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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
] |
matthaywardwebdesign/rethinkdb
|
external/v8_3.30.33.16/build/gyp/test/library/gyptest-static.py
|
430
|
2241
|
#!/usr/bin/env python
# Copyright (c) 2009 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Verifies simple build of a "Hello, world!" program with static libraries,
including verifying that libraries are rebuilt correctly when functions
move between libraries.
"""
import TestGyp
test = TestGyp.TestGyp()
test.run_gyp('library.gyp',
'-Dlibrary=static_library',
'-Dmoveable_function=lib1',
chdir='src')
test.relocate('src', 'relocate/src')
test.build('library.gyp', test.ALL, chdir='relocate/src')
expect = """\
Hello from program.c
Hello from lib1.c
Hello from lib2.c
Hello from lib1_moveable.c
"""
test.run_built_executable('program', chdir='relocate/src', stdout=expect)
test.run_gyp('library.gyp',
'-Dlibrary=static_library',
'-Dmoveable_function=lib2',
chdir='relocate/src')
# Update program.c to force a rebuild.
test.sleep()
contents = test.read('relocate/src/program.c')
contents = contents.replace('Hello', 'Hello again')
test.write('relocate/src/program.c', contents)
test.build('library.gyp', test.ALL, chdir='relocate/src')
expect = """\
Hello again from program.c
Hello from lib1.c
Hello from lib2.c
Hello from lib2_moveable.c
"""
test.run_built_executable('program', chdir='relocate/src', stdout=expect)
test.run_gyp('library.gyp',
'-Dlibrary=static_library',
'-Dmoveable_function=lib1',
chdir='relocate/src')
# Update program.c and lib2.c to force a rebuild.
test.sleep()
contents = test.read('relocate/src/program.c')
contents = contents.replace('again', 'again again')
test.write('relocate/src/program.c', contents)
# TODO(sgk): we have to force a rebuild of lib2 so that it weeds out
# the "moved" module. This should be done in gyp by adding a dependency
# on the generated .vcproj file itself.
test.touch('relocate/src/lib2.c')
test.build('library.gyp', test.ALL, chdir='relocate/src')
expect = """\
Hello again again from program.c
Hello from lib1.c
Hello from lib2.c
Hello from lib1_moveable.c
"""
test.run_built_executable('program', chdir='relocate/src', stdout=expect)
test.pass_test()
|
agpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
8937,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
199,
21168,
3486,
1900,
402,
282,
298,
6257,
12,
6701,
9539,
2240,
543,
2955,
8363,
12,
199,
15768,
31866,
626,
8363,
787,
295,
11730,
6657,
1380,
3423,
199,
1185,
3382,
8363,
14,
199,
624,
199,
199,
646,
25688,
199,
199,
396,
275,
25688,
14,
774,
13899,
342,
199,
199,
396,
14,
1065,
63,
6179,
360,
4342,
14,
6179,
297,
1467,
2475,
36,
4342,
29,
1986,
63,
4342,
297,
1467,
2475,
36,
1185,
461,
63,
1593,
29,
773,
17,
297,
1467,
13097,
534,
2164,
358,
199,
199,
396,
14,
18919,
360,
2164,
297,
283,
18919,
15,
2164,
358,
199,
199,
396,
14,
1506,
360,
4342,
14,
6179,
297,
511,
14,
1761,
12,
13097,
534,
18919,
15,
2164,
358,
199,
199,
4921,
275,
9638,
199,
6257,
687,
2240,
14,
67,
199,
6257,
687,
1973,
17,
14,
67,
199,
6257,
687,
1973,
18,
14,
67,
199,
6257,
687,
1973,
17,
63,
1185,
461,
14,
67,
199,
624,
199,
396,
14,
1065,
63,
11730,
63,
5904,
360,
6815,
297,
13097,
534,
18919,
15,
2164,
297,
3839,
29,
4921,
9,
421,
199,
396,
14,
1065,
63,
6179,
360,
4342,
14,
6179,
297,
1467,
2475,
36,
4342,
29,
1986,
63,
4342,
297,
1467,
2475,
36,
1185,
461,
63,
1593,
29,
773,
18,
297,
1467,
13097,
534,
18919,
15,
2164,
358,
199,
199,
3,
6162,
2240,
14,
67,
370,
3542,
282,
22110,
14,
199,
396,
14,
4532,
342,
199,
4407,
275,
511,
14,
739,
360,
18919,
15,
2164,
15,
6815,
14,
67,
358,
199,
4407,
275,
4072,
14,
1814,
360,
6257,
297,
283,
6257,
4020,
358,
199,
396,
14,
952,
360,
18919,
15,
2164,
15,
6815,
14,
67,
297,
4072,
9,
199,
199,
396,
14,
1506,
360,
4342,
14,
6179,
297,
511,
14,
1761,
12,
13097,
534,
18919,
15,
2164,
358,
199,
199,
4921,
275,
9638,
199,
6257,
4020,
687,
2240,
14,
67,
199,
6257,
687,
1973,
17,
14,
67,
199,
6257,
687,
1973,
18,
14,
67,
199,
6257,
687,
1973,
18,
63,
1185,
461,
14,
67,
199,
624,
199,
396,
14,
1065,
63,
11730,
63,
5904,
360,
6815,
297,
13097,
534,
18919,
15,
2164,
297,
3839,
29,
4921,
9,
421,
199,
396,
14,
1065,
63,
6179,
360,
4342,
14,
6179,
297,
1467,
2475,
36,
4342,
29,
1986,
63,
4342,
297,
1467,
2475,
36,
1185,
461,
63,
1593,
29,
773,
17,
297,
1467,
13097,
534,
18919,
15,
2164,
358,
199,
199,
3,
6162,
2240,
14,
67,
436,
1973,
18,
14,
67,
370,
3542,
282,
22110,
14,
199,
396,
14,
4532,
342,
199,
4407,
275,
511,
14,
739,
360,
18919,
15,
2164,
15,
6815,
14,
67,
358,
199,
4407,
275,
4072,
14,
1814,
360,
14199,
297,
283,
14199,
4020,
358,
199,
396,
14,
952,
360,
18919,
15,
2164,
15,
6815,
14,
67,
297,
4072,
9,
199,
199,
3,
3254,
8,
1226,
75,
304,
221,
781,
1172,
370,
3542,
282,
22110,
402,
1973,
18,
880,
626,
652,
781,
5923,
734,
199,
3,
314,
298,
3539,
2,
859,
14,
221,
961,
1077,
506,
4224,
315,
4902,
701,
7791,
282,
5936,
199,
3,
641,
314,
4046,
1275,
6737,
5468,
570,
6337,
14,
199,
396,
14,
12376,
360,
18919,
15,
2164,
15,
773,
18,
14,
67,
358,
199,
199,
396,
14,
1506,
360,
4342,
14,
6179,
297,
511,
14,
1761,
12,
13097,
534,
18919,
15,
2164,
358,
199,
199,
4921,
275,
9638,
199,
6257,
4020,
4020,
687,
2240,
14,
67,
199,
6257,
687,
1973,
17,
14,
67,
199,
6257,
687,
1973,
18,
14,
67,
199,
6257,
687,
1973,
17,
63,
1185,
461,
14,
67,
199,
624,
199,
396,
14,
1065,
63,
11730,
63,
5904,
360,
6815,
297,
13097,
534,
18919,
15,
2164,
297,
3839,
29,
4921,
9,
421,
199,
396,
14,
1529,
63,
396,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
8937,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
199,
21168,
3486,
1900,
402,
282,
298,
6257,
12,
6701,
9539,
2240,
543,
2955,
8363,
12,
199,
15768,
31866,
626,
8363,
787,
295,
11730,
6657,
1380,
3423,
199,
1185,
3382,
8363,
14,
199,
624,
199,
199,
646,
25688,
199,
199,
396,
275,
25688,
14,
774,
13899,
342,
199,
199,
396,
14,
1065,
63,
6179,
360,
4342,
14,
6179,
297,
1467,
2475,
36,
4342,
29,
1986,
63,
4342,
297,
1467,
2475,
36,
1185,
461,
63,
1593,
29,
773,
17,
297,
1467,
13097,
534,
2164,
358,
199,
199,
396,
14,
18919,
360,
2164,
297,
283,
18919,
15,
2164,
358,
199,
199,
396,
14,
1506,
360,
4342,
14,
6179,
297,
511,
14,
1761,
12,
13097,
534,
18919,
15,
2164,
358,
199,
199,
4921,
275,
9638,
199,
6257,
687,
2240,
14,
67,
199,
6257,
687,
1973,
17,
14,
67,
199,
6257,
687,
1973,
18,
14,
67,
199,
6257,
687,
1973,
17,
63,
1185,
461,
14,
67,
199,
624,
199,
396,
14,
1065,
63,
11730,
63,
5904,
360,
6815,
297,
13097,
534,
18919,
15,
2164,
297,
3839,
29,
4921,
9,
421,
199,
396,
14,
1065,
63,
6179,
360,
4342,
14,
6179,
297,
1467,
2475,
36,
4342,
29,
1986,
63,
4342,
297,
1467,
2475,
36,
1185,
461,
63,
1593,
29,
773,
18,
297,
1467,
13097,
534,
18919,
15,
2164,
358,
199,
199,
3,
6162,
2240,
14,
67,
370,
3542,
282,
22110,
14,
199,
396,
14,
4532,
342,
199,
4407,
275,
511,
14,
739,
360,
18919,
15,
2164,
15,
6815,
14,
67,
358,
199,
4407,
275,
4072,
14,
1814,
360,
6257,
297,
283,
6257,
4020,
358,
199,
396,
14,
952,
360,
18919,
15,
2164,
15,
6815,
14,
67,
297,
4072,
9,
199,
199,
396,
14,
1506,
360,
4342,
14,
6179,
297,
511,
14,
1761,
12,
13097,
534,
18919,
15,
2164,
358,
199,
199,
4921,
275,
9638,
199,
6257,
4020,
687,
2240,
14,
67,
199,
6257,
687,
1973,
17,
14,
67,
199,
6257,
687,
1973,
18,
14,
67,
199,
6257,
687,
1973,
18,
63,
1185,
461,
14,
67,
199,
624,
199,
396,
14,
1065,
63,
11730,
63,
5904,
360,
6815,
297,
13097,
534,
18919,
15,
2164,
297,
3839,
29,
4921,
9,
421,
199,
396,
14,
1065,
63,
6179,
360,
4342,
14,
6179,
297,
1467,
2475,
36,
4342,
29,
1986,
63,
4342,
297,
1467,
2475,
36,
1185,
461,
63,
1593,
29,
773,
17,
297,
1467,
13097,
534,
18919,
15,
2164,
358,
199,
199,
3,
6162,
2240,
14,
67,
436,
1973,
18,
14,
67,
370,
3542,
282,
22110,
14,
199,
396,
14,
4532,
342,
199,
4407,
275,
511,
14,
739,
360,
18919,
15,
2164,
15,
6815,
14,
67,
358,
199,
4407,
275,
4072,
14,
1814,
360,
14199,
297,
283,
14199,
4020,
358,
199,
396,
14,
952,
360,
18919,
15,
2164,
15,
6815,
14,
67,
297,
4072,
9,
199,
199,
3,
3254,
8,
1226,
75,
304,
221,
781,
1172,
370,
3542,
282,
22110,
402,
1973,
18,
880,
626,
652,
781,
5923,
734,
199,
3,
314,
298,
3539,
2,
859,
14,
221,
961,
1077,
506,
4224,
315,
4902,
701,
7791,
282,
5936,
199,
3,
641,
314,
4046,
1275,
6737,
5468,
570,
6337,
14,
199,
396,
14,
12376,
360,
18919,
15,
2164,
15,
773,
18,
14,
67,
358,
199,
199,
396,
14,
1506,
360,
4342,
14,
6179,
297,
511,
14,
1761,
12,
13097,
534,
18919,
15,
2164,
358,
199,
199,
4921,
275,
9638,
199,
6257,
4020,
4020,
687,
2240,
14,
67,
199,
6257,
687,
1973,
17,
14,
67,
199,
6257,
687,
1973,
18,
14,
67,
199,
6257,
687,
1973,
17,
63,
1185,
461,
14,
67,
199,
624,
199,
396,
14,
1065,
63,
11730,
63,
5904,
360,
6815,
297,
13097,
534,
18919,
15,
2164,
297,
3839,
29,
4921,
9,
421,
199,
396,
14,
1529,
63,
396,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
4022321818/2015cd_midterm
|
static/Brython3.1.1-20150328-091302/Lib/imp.py
|
637
|
9839
|
"""This module provides the components needed to build your own __import__
function. Undocumented functions are obsolete.
In most cases it is preferred you consider using the importlib module's
functionality over this module.
"""
# (Probably) need to stay in _imp
from _imp import (lock_held, acquire_lock, release_lock,
get_frozen_object, is_frozen_package,
init_builtin, init_frozen, is_builtin, is_frozen,
_fix_co_filename)
try:
from _imp import load_dynamic
except ImportError:
# Platform doesn't support dynamic loading.
load_dynamic = None
# Directly exposed by this module
from importlib._bootstrap import new_module
from importlib._bootstrap import cache_from_source, source_from_cache
from importlib import _bootstrap
#fixme brython
#from importlib import machinery
import importlib.machinery as machinery
import os
import sys
import tokenize
import warnings
# DEPRECATED
SEARCH_ERROR = 0
PY_SOURCE = 1
PY_COMPILED = 2
C_EXTENSION = 3
PY_RESOURCE = 4
PKG_DIRECTORY = 5
C_BUILTIN = 6
PY_FROZEN = 7
PY_CODERESOURCE = 8
IMP_HOOK = 9
def get_magic():
"""Return the magic number for .pyc or .pyo files."""
return _bootstrap._MAGIC_BYTES
def get_tag():
"""Return the magic tag for .pyc or .pyo files."""
return sys.implementation.cache_tag
def get_suffixes():
warnings.warn('imp.get_suffixes() is deprecated; use the constants '
'defined on importlib.machinery instead',
DeprecationWarning, 2)
extensions = [(s, 'rb', C_EXTENSION) for s in machinery.EXTENSION_SUFFIXES]
source = [(s, 'U', PY_SOURCE) for s in machinery.SOURCE_SUFFIXES]
bytecode = [(s, 'rb', PY_COMPILED) for s in machinery.BYTECODE_SUFFIXES]
return extensions + source + bytecode
class NullImporter:
"""Null import object."""
def __init__(self, path):
if path == '':
raise ImportError('empty pathname', path='')
elif os.path.isdir(path):
raise ImportError('existing directory', path=path)
def find_module(self, fullname):
"""Always returns None."""
return None
class _HackedGetData:
"""Compatibiilty support for 'file' arguments of various load_*()
functions."""
def __init__(self, fullname, path, file=None):
super().__init__(fullname, path)
self.file = file
def get_data(self, path):
"""Gross hack to contort loader to deal w/ load_*()'s bad API."""
if self.file and path == self.path:
if not self.file.closed:
file = self.file
else:
self.file = file = open(self.path, 'r')
with file:
# Technically should be returning bytes, but
# SourceLoader.get_code() just passed what is returned to
# compile() which can handle str. And converting to bytes would
# require figuring out the encoding to decode to and
# tokenize.detect_encoding() only accepts bytes.
return file.read()
else:
return super().get_data(path)
class _LoadSourceCompatibility(_HackedGetData, _bootstrap.SourceFileLoader):
"""Compatibility support for implementing load_source()."""
#brython fix me
pass
def load_source(name, pathname, file=None):
msg = ('imp.load_source() is deprecated; use '
'importlib.machinery.SourceFileLoader(name, pathname).load_module()'
' instead')
warnings.warn(msg, DeprecationWarning, 2)
_LoadSourceCompatibility(name, pathname, file).load_module(name)
module = sys.modules[name]
# To allow reloading to potentially work, use a non-hacked loader which
# won't rely on a now-closed file object.
module.__loader__ = _bootstrap.SourceFileLoader(name, pathname)
return module
class _LoadCompiledCompatibility(_HackedGetData,
_bootstrap.SourcelessFileLoader):
"""Compatibility support for implementing load_compiled()."""
#brython fix me
pass
def load_compiled(name, pathname, file=None):
msg = ('imp.load_compiled() is deprecated; use '
'importlib.machinery.SourcelessFileLoader(name, pathname).'
'load_module() instead ')
warnings.warn(msg, DeprecationWarning, 2)
_LoadCompiledCompatibility(name, pathname, file).load_module(name)
module = sys.modules[name]
# To allow reloading to potentially work, use a non-hacked loader which
# won't rely on a now-closed file object.
module.__loader__ = _bootstrap.SourcelessFileLoader(name, pathname)
return module
def load_package(name, path):
msg = ('imp.load_package() is deprecated; use either '
'importlib.machinery.SourceFileLoader() or '
'importlib.machinery.SourcelessFileLoader() instead')
warnings.warn(msg, DeprecationWarning, 2)
if os.path.isdir(path):
extensions = (machinery.SOURCE_SUFFIXES[:] +
machinery.BYTECODE_SUFFIXES[:])
for extension in extensions:
path = os.path.join(path, '__init__'+extension)
if os.path.exists(path):
break
else:
raise ValueError('{!r} is not a package'.format(path))
return _bootstrap.SourceFileLoader(name, path).load_module(name)
def load_module(name, file, filename, details):
"""**DEPRECATED**
Load a module, given information returned by find_module().
The module name must include the full package name, if any.
"""
suffix, mode, type_ = details
with warnings.catch_warnings():
warnings.simplefilter('ignore')
if mode and (not mode.startswith(('r', 'U')) or '+' in mode):
raise ValueError('invalid file open mode {!r}'.format(mode))
elif file is None and type_ in {PY_SOURCE, PY_COMPILED}:
msg = 'file object required for import (type code {})'.format(type_)
raise ValueError(msg)
elif type_ == PY_SOURCE:
return load_source(name, filename, file)
elif type_ == PY_COMPILED:
return load_compiled(name, filename, file)
elif type_ == C_EXTENSION and load_dynamic is not None:
if file is None:
with open(filename, 'rb') as opened_file:
return load_dynamic(name, filename, opened_file)
else:
return load_dynamic(name, filename, file)
elif type_ == PKG_DIRECTORY:
return load_package(name, filename)
elif type_ == C_BUILTIN:
return init_builtin(name)
elif type_ == PY_FROZEN:
return init_frozen(name)
else:
msg = "Don't know how to import {} (type code {})".format(name, type_)
raise ImportError(msg, name=name)
def find_module(name, path=None):
"""**DEPRECATED**
Search for a module.
If path is omitted or None, search for a built-in, frozen or special
module and continue search in sys.path. The module name cannot
contain '.'; to search for a submodule of a package, pass the
submodule name and the package's __path__.
"""
if not isinstance(name, str):
raise TypeError("'name' must be a str, not {}".format(type(name)))
elif not isinstance(path, (type(None), list)):
# Backwards-compatibility
raise RuntimeError("'list' must be None or a list, "
"not {}".format(type(name)))
if path is None:
if is_builtin(name):
return None, None, ('', '', C_BUILTIN)
elif is_frozen(name):
return None, None, ('', '', PY_FROZEN)
else:
path = sys.path
for entry in path:
package_directory = os.path.join(entry, name)
for suffix in ['.py', machinery.BYTECODE_SUFFIXES[0]]:
package_file_name = '__init__' + suffix
file_path = os.path.join(package_directory, package_file_name)
if os.path.isfile(file_path):
return None, package_directory, ('', '', PKG_DIRECTORY)
with warnings.catch_warnings():
warnings.simplefilter('ignore')
for suffix, mode, type_ in get_suffixes():
file_name = name + suffix
file_path = os.path.join(entry, file_name)
if os.path.isfile(file_path):
break
else:
continue
break # Break out of outer loop when breaking out of inner loop.
else:
raise ImportError(_bootstrap._ERR_MSG.format(name), name=name)
encoding = None
if mode == 'U':
with open(file_path, 'rb') as file:
encoding = tokenize.detect_encoding(file.readline)[0]
file = open(file_path, mode, encoding=encoding)
return file, file_path, (suffix, mode, type_)
_RELOADING = {}
def reload(module):
"""Reload the module and return it.
The module must have been successfully imported before.
"""
if not module or type(module) != type(sys):
raise TypeError("reload() argument must be module")
name = module.__name__
if name not in sys.modules:
msg = "module {} not in sys.modules"
raise ImportError(msg.format(name), name=name)
if name in _RELOADING:
return _RELOADING[name]
_RELOADING[name] = module
try:
parent_name = name.rpartition('.')[0]
if parent_name and parent_name not in sys.modules:
msg = "parent {!r} not in sys.modules"
raise ImportError(msg.format(parent_name), name=parent_name)
module.__loader__.load_module(name)
# The module may have replaced itself in sys.modules!
return sys.modules[module.__name__]
finally:
try:
del _RELOADING[name]
except KeyError:
pass
|
gpl-3.0
|
[
624,
2765,
859,
6571,
314,
7323,
4346,
370,
1900,
2195,
5705,
636,
646,
363,
199,
1593,
14,
221,
738,
977,
679,
12546,
3423,
787,
24985,
14,
199,
199,
607,
4750,
5560,
652,
365,
14388,
1265,
11201,
1808,
314,
14802,
859,
1159,
199,
1593,
6712,
1806,
642,
859,
14,
199,
199,
624,
199,
3,
334,
20122,
6665,
9,
1929,
370,
25578,
315,
485,
3236,
199,
504,
485,
3236,
492,
334,
831,
63,
31415,
12,
16919,
63,
831,
12,
4683,
63,
831,
12,
2116,
664,
63,
11202,
63,
785,
12,
365,
63,
11202,
63,
2491,
12,
2116,
4205,
63,
5351,
12,
4205,
63,
11202,
12,
365,
63,
5351,
12,
365,
63,
11202,
12,
2116,
485,
970,
63,
331,
63,
1501,
9,
199,
893,
26,
272,
687,
485,
3236,
492,
2248,
63,
7764,
199,
2590,
3545,
26,
272,
327,
16078,
3181,
1133,
2291,
8336,
8697,
14,
272,
2248,
63,
7764,
275,
488,
199,
199,
3,
21128,
590,
19282,
701,
642,
859,
199,
504,
14802,
423,
11146,
492,
892,
63,
578,
199,
504,
14802,
423,
11146,
492,
2581,
63,
504,
63,
1365,
12,
1350,
63,
504,
63,
1637,
421,
199,
504,
14802,
492,
485,
11146,
199,
3,
970,
278,
330,
23196,
199,
3,
504,
14802,
492,
28540,
199,
646,
14802,
14,
14121,
20067,
465,
28540,
199,
646,
747,
199,
646,
984,
199,
646,
13343,
199,
646,
3598,
421,
199,
3,
31404,
199,
15962,
63,
3170,
275,
378,
199,
4521,
63,
10187,
275,
413,
199,
4521,
63,
6790,
11540,
275,
499,
199,
35,
63,
15498,
275,
650,
199,
4521,
63,
14110,
275,
841,
199,
18150,
63,
16436,
275,
959,
199,
35,
63,
18637,
20012,
275,
1227,
199,
4521,
63,
38,
1092,
58,
742,
275,
1520,
199,
4521,
63,
1439,
11733,
654,
11644,
275,
1695,
199,
8947,
63,
28706,
275,
1749,
421,
199,
318,
664,
63,
11523,
837,
272,
408,
1767,
314,
10628,
1329,
367,
1275,
11357,
503,
1275,
22345,
1584,
1041,
272,
372,
485,
11146,
423,
19973,
63,
20352,
421,
199,
318,
664,
63,
1450,
837,
272,
408,
1767,
314,
10628,
1947,
367,
1275,
11357,
503,
1275,
22345,
1584,
1041,
272,
372,
984,
14,
12236,
14,
1637,
63,
1450,
421,
199,
318,
664,
63,
16097,
837,
272,
3598,
14,
4050,
360,
3236,
14,
362,
63,
16097,
342,
365,
5906,
27,
675,
314,
5262,
283,
2116,
283,
4037,
641,
14802,
14,
14121,
20067,
3140,
297,
2116,
13413,
12,
499,
9,
272,
5478,
275,
3842,
83,
12,
283,
4848,
297,
445,
63,
15498,
9,
367,
308,
315,
28540,
14,
15498,
63,
12273,
654,
61,
272,
1350,
275,
3842,
83,
12,
283,
53,
297,
7843,
63,
10187,
9,
367,
308,
315,
28540,
14,
10187,
63,
12273,
654,
61,
272,
16855,
275,
3842,
83,
12,
283,
4848,
297,
7843,
63,
6790,
11540,
9,
367,
308,
315,
28540,
14,
19714,
6012,
63,
12273,
654,
61,
339,
372,
5478,
435,
1350,
435,
16855,
421,
199,
533,
12119,
18484,
26,
339,
408,
8849,
492,
909,
1041,
339,
347,
636,
826,
721,
277,
12,
931,
304,
267,
340,
931,
508,
8061,
288,
746,
3545,
360,
1667,
11776,
297,
931,
13275,
267,
916,
747,
14,
515,
14,
6027,
8,
515,
304,
288,
746,
3545,
360,
5952,
2082,
297,
931,
29,
515,
9,
339,
347,
2342,
63,
578,
8,
277,
12,
11064,
304,
267,
408,
2439,
2885,
2529,
488,
1041,
267,
372,
488,
421,
199,
533,
485,
40,
564,
379,
25702,
26,
339,
408,
2404,
2159,
4492,
382,
369,
2291,
367,
283,
493,
7,
2368,
402,
7750,
2248,
15192,
342,
272,
3423,
1041,
339,
347,
636,
826,
721,
277,
12,
11064,
12,
931,
12,
570,
29,
403,
304,
267,
1613,
11027,
826,
721,
9930,
12,
931,
9,
267,
291,
14,
493,
275,
570,
339,
347,
664,
63,
576,
8,
277,
12,
931,
304,
267,
408,
39,
3685,
11176,
370,
13770,
361,
5077,
370,
7962,
336,
15,
2248,
15192,
11716,
83,
4875,
3261,
1041,
267,
340,
291,
14,
493,
436,
931,
508,
291,
14,
515,
26,
288,
340,
440,
291,
14,
493,
14,
5938,
26,
355,
570,
275,
291,
14,
493,
288,
587,
26,
355,
291,
14,
493,
275,
570,
275,
1551,
8,
277,
14,
515,
12,
283,
82,
358,
953,
543,
570,
26,
355,
327,
5773,
11019,
7288,
1077,
506,
8152,
2783,
12,
1325,
355,
327,
5800,
5455,
14,
362,
63,
600,
342,
2951,
3032,
4052,
365,
2138,
370,
355,
327,
6555,
342,
1314,
883,
2429,
620,
14,
6061,
13806,
370,
2783,
3955,
355,
327,
4409,
6085,
4039,
734,
314,
2644,
370,
4849,
370,
436,
355,
327,
13343,
14,
13552,
63,
2991,
342,
1454,
11479,
2783,
14,
355,
372,
570,
14,
739,
342,
267,
587,
26,
288,
372,
1613,
1252,
362,
63,
576,
8,
515,
9,
421,
199,
533,
485,
6200,
2980,
2404,
5880,
1547,
40,
564,
379,
25702,
12,
485,
11146,
14,
2980,
1173,
5455,
304,
339,
408,
2404,
5880,
2291,
367,
18234,
2248,
63,
1365,
20693,
272,
327,
66,
23196,
5325,
562,
272,
986,
199,
199,
318,
2248,
63,
1365,
8,
354,
12,
11776,
12,
570,
29,
403,
304,
272,
1499,
275,
661,
3236,
14,
912,
63,
1365,
342,
365,
5906,
27,
675,
283,
1779,
283,
25893,
14,
14121,
20067,
14,
2980,
1173,
5455,
8,
354,
12,
11776,
680,
912,
63,
578,
11716,
1779,
283,
3140,
358,
272,
3598,
14,
4050,
8,
1328,
12,
13413,
12,
499,
9,
272,
485,
6200,
2980,
2404,
5880,
8,
354,
12,
11776,
12,
570,
680,
912,
63,
578,
8,
354,
9,
272,
859,
275,
984,
14,
3112,
59,
354,
61,
272,
327,
4005,
2040,
295,
8786,
370,
18994,
1736,
12,
675,
282,
2222,
13,
20875,
379,
5077,
1314,
272,
327,
7859,
1133,
19687,
641,
282,
3063,
13,
5938,
570,
909,
14,
272,
859,
855,
3422,
363,
275,
485,
11146,
14,
2980,
1173,
5455,
8,
354,
12,
11776,
9,
272,
372,
859,
421,
199,
533,
485,
6200,
32521,
2404,
5880,
1547,
40,
564,
379,
25702,
12,
267,
485,
11146,
14,
2980,
2003,
1173,
5455,
304,
339,
408,
2404,
5880,
2291,
367,
18234,
2248,
63,
8427,
20693,
272,
327,
66,
23196,
5325,
562,
272,
986,
199,
199,
318,
2248,
63,
8427,
8,
354,
12,
11776,
12,
570,
29,
403,
304,
272,
1499,
275,
661,
3236,
14,
912,
63,
8427,
342,
365,
5906,
27
] |
[
2765,
859,
6571,
314,
7323,
4346,
370,
1900,
2195,
5705,
636,
646,
363,
199,
1593,
14,
221,
738,
977,
679,
12546,
3423,
787,
24985,
14,
199,
199,
607,
4750,
5560,
652,
365,
14388,
1265,
11201,
1808,
314,
14802,
859,
1159,
199,
1593,
6712,
1806,
642,
859,
14,
199,
199,
624,
199,
3,
334,
20122,
6665,
9,
1929,
370,
25578,
315,
485,
3236,
199,
504,
485,
3236,
492,
334,
831,
63,
31415,
12,
16919,
63,
831,
12,
4683,
63,
831,
12,
2116,
664,
63,
11202,
63,
785,
12,
365,
63,
11202,
63,
2491,
12,
2116,
4205,
63,
5351,
12,
4205,
63,
11202,
12,
365,
63,
5351,
12,
365,
63,
11202,
12,
2116,
485,
970,
63,
331,
63,
1501,
9,
199,
893,
26,
272,
687,
485,
3236,
492,
2248,
63,
7764,
199,
2590,
3545,
26,
272,
327,
16078,
3181,
1133,
2291,
8336,
8697,
14,
272,
2248,
63,
7764,
275,
488,
199,
199,
3,
21128,
590,
19282,
701,
642,
859,
199,
504,
14802,
423,
11146,
492,
892,
63,
578,
199,
504,
14802,
423,
11146,
492,
2581,
63,
504,
63,
1365,
12,
1350,
63,
504,
63,
1637,
421,
199,
504,
14802,
492,
485,
11146,
199,
3,
970,
278,
330,
23196,
199,
3,
504,
14802,
492,
28540,
199,
646,
14802,
14,
14121,
20067,
465,
28540,
199,
646,
747,
199,
646,
984,
199,
646,
13343,
199,
646,
3598,
421,
199,
3,
31404,
199,
15962,
63,
3170,
275,
378,
199,
4521,
63,
10187,
275,
413,
199,
4521,
63,
6790,
11540,
275,
499,
199,
35,
63,
15498,
275,
650,
199,
4521,
63,
14110,
275,
841,
199,
18150,
63,
16436,
275,
959,
199,
35,
63,
18637,
20012,
275,
1227,
199,
4521,
63,
38,
1092,
58,
742,
275,
1520,
199,
4521,
63,
1439,
11733,
654,
11644,
275,
1695,
199,
8947,
63,
28706,
275,
1749,
421,
199,
318,
664,
63,
11523,
837,
272,
408,
1767,
314,
10628,
1329,
367,
1275,
11357,
503,
1275,
22345,
1584,
1041,
272,
372,
485,
11146,
423,
19973,
63,
20352,
421,
199,
318,
664,
63,
1450,
837,
272,
408,
1767,
314,
10628,
1947,
367,
1275,
11357,
503,
1275,
22345,
1584,
1041,
272,
372,
984,
14,
12236,
14,
1637,
63,
1450,
421,
199,
318,
664,
63,
16097,
837,
272,
3598,
14,
4050,
360,
3236,
14,
362,
63,
16097,
342,
365,
5906,
27,
675,
314,
5262,
283,
2116,
283,
4037,
641,
14802,
14,
14121,
20067,
3140,
297,
2116,
13413,
12,
499,
9,
272,
5478,
275,
3842,
83,
12,
283,
4848,
297,
445,
63,
15498,
9,
367,
308,
315,
28540,
14,
15498,
63,
12273,
654,
61,
272,
1350,
275,
3842,
83,
12,
283,
53,
297,
7843,
63,
10187,
9,
367,
308,
315,
28540,
14,
10187,
63,
12273,
654,
61,
272,
16855,
275,
3842,
83,
12,
283,
4848,
297,
7843,
63,
6790,
11540,
9,
367,
308,
315,
28540,
14,
19714,
6012,
63,
12273,
654,
61,
339,
372,
5478,
435,
1350,
435,
16855,
421,
199,
533,
12119,
18484,
26,
339,
408,
8849,
492,
909,
1041,
339,
347,
636,
826,
721,
277,
12,
931,
304,
267,
340,
931,
508,
8061,
288,
746,
3545,
360,
1667,
11776,
297,
931,
13275,
267,
916,
747,
14,
515,
14,
6027,
8,
515,
304,
288,
746,
3545,
360,
5952,
2082,
297,
931,
29,
515,
9,
339,
347,
2342,
63,
578,
8,
277,
12,
11064,
304,
267,
408,
2439,
2885,
2529,
488,
1041,
267,
372,
488,
421,
199,
533,
485,
40,
564,
379,
25702,
26,
339,
408,
2404,
2159,
4492,
382,
369,
2291,
367,
283,
493,
7,
2368,
402,
7750,
2248,
15192,
342,
272,
3423,
1041,
339,
347,
636,
826,
721,
277,
12,
11064,
12,
931,
12,
570,
29,
403,
304,
267,
1613,
11027,
826,
721,
9930,
12,
931,
9,
267,
291,
14,
493,
275,
570,
339,
347,
664,
63,
576,
8,
277,
12,
931,
304,
267,
408,
39,
3685,
11176,
370,
13770,
361,
5077,
370,
7962,
336,
15,
2248,
15192,
11716,
83,
4875,
3261,
1041,
267,
340,
291,
14,
493,
436,
931,
508,
291,
14,
515,
26,
288,
340,
440,
291,
14,
493,
14,
5938,
26,
355,
570,
275,
291,
14,
493,
288,
587,
26,
355,
291,
14,
493,
275,
570,
275,
1551,
8,
277,
14,
515,
12,
283,
82,
358,
953,
543,
570,
26,
355,
327,
5773,
11019,
7288,
1077,
506,
8152,
2783,
12,
1325,
355,
327,
5800,
5455,
14,
362,
63,
600,
342,
2951,
3032,
4052,
365,
2138,
370,
355,
327,
6555,
342,
1314,
883,
2429,
620,
14,
6061,
13806,
370,
2783,
3955,
355,
327,
4409,
6085,
4039,
734,
314,
2644,
370,
4849,
370,
436,
355,
327,
13343,
14,
13552,
63,
2991,
342,
1454,
11479,
2783,
14,
355,
372,
570,
14,
739,
342,
267,
587,
26,
288,
372,
1613,
1252,
362,
63,
576,
8,
515,
9,
421,
199,
533,
485,
6200,
2980,
2404,
5880,
1547,
40,
564,
379,
25702,
12,
485,
11146,
14,
2980,
1173,
5455,
304,
339,
408,
2404,
5880,
2291,
367,
18234,
2248,
63,
1365,
20693,
272,
327,
66,
23196,
5325,
562,
272,
986,
199,
199,
318,
2248,
63,
1365,
8,
354,
12,
11776,
12,
570,
29,
403,
304,
272,
1499,
275,
661,
3236,
14,
912,
63,
1365,
342,
365,
5906,
27,
675,
283,
1779,
283,
25893,
14,
14121,
20067,
14,
2980,
1173,
5455,
8,
354,
12,
11776,
680,
912,
63,
578,
11716,
1779,
283,
3140,
358,
272,
3598,
14,
4050,
8,
1328,
12,
13413,
12,
499,
9,
272,
485,
6200,
2980,
2404,
5880,
8,
354,
12,
11776,
12,
570,
680,
912,
63,
578,
8,
354,
9,
272,
859,
275,
984,
14,
3112,
59,
354,
61,
272,
327,
4005,
2040,
295,
8786,
370,
18994,
1736,
12,
675,
282,
2222,
13,
20875,
379,
5077,
1314,
272,
327,
7859,
1133,
19687,
641,
282,
3063,
13,
5938,
570,
909,
14,
272,
859,
855,
3422,
363,
275,
485,
11146,
14,
2980,
1173,
5455,
8,
354,
12,
11776,
9,
272,
372,
859,
421,
199,
533,
485,
6200,
32521,
2404,
5880,
1547,
40,
564,
379,
25702,
12,
267,
485,
11146,
14,
2980,
2003,
1173,
5455,
304,
339,
408,
2404,
5880,
2291,
367,
18234,
2248,
63,
8427,
20693,
272,
327,
66,
23196,
5325,
562,
272,
986,
199,
199,
318,
2248,
63,
8427,
8,
354,
12,
11776,
12,
570,
29,
403,
304,
272,
1499,
275,
661,
3236,
14,
912,
63,
8427,
342,
365,
5906,
27,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tuxxy/CloudBot
|
plugins/youtube.py
|
16
|
5563
|
import re
import time
import isodate
import requests
from cloudbot import hook
from cloudbot.util import timeformat
from cloudbot.util.formatting import pluralize
youtube_re = re.compile(r'(?:youtube.*?(?:v=|/v/)|youtu\.be/|yooouuutuuube.*?id=)([-_a-zA-Z0-9]+)', re.I)
base_url = 'https://www.googleapis.com/youtube/v3/'
api_url = base_url + 'videos?part=contentDetails%2C+snippet%2C+statistics&id={}&key={}'
search_api_url = base_url + 'search?part=id&maxResults=1'
playlist_api_url = base_url + 'playlists?part=snippet%2CcontentDetails%2Cstatus'
video_url = "http://youtu.be/%s"
err_no_api = "The YouTube API is off in the Google Developers Console."
def get_video_description(video_id):
json = requests.get(api_url.format(video_id, dev_key)).json()
if json.get('error'):
if json['error']['code'] == 403:
return err_no_api
else:
return
data = json['items']
snippet = data[0]['snippet']
statistics = data[0]['statistics']
content_details = data[0]['contentDetails']
out = '\x02{}\x02'.format(snippet['title'])
if not content_details.get('duration'):
return out
length = isodate.parse_duration(content_details['duration'])
out += ' - length \x02{}\x02'.format(timeformat.format_time(int(length.total_seconds()), simple=True))
total_votes = float(statistics['likeCount']) + float(statistics['dislikeCount'])
if total_votes != 0:
# format
likes = pluralize(int(statistics['likeCount']), "like")
dislikes = pluralize(int(statistics['dislikeCount']), "dislike")
percent = 100 * float(statistics['likeCount']) / total_votes
out += ' - {}, {} (\x02{:.1f}\x02%)'.format(likes,
dislikes, percent)
if 'viewCount' in statistics:
views = int(statistics['viewCount'])
out += ' - \x02{:,}\x02 view{}'.format(views, "s"[views == 1:])
uploader = snippet['channelTitle']
upload_time = time.strptime(snippet['publishedAt'], "%Y-%m-%dT%H:%M:%S.000Z")
out += ' - \x02{}\x02 on \x02{}\x02'.format(uploader,
time.strftime("%Y.%m.%d", upload_time))
if 'contentRating' in content_details:
out += ' - \x034NSFW\x02'
return out
@hook.on_start()
def load_key(bot):
global dev_key
dev_key = bot.config.get("api_keys", {}).get("google_dev_key", None)
@hook.regex(youtube_re)
def youtube_url(match):
return get_video_description(match.group(1))
@hook.command("youtube", "you", "yt", "y")
def youtube(text):
"""youtube <query> -- Returns the first YouTube search result for <query>."""
if not dev_key:
return "This command requires a Google Developers Console API key."
json = requests.get(search_api_url, params={"q": text, "key": dev_key, "type": "video"}).json()
if json.get('error'):
if json['error']['code'] == 403:
return err_no_api
else:
return 'Error performing search.'
if json['pageInfo']['totalResults'] == 0:
return 'No results found.'
video_id = json['items'][0]['id']['videoId']
return get_video_description(video_id) + " - " + video_url % video_id
@hook.command("youtime", "ytime")
def youtime(text):
"""youtime <query> -- Gets the total run time of the first YouTube search result for <query>."""
if not dev_key:
return "This command requires a Google Developers Console API key."
json = requests.get(search_api_url, params={"q": text, "key": dev_key, "type": "video"}).json()
if json.get('error'):
if json['error']['code'] == 403:
return err_no_api
else:
return 'Error performing search.'
if json['pageInfo']['totalResults'] == 0:
return 'No results found.'
video_id = json['items'][0]['id']['videoId']
json = requests.get(api_url.format(video_id, dev_key)).json()
if json.get('error'):
return
data = json['items']
snippet = data[0]['snippet']
content_details = data[0]['contentDetails']
statistics = data[0]['statistics']
if not content_details.get('duration'):
return
length = isodate.parse_duration(content_details['duration'])
l_sec = int(length.total_seconds())
views = int(statistics['viewCount'])
total = int(l_sec * views)
length_text = timeformat.format_time(l_sec, simple=True)
total_text = timeformat.format_time(total, accuracy=8)
return 'The video \x02{}\x02 has a length of {} and has been viewed {:,} times for ' \
'a total run time of {}!'.format(snippet['title'], length_text, views,
total_text)
ytpl_re = re.compile(r'(.*:)//(www.youtube.com/playlist|youtube.com/playlist)(:[0-9]+)?(.*)', re.I)
@hook.regex(ytpl_re)
def ytplaylist_url(match):
location = match.group(4).split("=")[-1]
json = requests.get(playlist_api_url, params={"id": location, "key": dev_key}).json()
if json.get('error'):
if json['error']['code'] == 403:
return err_no_api
else:
return 'Error looking up playlist.'
data = json['items']
snippet = data[0]['snippet']
content_details = data[0]['contentDetails']
title = snippet['title']
author = snippet['channelTitle']
num_videos = int(content_details['itemCount'])
count_videos = ' - \x02{:,}\x02 video{}'.format(num_videos, "s"[num_videos == 1:])
return "\x02{}\x02 {} - \x02{}\x02".format(title, count_videos, author)
|
gpl-3.0
|
[
646,
295,
199,
646,
900,
199,
199,
646,
365,
364,
323,
199,
646,
4145,
199,
199,
504,
2463,
8301,
357,
492,
5759,
199,
504,
2463,
8301,
357,
14,
1974,
492,
900,
908,
199,
504,
2463,
8301,
357,
14,
1974,
14,
20034,
492,
11718,
794,
421,
199,
9788,
63,
264,
275,
295,
14,
2014,
8,
82,
20459,
9788,
6697,
5169,
86,
26777,
15,
86,
15,
8636,
89,
548,
85,
4537,
1235,
15,
92,
89,
1534,
810,
85,
337,
17031,
3375,
6697,
344,
29,
9,
11468,
63,
65,
13,
6353,
13,
58,
16,
13,
25,
28798,
295,
14,
41,
9,
199,
199,
1095,
63,
633,
275,
283,
2859,
921,
1544,
14,
17533,
14,
957,
15,
9788,
15,
86,
19,
4805,
199,
1246,
63,
633,
275,
1300,
63,
633,
435,
283,
11418,
31,
2064,
29,
1317,
11347,
5,
18,
35,
11,
18547,
5,
18,
35,
11,
13724,
6,
344,
7622,
6,
498,
7622,
7,
199,
1733,
63,
1246,
63,
633,
275,
1300,
63,
633,
435,
283,
1733,
31,
2064,
29,
344,
6,
988,
6579,
29,
17,
7,
199,
10411,
63,
1246,
63,
633,
275,
1300,
63,
633,
435,
283,
2802,
6717,
31,
2064,
29,
18547,
5,
18,
35,
1317,
11347,
5,
18,
35,
1205,
7,
199,
3722,
63,
633,
275,
298,
1014,
921,
89,
548,
85,
14,
1235,
3149,
83,
2,
199,
1508,
63,
889,
63,
1246,
275,
298,
1918,
23534,
3261,
365,
2331,
315,
314,
4475,
23493,
19809,
2122,
421,
199,
318,
664,
63,
3722,
63,
1802,
8,
3722,
63,
344,
304,
272,
2022,
275,
4145,
14,
362,
8,
1246,
63,
633,
14,
908,
8,
3722,
63,
344,
12,
4866,
63,
498,
4992,
1001,
342,
339,
340,
2022,
14,
362,
360,
705,
735,
267,
340,
2022,
459,
705,
2545,
600,
418,
508,
13269,
26,
288,
372,
2329,
63,
889,
63,
1246,
267,
587,
26,
288,
372,
339,
666,
275,
2022,
459,
1744,
418,
272,
17440,
275,
666,
59,
16,
2733,
18547,
418,
272,
11076,
275,
666,
59,
16,
2733,
13724,
418,
272,
1564,
63,
5087,
275,
666,
59,
16,
2733,
1317,
11347,
418,
339,
734,
275,
1557,
88,
996,
24423,
88,
996,
1370,
908,
8,
18547,
459,
1213,
1105,
339,
340,
440,
1564,
63,
5087,
14,
362,
360,
5553,
735,
267,
372,
734,
339,
2582,
275,
365,
364,
323,
14,
1122,
63,
5553,
8,
1317,
63,
5087,
459,
5553,
1105,
272,
734,
847,
283,
446,
2582,
971,
88,
996,
24423,
88,
996,
1370,
908,
8,
521,
908,
14,
908,
63,
521,
8,
442,
8,
1267,
14,
2923,
63,
4515,
4000,
3486,
29,
549,
430,
272,
3141,
63,
16660,
275,
2069,
8,
13724,
459,
2930,
2353,
1105,
435,
2069,
8,
13724,
459,
2297,
2930,
2353,
1105,
339,
340,
3141,
63,
16660,
1137,
378,
26,
267,
327,
1475,
267,
1212,
9246,
275,
11718,
794,
8,
442,
8,
13724,
459,
2930,
2353,
3815,
298,
2930,
531,
267,
2153,
29572,
275,
11718,
794,
8,
442,
8,
13724,
459,
2297,
2930,
2353,
3815,
298,
2297,
2930,
531,
398,
8878,
275,
2948,
627,
2069,
8,
13724,
459,
2930,
2353,
1105,
1182,
3141,
63,
16660,
267,
734,
847,
283,
446,
5479,
1052,
14749,
88,
996,
91,
14010,
17,
70,
4988,
88,
996,
5,
9,
1370,
908,
8,
29572,
12,
8105,
2153,
29572,
12,
8878,
9,
339,
340,
283,
1345,
2353,
7,
315,
11076,
26,
267,
6858,
275,
1109,
8,
13724,
459,
1345,
2353,
1105,
267,
734,
847,
283,
446,
971,
88,
996,
91,
11941,
4988,
88,
996,
2455,
11123,
908,
8,
4196,
12,
298,
83,
22774,
4196,
508,
413,
5728,
339,
25257,
275,
17440,
459,
2775,
6888,
418,
339,
5802,
63,
521,
275,
900,
14,
9866,
8,
18547,
459,
8987,
1271,
995,
2071,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
51,
14,
1493,
58,
531,
272,
734,
847,
283,
446,
971,
88,
996,
24423,
88,
996,
641,
971,
88,
996,
24423,
88,
996,
1370,
908,
8,
13671,
12,
6059,
900,
14,
6205,
3647,
57,
4111,
77,
4111,
68,
401,
5802,
63,
521,
430,
339,
340,
283,
1317,
32533,
7,
315,
1564,
63,
5087,
26,
267,
734,
847,
283,
446,
971,
88,
21756,
2709,
19445,
60,
88,
996,
7,
339,
372,
734,
421,
199,
32,
3664,
14,
265,
63,
928,
342,
199,
318,
2248,
63,
498,
8,
3018,
304,
272,
2288,
4866,
63,
498,
272,
4866,
63,
498,
275,
5888,
14,
888,
14,
362,
480,
1246,
63,
1612,
401,
13056,
362,
480,
3098,
63,
2374,
63,
498,
401,
488,
9,
421,
199,
32,
3664,
14,
3821,
8,
9788,
63,
264,
9,
199,
318,
22378,
63,
633,
8,
1431,
304,
272,
372,
664,
63,
3722,
63,
1802,
8,
1431,
14,
923,
8,
17,
430,
421,
199,
32,
3664,
14,
1531,
480,
9788,
401,
298,
13297,
401,
298,
24264,
401,
298,
89,
531,
199,
318,
22378,
8,
505,
304,
272,
408,
9788,
665,
1131,
30,
1553,
1803,
314,
1642,
23534,
2754,
754,
367,
665,
1131,
30,
1041,
272,
340,
440,
4866,
63,
498,
26,
267,
372,
298,
2765,
1414,
5074,
282,
4475,
23493,
19809,
3261,
790,
2122,
339,
2022,
275,
4145,
14,
362,
8,
1733,
63,
1246,
63,
633,
12,
1862,
8871,
81,
582,
1318,
12,
298,
498,
582,
4866,
63,
498,
12,
298,
466,
582,
298,
3722,
3570,
680,
1001,
342,
339,
340,
2022,
14,
362,
360,
705,
735,
267,
340,
2022,
459,
705,
2545,
600,
418,
508,
13269,
26,
288,
372,
2329,
63,
889,
63,
1246,
267,
587,
26,
288,
372,
283,
547,
19203,
2754,
3530,
339,
340,
2022,
459,
1606,
2354,
2545,
2923,
6579,
418,
508,
378,
26,
267,
372,
283,
1944,
2058,
1911,
3530,
339,
3991,
63,
344,
275,
2022,
459,
1744,
3488,
16,
2733,
344,
2545,
3722,
1304,
418,
339,
372,
664,
63,
3722,
63,
1802,
8,
3722,
63,
344,
9,
435,
298,
446,
298,
435,
3991,
63,
633,
450,
3991,
63,
344,
421,
199,
32,
3664,
14,
1531,
480,
13297,
521,
401,
298,
89,
521,
531,
199,
318,
1265,
521,
8,
505,
304,
272,
408,
13297,
521,
665,
1131,
30,
1553,
14509,
314,
3141,
1255,
900,
402,
314,
1642,
23534,
2754,
754,
367,
665,
1131,
30,
1041,
272,
340,
440,
4866,
63,
498,
26,
267,
372,
298,
2765,
1414,
5074,
282,
4475,
23493,
19809,
3261,
790,
2122
] |
[
295,
199,
646,
900,
199,
199,
646,
365,
364,
323,
199,
646,
4145,
199,
199,
504,
2463,
8301,
357,
492,
5759,
199,
504,
2463,
8301,
357,
14,
1974,
492,
900,
908,
199,
504,
2463,
8301,
357,
14,
1974,
14,
20034,
492,
11718,
794,
421,
199,
9788,
63,
264,
275,
295,
14,
2014,
8,
82,
20459,
9788,
6697,
5169,
86,
26777,
15,
86,
15,
8636,
89,
548,
85,
4537,
1235,
15,
92,
89,
1534,
810,
85,
337,
17031,
3375,
6697,
344,
29,
9,
11468,
63,
65,
13,
6353,
13,
58,
16,
13,
25,
28798,
295,
14,
41,
9,
199,
199,
1095,
63,
633,
275,
283,
2859,
921,
1544,
14,
17533,
14,
957,
15,
9788,
15,
86,
19,
4805,
199,
1246,
63,
633,
275,
1300,
63,
633,
435,
283,
11418,
31,
2064,
29,
1317,
11347,
5,
18,
35,
11,
18547,
5,
18,
35,
11,
13724,
6,
344,
7622,
6,
498,
7622,
7,
199,
1733,
63,
1246,
63,
633,
275,
1300,
63,
633,
435,
283,
1733,
31,
2064,
29,
344,
6,
988,
6579,
29,
17,
7,
199,
10411,
63,
1246,
63,
633,
275,
1300,
63,
633,
435,
283,
2802,
6717,
31,
2064,
29,
18547,
5,
18,
35,
1317,
11347,
5,
18,
35,
1205,
7,
199,
3722,
63,
633,
275,
298,
1014,
921,
89,
548,
85,
14,
1235,
3149,
83,
2,
199,
1508,
63,
889,
63,
1246,
275,
298,
1918,
23534,
3261,
365,
2331,
315,
314,
4475,
23493,
19809,
2122,
421,
199,
318,
664,
63,
3722,
63,
1802,
8,
3722,
63,
344,
304,
272,
2022,
275,
4145,
14,
362,
8,
1246,
63,
633,
14,
908,
8,
3722,
63,
344,
12,
4866,
63,
498,
4992,
1001,
342,
339,
340,
2022,
14,
362,
360,
705,
735,
267,
340,
2022,
459,
705,
2545,
600,
418,
508,
13269,
26,
288,
372,
2329,
63,
889,
63,
1246,
267,
587,
26,
288,
372,
339,
666,
275,
2022,
459,
1744,
418,
272,
17440,
275,
666,
59,
16,
2733,
18547,
418,
272,
11076,
275,
666,
59,
16,
2733,
13724,
418,
272,
1564,
63,
5087,
275,
666,
59,
16,
2733,
1317,
11347,
418,
339,
734,
275,
1557,
88,
996,
24423,
88,
996,
1370,
908,
8,
18547,
459,
1213,
1105,
339,
340,
440,
1564,
63,
5087,
14,
362,
360,
5553,
735,
267,
372,
734,
339,
2582,
275,
365,
364,
323,
14,
1122,
63,
5553,
8,
1317,
63,
5087,
459,
5553,
1105,
272,
734,
847,
283,
446,
2582,
971,
88,
996,
24423,
88,
996,
1370,
908,
8,
521,
908,
14,
908,
63,
521,
8,
442,
8,
1267,
14,
2923,
63,
4515,
4000,
3486,
29,
549,
430,
272,
3141,
63,
16660,
275,
2069,
8,
13724,
459,
2930,
2353,
1105,
435,
2069,
8,
13724,
459,
2297,
2930,
2353,
1105,
339,
340,
3141,
63,
16660,
1137,
378,
26,
267,
327,
1475,
267,
1212,
9246,
275,
11718,
794,
8,
442,
8,
13724,
459,
2930,
2353,
3815,
298,
2930,
531,
267,
2153,
29572,
275,
11718,
794,
8,
442,
8,
13724,
459,
2297,
2930,
2353,
3815,
298,
2297,
2930,
531,
398,
8878,
275,
2948,
627,
2069,
8,
13724,
459,
2930,
2353,
1105,
1182,
3141,
63,
16660,
267,
734,
847,
283,
446,
5479,
1052,
14749,
88,
996,
91,
14010,
17,
70,
4988,
88,
996,
5,
9,
1370,
908,
8,
29572,
12,
8105,
2153,
29572,
12,
8878,
9,
339,
340,
283,
1345,
2353,
7,
315,
11076,
26,
267,
6858,
275,
1109,
8,
13724,
459,
1345,
2353,
1105,
267,
734,
847,
283,
446,
971,
88,
996,
91,
11941,
4988,
88,
996,
2455,
11123,
908,
8,
4196,
12,
298,
83,
22774,
4196,
508,
413,
5728,
339,
25257,
275,
17440,
459,
2775,
6888,
418,
339,
5802,
63,
521,
275,
900,
14,
9866,
8,
18547,
459,
8987,
1271,
995,
2071,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
51,
14,
1493,
58,
531,
272,
734,
847,
283,
446,
971,
88,
996,
24423,
88,
996,
641,
971,
88,
996,
24423,
88,
996,
1370,
908,
8,
13671,
12,
6059,
900,
14,
6205,
3647,
57,
4111,
77,
4111,
68,
401,
5802,
63,
521,
430,
339,
340,
283,
1317,
32533,
7,
315,
1564,
63,
5087,
26,
267,
734,
847,
283,
446,
971,
88,
21756,
2709,
19445,
60,
88,
996,
7,
339,
372,
734,
421,
199,
32,
3664,
14,
265,
63,
928,
342,
199,
318,
2248,
63,
498,
8,
3018,
304,
272,
2288,
4866,
63,
498,
272,
4866,
63,
498,
275,
5888,
14,
888,
14,
362,
480,
1246,
63,
1612,
401,
13056,
362,
480,
3098,
63,
2374,
63,
498,
401,
488,
9,
421,
199,
32,
3664,
14,
3821,
8,
9788,
63,
264,
9,
199,
318,
22378,
63,
633,
8,
1431,
304,
272,
372,
664,
63,
3722,
63,
1802,
8,
1431,
14,
923,
8,
17,
430,
421,
199,
32,
3664,
14,
1531,
480,
9788,
401,
298,
13297,
401,
298,
24264,
401,
298,
89,
531,
199,
318,
22378,
8,
505,
304,
272,
408,
9788,
665,
1131,
30,
1553,
1803,
314,
1642,
23534,
2754,
754,
367,
665,
1131,
30,
1041,
272,
340,
440,
4866,
63,
498,
26,
267,
372,
298,
2765,
1414,
5074,
282,
4475,
23493,
19809,
3261,
790,
2122,
339,
2022,
275,
4145,
14,
362,
8,
1733,
63,
1246,
63,
633,
12,
1862,
8871,
81,
582,
1318,
12,
298,
498,
582,
4866,
63,
498,
12,
298,
466,
582,
298,
3722,
3570,
680,
1001,
342,
339,
340,
2022,
14,
362,
360,
705,
735,
267,
340,
2022,
459,
705,
2545,
600,
418,
508,
13269,
26,
288,
372,
2329,
63,
889,
63,
1246,
267,
587,
26,
288,
372,
283,
547,
19203,
2754,
3530,
339,
340,
2022,
459,
1606,
2354,
2545,
2923,
6579,
418,
508,
378,
26,
267,
372,
283,
1944,
2058,
1911,
3530,
339,
3991,
63,
344,
275,
2022,
459,
1744,
3488,
16,
2733,
344,
2545,
3722,
1304,
418,
339,
372,
664,
63,
3722,
63,
1802,
8,
3722,
63,
344,
9,
435,
298,
446,
298,
435,
3991,
63,
633,
450,
3991,
63,
344,
421,
199,
32,
3664,
14,
1531,
480,
13297,
521,
401,
298,
89,
521,
531,
199,
318,
1265,
521,
8,
505,
304,
272,
408,
13297,
521,
665,
1131,
30,
1553,
14509,
314,
3141,
1255,
900,
402,
314,
1642,
23534,
2754,
754,
367,
665,
1131,
30,
1041,
272,
340,
440,
4866,
63,
498,
26,
267,
372,
298,
2765,
1414,
5074,
282,
4475,
23493,
19809,
3261,
790,
2122,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
varunarya10/heat
|
heat/db/sqlalchemy/migrate_repo/versions/015_grizzly.py
|
4
|
6650
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# 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 sqlalchemy
def upgrade(migrate_engine):
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
raw_template = sqlalchemy.Table(
'raw_template', meta,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True,
nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('template', sqlalchemy.Text),
)
user_creds = sqlalchemy.Table(
'user_creds', meta,
sqlalchemy.Column('id', sqlalchemy.Integer,
primary_key=True, nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('username', sqlalchemy.String(255)),
sqlalchemy.Column('password', sqlalchemy.String(255)),
sqlalchemy.Column('service_user', sqlalchemy.String(255)),
sqlalchemy.Column('service_password', sqlalchemy.String(255)),
sqlalchemy.Column('tenant', sqlalchemy.String(1024)),
sqlalchemy.Column('auth_url', sqlalchemy.Text),
sqlalchemy.Column('aws_auth_url', sqlalchemy.Text),
sqlalchemy.Column('tenant_id', sqlalchemy.String(256)),
sqlalchemy.Column('aws_creds', sqlalchemy.Text),
)
stack = sqlalchemy.Table(
'stack', meta,
sqlalchemy.Column('id', sqlalchemy.String(36),
primary_key=True, nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('raw_template_id',
sqlalchemy.Integer,
sqlalchemy.ForeignKey('raw_template.id'),
nullable=False),
sqlalchemy.Column('user_creds_id', sqlalchemy.Integer,
sqlalchemy.ForeignKey('user_creds.id'),
nullable=False),
sqlalchemy.Column('username', sqlalchemy.String(256)),
sqlalchemy.Column('owner_id', sqlalchemy.String(36)),
sqlalchemy.Column('status', sqlalchemy.String(255)),
sqlalchemy.Column('status_reason', sqlalchemy.String(255)),
sqlalchemy.Column('parameters', sqlalchemy.Text),
sqlalchemy.Column('timeout', sqlalchemy.Integer, nullable=False),
sqlalchemy.Column('tenant', sqlalchemy.String(256)),
sqlalchemy.Column('disable_rollback', sqlalchemy.Boolean,
nullable=False),
)
resource = sqlalchemy.Table(
'resource', meta,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True,
nullable=False),
sqlalchemy.Column('nova_instance', sqlalchemy.String(255)),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('state', sqlalchemy.String(255)),
sqlalchemy.Column('state_description', sqlalchemy.String(255)),
sqlalchemy.Column('stack_id', sqlalchemy.String(36),
sqlalchemy.ForeignKey('stack.id'), nullable=False),
sqlalchemy.Column('rsrc_metadata', sqlalchemy.Text),
)
event = sqlalchemy.Table(
'event', meta,
sqlalchemy.Column('id', sqlalchemy.Integer,
primary_key=True, nullable=False),
sqlalchemy.Column('stack_id', sqlalchemy.String(36),
sqlalchemy.ForeignKey('stack.id'), nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('logical_resource_id', sqlalchemy.String(255)),
sqlalchemy.Column('physical_resource_id', sqlalchemy.String(255)),
sqlalchemy.Column('resource_status_reason', sqlalchemy.String(255)),
sqlalchemy.Column('resource_type', sqlalchemy.String(255)),
sqlalchemy.Column('resource_properties', sqlalchemy.PickleType),
)
watch_rule = sqlalchemy.Table(
'watch_rule', meta,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True,
nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('state', sqlalchemy.String(255)),
sqlalchemy.Column('rule', sqlalchemy.Text),
sqlalchemy.Column('last_evaluated', sqlalchemy.DateTime),
sqlalchemy.Column('stack_id', sqlalchemy.String(36),
sqlalchemy.ForeignKey('stack.id'), nullable=False),
)
watch_data = sqlalchemy.Table(
'watch_data', meta,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True,
nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('data', sqlalchemy.Text),
sqlalchemy.Column('watch_rule_id', sqlalchemy.Integer,
sqlalchemy.ForeignKey('watch_rule.id'),
nullable=False),
)
tables = (
raw_template,
user_creds,
stack,
resource,
event,
watch_rule,
watch_data,
)
for index, table in enumerate(tables):
try:
table.create()
except:
# If an error occurs, drop all tables created so far to return
# to the previously existing state.
meta.drop_all(tables=tables[:index])
raise
def downgrade(migrate_engine):
raise Exception('Database downgrade not supported - would drop all tables')
|
apache-2.0
|
[
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
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,
8335,
421,
199,
318,
10754,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
25285,
342,
272,
3404,
14,
3409,
275,
12810,
63,
3908,
339,
3066,
63,
1160,
275,
8335,
14,
3186,
8,
267,
283,
1773,
63,
1160,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
2674,
12,
5062,
63,
498,
29,
549,
12,
2079,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
1160,
297,
8335,
14,
1872,
395,
272,
776,
339,
922,
63,
15226,
275,
8335,
14,
3186,
8,
267,
283,
751,
63,
15226,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
2674,
12,
2079,
5062,
63,
498,
29,
549,
12,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
2473,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
2060,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1364,
63,
751,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1364,
63,
2060,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
4647,
297,
8335,
14,
1558,
8,
7727,
1826,
267,
8335,
14,
4547,
360,
1178,
63,
633,
297,
8335,
14,
1872,
395,
267,
8335,
14,
4547,
360,
7231,
63,
1178,
63,
633,
297,
8335,
14,
1872,
395,
267,
8335,
14,
4547,
360,
4647,
63,
344,
297,
8335,
14,
1558,
8,
3912,
1826,
267,
8335,
14,
4547,
360,
7231,
63,
15226,
297,
8335,
14,
1872,
395,
272,
776,
339,
3464,
275,
8335,
14,
3186,
8,
267,
283,
2340,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
1558,
8,
1344,
395,
2079,
5062,
63,
498,
29,
549,
12,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
354,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1773,
63,
1160,
63,
344,
297,
2079,
8335,
14,
2674,
12,
2079,
8335,
14,
3190,
360,
1773,
63,
1160,
14,
344,
659,
2079,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
751,
63,
15226,
63,
344,
297,
8335,
14,
2674,
12,
2079,
8335,
14,
3190,
360,
751,
63,
15226,
14,
344,
659,
2079,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
2473,
297,
8335,
14,
1558,
8,
3912,
1826,
267,
8335,
14,
4547,
360,
4597,
63,
344,
297,
8335,
14,
1558,
8,
1344,
1826,
267,
8335,
14,
4547,
360,
1205,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1205,
63,
5764,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
3214,
297,
8335,
14,
1872,
395,
267,
8335,
14,
4547,
360,
2593,
297,
8335,
14,
2674,
12,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
4647,
297,
8335,
14,
1558,
8,
3912,
1826,
267,
8335,
14,
4547,
360,
5993,
63,
10437,
297,
8335,
14,
4082,
12,
2079,
7854,
29,
797,
395,
272,
776,
339,
2073,
275,
8335,
14,
3186,
8,
267,
283,
1927,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
2674,
12,
5062,
63,
498,
29,
549,
12,
2079,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
6765,
63,
842,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
354,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
929,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
929,
63,
1802,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
2340,
63,
344,
297,
8335,
14,
1558,
8,
1344,
395,
2079,
8335,
14,
3190,
360,
2340,
14,
344,
659,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
30842,
63,
2343,
297,
8335,
14,
1872,
395,
272,
776,
339,
1566,
275,
8335,
14,
3186,
8,
267,
283,
1430,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
2674,
12,
2079,
5062,
63,
498,
29,
549,
12,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
2340,
63,
344,
297,
8335,
14,
1558,
8,
1344,
395,
2079,
8335,
14,
3190,
360,
2340,
14,
344,
659,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
354,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
7954,
63,
1927,
63,
344,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
15020,
63,
1927,
63,
344,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1927,
63,
1205,
63,
5764,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1927,
63,
466,
297
] |
[
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
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,
8335,
421,
199,
318,
10754,
8,
8462,
63,
3908,
304,
272,
3404,
275,
8335,
14,
25285,
342,
272,
3404,
14,
3409,
275,
12810,
63,
3908,
339,
3066,
63,
1160,
275,
8335,
14,
3186,
8,
267,
283,
1773,
63,
1160,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
2674,
12,
5062,
63,
498,
29,
549,
12,
2079,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
1160,
297,
8335,
14,
1872,
395,
272,
776,
339,
922,
63,
15226,
275,
8335,
14,
3186,
8,
267,
283,
751,
63,
15226,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
2674,
12,
2079,
5062,
63,
498,
29,
549,
12,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
2473,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
2060,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1364,
63,
751,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1364,
63,
2060,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
4647,
297,
8335,
14,
1558,
8,
7727,
1826,
267,
8335,
14,
4547,
360,
1178,
63,
633,
297,
8335,
14,
1872,
395,
267,
8335,
14,
4547,
360,
7231,
63,
1178,
63,
633,
297,
8335,
14,
1872,
395,
267,
8335,
14,
4547,
360,
4647,
63,
344,
297,
8335,
14,
1558,
8,
3912,
1826,
267,
8335,
14,
4547,
360,
7231,
63,
15226,
297,
8335,
14,
1872,
395,
272,
776,
339,
3464,
275,
8335,
14,
3186,
8,
267,
283,
2340,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
1558,
8,
1344,
395,
2079,
5062,
63,
498,
29,
549,
12,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
354,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1773,
63,
1160,
63,
344,
297,
2079,
8335,
14,
2674,
12,
2079,
8335,
14,
3190,
360,
1773,
63,
1160,
14,
344,
659,
2079,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
751,
63,
15226,
63,
344,
297,
8335,
14,
2674,
12,
2079,
8335,
14,
3190,
360,
751,
63,
15226,
14,
344,
659,
2079,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
2473,
297,
8335,
14,
1558,
8,
3912,
1826,
267,
8335,
14,
4547,
360,
4597,
63,
344,
297,
8335,
14,
1558,
8,
1344,
1826,
267,
8335,
14,
4547,
360,
1205,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1205,
63,
5764,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
3214,
297,
8335,
14,
1872,
395,
267,
8335,
14,
4547,
360,
2593,
297,
8335,
14,
2674,
12,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
4647,
297,
8335,
14,
1558,
8,
3912,
1826,
267,
8335,
14,
4547,
360,
5993,
63,
10437,
297,
8335,
14,
4082,
12,
2079,
7854,
29,
797,
395,
272,
776,
339,
2073,
275,
8335,
14,
3186,
8,
267,
283,
1927,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
2674,
12,
5062,
63,
498,
29,
549,
12,
2079,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
6765,
63,
842,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
354,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
929,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
929,
63,
1802,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
2340,
63,
344,
297,
8335,
14,
1558,
8,
1344,
395,
2079,
8335,
14,
3190,
360,
2340,
14,
344,
659,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
30842,
63,
2343,
297,
8335,
14,
1872,
395,
272,
776,
339,
1566,
275,
8335,
14,
3186,
8,
267,
283,
1430,
297,
3404,
12,
267,
8335,
14,
4547,
360,
344,
297,
8335,
14,
2674,
12,
2079,
5062,
63,
498,
29,
549,
12,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
2340,
63,
344,
297,
8335,
14,
1558,
8,
1344,
395,
2079,
8335,
14,
3190,
360,
2340,
14,
344,
659,
7854,
29,
797,
395,
267,
8335,
14,
4547,
360,
3966,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
5334,
63,
292,
297,
8335,
14,
3926,
395,
267,
8335,
14,
4547,
360,
354,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
7954,
63,
1927,
63,
344,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
15020,
63,
1927,
63,
344,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1927,
63,
1205,
63,
5764,
297,
8335,
14,
1558,
8,
2299,
1826,
267,
8335,
14,
4547,
360,
1927,
63,
466,
297,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
ntymtsiv/CloudFerry
|
cloudferrylib/os/actions/cleanup_images.py
|
9
|
1638
|
# Copyright (c) 2014 Mirantis 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 copy
from cloudferrylib.base.action import action
from cloudferrylib.utils import utils as utl
class CleanupImages(action.Action):
def run(self, info, **kwargs):
info = copy.deepcopy(info)
src_img = self.src_cloud.resources[utl.IMAGE_RESOURCE]
dst_img = self.dst_cloud.resources[utl.IMAGE_RESOURCE]
checksum_list = []
for instance in info[utl.INSTANCES_TYPE].itervalues():
volumes = instance[utl.META_INFO].get(utl.VOLUME_BODY)
if not volumes:
continue
for vol in volumes:
if utl.IMAGE_BODY in vol[utl.META_INFO]:
image_checksum = vol[utl.META_INFO][utl.IMAGE_BODY]['checksum']
if image_checksum not in checksum_list:
checksum_list.append(image_checksum)
for chs in checksum_list:
map(src_img.delete_image, src_img.get_img_id_list_by_checksum(chs))
map(dst_img.delete_image, dst_img.get_img_id_list_by_checksum(chs))
return {}
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6927,
603,
723,
4466,
83,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
844,
2736,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
4319,
2281,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
3,
199,
3,
4204,
1334,
314,
844,
14,
421,
199,
646,
1331,
199,
199,
504,
8002,
2412,
651,
773,
14,
1095,
14,
1287,
492,
1595,
199,
504,
8002,
2412,
651,
773,
14,
1208,
492,
3778,
465,
11430,
76,
421,
199,
533,
30022,
18882,
8,
1287,
14,
3310,
304,
339,
347,
1255,
8,
277,
12,
2256,
12,
1011,
958,
304,
267,
2256,
275,
1331,
14,
8293,
8,
815,
9,
398,
2928,
63,
4060,
275,
291,
14,
2164,
63,
4091,
14,
4435,
59,
337,
76,
14,
9438,
63,
14110,
61,
267,
5042,
63,
4060,
275,
291,
14,
5119,
63,
4091,
14,
4435,
59,
337,
76,
14,
9438,
63,
14110,
61,
398,
9040,
63,
513,
275,
942,
398,
367,
1256,
315,
2256,
59,
337,
76,
14,
7834,
879,
16734,
63,
2711,
1055,
13012,
837,
288,
12158,
275,
1256,
59,
337,
76,
14,
10614,
63,
4531,
1055,
362,
8,
337,
76,
14,
16689,
63,
23708,
9,
953,
340,
440,
12158,
26,
355,
1980,
953,
367,
5236,
315,
12158,
26,
355,
340,
11430,
76,
14,
9438,
63,
23708,
315,
5236,
59,
337,
76,
14,
10614,
63,
4531,
2189,
490,
1834,
63,
8928,
275,
5236,
59,
337,
76,
14,
10614,
63,
4531,
1527,
337,
76,
14,
9438,
63,
23708,
2733,
8928,
418,
4951,
340,
1834,
63,
8928,
440,
315,
9040,
63,
513,
26,
717,
9040,
63,
513,
14,
740,
8,
1569,
63,
8928,
9,
398,
367,
682,
83,
315,
9040,
63,
513,
26,
288,
2341,
8,
2164,
63,
4060,
14,
1807,
63,
1569,
12,
2928,
63,
4060,
14,
362,
63,
4060,
63,
344,
63,
513,
63,
991,
63,
8928,
8,
32556,
430,
288,
2341,
8,
5119,
63,
4060,
14,
1807,
63,
1569,
12,
5042,
63,
4060,
14,
362,
63,
4060,
63,
344,
63,
513,
63,
991,
63,
8928,
8,
32556,
430,
398,
372,
1052,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
6927,
603,
723,
4466,
83,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
844,
2736,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
4319,
2281,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
3,
199,
3,
4204,
1334,
314,
844,
14,
421,
199,
646,
1331,
199,
199,
504,
8002,
2412,
651,
773,
14,
1095,
14,
1287,
492,
1595,
199,
504,
8002,
2412,
651,
773,
14,
1208,
492,
3778,
465,
11430,
76,
421,
199,
533,
30022,
18882,
8,
1287,
14,
3310,
304,
339,
347,
1255,
8,
277,
12,
2256,
12,
1011,
958,
304,
267,
2256,
275,
1331,
14,
8293,
8,
815,
9,
398,
2928,
63,
4060,
275,
291,
14,
2164,
63,
4091,
14,
4435,
59,
337,
76,
14,
9438,
63,
14110,
61,
267,
5042,
63,
4060,
275,
291,
14,
5119,
63,
4091,
14,
4435,
59,
337,
76,
14,
9438,
63,
14110,
61,
398,
9040,
63,
513,
275,
942,
398,
367,
1256,
315,
2256,
59,
337,
76,
14,
7834,
879,
16734,
63,
2711,
1055,
13012,
837,
288,
12158,
275,
1256,
59,
337,
76,
14,
10614,
63,
4531,
1055,
362,
8,
337,
76,
14,
16689,
63,
23708,
9,
953,
340,
440,
12158,
26,
355,
1980,
953,
367,
5236,
315,
12158,
26,
355,
340,
11430,
76,
14,
9438,
63,
23708,
315,
5236,
59,
337,
76,
14,
10614,
63,
4531,
2189,
490,
1834,
63,
8928,
275,
5236,
59,
337,
76,
14,
10614,
63,
4531,
1527,
337,
76,
14,
9438,
63,
23708,
2733,
8928,
418,
4951,
340,
1834,
63,
8928,
440,
315,
9040,
63,
513,
26,
717,
9040,
63,
513,
14,
740,
8,
1569,
63,
8928,
9,
398,
367,
682,
83,
315,
9040,
63,
513,
26,
288,
2341,
8,
2164,
63,
4060,
14,
1807,
63,
1569,
12,
2928,
63,
4060,
14,
362,
63,
4060,
63,
344,
63,
513,
63,
991,
63,
8928,
8,
32556,
430,
288,
2341,
8,
5119,
63,
4060,
14,
1807,
63,
1569,
12,
5042,
63,
4060,
14,
362,
63,
4060,
63,
344,
63,
513,
63,
991,
63,
8928,
8,
32556,
430,
398,
372,
1052,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
triskadecaepyon/pyworkout-toolkit
|
pyworkout/parsers/tcxtools.py
|
1
|
4560
|
"""
Tools to process TCX files,
specifically for parsing and
converting to other formats.
"""
import numpy as np
import pandas as pd
from lxml import objectify
import dateutil.parser
import logging
TPXNS = "{http://www.garmin.com/xmlschemas/ActivityExtension/v2}TPX"
LXNS = "{http://www.garmin.com/xmlschemas/ActivityExtension/v2}LX"
class TCXPandas(object):
"""
Class for Parsing .TCX files to Pandas DataFrames.
Parameters
----------
tcx_file : string, path object,
the path to the tcx file
"""
def __init__(self, tcx_file, **kwds):
self.__filehandle__ = tcx_file
self.tcx = None
self.activity = None
self.dataframe = None
logging.basicConfig(filename="TCXconversion.log", level=logging.DEBUG)
def parse(self):
"""
Parse specified TCX file into a DataFrame
Return a Dataframe and sets Dataframe and sets
the self.dataframe object in the TCXParser.
"""
self.tcx = objectify.parse(open(self.__filehandle__))
self.activity = self.tcx.getroot().Activities.Activity
self.dataframe = pd.DataFrame(self._traverse_laps_())
return self.dataframe
def get_activity_timestamp(self):
"""
Returns the TCX file timestamp if parsed
"""
if self.activity is None:
return None
else:
return self.activity.Id
def get_sport(self):
"""
Returns the specified sport of the TCX file
"""
if self.activity is None:
return None
else:
return self.activity.attrib['Sport']
def get_workout_startime(self):
"""
Returns the starting timestamp of the specified TCX file
"""
if self.activity is None:
return None
else:
return self.activity.Lap.items()[0][1]
def _traverse_laps_(self):
# New iterator method to align with lxml standard
return_array = []
for laps in self.activity.Lap:
for tracks in laps.Track:
for trackingpoints in tracks.Trackpoint:
return_dict = {}
return_dict['time'] = dateutil.parser.parse(str(trackingpoints.Time))
try:
return_dict['latitude'] = \
np.float(trackingpoints.Position.LatitudeDegrees)
except AttributeError:
pass #TODO log this
try:
return_dict['longitude'] = \
np.float(trackingpoints.Position.LongitudeDegrees)
except AttributeError:
pass #TODO log this
try:
return_dict['altitude'] = np.float(trackingpoints.AltitudeMeters)
except AttributeError:
pass #TODO log this
try:
return_dict['distance'] = np.float(trackingpoints.DistanceMeters)
except AttributeError:
pass #TODO log this
try:
return_dict['hr'] = np.float(trackingpoints.HeartRateBpm.Value)
except AttributeError:
pass #TODO log this
try:
return_dict['speed'] = \
np.float(trackingpoints.Extensions[TPXNS].Speed)
except AttributeError:
pass #TODO log this
if self.get_sport == 'Running':
try:
return_dict['cadence'] = \
np.float(trackingpoints.Extensions[TPXNS].RunCadence)
except AttributeError:
pass #TODO log this
else: # self.activity.attrib['Sport'] == 'Biking':
try:
return_dict['cadence'] = np.float(trackingpoints.Cadence)
except AttributeError:
pass #TODO log this
try:
return_dict['power'] = \
np.float(trackingpoints.Extensions[TPXNS].Watts)
except AttributeError:
pass #TODO log this
return_array.append(return_dict)
return return_array
|
bsd-3-clause
|
[
624,
199,
11654,
370,
2112,
377,
26001,
1584,
12,
199,
6100,
1183,
367,
6057,
436,
199,
6435,
1337,
370,
1163,
6752,
14,
199,
624,
199,
199,
646,
2680,
465,
980,
199,
646,
10634,
465,
6454,
199,
504,
14490,
492,
1559,
825,
3338,
199,
646,
22208,
14,
2087,
199,
646,
2050,
199,
199,
6495,
56,
2709,
275,
5310,
1014,
921,
1544,
14,
23909,
827,
14,
957,
15,
10198,
478,
8532,
15,
14350,
6382,
15,
86,
18,
93,
6495,
56,
2,
199,
44,
56,
2709,
275,
5310,
1014,
921,
1544,
14,
23909,
827,
14,
957,
15,
10198,
478,
8532,
15,
14350,
6382,
15,
86,
18,
93,
44,
56,
2,
421,
199,
533,
377,
35,
20168,
7683,
8,
785,
304,
272,
408,
272,
8089,
367,
28747,
1275,
5708,
56,
1584,
370,
510,
7683,
10071,
83,
14,
339,
3897,
272,
4143,
272,
307,
11859,
63,
493,
520,
1059,
12,
931,
909,
12,
2049,
314,
931,
370,
314,
307,
11859,
570,
339,
408,
339,
347,
636,
826,
721,
277,
12,
307,
11859,
63,
493,
12,
1011,
10340,
304,
267,
291,
855,
493,
2479,
363,
275,
307,
11859,
63,
493,
267,
291,
14,
3641,
88,
275,
488,
267,
291,
14,
8240,
275,
488,
267,
291,
14,
23878,
275,
488,
398,
2050,
14,
19602,
8,
1501,
628,
5708,
56,
15083,
14,
793,
401,
2166,
29,
4806,
14,
5287,
9,
339,
347,
2198,
8,
277,
304,
267,
408,
267,
6077,
2013,
377,
26001,
570,
1901,
282,
10071,
267,
1432,
282,
3918,
1943,
436,
5951,
3918,
1943,
436,
5951,
267,
314,
291,
14,
23878,
909,
315,
314,
377,
26001,
2842,
14,
267,
408,
398,
291,
14,
3641,
88,
275,
1559,
825,
3338,
14,
1122,
8,
1490,
8,
277,
855,
493,
2479,
8964,
267,
291,
14,
8240,
275,
291,
14,
3641,
88,
14,
24544,
1252,
1945,
15805,
14,
14350,
267,
291,
14,
23878,
275,
6454,
14,
9205,
8,
277,
423,
23650,
63,
13719,
63,
1012,
267,
372,
291,
14,
23878,
339,
347,
664,
63,
8240,
63,
3954,
8,
277,
304,
267,
408,
267,
1803,
314,
377,
26001,
570,
4913,
340,
4565,
267,
408,
267,
340,
291,
14,
8240,
365,
488,
26,
288,
372,
488,
267,
587,
26,
288,
372,
291,
14,
8240,
14,
1304,
339,
347,
664,
63,
3275,
8,
277,
304,
267,
408,
267,
1803,
314,
2013,
308,
719,
402,
314,
377,
26001,
570,
267,
408,
267,
340,
291,
14,
8240,
365,
488,
26,
288,
372,
488,
267,
587,
26,
288,
372,
291,
14,
8240,
14,
6640,
459,
51,
719,
418,
339,
347,
664,
63,
800,
548,
63,
7848,
521,
8,
277,
304,
267,
408,
267,
1803,
314,
6617,
4913,
402,
314,
2013,
377,
26001,
570,
267,
408,
267,
340,
291,
14,
8240,
365,
488,
26,
288,
372,
488,
267,
587,
26,
288,
372,
291,
14,
8240,
14,
44,
439,
14,
1744,
3430,
16,
1527,
17,
61,
339,
347,
485,
23650,
63,
13719,
2531,
277,
304,
398,
327,
7053,
6122,
1083,
370,
6998,
543,
14490,
4465,
267,
372,
63,
1144,
275,
942,
267,
367,
1127,
1190,
315,
291,
14,
8240,
14,
44,
439,
26,
288,
367,
18917,
315,
1127,
1190,
14,
7927,
26,
355,
367,
15161,
3438,
315,
18917,
14,
7927,
1403,
26,
490,
372,
63,
807,
275,
1052,
490,
372,
63,
807,
459,
521,
418,
275,
22208,
14,
2087,
14,
1122,
8,
495,
8,
14428,
3438,
14,
1366,
430,
4951,
862,
26,
717,
372,
63,
807,
459,
13331,
418,
275,
971,
1169,
980,
14,
1609,
8,
14428,
3438,
14,
5625,
14,
44,
31429,
3786,
26135,
5710,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
13803,
418,
275,
971,
1169,
980,
14,
1609,
8,
14428,
3438,
14,
5625,
14,
9551,
7779,
26135,
5710,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
27539,
418,
275,
980,
14,
1609,
8,
14428,
3438,
14,
2439,
7951,
1352,
878,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
5590,
418,
275,
980,
14,
1609,
8,
14428,
3438,
14,
10076,
1352,
878,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
6271,
418,
275,
980,
14,
1609,
8,
14428,
3438,
14,
1966,
580,
6621,
34,
7073,
14,
1110,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
7625,
418,
275,
971,
1169,
980,
14,
1609,
8,
14428,
3438,
14,
10597,
59,
6495,
56,
2709,
1055,
15146,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
340,
291,
14,
362,
63,
3275,
508,
283,
9602,
356,
717,
862,
26,
1169,
372,
63,
807,
459,
696,
5606,
418,
275,
971,
1816,
980,
14,
1609,
8,
14428,
3438,
14,
10597,
59,
6495,
56,
2709,
1055,
2540,
3630,
5606,
9,
717,
871,
4281,
26,
1169,
986,
327,
11768,
943,
642,
490,
587,
26,
327,
291,
14,
8240,
14,
6640,
459,
51,
719,
418,
508,
283,
34,
3258,
316,
356,
717,
862,
26,
1169,
372,
63,
807,
459,
696,
5606,
418,
275,
980,
14,
1609,
8,
14428,
3438,
14,
3630,
5606,
9,
717,
871,
4281,
26,
1169,
986,
327,
11768,
943,
642,
9453,
862,
26,
1169,
372,
63,
807,
459,
5652,
418,
275,
971,
1816,
980,
14,
1609,
8,
14428,
3438,
14,
10597,
59,
6495,
56,
2709,
1055,
55,
32369,
9,
717,
871,
4281,
26,
1169,
986,
327,
11768,
943,
642,
4951,
372,
63,
1144,
14,
740,
8,
1107,
63,
807,
9,
355,
372,
372,
63,
1144,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
11654,
370,
2112,
377,
26001,
1584,
12,
199,
6100,
1183,
367,
6057,
436,
199,
6435,
1337,
370,
1163,
6752,
14,
199,
624,
199,
199,
646,
2680,
465,
980,
199,
646,
10634,
465,
6454,
199,
504,
14490,
492,
1559,
825,
3338,
199,
646,
22208,
14,
2087,
199,
646,
2050,
199,
199,
6495,
56,
2709,
275,
5310,
1014,
921,
1544,
14,
23909,
827,
14,
957,
15,
10198,
478,
8532,
15,
14350,
6382,
15,
86,
18,
93,
6495,
56,
2,
199,
44,
56,
2709,
275,
5310,
1014,
921,
1544,
14,
23909,
827,
14,
957,
15,
10198,
478,
8532,
15,
14350,
6382,
15,
86,
18,
93,
44,
56,
2,
421,
199,
533,
377,
35,
20168,
7683,
8,
785,
304,
272,
408,
272,
8089,
367,
28747,
1275,
5708,
56,
1584,
370,
510,
7683,
10071,
83,
14,
339,
3897,
272,
4143,
272,
307,
11859,
63,
493,
520,
1059,
12,
931,
909,
12,
2049,
314,
931,
370,
314,
307,
11859,
570,
339,
408,
339,
347,
636,
826,
721,
277,
12,
307,
11859,
63,
493,
12,
1011,
10340,
304,
267,
291,
855,
493,
2479,
363,
275,
307,
11859,
63,
493,
267,
291,
14,
3641,
88,
275,
488,
267,
291,
14,
8240,
275,
488,
267,
291,
14,
23878,
275,
488,
398,
2050,
14,
19602,
8,
1501,
628,
5708,
56,
15083,
14,
793,
401,
2166,
29,
4806,
14,
5287,
9,
339,
347,
2198,
8,
277,
304,
267,
408,
267,
6077,
2013,
377,
26001,
570,
1901,
282,
10071,
267,
1432,
282,
3918,
1943,
436,
5951,
3918,
1943,
436,
5951,
267,
314,
291,
14,
23878,
909,
315,
314,
377,
26001,
2842,
14,
267,
408,
398,
291,
14,
3641,
88,
275,
1559,
825,
3338,
14,
1122,
8,
1490,
8,
277,
855,
493,
2479,
8964,
267,
291,
14,
8240,
275,
291,
14,
3641,
88,
14,
24544,
1252,
1945,
15805,
14,
14350,
267,
291,
14,
23878,
275,
6454,
14,
9205,
8,
277,
423,
23650,
63,
13719,
63,
1012,
267,
372,
291,
14,
23878,
339,
347,
664,
63,
8240,
63,
3954,
8,
277,
304,
267,
408,
267,
1803,
314,
377,
26001,
570,
4913,
340,
4565,
267,
408,
267,
340,
291,
14,
8240,
365,
488,
26,
288,
372,
488,
267,
587,
26,
288,
372,
291,
14,
8240,
14,
1304,
339,
347,
664,
63,
3275,
8,
277,
304,
267,
408,
267,
1803,
314,
2013,
308,
719,
402,
314,
377,
26001,
570,
267,
408,
267,
340,
291,
14,
8240,
365,
488,
26,
288,
372,
488,
267,
587,
26,
288,
372,
291,
14,
8240,
14,
6640,
459,
51,
719,
418,
339,
347,
664,
63,
800,
548,
63,
7848,
521,
8,
277,
304,
267,
408,
267,
1803,
314,
6617,
4913,
402,
314,
2013,
377,
26001,
570,
267,
408,
267,
340,
291,
14,
8240,
365,
488,
26,
288,
372,
488,
267,
587,
26,
288,
372,
291,
14,
8240,
14,
44,
439,
14,
1744,
3430,
16,
1527,
17,
61,
339,
347,
485,
23650,
63,
13719,
2531,
277,
304,
398,
327,
7053,
6122,
1083,
370,
6998,
543,
14490,
4465,
267,
372,
63,
1144,
275,
942,
267,
367,
1127,
1190,
315,
291,
14,
8240,
14,
44,
439,
26,
288,
367,
18917,
315,
1127,
1190,
14,
7927,
26,
355,
367,
15161,
3438,
315,
18917,
14,
7927,
1403,
26,
490,
372,
63,
807,
275,
1052,
490,
372,
63,
807,
459,
521,
418,
275,
22208,
14,
2087,
14,
1122,
8,
495,
8,
14428,
3438,
14,
1366,
430,
4951,
862,
26,
717,
372,
63,
807,
459,
13331,
418,
275,
971,
1169,
980,
14,
1609,
8,
14428,
3438,
14,
5625,
14,
44,
31429,
3786,
26135,
5710,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
13803,
418,
275,
971,
1169,
980,
14,
1609,
8,
14428,
3438,
14,
5625,
14,
9551,
7779,
26135,
5710,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
27539,
418,
275,
980,
14,
1609,
8,
14428,
3438,
14,
2439,
7951,
1352,
878,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
5590,
418,
275,
980,
14,
1609,
8,
14428,
3438,
14,
10076,
1352,
878,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
6271,
418,
275,
980,
14,
1609,
8,
14428,
3438,
14,
1966,
580,
6621,
34,
7073,
14,
1110,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
862,
26,
717,
372,
63,
807,
459,
7625,
418,
275,
971,
1169,
980,
14,
1609,
8,
14428,
3438,
14,
10597,
59,
6495,
56,
2709,
1055,
15146,
9,
490,
871,
4281,
26,
717,
986,
327,
11768,
943,
642,
4951,
340,
291,
14,
362,
63,
3275,
508,
283,
9602,
356,
717,
862,
26,
1169,
372,
63,
807,
459,
696,
5606,
418,
275,
971,
1816,
980,
14,
1609,
8,
14428,
3438,
14,
10597,
59,
6495,
56,
2709,
1055,
2540,
3630,
5606,
9,
717,
871,
4281,
26,
1169,
986,
327,
11768,
943,
642,
490,
587,
26,
327,
291,
14,
8240,
14,
6640,
459,
51,
719,
418,
508,
283,
34,
3258,
316,
356,
717,
862,
26,
1169,
372,
63,
807,
459,
696,
5606,
418,
275,
980,
14,
1609,
8,
14428,
3438,
14,
3630,
5606,
9,
717,
871,
4281,
26,
1169,
986,
327,
11768,
943,
642,
9453,
862,
26,
1169,
372,
63,
807,
459,
5652,
418,
275,
971,
1816,
980,
14,
1609,
8,
14428,
3438,
14,
10597,
59,
6495,
56,
2709,
1055,
55,
32369,
9,
717,
871,
4281,
26,
1169,
986,
327,
11768,
943,
642,
4951,
372,
63,
1144,
14,
740,
8,
1107,
63,
807,
9,
355,
372,
372,
63,
1144,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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dbg/dbg_template_bounding_boxes_qsrs.py
|
8
|
2711
|
#!/usr/bin/python
# import numpy as np
from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle
class Dbg(object):
def __init__(self):
pass
def return_bounding_box_2d(self, x, y, xsize, ysize):
"""Return the bounding box
:param x: x center
:param y: y center
:param xsize: x size
:param ysize: y size
:return: list(x1, y1, x2, y2) where (x1, y1) and (x2, y2) are the coordinates of the diagonal points of the
bounding box depending on your coordinates frame
"""
if xsize <= 0 or ysize <= 0:
print("ERROR: can't compute bounding box, xsize or height has no positive value")
return []
return [x-xsize/2, y-ysize/2, x+xsize/2, y+ysize/2]
def compute_qsr(self, bb1, bb2):
"""Wrapper for __compute_qsr
:param bb1: diagonal points coordinates of first bounding box (x1, y1, x2, y2)
:param bb2: diagonal points coordinates of second bounding box (x1, y1, x2, y2)
:return: an RCC depending on your implementation
"""
return self.__compute_qsr(bb1, bb2)
def __compute_qsr(self, bb1, bb2):
"""Replace with your own
:param bb1: diagonal points coordinates of first bounding box (x1, y1, x2, y2)
:param bb2: diagonal points coordinates of second bounding box (x1, y1, x2, y2) :return: an RCC depending on your implementation
:return: an RCC depending on your implementation
"""
raise NotImplementedError("Replace with your code")
def plot_bbs(bb1, bb2):
plt.figure()
ax = plt.gca()
# ax.invert_yaxis()
ax.add_patch(Rectangle((bb1[0], bb1[1]), bb1[2]-bb1[0], bb1[3]-bb1[1], alpha=1, facecolor="blue"))
ax.annotate("o1", (bb1[0], bb1[1]), color='black', weight='bold', fontsize=14)
ax.add_patch(Rectangle((bb2[0], bb2[1]), bb2[2]-bb2[0], bb2[3]-bb2[1], alpha=1, facecolor="red"))
ax.annotate("o2", (bb2[0], bb2[1]), color='black', weight='bold', fontsize=14)
h = 6
l = 0
# ax.set_xlim(l, h)
# ax.set_ylim(l, h)
ax.set_xlim(l, h)
ax.set_ylim(h, l)
plt.show()
if __name__ == '__main__':
dbg = Dbg()
# Play with these to test (x_center, y_center, xsize(i.e. x-size), ysize(i.e. y-size))
o1 = (2.0, 2.0, 2., 2.)
o2 = (4.0, 3.0, 1., 1.)
o1 = dbg.return_bounding_box_2d(o1[0], o1[1], o1[2], o1[3])
o2 = dbg.return_bounding_box_2d(o2[0], o2[1], o2[2], o2[3])
# Bounding boxes
# print("o1:", o1)
# print("o2:", o2)
# Relations
print("o1o2:", dbg.compute_qsr(o1, o2))
print("o2o1:", dbg.compute_qsr(o2, o1))
# Plot the boxes
plot_bbs(o1, o2)
|
mit
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
3,
492,
2680,
465,
980,
199,
504,
8027,
492,
1134,
2798,
465,
4488,
199,
504,
8027,
14,
11350,
492,
21536,
4593,
199,
199,
533,
577,
6856,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
986,
339,
347,
372,
63,
24511,
63,
1977,
63,
18,
68,
8,
277,
12,
671,
12,
612,
12,
671,
890,
12,
612,
890,
304,
267,
408,
1767,
314,
16842,
5689,
398,
520,
635,
671,
26,
671,
8126,
267,
520,
635,
612,
26,
612,
8126,
267,
520,
635,
671,
890,
26,
671,
1568,
267,
520,
635,
612,
890,
26,
612,
1568,
267,
520,
1107,
26,
769,
8,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
2382,
334,
88,
17,
12,
612,
17,
9,
436,
334,
88,
18,
12,
612,
18,
9,
787,
314,
8983,
402,
314,
16788,
4501,
402,
314,
355,
16842,
5689,
10298,
641,
2195,
8983,
2787,
267,
408,
398,
340,
671,
890,
2695,
378,
503,
612,
890,
2695,
378,
26,
288,
870,
480,
3170,
26,
883,
1133,
4526,
16842,
5689,
12,
671,
890,
503,
4569,
965,
949,
7317,
574,
531,
288,
372,
942,
267,
372,
359,
88,
13,
88,
890,
15,
18,
12,
612,
13,
89,
890,
15,
18,
12,
671,
11,
88,
890,
15,
18,
12,
612,
11,
89,
890,
15,
18,
61,
2378,
347,
4526,
63,
81,
5474,
8,
277,
12,
14027,
17,
12,
14027,
18,
304,
267,
408,
4590,
367,
636,
3357,
63,
81,
5474,
398,
520,
635,
14027,
17,
26,
16788,
4501,
8983,
402,
1642,
16842,
5689,
334,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
267,
520,
635,
14027,
18,
26,
16788,
4501,
8983,
402,
3499,
16842,
5689,
334,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
267,
520,
1107,
26,
376,
820,
2571,
10298,
641,
2195,
4514,
267,
408,
267,
372,
291,
855,
3357,
63,
81,
5474,
8,
2501,
17,
12,
14027,
18,
9,
339,
347,
636,
3357,
63,
81,
5474,
8,
277,
12,
14027,
17,
12,
14027,
18,
304,
267,
408,
11328,
543,
2195,
5705,
398,
520,
635,
14027,
17,
26,
16788,
4501,
8983,
402,
1642,
16842,
5689,
334,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
267,
520,
635,
14027,
18,
26,
16788,
4501,
8983,
402,
3499,
16842,
5689,
334,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
263,
520,
1107,
26,
376,
820,
2571,
10298,
641,
2195,
4514,
267,
520,
1107,
26,
376,
820,
2571,
10298,
641,
2195,
4514,
267,
408,
267,
746,
4279,
480,
11328,
543,
2195,
1233,
531,
4388,
199,
318,
5137,
63,
66,
1533,
8,
2501,
17,
12,
14027,
18,
304,
272,
4488,
14,
8941,
342,
272,
2185,
275,
4488,
14,
71,
696,
342,
272,
327,
2185,
14,
18957,
63,
23876,
342,
272,
2185,
14,
525,
63,
2068,
8,
18127,
1332,
2501,
17,
59,
16,
467,
14027,
17,
59,
17,
2522,
14027,
17,
59,
18,
11285,
2501,
17,
59,
16,
467,
14027,
17,
59,
19,
11285,
2501,
17,
59,
17,
467,
5131,
29,
17,
12,
8870,
2326,
628,
6304,
2237,
272,
2185,
14,
10898,
480,
79,
17,
401,
334,
2501,
17,
59,
16,
467,
14027,
17,
59,
17,
2522,
3164,
534,
8399,
297,
5401,
534,
9771,
297,
19740,
29,
1079,
9,
272,
2185,
14,
525,
63,
2068,
8,
18127,
1332,
2501,
18,
59,
16,
467,
14027,
18,
59,
17,
2522,
14027,
18,
59,
18,
11285,
2501,
18,
59,
16,
467,
14027,
18,
59,
19,
11285,
2501,
18,
59,
17,
467,
5131,
29,
17,
12,
8870,
2326,
628,
581,
2237,
272,
2185,
14,
10898,
480,
79,
18,
401,
334,
2501,
18,
59,
16,
467,
14027,
18,
59,
17,
2522,
3164,
534,
8399,
297,
5401,
534,
9771,
297,
19740,
29,
1079,
9,
272,
394,
275,
1227,
272,
634,
275,
378,
272,
327,
2185,
14,
409,
63,
18512,
8,
76,
12,
394,
9,
272,
327,
2185,
14,
409,
63,
18123,
8,
76,
12,
394,
9,
272,
2185,
14,
409,
63,
18512,
8,
76,
12,
394,
9,
272,
2185,
14,
409,
63,
18123,
8,
72,
12,
634,
9,
272,
4488,
14,
2384,
342,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
24465,
275,
577,
6856,
342,
339,
327,
16527,
543,
3520,
370,
511,
334,
88,
63,
4218,
12,
612,
63,
4218,
12,
671,
890,
8,
73,
14,
69,
14,
671,
13,
890,
395,
612,
890,
8,
73,
14,
69,
14,
612,
13,
890,
430,
272,
312,
17,
275,
334,
18,
14,
16,
12,
499,
14,
16,
12,
499,
2020,
499,
4959,
272,
312,
18,
275,
334,
20,
14,
16,
12,
650,
14,
16,
12,
413,
2020,
413,
4959,
339,
312,
17,
275,
24465,
14,
1107,
63,
24511,
63,
1977,
63,
18,
68,
8,
79,
17,
59,
16,
467,
312,
17,
59,
17,
467,
312,
17,
59,
18,
467,
312,
17,
59,
19,
566,
272,
312,
18,
275,
24465,
14,
1107,
63,
24511,
63,
1977,
63,
18,
68,
8,
79,
18,
59,
16,
467,
312,
18,
59,
17,
467,
312,
18,
59,
18,
467,
312,
18,
59,
19,
566,
339,
327,
21972,
316,
17193,
272,
327,
870,
480,
79,
17,
6783,
312,
17,
9,
272,
327,
870,
480,
79,
18,
6783,
312,
18,
9,
339,
327,
9781,
1298,
272,
870,
480,
79,
17,
79,
18,
6783,
24465,
14,
3357,
63,
81,
5474,
8,
79,
17,
12,
312,
18,
430,
272,
870,
480,
79,
18,
79,
17,
6783,
24465,
14,
3357,
63,
81,
5474,
8,
79,
18,
12,
312,
17,
430,
339,
327,
14794,
314,
17193,
272,
5137,
63,
66,
1533,
8,
79,
17,
12,
312,
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
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
3,
492,
2680,
465,
980,
199,
504,
8027,
492,
1134,
2798,
465,
4488,
199,
504,
8027,
14,
11350,
492,
21536,
4593,
199,
199,
533,
577,
6856,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
986,
339,
347,
372,
63,
24511,
63,
1977,
63,
18,
68,
8,
277,
12,
671,
12,
612,
12,
671,
890,
12,
612,
890,
304,
267,
408,
1767,
314,
16842,
5689,
398,
520,
635,
671,
26,
671,
8126,
267,
520,
635,
612,
26,
612,
8126,
267,
520,
635,
671,
890,
26,
671,
1568,
267,
520,
635,
612,
890,
26,
612,
1568,
267,
520,
1107,
26,
769,
8,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
2382,
334,
88,
17,
12,
612,
17,
9,
436,
334,
88,
18,
12,
612,
18,
9,
787,
314,
8983,
402,
314,
16788,
4501,
402,
314,
355,
16842,
5689,
10298,
641,
2195,
8983,
2787,
267,
408,
398,
340,
671,
890,
2695,
378,
503,
612,
890,
2695,
378,
26,
288,
870,
480,
3170,
26,
883,
1133,
4526,
16842,
5689,
12,
671,
890,
503,
4569,
965,
949,
7317,
574,
531,
288,
372,
942,
267,
372,
359,
88,
13,
88,
890,
15,
18,
12,
612,
13,
89,
890,
15,
18,
12,
671,
11,
88,
890,
15,
18,
12,
612,
11,
89,
890,
15,
18,
61,
2378,
347,
4526,
63,
81,
5474,
8,
277,
12,
14027,
17,
12,
14027,
18,
304,
267,
408,
4590,
367,
636,
3357,
63,
81,
5474,
398,
520,
635,
14027,
17,
26,
16788,
4501,
8983,
402,
1642,
16842,
5689,
334,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
267,
520,
635,
14027,
18,
26,
16788,
4501,
8983,
402,
3499,
16842,
5689,
334,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
267,
520,
1107,
26,
376,
820,
2571,
10298,
641,
2195,
4514,
267,
408,
267,
372,
291,
855,
3357,
63,
81,
5474,
8,
2501,
17,
12,
14027,
18,
9,
339,
347,
636,
3357,
63,
81,
5474,
8,
277,
12,
14027,
17,
12,
14027,
18,
304,
267,
408,
11328,
543,
2195,
5705,
398,
520,
635,
14027,
17,
26,
16788,
4501,
8983,
402,
1642,
16842,
5689,
334,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
267,
520,
635,
14027,
18,
26,
16788,
4501,
8983,
402,
3499,
16842,
5689,
334,
88,
17,
12,
612,
17,
12,
671,
18,
12,
612,
18,
9,
263,
520,
1107,
26,
376,
820,
2571,
10298,
641,
2195,
4514,
267,
520,
1107,
26,
376,
820,
2571,
10298,
641,
2195,
4514,
267,
408,
267,
746,
4279,
480,
11328,
543,
2195,
1233,
531,
4388,
199,
318,
5137,
63,
66,
1533,
8,
2501,
17,
12,
14027,
18,
304,
272,
4488,
14,
8941,
342,
272,
2185,
275,
4488,
14,
71,
696,
342,
272,
327,
2185,
14,
18957,
63,
23876,
342,
272,
2185,
14,
525,
63,
2068,
8,
18127,
1332,
2501,
17,
59,
16,
467,
14027,
17,
59,
17,
2522,
14027,
17,
59,
18,
11285,
2501,
17,
59,
16,
467,
14027,
17,
59,
19,
11285,
2501,
17,
59,
17,
467,
5131,
29,
17,
12,
8870,
2326,
628,
6304,
2237,
272,
2185,
14,
10898,
480,
79,
17,
401,
334,
2501,
17,
59,
16,
467,
14027,
17,
59,
17,
2522,
3164,
534,
8399,
297,
5401,
534,
9771,
297,
19740,
29,
1079,
9,
272,
2185,
14,
525,
63,
2068,
8,
18127,
1332,
2501,
18,
59,
16,
467,
14027,
18,
59,
17,
2522,
14027,
18,
59,
18,
11285,
2501,
18,
59,
16,
467,
14027,
18,
59,
19,
11285,
2501,
18,
59,
17,
467,
5131,
29,
17,
12,
8870,
2326,
628,
581,
2237,
272,
2185,
14,
10898,
480,
79,
18,
401,
334,
2501,
18,
59,
16,
467,
14027,
18,
59,
17,
2522,
3164,
534,
8399,
297,
5401,
534,
9771,
297,
19740,
29,
1079,
9,
272,
394,
275,
1227,
272,
634,
275,
378,
272,
327,
2185,
14,
409,
63,
18512,
8,
76,
12,
394,
9,
272,
327,
2185,
14,
409,
63,
18123,
8,
76,
12,
394,
9,
272,
2185,
14,
409,
63,
18512,
8,
76,
12,
394,
9,
272,
2185,
14,
409,
63,
18123,
8,
72,
12,
634,
9,
272,
4488,
14,
2384,
342,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
24465,
275,
577,
6856,
342,
339,
327,
16527,
543,
3520,
370,
511,
334,
88,
63,
4218,
12,
612,
63,
4218,
12,
671,
890,
8,
73,
14,
69,
14,
671,
13,
890,
395,
612,
890,
8,
73,
14,
69,
14,
612,
13,
890,
430,
272,
312,
17,
275,
334,
18,
14,
16,
12,
499,
14,
16,
12,
499,
2020,
499,
4959,
272,
312,
18,
275,
334,
20,
14,
16,
12,
650,
14,
16,
12,
413,
2020,
413,
4959,
339,
312,
17,
275,
24465,
14,
1107,
63,
24511,
63,
1977,
63,
18,
68,
8,
79,
17,
59,
16,
467,
312,
17,
59,
17,
467,
312,
17,
59,
18,
467,
312,
17,
59,
19,
566,
272,
312,
18,
275,
24465,
14,
1107,
63,
24511,
63,
1977,
63,
18,
68,
8,
79,
18,
59,
16,
467,
312,
18,
59,
17,
467,
312,
18,
59,
18,
467,
312,
18,
59,
19,
566,
339,
327,
21972,
316,
17193,
272,
327,
870,
480,
79,
17,
6783,
312,
17,
9,
272,
327,
870,
480,
79,
18,
6783,
312,
18,
9,
339,
327,
9781,
1298,
272,
870,
480,
79,
17,
79,
18,
6783,
24465,
14,
3357,
63,
81,
5474,
8,
79,
17,
12,
312,
18,
430,
272,
870,
480,
79,
18,
79,
17,
6783,
24465,
14,
3357,
63,
81,
5474,
8,
79,
18,
12,
312,
17,
430,
339,
327,
14794,
314,
17193,
272,
5137,
63,
66,
1533,
8,
79,
17,
12,
312,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
scs/uclinux
|
lib/libxml2/libxml2-2.7.3/python/tests/error.py
|
87
|
1055
|
#!/usr/bin/python -u
#
# This test exercise the redirection of error messages with a
# functions defined in Python.
#
import sys
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
expect='--> I/O --> warning : --> failed to load external entity "missing.xml"\n'
err=""
def callback(ctx, str):
global err
err = err + "%s %s" % (ctx, str)
got_exc = 0
libxml2.registerErrorHandler(callback, "-->")
try:
doc = libxml2.parseFile("missing.xml")
except libxml2.parserError:
got_exc = 1
if got_exc == 0:
print "Failed to get a parser exception"
sys.exit(1)
if err != expect:
print "error"
print "received %s" %(err)
print "expected %s" %(expect)
sys.exit(1)
i = 10000
while i > 0:
try:
doc = libxml2.parseFile("missing.xml")
except libxml2.parserError:
got_exc = 1
err = ""
i = i - 1
# Memory debug specific
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
446,
85,
199,
3,
199,
3,
961,
511,
26511,
314,
23713,
402,
1125,
3788,
543,
282,
199,
3,
3423,
3247,
315,
2018,
14,
199,
3,
199,
646,
984,
199,
646,
15404,
18,
199,
199,
3,
15825,
3105,
2488,
199,
773,
1652,
18,
14,
1757,
8628,
8,
17,
9,
199,
199,
4921,
23791,
30,
473,
15,
47,
10541,
5721,
520,
10541,
3405,
370,
2248,
5957,
4642,
298,
4752,
14,
1652,
3212,
78,
7,
199,
1508,
9287,
199,
318,
3233,
8,
3799,
12,
620,
304,
1362,
2288,
2329,
10813,
2329,
275,
2329,
435,
2071,
83,
450,
83,
2,
450,
334,
3799,
12,
620,
9,
199,
199,
7808,
63,
2804,
275,
378,
199,
773,
1652,
18,
14,
2683,
25933,
8,
3058,
12,
4320,
9579,
199,
893,
26,
272,
1382,
275,
15404,
18,
14,
1122,
1173,
480,
4752,
14,
1652,
531,
199,
2590,
15404,
18,
14,
2087,
547,
26,
272,
4788,
63,
2804,
275,
413,
199,
199,
692,
4788,
63,
2804,
508,
378,
26,
272,
870,
298,
4276,
370,
664,
282,
1798,
1919,
2,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
692,
2329,
1137,
4282,
26,
272,
870,
298,
705,
2,
272,
870,
298,
9226,
450,
83,
2,
2818,
1508,
9,
272,
870,
298,
2062,
450,
83,
2,
2818,
4921,
9,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
73,
275,
11630,
199,
6710,
284,
690,
378,
26,
272,
862,
26,
267,
1382,
275,
15404,
18,
14,
1122,
1173,
480,
4752,
14,
1652,
531,
272,
871,
15404,
18,
14,
2087,
547,
26,
267,
4788,
63,
2804,
275,
413,
272,
2329,
275,
3087,
272,
284,
275,
284,
446,
413,
199,
199,
3,
15825,
3105,
2488,
199,
773,
1652,
18,
14,
7661,
2842,
342,
199,
692,
15404,
18,
14,
1757,
8628,
8,
17,
9,
508,
378,
26,
272,
870,
298,
3593,
2,
199,
2836,
26,
272,
870,
298,
8628,
25831,
450,
68,
2783,
2,
450,
334,
773,
1652,
18,
14,
1757,
8628,
8,
17,
430,
272,
15404,
18,
14,
2724,
8628,
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
] |
[
2647,
15,
1393,
15,
1548,
446,
85,
199,
3,
199,
3,
961,
511,
26511,
314,
23713,
402,
1125,
3788,
543,
282,
199,
3,
3423,
3247,
315,
2018,
14,
199,
3,
199,
646,
984,
199,
646,
15404,
18,
199,
199,
3,
15825,
3105,
2488,
199,
773,
1652,
18,
14,
1757,
8628,
8,
17,
9,
199,
199,
4921,
23791,
30,
473,
15,
47,
10541,
5721,
520,
10541,
3405,
370,
2248,
5957,
4642,
298,
4752,
14,
1652,
3212,
78,
7,
199,
1508,
9287,
199,
318,
3233,
8,
3799,
12,
620,
304,
1362,
2288,
2329,
10813,
2329,
275,
2329,
435,
2071,
83,
450,
83,
2,
450,
334,
3799,
12,
620,
9,
199,
199,
7808,
63,
2804,
275,
378,
199,
773,
1652,
18,
14,
2683,
25933,
8,
3058,
12,
4320,
9579,
199,
893,
26,
272,
1382,
275,
15404,
18,
14,
1122,
1173,
480,
4752,
14,
1652,
531,
199,
2590,
15404,
18,
14,
2087,
547,
26,
272,
4788,
63,
2804,
275,
413,
199,
199,
692,
4788,
63,
2804,
508,
378,
26,
272,
870,
298,
4276,
370,
664,
282,
1798,
1919,
2,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
692,
2329,
1137,
4282,
26,
272,
870,
298,
705,
2,
272,
870,
298,
9226,
450,
83,
2,
2818,
1508,
9,
272,
870,
298,
2062,
450,
83,
2,
2818,
4921,
9,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
73,
275,
11630,
199,
6710,
284,
690,
378,
26,
272,
862,
26,
267,
1382,
275,
15404,
18,
14,
1122,
1173,
480,
4752,
14,
1652,
531,
272,
871,
15404,
18,
14,
2087,
547,
26,
267,
4788,
63,
2804,
275,
413,
272,
2329,
275,
3087,
272,
284,
275,
284,
446,
413,
199,
199,
3,
15825,
3105,
2488,
199,
773,
1652,
18,
14,
7661,
2842,
342,
199,
692,
15404,
18,
14,
1757,
8628,
8,
17,
9,
508,
378,
26,
272,
870,
298,
3593,
2,
199,
2836,
26,
272,
870,
298,
8628,
25831,
450,
68,
2783,
2,
450,
334,
773,
1652,
18,
14,
1757,
8628,
8,
17,
430,
272,
15404,
18,
14,
2724,
8628,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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f-8
##########################################################################
from test import CollectorTestCase
from test import get_collector_config
from test import unittest
from mock import Mock
from mock import patch
from diamond.collector import Collector
from unbound import UnboundCollector
##########################################################################
class TestUnboundCollector(CollectorTestCase):
def setUp(self):
config = get_collector_config('UnboundCollector', {})
self.collector = UnboundCollector(config, None)
def test_import(self):
self.assertTrue(UnboundCollector)
@patch.object(Collector, 'publish')
def test_should_work_wtih_real_data(self, publish_mock):
fixture_data = self.getFixture('unbound_stats').getvalue()
collector_mock = patch.object(UnboundCollector,
'run_command',
Mock(return_value=[fixture_data, '']))
collector_mock.start()
self.collector.collect()
collector_mock.stop()
metrics = {
'thread0.num.queries': 10028,
'thread0.num.cachehits': 10021,
'thread0.num.cachemiss': 7,
'thread0.num.prefetch': 1,
'thread0.num.recursivereplies': 9,
'thread0.requestlist.avg': 1.25,
'thread0.requestlist.max': 2,
'thread0.requestlist.overwritten': 0,
'thread0.requestlist.exceeded': 0,
'thread0.requestlist.current.all': 1,
'thread0.requestlist.current.user': 1,
'thread0.recursion.time.avg': 9.914812,
'thread0.recursion.time.median': 0.08192,
'total.num.queries': 125609,
'total.num.cachehits': 125483,
'total.num.cachemiss': 126,
'total.num.prefetch': 16,
'total.num.recursivereplies': 136,
'total.requestlist.avg': 5.07746,
'total.requestlist.max': 10,
'total.requestlist.overwritten': 0,
'total.requestlist.exceeded': 0,
'total.requestlist.current.all': 23,
'total.requestlist.current.user': 23,
'total.recursion.time.avg': 13.045485,
'total.recursion.time.median': 0.06016,
'time.now': 1361926066.384873,
'time.up': 3006293.632453,
'time.elapsed': 9.981882,
'mem.total.sbrk': 26767360,
'mem.cache.rrset': 142606276,
'mem.cache.message': 71303005,
'mem.mod.iterator': 16532,
'mem.mod.validator': 1114579,
'num.query.type.A': 25596,
'num.query.type.PTR': 39,
'num.query.type.MX': 91,
'num.query.type.AAAA': 99883,
'num.query.class.IN': 125609,
'num.query.opcode.QUERY': 125609,
'num.query.tcp': 0,
'num.query.ipv6': 0,
'num.query.flags.QR': 0,
'num.query.flags.AA': 0,
'num.query.flags.TC': 0,
'num.query.flags.RD': 125609,
'num.query.flags.RA': 0,
'num.query.flags.Z': 0,
'num.query.flags.AD': 0,
'num.query.flags.CD': 62,
'num.query.edns.present': 62,
'num.query.edns.DO': 62,
'num.answer.rcode.NOERROR': 46989,
'num.answer.rcode.SERVFAIL': 55,
'num.answer.rcode.NXDOMAIN': 78575,
'num.answer.rcode.nodata': 20566,
'num.answer.secure': 0,
'num.answer.bogus': 0,
'num.rrset.bogus': 0,
'unwanted.queries': 0,
'unwanted.replies': 0,
'histogram.16s+': 0.0,
'histogram.256ms+': 3.0,
'histogram.4s+': 1.0,
'histogram.2s+': 0.0,
'histogram.1s+': 0.0,
'histogram.2ms+': 0.0,
'histogram.1ms': 39.0,
'histogram.32ms+': 18.0,
'histogram.4ms+': 0.0,
'histogram.16ms+': 10.0,
'histogram.1ms+': 5.0,
'histogram.32s+': 3.0,
'histogram.512ms+': 6.0,
'histogram.128ms+': 19.0,
'histogram.64ms+': 20.0,
'histogram.8ms+': 3.0,
'histogram.64s+': 9.0,
'histogram.8s+': 0.0,
}
self.setDocExample(collector=self.collector.__class__.__name__,
metrics=metrics,
defaultpath=self.collector.config['path'])
self.assertPublishedMany(publish_mock, metrics)
@patch.object(Collector, 'publish')
def test_should_fail_gracefully(self, publish_mock):
collector_mock = patch.object(UnboundCollector,
'run_command',
Mock(return_value=None))
collector_mock.start()
self.collector.collect()
collector_mock.stop()
self.assertPublishedMany(publish_mock, {})
@patch.object(Collector, 'publish')
def test_exclude_histogram(self, publish_mock):
self.collector.config['histogram'] = False
fixture_data = self.getFixture('unbound_stats').getvalue()
collector_mock = patch.object(UnboundCollector,
'run_command',
Mock(return_value=[fixture_data, '']))
collector_mock.start()
self.collector.collect()
collector_mock.stop()
metrics = {
'thread0.num.queries': 10028,
'thread0.num.cachehits': 10021,
'thread0.num.cachemiss': 7,
'thread0.num.prefetch': 1,
'thread0.num.recursivereplies': 9,
'thread0.requestlist.avg': 1.25,
'thread0.requestlist.max': 2,
'thread0.requestlist.overwritten': 0,
'thread0.requestlist.exceeded': 0,
'thread0.requestlist.current.all': 1,
'thread0.requestlist.current.user': 1,
'thread0.recursion.time.avg': 9.914812,
'thread0.recursion.time.median': 0.08192,
'total.num.queries': 125609,
'total.num.cachehits': 125483,
'total.num.cachemiss': 126,
'total.num.prefetch': 16,
'total.num.recursivereplies': 136,
'total.requestlist.avg': 5.07746,
'total.requestlist.max': 10,
'total.requestlist.overwritten': 0,
'total.requestlist.exceeded': 0,
'total.requestlist.current.all': 23,
'total.requestlist.current.user': 23,
'total.recursion.time.avg': 13.045485,
'total.recursion.time.median': 0.06016,
'time.now': 1361926066.384873,
'time.up': 3006293.632453,
'time.elapsed': 9.981882,
'mem.total.sbrk': 26767360,
'mem.cache.rrset': 142606276,
'mem.cache.message': 71303005,
'mem.mod.iterator': 16532,
'mem.mod.validator': 1114579,
'num.query.type.A': 25596,
'num.query.type.PTR': 39,
'num.query.type.MX': 91,
'num.query.type.AAAA': 99883,
'num.query.class.IN': 125609,
'num.query.opcode.QUERY': 125609,
'num.query.tcp': 0,
'num.query.ipv6': 0,
'num.query.flags.QR': 0,
'num.query.flags.AA': 0,
'num.query.flags.TC': 0,
'num.query.flags.RD': 125609,
'num.query.flags.RA': 0,
'num.query.flags.Z': 0,
'num.query.flags.AD': 0,
'num.query.flags.CD': 62,
'num.query.edns.present': 62,
'num.query.edns.DO': 62,
'num.answer.rcode.NOERROR': 46989,
'num.answer.rcode.SERVFAIL': 55,
'num.answer.rcode.NXDOMAIN': 78575,
'num.answer.rcode.nodata': 20566,
'num.answer.secure': 0,
'num.answer.bogus': 0,
'num.rrset.bogus': 0,
'unwanted.queries': 0,
'unwanted.replies': 0,
}
histogram = {
'histogram.16s+': 0.0,
'histogram.256ms+': 3.0,
'histogram.4s+': 1.0,
'histogram.2s+': 0.0,
'histogram.1s+': 0.0,
'histogram.2ms+': 0.0,
'histogram.1ms': 39.0,
'histogram.32ms+': 18.0,
'histogram.4ms+': 0.0,
'histogram.16ms+': 10.0,
'histogram.1ms+': 5.0,
'histogram.32s+': 3.0,
'histogram.512ms+': 6.0,
'histogram.128ms+': 19.0,
'histogram.64ms+': 20.0,
'histogram.8ms+': 3.0,
'histogram.64s+': 9.0,
'histogram.8s+': 0.0,
}
self.assertPublishedMany(publish_mock, metrics)
self.assertUnpublishedMany(publish_mock, histogram)
##########################################################################
if __name__ == "__main__":
unittest.main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
2803,
29,
1624,
13,
24,
199,
26863,
199,
199,
504,
511,
492,
3626,
3283,
1746,
199,
504,
511,
492,
664,
63,
10946,
63,
888,
199,
504,
511,
492,
2882,
199,
504,
1683,
492,
4420,
199,
504,
1683,
492,
3371,
199,
199,
504,
487,
24940,
14,
10946,
492,
3626,
3283,
199,
199,
504,
22334,
492,
1910,
3556,
12852,
199,
199,
26863,
421,
199,
533,
1379,
1358,
3556,
12852,
8,
12852,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
1101,
275,
664,
63,
10946,
63,
888,
360,
1358,
3556,
12852,
297,
5009,
398,
291,
14,
10946,
275,
1910,
3556,
12852,
8,
888,
12,
488,
9,
339,
347,
511,
63,
646,
8,
277,
304,
267,
291,
14,
1815,
8,
1358,
3556,
12852,
9,
339,
768,
2068,
14,
785,
8,
12852,
12,
283,
4763,
358,
272,
347,
511,
63,
5626,
63,
800,
63,
87,
280,
72,
63,
3093,
63,
576,
8,
277,
12,
2780,
63,
1805,
304,
267,
10949,
63,
576,
275,
291,
14,
362,
12812,
360,
18124,
63,
3200,
1959,
7150,
342,
267,
14910,
63,
1805,
275,
3371,
14,
785,
8,
1358,
3556,
12852,
12,
4228,
283,
1065,
63,
1531,
297,
4228,
4420,
8,
1107,
63,
585,
1524,
5997,
63,
576,
12,
283,
5156,
267,
14910,
63,
1805,
14,
928,
342,
267,
291,
14,
10946,
14,
7112,
342,
267,
14910,
63,
1805,
14,
2379,
342,
398,
7186,
275,
469,
288,
283,
2671,
16,
14,
1507,
14,
10590,
356,
2948,
1651,
12,
288,
283,
2671,
16,
14,
1507,
14,
1637,
16595,
356,
2948,
2025,
12,
288,
283,
2671,
16,
14,
1507,
14,
1637,
18420,
356,
1520,
12,
288,
283,
2671,
16,
14,
1507,
14,
15576,
356,
413,
12,
288,
283,
2671,
16,
14,
1507,
14,
9931,
1155,
6528,
356,
1749,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
8595,
356,
413,
14,
821,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
988,
356,
499,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
1883,
8938,
356,
378,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
476,
19750,
356,
378,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
1818,
14,
452,
356,
413,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
1818,
14,
751,
356,
413,
12,
288,
283,
2671,
16,
14,
21314,
14,
521,
14,
8595,
356,
1749,
14,
25,
10834,
713,
12,
288,
283,
2671,
16,
14,
21314,
14,
521,
14,
13106,
356,
378,
14,
2036,
5756,
12,
288,
283,
2923,
14,
1507,
14,
10590,
356,
413,
3912,
1643,
12,
288,
283,
2923,
14,
1507,
14,
1637,
16595,
356,
19163,
23946,
12,
288,
283,
2923,
14,
1507,
14,
1637,
18420,
356,
21572,
12,
288,
283,
2923,
14,
1507,
14,
15576,
356,
3193,
12,
288,
283,
2923,
14,
1507,
14,
9931,
1155,
6528,
356,
27208,
12,
288,
283,
2923,
14,
1069,
513,
14,
8595,
356,
959,
14,
27286,
2466,
12,
288,
283,
2923,
14,
1069,
513,
14,
988,
356,
1616,
12,
288,
283,
2923,
14,
1069,
513,
14,
1883,
8938,
356,
378,
12,
288,
283,
2923,
14,
1069,
513,
14,
476,
19750,
356,
378,
12,
288,
283,
2923,
14,
1069,
513,
14,
1818,
14,
452,
356,
6546,
12,
288,
283,
2923,
14,
1069,
513,
14,
1818,
14,
751,
356,
6546,
12,
288,
283,
2923,
14,
21314,
14,
521,
14,
8595,
356,
4944,
14,
966,
1477,
2426,
12,
288,
283,
2923,
14,
21314,
14,
521,
14,
13106,
356,
378,
14,
1690,
10882,
12,
288,
283,
521,
14,
2131,
356,
27208,
1167,
13085,
1272,
14,
8188,
17430,
12,
288,
283,
521,
14,
384,
356,
650,
8010,
16417,
14,
27250,
24135,
12,
288,
283,
521,
14,
16691,
356,
1749,
14,
2905,
1085,
2564,
12,
288,
283,
5286,
14,
2923,
14,
83,
3289,
75,
356,
499,
1822,
1822,
11197,
12,
288,
283,
5286,
14,
1637,
14,
9734,
409,
356,
4329,
1479,
1690,
13319,
12,
288,
283,
5286,
14,
1637,
14,
1188,
356,
1520,
969,
1644,
7972,
12,
288,
283,
5286,
14,
1494,
14,
5778,
356,
31852,
708,
12,
288,
283,
5286,
14,
1494,
14,
11034,
356,
413,
7636,
14003,
12,
288,
283,
1507,
14,
1131,
14,
466,
14,
33,
356,
5450,
2534,
12,
288,
283,
1507,
14,
1131,
14,
466,
14,
14528,
356,
10551,
12,
288,
283,
1507,
14,
1131,
14,
466,
14,
17401,
356,
21358,
12,
288,
283,
1507,
14,
1131,
14,
466,
14,
6151,
356,
8806,
16456,
12,
288,
283,
1507,
14,
1131,
14,
533,
14,
568,
356,
413,
3912,
1643,
12,
288,
283,
1507,
14,
1131,
14,
14325,
14,
11938,
356,
413,
3912,
1643,
12,
288,
283,
1507,
14,
1131,
14,
8815,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
4774,
22,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
26779,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
2276,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
5708,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
15543,
356,
413,
3912,
1643,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
2847,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
58,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
1554,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
7695,
356,
16202,
12,
288,
283,
1507,
14,
1131,
14,
379,
561,
14,
1881,
356,
16202,
12,
288,
283,
1507,
14,
1131,
14,
379,
561,
14,
1649,
356,
16202,
12,
288,
283,
1507,
14,
5934,
14,
82,
600,
14,
2826,
3170,
356,
841,
1876,
1407,
12,
288,
283,
1507,
14,
5934,
14,
82,
600,
14,
3279,
54,
8784,
356,
12766,
12,
288,
283,
1507,
14,
5934,
14,
82,
600,
14,
16764,
7378,
356,
14679,
14781,
12,
288,
283,
1507,
14,
5934,
14,
82,
600,
14,
18950,
419,
356,
24005,
1272,
12,
288,
283,
1507,
14,
5934,
14,
7817,
356,
378,
12,
288,
283,
1507,
14,
5934,
14,
18665,
356,
378,
12,
288,
283,
1507,
14,
9734,
409,
14,
18665,
356,
378,
12,
288,
283,
324,
19361,
14,
10590,
356,
378,
12,
288,
283,
324,
19361,
14,
1155,
6528,
356,
378,
12,
288,
283,
14805,
14,
975,
83,
11,
356,
378,
14,
16,
12,
288,
283
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
2803,
29,
1624,
13,
24,
199,
26863,
199,
199,
504,
511,
492,
3626,
3283,
1746,
199,
504,
511,
492,
664,
63,
10946,
63,
888,
199,
504,
511,
492,
2882,
199,
504,
1683,
492,
4420,
199,
504,
1683,
492,
3371,
199,
199,
504,
487,
24940,
14,
10946,
492,
3626,
3283,
199,
199,
504,
22334,
492,
1910,
3556,
12852,
199,
199,
26863,
421,
199,
533,
1379,
1358,
3556,
12852,
8,
12852,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
1101,
275,
664,
63,
10946,
63,
888,
360,
1358,
3556,
12852,
297,
5009,
398,
291,
14,
10946,
275,
1910,
3556,
12852,
8,
888,
12,
488,
9,
339,
347,
511,
63,
646,
8,
277,
304,
267,
291,
14,
1815,
8,
1358,
3556,
12852,
9,
339,
768,
2068,
14,
785,
8,
12852,
12,
283,
4763,
358,
272,
347,
511,
63,
5626,
63,
800,
63,
87,
280,
72,
63,
3093,
63,
576,
8,
277,
12,
2780,
63,
1805,
304,
267,
10949,
63,
576,
275,
291,
14,
362,
12812,
360,
18124,
63,
3200,
1959,
7150,
342,
267,
14910,
63,
1805,
275,
3371,
14,
785,
8,
1358,
3556,
12852,
12,
4228,
283,
1065,
63,
1531,
297,
4228,
4420,
8,
1107,
63,
585,
1524,
5997,
63,
576,
12,
283,
5156,
267,
14910,
63,
1805,
14,
928,
342,
267,
291,
14,
10946,
14,
7112,
342,
267,
14910,
63,
1805,
14,
2379,
342,
398,
7186,
275,
469,
288,
283,
2671,
16,
14,
1507,
14,
10590,
356,
2948,
1651,
12,
288,
283,
2671,
16,
14,
1507,
14,
1637,
16595,
356,
2948,
2025,
12,
288,
283,
2671,
16,
14,
1507,
14,
1637,
18420,
356,
1520,
12,
288,
283,
2671,
16,
14,
1507,
14,
15576,
356,
413,
12,
288,
283,
2671,
16,
14,
1507,
14,
9931,
1155,
6528,
356,
1749,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
8595,
356,
413,
14,
821,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
988,
356,
499,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
1883,
8938,
356,
378,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
476,
19750,
356,
378,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
1818,
14,
452,
356,
413,
12,
288,
283,
2671,
16,
14,
1069,
513,
14,
1818,
14,
751,
356,
413,
12,
288,
283,
2671,
16,
14,
21314,
14,
521,
14,
8595,
356,
1749,
14,
25,
10834,
713,
12,
288,
283,
2671,
16,
14,
21314,
14,
521,
14,
13106,
356,
378,
14,
2036,
5756,
12,
288,
283,
2923,
14,
1507,
14,
10590,
356,
413,
3912,
1643,
12,
288,
283,
2923,
14,
1507,
14,
1637,
16595,
356,
19163,
23946,
12,
288,
283,
2923,
14,
1507,
14,
1637,
18420,
356,
21572,
12,
288,
283,
2923,
14,
1507,
14,
15576,
356,
3193,
12,
288,
283,
2923,
14,
1507,
14,
9931,
1155,
6528,
356,
27208,
12,
288,
283,
2923,
14,
1069,
513,
14,
8595,
356,
959,
14,
27286,
2466,
12,
288,
283,
2923,
14,
1069,
513,
14,
988,
356,
1616,
12,
288,
283,
2923,
14,
1069,
513,
14,
1883,
8938,
356,
378,
12,
288,
283,
2923,
14,
1069,
513,
14,
476,
19750,
356,
378,
12,
288,
283,
2923,
14,
1069,
513,
14,
1818,
14,
452,
356,
6546,
12,
288,
283,
2923,
14,
1069,
513,
14,
1818,
14,
751,
356,
6546,
12,
288,
283,
2923,
14,
21314,
14,
521,
14,
8595,
356,
4944,
14,
966,
1477,
2426,
12,
288,
283,
2923,
14,
21314,
14,
521,
14,
13106,
356,
378,
14,
1690,
10882,
12,
288,
283,
521,
14,
2131,
356,
27208,
1167,
13085,
1272,
14,
8188,
17430,
12,
288,
283,
521,
14,
384,
356,
650,
8010,
16417,
14,
27250,
24135,
12,
288,
283,
521,
14,
16691,
356,
1749,
14,
2905,
1085,
2564,
12,
288,
283,
5286,
14,
2923,
14,
83,
3289,
75,
356,
499,
1822,
1822,
11197,
12,
288,
283,
5286,
14,
1637,
14,
9734,
409,
356,
4329,
1479,
1690,
13319,
12,
288,
283,
5286,
14,
1637,
14,
1188,
356,
1520,
969,
1644,
7972,
12,
288,
283,
5286,
14,
1494,
14,
5778,
356,
31852,
708,
12,
288,
283,
5286,
14,
1494,
14,
11034,
356,
413,
7636,
14003,
12,
288,
283,
1507,
14,
1131,
14,
466,
14,
33,
356,
5450,
2534,
12,
288,
283,
1507,
14,
1131,
14,
466,
14,
14528,
356,
10551,
12,
288,
283,
1507,
14,
1131,
14,
466,
14,
17401,
356,
21358,
12,
288,
283,
1507,
14,
1131,
14,
466,
14,
6151,
356,
8806,
16456,
12,
288,
283,
1507,
14,
1131,
14,
533,
14,
568,
356,
413,
3912,
1643,
12,
288,
283,
1507,
14,
1131,
14,
14325,
14,
11938,
356,
413,
3912,
1643,
12,
288,
283,
1507,
14,
1131,
14,
8815,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
4774,
22,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
26779,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
2276,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
5708,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
15543,
356,
413,
3912,
1643,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
2847,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
58,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
1554,
356,
378,
12,
288,
283,
1507,
14,
1131,
14,
2469,
14,
7695,
356,
16202,
12,
288,
283,
1507,
14,
1131,
14,
379,
561,
14,
1881,
356,
16202,
12,
288,
283,
1507,
14,
1131,
14,
379,
561,
14,
1649,
356,
16202,
12,
288,
283,
1507,
14,
5934,
14,
82,
600,
14,
2826,
3170,
356,
841,
1876,
1407,
12,
288,
283,
1507,
14,
5934,
14,
82,
600,
14,
3279,
54,
8784,
356,
12766,
12,
288,
283,
1507,
14,
5934,
14,
82,
600,
14,
16764,
7378,
356,
14679,
14781,
12,
288,
283,
1507,
14,
5934,
14,
82,
600,
14,
18950,
419,
356,
24005,
1272,
12,
288,
283,
1507,
14,
5934,
14,
7817,
356,
378,
12,
288,
283,
1507,
14,
5934,
14,
18665,
356,
378,
12,
288,
283,
1507,
14,
9734,
409,
14,
18665,
356,
378,
12,
288,
283,
324,
19361,
14,
10590,
356,
378,
12,
288,
283,
324,
19361,
14,
1155,
6528,
356,
378,
12,
288,
283,
14805,
14,
975,
83,
11,
356,
378,
14,
16,
12,
288,
283,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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, please refer to the documentation at
https://home-assistant.io/components/sensor.duke_energy/
"""
import logging
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
from homeassistant.helpers.entity import Entity
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['pydukeenergy==0.0.6']
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
})
LAST_BILL_USAGE = "last_bills_usage"
LAST_BILL_AVERAGE_USAGE = "last_bills_average_usage"
LAST_BILL_DAYS_BILLED = "last_bills_days_billed"
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up all Duke Energy meters."""
from pydukeenergy.api import DukeEnergy, DukeEnergyException
try:
duke = DukeEnergy(config[CONF_USERNAME],
config[CONF_PASSWORD],
update_interval=120)
except DukeEnergyException:
_LOGGER.error("Failed to set up Duke Energy")
return
add_entities([DukeEnergyMeter(meter) for meter in duke.get_meters()])
class DukeEnergyMeter(Entity):
"""Representation of a Duke Energy meter."""
def __init__(self, meter):
"""Initialize the meter."""
self.duke_meter = meter
@property
def name(self):
"""Return the name."""
return "duke_energy_{}".format(self.duke_meter.id)
@property
def unique_id(self):
"""Return the unique ID."""
return self.duke_meter.id
@property
def state(self):
"""Return yesterdays usage."""
return self.duke_meter.get_usage()
@property
def unit_of_measurement(self):
"""Return the unit of measurement this sensor expresses itself in."""
return self.duke_meter.get_unit()
@property
def device_state_attributes(self):
"""Return the state attributes."""
attributes = {
LAST_BILL_USAGE: self.duke_meter.get_total(),
LAST_BILL_AVERAGE_USAGE: self.duke_meter.get_average(),
LAST_BILL_DAYS_BILLED: self.duke_meter.get_days_billed()
}
return attributes
def update(self):
"""Update meter."""
self.duke_meter.update()
|
apache-2.0
|
[
624,
199,
11532,
367,
577,
85,
415,
662,
1372,
4312,
598,
305,
436,
662,
1264,
1567,
24808,
14,
199,
199,
1858,
1655,
2436,
3595,
642,
3931,
12,
8749,
10618,
370,
314,
3794,
737,
199,
2859,
921,
4219,
13,
7310,
14,
2308,
15,
4608,
15,
8956,
14,
2033,
415,
63,
8443,
15,
199,
624,
199,
646,
2050,
199,
199,
646,
30291,
465,
5236,
199,
199,
504,
8846,
14,
4608,
14,
8956,
492,
21966,
63,
10926,
199,
504,
8846,
14,
1297,
492,
6392,
63,
11958,
12,
6392,
63,
9032,
199,
504,
8846,
14,
7546,
14,
4502,
492,
17680,
199,
646,
8846,
14,
7546,
14,
888,
63,
6136,
465,
6277,
199,
199,
29168,
20967,
275,
788,
647,
2033,
415,
8443,
389,
16,
14,
16,
14,
22,
418,
199,
199,
63,
10186,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
17805,
63,
10926,
275,
21966,
63,
10926,
14,
2880,
2561,
272,
5236,
14,
8030,
8,
3103,
63,
11958,
304,
6277,
14,
875,
12,
272,
5236,
14,
8030,
8,
3103,
63,
9032,
304,
6277,
14,
875,
12,
199,
1552,
199,
199,
16901,
63,
34,
14961,
63,
20274,
275,
298,
2019,
63,
66,
15350,
63,
3807,
2,
199,
16901,
63,
34,
14961,
63,
33,
2111,
2962,
63,
20274,
275,
298,
2019,
63,
66,
15350,
63,
8536,
63,
3807,
2,
199,
16901,
63,
34,
14961,
63,
25683,
63,
34,
1193,
5290,
275,
298,
2019,
63,
66,
15350,
63,
4899,
63,
66,
14535,
2,
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,
1006,
577,
85,
415,
662,
1372,
4312,
24808,
1041,
272,
687,
1134,
2033,
415,
8443,
14,
1246,
492,
577,
85,
415,
9900,
12,
577,
85,
415,
9900,
1726,
339,
862,
26,
267,
15776,
415,
275,
577,
85,
415,
9900,
8,
888,
59,
3103,
63,
11958,
467,
2079,
1101,
59,
3103,
63,
9032,
467,
2079,
1678,
63,
4284,
29,
6708,
9,
272,
871,
577,
85,
415,
9900,
1726,
26,
267,
485,
10186,
14,
705,
480,
4276,
370,
663,
1536,
577,
85,
415,
662,
1372,
4312,
531,
267,
372,
339,
1050,
63,
8327,
779,
36,
85,
415,
9900,
27937,
8,
10011,
9,
367,
21247,
315,
15776,
415,
14,
362,
63,
20893,
9383,
421,
199,
533,
577,
85,
415,
9900,
27937,
8,
7302,
304,
272,
408,
20609,
402,
282,
577,
85,
415,
662,
1372,
4312,
21247,
1041,
339,
347,
636,
826,
721,
277,
12,
21247,
304,
267,
408,
9345,
314,
21247,
1041,
267,
291,
14,
2033,
415,
63,
10011,
275,
21247,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
408,
1767,
314,
536,
1041,
267,
372,
298,
2033,
415,
63,
8443,
63,
13536,
908,
8,
277,
14,
2033,
415,
63,
10011,
14,
344,
9,
339,
768,
1829,
272,
347,
3747,
63,
344,
8,
277,
304,
267,
408,
1767,
314,
3747,
2870,
1041,
267,
372,
291,
14,
2033,
415,
63,
10011,
14,
344,
339,
768,
1829,
272,
347,
1174,
8,
277,
304,
267,
408,
1767,
9456,
351,
4899,
4503,
1041,
267,
372,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
3807,
342,
339,
768,
1829,
272,
347,
4137,
63,
1618,
63,
17912,
8,
277,
304,
267,
408,
1767,
314,
4137,
402,
18216,
642,
8778,
1437,
4357,
6337,
315,
1041,
267,
372,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
3248,
342,
339,
768,
1829,
272,
347,
2243,
63,
929,
63,
2987,
8,
277,
304,
267,
408,
1767,
314,
1174,
3004,
1041,
267,
3004,
275,
469,
288,
491,
11307,
63,
34,
14961,
63,
20274,
26,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
2923,
1062,
288,
491,
11307,
63,
34,
14961,
63,
33,
2111,
2962,
63,
20274,
26,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
8536,
1062,
288,
491,
11307,
63,
34,
14961,
63,
25683,
63,
34,
1193,
5290,
26,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
4899,
63,
66,
14535,
342,
267,
789,
267,
372,
3004,
339,
347,
1678,
8,
277,
304,
267,
408,
4152,
21247,
1041,
267,
291,
14,
2033,
415,
63,
10011,
14,
873,
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
] |
[
199,
11532,
367,
577,
85,
415,
662,
1372,
4312,
598,
305,
436,
662,
1264,
1567,
24808,
14,
199,
199,
1858,
1655,
2436,
3595,
642,
3931,
12,
8749,
10618,
370,
314,
3794,
737,
199,
2859,
921,
4219,
13,
7310,
14,
2308,
15,
4608,
15,
8956,
14,
2033,
415,
63,
8443,
15,
199,
624,
199,
646,
2050,
199,
199,
646,
30291,
465,
5236,
199,
199,
504,
8846,
14,
4608,
14,
8956,
492,
21966,
63,
10926,
199,
504,
8846,
14,
1297,
492,
6392,
63,
11958,
12,
6392,
63,
9032,
199,
504,
8846,
14,
7546,
14,
4502,
492,
17680,
199,
646,
8846,
14,
7546,
14,
888,
63,
6136,
465,
6277,
199,
199,
29168,
20967,
275,
788,
647,
2033,
415,
8443,
389,
16,
14,
16,
14,
22,
418,
199,
199,
63,
10186,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
17805,
63,
10926,
275,
21966,
63,
10926,
14,
2880,
2561,
272,
5236,
14,
8030,
8,
3103,
63,
11958,
304,
6277,
14,
875,
12,
272,
5236,
14,
8030,
8,
3103,
63,
9032,
304,
6277,
14,
875,
12,
199,
1552,
199,
199,
16901,
63,
34,
14961,
63,
20274,
275,
298,
2019,
63,
66,
15350,
63,
3807,
2,
199,
16901,
63,
34,
14961,
63,
33,
2111,
2962,
63,
20274,
275,
298,
2019,
63,
66,
15350,
63,
8536,
63,
3807,
2,
199,
16901,
63,
34,
14961,
63,
25683,
63,
34,
1193,
5290,
275,
298,
2019,
63,
66,
15350,
63,
4899,
63,
66,
14535,
2,
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,
1006,
577,
85,
415,
662,
1372,
4312,
24808,
1041,
272,
687,
1134,
2033,
415,
8443,
14,
1246,
492,
577,
85,
415,
9900,
12,
577,
85,
415,
9900,
1726,
339,
862,
26,
267,
15776,
415,
275,
577,
85,
415,
9900,
8,
888,
59,
3103,
63,
11958,
467,
2079,
1101,
59,
3103,
63,
9032,
467,
2079,
1678,
63,
4284,
29,
6708,
9,
272,
871,
577,
85,
415,
9900,
1726,
26,
267,
485,
10186,
14,
705,
480,
4276,
370,
663,
1536,
577,
85,
415,
662,
1372,
4312,
531,
267,
372,
339,
1050,
63,
8327,
779,
36,
85,
415,
9900,
27937,
8,
10011,
9,
367,
21247,
315,
15776,
415,
14,
362,
63,
20893,
9383,
421,
199,
533,
577,
85,
415,
9900,
27937,
8,
7302,
304,
272,
408,
20609,
402,
282,
577,
85,
415,
662,
1372,
4312,
21247,
1041,
339,
347,
636,
826,
721,
277,
12,
21247,
304,
267,
408,
9345,
314,
21247,
1041,
267,
291,
14,
2033,
415,
63,
10011,
275,
21247,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
408,
1767,
314,
536,
1041,
267,
372,
298,
2033,
415,
63,
8443,
63,
13536,
908,
8,
277,
14,
2033,
415,
63,
10011,
14,
344,
9,
339,
768,
1829,
272,
347,
3747,
63,
344,
8,
277,
304,
267,
408,
1767,
314,
3747,
2870,
1041,
267,
372,
291,
14,
2033,
415,
63,
10011,
14,
344,
339,
768,
1829,
272,
347,
1174,
8,
277,
304,
267,
408,
1767,
9456,
351,
4899,
4503,
1041,
267,
372,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
3807,
342,
339,
768,
1829,
272,
347,
4137,
63,
1618,
63,
17912,
8,
277,
304,
267,
408,
1767,
314,
4137,
402,
18216,
642,
8778,
1437,
4357,
6337,
315,
1041,
267,
372,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
3248,
342,
339,
768,
1829,
272,
347,
2243,
63,
929,
63,
2987,
8,
277,
304,
267,
408,
1767,
314,
1174,
3004,
1041,
267,
3004,
275,
469,
288,
491,
11307,
63,
34,
14961,
63,
20274,
26,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
2923,
1062,
288,
491,
11307,
63,
34,
14961,
63,
33,
2111,
2962,
63,
20274,
26,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
8536,
1062,
288,
491,
11307,
63,
34,
14961,
63,
25683,
63,
34,
1193,
5290,
26,
291,
14,
2033,
415,
63,
10011,
14,
362,
63,
4899,
63,
66,
14535,
342,
267,
789,
267,
372,
3004,
339,
347,
1678,
8,
277,
304,
267,
408,
4152,
21247,
1041,
267,
291,
14,
2033,
415,
63,
10011,
14,
873,
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,
32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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
habnabit/pip
|
tests/lib/path.py
|
56
|
6574
|
# flake8: noqa
# -*- coding: utf-8 -*-
# Author: Aziz Köksal
from __future__ import absolute_import
import glob
import os
import sys
import shutil
try:
from os import supports_fd
except ImportError:
supports_fd = set()
if sys.version_info >= (3,):
unicode = str
u = str
else:
unicode = unicode
u = lambda s: s.decode('utf-8')
_base = os.path.supports_unicode_filenames and unicode or str
class Path(_base):
"""
Models a path in an object oriented way.
"""
# File system path separator: '/' or '\'.
sep = os.sep
# Separator in the PATH environment variable.
pathsep = os.pathsep
def __new__(cls, *paths):
if len(paths):
return _base.__new__(cls, os.path.join(*paths))
return _base.__new__(cls)
def __div__(self, path):
"""
Joins this path with another path.
>>> path_obj / 'bc.d'
>>> path_obj / path_obj2
"""
return Path(self, path)
__truediv__ = __div__
def __rdiv__(self, path):
"""
Joins this path with another path.
>>> "/home/a" / path_obj
"""
return Path(path, self)
__rtruediv__ = __rdiv__
def __idiv__(self, path):
"""
Like __div__ but also assigns to the variable.
>>> path_obj /= 'bc.d'
"""
return Path(self, path)
__itruediv__ = __idiv__
def __floordiv__(self, paths):
"""
Returns a list of paths prefixed with 'self'.
>>> '/home/a' // [bc.d, ef.g]
[/home/a/bc.d, /home/a/ef.g]
"""
return [Path(self, path) for path in paths]
def __sub__(self, path):
"""
Makes this path relative to another path.
>>> path_obj - '/home/a'
>>> path_obj - path_obj2
"""
return Path(os.path.relpath(self, path))
def __rsub__(self, path):
"""
Returns path relative to this path.
>>> "/home/a" - path_obj
"""
return Path(os.path.relpath(path, self))
def __add__(self, path):
"""
>>> Path('/home/a') + 'bc.d'
'/home/abc.d'
"""
return Path(_base(self) + path)
def __radd__(self, path):
"""
>>> '/home/a' + Path('bc.d')
'/home/abc.d'
"""
return Path(path + _base(self))
def __repr__(self):
return u("Path(%s)" % _base.__repr__(self))
def __hash__(self):
return _base.__hash__(self)
@property
def name(self):
"""
'/home/a/bc.d' -> 'bc.d'
"""
return os.path.basename(self)
@property
def namebase(self):
"""
'/home/a/bc.d' -> 'bc'
"""
return self.noext.name
@property
def noext(self):
"""
'/home/a/bc.d' -> '/home/a/bc'
"""
return Path(os.path.splitext(self)[0])
@property
def ext(self):
"""
'/home/a/bc.d' -> '.d'
"""
return Path(os.path.splitext(self)[1])
@property
def abspath(self):
"""
'./a/bc.d' -> '/home/a/bc.d'
"""
return Path(os.path.abspath(self))
@property
def realpath(self):
"""
Resolves symbolic links.
"""
return Path(os.path.realpath(self))
@property
def normpath(self):
"""
'/home/x/.././a//bc.d' -> '/home/a/bc.d'
"""
return Path(os.path.normpath(self))
@property
def normcase(self):
"""
Deals with case-insensitive filesystems
"""
return Path(os.path.normcase(self))
@property
def folder(self):
"""
Returns the folder of this path.
'/home/a/bc.d' -> '/home/a'
'/home/a/' -> '/home/a'
'/home/a' -> '/home'
"""
return Path(os.path.dirname(self))
@property
def exists(self):
"""
Returns True if the path exists.
"""
return os.path.exists(self)
@property
def atime(self):
"""
Returns last accessed time.
"""
return os.path.getatime(self)
@property
def mtime(self):
"""
Returns last modified time.
"""
return os.path.getmtime(self)
@property
def ctime(self):
"""
Returns last changed time.
"""
return os.path.getctime(self)
@classmethod
def supports_unicode(self):
"""
Returns True if the system can handle Unicode file names.
"""
return os.path.supports_unicode_filenames()
def walk(self, **kwargs):
""" Returns a generator that walks through a directory tree. """
return os.walk(self, **kwargs)
def mkdir(self, mode=0x1FF): # 0o777
"""
Creates a directory, if it doesn't exist already.
"""
if not self.exists:
os.mkdir(self, mode)
return self
def makedirs(self, mode=0x1FF): # 0o777
"""
Like mkdir(), but also creates parent directories.
"""
if not self.exists:
os.makedirs(self, mode)
return self
def remove(self):
"""
Removes a file.
"""
return os.remove(self)
rm = remove # Alias.
def rmdir(self):
"""
Removes a directory.
"""
return os.rmdir(self)
def rmtree(self, noerrors=True):
"""
Removes a directory tree. Ignores errors by default.
"""
return shutil.rmtree(self, ignore_errors=noerrors)
def copy(self, to):
return shutil.copy(self, to)
def copytree(self, to):
"""
Copies a directory tree to another path.
"""
return shutil.copytree(self, to, symlinks=True)
def move(self, to):
"""
Moves a file or directory to another path.
"""
return shutil.move(self, to)
def rename(self, to):
"""
Renames a file or directory. May throw an OSError.
"""
return os.rename(self, to)
def renames(self, to):
return os.renames(self, to)
def glob(self, pattern):
return (Path(i) for i in glob.iglob(self.join(pattern)))
def join(self, *parts):
return Path(self, *parts)
def write(self, content):
with open(self, "w") as fp:
fp.write(content)
def touch(self, times=None):
with open(self, "a") as fp:
os.utime(fp.fileno() if os.utime in supports_fd else self, times)
curdir = Path(os.path.curdir)
|
mit
|
[
3,
27510,
24,
26,
8151,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
6529,
26,
437,
90,
565,
1804,
14614,
6080,
279,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
5739,
199,
646,
747,
199,
646,
984,
199,
646,
5145,
199,
199,
893,
26,
272,
687,
747,
492,
5171,
63,
2592,
199,
2590,
3545,
26,
272,
5171,
63,
2592,
275,
663,
342,
199,
199,
692,
984,
14,
1023,
63,
815,
2356,
334,
19,
16095,
272,
2649,
275,
620,
272,
399,
275,
620,
199,
2836,
26,
272,
2649,
275,
2649,
272,
399,
275,
2400,
308,
26,
308,
14,
2708,
360,
1624,
13,
24,
358,
199,
199,
63,
1095,
275,
747,
14,
515,
14,
9823,
63,
2975,
63,
10309,
436,
2649,
503,
620,
421,
199,
533,
6912,
1547,
1095,
304,
272,
408,
272,
29941,
282,
931,
315,
376,
909,
503,
24555,
471,
4340,
14,
272,
408,
339,
327,
3814,
2656,
931,
9432,
26,
7324,
503,
1557,
1370,
272,
7375,
275,
747,
14,
4127,
339,
327,
27504,
707,
315,
314,
15097,
3734,
1750,
14,
272,
931,
4127,
275,
747,
14,
17843,
339,
347,
636,
1222,
721,
1886,
12,
627,
3771,
304,
267,
340,
822,
8,
3771,
304,
288,
372,
485,
1095,
855,
1222,
721,
1886,
12,
747,
14,
515,
14,
904,
2031,
3771,
430,
267,
372,
485,
1095,
855,
1222,
721,
1886,
9,
339,
347,
636,
3015,
721,
277,
12,
931,
304,
267,
408,
267,
7135,
3617,
642,
931,
543,
4573,
931,
14,
398,
1306,
931,
63,
1113,
1182,
283,
3776,
14,
68,
7,
267,
1306,
931,
63,
1113,
1182,
931,
63,
1113,
18,
267,
408,
267,
372,
6912,
8,
277,
12,
931,
9,
339,
636,
22062,
363,
275,
636,
3015,
363,
339,
347,
636,
82,
3015,
721,
277,
12,
931,
304,
267,
408,
267,
7135,
3617,
642,
931,
543,
4573,
931,
14,
398,
1306,
3286,
4219,
15,
65,
2,
1182,
931,
63,
1113,
267,
408,
267,
372,
6912,
8,
515,
12,
291,
9,
339,
636,
82,
22062,
363,
275,
636,
82,
3015,
363,
339,
347,
636,
73,
3015,
721,
277,
12,
931,
304,
267,
408,
267,
16485,
636,
3015,
363,
1325,
2597,
465,
20440,
370,
314,
1750,
14,
398,
1306,
931,
63,
1113,
12257,
283,
3776,
14,
68,
7,
267,
408,
267,
372,
6912,
8,
277,
12,
931,
9,
339,
636,
390,
431,
3015,
363,
275,
636,
73,
3015,
363,
339,
347,
636,
30835,
721,
277,
12,
3792,
304,
267,
408,
267,
1803,
282,
769,
402,
3792,
18239,
543,
283,
277,
1370,
398,
1306,
1994,
4219,
15,
65,
7,
5001,
359,
3776,
14,
68,
12,
9530,
14,
71,
61,
267,
359,
15,
4219,
15,
65,
15,
3776,
14,
68,
12,
1182,
4219,
15,
65,
15,
2829,
14,
71,
61,
267,
408,
267,
372,
359,
2042,
8,
277,
12,
931,
9,
367,
931,
315,
3792,
61,
339,
347,
636,
954,
721,
277,
12,
931,
304,
267,
408,
267,
23365,
642,
931,
3847,
370,
4573,
931,
14,
398,
1306,
931,
63,
1113,
446,
1994,
4219,
15,
65,
7,
267,
1306,
931,
63,
1113,
446,
931,
63,
1113,
18,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
12405,
8,
277,
12,
931,
430,
339,
347,
636,
82,
954,
721,
277,
12,
931,
304,
267,
408,
267,
1803,
931,
3847,
370,
642,
931,
14,
398,
1306,
3286,
4219,
15,
65,
2,
446,
931,
63,
1113,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
12405,
8,
515,
12,
291,
430,
339,
347,
636,
525,
721,
277,
12,
931,
304,
267,
408,
267,
1306,
6912,
2336,
4219,
15,
65,
358,
435,
283,
3776,
14,
68,
7,
267,
1994,
4219,
15,
3175,
14,
68,
7,
267,
408,
267,
372,
6912,
1547,
1095,
8,
277,
9,
435,
931,
9,
339,
347,
636,
22958,
721,
277,
12,
931,
304,
267,
408,
267,
1306,
1994,
4219,
15,
65,
7,
435,
6912,
360,
3776,
14,
68,
358,
267,
1994,
4219,
15,
3175,
14,
68,
7,
267,
408,
267,
372,
6912,
8,
515,
435,
485,
1095,
8,
277,
430,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
399,
480,
2042,
4042,
83,
2924,
450,
485,
1095,
855,
2722,
721,
277,
430,
339,
347,
636,
2227,
721,
277,
304,
267,
372,
485,
1095,
855,
2227,
721,
277,
9,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
1035,
283,
3776,
14,
68,
7,
267,
408,
267,
372,
747,
14,
515,
14,
4846,
8,
277,
9,
339,
768,
1829,
272,
347,
536,
1095,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
1035,
283,
3776,
7,
267,
408,
267,
372,
291,
14,
889,
832,
14,
354,
339,
768,
1829,
272,
347,
949,
832,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
1035,
1994,
4219,
15,
65,
15,
3776,
7,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
7973,
8,
277,
2788,
16,
566,
339,
768,
1829,
272,
347,
1599,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
1035,
1987,
68,
7,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
7973,
8,
277,
2788,
17,
566,
339,
768,
1829,
272,
347,
19529,
8,
277,
304,
267,
408,
267,
21526,
65,
15,
3776,
14,
68,
7,
1035,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
4832,
8,
277,
430,
339,
768,
1829,
272,
347,
3363,
515,
8,
277,
304,
267,
408,
267,
3591,
393,
2310,
13673,
6220,
14,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
11091,
8,
277,
430,
339,
768,
1829,
272,
347,
25962,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
88,
15,
5093,
13186,
65,
501,
3776,
14,
68,
7,
1035,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
9267,
8,
277,
430,
339,
768,
1829,
272,
347,
6316,
2546,
8,
277,
304,
267,
408,
267,
1487,
2551,
543,
1930,
13,
15851,
10036,
83,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
21288
] |
[
27510,
24,
26,
8151,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
6529,
26,
437,
90,
565,
1804,
14614,
6080,
279,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
5739,
199,
646,
747,
199,
646,
984,
199,
646,
5145,
199,
199,
893,
26,
272,
687,
747,
492,
5171,
63,
2592,
199,
2590,
3545,
26,
272,
5171,
63,
2592,
275,
663,
342,
199,
199,
692,
984,
14,
1023,
63,
815,
2356,
334,
19,
16095,
272,
2649,
275,
620,
272,
399,
275,
620,
199,
2836,
26,
272,
2649,
275,
2649,
272,
399,
275,
2400,
308,
26,
308,
14,
2708,
360,
1624,
13,
24,
358,
199,
199,
63,
1095,
275,
747,
14,
515,
14,
9823,
63,
2975,
63,
10309,
436,
2649,
503,
620,
421,
199,
533,
6912,
1547,
1095,
304,
272,
408,
272,
29941,
282,
931,
315,
376,
909,
503,
24555,
471,
4340,
14,
272,
408,
339,
327,
3814,
2656,
931,
9432,
26,
7324,
503,
1557,
1370,
272,
7375,
275,
747,
14,
4127,
339,
327,
27504,
707,
315,
314,
15097,
3734,
1750,
14,
272,
931,
4127,
275,
747,
14,
17843,
339,
347,
636,
1222,
721,
1886,
12,
627,
3771,
304,
267,
340,
822,
8,
3771,
304,
288,
372,
485,
1095,
855,
1222,
721,
1886,
12,
747,
14,
515,
14,
904,
2031,
3771,
430,
267,
372,
485,
1095,
855,
1222,
721,
1886,
9,
339,
347,
636,
3015,
721,
277,
12,
931,
304,
267,
408,
267,
7135,
3617,
642,
931,
543,
4573,
931,
14,
398,
1306,
931,
63,
1113,
1182,
283,
3776,
14,
68,
7,
267,
1306,
931,
63,
1113,
1182,
931,
63,
1113,
18,
267,
408,
267,
372,
6912,
8,
277,
12,
931,
9,
339,
636,
22062,
363,
275,
636,
3015,
363,
339,
347,
636,
82,
3015,
721,
277,
12,
931,
304,
267,
408,
267,
7135,
3617,
642,
931,
543,
4573,
931,
14,
398,
1306,
3286,
4219,
15,
65,
2,
1182,
931,
63,
1113,
267,
408,
267,
372,
6912,
8,
515,
12,
291,
9,
339,
636,
82,
22062,
363,
275,
636,
82,
3015,
363,
339,
347,
636,
73,
3015,
721,
277,
12,
931,
304,
267,
408,
267,
16485,
636,
3015,
363,
1325,
2597,
465,
20440,
370,
314,
1750,
14,
398,
1306,
931,
63,
1113,
12257,
283,
3776,
14,
68,
7,
267,
408,
267,
372,
6912,
8,
277,
12,
931,
9,
339,
636,
390,
431,
3015,
363,
275,
636,
73,
3015,
363,
339,
347,
636,
30835,
721,
277,
12,
3792,
304,
267,
408,
267,
1803,
282,
769,
402,
3792,
18239,
543,
283,
277,
1370,
398,
1306,
1994,
4219,
15,
65,
7,
5001,
359,
3776,
14,
68,
12,
9530,
14,
71,
61,
267,
359,
15,
4219,
15,
65,
15,
3776,
14,
68,
12,
1182,
4219,
15,
65,
15,
2829,
14,
71,
61,
267,
408,
267,
372,
359,
2042,
8,
277,
12,
931,
9,
367,
931,
315,
3792,
61,
339,
347,
636,
954,
721,
277,
12,
931,
304,
267,
408,
267,
23365,
642,
931,
3847,
370,
4573,
931,
14,
398,
1306,
931,
63,
1113,
446,
1994,
4219,
15,
65,
7,
267,
1306,
931,
63,
1113,
446,
931,
63,
1113,
18,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
12405,
8,
277,
12,
931,
430,
339,
347,
636,
82,
954,
721,
277,
12,
931,
304,
267,
408,
267,
1803,
931,
3847,
370,
642,
931,
14,
398,
1306,
3286,
4219,
15,
65,
2,
446,
931,
63,
1113,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
12405,
8,
515,
12,
291,
430,
339,
347,
636,
525,
721,
277,
12,
931,
304,
267,
408,
267,
1306,
6912,
2336,
4219,
15,
65,
358,
435,
283,
3776,
14,
68,
7,
267,
1994,
4219,
15,
3175,
14,
68,
7,
267,
408,
267,
372,
6912,
1547,
1095,
8,
277,
9,
435,
931,
9,
339,
347,
636,
22958,
721,
277,
12,
931,
304,
267,
408,
267,
1306,
1994,
4219,
15,
65,
7,
435,
6912,
360,
3776,
14,
68,
358,
267,
1994,
4219,
15,
3175,
14,
68,
7,
267,
408,
267,
372,
6912,
8,
515,
435,
485,
1095,
8,
277,
430,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
399,
480,
2042,
4042,
83,
2924,
450,
485,
1095,
855,
2722,
721,
277,
430,
339,
347,
636,
2227,
721,
277,
304,
267,
372,
485,
1095,
855,
2227,
721,
277,
9,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
1035,
283,
3776,
14,
68,
7,
267,
408,
267,
372,
747,
14,
515,
14,
4846,
8,
277,
9,
339,
768,
1829,
272,
347,
536,
1095,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
1035,
283,
3776,
7,
267,
408,
267,
372,
291,
14,
889,
832,
14,
354,
339,
768,
1829,
272,
347,
949,
832,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
1035,
1994,
4219,
15,
65,
15,
3776,
7,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
7973,
8,
277,
2788,
16,
566,
339,
768,
1829,
272,
347,
1599,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
1035,
1987,
68,
7,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
7973,
8,
277,
2788,
17,
566,
339,
768,
1829,
272,
347,
19529,
8,
277,
304,
267,
408,
267,
21526,
65,
15,
3776,
14,
68,
7,
1035,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
4832,
8,
277,
430,
339,
768,
1829,
272,
347,
3363,
515,
8,
277,
304,
267,
408,
267,
3591,
393,
2310,
13673,
6220,
14,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
11091,
8,
277,
430,
339,
768,
1829,
272,
347,
25962,
8,
277,
304,
267,
408,
267,
1994,
4219,
15,
88,
15,
5093,
13186,
65,
501,
3776,
14,
68,
7,
1035,
1994,
4219,
15,
65,
15,
3776,
14,
68,
7,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
9267,
8,
277,
430,
339,
768,
1829,
272,
347,
6316,
2546,
8,
277,
304,
267,
408,
267,
1487,
2551,
543,
1930,
13,
15851,
10036,
83,
267,
408,
267,
372,
6912,
8,
736,
14,
515,
14,
21288,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
michaeltchapman/kubernetes
|
cluster/juju/charms/trusty/kubernetes-master/unit_tests/test_install.py
|
105
|
4115
|
#!/usr/bin/env python
# Copyright 2015 The Kubernetes 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 mock import patch, Mock, MagicMock
from path import Path
import pytest
import sys
# Munge the python path so we can find our hook code
d = Path('__file__').parent.abspath() / 'hooks'
sys.path.insert(0, d.abspath())
# Import the modules from the hook
import install
class TestInstallHook():
@patch('install.path')
def test_update_rc_files(self, pmock):
"""
Test happy path on updating env files. Assuming everything
exists and is in place.
"""
pmock.return_value.lines.return_value = ['line1', 'line2']
install.update_rc_files(['test1', 'test2'])
pmock.return_value.write_lines.assert_called_with(['line1', 'line2',
'test1', 'test2'])
def test_update_rc_files_with_nonexistant_path(self):
"""
Test an unhappy path if the bashrc/users do not exist.
"""
with pytest.raises(OSError) as exinfo:
install.update_rc_files(['test1','test2'])
@patch('install.fetch')
@patch('install.hookenv')
def test_package_installation(self, hemock, ftmock):
"""
Verify we are calling the known essentials to build and syndicate
kubes.
"""
pkgs = ['build-essential', 'git',
'make', 'nginx', 'python-pip']
install.install_packages()
hemock.log.assert_called_with('Installing Debian packages')
ftmock.filter_installed_packages.assert_called_with(pkgs)
@patch('install.archiveurl.ArchiveUrlFetchHandler')
def test_go_download(self, aumock):
"""
Test that we are actually handing off to charm-helpers to
download a specific archive of Go. This is non-configurable so
its reasonably safe to assume we're going to always do this,
and when it changes we shall curse the brittleness of this test.
"""
ins_mock = aumock.return_value.install
install.download_go()
url = 'https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz'
sha1='5020af94b52b65cc9b6f11d50a67e4bae07b0aff'
ins_mock.assert_called_with(url, '/usr/local', sha1, 'sha1')
@patch('install.subprocess')
def test_clone_repository(self, spmock):
"""
We're not using a unit-tested git library - so ensure our subprocess
call is consistent. If we change this, we want to know we've broken it.
"""
install.clone_repository()
repo = 'https://github.com/GoogleCloudPlatform/kubernetes.git'
direct = '/opt/kubernetes'
spmock.check_output.assert_called_with(['git', 'clone', repo, direct])
@patch('install.install_packages')
@patch('install.download_go')
@patch('install.clone_repository')
@patch('install.update_rc_files')
@patch('install.hookenv')
def test_install_main(self, hemock, urmock, crmock, dgmock, ipmock):
"""
Ensure the driver/main method is calling all the supporting methods.
"""
strings = [
'export GOROOT=/usr/local/go\n',
'export PATH=$PATH:$GOROOT/bin\n',
'export KUBE_MASTER_IP=0.0.0.0\n',
'export KUBERNETES_MASTER=http://$KUBE_MASTER_IP\n',
]
install.install()
crmock.assert_called_once()
dgmock.assert_called_once()
crmock.assert_called_once()
urmock.assert_called_with(strings)
hemock.open_port.assert_called_with(8080)
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
6900,
710,
28723,
6642,
2900,
4481,
4644,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
1683,
492,
3371,
12,
4420,
12,
10079,
199,
504,
931,
492,
6912,
199,
646,
4613,
199,
646,
984,
199,
199,
3,
603,
16993,
314,
2366,
931,
880,
781,
883,
2342,
4154,
5759,
1233,
199,
68,
275,
6912,
10714,
493,
363,
1959,
1708,
14,
4832,
342,
1182,
283,
7922,
7,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
366,
14,
4832,
1012,
199,
199,
3,
3161,
314,
4621,
687,
314,
5759,
199,
646,
3907,
199,
199,
533,
1379,
8154,
8481,
837,
339,
768,
2068,
360,
3174,
14,
515,
358,
272,
347,
511,
63,
873,
63,
1195,
63,
1725,
8,
277,
12,
299,
1805,
304,
267,
408,
267,
1379,
394,
18869,
931,
641,
12928,
2589,
1584,
14,
10829,
12848,
8137,
267,
3495,
436,
365,
315,
4192,
14,
267,
408,
267,
299,
1805,
14,
1107,
63,
585,
14,
1278,
14,
1107,
63,
585,
275,
221,
788,
604,
17,
297,
283,
604,
18,
418,
267,
3907,
14,
873,
63,
1195,
63,
1725,
2941,
396,
17,
297,
283,
396,
18,
1105,
267,
299,
1805,
14,
1107,
63,
585,
14,
952,
63,
1278,
14,
479,
63,
3527,
63,
1045,
2941,
604,
17,
297,
283,
604,
18,
297,
15491,
283,
396,
17,
297,
283,
396,
18,
1105,
339,
347,
511,
63,
873,
63,
1195,
63,
1725,
63,
1045,
63,
3592,
88,
631,
867,
63,
515,
8,
277,
304,
267,
408,
267,
1379,
376,
625,
72,
18869,
931,
340,
314,
20387,
1195,
15,
3707,
886,
440,
2187,
14,
267,
408,
267,
543,
4613,
14,
3536,
8,
16719,
9,
465,
444,
815,
26,
288,
3907,
14,
873,
63,
1195,
63,
1725,
2941,
396,
17,
1673,
396,
18,
1105,
339,
768,
2068,
360,
3174,
14,
3535,
358,
272,
768,
2068,
360,
3174,
14,
3664,
1813,
358,
272,
347,
511,
63,
2491,
63,
23048,
8,
277,
12,
946,
1805,
12,
18133,
1805,
304,
267,
408,
267,
7635,
781,
787,
6358,
314,
6040,
22829,
1009,
83,
370,
1900,
436,
9560,
10188,
267,
1022,
456,
397,
14,
267,
408,
267,
24162,
275,
788,
1506,
13,
397,
2464,
1009,
297,
283,
3187,
297,
355,
283,
1875,
297,
283,
25826,
297,
283,
1548,
13,
9983,
418,
267,
3907,
14,
3174,
63,
5154,
342,
267,
946,
1805,
14,
793,
14,
479,
63,
3527,
63,
1045,
360,
31376,
30445,
6117,
358,
267,
18133,
1805,
14,
1541,
63,
7657,
63,
5154,
14,
479,
63,
3527,
63,
1045,
8,
16624,
9,
339,
768,
2068,
360,
3174,
14,
6404,
633,
14,
13042,
6417,
11135,
2461,
358,
272,
347,
511,
63,
1939,
63,
4249,
8,
277,
12,
282,
453,
766,
304,
267,
408,
288,
1379,
626,
781,
787,
5965,
4926,
316,
2331,
370,
1495,
77,
13,
7546,
370,
288,
5235,
282,
2488,
6359,
402,
3971,
14,
961,
365,
2222,
13,
888,
15684,
880,
288,
2399,
4499,
6665,
5048,
370,
5534,
781,
3984,
9995,
370,
3544,
886,
642,
12,
288,
436,
1380,
652,
4493,
781,
10989,
1094,
261,
314,
20611,
6215,
552,
16709,
402,
642,
511,
14,
267,
408,
267,
5261,
63,
1805,
275,
282,
453,
766,
14,
1107,
63,
585,
14,
3174,
267,
3907,
14,
4249,
63,
1939,
342,
267,
1166,
275,
283,
2859,
921,
3494,
14,
17533,
14,
957,
15,
71,
393,
621,
15,
1939,
17,
14,
20,
14,
18,
14,
5135,
13,
21778,
772,
14,
5369,
14,
6838,
7,
267,
7793,
17,
534,
21,
10173,
2756,
2635,
66,
2528,
66,
2182,
2055,
25,
66,
22,
70,
845,
68,
1400,
65,
1822,
69,
20,
28363,
1780,
66,
16,
9181,
7,
267,
5261,
63,
1805,
14,
479,
63,
3527,
63,
1045,
8,
633,
12,
1994,
2647,
15,
1832,
297,
7793,
17,
12,
283,
4835,
17,
358,
339,
768,
2068,
360,
3174,
14,
5781,
358,
272,
347,
511,
63,
6311,
63,
8421,
8,
277,
12,
2249,
1805,
304,
267,
408,
268,
2136,
3984,
440,
1808,
282,
4137,
13,
10453,
6135,
3555,
446,
880,
4868,
4154,
3873,
268,
1240,
365,
12137,
14,
982,
781,
1570,
642,
12,
781,
2934,
370,
5715,
781,
9064,
10529,
652,
14,
267,
408,
267,
3907,
14,
6311,
63,
8421,
342,
267,
3831,
275,
283,
2859,
921,
5031,
14,
957,
15,
13266,
9089,
10397,
15,
17422,
14,
3187,
7,
267,
4125,
275,
1994,
2992,
15,
17422,
7,
267,
2249,
1805,
14,
1074,
63,
1199,
14,
479,
63,
3527,
63,
1045,
2941,
3187,
297,
283,
6311,
297,
3831,
12,
4125,
566,
339,
768,
2068,
360,
3174,
14,
3174,
63,
5154,
358,
272,
768,
2068,
360,
3174,
14,
4249,
63,
1939,
358,
272,
768,
2068,
360,
3174,
14,
6311,
63,
8421,
358,
272,
768,
2068,
360,
3174,
14,
873,
63,
1195,
63,
1725,
358,
272,
768,
2068,
360,
3174,
14,
3664,
1813,
358,
272,
347,
511,
63,
3174,
63,
973,
8,
277,
12,
946,
1805,
12,
7629,
1805,
12,
2467,
1805,
12,
366,
71,
1805,
12,
3384,
1805,
304,
267,
408,
267,
7523,
314,
5253,
15,
973,
1083,
365,
6358,
1006,
314,
21038,
3102,
14,
267,
408,
267,
3326,
275,
359,
267,
283,
3790,
598,
726,
47,
1387,
13043,
2647,
15,
1832,
15,
1939,
60,
78,
297,
267,
283,
3790,
15097,
28617,
3243,
26,
4,
39,
726,
47,
1387,
15,
1393,
60,
78,
297,
267,
283,
3790,
1804,
21857,
63,
25050,
63,
1772,
29,
16,
14,
16,
14,
16,
14,
16,
60,
78,
297,
267,
283,
3790,
1804,
2533,
540,
7278
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
6900,
710,
28723,
6642,
2900,
4481,
4644,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
1683,
492,
3371,
12,
4420,
12,
10079,
199,
504,
931,
492,
6912,
199,
646,
4613,
199,
646,
984,
199,
199,
3,
603,
16993,
314,
2366,
931,
880,
781,
883,
2342,
4154,
5759,
1233,
199,
68,
275,
6912,
10714,
493,
363,
1959,
1708,
14,
4832,
342,
1182,
283,
7922,
7,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
366,
14,
4832,
1012,
199,
199,
3,
3161,
314,
4621,
687,
314,
5759,
199,
646,
3907,
199,
199,
533,
1379,
8154,
8481,
837,
339,
768,
2068,
360,
3174,
14,
515,
358,
272,
347,
511,
63,
873,
63,
1195,
63,
1725,
8,
277,
12,
299,
1805,
304,
267,
408,
267,
1379,
394,
18869,
931,
641,
12928,
2589,
1584,
14,
10829,
12848,
8137,
267,
3495,
436,
365,
315,
4192,
14,
267,
408,
267,
299,
1805,
14,
1107,
63,
585,
14,
1278,
14,
1107,
63,
585,
275,
221,
788,
604,
17,
297,
283,
604,
18,
418,
267,
3907,
14,
873,
63,
1195,
63,
1725,
2941,
396,
17,
297,
283,
396,
18,
1105,
267,
299,
1805,
14,
1107,
63,
585,
14,
952,
63,
1278,
14,
479,
63,
3527,
63,
1045,
2941,
604,
17,
297,
283,
604,
18,
297,
15491,
283,
396,
17,
297,
283,
396,
18,
1105,
339,
347,
511,
63,
873,
63,
1195,
63,
1725,
63,
1045,
63,
3592,
88,
631,
867,
63,
515,
8,
277,
304,
267,
408,
267,
1379,
376,
625,
72,
18869,
931,
340,
314,
20387,
1195,
15,
3707,
886,
440,
2187,
14,
267,
408,
267,
543,
4613,
14,
3536,
8,
16719,
9,
465,
444,
815,
26,
288,
3907,
14,
873,
63,
1195,
63,
1725,
2941,
396,
17,
1673,
396,
18,
1105,
339,
768,
2068,
360,
3174,
14,
3535,
358,
272,
768,
2068,
360,
3174,
14,
3664,
1813,
358,
272,
347,
511,
63,
2491,
63,
23048,
8,
277,
12,
946,
1805,
12,
18133,
1805,
304,
267,
408,
267,
7635,
781,
787,
6358,
314,
6040,
22829,
1009,
83,
370,
1900,
436,
9560,
10188,
267,
1022,
456,
397,
14,
267,
408,
267,
24162,
275,
788,
1506,
13,
397,
2464,
1009,
297,
283,
3187,
297,
355,
283,
1875,
297,
283,
25826,
297,
283,
1548,
13,
9983,
418,
267,
3907,
14,
3174,
63,
5154,
342,
267,
946,
1805,
14,
793,
14,
479,
63,
3527,
63,
1045,
360,
31376,
30445,
6117,
358,
267,
18133,
1805,
14,
1541,
63,
7657,
63,
5154,
14,
479,
63,
3527,
63,
1045,
8,
16624,
9,
339,
768,
2068,
360,
3174,
14,
6404,
633,
14,
13042,
6417,
11135,
2461,
358,
272,
347,
511,
63,
1939,
63,
4249,
8,
277,
12,
282,
453,
766,
304,
267,
408,
288,
1379,
626,
781,
787,
5965,
4926,
316,
2331,
370,
1495,
77,
13,
7546,
370,
288,
5235,
282,
2488,
6359,
402,
3971,
14,
961,
365,
2222,
13,
888,
15684,
880,
288,
2399,
4499,
6665,
5048,
370,
5534,
781,
3984,
9995,
370,
3544,
886,
642,
12,
288,
436,
1380,
652,
4493,
781,
10989,
1094,
261,
314,
20611,
6215,
552,
16709,
402,
642,
511,
14,
267,
408,
267,
5261,
63,
1805,
275,
282,
453,
766,
14,
1107,
63,
585,
14,
3174,
267,
3907,
14,
4249,
63,
1939,
342,
267,
1166,
275,
283,
2859,
921,
3494,
14,
17533,
14,
957,
15,
71,
393,
621,
15,
1939,
17,
14,
20,
14,
18,
14,
5135,
13,
21778,
772,
14,
5369,
14,
6838,
7,
267,
7793,
17,
534,
21,
10173,
2756,
2635,
66,
2528,
66,
2182,
2055,
25,
66,
22,
70,
845,
68,
1400,
65,
1822,
69,
20,
28363,
1780,
66,
16,
9181,
7,
267,
5261,
63,
1805,
14,
479,
63,
3527,
63,
1045,
8,
633,
12,
1994,
2647,
15,
1832,
297,
7793,
17,
12,
283,
4835,
17,
358,
339,
768,
2068,
360,
3174,
14,
5781,
358,
272,
347,
511,
63,
6311,
63,
8421,
8,
277,
12,
2249,
1805,
304,
267,
408,
268,
2136,
3984,
440,
1808,
282,
4137,
13,
10453,
6135,
3555,
446,
880,
4868,
4154,
3873,
268,
1240,
365,
12137,
14,
982,
781,
1570,
642,
12,
781,
2934,
370,
5715,
781,
9064,
10529,
652,
14,
267,
408,
267,
3907,
14,
6311,
63,
8421,
342,
267,
3831,
275,
283,
2859,
921,
5031,
14,
957,
15,
13266,
9089,
10397,
15,
17422,
14,
3187,
7,
267,
4125,
275,
1994,
2992,
15,
17422,
7,
267,
2249,
1805,
14,
1074,
63,
1199,
14,
479,
63,
3527,
63,
1045,
2941,
3187,
297,
283,
6311,
297,
3831,
12,
4125,
566,
339,
768,
2068,
360,
3174,
14,
3174,
63,
5154,
358,
272,
768,
2068,
360,
3174,
14,
4249,
63,
1939,
358,
272,
768,
2068,
360,
3174,
14,
6311,
63,
8421,
358,
272,
768,
2068,
360,
3174,
14,
873,
63,
1195,
63,
1725,
358,
272,
768,
2068,
360,
3174,
14,
3664,
1813,
358,
272,
347,
511,
63,
3174,
63,
973,
8,
277,
12,
946,
1805,
12,
7629,
1805,
12,
2467,
1805,
12,
366,
71,
1805,
12,
3384,
1805,
304,
267,
408,
267,
7523,
314,
5253,
15,
973,
1083,
365,
6358,
1006,
314,
21038,
3102,
14,
267,
408,
267,
3326,
275,
359,
267,
283,
3790,
598,
726,
47,
1387,
13043,
2647,
15,
1832,
15,
1939,
60,
78,
297,
267,
283,
3790,
15097,
28617,
3243,
26,
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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
] |
Grk0/python-libconf
|
setup.py
|
1
|
1185
|
from setuptools import setup
setup(
name='libconf',
version='2.0.1',
description="A pure-Python libconfig reader/writer with permissive license",
long_description=open('README.rst').read(),
author="Christian Aichinger",
author_email="Greek0@gmx.net",
url='https://github.com/Grk0/python-libconf',
download_url='https://github.com/Grk0/python-libconf/tarball/2.0.1',
license="MIT",
py_modules=['libconf'],
keywords='libconfig configuration parser library',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
)
|
mit
|
[
504,
9116,
492,
3272,
199,
199,
2758,
8,
272,
536,
534,
773,
2190,
297,
272,
1015,
534,
18,
14,
16,
14,
17,
297,
272,
1369,
628,
33,
15111,
13,
4718,
1973,
888,
7002,
15,
5491,
543,
1126,
32237,
4190,
401,
272,
1846,
63,
1802,
29,
1490,
360,
18195,
14,
8332,
1959,
739,
1062,
272,
4132,
628,
1049,
18824,
5653,
437,
1158,
7886,
401,
272,
4132,
63,
2123,
628,
29480,
16,
32,
71,
9457,
14,
846,
401,
272,
1166,
534,
2859,
921,
5031,
14,
957,
15,
23765,
75,
16,
15,
1548,
13,
773,
2190,
297,
272,
5235,
63,
633,
534,
2859,
921,
5031,
14,
957,
15,
23765,
75,
16,
15,
1548,
13,
773,
2190,
15,
18829,
15,
18,
14,
16,
14,
17,
297,
272,
4190,
628,
13965,
401,
272,
1134,
63,
3112,
2968,
773,
2190,
995,
272,
7681,
534,
773,
888,
2897,
1798,
3555,
297,
272,
19137,
1524,
267,
283,
23753,
9795,
3800,
959,
446,
24114,
15,
933,
461,
297,
267,
283,
23910,
23975,
3800,
23493,
297,
267,
283,
12157,
3800,
2290,
15290,
3800,
31454,
3800,
2018,
18167,
297,
267,
283,
3761,
3800,
25718,
26330,
3800,
10697,
844,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
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,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
20,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
21,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
22,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
23,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
24,
297,
272,
2156,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
9116,
492,
3272,
199,
199,
2758,
8,
272,
536,
534,
773,
2190,
297,
272,
1015,
534,
18,
14,
16,
14,
17,
297,
272,
1369,
628,
33,
15111,
13,
4718,
1973,
888,
7002,
15,
5491,
543,
1126,
32237,
4190,
401,
272,
1846,
63,
1802,
29,
1490,
360,
18195,
14,
8332,
1959,
739,
1062,
272,
4132,
628,
1049,
18824,
5653,
437,
1158,
7886,
401,
272,
4132,
63,
2123,
628,
29480,
16,
32,
71,
9457,
14,
846,
401,
272,
1166,
534,
2859,
921,
5031,
14,
957,
15,
23765,
75,
16,
15,
1548,
13,
773,
2190,
297,
272,
5235,
63,
633,
534,
2859,
921,
5031,
14,
957,
15,
23765,
75,
16,
15,
1548,
13,
773,
2190,
15,
18829,
15,
18,
14,
16,
14,
17,
297,
272,
4190,
628,
13965,
401,
272,
1134,
63,
3112,
2968,
773,
2190,
995,
272,
7681,
534,
773,
888,
2897,
1798,
3555,
297,
272,
19137,
1524,
267,
283,
23753,
9795,
3800,
959,
446,
24114,
15,
933,
461,
297,
267,
283,
23910,
23975,
3800,
23493,
297,
267,
283,
12157,
3800,
2290,
15290,
3800,
31454,
3800,
2018,
18167,
297,
267,
283,
3761,
3800,
25718,
26330,
3800,
10697,
844,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
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,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
20,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
21,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
22,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
23,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
24,
297,
272,
2156,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
sensepost/Snoopy
|
snoopy/server/bin/snoopy/src/snoopy/db/models.py
|
4
|
3432
|
"""Contains all SQLAlchemy ORM models."""
from cryptacular import bcrypt
from sqlalchemy import Column
from sqlalchemy import Boolean, CHAR, DateTime, Integer, Numeric, SmallInteger, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
crypt = bcrypt.BCRYPTPasswordManager()
def hash_password(password):
return unicode(crypt.encode(password))
Session = None
Base = declarative_base()
##########
# MODELS #
##########
class Probe(Base):
__tablename__ = 'probes'
# COLUMNS #
# id = Column(Integer, primary_key=True)
monitor = Column('monitor_id', String(20, convert_unicode=True), default=None, primary_key=True)
device_mac = Column(CHAR(17), default=None, primary_key=True)
probe_ssid = Column(String(100, convert_unicode=True), default=None, primary_key=True)
signal_db = Column(Integer, default=None)
timestamp = Column(DateTime, default=None, primary_key=True)
run_id = Column(String(50), default=None)
location = Column(String(50), default=None)
proximity_session = Column(String(20), default=None)
class Cookie(Base):
__tablename__ = 'cookies'
# COLUMNS #
id = Column(Integer, primary_key=True)
device_mac = Column(CHAR(17), nullable=False, default='')
device_ip = Column(CHAR(15), default=None)
site = Column(String(256), nullable=False, default='')
cookie_name = Column(String(256), nullable=False, default='')
cookie_name = Column(String(4096), nullable=False, default='')
class GpsMovement(Base):
__tablename__ = 'gps_movement'
# COLUMNS #
monitor = Column('monitor_id', String(20, convert_unicode=True), default=None, primary_key=True)
run_id = Column(String(20), default=None)
timestamp = Column(Integer, nullable=False, default=0, primary_key=True)
gps_lat = Column(Numeric(8, 6))
gps_long = Column(Numeric(8, 6))
accuracy = Column(Numeric(8, 6))
class Wigle(Base):
__tablename__ = 'wigle'
# COLUMNS #
ssid = Column(String(100), default=None, primary_key=True)
gps_long = Column(Numeric(11, 8), default=None, primary_key=True)
gps_lat = Column(Numeric(11, 8), default=None, primary_key=True)
last_update = Column(DateTime, default=None)
mac = Column(CHAR(17), default=None)
overflow = Column(SmallInteger, default=None)
class User(Base):
__tablename__ = 'snoopy_user'
# COLUMNS #
id = Column(Integer, primary_key=True)
name = Column(String(255, convert_unicode=True), unique=True)
password_raw = Column('password', String(255, convert_unicode=True), nullable=False, default=u'')
is_admin = Column(Boolean, default=False, nullable=False)
@hybrid_property
def password(self):
return self.password_raw
@password.setter
def password(self, password):
if len(password) < 8:
raise ValueError('Password too short')
self.password_raw = hash_password(password)
# CLASS METHODS #
@classmethod
def check_password(cls, name, password):
user = Session().query(cls).filter_by(name=name).first()
if not user:
return None
return crypt.check(user.password, password) and user or None
# SPECIAL METHODS #
def __repr__(self):
admin = ''
if self.is_admin:
admin = '*'
return '<%s%s %d:%r>' % (admin, self.__class__.__name__, self.id, self.name)
|
mit
|
[
624,
6906,
1006,
14303,
23383,
1709,
1041,
199,
199,
504,
286,
651,
80,
27308,
2238,
492,
330,
4997,
199,
504,
8335,
492,
4996,
199,
504,
8335,
492,
9411,
12,
8518,
12,
13686,
12,
7225,
12,
19378,
12,
23704,
2674,
12,
2624,
199,
504,
8335,
14,
832,
14,
12164,
1905,
492,
30191,
63,
1095,
199,
504,
8335,
14,
832,
14,
27758,
492,
7188,
14601,
63,
1829,
421,
199,
4997,
275,
330,
4997,
14,
34,
19079,
6139,
2988,
342,
199,
199,
318,
2631,
63,
2060,
8,
2060,
304,
272,
372,
2649,
8,
4997,
14,
2143,
8,
2060,
430,
421,
199,
4434,
275,
488,
199,
1563,
275,
30191,
63,
1095,
342,
421,
199,
516,
309,
199,
3,
10362,
4424,
51,
327,
199,
516,
309,
199,
199,
533,
2165,
1235,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
6101,
397,
7,
339,
327,
26865,
2709,
327,
199,
3,
259,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
272,
8372,
275,
4996,
360,
7157,
63,
344,
297,
2624,
8,
1165,
12,
3957,
63,
2975,
29,
549,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
2243,
63,
3088,
275,
4996,
8,
5901,
8,
1196,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
22362,
63,
23283,
275,
4996,
8,
1558,
8,
1960,
12,
3957,
63,
2975,
29,
549,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
4673,
63,
697,
275,
4996,
8,
2674,
12,
849,
29,
403,
9,
272,
4913,
275,
4996,
8,
3926,
12,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
1255,
63,
344,
275,
4996,
8,
1558,
8,
1400,
395,
849,
29,
403,
9,
272,
2909,
275,
4996,
8,
1558,
8,
1400,
395,
849,
29,
403,
9,
272,
10645,
1017,
1209,
63,
1730,
275,
4996,
8,
1558,
8,
1165,
395,
849,
29,
403,
9,
421,
199,
533,
14798,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
7792,
7,
339,
327,
26865,
2709,
327,
272,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
272,
2243,
63,
3088,
275,
4996,
8,
5901,
8,
1196,
395,
7854,
29,
797,
12,
849,
13275,
272,
2243,
63,
711,
275,
4996,
8,
5901,
8,
1046,
395,
849,
29,
403,
9,
272,
4770,
275,
4996,
8,
1558,
8,
3912,
395,
7854,
29,
797,
12,
849,
13275,
272,
5494,
63,
354,
275,
4996,
8,
1558,
8,
3912,
395,
7854,
29,
797,
12,
849,
13275,
272,
5494,
63,
354,
275,
4996,
8,
1558,
8,
20579,
395,
7854,
29,
797,
12,
849,
13275,
421,
199,
533,
598,
1190,
10370,
434,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
25556,
63,
1185,
434,
7,
339,
327,
26865,
2709,
327,
272,
8372,
275,
4996,
360,
7157,
63,
344,
297,
2624,
8,
1165,
12,
3957,
63,
2975,
29,
549,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
1255,
63,
344,
275,
4996,
8,
1558,
8,
1165,
395,
849,
29,
403,
9,
272,
4913,
275,
4996,
8,
2674,
12,
7854,
29,
797,
12,
849,
29,
16,
12,
5062,
63,
498,
29,
549,
9,
272,
486,
1190,
63,
4452,
275,
4996,
8,
14687,
8,
24,
12,
1227,
430,
272,
486,
1190,
63,
2809,
275,
4996,
8,
14687,
8,
24,
12,
1227,
430,
272,
12862,
275,
4996,
8,
14687,
8,
24,
12,
1227,
430,
421,
199,
533,
644,
528,
274,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
87,
528,
274,
7,
339,
327,
26865,
2709,
327,
272,
25891,
275,
4996,
8,
1558,
8,
1960,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
486,
1190,
63,
2809,
275,
4996,
8,
14687,
8,
845,
12,
1695,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
486,
1190,
63,
4452,
275,
4996,
8,
14687,
8,
845,
12,
1695,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
2061,
63,
873,
275,
4996,
8,
3926,
12,
849,
29,
403,
9,
272,
4497,
275,
4996,
8,
5901,
8,
1196,
395,
849,
29,
403,
9,
272,
15784,
275,
4996,
8,
10712,
2674,
12,
849,
29,
403,
9,
421,
199,
533,
2876,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
83,
889,
927,
63,
751,
7,
339,
327,
26865,
2709,
327,
272,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
272,
536,
275,
4996,
8,
1558,
8,
2299,
12,
3957,
63,
2975,
29,
549,
395,
3747,
29,
549,
9,
272,
2505,
63,
1773,
275,
4996,
360,
2060,
297,
2624,
8,
2299,
12,
3957,
63,
2975,
29,
549,
395,
7854,
29,
797,
12,
849,
29,
85,
17483,
272,
365,
63,
2113,
275,
4996,
8,
4082,
12,
849,
29,
797,
12,
7854,
29,
797,
9,
339,
768,
27758,
63,
1829,
272,
347,
2505,
8,
277,
304,
267,
372,
291,
14,
2060,
63,
1773,
339,
768,
2060,
14,
8345,
272,
347,
2505,
8,
277,
12,
2505,
304,
267,
340,
822,
8,
2060,
9,
665,
1695,
26,
288,
746,
1722,
360,
6139,
4634,
3974,
358,
267,
291,
14,
2060,
63,
1773,
275,
2631,
63,
2060,
8,
2060,
9,
339,
327,
24221,
27411,
3177,
327,
272,
768,
3744,
272,
347,
1104,
63,
2060,
8,
1886,
12,
536,
12,
2505,
304,
267,
922,
275,
8596,
1252,
1131,
8,
1886,
680,
1541,
63,
991,
8,
354,
29,
354,
680,
2246,
342,
267,
340,
440,
922,
26,
288,
372,
488,
267,
372,
21570,
14,
1074,
8,
751,
14,
2060,
12,
2505,
9,
436,
922,
503,
488,
339,
327,
8820,
27411,
3177,
327,
272,
347,
636,
2722,
721,
277,
304,
267,
4628,
275,
2125,
267,
340,
291,
14,
374,
63,
2113,
26,
288,
4628,
275,
13626,
267,
372,
18342,
83,
5,
83,
450,
68,
2689,
82,
3524,
450,
334,
2113,
12,
291,
855,
533,
4914,
354,
3108,
291,
14,
344,
12,
291,
14,
354,
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
] |
[
6906,
1006,
14303,
23383,
1709,
1041,
199,
199,
504,
286,
651,
80,
27308,
2238,
492,
330,
4997,
199,
504,
8335,
492,
4996,
199,
504,
8335,
492,
9411,
12,
8518,
12,
13686,
12,
7225,
12,
19378,
12,
23704,
2674,
12,
2624,
199,
504,
8335,
14,
832,
14,
12164,
1905,
492,
30191,
63,
1095,
199,
504,
8335,
14,
832,
14,
27758,
492,
7188,
14601,
63,
1829,
421,
199,
4997,
275,
330,
4997,
14,
34,
19079,
6139,
2988,
342,
199,
199,
318,
2631,
63,
2060,
8,
2060,
304,
272,
372,
2649,
8,
4997,
14,
2143,
8,
2060,
430,
421,
199,
4434,
275,
488,
199,
1563,
275,
30191,
63,
1095,
342,
421,
199,
516,
309,
199,
3,
10362,
4424,
51,
327,
199,
516,
309,
199,
199,
533,
2165,
1235,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
6101,
397,
7,
339,
327,
26865,
2709,
327,
199,
3,
259,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
272,
8372,
275,
4996,
360,
7157,
63,
344,
297,
2624,
8,
1165,
12,
3957,
63,
2975,
29,
549,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
2243,
63,
3088,
275,
4996,
8,
5901,
8,
1196,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
22362,
63,
23283,
275,
4996,
8,
1558,
8,
1960,
12,
3957,
63,
2975,
29,
549,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
4673,
63,
697,
275,
4996,
8,
2674,
12,
849,
29,
403,
9,
272,
4913,
275,
4996,
8,
3926,
12,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
1255,
63,
344,
275,
4996,
8,
1558,
8,
1400,
395,
849,
29,
403,
9,
272,
2909,
275,
4996,
8,
1558,
8,
1400,
395,
849,
29,
403,
9,
272,
10645,
1017,
1209,
63,
1730,
275,
4996,
8,
1558,
8,
1165,
395,
849,
29,
403,
9,
421,
199,
533,
14798,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
7792,
7,
339,
327,
26865,
2709,
327,
272,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
272,
2243,
63,
3088,
275,
4996,
8,
5901,
8,
1196,
395,
7854,
29,
797,
12,
849,
13275,
272,
2243,
63,
711,
275,
4996,
8,
5901,
8,
1046,
395,
849,
29,
403,
9,
272,
4770,
275,
4996,
8,
1558,
8,
3912,
395,
7854,
29,
797,
12,
849,
13275,
272,
5494,
63,
354,
275,
4996,
8,
1558,
8,
3912,
395,
7854,
29,
797,
12,
849,
13275,
272,
5494,
63,
354,
275,
4996,
8,
1558,
8,
20579,
395,
7854,
29,
797,
12,
849,
13275,
421,
199,
533,
598,
1190,
10370,
434,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
25556,
63,
1185,
434,
7,
339,
327,
26865,
2709,
327,
272,
8372,
275,
4996,
360,
7157,
63,
344,
297,
2624,
8,
1165,
12,
3957,
63,
2975,
29,
549,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
1255,
63,
344,
275,
4996,
8,
1558,
8,
1165,
395,
849,
29,
403,
9,
272,
4913,
275,
4996,
8,
2674,
12,
7854,
29,
797,
12,
849,
29,
16,
12,
5062,
63,
498,
29,
549,
9,
272,
486,
1190,
63,
4452,
275,
4996,
8,
14687,
8,
24,
12,
1227,
430,
272,
486,
1190,
63,
2809,
275,
4996,
8,
14687,
8,
24,
12,
1227,
430,
272,
12862,
275,
4996,
8,
14687,
8,
24,
12,
1227,
430,
421,
199,
533,
644,
528,
274,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
87,
528,
274,
7,
339,
327,
26865,
2709,
327,
272,
25891,
275,
4996,
8,
1558,
8,
1960,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
486,
1190,
63,
2809,
275,
4996,
8,
14687,
8,
845,
12,
1695,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
486,
1190,
63,
4452,
275,
4996,
8,
14687,
8,
845,
12,
1695,
395,
849,
29,
403,
12,
5062,
63,
498,
29,
549,
9,
272,
2061,
63,
873,
275,
4996,
8,
3926,
12,
849,
29,
403,
9,
272,
4497,
275,
4996,
8,
5901,
8,
1196,
395,
849,
29,
403,
9,
272,
15784,
275,
4996,
8,
10712,
2674,
12,
849,
29,
403,
9,
421,
199,
533,
2876,
8,
1563,
304,
272,
636,
10983,
363,
275,
283,
83,
889,
927,
63,
751,
7,
339,
327,
26865,
2709,
327,
272,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
272,
536,
275,
4996,
8,
1558,
8,
2299,
12,
3957,
63,
2975,
29,
549,
395,
3747,
29,
549,
9,
272,
2505,
63,
1773,
275,
4996,
360,
2060,
297,
2624,
8,
2299,
12,
3957,
63,
2975,
29,
549,
395,
7854,
29,
797,
12,
849,
29,
85,
17483,
272,
365,
63,
2113,
275,
4996,
8,
4082,
12,
849,
29,
797,
12,
7854,
29,
797,
9,
339,
768,
27758,
63,
1829,
272,
347,
2505,
8,
277,
304,
267,
372,
291,
14,
2060,
63,
1773,
339,
768,
2060,
14,
8345,
272,
347,
2505,
8,
277,
12,
2505,
304,
267,
340,
822,
8,
2060,
9,
665,
1695,
26,
288,
746,
1722,
360,
6139,
4634,
3974,
358,
267,
291,
14,
2060,
63,
1773,
275,
2631,
63,
2060,
8,
2060,
9,
339,
327,
24221,
27411,
3177,
327,
272,
768,
3744,
272,
347,
1104,
63,
2060,
8,
1886,
12,
536,
12,
2505,
304,
267,
922,
275,
8596,
1252,
1131,
8,
1886,
680,
1541,
63,
991,
8,
354,
29,
354,
680,
2246,
342,
267,
340,
440,
922,
26,
288,
372,
488,
267,
372,
21570,
14,
1074,
8,
751,
14,
2060,
12,
2505,
9,
436,
922,
503,
488,
339,
327,
8820,
27411,
3177,
327,
272,
347,
636,
2722,
721,
277,
304,
267,
4628,
275,
2125,
267,
340,
291,
14,
374,
63,
2113,
26,
288,
4628,
275,
13626,
267,
372,
18342,
83,
5,
83,
450,
68,
2689,
82,
3524,
450,
334,
2113,
12,
291,
855,
533,
4914,
354,
3108,
291,
14,
344,
12,
291,
14,
354,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
40223117cda/cda
|
static/Brython3.1.1-20150328-091302/Lib/_thread.py
|
740
|
4879
|
"""Drop-in replacement for the thread module.
Meant to be used as a brain-dead substitute so that threaded code does
not need to be rewritten for when the thread module is not present.
Suggested usage is::
try:
import _thread
except ImportError:
import _dummy_thread as _thread
"""
# Exports only things specified by thread documentation;
# skipping obsolete synonyms allocate(), start_new(), exit_thread().
__all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock',
'interrupt_main', 'LockType']
# A dummy value
TIMEOUT_MAX = 2**31
# NOTE: this module can be imported early in the extension building process,
# and so top level imports of other modules should be avoided. Instead, all
# imports are done when needed on a function-by-function basis. Since threads
# are disabled, the import lock should not be an issue anyway (??).
error = RuntimeError
def start_new_thread(function, args, kwargs={}):
"""Dummy implementation of _thread.start_new_thread().
Compatibility is maintained by making sure that ``args`` is a
tuple and ``kwargs`` is a dictionary. If an exception is raised
and it is SystemExit (which can be done by _thread.exit()) it is
caught and nothing is done; all other exceptions are printed out
by using traceback.print_exc().
If the executed function calls interrupt_main the KeyboardInterrupt will be
raised when the function returns.
"""
if type(args) != type(tuple()):
raise TypeError("2nd arg must be a tuple")
if type(kwargs) != type(dict()):
raise TypeError("3rd arg must be a dict")
global _main
_main = False
try:
function(*args, **kwargs)
except SystemExit:
pass
except:
import traceback
traceback.print_exc()
_main = True
global _interrupt
if _interrupt:
_interrupt = False
raise KeyboardInterrupt
def exit():
"""Dummy implementation of _thread.exit()."""
raise SystemExit
def get_ident():
"""Dummy implementation of _thread.get_ident().
Since this module should only be used when _threadmodule is not
available, it is safe to assume that the current process is the
only thread. Thus a constant can be safely returned.
"""
return -1
def allocate_lock():
"""Dummy implementation of _thread.allocate_lock()."""
return LockType()
def stack_size(size=None):
"""Dummy implementation of _thread.stack_size()."""
if size is not None:
raise error("setting thread stack size not supported")
return 0
class LockType(object):
"""Class implementing dummy implementation of _thread.LockType.
Compatibility is maintained by maintaining self.locked_status
which is a boolean that stores the state of the lock. Pickling of
the lock, though, should not be done since if the _thread module is
then used with an unpickled ``lock()`` from here problems could
occur from this class not having atomic methods.
"""
def __init__(self):
self.locked_status = False
def acquire(self, waitflag=None, timeout=-1):
"""Dummy implementation of acquire().
For blocking calls, self.locked_status is automatically set to
True and returned appropriately based on value of
``waitflag``. If it is non-blocking, then the value is
actually checked and not set if it is already acquired. This
is all done so that threading.Condition's assert statements
aren't triggered and throw a little fit.
"""
if waitflag is None or waitflag:
self.locked_status = True
return True
else:
if not self.locked_status:
self.locked_status = True
return True
else:
if timeout > 0:
import time
time.sleep(timeout)
return False
__enter__ = acquire
def __exit__(self, typ, val, tb):
self.release()
def release(self):
"""Release the dummy lock."""
# XXX Perhaps shouldn't actually bother to test? Could lead
# to problems for complex, threaded code.
if not self.locked_status:
raise error
self.locked_status = False
return True
def locked(self):
return self.locked_status
# Used to signal that interrupt_main was called in a "thread"
_interrupt = False
# True when not executing in a "thread"
_main = True
def interrupt_main():
"""Set _interrupt flag to True to have start_new_thread raise
KeyboardInterrupt upon exiting."""
if _main:
raise KeyboardInterrupt
else:
global _interrupt
_interrupt = True
# Brython-specific to avoid circular references between threading and _threading_local
class _local:
pass
|
gpl-3.0
|
[
624,
11070,
13,
262,
8343,
367,
314,
2462,
859,
14,
199,
199,
1352,
867,
370,
506,
1202,
465,
282,
330,
6322,
13,
10957,
23080,
880,
626,
25396,
1233,
1630,
199,
1397,
1929,
370,
506,
28286,
367,
1380,
314,
2462,
859,
365,
440,
3451,
14,
199,
199,
51,
17417,
4503,
365,
447,
339,
862,
26,
267,
492,
485,
2671,
272,
871,
3545,
26,
267,
492,
485,
5869,
63,
2671,
465,
485,
2671,
199,
199,
624,
199,
3,
1316,
5203,
1454,
7645,
2013,
701,
2462,
3794,
27,
199,
3,
16068,
24985,
9560,
5220,
706,
18310,
1062,
1343,
63,
1222,
1062,
4458,
63,
2671,
1252,
199,
363,
452,
363,
275,
788,
705,
297,
283,
928,
63,
1222,
63,
2671,
297,
283,
2224,
297,
283,
362,
63,
5425,
297,
283,
12991,
63,
831,
297,
1779,
283,
20172,
63,
973,
297,
283,
6432,
804,
418,
199,
199,
3,
437,
7283,
574,
199,
8899,
63,
4283,
275,
499,
538,
2192,
199,
199,
3,
6944,
26,
642,
859,
883,
506,
8439,
14670,
315,
314,
3329,
10015,
2112,
12,
199,
3,
436,
880,
2746,
2166,
8925,
402,
1163,
4621,
1077,
506,
2289,
16142,
770,
14,
221,
15345,
12,
1006,
199,
3,
8925,
787,
4224,
1380,
4346,
641,
282,
805,
13,
991,
13,
1593,
5597,
14,
221,
9336,
7183,
199,
3,
787,
6980,
12,
314,
492,
4650,
1077,
440,
506,
376,
4976,
15988,
7558,
31,
680,
199,
199,
705,
275,
6064,
199,
199,
318,
1343,
63,
1222,
63,
2671,
8,
1593,
12,
1249,
12,
2074,
16420,
272,
408,
11324,
4514,
402,
485,
2671,
14,
928,
63,
1222,
63,
2671,
1252,
339,
3599,
5880,
365,
26391,
701,
10663,
3238,
626,
1124,
589,
1040,
365,
282,
272,
2008,
436,
1124,
958,
1040,
365,
282,
2600,
14,
221,
982,
376,
1919,
365,
4915,
272,
436,
652,
365,
14838,
334,
6777,
883,
506,
4224,
701,
485,
2671,
14,
2224,
1012,
652,
365,
272,
15604,
436,
6548,
365,
4224,
27,
1006,
1163,
4967,
787,
12487,
734,
272,
701,
1808,
5190,
14,
1361,
63,
2804,
1252,
339,
982,
314,
7934,
805,
4882,
26791,
63,
973,
314,
13483,
911,
506,
272,
4915,
1380,
314,
805,
2529,
14,
339,
408,
272,
340,
730,
8,
589,
9,
1137,
730,
8,
2960,
5109,
267,
746,
3146,
480,
18,
977,
1680,
1471,
506,
282,
2008,
531,
272,
340,
730,
8,
958,
9,
1137,
730,
8,
807,
5109,
267,
746,
3146,
480,
19,
6883,
1680,
1471,
506,
282,
1211,
531,
272,
2288,
485,
973,
272,
485,
973,
275,
756,
272,
862,
26,
267,
805,
2031,
589,
12,
1011,
958,
9,
272,
871,
14838,
26,
267,
986,
272,
871,
26,
267,
492,
5190,
267,
5190,
14,
1361,
63,
2804,
342,
272,
485,
973,
275,
715,
272,
2288,
485,
20172,
272,
340,
485,
20172,
26,
267,
485,
20172,
275,
756,
267,
746,
13483,
199,
199,
318,
4458,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
2224,
20693,
272,
746,
14838,
199,
199,
318,
664,
63,
5425,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
362,
63,
5425,
1252,
339,
9336,
642,
859,
1077,
1454,
506,
1202,
1380,
485,
2671,
578,
365,
440,
272,
2808,
12,
652,
365,
5048,
370,
5534,
626,
314,
1453,
2112,
365,
314,
272,
1454,
2462,
14,
221,
20227,
282,
4413,
883,
506,
19353,
2138,
14,
272,
408,
272,
372,
446,
17,
199,
199,
318,
18310,
63,
831,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
12991,
63,
831,
20693,
272,
372,
15536,
804,
342,
199,
199,
318,
3464,
63,
890,
8,
890,
29,
403,
304,
272,
408,
11324,
4514,
402,
485,
2671,
14,
2340,
63,
890,
20693,
272,
340,
1568,
365,
440,
488,
26,
267,
746,
1125,
480,
6031,
2462,
3464,
1568,
440,
3748,
531,
272,
372,
378,
199,
199,
533,
15536,
804,
8,
785,
304,
272,
408,
2543,
18234,
7283,
4514,
402,
485,
2671,
14,
6432,
804,
14,
339,
3599,
5880,
365,
26391,
701,
11075,
316,
291,
14,
9325,
63,
1205,
272,
1314,
365,
282,
5046,
626,
14086,
314,
1174,
402,
314,
4650,
14,
221,
16568,
2983,
402,
272,
314,
4650,
12,
10617,
12,
1077,
440,
506,
4224,
3967,
340,
314,
485,
2671,
859,
365,
272,
2066,
1202,
543,
376,
625,
20428,
1124,
831,
8497,
687,
2348,
8826,
4293,
272,
4781,
687,
642,
1021,
440,
9445,
15374,
3102,
14,
339,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
9325,
63,
1205,
275,
756,
339,
347,
16919,
8,
277,
12,
3618,
4173,
29,
403,
12,
2653,
4022,
17,
304,
267,
408,
11324,
4514,
402,
16919,
1252,
398,
2104,
14592,
4882,
12,
291,
14,
9325,
63,
1205,
365,
5847,
663,
370,
267,
715,
436,
2138,
22497,
4079,
641,
574,
402,
267,
1124,
2573,
4173,
4345,
221,
982,
652,
365,
2222,
13,
13091,
12,
2066,
314,
574,
365,
267,
5965,
7923,
436,
440,
663,
340,
652,
365,
2575,
28320,
14,
221,
961,
267,
365,
1006,
4224,
880,
626,
5796,
14,
9558,
1159,
702,
9834,
267,
10621,
1133,
15572,
436,
7978,
282,
12050,
5542,
14,
398,
408,
267,
340,
3618,
4173,
365,
488,
503,
3618,
4173,
26,
288,
291,
14,
9325,
63,
1205,
275,
715,
288,
372,
715,
267,
587,
26,
288,
340,
440,
291,
14,
9325,
63,
1205,
26,
355,
291,
14,
9325,
63,
1205,
275,
715,
355,
372,
715,
288,
587,
26,
355,
340,
2653,
690,
378,
26,
490,
492,
900,
490,
900,
14,
4532,
8,
2593,
9,
355,
372,
756,
339,
636,
4200,
363,
275,
16919,
339,
347,
636,
2224,
721,
277,
12,
6211,
12,
1139,
12,
7070,
304,
267,
291,
14,
3221,
342,
339,
347,
4683,
8,
277,
304,
267,
408,
9625,
314,
7283,
4650,
1041,
267,
327,
5787,
3492,
17396,
9296,
1133,
5965,
26962,
370,
511,
31,
221,
18615,
12690,
267,
327,
258,
370,
8826,
367,
6114,
12,
25396,
1233,
14,
267,
340,
440,
291,
14,
9325,
63,
1205,
26,
288,
746,
1125,
267,
291,
14,
9325,
63,
1205,
275,
756,
267,
372,
715,
339,
347,
14233,
8,
277,
304,
267,
372,
291,
14,
9325,
63,
1205,
199,
199,
3,
8051,
370,
4673,
626,
26791,
63,
973,
1990,
2797,
315,
282,
298,
2671,
2,
199,
63,
20172,
275,
756,
199,
3,
715,
1380,
440,
14043,
315,
282,
298,
2671,
2,
199,
63,
973,
275,
715
] |
[
11070,
13,
262,
8343,
367,
314,
2462,
859,
14,
199,
199,
1352,
867,
370,
506,
1202,
465,
282,
330,
6322,
13,
10957,
23080,
880,
626,
25396,
1233,
1630,
199,
1397,
1929,
370,
506,
28286,
367,
1380,
314,
2462,
859,
365,
440,
3451,
14,
199,
199,
51,
17417,
4503,
365,
447,
339,
862,
26,
267,
492,
485,
2671,
272,
871,
3545,
26,
267,
492,
485,
5869,
63,
2671,
465,
485,
2671,
199,
199,
624,
199,
3,
1316,
5203,
1454,
7645,
2013,
701,
2462,
3794,
27,
199,
3,
16068,
24985,
9560,
5220,
706,
18310,
1062,
1343,
63,
1222,
1062,
4458,
63,
2671,
1252,
199,
363,
452,
363,
275,
788,
705,
297,
283,
928,
63,
1222,
63,
2671,
297,
283,
2224,
297,
283,
362,
63,
5425,
297,
283,
12991,
63,
831,
297,
1779,
283,
20172,
63,
973,
297,
283,
6432,
804,
418,
199,
199,
3,
437,
7283,
574,
199,
8899,
63,
4283,
275,
499,
538,
2192,
199,
199,
3,
6944,
26,
642,
859,
883,
506,
8439,
14670,
315,
314,
3329,
10015,
2112,
12,
199,
3,
436,
880,
2746,
2166,
8925,
402,
1163,
4621,
1077,
506,
2289,
16142,
770,
14,
221,
15345,
12,
1006,
199,
3,
8925,
787,
4224,
1380,
4346,
641,
282,
805,
13,
991,
13,
1593,
5597,
14,
221,
9336,
7183,
199,
3,
787,
6980,
12,
314,
492,
4650,
1077,
440,
506,
376,
4976,
15988,
7558,
31,
680,
199,
199,
705,
275,
6064,
199,
199,
318,
1343,
63,
1222,
63,
2671,
8,
1593,
12,
1249,
12,
2074,
16420,
272,
408,
11324,
4514,
402,
485,
2671,
14,
928,
63,
1222,
63,
2671,
1252,
339,
3599,
5880,
365,
26391,
701,
10663,
3238,
626,
1124,
589,
1040,
365,
282,
272,
2008,
436,
1124,
958,
1040,
365,
282,
2600,
14,
221,
982,
376,
1919,
365,
4915,
272,
436,
652,
365,
14838,
334,
6777,
883,
506,
4224,
701,
485,
2671,
14,
2224,
1012,
652,
365,
272,
15604,
436,
6548,
365,
4224,
27,
1006,
1163,
4967,
787,
12487,
734,
272,
701,
1808,
5190,
14,
1361,
63,
2804,
1252,
339,
982,
314,
7934,
805,
4882,
26791,
63,
973,
314,
13483,
911,
506,
272,
4915,
1380,
314,
805,
2529,
14,
339,
408,
272,
340,
730,
8,
589,
9,
1137,
730,
8,
2960,
5109,
267,
746,
3146,
480,
18,
977,
1680,
1471,
506,
282,
2008,
531,
272,
340,
730,
8,
958,
9,
1137,
730,
8,
807,
5109,
267,
746,
3146,
480,
19,
6883,
1680,
1471,
506,
282,
1211,
531,
272,
2288,
485,
973,
272,
485,
973,
275,
756,
272,
862,
26,
267,
805,
2031,
589,
12,
1011,
958,
9,
272,
871,
14838,
26,
267,
986,
272,
871,
26,
267,
492,
5190,
267,
5190,
14,
1361,
63,
2804,
342,
272,
485,
973,
275,
715,
272,
2288,
485,
20172,
272,
340,
485,
20172,
26,
267,
485,
20172,
275,
756,
267,
746,
13483,
199,
199,
318,
4458,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
2224,
20693,
272,
746,
14838,
199,
199,
318,
664,
63,
5425,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
362,
63,
5425,
1252,
339,
9336,
642,
859,
1077,
1454,
506,
1202,
1380,
485,
2671,
578,
365,
440,
272,
2808,
12,
652,
365,
5048,
370,
5534,
626,
314,
1453,
2112,
365,
314,
272,
1454,
2462,
14,
221,
20227,
282,
4413,
883,
506,
19353,
2138,
14,
272,
408,
272,
372,
446,
17,
199,
199,
318,
18310,
63,
831,
837,
272,
408,
11324,
4514,
402,
485,
2671,
14,
12991,
63,
831,
20693,
272,
372,
15536,
804,
342,
199,
199,
318,
3464,
63,
890,
8,
890,
29,
403,
304,
272,
408,
11324,
4514,
402,
485,
2671,
14,
2340,
63,
890,
20693,
272,
340,
1568,
365,
440,
488,
26,
267,
746,
1125,
480,
6031,
2462,
3464,
1568,
440,
3748,
531,
272,
372,
378,
199,
199,
533,
15536,
804,
8,
785,
304,
272,
408,
2543,
18234,
7283,
4514,
402,
485,
2671,
14,
6432,
804,
14,
339,
3599,
5880,
365,
26391,
701,
11075,
316,
291,
14,
9325,
63,
1205,
272,
1314,
365,
282,
5046,
626,
14086,
314,
1174,
402,
314,
4650,
14,
221,
16568,
2983,
402,
272,
314,
4650,
12,
10617,
12,
1077,
440,
506,
4224,
3967,
340,
314,
485,
2671,
859,
365,
272,
2066,
1202,
543,
376,
625,
20428,
1124,
831,
8497,
687,
2348,
8826,
4293,
272,
4781,
687,
642,
1021,
440,
9445,
15374,
3102,
14,
339,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
9325,
63,
1205,
275,
756,
339,
347,
16919,
8,
277,
12,
3618,
4173,
29,
403,
12,
2653,
4022,
17,
304,
267,
408,
11324,
4514,
402,
16919,
1252,
398,
2104,
14592,
4882,
12,
291,
14,
9325,
63,
1205,
365,
5847,
663,
370,
267,
715,
436,
2138,
22497,
4079,
641,
574,
402,
267,
1124,
2573,
4173,
4345,
221,
982,
652,
365,
2222,
13,
13091,
12,
2066,
314,
574,
365,
267,
5965,
7923,
436,
440,
663,
340,
652,
365,
2575,
28320,
14,
221,
961,
267,
365,
1006,
4224,
880,
626,
5796,
14,
9558,
1159,
702,
9834,
267,
10621,
1133,
15572,
436,
7978,
282,
12050,
5542,
14,
398,
408,
267,
340,
3618,
4173,
365,
488,
503,
3618,
4173,
26,
288,
291,
14,
9325,
63,
1205,
275,
715,
288,
372,
715,
267,
587,
26,
288,
340,
440,
291,
14,
9325,
63,
1205,
26,
355,
291,
14,
9325,
63,
1205,
275,
715,
355,
372,
715,
288,
587,
26,
355,
340,
2653,
690,
378,
26,
490,
492,
900,
490,
900,
14,
4532,
8,
2593,
9,
355,
372,
756,
339,
636,
4200,
363,
275,
16919,
339,
347,
636,
2224,
721,
277,
12,
6211,
12,
1139,
12,
7070,
304,
267,
291,
14,
3221,
342,
339,
347,
4683,
8,
277,
304,
267,
408,
9625,
314,
7283,
4650,
1041,
267,
327,
5787,
3492,
17396,
9296,
1133,
5965,
26962,
370,
511,
31,
221,
18615,
12690,
267,
327,
258,
370,
8826,
367,
6114,
12,
25396,
1233,
14,
267,
340,
440,
291,
14,
9325,
63,
1205,
26,
288,
746,
1125,
267,
291,
14,
9325,
63,
1205,
275,
756,
267,
372,
715,
339,
347,
14233,
8,
277,
304,
267,
372,
291,
14,
9325,
63,
1205,
199,
199,
3,
8051,
370,
4673,
626,
26791,
63,
973,
1990,
2797,
315,
282,
298,
2671,
2,
199,
63,
20172,
275,
756,
199,
3,
715,
1380,
440,
14043,
315,
282,
298,
2671,
2,
199,
63,
973,
275,
715,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
B-MOOC/configuration
|
playbooks/roles/gh_mirror/files/repos_from_orgs.py
|
79
|
3314
|
#!/usr/bin/python
# Given a list of repos in a yaml
# file will create or update mirrors
#
# Generates /var/tmp/repos.json from
# a yaml file containing a list of
# github organizations
import yaml
import sys
import requests
import json
import subprocess
import os
import logging
import fcntl
from os.path import dirname, abspath, join
from argparse import ArgumentParser
def check_running(run_type=''):
pid_file = '{}-{}.pid'.format(
os.path.basename(__file__),run_type)
fp = open(pid_file, 'w')
try:
fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
# another instance is running
sys.exit(0)
def run_cmd(cmd):
logging.debug('running: {}\n'.format(cmd))
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=True)
for line in iter(process.stdout.readline, ""):
logging.debug(line)
def parse_args():
parser = ArgumentParser()
parser.add_argument('-r', '--refresh', action='store_true',
help="Refresh the list of repos", default=False)
parser.add_argument('-d', '--datadir', help="repo directory")
return parser.parse_args()
def refresh_cache():
path = dirname(abspath(__file__))
try:
with open(join(path, 'orgs.yml')) as f:
orgs = yaml.load(f)
except IOError:
print "Unable to read {}/orgs.yml, does it exist?".format(path)
sys.exit(1)
repos = []
for org in orgs:
page = 1
while True:
r = requests.get('https://api.github.com/users/{}/repos?page={}'.format(org, page))
org_data = r.json()
# request pages until we get zero results
if not isinstance(org_data, list) or len(org_data) == 0:
break
for repo_data in org_data:
if 'html_url' in repo_data:
repos.append({'html_url': repo_data['html_url'],
'name': repo_data['name'],
'org': repo_data['owner']['login']})
page += 1
with open('/var/tmp/repos.json', 'wb') as f:
f.write(json.dumps(repos))
def update_repos():
with open('/var/tmp/repos.json') as f:
repos = json.load(f)
for repo in repos:
repo_path = os.path.join(args.datadir, repo['org'], repo['name'] + '.git')
if not os.path.exists(repo_path):
run_cmd('mkdir -p {}'.format(repo_path))
run_cmd('git clone --mirror {} {}'.format(repo['html_url'], repo_path))
run_cmd('cd {} && git update-server-info'.format(repo_path))
else:
run_cmd('cd {} && git fetch --all --tags'.format(repo_path))
run_cmd('cd {} && git update-server-info'.format(repo_path))
if __name__ == '__main__':
args = parse_args()
logging.basicConfig(filename='/var/log/repos-from-orgs.log',
level=logging.DEBUG)
if args.refresh:
check_running('refresh')
refresh_cache()
else:
check_running()
if not args.datadir:
print "Please specificy a repository directory"
sys.exit(1)
if not os.path.exists('/var/tmp/repos.json'):
refresh_cache()
update_repos()
|
agpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
257,
9138,
282,
769,
402,
20416,
315,
282,
8864,
199,
3,
257,
570,
911,
1218,
503,
1678,
15216,
83,
199,
3,
199,
3,
257,
21687,
1182,
1391,
15,
2791,
15,
11857,
14,
1001,
687,
199,
3,
257,
282,
8864,
570,
3035,
282,
769,
402,
199,
3,
257,
12869,
20765,
12270,
199,
199,
646,
8864,
199,
646,
984,
199,
646,
4145,
199,
646,
2022,
199,
646,
3873,
199,
646,
747,
199,
646,
2050,
199,
646,
12871,
199,
504,
747,
14,
515,
492,
9017,
12,
19529,
12,
4263,
199,
504,
7534,
492,
27615,
199,
199,
318,
1104,
63,
5720,
8,
1065,
63,
466,
9280,
339,
4422,
63,
493,
275,
9005,
13,
31270,
3150,
1370,
908,
8,
267,
747,
14,
515,
14,
4846,
3460,
493,
10139,
1065,
63,
466,
9,
272,
4090,
275,
1551,
8,
3150,
63,
493,
12,
283,
87,
358,
272,
862,
26,
267,
12871,
14,
831,
70,
8,
3997,
12,
12871,
14,
4406,
63,
1438,
1204,
12871,
14,
4406,
63,
16170,
9,
272,
871,
5925,
26,
267,
327,
4573,
1256,
365,
3879,
267,
984,
14,
2224,
8,
16,
9,
199,
199,
318,
1255,
63,
1760,
8,
1760,
304,
272,
2050,
14,
1757,
360,
5720,
26,
22902,
78,
1370,
908,
8,
1760,
430,
272,
2112,
275,
3873,
14,
7942,
8,
267,
2088,
12,
3839,
29,
5781,
14,
6089,
12,
4635,
29,
5781,
14,
6089,
12,
267,
5218,
29,
549,
9,
272,
367,
1004,
315,
2740,
8,
1412,
14,
2703,
14,
6407,
12,
26430,
267,
2050,
14,
1757,
8,
604,
9,
421,
199,
318,
2198,
63,
589,
837,
272,
1798,
275,
27615,
342,
272,
1798,
14,
525,
63,
2094,
3654,
82,
297,
2850,
6635,
297,
1595,
534,
1617,
63,
2052,
297,
717,
1720,
628,
18730,
314,
769,
402,
20416,
401,
849,
29,
797,
9,
272,
1798,
14,
525,
63,
2094,
3654,
68,
297,
2850,
18259,
297,
1720,
628,
3417,
2082,
531,
272,
372,
1798,
14,
1122,
63,
589,
342,
421,
199,
318,
9236,
63,
1637,
837,
272,
931,
275,
9017,
8,
4832,
3460,
493,
8964,
272,
862,
26,
267,
543,
1551,
8,
904,
8,
515,
12,
283,
30146,
14,
11714,
1333,
465,
289,
26,
288,
503,
458,
275,
8864,
14,
912,
8,
70,
9,
272,
871,
5925,
26,
267,
870,
298,
6005,
370,
1586,
1052,
15,
30146,
14,
11714,
12,
1630,
652,
2187,
31,
1674,
908,
8,
515,
9,
267,
984,
14,
2224,
8,
17,
9,
339,
20416,
275,
942,
339,
367,
5981,
315,
503,
458,
26,
267,
2034,
275,
413,
267,
1830,
715,
26,
288,
519,
275,
4145,
14,
362,
360,
2859,
921,
1246,
14,
5031,
14,
957,
15,
3707,
19655,
11857,
31,
1606,
27244,
908,
8,
1308,
12,
2034,
430,
288,
5981,
63,
576,
275,
519,
14,
1001,
342,
288,
327,
1056,
6497,
5133,
781,
664,
4697,
2058,
288,
340,
440,
1228,
8,
1308,
63,
576,
12,
769,
9,
503,
822,
8,
1308,
63,
576,
9,
508,
378,
26,
355,
2059,
288,
367,
3831,
63,
576,
315,
5981,
63,
576,
26,
355,
340,
283,
1360,
63,
633,
7,
315,
3831,
63,
576,
26,
490,
20416,
14,
740,
3252,
1360,
63,
633,
356,
3831,
63,
576,
459,
1360,
63,
633,
995,
3303,
283,
354,
356,
3831,
63,
576,
459,
354,
995,
3303,
283,
1308,
356,
3831,
63,
576,
459,
4597,
2545,
2886,
13678,
288,
2034,
847,
413,
272,
543,
1551,
2336,
1391,
15,
2791,
15,
11857,
14,
1001,
297,
283,
6603,
358,
465,
289,
26,
267,
289,
14,
952,
8,
1001,
14,
4180,
8,
11857,
430,
421,
199,
318,
1678,
63,
11857,
837,
272,
543,
1551,
2336,
1391,
15,
2791,
15,
11857,
14,
1001,
358,
465,
289,
26,
267,
20416,
275,
2022,
14,
912,
8,
70,
9,
272,
367,
3831,
315,
20416,
26,
267,
3831,
63,
515,
275,
747,
14,
515,
14,
904,
8,
589,
14,
18259,
12,
3831,
459,
1308,
995,
3831,
459,
354,
418,
435,
1987,
3187,
358,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
3417,
63,
515,
304,
288,
1255,
63,
1760,
360,
8215,
446,
80,
9499,
908,
8,
3417,
63,
515,
430,
288,
1255,
63,
1760,
360,
3187,
7289,
1553,
12324,
1052,
9499,
908,
8,
3417,
459,
1360,
63,
633,
995,
3831,
63,
515,
430,
288,
1255,
63,
1760,
360,
2866,
1052,
10883,
6135,
1678,
13,
1000,
13,
815,
1370,
908,
8,
3417,
63,
515,
430,
267,
587,
26,
288,
1255,
63,
1760,
360,
2866,
1052,
10883,
6135,
5267,
1553,
452,
1553,
2969,
1370,
908,
8,
3417,
63,
515,
430,
288,
1255,
63,
1760,
360,
2866,
1052,
10883,
6135,
1678,
13,
1000,
13,
815,
1370,
908,
8,
3417,
63,
515,
430,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1249,
275,
2198,
63,
589,
342,
272,
2050,
14,
19602,
8,
1501,
8805,
1391,
15,
793,
15,
11857,
13,
504,
13,
30146,
14,
793,
297,
717,
2166,
29,
4806,
14,
5287,
9,
272,
340,
1249,
14,
6635,
26,
267,
1104,
63,
5720,
360,
6635,
358,
267,
9236,
63,
1637,
342,
272,
587,
26,
267,
1104,
63,
5720,
342,
267,
340,
440,
1249,
14,
18259,
26,
288,
870,
298,
8254,
1106,
329,
1480,
282,
7611,
2082,
2,
288,
984,
14,
2224,
8,
17,
9,
267,
340,
440,
747,
14,
515,
14,
2444,
2336,
1391,
15,
2791,
15,
11857,
14,
1001,
735,
288,
9236,
63,
1637,
342,
267,
1678,
63,
11857,
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
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
257,
9138,
282,
769,
402,
20416,
315,
282,
8864,
199,
3,
257,
570,
911,
1218,
503,
1678,
15216,
83,
199,
3,
199,
3,
257,
21687,
1182,
1391,
15,
2791,
15,
11857,
14,
1001,
687,
199,
3,
257,
282,
8864,
570,
3035,
282,
769,
402,
199,
3,
257,
12869,
20765,
12270,
199,
199,
646,
8864,
199,
646,
984,
199,
646,
4145,
199,
646,
2022,
199,
646,
3873,
199,
646,
747,
199,
646,
2050,
199,
646,
12871,
199,
504,
747,
14,
515,
492,
9017,
12,
19529,
12,
4263,
199,
504,
7534,
492,
27615,
199,
199,
318,
1104,
63,
5720,
8,
1065,
63,
466,
9280,
339,
4422,
63,
493,
275,
9005,
13,
31270,
3150,
1370,
908,
8,
267,
747,
14,
515,
14,
4846,
3460,
493,
10139,
1065,
63,
466,
9,
272,
4090,
275,
1551,
8,
3150,
63,
493,
12,
283,
87,
358,
272,
862,
26,
267,
12871,
14,
831,
70,
8,
3997,
12,
12871,
14,
4406,
63,
1438,
1204,
12871,
14,
4406,
63,
16170,
9,
272,
871,
5925,
26,
267,
327,
4573,
1256,
365,
3879,
267,
984,
14,
2224,
8,
16,
9,
199,
199,
318,
1255,
63,
1760,
8,
1760,
304,
272,
2050,
14,
1757,
360,
5720,
26,
22902,
78,
1370,
908,
8,
1760,
430,
272,
2112,
275,
3873,
14,
7942,
8,
267,
2088,
12,
3839,
29,
5781,
14,
6089,
12,
4635,
29,
5781,
14,
6089,
12,
267,
5218,
29,
549,
9,
272,
367,
1004,
315,
2740,
8,
1412,
14,
2703,
14,
6407,
12,
26430,
267,
2050,
14,
1757,
8,
604,
9,
421,
199,
318,
2198,
63,
589,
837,
272,
1798,
275,
27615,
342,
272,
1798,
14,
525,
63,
2094,
3654,
82,
297,
2850,
6635,
297,
1595,
534,
1617,
63,
2052,
297,
717,
1720,
628,
18730,
314,
769,
402,
20416,
401,
849,
29,
797,
9,
272,
1798,
14,
525,
63,
2094,
3654,
68,
297,
2850,
18259,
297,
1720,
628,
3417,
2082,
531,
272,
372,
1798,
14,
1122,
63,
589,
342,
421,
199,
318,
9236,
63,
1637,
837,
272,
931,
275,
9017,
8,
4832,
3460,
493,
8964,
272,
862,
26,
267,
543,
1551,
8,
904,
8,
515,
12,
283,
30146,
14,
11714,
1333,
465,
289,
26,
288,
503,
458,
275,
8864,
14,
912,
8,
70,
9,
272,
871,
5925,
26,
267,
870,
298,
6005,
370,
1586,
1052,
15,
30146,
14,
11714,
12,
1630,
652,
2187,
31,
1674,
908,
8,
515,
9,
267,
984,
14,
2224,
8,
17,
9,
339,
20416,
275,
942,
339,
367,
5981,
315,
503,
458,
26,
267,
2034,
275,
413,
267,
1830,
715,
26,
288,
519,
275,
4145,
14,
362,
360,
2859,
921,
1246,
14,
5031,
14,
957,
15,
3707,
19655,
11857,
31,
1606,
27244,
908,
8,
1308,
12,
2034,
430,
288,
5981,
63,
576,
275,
519,
14,
1001,
342,
288,
327,
1056,
6497,
5133,
781,
664,
4697,
2058,
288,
340,
440,
1228,
8,
1308,
63,
576,
12,
769,
9,
503,
822,
8,
1308,
63,
576,
9,
508,
378,
26,
355,
2059,
288,
367,
3831,
63,
576,
315,
5981,
63,
576,
26,
355,
340,
283,
1360,
63,
633,
7,
315,
3831,
63,
576,
26,
490,
20416,
14,
740,
3252,
1360,
63,
633,
356,
3831,
63,
576,
459,
1360,
63,
633,
995,
3303,
283,
354,
356,
3831,
63,
576,
459,
354,
995,
3303,
283,
1308,
356,
3831,
63,
576,
459,
4597,
2545,
2886,
13678,
288,
2034,
847,
413,
272,
543,
1551,
2336,
1391,
15,
2791,
15,
11857,
14,
1001,
297,
283,
6603,
358,
465,
289,
26,
267,
289,
14,
952,
8,
1001,
14,
4180,
8,
11857,
430,
421,
199,
318,
1678,
63,
11857,
837,
272,
543,
1551,
2336,
1391,
15,
2791,
15,
11857,
14,
1001,
358,
465,
289,
26,
267,
20416,
275,
2022,
14,
912,
8,
70,
9,
272,
367,
3831,
315,
20416,
26,
267,
3831,
63,
515,
275,
747,
14,
515,
14,
904,
8,
589,
14,
18259,
12,
3831,
459,
1308,
995,
3831,
459,
354,
418,
435,
1987,
3187,
358,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
3417,
63,
515,
304,
288,
1255,
63,
1760,
360,
8215,
446,
80,
9499,
908,
8,
3417,
63,
515,
430,
288,
1255,
63,
1760,
360,
3187,
7289,
1553,
12324,
1052,
9499,
908,
8,
3417,
459,
1360,
63,
633,
995,
3831,
63,
515,
430,
288,
1255,
63,
1760,
360,
2866,
1052,
10883,
6135,
1678,
13,
1000,
13,
815,
1370,
908,
8,
3417,
63,
515,
430,
267,
587,
26,
288,
1255,
63,
1760,
360,
2866,
1052,
10883,
6135,
5267,
1553,
452,
1553,
2969,
1370,
908,
8,
3417,
63,
515,
430,
288,
1255,
63,
1760,
360,
2866,
1052,
10883,
6135,
1678,
13,
1000,
13,
815,
1370,
908,
8,
3417,
63,
515,
430,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1249,
275,
2198,
63,
589,
342,
272,
2050,
14,
19602,
8,
1501,
8805,
1391,
15,
793,
15,
11857,
13,
504,
13,
30146,
14,
793,
297,
717,
2166,
29,
4806,
14,
5287,
9,
272,
340,
1249,
14,
6635,
26,
267,
1104,
63,
5720,
360,
6635,
358,
267,
9236,
63,
1637,
342,
272,
587,
26,
267,
1104,
63,
5720,
342,
267,
340,
440,
1249,
14,
18259,
26,
288,
870,
298,
8254,
1106,
329,
1480,
282,
7611,
2082,
2,
288,
984,
14,
2224,
8,
17,
9,
267,
340,
440,
747,
14,
515,
14,
2444,
2336,
1391,
15,
2791,
15,
11857,
14,
1001,
735,
288,
9236,
63,
1637,
342,
267,
1678,
63,
11857,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
browseinfo/odoo_saas3_nicolas
|
addons/l10n_fr_rib/bank.py
|
39
|
4961
|
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Numérigraphe SARL.
#
# 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
from openerp.tools.translate import _
class res_partner_bank(osv.osv):
"""Add fields and behavior for French RIB"""
_inherit = "res.partner.bank"
def _check_key(self, cr, uid, ids):
"""Check the RIB key"""
for bank_acc in self.browse(cr, uid, ids):
# Ignore the accounts of type other than rib
if bank_acc.state != 'rib':
continue
# Fail if the needed values are empty of too short
if (not bank_acc.bank_code
or len(bank_acc.bank_code) != 5
or not bank_acc.office or len(bank_acc.office) != 5
or not bank_acc.rib_acc_number or len(bank_acc.rib_acc_number) != 11
or not bank_acc.key or len(bank_acc.key) != 2):
return False
# Get the rib data (without the key)
rib = "%s%s%s" % (bank_acc.bank_code, bank_acc.office, bank_acc.rib_acc_number)
# Translate letters into numbers according to a specific table
# (notice how s -> 2)
table = dict((ord(a), b) for a, b in zip(
u'abcdefghijklmnopqrstuvwxyz', u'12345678912345678923456789'))
rib = rib.lower().translate(table)
# compute the key
key = 97 - (100 * int(rib)) % 97
if int(bank_acc.key) != key:
raise osv.except_osv(_('Error!'),
_("The RIB key %s does not correspond to the other codes: %s %s %s.") % \
(bank_acc.key, bank_acc.bank_code, bank_acc.office, bank_acc.rib_acc_number) )
if bank_acc.acc_number:
if not self.is_iban_valid(cr, uid, bank_acc.acc_number):
raise osv.except_osv(_('Error!'), _("The IBAN %s is not valid.") % bank_acc.acc_number)
return True
def onchange_bank_id(self, cr, uid, ids, bank_id, context=None):
"""Change the bank code"""
result = super(res_partner_bank, self).onchange_bank_id(cr, uid, ids, bank_id,
context=context)
if bank_id:
value = result.setdefault('value', {})
bank = self.pool.get('res.bank').browse(cr, uid, bank_id,
context=context)
value['bank_code'] = bank.rib_code
return result
_columns = {
'acc_number': fields.char('Account Number', size=64, required=False),
'rib_acc_number': fields.char('RIB account number', size=11, readonly=True,),
'bank_code': fields.char('Bank Code', size=64, readonly=True,),
'office': fields.char('Office Code', size=5, readonly=True,),
'key': fields.char('Key', size=2, readonly=True,
help="The key is a number allowing to check the "
"correctness of the other codes."),
}
_constraints = [(_check_key, 'The RIB and/or IBAN is not valid', ['rib_acc_number', 'bank_code', 'office', 'key'])]
class res_bank(osv.osv):
"""Add the bank code to make it easier to enter RIB data"""
_inherit = 'res.bank'
def name_search(self, cr, user, name, args=None, operator='ilike',
context=None, limit=80):
"""Search by bank code in addition to the standard search"""
# Get the standard results
results = super(res_bank, self).name_search(cr, user,
name, args=args ,operator=operator, context=context, limit=limit)
# Get additional results using the RIB code
ids = self.search(cr, user, [('rib_code', operator, name)],
limit=limit, context=context)
# Merge the results
results = list(set(results + self.name_get(cr, user, ids, context)))
return results
_columns = {
'rib_code': fields.char('RIB Bank Code', size=64),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7760,
16817,
5741,
322,
926,
80,
426,
428,
689,
44,
14,
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,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
533,
522,
63,
3899,
63,
9860,
8,
4795,
14,
4795,
304,
272,
408,
1123,
1504,
436,
5953,
367,
481,
15148,
820,
2100,
624,
272,
485,
6486,
275,
298,
470,
14,
3899,
14,
9860,
2,
339,
347,
485,
1074,
63,
498,
8,
277,
12,
2467,
12,
1747,
12,
2762,
304,
267,
408,
1799,
314,
820,
2100,
790,
624,
267,
367,
16297,
63,
5470,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
304,
288,
327,
14092,
314,
12639,
402,
730,
1163,
2419,
8012,
66,
288,
340,
16297,
63,
5470,
14,
929,
1137,
283,
30759,
356,
355,
1980,
288,
327,
12176,
340,
314,
4346,
1338,
787,
2701,
402,
4634,
3974,
7205,
340,
334,
1397,
16297,
63,
5470,
14,
9860,
63,
600,
288,
503,
822,
8,
9860,
63,
5470,
14,
9860,
63,
600,
9,
1137,
959,
288,
503,
440,
16297,
63,
5470,
14,
18812,
503,
822,
8,
9860,
63,
5470,
14,
18812,
9,
1137,
959,
288,
503,
440,
16297,
63,
5470,
14,
30759,
63,
5470,
63,
1955,
503,
822,
8,
9860,
63,
5470,
14,
30759,
63,
5470,
63,
1955,
9,
1137,
4119,
288,
503,
440,
16297,
63,
5470,
14,
498,
503,
822,
8,
9860,
63,
5470,
14,
498,
9,
1137,
499,
304,
355,
372,
756,
288,
327,
2372,
314,
8012,
66,
666,
334,
7395,
314,
790,
9,
288,
8012,
66,
275,
2071,
83,
5,
83,
5,
83,
2,
450,
334,
9860,
63,
5470,
14,
9860,
63,
600,
12,
16297,
63,
5470,
14,
18812,
12,
16297,
63,
5470,
14,
30759,
63,
5470,
63,
1955,
9,
288,
327,
25540,
14435,
1901,
5579,
7182,
370,
282,
2488,
1817,
288,
327,
259,
334,
20556,
4212,
308,
1035,
499,
9,
288,
1817,
275,
1211,
1332,
2181,
8,
65,
395,
330,
9,
367,
282,
12,
330,
315,
3482,
8,
355,
399,
7,
23459,
297,
399,
7,
11272,
11272,
5533,
6690,
1333,
288,
8012,
66,
275,
8012,
66,
14,
2325,
1252,
5275,
8,
1224,
9,
288,
327,
4526,
314,
790,
198,
288,
790,
275,
15997,
446,
334,
1960,
627,
1109,
8,
30759,
430,
450,
15997,
288,
340,
1109,
8,
9860,
63,
5470,
14,
498,
9,
1137,
790,
26,
355,
746,
9506,
14,
2590,
63,
4795,
6723,
547,
15659,
490,
3824,
1918,
820,
2100,
790,
450,
83,
1630,
440,
17118,
370,
314,
1163,
9479,
26,
450,
83,
450,
83,
450,
83,
2685,
450,
971,
717,
334,
9860,
63,
5470,
14,
498,
12,
16297,
63,
5470,
14,
9860,
63,
600,
12,
16297,
63,
5470,
14,
18812,
12,
16297,
63,
5470,
14,
30759,
63,
5470,
63,
1955,
9,
776,
288,
340,
16297,
63,
5470,
14,
5470,
63,
1955,
26,
355,
340,
440,
291,
14,
374,
63,
1892,
290,
63,
1078,
8,
1556,
12,
1747,
12,
16297,
63,
5470,
14,
5470,
63,
1955,
304,
490,
746,
9506,
14,
2590,
63,
4795,
6723,
547,
15659,
3824,
1918,
473,
34,
879,
450,
83,
365,
440,
1686,
2685,
450,
16297,
63,
5470,
14,
5470,
63,
1955,
9,
267,
372,
715,
339,
347,
20258,
63,
9860,
63,
344,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
16297,
63,
344,
12,
1067,
29,
403,
304,
267,
408,
4001,
314,
16297,
1233,
624,
267,
754,
275,
1613,
8,
470,
63,
3899,
63,
9860,
12,
291,
680,
18128,
63,
9860,
63,
344,
8,
1556,
12,
1747,
12,
2762,
12,
16297,
63,
344,
12,
9144,
1067,
29,
1100,
9,
267,
340,
16297,
63,
344,
26,
288,
574,
275,
754,
14,
5486,
360,
585,
297,
5009,
288,
16297,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
9860,
1959,
4570,
8,
1556,
12,
1747,
12,
16297,
63,
344,
12,
221,
8105,
1067,
29,
1100,
9,
288,
574,
459,
9860,
63,
600,
418,
275,
16297,
14,
30759,
63,
600,
267,
372,
754,
339,
485,
3406,
275,
469,
267,
283,
5470,
63,
1955,
356,
1504,
14,
1560,
360,
6009,
4860,
297,
1568,
29,
772,
12,
1415,
29,
797,
395,
267,
283,
30759,
63,
5470,
63,
1955,
356,
1504,
14,
1560,
360,
50,
2100,
2933,
1329,
297,
1568,
29,
845,
12,
6863,
29,
549,
4706,
267,
283,
9860,
63,
600,
356,
1504,
14,
1560,
360,
14814,
5495,
297,
1568,
29,
772,
12,
6863,
29,
549,
4706,
267,
283,
18812,
356,
1504,
14,
1560,
360,
31166,
5495,
297,
1568,
29,
21,
12,
6863,
29,
549,
4706,
267,
283,
498,
356,
1504,
14,
1560,
360,
1197,
297,
1568,
29,
18,
12,
6863,
29,
549,
12,
2574,
1720,
628,
1918,
790,
365,
282,
1329,
17266,
370,
1104,
314,
298,
1816,
298,
4525,
4171,
402,
314,
1163,
9479,
7651,
272,
789,
339,
485,
9882,
275,
359,
1547,
1074,
63,
498,
12,
283,
1918,
820,
2100,
436,
15,
269,
473,
34,
879,
365,
440,
1686,
297,
788,
30759,
63,
5470,
63,
1955,
297,
283,
9860,
63,
600,
297,
283,
18812,
297,
283,
498,
24437,
421,
199,
533,
522,
63,
9860,
8,
4795,
14,
4795,
304
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7760,
16817,
5741,
322,
926,
80,
426,
428,
689,
44,
14,
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,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
533,
522,
63,
3899,
63,
9860,
8,
4795,
14,
4795,
304,
272,
408,
1123,
1504,
436,
5953,
367,
481,
15148,
820,
2100,
624,
272,
485,
6486,
275,
298,
470,
14,
3899,
14,
9860,
2,
339,
347,
485,
1074,
63,
498,
8,
277,
12,
2467,
12,
1747,
12,
2762,
304,
267,
408,
1799,
314,
820,
2100,
790,
624,
267,
367,
16297,
63,
5470,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
304,
288,
327,
14092,
314,
12639,
402,
730,
1163,
2419,
8012,
66,
288,
340,
16297,
63,
5470,
14,
929,
1137,
283,
30759,
356,
355,
1980,
288,
327,
12176,
340,
314,
4346,
1338,
787,
2701,
402,
4634,
3974,
7205,
340,
334,
1397,
16297,
63,
5470,
14,
9860,
63,
600,
288,
503,
822,
8,
9860,
63,
5470,
14,
9860,
63,
600,
9,
1137,
959,
288,
503,
440,
16297,
63,
5470,
14,
18812,
503,
822,
8,
9860,
63,
5470,
14,
18812,
9,
1137,
959,
288,
503,
440,
16297,
63,
5470,
14,
30759,
63,
5470,
63,
1955,
503,
822,
8,
9860,
63,
5470,
14,
30759,
63,
5470,
63,
1955,
9,
1137,
4119,
288,
503,
440,
16297,
63,
5470,
14,
498,
503,
822,
8,
9860,
63,
5470,
14,
498,
9,
1137,
499,
304,
355,
372,
756,
288,
327,
2372,
314,
8012,
66,
666,
334,
7395,
314,
790,
9,
288,
8012,
66,
275,
2071,
83,
5,
83,
5,
83,
2,
450,
334,
9860,
63,
5470,
14,
9860,
63,
600,
12,
16297,
63,
5470,
14,
18812,
12,
16297,
63,
5470,
14,
30759,
63,
5470,
63,
1955,
9,
288,
327,
25540,
14435,
1901,
5579,
7182,
370,
282,
2488,
1817,
288,
327,
259,
334,
20556,
4212,
308,
1035,
499,
9,
288,
1817,
275,
1211,
1332,
2181,
8,
65,
395,
330,
9,
367,
282,
12,
330,
315,
3482,
8,
355,
399,
7,
23459,
297,
399,
7,
11272,
11272,
5533,
6690,
1333,
288,
8012,
66,
275,
8012,
66,
14,
2325,
1252,
5275,
8,
1224,
9,
288,
327,
4526,
314,
790,
198,
288,
790,
275,
15997,
446,
334,
1960,
627,
1109,
8,
30759,
430,
450,
15997,
288,
340,
1109,
8,
9860,
63,
5470,
14,
498,
9,
1137,
790,
26,
355,
746,
9506,
14,
2590,
63,
4795,
6723,
547,
15659,
490,
3824,
1918,
820,
2100,
790,
450,
83,
1630,
440,
17118,
370,
314,
1163,
9479,
26,
450,
83,
450,
83,
450,
83,
2685,
450,
971,
717,
334,
9860,
63,
5470,
14,
498,
12,
16297,
63,
5470,
14,
9860,
63,
600,
12,
16297,
63,
5470,
14,
18812,
12,
16297,
63,
5470,
14,
30759,
63,
5470,
63,
1955,
9,
776,
288,
340,
16297,
63,
5470,
14,
5470,
63,
1955,
26,
355,
340,
440,
291,
14,
374,
63,
1892,
290,
63,
1078,
8,
1556,
12,
1747,
12,
16297,
63,
5470,
14,
5470,
63,
1955,
304,
490,
746,
9506,
14,
2590,
63,
4795,
6723,
547,
15659,
3824,
1918,
473,
34,
879,
450,
83,
365,
440,
1686,
2685,
450,
16297,
63,
5470,
14,
5470,
63,
1955,
9,
267,
372,
715,
339,
347,
20258,
63,
9860,
63,
344,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
16297,
63,
344,
12,
1067,
29,
403,
304,
267,
408,
4001,
314,
16297,
1233,
624,
267,
754,
275,
1613,
8,
470,
63,
3899,
63,
9860,
12,
291,
680,
18128,
63,
9860,
63,
344,
8,
1556,
12,
1747,
12,
2762,
12,
16297,
63,
344,
12,
9144,
1067,
29,
1100,
9,
267,
340,
16297,
63,
344,
26,
288,
574,
275,
754,
14,
5486,
360,
585,
297,
5009,
288,
16297,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
9860,
1959,
4570,
8,
1556,
12,
1747,
12,
16297,
63,
344,
12,
221,
8105,
1067,
29,
1100,
9,
288,
574,
459,
9860,
63,
600,
418,
275,
16297,
14,
30759,
63,
600,
267,
372,
754,
339,
485,
3406,
275,
469,
267,
283,
5470,
63,
1955,
356,
1504,
14,
1560,
360,
6009,
4860,
297,
1568,
29,
772,
12,
1415,
29,
797,
395,
267,
283,
30759,
63,
5470,
63,
1955,
356,
1504,
14,
1560,
360,
50,
2100,
2933,
1329,
297,
1568,
29,
845,
12,
6863,
29,
549,
4706,
267,
283,
9860,
63,
600,
356,
1504,
14,
1560,
360,
14814,
5495,
297,
1568,
29,
772,
12,
6863,
29,
549,
4706,
267,
283,
18812,
356,
1504,
14,
1560,
360,
31166,
5495,
297,
1568,
29,
21,
12,
6863,
29,
549,
4706,
267,
283,
498,
356,
1504,
14,
1560,
360,
1197,
297,
1568,
29,
18,
12,
6863,
29,
549,
12,
2574,
1720,
628,
1918,
790,
365,
282,
1329,
17266,
370,
1104,
314,
298,
1816,
298,
4525,
4171,
402,
314,
1163,
9479,
7651,
272,
789,
339,
485,
9882,
275,
359,
1547,
1074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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
] |
nvoron23/hue
|
desktop/core/src/desktop/api2.py
|
4
|
2227
|
#!/usr/bin/env python
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import itertools
import logging
import json
import time
from collections import defaultdict
from django.core.urlresolvers import reverse
from django.utils import html
from django.utils.translation import ugettext as _
from desktop.lib.django_util import JsonResponse
from desktop.lib.i18n import force_unicode
from desktop.models import Document2, DocumentTag
LOG = logging.getLogger(__name__)
def get_document(request):
if request.GET.get('id'):
doc = Document2.objects.get(id=request.GET['id'])
else:
doc = Document2.objects.get(uuid=request.GET['uuid'])
response = _massage_doc_for_json(doc, request.user, with_data=request.GET.get('with_data'))
return JsonResponse(response)
def _massage_doc_for_json(document, user, with_data=False):
massaged_doc = {
'id': document.id,
'uuid': document.uuid,
'owner': document.owner.username,
'type': html.conditional_escape(document.type),
'name': html.conditional_escape(document.name),
'description': html.conditional_escape(document.description),
'isMine': document.owner == user,
'lastModified': document.last_modified.strftime("%x %X"),
'lastModifiedInMillis': time.mktime(document.last_modified.timetuple()),
'version': document.version,
'is_history': document.is_history,
# tags
# dependencies
}
if with_data:
massaged_doc['data'] = document.data_dict
return massaged_doc
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
3909,
370,
5980,
3786,
345,
12,
3277,
14,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
5980,
3786,
345,
12,
3277,
14,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
646,
7975,
199,
646,
2050,
199,
646,
2022,
199,
646,
900,
199,
199,
504,
5055,
492,
10018,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
199,
504,
1639,
14,
1208,
492,
3517,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
199,
504,
19763,
14,
773,
14,
1176,
63,
1974,
492,
21072,
199,
504,
19763,
14,
773,
14,
73,
1085,
78,
492,
3542,
63,
2975,
199,
504,
19763,
14,
992,
492,
7543,
18,
12,
7543,
1931,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
318,
664,
63,
3554,
8,
1069,
304,
523,
340,
1056,
14,
2970,
14,
362,
360,
344,
735,
272,
1382,
275,
7543,
18,
14,
1462,
14,
362,
8,
344,
29,
1069,
14,
2970,
459,
344,
1105,
523,
587,
26,
272,
1382,
275,
7543,
18,
14,
1462,
14,
362,
8,
2580,
29,
1069,
14,
2970,
459,
2580,
1105,
819,
1177,
275,
485,
11535,
474,
63,
1301,
63,
509,
63,
1001,
8,
1301,
12,
1056,
14,
751,
12,
543,
63,
576,
29,
1069,
14,
2970,
14,
362,
360,
1045,
63,
576,
1333,
819,
372,
21072,
8,
1310,
9,
421,
199,
318,
485,
11535,
474,
63,
1301,
63,
509,
63,
1001,
8,
3554,
12,
922,
12,
543,
63,
576,
29,
797,
304,
819,
12250,
6028,
63,
1301,
275,
469,
272,
283,
344,
356,
2213,
14,
344,
12,
272,
283,
2580,
356,
2213,
14,
2580,
12,
2286,
283,
4597,
356,
2213,
14,
4597,
14,
2473,
12,
272,
283,
466,
356,
3517,
14,
14353,
63,
3765,
8,
3554,
14,
466,
395,
14821,
283,
354,
356,
3517,
14,
14353,
63,
3765,
8,
3554,
14,
354,
395,
272,
283,
1802,
356,
3517,
14,
14353,
63,
3765,
8,
3554,
14,
1802,
395,
258,
339,
283,
374,
45,
1132,
356,
2213,
14,
4597,
508,
922,
12,
272,
283,
2019,
11911,
356,
2213,
14,
2019,
63,
5540,
14,
6205,
3647,
88,
450,
56,
1288,
272,
283,
2019,
11911,
607,
30145,
83,
356,
900,
14,
23456,
8,
3554,
14,
2019,
63,
5540,
14,
22309,
4000,
272,
283,
1023,
356,
2213,
14,
1023,
12,
272,
283,
374,
63,
5570,
356,
2213,
14,
374,
63,
5570,
12,
2286,
327,
3762,
272,
327,
5124,
523,
789,
12244,
340,
543,
63,
576,
26,
272,
12250,
6028,
63,
1301,
459,
576,
418,
275,
2213,
14,
576,
63,
807,
819,
372,
12250,
6028,
63,
1301,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
3909,
370,
5980,
3786,
345,
12,
3277,
14,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
5980,
3786,
345,
12,
3277,
14,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
646,
7975,
199,
646,
2050,
199,
646,
2022,
199,
646,
900,
199,
199,
504,
5055,
492,
10018,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
199,
504,
1639,
14,
1208,
492,
3517,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
199,
504,
19763,
14,
773,
14,
1176,
63,
1974,
492,
21072,
199,
504,
19763,
14,
773,
14,
73,
1085,
78,
492,
3542,
63,
2975,
199,
504,
19763,
14,
992,
492,
7543,
18,
12,
7543,
1931,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
318,
664,
63,
3554,
8,
1069,
304,
523,
340,
1056,
14,
2970,
14,
362,
360,
344,
735,
272,
1382,
275,
7543,
18,
14,
1462,
14,
362,
8,
344,
29,
1069,
14,
2970,
459,
344,
1105,
523,
587,
26,
272,
1382,
275,
7543,
18,
14,
1462,
14,
362,
8,
2580,
29,
1069,
14,
2970,
459,
2580,
1105,
819,
1177,
275,
485,
11535,
474,
63,
1301,
63,
509,
63,
1001,
8,
1301,
12,
1056,
14,
751,
12,
543,
63,
576,
29,
1069,
14,
2970,
14,
362,
360,
1045,
63,
576,
1333,
819,
372,
21072,
8,
1310,
9,
421,
199,
318,
485,
11535,
474,
63,
1301,
63,
509,
63,
1001,
8,
3554,
12,
922,
12,
543,
63,
576,
29,
797,
304,
819,
12250,
6028,
63,
1301,
275,
469,
272,
283,
344,
356,
2213,
14,
344,
12,
272,
283,
2580,
356,
2213,
14,
2580,
12,
2286,
283,
4597,
356,
2213,
14,
4597,
14,
2473,
12,
272,
283,
466,
356,
3517,
14,
14353,
63,
3765,
8,
3554,
14,
466,
395,
14821,
283,
354,
356,
3517,
14,
14353,
63,
3765,
8,
3554,
14,
354,
395,
272,
283,
1802,
356,
3517,
14,
14353,
63,
3765,
8,
3554,
14,
1802,
395,
258,
339,
283,
374,
45,
1132,
356,
2213,
14,
4597,
508,
922,
12,
272,
283,
2019,
11911,
356,
2213,
14,
2019,
63,
5540,
14,
6205,
3647,
88,
450,
56,
1288,
272,
283,
2019,
11911,
607,
30145,
83,
356,
900,
14,
23456,
8,
3554,
14,
2019,
63,
5540,
14,
22309,
4000,
272,
283,
1023,
356,
2213,
14,
1023,
12,
272,
283,
374,
63,
5570,
356,
2213,
14,
374,
63,
5570,
12,
2286,
327,
3762,
272,
327,
5124,
523,
789,
12244,
340,
543,
63,
576,
26,
272,
12250,
6028,
63,
1301,
459,
576,
418,
275,
2213,
14,
576,
63,
807,
819,
372,
12250,
6028,
63,
1301,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
tedder/ansible
|
test/units/modules/network/routeros/test_routeros_facts.py
|
49
|
4308
|
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from units.compat.mock import patch
from ansible.modules.network.routeros import routeros_facts
from units.modules.utils import set_module_args
from .routeros_module import TestRouterosModule, load_fixture
class TestRouterosFactsModule(TestRouterosModule):
module = routeros_facts
def setUp(self):
super(TestRouterosFactsModule, self).setUp()
self.mock_run_commands = patch('ansible.modules.network.routeros.routeros_facts.run_commands')
self.run_commands = self.mock_run_commands.start()
def tearDown(self):
super(TestRouterosFactsModule, self).tearDown()
self.mock_run_commands.stop()
def load_fixtures(self, commands=None):
def load_from_file(*args, **kwargs):
module = args
commands = kwargs['commands']
output = list()
for command in commands:
filename = str(command).split(' | ')[0].replace(' ', '_')
output.append(load_fixture('routeros_facts%s' % filename))
return output
self.run_commands.side_effect = load_from_file
def test_routeros_facts_default(self):
set_module_args(dict(gather_subset='default'))
result = self.execute_module()
self.assertEqual(
result['ansible_facts']['ansible_net_hostname'], 'MikroTik'
)
self.assertEqual(
result['ansible_facts']['ansible_net_version'], '6.42.5 (stable)'
)
self.assertEqual(
result['ansible_facts']['ansible_net_model'], 'RouterBOARD 3011UiAS'
)
self.assertEqual(
result['ansible_facts']['ansible_net_serialnum'], '1234567890'
)
def test_routeros_facts_hardware(self):
set_module_args(dict(gather_subset='hardware'))
result = self.execute_module()
self.assertEqual(
result['ansible_facts']['ansible_net_spacefree_mb'], 64921.6
)
self.assertEqual(
result['ansible_facts']['ansible_net_spacetotal_mb'], 65024.0
)
self.assertEqual(
result['ansible_facts']['ansible_net_memfree_mb'], 988.3
)
self.assertEqual(
result['ansible_facts']['ansible_net_memtotal_mb'], 1010.8
)
def test_routeros_facts_config(self):
set_module_args(dict(gather_subset='config'))
result = self.execute_module()
self.assertIsInstance(
result['ansible_facts']['ansible_net_config'], str
)
def test_routeros_facts_interfaces(self):
set_module_args(dict(gather_subset='interfaces'))
result = self.execute_module()
self.assertEqual(
result['ansible_facts']['ansible_net_all_ipv4_addresses'][0], '10.37.129.3'
)
self.assertEqual(
result['ansible_facts']['ansible_net_all_ipv4_addresses'][0],
result['ansible_facts']['ansible_net_interfaces']['ether1']['ipv4'][0]['address']
)
self.assertEqual(
result['ansible_facts']['ansible_net_all_ipv6_addresses'], ['fe80::21c:42ff:fe36:5290']
)
self.assertEqual(
result['ansible_facts']['ansible_net_all_ipv6_addresses'][0],
result['ansible_facts']['ansible_net_interfaces']['ether1']['ipv6'][0]['address']
)
self.assertEqual(
len(result['ansible_facts']['ansible_net_interfaces'].keys()), 2
)
self.assertEqual(
len(result['ansible_facts']['ansible_net_neighbors'].keys()), 4
)
|
gpl-3.0
|
[
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
6204,
14,
5819,
14,
1805,
492,
3371,
199,
504,
3242,
14,
3112,
14,
1200,
14,
4449,
4796,
492,
7475,
4796,
63,
5047,
199,
504,
6204,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
199,
504,
1275,
4449,
4796,
63,
578,
492,
1379,
7161,
4796,
2377,
12,
2248,
63,
5997,
421,
199,
533,
1379,
7161,
4796,
25821,
2377,
8,
774,
7161,
4796,
2377,
304,
339,
859,
275,
7475,
4796,
63,
5047,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
7161,
4796,
25821,
2377,
12,
291,
680,
5996,
342,
267,
291,
14,
1805,
63,
1065,
63,
4405,
275,
3371,
360,
4853,
14,
3112,
14,
1200,
14,
4449,
4796,
14,
4449,
4796,
63,
5047,
14,
1065,
63,
4405,
358,
267,
291,
14,
1065,
63,
4405,
275,
291,
14,
1805,
63,
1065,
63,
4405,
14,
928,
342,
339,
347,
6766,
8,
277,
304,
267,
1613,
8,
774,
7161,
4796,
25821,
2377,
12,
291,
680,
12336,
342,
267,
291,
14,
1805,
63,
1065,
63,
4405,
14,
2379,
342,
339,
347,
2248,
63,
8769,
8,
277,
12,
3718,
29,
403,
304,
267,
347,
2248,
63,
504,
63,
493,
2031,
589,
12,
1011,
958,
304,
288,
859,
275,
1249,
288,
3718,
275,
2074,
459,
4405,
418,
288,
1072,
275,
769,
342,
953,
367,
1414,
315,
3718,
26,
355,
1788,
275,
620,
8,
1531,
680,
1294,
360,
1204,
27618,
16,
1055,
1814,
360,
1656,
18962,
355,
1072,
14,
740,
8,
912,
63,
5997,
360,
4449,
4796,
63,
5047,
5,
83,
7,
450,
1788,
430,
288,
372,
1072,
398,
291,
14,
1065,
63,
4405,
14,
2441,
63,
5881,
275,
2248,
63,
504,
63,
493,
339,
347,
511,
63,
4449,
4796,
63,
5047,
63,
885,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
13737,
63,
9401,
534,
885,
1333,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
4269,
995,
283,
45,
3258,
293,
52,
3258,
7,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
1023,
995,
283,
22,
14,
2260,
14,
21,
334,
11989,
3171,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
1238,
995,
283,
11691,
23368,
650,
13059,
18203,
1179,
7,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
2171,
1507,
995,
283,
21515,
7,
267,
776,
339,
347,
511,
63,
4449,
4796,
63,
5047,
63,
16529,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
13737,
63,
9401,
534,
16529,
1333,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
2638,
4624,
63,
887,
995,
5049,
25,
2025,
14,
22,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
2638,
2923,
63,
887,
995,
11738,
5284,
14,
16,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
5286,
4624,
63,
887,
995,
1749,
1299,
14,
19,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
278,
2037,
1735,
63,
887,
995,
413,
9523,
14,
24,
267,
776,
339,
347,
511,
63,
4449,
4796,
63,
5047,
63,
888,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
13737,
63,
9401,
534,
888,
1333,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
6926,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
888,
995,
620,
267,
776,
339,
347,
511,
63,
4449,
4796,
63,
5047,
63,
7436,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
13737,
63,
9401,
534,
7436,
1333,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
452,
63,
4774,
20,
63,
7423,
3488,
16,
467,
283,
709,
14,
1401,
14,
7263,
14,
19,
7,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
452,
63,
4774,
20,
63,
7423,
3488,
16,
467,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
7436,
2545,
27732,
17,
2545,
4774,
20,
3488,
16,
2733,
1562,
418,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
452,
63,
4774,
22,
63,
7423,
995,
788,
771,
1257,
447,
2025,
67,
26,
2260,
556,
26,
771,
1344,
26,
21,
15117,
418,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
452,
63,
4774,
22,
63,
7423,
3488,
16,
467,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
7436,
2545,
27732,
17,
2545,
4774,
22,
3488,
16,
2733,
1562,
418,
267,
776
] |
[
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
6204,
14,
5819,
14,
1805,
492,
3371,
199,
504,
3242,
14,
3112,
14,
1200,
14,
4449,
4796,
492,
7475,
4796,
63,
5047,
199,
504,
6204,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
199,
504,
1275,
4449,
4796,
63,
578,
492,
1379,
7161,
4796,
2377,
12,
2248,
63,
5997,
421,
199,
533,
1379,
7161,
4796,
25821,
2377,
8,
774,
7161,
4796,
2377,
304,
339,
859,
275,
7475,
4796,
63,
5047,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
7161,
4796,
25821,
2377,
12,
291,
680,
5996,
342,
267,
291,
14,
1805,
63,
1065,
63,
4405,
275,
3371,
360,
4853,
14,
3112,
14,
1200,
14,
4449,
4796,
14,
4449,
4796,
63,
5047,
14,
1065,
63,
4405,
358,
267,
291,
14,
1065,
63,
4405,
275,
291,
14,
1805,
63,
1065,
63,
4405,
14,
928,
342,
339,
347,
6766,
8,
277,
304,
267,
1613,
8,
774,
7161,
4796,
25821,
2377,
12,
291,
680,
12336,
342,
267,
291,
14,
1805,
63,
1065,
63,
4405,
14,
2379,
342,
339,
347,
2248,
63,
8769,
8,
277,
12,
3718,
29,
403,
304,
267,
347,
2248,
63,
504,
63,
493,
2031,
589,
12,
1011,
958,
304,
288,
859,
275,
1249,
288,
3718,
275,
2074,
459,
4405,
418,
288,
1072,
275,
769,
342,
953,
367,
1414,
315,
3718,
26,
355,
1788,
275,
620,
8,
1531,
680,
1294,
360,
1204,
27618,
16,
1055,
1814,
360,
1656,
18962,
355,
1072,
14,
740,
8,
912,
63,
5997,
360,
4449,
4796,
63,
5047,
5,
83,
7,
450,
1788,
430,
288,
372,
1072,
398,
291,
14,
1065,
63,
4405,
14,
2441,
63,
5881,
275,
2248,
63,
504,
63,
493,
339,
347,
511,
63,
4449,
4796,
63,
5047,
63,
885,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
13737,
63,
9401,
534,
885,
1333,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
4269,
995,
283,
45,
3258,
293,
52,
3258,
7,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
1023,
995,
283,
22,
14,
2260,
14,
21,
334,
11989,
3171,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
1238,
995,
283,
11691,
23368,
650,
13059,
18203,
1179,
7,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
2171,
1507,
995,
283,
21515,
7,
267,
776,
339,
347,
511,
63,
4449,
4796,
63,
5047,
63,
16529,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
13737,
63,
9401,
534,
16529,
1333,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
2638,
4624,
63,
887,
995,
5049,
25,
2025,
14,
22,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
2638,
2923,
63,
887,
995,
11738,
5284,
14,
16,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
5286,
4624,
63,
887,
995,
1749,
1299,
14,
19,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
278,
2037,
1735,
63,
887,
995,
413,
9523,
14,
24,
267,
776,
339,
347,
511,
63,
4449,
4796,
63,
5047,
63,
888,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
13737,
63,
9401,
534,
888,
1333,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
6926,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
888,
995,
620,
267,
776,
339,
347,
511,
63,
4449,
4796,
63,
5047,
63,
7436,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
13737,
63,
9401,
534,
7436,
1333,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
452,
63,
4774,
20,
63,
7423,
3488,
16,
467,
283,
709,
14,
1401,
14,
7263,
14,
19,
7,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
452,
63,
4774,
20,
63,
7423,
3488,
16,
467,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
7436,
2545,
27732,
17,
2545,
4774,
20,
3488,
16,
2733,
1562,
418,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
452,
63,
4774,
22,
63,
7423,
995,
788,
771,
1257,
447,
2025,
67,
26,
2260,
556,
26,
771,
1344,
26,
21,
15117,
418,
267,
776,
267,
291,
14,
629,
8,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
452,
63,
4774,
22,
63,
7423,
3488,
16,
467,
288,
754,
459,
4853,
63,
5047,
2545,
4853,
63,
846,
63,
7436,
2545,
27732,
17,
2545,
4774,
22,
3488,
16,
2733,
1562,
418,
267,
776,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jyotsna1820/django
|
django/core/checks/model_checks.py
|
525
|
2390
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import inspect
import types
from django.apps import apps
from django.core.checks import Error, Tags, register
@register(Tags.models)
def check_all_models(app_configs=None, **kwargs):
errors = []
for model in apps.get_models():
if app_configs is None or model._meta.app_config in app_configs:
if not inspect.ismethod(model.check):
errors.append(
Error(
"The '%s.check()' class method is "
"currently overridden by %r." % (
model.__name__, model.check),
hint=None,
obj=model,
id='models.E020'
)
)
else:
errors.extend(model.check(**kwargs))
return errors
@register(Tags.models, Tags.signals)
def check_model_signals(app_configs=None, **kwargs):
"""
Ensure lazily referenced model signals senders are installed.
"""
# Avoid circular import
from django.db import models
errors = []
for name in dir(models.signals):
obj = getattr(models.signals, name)
if isinstance(obj, models.signals.ModelSignal):
for reference, receivers in obj.unresolved_references.items():
for receiver, _, _ in receivers:
# The receiver is either a function or an instance of class
# defining a `__call__` method.
if isinstance(receiver, types.FunctionType):
description = "The '%s' function" % receiver.__name__
else:
description = "An instance of the '%s' class" % receiver.__class__.__name__
errors.append(
Error(
"%s was connected to the '%s' signal "
"with a lazy reference to the '%s' sender, "
"which has not been installed." % (
description, name, '.'.join(reference)
),
obj=receiver.__module__,
hint=None,
id='signals.E001'
)
)
return errors
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
6485,
199,
646,
2943,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
1018,
14,
8625,
492,
4520,
12,
25204,
12,
2274,
421,
199,
32,
2683,
8,
9440,
14,
992,
9,
199,
318,
1104,
63,
452,
63,
992,
8,
571,
63,
7532,
29,
403,
12,
1011,
958,
304,
272,
2552,
275,
942,
272,
367,
1402,
315,
8686,
14,
362,
63,
992,
837,
267,
340,
1145,
63,
7532,
365,
488,
503,
1402,
423,
2024,
14,
571,
63,
888,
315,
1145,
63,
7532,
26,
288,
340,
440,
6485,
14,
374,
765,
8,
1238,
14,
1074,
304,
355,
2552,
14,
740,
8,
490,
4520,
8,
717,
298,
1918,
1543,
83,
14,
1074,
11716,
1021,
1083,
365,
298,
717,
298,
19767,
10087,
701,
450,
82,
2122,
450,
334,
1169,
1402,
855,
354,
3108,
1402,
14,
1074,
395,
717,
8328,
29,
403,
12,
717,
1559,
29,
1238,
12,
717,
1305,
534,
992,
14,
37,
10173,
7,
490,
776,
355,
776,
288,
587,
26,
355,
2552,
14,
2880,
8,
1238,
14,
1074,
3682,
958,
430,
272,
372,
2552,
421,
199,
32,
2683,
8,
9440,
14,
992,
12,
25204,
14,
10458,
9,
199,
318,
1104,
63,
1238,
63,
10458,
8,
571,
63,
7532,
29,
403,
12,
1011,
958,
304,
272,
408,
272,
7523,
29667,
3444,
11812,
1402,
10166,
4334,
7735,
787,
4903,
14,
272,
408,
272,
327,
19503,
15032,
492,
272,
687,
1639,
14,
697,
492,
1709,
339,
2552,
275,
942,
272,
367,
536,
315,
2935,
8,
992,
14,
10458,
304,
267,
1559,
275,
2519,
8,
992,
14,
10458,
12,
536,
9,
267,
340,
1228,
8,
1113,
12,
1709,
14,
10458,
14,
1685,
11274,
304,
288,
367,
3659,
12,
13035,
83,
315,
1559,
14,
324,
13697,
63,
12635,
14,
1744,
837,
355,
367,
13035,
12,
5501,
485,
315,
13035,
83,
26,
490,
327,
710,
13035,
365,
1902,
282,
805,
503,
376,
1256,
402,
1021,
490,
327,
12669,
282,
26856,
1250,
29341,
1083,
14,
490,
340,
1228,
8,
10244,
12,
2943,
14,
26371,
304,
717,
1369,
275,
298,
1918,
1543,
83,
7,
805,
2,
450,
13035,
855,
354,
363,
490,
587,
26,
717,
1369,
275,
298,
2493,
1256,
402,
314,
1543,
83,
7,
1021,
2,
450,
13035,
855,
533,
4914,
354,
363,
490,
2552,
14,
740,
8,
717,
4520,
8,
1169,
2071,
83,
1990,
8539,
370,
314,
1543,
83,
7,
4673,
298,
1169,
298,
1045,
282,
9617,
3659,
370,
314,
1543,
83,
7,
8904,
12,
298,
1169,
298,
6777,
965,
440,
2757,
4903,
2122,
450,
334,
1816,
1369,
12,
536,
12,
15671,
904,
8,
4443,
9,
1169,
2318,
1169,
1559,
29,
10244,
855,
578,
3108,
1169,
8328,
29,
403,
12,
1169,
1305,
534,
10458,
14,
37,
4587,
7,
717,
776,
490,
776,
272,
372,
2552,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
6485,
199,
646,
2943,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
1018,
14,
8625,
492,
4520,
12,
25204,
12,
2274,
421,
199,
32,
2683,
8,
9440,
14,
992,
9,
199,
318,
1104,
63,
452,
63,
992,
8,
571,
63,
7532,
29,
403,
12,
1011,
958,
304,
272,
2552,
275,
942,
272,
367,
1402,
315,
8686,
14,
362,
63,
992,
837,
267,
340,
1145,
63,
7532,
365,
488,
503,
1402,
423,
2024,
14,
571,
63,
888,
315,
1145,
63,
7532,
26,
288,
340,
440,
6485,
14,
374,
765,
8,
1238,
14,
1074,
304,
355,
2552,
14,
740,
8,
490,
4520,
8,
717,
298,
1918,
1543,
83,
14,
1074,
11716,
1021,
1083,
365,
298,
717,
298,
19767,
10087,
701,
450,
82,
2122,
450,
334,
1169,
1402,
855,
354,
3108,
1402,
14,
1074,
395,
717,
8328,
29,
403,
12,
717,
1559,
29,
1238,
12,
717,
1305,
534,
992,
14,
37,
10173,
7,
490,
776,
355,
776,
288,
587,
26,
355,
2552,
14,
2880,
8,
1238,
14,
1074,
3682,
958,
430,
272,
372,
2552,
421,
199,
32,
2683,
8,
9440,
14,
992,
12,
25204,
14,
10458,
9,
199,
318,
1104,
63,
1238,
63,
10458,
8,
571,
63,
7532,
29,
403,
12,
1011,
958,
304,
272,
408,
272,
7523,
29667,
3444,
11812,
1402,
10166,
4334,
7735,
787,
4903,
14,
272,
408,
272,
327,
19503,
15032,
492,
272,
687,
1639,
14,
697,
492,
1709,
339,
2552,
275,
942,
272,
367,
536,
315,
2935,
8,
992,
14,
10458,
304,
267,
1559,
275,
2519,
8,
992,
14,
10458,
12,
536,
9,
267,
340,
1228,
8,
1113,
12,
1709,
14,
10458,
14,
1685,
11274,
304,
288,
367,
3659,
12,
13035,
83,
315,
1559,
14,
324,
13697,
63,
12635,
14,
1744,
837,
355,
367,
13035,
12,
5501,
485,
315,
13035,
83,
26,
490,
327,
710,
13035,
365,
1902,
282,
805,
503,
376,
1256,
402,
1021,
490,
327,
12669,
282,
26856,
1250,
29341,
1083,
14,
490,
340,
1228,
8,
10244,
12,
2943,
14,
26371,
304,
717,
1369,
275,
298,
1918,
1543,
83,
7,
805,
2,
450,
13035,
855,
354,
363,
490,
587,
26,
717,
1369,
275,
298,
2493,
1256,
402,
314,
1543,
83,
7,
1021,
2,
450,
13035,
855,
533,
4914,
354,
363,
490,
2552,
14,
740,
8,
717,
4520,
8,
1169,
2071,
83,
1990,
8539,
370,
314,
1543,
83,
7,
4673,
298,
1169,
298,
1045,
282,
9617,
3659,
370,
314,
1543,
83,
7,
8904,
12,
298,
1169,
298,
6777,
965,
440,
2757,
4903,
2122,
450,
334,
1816,
1369,
12,
536,
12,
15671,
904,
8,
4443,
9,
1169,
2318,
1169,
1559,
29,
10244,
855,
578,
3108,
1169,
8328,
29,
403,
12,
1169,
1305,
534,
10458,
14,
37,
4587,
7,
717,
776,
490,
776,
272,
372,
2552,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
imoseyon/leanKernel-d2usc-deprecated
|
external/webkit/Tools/Scripts/webkitpy/tool/commands/sheriffbot.py
|
15
|
4417
|
# Copyright (c) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
from webkitpy.common.system.deprecated_logging import log
from webkitpy.common.config.ports import WebKitPort
from webkitpy.tool.bot.sheriff import Sheriff
from webkitpy.tool.bot.sheriffircbot import SheriffIRCBot
from webkitpy.tool.commands.queues import AbstractQueue
from webkitpy.tool.commands.stepsequence import StepSequenceErrorHandler
class SheriffBot(AbstractQueue, StepSequenceErrorHandler):
name = "sheriff-bot"
watchers = AbstractQueue.watchers + [
"abarth@webkit.org",
"eric@webkit.org",
]
def _update(self):
self.run_webkit_patch(["update", "--force-clean", "--quiet"])
# AbstractQueue methods
def begin_work_queue(self):
AbstractQueue.begin_work_queue(self)
self._sheriff = Sheriff(self._tool, self)
self._irc_bot = SheriffIRCBot(self._tool, self._sheriff)
self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
def work_item_log_path(self, failure_map):
return None
def _is_old_failure(self, revision):
return self._tool.status_server.svn_revision(revision)
def next_work_item(self):
self._irc_bot.process_pending_messages()
self._update()
# FIXME: We need to figure out how to provoke_flaky_builders.
failure_map = self._tool.buildbot.failure_map()
failure_map.filter_out_old_failures(self._is_old_failure)
if failure_map.is_empty():
return None
return failure_map
def should_proceed_with_work_item(self, failure_map):
# Currently, we don't have any reasons not to proceed with work items.
return True
def process_work_item(self, failure_map):
failing_revisions = failure_map.failing_revisions()
for revision in failing_revisions:
builders = failure_map.builders_failing_for(revision)
tests = failure_map.tests_failing_for(revision)
try:
commit_info = self._tool.checkout().commit_info_for_revision(revision)
if not commit_info:
print "FAILED to fetch CommitInfo for r%s, likely missing ChangeLog" % revision
continue
self._sheriff.post_irc_warning(commit_info, builders)
self._sheriff.post_blame_comment_on_bug(commit_info, builders, tests)
finally:
for builder in builders:
self._tool.status_server.update_svn_revision(revision, builder.name())
return True
def handle_unexpected_error(self, failure_map, message):
log(message)
# StepSequenceErrorHandler methods
@classmethod
def handle_script_error(cls, tool, state, script_error):
# Ideally we would post some information to IRC about what went wrong
# here, but we don't have the IRC password in the child process.
pass
|
gpl-2.0
|
[
3,
1898,
334,
67,
9,
8937,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
221,
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,
221,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
747,
199,
199,
504,
18007,
14,
2330,
14,
2253,
14,
6667,
63,
4806,
492,
943,
199,
504,
18007,
14,
2330,
14,
888,
14,
5203,
492,
6001,
14591,
4313,
199,
504,
18007,
14,
3557,
14,
3018,
14,
609,
281,
15126,
492,
428,
2523,
15126,
199,
504,
18007,
14,
3557,
14,
3018,
14,
609,
281,
692,
329,
1195,
3018,
492,
428,
2523,
15126,
3927,
9956,
357,
199,
504,
18007,
14,
3557,
14,
4405,
14,
18849,
492,
11836,
3737,
199,
504,
18007,
14,
3557,
14,
4405,
14,
2926,
4041,
492,
13382,
5826,
25933,
421,
199,
533,
428,
2523,
15126,
14026,
8,
8458,
3737,
12,
13382,
5826,
25933,
304,
272,
536,
275,
298,
609,
281,
15126,
13,
3018,
2,
272,
9626,
1192,
275,
11836,
3737,
14,
6821,
1192,
435,
359,
267,
298,
371,
19677,
32,
12554,
14,
1308,
401,
267,
298,
281,
530,
32,
12554,
14,
1308,
401,
272,
1622,
339,
347,
485,
873,
8,
277,
304,
267,
291,
14,
1065,
63,
12554,
63,
2068,
5234,
873,
401,
4320,
3990,
13,
3118,
401,
4320,
10243,
3135,
339,
327,
11836,
3737,
3102,
339,
347,
5386,
63,
800,
63,
1825,
8,
277,
304,
267,
11836,
3737,
14,
5037,
63,
800,
63,
1825,
8,
277,
9,
267,
291,
423,
609,
281,
15126,
275,
428,
2523,
15126,
8,
277,
423,
3557,
12,
291,
9,
267,
291,
423,
5958,
63,
3018,
275,
428,
2523,
15126,
3927,
9956,
357,
8,
277,
423,
3557,
12,
291,
423,
609,
281,
15126,
9,
267,
291,
423,
3557,
14,
7505,
63,
5958,
63,
7113,
8,
277,
423,
5958,
63,
3018,
14,
5958,
63,
15286,
1012,
339,
347,
1736,
63,
1053,
63,
793,
63,
515,
8,
277,
12,
5988,
63,
1130,
304,
267,
372,
488,
339,
347,
485,
374,
63,
1753,
63,
5328,
8,
277,
12,
6974,
304,
267,
372,
291,
423,
3557,
14,
1205,
63,
1000,
14,
6836,
63,
5792,
8,
5792,
9,
339,
347,
2163,
63,
800,
63,
1053,
8,
277,
304,
267,
291,
423,
5958,
63,
3018,
14,
1412,
63,
6455,
63,
3431,
342,
267,
291,
423,
873,
342,
398,
327,
7600,
26,
2136,
1929,
370,
9658,
734,
4212,
370,
557,
6720,
63,
14163,
10562,
63,
20968,
14,
398,
5988,
63,
1130,
275,
291,
423,
3557,
14,
25497,
14,
5328,
63,
1130,
342,
267,
5988,
63,
1130,
14,
1541,
63,
548,
63,
1753,
63,
9968,
8,
277,
423,
374,
63,
1753,
63,
5328,
9,
267,
340,
5988,
63,
1130,
14,
374,
63,
1667,
837,
288,
372,
488,
267,
372,
5988,
63,
1130,
339,
347,
1077,
63,
496,
15648,
63,
1045,
63,
800,
63,
1053,
8,
277,
12,
5988,
63,
1130,
304,
267,
327,
13550,
12,
781,
2793,
1133,
1172,
1263,
14872,
440,
370,
20320,
543,
1736,
2974,
14,
267,
372,
715,
339,
347,
2112,
63,
800,
63,
1053,
8,
277,
12,
5988,
63,
1130,
304,
267,
18648,
63,
23449,
275,
5988,
63,
1130,
14,
25299,
63,
23449,
342,
267,
367,
6974,
315,
18648,
63,
23449,
26,
288,
27378,
275,
5988,
63,
1130,
14,
20968,
63,
25299,
63,
509,
8,
5792,
9,
288,
2295,
275,
5988,
63,
1130,
14,
2219,
63,
25299,
63,
509,
8,
5792,
9,
288,
862,
26,
355,
5532,
63,
815,
275,
291,
423,
3557,
14,
12891,
1252,
3543,
63,
815,
63,
509,
63,
5792,
8,
5792,
9,
355,
340,
440,
5532,
63,
815,
26,
490,
870,
298,
12299,
370,
5267,
21447,
2354,
367,
519,
5,
83,
12,
12060,
4124,
7743,
2445,
2,
450,
6974,
490,
1980,
355,
291,
423,
609,
281,
15126,
14,
1932,
63,
5958,
63,
3764,
8,
3543,
63,
815,
12,
27378,
9,
355,
291,
423,
609,
281,
15126,
14,
1932,
63,
3345,
313,
63,
3349,
63,
265,
63,
1266,
8,
3543,
63,
815,
12,
27378,
12,
2295,
9,
953,
3753,
26,
355,
367,
6545,
315,
27378,
26,
490,
291,
423,
3557,
14,
1205,
63,
1000,
14,
873,
63,
6836,
63,
5792,
8,
5792,
12,
6545,
14,
354,
1012,
267,
372,
715,
339,
347,
2429,
63,
8953,
63,
705,
8,
277,
12,
5988,
63,
1130,
12,
1245,
304,
267,
943,
8,
1188,
9,
339,
327,
13382,
5826,
25933,
3102,
339,
768,
3744,
272,
347,
2429,
63,
1579,
63,
705,
8,
1886,
12,
4744,
12,
1174,
12,
2884,
63,
705,
304,
267,
327,
473,
271,
1183,
781
] |
[
1898,
334,
67,
9,
8937,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
221,
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,
221,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
747,
199,
199,
504,
18007,
14,
2330,
14,
2253,
14,
6667,
63,
4806,
492,
943,
199,
504,
18007,
14,
2330,
14,
888,
14,
5203,
492,
6001,
14591,
4313,
199,
504,
18007,
14,
3557,
14,
3018,
14,
609,
281,
15126,
492,
428,
2523,
15126,
199,
504,
18007,
14,
3557,
14,
3018,
14,
609,
281,
692,
329,
1195,
3018,
492,
428,
2523,
15126,
3927,
9956,
357,
199,
504,
18007,
14,
3557,
14,
4405,
14,
18849,
492,
11836,
3737,
199,
504,
18007,
14,
3557,
14,
4405,
14,
2926,
4041,
492,
13382,
5826,
25933,
421,
199,
533,
428,
2523,
15126,
14026,
8,
8458,
3737,
12,
13382,
5826,
25933,
304,
272,
536,
275,
298,
609,
281,
15126,
13,
3018,
2,
272,
9626,
1192,
275,
11836,
3737,
14,
6821,
1192,
435,
359,
267,
298,
371,
19677,
32,
12554,
14,
1308,
401,
267,
298,
281,
530,
32,
12554,
14,
1308,
401,
272,
1622,
339,
347,
485,
873,
8,
277,
304,
267,
291,
14,
1065,
63,
12554,
63,
2068,
5234,
873,
401,
4320,
3990,
13,
3118,
401,
4320,
10243,
3135,
339,
327,
11836,
3737,
3102,
339,
347,
5386,
63,
800,
63,
1825,
8,
277,
304,
267,
11836,
3737,
14,
5037,
63,
800,
63,
1825,
8,
277,
9,
267,
291,
423,
609,
281,
15126,
275,
428,
2523,
15126,
8,
277,
423,
3557,
12,
291,
9,
267,
291,
423,
5958,
63,
3018,
275,
428,
2523,
15126,
3927,
9956,
357,
8,
277,
423,
3557,
12,
291,
423,
609,
281,
15126,
9,
267,
291,
423,
3557,
14,
7505,
63,
5958,
63,
7113,
8,
277,
423,
5958,
63,
3018,
14,
5958,
63,
15286,
1012,
339,
347,
1736,
63,
1053,
63,
793,
63,
515,
8,
277,
12,
5988,
63,
1130,
304,
267,
372,
488,
339,
347,
485,
374,
63,
1753,
63,
5328,
8,
277,
12,
6974,
304,
267,
372,
291,
423,
3557,
14,
1205,
63,
1000,
14,
6836,
63,
5792,
8,
5792,
9,
339,
347,
2163,
63,
800,
63,
1053,
8,
277,
304,
267,
291,
423,
5958,
63,
3018,
14,
1412,
63,
6455,
63,
3431,
342,
267,
291,
423,
873,
342,
398,
327,
7600,
26,
2136,
1929,
370,
9658,
734,
4212,
370,
557,
6720,
63,
14163,
10562,
63,
20968,
14,
398,
5988,
63,
1130,
275,
291,
423,
3557,
14,
25497,
14,
5328,
63,
1130,
342,
267,
5988,
63,
1130,
14,
1541,
63,
548,
63,
1753,
63,
9968,
8,
277,
423,
374,
63,
1753,
63,
5328,
9,
267,
340,
5988,
63,
1130,
14,
374,
63,
1667,
837,
288,
372,
488,
267,
372,
5988,
63,
1130,
339,
347,
1077,
63,
496,
15648,
63,
1045,
63,
800,
63,
1053,
8,
277,
12,
5988,
63,
1130,
304,
267,
327,
13550,
12,
781,
2793,
1133,
1172,
1263,
14872,
440,
370,
20320,
543,
1736,
2974,
14,
267,
372,
715,
339,
347,
2112,
63,
800,
63,
1053,
8,
277,
12,
5988,
63,
1130,
304,
267,
18648,
63,
23449,
275,
5988,
63,
1130,
14,
25299,
63,
23449,
342,
267,
367,
6974,
315,
18648,
63,
23449,
26,
288,
27378,
275,
5988,
63,
1130,
14,
20968,
63,
25299,
63,
509,
8,
5792,
9,
288,
2295,
275,
5988,
63,
1130,
14,
2219,
63,
25299,
63,
509,
8,
5792,
9,
288,
862,
26,
355,
5532,
63,
815,
275,
291,
423,
3557,
14,
12891,
1252,
3543,
63,
815,
63,
509,
63,
5792,
8,
5792,
9,
355,
340,
440,
5532,
63,
815,
26,
490,
870,
298,
12299,
370,
5267,
21447,
2354,
367,
519,
5,
83,
12,
12060,
4124,
7743,
2445,
2,
450,
6974,
490,
1980,
355,
291,
423,
609,
281,
15126,
14,
1932,
63,
5958,
63,
3764,
8,
3543,
63,
815,
12,
27378,
9,
355,
291,
423,
609,
281,
15126,
14,
1932,
63,
3345,
313,
63,
3349,
63,
265,
63,
1266,
8,
3543,
63,
815,
12,
27378,
12,
2295,
9,
953,
3753,
26,
355,
367,
6545,
315,
27378,
26,
490,
291,
423,
3557,
14,
1205,
63,
1000,
14,
873,
63,
6836,
63,
5792,
8,
5792,
12,
6545,
14,
354,
1012,
267,
372,
715,
339,
347,
2429,
63,
8953,
63,
705,
8,
277,
12,
5988,
63,
1130,
12,
1245,
304,
267,
943,
8,
1188,
9,
339,
327,
13382,
5826,
25933,
3102,
339,
768,
3744,
272,
347,
2429,
63,
1579,
63,
705,
8,
1886,
12,
4744,
12,
1174,
12,
2884,
63,
705,
304,
267,
327,
473,
271,
1183,
781,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
LumaPictures/rez
|
src/rez/utils/sourcecode.py
|
1
|
11788
|
from rez.utils.formatting import indent
from rez.utils.data_utils import cached_property
from rez.utils.logging_ import print_debug
from inspect import getsourcelines
from textwrap import dedent
from glob import glob
import traceback
import os.path
import imp
def early():
"""Used by functions in package.py to harden to the return value at build time.
The term 'early' refers to the fact these package attribute are evaluated
early, ie at build time and before a package is installed.
"""
def decorated(fn):
setattr(fn, "_early", True)
return fn
return decorated
def late():
"""Used by functions in package.py that are evaluated lazily.
The term 'late' refers to the fact these package attributes are evaluated
late, ie when the attribute is queried for the first time.
If you want to implement a package.py attribute as a function, you MUST use
this decorator - otherwise it is understood that you want your attribute to
be a function, not the return value of that function.
"""
from rez.package_resources_ import package_rex_keys
def decorated(fn):
# this is done here rather than in standard schema validation because
# the latter causes a very obfuscated error message
if fn.__name__ in package_rex_keys:
raise ValueError("Cannot use @late decorator on function '%s'"
% fn.__name__)
setattr(fn, "_late", True)
_add_decorator(fn, "late")
return fn
return decorated
def include(module_name, *module_names):
"""Used by functions in package.py to have access to named modules.
See the 'package_definition_python_path' config setting for more info.
"""
def decorated(fn):
_add_decorator(fn, "include", nargs=[module_name] + list(module_names))
return fn
return decorated
def _add_decorator(fn, name, **kwargs):
if not hasattr(fn, "_decorators"):
setattr(fn, "_decorators", [])
kwargs.update({"name": name})
fn._decorators.append(kwargs)
class SourceCodeError(Exception):
def __init__(self, msg, short_msg):
super(SourceCodeError, self).__init__(msg)
self.short_msg = short_msg
class SourceCodeCompileError(SourceCodeError):
pass
class SourceCodeExecError(SourceCodeError):
pass
class SourceCode(object):
"""Wrapper for python source code.
This object is aware of the decorators defined in this sourcefile (such as
'include') and deals with them appropriately.
"""
def __init__(self, source=None, func=None, filepath=None,
eval_as_function=True):
self.source = (source or '').rstrip()
self.func = func
self.filepath = filepath
self.eval_as_function = eval_as_function
self.package = None
self.funcname = None
self.decorators = []
if self.func is not None:
self._init_from_func()
def copy(self):
other = SourceCode.__new__(SourceCode)
other.source = self.source
other.func = self.func
other.filepath = self.filepath
other.eval_as_function = self.eval_as_function
other.package =self.package
other.funcname = self.funcname
other.decorators = self.decorators
return other
def _init_from_func(self):
self.funcname = self.func.__name__
self.decorators = getattr(self.func, "_decorators", [])
# get txt of function body. Skips sig and any decorators. Assumes that
# only the decorators in this file (such as 'include') are used.
loc = getsourcelines(self.func)[0][len(self.decorators) + 1:]
code = dedent(''.join(loc))
# align lines that start with a comment (#)
codelines = code.split('\n')
linescount = len(codelines)
for i, line in enumerate(codelines):
if line.startswith('#'):
nextindex = i + 1 if i < linescount else i - 1
nextline = codelines[nextindex]
while nextline.startswith('#'):
nextline = codelines[nextindex]
nextindex = (nextindex + 1 if nextindex < linescount
else nextindex - 1)
firstchar = len(nextline) - len(nextline.lstrip())
codelines[i] = '%s%s' % (nextline[:firstchar], line)
code = '\n'.join(codelines).rstrip()
code = dedent(code)
self.source = code
@cached_property
def includes(self):
info = self._get_decorator_info("include")
if not info:
return None
return set(info.get("nargs", []))
@cached_property
def late_binding(self):
info = self._get_decorator_info("late")
return bool(info)
@cached_property
def evaluated_code(self):
if self.eval_as_function:
funcname = self.funcname or "_unnamed"
code = indent(self.source)
code = ("def %s():\n" % funcname
+ code
+ "\n_result = %s()" % funcname)
else:
code = "if True:\n" + indent(self.source)
return code
@property
def sourcename(self):
if self.filepath:
filename = self.filepath
else:
filename = "string"
if self.funcname:
filename += ":%s" % self.funcname
return "<%s>" % filename
@cached_property
def compiled(self):
try:
pyc = compile(self.evaluated_code, self.sourcename, 'exec')
except Exception as e:
stack = traceback.format_exc()
raise SourceCodeCompileError(
"Failed to compile %s:\n%s" % (self.sourcename, stack),
short_msg=str(e))
return pyc
def set_package(self, package):
# this is needed to load @included modules
self.package = package
def exec_(self, globals_={}):
# bind import modules
if self.package is not None and self.includes:
for name in self.includes:
module = include_module_manager.load_module(name, self.package)
globals_[name] = module
# exec
pyc = self.compiled
try:
exec pyc in globals_
except Exception as e:
stack = traceback.format_exc()
raise SourceCodeExecError(
"Failed to execute %s:\n%s" % (self.sourcename, stack),
short_msg=str(e))
return globals_.get("_result")
def exec_late(self, package):
context = getattr(package, 'context', None)
g = {}
if context is None:
g["in_context"] = lambda: False
else:
g["in_context"] = lambda: True
g["context"] = context
# 'request', 'system' etc
bindings = context._get_pre_resolve_bindings()
g.update(bindings)
# note that what 'this' actually points to depends on whether the context
# is available or not. If not, then 'this' is a Package instance; if the
# context is available, it is a Variant instance. So for example, if
# in_context() is True, 'this' will have a 'root' attribute, but will
# not if in_context() is False.
#
g["this"] = package
self.set_package(package)
return self.exec_(globals_=g)
def to_text(self, funcname):
# don't indent code if already indented
if self.source[0] in (' ', '\t'):
source = self.source
else:
source = indent(self.source)
txt = "def %s():\n%s" % (funcname, source)
for entry in self.decorators:
nargs_str = ", ".join(map(repr, entry.get("nargs", [])))
name_str = entry.get("name")
sig = "@%s(%s)" % (name_str, nargs_str)
txt = sig + '\n' + txt
return txt
def _get_decorator_info(self, name):
matches = [x for x in self.decorators if x.get("name") == name]
if not matches:
return None
return matches[0]
def __getstate__(self):
return {
"source": self.source,
"filepath": self.filepath,
"funcname": self.funcname,
"eval_as_function": self.eval_as_function,
"decorators": self.decorators
}
def __setstate__(self, state):
self.source = state["source"]
self.filepath = state["filepath"]
self.funcname = state["funcname"]
self.eval_as_function = state["eval_as_function"]
self.decorators = state["decorators"]
self.func = None
self.package = None
def __eq__(self, other):
return (isinstance(other, SourceCode)
and other.source == self.source)
def __ne__(self, other):
return not (other == self)
def __str__(self):
return self.source
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.source)
class IncludeModuleManager(object):
"""Manages a cache of modules imported via '@include' decorator.
"""
# subdirectory under package 'base' path where we expect to find copied
# sourcefiles referred to by the '@include' function decorator.
#
include_modules_subpath = ".rez/include"
def __init__(self):
self.modules = {}
def load_module(self, name, package):
from rez.config import config # avoiding circular import
from rez.developer_package import DeveloperPackage
# in rare cases, a @late bound function may get called before the
# package is built. An example is 'requires' and the other requires-like
# functions. These need to be evaluated before a build, but it does also
# make sense to sometimes implement these as late-bound functions. We
# detect this case here, and load the modules from the original (pre-
# copied into package payload) location.
#
if isinstance(package, DeveloperPackage):
from hashlib import sha1
# load sourcefile from original location
path = config.package_definition_python_path
filepath = os.path.join(path, "%s.py" % name)
if not os.path.exists(filepath):
return None
with open(filepath) as f:
txt = f.read().strip()
hash_str = sha1(txt).hexdigest()
else:
# load sourcefile that's been copied into package install payload
base = getattr(package, 'base', None)
if base is None:
# may have no base if it's a multi-version package... see if
# it has a location
base = getattr(package, 'location', None)
if base is None:
if hasattr(package, 'wrapped'):
base = getattr(package.wrapped, 'location', None)
path = os.path.join(base, self.include_modules_subpath)
pathname = os.path.join(path, "%s-*.py" % name)
pathnames = glob(pathname)
if not pathnames:
return None
filepath = pathnames[0]
hash_str = filepath.rsplit('-', 1)[-1].split('.', 1)[0]
module = self.modules.get(hash_str)
if module is not None:
return module
if config.debug("file_loads"):
print_debug("Loading include sourcefile: %s" % filepath)
with open(filepath) as f:
module = imp.load_source(name, filepath, f)
self.modules[hash_str] = module
return module
# singleton
include_module_manager = IncludeModuleManager()
|
lgpl-3.0
|
[
504,
295,
90,
14,
1208,
14,
20034,
492,
4363,
199,
504,
295,
90,
14,
1208,
14,
576,
63,
1208,
492,
6328,
63,
1829,
199,
504,
295,
90,
14,
1208,
14,
4806,
63,
492,
870,
63,
1757,
199,
504,
6485,
492,
664,
1365,
1278,
199,
504,
13390,
492,
22622,
199,
504,
5739,
492,
5739,
199,
646,
5190,
199,
646,
747,
14,
515,
199,
646,
1742,
421,
199,
318,
14670,
837,
272,
408,
9167,
701,
3423,
315,
2559,
14,
647,
370,
12159,
848,
370,
314,
372,
574,
737,
1900,
900,
14,
339,
710,
6707,
283,
21423,
7,
15724,
370,
314,
10572,
3520,
2559,
2225,
787,
13006,
272,
14670,
12,
13446,
737,
1900,
900,
436,
2544,
282,
2559,
365,
4903,
14,
272,
408,
272,
347,
16225,
8,
2324,
304,
267,
5371,
8,
2324,
12,
2668,
21423,
401,
715,
9,
267,
372,
4325,
339,
372,
16225,
421,
199,
318,
2465,
837,
272,
408,
9167,
701,
3423,
315,
2559,
14,
647,
626,
787,
13006,
29667,
3444,
14,
339,
710,
6707,
283,
750,
7,
15724,
370,
314,
10572,
3520,
2559,
3004,
787,
13006,
272,
2465,
12,
13446,
1380,
314,
2225,
365,
30081,
367,
314,
1642,
900,
14,
339,
982,
1265,
2934,
370,
5669,
282,
2559,
14,
647,
2225,
465,
282,
805,
12,
1265,
18095,
675,
272,
642,
7531,
446,
4257,
652,
365,
1334,
14308,
364,
626,
1265,
2934,
2195,
2225,
370,
272,
506,
282,
805,
12,
440,
314,
372,
574,
402,
626,
805,
14,
272,
408,
272,
687,
295,
90,
14,
2491,
63,
4435,
63,
492,
2559,
63,
15063,
63,
1612,
339,
347,
16225,
8,
2324,
304,
398,
327,
642,
365,
4224,
2348,
7830,
2419,
315,
4465,
4177,
6411,
2952,
267,
327,
314,
19045,
14486,
282,
7437,
2607,
31958,
3153,
1125,
1245,
267,
340,
4325,
855,
354,
363,
315,
2559,
63,
15063,
63,
1612,
26,
288,
746,
1722,
480,
6612,
675,
768,
750,
7531,
641,
805,
1543,
83,
4065,
2490,
450,
4325,
855,
354,
3368,
398,
5371,
8,
2324,
12,
2668,
750,
401,
715,
9,
267,
485,
525,
63,
11547,
8,
2324,
12,
298,
750,
531,
267,
372,
4325,
339,
372,
16225,
421,
199,
318,
2387,
8,
578,
63,
354,
12,
627,
578,
63,
1247,
304,
272,
408,
9167,
701,
3423,
315,
2559,
14,
647,
370,
1172,
2879,
370,
4310,
4621,
14,
339,
1666,
314,
283,
2491,
63,
7463,
63,
1548,
63,
515,
7,
1101,
4260,
367,
1655,
2256,
14,
272,
408,
272,
347,
16225,
8,
2324,
304,
267,
485,
525,
63,
11547,
8,
2324,
12,
298,
2613,
401,
9237,
1524,
578,
63,
354,
61,
435,
769,
8,
578,
63,
1247,
430,
267,
372,
4325,
339,
372,
16225,
421,
199,
318,
485,
525,
63,
11547,
8,
2324,
12,
536,
12,
1011,
958,
304,
272,
340,
440,
2688,
8,
2324,
12,
2668,
11582,
2349,
267,
5371,
8,
2324,
12,
2668,
11582,
401,
3073,
339,
2074,
14,
873,
6333,
354,
582,
536,
1552,
272,
4325,
423,
11582,
14,
740,
8,
958,
9,
421,
199,
533,
5800,
3034,
547,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1499,
12,
3974,
63,
1328,
304,
267,
1613,
8,
2980,
3034,
547,
12,
291,
2843,
826,
721,
1328,
9,
267,
291,
14,
3612,
63,
1328,
275,
3974,
63,
1328,
421,
199,
533,
5800,
3034,
12626,
547,
8,
2980,
3034,
547,
304,
272,
986,
421,
199,
533,
5800,
3034,
4858,
547,
8,
2980,
3034,
547,
304,
272,
986,
421,
199,
533,
5800,
3034,
8,
785,
304,
272,
408,
4590,
367,
2366,
1350,
1233,
14,
339,
961,
909,
365,
20381,
402,
314,
20419,
3247,
315,
642,
1350,
493,
334,
10180,
465,
272,
283,
2613,
358,
436,
477,
2551,
543,
3062,
22497,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1350,
29,
403,
12,
2562,
29,
403,
12,
9911,
29,
403,
12,
326,
3468,
63,
305,
63,
1593,
29,
549,
304,
267,
291,
14,
1365,
275,
334,
1365,
503,
12548,
6735,
342,
267,
291,
14,
1532,
275,
2562,
267,
291,
14,
7218,
275,
9911,
267,
291,
14,
2579,
63,
305,
63,
1593,
275,
3468,
63,
305,
63,
1593,
267,
291,
14,
2491,
275,
488,
398,
291,
14,
29577,
275,
488,
267,
291,
14,
11582,
275,
942,
398,
340,
291,
14,
1532,
365,
440,
488,
26,
288,
291,
423,
826,
63,
504,
63,
1532,
342,
339,
347,
1331,
8,
277,
304,
267,
1163,
275,
5800,
3034,
855,
1222,
721,
2980,
3034,
9,
267,
1163,
14,
1365,
275,
291,
14,
1365,
267,
1163,
14,
1532,
275,
291,
14,
1532,
267,
1163,
14,
7218,
275,
291,
14,
7218,
267,
1163,
14,
2579,
63,
305,
63,
1593,
275,
291,
14,
2579,
63,
305,
63,
1593,
267,
1163,
14,
2491,
275,
277,
14,
2491,
267,
1163,
14,
29577,
275,
291,
14,
29577,
267,
1163,
14,
11582,
275,
291,
14,
11582,
398,
372,
1163,
339,
347,
485,
826,
63,
504,
63,
1532,
8,
277,
304,
267,
291,
14,
29577,
275,
291,
14,
1532,
855,
354,
363,
267,
291,
14,
11582,
275,
2519,
8,
277,
14,
1532,
12,
2668,
11582,
401,
3073,
398,
327,
664,
9444,
402,
805,
2396,
14,
8232,
83,
5259,
436,
1263,
20419,
14,
30451,
626,
267,
327,
1454,
314,
20419,
315,
642,
570,
334,
10180,
465,
283,
2613,
358,
787,
1202,
14,
267,
4355,
275,
664,
1365,
1278,
8,
277,
14,
1532,
2788,
16,
1527,
552,
8,
277,
14,
11582,
9,
435,
413,
2938,
267,
1233,
275,
22622,
17840,
904,
8,
2102,
430,
398,
327,
6998,
2385,
626,
1343,
543,
282,
3721,
15196,
9,
267,
1233,
1278,
275,
1233,
14,
1294,
2258,
78,
358,
267,
2385,
835,
275,
822,
8,
600,
1278,
9,
398,
367,
284,
12,
1004,
315,
3874,
8,
600,
1278,
304,
288,
340,
1004,
14,
2460,
7863,
735,
355,
2163,
1080,
275,
284,
435,
413,
340,
284,
665,
2385,
835,
587,
284,
446,
413,
355,
2163,
604,
275,
1233,
1278,
59,
2184,
1080,
61,
2234,
1830,
2163,
604,
14,
2460,
7863,
735,
490,
2163,
604,
275,
1233,
1278,
59,
2184,
1080,
61,
490,
2163,
1080,
275,
334,
2184,
1080,
435,
413,
340,
2163,
1080,
665,
2385,
835,
639,
587,
2163,
1080,
446,
413,
9,
2234,
1642,
1560,
275,
822,
8,
2184,
604,
9,
446,
822,
8,
2184,
604,
14,
10124,
1012,
355,
1233,
1278,
59
] |
[
295,
90,
14,
1208,
14,
20034,
492,
4363,
199,
504,
295,
90,
14,
1208,
14,
576,
63,
1208,
492,
6328,
63,
1829,
199,
504,
295,
90,
14,
1208,
14,
4806,
63,
492,
870,
63,
1757,
199,
504,
6485,
492,
664,
1365,
1278,
199,
504,
13390,
492,
22622,
199,
504,
5739,
492,
5739,
199,
646,
5190,
199,
646,
747,
14,
515,
199,
646,
1742,
421,
199,
318,
14670,
837,
272,
408,
9167,
701,
3423,
315,
2559,
14,
647,
370,
12159,
848,
370,
314,
372,
574,
737,
1900,
900,
14,
339,
710,
6707,
283,
21423,
7,
15724,
370,
314,
10572,
3520,
2559,
2225,
787,
13006,
272,
14670,
12,
13446,
737,
1900,
900,
436,
2544,
282,
2559,
365,
4903,
14,
272,
408,
272,
347,
16225,
8,
2324,
304,
267,
5371,
8,
2324,
12,
2668,
21423,
401,
715,
9,
267,
372,
4325,
339,
372,
16225,
421,
199,
318,
2465,
837,
272,
408,
9167,
701,
3423,
315,
2559,
14,
647,
626,
787,
13006,
29667,
3444,
14,
339,
710,
6707,
283,
750,
7,
15724,
370,
314,
10572,
3520,
2559,
3004,
787,
13006,
272,
2465,
12,
13446,
1380,
314,
2225,
365,
30081,
367,
314,
1642,
900,
14,
339,
982,
1265,
2934,
370,
5669,
282,
2559,
14,
647,
2225,
465,
282,
805,
12,
1265,
18095,
675,
272,
642,
7531,
446,
4257,
652,
365,
1334,
14308,
364,
626,
1265,
2934,
2195,
2225,
370,
272,
506,
282,
805,
12,
440,
314,
372,
574,
402,
626,
805,
14,
272,
408,
272,
687,
295,
90,
14,
2491,
63,
4435,
63,
492,
2559,
63,
15063,
63,
1612,
339,
347,
16225,
8,
2324,
304,
398,
327,
642,
365,
4224,
2348,
7830,
2419,
315,
4465,
4177,
6411,
2952,
267,
327,
314,
19045,
14486,
282,
7437,
2607,
31958,
3153,
1125,
1245,
267,
340,
4325,
855,
354,
363,
315,
2559,
63,
15063,
63,
1612,
26,
288,
746,
1722,
480,
6612,
675,
768,
750,
7531,
641,
805,
1543,
83,
4065,
2490,
450,
4325,
855,
354,
3368,
398,
5371,
8,
2324,
12,
2668,
750,
401,
715,
9,
267,
485,
525,
63,
11547,
8,
2324,
12,
298,
750,
531,
267,
372,
4325,
339,
372,
16225,
421,
199,
318,
2387,
8,
578,
63,
354,
12,
627,
578,
63,
1247,
304,
272,
408,
9167,
701,
3423,
315,
2559,
14,
647,
370,
1172,
2879,
370,
4310,
4621,
14,
339,
1666,
314,
283,
2491,
63,
7463,
63,
1548,
63,
515,
7,
1101,
4260,
367,
1655,
2256,
14,
272,
408,
272,
347,
16225,
8,
2324,
304,
267,
485,
525,
63,
11547,
8,
2324,
12,
298,
2613,
401,
9237,
1524,
578,
63,
354,
61,
435,
769,
8,
578,
63,
1247,
430,
267,
372,
4325,
339,
372,
16225,
421,
199,
318,
485,
525,
63,
11547,
8,
2324,
12,
536,
12,
1011,
958,
304,
272,
340,
440,
2688,
8,
2324,
12,
2668,
11582,
2349,
267,
5371,
8,
2324,
12,
2668,
11582,
401,
3073,
339,
2074,
14,
873,
6333,
354,
582,
536,
1552,
272,
4325,
423,
11582,
14,
740,
8,
958,
9,
421,
199,
533,
5800,
3034,
547,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1499,
12,
3974,
63,
1328,
304,
267,
1613,
8,
2980,
3034,
547,
12,
291,
2843,
826,
721,
1328,
9,
267,
291,
14,
3612,
63,
1328,
275,
3974,
63,
1328,
421,
199,
533,
5800,
3034,
12626,
547,
8,
2980,
3034,
547,
304,
272,
986,
421,
199,
533,
5800,
3034,
4858,
547,
8,
2980,
3034,
547,
304,
272,
986,
421,
199,
533,
5800,
3034,
8,
785,
304,
272,
408,
4590,
367,
2366,
1350,
1233,
14,
339,
961,
909,
365,
20381,
402,
314,
20419,
3247,
315,
642,
1350,
493,
334,
10180,
465,
272,
283,
2613,
358,
436,
477,
2551,
543,
3062,
22497,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1350,
29,
403,
12,
2562,
29,
403,
12,
9911,
29,
403,
12,
326,
3468,
63,
305,
63,
1593,
29,
549,
304,
267,
291,
14,
1365,
275,
334,
1365,
503,
12548,
6735,
342,
267,
291,
14,
1532,
275,
2562,
267,
291,
14,
7218,
275,
9911,
267,
291,
14,
2579,
63,
305,
63,
1593,
275,
3468,
63,
305,
63,
1593,
267,
291,
14,
2491,
275,
488,
398,
291,
14,
29577,
275,
488,
267,
291,
14,
11582,
275,
942,
398,
340,
291,
14,
1532,
365,
440,
488,
26,
288,
291,
423,
826,
63,
504,
63,
1532,
342,
339,
347,
1331,
8,
277,
304,
267,
1163,
275,
5800,
3034,
855,
1222,
721,
2980,
3034,
9,
267,
1163,
14,
1365,
275,
291,
14,
1365,
267,
1163,
14,
1532,
275,
291,
14,
1532,
267,
1163,
14,
7218,
275,
291,
14,
7218,
267,
1163,
14,
2579,
63,
305,
63,
1593,
275,
291,
14,
2579,
63,
305,
63,
1593,
267,
1163,
14,
2491,
275,
277,
14,
2491,
267,
1163,
14,
29577,
275,
291,
14,
29577,
267,
1163,
14,
11582,
275,
291,
14,
11582,
398,
372,
1163,
339,
347,
485,
826,
63,
504,
63,
1532,
8,
277,
304,
267,
291,
14,
29577,
275,
291,
14,
1532,
855,
354,
363,
267,
291,
14,
11582,
275,
2519,
8,
277,
14,
1532,
12,
2668,
11582,
401,
3073,
398,
327,
664,
9444,
402,
805,
2396,
14,
8232,
83,
5259,
436,
1263,
20419,
14,
30451,
626,
267,
327,
1454,
314,
20419,
315,
642,
570,
334,
10180,
465,
283,
2613,
358,
787,
1202,
14,
267,
4355,
275,
664,
1365,
1278,
8,
277,
14,
1532,
2788,
16,
1527,
552,
8,
277,
14,
11582,
9,
435,
413,
2938,
267,
1233,
275,
22622,
17840,
904,
8,
2102,
430,
398,
327,
6998,
2385,
626,
1343,
543,
282,
3721,
15196,
9,
267,
1233,
1278,
275,
1233,
14,
1294,
2258,
78,
358,
267,
2385,
835,
275,
822,
8,
600,
1278,
9,
398,
367,
284,
12,
1004,
315,
3874,
8,
600,
1278,
304,
288,
340,
1004,
14,
2460,
7863,
735,
355,
2163,
1080,
275,
284,
435,
413,
340,
284,
665,
2385,
835,
587,
284,
446,
413,
355,
2163,
604,
275,
1233,
1278,
59,
2184,
1080,
61,
2234,
1830,
2163,
604,
14,
2460,
7863,
735,
490,
2163,
604,
275,
1233,
1278,
59,
2184,
1080,
61,
490,
2163,
1080,
275,
334,
2184,
1080,
435,
413,
340,
2163,
1080,
665,
2385,
835,
639,
587,
2163,
1080,
446,
413,
9,
2234,
1642,
1560,
275,
822,
8,
2184,
604,
9,
446,
822,
8,
2184,
604,
14,
10124,
1012,
355,
1233,
1278,
59,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
josephpbuarao/Preside-CMS
|
support/docs/source/conf.py
|
2
|
10367
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Preside CMS documentation build configuration file, created by
# sphinx-quickstart on Sun May 18 22:23:25 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
html_theme = "pixl8_rtd_theme"
html_theme_path = ["_themes", ]
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'Preside CMS'
copyright = '2014, Pixl8 Interactive'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
# html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'PresideCMSdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'PresideCMS.tex', 'Preside CMS Documentation',
'Pixl8 Interactive', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'presidecms', 'Preside CMS Documentation',
['Pixl8 Interactive'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'PresideCMS', 'Preside CMS Documentation',
'Pixl8 Interactive', 'PresideCMS', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# -- Options for Epub output ----------------------------------------------
# Bibliographic Dublin Core info.
epub_title = 'Preside CMS'
epub_author = 'Pixl8 Interactive'
epub_publisher = 'Pixl8 Interactive'
epub_copyright = '2014, Pixl8 Interactive'
# The basename for the epub file. It defaults to the project name.
#epub_basename = 'Preside CMS'
# The HTML theme for the epub output. Since the default themes are not optimized
# for small screen space, using the same theme for HTML and epub output is
# usually not wise. This defaults to 'epub', a theme designed to save visual
# space.
#epub_theme = 'epub'
# The language of the text. It defaults to the language option
# or en if the language is not set.
#epub_language = ''
# The scheme of the identifier. Typical schemes are ISBN or URL.
#epub_scheme = ''
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#epub_identifier = ''
# A unique identification for the text.
#epub_uid = ''
# A tuple containing the cover image and cover page html template filenames.
#epub_cover = ()
# A sequence of (type, uri, title) tuples for the guide element of content.opf.
#epub_guide = ()
# HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_pre_files = []
# HTML files shat should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_post_files = []
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# The depth of the table of contents in toc.ncx.
#epub_tocdepth = 3
# Allow duplicate toc entries.
#epub_tocdup = True
# Choose between 'default' and 'includehidden'.
#epub_tocscope = 'default'
# Fix unsupported image types using the PIL.
#epub_fix_images = False
# Scale large images.
#epub_max_image_width = 0
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#epub_show_urls = 'inline'
# If false, no index is generated.
#epub_use_index = True
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
5543,
2441,
29554,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
25625,
10162,
6155,
6928,
26,
1789,
26,
821,
6927,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
199,
3,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
199,
646,
747,
421,
199,
1360,
63,
7915,
275,
298,
6644,
76,
24,
63,
29048,
63,
7915,
2,
199,
1360,
63,
7915,
63,
515,
275,
2097,
63,
23900,
401,
1622,
199,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
199,
3,
5478,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
199,
3,
7869,
14,
199,
5359,
275,
359,
272,
283,
8008,
14,
832,
14,
28056,
297,
199,
61,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
283,
2398,
2441,
29554,
7,
199,
7307,
275,
283,
7280,
12,
510,
1148,
76,
24,
1010,
7502,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
283,
16,
14,
17,
7,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
283,
16,
14,
17,
14,
16,
7,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
942,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
199,
3,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
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,
525,
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,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
199,
199,
3,
982,
2549,
12,
4215,
3598,
465,
298,
2253,
1245,
2,
26603,
315,
314,
6137,
8247,
14,
199,
3,
3250,
63,
5451,
275,
756,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
11016,
10965,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
3,
3517,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
5543,
2441,
29554,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
25625,
10162,
6155,
6928,
26,
1789,
26,
821,
6927,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
199,
3,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
199,
646,
747,
421,
199,
1360,
63,
7915,
275,
298,
6644,
76,
24,
63,
29048,
63,
7915,
2,
199,
1360,
63,
7915,
63,
515,
275,
2097,
63,
23900,
401,
1622,
199,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
199,
3,
5478,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
199,
3,
7869,
14,
199,
5359,
275,
359,
272,
283,
8008,
14,
832,
14,
28056,
297,
199,
61,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
283,
2398,
2441,
29554,
7,
199,
7307,
275,
283,
7280,
12,
510,
1148,
76,
24,
1010,
7502,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
283,
16,
14,
17,
7,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
283,
16,
14,
17,
14,
16,
7,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
942,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
199,
3,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
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,
525,
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,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
199,
199,
3,
982,
2549,
12,
4215,
3598,
465,
298,
2253,
1245,
2,
26603,
315,
314,
6137,
8247,
14,
199,
3,
3250,
63,
5451,
275,
756,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
11016,
10965,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
3,
3517,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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policy_templates/writers/admx_writer_unittest.py
|
41
|
21095
|
#!/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.
"""Unittests for grit.format.policy_templates.writers.admx_writer."""
import os
import sys
import unittest
if __name__ == '__main__':
sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..'))
from grit.format.policy_templates.writers import admx_writer
from grit.format.policy_templates.writers import xml_writer_base_unittest
from xml.dom import minidom
class AdmxWriterUnittest(xml_writer_base_unittest.XmlWriterBaseTest):
def _CreateDocumentElement(self):
dom_impl = minidom.getDOMImplementation('')
doc = dom_impl.createDocument(None, 'root', None)
return doc.documentElement
def setUp(self):
# Writer configuration. This dictionary contains parameter used by the ADMX
# Writer
config = {
'win_group_policy_class': 'TestClass',
'win_supported_os': 'SUPPORTED_TESTOS',
'win_reg_mandatory_key_name': 'Software\\Policies\\Test',
'win_reg_recommended_key_name': 'Software\\Policies\\Test\\Recommended',
'win_mandatory_category_path': ['test_category'],
'win_recommended_category_path': ['test_recommended_category'],
'admx_namespace': 'ADMXWriter.Test.Namespace',
'admx_prefix': 'test_prefix',
'build': 'test_product',
}
self.writer = admx_writer.GetWriter(config)
self.writer.Init()
def _GetPoliciesElement(self, doc):
node_list = doc.getElementsByTagName('policies')
self.assertTrue(node_list.length == 1)
return node_list.item(0)
def _GetCategoriesElement(self, doc):
node_list = doc.getElementsByTagName('categories')
self.assertTrue(node_list.length == 1)
return node_list.item(0)
def testEmpty(self):
self.writer.BeginTemplate()
self.writer.EndTemplate()
output = self.writer.GetTemplateText()
expected_output = (
'<?xml version="1.0" ?>\n'
'<policyDefinitions revision="1.0" schemaVersion="1.0">\n'
' <policyNamespaces>\n'
' <target namespace="ADMXWriter.Test.Namespace"'
' prefix="test_prefix"/>\n'
' <using namespace="Microsoft.Policies.Windows" prefix="windows"/>\n'
' </policyNamespaces>\n'
' <resources minRequiredRevision="1.0"/>\n'
' <supportedOn>\n'
' <definitions>\n'
' <definition displayName="'
'$(string.SUPPORTED_TESTOS)" name="SUPPORTED_TESTOS"/>\n'
' </definitions>\n'
' </supportedOn>\n'
' <categories>\n'
' <category displayName="$(string.test_category)"'
' name="test_category"/>\n'
' <category displayName="$(string.test_recommended_category)"'
' name="test_recommended_category"/>\n'
' </categories>\n'
' <policies/>\n'
'</policyDefinitions>')
self.AssertXMLEquals(output, expected_output)
def testEmptyVersion(self):
self.writer.config['version'] = '39.0.0.0'
self.writer.BeginTemplate()
self.writer.EndTemplate()
output = self.writer.GetTemplateText()
expected_output = (
'<?xml version="1.0" ?>\n'
'<policyDefinitions revision="1.0" schemaVersion="1.0">\n'
' <!--test_product version: 39.0.0.0-->\n'
' <policyNamespaces>\n'
' <target namespace="ADMXWriter.Test.Namespace"'
' prefix="test_prefix"/>\n'
' <using namespace="Microsoft.Policies.Windows" prefix="windows"/>\n'
' </policyNamespaces>\n'
' <resources minRequiredRevision="1.0"/>\n'
' <supportedOn>\n'
' <definitions>\n'
' <definition displayName="'
'$(string.SUPPORTED_TESTOS)" name="SUPPORTED_TESTOS"/>\n'
' </definitions>\n'
' </supportedOn>\n'
' <categories>\n'
' <category displayName="$(string.test_category)"'
' name="test_category"/>\n'
' <category displayName="$(string.test_recommended_category)"'
' name="test_recommended_category"/>\n'
' </categories>\n'
' <policies/>\n'
'</policyDefinitions>')
self.AssertXMLEquals(output, expected_output)
def testEmptyPolicyGroup(self):
empty_policy_group = {
'name': 'PolicyGroup',
'policies': []
}
# Initialize writer to write a policy group.
self.writer.BeginTemplate()
# Write policy group
self.writer.BeginPolicyGroup(empty_policy_group)
self.writer.EndPolicyGroup()
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = ''
self.AssertXMLEquals(output, expected_output)
output = self.GetXMLOfChildren(
self._GetCategoriesElement(self.writer._doc))
expected_output = (
'<category displayName="$(string.test_category)"'
' name="test_category"/>\n'
'<category displayName="$(string.test_recommended_category)"'
' name="test_recommended_category"/>\n'
'<category displayName="$(string.PolicyGroup_group)"'
' name="PolicyGroup">\n'
' <parentCategory ref="test_category"/>\n'
'</category>')
self.AssertXMLEquals(output, expected_output)
def testPolicyGroup(self):
empty_policy_group = {
'name': 'PolicyGroup',
'policies': [
{'name': 'PolicyStub2',
'type': 'main'},
{'name': 'PolicyStub1',
'type': 'main'},
]
}
# Initialize writer to write a policy group.
self.writer.BeginTemplate()
# Write policy group
self.writer.BeginPolicyGroup(empty_policy_group)
self.writer.EndPolicyGroup()
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = ''
self.AssertXMLEquals(output, expected_output)
output = self.GetXMLOfChildren(
self._GetCategoriesElement(self.writer._doc))
expected_output = (
'<category displayName="$(string.test_category)"'
' name="test_category"/>\n'
'<category displayName="$(string.test_recommended_category)"'
' name="test_recommended_category"/>\n'
'<category displayName="$(string.PolicyGroup_group)"'
' name="PolicyGroup">\n'
' <parentCategory ref="test_category"/>\n'
'</category>')
self.AssertXMLEquals(output, expected_output)
def _initWriterForPolicy(self, writer, policy):
'''Initializes the writer to write the given policy next.
'''
policy_group = {
'name': 'PolicyGroup',
'policies': [policy]
}
writer.BeginTemplate()
writer.BeginPolicyGroup(policy_group)
def testMainPolicy(self):
main_policy = {
'name': 'DummyMainPolicy',
'type': 'main',
}
self._initWriterForPolicy(self.writer, main_policy)
self.writer.WritePolicy(main_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.DummyMainPolicy)"'
' explainText="$(string.DummyMainPolicy_Explain)"'
' key="Software\\Policies\\Test" name="DummyMainPolicy"'
' presentation="$(presentation.DummyMainPolicy)"'
' valueName="DummyMainPolicy">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <enabledValue>\n'
' <decimal value="1"/>\n'
' </enabledValue>\n'
' <disabledValue>\n'
' <decimal value="0"/>\n'
' </disabledValue>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testRecommendedPolicy(self):
main_policy = {
'name': 'DummyMainPolicy',
'type': 'main',
}
policy_group = {
'name': 'PolicyGroup',
'policies': [main_policy],
}
self.writer.BeginTemplate()
self.writer.BeginRecommendedPolicyGroup(policy_group)
self.writer.WriteRecommendedPolicy(main_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.DummyMainPolicy)"'
' explainText="$(string.DummyMainPolicy_Explain)"'
' key="Software\\Policies\\Test\\Recommended"'
' name="DummyMainPolicy_recommended"'
' presentation="$(presentation.DummyMainPolicy)"'
' valueName="DummyMainPolicy">\n'
' <parentCategory ref="PolicyGroup_recommended"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <enabledValue>\n'
' <decimal value="1"/>\n'
' </enabledValue>\n'
' <disabledValue>\n'
' <decimal value="0"/>\n'
' </disabledValue>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testRecommendedOnlyPolicy(self):
main_policy = {
'name': 'DummyMainPolicy',
'type': 'main',
'features': {
'can_be_recommended': True,
'can_be_mandatory': False,
}
}
policy_group = {
'name': 'PolicyGroup',
'policies': [main_policy],
}
self.writer.BeginTemplate()
self.writer.BeginRecommendedPolicyGroup(policy_group)
self.writer.WritePolicy(main_policy)
self.writer.WriteRecommendedPolicy(main_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.DummyMainPolicy)"'
' explainText="$(string.DummyMainPolicy_Explain)"'
' key="Software\\Policies\\Test\\Recommended"'
' name="DummyMainPolicy_recommended"'
' presentation="$(presentation.DummyMainPolicy)"'
' valueName="DummyMainPolicy">\n'
' <parentCategory ref="PolicyGroup_recommended"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <enabledValue>\n'
' <decimal value="1"/>\n'
' </enabledValue>\n'
' <disabledValue>\n'
' <decimal value="0"/>\n'
' </disabledValue>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testStringPolicy(self):
string_policy = {
'name': 'SampleStringPolicy',
'type': 'string',
}
self._initWriterForPolicy(self.writer, string_policy)
self.writer.WritePolicy(string_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.SampleStringPolicy)"'
' explainText="$(string.SampleStringPolicy_Explain)"'
' key="Software\\Policies\\Test" name="SampleStringPolicy"'
' presentation="$(presentation.SampleStringPolicy)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <text id="SampleStringPolicy" maxLength="1000000"'
' valueName="SampleStringPolicy"/>\n'
' </elements>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testIntPolicy(self):
int_policy = {
'name': 'SampleIntPolicy',
'type': 'int',
}
self._initWriterForPolicy(self.writer, int_policy)
self.writer.WritePolicy(int_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.SampleIntPolicy)"'
' explainText="$(string.SampleIntPolicy_Explain)"'
' key="Software\\Policies\\Test" name="SampleIntPolicy"'
' presentation="$(presentation.SampleIntPolicy)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <decimal id="SampleIntPolicy" maxValue="2000000000" '
'valueName="SampleIntPolicy"/>\n'
' </elements>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testIntEnumPolicy(self):
enum_policy = {
'name': 'SampleEnumPolicy',
'type': 'int-enum',
'items': [
{'name': 'item_1', 'value': 0},
{'name': 'item_2', 'value': 1},
]
}
self._initWriterForPolicy(self.writer, enum_policy)
self.writer.WritePolicy(enum_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.SampleEnumPolicy)"'
' explainText="$(string.SampleEnumPolicy_Explain)"'
' key="Software\\Policies\\Test" name="SampleEnumPolicy"'
' presentation="$(presentation.SampleEnumPolicy)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <enum id="SampleEnumPolicy" valueName="SampleEnumPolicy">\n'
' <item displayName="$(string.item_1)">\n'
' <value>\n'
' <decimal value="0"/>\n'
' </value>\n'
' </item>\n'
' <item displayName="$(string.item_2)">\n'
' <value>\n'
' <decimal value="1"/>\n'
' </value>\n'
' </item>\n'
' </enum>\n'
' </elements>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testStringEnumPolicy(self):
enum_policy = {
'name': 'SampleEnumPolicy',
'type': 'string-enum',
'items': [
{'name': 'item_1', 'value': 'one'},
{'name': 'item_2', 'value': 'two'},
]
}
# This test is different than the others because it also tests that space
# usage inside <string> nodes is correct.
dom_impl = minidom.getDOMImplementation('')
self.writer._doc = dom_impl.createDocument(None, 'policyDefinitions', None)
self.writer._active_policies_elem = self.writer._doc.documentElement
self.writer._active_mandatory_policy_group_name = 'PolicyGroup'
self.writer.WritePolicy(enum_policy)
output = self.writer.GetTemplateText()
expected_output = (
'<?xml version="1.0" ?>\n'
'<policyDefinitions>\n'
' <policy class="TestClass" displayName="$(string.SampleEnumPolicy)"'
' explainText="$(string.SampleEnumPolicy_Explain)"'
' key="Software\\Policies\\Test" name="SampleEnumPolicy"'
' presentation="$(presentation.SampleEnumPolicy)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <enum id="SampleEnumPolicy" valueName="SampleEnumPolicy">\n'
' <item displayName="$(string.item_1)">\n'
' <value>\n'
' <string>one</string>\n'
' </value>\n'
' </item>\n'
' <item displayName="$(string.item_2)">\n'
' <value>\n'
' <string>two</string>\n'
' </value>\n'
' </item>\n'
' </enum>\n'
' </elements>\n'
' </policy>\n'
'</policyDefinitions>')
self.AssertXMLEquals(output, expected_output)
def testListPolicy(self):
list_policy = {
'name': 'SampleListPolicy',
'type': 'list',
}
self._initWriterForPolicy(self.writer, list_policy)
self.writer.WritePolicy(list_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.SampleListPolicy)"'
' explainText="$(string.SampleListPolicy_Explain)"'
' key="Software\\Policies\\Test" name="SampleListPolicy"'
' presentation="$(presentation.SampleListPolicy)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <list id="SampleListPolicyDesc"'
' key="Software\Policies\Test\SampleListPolicy" valuePrefix=""/>\n'
' </elements>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testStringEnumListPolicy(self):
list_policy = {
'name': 'SampleListPolicy',
'type': 'string-enum-list',
'items': [
{'name': 'item_1', 'value': 'one'},
{'name': 'item_2', 'value': 'two'},
]
}
self._initWriterForPolicy(self.writer, list_policy)
self.writer.WritePolicy(list_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.SampleListPolicy)"'
' explainText="$(string.SampleListPolicy_Explain)"'
' key="Software\\Policies\\Test" name="SampleListPolicy"'
' presentation="$(presentation.SampleListPolicy)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <list id="SampleListPolicyDesc"'
' key="Software\Policies\Test\SampleListPolicy" valuePrefix=""/>\n'
' </elements>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testDictionaryPolicy(self):
dict_policy = {
'name': 'SampleDictionaryPolicy',
'type': 'dict',
}
self._initWriterForPolicy(self.writer, dict_policy)
self.writer.WritePolicy(dict_policy)
output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
expected_output = (
'<policy class="TestClass" displayName="$(string.'
'SampleDictionaryPolicy)"'
' explainText="$(string.SampleDictionaryPolicy_Explain)"'
' key="Software\\Policies\\Test" name="SampleDictionaryPolicy"'
' presentation="$(presentation.SampleDictionaryPolicy)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <text id="SampleDictionaryPolicy" maxLength="1000000"'
' valueName="SampleDictionaryPolicy"/>\n'
' </elements>\n'
'</policy>')
self.AssertXMLEquals(output, expected_output)
def testPlatform(self):
# Test that the writer correctly chooses policies of platform Windows.
self.assertTrue(self.writer.IsPolicySupported({
'supported_on': [
{'platforms': ['win', 'zzz']}, {'platforms': ['aaa']}
]
}))
self.assertFalse(self.writer.IsPolicySupported({
'supported_on': [
{'platforms': ['mac', 'linux']}, {'platforms': ['aaa']}
]
}))
def testStringEncodings(self):
enum_policy_a = {
'name': 'SampleEnumPolicy.A',
'type': 'string-enum',
'items': [
{'name': 'tls1.2', 'value': 'tls1.2'}
]
}
enum_policy_b = {
'name': 'SampleEnumPolicy.B',
'type': 'string-enum',
'items': [
{'name': 'tls1.2', 'value': 'tls1.2'}
]
}
dom_impl = minidom.getDOMImplementation('')
self.writer._doc = dom_impl.createDocument(None, 'policyDefinitions', None)
self.writer._active_policies_elem = self.writer._doc.documentElement
self.writer._active_mandatory_policy_group_name = 'PolicyGroup'
self.writer.WritePolicy(enum_policy_a)
self.writer.WritePolicy(enum_policy_b)
output = self.writer.GetTemplateText()
expected_output = (
'<?xml version="1.0" ?>\n'
'<policyDefinitions>\n'
' <policy class="TestClass" displayName="$(string.SampleEnumPolicy_A)"'
' explainText="$(string.SampleEnumPolicy_A_Explain)"'
' key="Software\\Policies\\Test" name="SampleEnumPolicy.A"'
' presentation="$(presentation.SampleEnumPolicy.A)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <enum id="SampleEnumPolicy.A" valueName="SampleEnumPolicy.A">\n'
' <item displayName="$(string.tls1_2)">\n'
' <value>\n'
' <string>tls1.2</string>\n'
' </value>\n'
' </item>\n'
' </enum>\n'
' </elements>\n'
' </policy>\n'
' <policy class="TestClass" displayName="$(string.SampleEnumPolicy_B)"'
' explainText="$(string.SampleEnumPolicy_B_Explain)"'
' key="Software\\Policies\\Test" name="SampleEnumPolicy.B"'
' presentation="$(presentation.SampleEnumPolicy.B)">\n'
' <parentCategory ref="PolicyGroup"/>\n'
' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
' <elements>\n'
' <enum id="SampleEnumPolicy.B" valueName="SampleEnumPolicy.B">\n'
' <item displayName="$(string.tls1_2)">\n'
' <value>\n'
' <string>tls1.2</string>\n'
' </value>\n'
' </item>\n'
' </enum>\n'
' </elements>\n'
' </policy>\n'
'</policyDefinitions>')
self.AssertXMLEquals(output, expected_output)
if __name__ == '__main__':
unittest.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,
421,
199,
624,
1358,
1770,
83,
367,
486,
11133,
14,
908,
14,
3185,
63,
5876,
14,
26224,
14,
350,
9457,
63,
5491,
1041,
421,
199,
646,
747,
199,
646,
984,
199,
646,
2882,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
984,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
29866,
703,
1333,
421,
199,
504,
486,
11133,
14,
908,
14,
3185,
63,
5876,
14,
26224,
492,
1503,
9457,
63,
5491,
199,
504,
486,
11133,
14,
908,
14,
3185,
63,
5876,
14,
26224,
492,
2748,
63,
5491,
63,
1095,
63,
2796,
199,
504,
2748,
14,
4556,
492,
19165,
421,
199,
533,
4431,
9457,
6261,
1358,
1770,
8,
1652,
63,
5491,
63,
1095,
63,
2796,
14,
8672,
6261,
23170,
304,
819,
347,
485,
2499,
5564,
2162,
8,
277,
304,
272,
8266,
63,
5472,
275,
19165,
14,
362,
10462,
7921,
8355,
272,
1382,
275,
8266,
63,
5472,
14,
981,
5564,
8,
403,
12,
283,
1231,
297,
488,
9,
272,
372,
1382,
14,
22464,
819,
347,
3613,
8,
277,
304,
272,
327,
24441,
2897,
14,
961,
2600,
3509,
2725,
1202,
701,
314,
16271,
17401,
272,
327,
24441,
272,
1101,
275,
469,
489,
283,
2676,
63,
923,
63,
3185,
63,
533,
356,
283,
22009,
297,
489,
283,
2676,
63,
4946,
63,
736,
356,
283,
15925,
63,
2864,
3100,
297,
489,
283,
2676,
63,
1135,
63,
19900,
63,
498,
63,
354,
356,
283,
10337,
1103,
27079,
1103,
774,
297,
489,
283,
2676,
63,
1135,
63,
264,
11902,
63,
498,
63,
354,
356,
283,
10337,
1103,
27079,
1103,
774,
1103,
497,
11902,
297,
489,
283,
2676,
63,
19900,
63,
3710,
63,
515,
356,
788,
396,
63,
3710,
995,
489,
283,
2676,
63,
264,
11902,
63,
3710,
63,
515,
356,
788,
396,
63,
264,
11902,
63,
3710,
995,
489,
283,
350,
9457,
63,
3251,
356,
283,
1554,
17401,
6261,
14,
774,
14,
8814,
297,
489,
283,
350,
9457,
63,
1861,
356,
283,
396,
63,
1861,
297,
489,
283,
1506,
356,
283,
396,
63,
2558,
297,
272,
789,
272,
291,
14,
5491,
275,
1503,
9457,
63,
5491,
14,
1002,
6261,
8,
888,
9,
272,
291,
14,
5491,
14,
9346,
342,
819,
347,
485,
1002,
27079,
2162,
8,
277,
12,
1382,
304,
272,
1031,
63,
513,
275,
1382,
14,
15045,
360,
11767,
358,
272,
291,
14,
1815,
8,
932,
63,
513,
14,
1267,
508,
413,
9,
272,
372,
1031,
63,
513,
14,
1053,
8,
16,
9,
819,
347,
485,
1002,
28731,
2162,
8,
277,
12,
1382,
304,
272,
1031,
63,
513,
275,
1382,
14,
15045,
360,
8906,
358,
272,
291,
14,
1815,
8,
932,
63,
513,
14,
1267,
508,
413,
9,
272,
372,
1031,
63,
513,
14,
1053,
8,
16,
9,
819,
347,
511,
4699,
8,
277,
304,
272,
291,
14,
5491,
14,
5595,
4231,
342,
272,
291,
14,
5491,
14,
3005,
4231,
342,
339,
1072,
275,
291,
14,
5491,
14,
1002,
4231,
1872,
342,
272,
1420,
63,
1199,
275,
334,
267,
2650,
31,
1652,
1015,
628,
17,
14,
16,
2,
5805,
3072,
78,
7,
267,
2650,
3185,
16738,
6974,
628,
17,
14,
16,
2,
4177,
3353,
628,
17,
14,
16,
14559,
78,
7,
267,
283,
221,
665,
3185,
985,
10749,
3072,
78,
7,
267,
283,
259,
665,
1375,
3231,
628,
1554,
17401,
6261,
14,
774,
14,
8814,
4507,
267,
283,
2403,
628,
396,
63,
1861,
15313,
3072,
78,
7,
267,
283,
259,
665,
4941,
3231,
628,
12940,
14,
27079,
14,
8647,
2,
2403,
628,
8258,
15313,
3072,
78,
7,
267,
283,
221,
3068,
3185,
985,
10749,
3072,
78,
7,
267,
283,
221,
665,
4435,
1748,
8030,
12714,
628,
17,
14,
16,
15313,
3072,
78,
7,
267,
283,
221,
665,
4946,
3314,
3072,
78,
7,
267,
283,
259,
665,
15388,
3072,
78,
7,
267,
283,
420,
665,
7463,
2929,
985,
26957,
267,
9774,
875,
14,
15925,
63,
2864,
3100,
2924,
536,
628,
15925,
63,
2864,
3100,
15313,
3072,
78,
7,
267,
283,
259,
3068,
15388,
3072,
78,
7,
267,
283,
221,
3068,
4946,
3314,
3072,
78,
7,
267,
283,
221,
665,
8906,
3072,
78,
7,
267,
283,
259,
665,
3710,
2929,
985,
628,
6629,
875,
14,
396,
63,
3710,
2924,
7,
267,
283,
536,
628,
396,
63,
3710,
15313,
3072,
78,
7,
267,
283,
259,
665,
3710,
2929,
985,
628,
6629,
875,
14,
396,
63,
264,
11902,
63,
3710,
2924,
7,
267,
283,
536,
628,
396,
63,
264,
11902,
63,
3710,
15313,
3072,
78,
7,
267,
283,
221,
3068,
8906,
3072,
78,
7,
267,
283,
221,
665,
11767,
15,
3072,
78,
7,
267,
11936,
3185,
16738,
5971,
272,
291,
14,
9699,
4317,
13317,
8,
1199,
12,
1420,
63,
1199,
9,
819,
347,
511,
4699,
3353,
8,
277,
304,
272,
291,
14,
5491,
14,
888,
459,
1023,
418,
275,
283,
1355,
14,
16,
14,
16,
14,
16,
7,
272,
291,
14,
5491,
14,
5595,
4231,
342,
272,
291,
14,
5491,
14,
3005,
4231,
342,
339,
1072,
275,
291,
14,
5491,
14,
1002,
4231,
1872,
342,
272,
1420,
63,
1199,
275,
334,
267,
2650,
31,
1652,
1015,
628,
17,
14,
16,
2,
5805,
3072,
78,
7,
267,
2650,
3185,
16738,
6974,
628,
17,
14,
16,
2,
4177,
3353,
628,
17,
14,
16,
14559,
78,
7,
267,
283,
221,
28253,
396,
63,
2558,
1015,
26,
10551,
14,
16,
14,
16,
14,
16,
306,
3072,
78,
7,
267,
283,
221,
665,
3185,
985,
10749,
3072,
78,
7,
267,
283,
259,
665,
1375,
3231,
628,
1554,
17401,
6261,
14,
774,
14,
8814,
4507,
267,
283,
2403,
628,
396,
63,
1861,
15313,
3072,
78,
7,
267,
283,
259,
665,
4941,
3231,
628,
12940,
14,
27079,
14,
8647,
2,
2403,
628,
8258,
15313,
3072,
78,
7,
267,
283,
221,
3068,
3185,
985,
10749,
3072,
78,
7,
267,
283,
221,
665,
4435,
1748,
8030,
12714,
628,
17,
14,
16,
15313,
3072,
78,
7,
267,
283,
221,
665,
4946,
3314
] |
[
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,
421,
199,
624,
1358,
1770,
83,
367,
486,
11133,
14,
908,
14,
3185,
63,
5876,
14,
26224,
14,
350,
9457,
63,
5491,
1041,
421,
199,
646,
747,
199,
646,
984,
199,
646,
2882,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
984,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
29866,
703,
1333,
421,
199,
504,
486,
11133,
14,
908,
14,
3185,
63,
5876,
14,
26224,
492,
1503,
9457,
63,
5491,
199,
504,
486,
11133,
14,
908,
14,
3185,
63,
5876,
14,
26224,
492,
2748,
63,
5491,
63,
1095,
63,
2796,
199,
504,
2748,
14,
4556,
492,
19165,
421,
199,
533,
4431,
9457,
6261,
1358,
1770,
8,
1652,
63,
5491,
63,
1095,
63,
2796,
14,
8672,
6261,
23170,
304,
819,
347,
485,
2499,
5564,
2162,
8,
277,
304,
272,
8266,
63,
5472,
275,
19165,
14,
362,
10462,
7921,
8355,
272,
1382,
275,
8266,
63,
5472,
14,
981,
5564,
8,
403,
12,
283,
1231,
297,
488,
9,
272,
372,
1382,
14,
22464,
819,
347,
3613,
8,
277,
304,
272,
327,
24441,
2897,
14,
961,
2600,
3509,
2725,
1202,
701,
314,
16271,
17401,
272,
327,
24441,
272,
1101,
275,
469,
489,
283,
2676,
63,
923,
63,
3185,
63,
533,
356,
283,
22009,
297,
489,
283,
2676,
63,
4946,
63,
736,
356,
283,
15925,
63,
2864,
3100,
297,
489,
283,
2676,
63,
1135,
63,
19900,
63,
498,
63,
354,
356,
283,
10337,
1103,
27079,
1103,
774,
297,
489,
283,
2676,
63,
1135,
63,
264,
11902,
63,
498,
63,
354,
356,
283,
10337,
1103,
27079,
1103,
774,
1103,
497,
11902,
297,
489,
283,
2676,
63,
19900,
63,
3710,
63,
515,
356,
788,
396,
63,
3710,
995,
489,
283,
2676,
63,
264,
11902,
63,
3710,
63,
515,
356,
788,
396,
63,
264,
11902,
63,
3710,
995,
489,
283,
350,
9457,
63,
3251,
356,
283,
1554,
17401,
6261,
14,
774,
14,
8814,
297,
489,
283,
350,
9457,
63,
1861,
356,
283,
396,
63,
1861,
297,
489,
283,
1506,
356,
283,
396,
63,
2558,
297,
272,
789,
272,
291,
14,
5491,
275,
1503,
9457,
63,
5491,
14,
1002,
6261,
8,
888,
9,
272,
291,
14,
5491,
14,
9346,
342,
819,
347,
485,
1002,
27079,
2162,
8,
277,
12,
1382,
304,
272,
1031,
63,
513,
275,
1382,
14,
15045,
360,
11767,
358,
272,
291,
14,
1815,
8,
932,
63,
513,
14,
1267,
508,
413,
9,
272,
372,
1031,
63,
513,
14,
1053,
8,
16,
9,
819,
347,
485,
1002,
28731,
2162,
8,
277,
12,
1382,
304,
272,
1031,
63,
513,
275,
1382,
14,
15045,
360,
8906,
358,
272,
291,
14,
1815,
8,
932,
63,
513,
14,
1267,
508,
413,
9,
272,
372,
1031,
63,
513,
14,
1053,
8,
16,
9,
819,
347,
511,
4699,
8,
277,
304,
272,
291,
14,
5491,
14,
5595,
4231,
342,
272,
291,
14,
5491,
14,
3005,
4231,
342,
339,
1072,
275,
291,
14,
5491,
14,
1002,
4231,
1872,
342,
272,
1420,
63,
1199,
275,
334,
267,
2650,
31,
1652,
1015,
628,
17,
14,
16,
2,
5805,
3072,
78,
7,
267,
2650,
3185,
16738,
6974,
628,
17,
14,
16,
2,
4177,
3353,
628,
17,
14,
16,
14559,
78,
7,
267,
283,
221,
665,
3185,
985,
10749,
3072,
78,
7,
267,
283,
259,
665,
1375,
3231,
628,
1554,
17401,
6261,
14,
774,
14,
8814,
4507,
267,
283,
2403,
628,
396,
63,
1861,
15313,
3072,
78,
7,
267,
283,
259,
665,
4941,
3231,
628,
12940,
14,
27079,
14,
8647,
2,
2403,
628,
8258,
15313,
3072,
78,
7,
267,
283,
221,
3068,
3185,
985,
10749,
3072,
78,
7,
267,
283,
221,
665,
4435,
1748,
8030,
12714,
628,
17,
14,
16,
15313,
3072,
78,
7,
267,
283,
221,
665,
4946,
3314,
3072,
78,
7,
267,
283,
259,
665,
15388,
3072,
78,
7,
267,
283,
420,
665,
7463,
2929,
985,
26957,
267,
9774,
875,
14,
15925,
63,
2864,
3100,
2924,
536,
628,
15925,
63,
2864,
3100,
15313,
3072,
78,
7,
267,
283,
259,
3068,
15388,
3072,
78,
7,
267,
283,
221,
3068,
4946,
3314,
3072,
78,
7,
267,
283,
221,
665,
8906,
3072,
78,
7,
267,
283,
259,
665,
3710,
2929,
985,
628,
6629,
875,
14,
396,
63,
3710,
2924,
7,
267,
283,
536,
628,
396,
63,
3710,
15313,
3072,
78,
7,
267,
283,
259,
665,
3710,
2929,
985,
628,
6629,
875,
14,
396,
63,
264,
11902,
63,
3710,
2924,
7,
267,
283,
536,
628,
396,
63,
264,
11902,
63,
3710,
15313,
3072,
78,
7,
267,
283,
221,
3068,
8906,
3072,
78,
7,
267,
283,
221,
665,
11767,
15,
3072,
78,
7,
267,
11936,
3185,
16738,
5971,
272,
291,
14,
9699,
4317,
13317,
8,
1199,
12,
1420,
63,
1199,
9,
819,
347,
511,
4699,
3353,
8,
277,
304,
272,
291,
14,
5491,
14,
888,
459,
1023,
418,
275,
283,
1355,
14,
16,
14,
16,
14,
16,
7,
272,
291,
14,
5491,
14,
5595,
4231,
342,
272,
291,
14,
5491,
14,
3005,
4231,
342,
339,
1072,
275,
291,
14,
5491,
14,
1002,
4231,
1872,
342,
272,
1420,
63,
1199,
275,
334,
267,
2650,
31,
1652,
1015,
628,
17,
14,
16,
2,
5805,
3072,
78,
7,
267,
2650,
3185,
16738,
6974,
628,
17,
14,
16,
2,
4177,
3353,
628,
17,
14,
16,
14559,
78,
7,
267,
283,
221,
28253,
396,
63,
2558,
1015,
26,
10551,
14,
16,
14,
16,
14,
16,
306,
3072,
78,
7,
267,
283,
221,
665,
3185,
985,
10749,
3072,
78,
7,
267,
283,
259,
665,
1375,
3231,
628,
1554,
17401,
6261,
14,
774,
14,
8814,
4507,
267,
283,
2403,
628,
396,
63,
1861,
15313,
3072,
78,
7,
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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
] |
myerpengine/odoo
|
addons/report/tests/test_reports.py
|
385
|
2251
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2014-Today OpenERP SA (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 logging
import openerp
import openerp.tests
_logger = logging.getLogger(__name__)
@openerp.tests.common.at_install(False)
@openerp.tests.common.post_install(True)
class TestReports(openerp.tests.TransactionCase):
def test_reports(self):
registry, cr, uid = self.registry, self.cr, self.uid
r_model = registry('ir.actions.report.xml')
domain = [('report_type', 'like', 'qweb')]
for r in r_model.browse(cr, uid, r_model.search(cr, uid, domain)):
report_model = 'report.%s' % r.report_name
try:
registry(report_model)
except KeyError:
# Only test the generic reports here
_logger.info("testing report %s", r.report_name)
report_model = registry(r.model)
report_model_ids = report_model.search(cr, uid, [], limit=10)
if not report_model_ids:
_logger.info("no record found skipping report %s", r.report_name)
if not r.multi:
report_model_ids = report_model_ids[:1]
# Test report generation
registry('report').get_html(cr, uid, report_model_ids, r.report_name)
else:
continue
|
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,
6927,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
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,
646,
2050,
199,
199,
646,
5166,
199,
646,
5166,
14,
2219,
421,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
32,
11267,
14,
2219,
14,
2330,
14,
292,
63,
3174,
8,
797,
9,
199,
32,
11267,
14,
2219,
14,
2330,
14,
1932,
63,
3174,
8,
549,
9,
199,
533,
1379,
497,
5203,
8,
11267,
14,
2219,
14,
10161,
1538,
304,
272,
347,
511,
63,
15629,
8,
277,
304,
267,
7086,
12,
2467,
12,
1747,
275,
291,
14,
5189,
12,
291,
14,
1556,
12,
291,
14,
1535,
267,
519,
63,
1238,
275,
7086,
360,
723,
14,
3723,
14,
3070,
14,
1652,
358,
267,
2881,
275,
4274,
3070,
63,
466,
297,
283,
2930,
297,
283,
22600,
5440,
267,
367,
519,
315,
519,
63,
1238,
14,
4570,
8,
1556,
12,
1747,
12,
519,
63,
1238,
14,
1733,
8,
1556,
12,
1747,
12,
2881,
2298,
288,
3622,
63,
1238,
275,
283,
3070,
4111,
83,
7,
450,
519,
14,
3070,
63,
354,
288,
862,
26,
355,
7086,
8,
3070,
63,
1238,
9,
288,
871,
4067,
26,
288,
327,
5972,
511,
314,
7809,
13924,
2348,
355,
485,
2921,
14,
815,
480,
4776,
3622,
450,
83,
401,
519,
14,
3070,
63,
354,
9,
355,
3622,
63,
1238,
275,
7086,
8,
82,
14,
1238,
9,
355,
3622,
63,
1238,
63,
1580,
275,
3622,
63,
1238,
14,
1733,
8,
1556,
12,
1747,
12,
990,
2304,
29,
709,
9,
355,
340,
440,
3622,
63,
1238,
63,
1580,
26,
490,
485,
2921,
14,
815,
480,
889,
2777,
1911,
16068,
3622,
450,
83,
401,
519,
14,
3070,
63,
354,
9,
355,
340,
440,
519,
14,
3029,
26,
490,
3622,
63,
1238,
63,
1580,
275,
3622,
63,
1238,
63,
1580,
1491,
17,
61,
2234,
327,
1379,
3622,
10152,
355,
7086,
360,
3070,
1959,
362,
63,
1360,
8,
1556,
12,
1747,
12,
3622,
63,
1238,
63,
1580,
12,
519,
14,
3070,
63,
354,
9,
288,
587,
26,
355,
1980,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
6927,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
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,
646,
2050,
199,
199,
646,
5166,
199,
646,
5166,
14,
2219,
421,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
32,
11267,
14,
2219,
14,
2330,
14,
292,
63,
3174,
8,
797,
9,
199,
32,
11267,
14,
2219,
14,
2330,
14,
1932,
63,
3174,
8,
549,
9,
199,
533,
1379,
497,
5203,
8,
11267,
14,
2219,
14,
10161,
1538,
304,
272,
347,
511,
63,
15629,
8,
277,
304,
267,
7086,
12,
2467,
12,
1747,
275,
291,
14,
5189,
12,
291,
14,
1556,
12,
291,
14,
1535,
267,
519,
63,
1238,
275,
7086,
360,
723,
14,
3723,
14,
3070,
14,
1652,
358,
267,
2881,
275,
4274,
3070,
63,
466,
297,
283,
2930,
297,
283,
22600,
5440,
267,
367,
519,
315,
519,
63,
1238,
14,
4570,
8,
1556,
12,
1747,
12,
519,
63,
1238,
14,
1733,
8,
1556,
12,
1747,
12,
2881,
2298,
288,
3622,
63,
1238,
275,
283,
3070,
4111,
83,
7,
450,
519,
14,
3070,
63,
354,
288,
862,
26,
355,
7086,
8,
3070,
63,
1238,
9,
288,
871,
4067,
26,
288,
327,
5972,
511,
314,
7809,
13924,
2348,
355,
485,
2921,
14,
815,
480,
4776,
3622,
450,
83,
401,
519,
14,
3070,
63,
354,
9,
355,
3622,
63,
1238,
275,
7086,
8,
82,
14,
1238,
9,
355,
3622,
63,
1238,
63,
1580,
275,
3622,
63,
1238,
14,
1733,
8,
1556,
12,
1747,
12,
990,
2304,
29,
709,
9,
355,
340,
440,
3622,
63,
1238,
63,
1580,
26,
490,
485,
2921,
14,
815,
480,
889,
2777,
1911,
16068,
3622,
450,
83,
401,
519,
14,
3070,
63,
354,
9,
355,
340,
440,
519,
14,
3029,
26,
490,
3622,
63,
1238,
63,
1580,
275,
3622,
63,
1238,
63,
1580,
1491,
17,
61,
2234,
327,
1379,
3622,
10152,
355,
7086,
360,
3070,
1959,
362,
63,
1360,
8,
1556,
12,
1747,
12,
3622,
63,
1238,
63,
1580,
12,
519,
14,
3070,
63,
354,
9,
288,
587,
26,
355,
1980,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
AloneRoad/Inforlearn
|
vendor/django/forms/util.py
|
12
|
2577
|
from django.utils.html import conditional_escape
from django.utils.encoding import smart_unicode, StrAndUnicode, force_unicode
from django.utils.safestring import mark_safe
def flatatt(attrs):
"""
Convert a dictionary of attributes to a single string.
The returned string will contain a leading space followed by key="value",
XML-style pairs. It is assumed that the keys do not need to be XML-escaped.
If the passed dictionary is empty, then return an empty string.
"""
return u''.join([u' %s="%s"' % (k, conditional_escape(v)) for k, v in attrs.items()])
class ErrorDict(dict, StrAndUnicode):
"""
A collection of errors that knows how to display itself in various formats.
The dictionary keys are the field names, and the values are the errors.
"""
def __unicode__(self):
return self.as_ul()
def as_ul(self):
if not self: return u''
return mark_safe(u'<ul class="errorlist">%s</ul>'
% ''.join([u'<li>%s%s</li>' % (k, force_unicode(v))
for k, v in self.items()]))
def as_text(self):
return u'\n'.join([u'* %s\n%s' % (k, u'\n'.join([u' * %s' % force_unicode(i) for i in v])) for k, v in self.items()])
class ErrorList(list, StrAndUnicode):
"""
A collection of errors that knows how to display itself in various formats.
"""
def __unicode__(self):
return self.as_ul()
def as_ul(self):
if not self: return u''
return mark_safe(u'<ul class="errorlist">%s</ul>'
% ''.join([u'<li>%s</li>' % force_unicode(e) for e in self]))
def as_text(self):
if not self: return u''
return u'\n'.join([u'* %s' % force_unicode(e) for e in self])
def __repr__(self):
return repr([force_unicode(e) for e in self])
class ValidationError(Exception):
def __init__(self, message):
"""
ValidationError can be passed any object that can be printed (usually
a string) or a list of objects.
"""
if isinstance(message, list):
self.messages = ErrorList([smart_unicode(msg) for msg in message])
else:
message = smart_unicode(message)
self.messages = ErrorList([message])
def __str__(self):
# This is needed because, without a __str__(), printing an exception
# instance would result in this:
# AttributeError: ValidationError instance has no attribute 'args'
# See http://www.python.org/doc/current/tut/node10.html#handling
return repr(self.messages)
|
apache-2.0
|
[
504,
1639,
14,
1208,
14,
1360,
492,
12303,
63,
3765,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
2975,
12,
8303,
3325,
7087,
12,
3542,
63,
2975,
199,
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
199,
199,
318,
6829,
6796,
8,
3288,
304,
272,
408,
272,
7905,
282,
2600,
402,
3004,
370,
282,
2849,
1059,
14,
272,
710,
2138,
1059,
911,
1395,
282,
9186,
4601,
9437,
701,
790,
628,
585,
401,
272,
4692,
13,
2487,
6342,
14,
221,
2779,
365,
10826,
626,
314,
2883,
886,
440,
1929,
370,
506,
4692,
13,
13572,
14,
272,
982,
314,
3032,
2600,
365,
2701,
12,
2066,
372,
376,
2701,
1059,
14,
272,
408,
272,
372,
399,
17067,
904,
779,
85,
7,
450,
83,
5961,
83,
4507,
450,
334,
75,
12,
12303,
63,
3765,
8,
86,
430,
367,
1022,
12,
373,
315,
3290,
14,
1744,
9383,
199,
199,
533,
4520,
2141,
8,
807,
12,
8303,
3325,
7087,
304,
272,
408,
272,
437,
3245,
402,
2552,
626,
19428,
4212,
370,
2929,
6337,
315,
7750,
6752,
14,
339,
710,
2600,
2883,
787,
314,
901,
1561,
12,
436,
314,
1338,
787,
314,
2552,
14,
272,
408,
272,
347,
636,
2975,
721,
277,
304,
267,
372,
291,
14,
305,
63,
348,
342,
339,
347,
465,
63,
348,
8,
277,
304,
267,
340,
440,
291,
26,
372,
399,
891,
267,
372,
2216,
63,
3489,
8,
85,
7601,
348,
1021,
628,
22326,
14423,
83,
1108,
348,
3524,
355,
450,
6522,
904,
779,
85,
7601,
317,
6598,
83,
5,
83,
1108,
317,
3524,
450,
334,
75,
12,
3542,
63,
2975,
8,
86,
430,
490,
367,
1022,
12,
373,
315,
291,
14,
1744,
342,
2459,
339,
347,
465,
63,
505,
8,
277,
304,
267,
372,
399,
1154,
78,
1370,
904,
779,
85,
16804,
450,
83,
60,
78,
5,
83,
7,
450,
334,
75,
12,
399,
1154,
78,
1370,
904,
779,
85,
7,
221,
627,
450,
83,
7,
450,
3542,
63,
2975,
8,
73,
9,
367,
284,
315,
373,
2459,
367,
1022,
12,
373,
315,
291,
14,
1744,
9383,
199,
199,
533,
4520,
1296,
8,
513,
12,
8303,
3325,
7087,
304,
272,
408,
272,
437,
3245,
402,
2552,
626,
19428,
4212,
370,
2929,
6337,
315,
7750,
6752,
14,
272,
408,
272,
347,
636,
2975,
721,
277,
304,
267,
372,
291,
14,
305,
63,
348,
342,
339,
347,
465,
63,
348,
8,
277,
304,
267,
340,
440,
291,
26,
372,
399,
891,
267,
372,
2216,
63,
3489,
8,
85,
7601,
348,
1021,
628,
22326,
14423,
83,
1108,
348,
3524,
355,
450,
6522,
904,
779,
85,
7601,
317,
6598,
83,
1108,
317,
3524,
450,
3542,
63,
2975,
8,
69,
9,
367,
325,
315,
291,
2459,
339,
347,
465,
63,
505,
8,
277,
304,
267,
340,
440,
291,
26,
372,
399,
891,
267,
372,
399,
1154,
78,
1370,
904,
779,
85,
16804,
450,
83,
7,
450,
3542,
63,
2975,
8,
69,
9,
367,
325,
315,
291,
566,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
4700,
779,
3990,
63,
2975,
8,
69,
9,
367,
325,
315,
291,
566,
199,
199,
533,
8505,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1245,
304,
267,
408,
267,
8505,
883,
506,
3032,
1263,
909,
626,
883,
506,
12487,
334,
25118,
267,
282,
1059,
9,
503,
282,
769,
402,
2251,
14,
267,
408,
267,
340,
1228,
8,
1188,
12,
769,
304,
288,
291,
14,
3431,
275,
4520,
1296,
779,
7853,
63,
2975,
8,
1328,
9,
367,
1499,
315,
1245,
566,
267,
587,
26,
288,
1245,
275,
11179,
63,
2975,
8,
1188,
9,
288,
291,
14,
3431,
275,
4520,
1296,
779,
1188,
566,
339,
347,
636,
495,
721,
277,
304,
267,
327,
961,
365,
4346,
2952,
12,
1928,
282,
636,
495,
29709,
16116,
376,
1919,
267,
327,
1256,
3955,
754,
315,
642,
26,
267,
327,
4281,
26,
8505,
1256,
965,
949,
2225,
283,
589,
7,
267,
327,
1666,
1455,
921,
1544,
14,
1548,
14,
1308,
15,
1301,
15,
1818,
15,
84,
337,
15,
932,
709,
14,
1360,
3,
22273,
267,
372,
4700,
8,
277,
14,
3431,
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
] |
[
1639,
14,
1208,
14,
1360,
492,
12303,
63,
3765,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
2975,
12,
8303,
3325,
7087,
12,
3542,
63,
2975,
199,
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
199,
199,
318,
6829,
6796,
8,
3288,
304,
272,
408,
272,
7905,
282,
2600,
402,
3004,
370,
282,
2849,
1059,
14,
272,
710,
2138,
1059,
911,
1395,
282,
9186,
4601,
9437,
701,
790,
628,
585,
401,
272,
4692,
13,
2487,
6342,
14,
221,
2779,
365,
10826,
626,
314,
2883,
886,
440,
1929,
370,
506,
4692,
13,
13572,
14,
272,
982,
314,
3032,
2600,
365,
2701,
12,
2066,
372,
376,
2701,
1059,
14,
272,
408,
272,
372,
399,
17067,
904,
779,
85,
7,
450,
83,
5961,
83,
4507,
450,
334,
75,
12,
12303,
63,
3765,
8,
86,
430,
367,
1022,
12,
373,
315,
3290,
14,
1744,
9383,
199,
199,
533,
4520,
2141,
8,
807,
12,
8303,
3325,
7087,
304,
272,
408,
272,
437,
3245,
402,
2552,
626,
19428,
4212,
370,
2929,
6337,
315,
7750,
6752,
14,
339,
710,
2600,
2883,
787,
314,
901,
1561,
12,
436,
314,
1338,
787,
314,
2552,
14,
272,
408,
272,
347,
636,
2975,
721,
277,
304,
267,
372,
291,
14,
305,
63,
348,
342,
339,
347,
465,
63,
348,
8,
277,
304,
267,
340,
440,
291,
26,
372,
399,
891,
267,
372,
2216,
63,
3489,
8,
85,
7601,
348,
1021,
628,
22326,
14423,
83,
1108,
348,
3524,
355,
450,
6522,
904,
779,
85,
7601,
317,
6598,
83,
5,
83,
1108,
317,
3524,
450,
334,
75,
12,
3542,
63,
2975,
8,
86,
430,
490,
367,
1022,
12,
373,
315,
291,
14,
1744,
342,
2459,
339,
347,
465,
63,
505,
8,
277,
304,
267,
372,
399,
1154,
78,
1370,
904,
779,
85,
16804,
450,
83,
60,
78,
5,
83,
7,
450,
334,
75,
12,
399,
1154,
78,
1370,
904,
779,
85,
7,
221,
627,
450,
83,
7,
450,
3542,
63,
2975,
8,
73,
9,
367,
284,
315,
373,
2459,
367,
1022,
12,
373,
315,
291,
14,
1744,
9383,
199,
199,
533,
4520,
1296,
8,
513,
12,
8303,
3325,
7087,
304,
272,
408,
272,
437,
3245,
402,
2552,
626,
19428,
4212,
370,
2929,
6337,
315,
7750,
6752,
14,
272,
408,
272,
347,
636,
2975,
721,
277,
304,
267,
372,
291,
14,
305,
63,
348,
342,
339,
347,
465,
63,
348,
8,
277,
304,
267,
340,
440,
291,
26,
372,
399,
891,
267,
372,
2216,
63,
3489,
8,
85,
7601,
348,
1021,
628,
22326,
14423,
83,
1108,
348,
3524,
355,
450,
6522,
904,
779,
85,
7601,
317,
6598,
83,
1108,
317,
3524,
450,
3542,
63,
2975,
8,
69,
9,
367,
325,
315,
291,
2459,
339,
347,
465,
63,
505,
8,
277,
304,
267,
340,
440,
291,
26,
372,
399,
891,
267,
372,
399,
1154,
78,
1370,
904,
779,
85,
16804,
450,
83,
7,
450,
3542,
63,
2975,
8,
69,
9,
367,
325,
315,
291,
566,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
4700,
779,
3990,
63,
2975,
8,
69,
9,
367,
325,
315,
291,
566,
199,
199,
533,
8505,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1245,
304,
267,
408,
267,
8505,
883,
506,
3032,
1263,
909,
626,
883,
506,
12487,
334,
25118,
267,
282,
1059,
9,
503,
282,
769,
402,
2251,
14,
267,
408,
267,
340,
1228,
8,
1188,
12,
769,
304,
288,
291,
14,
3431,
275,
4520,
1296,
779,
7853,
63,
2975,
8,
1328,
9,
367,
1499,
315,
1245,
566,
267,
587,
26,
288,
1245,
275,
11179,
63,
2975,
8,
1188,
9,
288,
291,
14,
3431,
275,
4520,
1296,
779,
1188,
566,
339,
347,
636,
495,
721,
277,
304,
267,
327,
961,
365,
4346,
2952,
12,
1928,
282,
636,
495,
29709,
16116,
376,
1919,
267,
327,
1256,
3955,
754,
315,
642,
26,
267,
327,
4281,
26,
8505,
1256,
965,
949,
2225,
283,
589,
7,
267,
327,
1666,
1455,
921,
1544,
14,
1548,
14,
1308,
15,
1301,
15,
1818,
15,
84,
337,
15,
932,
709,
14,
1360,
3,
22273,
267,
372,
4700,
8,
277,
14,
3431,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tealover/nova
|
nova/pci/utils.py
|
52
|
4704
|
# Copyright (c) 2013 Intel, Inc.
# Copyright (c) 2012 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import glob
import os
import re
from oslo_log import log as logging
import six
from nova import exception
from nova.i18n import _LE
LOG = logging.getLogger(__name__)
PCI_VENDOR_PATTERN = "^(hex{4})$".replace("hex", "[\da-fA-F]")
_PCI_ADDRESS_PATTERN = ("^(hex{4}):(hex{2}):(hex{2}).(oct{1})$".
replace("hex", "[\da-fA-F]").
replace("oct", "[0-7]"))
_PCI_ADDRESS_REGEX = re.compile(_PCI_ADDRESS_PATTERN)
_VIRTFN_RE = re.compile("virtfn\d+")
def pci_device_prop_match(pci_dev, specs):
"""Check if the pci_dev meet spec requirement
Specs is a list of PCI device property requirements.
An example of device requirement that the PCI should be either:
a) Device with vendor_id as 0x8086 and product_id as 0x8259, or
b) Device with vendor_id as 0x10de and product_id as 0x10d8:
[{"vendor_id":"8086", "product_id":"8259"},
{"vendor_id":"10de", "product_id":"10d8"}]
"""
def _matching_devices(spec):
return all(pci_dev.get(k) == v for k, v in six.iteritems(spec))
return any(_matching_devices(spec) for spec in specs)
def parse_address(address):
"""Returns (domain, bus, slot, function) from PCI address that is stored in
PciDevice DB table.
"""
m = _PCI_ADDRESS_REGEX.match(address)
if not m:
raise exception.PciDeviceWrongAddressFormat(address=address)
return m.groups()
def get_pci_address_fields(pci_addr):
dbs, sep, func = pci_addr.partition('.')
domain, bus, slot = dbs.split(':')
return (domain, bus, slot, func)
def get_function_by_ifname(ifname):
"""Given the device name, returns the PCI address of a an device
and returns True if the address in a physical function.
"""
try:
dev_path = "/sys/class/net/%s/device" % ifname
dev_info = os.listdir(dev_path)
for dev_file in dev_info:
if _VIRTFN_RE.match(dev_file):
return os.readlink(dev_path).strip("./"), True
else:
return os.readlink(dev_path).strip("./"), False
except Exception:
LOG.error(_LE("PCI device %s not found") % ifname)
return None, False
def is_physical_function(pci_addr):
dev_path = "/sys/bus/pci/devices/%(d)s:%(b)s:%(s)s.%(f)s/" % {
"d": pci_addr.domain, "b": pci_addr.bus,
"s": pci_addr.slot, "f": pci_addr.func}
try:
dev_info = os.listdir(dev_path)
for dev_file in dev_info:
if _VIRTFN_RE.match(dev_file):
return True
else:
return False
except Exception:
LOG.error(_LE("PCI device %s not found") % dev_path)
return False
def get_ifname_by_pci_address(pci_addr, pf_interface=False):
"""Get the interface name based on a VF's pci address
The returned interface name is either the parent PF's or that of the VF
itself based on the argument of pf_interface.
"""
if pf_interface:
dev_path = "/sys/bus/pci/devices/%s/physfn/net" % (pci_addr)
else:
dev_path = "/sys/bus/pci/devices/%s/net" % (pci_addr)
try:
dev_info = os.listdir(dev_path)
return dev_info.pop()
except Exception:
raise exception.PciDeviceNotFoundById(id=pci_addr)
def get_vf_num_by_pci_address(pci_addr):
"""Get the VF number based on a VF's pci address
A VF is associated with an VF number, which ip link command uses to
configure it. This number can be obtained from the PCI device filesystem.
"""
VIRTFN_RE = re.compile("virtfn(\d+)")
virtfns_path = "/sys/bus/pci/devices/%s/physfn/virtfn*" % (pci_addr)
vf_num = None
try:
for vf_path in glob.iglob(virtfns_path):
if re.search(pci_addr, os.readlink(vf_path)):
t = VIRTFN_RE.search(vf_path)
vf_num = t.group(1)
break
except Exception:
pass
if vf_num is None:
raise exception.PciDeviceNotFoundById(id=pci_addr)
return vf_num
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6171,
20619,
12,
3277,
14,
199,
3,
1898,
334,
67,
9,
6029,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
421,
199,
646,
5739,
199,
646,
747,
199,
646,
295,
199,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
646,
3816,
199,
199,
504,
5913,
492,
1919,
199,
504,
5913,
14,
73,
1085,
78,
492,
485,
906,
199,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
23905,
63,
27839,
726,
63,
10764,
275,
18129,
8,
4097,
91,
20,
1552,
4,
1674,
1814,
480,
4097,
401,
298,
7023,
983,
13,
13753,
13,
38,
12523,
199,
63,
23905,
63,
12368,
63,
10764,
275,
1689,
62,
8,
4097,
91,
20,
22558,
8,
4097,
91,
18,
22558,
8,
4097,
91,
18,
21385,
8,
15560,
91,
17,
1552,
4,
1674,
6163,
3350,
480,
4097,
401,
298,
7023,
983,
13,
13753,
13,
38,
61,
3471,
6163,
3350,
480,
15560,
401,
7369,
16,
13,
23,
61,
2237,
199,
63,
23905,
63,
12368,
63,
10710,
275,
295,
14,
2014,
1547,
23905,
63,
12368,
63,
10764,
9,
199,
199,
63,
18228,
4963,
63,
907,
275,
295,
14,
2014,
480,
4549,
2324,
60,
68,
21425,
421,
199,
318,
19950,
63,
1782,
63,
4469,
63,
1431,
8,
12024,
63,
2374,
12,
15941,
304,
272,
408,
1799,
340,
314,
19950,
63,
2374,
26743,
3158,
10685,
339,
31511,
83,
365,
282,
769,
402,
510,
3553,
2243,
3324,
9760,
14,
272,
1626,
2893,
402,
2243,
10685,
626,
314,
510,
3553,
1077,
506,
1902,
26,
272,
282,
9,
12272,
543,
20868,
63,
344,
465,
378,
88,
1257,
1184,
436,
3336,
63,
344,
465,
378,
88,
24,
11990,
12,
503,
272,
330,
9,
12272,
543,
20868,
63,
344,
465,
378,
88,
709,
271,
436,
3336,
63,
344,
465,
378,
88,
709,
68,
24,
26,
339,
16870,
9884,
63,
344,
5122,
1257,
1184,
401,
298,
2558,
63,
344,
5122,
24,
11990,
6018,
1362,
2420,
9884,
63,
344,
5122,
709,
271,
401,
298,
2558,
63,
344,
5122,
709,
68,
24,
3570,
61,
339,
408,
272,
347,
485,
9467,
63,
6410,
8,
1650,
304,
267,
372,
1006,
8,
12024,
63,
2374,
14,
362,
8,
75,
9,
508,
373,
367,
1022,
12,
373,
315,
3816,
14,
4611,
8,
1650,
430,
339,
372,
1263,
1547,
9467,
63,
6410,
8,
1650,
9,
367,
3158,
315,
15941,
9,
421,
199,
318,
2198,
63,
1562,
8,
1562,
304,
272,
408,
3407,
334,
2261,
12,
10414,
12,
9348,
12,
805,
9,
687,
510,
3553,
2287,
626,
365,
5489,
315,
272,
510,
559,
2510,
6249,
1817,
14,
272,
408,
272,
333,
275,
485,
23905,
63,
12368,
63,
10710,
14,
1431,
8,
1562,
9,
272,
340,
440,
333,
26,
267,
746,
1919,
14,
23246,
2510,
14858,
1476,
3484,
8,
1562,
29,
1562,
9,
272,
372,
333,
14,
2634,
342,
421,
199,
318,
664,
63,
12024,
63,
1562,
63,
955,
8,
12024,
63,
2697,
304,
272,
366,
1533,
12,
7375,
12,
2562,
275,
19950,
63,
2697,
14,
5312,
7563,
272,
2881,
12,
10414,
12,
9348,
275,
366,
1533,
14,
1294,
11633,
272,
372,
334,
2261,
12,
10414,
12,
9348,
12,
2562,
9,
421,
199,
318,
664,
63,
1593,
63,
991,
63,
30702,
8,
30702,
304,
272,
408,
13735,
314,
2243,
536,
12,
2529,
314,
510,
3553,
2287,
402,
282,
376,
2243,
272,
436,
2529,
715,
340,
314,
2287,
315,
282,
14095,
805,
14,
272,
408,
272,
862,
26,
267,
4866,
63,
515,
275,
3286,
1274,
15,
533,
15,
846,
3149,
83,
15,
1782,
2,
450,
340,
354,
267,
4866,
63,
815,
275,
747,
14,
7374,
8,
2374,
63,
515,
9,
267,
367,
4866,
63,
493,
315,
4866,
63,
815,
26,
288,
340,
485,
18228,
4963,
63,
907,
14,
1431,
8,
2374,
63,
493,
304,
355,
372,
747,
14,
31654,
8,
2374,
63,
515,
680,
1913,
28615,
1288,
715,
267,
587,
26,
288,
372,
747,
14,
31654,
8,
2374,
63,
515,
680,
1913,
28615,
1288,
756,
272,
871,
2186,
26,
267,
5051,
14,
705,
1547,
906,
480,
23905,
2243,
450,
83,
440,
1911,
531,
450,
340,
354,
9,
267,
372,
488,
12,
756,
421,
199,
318,
365,
63,
15020,
63,
1593,
8,
12024,
63,
2697,
304,
272,
4866,
63,
515,
275,
3286,
1274,
15,
5610,
15,
12024,
15,
6410,
21275,
68,
9,
83,
19648,
66,
9,
83,
19648,
83,
9,
83,
31706,
70,
9,
83,
6687,
450,
469,
267,
298,
68,
582,
19950,
63,
2697,
14,
2261,
12,
298,
66,
582,
19950,
63,
2697,
14,
5610,
12,
267,
298,
83,
582,
19950,
63,
2697,
14,
7998,
12,
298,
70,
582,
19950,
63,
2697,
14,
1532,
93,
272,
862,
26,
267,
4866,
63,
815,
275,
747,
14,
7374,
8,
2374,
63,
515,
9,
267,
367,
4866,
63,
493,
315,
4866,
63,
815,
26,
288,
340,
485,
18228,
4963,
63,
907,
14,
1431,
8,
2374,
63,
493,
304,
355,
372,
715,
267,
587,
26,
288,
372,
756,
272,
871,
2186,
26,
267,
5051,
14,
705,
1547,
906,
480,
23905,
2243,
450,
83,
440,
1911,
531,
450,
4866,
63,
515,
9,
267,
372,
756,
421,
199,
318,
664,
63,
30702,
63,
991,
63,
12024,
63,
1562,
8,
12024,
63,
2697,
12,
18258,
63,
3266,
29,
797,
304,
272,
408,
1002,
314,
3217,
536,
4079,
641,
282,
812,
38,
1159,
19950,
2287,
339,
710,
2138,
3217,
536,
365,
1902,
314,
1676,
17689,
1159,
503,
626,
402,
314,
812
] |
[
1898,
334,
67,
9,
6171,
20619,
12,
3277,
14,
199,
3,
1898,
334,
67,
9,
6029,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
421,
199,
646,
5739,
199,
646,
747,
199,
646,
295,
199,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
646,
3816,
199,
199,
504,
5913,
492,
1919,
199,
504,
5913,
14,
73,
1085,
78,
492,
485,
906,
199,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
23905,
63,
27839,
726,
63,
10764,
275,
18129,
8,
4097,
91,
20,
1552,
4,
1674,
1814,
480,
4097,
401,
298,
7023,
983,
13,
13753,
13,
38,
12523,
199,
63,
23905,
63,
12368,
63,
10764,
275,
1689,
62,
8,
4097,
91,
20,
22558,
8,
4097,
91,
18,
22558,
8,
4097,
91,
18,
21385,
8,
15560,
91,
17,
1552,
4,
1674,
6163,
3350,
480,
4097,
401,
298,
7023,
983,
13,
13753,
13,
38,
61,
3471,
6163,
3350,
480,
15560,
401,
7369,
16,
13,
23,
61,
2237,
199,
63,
23905,
63,
12368,
63,
10710,
275,
295,
14,
2014,
1547,
23905,
63,
12368,
63,
10764,
9,
199,
199,
63,
18228,
4963,
63,
907,
275,
295,
14,
2014,
480,
4549,
2324,
60,
68,
21425,
421,
199,
318,
19950,
63,
1782,
63,
4469,
63,
1431,
8,
12024,
63,
2374,
12,
15941,
304,
272,
408,
1799,
340,
314,
19950,
63,
2374,
26743,
3158,
10685,
339,
31511,
83,
365,
282,
769,
402,
510,
3553,
2243,
3324,
9760,
14,
272,
1626,
2893,
402,
2243,
10685,
626,
314,
510,
3553,
1077,
506,
1902,
26,
272,
282,
9,
12272,
543,
20868,
63,
344,
465,
378,
88,
1257,
1184,
436,
3336,
63,
344,
465,
378,
88,
24,
11990,
12,
503,
272,
330,
9,
12272,
543,
20868,
63,
344,
465,
378,
88,
709,
271,
436,
3336,
63,
344,
465,
378,
88,
709,
68,
24,
26,
339,
16870,
9884,
63,
344,
5122,
1257,
1184,
401,
298,
2558,
63,
344,
5122,
24,
11990,
6018,
1362,
2420,
9884,
63,
344,
5122,
709,
271,
401,
298,
2558,
63,
344,
5122,
709,
68,
24,
3570,
61,
339,
408,
272,
347,
485,
9467,
63,
6410,
8,
1650,
304,
267,
372,
1006,
8,
12024,
63,
2374,
14,
362,
8,
75,
9,
508,
373,
367,
1022,
12,
373,
315,
3816,
14,
4611,
8,
1650,
430,
339,
372,
1263,
1547,
9467,
63,
6410,
8,
1650,
9,
367,
3158,
315,
15941,
9,
421,
199,
318,
2198,
63,
1562,
8,
1562,
304,
272,
408,
3407,
334,
2261,
12,
10414,
12,
9348,
12,
805,
9,
687,
510,
3553,
2287,
626,
365,
5489,
315,
272,
510,
559,
2510,
6249,
1817,
14,
272,
408,
272,
333,
275,
485,
23905,
63,
12368,
63,
10710,
14,
1431,
8,
1562,
9,
272,
340,
440,
333,
26,
267,
746,
1919,
14,
23246,
2510,
14858,
1476,
3484,
8,
1562,
29,
1562,
9,
272,
372,
333,
14,
2634,
342,
421,
199,
318,
664,
63,
12024,
63,
1562,
63,
955,
8,
12024,
63,
2697,
304,
272,
366,
1533,
12,
7375,
12,
2562,
275,
19950,
63,
2697,
14,
5312,
7563,
272,
2881,
12,
10414,
12,
9348,
275,
366,
1533,
14,
1294,
11633,
272,
372,
334,
2261,
12,
10414,
12,
9348,
12,
2562,
9,
421,
199,
318,
664,
63,
1593,
63,
991,
63,
30702,
8,
30702,
304,
272,
408,
13735,
314,
2243,
536,
12,
2529,
314,
510,
3553,
2287,
402,
282,
376,
2243,
272,
436,
2529,
715,
340,
314,
2287,
315,
282,
14095,
805,
14,
272,
408,
272,
862,
26,
267,
4866,
63,
515,
275,
3286,
1274,
15,
533,
15,
846,
3149,
83,
15,
1782,
2,
450,
340,
354,
267,
4866,
63,
815,
275,
747,
14,
7374,
8,
2374,
63,
515,
9,
267,
367,
4866,
63,
493,
315,
4866,
63,
815,
26,
288,
340,
485,
18228,
4963,
63,
907,
14,
1431,
8,
2374,
63,
493,
304,
355,
372,
747,
14,
31654,
8,
2374,
63,
515,
680,
1913,
28615,
1288,
715,
267,
587,
26,
288,
372,
747,
14,
31654,
8,
2374,
63,
515,
680,
1913,
28615,
1288,
756,
272,
871,
2186,
26,
267,
5051,
14,
705,
1547,
906,
480,
23905,
2243,
450,
83,
440,
1911,
531,
450,
340,
354,
9,
267,
372,
488,
12,
756,
421,
199,
318,
365,
63,
15020,
63,
1593,
8,
12024,
63,
2697,
304,
272,
4866,
63,
515,
275,
3286,
1274,
15,
5610,
15,
12024,
15,
6410,
21275,
68,
9,
83,
19648,
66,
9,
83,
19648,
83,
9,
83,
31706,
70,
9,
83,
6687,
450,
469,
267,
298,
68,
582,
19950,
63,
2697,
14,
2261,
12,
298,
66,
582,
19950,
63,
2697,
14,
5610,
12,
267,
298,
83,
582,
19950,
63,
2697,
14,
7998,
12,
298,
70,
582,
19950,
63,
2697,
14,
1532,
93,
272,
862,
26,
267,
4866,
63,
815,
275,
747,
14,
7374,
8,
2374,
63,
515,
9,
267,
367,
4866,
63,
493,
315,
4866,
63,
815,
26,
288,
340,
485,
18228,
4963,
63,
907,
14,
1431,
8,
2374,
63,
493,
304,
355,
372,
715,
267,
587,
26,
288,
372,
756,
272,
871,
2186,
26,
267,
5051,
14,
705,
1547,
906,
480,
23905,
2243,
450,
83,
440,
1911,
531,
450,
4866,
63,
515,
9,
267,
372,
756,
421,
199,
318,
664,
63,
30702,
63,
991,
63,
12024,
63,
1562,
8,
12024,
63,
2697,
12,
18258,
63,
3266,
29,
797,
304,
272,
408,
1002,
314,
3217,
536,
4079,
641,
282,
812,
38,
1159,
19950,
2287,
339,
710,
2138,
3217,
536,
365,
1902,
314,
1676,
17689,
1159,
503,
626,
402,
314,
812,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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