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
|
|---|---|---|---|---|---|---|---|---|
duqiao/django
|
django/contrib/gis/geoip/prototypes.py
|
535
|
3943
|
from ctypes import POINTER, Structure, c_char_p, c_float, c_int, string_at
from django.contrib.gis.geoip.libgeoip import free, lgeoip
# #### GeoIP C Structure definitions ####
class GeoIPRecord(Structure):
_fields_ = [('country_code', c_char_p),
('country_code3', c_char_p),
('country_name', c_char_p),
('region', c_char_p),
('city', c_char_p),
('postal_code', c_char_p),
('latitude', c_float),
('longitude', c_float),
# TODO: In 1.4.6 this changed from `int dma_code;` to
# `union {int metro_code; int dma_code;};`. Change
# to a `ctypes.Union` in to accommodate in future when
# pre-1.4.6 versions are no longer distributed.
('dma_code', c_int),
('area_code', c_int),
('charset', c_int),
('continent_code', c_char_p),
]
geoip_char_fields = [name for name, ctype in GeoIPRecord._fields_ if ctype is c_char_p]
GEOIP_DEFAULT_ENCODING = 'iso-8859-1'
geoip_encodings = {
0: 'iso-8859-1',
1: 'utf8',
}
class GeoIPTag(Structure):
pass
RECTYPE = POINTER(GeoIPRecord)
DBTYPE = POINTER(GeoIPTag)
# #### ctypes function prototypes ####
# GeoIP_lib_version appeared in version 1.4.7.
if hasattr(lgeoip, 'GeoIP_lib_version'):
GeoIP_lib_version = lgeoip.GeoIP_lib_version
GeoIP_lib_version.argtypes = None
GeoIP_lib_version.restype = c_char_p
else:
GeoIP_lib_version = None
# For freeing memory allocated within a record
GeoIPRecord_delete = lgeoip.GeoIPRecord_delete
GeoIPRecord_delete.argtypes = [RECTYPE]
GeoIPRecord_delete.restype = None
# For retrieving records by name or address.
def check_record(result, func, cargs):
if result:
# Checking the pointer to the C structure, if valid pull out elements
# into a dictionary.
rec = result.contents
record = {fld: getattr(rec, fld) for fld, ctype in rec._fields_}
# Now converting the strings to unicode using the proper encoding.
encoding = geoip_encodings[record['charset']]
for char_field in geoip_char_fields:
if record[char_field]:
record[char_field] = record[char_field].decode(encoding)
# Free the memory allocated for the struct & return.
GeoIPRecord_delete(result)
return record
else:
return None
def record_output(func):
func.argtypes = [DBTYPE, c_char_p]
func.restype = RECTYPE
func.errcheck = check_record
return func
GeoIP_record_by_addr = record_output(lgeoip.GeoIP_record_by_addr)
GeoIP_record_by_name = record_output(lgeoip.GeoIP_record_by_name)
# For opening & closing GeoIP database files.
GeoIP_open = lgeoip.GeoIP_open
GeoIP_open.restype = DBTYPE
GeoIP_delete = lgeoip.GeoIP_delete
GeoIP_delete.argtypes = [DBTYPE]
GeoIP_delete.restype = None
# This is so the string pointer can be freed within Python.
class geoip_char_p(c_char_p):
pass
def check_string(result, func, cargs):
if result:
s = string_at(result)
free(result)
else:
s = ''
return s.decode(GEOIP_DEFAULT_ENCODING)
GeoIP_database_info = lgeoip.GeoIP_database_info
GeoIP_database_info.restype = geoip_char_p
GeoIP_database_info.errcheck = check_string
# String output routines.
def string_output(func):
def _err_check(result, func, cargs):
if result:
return result.decode(GEOIP_DEFAULT_ENCODING)
return result
func.restype = c_char_p
func.errcheck = _err_check
return func
GeoIP_country_code_by_addr = string_output(lgeoip.GeoIP_country_code_by_addr)
GeoIP_country_code_by_name = string_output(lgeoip.GeoIP_country_code_by_name)
GeoIP_country_name_by_addr = string_output(lgeoip.GeoIP_country_name_by_addr)
GeoIP_country_name_by_name = string_output(lgeoip.GeoIP_country_name_by_name)
|
bsd-3-clause
|
[
504,
5577,
492,
6569,
12,
21730,
12,
286,
63,
1560,
63,
80,
12,
286,
63,
1609,
12,
286,
63,
442,
12,
1059,
63,
292,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
28799,
14,
773,
28799,
492,
2867,
12,
634,
28799,
421,
199,
3,
14055,
18378,
445,
21730,
10269,
14055,
199,
199,
533,
18378,
5433,
8,
10766,
304,
272,
485,
955,
63,
275,
4274,
6063,
63,
600,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
6063,
63,
600,
19,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
6063,
63,
354,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
4551,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
3690,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
31580,
63,
600,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
13331,
297,
286,
63,
1609,
395,
355,
661,
13803,
297,
286,
63,
1609,
395,
355,
327,
3254,
26,
1010,
413,
14,
20,
14,
22,
642,
2896,
687,
658,
442,
366,
391,
63,
600,
27,
64,
370,
355,
327,
658,
8888,
469,
442,
562,
1374,
63,
600,
27,
1109,
366,
391,
63,
600,
27,
12084,
2313,
221,
7743,
355,
327,
370,
282,
658,
9798,
14,
15540,
64,
315,
370,
1066,
1404,
364,
323,
315,
6466,
1380,
355,
327,
876,
13,
17,
14,
20,
14,
22,
5459,
787,
949,
8088,
1854,
14,
355,
661,
68,
391,
63,
600,
297,
286,
63,
442,
395,
355,
661,
6789,
63,
600,
297,
286,
63,
442,
395,
355,
661,
6043,
297,
286,
63,
442,
395,
355,
661,
12875,
484,
63,
600,
297,
286,
63,
1560,
63,
80,
395,
355,
1622,
199,
28799,
63,
1560,
63,
955,
275,
359,
354,
367,
536,
12,
16360,
315,
18378,
5433,
423,
955,
63,
340,
16360,
365,
286,
63,
1560,
63,
80,
61,
199,
18120,
1772,
63,
3472,
63,
16314,
275,
283,
4595,
13,
4830,
13,
17,
7,
199,
28799,
63,
21138,
275,
469,
272,
378,
26,
283,
4595,
13,
4830,
13,
17,
297,
272,
413,
26,
283,
1624,
24,
297,
199,
93,
421,
199,
533,
18378,
1931,
8,
10766,
304,
272,
986,
199,
199,
4168,
4948,
275,
6569,
8,
28848,
5433,
9,
199,
2846,
2711,
275,
6569,
8,
28848,
1931,
9,
199,
199,
3,
14055,
5577,
805,
19393,
83,
14055,
199,
199,
3,
18378,
63,
773,
63,
1023,
5704,
2899,
315,
1015,
413,
14,
20,
14,
23,
14,
199,
692,
2688,
8,
76,
28799,
12,
283,
28848,
63,
773,
63,
1023,
735,
272,
18378,
63,
773,
63,
1023,
275,
634,
28799,
14,
28848,
63,
773,
63,
1023,
272,
18378,
63,
773,
63,
1023,
14,
10025,
275,
488,
272,
18378,
63,
773,
63,
1023,
14,
9990,
275,
286,
63,
1560,
63,
80,
199,
2836,
26,
272,
18378,
63,
773,
63,
1023,
275,
488,
199,
199,
3,
2104,
2867,
316,
4402,
17659,
4453,
282,
2777,
199,
28848,
5433,
63,
1807,
275,
634,
28799,
14,
28848,
5433,
63,
1807,
199,
28848,
5433,
63,
1807,
14,
10025,
275,
359,
4168,
4948,
61,
199,
28848,
5433,
63,
1807,
14,
9990,
275,
488,
421,
199,
3,
2104,
23812,
5767,
701,
536,
503,
2287,
14,
199,
318,
1104,
63,
3059,
8,
1099,
12,
2562,
12,
286,
589,
304,
272,
340,
754,
26,
267,
327,
25109,
314,
7849,
370,
314,
445,
5523,
12,
340,
1686,
10299,
734,
4008,
267,
327,
1901,
282,
2600,
14,
267,
6488,
275,
754,
14,
4407,
267,
2777,
275,
469,
17511,
26,
2519,
8,
2761,
12,
22928,
9,
367,
22928,
12,
16360,
315,
6488,
423,
955,
63,
93,
398,
327,
7356,
13806,
314,
3326,
370,
2649,
1808,
314,
5576,
2644,
14,
267,
2644,
275,
8509,
711,
63,
21138,
59,
3059,
459,
6043,
6538,
267,
367,
1495,
63,
698,
315,
8509,
711,
63,
1560,
63,
955,
26,
288,
340,
2777,
59,
1560,
63,
698,
2189,
355,
2777,
59,
1560,
63,
698,
61,
275,
2777,
59,
1560,
63,
698,
1055,
2708,
8,
2991,
9,
398,
327,
2868,
314,
4402,
17659,
367,
314,
2702,
1253,
372,
14,
267,
18378,
5433,
63,
1807,
8,
1099,
9,
267,
372,
2777,
272,
587,
26,
267,
372,
488,
421,
199,
318,
2777,
63,
1199,
8,
1532,
304,
272,
2562,
14,
10025,
275,
359,
2846,
2711,
12,
286,
63,
1560,
63,
80,
61,
272,
2562,
14,
9990,
275,
820,
3582,
4948,
272,
2562,
14,
21205,
275,
1104,
63,
3059,
272,
372,
2562,
199,
28848,
63,
3059,
63,
991,
63,
2697,
275,
2777,
63,
1199,
8,
76,
28799,
14,
28848,
63,
3059,
63,
991,
63,
2697,
9,
199,
28848,
63,
3059,
63,
991,
63,
354,
275,
2777,
63,
1199,
8,
76,
28799,
14,
28848,
63,
3059,
63,
991,
63,
354,
9,
421,
199,
3,
2104,
13618,
1253,
11261,
18378,
3050,
1584,
14,
199,
28848,
63,
1490,
275,
634,
28799,
14,
28848,
63,
1490,
199,
28848,
63,
1490,
14,
9990,
275,
6249,
2711,
199,
28848,
63,
1807,
275,
634,
28799,
14,
28848,
63,
1807,
199,
28848,
63,
1807,
14,
10025,
275,
359,
2846,
2711,
61,
199,
28848,
63,
1807,
14,
9990,
275,
488,
421,
199,
3,
961,
365,
880,
314,
1059,
7849,
883,
506,
23694,
4453,
2018,
14,
199,
533,
8509,
711,
63,
1560,
63,
80,
8,
67,
63,
1560,
63,
80,
304,
272,
986,
421,
199,
318,
1104,
63,
875,
8,
1099,
12,
2562,
12,
286,
589,
304,
272,
340,
754,
26,
267,
308,
275,
1059,
63,
292,
8,
1099,
9,
267,
2867,
8,
1099,
9,
272,
587,
26,
267,
308,
275,
2125,
272,
372,
308,
14,
2708,
8,
18120,
1772,
63,
3472,
63,
16314,
9,
199,
199,
28848,
63,
4659,
63,
815,
275,
634,
28799,
14,
28848,
63,
4659,
63,
815,
199,
28848,
63,
4659,
63,
815,
14,
9990,
275,
8509,
711,
63,
1560,
63,
80,
199,
28848,
63,
4659,
63,
815,
14,
21205,
275,
1104,
63,
875,
421,
199,
3,
2624,
1072,
14975,
14,
199,
318,
1059,
63,
1199,
8,
1532,
304,
272,
347,
485,
1508,
63,
1074,
8,
1099,
12,
2562,
12,
286,
589,
304,
267,
340,
754,
26,
288,
372,
754,
14,
2708,
8,
18120,
1772,
63,
3472,
63,
16314,
9,
267,
372,
754,
272,
2562,
14,
9990,
275,
286,
63,
1560,
63,
80,
272,
2562,
14,
21205,
275,
485,
1508,
63,
1074,
272,
372,
2562,
199,
199,
28848
] |
[
5577,
492,
6569,
12,
21730,
12,
286,
63,
1560,
63,
80,
12,
286,
63,
1609,
12,
286,
63,
442,
12,
1059,
63,
292,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
28799,
14,
773,
28799,
492,
2867,
12,
634,
28799,
421,
199,
3,
14055,
18378,
445,
21730,
10269,
14055,
199,
199,
533,
18378,
5433,
8,
10766,
304,
272,
485,
955,
63,
275,
4274,
6063,
63,
600,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
6063,
63,
600,
19,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
6063,
63,
354,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
4551,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
3690,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
31580,
63,
600,
297,
286,
63,
1560,
63,
80,
395,
355,
661,
13331,
297,
286,
63,
1609,
395,
355,
661,
13803,
297,
286,
63,
1609,
395,
355,
327,
3254,
26,
1010,
413,
14,
20,
14,
22,
642,
2896,
687,
658,
442,
366,
391,
63,
600,
27,
64,
370,
355,
327,
658,
8888,
469,
442,
562,
1374,
63,
600,
27,
1109,
366,
391,
63,
600,
27,
12084,
2313,
221,
7743,
355,
327,
370,
282,
658,
9798,
14,
15540,
64,
315,
370,
1066,
1404,
364,
323,
315,
6466,
1380,
355,
327,
876,
13,
17,
14,
20,
14,
22,
5459,
787,
949,
8088,
1854,
14,
355,
661,
68,
391,
63,
600,
297,
286,
63,
442,
395,
355,
661,
6789,
63,
600,
297,
286,
63,
442,
395,
355,
661,
6043,
297,
286,
63,
442,
395,
355,
661,
12875,
484,
63,
600,
297,
286,
63,
1560,
63,
80,
395,
355,
1622,
199,
28799,
63,
1560,
63,
955,
275,
359,
354,
367,
536,
12,
16360,
315,
18378,
5433,
423,
955,
63,
340,
16360,
365,
286,
63,
1560,
63,
80,
61,
199,
18120,
1772,
63,
3472,
63,
16314,
275,
283,
4595,
13,
4830,
13,
17,
7,
199,
28799,
63,
21138,
275,
469,
272,
378,
26,
283,
4595,
13,
4830,
13,
17,
297,
272,
413,
26,
283,
1624,
24,
297,
199,
93,
421,
199,
533,
18378,
1931,
8,
10766,
304,
272,
986,
199,
199,
4168,
4948,
275,
6569,
8,
28848,
5433,
9,
199,
2846,
2711,
275,
6569,
8,
28848,
1931,
9,
199,
199,
3,
14055,
5577,
805,
19393,
83,
14055,
199,
199,
3,
18378,
63,
773,
63,
1023,
5704,
2899,
315,
1015,
413,
14,
20,
14,
23,
14,
199,
692,
2688,
8,
76,
28799,
12,
283,
28848,
63,
773,
63,
1023,
735,
272,
18378,
63,
773,
63,
1023,
275,
634,
28799,
14,
28848,
63,
773,
63,
1023,
272,
18378,
63,
773,
63,
1023,
14,
10025,
275,
488,
272,
18378,
63,
773,
63,
1023,
14,
9990,
275,
286,
63,
1560,
63,
80,
199,
2836,
26,
272,
18378,
63,
773,
63,
1023,
275,
488,
199,
199,
3,
2104,
2867,
316,
4402,
17659,
4453,
282,
2777,
199,
28848,
5433,
63,
1807,
275,
634,
28799,
14,
28848,
5433,
63,
1807,
199,
28848,
5433,
63,
1807,
14,
10025,
275,
359,
4168,
4948,
61,
199,
28848,
5433,
63,
1807,
14,
9990,
275,
488,
421,
199,
3,
2104,
23812,
5767,
701,
536,
503,
2287,
14,
199,
318,
1104,
63,
3059,
8,
1099,
12,
2562,
12,
286,
589,
304,
272,
340,
754,
26,
267,
327,
25109,
314,
7849,
370,
314,
445,
5523,
12,
340,
1686,
10299,
734,
4008,
267,
327,
1901,
282,
2600,
14,
267,
6488,
275,
754,
14,
4407,
267,
2777,
275,
469,
17511,
26,
2519,
8,
2761,
12,
22928,
9,
367,
22928,
12,
16360,
315,
6488,
423,
955,
63,
93,
398,
327,
7356,
13806,
314,
3326,
370,
2649,
1808,
314,
5576,
2644,
14,
267,
2644,
275,
8509,
711,
63,
21138,
59,
3059,
459,
6043,
6538,
267,
367,
1495,
63,
698,
315,
8509,
711,
63,
1560,
63,
955,
26,
288,
340,
2777,
59,
1560,
63,
698,
2189,
355,
2777,
59,
1560,
63,
698,
61,
275,
2777,
59,
1560,
63,
698,
1055,
2708,
8,
2991,
9,
398,
327,
2868,
314,
4402,
17659,
367,
314,
2702,
1253,
372,
14,
267,
18378,
5433,
63,
1807,
8,
1099,
9,
267,
372,
2777,
272,
587,
26,
267,
372,
488,
421,
199,
318,
2777,
63,
1199,
8,
1532,
304,
272,
2562,
14,
10025,
275,
359,
2846,
2711,
12,
286,
63,
1560,
63,
80,
61,
272,
2562,
14,
9990,
275,
820,
3582,
4948,
272,
2562,
14,
21205,
275,
1104,
63,
3059,
272,
372,
2562,
199,
28848,
63,
3059,
63,
991,
63,
2697,
275,
2777,
63,
1199,
8,
76,
28799,
14,
28848,
63,
3059,
63,
991,
63,
2697,
9,
199,
28848,
63,
3059,
63,
991,
63,
354,
275,
2777,
63,
1199,
8,
76,
28799,
14,
28848,
63,
3059,
63,
991,
63,
354,
9,
421,
199,
3,
2104,
13618,
1253,
11261,
18378,
3050,
1584,
14,
199,
28848,
63,
1490,
275,
634,
28799,
14,
28848,
63,
1490,
199,
28848,
63,
1490,
14,
9990,
275,
6249,
2711,
199,
28848,
63,
1807,
275,
634,
28799,
14,
28848,
63,
1807,
199,
28848,
63,
1807,
14,
10025,
275,
359,
2846,
2711,
61,
199,
28848,
63,
1807,
14,
9990,
275,
488,
421,
199,
3,
961,
365,
880,
314,
1059,
7849,
883,
506,
23694,
4453,
2018,
14,
199,
533,
8509,
711,
63,
1560,
63,
80,
8,
67,
63,
1560,
63,
80,
304,
272,
986,
421,
199,
318,
1104,
63,
875,
8,
1099,
12,
2562,
12,
286,
589,
304,
272,
340,
754,
26,
267,
308,
275,
1059,
63,
292,
8,
1099,
9,
267,
2867,
8,
1099,
9,
272,
587,
26,
267,
308,
275,
2125,
272,
372,
308,
14,
2708,
8,
18120,
1772,
63,
3472,
63,
16314,
9,
199,
199,
28848,
63,
4659,
63,
815,
275,
634,
28799,
14,
28848,
63,
4659,
63,
815,
199,
28848,
63,
4659,
63,
815,
14,
9990,
275,
8509,
711,
63,
1560,
63,
80,
199,
28848,
63,
4659,
63,
815,
14,
21205,
275,
1104,
63,
875,
421,
199,
3,
2624,
1072,
14975,
14,
199,
318,
1059,
63,
1199,
8,
1532,
304,
272,
347,
485,
1508,
63,
1074,
8,
1099,
12,
2562,
12,
286,
589,
304,
267,
340,
754,
26,
288,
372,
754,
14,
2708,
8,
18120,
1772,
63,
3472,
63,
16314,
9,
267,
372,
754,
272,
2562,
14,
9990,
275,
286,
63,
1560,
63,
80,
272,
2562,
14,
21205,
275,
485,
1508,
63,
1074,
272,
372,
2562,
199,
199,
28848,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
birkin/iip_processing_project
|
run_travis_tests.py
|
1
|
1651
|
# -*- coding: utf-8 -*-
# flake8: noqa
from __future__ import unicode_literals
import os
import sys
import django
from django.conf import settings
from django.test.utils import get_runner
if __name__ == '__main__':
os.environ['DJANGO_SETTINGS_MODULE'] = 'config.settings_travis'
## initialize dummy envvars used by class initialization
for not_used_for_testing_item in [
'IIP_PRC__BASIC_AUTH_PASSWORD',
'IIP_PRC__BASIC_AUTH_USERNAME',
'IIP_PRC__CLONED_INSCRIPTIONS_PATH',
'IIP_PRC__DEV_URL',
'IIP_PRC__DISPLAY_STATUSES_BACKUP_DIR',
'IIP_PRC__LEGIT_QUEUE_VIEWER_PASSWORD',
'IIP_PRC__LEGIT_QUEUE_VIEWER_USER',
'IIP_PRC__PROCESS_STATUS_UPDATER_URL',
'IIP_PRC__PRODUCTION_HOSTNAME',
'IIP_PRC__REPO_SECRET_KEY',
'IIP_PRC__SOLR_DOC_STYLESHEET_PATH',
'IIP_PRC__SOLR_URL',
'IIP_PRC__STATUSES_GIST_PASSWORD',
'IIP_PRC__STATUSES_GIST_URL',
'IIP_PRC__STATUSES_GIST_USERNAME',
'IIP_PRC__TRANSFORMER_AUTH_KEY',
'IIP_PRC__TRANSFORMER_URL' ]:
os.environ[ not_used_for_testing_item ] = 'foo'
os.environ['IIP_PRC__DISPLAY_STATUSES_BACKUP_TIMEFRAME_IN_DAYS'] = '1' # converted to int by __init__
os.environ['IIP_PRC__LEGIT_ADMINS_JSON'] = '"foo"' # valid json required
os.environ['IIP_PRC__LEGIT_QUEUE_VIEWER_GROUPS_JSON'] = '"foo"'
os.environ['IIP_PRC__LEGIT_QUEUE_VIEWER_EPPNS_JSON'] = '"foo"'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(['iip_processing_app.tests.tests_unit'])
sys.exit(bool(failures))
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
27510,
24,
26,
8151,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
747,
199,
646,
984,
199,
646,
1639,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
396,
14,
1208,
492,
664,
63,
5933,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
747,
14,
2314,
459,
22848,
63,
13931,
63,
10001,
418,
275,
283,
888,
14,
1751,
63,
1239,
5068,
7,
272,
925,
8265,
7283,
2589,
2936,
1202,
701,
1021,
11097,
272,
367,
440,
63,
2972,
63,
509,
63,
4776,
63,
1053,
315,
359,
267,
283,
41,
1772,
63,
3311,
35,
363,
27271,
63,
5580,
63,
9032,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
27271,
63,
5580,
63,
11958,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
1981,
615,
1149,
63,
568,
10484,
2823,
63,
3243,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
13260,
63,
2632,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
20993,
63,
6305,
654,
63,
31752,
63,
3022,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
15125,
63,
12058,
540,
63,
9032,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
15125,
63,
12058,
540,
63,
3791,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
10494,
63,
6305,
63,
23612,
540,
63,
2632,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
2514,
4980,
5430,
63,
22647,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
20424,
63,
12961,
63,
3078,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
15096,
50,
63,
16618,
63,
12307,
11344,
1645,
775,
63,
3243,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
15096,
50,
63,
2632,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
6305,
654,
63,
39,
6225,
63,
9032,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
6305,
654,
63,
39,
6225,
63,
2632,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
6305,
654,
63,
39,
6225,
63,
11958,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
30190,
540,
63,
5580,
63,
3078,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
30190,
540,
63,
2632,
7,
16246,
267,
747,
14,
2314,
59,
440,
63,
2972,
63,
509,
63,
4776,
63,
1053,
1622,
275,
283,
1421,
7,
272,
747,
14,
2314,
459,
41,
1772,
63,
3311,
35,
363,
20993,
63,
6305,
654,
63,
31752,
63,
4961,
12683,
63,
568,
63,
25683,
418,
275,
283,
17,
7,
221,
327,
6702,
370,
1109,
701,
636,
826,
363,
272,
747,
14,
2314,
459,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
14288,
51,
63,
6243,
418,
275,
5522,
1421,
4507,
221,
327,
1686,
2022,
1415,
272,
747,
14,
2314,
459,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
15125,
63,
12058,
540,
63,
27544,
63,
6243,
418,
275,
5522,
1421,
4507,
272,
747,
14,
2314,
459,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
15125,
63,
12058,
540,
63,
6102,
48,
2709,
63,
6243,
418,
275,
5522,
1421,
4507,
272,
1639,
14,
2758,
342,
272,
1379,
7446,
275,
664,
63,
5933,
8,
1751,
9,
272,
511,
63,
5933,
275,
1379,
7446,
342,
272,
9081,
275,
511,
63,
5933,
14,
1065,
63,
2219,
2941,
73,
711,
63,
6338,
63,
571,
14,
2219,
14,
2219,
63,
3248,
1105,
272,
984,
14,
2224,
8,
2245,
8,
9968,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
27510,
24,
26,
8151,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
747,
199,
646,
984,
199,
646,
1639,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
396,
14,
1208,
492,
664,
63,
5933,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
747,
14,
2314,
459,
22848,
63,
13931,
63,
10001,
418,
275,
283,
888,
14,
1751,
63,
1239,
5068,
7,
272,
925,
8265,
7283,
2589,
2936,
1202,
701,
1021,
11097,
272,
367,
440,
63,
2972,
63,
509,
63,
4776,
63,
1053,
315,
359,
267,
283,
41,
1772,
63,
3311,
35,
363,
27271,
63,
5580,
63,
9032,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
27271,
63,
5580,
63,
11958,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
1981,
615,
1149,
63,
568,
10484,
2823,
63,
3243,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
13260,
63,
2632,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
20993,
63,
6305,
654,
63,
31752,
63,
3022,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
15125,
63,
12058,
540,
63,
9032,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
15125,
63,
12058,
540,
63,
3791,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
10494,
63,
6305,
63,
23612,
540,
63,
2632,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
2514,
4980,
5430,
63,
22647,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
20424,
63,
12961,
63,
3078,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
15096,
50,
63,
16618,
63,
12307,
11344,
1645,
775,
63,
3243,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
15096,
50,
63,
2632,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
6305,
654,
63,
39,
6225,
63,
9032,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
6305,
654,
63,
39,
6225,
63,
2632,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
6305,
654,
63,
39,
6225,
63,
11958,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
30190,
540,
63,
5580,
63,
3078,
297,
267,
283,
41,
1772,
63,
3311,
35,
363,
30190,
540,
63,
2632,
7,
16246,
267,
747,
14,
2314,
59,
440,
63,
2972,
63,
509,
63,
4776,
63,
1053,
1622,
275,
283,
1421,
7,
272,
747,
14,
2314,
459,
41,
1772,
63,
3311,
35,
363,
20993,
63,
6305,
654,
63,
31752,
63,
4961,
12683,
63,
568,
63,
25683,
418,
275,
283,
17,
7,
221,
327,
6702,
370,
1109,
701,
636,
826,
363,
272,
747,
14,
2314,
459,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
14288,
51,
63,
6243,
418,
275,
5522,
1421,
4507,
221,
327,
1686,
2022,
1415,
272,
747,
14,
2314,
459,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
15125,
63,
12058,
540,
63,
27544,
63,
6243,
418,
275,
5522,
1421,
4507,
272,
747,
14,
2314,
459,
41,
1772,
63,
3311,
35,
363,
906,
20072,
63,
15125,
63,
12058,
540,
63,
6102,
48,
2709,
63,
6243,
418,
275,
5522,
1421,
4507,
272,
1639,
14,
2758,
342,
272,
1379,
7446,
275,
664,
63,
5933,
8,
1751,
9,
272,
511,
63,
5933,
275,
1379,
7446,
342,
272,
9081,
275,
511,
63,
5933,
14,
1065,
63,
2219,
2941,
73,
711,
63,
6338,
63,
571,
14,
2219,
14,
2219,
63,
3248,
1105,
272,
984,
14,
2224,
8,
2245,
8,
9968,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
whip112/Whip112
|
vendor/packages/pygments/styles/monokai.py
|
135
|
5080
|
# -*- coding: utf-8 -*-
"""
pygments.styles.monokai
~~~~~~~~~~~~~~~~~~~~~~~
Mimic the Monokai color scheme. Based on tango.py.
http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
:copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, Text, \
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
class MonokaiStyle(Style):
"""
This style mimics the Monokai color scheme.
"""
background_color = "#272822"
highlight_color = "#49483e"
styles = {
# No corresponding class for the following:
Text: "#f8f8f2", # class: ''
Whitespace: "", # class: 'w'
Error: "#960050 bg:#1e0010", # class: 'err'
Other: "", # class 'x'
Comment: "#75715e", # class: 'c'
Comment.Multiline: "", # class: 'cm'
Comment.Preproc: "", # class: 'cp'
Comment.Single: "", # class: 'c1'
Comment.Special: "", # class: 'cs'
Keyword: "#66d9ef", # class: 'k'
Keyword.Constant: "", # class: 'kc'
Keyword.Declaration: "", # class: 'kd'
Keyword.Namespace: "#f92672", # class: 'kn'
Keyword.Pseudo: "", # class: 'kp'
Keyword.Reserved: "", # class: 'kr'
Keyword.Type: "", # class: 'kt'
Operator: "#f92672", # class: 'o'
Operator.Word: "", # class: 'ow' - like keywords
Punctuation: "#f8f8f2", # class: 'p'
Name: "#f8f8f2", # class: 'n'
Name.Attribute: "#a6e22e", # class: 'na' - to be revised
Name.Builtin: "", # class: 'nb'
Name.Builtin.Pseudo: "", # class: 'bp'
Name.Class: "#a6e22e", # class: 'nc' - to be revised
Name.Constant: "#66d9ef", # class: 'no' - to be revised
Name.Decorator: "#a6e22e", # class: 'nd' - to be revised
Name.Entity: "", # class: 'ni'
Name.Exception: "#a6e22e", # class: 'ne'
Name.Function: "#a6e22e", # class: 'nf'
Name.Property: "", # class: 'py'
Name.Label: "", # class: 'nl'
Name.Namespace: "", # class: 'nn' - to be revised
Name.Other: "#a6e22e", # class: 'nx'
Name.Tag: "#f92672", # class: 'nt' - like a keyword
Name.Variable: "", # class: 'nv' - to be revised
Name.Variable.Class: "", # class: 'vc' - to be revised
Name.Variable.Global: "", # class: 'vg' - to be revised
Name.Variable.Instance: "", # class: 'vi' - to be revised
Number: "#ae81ff", # class: 'm'
Number.Float: "", # class: 'mf'
Number.Hex: "", # class: 'mh'
Number.Integer: "", # class: 'mi'
Number.Integer.Long: "", # class: 'il'
Number.Oct: "", # class: 'mo'
Literal: "#ae81ff", # class: 'l'
Literal.Date: "#e6db74", # class: 'ld'
String: "#e6db74", # class: 's'
String.Backtick: "", # class: 'sb'
String.Char: "", # class: 'sc'
String.Doc: "", # class: 'sd' - like a comment
String.Double: "", # class: 's2'
String.Escape: "#ae81ff", # class: 'se'
String.Heredoc: "", # class: 'sh'
String.Interpol: "", # class: 'si'
String.Other: "", # class: 'sx'
String.Regex: "", # class: 'sr'
String.Single: "", # class: 's1'
String.Symbol: "", # class: 'ss'
Generic: "", # class: 'g'
Generic.Deleted: "#f92672", # class: 'gd',
Generic.Emph: "italic", # class: 'ge'
Generic.Error: "", # class: 'gr'
Generic.Heading: "", # class: 'gh'
Generic.Inserted: "#a6e22e", # class: 'gi'
Generic.Output: "", # class: 'go'
Generic.Prompt: "", # class: 'gp'
Generic.Strong: "bold", # class: 'gs'
Generic.Subheading: "#75715e", # class: 'gu'
Generic.Traceback: "", # class: 'gt'
}
|
mpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12955,
14,
2106,
745,
5789,
272,
18294,
2878,
23597,
339,
603,
1017,
530,
314,
10953,
745,
5789,
3164,
5687,
14,
21311,
641,
307,
17771,
14,
647,
14,
339,
1455,
921,
1544,
14,
2106,
745,
5789,
14,
7530,
15,
11486,
15,
7968,
15,
1780,
15,
1046,
15,
505,
17684,
13,
2326,
13,
7915,
15,
339,
520,
7307,
26,
1898,
8315,
13,
7280,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
504,
13277,
14,
2487,
492,
19442,
199,
504,
13277,
14,
1418,
492,
6431,
12,
2812,
12,
6819,
12,
2624,
12,
4520,
12,
4516,
12,
971,
1362,
4860,
12,
11013,
12,
8307,
12,
24403,
12,
10357,
12,
5439,
12,
18271,
199,
199,
533,
10953,
745,
5789,
6609,
8,
6609,
304,
272,
408,
272,
961,
3449,
24102,
2932,
314,
10953,
745,
5789,
3164,
5687,
14,
272,
408,
339,
8020,
63,
2326,
275,
5426,
1465,
29736,
2,
272,
11850,
63,
2326,
275,
5426,
1887,
23946,
69,
2,
339,
15725,
275,
469,
267,
327,
3091,
5226,
1021,
367,
314,
2569,
26,
267,
4516,
26,
10473,
5426,
70,
24,
70,
24,
70,
18,
401,
327,
1021,
26,
221,
2125,
267,
24403,
26,
4483,
4873,
263,
327,
1021,
26,
283,
87,
7,
267,
4520,
26,
9326,
5426,
2534,
25426,
12994,
15596,
17,
69,
17657,
401,
327,
1021,
26,
283,
1508,
7,
267,
5439,
26,
9326,
4873,
263,
327,
1021,
283,
88,
7,
398,
6819,
26,
7861,
5426,
32339,
1046,
69,
401,
327,
1021,
26,
283,
67,
7,
267,
6819,
14,
18933,
26,
260,
4873,
263,
327,
1021,
26,
283,
4400,
7,
267,
6819,
14,
19285,
26,
3698,
4873,
263,
327,
1021,
26,
283,
1850,
7,
267,
6819,
14,
7200,
26,
3322,
4873,
263,
327,
1021,
26,
283,
67,
17,
7,
267,
6819,
14,
12246,
26,
3698,
4873,
263,
327,
1021,
26,
283,
1259,
7,
398,
6431,
26,
7861,
5426,
1272,
68,
25,
2829,
401,
327,
1021,
26,
283,
75,
7,
267,
6431,
14,
9737,
26,
3515,
4873,
263,
327,
1021,
26,
283,
75,
67,
7,
267,
6431,
14,
17737,
26,
755,
4873,
263,
327,
1021,
26,
283,
25606,
7,
267,
6431,
14,
8814,
26,
260,
5426,
70,
27642,
2819,
401,
327,
1021,
26,
283,
18974,
7,
267,
6431,
14,
23414,
26,
3322,
4873,
263,
327,
1021,
26,
283,
25017,
7,
267,
6431,
14,
10285,
26,
3515,
4873,
263,
327,
1021,
26,
283,
16779,
7,
267,
6431,
14,
804,
26,
4519,
4873,
263,
327,
1021,
26,
283,
5973,
7,
398,
11013,
26,
8295,
5426,
70,
27642,
2819,
401,
327,
1021,
26,
283,
79,
7,
267,
11013,
14,
10155,
26,
3777,
4873,
263,
327,
1021,
26,
283,
583,
7,
446,
2839,
7681,
398,
10357,
26,
5185,
5426,
70,
24,
70,
24,
70,
18,
401,
327,
1021,
26,
283,
80,
7,
398,
2812,
26,
10473,
5426,
70,
24,
70,
24,
70,
18,
401,
327,
1021,
26,
283,
78,
7,
267,
2812,
14,
1646,
26,
3322,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
3540,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
12306,
26,
4519,
4873,
263,
327,
1021,
26,
283,
4994,
7,
267,
2812,
14,
12306,
14,
23414,
26,
755,
4873,
263,
327,
1021,
26,
283,
10913,
7,
267,
2812,
14,
2543,
26,
4483,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
7966,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
9737,
26,
3777,
5426,
1272,
68,
25,
2829,
401,
327,
1021,
26,
283,
889,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
14946,
26,
3322,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
977,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
7302,
26,
5185,
4873,
263,
327,
1021,
26,
283,
8445,
7,
267,
2812,
14,
1726,
26,
3322,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
685,
7,
267,
2812,
14,
3481,
26,
3777,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
9914,
7,
267,
2812,
14,
3697,
26,
3777,
4873,
263,
327,
1021,
26,
283,
647,
7,
267,
2812,
14,
4314,
26,
4483,
4873,
263,
327,
1021,
26,
283,
7530,
7,
267,
2812,
14,
8814,
26,
3322,
4873,
263,
327,
1021,
26,
283,
4411,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
8632,
26,
4483,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
7343,
7,
267,
2812,
14,
1931,
26,
8295,
5426,
70,
27642,
2819,
401,
327,
1021,
26,
283,
343,
7,
446,
2839,
282,
4252,
267,
2812,
14,
2773,
26,
3777,
4873,
263,
327,
1021,
26,
283,
15969,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
2773,
14,
2543,
26,
755,
4873,
263,
327,
1021,
26,
283,
6737,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
2773,
14,
7025,
26,
420,
4873,
263,
327,
1021,
26,
283,
10929,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
2773,
14,
3244,
26,
259,
4873,
263,
327,
1021,
26,
283,
433,
7,
446,
370,
506,
295,
17311,
398,
4860,
26,
8540,
5426,
3624,
2835,
556,
401,
327,
1021,
26,
283,
77,
7,
267,
4860,
14,
5136,
26,
4519,
4873,
263,
327,
1021,
26,
283,
11821,
7,
267,
4860,
14,
10373,
26,
4483,
4873,
263,
327,
1021,
26,
283,
17077,
7,
267,
4860,
14,
2674,
26,
3322,
4873,
263,
327,
1021,
26,
283,
2664,
7,
267,
4860,
14,
2674,
14,
9551,
26,
755,
4873,
263,
327,
1021,
26,
283,
382,
7,
267,
4860,
14,
17584,
26,
4483,
4873,
263,
327,
1021,
26,
283,
573,
7,
398,
18271,
26,
7861,
5426,
3624,
2835,
556,
401,
327,
1021,
26,
283,
76,
7,
267,
18271,
14,
2506,
26,
4519,
5426,
69,
22,
697,
1342,
401,
327,
1021,
26,
283,
1447,
7,
398,
2624,
26,
8540,
5426,
69,
22,
697,
1342,
401,
327,
1021,
26,
283,
83,
7,
267,
2624,
14,
4540,
8284,
26,
3698,
4873,
263,
327,
1021,
26,
283,
9264,
7,
267,
2624,
14,
1610,
26,
5185,
4873,
263,
327,
1021,
26,
283,
551,
7,
267,
2624,
14,
3768,
26,
4483,
4873,
263,
327,
1021,
26,
283,
3893,
7,
446,
2839
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12955,
14,
2106,
745,
5789,
272,
18294,
2878,
23597,
339,
603,
1017,
530,
314,
10953,
745,
5789,
3164,
5687,
14,
21311,
641,
307,
17771,
14,
647,
14,
339,
1455,
921,
1544,
14,
2106,
745,
5789,
14,
7530,
15,
11486,
15,
7968,
15,
1780,
15,
1046,
15,
505,
17684,
13,
2326,
13,
7915,
15,
339,
520,
7307,
26,
1898,
8315,
13,
7280,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
504,
13277,
14,
2487,
492,
19442,
199,
504,
13277,
14,
1418,
492,
6431,
12,
2812,
12,
6819,
12,
2624,
12,
4520,
12,
4516,
12,
971,
1362,
4860,
12,
11013,
12,
8307,
12,
24403,
12,
10357,
12,
5439,
12,
18271,
199,
199,
533,
10953,
745,
5789,
6609,
8,
6609,
304,
272,
408,
272,
961,
3449,
24102,
2932,
314,
10953,
745,
5789,
3164,
5687,
14,
272,
408,
339,
8020,
63,
2326,
275,
5426,
1465,
29736,
2,
272,
11850,
63,
2326,
275,
5426,
1887,
23946,
69,
2,
339,
15725,
275,
469,
267,
327,
3091,
5226,
1021,
367,
314,
2569,
26,
267,
4516,
26,
10473,
5426,
70,
24,
70,
24,
70,
18,
401,
327,
1021,
26,
221,
2125,
267,
24403,
26,
4483,
4873,
263,
327,
1021,
26,
283,
87,
7,
267,
4520,
26,
9326,
5426,
2534,
25426,
12994,
15596,
17,
69,
17657,
401,
327,
1021,
26,
283,
1508,
7,
267,
5439,
26,
9326,
4873,
263,
327,
1021,
283,
88,
7,
398,
6819,
26,
7861,
5426,
32339,
1046,
69,
401,
327,
1021,
26,
283,
67,
7,
267,
6819,
14,
18933,
26,
260,
4873,
263,
327,
1021,
26,
283,
4400,
7,
267,
6819,
14,
19285,
26,
3698,
4873,
263,
327,
1021,
26,
283,
1850,
7,
267,
6819,
14,
7200,
26,
3322,
4873,
263,
327,
1021,
26,
283,
67,
17,
7,
267,
6819,
14,
12246,
26,
3698,
4873,
263,
327,
1021,
26,
283,
1259,
7,
398,
6431,
26,
7861,
5426,
1272,
68,
25,
2829,
401,
327,
1021,
26,
283,
75,
7,
267,
6431,
14,
9737,
26,
3515,
4873,
263,
327,
1021,
26,
283,
75,
67,
7,
267,
6431,
14,
17737,
26,
755,
4873,
263,
327,
1021,
26,
283,
25606,
7,
267,
6431,
14,
8814,
26,
260,
5426,
70,
27642,
2819,
401,
327,
1021,
26,
283,
18974,
7,
267,
6431,
14,
23414,
26,
3322,
4873,
263,
327,
1021,
26,
283,
25017,
7,
267,
6431,
14,
10285,
26,
3515,
4873,
263,
327,
1021,
26,
283,
16779,
7,
267,
6431,
14,
804,
26,
4519,
4873,
263,
327,
1021,
26,
283,
5973,
7,
398,
11013,
26,
8295,
5426,
70,
27642,
2819,
401,
327,
1021,
26,
283,
79,
7,
267,
11013,
14,
10155,
26,
3777,
4873,
263,
327,
1021,
26,
283,
583,
7,
446,
2839,
7681,
398,
10357,
26,
5185,
5426,
70,
24,
70,
24,
70,
18,
401,
327,
1021,
26,
283,
80,
7,
398,
2812,
26,
10473,
5426,
70,
24,
70,
24,
70,
18,
401,
327,
1021,
26,
283,
78,
7,
267,
2812,
14,
1646,
26,
3322,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
3540,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
12306,
26,
4519,
4873,
263,
327,
1021,
26,
283,
4994,
7,
267,
2812,
14,
12306,
14,
23414,
26,
755,
4873,
263,
327,
1021,
26,
283,
10913,
7,
267,
2812,
14,
2543,
26,
4483,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
7966,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
9737,
26,
3777,
5426,
1272,
68,
25,
2829,
401,
327,
1021,
26,
283,
889,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
14946,
26,
3322,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
977,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
7302,
26,
5185,
4873,
263,
327,
1021,
26,
283,
8445,
7,
267,
2812,
14,
1726,
26,
3322,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
685,
7,
267,
2812,
14,
3481,
26,
3777,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
9914,
7,
267,
2812,
14,
3697,
26,
3777,
4873,
263,
327,
1021,
26,
283,
647,
7,
267,
2812,
14,
4314,
26,
4483,
4873,
263,
327,
1021,
26,
283,
7530,
7,
267,
2812,
14,
8814,
26,
3322,
4873,
263,
327,
1021,
26,
283,
4411,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
8632,
26,
4483,
5426,
65,
22,
69,
1081,
69,
401,
327,
1021,
26,
283,
7343,
7,
267,
2812,
14,
1931,
26,
8295,
5426,
70,
27642,
2819,
401,
327,
1021,
26,
283,
343,
7,
446,
2839,
282,
4252,
267,
2812,
14,
2773,
26,
3777,
4873,
263,
327,
1021,
26,
283,
15969,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
2773,
14,
2543,
26,
755,
4873,
263,
327,
1021,
26,
283,
6737,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
2773,
14,
7025,
26,
420,
4873,
263,
327,
1021,
26,
283,
10929,
7,
446,
370,
506,
295,
17311,
267,
2812,
14,
2773,
14,
3244,
26,
259,
4873,
263,
327,
1021,
26,
283,
433,
7,
446,
370,
506,
295,
17311,
398,
4860,
26,
8540,
5426,
3624,
2835,
556,
401,
327,
1021,
26,
283,
77,
7,
267,
4860,
14,
5136,
26,
4519,
4873,
263,
327,
1021,
26,
283,
11821,
7,
267,
4860,
14,
10373,
26,
4483,
4873,
263,
327,
1021,
26,
283,
17077,
7,
267,
4860,
14,
2674,
26,
3322,
4873,
263,
327,
1021,
26,
283,
2664,
7,
267,
4860,
14,
2674,
14,
9551,
26,
755,
4873,
263,
327,
1021,
26,
283,
382,
7,
267,
4860,
14,
17584,
26,
4483,
4873,
263,
327,
1021,
26,
283,
573,
7,
398,
18271,
26,
7861,
5426,
3624,
2835,
556,
401,
327,
1021,
26,
283,
76,
7,
267,
18271,
14,
2506,
26,
4519,
5426,
69,
22,
697,
1342,
401,
327,
1021,
26,
283,
1447,
7,
398,
2624,
26,
8540,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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
] |
mshafiq9/django
|
django/contrib/messages/api.py
|
512
|
3202
|
from django.contrib.messages import constants
from django.contrib.messages.storage import default_storage
from django.http import HttpRequest
__all__ = (
'add_message', 'get_messages',
'get_level', 'set_level',
'debug', 'info', 'success', 'warning', 'error',
'MessageFailure',
)
class MessageFailure(Exception):
pass
def add_message(request, level, message, extra_tags='', fail_silently=False):
"""
Attempts to add a message to the request using the 'messages' app.
"""
if not isinstance(request, HttpRequest):
raise TypeError("add_message() argument must be an HttpRequest object, "
"not '%s'." % request.__class__.__name__)
if hasattr(request, '_messages'):
return request._messages.add(level, message, extra_tags)
if not fail_silently:
raise MessageFailure('You cannot add messages without installing '
'django.contrib.messages.middleware.MessageMiddleware')
def get_messages(request):
"""
Returns the message storage on the request if it exists, otherwise returns
an empty list.
"""
if hasattr(request, '_messages'):
return request._messages
else:
return []
def get_level(request):
"""
Returns the minimum level of messages to be recorded.
The default level is the ``MESSAGE_LEVEL`` setting. If this is not found,
the ``INFO`` level is used.
"""
if hasattr(request, '_messages'):
storage = request._messages
else:
storage = default_storage(request)
return storage.level
def set_level(request, level):
"""
Sets the minimum level of messages to be recorded, returning ``True`` if
the level was recorded successfully.
If set to ``None``, the default level will be used (see the ``get_level``
method).
"""
if not hasattr(request, '_messages'):
return False
request._messages.level = level
return True
def debug(request, message, extra_tags='', fail_silently=False):
"""
Adds a message with the ``DEBUG`` level.
"""
add_message(request, constants.DEBUG, message, extra_tags=extra_tags,
fail_silently=fail_silently)
def info(request, message, extra_tags='', fail_silently=False):
"""
Adds a message with the ``INFO`` level.
"""
add_message(request, constants.INFO, message, extra_tags=extra_tags,
fail_silently=fail_silently)
def success(request, message, extra_tags='', fail_silently=False):
"""
Adds a message with the ``SUCCESS`` level.
"""
add_message(request, constants.SUCCESS, message, extra_tags=extra_tags,
fail_silently=fail_silently)
def warning(request, message, extra_tags='', fail_silently=False):
"""
Adds a message with the ``WARNING`` level.
"""
add_message(request, constants.WARNING, message, extra_tags=extra_tags,
fail_silently=fail_silently)
def error(request, message, extra_tags='', fail_silently=False):
"""
Adds a message with the ``ERROR`` level.
"""
add_message(request, constants.ERROR, message, extra_tags=extra_tags,
fail_silently=fail_silently)
|
bsd-3-clause
|
[
504,
1639,
14,
2828,
14,
3431,
492,
5262,
199,
504,
1639,
14,
2828,
14,
3431,
14,
3494,
492,
849,
63,
3494,
199,
504,
1639,
14,
1014,
492,
20730,
199,
199,
363,
452,
363,
275,
334,
272,
283,
525,
63,
1188,
297,
283,
362,
63,
3431,
297,
272,
283,
362,
63,
1896,
297,
283,
409,
63,
1896,
297,
272,
283,
1757,
297,
283,
815,
297,
283,
3742,
297,
283,
3764,
297,
283,
705,
297,
272,
283,
2209,
6782,
297,
199,
9,
421,
199,
533,
6430,
6782,
8,
1726,
304,
272,
986,
421,
199,
318,
1050,
63,
1188,
8,
1069,
12,
2166,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
17413,
1086,
370,
1050,
282,
1245,
370,
314,
1056,
1808,
314,
283,
3431,
7,
1145,
14,
272,
408,
272,
340,
440,
1228,
8,
1069,
12,
20730,
304,
267,
746,
3146,
480,
525,
63,
1188,
342,
1423,
1471,
506,
376,
20730,
909,
12,
298,
717,
298,
1397,
1543,
83,
16669,
450,
1056,
855,
533,
4914,
354,
3368,
272,
340,
2688,
8,
1069,
12,
2513,
3431,
735,
267,
372,
1056,
423,
3431,
14,
525,
8,
1896,
12,
1245,
12,
2402,
63,
2969,
9,
272,
340,
440,
2449,
63,
25163,
26,
267,
746,
6430,
6782,
360,
5556,
3913,
1050,
3788,
1928,
22200,
283,
490,
283,
1176,
14,
2828,
14,
3431,
14,
5754,
14,
2209,
6608,
358,
421,
199,
318,
664,
63,
3431,
8,
1069,
304,
272,
408,
272,
1803,
314,
1245,
4887,
641,
314,
1056,
340,
652,
3495,
12,
4257,
2529,
272,
376,
2701,
769,
14,
272,
408,
272,
340,
2688,
8,
1069,
12,
2513,
3431,
735,
267,
372,
1056,
423,
3431,
272,
587,
26,
267,
372,
942,
421,
199,
318,
664,
63,
1896,
8,
1069,
304,
272,
408,
272,
1803,
314,
7481,
2166,
402,
3788,
370,
506,
18894,
14,
339,
710,
849,
2166,
365,
314,
1124,
8272,
63,
11817,
1040,
4260,
14,
982,
642,
365,
440,
1911,
12,
272,
314,
1124,
4531,
1040,
2166,
365,
1202,
14,
272,
408,
272,
340,
2688,
8,
1069,
12,
2513,
3431,
735,
267,
4887,
275,
1056,
423,
3431,
272,
587,
26,
267,
4887,
275,
849,
63,
3494,
8,
1069,
9,
272,
372,
4887,
14,
1896,
421,
199,
318,
663,
63,
1896,
8,
1069,
12,
2166,
304,
272,
408,
272,
10729,
314,
7481,
2166,
402,
3788,
370,
506,
18894,
12,
8152,
1124,
549,
1040,
340,
272,
314,
2166,
1990,
18894,
8792,
14,
339,
982,
663,
370,
1124,
403,
4542,
314,
849,
2166,
911,
506,
1202,
334,
3239,
314,
1124,
362,
63,
1896,
1040,
272,
1083,
680,
272,
408,
272,
340,
440,
2688,
8,
1069,
12,
2513,
3431,
735,
267,
372,
756,
272,
1056,
423,
3431,
14,
1896,
275,
2166,
272,
372,
715,
421,
199,
318,
3105,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
5287,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
5287,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
9,
421,
199,
318,
2256,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
4531,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
4531,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
9,
421,
199,
318,
3182,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
12779,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
12779,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
9,
421,
199,
318,
5721,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
9171,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
9171,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
9,
421,
199,
318,
1125,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
3170,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
3170,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
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
] |
[
1639,
14,
2828,
14,
3431,
492,
5262,
199,
504,
1639,
14,
2828,
14,
3431,
14,
3494,
492,
849,
63,
3494,
199,
504,
1639,
14,
1014,
492,
20730,
199,
199,
363,
452,
363,
275,
334,
272,
283,
525,
63,
1188,
297,
283,
362,
63,
3431,
297,
272,
283,
362,
63,
1896,
297,
283,
409,
63,
1896,
297,
272,
283,
1757,
297,
283,
815,
297,
283,
3742,
297,
283,
3764,
297,
283,
705,
297,
272,
283,
2209,
6782,
297,
199,
9,
421,
199,
533,
6430,
6782,
8,
1726,
304,
272,
986,
421,
199,
318,
1050,
63,
1188,
8,
1069,
12,
2166,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
17413,
1086,
370,
1050,
282,
1245,
370,
314,
1056,
1808,
314,
283,
3431,
7,
1145,
14,
272,
408,
272,
340,
440,
1228,
8,
1069,
12,
20730,
304,
267,
746,
3146,
480,
525,
63,
1188,
342,
1423,
1471,
506,
376,
20730,
909,
12,
298,
717,
298,
1397,
1543,
83,
16669,
450,
1056,
855,
533,
4914,
354,
3368,
272,
340,
2688,
8,
1069,
12,
2513,
3431,
735,
267,
372,
1056,
423,
3431,
14,
525,
8,
1896,
12,
1245,
12,
2402,
63,
2969,
9,
272,
340,
440,
2449,
63,
25163,
26,
267,
746,
6430,
6782,
360,
5556,
3913,
1050,
3788,
1928,
22200,
283,
490,
283,
1176,
14,
2828,
14,
3431,
14,
5754,
14,
2209,
6608,
358,
421,
199,
318,
664,
63,
3431,
8,
1069,
304,
272,
408,
272,
1803,
314,
1245,
4887,
641,
314,
1056,
340,
652,
3495,
12,
4257,
2529,
272,
376,
2701,
769,
14,
272,
408,
272,
340,
2688,
8,
1069,
12,
2513,
3431,
735,
267,
372,
1056,
423,
3431,
272,
587,
26,
267,
372,
942,
421,
199,
318,
664,
63,
1896,
8,
1069,
304,
272,
408,
272,
1803,
314,
7481,
2166,
402,
3788,
370,
506,
18894,
14,
339,
710,
849,
2166,
365,
314,
1124,
8272,
63,
11817,
1040,
4260,
14,
982,
642,
365,
440,
1911,
12,
272,
314,
1124,
4531,
1040,
2166,
365,
1202,
14,
272,
408,
272,
340,
2688,
8,
1069,
12,
2513,
3431,
735,
267,
4887,
275,
1056,
423,
3431,
272,
587,
26,
267,
4887,
275,
849,
63,
3494,
8,
1069,
9,
272,
372,
4887,
14,
1896,
421,
199,
318,
663,
63,
1896,
8,
1069,
12,
2166,
304,
272,
408,
272,
10729,
314,
7481,
2166,
402,
3788,
370,
506,
18894,
12,
8152,
1124,
549,
1040,
340,
272,
314,
2166,
1990,
18894,
8792,
14,
339,
982,
663,
370,
1124,
403,
4542,
314,
849,
2166,
911,
506,
1202,
334,
3239,
314,
1124,
362,
63,
1896,
1040,
272,
1083,
680,
272,
408,
272,
340,
440,
2688,
8,
1069,
12,
2513,
3431,
735,
267,
372,
756,
272,
1056,
423,
3431,
14,
1896,
275,
2166,
272,
372,
715,
421,
199,
318,
3105,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
5287,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
5287,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
9,
421,
199,
318,
2256,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
4531,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
4531,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
9,
421,
199,
318,
3182,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
12779,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
12779,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
9,
421,
199,
318,
5721,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
9171,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
9171,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
9,
421,
199,
318,
1125,
8,
1069,
12,
1245,
12,
2402,
63,
2969,
4581,
2449,
63,
25163,
29,
797,
304,
272,
408,
272,
15747,
282,
1245,
543,
314,
1124,
3170,
1040,
2166,
14,
272,
408,
272,
1050,
63,
1188,
8,
1069,
12,
5262,
14,
3170,
12,
1245,
12,
2402,
63,
2969,
29,
2911,
63,
2969,
12,
355,
2449,
63,
25163,
29,
1633,
63,
25163,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
mosbasik/buzhug
|
javasrc/lib/Jython/Lib/test/test_builtin_jy.py
|
9
|
9889
|
# -*- coding: utf-8 -*-
import test.test_support, unittest
from test.test_support import TESTFN, unlink
import sys, UserDict
from codecs import BOM_UTF8
class BuiltinTest(unittest.TestCase):
def test_in_sys_modules(self):
self.assert_("__builtin__" in sys.modules,
"__builtin__ not found in sys.modules")
def test_hasattr_swallows_exceptions(self):
class Foo(object):
def __getattr__(self, name):
raise TypeError()
self.assert_(not hasattr(Foo(), 'bar'))
def test_getattr_custom_AttributeError(self):
class Foo(object):
def __getattr__(self, name):
raise AttributeError('baz')
try:
getattr(Foo(), 'bar')
except AttributeError, ae:
self.assertEqual(str(ae), 'baz')
else:
self.assertTrue(False)
def test_dir(self):
# for http://bugs.jython.org/issue1196
class Foo(object):
def __getattribute__(self, name):
return name
self.assertEqual(dir(Foo()), [])
def test_numeric_cmp(self):
# http://bugs.jython.org/issue1449
for numeric in 1, 2L, 3.0, 4j:
self.assertTrue(numeric < Ellipsis)
self.assertTrue(Ellipsis > numeric)
class LoopTest(unittest.TestCase):
def test_break(self):
while 1:
i = 0
while i<10:
i = i+1
else:
break
class DebugTest(unittest.TestCase):
def test_debug(self):
"__debug__ exists"
try:
foo = __debug__
except NameError, e:
self.assert_(False)
class GetSliceTest(unittest.TestCase):
def test_getslice(self):
class F:
def __getitem__(self,*args): return '__getitem__ '+repr(args)
def __getslice__(self,*args): return '__getslice__ '+repr(args)
self.failUnless("__getslice__ (1, 1)" in F()[1:1])
class ChrTest(unittest.TestCase):
def test_debug(self):
"chr(None) throws TypeError"
foo = False
try:
chr(None)
except TypeError, e:
foo = True
self.assert_(foo)
class ReturnTest(unittest.TestCase):
def test_finally(self):
'''return in finally causes java.lang.VerifyError at compile time'''
def timeit(f):
t0 = time.clock()
try:
f()
finally:
t1 = time.clock()
return t1 - t0
class ReprTest(unittest.TestCase):
def test_unbound(self):
"Unbound methods indicated properly in repr"
class Foo:
def bar(s):
pass
self.failUnless(repr(Foo.bar).startswith('<unbound method'))
class CallableTest(unittest.TestCase):
def test_callable_oldstyle(self):
class Foo:
pass
self.assert_(callable(Foo))
self.assert_(not callable(Foo()))
class Bar:
def __call__(self):
return None
self.assert_(callable(Bar()))
class Baz:
def __getattr__(self, name):
return None
self.assert_(callable(Baz()))
def test_callable_newstyle(self):
class Foo(object):
pass
self.assert_(callable(Foo))
self.assert_(not callable(Foo()))
class Bar(object):
def __call__(self):
return None
self.assert_(callable(Bar()))
class Baz(object):
def __getattr__(self, name):
return None
self.assert_(not callable(Baz()))
class ConversionTest(unittest.TestCase):
class Foo(object):
def __int__(self):
return 3
def __float__(self):
return 3.14
foo = Foo()
def test_range_non_int(self):
self.assertEqual(range(self.foo), [0, 1, 2])
def test_xrange_non_int(self):
self.assertEqual(list(xrange(self.foo)), [0, 1, 2])
def test_round_non_float(self):
self.assertEqual(round(self.Foo(), 1), 3.1)
# 2.5/2.5.1 regression
self.assertRaises(TypeError, round, '1.5')
class ExecEvalTest(unittest.TestCase):
def test_eval_bom(self):
self.assertEqual(eval(BOM_UTF8 + '"foo"'), 'foo')
# Actual BOM ignored, so causes a SyntaxError
self.assertRaises(SyntaxError, eval,
BOM_UTF8.decode('iso-8859-1') + '"foo"')
def test_parse_str_eval(self):
foo = 'föö'
for code, expected in (
("'%s'" % foo.decode('utf-8'), foo),
("# coding: utf-8\n'%s'" % foo, foo),
("%s'%s'" % (BOM_UTF8, foo), foo),
("'\rfoo\r'", '\rfoo\r')
):
mod = compile(code, 'test.py', 'eval')
result = eval(mod)
self.assertEqual(result, expected)
result = eval(code)
self.assertEqual(result, expected)
def test_parse_str_exec(self):
foo = 'föö'
for code, expected in (
("bar = '%s'" % foo.decode('utf-8'), foo),
("# coding: utf-8\nbar = '%s'" % foo, foo),
("%sbar = '%s'" % (BOM_UTF8, foo), foo),
("bar = '\rfoo\r'", '\rfoo\r')
):
ns = {}
exec code in ns
self.assertEqual(ns['bar'], expected)
def test_general_eval(self):
# Tests that general mappings can be used for the locals argument
class M:
"Test mapping interface versus possible calls from eval()."
def __getitem__(self, key):
if key == 'a':
return 12
raise KeyError
def keys(self):
return list('xyz')
m = M()
g = globals()
self.assertEqual(eval('a', g, m), 12)
self.assertRaises(NameError, eval, 'b', g, m)
self.assertEqual(eval('dir()', g, m), list('xyz'))
self.assertEqual(eval('globals()', g, m), g)
self.assertEqual(eval('locals()', g, m), m)
#XXX: the following assert holds in CPython because globals must be a
# real dict. Should Jython be as strict?
#self.assertRaises(TypeError, eval, 'a', m)
class A:
"Non-mapping"
pass
m = A()
self.assertRaises(TypeError, eval, 'a', g, m)
# Verify that dict subclasses work as well
class D(dict):
def __getitem__(self, key):
if key == 'a':
return 12
return dict.__getitem__(self, key)
def keys(self):
return list('xyz')
d = D()
self.assertEqual(eval('a', g, d), 12)
self.assertRaises(NameError, eval, 'b', g, d)
self.assertEqual(eval('dir()', g, d), list('xyz'))
self.assertEqual(eval('globals()', g, d), g)
self.assertEqual(eval('locals()', g, d), d)
# Verify locals stores (used by list comps)
eval('[locals() for i in (2,3)]', g, d)
eval('[locals() for i in (2,3)]', g, UserDict.UserDict())
class SpreadSheet:
"Sample application showing nested, calculated lookups."
_cells = {}
def __setitem__(self, key, formula):
self._cells[key] = formula
def __getitem__(self, key):
return eval(self._cells[key], globals(), self)
ss = SpreadSheet()
ss['a1'] = '5'
ss['a2'] = 'a1*6'
ss['a3'] = 'a2*7'
self.assertEqual(ss['a3'], 210)
# Verify that dir() catches a non-list returned by eval
# SF bug #1004669
class C:
def __getitem__(self, item):
raise KeyError(item)
def keys(self):
return 'a'
self.assertRaises(TypeError, eval, 'dir()', globals(), C())
# Done outside of the method test_z to get the correct scope
z = 0
f = open(TESTFN, 'w')
f.write('z = z+1\n')
f.write('z = z*2\n')
f.close()
execfile(TESTFN)
def test_execfile(self):
globals = {'a': 1, 'b': 2}
locals = {'b': 200, 'c': 300}
class M:
"Test mapping interface versus possible calls from execfile()."
def __init__(self):
self.z = 10
def __getitem__(self, key):
if key == 'z':
return self.z
raise KeyError
def __setitem__(self, key, value):
if key == 'z':
self.z = value
return
raise KeyError
locals = M()
locals['z'] = 0
execfile(TESTFN, globals, locals)
self.assertEqual(locals['z'], 2)
self.assertRaises(TypeError, execfile)
self.assertRaises(TypeError, execfile, TESTFN, {}, ())
unlink(TESTFN)
class ModuleNameTest(unittest.TestCase):
"""Tests that the module when imported has the same __name__"""
def test_names(self):
for name in sys.builtin_module_names:
if name not in ('time', '_random', 'array', '_collections', '_ast'):
module = __import__(name)
self.assertEqual(name, module.__name__)
def test_main():
test.test_support.run_unittest(BuiltinTest,
LoopTest,
DebugTest,
GetSliceTest,
ChrTest,
ReturnTest,
ReprTest,
CallableTest,
ConversionTest,
ExecEvalTest,
ModuleNameTest,
)
if __name__ == "__main__":
test_main()
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
511,
14,
396,
63,
4058,
12,
2882,
199,
504,
511,
14,
396,
63,
4058,
492,
25788,
12,
17002,
199,
199,
646,
984,
12,
32241,
199,
199,
504,
6010,
492,
17720,
63,
6610,
24,
199,
199,
533,
22422,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
262,
63,
1274,
63,
3112,
8,
277,
304,
267,
291,
14,
479,
14332,
363,
5351,
16526,
315,
984,
14,
3112,
12,
288,
4396,
5351,
363,
440,
1911,
315,
984,
14,
3112,
531,
339,
347,
511,
63,
11161,
63,
3519,
24077,
63,
3924,
8,
277,
304,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
5675,
721,
277,
12,
536,
304,
355,
746,
3146,
342,
267,
291,
14,
479,
2531,
1397,
2688,
8,
5686,
1062,
283,
1700,
1333,
339,
347,
511,
63,
5675,
63,
4229,
63,
10227,
8,
277,
304,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
5675,
721,
277,
12,
536,
304,
355,
746,
4281,
360,
6185,
358,
267,
862,
26,
288,
2519,
8,
5686,
1062,
283,
1700,
358,
267,
871,
4281,
12,
16951,
26,
288,
291,
14,
629,
8,
495,
8,
3624,
395,
283,
6185,
358,
267,
587,
26,
288,
291,
14,
1815,
8,
797,
9,
339,
347,
511,
63,
694,
8,
277,
304,
267,
327,
367,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
845,
2534,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
18480,
721,
277,
12,
536,
304,
355,
372,
536,
267,
291,
14,
629,
8,
694,
8,
5686,
4000,
3073,
339,
347,
511,
63,
6677,
63,
5730,
8,
277,
304,
267,
327,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
1079,
1887,
267,
367,
8950,
315,
413,
12,
499,
44,
12,
650,
14,
16,
12,
841,
74,
26,
288,
291,
14,
1815,
8,
6677,
665,
27761,
2316,
9,
288,
291,
14,
1815,
8,
23525,
2316,
690,
8950,
9,
199,
199,
533,
18175,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
4785,
8,
277,
304,
267,
1830,
413,
26,
288,
284,
275,
378,
288,
1830,
284,
28,
709,
26,
355,
284,
275,
284,
11,
17,
288,
587,
26,
355,
2059,
199,
199,
533,
14245,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1757,
8,
277,
304,
267,
4396,
1757,
363,
3495,
2,
267,
862,
26,
288,
3925,
275,
636,
1757,
363,
267,
871,
12746,
12,
325,
26,
288,
291,
14,
479,
2531,
797,
9,
199,
199,
533,
2372,
14034,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
32131,
8,
277,
304,
267,
1021,
481,
26,
288,
347,
636,
6095,
721,
277,
19166,
589,
304,
372,
2560,
6095,
363,
6681,
2722,
8,
589,
9,
288,
347,
636,
32131,
721,
277,
19166,
589,
304,
372,
2560,
32131,
363,
6681,
2722,
8,
589,
9,
267,
291,
14,
7589,
16232,
32131,
363,
334,
17,
12,
413,
2924,
315,
481,
3430,
17,
26,
17,
566,
199,
199,
533,
2799,
82,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1757,
8,
277,
304,
267,
298,
10194,
8,
403,
9,
24266,
3146,
2,
267,
3925,
275,
756,
267,
862,
26,
288,
8678,
8,
403,
9,
267,
871,
3146,
12,
325,
26,
288,
3925,
275,
715,
267,
291,
14,
479,
2531,
1421,
9,
199,
199,
533,
1432,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
15172,
8,
277,
304,
267,
1449,
1107,
315,
3753,
14486,
12120,
14,
4159,
14,
7496,
547,
737,
6555,
900,
2344,
267,
347,
900,
390,
8,
70,
304,
288,
307,
16,
275,
900,
14,
9597,
342,
288,
862,
26,
355,
289,
342,
288,
3753,
26,
355,
307,
17,
275,
900,
14,
9597,
342,
355,
372,
307,
17,
446,
307,
16,
199,
199,
533,
799,
2700,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
18124,
8,
277,
304,
267,
298,
1358,
3556,
3102,
22141,
7684,
315,
4700,
2,
267,
1021,
8024,
26,
288,
347,
4681,
8,
83,
304,
355,
986,
267,
291,
14,
7589,
8,
2722,
8,
5686,
14,
1700,
680,
2460,
4827,
18124,
1083,
1333,
199,
199,
533,
16975,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
8296,
63,
1753,
2487,
8,
277,
304,
267,
1021,
8024,
26,
288,
986,
267,
291,
14,
479,
2531,
8296,
8,
5686,
430,
267,
291,
14,
479,
2531,
1397,
4550,
8,
5686,
4059,
267,
1021,
12377,
26,
288,
347,
636,
1250,
721,
277,
304,
355,
372,
488,
267,
291,
14,
479,
2531,
8296,
8,
5281,
4059,
267,
1021,
699,
4651,
26,
288,
347,
636,
5675,
721,
277,
12,
536,
304,
355,
372,
488,
267,
291,
14,
479,
2531,
8296,
8,
19726,
4059,
339,
347,
511,
63,
8296,
63,
1222,
2487,
8,
277,
304,
267,
1021,
8024,
8,
785,
304,
288,
986,
267,
291,
14,
479,
2531,
8296,
8,
5686,
430,
267,
291,
14,
479,
2531,
1397,
4550,
8,
5686,
4059,
267,
1021,
12377,
8,
785,
304,
288,
347,
636,
1250,
721,
277,
304,
355,
372,
488,
267,
291,
14,
479,
2531,
8296,
8,
5281,
4059,
267,
1021,
699,
4651,
8,
785,
304,
288,
347,
636,
5675,
721,
277,
12,
536,
304,
355,
372,
488,
267,
291,
14,
479,
2531,
1397,
4550,
8,
19726,
4059,
199,
199,
533,
1448,
1023,
774,
8,
2796,
14,
1746,
304,
339,
1021,
8024,
8,
785,
304,
267,
347,
636,
442,
721,
277,
304,
288,
372,
650,
267,
347,
636,
1609,
721,
277,
304,
288,
372,
650,
14,
1079,
272,
3925,
275,
8024,
342,
339,
347,
511,
63,
1842,
63,
2865,
63,
442,
8,
277,
304,
267,
291,
14,
629,
8,
1842,
8,
277,
14,
1421,
395,
359,
16,
12,
413,
12,
499,
566,
339,
347,
511,
63,
21120,
63,
2865,
63,
442,
8,
277,
304,
267,
291,
14,
629,
8,
513,
8,
21120,
8,
277,
14,
1421,
1826,
359,
16,
12,
413,
12,
499,
566,
339,
347,
511,
63,
2363,
63,
2865,
63,
1609,
8,
277,
304,
267,
291,
14,
629,
8,
2363,
8,
277,
14,
5686,
1062,
413,
395,
650,
14,
17,
9,
267,
327,
499,
14,
21,
15,
18,
14,
21,
14,
17,
10864,
267,
291,
14,
1855,
8,
4333,
12,
6168,
12,
283,
17,
14,
21,
358,
199,
199,
533,
9434,
10006,
774,
8
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
511,
14,
396,
63,
4058,
12,
2882,
199,
504,
511,
14,
396,
63,
4058,
492,
25788,
12,
17002,
199,
199,
646,
984,
12,
32241,
199,
199,
504,
6010,
492,
17720,
63,
6610,
24,
199,
199,
533,
22422,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
262,
63,
1274,
63,
3112,
8,
277,
304,
267,
291,
14,
479,
14332,
363,
5351,
16526,
315,
984,
14,
3112,
12,
288,
4396,
5351,
363,
440,
1911,
315,
984,
14,
3112,
531,
339,
347,
511,
63,
11161,
63,
3519,
24077,
63,
3924,
8,
277,
304,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
5675,
721,
277,
12,
536,
304,
355,
746,
3146,
342,
267,
291,
14,
479,
2531,
1397,
2688,
8,
5686,
1062,
283,
1700,
1333,
339,
347,
511,
63,
5675,
63,
4229,
63,
10227,
8,
277,
304,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
5675,
721,
277,
12,
536,
304,
355,
746,
4281,
360,
6185,
358,
267,
862,
26,
288,
2519,
8,
5686,
1062,
283,
1700,
358,
267,
871,
4281,
12,
16951,
26,
288,
291,
14,
629,
8,
495,
8,
3624,
395,
283,
6185,
358,
267,
587,
26,
288,
291,
14,
1815,
8,
797,
9,
339,
347,
511,
63,
694,
8,
277,
304,
267,
327,
367,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
845,
2534,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
18480,
721,
277,
12,
536,
304,
355,
372,
536,
267,
291,
14,
629,
8,
694,
8,
5686,
4000,
3073,
339,
347,
511,
63,
6677,
63,
5730,
8,
277,
304,
267,
327,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
1079,
1887,
267,
367,
8950,
315,
413,
12,
499,
44,
12,
650,
14,
16,
12,
841,
74,
26,
288,
291,
14,
1815,
8,
6677,
665,
27761,
2316,
9,
288,
291,
14,
1815,
8,
23525,
2316,
690,
8950,
9,
199,
199,
533,
18175,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
4785,
8,
277,
304,
267,
1830,
413,
26,
288,
284,
275,
378,
288,
1830,
284,
28,
709,
26,
355,
284,
275,
284,
11,
17,
288,
587,
26,
355,
2059,
199,
199,
533,
14245,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1757,
8,
277,
304,
267,
4396,
1757,
363,
3495,
2,
267,
862,
26,
288,
3925,
275,
636,
1757,
363,
267,
871,
12746,
12,
325,
26,
288,
291,
14,
479,
2531,
797,
9,
199,
199,
533,
2372,
14034,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
32131,
8,
277,
304,
267,
1021,
481,
26,
288,
347,
636,
6095,
721,
277,
19166,
589,
304,
372,
2560,
6095,
363,
6681,
2722,
8,
589,
9,
288,
347,
636,
32131,
721,
277,
19166,
589,
304,
372,
2560,
32131,
363,
6681,
2722,
8,
589,
9,
267,
291,
14,
7589,
16232,
32131,
363,
334,
17,
12,
413,
2924,
315,
481,
3430,
17,
26,
17,
566,
199,
199,
533,
2799,
82,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1757,
8,
277,
304,
267,
298,
10194,
8,
403,
9,
24266,
3146,
2,
267,
3925,
275,
756,
267,
862,
26,
288,
8678,
8,
403,
9,
267,
871,
3146,
12,
325,
26,
288,
3925,
275,
715,
267,
291,
14,
479,
2531,
1421,
9,
199,
199,
533,
1432,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
15172,
8,
277,
304,
267,
1449,
1107,
315,
3753,
14486,
12120,
14,
4159,
14,
7496,
547,
737,
6555,
900,
2344,
267,
347,
900,
390,
8,
70,
304,
288,
307,
16,
275,
900,
14,
9597,
342,
288,
862,
26,
355,
289,
342,
288,
3753,
26,
355,
307,
17,
275,
900,
14,
9597,
342,
355,
372,
307,
17,
446,
307,
16,
199,
199,
533,
799,
2700,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
18124,
8,
277,
304,
267,
298,
1358,
3556,
3102,
22141,
7684,
315,
4700,
2,
267,
1021,
8024,
26,
288,
347,
4681,
8,
83,
304,
355,
986,
267,
291,
14,
7589,
8,
2722,
8,
5686,
14,
1700,
680,
2460,
4827,
18124,
1083,
1333,
199,
199,
533,
16975,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
8296,
63,
1753,
2487,
8,
277,
304,
267,
1021,
8024,
26,
288,
986,
267,
291,
14,
479,
2531,
8296,
8,
5686,
430,
267,
291,
14,
479,
2531,
1397,
4550,
8,
5686,
4059,
267,
1021,
12377,
26,
288,
347,
636,
1250,
721,
277,
304,
355,
372,
488,
267,
291,
14,
479,
2531,
8296,
8,
5281,
4059,
267,
1021,
699,
4651,
26,
288,
347,
636,
5675,
721,
277,
12,
536,
304,
355,
372,
488,
267,
291,
14,
479,
2531,
8296,
8,
19726,
4059,
339,
347,
511,
63,
8296,
63,
1222,
2487,
8,
277,
304,
267,
1021,
8024,
8,
785,
304,
288,
986,
267,
291,
14,
479,
2531,
8296,
8,
5686,
430,
267,
291,
14,
479,
2531,
1397,
4550,
8,
5686,
4059,
267,
1021,
12377,
8,
785,
304,
288,
347,
636,
1250,
721,
277,
304,
355,
372,
488,
267,
291,
14,
479,
2531,
8296,
8,
5281,
4059,
267,
1021,
699,
4651,
8,
785,
304,
288,
347,
636,
5675,
721,
277,
12,
536,
304,
355,
372,
488,
267,
291,
14,
479,
2531,
1397,
4550,
8,
19726,
4059,
199,
199,
533,
1448,
1023,
774,
8,
2796,
14,
1746,
304,
339,
1021,
8024,
8,
785,
304,
267,
347,
636,
442,
721,
277,
304,
288,
372,
650,
267,
347,
636,
1609,
721,
277,
304,
288,
372,
650,
14,
1079,
272,
3925,
275,
8024,
342,
339,
347,
511,
63,
1842,
63,
2865,
63,
442,
8,
277,
304,
267,
291,
14,
629,
8,
1842,
8,
277,
14,
1421,
395,
359,
16,
12,
413,
12,
499,
566,
339,
347,
511,
63,
21120,
63,
2865,
63,
442,
8,
277,
304,
267,
291,
14,
629,
8,
513,
8,
21120,
8,
277,
14,
1421,
1826,
359,
16,
12,
413,
12,
499,
566,
339,
347,
511,
63,
2363,
63,
2865,
63,
1609,
8,
277,
304,
267,
291,
14,
629,
8,
2363,
8,
277,
14,
5686,
1062,
413,
395,
650,
14,
17,
9,
267,
327,
499,
14,
21,
15,
18,
14,
21,
14,
17,
10864,
267,
291,
14,
1855,
8,
4333,
12,
6168,
12,
283,
17,
14,
21,
358,
199,
199,
533,
9434,
10006,
774,
8,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
stevekuznetsov/ansible
|
lib/ansible/modules/network/nxos/nxos_vrf_af.py
|
4
|
9260
|
#!/usr/bin/python
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
DOCUMENTATION = '''
---
module: nxos_vrf_af
version_added: "2.2"
short_description: Manages VRF AF.
description:
- Manages VRF AF
author: Gabriele Gerbino (@GGabriele)
notes:
- Default, where supported, restores params default value.
options:
vrf:
description:
- Name of the VRF.
required: true
afi:
description:
- Address-Family Identifier (AFI).
required: true
choices: ['ipv4', 'ipv6']
default: null
safi:
description:
- Sub Address-Family Identifier (SAFI).
required: true
choices: ['unicast', 'multicast']
default: null
route_target_both_auto_evpn:
description:
- Enable/Disable the EVPN route-target 'auto' setting for both
import and export target communities.
required: false
choices: ['true', 'false']
default: null
state:
description:
- Determines whether the config should be present or
not on the device.
required: false
default: present
choices: ['present','absent']
'''
EXAMPLES = '''
- nxos_vrf_af:
interface: nve1
vni: 6000
ingress_replication: true
username: "{{ un }}"
password: "{{ pwd }}"
host: "{{ inventory_hostname }}"
'''
RETURN = '''
proposed:
description: k/v pairs of parameters passed into module
returned: verbose mode
type: dict
sample: {"afi": "ipv4", "route_target_both_auto_evpn": true,
"safi": "unicast", "vrf": "test"}
existing:
description: k/v pairs of existing configuration
returned: verbose mode
type: dict
sample: {"afi": "ipv4", "route_target_both_auto_evpn": false,
"safi": "unicast", "vrf": "test"}
end_state:
description: k/v pairs of configuration after module execution
returned: verbose mode
type: dict
sample: {"afi": "ipv4", "route_target_both_auto_evpn": true,
"safi": "unicast", "vrf": "test"}
updates:
description: commands sent to the device
returned: always
type: list
sample: ["vrf context test", "address-family ipv4 unicast",
"route-target both auto evpn"]
changed:
description: check to see if a change was made on the device
returned: always
type: boolean
sample: true
'''
import re
from ansible.module_utils.nxos import get_config, load_config, run_commands
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.netcfg import CustomNetworkConfig
BOOL_PARAMS = ['route_target_both_auto_evpn']
PARAM_TO_COMMAND_KEYMAP = {
'route_target_both_auto_evpn': 'route-target both auto evpn',
}
PARAM_TO_DEFAULT_KEYMAP = {}
WARNINGS = []
def invoke(name, *args, **kwargs):
func = globals().get(name)
if func:
return func(*args, **kwargs)
def get_value(arg, config, module):
if arg in BOOL_PARAMS:
REGEX = re.compile(r'\s+{0}\s*$'.format(PARAM_TO_COMMAND_KEYMAP[arg]), re.M)
value = False
try:
if REGEX.search(config):
value = True
except TypeError:
value = False
else:
REGEX = re.compile(r'(?:{0}\s)(?P<value>.*)$'.format(PARAM_TO_COMMAND_KEYMAP[arg]), re.M)
value = ''
if PARAM_TO_COMMAND_KEYMAP[arg] in config:
value = REGEX.search(config).group('value')
return value
def get_existing(module, args):
existing = {}
netcfg = get_config(module)
parents = ['vrf context {0}'.format(module.params['vrf'])]
parents.append('address-family {0} {1}'.format(module.params['afi'],
module.params['safi']))
config = netcfg.get_section(parents)
if config:
splitted_config = config.splitlines()
vrf_index = False
for index in range(0, len(splitted_config) - 1):
if 'vrf' in splitted_config[index].strip():
vrf_index = index
break
if vrf_index:
config = '\n'.join(splitted_config[0:vrf_index])
for arg in args:
if arg not in ['afi', 'safi', 'vrf']:
existing[arg] = get_value(arg, config, module)
existing['afi'] = module.params['afi']
existing['safi'] = module.params['safi']
existing['vrf'] = module.params['vrf']
return existing
def apply_key_map(key_map, table):
new_dict = {}
for key, value in table.items():
new_key = key_map.get(key)
if new_key:
value = table.get(key)
if value:
new_dict[new_key] = value
else:
new_dict[new_key] = value
return new_dict
def state_present(module, existing, proposed, candidate):
commands = list()
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
for key, value in proposed_commands.items():
if value is True:
commands.append(key)
elif value is False:
commands.append('no {0}'.format(key))
elif value == 'default':
if existing_commands.get(key):
existing_value = existing_commands.get(key)
commands.append('no {0} {1}'.format(key, existing_value))
else:
command = '{0} {1}'.format(key, value.lower())
commands.append(command)
if commands:
parents = ['vrf context {0}'.format(module.params['vrf'])]
parents.append('address-family {0} {1}'.format(module.params['afi'],
module.params['safi']))
candidate.add(commands, parents=parents)
def state_absent(module, existing, proposed, candidate):
commands = []
parents = ['vrf context {0}'.format(module.params['vrf'])]
commands.append('no address-family {0} {1}'.format(module.params['afi'],
module.params['safi']))
candidate.add(commands, parents=parents)
def main():
argument_spec = dict(
vrf=dict(required=True, type='str'),
safi=dict(required=True, type='str', choices=['unicast','multicast']),
afi=dict(required=True, type='str', choices=['ipv4','ipv6']),
route_target_both_auto_evpn=dict(required=False, type='bool'),
m_facts=dict(required=False, default=False, type='bool'),
state=dict(choices=['present', 'absent'], default='present',
required=False),
include_defaults=dict(default=False),
config=dict(),
save=dict(type='bool', default=False)
)
argument_spec.update(nxos_argument_spec)
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)
warnings = list()
check_args(module, warnings)
state = module.params['state']
args = [
'vrf',
'safi',
'afi',
'route_target_both_auto_evpn'
]
existing = invoke('get_existing', module, args)
end_state = existing
proposed_args = dict((k, v) for k, v in module.params.items()
if v is not None and k in args)
proposed = {}
for key, value in proposed_args.items():
if key != 'interface':
if str(value).lower() == 'default':
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
if value is None:
value = 'default'
if existing.get(key) or (not existing.get(key) and value):
proposed[key] = value
result = {}
if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else:
result['updates'] = []
if module._verbosity > 0:
end_state = invoke('get_existing', module, args)
result['end_state'] = end_state
result['existing'] = existing
result['proposed'] = proposed_args
if WARNINGS:
result['warnings'] = WARNINGS
module.exit_json(**result)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
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,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
297,
490,
283,
1023,
356,
283,
17,
14,
16,
936,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
22072,
63,
11863,
63,
2756,
199,
1023,
63,
3270,
26,
298,
18,
14,
18,
2,
199,
3612,
63,
1802,
26,
21612,
812,
11778,
20089,
14,
199,
1802,
26,
272,
446,
21612,
812,
11778,
20089,
199,
2502,
26,
598,
371,
322,
8081,
22261,
1393,
79,
8593,
2916,
371,
322,
8081,
9,
199,
5983,
26,
272,
446,
3758,
12,
2382,
3748,
12,
4618,
7944,
1862,
849,
574,
14,
199,
1419,
26,
272,
15209,
26,
267,
1369,
26,
288,
446,
2812,
402,
314,
812,
11778,
14,
267,
1415,
26,
2549,
272,
282,
329,
26,
267,
1369,
26,
288,
446,
9906,
13,
16345,
23285,
334,
33,
1976,
680,
267,
1415,
26,
2549,
267,
3415,
26,
788,
4774,
20,
297,
283,
4774,
22,
418,
267,
849,
26,
2973,
272,
2937,
329,
26,
267,
1369,
26,
288,
446,
4804,
9906,
13,
16345,
23285,
334,
4251,
1976,
680,
267,
1415,
26,
2549,
267,
3415,
26,
788,
5209,
1810,
297,
283,
23797,
418,
267,
849,
26,
2973,
272,
7475,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
26,
267,
1369,
26,
288,
446,
12030,
15,
13707,
314,
30069,
9060,
7475,
13,
1375,
283,
2495,
7,
4260,
367,
3865,
1598,
492,
436,
4843,
1347,
1923,
22047,
14,
267,
1415,
26,
3055,
267,
3415,
26,
788,
2052,
297,
283,
3910,
418,
267,
849,
26,
2973,
272,
1174,
26,
267,
1369,
26,
288,
446,
22391,
3775,
314,
1101,
1077,
506,
3451,
503,
1598,
440,
641,
314,
2243,
14,
267,
1415,
26,
3055,
267,
849,
26,
3451,
267,
3415,
26,
788,
1881,
1673,
5575,
418,
199,
2344,
199,
8918,
275,
1449,
199,
13,
22072,
63,
11863,
63,
2756,
26,
272,
3217,
26,
302,
432,
17,
272,
373,
8445,
26,
1227,
1493,
272,
315,
3313,
63,
17144,
26,
2549,
272,
3434,
26,
7370,
625,
7820,
272,
2505,
26,
7370,
14374,
7820,
272,
1591,
26,
7370,
8200,
63,
4269,
7820,
199,
2344,
199,
9677,
275,
1449,
199,
15676,
26,
272,
1369,
26,
1022,
15,
86,
6342,
402,
2633,
3032,
1901,
859,
272,
2138,
26,
3376,
818,
272,
730,
26,
1211,
272,
2690,
26,
2420,
13030,
582,
298,
4774,
20,
401,
298,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
582,
2549,
12,
288,
298,
2231,
329,
582,
298,
5209,
1810,
401,
298,
11863,
582,
298,
396,
3570,
199,
5952,
26,
272,
1369,
26,
1022,
15,
86,
6342,
402,
3411,
2897,
272,
2138,
26,
3376,
818,
272,
730,
26,
1211,
272,
2690,
26,
2420,
13030,
582,
298,
4774,
20,
401,
298,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
582,
3055,
12,
288,
298,
2231,
329,
582,
298,
5209,
1810,
401,
298,
11863,
582,
298,
396,
3570,
199,
500,
63,
929,
26,
272,
1369,
26,
1022,
15,
86,
6342,
402,
2897,
2410,
859,
6451,
272,
2138,
26,
3376,
818,
272,
730,
26,
1211,
272,
2690,
26,
2420,
13030,
582,
298,
4774,
20,
401,
298,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
582,
2549,
12,
288,
298,
2231,
329,
582,
298,
5209,
1810,
401,
298,
11863,
582,
298,
396,
3570,
199,
7618,
26,
272,
1369,
26,
3718,
4847,
370,
314,
2243,
272,
2138,
26,
3544,
272,
730,
26,
769,
272,
2690,
26,
2097,
11863,
1067,
511,
401,
298,
1562,
13,
6606,
3278,
20,
625,
530,
1810,
401,
288,
298,
4449,
13,
1375,
3865,
2599,
8145,
4812,
937,
199,
2489,
26,
272,
1369,
26,
1104,
370,
1937,
340,
282,
1570,
1990,
6326,
641,
314,
2243,
272,
2138,
26,
3544,
272,
730,
26,
5046,
272,
2690,
26,
2549,
199,
2344,
199,
199,
646,
295,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
17982,
492,
664,
63,
888,
12,
2248,
63,
888,
12,
1255,
63,
4405,
199,
504,
3242,
14,
578,
63,
1208,
14,
17982,
492,
22072,
63,
2094,
63,
1650,
12,
1104,
63,
589,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
846,
4128,
492,
8388,
4491,
2028,
199,
199,
16026,
63,
17978,
275,
788,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
418,
199,
7258,
63,
2566,
63,
10761,
63,
3078,
5443,
275,
469,
272,
283,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
356,
283,
4449,
13,
1375,
3865,
2599,
8145,
4812,
297,
199,
93,
199,
7258,
63,
2566,
63,
3472,
63,
3078,
5443,
275,
1052,
199,
17449,
3881,
275,
942,
199,
199,
318,
12677,
8,
354,
12,
627,
589,
12,
1011,
958,
304,
272,
2562,
275,
7992,
1252,
362,
8,
354,
9,
272,
340,
2562,
26,
267,
372,
2562,
2031,
589,
12,
1011,
958,
9,
421,
199,
318,
664,
63,
585,
8,
1273,
12,
1101,
12,
859,
304,
272,
340,
1680,
315,
25849,
63,
17978,
26,
267,
14142,
1438,
275,
295,
14,
2014,
8,
82,
1154,
83,
11,
91,
16,
4988,
83,
10,
4,
1370,
908,
8,
7258,
63,
2566,
63,
10761,
63,
3078,
5443,
59,
1273,
2522,
295,
14,
45,
9,
267,
574,
275,
756,
267,
862,
26
] |
[
2647,
15,
1393,
15,
1548,
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,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
297,
490,
283,
1023,
356,
283,
17,
14,
16,
936,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
22072,
63,
11863,
63,
2756,
199,
1023,
63,
3270,
26,
298,
18,
14,
18,
2,
199,
3612,
63,
1802,
26,
21612,
812,
11778,
20089,
14,
199,
1802,
26,
272,
446,
21612,
812,
11778,
20089,
199,
2502,
26,
598,
371,
322,
8081,
22261,
1393,
79,
8593,
2916,
371,
322,
8081,
9,
199,
5983,
26,
272,
446,
3758,
12,
2382,
3748,
12,
4618,
7944,
1862,
849,
574,
14,
199,
1419,
26,
272,
15209,
26,
267,
1369,
26,
288,
446,
2812,
402,
314,
812,
11778,
14,
267,
1415,
26,
2549,
272,
282,
329,
26,
267,
1369,
26,
288,
446,
9906,
13,
16345,
23285,
334,
33,
1976,
680,
267,
1415,
26,
2549,
267,
3415,
26,
788,
4774,
20,
297,
283,
4774,
22,
418,
267,
849,
26,
2973,
272,
2937,
329,
26,
267,
1369,
26,
288,
446,
4804,
9906,
13,
16345,
23285,
334,
4251,
1976,
680,
267,
1415,
26,
2549,
267,
3415,
26,
788,
5209,
1810,
297,
283,
23797,
418,
267,
849,
26,
2973,
272,
7475,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
26,
267,
1369,
26,
288,
446,
12030,
15,
13707,
314,
30069,
9060,
7475,
13,
1375,
283,
2495,
7,
4260,
367,
3865,
1598,
492,
436,
4843,
1347,
1923,
22047,
14,
267,
1415,
26,
3055,
267,
3415,
26,
788,
2052,
297,
283,
3910,
418,
267,
849,
26,
2973,
272,
1174,
26,
267,
1369,
26,
288,
446,
22391,
3775,
314,
1101,
1077,
506,
3451,
503,
1598,
440,
641,
314,
2243,
14,
267,
1415,
26,
3055,
267,
849,
26,
3451,
267,
3415,
26,
788,
1881,
1673,
5575,
418,
199,
2344,
199,
8918,
275,
1449,
199,
13,
22072,
63,
11863,
63,
2756,
26,
272,
3217,
26,
302,
432,
17,
272,
373,
8445,
26,
1227,
1493,
272,
315,
3313,
63,
17144,
26,
2549,
272,
3434,
26,
7370,
625,
7820,
272,
2505,
26,
7370,
14374,
7820,
272,
1591,
26,
7370,
8200,
63,
4269,
7820,
199,
2344,
199,
9677,
275,
1449,
199,
15676,
26,
272,
1369,
26,
1022,
15,
86,
6342,
402,
2633,
3032,
1901,
859,
272,
2138,
26,
3376,
818,
272,
730,
26,
1211,
272,
2690,
26,
2420,
13030,
582,
298,
4774,
20,
401,
298,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
582,
2549,
12,
288,
298,
2231,
329,
582,
298,
5209,
1810,
401,
298,
11863,
582,
298,
396,
3570,
199,
5952,
26,
272,
1369,
26,
1022,
15,
86,
6342,
402,
3411,
2897,
272,
2138,
26,
3376,
818,
272,
730,
26,
1211,
272,
2690,
26,
2420,
13030,
582,
298,
4774,
20,
401,
298,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
582,
3055,
12,
288,
298,
2231,
329,
582,
298,
5209,
1810,
401,
298,
11863,
582,
298,
396,
3570,
199,
500,
63,
929,
26,
272,
1369,
26,
1022,
15,
86,
6342,
402,
2897,
2410,
859,
6451,
272,
2138,
26,
3376,
818,
272,
730,
26,
1211,
272,
2690,
26,
2420,
13030,
582,
298,
4774,
20,
401,
298,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
582,
2549,
12,
288,
298,
2231,
329,
582,
298,
5209,
1810,
401,
298,
11863,
582,
298,
396,
3570,
199,
7618,
26,
272,
1369,
26,
3718,
4847,
370,
314,
2243,
272,
2138,
26,
3544,
272,
730,
26,
769,
272,
2690,
26,
2097,
11863,
1067,
511,
401,
298,
1562,
13,
6606,
3278,
20,
625,
530,
1810,
401,
288,
298,
4449,
13,
1375,
3865,
2599,
8145,
4812,
937,
199,
2489,
26,
272,
1369,
26,
1104,
370,
1937,
340,
282,
1570,
1990,
6326,
641,
314,
2243,
272,
2138,
26,
3544,
272,
730,
26,
5046,
272,
2690,
26,
2549,
199,
2344,
199,
199,
646,
295,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
17982,
492,
664,
63,
888,
12,
2248,
63,
888,
12,
1255,
63,
4405,
199,
504,
3242,
14,
578,
63,
1208,
14,
17982,
492,
22072,
63,
2094,
63,
1650,
12,
1104,
63,
589,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
846,
4128,
492,
8388,
4491,
2028,
199,
199,
16026,
63,
17978,
275,
788,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
418,
199,
7258,
63,
2566,
63,
10761,
63,
3078,
5443,
275,
469,
272,
283,
4449,
63,
1375,
63,
10727,
63,
2495,
63,
6857,
4812,
356,
283,
4449,
13,
1375,
3865,
2599,
8145,
4812,
297,
199,
93,
199,
7258,
63,
2566,
63,
3472,
63,
3078,
5443,
275,
1052,
199,
17449,
3881,
275,
942,
199,
199,
318,
12677,
8,
354,
12,
627,
589,
12,
1011,
958,
304,
272,
2562,
275,
7992,
1252,
362,
8,
354,
9,
272,
340,
2562,
26,
267,
372,
2562,
2031,
589,
12,
1011,
958,
9,
421,
199,
318,
664,
63,
585,
8,
1273,
12,
1101,
12,
859,
304,
272,
340,
1680,
315,
25849,
63,
17978,
26,
267,
14142,
1438,
275,
295,
14,
2014,
8,
82,
1154,
83,
11,
91,
16,
4988,
83,
10,
4,
1370,
908,
8,
7258,
63,
2566,
63,
10761,
63,
3078,
5443,
59,
1273,
2522,
295,
14,
45,
9,
267,
574,
275,
756,
267,
862,
26,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jamespacileo/django-france
|
django/core/handlers/base.py
|
105
|
11468
|
import sys
from django import http
from django.core import signals
from django.utils.encoding import force_unicode
from django.utils.importlib import import_module
from django.utils.log import getLogger
logger = getLogger('django.request')
class BaseHandler(object):
# Changes that are always applied to a response (in this order).
response_fixes = [
http.fix_location_header,
http.conditional_content_removal,
http.fix_IE_for_attach,
http.fix_IE_for_vary,
]
def __init__(self):
self._request_middleware = self._view_middleware = self._response_middleware = self._exception_middleware = None
def load_middleware(self):
"""
Populate middleware lists from settings.MIDDLEWARE_CLASSES.
Must be called after the environment is fixed (see __call__).
"""
from django.conf import settings
from django.core import exceptions
self._view_middleware = []
self._template_response_middleware = []
self._response_middleware = []
self._exception_middleware = []
request_middleware = []
for middleware_path in settings.MIDDLEWARE_CLASSES:
try:
mw_module, mw_classname = middleware_path.rsplit('.', 1)
except ValueError:
raise exceptions.ImproperlyConfigured('%s isn\'t a middleware module' % middleware_path)
try:
mod = import_module(mw_module)
except ImportError, e:
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
try:
mw_class = getattr(mod, mw_classname)
except AttributeError:
raise exceptions.ImproperlyConfigured('Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname))
try:
mw_instance = mw_class()
except exceptions.MiddlewareNotUsed:
continue
if hasattr(mw_instance, 'process_request'):
request_middleware.append(mw_instance.process_request)
if hasattr(mw_instance, 'process_view'):
self._view_middleware.append(mw_instance.process_view)
if hasattr(mw_instance, 'process_template_response'):
self._template_response_middleware.insert(0, mw_instance.process_template_response)
if hasattr(mw_instance, 'process_response'):
self._response_middleware.insert(0, mw_instance.process_response)
if hasattr(mw_instance, 'process_exception'):
self._exception_middleware.insert(0, mw_instance.process_exception)
# We only assign to this when initialization is complete as it is used
# as a flag for initialization being complete.
self._request_middleware = request_middleware
def get_response(self, request):
"Returns an HttpResponse object for the given HttpRequest"
from django.core import exceptions, urlresolvers
from django.conf import settings
try:
# Setup default url resolver for this thread, this code is outside
# the try/except so we don't get a spurious "unbound local
# variable" exception in the event an exception is raised before
# resolver is set
urlconf = settings.ROOT_URLCONF
urlresolvers.set_urlconf(urlconf)
resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
try:
response = None
# Apply request middleware
for middleware_method in self._request_middleware:
response = middleware_method(request)
if response:
break
if response is None:
if hasattr(request, "urlconf"):
# Reset url resolver with a custom urlconf.
urlconf = request.urlconf
urlresolvers.set_urlconf(urlconf)
resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
callback, callback_args, callback_kwargs = resolver.resolve(
request.path_info)
# Apply view middleware
for middleware_method in self._view_middleware:
response = middleware_method(request, callback, callback_args, callback_kwargs)
if response:
break
if response is None:
try:
response = callback(request, *callback_args, **callback_kwargs)
except Exception, e:
# If the view raised an exception, run it through exception
# middleware, and if the exception middleware returns a
# response, use that. Otherwise, reraise the exception.
for middleware_method in self._exception_middleware:
response = middleware_method(request, e)
if response:
break
if response is None:
raise
# Complain if the view returned None (a common error).
if response is None:
try:
view_name = callback.func_name # If it's a function
except AttributeError:
view_name = callback.__class__.__name__ + '.__call__' # If it's a class
raise ValueError("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name))
# If the response supports deferred rendering, apply template
# response middleware and the render the response
if hasattr(response, 'render') and callable(response.render):
for middleware_method in self._template_response_middleware:
response = middleware_method(request, response)
response.render()
except http.Http404, e:
logger.warning('Not Found: %s' % request.path,
extra={
'status_code': 404,
'request': request
})
if settings.DEBUG:
from django.views import debug
response = debug.technical_404_response(request, e)
else:
try:
callback, param_dict = resolver.resolve404()
response = callback(request, **param_dict)
except:
try:
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
finally:
receivers = signals.got_request_exception.send(sender=self.__class__, request=request)
except exceptions.PermissionDenied:
logger.warning('Forbidden (Permission denied): %s' % request.path,
extra={
'status_code': 403,
'request': request
})
response = http.HttpResponseForbidden('<h1>Permission denied</h1>')
except SystemExit:
# Allow sys.exit() to actually exit. See tickets #1023 and #4701
raise
except: # Handle everything else, including SuspiciousOperation, etc.
# Get the exception info now, in case another exception is thrown later.
receivers = signals.got_request_exception.send(sender=self.__class__, request=request)
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
finally:
# Reset URLconf for this thread on the way out for complete
# isolation of request.urlconf
urlresolvers.set_urlconf(None)
try:
# Apply response middleware, regardless of the response
for middleware_method in self._response_middleware:
response = middleware_method(request, response)
response = self.apply_response_fixes(request, response)
except: # Any exception should be gathered and handled
receivers = signals.got_request_exception.send(sender=self.__class__, request=request)
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
return response
def handle_uncaught_exception(self, request, resolver, exc_info):
"""
Processing for any otherwise uncaught exceptions (those that will
generate HTTP 500 responses). Can be overridden by subclasses who want
customised 500 handling.
Be *very* careful when overriding this because the error could be
caused by anything, so assuming something like the database is always
available would be an error.
"""
from django.conf import settings
if settings.DEBUG_PROPAGATE_EXCEPTIONS:
raise
if settings.DEBUG:
from django.views import debug
return debug.technical_500_response(request, *exc_info)
logger.error('Internal Server Error: %s' % request.path,
exc_info=exc_info,
extra={
'status_code': 500,
'request':request
}
)
# If Http500 handler is not installed, re-raise last exception
if resolver.urlconf_module is None:
raise exc_info[1], None, exc_info[2]
# Return an HttpResponse that displays a friendly error message.
callback, param_dict = resolver.resolve500()
return callback(request, **param_dict)
def apply_response_fixes(self, request, response):
"""
Applies each of the functions in self.response_fixes to the request and
response, modifying the response in the process. Returns the new
response.
"""
for func in self.response_fixes:
response = func(request, response)
return response
def get_script_name(environ):
"""
Returns the equivalent of the HTTP request's SCRIPT_NAME environment
variable. If Apache mod_rewrite has been used, returns what would have been
the script name prior to any rewriting (so it's the script name as seen
from the client's perspective), unless DJANGO_USE_POST_REWRITE is set (to
anything).
"""
from django.conf import settings
if settings.FORCE_SCRIPT_NAME is not None:
return force_unicode(settings.FORCE_SCRIPT_NAME)
# If Apache's mod_rewrite had a whack at the URL, Apache set either
# SCRIPT_URL or REDIRECT_URL to the full resource URL before applying any
# rewrites. Unfortunately not every Web server (lighttpd!) passes this
# information through all the time, so FORCE_SCRIPT_NAME, above, is still
# needed.
script_url = environ.get('SCRIPT_URL', u'')
if not script_url:
script_url = environ.get('REDIRECT_URL', u'')
if script_url:
return force_unicode(script_url[:-len(environ.get('PATH_INFO', ''))])
return force_unicode(environ.get('SCRIPT_NAME', u''))
|
bsd-3-clause
|
[
646,
984,
199,
199,
504,
1639,
492,
1455,
199,
504,
1639,
14,
1018,
492,
10166,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2975,
199,
504,
1639,
14,
1208,
14,
25893,
492,
492,
63,
578,
199,
504,
1639,
14,
1208,
14,
793,
492,
28138,
199,
199,
2921,
275,
28138,
360,
1176,
14,
1069,
358,
421,
199,
533,
3523,
2461,
8,
785,
304,
272,
327,
18784,
626,
787,
3544,
6781,
370,
282,
1177,
334,
262,
642,
1865,
680,
272,
1177,
63,
26205,
275,
359,
267,
1455,
14,
970,
63,
1985,
63,
1291,
12,
267,
1455,
14,
14353,
63,
1317,
63,
25818,
12,
267,
1455,
14,
970,
63,
4332,
63,
509,
63,
5040,
12,
267,
1455,
14,
970,
63,
4332,
63,
509,
63,
21989,
12,
272,
1622,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
1069,
63,
5754,
275,
291,
423,
1345,
63,
5754,
275,
291,
423,
1310,
63,
5754,
275,
291,
423,
1971,
63,
5754,
275,
488,
2378,
347,
2248,
63,
5754,
8,
277,
304,
267,
408,
267,
31731,
10816,
5548,
687,
2202,
14,
19987,
63,
13748,
14,
398,
9498,
506,
2797,
2410,
314,
3734,
365,
6317,
334,
3239,
636,
1250,
28634,
267,
408,
267,
687,
1639,
14,
2190,
492,
2202,
267,
687,
1639,
14,
1018,
492,
4967,
267,
291,
423,
1345,
63,
5754,
275,
942,
267,
291,
423,
1160,
63,
1310,
63,
5754,
275,
942,
267,
291,
423,
1310,
63,
5754,
275,
942,
267,
291,
423,
1971,
63,
5754,
275,
942,
398,
1056,
63,
5754,
275,
942,
267,
367,
10816,
63,
515,
315,
2202,
14,
19987,
63,
13748,
26,
288,
862,
26,
355,
23530,
63,
578,
12,
23530,
63,
19851,
275,
10816,
63,
515,
14,
13490,
14078,
413,
9,
288,
871,
1722,
26,
355,
746,
4967,
14,
8499,
10951,
3508,
83,
5712,
3985,
84,
282,
10816,
859,
7,
450,
10816,
63,
515,
9,
288,
862,
26,
355,
3413,
275,
492,
63,
578,
8,
14716,
63,
578,
9,
288,
871,
3545,
12,
325,
26,
355,
746,
4967,
14,
8499,
10951,
360,
547,
16306,
10816,
450,
83,
26,
2071,
83,
4507,
450,
334,
14716,
63,
578,
12,
325,
430,
288,
862,
26,
355,
23530,
63,
533,
275,
2519,
8,
1494,
12,
23530,
63,
19851,
9,
288,
871,
4281,
26,
355,
746,
4967,
14,
8499,
10951,
360,
6608,
859,
2071,
83,
2,
1630,
440,
5627,
282,
2071,
83,
2,
1021,
7,
450,
334,
14716,
63,
578,
12,
23530,
63,
19851,
430,
288,
862,
26,
355,
23530,
63,
842,
275,
23530,
63,
533,
342,
288,
871,
4967,
14,
6608,
1763,
9167,
26,
355,
1980,
953,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1069,
735,
355,
1056,
63,
5754,
14,
740,
8,
14716,
63,
842,
14,
1412,
63,
1069,
9,
288,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1345,
735,
355,
291,
423,
1345,
63,
5754,
14,
740,
8,
14716,
63,
842,
14,
1412,
63,
1345,
9,
288,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1160,
63,
1310,
735,
355,
291,
423,
1160,
63,
1310,
63,
5754,
14,
3176,
8,
16,
12,
23530,
63,
842,
14,
1412,
63,
1160,
63,
1310,
9,
288,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1310,
735,
355,
291,
423,
1310,
63,
5754,
14,
3176,
8,
16,
12,
23530,
63,
842,
14,
1412,
63,
1310,
9,
288,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1971,
735,
355,
291,
423,
1971,
63,
5754,
14,
3176,
8,
16,
12,
23530,
63,
842,
14,
1412,
63,
1971,
9,
398,
327,
2136,
1454,
5090,
370,
642,
1380,
11097,
365,
4890,
465,
652,
365,
1202,
267,
327,
465,
282,
3305,
367,
11097,
3769,
4890,
14,
267,
291,
423,
1069,
63,
5754,
275,
1056,
63,
5754,
339,
347,
664,
63,
1310,
8,
277,
12,
1056,
304,
267,
298,
3407,
376,
6183,
909,
367,
314,
1627,
20730,
2,
267,
687,
1639,
14,
1018,
492,
4967,
12,
32403,
267,
687,
1639,
14,
2190,
492,
2202,
398,
862,
26,
288,
327,
12439,
849,
1166,
15611,
367,
642,
2462,
12,
642,
1233,
365,
9682,
288,
327,
314,
862,
15,
2590,
880,
781,
2793,
1133,
664,
282,
2249,
2302,
1785,
298,
18124,
2257,
288,
327,
1750,
2,
1919,
315,
314,
1566,
376,
1919,
365,
4915,
2544,
288,
327,
15611,
365,
663,
288,
30009,
275,
2202,
14,
5441,
63,
18125,
288,
32403,
14,
409,
63,
21801,
8,
21801,
9,
288,
15611,
275,
32403,
14,
5103,
2632,
12407,
8,
82,
4289,
3678,
30009,
9,
288,
862,
26,
355,
1177,
275,
488,
355,
327,
14618,
1056,
10816,
355,
367,
10816,
63,
765,
315,
291,
423,
1069,
63,
5754,
26,
490,
1177,
275,
10816,
63,
765,
8,
1069,
9,
490,
340,
1177,
26,
717,
2059,
2234,
340,
1177,
365,
488,
26,
490,
340,
2688,
8,
1069,
12,
298,
21801,
2349,
717,
327,
15510,
1166,
15611,
543,
282,
3537,
30009,
14,
717,
30009,
275,
1056,
14,
21801,
717,
32403,
14,
409,
63,
21801,
8,
21801,
9,
717,
15611,
275,
32403,
14,
5103,
2632,
12407,
8,
82,
4289,
3678,
30009,
9,
4951,
3233,
12,
3233,
63,
589,
12,
3233,
63,
958,
275,
15611,
14,
6983,
8,
1169,
1056,
14,
515,
63,
815,
9,
4951,
327,
14618,
2455,
10816,
490,
367,
10816,
63,
765,
315,
291,
423,
1345,
63,
5754,
26,
717,
1177,
275,
10816,
63,
765,
8,
1069,
12,
3233,
12,
3233,
63,
589,
12,
3233,
63,
958,
9,
717,
340,
1177,
26,
1169,
2059,
2234,
340,
1177,
365,
488,
26,
490,
862,
26,
717,
1177,
275,
3233,
8,
1069,
12,
627,
3058,
63,
589,
12,
1011,
3058,
63,
958,
9,
490,
871,
2186,
12,
325,
26,
717,
327,
982,
314,
2455,
4915,
376,
1919,
12,
1255,
652,
4012,
1919,
717,
327,
10816,
12,
436,
340,
314,
1919,
10816,
2529,
282,
717,
327,
1177,
12,
675,
626,
14,
6630,
12,
24139,
314,
1919,
14,
717,
367,
10816,
63,
765,
315,
291,
423,
1971,
63,
5754,
26,
1169,
1177,
275,
10816,
63,
765,
8,
1069,
12,
325,
9,
1169,
340,
1177,
26,
1816,
2059,
717,
340,
1177,
365,
488,
26,
1169,
746,
2234,
327,
3599,
3993,
340,
314,
2455,
2138,
488,
334,
65,
2863,
1125,
680,
355,
340,
1177,
365,
488,
26,
490
] |
[
984,
199,
199,
504,
1639,
492,
1455,
199,
504,
1639,
14,
1018,
492,
10166,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2975,
199,
504,
1639,
14,
1208,
14,
25893,
492,
492,
63,
578,
199,
504,
1639,
14,
1208,
14,
793,
492,
28138,
199,
199,
2921,
275,
28138,
360,
1176,
14,
1069,
358,
421,
199,
533,
3523,
2461,
8,
785,
304,
272,
327,
18784,
626,
787,
3544,
6781,
370,
282,
1177,
334,
262,
642,
1865,
680,
272,
1177,
63,
26205,
275,
359,
267,
1455,
14,
970,
63,
1985,
63,
1291,
12,
267,
1455,
14,
14353,
63,
1317,
63,
25818,
12,
267,
1455,
14,
970,
63,
4332,
63,
509,
63,
5040,
12,
267,
1455,
14,
970,
63,
4332,
63,
509,
63,
21989,
12,
272,
1622,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
1069,
63,
5754,
275,
291,
423,
1345,
63,
5754,
275,
291,
423,
1310,
63,
5754,
275,
291,
423,
1971,
63,
5754,
275,
488,
2378,
347,
2248,
63,
5754,
8,
277,
304,
267,
408,
267,
31731,
10816,
5548,
687,
2202,
14,
19987,
63,
13748,
14,
398,
9498,
506,
2797,
2410,
314,
3734,
365,
6317,
334,
3239,
636,
1250,
28634,
267,
408,
267,
687,
1639,
14,
2190,
492,
2202,
267,
687,
1639,
14,
1018,
492,
4967,
267,
291,
423,
1345,
63,
5754,
275,
942,
267,
291,
423,
1160,
63,
1310,
63,
5754,
275,
942,
267,
291,
423,
1310,
63,
5754,
275,
942,
267,
291,
423,
1971,
63,
5754,
275,
942,
398,
1056,
63,
5754,
275,
942,
267,
367,
10816,
63,
515,
315,
2202,
14,
19987,
63,
13748,
26,
288,
862,
26,
355,
23530,
63,
578,
12,
23530,
63,
19851,
275,
10816,
63,
515,
14,
13490,
14078,
413,
9,
288,
871,
1722,
26,
355,
746,
4967,
14,
8499,
10951,
3508,
83,
5712,
3985,
84,
282,
10816,
859,
7,
450,
10816,
63,
515,
9,
288,
862,
26,
355,
3413,
275,
492,
63,
578,
8,
14716,
63,
578,
9,
288,
871,
3545,
12,
325,
26,
355,
746,
4967,
14,
8499,
10951,
360,
547,
16306,
10816,
450,
83,
26,
2071,
83,
4507,
450,
334,
14716,
63,
578,
12,
325,
430,
288,
862,
26,
355,
23530,
63,
533,
275,
2519,
8,
1494,
12,
23530,
63,
19851,
9,
288,
871,
4281,
26,
355,
746,
4967,
14,
8499,
10951,
360,
6608,
859,
2071,
83,
2,
1630,
440,
5627,
282,
2071,
83,
2,
1021,
7,
450,
334,
14716,
63,
578,
12,
23530,
63,
19851,
430,
288,
862,
26,
355,
23530,
63,
842,
275,
23530,
63,
533,
342,
288,
871,
4967,
14,
6608,
1763,
9167,
26,
355,
1980,
953,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1069,
735,
355,
1056,
63,
5754,
14,
740,
8,
14716,
63,
842,
14,
1412,
63,
1069,
9,
288,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1345,
735,
355,
291,
423,
1345,
63,
5754,
14,
740,
8,
14716,
63,
842,
14,
1412,
63,
1345,
9,
288,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1160,
63,
1310,
735,
355,
291,
423,
1160,
63,
1310,
63,
5754,
14,
3176,
8,
16,
12,
23530,
63,
842,
14,
1412,
63,
1160,
63,
1310,
9,
288,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1310,
735,
355,
291,
423,
1310,
63,
5754,
14,
3176,
8,
16,
12,
23530,
63,
842,
14,
1412,
63,
1310,
9,
288,
340,
2688,
8,
14716,
63,
842,
12,
283,
1412,
63,
1971,
735,
355,
291,
423,
1971,
63,
5754,
14,
3176,
8,
16,
12,
23530,
63,
842,
14,
1412,
63,
1971,
9,
398,
327,
2136,
1454,
5090,
370,
642,
1380,
11097,
365,
4890,
465,
652,
365,
1202,
267,
327,
465,
282,
3305,
367,
11097,
3769,
4890,
14,
267,
291,
423,
1069,
63,
5754,
275,
1056,
63,
5754,
339,
347,
664,
63,
1310,
8,
277,
12,
1056,
304,
267,
298,
3407,
376,
6183,
909,
367,
314,
1627,
20730,
2,
267,
687,
1639,
14,
1018,
492,
4967,
12,
32403,
267,
687,
1639,
14,
2190,
492,
2202,
398,
862,
26,
288,
327,
12439,
849,
1166,
15611,
367,
642,
2462,
12,
642,
1233,
365,
9682,
288,
327,
314,
862,
15,
2590,
880,
781,
2793,
1133,
664,
282,
2249,
2302,
1785,
298,
18124,
2257,
288,
327,
1750,
2,
1919,
315,
314,
1566,
376,
1919,
365,
4915,
2544,
288,
327,
15611,
365,
663,
288,
30009,
275,
2202,
14,
5441,
63,
18125,
288,
32403,
14,
409,
63,
21801,
8,
21801,
9,
288,
15611,
275,
32403,
14,
5103,
2632,
12407,
8,
82,
4289,
3678,
30009,
9,
288,
862,
26,
355,
1177,
275,
488,
355,
327,
14618,
1056,
10816,
355,
367,
10816,
63,
765,
315,
291,
423,
1069,
63,
5754,
26,
490,
1177,
275,
10816,
63,
765,
8,
1069,
9,
490,
340,
1177,
26,
717,
2059,
2234,
340,
1177,
365,
488,
26,
490,
340,
2688,
8,
1069,
12,
298,
21801,
2349,
717,
327,
15510,
1166,
15611,
543,
282,
3537,
30009,
14,
717,
30009,
275,
1056,
14,
21801,
717,
32403,
14,
409,
63,
21801,
8,
21801,
9,
717,
15611,
275,
32403,
14,
5103,
2632,
12407,
8,
82,
4289,
3678,
30009,
9,
4951,
3233,
12,
3233,
63,
589,
12,
3233,
63,
958,
275,
15611,
14,
6983,
8,
1169,
1056,
14,
515,
63,
815,
9,
4951,
327,
14618,
2455,
10816,
490,
367,
10816,
63,
765,
315,
291,
423,
1345,
63,
5754,
26,
717,
1177,
275,
10816,
63,
765,
8,
1069,
12,
3233,
12,
3233,
63,
589,
12,
3233,
63,
958,
9,
717,
340,
1177,
26,
1169,
2059,
2234,
340,
1177,
365,
488,
26,
490,
862,
26,
717,
1177,
275,
3233,
8,
1069,
12,
627,
3058,
63,
589,
12,
1011,
3058,
63,
958,
9,
490,
871,
2186,
12,
325,
26,
717,
327,
982,
314,
2455,
4915,
376,
1919,
12,
1255,
652,
4012,
1919,
717,
327,
10816,
12,
436,
340,
314,
1919,
10816,
2529,
282,
717,
327,
1177,
12,
675,
626,
14,
6630,
12,
24139,
314,
1919,
14,
717,
367,
10816,
63,
765,
315,
291,
423,
1971,
63,
5754,
26,
1169,
1177,
275,
10816,
63,
765,
8,
1069,
12,
325,
9,
1169,
340,
1177,
26,
1816,
2059,
717,
340,
1177,
365,
488,
26,
1169,
746,
2234,
327,
3599,
3993,
340,
314,
2455,
2138,
488,
334,
65,
2863,
1125,
680,
355,
340,
1177,
365,
488,
26,
490,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
RevelSystems/django
|
django/test/client.py
|
106
|
26068
|
from __future__ import unicode_literals
import mimetypes
import os
import re
import sys
from copy import copy
from importlib import import_module
from io import BytesIO
from django.apps import apps
from django.conf import settings
from django.core import urlresolvers
from django.core.handlers.base import BaseHandler
from django.core.handlers.wsgi import ISO_8859_1, UTF_8, WSGIRequest
from django.core.signals import (
got_request_exception, request_finished, request_started,
)
from django.db import close_old_connections
from django.http import HttpRequest, QueryDict, SimpleCookie
from django.template import TemplateDoesNotExist
from django.test import signals
from django.test.utils import ContextList
from django.utils import six
from django.utils.encoding import force_bytes, force_str, uri_to_iri
from django.utils.functional import SimpleLazyObject, curry
from django.utils.http import urlencode
from django.utils.itercompat import is_iterable
from django.utils.six.moves.urllib.parse import urlparse, urlsplit
__all__ = ('Client', 'RedirectCycleError', 'RequestFactory', 'encode_file', 'encode_multipart')
BOUNDARY = 'BoUnDaRyStRiNg'
MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY
CONTENT_TYPE_RE = re.compile('.*; charset=([\w\d-]+);?')
class RedirectCycleError(Exception):
"""
The test client has been asked to follow a redirect loop.
"""
def __init__(self, message, last_response):
super(RedirectCycleError, self).__init__(message)
self.last_response = last_response
self.redirect_chain = last_response.redirect_chain
class FakePayload(object):
"""
A wrapper around BytesIO that restricts what can be read since data from
the network can't be seeked and cannot be read outside of its content
length. This makes sure that views can't do anything under the test client
that wouldn't work in Real Life.
"""
def __init__(self, content=None):
self.__content = BytesIO()
self.__len = 0
self.read_started = False
if content is not None:
self.write(content)
def __len__(self):
return self.__len
def read(self, num_bytes=None):
if not self.read_started:
self.__content.seek(0)
self.read_started = True
if num_bytes is None:
num_bytes = self.__len or 0
assert self.__len >= num_bytes, "Cannot read more than the available bytes from the HTTP incoming data."
content = self.__content.read(num_bytes)
self.__len -= num_bytes
return content
def write(self, content):
if self.read_started:
raise ValueError("Unable to write a payload after he's been read")
content = force_bytes(content)
self.__content.write(content)
self.__len += len(content)
def closing_iterator_wrapper(iterable, close):
try:
for item in iterable:
yield item
finally:
request_finished.disconnect(close_old_connections)
close() # will fire request_finished
request_finished.connect(close_old_connections)
class ClientHandler(BaseHandler):
"""
A HTTP Handler that can be used for testing purposes. Uses the WSGI
interface to compose requests, but returns the raw HttpResponse object with
the originating WSGIRequest attached to its ``wsgi_request`` attribute.
"""
def __init__(self, enforce_csrf_checks=True, *args, **kwargs):
self.enforce_csrf_checks = enforce_csrf_checks
super(ClientHandler, self).__init__(*args, **kwargs)
def __call__(self, environ):
# Set up middleware if needed. We couldn't do this earlier, because
# settings weren't available.
if self._request_middleware is None:
self.load_middleware()
request_started.disconnect(close_old_connections)
request_started.send(sender=self.__class__, environ=environ)
request_started.connect(close_old_connections)
request = WSGIRequest(environ)
# sneaky little hack so that we can easily get round
# CsrfViewMiddleware. This makes life easier, and is probably
# required for backwards compatibility with external tests against
# admin views.
request._dont_enforce_csrf_checks = not self.enforce_csrf_checks
# Request goes through middleware.
response = self.get_response(request)
# Attach the originating request to the response so that it could be
# later retrieved.
response.wsgi_request = request
# We're emulating a WSGI server; we must call the close method
# on completion.
if response.streaming:
response.streaming_content = closing_iterator_wrapper(
response.streaming_content, response.close)
else:
request_finished.disconnect(close_old_connections)
response.close() # will fire request_finished
request_finished.connect(close_old_connections)
return response
def store_rendered_templates(store, signal, sender, template, context, **kwargs):
"""
Stores templates and contexts that are rendered.
The context is copied so that it is an accurate representation at the time
of rendering.
"""
store.setdefault('templates', []).append(template)
store.setdefault('context', ContextList()).append(copy(context))
def encode_multipart(boundary, data):
"""
Encodes multipart POST data from a dictionary of form values.
The key will be used as the form data name; the value will be transmitted
as content. If the value is a file, the contents of the file will be sent
as an application/octet-stream; otherwise, str(value) will be sent.
"""
lines = []
to_bytes = lambda s: force_bytes(s, settings.DEFAULT_CHARSET)
# Not by any means perfect, but good enough for our purposes.
is_file = lambda thing: hasattr(thing, "read") and callable(thing.read)
# Each bit of the multipart form data could be either a form value or a
# file, or a *list* of form values and/or files. Remember that HTTP field
# names can be duplicated!
for (key, value) in data.items():
if is_file(value):
lines.extend(encode_file(boundary, key, value))
elif not isinstance(value, six.string_types) and is_iterable(value):
for item in value:
if is_file(item):
lines.extend(encode_file(boundary, key, item))
else:
lines.extend(to_bytes(val) for val in [
'--%s' % boundary,
'Content-Disposition: form-data; name="%s"' % key,
'',
item
])
else:
lines.extend(to_bytes(val) for val in [
'--%s' % boundary,
'Content-Disposition: form-data; name="%s"' % key,
'',
value
])
lines.extend([
to_bytes('--%s--' % boundary),
b'',
])
return b'\r\n'.join(lines)
def encode_file(boundary, key, file):
to_bytes = lambda s: force_bytes(s, settings.DEFAULT_CHARSET)
filename = os.path.basename(file.name) if hasattr(file, 'name') else ''
if hasattr(file, 'content_type'):
content_type = file.content_type
elif filename:
content_type = mimetypes.guess_type(filename)[0]
else:
content_type = None
if content_type is None:
content_type = 'application/octet-stream'
if not filename:
filename = key
return [
to_bytes('--%s' % boundary),
to_bytes('Content-Disposition: form-data; name="%s"; filename="%s"'
% (key, filename)),
to_bytes('Content-Type: %s' % content_type),
b'',
to_bytes(file.read())
]
class RequestFactory(object):
"""
Class that lets you create mock Request objects for use in testing.
Usage:
rf = RequestFactory()
get_request = rf.get('/hello/')
post_request = rf.post('/submit/', {'foo': 'bar'})
Once you have a request object you can pass it to any view function,
just as if that view had been hooked up using a URLconf.
"""
def __init__(self, **defaults):
self.defaults = defaults
self.cookies = SimpleCookie()
self.errors = BytesIO()
def _base_environ(self, **request):
"""
The base environment for a request.
"""
# This is a minimal valid WSGI environ dictionary, plus:
# - HTTP_COOKIE: for cookie support,
# - REMOTE_ADDR: often useful, see #8551.
# See http://www.python.org/dev/peps/pep-3333/#environ-variables
environ = {
'HTTP_COOKIE': self.cookies.output(header='', sep='; '),
'PATH_INFO': str('/'),
'REMOTE_ADDR': str('127.0.0.1'),
'REQUEST_METHOD': str('GET'),
'SCRIPT_NAME': str(''),
'SERVER_NAME': str('testserver'),
'SERVER_PORT': str('80'),
'SERVER_PROTOCOL': str('HTTP/1.1'),
'wsgi.version': (1, 0),
'wsgi.url_scheme': str('http'),
'wsgi.input': FakePayload(b''),
'wsgi.errors': self.errors,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
'wsgi.run_once': False,
}
environ.update(self.defaults)
environ.update(request)
return environ
def request(self, **request):
"Construct a generic request object."
return WSGIRequest(self._base_environ(**request))
def _encode_data(self, data, content_type):
if content_type is MULTIPART_CONTENT:
return encode_multipart(BOUNDARY, data)
else:
# Encode the content so that the byte representation is correct.
match = CONTENT_TYPE_RE.match(content_type)
if match:
charset = match.group(1)
else:
charset = settings.DEFAULT_CHARSET
return force_bytes(data, encoding=charset)
def _get_path(self, parsed):
path = force_str(parsed[2])
# If there are parameters, add them
if parsed[3]:
path += str(";") + force_str(parsed[3])
path = uri_to_iri(path).encode(UTF_8)
# Under Python 3, non-ASCII values in the WSGI environ are arbitrarily
# decoded with ISO-8859-1. We replicate this behavior here.
# Refs comment in `get_bytes_from_wsgi()`.
return path.decode(ISO_8859_1) if six.PY3 else path
def get(self, path, data=None, secure=False, **extra):
"Construct a GET request."
data = {} if data is None else data
r = {
'QUERY_STRING': urlencode(data, doseq=True),
}
r.update(extra)
return self.generic('GET', path, secure=secure, **r)
def post(self, path, data=None, content_type=MULTIPART_CONTENT,
secure=False, **extra):
"Construct a POST request."
data = {} if data is None else data
post_data = self._encode_data(data, content_type)
return self.generic('POST', path, post_data, content_type,
secure=secure, **extra)
def head(self, path, data=None, secure=False, **extra):
"Construct a HEAD request."
data = {} if data is None else data
r = {
'QUERY_STRING': urlencode(data, doseq=True),
}
r.update(extra)
return self.generic('HEAD', path, secure=secure, **r)
def trace(self, path, secure=False, **extra):
"Construct a TRACE request."
return self.generic('TRACE', path, secure=secure, **extra)
def options(self, path, data='', content_type='application/octet-stream',
secure=False, **extra):
"Construct an OPTIONS request."
return self.generic('OPTIONS', path, data, content_type,
secure=secure, **extra)
def put(self, path, data='', content_type='application/octet-stream',
secure=False, **extra):
"Construct a PUT request."
return self.generic('PUT', path, data, content_type,
secure=secure, **extra)
def patch(self, path, data='', content_type='application/octet-stream',
secure=False, **extra):
"Construct a PATCH request."
return self.generic('PATCH', path, data, content_type,
secure=secure, **extra)
def delete(self, path, data='', content_type='application/octet-stream',
secure=False, **extra):
"Construct a DELETE request."
return self.generic('DELETE', path, data, content_type,
secure=secure, **extra)
def generic(self, method, path, data='',
content_type='application/octet-stream', secure=False,
**extra):
"""Constructs an arbitrary HTTP request."""
parsed = urlparse(path)
data = force_bytes(data, settings.DEFAULT_CHARSET)
r = {
'PATH_INFO': self._get_path(parsed),
'REQUEST_METHOD': str(method),
'SERVER_PORT': str('443') if secure else str('80'),
'wsgi.url_scheme': str('https') if secure else str('http'),
}
if data:
r.update({
'CONTENT_LENGTH': len(data),
'CONTENT_TYPE': str(content_type),
'wsgi.input': FakePayload(data),
})
r.update(extra)
# If QUERY_STRING is absent or empty, we want to extract it from the URL.
if not r.get('QUERY_STRING'):
query_string = force_bytes(parsed[4])
# WSGI requires latin-1 encoded strings. See get_path_info().
if six.PY3:
query_string = query_string.decode('iso-8859-1')
r['QUERY_STRING'] = query_string
return self.request(**r)
class Client(RequestFactory):
"""
A class that can act as a client for testing purposes.
It allows the user to compose GET and POST requests, and
obtain the response that the server gave to those requests.
The server Response objects are annotated with the details
of the contexts and templates that were rendered during the
process of serving the request.
Client objects are stateful - they will retain cookie (and
thus session) details for the lifetime of the Client instance.
This is not intended as a replacement for Twill/Selenium or
the like - it is here to allow testing against the
contexts and templates produced by a view, rather than the
HTML rendered to the end-user.
"""
def __init__(self, enforce_csrf_checks=False, **defaults):
super(Client, self).__init__(**defaults)
self.handler = ClientHandler(enforce_csrf_checks)
self.exc_info = None
def store_exc_info(self, **kwargs):
"""
Stores exceptions when they are generated by a view.
"""
self.exc_info = sys.exc_info()
def _session(self):
"""
Obtains the current session variables.
"""
if apps.is_installed('django.contrib.sessions'):
engine = import_module(settings.SESSION_ENGINE)
cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None)
if cookie:
return engine.SessionStore(cookie.value)
else:
s = engine.SessionStore()
s.save()
self.cookies[settings.SESSION_COOKIE_NAME] = s.session_key
return s
return {}
session = property(_session)
def request(self, **request):
"""
The master request method. Composes the environment dictionary
and passes to the handler, returning the result of the handler.
Assumes defaults for the query environment, which can be overridden
using the arguments to the request.
"""
environ = self._base_environ(**request)
# Curry a data dictionary into an instance of the template renderer
# callback function.
data = {}
on_template_render = curry(store_rendered_templates, data)
signal_uid = "template-render-%s" % id(request)
signals.template_rendered.connect(on_template_render, dispatch_uid=signal_uid)
# Capture exceptions created by the handler.
got_request_exception.connect(self.store_exc_info, dispatch_uid="request-exception")
try:
try:
response = self.handler(environ)
except TemplateDoesNotExist as e:
# If the view raises an exception, Django will attempt to show
# the 500.html template. If that template is not available,
# we should ignore the error in favor of re-raising the
# underlying exception that caused the 500 error. Any other
# template found to be missing during view error handling
# should be reported as-is.
if e.args != ('500.html',):
raise
# Look for a signalled exception, clear the current context
# exception data, then re-raise the signalled exception.
# Also make sure that the signalled exception is cleared from
# the local cache!
if self.exc_info:
exc_info = self.exc_info
self.exc_info = None
six.reraise(*exc_info)
# Save the client and request that stimulated the response.
response.client = self
response.request = request
# Add any rendered template detail to the response.
response.templates = data.get("templates", [])
response.context = data.get("context")
# Attach the ResolverMatch instance to the response
response.resolver_match = SimpleLazyObject(
lambda: urlresolvers.resolve(request['PATH_INFO']))
# Flatten a single context. Not really necessary anymore thanks to
# the __getattr__ flattening in ContextList, but has some edge-case
# backwards-compatibility implications.
if response.context and len(response.context) == 1:
response.context = response.context[0]
# Update persistent cookie data.
if response.cookies:
self.cookies.update(response.cookies)
return response
finally:
signals.template_rendered.disconnect(dispatch_uid=signal_uid)
got_request_exception.disconnect(dispatch_uid="request-exception")
def get(self, path, data=None, follow=False, secure=False, **extra):
"""
Requests a response from the server using GET.
"""
response = super(Client, self).get(path, data=data, secure=secure,
**extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
def post(self, path, data=None, content_type=MULTIPART_CONTENT,
follow=False, secure=False, **extra):
"""
Requests a response from the server using POST.
"""
response = super(Client, self).post(path, data=data,
content_type=content_type,
secure=secure, **extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
def head(self, path, data=None, follow=False, secure=False, **extra):
"""
Request a response from the server using HEAD.
"""
response = super(Client, self).head(path, data=data, secure=secure,
**extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
def options(self, path, data='', content_type='application/octet-stream',
follow=False, secure=False, **extra):
"""
Request a response from the server using OPTIONS.
"""
response = super(Client, self).options(path, data=data,
content_type=content_type,
secure=secure, **extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
def put(self, path, data='', content_type='application/octet-stream',
follow=False, secure=False, **extra):
"""
Send a resource to the server using PUT.
"""
response = super(Client, self).put(path, data=data,
content_type=content_type,
secure=secure, **extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
def patch(self, path, data='', content_type='application/octet-stream',
follow=False, secure=False, **extra):
"""
Send a resource to the server using PATCH.
"""
response = super(Client, self).patch(path, data=data,
content_type=content_type,
secure=secure, **extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
def delete(self, path, data='', content_type='application/octet-stream',
follow=False, secure=False, **extra):
"""
Send a DELETE request to the server.
"""
response = super(Client, self).delete(path, data=data,
content_type=content_type,
secure=secure, **extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
def trace(self, path, data='', follow=False, secure=False, **extra):
"""
Send a TRACE request to the server.
"""
response = super(Client, self).trace(path, data=data, secure=secure, **extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
def login(self, **credentials):
"""
Sets the Factory to appear as if it has successfully logged into a site.
Returns True if login is possible; False if the provided credentials
are incorrect, or the user is inactive, or if the sessions framework is
not available.
"""
from django.contrib.auth import authenticate, login
user = authenticate(**credentials)
if (user and user.is_active and
apps.is_installed('django.contrib.sessions')):
engine = import_module(settings.SESSION_ENGINE)
# Create a fake request to store login details.
request = HttpRequest()
if self.session:
request.session = self.session
else:
request.session = engine.SessionStore()
login(request, user)
# Save the session values.
request.session.save()
# Set the cookie to represent the session.
session_cookie = settings.SESSION_COOKIE_NAME
self.cookies[session_cookie] = request.session.session_key
cookie_data = {
'max-age': None,
'path': '/',
'domain': settings.SESSION_COOKIE_DOMAIN,
'secure': settings.SESSION_COOKIE_SECURE or None,
'expires': None,
}
self.cookies[session_cookie].update(cookie_data)
return True
else:
return False
def logout(self):
"""
Removes the authenticated user's cookies and session object.
Causes the authenticated user to be logged out.
"""
from django.contrib.auth import get_user, logout
request = HttpRequest()
engine = import_module(settings.SESSION_ENGINE)
if self.session:
request.session = self.session
request.user = get_user(request)
else:
request.session = engine.SessionStore()
logout(request)
self.cookies = SimpleCookie()
def _handle_redirects(self, response, **extra):
"Follows any redirects by requesting responses from the server using GET."
response.redirect_chain = []
while response.status_code in (301, 302, 303, 307):
response_url = response.url
redirect_chain = response.redirect_chain
redirect_chain.append((response_url, response.status_code))
url = urlsplit(response_url)
if url.scheme:
extra['wsgi.url_scheme'] = url.scheme
if url.hostname:
extra['SERVER_NAME'] = url.hostname
if url.port:
extra['SERVER_PORT'] = str(url.port)
response = self.get(url.path, QueryDict(url.query), follow=False, **extra)
response.redirect_chain = redirect_chain
if redirect_chain[-1] in redirect_chain[:-1]:
# Check that we're not redirecting to somewhere we've already
# been to, to prevent loops.
raise RedirectCycleError("Redirect loop detected.", last_response=response)
if len(redirect_chain) > 20:
# Such a lengthy chain likely also means a loop, but one with
# a growing path, changing view, or changing query argument;
# 20 is the value of "network.http.redirection-limit" from Firefox.
raise RedirectCycleError("Too many redirects.", last_response=response)
return response
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
13290,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
504,
1331,
492,
1331,
199,
504,
14802,
492,
492,
63,
578,
199,
504,
5890,
492,
11808,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
492,
32403,
199,
504,
1639,
14,
1018,
14,
5586,
14,
1095,
492,
3523,
2461,
199,
504,
1639,
14,
1018,
14,
5586,
14,
6508,
492,
9055,
63,
4830,
63,
17,
12,
9094,
63,
24,
12,
9279,
2017,
199,
504,
1639,
14,
1018,
14,
10458,
492,
334,
272,
4788,
63,
1069,
63,
1971,
12,
1056,
63,
8669,
12,
1056,
63,
8924,
12,
199,
9,
199,
504,
1639,
14,
697,
492,
4002,
63,
1753,
63,
7995,
199,
504,
1639,
14,
1014,
492,
20730,
12,
8133,
2141,
12,
5870,
7810,
199,
504,
1639,
14,
1160,
492,
27193,
199,
504,
1639,
14,
396,
492,
10166,
199,
504,
1639,
14,
396,
14,
1208,
492,
9470,
1296,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
12,
3542,
63,
495,
12,
5108,
63,
475,
63,
19081,
199,
504,
1639,
14,
1208,
14,
15481,
492,
5870,
14269,
1692,
12,
1094,
651,
199,
504,
1639,
14,
1208,
14,
1014,
492,
16511,
199,
504,
1639,
14,
1208,
14,
1661,
5819,
492,
365,
63,
8147,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1122,
492,
7097,
12,
29596,
199,
199,
363,
452,
363,
275,
661,
3041,
297,
283,
7071,
15302,
547,
297,
283,
2017,
2927,
297,
283,
2143,
63,
493,
297,
283,
2143,
63,
10123,
358,
421,
199,
21489,
275,
283,
2208,
1358,
25014,
50,
89,
933,
28522,
46,
71,
7,
199,
21894,
2294,
63,
9663,
275,
283,
10123,
15,
964,
13,
576,
27,
8424,
2458,
83,
7,
450,
4367,
6131,
4392,
199,
9663,
63,
2711,
63,
907,
275,
295,
14,
2014,
360,
2795,
27,
5960,
29,
16510,
87,
60,
68,
20253,
2736,
18478,
421,
199,
533,
18532,
15302,
547,
8,
1726,
304,
272,
408,
272,
710,
511,
1890,
965,
2757,
20864,
370,
2035,
282,
4660,
4438,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1245,
12,
2061,
63,
1310,
304,
267,
1613,
8,
7071,
15302,
547,
12,
291,
2843,
826,
721,
1188,
9,
267,
291,
14,
2019,
63,
1310,
275,
2061,
63,
1310,
267,
291,
14,
4876,
63,
4429,
275,
2061,
63,
1310,
14,
4876,
63,
4429,
421,
199,
533,
7777,
17215,
8,
785,
304,
272,
408,
272,
437,
4975,
6818,
11808,
626,
7213,
3021,
4052,
883,
506,
1586,
3967,
666,
687,
272,
314,
2784,
883,
1133,
506,
12005,
379,
436,
3913,
506,
1586,
9682,
402,
2399,
1564,
272,
2582,
14,
961,
7704,
3238,
626,
6858,
883,
1133,
886,
7003,
1334,
314,
511,
1890,
272,
626,
3955,
78,
1133,
1736,
315,
14849,
491,
16839,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1564,
29,
403,
304,
267,
291,
855,
1317,
275,
11808,
342,
267,
291,
855,
552,
275,
378,
267,
291,
14,
739,
63,
8924,
275,
756,
267,
340,
1564,
365,
440,
488,
26,
288,
291,
14,
952,
8,
1317,
9,
339,
347,
636,
552,
721,
277,
304,
267,
372,
291,
855,
552,
339,
347,
1586,
8,
277,
12,
1967,
63,
2394,
29,
403,
304,
267,
340,
440,
291,
14,
739,
63,
8924,
26,
288,
291,
855,
1317,
14,
5507,
8,
16,
9,
288,
291,
14,
739,
63,
8924,
275,
715,
267,
340,
1967,
63,
2394,
365,
488,
26,
288,
1967,
63,
2394,
275,
291,
855,
552,
503,
378,
267,
702,
291,
855,
552,
2356,
1967,
63,
2394,
12,
298,
6612,
1586,
1655,
2419,
314,
2808,
2783,
687,
314,
3101,
12467,
666,
2122,
267,
1564,
275,
291,
855,
1317,
14,
739,
8,
1507,
63,
2394,
9,
267,
291,
855,
552,
4862,
1967,
63,
2394,
267,
372,
1564,
339,
347,
2218,
8,
277,
12,
1564,
304,
267,
340,
291,
14,
739,
63,
8924,
26,
288,
746,
1722,
480,
6005,
370,
2218,
282,
4886,
2410,
946,
1159,
2757,
1586,
531,
267,
1564,
275,
3542,
63,
2394,
8,
1317,
9,
267,
291,
855,
1317,
14,
952,
8,
1317,
9,
267,
291,
855,
552,
847,
822,
8,
1317,
9,
421,
199,
318,
11261,
63,
5778,
63,
5029,
8,
8147,
12,
4002,
304,
272,
862,
26,
267,
367,
1242,
315,
6076,
26,
288,
1995,
1242,
272,
3753,
26,
267,
1056,
63,
8669,
14,
10673,
8,
1600,
63,
1753,
63,
7995,
9,
267,
4002,
342,
2476,
327,
911,
8344,
1056,
63,
8669,
267,
1056,
63,
8669,
14,
2242,
8,
1600,
63,
1753,
63,
7995,
9,
421,
199,
533,
6810,
2461,
8,
1563,
2461,
304,
272,
408,
272,
437,
3101,
18599,
626,
883,
506,
1202,
367,
5343,
12901,
14,
14911,
314,
9279,
272,
3217,
370,
23366,
4145,
12,
1325,
2529,
314,
3066,
6183,
909,
543,
272,
314,
6330,
1958,
9279,
2017,
10102,
370,
2399,
1124,
6508,
63,
1069,
1040,
2225,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
15814,
63,
10088,
63,
8625,
29,
549,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
14,
19817,
63,
10088,
63,
8625,
275,
15814,
63,
10088,
63,
8625,
267,
1613,
8,
3041,
2461,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
636,
1250,
721,
277,
12,
6160,
304,
267,
327,
2494,
1536,
10816,
340,
4346,
14,
2136,
21554,
1133,
886,
642,
14119,
12,
2952,
267,
327,
2202,
781,
828,
1133,
2808,
14,
267,
340,
291,
423,
1069,
63,
5754,
365,
488,
26,
288,
291,
14,
912,
63,
5754,
342,
398,
1056,
63,
8924,
14,
10673,
8,
1600,
63,
1753,
63,
7995,
9,
267,
1056,
63,
8924,
14,
2254,
8,
8114,
29,
277,
855,
533,
3108,
6160,
29,
2314,
9,
267,
1056,
63,
8924,
14,
2242,
8,
1600,
63,
1753,
63,
7995,
9,
267,
1056,
275,
9279,
2017,
8,
2314,
9,
267,
327,
308,
685,
1151,
89,
12050,
11176,
880,
626,
781,
883,
16174,
664,
6168,
267,
327,
22145,
25322,
14,
221,
961,
7704,
15451,
14905,
12,
436,
365,
8646,
267,
327,
1415,
367,
8552,
7163,
543,
5957,
2295,
6169,
267,
327,
4628,
6858,
14,
267,
1056,
423,
18671,
63,
19817,
63,
10088
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
13290,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
504,
1331,
492,
1331,
199,
504,
14802,
492,
492,
63,
578,
199,
504,
5890,
492,
11808,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
492,
32403,
199,
504,
1639,
14,
1018,
14,
5586,
14,
1095,
492,
3523,
2461,
199,
504,
1639,
14,
1018,
14,
5586,
14,
6508,
492,
9055,
63,
4830,
63,
17,
12,
9094,
63,
24,
12,
9279,
2017,
199,
504,
1639,
14,
1018,
14,
10458,
492,
334,
272,
4788,
63,
1069,
63,
1971,
12,
1056,
63,
8669,
12,
1056,
63,
8924,
12,
199,
9,
199,
504,
1639,
14,
697,
492,
4002,
63,
1753,
63,
7995,
199,
504,
1639,
14,
1014,
492,
20730,
12,
8133,
2141,
12,
5870,
7810,
199,
504,
1639,
14,
1160,
492,
27193,
199,
504,
1639,
14,
396,
492,
10166,
199,
504,
1639,
14,
396,
14,
1208,
492,
9470,
1296,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
12,
3542,
63,
495,
12,
5108,
63,
475,
63,
19081,
199,
504,
1639,
14,
1208,
14,
15481,
492,
5870,
14269,
1692,
12,
1094,
651,
199,
504,
1639,
14,
1208,
14,
1014,
492,
16511,
199,
504,
1639,
14,
1208,
14,
1661,
5819,
492,
365,
63,
8147,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1122,
492,
7097,
12,
29596,
199,
199,
363,
452,
363,
275,
661,
3041,
297,
283,
7071,
15302,
547,
297,
283,
2017,
2927,
297,
283,
2143,
63,
493,
297,
283,
2143,
63,
10123,
358,
421,
199,
21489,
275,
283,
2208,
1358,
25014,
50,
89,
933,
28522,
46,
71,
7,
199,
21894,
2294,
63,
9663,
275,
283,
10123,
15,
964,
13,
576,
27,
8424,
2458,
83,
7,
450,
4367,
6131,
4392,
199,
9663,
63,
2711,
63,
907,
275,
295,
14,
2014,
360,
2795,
27,
5960,
29,
16510,
87,
60,
68,
20253,
2736,
18478,
421,
199,
533,
18532,
15302,
547,
8,
1726,
304,
272,
408,
272,
710,
511,
1890,
965,
2757,
20864,
370,
2035,
282,
4660,
4438,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1245,
12,
2061,
63,
1310,
304,
267,
1613,
8,
7071,
15302,
547,
12,
291,
2843,
826,
721,
1188,
9,
267,
291,
14,
2019,
63,
1310,
275,
2061,
63,
1310,
267,
291,
14,
4876,
63,
4429,
275,
2061,
63,
1310,
14,
4876,
63,
4429,
421,
199,
533,
7777,
17215,
8,
785,
304,
272,
408,
272,
437,
4975,
6818,
11808,
626,
7213,
3021,
4052,
883,
506,
1586,
3967,
666,
687,
272,
314,
2784,
883,
1133,
506,
12005,
379,
436,
3913,
506,
1586,
9682,
402,
2399,
1564,
272,
2582,
14,
961,
7704,
3238,
626,
6858,
883,
1133,
886,
7003,
1334,
314,
511,
1890,
272,
626,
3955,
78,
1133,
1736,
315,
14849,
491,
16839,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1564,
29,
403,
304,
267,
291,
855,
1317,
275,
11808,
342,
267,
291,
855,
552,
275,
378,
267,
291,
14,
739,
63,
8924,
275,
756,
267,
340,
1564,
365,
440,
488,
26,
288,
291,
14,
952,
8,
1317,
9,
339,
347,
636,
552,
721,
277,
304,
267,
372,
291,
855,
552,
339,
347,
1586,
8,
277,
12,
1967,
63,
2394,
29,
403,
304,
267,
340,
440,
291,
14,
739,
63,
8924,
26,
288,
291,
855,
1317,
14,
5507,
8,
16,
9,
288,
291,
14,
739,
63,
8924,
275,
715,
267,
340,
1967,
63,
2394,
365,
488,
26,
288,
1967,
63,
2394,
275,
291,
855,
552,
503,
378,
267,
702,
291,
855,
552,
2356,
1967,
63,
2394,
12,
298,
6612,
1586,
1655,
2419,
314,
2808,
2783,
687,
314,
3101,
12467,
666,
2122,
267,
1564,
275,
291,
855,
1317,
14,
739,
8,
1507,
63,
2394,
9,
267,
291,
855,
552,
4862,
1967,
63,
2394,
267,
372,
1564,
339,
347,
2218,
8,
277,
12,
1564,
304,
267,
340,
291,
14,
739,
63,
8924,
26,
288,
746,
1722,
480,
6005,
370,
2218,
282,
4886,
2410,
946,
1159,
2757,
1586,
531,
267,
1564,
275,
3542,
63,
2394,
8,
1317,
9,
267,
291,
855,
1317,
14,
952,
8,
1317,
9,
267,
291,
855,
552,
847,
822,
8,
1317,
9,
421,
199,
318,
11261,
63,
5778,
63,
5029,
8,
8147,
12,
4002,
304,
272,
862,
26,
267,
367,
1242,
315,
6076,
26,
288,
1995,
1242,
272,
3753,
26,
267,
1056,
63,
8669,
14,
10673,
8,
1600,
63,
1753,
63,
7995,
9,
267,
4002,
342,
2476,
327,
911,
8344,
1056,
63,
8669,
267,
1056,
63,
8669,
14,
2242,
8,
1600,
63,
1753,
63,
7995,
9,
421,
199,
533,
6810,
2461,
8,
1563,
2461,
304,
272,
408,
272,
437,
3101,
18599,
626,
883,
506,
1202,
367,
5343,
12901,
14,
14911,
314,
9279,
272,
3217,
370,
23366,
4145,
12,
1325,
2529,
314,
3066,
6183,
909,
543,
272,
314,
6330,
1958,
9279,
2017,
10102,
370,
2399,
1124,
6508,
63,
1069,
1040,
2225,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
15814,
63,
10088,
63,
8625,
29,
549,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
14,
19817,
63,
10088,
63,
8625,
275,
15814,
63,
10088,
63,
8625,
267,
1613,
8,
3041,
2461,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
636,
1250,
721,
277,
12,
6160,
304,
267,
327,
2494,
1536,
10816,
340,
4346,
14,
2136,
21554,
1133,
886,
642,
14119,
12,
2952,
267,
327,
2202,
781,
828,
1133,
2808,
14,
267,
340,
291,
423,
1069,
63,
5754,
365,
488,
26,
288,
291,
14,
912,
63,
5754,
342,
398,
1056,
63,
8924,
14,
10673,
8,
1600,
63,
1753,
63,
7995,
9,
267,
1056,
63,
8924,
14,
2254,
8,
8114,
29,
277,
855,
533,
3108,
6160,
29,
2314,
9,
267,
1056,
63,
8924,
14,
2242,
8,
1600,
63,
1753,
63,
7995,
9,
267,
1056,
275,
9279,
2017,
8,
2314,
9,
267,
327,
308,
685,
1151,
89,
12050,
11176,
880,
626,
781,
883,
16174,
664,
6168,
267,
327,
22145,
25322,
14,
221,
961,
7704,
15451,
14905,
12,
436,
365,
8646,
267,
327,
1415,
367,
8552,
7163,
543,
5957,
2295,
6169,
267,
327,
4628,
6858,
14,
267,
1056,
423,
18671,
63,
19817,
63,
10088,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
BoltzmannBrain/nupic.research
|
htmresearch/frameworks/sensorimotor/behavior_memory.py
|
10
|
8905
|
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2014, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions apply:
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero Public License for more details.
#
# You should have received a copy of the GNU Affero Public License
# along with this program. If not, see http://www.gnu.org/licenses.
#
# http://numenta.org/licenses/
# ----------------------------------------------------------------------
import numpy
class BehaviorMemory(object):
def __init__(self,
numMotorColumns=1024,
numSensorColumns=1024,
numCellsPerSensorColumn=32,
goalToBehaviorLearningRate=0.3,
behaviorToMotorLearningRate=0.3,
motorToBehaviorLearningRate=0.3,
behaviorDecayRate=0.10):
self.numMotorColumns = numMotorColumns
self.numSensorColumns = numSensorColumns
self.numCellsPerSensorColumn = numCellsPerSensorColumn
self.goalToBehaviorLearningRate = goalToBehaviorLearningRate
self.behaviorToMotorLearningRate = behaviorToMotorLearningRate
self.motorToBehaviorLearningRate = motorToBehaviorLearningRate
self.behaviorDecayRate = behaviorDecayRate
self.numMotorCells = numMotorColumns
self.numGoalCells = numSensorColumns
self.motor = numpy.zeros(self.numMotorCells)
self.learningBehavior = numpy.zeros([self.numSensorColumns,
self.numCellsPerSensorColumn])
self.activeBehavior = numpy.zeros([self.numSensorColumns,
self.numCellsPerSensorColumn])
self.goal = numpy.zeros(self.numGoalCells)
self.goalToBehavior = self._initWeights([self.numSensorColumns,
self.numCellsPerSensorColumn,
self.numGoalCells])
self.behaviorToMotor = self._initWeights([self.numMotorCells,
self.numSensorColumns,
self.numCellsPerSensorColumn])
self.motorToBehavior = self._initWeights([self.numSensorColumns,
self.numCellsPerSensorColumn,
self.numMotorCells])
# For debugging
self.activeMotorColumns = set()
self.activeSensorColumns = set()
self.activeGoalColumns = set()
self.prevActiveSensorColumns = set()
self.reconstructedBehavior = numpy.zeros([self.numSensorColumns,
self.numCellsPerSensorColumn])
self.reconstructedMotor = numpy.zeros(self.numMotorCells)
@staticmethod
def _initWeights(shape):
weights = numpy.random.normal(0.1, 0.1, shape)
numpy.clip(weights, 0, 1, out=weights)
return weights
@staticmethod
def _makeArray(s, length):
arr = numpy.zeros(length)
arr[list(s)] = 1
return arr
@classmethod
def _reinforce(cls, weights, active, learningRate):
delta = active * learningRate
return cls._addAndNormalize(weights, delta)
@staticmethod
def _addAndNormalize(numbers, delta):
total = numbers.sum()
numbers += delta
numpy.clip(numbers, 0, 1, out=numbers)
numbers /= (numbers.sum() / total)
return numbers
def compute(self, activeMotorColumns, activeSensorColumns, activeGoalColumns):
self.prevActiveSensorColumns = self.activeSensorColumns
self.activeMotorColumns = activeMotorColumns
self.activeSensorColumns = activeSensorColumns
self.activeGoalColumns = activeGoalColumns
motorPattern = self._makeArray(activeMotorColumns, self.numMotorColumns)
sensorPattern = self._makeArray(activeSensorColumns, self.numSensorColumns)
goalPattern = self._makeArray(activeGoalColumns, self.numSensorColumns)
self.motor = motorPattern
self.goal = goalPattern if len(activeGoalColumns) else sensorPattern
prevSensorPattern = self._makeArray(self.prevActiveSensorColumns,
self.numSensorColumns)
self.reconstructedBehavior = self._computeBehaviorFromGoal(
self.goal, prevSensorPattern)
self.reconstructedMotor = self._computeMotorFromBehavior(
self.reconstructedBehavior)
if len(activeGoalColumns):
self.activeBehavior = self._computeBehaviorFromGoal(self.goal,
sensorPattern)
self.motor = self._computeMotorFromBehavior(self.activeBehavior)
else:
self._reinforceGoalToBehavior(self.goal, self.learningBehavior)
self.activeBehavior = self._computeBehaviorFromMotor(self.motor,
sensorPattern)
self.learningBehavior = self._computeLearningBehavior(
self.learningBehavior, self.activeBehavior)
self._reinforceBehaviorToMotor(self.activeBehavior, self.motor)
self._reinforceMotorToBehavior(self.motor, self.activeBehavior)
def numBehaviorCells(self):
return self.numSensorColumns * self.numCellsPerSensorColumn
def goalToBehaviorFlat(self):
return self.goalToBehavior.reshape([self.numBehaviorCells(),
self.numGoalCells])
def motorToBehaviorFlat(self):
return self.motorToBehavior.reshape([self.numBehaviorCells(),
self.numMotorCells])
def behaviorToMotorFlat(self):
return self.behaviorToMotor.reshape([self.numMotorCells,
self.numBehaviorCells()])
def _reinforceGoalToBehavior(self, goal, behavior):
goalToBehaviorFlat = self.goalToBehaviorFlat()
for cell in numpy.flatnonzero(behavior):
weights = goalToBehaviorFlat[cell]
idx = numpy.unravel_index(cell, behavior.shape)
learningRate = self.goalToBehaviorLearningRate * behavior[idx]
self._reinforce(weights, goal, learningRate)
def _reinforceBehaviorToMotor(self, behavior, motor):
for cell in motor.nonzero()[0]:
weights = self.behaviorToMotor[cell]
self._reinforce(weights,
behavior,
self.behaviorToMotorLearningRate)
def _reinforceMotorToBehavior(self, motor, behavior):
for cell in numpy.transpose(behavior.nonzero()):
weights = self.motorToBehavior[cell[0], cell[1]]
self._reinforce(weights,
motor,
self.motorToBehaviorLearningRate)
def _computeLearningBehavior(self, learningBehavior, activeBehavior,
minWeight=0.001):
behavior = learningBehavior * (1 - self.behaviorDecayRate)
behavior += activeBehavior
winnerCells = behavior.argmax(axis=1)
sparseBehavior = numpy.zeros(behavior.shape)
for column in range(len(winnerCells)):
winnerCell = winnerCells[column]
sparseBehavior[column][winnerCell] = behavior[column][winnerCell]
numpy.clip(sparseBehavior, 0, 1, out=sparseBehavior)
sparseBehavior[sparseBehavior < minWeight] = 0
return sparseBehavior
def _computeBehaviorFromMotor(self, motor, sensorPattern):
activity = numpy.dot(motor, self.motorToBehaviorFlat().transpose())
activity = activity.reshape([self.numSensorColumns,
self.numCellsPerSensorColumn])
winnerCells = numpy.argmax(activity, axis=1)
behavior = numpy.zeros([self.numSensorColumns,
self.numCellsPerSensorColumn])
for column in sensorPattern.nonzero()[0]:
winnerCell = winnerCells[column]
behavior[column][winnerCell] = 1
return behavior
def _computeBehaviorFromGoal(self, goal, sensorPattern):
"""TODO: Rename to _reconstruct..."""
activity = numpy.dot(goal, self.goalToBehaviorFlat().transpose())
activity = activity.reshape([self.numSensorColumns,
self.numCellsPerSensorColumn])
behavior = numpy.zeros(activity.shape)
for column in sensorPattern.nonzero()[0]:
behavior[column][:] = activity[column]
behavior /= behavior.max()
return behavior
def _computeMotorFromBehavior(self, behavior):
"""TODO: Rename to _reconstruct..."""
motor = numpy.dot(behavior.flatten(),
self.behaviorToMotorFlat().transpose())
motor /= self.motor.sum()
motor /= motor.max()
return motor
|
agpl-3.0
|
[
3,
20359,
199,
3,
22783,
16078,
367,
8883,
24024,
27799,
334,
21988,
26769,
9,
199,
3,
1898,
334,
35,
9,
6927,
12,
22783,
12,
3277,
14,
221,
4158,
1265,
1172,
376,
25025,
199,
3,
543,
22783,
12,
3277,
2020,
367,
282,
7396,
4190,
367,
642,
2032,
1233,
12,
314,
199,
3,
2569,
2895,
436,
3704,
4838,
26,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1684,
844,
1015,
650,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
199,
3,
1666,
314,
1664,
4265,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
14,
199,
3,
199,
3,
1455,
921,
78,
18952,
14,
1308,
15,
2383,
15,
199,
3,
20359,
199,
199,
646,
2680,
4388,
199,
533,
6423,
13115,
8628,
8,
785,
304,
819,
347,
636,
826,
721,
277,
12,
2049,
1967,
31642,
15086,
29,
7727,
12,
2049,
1967,
10160,
15086,
29,
7727,
12,
2049,
1967,
16852,
2623,
10160,
4547,
29,
708,
12,
2049,
14850,
1378,
25361,
25519,
6621,
29,
16,
14,
19,
12,
2049,
5953,
1378,
31642,
25519,
6621,
29,
16,
14,
19,
12,
2049,
28496,
1378,
25361,
25519,
6621,
29,
16,
14,
19,
12,
2049,
5953,
872,
9972,
6621,
29,
16,
14,
709,
304,
272,
291,
14,
1507,
31642,
15086,
275,
1967,
31642,
15086,
272,
291,
14,
1507,
10160,
15086,
275,
1967,
10160,
15086,
272,
291,
14,
1507,
16852,
2623,
10160,
4547,
275,
1967,
16852,
2623,
10160,
4547,
272,
291,
14,
16117,
1378,
25361,
25519,
6621,
275,
14850,
1378,
25361,
25519,
6621,
272,
291,
14,
17537,
1378,
31642,
25519,
6621,
275,
5953,
1378,
31642,
25519,
6621,
272,
291,
14,
27840,
1378,
25361,
25519,
6621,
275,
28496,
1378,
25361,
25519,
6621,
272,
291,
14,
17537,
872,
9972,
6621,
275,
5953,
872,
9972,
6621,
339,
291,
14,
1507,
31642,
16852,
275,
1967,
31642,
15086,
272,
291,
14,
1507,
31274,
16852,
275,
1967,
10160,
15086,
339,
291,
14,
27840,
275,
2680,
14,
4250,
8,
277,
14,
1507,
31642,
16852,
9,
272,
291,
14,
10546,
25361,
275,
2680,
14,
4250,
779,
277,
14,
1507,
10160,
15086,
12,
1460,
291,
14,
1507,
16852,
2623,
10160,
4547,
566,
272,
291,
14,
2682,
25361,
275,
2680,
14,
4250,
779,
277,
14,
1507,
10160,
15086,
12,
4318,
291,
14,
1507,
16852,
2623,
10160,
4547,
566,
272,
291,
14,
16117,
275,
2680,
14,
4250,
8,
277,
14,
1507,
31274,
16852,
9,
339,
291,
14,
16117,
1378,
25361,
275,
291,
423,
826,
23885,
779,
277,
14,
1507,
10160,
15086,
12,
6163,
291,
14,
1507,
16852,
2623,
10160,
4547,
12,
6163,
291,
14,
1507,
31274,
16852,
566,
272,
291,
14,
17537,
1378,
31642,
275,
291,
423,
826,
23885,
779,
277,
14,
1507,
31642,
16852,
12,
6343,
291,
14,
1507,
10160,
15086,
12,
6343,
291,
14,
1507,
16852,
2623,
10160,
4547,
566,
272,
291,
14,
27840,
1378,
25361,
275,
291,
423,
826,
23885,
779,
277,
14,
1507,
10160,
15086,
12,
6343,
291,
14,
1507,
16852,
2623,
10160,
4547,
12,
6343,
291,
14,
1507,
31642,
16852,
566,
339,
327,
2104,
10201,
272,
291,
14,
2682,
31642,
15086,
275,
663,
342,
272,
291,
14,
2682,
10160,
15086,
275,
663,
342,
272,
291,
14,
2682,
31274,
15086,
275,
663,
342,
339,
291,
14,
5701,
7472,
10160,
15086,
275,
663,
342,
339,
291,
14,
25981,
11614,
25361,
275,
2680,
14,
4250,
779,
277,
14,
1507,
10160,
15086,
12,
6343,
291,
14,
1507,
16852,
2623,
10160,
4547,
566,
272,
291,
14,
25981,
11614,
31642,
275,
2680,
14,
4250,
8,
277,
14,
1507,
31642,
16852,
9,
8330,
768,
4639,
523,
347,
485,
826,
23885,
8,
1392,
304,
272,
4931,
275,
2680,
14,
2355,
14,
3302,
8,
16,
14,
17,
12,
378,
14,
17,
12,
2215,
9,
272,
2680,
14,
7548,
8,
4916,
12,
378,
12,
413,
12,
734,
29,
4916,
9,
339,
372,
4931,
8330,
768,
4639,
523,
347,
485,
1875,
3836,
8,
83,
12,
2582,
304,
272,
7953,
275,
2680,
14,
4250,
8,
1267,
9,
272,
7953,
59,
513,
8,
83,
1874,
275,
413,
272,
372,
7953,
8330,
768,
3744,
523,
347,
485,
264,
262,
3990,
8,
1886,
12,
4931,
12,
4702,
12,
9328,
6621,
304,
272,
5762,
275,
4702,
627,
9328,
6621,
272,
372,
843,
423,
525,
3325,
22580,
8,
4916,
12,
5762,
9,
8330,
768,
4639,
523,
347,
485,
525,
3325,
22580,
8,
10548,
12,
5762,
304,
272,
3141,
275,
5579,
14,
1838,
342,
272,
5579,
847,
5762,
272,
2680,
14,
7548,
8,
10548,
12,
378,
12,
413,
12,
734,
29,
10548,
9,
272,
5579,
12257,
334,
10548,
14,
1838,
342,
1182,
3141,
9,
272,
372,
5579,
8330,
347,
4526,
8,
277,
12,
4702,
31642,
15086,
12,
4702,
10160,
15086,
12,
4702,
31274,
15086,
304,
272,
291,
14,
5701,
7472,
10160,
15086,
275,
291,
14,
2682,
10160,
15086,
272,
291,
14,
2682,
31642,
15086,
275,
4702,
31642,
15086,
272,
291,
14,
2682,
10160,
15086,
275,
4702,
10160,
15086,
272,
291,
14,
2682,
31274,
15086,
275,
4702,
31274,
15086,
339,
28496,
9959,
275,
291,
423,
1875,
3836,
8,
2682,
31642,
15086,
12,
291,
14,
1507,
31642,
15086,
9,
272,
8778,
9959,
275,
291,
423,
1875,
3836,
8,
2682,
10160,
15086,
12,
291,
14,
1507,
10160,
15086,
9,
272,
14850,
9959,
275,
291,
423,
1875,
3836,
8,
2682,
31274,
15086,
12,
291,
14,
1507,
10160,
15086,
9,
339,
291,
14,
27840,
275,
28496,
9959,
272,
291,
14,
16117,
275,
14850,
9959,
340,
822,
8,
2682,
31274,
15086,
9,
587,
8778,
9959,
339,
5071,
10160,
9959,
275,
291,
423,
1875,
3836,
8,
277,
14,
5701,
7472,
10160,
15086,
12,
3147,
291,
14,
1507,
10160,
15086,
9,
272,
291,
14,
25981,
11614,
25361,
275,
291,
423,
3357,
25361,
2532,
31274,
8,
489,
291,
14,
16117,
12
] |
[
20359,
199,
3,
22783,
16078,
367,
8883,
24024,
27799,
334,
21988,
26769,
9,
199,
3,
1898,
334,
35,
9,
6927,
12,
22783,
12,
3277,
14,
221,
4158,
1265,
1172,
376,
25025,
199,
3,
543,
22783,
12,
3277,
2020,
367,
282,
7396,
4190,
367,
642,
2032,
1233,
12,
314,
199,
3,
2569,
2895,
436,
3704,
4838,
26,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1684,
844,
1015,
650,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
199,
3,
1666,
314,
1664,
4265,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
14,
199,
3,
199,
3,
1455,
921,
78,
18952,
14,
1308,
15,
2383,
15,
199,
3,
20359,
199,
199,
646,
2680,
4388,
199,
533,
6423,
13115,
8628,
8,
785,
304,
819,
347,
636,
826,
721,
277,
12,
2049,
1967,
31642,
15086,
29,
7727,
12,
2049,
1967,
10160,
15086,
29,
7727,
12,
2049,
1967,
16852,
2623,
10160,
4547,
29,
708,
12,
2049,
14850,
1378,
25361,
25519,
6621,
29,
16,
14,
19,
12,
2049,
5953,
1378,
31642,
25519,
6621,
29,
16,
14,
19,
12,
2049,
28496,
1378,
25361,
25519,
6621,
29,
16,
14,
19,
12,
2049,
5953,
872,
9972,
6621,
29,
16,
14,
709,
304,
272,
291,
14,
1507,
31642,
15086,
275,
1967,
31642,
15086,
272,
291,
14,
1507,
10160,
15086,
275,
1967,
10160,
15086,
272,
291,
14,
1507,
16852,
2623,
10160,
4547,
275,
1967,
16852,
2623,
10160,
4547,
272,
291,
14,
16117,
1378,
25361,
25519,
6621,
275,
14850,
1378,
25361,
25519,
6621,
272,
291,
14,
17537,
1378,
31642,
25519,
6621,
275,
5953,
1378,
31642,
25519,
6621,
272,
291,
14,
27840,
1378,
25361,
25519,
6621,
275,
28496,
1378,
25361,
25519,
6621,
272,
291,
14,
17537,
872,
9972,
6621,
275,
5953,
872,
9972,
6621,
339,
291,
14,
1507,
31642,
16852,
275,
1967,
31642,
15086,
272,
291,
14,
1507,
31274,
16852,
275,
1967,
10160,
15086,
339,
291,
14,
27840,
275,
2680,
14,
4250,
8,
277,
14,
1507,
31642,
16852,
9,
272,
291,
14,
10546,
25361,
275,
2680,
14,
4250,
779,
277,
14,
1507,
10160,
15086,
12,
1460,
291,
14,
1507,
16852,
2623,
10160,
4547,
566,
272,
291,
14,
2682,
25361,
275,
2680,
14,
4250,
779,
277,
14,
1507,
10160,
15086,
12,
4318,
291,
14,
1507,
16852,
2623,
10160,
4547,
566,
272,
291,
14,
16117,
275,
2680,
14,
4250,
8,
277,
14,
1507,
31274,
16852,
9,
339,
291,
14,
16117,
1378,
25361,
275,
291,
423,
826,
23885,
779,
277,
14,
1507,
10160,
15086,
12,
6163,
291,
14,
1507,
16852,
2623,
10160,
4547,
12,
6163,
291,
14,
1507,
31274,
16852,
566,
272,
291,
14,
17537,
1378,
31642,
275,
291,
423,
826,
23885,
779,
277,
14,
1507,
31642,
16852,
12,
6343,
291,
14,
1507,
10160,
15086,
12,
6343,
291,
14,
1507,
16852,
2623,
10160,
4547,
566,
272,
291,
14,
27840,
1378,
25361,
275,
291,
423,
826,
23885,
779,
277,
14,
1507,
10160,
15086,
12,
6343,
291,
14,
1507,
16852,
2623,
10160,
4547,
12,
6343,
291,
14,
1507,
31642,
16852,
566,
339,
327,
2104,
10201,
272,
291,
14,
2682,
31642,
15086,
275,
663,
342,
272,
291,
14,
2682,
10160,
15086,
275,
663,
342,
272,
291,
14,
2682,
31274,
15086,
275,
663,
342,
339,
291,
14,
5701,
7472,
10160,
15086,
275,
663,
342,
339,
291,
14,
25981,
11614,
25361,
275,
2680,
14,
4250,
779,
277,
14,
1507,
10160,
15086,
12,
6343,
291,
14,
1507,
16852,
2623,
10160,
4547,
566,
272,
291,
14,
25981,
11614,
31642,
275,
2680,
14,
4250,
8,
277,
14,
1507,
31642,
16852,
9,
8330,
768,
4639,
523,
347,
485,
826,
23885,
8,
1392,
304,
272,
4931,
275,
2680,
14,
2355,
14,
3302,
8,
16,
14,
17,
12,
378,
14,
17,
12,
2215,
9,
272,
2680,
14,
7548,
8,
4916,
12,
378,
12,
413,
12,
734,
29,
4916,
9,
339,
372,
4931,
8330,
768,
4639,
523,
347,
485,
1875,
3836,
8,
83,
12,
2582,
304,
272,
7953,
275,
2680,
14,
4250,
8,
1267,
9,
272,
7953,
59,
513,
8,
83,
1874,
275,
413,
272,
372,
7953,
8330,
768,
3744,
523,
347,
485,
264,
262,
3990,
8,
1886,
12,
4931,
12,
4702,
12,
9328,
6621,
304,
272,
5762,
275,
4702,
627,
9328,
6621,
272,
372,
843,
423,
525,
3325,
22580,
8,
4916,
12,
5762,
9,
8330,
768,
4639,
523,
347,
485,
525,
3325,
22580,
8,
10548,
12,
5762,
304,
272,
3141,
275,
5579,
14,
1838,
342,
272,
5579,
847,
5762,
272,
2680,
14,
7548,
8,
10548,
12,
378,
12,
413,
12,
734,
29,
10548,
9,
272,
5579,
12257,
334,
10548,
14,
1838,
342,
1182,
3141,
9,
272,
372,
5579,
8330,
347,
4526,
8,
277,
12,
4702,
31642,
15086,
12,
4702,
10160,
15086,
12,
4702,
31274,
15086,
304,
272,
291,
14,
5701,
7472,
10160,
15086,
275,
291,
14,
2682,
10160,
15086,
272,
291,
14,
2682,
31642,
15086,
275,
4702,
31642,
15086,
272,
291,
14,
2682,
10160,
15086,
275,
4702,
10160,
15086,
272,
291,
14,
2682,
31274,
15086,
275,
4702,
31274,
15086,
339,
28496,
9959,
275,
291,
423,
1875,
3836,
8,
2682,
31642,
15086,
12,
291,
14,
1507,
31642,
15086,
9,
272,
8778,
9959,
275,
291,
423,
1875,
3836,
8,
2682,
10160,
15086,
12,
291,
14,
1507,
10160,
15086,
9,
272,
14850,
9959,
275,
291,
423,
1875,
3836,
8,
2682,
31274,
15086,
12,
291,
14,
1507,
10160,
15086,
9,
339,
291,
14,
27840,
275,
28496,
9959,
272,
291,
14,
16117,
275,
14850,
9959,
340,
822,
8,
2682,
31274,
15086,
9,
587,
8778,
9959,
339,
5071,
10160,
9959,
275,
291,
423,
1875,
3836,
8,
277,
14,
5701,
7472,
10160,
15086,
12,
3147,
291,
14,
1507,
10160,
15086,
9,
272,
291,
14,
25981,
11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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
weebygames/boto
|
boto/sdb/db/__init__.py
|
189
|
1108
|
# Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
|
mit
|
[
3,
1898,
334,
67,
9,
8315,
12,
9488,
12,
9300,
603,
9414,
598,
26272,
1455,
921,
71,
26272,
14,
1308,
15,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
8315,
12,
9488,
12,
9300,
603,
9414,
598,
26272,
1455,
921,
71,
26272,
14,
1308,
15,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
chrisdickinson/tweezers
|
docs/conf.py
|
1
|
7099
|
# -*- coding: utf-8 -*-
#
# Read The Docs documentation build configuration file, created by
# sphinx-quickstart on Sat Aug 14 00:06:40 2010.
#
# 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
# 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 = []
# 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'Read The Docs'
copyright = u'2010, Eric Holscher, Charlie Leifer, Bobby Grace'
# 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'
# 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'
# 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 = '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']
# 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 = 'ReadTheDocsdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'ReadTheDocs.tex', u'Read The Docs Documentation',
u'Eric Holscher, Charlie Leifer, Bobby Grace', '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
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_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', 'readthedocs', u'Read The Docs Documentation',
[u'Eric Holscher, Charlie Leifer, Bobby Grace'], 1)
]
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
5574,
710,
5454,
83,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
428,
292,
25298,
4329,
8733,
26,
1690,
26,
2167,
7129,
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,
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,
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,
3284,
710,
5454,
83,
7,
199,
7307,
275,
399,
7,
6542,
12,
662,
1567,
869,
1446,
7641,
12,
6659,
21530,
7005,
692,
281,
12,
699,
2873,
991,
598,
5986,
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,
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,
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,
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,
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,
3769,
3193,
88,
975,
503,
4337
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
5574,
710,
5454,
83,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
428,
292,
25298,
4329,
8733,
26,
1690,
26,
2167,
7129,
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,
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,
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,
3284,
710,
5454,
83,
7,
199,
7307,
275,
399,
7,
6542,
12,
662,
1567,
869,
1446,
7641,
12,
6659,
21530,
7005,
692,
281,
12,
699,
2873,
991,
598,
5986,
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,
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,
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,
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,
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,
3769,
3193,
88,
975,
503,
4337,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ys305751572/jstorm
|
bin/jstorm.py
|
19
|
16272
|
#!/usr/bin/env python
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/usr/bin/python
import os
import sys
import random
import subprocess as sub
import getopt
def identity(x):
return x
def cygpath(x):
command = ["cygpath", "-wp", x]
p = sub.Popen(command,stdout=sub.PIPE)
output, errors = p.communicate()
lines = output.split("\n")
return lines[0]
if sys.platform == "cygwin":
normclasspath = cygpath
else:
normclasspath = identity
CLIENT_CONF_FILE = ""
JSTORM_DIR = "/".join(os.path.realpath( __file__ ).split("/")[:-2])
JSTORM_CONF_DIR = os.getenv("JSTORM_CONF_DIR", JSTORM_DIR + "/conf" )
LOGBACK_CONF = JSTORM_CONF_DIR + "/jstorm.logback.xml"
CONFIG_OPTS = []
EXCLUDE_JARS = []
INCLUDE_JARS = []
STATUS = 0
def check_java():
check_java_cmd = 'which java'
ret = os.system(check_java_cmd)
if ret != 0:
print("Failed to find java, please add java to PATH")
sys.exit(-1)
def get_config_opts():
global CONFIG_OPTS
return "-Dstorm.options=" + (','.join(CONFIG_OPTS)).replace(' ', "%%%%")
def get_client_childopts():
ret = (" -Dstorm.root.logger=INFO,stdout -Dlogback.configurationFile=" + JSTORM_DIR +
"/conf/client_logback.xml -Dlog4j.configuration=File:" + JSTORM_DIR +
"/conf/client_log4j.properties")
if CLIENT_CONF_FILE != "":
ret += (" -Dstorm.conf.file=" + CLIENT_CONF_FILE)
return ret
def get_server_childopts(log_name):
ret = (" -Dlogfile.name=%s -Dlogback.configurationFile=%s" %(log_name, LOGBACK_CONF))
return ret
if not os.path.exists(JSTORM_DIR + "/RELEASE"):
print "******************************************"
print "The jstorm client can only be run from within a release. You appear to be trying to run the client from a checkout of JStorm's source code."
print "\nYou can download a JStorm release "
print "******************************************"
sys.exit(1)
def get_jars_full(adir):
files = os.listdir(adir)
ret = []
for f in files:
if f.endswith(".jar") == False:
continue
filter = False
for exclude_jar in EXCLUDE_JARS:
if f.find(exclude_jar) >= 0:
filter = True
break
if filter == True:
print "Don't add " + f + " to classpath"
else:
ret.append(adir + "/" + f)
return ret
def get_classpath(extrajars):
ret = []
ret.extend(extrajars)
ret.extend(get_jars_full(JSTORM_DIR))
ret.extend(get_jars_full(JSTORM_DIR + "/lib"))
ret.extend(INCLUDE_JARS)
return normclasspath(":".join(ret))
def confvalue(name, extrapaths):
command = [
"java", "-client", "-Xms256m", "-Xmx256m", get_config_opts(), "-cp", get_classpath(extrapaths), "backtype.storm.command.config_value", name
]
p = sub.Popen(command, stdout=sub.PIPE)
output, errors = p.communicate()
lines = output.split("\n")
for line in lines:
tokens = line.split(" ")
if tokens[0] == "VALUE:":
return " ".join(tokens[1:])
print "Failed to get config " + name
print errors
print output
def print_localconfvalue(name):
"""Syntax: [jstorm localconfvalue conf-name]
Prints out the value for conf-name in the local JStorm configs.
The local JStorm configs are the ones in ~/.jstorm/storm.yaml merged
in with the configs in defaults.yaml.
"""
print name + ": " + confvalue(name, [JSTORM_CONF_DIR])
def print_remoteconfvalue(name):
"""Syntax: [jstorm remoteconfvalue conf-name]
Prints out the value for conf-name in the cluster's JStorm configs.
The cluster's JStorm configs are the ones in $STORM-PATH/conf/storm.yaml
merged in with the configs in defaults.yaml.
This command must be run on a cluster machine.
"""
print name + ": " + confvalue(name, [JSTORM_CONF_DIR])
def exec_storm_class(klass, jvmtype="-server", childopts="", extrajars=[], args=[]):
nativepath = confvalue("java.library.path", extrajars)
args_str = " ".join(map(lambda s: "\"" + s + "\"", args))
command = "java " + jvmtype + " -Djstorm.home=" + JSTORM_DIR + " " + get_config_opts() + " -Djava.library.path=" + nativepath + " " + childopts + " -cp " + get_classpath(extrajars) + " " + klass + " " + args_str
print "Running: " + command
global STATUS
STATUS = os.system(command)
def jar(jarfile, klass, *args):
"""Syntax: [jstorm jar topology-jar-path class ...]
Runs the main method of class with the specified arguments.
The jstorm jars and configs in $JSTORM_CONF_DIR/storm.yaml are put on the classpath.
The process is configured so that StormSubmitter
(https://github.com/alibaba/jstorm/wiki/JStorm-Chinese-Documentation)
will upload the jar at topology-jar-path when the topology is submitted.
"""
childopts = "-Dstorm.jar=" + jarfile + get_client_childopts()
exec_storm_class(
klass,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[jarfile, JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
args=args,
childopts=childopts)
def zktool(*args):
"""Syntax: [jstorm jar topology-jar-path class ...]
Runs the main method of class with the specified arguments.
The jstorm jars and configs in ~/.jstorm are put on the classpath.
The process is configured so that StormSubmitter
(https://github.com/alibaba/jstorm/wiki/JStorm-Chinese-Documentation)
will upload the jar at topology-jar-path when the topology is submitted.
"""
childopts = get_client_childopts()
exec_storm_class(
"com.alibaba.jstorm.zk.ZkTool",
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[ JSTORM_CONF_DIR, CLIENT_CONF_FILE],
args=args,
childopts=childopts)
def kill(*args):
"""Syntax: [jstorm kill topology-name [wait-time-secs]]
Kills the topology with the name topology-name. JStorm will
first deactivate the topology's spouts for the duration of
the topology's message timeout to allow all messages currently
being processed to finish processing. JStorm will then shutdown
the workers and clean up their state. You can override the length
of time JStorm waits between deactivation and shutdown.
"""
childopts = get_client_childopts()
exec_storm_class(
"backtype.storm.command.kill_topology",
args=args,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
childopts=childopts)
def activate(*args):
"""Syntax: [jstorm activate topology-name]
Activates the specified topology's spouts.
"""
childopts = get_client_childopts()
exec_storm_class(
"backtype.storm.command.activate",
args=args,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
childopts=childopts)
def deactivate(*args):
"""Syntax: [jstorm deactivate topology-name]
Deactivates the specified topology's spouts.
"""
childopts = get_client_childopts()
exec_storm_class(
"backtype.storm.command.deactivate",
args=args,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
childopts=childopts)
def rebalance(*args):
"""Syntax: [jstorm rebalance topology-name [-w wait-time-secs]]
Sometimes you may wish to spread out where the workers for a topology
are running. For example, let's say you have a 10 node cluster running
4 workers per node, and then let's say you add another 10 nodes to
the cluster. You may wish to have JStorm spread out the workers for the
running topology so that each node runs 2 workers. One way to do this
is to kill the topology and resubmit it, but JStorm provides a "rebalance"
command that provides an easier way to do this.
Rebalance will first deactivate the topology for the duration of the
message timeout and then redistribute
the workers evenly around the cluster. The topology will then return to
its previous state of activation (so a deactivated topology will still
be deactivated and an activated topology will go back to being activated).
"""
childopts = get_client_childopts()
exec_storm_class(
"backtype.storm.command.rebalance",
args=args,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
childopts=childopts)
def restart(*args):
"""Syntax: [jstorm restart topology-name [conf]]
"""
childopts = get_client_childopts()
exec_storm_class(
"backtype.storm.command.restart",
args=args,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
childopts=childopts)
def update_config(*args):
"""Syntax: [jstorm restart topology-name [conf]]
"""
childopts = get_client_childopts()
exec_storm_class(
"backtype.storm.command.update_config",
args=args,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
childopts=childopts)
def nimbus():
"""Syntax: [jstorm nimbus]
Launches the nimbus daemon. This command should be run under
supervision with a tool like daemontools or monit.
See Setting up a JStorm cluster for more information.
(https://github.com/alibaba/jstorm/wiki/JStorm-Chinese-Documentation)
"""
cppaths = [JSTORM_CONF_DIR]
nimbus_classpath = confvalue("nimbus.classpath", cppaths)
childopts = confvalue("nimbus.childopts", cppaths) + get_server_childopts("nimbus.log")
exec_storm_class(
"com.alibaba.jstorm.daemon.nimbus.NimbusServer",
jvmtype="-server",
extrajars=(cppaths+[nimbus_classpath]),
childopts=childopts)
def supervisor():
"""Syntax: [jstorm supervisor]
Launches the supervisor daemon. This command should be run
under supervision with a tool like daemontools or monit.
See Setting up a JStorm cluster for more information.
(https://github.com/alibaba/jstorm/wiki/JStorm-Chinese-Documentation)
"""
cppaths = [JSTORM_CONF_DIR]
childopts = confvalue("supervisor.childopts", cppaths) + get_server_childopts("supervisor.log")
exec_storm_class(
"com.alibaba.jstorm.daemon.supervisor.Supervisor",
jvmtype="-server",
extrajars=cppaths,
childopts=childopts)
def drpc():
"""Syntax: [jstorm drpc]
Launches a DRPC daemon. This command should be run under supervision
with a tool like daemontools or monit.
See Distributed RPC for more information.
(https://github.com/alibaba/jstorm/wiki/JStorm-Chinese-Documentation)
"""
cppaths = [JSTORM_CONF_DIR]
childopts = confvalue("drpc.childopts", cppaths) + get_server_childopts("drpc.log")
exec_storm_class(
"com.alibaba.jstorm.drpc.Drpc",
jvmtype="-server",
extrajars=cppaths,
childopts=childopts)
def print_classpath():
"""Syntax: [jstorm classpath]
Prints the classpath used by the jstorm client when running commands.
"""
print get_classpath([])
def print_commands():
"""Print all client commands and link to documentation"""
print "jstorm command [--config client_storm.yaml] [--exclude-jars exclude1.jar,exclude2.jar] [-c key1=value1,key2=value2][command parameter]"
print "Commands:\n\t", "\n\t".join(sorted(COMMANDS.keys()))
print "\n\t[--config client_storm.yaml]\t\t\t optional, setting client's storm.yaml"
print "\n\t[--exclude-jars exclude1.jar,exclude2.jar]\t optional, exclude jars, avoid jar conflict"
print "\n\t[-c key1=value1,key2=value2]\t\t\t optional, add key=value pair to configuration"
print "\nHelp:", "\n\thelp", "\n\thelp <command>"
print "\nDocumentation for the jstorm client can be found at https://github.com/alibaba/jstorm/wiki/JStorm-Chinese-Documentation\n"
def print_usage(command=None):
"""Print one help message or list of available commands"""
if command != None:
if COMMANDS.has_key(command):
print (COMMANDS[command].__doc__ or
"No documentation provided for <%s>" % command)
else:
print "<%s> is not a valid command" % command
else:
print_commands()
def unknown_command(*args):
print "Unknown command: [jstorm %s]" % ' '.join(sys.argv[1:])
print_usage()
def metrics_Monitor(*args):
"""Syntax: [jstorm metricsMonitor topologyname bool]
Enable or disable the metrics monitor of one topology.
"""
childopts = get_client_childopts()
exec_storm_class(
"backtype.storm.command.metrics_monitor",
args=args,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
childopts=childopts)
def list(*args):
"""Syntax: [jstorm list]
List cluster information
"""
childopts = get_client_childopts()
exec_storm_class(
"backtype.storm.command.list",
args=args,
jvmtype="-client -Xms256m -Xmx256m",
extrajars=[JSTORM_CONF_DIR, JSTORM_DIR + "/bin", CLIENT_CONF_FILE],
childopts=childopts)
COMMANDS = {"jar": jar, "kill": kill, "nimbus": nimbus, "zktool": zktool,
"drpc": drpc, "supervisor": supervisor, "localconfvalue": print_localconfvalue,
"remoteconfvalue": print_remoteconfvalue, "classpath": print_classpath,
"activate": activate, "deactivate": deactivate, "rebalance": rebalance, "help": print_usage,
"metricsMonitor": metrics_Monitor, "list": list, "restart": restart, "update_config": update_config}
def parse_config(config_list):
global CONFIG_OPTS
if len(config_list) > 0:
for config in config_list:
CONFIG_OPTS.append(config)
def parse_exclude_jars(jars):
global EXCLUDE_JARS
EXCLUDE_JARS = jars.split(",")
print " Excludes jars:"
print EXCLUDE_JARS
def parse_include_jars(jars):
global INCLUDE_JARS
INCLUDE_JARS = jars.split(",")
print " Include jars:"
print INCLUDE_JARS
def parse_config_opts(args):
curr = args[:]
curr.reverse()
config_list = []
args_list = []
while len(curr) > 0:
token = curr.pop()
if token == "-c":
config_list.append(curr.pop())
elif token == "--config":
global CLIENT_CONF_FILE
CLIENT_CONF_FILE = curr.pop()
elif token == "--exclude-jars":
parse_exclude_jars(curr.pop())
elif token == "--include-jars":
parse_include_jars(curr.pop())
else:
args_list.append(token)
return config_list, args_list
def main():
if len(sys.argv) <= 1:
print_usage()
sys.exit(-1)
global CONFIG_OPTS
config_list, args = parse_config_opts(sys.argv[1:])
parse_config(config_list)
COMMAND = args[0]
ARGS = args[1:]
if COMMANDS.get(COMMAND) == None:
unknown_command(COMMAND)
sys.exit(-1)
if len(ARGS) != 0 and ARGS[0] == "help":
print_usage(COMMAND)
sys.exit(0)
try:
(COMMANDS.get(COMMAND, "help"))(*ARGS)
except Exception, msg:
print(msg)
print_usage(COMMAND)
sys.exit(-1)
sys.exit(STATUS)
if __name__ == "__main__":
check_java()
main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
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,
3381,
2647,
15,
1393,
15,
1548,
199,
199,
646,
747,
199,
646,
984,
199,
646,
2196,
199,
646,
3873,
465,
1007,
199,
646,
12733,
199,
199,
318,
8503,
8,
88,
304,
272,
372,
671,
199,
199,
318,
286,
5016,
515,
8,
88,
304,
272,
1414,
275,
2097,
15076,
515,
401,
3905,
14649,
401,
671,
61,
272,
299,
275,
1007,
14,
7942,
8,
1531,
12,
2703,
29,
954,
14,
6089,
9,
272,
1072,
12,
2552,
275,
299,
14,
10664,
342,
272,
2385,
275,
1072,
14,
1294,
4582,
78,
531,
272,
372,
2385,
59,
16,
61,
199,
199,
692,
984,
14,
3246,
508,
298,
16680,
582,
272,
6316,
26977,
275,
286,
5016,
515,
199,
2836,
26,
272,
6316,
26977,
275,
8503,
199,
199,
9901,
63,
3103,
63,
3817,
275,
3087,
199,
42,
840,
8832,
63,
3022,
275,
3286,
1674,
904,
8,
736,
14,
515,
14,
11091,
8,
636,
493,
363,
7092,
1294,
19031,
4439,
18,
566,
199,
42,
840,
8832,
63,
3103,
63,
3022,
275,
747,
14,
12959,
480,
42,
840,
8832,
63,
3103,
63,
3022,
401,
1603,
840,
8832,
63,
3022,
435,
3286,
2190,
2,
776,
199,
4947,
7111,
63,
3103,
275,
1603,
840,
8832,
63,
3103,
63,
3022,
435,
3286,
74,
26949,
14,
793,
894,
14,
1652,
2,
199,
5569,
63,
25636,
275,
942,
199,
1438,
13958,
63,
42,
689,
51,
275,
942,
199,
18171,
63,
42,
689,
51,
275,
942,
199,
6305,
275,
378,
421,
199,
318,
1104,
63,
6138,
837,
272,
1104,
63,
6138,
63,
1760,
275,
283,
6777,
12120,
7,
272,
2203,
275,
747,
14,
2253,
8,
1074,
63,
6138,
63,
1760,
9,
272,
340,
2203,
1137,
378,
26,
267,
870,
480,
4276,
370,
2342,
12120,
12,
8749,
1050,
12120,
370,
15097,
531,
267,
984,
14,
2224,
2801,
17,
9,
199,
199,
318,
664,
63,
888,
63,
3291,
837,
272,
2288,
15869,
63,
25636,
272,
372,
3905,
36,
26949,
14,
1419,
628,
435,
334,
26409,
904,
8,
5569,
63,
25636,
4992,
1814,
360,
1656,
2071,
8530,
5,
531,
199,
199,
318,
664,
63,
1258,
63,
1739,
3291,
837,
272,
2203,
275,
1689,
446,
36,
26949,
14,
1231,
14,
2921,
29,
4531,
12,
2703,
446,
36,
793,
894,
14,
4758,
1173,
628,
435,
1603,
840,
8832,
63,
3022,
435,
1779,
3286,
2190,
15,
1258,
63,
793,
894,
14,
1652,
446,
36,
793,
20,
74,
14,
4758,
29,
1173,
5424,
435,
1603,
840,
8832,
63,
3022,
435,
221,
1779,
3286,
2190,
15,
1258,
63,
793,
20,
74,
14,
3282,
531,
272,
340,
14214,
1309,
63,
3103,
63,
3817,
1137,
10812,
267,
2203,
847,
1689,
446,
36,
26949,
14,
2190,
14,
493,
628,
435,
14214,
1309,
63,
3103,
63,
3817,
9,
272,
372,
2203,
199,
199,
318,
664,
63,
1000,
63,
1739,
3291,
8,
793,
63,
354,
304,
272,
2203,
275,
1689,
446,
36,
12804,
14,
354,
2458,
83,
446,
36,
793,
894,
14,
4758,
1173,
2458,
83,
2,
221,
2818,
793,
63,
354,
12,
5051,
7111,
63,
3103,
430,
272,
372,
2203,
199,
199,
692,
440,
747,
14,
515,
14,
2444,
8,
42,
840,
8832,
63,
3022,
435,
3286,
19736,
2349,
272,
870,
298,
5815,
1801,
538,
2,
272,
870,
298,
1918,
1335,
26949,
1890,
883,
1454,
506,
1255,
687,
4453,
282,
4683,
14,
2047,
7468,
370,
506,
9936,
370,
1255,
314,
1890,
687,
282,
15243,
402,
1603,
933,
1025,
1159,
1350,
1233,
2122,
272,
870,
1867,
78,
5556,
883,
5235,
282,
1603,
933,
1025,
4683,
298,
272,
870,
298,
5815,
1801,
538,
2,
272,
984,
14,
2224,
8,
17,
9,
257,
199,
199,
318,
664,
63,
32262,
63,
2861,
8,
65,
694,
304,
272,
1584,
275,
747,
14,
7374,
8,
65,
694,
9,
272,
2203,
275,
942,
272,
367,
289,
315,
1584,
26,
267,
340,
289,
14,
4130,
9520,
7338,
531,
508,
756,
26,
288,
1980,
267,
2457,
275,
756,
267,
367,
5760,
63,
7338,
315,
3651,
13958,
63,
42,
689,
51,
26,
288,
340,
289,
14,
1623,
8,
5473,
63,
7338,
9,
2356,
378,
26,
355,
2457,
275,
715,
355,
2059,
2728,
340,
2457,
508,
715,
26,
288,
870,
298,
16932,
1133,
1050,
298,
435,
289,
435,
298,
370,
1021,
515,
2,
267,
587,
26,
288,
2203,
14,
740,
8,
65,
694,
435,
10609,
435,
289,
9,
272,
372,
2203,
199,
199,
318,
664,
63,
26977,
8,
2911,
32262,
304,
272,
2203,
275,
942,
272,
2203,
14,
2880,
8,
2911,
32262,
9,
272,
2203,
14,
2880,
8,
362,
63,
32262,
63,
2861,
8,
42,
840,
8832,
63,
3022,
430,
272,
2203,
14,
2880,
8,
362,
63,
32262,
63,
2861,
8,
42,
840,
8832,
63,
3022,
435,
3286,
773,
2237,
272,
2203,
14,
2880,
8,
18171,
63,
42,
689,
51,
9,
2286,
372,
6316,
26977,
20308,
1674,
904,
8,
3292,
430,
199,
199,
318,
3743,
585,
8,
354,
12,
2402,
3771,
304,
272,
1414,
275,
359,
267,
298,
6138,
401,
3905,
1258,
401,
3905,
56,
706,
3912,
77,
401,
3905,
56,
9457,
3912,
77,
401,
664,
63,
888,
63,
3291,
1062,
3905,
1850,
401,
664,
63,
26977,
8,
2911,
3771,
395,
298,
894,
466
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
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,
3381,
2647,
15,
1393,
15,
1548,
199,
199,
646,
747,
199,
646,
984,
199,
646,
2196,
199,
646,
3873,
465,
1007,
199,
646,
12733,
199,
199,
318,
8503,
8,
88,
304,
272,
372,
671,
199,
199,
318,
286,
5016,
515,
8,
88,
304,
272,
1414,
275,
2097,
15076,
515,
401,
3905,
14649,
401,
671,
61,
272,
299,
275,
1007,
14,
7942,
8,
1531,
12,
2703,
29,
954,
14,
6089,
9,
272,
1072,
12,
2552,
275,
299,
14,
10664,
342,
272,
2385,
275,
1072,
14,
1294,
4582,
78,
531,
272,
372,
2385,
59,
16,
61,
199,
199,
692,
984,
14,
3246,
508,
298,
16680,
582,
272,
6316,
26977,
275,
286,
5016,
515,
199,
2836,
26,
272,
6316,
26977,
275,
8503,
199,
199,
9901,
63,
3103,
63,
3817,
275,
3087,
199,
42,
840,
8832,
63,
3022,
275,
3286,
1674,
904,
8,
736,
14,
515,
14,
11091,
8,
636,
493,
363,
7092,
1294,
19031,
4439,
18,
566,
199,
42,
840,
8832,
63,
3103,
63,
3022,
275,
747,
14,
12959,
480,
42,
840,
8832,
63,
3103,
63,
3022,
401,
1603,
840,
8832,
63,
3022,
435,
3286,
2190,
2,
776,
199,
4947,
7111,
63,
3103,
275,
1603,
840,
8832,
63,
3103,
63,
3022,
435,
3286,
74,
26949,
14,
793,
894,
14,
1652,
2,
199,
5569,
63,
25636,
275,
942,
199,
1438,
13958,
63,
42,
689,
51,
275,
942,
199,
18171,
63,
42,
689,
51,
275,
942,
199,
6305,
275,
378,
421,
199,
318,
1104,
63,
6138,
837,
272,
1104,
63,
6138,
63,
1760,
275,
283,
6777,
12120,
7,
272,
2203,
275,
747,
14,
2253,
8,
1074,
63,
6138,
63,
1760,
9,
272,
340,
2203,
1137,
378,
26,
267,
870,
480,
4276,
370,
2342,
12120,
12,
8749,
1050,
12120,
370,
15097,
531,
267,
984,
14,
2224,
2801,
17,
9,
199,
199,
318,
664,
63,
888,
63,
3291,
837,
272,
2288,
15869,
63,
25636,
272,
372,
3905,
36,
26949,
14,
1419,
628,
435,
334,
26409,
904,
8,
5569,
63,
25636,
4992,
1814,
360,
1656,
2071,
8530,
5,
531,
199,
199,
318,
664,
63,
1258,
63,
1739,
3291,
837,
272,
2203,
275,
1689,
446,
36,
26949,
14,
1231,
14,
2921,
29,
4531,
12,
2703,
446,
36,
793,
894,
14,
4758,
1173,
628,
435,
1603,
840,
8832,
63,
3022,
435,
1779,
3286,
2190,
15,
1258,
63,
793,
894,
14,
1652,
446,
36,
793,
20,
74,
14,
4758,
29,
1173,
5424,
435,
1603,
840,
8832,
63,
3022,
435,
221,
1779,
3286,
2190,
15,
1258,
63,
793,
20,
74,
14,
3282,
531,
272,
340,
14214,
1309,
63,
3103,
63,
3817,
1137,
10812,
267,
2203,
847,
1689,
446,
36,
26949,
14,
2190,
14,
493,
628,
435,
14214,
1309,
63,
3103,
63,
3817,
9,
272,
372,
2203,
199,
199,
318,
664,
63,
1000,
63,
1739,
3291,
8,
793,
63,
354,
304,
272,
2203,
275,
1689,
446,
36,
12804,
14,
354,
2458,
83,
446,
36,
793,
894,
14,
4758,
1173,
2458,
83,
2,
221,
2818,
793,
63,
354,
12,
5051,
7111,
63,
3103,
430,
272,
372,
2203,
199,
199,
692,
440,
747,
14,
515,
14,
2444,
8,
42,
840,
8832,
63,
3022,
435,
3286,
19736,
2349,
272,
870,
298,
5815,
1801,
538,
2,
272,
870,
298,
1918,
1335,
26949,
1890,
883,
1454,
506,
1255,
687,
4453,
282,
4683,
14,
2047,
7468,
370,
506,
9936,
370,
1255,
314,
1890,
687,
282,
15243,
402,
1603,
933,
1025,
1159,
1350,
1233,
2122,
272,
870,
1867,
78,
5556,
883,
5235,
282,
1603,
933,
1025,
4683,
298,
272,
870,
298,
5815,
1801,
538,
2,
272,
984,
14,
2224,
8,
17,
9,
257,
199,
199,
318,
664,
63,
32262,
63,
2861,
8,
65,
694,
304,
272,
1584,
275,
747,
14,
7374,
8,
65,
694,
9,
272,
2203,
275,
942,
272,
367,
289,
315,
1584,
26,
267,
340,
289,
14,
4130,
9520,
7338,
531,
508,
756,
26,
288,
1980,
267,
2457,
275,
756,
267,
367,
5760,
63,
7338,
315,
3651,
13958,
63,
42,
689,
51,
26,
288,
340,
289,
14,
1623,
8,
5473,
63,
7338,
9,
2356,
378,
26,
355,
2457,
275,
715,
355,
2059,
2728,
340,
2457,
508,
715,
26,
288,
870,
298,
16932,
1133,
1050,
298,
435,
289,
435,
298,
370,
1021,
515,
2,
267,
587,
26,
288,
2203,
14,
740,
8,
65,
694,
435,
10609,
435,
289,
9,
272,
372,
2203,
199,
199,
318,
664,
63,
26977,
8,
2911,
32262,
304,
272,
2203,
275,
942,
272,
2203,
14,
2880,
8,
2911,
32262,
9,
272,
2203,
14,
2880,
8,
362,
63,
32262,
63,
2861,
8,
42,
840,
8832,
63,
3022,
430,
272,
2203,
14,
2880,
8,
362,
63,
32262,
63,
2861,
8,
42,
840,
8832,
63,
3022,
435,
3286,
773,
2237,
272,
2203,
14,
2880,
8,
18171,
63,
42,
689,
51,
9,
2286,
372,
6316,
26977,
20308,
1674,
904,
8,
3292,
430,
199,
199,
318,
3743,
585,
8,
354,
12,
2402,
3771,
304,
272,
1414,
275,
359,
267,
298,
6138,
401,
3905,
1258,
401,
3905,
56,
706,
3912,
77,
401,
3905,
56,
9457,
3912,
77,
401,
664,
63,
888,
63,
3291,
1062,
3905,
1850,
401,
664,
63,
26977,
8,
2911,
3771,
395,
298,
894,
466,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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id = '4WKYHL-AWUQL4GWA3' # Use your app id
waeo = wap.WolframAlphaEngine(appid,'http://api.wolframalpha.com/v2/query?')
waeq = wap.WolframAlphaQuery(inputsta,appid)
waeq.ScanTimeout = '3.0'
waeq.AddPodState('DifferentialEquationSolution__Step-by-step solution')
waeq.Async = False
waeq.ToURL() # After configuring the waeq must call ToURL()
#print(waeq.Query)
result = waeo.PerformQuery(waeq.Query) # result is in xml format
return result
def WolframPyToJson():
#waeqr = wap.WolframAlphaQueryResult(getFromWolfram())
waeqr = wap.WolframAlphaQueryResult(readFile())
jsonResult = waeqr.JsonResult()
a = jsonResult.decode()
print(a)
print(a[0])
#print(jsonResult.)
print(jsonResult[2])
print(jsonResult[3])
def WolframPy():
#from urllib import request
#url = "http://api.wolframalpha.com/v2/query?input=pi&appid=4WKYHL-AWUQL4GWA3"
#urllib.getproxies()
#fp = request.urlopen(url)
#fp = urllib.urlopen(url)
#data = fp.read()
#f = open('workfile', 'w')
#f.write(data)
#n = int(data)
#giveTheInt = [n]
#print(giveTheInt)
#print(data)
result = getFromWolfram()
#result = readFile()
print(result)
waeqr = wap.WolframAlphaQueryResult(result)
#desktop = XSCRIPTCONTEXT.getDesktop()
#model = desktop.getCurrentComponent()
#if not hasattr(model, "Text"):
# model = desktop.loadComponentFromURL("private:factory/swriter","_blank", 0, () )
#text = model.Text
#cursor = text.createTextCursor()
for pod in waeqr.Pods():
waep = wap.Pod(pod)
xtit = waep.Title()
for u in xtit:
#text.insertString( cursor, u, 0 )
print(u)
if(u=='Plots of sample individual solutions'):
plotSub = waep.Subpods()
for pltpod in plotSub:
spod = wap.Subpod(pltpod)
imgData = spod.Img()
a=dict(imgData.pop())
print(a['src'])
imgurl = a['src']
f = open('00000001.gif','wb')
f.write(urllib.urlopen(imgurl).read())
f.close()
print("done")
#text.insertString( cursor, "Hello World", 0 )
print(waep.Title())
#text.insertString( cursor, "Hello World", 0 )
def getInputFromDoc():
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext )
ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
doc = desktop.getCurrentComponent()
if not hasattr(doc, "Math"):
doc = desktop.loadComponentFromURL( "private:factory/smath","_blank", 0, () )
formula=doc.createInstance("com.sun.star.formula.FormulaProperties")
formula.Formula="int x dx"
#WolframPy()
|
lgpl-3.0
|
[
199,
646,
4011,
199,
646,
336,
439,
199,
199,
318,
1586,
1173,
837,
272,
289,
275,
1551,
360,
3271,
2364,
14,
2424,
297,
283,
82,
358,
272,
522,
275,
289,
14,
739,
342,
272,
372,
522,
199,
199,
318,
664,
2532,
26724,
276,
5975,
837,
272,
1324,
1207,
534,
89,
7709,
89,
29,
16,
7,
272,
1145,
344,
275,
283,
20,
31005,
57,
29210,
13,
15088,
53,
2940,
20,
39,
9004,
19,
7,
327,
3645,
2195,
1145,
1305,
272,
336,
3624,
79,
275,
336,
439,
14,
26724,
276,
5975,
16192,
8524,
8,
571,
344,
2584,
1014,
921,
1246,
14,
28070,
345,
2174,
2914,
14,
957,
15,
86,
18,
15,
1131,
18478,
272,
336,
3624,
81,
275,
336,
439,
14,
26724,
276,
5975,
16192,
3227,
8,
1210,
1207,
12,
571,
344,
9,
272,
336,
3624,
81,
14,
15936,
6372,
275,
283,
19,
14,
16,
7,
272,
336,
3624,
81,
14,
1123,
25928,
2223,
360,
16384,
27257,
27933,
425,
24277,
363,
7801,
13,
991,
13,
2926,
8744,
358,
272,
336,
3624,
81,
14,
12807,
275,
756,
272,
336,
3624,
81,
14,
1378,
2632,
342,
327,
12836,
1101,
4039,
314,
336,
3624,
81,
1471,
1240,
4005,
2632,
342,
272,
327,
1361,
8,
758,
4077,
14,
3227,
9,
272,
754,
275,
336,
3624,
79,
14,
20906,
3227,
8,
758,
4077,
14,
3227,
9,
327,
754,
365,
315,
2748,
1475,
272,
372,
754,
199,
199,
318,
644,
79,
276,
5975,
2713,
1378,
9653,
837,
272,
327,
758,
4077,
82,
275,
336,
439,
14,
26724,
276,
5975,
16192,
3227,
2889,
8,
362,
2532,
26724,
276,
5975,
1012,
272,
336,
3624,
16596,
275,
336,
439,
14,
26724,
276,
5975,
16192,
3227,
2889,
8,
739,
1173,
1012,
272,
2022,
2889,
275,
336,
3624,
16596,
14,
9653,
2889,
342,
272,
282,
275,
2022,
2889,
14,
2708,
342,
272,
870,
8,
65,
9,
272,
870,
8,
65,
59,
16,
566,
272,
327,
1361,
8,
1001,
2889,
4959,
272,
870,
8,
1001,
2889,
59,
18,
566,
272,
870,
8,
1001,
2889,
59,
19,
566,
199,
199,
318,
644,
79,
276,
5975,
2713,
837,
272,
327,
504,
4011,
492,
1056,
23855,
327,
633,
275,
298,
1014,
921,
1246,
14,
28070,
345,
2174,
2914,
14,
957,
15,
86,
18,
15,
1131,
31,
1210,
29,
1038,
6,
571,
344,
29,
20,
31005,
57,
29210,
13,
15088,
53,
2940,
20,
39,
9004,
19,
2,
272,
327,
4078,
14,
362,
17128,
342,
272,
327,
3997,
275,
1056,
14,
10890,
8,
633,
9,
272,
327,
3997,
275,
4011,
14,
10890,
8,
633,
9,
272,
327,
576,
275,
4090,
14,
739,
342,
272,
327,
70,
275,
1551,
360,
800,
493,
297,
283,
87,
358,
272,
327,
70,
14,
952,
8,
576,
9,
272,
327,
78,
275,
1109,
8,
576,
9,
272,
327,
26035,
1918,
3241,
275,
359,
78,
61,
272,
327,
1361,
8,
26035,
1918,
3241,
9,
272,
327,
1361,
8,
576,
9,
2286,
754,
275,
664,
2532,
26724,
276,
5975,
342,
272,
327,
1099,
275,
1586,
1173,
342,
272,
870,
8,
1099,
9,
272,
336,
3624,
16596,
275,
336,
439,
14,
26724,
276,
5975,
16192,
3227,
2889,
8,
1099,
9,
272,
327,
14487,
275,
1323,
10484,
9059,
14,
362,
20436,
342,
272,
327,
1238,
275,
19763,
14,
16662,
7004,
342,
272,
327,
692,
440,
2688,
8,
1238,
12,
298,
1872,
2349,
272,
327,
259,
1402,
275,
19763,
14,
912,
7004,
2532,
2632,
480,
4239,
26,
3702,
15,
83,
5491,
2266,
63,
2500,
401,
378,
12,
6248,
776,
272,
327,
505,
275,
1402,
14,
1872,
272,
327,
3937,
275,
1318,
14,
981,
1872,
8993,
342,
272,
367,
15329,
315,
336,
3624,
16596,
14,
25928,
83,
837,
267,
14442,
1545,
275,
336,
439,
14,
25928,
8,
12656,
9,
267,
671,
6403,
275,
14442,
1545,
14,
6888,
342,
267,
367,
399,
315,
671,
6403,
26,
288,
327,
505,
14,
3176,
1558,
8,
3920,
12,
399,
12,
378,
776,
288,
870,
8,
85,
9,
288,
340,
8,
85,
6803,
48,
4555,
402,
2690,
8212,
24886,
735,
355,
5137,
2610,
275,
14442,
1545,
14,
2610,
12656,
83,
342,
355,
367,
1620,
683,
364,
315,
5137,
2610,
26,
490,
2249,
364,
275,
336,
439,
14,
2610,
12656,
8,
1168,
683,
364,
9,
490,
6050,
1451,
275,
2249,
364,
14,
27261,
342,
490,
282,
29,
807,
8,
4060,
1451,
14,
1935,
1012,
490,
870,
8,
65,
459,
2164,
1105,
490,
6050,
633,
275,
282,
459,
2164,
418,
490,
289,
275,
1551,
360,
23848,
14,
14513,
1673,
6603,
358,
490,
289,
14,
952,
8,
4078,
14,
10890,
8,
4060,
633,
680,
739,
1012,
490,
289,
14,
1600,
342,
490,
870,
480,
4456,
531,
2151,
267,
327,
505,
14,
3176,
1558,
8,
3920,
12,
298,
6257,
13064,
401,
378,
776,
267,
870,
8,
758,
1545,
14,
6888,
1012,
272,
327,
505,
14,
3176,
1558,
8,
3920,
12,
298,
6257,
13064,
401,
378,
776,
199,
199,
318,
664,
3205,
2532,
3768,
837,
272,
2257,
2998,
275,
625,
79,
14,
362,
7004,
2998,
342,
272,
15611,
275,
2257,
2998,
14,
3167,
2988,
14,
981,
3244,
3007,
2998,
480,
957,
14,
11846,
14,
7848,
14,
9528,
14,
53,
889,
6417,
12407,
401,
2257,
2998,
776,
272,
4027,
275,
15611,
14,
6983,
8,
298,
324,
79,
26,
3450,
12,
1102,
29,
5967,
12,
719,
29,
15135,
27,
300,
80,
27,
23197,
31166,
14,
7004,
2998,
2,
776,
272,
4383,
2587,
275,
4027,
14,
3167,
2988,
272,
19763,
275,
4383,
2587,
14,
981,
3244,
3007,
2998,
8,
298,
957,
14,
11846,
14,
7848,
14,
1943,
14,
20436,
401,
3799,
9,
272,
1382,
275,
19763,
14,
16662,
7004,
342,
272,
340,
440,
2688,
8,
1301,
12,
298,
18568,
2349,
267,
1382,
275,
19763,
14,
912,
7004,
2532,
2632,
8,
298,
4239,
26,
3702,
15,
83,
3442,
2266,
63,
2500,
401,
378,
12,
6248,
776,
272,
15723,
29,
1301,
14,
981,
3244,
480,
957,
14,
11846,
14,
7848,
14,
16798,
14,
28533,
8516,
531,
272,
15723,
14,
28533,
628,
442,
671,
11868,
2,
199,
3,
26724,
276,
5975,
2713,
342,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
646,
4011,
199,
646,
336,
439,
199,
199,
318,
1586,
1173,
837,
272,
289,
275,
1551,
360,
3271,
2364,
14,
2424,
297,
283,
82,
358,
272,
522,
275,
289,
14,
739,
342,
272,
372,
522,
199,
199,
318,
664,
2532,
26724,
276,
5975,
837,
272,
1324,
1207,
534,
89,
7709,
89,
29,
16,
7,
272,
1145,
344,
275,
283,
20,
31005,
57,
29210,
13,
15088,
53,
2940,
20,
39,
9004,
19,
7,
327,
3645,
2195,
1145,
1305,
272,
336,
3624,
79,
275,
336,
439,
14,
26724,
276,
5975,
16192,
8524,
8,
571,
344,
2584,
1014,
921,
1246,
14,
28070,
345,
2174,
2914,
14,
957,
15,
86,
18,
15,
1131,
18478,
272,
336,
3624,
81,
275,
336,
439,
14,
26724,
276,
5975,
16192,
3227,
8,
1210,
1207,
12,
571,
344,
9,
272,
336,
3624,
81,
14,
15936,
6372,
275,
283,
19,
14,
16,
7,
272,
336,
3624,
81,
14,
1123,
25928,
2223,
360,
16384,
27257,
27933,
425,
24277,
363,
7801,
13,
991,
13,
2926,
8744,
358,
272,
336,
3624,
81,
14,
12807,
275,
756,
272,
336,
3624,
81,
14,
1378,
2632,
342,
327,
12836,
1101,
4039,
314,
336,
3624,
81,
1471,
1240,
4005,
2632,
342,
272,
327,
1361,
8,
758,
4077,
14,
3227,
9,
272,
754,
275,
336,
3624,
79,
14,
20906,
3227,
8,
758,
4077,
14,
3227,
9,
327,
754,
365,
315,
2748,
1475,
272,
372,
754,
199,
199,
318,
644,
79,
276,
5975,
2713,
1378,
9653,
837,
272,
327,
758,
4077,
82,
275,
336,
439,
14,
26724,
276,
5975,
16192,
3227,
2889,
8,
362,
2532,
26724,
276,
5975,
1012,
272,
336,
3624,
16596,
275,
336,
439,
14,
26724,
276,
5975,
16192,
3227,
2889,
8,
739,
1173,
1012,
272,
2022,
2889,
275,
336,
3624,
16596,
14,
9653,
2889,
342,
272,
282,
275,
2022,
2889,
14,
2708,
342,
272,
870,
8,
65,
9,
272,
870,
8,
65,
59,
16,
566,
272,
327,
1361,
8,
1001,
2889,
4959,
272,
870,
8,
1001,
2889,
59,
18,
566,
272,
870,
8,
1001,
2889,
59,
19,
566,
199,
199,
318,
644,
79,
276,
5975,
2713,
837,
272,
327,
504,
4011,
492,
1056,
23855,
327,
633,
275,
298,
1014,
921,
1246,
14,
28070,
345,
2174,
2914,
14,
957,
15,
86,
18,
15,
1131,
31,
1210,
29,
1038,
6,
571,
344,
29,
20,
31005,
57,
29210,
13,
15088,
53,
2940,
20,
39,
9004,
19,
2,
272,
327,
4078,
14,
362,
17128,
342,
272,
327,
3997,
275,
1056,
14,
10890,
8,
633,
9,
272,
327,
3997,
275,
4011,
14,
10890,
8,
633,
9,
272,
327,
576,
275,
4090,
14,
739,
342,
272,
327,
70,
275,
1551,
360,
800,
493,
297,
283,
87,
358,
272,
327,
70,
14,
952,
8,
576,
9,
272,
327,
78,
275,
1109,
8,
576,
9,
272,
327,
26035,
1918,
3241,
275,
359,
78,
61,
272,
327,
1361,
8,
26035,
1918,
3241,
9,
272,
327,
1361,
8,
576,
9,
2286,
754,
275,
664,
2532,
26724,
276,
5975,
342,
272,
327,
1099,
275,
1586,
1173,
342,
272,
870,
8,
1099,
9,
272,
336,
3624,
16596,
275,
336,
439,
14,
26724,
276,
5975,
16192,
3227,
2889,
8,
1099,
9,
272,
327,
14487,
275,
1323,
10484,
9059,
14,
362,
20436,
342,
272,
327,
1238,
275,
19763,
14,
16662,
7004,
342,
272,
327,
692,
440,
2688,
8,
1238,
12,
298,
1872,
2349,
272,
327,
259,
1402,
275,
19763,
14,
912,
7004,
2532,
2632,
480,
4239,
26,
3702,
15,
83,
5491,
2266,
63,
2500,
401,
378,
12,
6248,
776,
272,
327,
505,
275,
1402,
14,
1872,
272,
327,
3937,
275,
1318,
14,
981,
1872,
8993,
342,
272,
367,
15329,
315,
336,
3624,
16596,
14,
25928,
83,
837,
267,
14442,
1545,
275,
336,
439,
14,
25928,
8,
12656,
9,
267,
671,
6403,
275,
14442,
1545,
14,
6888,
342,
267,
367,
399,
315,
671,
6403,
26,
288,
327,
505,
14,
3176,
1558,
8,
3920,
12,
399,
12,
378,
776,
288,
870,
8,
85,
9,
288,
340,
8,
85,
6803,
48,
4555,
402,
2690,
8212,
24886,
735,
355,
5137,
2610,
275,
14442,
1545,
14,
2610,
12656,
83,
342,
355,
367,
1620,
683,
364,
315,
5137,
2610,
26,
490,
2249,
364,
275,
336,
439,
14,
2610,
12656,
8,
1168,
683,
364,
9,
490,
6050,
1451,
275,
2249,
364,
14,
27261,
342,
490,
282,
29,
807,
8,
4060,
1451,
14,
1935,
1012,
490,
870,
8,
65,
459,
2164,
1105,
490,
6050,
633,
275,
282,
459,
2164,
418,
490,
289,
275,
1551,
360,
23848,
14,
14513,
1673,
6603,
358,
490,
289,
14,
952,
8,
4078,
14,
10890,
8,
4060,
633,
680,
739,
1012,
490,
289,
14,
1600,
342,
490,
870,
480,
4456,
531,
2151,
267,
327,
505,
14,
3176,
1558,
8,
3920,
12,
298,
6257,
13064,
401,
378,
776,
267,
870,
8,
758,
1545,
14,
6888,
1012,
272,
327,
505,
14,
3176,
1558,
8,
3920,
12,
298,
6257,
13064,
401,
378,
776,
199,
199,
318,
664,
3205,
2532,
3768,
837,
272,
2257,
2998,
275,
625,
79,
14,
362,
7004,
2998,
342,
272,
15611,
275,
2257,
2998,
14,
3167,
2988,
14,
981,
3244,
3007,
2998,
480,
957,
14,
11846,
14,
7848,
14,
9528,
14,
53,
889,
6417,
12407,
401,
2257,
2998,
776,
272,
4027,
275,
15611,
14,
6983,
8,
298,
324,
79,
26,
3450,
12,
1102,
29,
5967,
12,
719,
29,
15135,
27,
300,
80,
27,
23197,
31166,
14,
7004,
2998,
2,
776,
272,
4383,
2587,
275,
4027,
14,
3167,
2988,
272,
19763,
275,
4383,
2587,
14,
981,
3244,
3007,
2998,
8,
298,
957,
14,
11846,
14,
7848,
14,
1943,
14,
20436,
401,
3799,
9,
272,
1382,
275,
19763,
14,
16662,
7004,
342,
272,
340,
440,
2688,
8,
1301,
12,
298,
18568,
2349,
267,
1382,
275,
19763,
14,
912,
7004,
2532,
2632,
8,
298,
4239,
26,
3702,
15,
83,
3442,
2266,
63,
2500,
401,
378,
12,
6248,
776,
272,
15723,
29,
1301,
14,
981,
3244,
480,
957,
14,
11846,
14,
7848,
14,
16798,
14,
28533,
8516,
531,
272,
15723,
14,
28533,
628,
442,
671,
11868,
2,
199,
3,
26724,
276,
5975,
2713,
342,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
eyohansa/django
|
tests/urlpatterns_reverse/urls.py
|
199
|
5421
|
import warnings
from django.conf.urls import include, patterns, url
from django.utils.deprecation import RemovedInDjango110Warning
from .views import (
absolute_kwargs_view, defaults_view, empty_view, empty_view_partial,
empty_view_wrapped, nested_view,
)
other_patterns = [
url(r'non_path_include/$', empty_view, name='non_path_include'),
url(r'nested_path/$', nested_view),
]
# test deprecated patterns() function. convert to list of urls() in Django 1.10
with warnings.catch_warnings():
warnings.filterwarnings('ignore', category=RemovedInDjango110Warning)
urlpatterns = patterns('',
url(r'^places/([0-9]+)/$', empty_view, name='places'),
url(r'^places?/$', empty_view, name="places?"),
url(r'^places+/$', empty_view, name="places+"),
url(r'^places*/$', empty_view, name="places*"),
url(r'^(?:places/)?$', empty_view, name="places2?"),
url(r'^(?:places/)+$', empty_view, name="places2+"),
url(r'^(?:places/)*$', empty_view, name="places2*"),
url(r'^places/([0-9]+|[a-z_]+)/', empty_view, name="places3"),
url(r'^places/(?P<id>[0-9]+)/$', empty_view, name="places4"),
url(r'^people/(?P<name>\w+)/$', empty_view, name="people"),
url(r'^people/(?:name/)', empty_view, name="people2"),
url(r'^people/(?:name/(\w+)/)?', empty_view, name="people2a"),
url(r'^people/(?P<name>\w+)-(?P=name)/$', empty_view, name="people_backref"),
url(r'^optional/(?P<name>.*)/(?:.+/)?', empty_view, name="optional"),
url(r'^optional/(?P<arg1>\d+)/(?:(?P<arg2>\d+)/)?', absolute_kwargs_view, name="named_optional"),
url(r'^optional/(?P<arg1>\d+)/(?:(?P<arg2>\d+)/)?$', absolute_kwargs_view, name="named_optional_terminated"),
url(r'^nested/noncapture/(?:(?P<p>\w+))$', empty_view, name='nested-noncapture'),
url(r'^nested/capture/((\w+)/)?$', empty_view, name='nested-capture'),
url(r'^nested/capture/mixed/((?P<p>\w+))$', empty_view, name='nested-mixedcapture'),
url(r'^nested/capture/named/(?P<outer>(?P<inner>\w+)/)?$', empty_view, name='nested-namedcapture'),
url(r'^hardcoded/$', empty_view, name="hardcoded"),
url(r'^hardcoded/doc\.pdf$', empty_view, name="hardcoded2"),
url(r'^people/(?P<state>\w\w)/(?P<name>\w+)/$', empty_view, name="people3"),
url(r'^people/(?P<state>\w\w)/(?P<name>[0-9])/$', empty_view, name="people4"),
url(r'^people/((?P<state>\w\w)/test)?/(\w+)/$', empty_view, name="people6"),
url(r'^character_set/[abcdef0-9]/$', empty_view, name="range"),
url(r'^character_set/[\w]/$', empty_view, name="range2"),
url(r'^price/\$([0-9]+)/$', empty_view, name="price"),
url(r'^price/[$]([0-9]+)/$', empty_view, name="price2"),
url(r'^price/[\$]([0-9]+)/$', empty_view, name="price3"),
url(r'^product/(?P<product>\w+)\+\(\$(?P<price>[0-9]+(\.[0-9]+)?)\)/$', empty_view, name="product"),
url(r'^headlines/(?P<year>[0-9]+)\.(?P<month>[0-9]+)\.(?P<day>[0-9]+)/$', empty_view, name="headlines"),
url(r'^windows_path/(?P<drive_name>[A-Z]):\\(?P<path>.+)/$', empty_view, name="windows"),
url(r'^special_chars/(?P<chars>.+)/$', empty_view, name="special"),
url(r'^(?P<name>.+)/[0-9]+/$', empty_view, name="mixed"),
url(r'^repeats/a{1,2}/$', empty_view, name="repeats"),
url(r'^repeats/a{2,4}/$', empty_view, name="repeats2"),
url(r'^repeats/a{2}/$', empty_view, name="repeats3"),
url(r'^(?i)CaseInsensitive/(\w+)', empty_view, name="insensitive"),
url(r'^test/1/?', empty_view, name="test"),
url(r'^(?i)test/2/?$', empty_view, name="test2"),
url(r'^outer/(?P<outer>[0-9]+)/', include('urlpatterns_reverse.included_urls')),
url(r'^outer-no-kwargs/([0-9]+)/', include('urlpatterns_reverse.included_no_kwargs_urls')),
url('', include('urlpatterns_reverse.extra_urls')),
url(r'^lookahead-/(?!not-a-city)(?P<city>[^/]+)/$', empty_view, name='lookahead-negative'),
url(r'^lookahead\+/(?=a-city)(?P<city>[^/]+)/$', empty_view, name='lookahead-positive'),
url(r'^lookbehind-/(?P<city>[^/]+)(?<!not-a-city)/$', empty_view, name='lookbehind-negative'),
url(r'^lookbehind\+/(?P<city>[^/]+)(?<=a-city)/$', empty_view, name='lookbehind-positive'),
# Partials should be fine.
url(r'^partial/', empty_view_partial, name="partial"),
url(r'^partial_wrapped/', empty_view_wrapped, name="partial_wrapped"),
# This is non-reversible, but we shouldn't blow up when parsing it.
url(r'^(?:foo|bar)(\w+)/$', empty_view, name="disjunction"),
# Regression views for #9038. See tests for more details
url(r'arg_view/$', 'urlpatterns_reverse.views.kwargs_view'),
url(r'arg_view/(?P<arg1>[0-9]+)/$', 'urlpatterns_reverse.views.kwargs_view'),
url(r'absolute_arg_view/(?P<arg1>[0-9]+)/$', absolute_kwargs_view),
url(r'absolute_arg_view/$', absolute_kwargs_view),
# Tests for #13154. Mixed syntax to test both ways of defining URLs.
url(r'defaults_view1/(?P<arg1>[0-9]+)/', defaults_view, {'arg2': 1}, name='defaults'),
(r'defaults_view2/(?P<arg1>[0-9]+)/', defaults_view, {'arg2': 2}, 'defaults'),
url('^includes/', include(other_patterns)),
# Security tests
url('(.+)/security/$', empty_view, name='security'),
)
|
bsd-3-clause
|
[
646,
3598,
199,
199,
504,
1639,
14,
2190,
14,
3603,
492,
2387,
12,
7970,
12,
1166,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
199,
504,
1275,
4196,
492,
334,
272,
3679,
63,
958,
63,
1345,
12,
4243,
63,
1345,
12,
2701,
63,
1345,
12,
2701,
63,
1345,
63,
6672,
12,
272,
2701,
63,
1345,
63,
9130,
12,
6032,
63,
1345,
12,
199,
9,
199,
199,
1848,
63,
7435,
275,
359,
272,
1166,
8,
82,
7,
2865,
63,
515,
63,
2613,
10884,
2701,
63,
1345,
12,
536,
534,
2865,
63,
515,
63,
2613,
659,
272,
1166,
8,
82,
7,
6376,
63,
515,
10884,
6032,
63,
1345,
395,
199,
61,
199,
199,
3,
511,
5906,
7970,
342,
805,
14,
3957,
370,
769,
402,
8187,
342,
315,
5634,
413,
14,
709,
199,
1045,
3598,
14,
9341,
63,
5451,
837,
272,
3598,
14,
23945,
360,
4247,
297,
4637,
29,
497,
19797,
6019,
3849,
9,
339,
26177,
275,
7970,
8594,
267,
1166,
8,
82,
4289,
10696,
15,
779,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
534,
10696,
659,
267,
1166,
8,
82,
4289,
10696,
31,
10884,
2701,
63,
1345,
12,
536,
628,
10696,
31,
1288,
267,
1166,
8,
82,
4289,
10696,
11,
10884,
2701,
63,
1345,
12,
536,
628,
10696,
11,
1288,
267,
1166,
8,
82,
4289,
10696,
10,
10884,
2701,
63,
1345,
12,
536,
628,
10696,
10,
1288,
267,
1166,
8,
82,
4289,
5169,
10696,
15,
5547,
4268,
2701,
63,
1345,
12,
536,
628,
10696,
18,
31,
1288,
267,
1166,
8,
82,
4289,
5169,
10696,
15,
6393,
4268,
2701,
63,
1345,
12,
536,
628,
10696,
18,
11,
1288,
267,
1166,
8,
82,
4289,
5169,
10696,
15,
3342,
4268,
2701,
63,
1345,
12,
536,
628,
10696,
18,
10,
1288,
267,
1166,
8,
82,
4289,
10696,
15,
779,
16,
13,
25,
2807,
17884,
65,
13,
90,
22155,
2447,
297,
2701,
63,
1345,
12,
536,
628,
10696,
19,
1288,
267,
1166,
8,
82,
4289,
10696,
9448,
48,
28,
344,
9514,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
10696,
20,
1288,
267,
1166,
8,
82,
4289,
13562,
9448,
48,
28,
354,
3072,
87,
18830,
4268,
2701,
63,
1345,
12,
536,
628,
13562,
1288,
267,
1166,
8,
82,
4289,
13562,
32576,
354,
15,
3196,
2701,
63,
1345,
12,
536,
628,
13562,
18,
1288,
267,
1166,
8,
82,
4289,
13562,
32576,
354,
15,
2961,
87,
18830,
5547,
297,
2701,
63,
1345,
12,
536,
628,
13562,
18,
65,
1288,
267,
1166,
8,
82,
4289,
13562,
9448,
48,
28,
354,
3072,
87,
11,
7216,
2229,
48,
29,
354,
2447,
4268,
2701,
63,
1345,
12,
536,
628,
13562,
63,
894,
1121,
1288,
267,
1166,
8,
82,
4289,
4144,
9448,
48,
28,
354,
23742,
2447,
5169,
6977,
15,
5547,
297,
2701,
63,
1345,
12,
536,
628,
4144,
1288,
267,
1166,
8,
82,
4289,
4144,
9448,
48,
28,
1273,
17,
3072,
68,
18830,
5169,
2229,
48,
28,
1273,
18,
3072,
68,
18830,
5547,
297,
3679,
63,
958,
63,
1345,
12,
536,
628,
4579,
63,
4144,
1288,
267,
1166,
8,
82,
4289,
4144,
9448,
48,
28,
1273,
17,
3072,
68,
18830,
5169,
2229,
48,
28,
1273,
18,
3072,
68,
18830,
5547,
4268,
3679,
63,
958,
63,
1345,
12,
536,
628,
4579,
63,
4144,
63,
18375,
1288,
267,
1166,
8,
82,
4289,
6376,
15,
2865,
12685,
32576,
2229,
48,
28,
80,
3072,
87,
11,
430,
4268,
2701,
63,
1345,
12,
536,
534,
6376,
13,
2865,
12685,
659,
267,
1166,
8,
82,
4289,
6376,
15,
12685,
15,
1332,
60,
87,
18830,
5547,
4268,
2701,
63,
1345,
12,
536,
534,
6376,
13,
12685,
659,
267,
1166,
8,
82,
4289,
6376,
15,
12685,
15,
10455,
15,
17304,
48,
28,
80,
3072,
87,
11,
430,
4268,
2701,
63,
1345,
12,
536,
534,
6376,
13,
10455,
12685,
659,
267,
1166,
8,
82,
4289,
6376,
15,
12685,
15,
4579,
9448,
48,
28,
7837,
30,
2229,
48,
28,
5216,
3072,
87,
18830,
5547,
4268,
2701,
63,
1345,
12,
536,
534,
6376,
13,
4579,
12685,
659,
267,
1166,
8,
82,
4289,
8726,
15282,
10884,
2701,
63,
1345,
12,
536,
628,
8726,
15282,
1288,
267,
1166,
8,
82,
4289,
8726,
15282,
15,
1301,
4537,
5607,
4268,
2701,
63,
1345,
12,
536,
628,
8726,
15282,
18,
1288,
267,
1166,
8,
82,
4289,
13562,
9448,
48,
28,
929,
3072,
87,
60,
87,
2447,
2229,
48,
28,
354,
3072,
87,
18830,
4268,
2701,
63,
1345,
12,
536,
628,
13562,
19,
1288,
267,
1166,
8,
82,
4289,
13562,
9448,
48,
28,
929,
3072,
87,
60,
87,
2447,
2229,
48,
28,
354,
9514,
16,
13,
25,
566,
10884,
2701,
63,
1345,
12,
536,
628,
13562,
20,
1288,
267,
1166,
8,
82,
4289,
13562,
15,
17304,
48,
28,
929,
3072,
87,
60,
87,
2447,
396,
5547,
15,
2961,
87,
18830,
4268,
2701,
63,
1345,
12,
536,
628,
13562,
22,
1288,
267,
1166,
8,
82,
4289,
10856,
63,
409,
32418,
10678,
16,
13,
25,
61,
10884,
2701,
63,
1345,
12,
536,
628,
1842,
1288,
267,
1166,
8,
82,
4289,
10856,
63,
409,
15,
7023,
87,
61,
10884,
2701,
63,
1345,
12,
536,
628,
1842,
18,
1288,
267,
1166,
8,
82,
4289,
4777,
6307,
4,
779,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
4777,
1288,
267,
1166,
8,
82,
4289,
4777,
32418,
4,
61,
779,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
4777,
18,
1288,
267,
1166,
8,
82,
4289,
4777,
15,
7023,
4,
61,
779,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
4777,
19,
1288,
267,
1166,
8,
82,
4289,
2558,
9448,
48,
28,
2558,
3072,
87,
13439,
7896,
2961,
4,
2229,
48,
28,
4777,
9514,
16,
13,
25,
2807,
2961,
24097,
16,
13,
25,
23763,
2862,
2447,
4268,
2701,
63,
1345,
12,
536,
628,
2558,
1288,
267,
1166,
8,
82,
4289,
2993,
1278,
9448,
48,
28,
3403,
9514,
16,
13,
25,
18096,
14,
2229,
48,
28,
4482,
9514,
16,
13,
25,
18096,
14,
2229,
48,
28,
2977,
9514,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
2993,
1278,
1288,
267,
1166,
8,
82,
4289,
8258,
63,
515,
9448,
48,
28,
9541,
63,
354,
9514,
33,
13,
58,
4682,
1103
] |
[
3598,
199,
199,
504,
1639,
14,
2190,
14,
3603,
492,
2387,
12,
7970,
12,
1166,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
199,
504,
1275,
4196,
492,
334,
272,
3679,
63,
958,
63,
1345,
12,
4243,
63,
1345,
12,
2701,
63,
1345,
12,
2701,
63,
1345,
63,
6672,
12,
272,
2701,
63,
1345,
63,
9130,
12,
6032,
63,
1345,
12,
199,
9,
199,
199,
1848,
63,
7435,
275,
359,
272,
1166,
8,
82,
7,
2865,
63,
515,
63,
2613,
10884,
2701,
63,
1345,
12,
536,
534,
2865,
63,
515,
63,
2613,
659,
272,
1166,
8,
82,
7,
6376,
63,
515,
10884,
6032,
63,
1345,
395,
199,
61,
199,
199,
3,
511,
5906,
7970,
342,
805,
14,
3957,
370,
769,
402,
8187,
342,
315,
5634,
413,
14,
709,
199,
1045,
3598,
14,
9341,
63,
5451,
837,
272,
3598,
14,
23945,
360,
4247,
297,
4637,
29,
497,
19797,
6019,
3849,
9,
339,
26177,
275,
7970,
8594,
267,
1166,
8,
82,
4289,
10696,
15,
779,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
534,
10696,
659,
267,
1166,
8,
82,
4289,
10696,
31,
10884,
2701,
63,
1345,
12,
536,
628,
10696,
31,
1288,
267,
1166,
8,
82,
4289,
10696,
11,
10884,
2701,
63,
1345,
12,
536,
628,
10696,
11,
1288,
267,
1166,
8,
82,
4289,
10696,
10,
10884,
2701,
63,
1345,
12,
536,
628,
10696,
10,
1288,
267,
1166,
8,
82,
4289,
5169,
10696,
15,
5547,
4268,
2701,
63,
1345,
12,
536,
628,
10696,
18,
31,
1288,
267,
1166,
8,
82,
4289,
5169,
10696,
15,
6393,
4268,
2701,
63,
1345,
12,
536,
628,
10696,
18,
11,
1288,
267,
1166,
8,
82,
4289,
5169,
10696,
15,
3342,
4268,
2701,
63,
1345,
12,
536,
628,
10696,
18,
10,
1288,
267,
1166,
8,
82,
4289,
10696,
15,
779,
16,
13,
25,
2807,
17884,
65,
13,
90,
22155,
2447,
297,
2701,
63,
1345,
12,
536,
628,
10696,
19,
1288,
267,
1166,
8,
82,
4289,
10696,
9448,
48,
28,
344,
9514,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
10696,
20,
1288,
267,
1166,
8,
82,
4289,
13562,
9448,
48,
28,
354,
3072,
87,
18830,
4268,
2701,
63,
1345,
12,
536,
628,
13562,
1288,
267,
1166,
8,
82,
4289,
13562,
32576,
354,
15,
3196,
2701,
63,
1345,
12,
536,
628,
13562,
18,
1288,
267,
1166,
8,
82,
4289,
13562,
32576,
354,
15,
2961,
87,
18830,
5547,
297,
2701,
63,
1345,
12,
536,
628,
13562,
18,
65,
1288,
267,
1166,
8,
82,
4289,
13562,
9448,
48,
28,
354,
3072,
87,
11,
7216,
2229,
48,
29,
354,
2447,
4268,
2701,
63,
1345,
12,
536,
628,
13562,
63,
894,
1121,
1288,
267,
1166,
8,
82,
4289,
4144,
9448,
48,
28,
354,
23742,
2447,
5169,
6977,
15,
5547,
297,
2701,
63,
1345,
12,
536,
628,
4144,
1288,
267,
1166,
8,
82,
4289,
4144,
9448,
48,
28,
1273,
17,
3072,
68,
18830,
5169,
2229,
48,
28,
1273,
18,
3072,
68,
18830,
5547,
297,
3679,
63,
958,
63,
1345,
12,
536,
628,
4579,
63,
4144,
1288,
267,
1166,
8,
82,
4289,
4144,
9448,
48,
28,
1273,
17,
3072,
68,
18830,
5169,
2229,
48,
28,
1273,
18,
3072,
68,
18830,
5547,
4268,
3679,
63,
958,
63,
1345,
12,
536,
628,
4579,
63,
4144,
63,
18375,
1288,
267,
1166,
8,
82,
4289,
6376,
15,
2865,
12685,
32576,
2229,
48,
28,
80,
3072,
87,
11,
430,
4268,
2701,
63,
1345,
12,
536,
534,
6376,
13,
2865,
12685,
659,
267,
1166,
8,
82,
4289,
6376,
15,
12685,
15,
1332,
60,
87,
18830,
5547,
4268,
2701,
63,
1345,
12,
536,
534,
6376,
13,
12685,
659,
267,
1166,
8,
82,
4289,
6376,
15,
12685,
15,
10455,
15,
17304,
48,
28,
80,
3072,
87,
11,
430,
4268,
2701,
63,
1345,
12,
536,
534,
6376,
13,
10455,
12685,
659,
267,
1166,
8,
82,
4289,
6376,
15,
12685,
15,
4579,
9448,
48,
28,
7837,
30,
2229,
48,
28,
5216,
3072,
87,
18830,
5547,
4268,
2701,
63,
1345,
12,
536,
534,
6376,
13,
4579,
12685,
659,
267,
1166,
8,
82,
4289,
8726,
15282,
10884,
2701,
63,
1345,
12,
536,
628,
8726,
15282,
1288,
267,
1166,
8,
82,
4289,
8726,
15282,
15,
1301,
4537,
5607,
4268,
2701,
63,
1345,
12,
536,
628,
8726,
15282,
18,
1288,
267,
1166,
8,
82,
4289,
13562,
9448,
48,
28,
929,
3072,
87,
60,
87,
2447,
2229,
48,
28,
354,
3072,
87,
18830,
4268,
2701,
63,
1345,
12,
536,
628,
13562,
19,
1288,
267,
1166,
8,
82,
4289,
13562,
9448,
48,
28,
929,
3072,
87,
60,
87,
2447,
2229,
48,
28,
354,
9514,
16,
13,
25,
566,
10884,
2701,
63,
1345,
12,
536,
628,
13562,
20,
1288,
267,
1166,
8,
82,
4289,
13562,
15,
17304,
48,
28,
929,
3072,
87,
60,
87,
2447,
396,
5547,
15,
2961,
87,
18830,
4268,
2701,
63,
1345,
12,
536,
628,
13562,
22,
1288,
267,
1166,
8,
82,
4289,
10856,
63,
409,
32418,
10678,
16,
13,
25,
61,
10884,
2701,
63,
1345,
12,
536,
628,
1842,
1288,
267,
1166,
8,
82,
4289,
10856,
63,
409,
15,
7023,
87,
61,
10884,
2701,
63,
1345,
12,
536,
628,
1842,
18,
1288,
267,
1166,
8,
82,
4289,
4777,
6307,
4,
779,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
4777,
1288,
267,
1166,
8,
82,
4289,
4777,
32418,
4,
61,
779,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
4777,
18,
1288,
267,
1166,
8,
82,
4289,
4777,
15,
7023,
4,
61,
779,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
4777,
19,
1288,
267,
1166,
8,
82,
4289,
2558,
9448,
48,
28,
2558,
3072,
87,
13439,
7896,
2961,
4,
2229,
48,
28,
4777,
9514,
16,
13,
25,
2807,
2961,
24097,
16,
13,
25,
23763,
2862,
2447,
4268,
2701,
63,
1345,
12,
536,
628,
2558,
1288,
267,
1166,
8,
82,
4289,
2993,
1278,
9448,
48,
28,
3403,
9514,
16,
13,
25,
18096,
14,
2229,
48,
28,
4482,
9514,
16,
13,
25,
18096,
14,
2229,
48,
28,
2977,
9514,
16,
13,
25,
24598,
4268,
2701,
63,
1345,
12,
536,
628,
2993,
1278,
1288,
267,
1166,
8,
82,
4289,
8258,
63,
515,
9448,
48,
28,
9541,
63,
354,
9514,
33,
13,
58,
4682,
1103,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
brandondrew/bigcouch
|
couchjs/scons/scons-local-2.0.1/SCons/Tool/rmic.py
|
61
|
4138
|
"""SCons.Tool.rmic
Tool-specific initialization for rmic.
There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""
#
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__revision__ = "src/engine/SCons/Tool/rmic.py 5134 2010/08/16 23:02:40 bdeegan"
import os.path
import SCons.Action
import SCons.Builder
import SCons.Node.FS
import SCons.Util
def emit_rmic_classes(target, source, env):
"""Create and return lists of Java RMI stub and skeleton
class files to be created from a set of class files.
"""
class_suffix = env.get('JAVACLASSSUFFIX', '.class')
classdir = env.get('JAVACLASSDIR')
if not classdir:
try:
s = source[0]
except IndexError:
classdir = '.'
else:
try:
classdir = s.attributes.java_classdir
except AttributeError:
classdir = '.'
classdir = env.Dir(classdir).rdir()
if str(classdir) == '.':
c_ = None
else:
c_ = str(classdir) + os.sep
slist = []
for src in source:
try:
classname = src.attributes.java_classname
except AttributeError:
classname = str(src)
if c_ and classname[:len(c_)] == c_:
classname = classname[len(c_):]
if class_suffix and classname[:-len(class_suffix)] == class_suffix:
classname = classname[-len(class_suffix):]
s = src.rfile()
s.attributes.java_classdir = classdir
s.attributes.java_classname = classname
slist.append(s)
stub_suffixes = ['_Stub']
if env.get('JAVAVERSION') == '1.4':
stub_suffixes.append('_Skel')
tlist = []
for s in source:
for suff in stub_suffixes:
fname = s.attributes.java_classname.replace('.', os.sep) + \
suff + class_suffix
t = target[0].File(fname)
t.attributes.java_lookupdir = target[0]
tlist.append(t)
return tlist, source
RMICAction = SCons.Action.Action('$RMICCOM', '$RMICCOMSTR')
RMICBuilder = SCons.Builder.Builder(action = RMICAction,
emitter = emit_rmic_classes,
src_suffix = '$JAVACLASSSUFFIX',
target_factory = SCons.Node.FS.Dir,
source_factory = SCons.Node.FS.File)
def generate(env):
"""Add Builders and construction variables for rmic to an Environment."""
env['BUILDERS']['RMIC'] = RMICBuilder
env['RMIC'] = 'rmic'
env['RMICFLAGS'] = SCons.Util.CLVar('')
env['RMICCOM'] = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpath ${SOURCE.attributes.java_classdir} ${SOURCES.attributes.java_classname}'
env['JAVACLASSSUFFIX'] = '.class'
def exists(env):
return env.Detect('rmic')
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
|
apache-2.0
|
[
624,
18521,
14,
5157,
14,
5682,
530,
199,
199,
5157,
13,
6100,
11097,
367,
14267,
530,
14,
199,
199,
10924,
12252,
9296,
1133,
506,
1263,
1929,
370,
492,
642,
859,
5370,
14,
199,
7940,
911,
9987,
506,
8439,
4012,
314,
7809,
8218,
14,
5157,
14,
5157,
342,
199,
5592,
1083,
14,
199,
199,
624,
199,
199,
3,
199,
3,
1898,
334,
67,
9,
12521,
12,
14790,
12,
13004,
12,
8353,
12,
11811,
12,
8315,
12,
10219,
12,
9079,
12,
8937,
12,
7129,
710,
8218,
2752,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
199,
3,
282,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
199,
3,
11207,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
199,
3,
11291,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
199,
3,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
199,
3,
3826,
12,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
199,
3,
2990,
1634,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
5877,
8164,
6262,
199,
3,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
1621,
1261,
9612,
199,
3,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
11287,
199,
3,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
4141,
14,
199,
3,
199,
199,
363,
5792,
363,
275,
298,
2164,
15,
3908,
15,
18521,
15,
5157,
15,
5682,
530,
14,
647,
959,
7582,
7129,
15,
2036,
15,
975,
6546,
26,
996,
26,
2167,
330,
271,
5902,
290,
2,
199,
199,
646,
747,
14,
515,
199,
199,
646,
8218,
14,
3310,
199,
646,
8218,
14,
6437,
199,
646,
8218,
14,
1716,
14,
7079,
199,
646,
8218,
14,
9562,
199,
199,
318,
8689,
63,
5682,
530,
63,
2888,
8,
1375,
12,
1350,
12,
2589,
304,
272,
408,
2499,
436,
372,
5548,
402,
9586,
820,
10709,
10098,
436,
30537,
272,
1021,
1584,
370,
506,
2737,
687,
282,
663,
402,
1021,
1584,
14,
272,
408,
272,
1021,
63,
4511,
275,
2589,
14,
362,
360,
42,
6087,
18765,
1179,
2300,
8158,
3867,
297,
1987,
533,
358,
272,
1021,
694,
275,
2589,
14,
362,
360,
42,
6087,
18765,
3755,
3022,
358,
339,
340,
440,
1021,
694,
26,
267,
862,
26,
288,
308,
275,
1350,
59,
16,
61,
267,
871,
7888,
26,
288,
1021,
694,
275,
7815,
267,
587,
26,
288,
862,
26,
355,
1021,
694,
275,
308,
14,
2987,
14,
6138,
63,
533,
694,
288,
871,
4281,
26,
355,
1021,
694,
275,
7815,
272,
1021,
694,
275,
2589,
14,
3567,
8,
533,
694,
680,
82,
694,
342,
272,
340,
620,
8,
533,
694,
9,
508,
26351,
267,
286,
63,
275,
488,
272,
587,
26,
267,
286,
63,
275,
620,
8,
533,
694,
9,
435,
747,
14,
4127,
339,
308,
513,
275,
942,
272,
367,
2928,
315,
1350,
26,
267,
862,
26,
288,
15876,
275,
2928,
14,
2987,
14,
6138,
63,
19851,
267,
871,
4281,
26,
288,
15876,
275,
620,
8,
2164,
9,
288,
340,
286,
63,
436,
15876,
1491,
552,
8,
67,
63,
1874,
508,
286,
10388,
355,
15876,
275,
15876,
59,
552,
8,
67,
7822,
61,
288,
340,
1021,
63,
4511,
436,
15876,
4439,
552,
8,
533,
63,
4511,
1874,
508,
1021,
63,
4511,
26,
355,
15876,
275,
15876,
1988,
552,
8,
533,
63,
4511,
15405,
267,
308,
275,
2928,
14,
23830,
342,
267,
308,
14,
2987,
14,
6138,
63,
533,
694,
275,
1021,
694,
267,
308,
14,
2987,
14,
6138,
63,
19851,
275,
15876,
267,
308,
513,
14,
740,
8,
83,
9,
339,
10098,
63,
16097,
275,
4044,
8067,
418,
272,
340,
2589,
14,
362,
360,
42,
28520,
4612,
358,
508,
283,
17,
14,
20,
356,
267,
10098,
63,
16097,
14,
740,
6412,
14194,
352,
358,
339,
307,
513,
275,
942,
272,
367,
308,
315,
1350,
26,
267,
367,
308,
3043,
315,
10098,
63,
16097,
26,
288,
6748,
275,
308,
14,
2987,
14,
6138,
63,
19851,
14,
1814,
14078,
747,
14,
4127,
9,
435,
971,
490,
308,
3043,
435,
1021,
63,
4511,
288,
307,
275,
1347,
59,
16,
1055,
1173,
8,
5252,
9,
288,
307,
14,
2987,
14,
6138,
63,
3892,
694,
275,
1347,
59,
16,
61,
288,
307,
513,
14,
740,
8,
84,
9,
339,
372,
307,
513,
12,
1350,
199,
199,
11026,
948,
3310,
275,
8218,
14,
3310,
14,
3310,
14676,
11026,
948,
11265,
297,
4505,
11026,
948,
11265,
3027,
358,
199,
199,
11026,
948,
6437,
275,
8218,
14,
6437,
14,
6437,
8,
1287,
275,
820,
17233,
3310,
12,
2151,
8689,
351,
275,
8689,
63,
5682,
530,
63,
2888,
12,
2151,
2928,
63,
4511,
275,
4505,
42,
6087,
18765,
1179,
2300,
8158,
3867,
297,
2151,
1347,
63,
3702,
275,
8218,
14,
1716,
14,
7079,
14,
3567,
12,
2151,
1350,
63,
3702,
275,
8218,
14,
1716,
14,
7079,
14,
1173,
9,
199,
199,
318,
3550,
8,
1813,
304,
272,
408,
1123,
19286,
83,
436,
14538,
2860,
367,
14267,
530,
370,
376,
9711,
1041,
272,
2589,
459,
8248,
3960,
2545,
11026,
948,
418,
275,
820,
17233,
6437,
339,
2589,
459,
11026,
948,
418,
3322,
275,
283,
5682,
530,
7,
272,
2589,
459,
11026,
948,
4831,
418,
755,
275,
8218,
14,
9562,
14,
1981,
5894,
8355,
272,
2589,
459,
11026,
948,
11265,
418,
260,
275,
4505,
11026,
948,
2672,
11026,
948,
4831,
446,
68,
10839,
9268,
14,
2987,
14,
6138,
63,
3892,
694,
93,
446,
26977,
10839,
10187,
14,
2987,
14,
6138,
63,
533,
694,
93,
10839,
25744,
14,
2987,
14,
6138,
63,
19851,
6834,
272,
2589,
459,
42,
6087,
18765,
1179,
2300,
8158,
3867,
418,
221,
275,
1987,
533,
7,
199,
199
] |
[
18521,
14,
5157,
14,
5682,
530,
199,
199,
5157,
13,
6100,
11097,
367,
14267,
530,
14,
199,
199,
10924,
12252,
9296,
1133,
506,
1263,
1929,
370,
492,
642,
859,
5370,
14,
199,
7940,
911,
9987,
506,
8439,
4012,
314,
7809,
8218,
14,
5157,
14,
5157,
342,
199,
5592,
1083,
14,
199,
199,
624,
199,
199,
3,
199,
3,
1898,
334,
67,
9,
12521,
12,
14790,
12,
13004,
12,
8353,
12,
11811,
12,
8315,
12,
10219,
12,
9079,
12,
8937,
12,
7129,
710,
8218,
2752,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
199,
3,
282,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
199,
3,
11207,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
199,
3,
11291,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
199,
3,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
199,
3,
3826,
12,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
199,
3,
2990,
1634,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
5877,
8164,
6262,
199,
3,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
1621,
1261,
9612,
199,
3,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
11287,
199,
3,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
4141,
14,
199,
3,
199,
199,
363,
5792,
363,
275,
298,
2164,
15,
3908,
15,
18521,
15,
5157,
15,
5682,
530,
14,
647,
959,
7582,
7129,
15,
2036,
15,
975,
6546,
26,
996,
26,
2167,
330,
271,
5902,
290,
2,
199,
199,
646,
747,
14,
515,
199,
199,
646,
8218,
14,
3310,
199,
646,
8218,
14,
6437,
199,
646,
8218,
14,
1716,
14,
7079,
199,
646,
8218,
14,
9562,
199,
199,
318,
8689,
63,
5682,
530,
63,
2888,
8,
1375,
12,
1350,
12,
2589,
304,
272,
408,
2499,
436,
372,
5548,
402,
9586,
820,
10709,
10098,
436,
30537,
272,
1021,
1584,
370,
506,
2737,
687,
282,
663,
402,
1021,
1584,
14,
272,
408,
272,
1021,
63,
4511,
275,
2589,
14,
362,
360,
42,
6087,
18765,
1179,
2300,
8158,
3867,
297,
1987,
533,
358,
272,
1021,
694,
275,
2589,
14,
362,
360,
42,
6087,
18765,
3755,
3022,
358,
339,
340,
440,
1021,
694,
26,
267,
862,
26,
288,
308,
275,
1350,
59,
16,
61,
267,
871,
7888,
26,
288,
1021,
694,
275,
7815,
267,
587,
26,
288,
862,
26,
355,
1021,
694,
275,
308,
14,
2987,
14,
6138,
63,
533,
694,
288,
871,
4281,
26,
355,
1021,
694,
275,
7815,
272,
1021,
694,
275,
2589,
14,
3567,
8,
533,
694,
680,
82,
694,
342,
272,
340,
620,
8,
533,
694,
9,
508,
26351,
267,
286,
63,
275,
488,
272,
587,
26,
267,
286,
63,
275,
620,
8,
533,
694,
9,
435,
747,
14,
4127,
339,
308,
513,
275,
942,
272,
367,
2928,
315,
1350,
26,
267,
862,
26,
288,
15876,
275,
2928,
14,
2987,
14,
6138,
63,
19851,
267,
871,
4281,
26,
288,
15876,
275,
620,
8,
2164,
9,
288,
340,
286,
63,
436,
15876,
1491,
552,
8,
67,
63,
1874,
508,
286,
10388,
355,
15876,
275,
15876,
59,
552,
8,
67,
7822,
61,
288,
340,
1021,
63,
4511,
436,
15876,
4439,
552,
8,
533,
63,
4511,
1874,
508,
1021,
63,
4511,
26,
355,
15876,
275,
15876,
1988,
552,
8,
533,
63,
4511,
15405,
267,
308,
275,
2928,
14,
23830,
342,
267,
308,
14,
2987,
14,
6138,
63,
533,
694,
275,
1021,
694,
267,
308,
14,
2987,
14,
6138,
63,
19851,
275,
15876,
267,
308,
513,
14,
740,
8,
83,
9,
339,
10098,
63,
16097,
275,
4044,
8067,
418,
272,
340,
2589,
14,
362,
360,
42,
28520,
4612,
358,
508,
283,
17,
14,
20,
356,
267,
10098,
63,
16097,
14,
740,
6412,
14194,
352,
358,
339,
307,
513,
275,
942,
272,
367,
308,
315,
1350,
26,
267,
367,
308,
3043,
315,
10098,
63,
16097,
26,
288,
6748,
275,
308,
14,
2987,
14,
6138,
63,
19851,
14,
1814,
14078,
747,
14,
4127,
9,
435,
971,
490,
308,
3043,
435,
1021,
63,
4511,
288,
307,
275,
1347,
59,
16,
1055,
1173,
8,
5252,
9,
288,
307,
14,
2987,
14,
6138,
63,
3892,
694,
275,
1347,
59,
16,
61,
288,
307,
513,
14,
740,
8,
84,
9,
339,
372,
307,
513,
12,
1350,
199,
199,
11026,
948,
3310,
275,
8218,
14,
3310,
14,
3310,
14676,
11026,
948,
11265,
297,
4505,
11026,
948,
11265,
3027,
358,
199,
199,
11026,
948,
6437,
275,
8218,
14,
6437,
14,
6437,
8,
1287,
275,
820,
17233,
3310,
12,
2151,
8689,
351,
275,
8689,
63,
5682,
530,
63,
2888,
12,
2151,
2928,
63,
4511,
275,
4505,
42,
6087,
18765,
1179,
2300,
8158,
3867,
297,
2151,
1347,
63,
3702,
275,
8218,
14,
1716,
14,
7079,
14,
3567,
12,
2151,
1350,
63,
3702,
275,
8218,
14,
1716,
14,
7079,
14,
1173,
9,
199,
199,
318,
3550,
8,
1813,
304,
272,
408,
1123,
19286,
83,
436,
14538,
2860,
367,
14267,
530,
370,
376,
9711,
1041,
272,
2589,
459,
8248,
3960,
2545,
11026,
948,
418,
275,
820,
17233,
6437,
339,
2589,
459,
11026,
948,
418,
3322,
275,
283,
5682,
530,
7,
272,
2589,
459,
11026,
948,
4831,
418,
755,
275,
8218,
14,
9562,
14,
1981,
5894,
8355,
272,
2589,
459,
11026,
948,
11265,
418,
260,
275,
4505,
11026,
948,
2672,
11026,
948,
4831,
446,
68,
10839,
9268,
14,
2987,
14,
6138,
63,
3892,
694,
93,
446,
26977,
10839,
10187,
14,
2987,
14,
6138,
63,
533,
694,
93,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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
] |
geminy/aidear
|
snippets/cppfunc/cppcheck/cppcheck-1.80/addons/cert.py
|
1
|
2959
|
#!/usr/bin/env python
#
# Cert: Some extra CERT checkers
#
# Cppcheck itself handles many CERT rules. Cppcheck warns when there is undefined behaviour.
#
# Example usage of this addon (scan a sourcefile main.cpp)
# cppcheck --dump main.cpp
# python cert.py main.cpp.dump
import cppcheckdata
import sys
import re
def reportError(token, severity, msg):
sys.stderr.write(
'[' + token.file + ':' + str(token.linenr) + '] (' + severity + ') cert.py: ' + msg + '\n')
def isUnpackedStruct(var):
decl = var.typeStartToken
while decl and decl.isName:
if decl.str == 'struct':
structScope = decl.next.typeScope
if structScope:
linenr = int(structScope.classStart.linenr)
for line in open(structScope.classStart.file):
linenr -= 1
if linenr == 0:
return True
if re.match(r'#pragma\s+pack\s*\(', line):
return False
break
decl = decl.next
return False
def isLocalUnpackedStruct(arg):
if arg and arg.str == '&' and not arg.astOperand2:
arg = arg.astOperand1
return arg and arg.variable and (arg.variable.isLocal or arg.variable.isArgument) and isUnpackedStruct(arg.variable)
def isBitwiseOp(token):
return token and (token.str in {'&', '|', '^'})
def isComparisonOp(token):
return token and (token.str in {'==', '!=', '>', '>=', '<', '<='})
# EXP42-C
# do not compare padding data
def exp42(data):
for token in data.tokenlist:
if token.str != '(' or not token.astOperand1:
continue
arg1 = None
arg2 = None
if token.astOperand2 and token.astOperand2.str == ',':
if token.astOperand2.astOperand1 and token.astOperand2.astOperand1.str == ',':
arg1 = token.astOperand2.astOperand1.astOperand1
arg2 = token.astOperand2.astOperand1.astOperand2
if token.astOperand1.str == 'memcmp' and (isLocalUnpackedStruct(arg1) or isLocalUnpackedStruct(arg2)):
reportError(
token, 'style', "EXP42-C Comparison of struct padding data " +
"(fix either by packing the struct using '#pragma pack' or by rewriting the comparison)")
# EXP46-C
# Do not use a bitwise operator with a Boolean-like operand
# int x = (a == b) & c;
def exp46(data):
for token in data.tokenlist:
if isBitwiseOp(token) and (isComparisonOp(token.astOperand1) or isComparisonOp(token.astOperand2)):
reportError(
token, 'style', 'EXP46-C Bitwise operator is used with a Boolean-like operand')
for arg in sys.argv[1:]:
print('Checking ' + arg + '...')
data = cppcheckdata.parsedump(arg)
for cfg in data.configurations:
if len(data.configurations) > 1:
print('Checking ' + arg + ', config "' + cfg.name + '"...')
exp42(cfg)
exp46(cfg)
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
11002,
84,
26,
6601,
2402,
28313,
1104,
1192,
199,
3,
199,
3,
445,
802,
1074,
6337,
10022,
5002,
28313,
4713,
14,
445,
802,
1074,
3429,
561,
1380,
2337,
365,
10942,
13942,
14,
199,
3,
199,
3,
5679,
4503,
402,
642,
13553,
334,
6282,
282,
1350,
493,
2446,
14,
5910,
9,
199,
3,
7246,
1074,
1553,
2724,
2446,
14,
5910,
199,
3,
2366,
6250,
14,
647,
2446,
14,
5910,
14,
2724,
199,
199,
646,
7246,
1074,
576,
199,
646,
984,
199,
646,
295,
421,
199,
318,
3622,
547,
8,
1418,
12,
25574,
12,
1499,
304,
272,
984,
14,
3083,
14,
952,
8,
267,
22640,
435,
1526,
14,
493,
435,
10871,
435,
620,
8,
1418,
14,
2950,
82,
9,
435,
24710,
661,
435,
25574,
435,
5320,
6250,
14,
647,
26,
283,
435,
1499,
435,
1557,
78,
358,
421,
199,
318,
365,
1358,
12286,
4836,
8,
1391,
304,
272,
15021,
275,
2729,
14,
466,
3162,
3264,
272,
1830,
15021,
436,
15021,
14,
374,
985,
26,
267,
340,
15021,
14,
495,
508,
283,
1820,
356,
288,
2702,
7812,
275,
15021,
14,
2184,
14,
466,
7812,
288,
340,
2702,
7812,
26,
355,
27466,
275,
1109,
8,
1820,
7812,
14,
533,
3162,
14,
2950,
82,
9,
355,
367,
1004,
315,
1551,
8,
1820,
7812,
14,
533,
3162,
14,
493,
304,
490,
27466,
4862,
413,
490,
340,
27466,
508,
378,
26,
717,
372,
715,
490,
340,
295,
14,
1431,
8,
82,
11525,
25852,
60,
83,
11,
1389,
60,
83,
7590,
5102,
1004,
304,
717,
372,
756,
288,
2059,
267,
15021,
275,
15021,
14,
2184,
272,
372,
756,
421,
199,
318,
365,
5339,
1358,
12286,
4836,
8,
1273,
304,
272,
340,
1680,
436,
1680,
14,
495,
508,
29285,
436,
440,
1680,
14,
1810,
18391,
18,
26,
267,
1680,
275,
1680,
14,
1810,
18391,
17,
272,
372,
1680,
436,
1680,
14,
1975,
436,
334,
1273,
14,
1975,
14,
374,
5339,
503,
1680,
14,
1975,
14,
374,
5201,
9,
436,
365,
1358,
12286,
4836,
8,
1273,
14,
1975,
9,
421,
199,
318,
365,
4734,
2605,
4619,
8,
1418,
304,
272,
372,
1526,
436,
334,
1418,
14,
495,
315,
791,
16749,
11280,
297,
14452,
3071,
421,
199,
318,
365,
25834,
4619,
8,
1418,
304,
272,
372,
1526,
436,
334,
1418,
14,
495,
315,
791,
389,
297,
31326,
26120,
12696,
4009,
30243,
2650,
534,
1552,
421,
199,
3,
3651,
48,
2260,
13,
35,
199,
3,
886,
440,
6540,
6273,
666,
199,
318,
1437,
2260,
8,
576,
304,
272,
367,
1526,
315,
666,
14,
1418,
513,
26,
267,
340,
1526,
14,
495,
1137,
16746,
503,
440,
1526,
14,
1810,
18391,
17,
26,
288,
1980,
398,
1680,
17,
275,
488,
267,
1680,
18,
275,
488,
267,
340,
1526,
14,
1810,
18391,
18,
436,
1526,
14,
1810,
18391,
18,
14,
495,
508,
1656,
356,
288,
340,
1526,
14,
1810,
18391,
18,
14,
1810,
18391,
17,
436,
1526,
14,
1810,
18391,
18,
14,
1810,
18391,
17,
14,
495,
508,
1656,
356,
355,
1680,
17,
275,
1526,
14,
1810,
18391,
18,
14,
1810,
18391,
17,
14,
1810,
18391,
17,
355,
1680,
18,
275,
1526,
14,
1810,
18391,
18,
14,
1810,
18391,
17,
14,
1810,
18391,
18,
398,
340,
1526,
14,
1810,
18391,
17,
14,
495,
508,
283,
5286,
5730,
7,
436,
334,
374,
5339,
1358,
12286,
4836,
8,
1273,
17,
9,
503,
365,
5339,
1358,
12286,
4836,
8,
1273,
18,
2298,
288,
3622,
547,
8,
355,
1526,
12,
283,
2487,
297,
298,
11992,
2260,
13,
35,
3599,
5447,
402,
2702,
6273,
666,
298,
435,
355,
7340,
970,
1902,
701,
1706,
316,
314,
2702,
1808,
3943,
25852,
1706,
7,
503,
701,
295,
14827,
314,
9132,
6320,
421,
199,
3,
3651,
48,
2466,
13,
35,
199,
3,
4226,
440,
675,
282,
31927,
4182,
543,
282,
9411,
13,
2930,
14888,
199,
3,
257,
1109,
671,
275,
334,
65,
508,
330,
9,
1253,
286,
27,
199,
318,
1437,
2466,
8,
576,
304,
272,
367,
1526,
315,
666,
14,
1418,
513,
26,
267,
340,
365,
4734,
2605,
4619,
8,
1418,
9,
436,
334,
374,
25834,
4619,
8,
1418,
14,
1810,
18391,
17,
9,
503,
365,
25834,
4619,
8,
1418,
14,
1810,
18391,
18,
2298,
288,
3622,
547,
8,
355,
1526,
12,
283,
2487,
297,
283,
11992,
2466,
13,
35,
10199,
2605,
4182,
365,
1202,
543,
282,
9411,
13,
2930,
14888,
358,
199,
199,
509,
1680,
315,
984,
14,
3020,
59,
17,
10688,
272,
870,
360,
14740,
283,
435,
1680,
435,
283,
15103,
272,
666,
275,
7246,
1074,
576,
14,
6751,
1220,
8,
1273,
9,
272,
367,
4810,
315,
666,
14,
10057,
26,
267,
340,
822,
8,
576,
14,
10057,
9,
690,
413,
26,
288,
870,
360,
14740,
283,
435,
1680,
435,
1656,
1101,
3546,
435,
4810,
14,
354,
435,
5522,
15103,
267,
1437,
2260,
8,
4128,
9,
267,
1437,
2466,
8,
4128,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
11002,
84,
26,
6601,
2402,
28313,
1104,
1192,
199,
3,
199,
3,
445,
802,
1074,
6337,
10022,
5002,
28313,
4713,
14,
445,
802,
1074,
3429,
561,
1380,
2337,
365,
10942,
13942,
14,
199,
3,
199,
3,
5679,
4503,
402,
642,
13553,
334,
6282,
282,
1350,
493,
2446,
14,
5910,
9,
199,
3,
7246,
1074,
1553,
2724,
2446,
14,
5910,
199,
3,
2366,
6250,
14,
647,
2446,
14,
5910,
14,
2724,
199,
199,
646,
7246,
1074,
576,
199,
646,
984,
199,
646,
295,
421,
199,
318,
3622,
547,
8,
1418,
12,
25574,
12,
1499,
304,
272,
984,
14,
3083,
14,
952,
8,
267,
22640,
435,
1526,
14,
493,
435,
10871,
435,
620,
8,
1418,
14,
2950,
82,
9,
435,
24710,
661,
435,
25574,
435,
5320,
6250,
14,
647,
26,
283,
435,
1499,
435,
1557,
78,
358,
421,
199,
318,
365,
1358,
12286,
4836,
8,
1391,
304,
272,
15021,
275,
2729,
14,
466,
3162,
3264,
272,
1830,
15021,
436,
15021,
14,
374,
985,
26,
267,
340,
15021,
14,
495,
508,
283,
1820,
356,
288,
2702,
7812,
275,
15021,
14,
2184,
14,
466,
7812,
288,
340,
2702,
7812,
26,
355,
27466,
275,
1109,
8,
1820,
7812,
14,
533,
3162,
14,
2950,
82,
9,
355,
367,
1004,
315,
1551,
8,
1820,
7812,
14,
533,
3162,
14,
493,
304,
490,
27466,
4862,
413,
490,
340,
27466,
508,
378,
26,
717,
372,
715,
490,
340,
295,
14,
1431,
8,
82,
11525,
25852,
60,
83,
11,
1389,
60,
83,
7590,
5102,
1004,
304,
717,
372,
756,
288,
2059,
267,
15021,
275,
15021,
14,
2184,
272,
372,
756,
421,
199,
318,
365,
5339,
1358,
12286,
4836,
8,
1273,
304,
272,
340,
1680,
436,
1680,
14,
495,
508,
29285,
436,
440,
1680,
14,
1810,
18391,
18,
26,
267,
1680,
275,
1680,
14,
1810,
18391,
17,
272,
372,
1680,
436,
1680,
14,
1975,
436,
334,
1273,
14,
1975,
14,
374,
5339,
503,
1680,
14,
1975,
14,
374,
5201,
9,
436,
365,
1358,
12286,
4836,
8,
1273,
14,
1975,
9,
421,
199,
318,
365,
4734,
2605,
4619,
8,
1418,
304,
272,
372,
1526,
436,
334,
1418,
14,
495,
315,
791,
16749,
11280,
297,
14452,
3071,
421,
199,
318,
365,
25834,
4619,
8,
1418,
304,
272,
372,
1526,
436,
334,
1418,
14,
495,
315,
791,
389,
297,
31326,
26120,
12696,
4009,
30243,
2650,
534,
1552,
421,
199,
3,
3651,
48,
2260,
13,
35,
199,
3,
886,
440,
6540,
6273,
666,
199,
318,
1437,
2260,
8,
576,
304,
272,
367,
1526,
315,
666,
14,
1418,
513,
26,
267,
340,
1526,
14,
495,
1137,
16746,
503,
440,
1526,
14,
1810,
18391,
17,
26,
288,
1980,
398,
1680,
17,
275,
488,
267,
1680,
18,
275,
488,
267,
340,
1526,
14,
1810,
18391,
18,
436,
1526,
14,
1810,
18391,
18,
14,
495,
508,
1656,
356,
288,
340,
1526,
14,
1810,
18391,
18,
14,
1810,
18391,
17,
436,
1526,
14,
1810,
18391,
18,
14,
1810,
18391,
17,
14,
495,
508,
1656,
356,
355,
1680,
17,
275,
1526,
14,
1810,
18391,
18,
14,
1810,
18391,
17,
14,
1810,
18391,
17,
355,
1680,
18,
275,
1526,
14,
1810,
18391,
18,
14,
1810,
18391,
17,
14,
1810,
18391,
18,
398,
340,
1526,
14,
1810,
18391,
17,
14,
495,
508,
283,
5286,
5730,
7,
436,
334,
374,
5339,
1358,
12286,
4836,
8,
1273,
17,
9,
503,
365,
5339,
1358,
12286,
4836,
8,
1273,
18,
2298,
288,
3622,
547,
8,
355,
1526,
12,
283,
2487,
297,
298,
11992,
2260,
13,
35,
3599,
5447,
402,
2702,
6273,
666,
298,
435,
355,
7340,
970,
1902,
701,
1706,
316,
314,
2702,
1808,
3943,
25852,
1706,
7,
503,
701,
295,
14827,
314,
9132,
6320,
421,
199,
3,
3651,
48,
2466,
13,
35,
199,
3,
4226,
440,
675,
282,
31927,
4182,
543,
282,
9411,
13,
2930,
14888,
199,
3,
257,
1109,
671,
275,
334,
65,
508,
330,
9,
1253,
286,
27,
199,
318,
1437,
2466,
8,
576,
304,
272,
367,
1526,
315,
666,
14,
1418,
513,
26,
267,
340,
365,
4734,
2605,
4619,
8,
1418,
9,
436,
334,
374,
25834,
4619,
8,
1418,
14,
1810,
18391,
17,
9,
503,
365,
25834,
4619,
8,
1418,
14,
1810,
18391,
18,
2298,
288,
3622,
547,
8,
355,
1526,
12,
283,
2487,
297,
283,
11992,
2466,
13,
35,
10199,
2605,
4182,
365,
1202,
543,
282,
9411,
13,
2930,
14888,
358,
199,
199,
509,
1680,
315,
984,
14,
3020,
59,
17,
10688,
272,
870,
360,
14740,
283,
435,
1680,
435,
283,
15103,
272,
666,
275,
7246,
1074,
576,
14,
6751,
1220,
8,
1273,
9,
272,
367,
4810,
315,
666,
14,
10057,
26,
267,
340,
822,
8,
576,
14,
10057,
9,
690,
413,
26,
288,
870,
360,
14740,
283,
435,
1680,
435,
1656,
1101,
3546,
435,
4810,
14,
354,
435,
5522,
15103,
267,
1437,
2260,
8,
4128,
9,
267,
1437,
2466,
8,
4128,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
MeshCollider/bitcoin
|
test/functional/mempool_expiry.py
|
18
|
5133
|
#!/usr/bin/env python3
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Tests that a mempool transaction expires after a given timeout and that its
children are removed as well.
Both the default expiry timeout defined by DEFAULT_MEMPOOL_EXPIRY and a user
definable expiry timeout via the '-mempoolexpiry=<n>' command line argument
(<n> is the timeout in hours) are tested.
"""
from datetime import timedelta
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
)
from test_framework.wallet import MiniWallet
DEFAULT_MEMPOOL_EXPIRY = 336 # hours
CUSTOM_MEMPOOL_EXPIRY = 10 # hours
class MempoolExpiryTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
def test_transaction_expiry(self, timeout):
"""Tests that a transaction expires after the expiry timeout and its
children are removed as well."""
node = self.nodes[0]
self.wallet = MiniWallet(node)
# Add enough mature utxos to the wallet so that all txs spend confirmed coins.
self.wallet.generate(4)
node.generate(100)
# Send a parent transaction that will expire.
parent_txid = self.wallet.send_self_transfer(from_node=node)['txid']
parent_utxo = self.wallet.get_utxo(txid=parent_txid)
independent_utxo = self.wallet.get_utxo()
# Ensure the transactions we send to trigger the mempool check spend utxos that are independent of
# the transactions being tested for expiration.
trigger_utxo1 = self.wallet.get_utxo()
trigger_utxo2 = self.wallet.get_utxo()
# Set the mocktime to the arrival time of the parent transaction.
entry_time = node.getmempoolentry(parent_txid)['time']
node.setmocktime(entry_time)
# Let half of the timeout elapse and broadcast the child transaction spending the parent transaction.
half_expiry_time = entry_time + int(60 * 60 * timeout/2)
node.setmocktime(half_expiry_time)
child_txid = self.wallet.send_self_transfer(from_node=node, utxo_to_spend=parent_utxo)['txid']
assert_equal(parent_txid, node.getmempoolentry(child_txid)['depends'][0])
self.log.info('Broadcast child transaction after {} hours.'.format(
timedelta(seconds=(half_expiry_time-entry_time))))
# Broadcast another (independent) transaction.
independent_txid = self.wallet.send_self_transfer(from_node=node, utxo_to_spend=independent_utxo)['txid']
# Let most of the timeout elapse and check that the parent tx is still
# in the mempool.
nearly_expiry_time = entry_time + 60 * 60 * timeout - 5
node.setmocktime(nearly_expiry_time)
# Broadcast a transaction as the expiry of transactions in the mempool is only checked
# when a new transaction is added to the mempool.
self.wallet.send_self_transfer(from_node=node, utxo_to_spend=trigger_utxo1)
self.log.info('Test parent tx not expired after {} hours.'.format(
timedelta(seconds=(nearly_expiry_time-entry_time))))
assert_equal(entry_time, node.getmempoolentry(parent_txid)['time'])
# Transaction should be evicted from the mempool after the expiry time
# has passed.
expiry_time = entry_time + 60 * 60 * timeout + 5
node.setmocktime(expiry_time)
# Again, broadcast a transaction so the expiry of transactions in the mempool is checked.
self.wallet.send_self_transfer(from_node=node, utxo_to_spend=trigger_utxo2)
self.log.info('Test parent tx expiry after {} hours.'.format(
timedelta(seconds=(expiry_time-entry_time))))
assert_raises_rpc_error(-5, 'Transaction not in mempool',
node.getmempoolentry, parent_txid)
# The child transaction should be removed from the mempool as well.
self.log.info('Test child tx is evicted as well.')
assert_raises_rpc_error(-5, 'Transaction not in mempool',
node.getmempoolentry, child_txid)
# Check that the independent tx is still in the mempool.
self.log.info('Test the independent tx not expired after {} hours.'.format(
timedelta(seconds=(expiry_time-half_expiry_time))))
assert_equal(half_expiry_time, node.getmempoolentry(independent_txid)['time'])
def run_test(self):
self.log.info('Test default mempool expiry timeout of %d hours.' %
DEFAULT_MEMPOOL_EXPIRY)
self.test_transaction_expiry(DEFAULT_MEMPOOL_EXPIRY)
self.log.info('Test custom mempool expiry timeout of %d hours.' %
CUSTOM_MEMPOOL_EXPIRY)
self.restart_node(0, ['-mempoolexpiry=%d' % CUSTOM_MEMPOOL_EXPIRY])
self.test_transaction_expiry(CUSTOM_MEMPOOL_EXPIRY)
if __name__ == '__main__':
MempoolExpiryTest().main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
25455,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
2925,
626,
282,
30330,
6008,
12261,
2410,
282,
1627,
2653,
436,
626,
2399,
199,
3223,
787,
4829,
465,
5521,
14,
199,
199,
18088,
314,
849,
23402,
2653,
3247,
701,
6186,
63,
10293,
19693,
63,
25632,
5782,
436,
282,
922,
199,
318,
262,
461,
23402,
2653,
4799,
314,
2475,
278,
311,
1534,
3113,
1038,
651,
18987,
78,
3524,
1414,
1004,
1423,
199,
27530,
78,
30,
365,
314,
2653,
315,
10857,
9,
787,
12470,
14,
199,
624,
199,
199,
504,
2197,
492,
6871,
199,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
21158,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
334,
272,
702,
63,
1452,
12,
272,
702,
63,
3536,
63,
4354,
63,
705,
12,
199,
9,
199,
504,
511,
63,
4857,
14,
13892,
492,
24954,
55,
9478,
199,
199,
3472,
63,
10293,
19693,
63,
25632,
5782,
275,
650,
1344,
221,
327,
10857,
199,
20519,
63,
10293,
19693,
63,
25632,
5782,
275,
1616,
221,
327,
10857,
421,
199,
533,
603,
2109,
21943,
14000,
651,
774,
8,
4734,
9061,
26203,
304,
272,
347,
663,
63,
396,
63,
1162,
8,
277,
304,
267,
291,
14,
1507,
63,
2415,
275,
413,
267,
291,
14,
2758,
63,
3118,
63,
4429,
275,
715,
339,
347,
511,
63,
5945,
63,
16844,
8,
277,
12,
2653,
304,
267,
408,
2925,
626,
282,
6008,
12261,
2410,
314,
23402,
2653,
436,
2399,
267,
4978,
787,
4829,
465,
5521,
1041,
267,
1031,
275,
291,
14,
2415,
59,
16,
61,
267,
291,
14,
13892,
275,
24954,
55,
9478,
8,
932,
9,
398,
327,
2654,
8321,
333,
1463,
11430,
22101,
370,
314,
20534,
880,
626,
1006,
4773,
83,
26387,
22763,
512,
3617,
14,
267,
291,
14,
13892,
14,
4208,
8,
20,
9,
267,
1031,
14,
4208,
8,
1960,
9,
398,
327,
10217,
282,
1676,
6008,
626,
911,
16667,
14,
267,
1676,
63,
14113,
275,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
11820,
14113,
418,
267,
1676,
63,
30275,
275,
291,
14,
13892,
14,
362,
63,
30275,
8,
14113,
29,
1708,
63,
14113,
9,
267,
12717,
63,
30275,
275,
291,
14,
13892,
14,
362,
63,
30275,
342,
398,
327,
7523,
314,
15809,
781,
3222,
370,
6804,
314,
30330,
1104,
26387,
11430,
22101,
626,
787,
12717,
402,
267,
327,
314,
15809,
3769,
12470,
367,
15399,
14,
267,
6804,
63,
30275,
17,
275,
291,
14,
13892,
14,
362,
63,
30275,
342,
267,
6804,
63,
30275,
18,
275,
291,
14,
13892,
14,
362,
63,
30275,
342,
398,
327,
2494,
314,
1683,
521,
370,
314,
601,
26976,
900,
402,
314,
1676,
6008,
14,
267,
2397,
63,
521,
275,
1031,
14,
362,
278,
311,
1534,
274,
3410,
8,
1708,
63,
14113,
11820,
521,
418,
267,
1031,
14,
409,
1805,
521,
8,
2373,
63,
521,
9,
398,
327,
12230,
12995,
402,
314,
2653,
325,
12057,
436,
11180,
314,
1982,
6008,
2249,
3219,
314,
1676,
6008,
14,
267,
12995,
63,
16844,
63,
521,
275,
2397,
63,
521,
435,
1109,
8,
2259,
627,
5212,
627,
2653,
15,
18,
9,
267,
1031,
14,
409,
1805,
521,
8,
10220,
63,
16844,
63,
521,
9,
267,
1982,
63,
14113,
275,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
12,
11430,
15987,
63,
475,
63,
31340,
29,
1708,
63,
30275,
11820,
14113,
418,
267,
702,
63,
1452,
8,
1708,
63,
14113,
12,
1031,
14,
362,
278,
311,
1534,
274,
3410,
8,
1739,
63,
14113,
11820,
8912,
3488,
16,
566,
267,
291,
14,
793,
14,
815,
360,
12105,
1982,
6008,
2410,
1052,
10857,
17374,
908,
8,
288,
6871,
8,
4515,
2687,
10220,
63,
16844,
63,
521,
13,
2373,
63,
521,
7845,
398,
327,
699,
5659,
4573,
334,
26083,
9,
6008,
14,
267,
12717,
63,
14113,
275,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
12,
11430,
15987,
63,
475,
63,
31340,
29,
26083,
63,
30275,
11820,
14113,
418,
398,
327,
12230,
4750,
402,
314,
2653,
325,
12057,
436,
1104,
626,
314,
1676,
4773,
365,
5139,
267,
327,
315,
314,
30330,
14,
267,
17429,
590,
63,
16844,
63,
521,
275,
2397,
63,
521,
435,
5212,
627,
5212,
627,
2653,
446,
959,
267,
1031,
14,
409,
1805,
521,
8,
21078,
590,
63,
16844,
63,
521,
9,
267,
327,
699,
5659,
282,
6008,
465,
314,
23402,
402,
15809,
315,
314,
30330,
365,
1454,
7923,
267,
327,
1380,
282,
892,
6008,
365,
3483,
370,
314,
30330,
14,
267,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
12,
11430,
15987,
63,
475,
63,
31340,
29,
7631,
63,
30275,
17,
9,
267,
291,
14,
793,
14,
815,
360,
774,
1676,
4773,
440,
14721,
2410,
1052,
10857,
17374,
908,
8,
288,
6871,
8,
4515,
2687,
21078,
590,
63,
16844,
63,
521,
13,
2373,
63,
521,
7845,
267,
702,
63,
1452,
8,
2373,
63,
521,
12,
1031,
14,
362,
278,
311,
1534,
274,
3410,
8,
1708,
63,
14113,
11820,
521,
1105,
398,
327,
18244,
1077,
506,
24656,
1522,
687,
314,
30330,
2410,
314,
23402,
900,
267,
327,
965,
3032,
14,
267,
23402,
63,
521,
275,
2397,
63,
521,
435,
5212,
627,
5212,
627,
2653,
435,
959,
267,
1031,
14,
409,
1805,
521,
8,
16844,
63,
521,
9,
267,
327,
437,
13020,
12,
11180,
282,
6008,
880,
314,
23402,
402,
15809,
315,
314,
30330,
365,
7923,
14,
267,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
12,
11430,
15987,
63,
475,
63,
31340,
29,
7631,
63,
30275,
18,
9,
267,
291,
14,
793,
14,
815,
360,
774,
1676,
4773,
23402,
2410,
1052,
10857,
17374,
908,
8,
288,
6871,
8,
4515,
2687,
16844,
63,
521,
13,
2373,
63,
521,
7845,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
21,
12,
283,
10161,
440,
315,
30330,
297,
1816,
1031,
14,
362,
278,
311,
1534,
274,
3410,
12,
1676
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
25455,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
2925,
626,
282,
30330,
6008,
12261,
2410,
282,
1627,
2653,
436,
626,
2399,
199,
3223,
787,
4829,
465,
5521,
14,
199,
199,
18088,
314,
849,
23402,
2653,
3247,
701,
6186,
63,
10293,
19693,
63,
25632,
5782,
436,
282,
922,
199,
318,
262,
461,
23402,
2653,
4799,
314,
2475,
278,
311,
1534,
3113,
1038,
651,
18987,
78,
3524,
1414,
1004,
1423,
199,
27530,
78,
30,
365,
314,
2653,
315,
10857,
9,
787,
12470,
14,
199,
624,
199,
199,
504,
2197,
492,
6871,
199,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
21158,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
334,
272,
702,
63,
1452,
12,
272,
702,
63,
3536,
63,
4354,
63,
705,
12,
199,
9,
199,
504,
511,
63,
4857,
14,
13892,
492,
24954,
55,
9478,
199,
199,
3472,
63,
10293,
19693,
63,
25632,
5782,
275,
650,
1344,
221,
327,
10857,
199,
20519,
63,
10293,
19693,
63,
25632,
5782,
275,
1616,
221,
327,
10857,
421,
199,
533,
603,
2109,
21943,
14000,
651,
774,
8,
4734,
9061,
26203,
304,
272,
347,
663,
63,
396,
63,
1162,
8,
277,
304,
267,
291,
14,
1507,
63,
2415,
275,
413,
267,
291,
14,
2758,
63,
3118,
63,
4429,
275,
715,
339,
347,
511,
63,
5945,
63,
16844,
8,
277,
12,
2653,
304,
267,
408,
2925,
626,
282,
6008,
12261,
2410,
314,
23402,
2653,
436,
2399,
267,
4978,
787,
4829,
465,
5521,
1041,
267,
1031,
275,
291,
14,
2415,
59,
16,
61,
267,
291,
14,
13892,
275,
24954,
55,
9478,
8,
932,
9,
398,
327,
2654,
8321,
333,
1463,
11430,
22101,
370,
314,
20534,
880,
626,
1006,
4773,
83,
26387,
22763,
512,
3617,
14,
267,
291,
14,
13892,
14,
4208,
8,
20,
9,
267,
1031,
14,
4208,
8,
1960,
9,
398,
327,
10217,
282,
1676,
6008,
626,
911,
16667,
14,
267,
1676,
63,
14113,
275,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
11820,
14113,
418,
267,
1676,
63,
30275,
275,
291,
14,
13892,
14,
362,
63,
30275,
8,
14113,
29,
1708,
63,
14113,
9,
267,
12717,
63,
30275,
275,
291,
14,
13892,
14,
362,
63,
30275,
342,
398,
327,
7523,
314,
15809,
781,
3222,
370,
6804,
314,
30330,
1104,
26387,
11430,
22101,
626,
787,
12717,
402,
267,
327,
314,
15809,
3769,
12470,
367,
15399,
14,
267,
6804,
63,
30275,
17,
275,
291,
14,
13892,
14,
362,
63,
30275,
342,
267,
6804,
63,
30275,
18,
275,
291,
14,
13892,
14,
362,
63,
30275,
342,
398,
327,
2494,
314,
1683,
521,
370,
314,
601,
26976,
900,
402,
314,
1676,
6008,
14,
267,
2397,
63,
521,
275,
1031,
14,
362,
278,
311,
1534,
274,
3410,
8,
1708,
63,
14113,
11820,
521,
418,
267,
1031,
14,
409,
1805,
521,
8,
2373,
63,
521,
9,
398,
327,
12230,
12995,
402,
314,
2653,
325,
12057,
436,
11180,
314,
1982,
6008,
2249,
3219,
314,
1676,
6008,
14,
267,
12995,
63,
16844,
63,
521,
275,
2397,
63,
521,
435,
1109,
8,
2259,
627,
5212,
627,
2653,
15,
18,
9,
267,
1031,
14,
409,
1805,
521,
8,
10220,
63,
16844,
63,
521,
9,
267,
1982,
63,
14113,
275,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
12,
11430,
15987,
63,
475,
63,
31340,
29,
1708,
63,
30275,
11820,
14113,
418,
267,
702,
63,
1452,
8,
1708,
63,
14113,
12,
1031,
14,
362,
278,
311,
1534,
274,
3410,
8,
1739,
63,
14113,
11820,
8912,
3488,
16,
566,
267,
291,
14,
793,
14,
815,
360,
12105,
1982,
6008,
2410,
1052,
10857,
17374,
908,
8,
288,
6871,
8,
4515,
2687,
10220,
63,
16844,
63,
521,
13,
2373,
63,
521,
7845,
398,
327,
699,
5659,
4573,
334,
26083,
9,
6008,
14,
267,
12717,
63,
14113,
275,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
12,
11430,
15987,
63,
475,
63,
31340,
29,
26083,
63,
30275,
11820,
14113,
418,
398,
327,
12230,
4750,
402,
314,
2653,
325,
12057,
436,
1104,
626,
314,
1676,
4773,
365,
5139,
267,
327,
315,
314,
30330,
14,
267,
17429,
590,
63,
16844,
63,
521,
275,
2397,
63,
521,
435,
5212,
627,
5212,
627,
2653,
446,
959,
267,
1031,
14,
409,
1805,
521,
8,
21078,
590,
63,
16844,
63,
521,
9,
267,
327,
699,
5659,
282,
6008,
465,
314,
23402,
402,
15809,
315,
314,
30330,
365,
1454,
7923,
267,
327,
1380,
282,
892,
6008,
365,
3483,
370,
314,
30330,
14,
267,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
12,
11430,
15987,
63,
475,
63,
31340,
29,
7631,
63,
30275,
17,
9,
267,
291,
14,
793,
14,
815,
360,
774,
1676,
4773,
440,
14721,
2410,
1052,
10857,
17374,
908,
8,
288,
6871,
8,
4515,
2687,
21078,
590,
63,
16844,
63,
521,
13,
2373,
63,
521,
7845,
267,
702,
63,
1452,
8,
2373,
63,
521,
12,
1031,
14,
362,
278,
311,
1534,
274,
3410,
8,
1708,
63,
14113,
11820,
521,
1105,
398,
327,
18244,
1077,
506,
24656,
1522,
687,
314,
30330,
2410,
314,
23402,
900,
267,
327,
965,
3032,
14,
267,
23402,
63,
521,
275,
2397,
63,
521,
435,
5212,
627,
5212,
627,
2653,
435,
959,
267,
1031,
14,
409,
1805,
521,
8,
16844,
63,
521,
9,
267,
327,
437,
13020,
12,
11180,
282,
6008,
880,
314,
23402,
402,
15809,
315,
314,
30330,
365,
7923,
14,
267,
291,
14,
13892,
14,
2254,
63,
277,
63,
9609,
8,
504,
63,
932,
29,
932,
12,
11430,
15987,
63,
475,
63,
31340,
29,
7631,
63,
30275,
18,
9,
267,
291,
14,
793,
14,
815,
360,
774,
1676,
4773,
23402,
2410,
1052,
10857,
17374,
908,
8,
288,
6871,
8,
4515,
2687,
16844,
63,
521,
13,
2373,
63,
521,
7845,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801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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
] |
huaweiswitch/neutron
|
neutron/openstack/common/network_utils.py
|
41
|
2899
|
# Copyright 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.
"""
Network-related utilities and helper functions.
"""
# TODO(jd) Use six.moves once
# https://bitbucket.org/gutworth/six/pull-request/28
# is merged
try:
import urllib.parse
SplitResult = urllib.parse.SplitResult
except ImportError:
import urlparse
SplitResult = urlparse.SplitResult
from six.moves.urllib import parse
def parse_host_port(address, default_port=None):
"""Interpret a string as a host:port pair.
An IPv6 address MUST be escaped if accompanied by a port,
because otherwise ambiguity ensues: 2001:db8:85a3::8a2e:370:7334
means both [2001:db8:85a3::8a2e:370:7334] and
[2001:db8:85a3::8a2e:370]:7334.
>>> parse_host_port('server01:80')
('server01', 80)
>>> parse_host_port('server01')
('server01', None)
>>> parse_host_port('server01', default_port=1234)
('server01', 1234)
>>> parse_host_port('[::1]:80')
('::1', 80)
>>> parse_host_port('[::1]')
('::1', None)
>>> parse_host_port('[::1]', default_port=1234)
('::1', 1234)
>>> parse_host_port('2001:db8:85a3::8a2e:370:7334', default_port=1234)
('2001:db8:85a3::8a2e:370:7334', 1234)
"""
if address[0] == '[':
# Escaped ipv6
_host, _port = address[1:].split(']')
host = _host
if ':' in _port:
port = _port.split(':')[1]
else:
port = default_port
else:
if address.count(':') == 1:
host, port = address.split(':')
else:
# 0 means ipv4, >1 means ipv6.
# We prohibit unescaped ipv6 addresses with port.
host = address
port = default_port
return (host, None if port is None else int(port))
def urlsplit(url, scheme='', allow_fragments=True):
"""Parse a URL using urlparse.urlsplit(), splitting query and fragments.
This function papers over Python issue9374 when needed.
The parameters are the same as urlparse.urlsplit.
"""
scheme, netloc, path, query, fragment = parse.urlsplit(
url, scheme, allow_fragments)
if allow_fragments and '#' in path:
path, fragment = path.split('#', 1)
if '?' in path:
path, query = path.split('?', 1)
return SplitResult(scheme, netloc, path, query, fragment)
|
apache-2.0
|
[
3,
1898,
6029,
14260,
2752,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
624,
199,
4491,
13,
2407,
15841,
436,
5922,
3423,
14,
199,
624,
199,
199,
3,
3254,
8,
17694,
9,
3645,
3816,
14,
4912,
5403,
199,
3,
4178,
921,
25668,
14,
1308,
15,
71,
337,
584,
273,
15,
4174,
15,
9302,
13,
1069,
15,
1651,
199,
3,
365,
9545,
199,
893,
26,
272,
492,
4011,
14,
1122,
272,
11740,
2889,
275,
4011,
14,
1122,
14,
8862,
2889,
199,
2590,
3545,
26,
272,
492,
7097,
272,
11740,
2889,
275,
7097,
14,
8862,
2889,
199,
199,
504,
3816,
14,
4912,
14,
4078,
492,
2198,
421,
199,
318,
2198,
63,
1102,
63,
719,
8,
1562,
12,
849,
63,
719,
29,
403,
304,
272,
408,
2620,
25133,
282,
1059,
465,
282,
1591,
26,
719,
4092,
14,
339,
1626,
6509,
22,
2287,
18095,
506,
11077,
340,
1066,
863,
290,
5299,
701,
282,
1844,
12,
272,
2952,
4257,
16353,
528,
24180,
655,
3309,
83,
26,
12521,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
26,
2898,
1082,
272,
4910,
3865,
359,
8339,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
26,
2898,
1082,
61,
436,
272,
359,
8339,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
2189,
2898,
1082,
14,
339,
1306,
2198,
63,
1102,
63,
719,
360,
1000,
614,
26,
1257,
358,
272,
661,
1000,
614,
297,
5939,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
1000,
614,
358,
272,
661,
1000,
614,
297,
488,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
1000,
614,
297,
849,
63,
719,
29,
4321,
9,
272,
661,
1000,
614,
297,
14763,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
10345,
17,
2189,
1257,
358,
272,
334,
356,
26,
17,
297,
5939,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
10345,
17,
10374,
272,
334,
356,
26,
17,
297,
488,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
10345,
17,
4300,
849,
63,
719,
29,
4321,
9,
272,
334,
356,
26,
17,
297,
14763,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
8339,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
26,
2898,
1082,
297,
849,
63,
719,
29,
4321,
9,
272,
661,
8339,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
26,
2898,
1082,
297,
14763,
9,
339,
408,
272,
340,
2287,
59,
16,
61,
508,
6730,
356,
267,
327,
21067,
68,
3278,
22,
267,
485,
1102,
12,
485,
719,
275,
2287,
59,
17,
11455,
1294,
360,
10374,
267,
1591,
275,
485,
1102,
267,
340,
10871,
315,
485,
719,
26,
288,
1844,
275,
485,
719,
14,
1294,
24050,
17,
61,
267,
587,
26,
288,
1844,
275,
849,
63,
719,
272,
587,
26,
267,
340,
2287,
14,
835,
11633,
508,
413,
26,
288,
1591,
12,
1844,
275,
2287,
14,
1294,
11633,
267,
587,
26,
288,
327,
378,
4910,
3278,
20,
12,
690,
17,
4910,
3278,
22,
14,
288,
327,
2136,
557,
20215,
390,
625,
13572,
3278,
22,
7149,
543,
1844,
14,
288,
1591,
275,
2287,
288,
1844,
275,
849,
63,
719,
339,
372,
334,
1102,
12,
488,
340,
1844,
365,
488,
587,
1109,
8,
719,
430,
421,
199,
318,
29596,
8,
633,
12,
5687,
4581,
2040,
63,
18047,
29,
549,
304,
272,
408,
4003,
282,
2851,
1808,
7097,
14,
29491,
1062,
26518,
1827,
436,
21495,
14,
272,
961,
805,
299,
439,
1192,
1806,
2018,
4976,
3129,
1342,
1380,
4346,
14,
339,
710,
2633,
787,
314,
2011,
465,
7097,
14,
29491,
14,
272,
408,
272,
5687,
12,
10154,
12,
931,
12,
1827,
12,
7956,
275,
2198,
14,
29491,
8,
267,
1166,
12,
5687,
12,
2040,
63,
18047,
9,
272,
340,
2040,
63,
18047,
436,
19619,
315,
931,
26,
267,
931,
12,
7956,
275,
931,
14,
1294,
7863,
297,
413,
9,
272,
340,
15539,
315,
931,
26,
267,
931,
12,
1827,
275,
931,
14,
1294,
360,
7044,
413,
9,
272,
372,
11740,
2889,
8,
5512,
12,
10154,
12,
931,
12,
1827,
12,
7956,
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
] |
[
1898,
6029,
14260,
2752,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
624,
199,
4491,
13,
2407,
15841,
436,
5922,
3423,
14,
199,
624,
199,
199,
3,
3254,
8,
17694,
9,
3645,
3816,
14,
4912,
5403,
199,
3,
4178,
921,
25668,
14,
1308,
15,
71,
337,
584,
273,
15,
4174,
15,
9302,
13,
1069,
15,
1651,
199,
3,
365,
9545,
199,
893,
26,
272,
492,
4011,
14,
1122,
272,
11740,
2889,
275,
4011,
14,
1122,
14,
8862,
2889,
199,
2590,
3545,
26,
272,
492,
7097,
272,
11740,
2889,
275,
7097,
14,
8862,
2889,
199,
199,
504,
3816,
14,
4912,
14,
4078,
492,
2198,
421,
199,
318,
2198,
63,
1102,
63,
719,
8,
1562,
12,
849,
63,
719,
29,
403,
304,
272,
408,
2620,
25133,
282,
1059,
465,
282,
1591,
26,
719,
4092,
14,
339,
1626,
6509,
22,
2287,
18095,
506,
11077,
340,
1066,
863,
290,
5299,
701,
282,
1844,
12,
272,
2952,
4257,
16353,
528,
24180,
655,
3309,
83,
26,
12521,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
26,
2898,
1082,
272,
4910,
3865,
359,
8339,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
26,
2898,
1082,
61,
436,
272,
359,
8339,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
2189,
2898,
1082,
14,
339,
1306,
2198,
63,
1102,
63,
719,
360,
1000,
614,
26,
1257,
358,
272,
661,
1000,
614,
297,
5939,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
1000,
614,
358,
272,
661,
1000,
614,
297,
488,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
1000,
614,
297,
849,
63,
719,
29,
4321,
9,
272,
661,
1000,
614,
297,
14763,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
10345,
17,
2189,
1257,
358,
272,
334,
356,
26,
17,
297,
5939,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
10345,
17,
10374,
272,
334,
356,
26,
17,
297,
488,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
10345,
17,
4300,
849,
63,
719,
29,
4321,
9,
272,
334,
356,
26,
17,
297,
14763,
9,
272,
1306,
2198,
63,
1102,
63,
719,
360,
8339,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
26,
2898,
1082,
297,
849,
63,
719,
29,
4321,
9,
272,
661,
8339,
26,
697,
24,
26,
2426,
65,
19,
447,
24,
65,
18,
69,
26,
13812,
26,
2898,
1082,
297,
14763,
9,
339,
408,
272,
340,
2287,
59,
16,
61,
508,
6730,
356,
267,
327,
21067,
68,
3278,
22,
267,
485,
1102,
12,
485,
719,
275,
2287,
59,
17,
11455,
1294,
360,
10374,
267,
1591,
275,
485,
1102,
267,
340,
10871,
315,
485,
719,
26,
288,
1844,
275,
485,
719,
14,
1294,
24050,
17,
61,
267,
587,
26,
288,
1844,
275,
849,
63,
719,
272,
587,
26,
267,
340,
2287,
14,
835,
11633,
508,
413,
26,
288,
1591,
12,
1844,
275,
2287,
14,
1294,
11633,
267,
587,
26,
288,
327,
378,
4910,
3278,
20,
12,
690,
17,
4910,
3278,
22,
14,
288,
327,
2136,
557,
20215,
390,
625,
13572,
3278,
22,
7149,
543,
1844,
14,
288,
1591,
275,
2287,
288,
1844,
275,
849,
63,
719,
339,
372,
334,
1102,
12,
488,
340,
1844,
365,
488,
587,
1109,
8,
719,
430,
421,
199,
318,
29596,
8,
633,
12,
5687,
4581,
2040,
63,
18047,
29,
549,
304,
272,
408,
4003,
282,
2851,
1808,
7097,
14,
29491,
1062,
26518,
1827,
436,
21495,
14,
272,
961,
805,
299,
439,
1192,
1806,
2018,
4976,
3129,
1342,
1380,
4346,
14,
339,
710,
2633,
787,
314,
2011,
465,
7097,
14,
29491,
14,
272,
408,
272,
5687,
12,
10154,
12,
931,
12,
1827,
12,
7956,
275,
2198,
14,
29491,
8,
267,
1166,
12,
5687,
12,
2040,
63,
18047,
9,
272,
340,
2040,
63,
18047,
436,
19619,
315,
931,
26,
267,
931,
12,
7956,
275,
931,
14,
1294,
7863,
297,
413,
9,
272,
340,
15539,
315,
931,
26,
267,
931,
12,
1827,
275,
931,
14,
1294,
360,
7044,
413,
9,
272,
372,
11740,
2889,
8,
5512,
12,
10154,
12,
931,
12,
1827,
12,
7956,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
shravan-achar/servo
|
tests/wpt/css-tests/tools/html5lib/html5lib/utils.py
|
982
|
2545
|
from __future__ import absolute_import, division, unicode_literals
from types import ModuleType
try:
import xml.etree.cElementTree as default_etree
except ImportError:
import xml.etree.ElementTree as default_etree
__all__ = ["default_etree", "MethodDispatcher", "isSurrogatePair",
"surrogatePairToCodepoint", "moduleFactoryFactory"]
class MethodDispatcher(dict):
"""Dict with 2 special properties:
On initiation, keys that are lists, sets or tuples are converted to
multiple keys so accessing any one of the items in the original
list-like object returns the matching value
md = MethodDispatcher({("foo", "bar"):"baz"})
md["foo"] == "baz"
A default value which can be set through the default attribute.
"""
def __init__(self, items=()):
# Using _dictEntries instead of directly assigning to self is about
# twice as fast. Please do careful performance testing before changing
# anything here.
_dictEntries = []
for name, value in items:
if type(name) in (list, tuple, frozenset, set):
for item in name:
_dictEntries.append((item, value))
else:
_dictEntries.append((name, value))
dict.__init__(self, _dictEntries)
self.default = None
def __getitem__(self, key):
return dict.get(self, key, self.default)
# Some utility functions to dal with weirdness around UCS2 vs UCS4
# python builds
def isSurrogatePair(data):
return (len(data) == 2 and
ord(data[0]) >= 0xD800 and ord(data[0]) <= 0xDBFF and
ord(data[1]) >= 0xDC00 and ord(data[1]) <= 0xDFFF)
def surrogatePairToCodepoint(data):
char_val = (0x10000 + (ord(data[0]) - 0xD800) * 0x400 +
(ord(data[1]) - 0xDC00))
return char_val
# Module Factory Factory (no, this isn't Java, I know)
# Here to stop this being duplicated all over the place.
def moduleFactoryFactory(factory):
moduleCache = {}
def moduleFactory(baseModule, *args, **kwargs):
if isinstance(ModuleType.__name__, type("")):
name = "_%s_factory" % baseModule.__name__
else:
name = b"_%s_factory" % baseModule.__name__
if name in moduleCache:
return moduleCache[name]
else:
mod = ModuleType(name)
objs = factory(baseModule, *args, **kwargs)
mod.__dict__.update(objs)
moduleCache[name] = mod
return mod
return moduleFactory
|
mpl-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
199,
504,
2943,
492,
5673,
804,
199,
199,
893,
26,
272,
492,
2748,
14,
9464,
14,
67,
15325,
465,
849,
63,
9464,
199,
2590,
3545,
26,
272,
492,
2748,
14,
9464,
14,
15325,
465,
849,
63,
9464,
421,
199,
363,
452,
363,
275,
2097,
885,
63,
9464,
401,
298,
3767,
15461,
401,
298,
374,
11762,
13095,
12882,
401,
1779,
298,
16380,
12882,
1378,
3034,
1403,
401,
298,
578,
2927,
2927,
937,
421,
199,
533,
9075,
15461,
8,
807,
304,
272,
408,
2141,
543,
499,
4539,
4382,
26,
339,
4068,
11023,
425,
12,
2883,
626,
787,
5548,
12,
5951,
503,
6346,
787,
6702,
370,
272,
3663,
2883,
880,
18549,
1263,
1373,
402,
314,
2974,
315,
314,
3379,
272,
769,
13,
2930,
909,
2529,
314,
4877,
574,
339,
6128,
275,
9075,
15461,
2561,
480,
1421,
401,
298,
1700,
2349,
2,
6185,
5984,
272,
6128,
905,
1421,
937,
508,
298,
6185,
2,
339,
437,
849,
574,
1314,
883,
506,
663,
4012,
314,
849,
2225,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
2974,
23603,
267,
327,
11719,
485,
807,
17816,
3140,
402,
5370,
26694,
370,
291,
365,
3595,
267,
327,
13373,
465,
7377,
14,
7754,
886,
25082,
10238,
5343,
2544,
13729,
267,
327,
7003,
2348,
14,
267,
485,
807,
17816,
275,
942,
267,
367,
536,
12,
574,
315,
2974,
26,
288,
340,
730,
8,
354,
9,
315,
334,
513,
12,
2008,
12,
9522,
12,
663,
304,
355,
367,
1242,
315,
536,
26,
490,
485,
807,
17816,
14,
740,
1332,
1053,
12,
574,
430,
288,
587,
26,
355,
485,
807,
17816,
14,
740,
1332,
354,
12,
574,
430,
267,
1211,
855,
826,
721,
277,
12,
485,
807,
17816,
9,
267,
291,
14,
885,
275,
488,
339,
347,
636,
6095,
721,
277,
12,
790,
304,
267,
372,
1211,
14,
362,
8,
277,
12,
790,
12,
291,
14,
885,
9,
421,
199,
3,
6601,
11420,
3423,
370,
366,
279,
543,
22965,
4171,
6818,
21884,
18,
8118,
21884,
20,
199,
3,
2366,
14723,
199,
199,
318,
365,
11762,
13095,
12882,
8,
576,
304,
272,
372,
334,
552,
8,
576,
9,
508,
499,
436,
288,
6206,
8,
576,
59,
16,
566,
2356,
378,
8313,
6718,
436,
6206,
8,
576,
59,
16,
566,
2695,
378,
88,
2846,
1665,
436,
288,
6206,
8,
576,
59,
17,
566,
2356,
378,
88,
5196,
383,
436,
6206,
8,
576,
59,
17,
566,
2695,
378,
8313,
24254,
9,
421,
199,
318,
6296,
13095,
12882,
1378,
3034,
1403,
8,
576,
304,
272,
1495,
63,
637,
275,
334,
16,
88,
9943,
435,
334,
2181,
8,
576,
59,
16,
566,
446,
378,
8313,
6718,
9,
627,
378,
88,
5303,
435,
355,
334,
2181,
8,
576,
59,
17,
566,
446,
378,
88,
5196,
383,
430,
272,
372,
1495,
63,
637,
199,
199,
3,
5673,
23616,
23616,
334,
889,
12,
642,
5712,
1133,
9586,
12,
473,
5715,
9,
199,
3,
11842,
370,
3631,
642,
3769,
21747,
1006,
1806,
314,
4192,
14,
421,
199,
318,
859,
2927,
2927,
8,
3702,
304,
272,
859,
4437,
275,
1052,
339,
347,
859,
2927,
8,
1095,
2377,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
1228,
8,
21820,
855,
354,
3108,
730,
11986,
2298,
288,
536,
275,
2668,
5,
83,
63,
3702,
2,
450,
1300,
2377,
855,
354,
363,
267,
587,
26,
288,
536,
275,
330,
2,
4970,
83,
63,
3702,
2,
450,
1300,
2377,
855,
354,
363,
398,
340,
536,
315,
859,
4437,
26,
288,
372,
859,
4437,
59,
354,
61,
267,
587,
26,
288,
3413,
275,
5673,
804,
8,
354,
9,
288,
13474,
275,
6434,
8,
1095,
2377,
12,
627,
589,
12,
1011,
958,
9,
288,
3413,
855,
807,
4343,
873,
8,
8718,
9,
288,
859,
4437,
59,
354,
61,
275,
3413,
288,
372,
3413,
339,
372,
859,
2927,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
199,
504,
2943,
492,
5673,
804,
199,
199,
893,
26,
272,
492,
2748,
14,
9464,
14,
67,
15325,
465,
849,
63,
9464,
199,
2590,
3545,
26,
272,
492,
2748,
14,
9464,
14,
15325,
465,
849,
63,
9464,
421,
199,
363,
452,
363,
275,
2097,
885,
63,
9464,
401,
298,
3767,
15461,
401,
298,
374,
11762,
13095,
12882,
401,
1779,
298,
16380,
12882,
1378,
3034,
1403,
401,
298,
578,
2927,
2927,
937,
421,
199,
533,
9075,
15461,
8,
807,
304,
272,
408,
2141,
543,
499,
4539,
4382,
26,
339,
4068,
11023,
425,
12,
2883,
626,
787,
5548,
12,
5951,
503,
6346,
787,
6702,
370,
272,
3663,
2883,
880,
18549,
1263,
1373,
402,
314,
2974,
315,
314,
3379,
272,
769,
13,
2930,
909,
2529,
314,
4877,
574,
339,
6128,
275,
9075,
15461,
2561,
480,
1421,
401,
298,
1700,
2349,
2,
6185,
5984,
272,
6128,
905,
1421,
937,
508,
298,
6185,
2,
339,
437,
849,
574,
1314,
883,
506,
663,
4012,
314,
849,
2225,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
2974,
23603,
267,
327,
11719,
485,
807,
17816,
3140,
402,
5370,
26694,
370,
291,
365,
3595,
267,
327,
13373,
465,
7377,
14,
7754,
886,
25082,
10238,
5343,
2544,
13729,
267,
327,
7003,
2348,
14,
267,
485,
807,
17816,
275,
942,
267,
367,
536,
12,
574,
315,
2974,
26,
288,
340,
730,
8,
354,
9,
315,
334,
513,
12,
2008,
12,
9522,
12,
663,
304,
355,
367,
1242,
315,
536,
26,
490,
485,
807,
17816,
14,
740,
1332,
1053,
12,
574,
430,
288,
587,
26,
355,
485,
807,
17816,
14,
740,
1332,
354,
12,
574,
430,
267,
1211,
855,
826,
721,
277,
12,
485,
807,
17816,
9,
267,
291,
14,
885,
275,
488,
339,
347,
636,
6095,
721,
277,
12,
790,
304,
267,
372,
1211,
14,
362,
8,
277,
12,
790,
12,
291,
14,
885,
9,
421,
199,
3,
6601,
11420,
3423,
370,
366,
279,
543,
22965,
4171,
6818,
21884,
18,
8118,
21884,
20,
199,
3,
2366,
14723,
199,
199,
318,
365,
11762,
13095,
12882,
8,
576,
304,
272,
372,
334,
552,
8,
576,
9,
508,
499,
436,
288,
6206,
8,
576,
59,
16,
566,
2356,
378,
8313,
6718,
436,
6206,
8,
576,
59,
16,
566,
2695,
378,
88,
2846,
1665,
436,
288,
6206,
8,
576,
59,
17,
566,
2356,
378,
88,
5196,
383,
436,
6206,
8,
576,
59,
17,
566,
2695,
378,
8313,
24254,
9,
421,
199,
318,
6296,
13095,
12882,
1378,
3034,
1403,
8,
576,
304,
272,
1495,
63,
637,
275,
334,
16,
88,
9943,
435,
334,
2181,
8,
576,
59,
16,
566,
446,
378,
8313,
6718,
9,
627,
378,
88,
5303,
435,
355,
334,
2181,
8,
576,
59,
17,
566,
446,
378,
88,
5196,
383,
430,
272,
372,
1495,
63,
637,
199,
199,
3,
5673,
23616,
23616,
334,
889,
12,
642,
5712,
1133,
9586,
12,
473,
5715,
9,
199,
3,
11842,
370,
3631,
642,
3769,
21747,
1006,
1806,
314,
4192,
14,
421,
199,
318,
859,
2927,
2927,
8,
3702,
304,
272,
859,
4437,
275,
1052,
339,
347,
859,
2927,
8,
1095,
2377,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
1228,
8,
21820,
855,
354,
3108,
730,
11986,
2298,
288,
536,
275,
2668,
5,
83,
63,
3702,
2,
450,
1300,
2377,
855,
354,
363,
267,
587,
26,
288,
536,
275,
330,
2,
4970,
83,
63,
3702,
2,
450,
1300,
2377,
855,
354,
363,
398,
340,
536,
315,
859,
4437,
26,
288,
372,
859,
4437,
59,
354,
61,
267,
587,
26,
288,
3413,
275,
5673,
804,
8,
354,
9,
288,
13474,
275,
6434,
8,
1095,
2377,
12,
627,
589,
12,
1011,
958,
9,
288,
3413,
855,
807,
4343,
873,
8,
8718,
9,
288,
859,
4437,
59,
354,
61,
275,
3413,
288,
372,
3413,
339,
372,
859,
2927,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
rue89-tech/edx-platform
|
common/lib/xmodule/xmodule/modulestore/tests/test_contentstore.py
|
87
|
8284
|
"""
Test contentstore.mongo functionality
"""
import logging
from uuid import uuid4
import unittest
import mimetypes
from tempfile import mkdtemp
import path
import shutil
from opaque_keys.edx.locator import CourseLocator, AssetLocator
from opaque_keys.edx.keys import AssetKey
from xmodule.tests import DATA_DIR
from xmodule.contentstore.mongo import MongoContentStore
from xmodule.contentstore.content import StaticContent
from xmodule.exceptions import NotFoundError
import ddt
from __builtin__ import delattr
from xmodule.modulestore.tests.mongo_connection import MONGO_PORT_NUM, MONGO_HOST
log = logging.getLogger(__name__)
HOST = MONGO_HOST
PORT = MONGO_PORT_NUM
DB = 'test_mongo_%s' % uuid4().hex[:5]
@ddt.ddt
class TestContentstore(unittest.TestCase):
"""
Test the methods in contentstore.mongo using deprecated and non-deprecated keys
"""
# don't use these 2 class vars as they restore behavior once the tests are done
asset_deprecated = None
ssck_deprecated = None
@classmethod
def tearDownClass(cls):
"""
Restores deprecated values
"""
if cls.asset_deprecated is not None:
setattr(AssetLocator, 'deprecated', cls.asset_deprecated)
else:
delattr(AssetLocator, 'deprecated')
if cls.ssck_deprecated is not None:
setattr(CourseLocator, 'deprecated', cls.ssck_deprecated)
else:
delattr(CourseLocator, 'deprecated')
return super(TestContentstore, cls).tearDownClass()
def set_up_assets(self, deprecated):
"""
Setup contentstore w/ proper overriding of deprecated.
"""
# since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
# as well
self.contentstore = MongoContentStore(HOST, DB, port=PORT)
self.addCleanup(self.contentstore._drop_database) # pylint: disable=protected-access
setattr(AssetLocator, 'deprecated', deprecated)
setattr(CourseLocator, 'deprecated', deprecated)
self.course1_key = CourseLocator('test', 'asset_test', '2014_07')
self.course2_key = CourseLocator('test', 'asset_test2', '2014_07')
self.course1_files = ['contains.sh', 'picture1.jpg', 'picture2.jpg']
self.course2_files = ['picture1.jpg', 'picture3.jpg', 'door_2.ogg']
def load_assets(course_key, files):
locked = False
for filename in files:
asset_key = course_key.make_asset_key('asset', filename)
self.save_asset(filename, asset_key, filename, locked)
locked = not locked
load_assets(self.course1_key, self.course1_files)
load_assets(self.course2_key, self.course2_files)
def save_asset(self, filename, asset_key, displayname, locked):
"""
Load and save the given file.
"""
with open("{}/static/{}".format(DATA_DIR, filename), "rb") as f:
content = StaticContent(
asset_key, displayname, mimetypes.guess_type(filename)[0], f.read(),
locked=locked
)
self.contentstore.save(content)
@ddt.data(True, False)
def test_delete(self, deprecated):
"""
Test that deleting assets works
"""
self.set_up_assets(deprecated)
asset_key = self.course1_key.make_asset_key('asset', self.course1_files[0])
self.contentstore.delete(asset_key)
with self.assertRaises(NotFoundError):
self.contentstore.find(asset_key)
# ensure deleting a non-existent file is a noop
self.contentstore.delete(asset_key)
@ddt.data(True, False)
def test_find(self, deprecated):
"""
Test using find
"""
self.set_up_assets(deprecated)
asset_key = self.course1_key.make_asset_key('asset', self.course1_files[0])
self.assertIsNotNone(self.contentstore.find(asset_key), "Could not find {}".format(asset_key))
self.assertIsNotNone(self.contentstore.find(asset_key, as_stream=True), "Could not find {}".format(asset_key))
unknown_asset = self.course1_key.make_asset_key('asset', 'no_such_file.gif')
with self.assertRaises(NotFoundError):
self.contentstore.find(unknown_asset)
self.assertIsNone(
self.contentstore.find(unknown_asset, throw_on_not_found=False),
"Found unknown asset {}".format(unknown_asset)
)
@ddt.data(True, False)
def test_export_for_course(self, deprecated):
"""
Test export
"""
self.set_up_assets(deprecated)
root_dir = path.path(mkdtemp())
try:
self.contentstore.export_all_for_course(
self.course1_key, root_dir,
path.path(root_dir / "policy.json"),
)
for filename in self.course1_files:
filepath = path.path(root_dir / filename)
self.assertTrue(filepath.isfile(), "{} is not a file".format(filepath))
for filename in self.course2_files:
if filename not in self.course1_files:
filepath = path.path(root_dir / filename)
self.assertFalse(filepath.isfile(), "{} is unexpected exported a file".format(filepath))
finally:
shutil.rmtree(root_dir)
@ddt.data(True, False)
def test_get_all_content(self, deprecated):
"""
Test get_all_content_for_course
"""
self.set_up_assets(deprecated)
course1_assets, count = self.contentstore.get_all_content_for_course(self.course1_key)
self.assertEqual(count, len(self.course1_files), course1_assets)
for asset in course1_assets:
parsed = AssetKey.from_string(asset['filename'])
self.assertIn(parsed.name, self.course1_files)
course1_assets, __ = self.contentstore.get_all_content_for_course(self.course1_key, 1, 1)
self.assertEqual(len(course1_assets), 1, course1_assets)
fake_course = CourseLocator('test', 'fake', 'non')
course_assets, count = self.contentstore.get_all_content_for_course(fake_course)
self.assertEqual(count, 0)
self.assertEqual(course_assets, [])
@ddt.data(True, False)
def test_attrs(self, deprecated):
"""
Test setting and getting attrs
"""
self.set_up_assets(deprecated)
for filename in self.course1_files:
asset_key = self.course1_key.make_asset_key('asset', filename)
prelocked = self.contentstore.get_attr(asset_key, 'locked', False)
self.contentstore.set_attr(asset_key, 'locked', not prelocked)
self.assertEqual(self.contentstore.get_attr(asset_key, 'locked', False), not prelocked)
@ddt.data(True, False)
def test_copy_assets(self, deprecated):
"""
copy_all_course_assets
"""
self.set_up_assets(deprecated)
dest_course = CourseLocator('test', 'destination', 'copy')
self.contentstore.copy_all_course_assets(self.course1_key, dest_course)
for filename in self.course1_files:
asset_key = self.course1_key.make_asset_key('asset', filename)
dest_key = dest_course.make_asset_key('asset', filename)
source = self.contentstore.find(asset_key)
copied = self.contentstore.find(dest_key)
for propname in ['name', 'content_type', 'length', 'locked']:
self.assertEqual(getattr(source, propname), getattr(copied, propname))
__, count = self.contentstore.get_all_content_for_course(dest_course)
self.assertEqual(count, len(self.course1_files))
@ddt.data(True, False)
def test_delete_assets(self, deprecated):
"""
delete_all_course_assets
"""
self.set_up_assets(deprecated)
self.contentstore.delete_all_course_assets(self.course1_key)
__, count = self.contentstore.get_all_content_for_course(self.course1_key)
self.assertEqual(count, 0)
# ensure it didn't remove any from other course
__, count = self.contentstore.get_all_content_for_course(self.course2_key)
self.assertEqual(count, len(self.course2_files))
|
agpl-3.0
|
[
624,
199,
1379,
23061,
14,
9217,
9330,
199,
624,
199,
646,
2050,
199,
504,
5377,
492,
5377,
20,
199,
646,
2882,
199,
646,
13290,
199,
504,
5549,
492,
31781,
199,
646,
931,
199,
646,
5145,
199,
199,
504,
15058,
63,
1612,
14,
8268,
14,
6354,
492,
31480,
12,
25670,
10725,
199,
504,
15058,
63,
1612,
14,
8268,
14,
1612,
492,
25670,
1197,
199,
504,
9872,
14,
2219,
492,
7126,
63,
3022,
199,
504,
9872,
14,
28160,
14,
9217,
492,
13503,
2714,
5502,
199,
504,
9872,
14,
28160,
14,
1317,
492,
13599,
2714,
199,
504,
9872,
14,
3924,
492,
21909,
547,
199,
646,
366,
3583,
199,
504,
636,
5351,
363,
492,
24358,
199,
504,
9872,
14,
10012,
14,
2219,
14,
9217,
63,
2105,
492,
603,
26477,
63,
3657,
63,
7125,
12,
603,
26477,
63,
5449,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
5449,
275,
603,
26477,
63,
5449,
199,
3657,
275,
603,
26477,
63,
3657,
63,
7125,
199,
2846,
275,
283,
396,
63,
9217,
4970,
83,
7,
450,
5377,
20,
1252,
4097,
1491,
21,
61,
421,
199,
32,
11138,
14,
11138,
199,
533,
1379,
2714,
1617,
8,
2796,
14,
1746,
304,
272,
408,
272,
1379,
314,
3102,
315,
23061,
14,
9217,
1808,
5906,
436,
2222,
13,
6667,
2883,
272,
408,
339,
327,
2793,
1133,
675,
3520,
499,
1021,
6802,
465,
2985,
9066,
5953,
5403,
314,
2295,
787,
4224,
272,
8977,
63,
6667,
275,
488,
272,
10110,
346,
63,
6667,
275,
488,
339,
768,
3744,
272,
347,
24468,
8,
1886,
304,
267,
408,
267,
799,
18958,
5906,
1338,
267,
408,
267,
340,
843,
14,
6562,
63,
6667,
365,
440,
488,
26,
288,
5371,
8,
19979,
10725,
12,
283,
6667,
297,
843,
14,
6562,
63,
6667,
9,
267,
587,
26,
288,
24358,
8,
19979,
10725,
12,
283,
6667,
358,
267,
340,
843,
14,
385,
346,
63,
6667,
365,
440,
488,
26,
288,
5371,
8,
6979,
10725,
12,
283,
6667,
297,
843,
14,
385,
346,
63,
6667,
9,
267,
587,
26,
288,
24358,
8,
6979,
10725,
12,
283,
6667,
358,
267,
372,
1613,
8,
774,
2714,
1617,
12,
843,
680,
12336,
2543,
342,
339,
347,
663,
63,
384,
63,
12186,
8,
277,
12,
5906,
304,
267,
408,
267,
12439,
23061,
336,
15,
5576,
18972,
402,
5906,
14,
267,
408,
267,
327,
3967,
13503,
14389,
436,
13503,
2714,
5502,
787,
26014,
10826,
370,
506,
10451,
12,
1218,
642,
1021,
267,
327,
465,
5521,
267,
291,
14,
28160,
275,
13503,
2714,
5502,
8,
5449,
12,
6249,
12,
1844,
29,
3657,
9,
267,
291,
14,
12808,
8,
277,
14,
28160,
423,
4824,
63,
4659,
9,
221,
327,
4287,
26,
3507,
29,
6798,
13,
2732,
398,
5371,
8,
19979,
10725,
12,
283,
6667,
297,
5906,
9,
267,
5371,
8,
6979,
10725,
12,
283,
6667,
297,
5906,
9,
398,
291,
14,
1972,
17,
63,
498,
275,
31480,
360,
396,
297,
283,
6562,
63,
396,
297,
283,
7280,
63,
1780,
358,
267,
291,
14,
1972,
18,
63,
498,
275,
31480,
360,
396,
297,
283,
6562,
63,
396,
18,
297,
283,
7280,
63,
1780,
358,
398,
291,
14,
1972,
17,
63,
1725,
275,
788,
6134,
14,
609,
297,
283,
12538,
17,
14,
8476,
297,
283,
12538,
18,
14,
8476,
418,
267,
291,
14,
1972,
18,
63,
1725,
275,
788,
12538,
17,
14,
8476,
297,
283,
12538,
19,
14,
8476,
297,
283,
20842,
63,
18,
14,
24798,
418,
398,
347,
2248,
63,
12186,
8,
1972,
63,
498,
12,
1584,
304,
288,
14233,
275,
756,
288,
367,
1788,
315,
1584,
26,
355,
8977,
63,
498,
275,
2518,
63,
498,
14,
1875,
63,
6562,
63,
498,
360,
6562,
297,
1788,
9,
355,
291,
14,
2117,
63,
6562,
8,
1501,
12,
8977,
63,
498,
12,
1788,
12,
14233,
9,
355,
14233,
275,
440,
14233,
398,
2248,
63,
12186,
8,
277,
14,
1972,
17,
63,
498,
12,
291,
14,
1972,
17,
63,
1725,
9,
267,
2248,
63,
12186,
8,
277,
14,
1972,
18,
63,
498,
12,
291,
14,
1972,
18,
63,
1725,
9,
339,
347,
3354,
63,
6562,
8,
277,
12,
1788,
12,
8977,
63,
498,
12,
2929,
354,
12,
14233,
304,
267,
408,
267,
7190,
436,
3354,
314,
1627,
570,
14,
267,
408,
267,
543,
1551,
20794,
15,
1986,
15,
13536,
908,
8,
3998,
63,
3022,
12,
1788,
395,
298,
4848,
531,
465,
289,
26,
288,
1564,
275,
13599,
2714,
8,
355,
8977,
63,
498,
12,
2929,
354,
12,
13290,
14,
11636,
63,
466,
8,
1501,
2788,
16,
467,
289,
14,
739,
1062,
355,
14233,
29,
9325,
288,
776,
288,
291,
14,
28160,
14,
2117,
8,
1317,
9,
339,
768,
11138,
14,
576,
8,
549,
12,
756,
9,
272,
347,
511,
63,
1807,
8,
277,
12,
5906,
304,
267,
408,
267,
1379,
626,
13794,
17202,
5419,
267,
408,
267,
291,
14,
409,
63,
384,
63,
12186,
8,
6667,
9,
267,
8977,
63,
498,
275,
291,
14,
1972,
17,
63,
498,
14,
1875,
63,
6562,
63,
498,
360,
6562,
297,
291,
14,
1972,
17,
63,
1725,
59,
16,
566,
267,
291,
14,
28160,
14,
1807,
8,
6562,
63,
498,
9,
398,
543,
291,
14,
1855,
8,
10870,
304,
288,
291,
14,
28160,
14,
1623,
8,
6562,
63,
498,
9,
398,
327,
4868,
13794,
282,
2222,
13,
15025,
570,
365,
282,
29689,
267,
291,
14,
28160,
14,
1807,
8,
6562,
63,
498,
9,
339,
768,
11138,
14,
576,
8,
549,
12,
756,
9,
272,
347,
511,
63,
1623,
8,
277,
12,
5906,
304,
267,
408,
267,
1379,
1808,
2342,
267,
408,
267,
291,
14,
409,
63,
384,
63,
12186,
8,
6667,
9,
267,
8977,
63,
498,
275,
291,
14,
1972,
17,
63,
498,
14,
1875,
63,
6562,
63,
498,
360,
6562,
297,
291,
14,
1972,
17,
63,
1725,
59,
16,
566,
267,
291,
14,
10389,
8,
277,
14,
28160,
14,
1623,
8,
6562,
63,
498,
395,
298,
6531,
440,
2342,
8352,
908,
8,
6562,
63,
498,
430,
398,
291,
14,
10389,
8,
277,
14,
28160,
14,
1623,
8,
6562,
63,
498,
12,
465,
63,
1745,
29,
549,
395,
298,
6531,
440,
2342,
8352,
908,
8,
6562,
63,
498,
430,
398,
5809,
63,
6562,
275,
291,
14,
1972,
17,
63,
498,
14,
1875,
63,
6562,
63,
498
] |
[
199,
1379,
23061,
14,
9217,
9330,
199,
624,
199,
646,
2050,
199,
504,
5377,
492,
5377,
20,
199,
646,
2882,
199,
646,
13290,
199,
504,
5549,
492,
31781,
199,
646,
931,
199,
646,
5145,
199,
199,
504,
15058,
63,
1612,
14,
8268,
14,
6354,
492,
31480,
12,
25670,
10725,
199,
504,
15058,
63,
1612,
14,
8268,
14,
1612,
492,
25670,
1197,
199,
504,
9872,
14,
2219,
492,
7126,
63,
3022,
199,
504,
9872,
14,
28160,
14,
9217,
492,
13503,
2714,
5502,
199,
504,
9872,
14,
28160,
14,
1317,
492,
13599,
2714,
199,
504,
9872,
14,
3924,
492,
21909,
547,
199,
646,
366,
3583,
199,
504,
636,
5351,
363,
492,
24358,
199,
504,
9872,
14,
10012,
14,
2219,
14,
9217,
63,
2105,
492,
603,
26477,
63,
3657,
63,
7125,
12,
603,
26477,
63,
5449,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
5449,
275,
603,
26477,
63,
5449,
199,
3657,
275,
603,
26477,
63,
3657,
63,
7125,
199,
2846,
275,
283,
396,
63,
9217,
4970,
83,
7,
450,
5377,
20,
1252,
4097,
1491,
21,
61,
421,
199,
32,
11138,
14,
11138,
199,
533,
1379,
2714,
1617,
8,
2796,
14,
1746,
304,
272,
408,
272,
1379,
314,
3102,
315,
23061,
14,
9217,
1808,
5906,
436,
2222,
13,
6667,
2883,
272,
408,
339,
327,
2793,
1133,
675,
3520,
499,
1021,
6802,
465,
2985,
9066,
5953,
5403,
314,
2295,
787,
4224,
272,
8977,
63,
6667,
275,
488,
272,
10110,
346,
63,
6667,
275,
488,
339,
768,
3744,
272,
347,
24468,
8,
1886,
304,
267,
408,
267,
799,
18958,
5906,
1338,
267,
408,
267,
340,
843,
14,
6562,
63,
6667,
365,
440,
488,
26,
288,
5371,
8,
19979,
10725,
12,
283,
6667,
297,
843,
14,
6562,
63,
6667,
9,
267,
587,
26,
288,
24358,
8,
19979,
10725,
12,
283,
6667,
358,
267,
340,
843,
14,
385,
346,
63,
6667,
365,
440,
488,
26,
288,
5371,
8,
6979,
10725,
12,
283,
6667,
297,
843,
14,
385,
346,
63,
6667,
9,
267,
587,
26,
288,
24358,
8,
6979,
10725,
12,
283,
6667,
358,
267,
372,
1613,
8,
774,
2714,
1617,
12,
843,
680,
12336,
2543,
342,
339,
347,
663,
63,
384,
63,
12186,
8,
277,
12,
5906,
304,
267,
408,
267,
12439,
23061,
336,
15,
5576,
18972,
402,
5906,
14,
267,
408,
267,
327,
3967,
13503,
14389,
436,
13503,
2714,
5502,
787,
26014,
10826,
370,
506,
10451,
12,
1218,
642,
1021,
267,
327,
465,
5521,
267,
291,
14,
28160,
275,
13503,
2714,
5502,
8,
5449,
12,
6249,
12,
1844,
29,
3657,
9,
267,
291,
14,
12808,
8,
277,
14,
28160,
423,
4824,
63,
4659,
9,
221,
327,
4287,
26,
3507,
29,
6798,
13,
2732,
398,
5371,
8,
19979,
10725,
12,
283,
6667,
297,
5906,
9,
267,
5371,
8,
6979,
10725,
12,
283,
6667,
297,
5906,
9,
398,
291,
14,
1972,
17,
63,
498,
275,
31480,
360,
396,
297,
283,
6562,
63,
396,
297,
283,
7280,
63,
1780,
358,
267,
291,
14,
1972,
18,
63,
498,
275,
31480,
360,
396,
297,
283,
6562,
63,
396,
18,
297,
283,
7280,
63,
1780,
358,
398,
291,
14,
1972,
17,
63,
1725,
275,
788,
6134,
14,
609,
297,
283,
12538,
17,
14,
8476,
297,
283,
12538,
18,
14,
8476,
418,
267,
291,
14,
1972,
18,
63,
1725,
275,
788,
12538,
17,
14,
8476,
297,
283,
12538,
19,
14,
8476,
297,
283,
20842,
63,
18,
14,
24798,
418,
398,
347,
2248,
63,
12186,
8,
1972,
63,
498,
12,
1584,
304,
288,
14233,
275,
756,
288,
367,
1788,
315,
1584,
26,
355,
8977,
63,
498,
275,
2518,
63,
498,
14,
1875,
63,
6562,
63,
498,
360,
6562,
297,
1788,
9,
355,
291,
14,
2117,
63,
6562,
8,
1501,
12,
8977,
63,
498,
12,
1788,
12,
14233,
9,
355,
14233,
275,
440,
14233,
398,
2248,
63,
12186,
8,
277,
14,
1972,
17,
63,
498,
12,
291,
14,
1972,
17,
63,
1725,
9,
267,
2248,
63,
12186,
8,
277,
14,
1972,
18,
63,
498,
12,
291,
14,
1972,
18,
63,
1725,
9,
339,
347,
3354,
63,
6562,
8,
277,
12,
1788,
12,
8977,
63,
498,
12,
2929,
354,
12,
14233,
304,
267,
408,
267,
7190,
436,
3354,
314,
1627,
570,
14,
267,
408,
267,
543,
1551,
20794,
15,
1986,
15,
13536,
908,
8,
3998,
63,
3022,
12,
1788,
395,
298,
4848,
531,
465,
289,
26,
288,
1564,
275,
13599,
2714,
8,
355,
8977,
63,
498,
12,
2929,
354,
12,
13290,
14,
11636,
63,
466,
8,
1501,
2788,
16,
467,
289,
14,
739,
1062,
355,
14233,
29,
9325,
288,
776,
288,
291,
14,
28160,
14,
2117,
8,
1317,
9,
339,
768,
11138,
14,
576,
8,
549,
12,
756,
9,
272,
347,
511,
63,
1807,
8,
277,
12,
5906,
304,
267,
408,
267,
1379,
626,
13794,
17202,
5419,
267,
408,
267,
291,
14,
409,
63,
384,
63,
12186,
8,
6667,
9,
267,
8977,
63,
498,
275,
291,
14,
1972,
17,
63,
498,
14,
1875,
63,
6562,
63,
498,
360,
6562,
297,
291,
14,
1972,
17,
63,
1725,
59,
16,
566,
267,
291,
14,
28160,
14,
1807,
8,
6562,
63,
498,
9,
398,
543,
291,
14,
1855,
8,
10870,
304,
288,
291,
14,
28160,
14,
1623,
8,
6562,
63,
498,
9,
398,
327,
4868,
13794,
282,
2222,
13,
15025,
570,
365,
282,
29689,
267,
291,
14,
28160,
14,
1807,
8,
6562,
63,
498,
9,
339,
768,
11138,
14,
576,
8,
549,
12,
756,
9,
272,
347,
511,
63,
1623,
8,
277,
12,
5906,
304,
267,
408,
267,
1379,
1808,
2342,
267,
408,
267,
291,
14,
409,
63,
384,
63,
12186,
8,
6667,
9,
267,
8977,
63,
498,
275,
291,
14,
1972,
17,
63,
498,
14,
1875,
63,
6562,
63,
498,
360,
6562,
297,
291,
14,
1972,
17,
63,
1725,
59,
16,
566,
267,
291,
14,
10389,
8,
277,
14,
28160,
14,
1623,
8,
6562,
63,
498,
395,
298,
6531,
440,
2342,
8352,
908,
8,
6562,
63,
498,
430,
398,
291,
14,
10389,
8,
277,
14,
28160,
14,
1623,
8,
6562,
63,
498,
12,
465,
63,
1745,
29,
549,
395,
298,
6531,
440,
2342,
8352,
908,
8,
6562,
63,
498,
430,
398,
5809,
63,
6562,
275,
291,
14,
1972,
17,
63,
498,
14,
1875,
63,
6562,
63,
498,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
"""Global Defaults"""
import webnotes
import webnotes.defaults
from webnotes.utils import cint
keydict = {
# "key in defaults": "key in Global Defaults"
"print_style": "print_style",
"fiscal_year": "current_fiscal_year",
'company': 'default_company',
'currency': 'default_currency',
'hide_currency_symbol':'hide_currency_symbol',
'date_format': 'date_format',
'number_format': 'number_format',
'float_precision': 'float_precision',
'account_url':'account_url',
'session_expiry': 'session_expiry',
'disable_rounded_total': 'disable_rounded_total',
}
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def on_update(self):
"""update defaults"""
self.validate_session_expiry()
self.update_control_panel()
for key in keydict:
webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
# update year start date and year end date from fiscal_year
year_start_end_date = webnotes.conn.sql("""select year_start_date, year_end_date
from `tabFiscal Year` where name=%s""", self.doc.current_fiscal_year)
ysd = year_start_end_date[0][0] or ''
yed = year_start_end_date[0][1] or ''
if ysd and yed:
webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
webnotes.conn.set_default('year_end_date', yed.strftime('%Y-%m-%d'))
# enable default currency
if self.doc.default_currency:
webnotes.conn.set_value("Currency", self.doc.default_currency, "enabled", 1)
# clear cache
webnotes.clear_cache()
def validate_session_expiry(self):
if self.doc.session_expiry:
parts = self.doc.session_expiry.split(":")
if len(parts)!=2 or not (cint(parts[0]) or cint(parts[1])):
webnotes.msgprint("""Session Expiry must be in format hh:mm""",
raise_exception=1)
def update_control_panel(self):
cp_bean = webnotes.bean("Control Panel")
if self.doc.country:
cp_bean.doc.country = self.doc.country
if self.doc.time_zone:
cp_bean.doc.time_zone = self.doc.time_zone
cp_bean.ignore_permissions = True
cp_bean.save()
def get_defaults(self):
return webnotes.defaults.get_defaults()
|
agpl-3.0
|
[
3,
1898,
334,
67,
9,
6171,
12,
6001,
8144,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
844,
26,
1664,
1696,
1684,
844,
373,
19,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
624,
7025,
7827,
624,
199,
646,
23154,
199,
646,
23154,
14,
4322,
199,
504,
23154,
14,
1208,
492,
286,
442,
199,
199,
498,
807,
275,
469,
199,
198,
3,
298,
498,
315,
4243,
582,
298,
498,
315,
13641,
7827,
2,
199,
198,
2,
1361,
63,
2487,
582,
298,
1361,
63,
2487,
401,
199,
198,
2,
18646,
63,
3403,
582,
298,
1818,
63,
18646,
63,
3403,
401,
199,
198,
7,
4627,
356,
283,
885,
63,
4627,
297,
199,
198,
7,
4968,
356,
283,
885,
63,
4968,
297,
199,
198,
7,
8191,
63,
4968,
63,
5155,
5242,
8191,
63,
4968,
63,
5155,
297,
199,
198,
5121,
323,
63,
908,
356,
283,
602,
63,
908,
297,
199,
198,
7,
1955,
63,
908,
356,
283,
1955,
63,
908,
297,
199,
198,
7,
1609,
63,
6833,
356,
283,
1609,
63,
6833,
297,
199,
198,
7,
2048,
63,
633,
5242,
2048,
63,
633,
297,
199,
198,
1159,
3552,
63,
16844,
356,
283,
1730,
63,
16844,
297,
199,
198,
5121,
374,
461,
63,
25677,
63,
2923,
356,
283,
5993,
63,
25677,
63,
2923,
297,
199,
93,
199,
199,
533,
5454,
804,
26,
199,
198,
318,
636,
826,
721,
277,
12,
366,
12,
15396,
304,
507,
198,
277,
14,
1301,
12,
291,
14,
1301,
513,
275,
366,
12,
15396,
18118,
198,
318,
641,
63,
873,
8,
277,
304,
507,
198,
624,
873,
4243,
624,
507,
198,
277,
14,
3502,
63,
1730,
63,
16844,
342,
507,
198,
277,
14,
873,
63,
2785,
63,
7885,
342,
9068,
198,
509,
790,
315,
790,
807,
26,
686,
198,
30307,
14,
1631,
14,
409,
63,
885,
8,
498,
12,
291,
14,
1301,
14,
955,
14,
362,
8,
498,
807,
59,
498,
467,
12381,
1585,
507,
198,
3,
1678,
5361,
1343,
1434,
436,
5361,
1284,
1434,
687,
18672,
63,
3403,
507,
198,
3403,
63,
928,
63,
500,
63,
602,
275,
23154,
14,
1631,
14,
3009,
4852,
2416,
5361,
63,
928,
63,
602,
12,
5361,
63,
500,
63,
602,
20866,
198,
504,
658,
2902,
38,
15734,
28497,
64,
2382,
536,
2458,
83,
7208,
291,
14,
1301,
14,
1818,
63,
18646,
63,
3403,
9,
2742,
198,
588,
68,
275,
5361,
63,
928,
63,
500,
63,
602,
59,
16,
1527,
16,
61,
503,
2125,
507,
198,
89,
379,
275,
5361,
63,
928,
63,
500,
63,
602,
59,
16,
1527,
17,
61,
503,
2125,
2742,
198,
692,
19205,
68,
436,
612,
379,
26,
686,
198,
30307,
14,
1631,
14,
409,
63,
885,
360,
3403,
63,
928,
63,
602,
297,
19205,
68,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
1333,
686,
198,
30307,
14,
1631,
14,
409,
63,
885,
360,
3403,
63,
500,
63,
602,
297,
612,
379,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
1333,
9068,
198,
3,
4756,
849,
9952,
507,
198,
692,
291,
14,
1301,
14,
885,
63,
4968,
26,
686,
198,
30307,
14,
1631,
14,
409,
63,
585,
480,
19567,
401,
291,
14,
1301,
14,
885,
63,
4968,
12,
298,
3827,
401,
413,
9,
9068,
198,
3,
5436,
2581,
507,
198,
30307,
14,
3584,
63,
1637,
342,
8299,
198,
318,
4107,
63,
1730,
63,
16844,
8,
277,
304,
507,
198,
692,
291,
14,
1301,
14,
1730,
63,
16844,
26,
686,
198,
4181,
275,
291,
14,
1301,
14,
1730,
63,
16844,
14,
1294,
20063,
686,
198,
692,
822,
8,
4181,
9,
1111,
18,
503,
440,
334,
67,
442,
8,
4181,
59,
16,
566,
503,
286,
442,
8,
4181,
59,
17,
18710,
1585,
198,
30307,
14,
1328,
1361,
4852,
4434,
1316,
1038,
651,
1471,
506,
315,
1475,
25783,
26,
596,
7208,
1871,
198,
3730,
63,
1971,
29,
17,
9,
421,
198,
318,
1678,
63,
2785,
63,
7885,
8,
277,
304,
507,
198,
1850,
63,
28142,
275,
23154,
14,
28142,
480,
3717,
510,
4822,
531,
507,
198,
692,
291,
14,
1301,
14,
6063,
26,
686,
198,
1850,
63,
28142,
14,
1301,
14,
6063,
275,
291,
14,
1301,
14,
6063,
507,
198,
692,
291,
14,
1301,
14,
521,
63,
2619,
26,
686,
198,
1850,
63,
28142,
14,
1301,
14,
521,
63,
2619,
275,
291,
14,
1301,
14,
521,
63,
2619,
507,
198,
1850,
63,
28142,
14,
4247,
63,
6060,
275,
715,
507,
198,
1850,
63,
28142,
14,
2117,
342,
421,
198,
318,
664,
63,
4322,
8,
277,
304,
507,
198,
1107,
23154,
14,
4322,
14,
362,
63,
4322,
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
] |
[
1898,
334,
67,
9,
6171,
12,
6001,
8144,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
844,
26,
1664,
1696,
1684,
844,
373,
19,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
624,
7025,
7827,
624,
199,
646,
23154,
199,
646,
23154,
14,
4322,
199,
504,
23154,
14,
1208,
492,
286,
442,
199,
199,
498,
807,
275,
469,
199,
198,
3,
298,
498,
315,
4243,
582,
298,
498,
315,
13641,
7827,
2,
199,
198,
2,
1361,
63,
2487,
582,
298,
1361,
63,
2487,
401,
199,
198,
2,
18646,
63,
3403,
582,
298,
1818,
63,
18646,
63,
3403,
401,
199,
198,
7,
4627,
356,
283,
885,
63,
4627,
297,
199,
198,
7,
4968,
356,
283,
885,
63,
4968,
297,
199,
198,
7,
8191,
63,
4968,
63,
5155,
5242,
8191,
63,
4968,
63,
5155,
297,
199,
198,
5121,
323,
63,
908,
356,
283,
602,
63,
908,
297,
199,
198,
7,
1955,
63,
908,
356,
283,
1955,
63,
908,
297,
199,
198,
7,
1609,
63,
6833,
356,
283,
1609,
63,
6833,
297,
199,
198,
7,
2048,
63,
633,
5242,
2048,
63,
633,
297,
199,
198,
1159,
3552,
63,
16844,
356,
283,
1730,
63,
16844,
297,
199,
198,
5121,
374,
461,
63,
25677,
63,
2923,
356,
283,
5993,
63,
25677,
63,
2923,
297,
199,
93,
199,
199,
533,
5454,
804,
26,
199,
198,
318,
636,
826,
721,
277,
12,
366,
12,
15396,
304,
507,
198,
277,
14,
1301,
12,
291,
14,
1301,
513,
275,
366,
12,
15396,
18118,
198,
318,
641,
63,
873,
8,
277,
304,
507,
198,
624,
873,
4243,
624,
507,
198,
277,
14,
3502,
63,
1730,
63,
16844,
342,
507,
198,
277,
14,
873,
63,
2785,
63,
7885,
342,
9068,
198,
509,
790,
315,
790,
807,
26,
686,
198,
30307,
14,
1631,
14,
409,
63,
885,
8,
498,
12,
291,
14,
1301,
14,
955,
14,
362,
8,
498,
807,
59,
498,
467,
12381,
1585,
507,
198,
3,
1678,
5361,
1343,
1434,
436,
5361,
1284,
1434,
687,
18672,
63,
3403,
507,
198,
3403,
63,
928,
63,
500,
63,
602,
275,
23154,
14,
1631,
14,
3009,
4852,
2416,
5361,
63,
928,
63,
602,
12,
5361,
63,
500,
63,
602,
20866,
198,
504,
658,
2902,
38,
15734,
28497,
64,
2382,
536,
2458,
83,
7208,
291,
14,
1301,
14,
1818,
63,
18646,
63,
3403,
9,
2742,
198,
588,
68,
275,
5361,
63,
928,
63,
500,
63,
602,
59,
16,
1527,
16,
61,
503,
2125,
507,
198,
89,
379,
275,
5361,
63,
928,
63,
500,
63,
602,
59,
16,
1527,
17,
61,
503,
2125,
2742,
198,
692,
19205,
68,
436,
612,
379,
26,
686,
198,
30307,
14,
1631,
14,
409,
63,
885,
360,
3403,
63,
928,
63,
602,
297,
19205,
68,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
1333,
686,
198,
30307,
14,
1631,
14,
409,
63,
885,
360,
3403,
63,
500,
63,
602,
297,
612,
379,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
1333,
9068,
198,
3,
4756,
849,
9952,
507,
198,
692,
291,
14,
1301,
14,
885,
63,
4968,
26,
686,
198,
30307,
14,
1631,
14,
409,
63,
585,
480,
19567,
401,
291,
14,
1301,
14,
885,
63,
4968,
12,
298,
3827,
401,
413,
9,
9068,
198,
3,
5436,
2581,
507,
198,
30307,
14,
3584,
63,
1637,
342,
8299,
198,
318,
4107,
63,
1730,
63,
16844,
8,
277,
304,
507,
198,
692,
291,
14,
1301,
14,
1730,
63,
16844,
26,
686,
198,
4181,
275,
291,
14,
1301,
14,
1730,
63,
16844,
14,
1294,
20063,
686,
198,
692,
822,
8,
4181,
9,
1111,
18,
503,
440,
334,
67,
442,
8,
4181,
59,
16,
566,
503,
286,
442,
8,
4181,
59,
17,
18710,
1585,
198,
30307,
14,
1328,
1361,
4852,
4434,
1316,
1038,
651,
1471,
506,
315,
1475,
25783,
26,
596,
7208,
1871,
198,
3730,
63,
1971,
29,
17,
9,
421,
198,
318,
1678,
63,
2785,
63,
7885,
8,
277,
304,
507,
198,
1850,
63,
28142,
275,
23154,
14,
28142,
480,
3717,
510,
4822,
531,
507,
198,
692,
291,
14,
1301,
14,
6063,
26,
686,
198,
1850,
63,
28142,
14,
1301,
14,
6063,
275,
291,
14,
1301,
14,
6063,
507,
198,
692,
291,
14,
1301,
14,
521,
63,
2619,
26,
686,
198,
1850,
63,
28142,
14,
1301,
14,
521,
63,
2619,
275,
291,
14,
1301,
14,
521,
63,
2619,
507,
198,
1850,
63,
28142,
14,
4247,
63,
6060,
275,
715,
507,
198,
1850,
63,
28142,
14,
2117,
342,
421,
198,
318,
664,
63,
4322,
8,
277,
304,
507,
198,
1107,
23154,
14,
4322,
14,
362,
63,
4322,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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matplotlib.pyplot as plt
from matplotlib import cm
import matplotlib.colors as col
import scipy.ndimage as ni
import ImageAnalysis as ia
try:
import skimage.external.tifffile as tf
except ImportError:
import tifffile as tf
try: import cv2
except ImportError as e: print e
def get_rgb(colorStr):
"""
get R,G,B int value from a hex color string
"""
return int(colorStr[1:3], 16), int(colorStr[3:5], 16), int(colorStr[5:7], 16)
def get_color_str(R, G, B):
"""
get hex color string from R,G,B value (integer with uint8 format)
"""
if not (isinstance(R, (int, long)) and isinstance(G, (int, long)) and isinstance(G, (int, long))):
raise TypeError, 'Input R, G and B should be integer!'
if not ((0 <= R <= 255) and (0 <= G <= 255) and (
0 <= B <= 255)): raise ValueError, 'Input R, G and B should between 0 and 255!'
return '#' + ''.join(map(chr, (R, G, B))).encode('hex')
def binary_2_rgba(img, foregroundColor='#ff0000', backgroundColor='#000000', foregroundAlpha=255, backgroundAlpha=0):
"""
generate display image in (RGBA).(np.uint8) format which can be displayed by imshow
:param img: input image, should be a binary array (np.bool, or np.(u)int
:param foregroundColor: color for 1 in the array, RGB str, i.e. '#ff0000'
:param backgroundColor: color for 0 in the array, RGB str, i.e. '#ff00ff'
:param foregroundAlpha: alpha for 1 in the array, int, 0-255
:param backgroundAlpha: alpha for 1 in the array, int, 0-255
:return: displayImg, (RGBA).(np.uint8) format, ready for imshow
"""
if img.dtype == np.bool:
pass
elif issubclass(img.dtype.type, np.integer):
if np.amin(img) < 0 or np.amax(img) > 1: raise ValueError, 'Values of input image should be either 0 or 1.'
else:
raise TypeError, 'Data type of input image should be either np.bool or integer.'
if type(foregroundAlpha) is int:
if foregroundAlpha < 0 or foregroundAlpha > 255: raise ValueError, 'Value of foreGroundAlpha should be between 0 and 255.'
else:
raise TypeError, 'Data type of foreGroundAlpha should be integer.'
if type(backgroundAlpha) is int:
if backgroundAlpha < 0 or backgroundAlpha > 255: raise ValueError, 'Value of backGroundAlpha should be between 0 and 255.'
else:
raise TypeError, 'Data type of backGroundAlpha should be integer.'
fR, fG, fB = get_rgb(foregroundColor)
bR, bG, bB = get_rgb(backgroundColor)
displayImg = np.zeros((img.shape[0], img.shape[1], 4)).astype(np.uint8)
displayImg[img == 1] = np.array([fR, fG, fB, foregroundAlpha]).astype(np.uint8)
displayImg[img == 0] = np.array([bR, bG, bB, backgroundAlpha]).astype(np.uint8)
return displayImg
def scalar_2_rgba(img, color='#ff0000'):
"""
generate display a image in (RGBA).(np.uint8) format which can be displayed by imshow
alpha is defined by values in the img
:param img: input image
:param alphaMatrix: matrix of alpha
:param foreGroundColor: color for 1 in the array, RGB str, i.e. '#ff0000'
:return: displayImg, (RGBA).(np.uint8) format, ready for imshow
"""
R, G, B = get_rgb(color)
RMatrix = (R * ia.array_nor(img.astype(np.float32))).astype(np.uint8)
GMatrix = (G * ia.array_nor(img.astype(np.float32))).astype(np.uint8)
BMatrix = (B * ia.array_nor(img.astype(np.float32))).astype(np.uint8)
alphaMatrix = (ia.array_nor(img.astype(np.float32)) * 255).astype(np.uint8)
displayImg = np.zeros((img.shape[0], img.shape[1], 4)).astype(np.uint8)
displayImg[:, :, 0] = RMatrix;
displayImg[:, :, 1] = GMatrix;
displayImg[:, :, 2] = BMatrix;
displayImg[:, :, 3] = alphaMatrix
return displayImg
def bar_graph(left,
height,
error,
errorDir='both', # 'both', 'positive' or 'negative'
width=0.1,
plotAxis=None,
lw=3,
faceColor='#000000',
edgeColor='none',
capSize=10,
label=None
):
"""
plot a single bar with error bar
"""
if not plotAxis:
f = plt.figure()
plotAxis = f.add_subplot(111)
if errorDir == 'both':
yerr = error
elif errorDir == 'positive':
yerr = [[0], [error]]
elif errorDir == 'negative':
yerr = [[error], [0]]
plotAxis.errorbar(left + width / 2,
height,
yerr=yerr,
lw=lw,
capsize=capSize,
capthick=lw,
color=edgeColor)
plotAxis.bar(left,
height,
width=width,
color=faceColor,
edgecolor=edgeColor,
lw=lw,
label=label)
return plotAxis
def random_color(numOfColor=10):
"""
generate as list of random colors
"""
numOfColor = int(numOfColor)
colors = []
Cmatrix = (np.random.rand(numOfColor, 3) * 255).astype(np.uint8)
for i in range(numOfColor):
r = hex(Cmatrix[i][0]).split('x')[1]
if len(r) == 1:
r = '0' + r
g = hex(Cmatrix[i][1]).split('x')[1]
if len(g) == 1:
g = '0' + g
b = hex(Cmatrix[i][2]).split('x')[1]
if len(b) == 1:
b = '0' + b
colors.append('#' + r + g + b)
return colors
def show_movie(path, # tif file path or numpy arrary of the movie
mode='raw', # 'raw', 'dF' or 'dFoverF'
baselinePic=None, # picuture of baseline
baselineType='mean', # way to calculate baseline
cmap='gray'):
"""
plot tf movie in the way defined by mode
"""
if isinstance(path, str):
rawMov = tf.imread(path)
elif isinstance(path, np.ndarray):
rawMov = path
if mode == 'raw':
mov = rawMov
else:
_, dFMov, dFoverFMov = ia.normalize_movie(rawMov,
baselinePic=baselinePic,
baselineType=baselineType)
if mode == 'dF':
mov = dFMov
elif mode == 'dFoverF':
mov = dFoverFMov
else:
raise LookupError, 'The "mode" should be "raw", "dF" or "dFoverF"!'
if isinstance(path, str):
tf.imshow(mov,
cmap=cmap,
vmax=np.amax(mov),
vmin=np.amin(mov),
title=mode + ' movie of ' + path)
elif isinstance(path, np.ndarray):
tf.imshow(mov,
cmap=cmap,
vmax=np.amax(mov),
vmin=np.amin(mov),
title=mode + ' Movie')
return mov
def standalone_color_bar(vmin, vmax, cmap, sectionNum=10):
"""
plot a stand alone color bar.
"""
a = np.array([[vmin, vmax]])
plt.figure(figsize=(0.1, 9))
img = plt.imshow(a, cmap=cmap, vmin=vmin, vmax=vmax)
plt.gca().set_visible(False)
cbar = plt.colorbar()
cbar.set_ticks(np.linspace(vmin, vmax, num=sectionNum + 1))
def alpha_blending(image, alphaData, vmin, vmax, cmap='Paired', sectionNum=10, background=-1, interpolation='nearest',
isSave=False, savePath=None):
"""
Generate image with transparency weighted by another matrix.
Plot numpy array 'image' with colormap 'cmap'. And define the tranparency
of each pixel by the value in another numpy array alphaData.
All the elements in alphaData should be non-negative.
"""
if image.shape != alphaData.shape:
raise LookupError, '"image" and "alphaData" should have same shape!!'
if np.amin(alphaData) < 0:
raise ValueError, 'All the elements in alphaData should be bigger than zero.'
# normalize image
image[image > vmax] = vmax
image[image < vmin] = vmin
image = (image - vmin) / (vmax - vmin)
# get colored image of image
exec ('colorImage = cm.' + cmap + '(image)')
# normalize alphadata
alphaDataNor = alphaData / np.amax(alphaData)
alphaDataNor = np.sqrt(alphaDataNor)
colorImage[:, :, 3] = alphaDataNor
# plt.figure()
# plot dummy figure for colorbar
a = np.array([[vmin, vmax]])
plt.imshow(a, cmap=cmap, vmin=vmin, vmax=vmax, alpha=0)
# plt.gca().set_visible(False)
cbar = plt.colorbar()
cbar.set_ticks(np.linspace(vmin, vmax, num=sectionNum + 1))
cbar.set_alpha(1)
cbar.draw_all()
# generate black background
b = np.array(colorImage)
b[:] = background
b[:, :, 3] = 1
plt.imshow(b, cmap='gray')
# plot map
plt.imshow(colorImage, interpolation=interpolation)
return colorImage
def plot_mask(mask, plotAxis=None, color='#ff0000', zoom=1, borderWidth=None, closingIteration=None):
"""
plot mask borders in a given color
"""
if not plotAxis:
f = plt.figure()
plotAxis = f.add_subplot(111)
cmap1 = col.ListedColormap(color, 'temp')
cm.register_cmap(cmap=cmap1)
if zoom != 1:
mask = ni.interpolation.zoom(mask, zoom, order=0)
mask2 = mask.astype(np.float32)
mask2[np.invert(np.isnan(mask2))] = 1.
mask2[np.isnan(mask2)] = 0.
struc = ni.generate_binary_structure(2, 2)
if borderWidth:
border = mask2 - ni.binary_erosion(mask2, struc, iterations=borderWidth).astype(np.float32)
else:
border = mask2 - ni.binary_erosion(mask2, struc).astype(np.float32)
if closingIteration:
border = ni.binary_closing(border, iterations=closingIteration).astype(np.float32)
border[border == 0] = np.nan
currfig = plotAxis.imshow(border, cmap='temp', interpolation='nearest')
return currfig
def plot_mask_borders(mask, plotAxis=None, color='#ff0000', zoom=1, borderWidth=2, closingIteration=None, **kwargs):
"""
plot mask (ROI) borders by using pyplot.contour function. all the 0s and Nans in the input mask will be considered
as background, and non-zero, non-nan pixel will be considered in ROI.
"""
if not plotAxis:
f = plt.figure()
plotAxis = f.add_subplot(111)
plotingMask = np.ones(mask.shape, dtype=np.uint8)
plotingMask[np.logical_or(np.isnan(mask), mask == 0)] = 0
if zoom != 1:
plotingMask = cv2.resize(plotingMask.astype(np.float),
dsize=(int(plotingMask.shape[1] * zoom), int(plotingMask.shape[0] * zoom)))
plotingMask[plotingMask < 0.5] = 0
plotingMask[plotingMask >= 0.5] = 1
plotingMask = plotingMask.astype(np.uint8)
if closingIteration is not None:
plotingMask = ni.binary_closing(plotingMask, iterations=closingIteration).astype(np.uint8)
plotingMask = ni.binary_erosion(plotingMask, iterations=borderWidth)
currfig = plotAxis.contour(plotingMask, levels=[0.5], colors=color, linewidths=borderWidth, **kwargs)
# put y axis in decreasing order
y_lim = list(plotAxis.get_ylim())
y_lim.sort()
plotAxis.set_ylim(y_lim[::-1])
plotAxis.set_aspect('equal')
return currfig
def grid_axis(rowNum, columnNum, totalPlotNum, **kwarg):
"""
return figure handles and axis handels for multiple subplots and figures
"""
figureNum = totalPlotNum // (rowNum * columnNum) + 1
figureHandles = []
for i in range(figureNum):
f = plt.figure(**kwarg)
figureHandles.append(f)
axisHandles = []
for i in range(totalPlotNum):
currFig = figureHandles[i // (rowNum * columnNum)]
currIndex = i % (rowNum * columnNum)
currAxis = currFig.add_subplot(rowNum, columnNum, currIndex + 1)
axisHandles.append(currAxis)
return figureHandles, axisHandles
def tile_axis(f, rowNum, columnNum, topDownMargin=0.05, leftRightMargin=0.05, rowSpacing=0.05, columnSpacing=0.05):
if 2 * topDownMargin + (
(rowNum - 1) * rowSpacing) >= 1: raise ValueError, 'Top down margin or row spacing are too big!'
if 2 * leftRightMargin + (
(columnNum - 1) * columnSpacing) >= 1: raise ValueError, 'Left right margin or column spacing are too big!'
height = (1 - (2 * topDownMargin) - (rowNum - 1) * rowSpacing) / rowNum
width = (1 - (2 * leftRightMargin) - (columnNum - 1) * columnSpacing) / columnNum
xStarts = np.arange(leftRightMargin, 1 - leftRightMargin, (width + columnSpacing))
yStarts = np.arange(topDownMargin, 1 - topDownMargin, (height + rowSpacing))[::-1]
axisList = [[f.add_axes([xStart, yStart, width, height]) for xStart in xStarts] for yStart in yStarts]
return axisList
def save_figure_without_borders(f,
savePath,
removeSuperTitle=True,
**kwargs):
"""
remove borders of a figure
"""
f.gca().get_xaxis().set_visible(False)
f.gca().get_yaxis().set_visible(False)
f.gca().set_title('')
if removeSuperTitle:
f.suptitle('')
f.savefig(savePath, pad_inches=0, bbox_inches='tight', **kwargs)
def merge_normalized_images(imgList, isFilter=True, sigma=50, mergeMethod='mean', dtype=np.float32):
"""
merge images in a list in to one, for each image, local intensity variability will be removed by subtraction of
gaussian filtered image. Then all images will be collapsed by the mergeMethod in to single image
"""
imgList2 = []
for currImg in imgList:
imgList2.append(ia.array_nor(currImg.astype(dtype)))
if mergeMethod == 'mean':
mergedImg = np.mean(np.array(imgList2), axis=0)
elif mergeMethod == 'min':
mergedImg = np.min(np.array(imgList2), axis=0)
elif mergeMethod == 'max':
mergedImg = np.max(np.array(imgList2), axis=0)
elif mergeMethod == 'median':
mergedImg = np.median(np.array(imgList2), axis=0)
if isFilter:
mergedImgf = ni.filters.gaussian_filter(mergedImg.astype(np.float), sigma=sigma)
return ia.array_nor(mergedImg - mergedImgf).astype(dtype)
else:
return ia.array_nor(mergedImg).astype(dtype)
# def hue2RGB(hue):
# """
# get the RGB value as format as hex string from the decimal ratio of hue (from 0 to 1)
# color model as described in:
# https://en.wikipedia.org/wiki/Hue
# """
# if hue < 0: hue = 0
# if hue > 1: hue = 1
# color = colorsys.hsv_to_rgb(hue,1,1)
# color = [int(x*255) for x in color]
# return get_color_str(*color)
#
#
def hot_2_rgb(hot):
"""
get the RGB value as format as hex string from the decimal ratio of hot colormap (from 0 to 1)
"""
if hot < 0: hot = 0
if hot > 1: hot = 1
cmap_hot = plt.get_cmap('hot')
color = cmap_hot(hot)[0:3];
color = [int(x * 255) for x in color]
return get_color_str(*color)
def value_2_rgb(value, cmap):
"""
get the RGB value as format as hex string from the decimal ratio of a given colormap (from 0 to 1)
"""
if value < 0: value = 0
if value > 1: value = 1
cmap = plt.get_cmap(cmap)
color = cmap(value)[0:3];
color = [int(x * 255) for x in color]
return get_color_str(*color)
if __name__ == '__main__':
plt.ioff()
print 'for debug'
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
10502,
641,
31712,
18365,
7105,
4119,
26,
1780,
26,
1165,
6927,
199,
199,
32,
2502,
26,
1335,
324,
90,
199,
624,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
504,
8027,
492,
6904,
199,
646,
8027,
14,
7120,
465,
1048,
199,
646,
7026,
14,
78,
23335,
465,
302,
73,
199,
646,
6047,
13182,
465,
284,
65,
199,
199,
893,
26,
272,
492,
2386,
1569,
14,
5159,
14,
29119,
493,
465,
2833,
199,
2590,
3545,
26,
272,
492,
3367,
556,
493,
465,
2833,
199,
199,
893,
26,
492,
6277,
18,
199,
2590,
3545,
465,
325,
26,
870,
325,
421,
199,
318,
664,
63,
10090,
8,
2326,
2848,
304,
272,
408,
272,
664,
820,
12,
39,
12,
34,
1109,
574,
687,
282,
6318,
3164,
1059,
272,
408,
272,
372,
1109,
8,
2326,
2848,
59,
17,
26,
19,
467,
3193,
395,
1109,
8,
2326,
2848,
59,
19,
26,
21,
467,
3193,
395,
1109,
8,
2326,
2848,
59,
21,
26,
23,
467,
3193,
9,
421,
199,
318,
664,
63,
2326,
63,
495,
8,
50,
12,
598,
12,
699,
304,
272,
408,
272,
664,
6318,
3164,
1059,
687,
820,
12,
39,
12,
34,
574,
334,
4115,
543,
3152,
24,
1475,
9,
272,
408,
272,
340,
440,
334,
6074,
8,
50,
12,
334,
442,
12,
1846,
430,
436,
1228,
8,
39,
12,
334,
442,
12,
1846,
430,
436,
1228,
8,
39,
12,
334,
442,
12,
1846,
15206,
267,
746,
3146,
12,
283,
3205,
820,
12,
598,
436,
699,
1077,
506,
3000,
11213,
339,
340,
440,
3666,
16,
2695,
820,
2695,
5450,
9,
436,
334,
16,
2695,
598,
2695,
5450,
9,
436,
334,
288,
378,
2695,
699,
2695,
5450,
2298,
746,
1722,
12,
283,
3205,
820,
12,
598,
436,
699,
1077,
3382,
378,
436,
5450,
11213,
272,
372,
19619,
435,
6522,
904,
8,
1130,
8,
10194,
12,
334,
50,
12,
598,
12,
699,
23261,
2143,
360,
4097,
358,
421,
199,
318,
3366,
63,
18,
63,
22118,
8,
4060,
12,
24470,
4117,
26431,
556,
993,
297,
8020,
4117,
26431,
3273,
297,
24470,
16192,
29,
2299,
12,
8020,
16192,
29,
16,
304,
272,
408,
272,
3550,
2929,
1834,
315,
334,
21631,
680,
8,
1590,
14,
1635,
24,
9,
1475,
1314,
883,
506,
9080,
701,
284,
706,
1917,
272,
520,
635,
6050,
26,
1324,
1834,
12,
1077,
506,
282,
3366,
1625,
334,
1590,
14,
2245,
12,
503,
980,
14,
8,
85,
9,
442,
272,
520,
635,
24470,
4117,
26,
3164,
367,
413,
315,
314,
1625,
12,
19013,
620,
12,
284,
14,
69,
14,
3943,
556,
993,
7,
272,
520,
635,
8020,
4117,
26,
3164,
367,
378,
315,
314,
1625,
12,
19013,
620,
12,
284,
14,
69,
14,
3943,
556,
383,
556,
7,
272,
520,
635,
24470,
16192,
26,
5131,
367,
413,
315,
314,
1625,
12,
1109,
12,
378,
13,
2299,
272,
520,
635,
8020,
16192,
26,
5131,
367,
413,
315,
314,
1625,
12,
1109,
12,
378,
13,
2299,
272,
520,
1107,
26,
2929,
27261,
12,
334,
21631,
680,
8,
1590,
14,
1635,
24,
9,
1475,
12,
10144,
367,
284,
706,
1917,
272,
408,
339,
340,
6050,
14,
2271,
508,
980,
14,
2245,
26,
267,
986,
272,
916,
11602,
8,
4060,
14,
2271,
14,
466,
12,
980,
14,
4115,
304,
267,
340,
980,
14,
32374,
8,
4060,
9,
665,
378,
503,
980,
14,
65,
988,
8,
4060,
9,
690,
413,
26,
746,
1722,
12,
283,
6550,
402,
1324,
1834,
1077,
506,
1902,
378,
503,
413,
3530,
272,
587,
26,
267,
746,
3146,
12,
283,
1451,
730,
402,
1324,
1834,
1077,
506,
1902,
980,
14,
2245,
503,
3000,
3530,
339,
340,
730,
8,
23801,
16192,
9,
365,
1109,
26,
267,
340,
24470,
16192,
665,
378,
503,
24470,
16192,
690,
5450,
26,
746,
1722,
12,
283,
1110,
402,
11257,
39,
2363,
16192,
1077,
506,
3382,
378,
436,
5450,
3530,
272,
587,
26,
267,
746,
3146,
12,
283,
1451,
730,
402,
11257,
39,
2363,
16192,
1077,
506,
3000,
3530,
339,
340,
730,
8,
7451,
16192,
9,
365,
1109,
26,
267,
340,
8020,
16192,
665,
378,
503,
8020,
16192,
690,
5450,
26,
746,
1722,
12,
283,
1110,
402,
1771,
39,
2363,
16192,
1077,
506,
3382,
378,
436,
5450,
3530,
272,
587,
26,
267,
746,
3146,
12,
283,
1451,
730,
402,
1771,
39,
2363,
16192,
1077,
506,
3000,
3530,
339,
289,
50,
12,
289,
39,
12,
289,
34,
275,
664,
63,
10090,
8,
23801,
4117,
9,
272,
330,
50,
12,
330,
39,
12,
330,
34,
275,
664,
63,
10090,
8,
7451,
4117,
9,
339,
2929,
27261,
275,
980,
14,
4250,
1332,
4060,
14,
1392,
59,
16,
467,
6050,
14,
1392,
59,
17,
467,
841,
4992,
6041,
8,
1590,
14,
1635,
24,
9,
272,
2929,
27261,
59,
4060,
508,
413,
61,
275,
980,
14,
1144,
779,
70,
50,
12,
289,
39,
12,
289,
34,
12,
24470,
16192,
6575,
6041,
8,
1590,
14,
1635,
24,
9,
272,
2929,
27261,
59,
4060,
508,
378,
61,
275,
980,
14,
1144,
779,
66,
50,
12,
330,
39,
12,
330,
34,
12,
8020,
16192,
6575,
6041,
8,
1590,
14,
1635,
24,
9,
339,
372,
2929,
27261,
421,
199,
318,
6917,
63,
18,
63,
22118,
8,
4060,
12,
3164,
26431,
556,
993,
735,
272,
408,
272,
3550,
2929,
282,
1834,
315,
334,
21631,
680,
8,
1590,
14,
1635,
24,
9,
1475,
1314,
883,
506,
9080,
701,
284,
706,
1917,
272,
5131,
365,
3247,
701,
1338,
315,
314,
6050,
272,
520,
635,
6050,
26,
1324,
1834,
272,
520,
635,
5131,
6443,
26,
3634,
402,
5131,
272,
520,
635,
11257,
39,
2363,
4117,
26,
3164,
367,
413,
315,
314,
1625,
12,
19013,
620,
12,
284,
14,
69,
14,
3943,
556,
993,
7,
272,
520,
1107,
26,
2929,
27261,
12,
334,
21631,
680,
8,
1590,
14,
1635,
24,
9,
1475,
12,
10144,
367,
284,
706,
1917,
272,
408,
339,
820,
12,
598,
12,
699,
275,
664,
63,
10090,
8,
2326,
9,
339,
820,
6443,
275,
334,
50,
627,
284,
65,
14,
1144,
63,
6505,
8,
4060,
14,
6041,
8,
1590,
14,
1609,
708,
23261,
6041,
8,
1590,
14,
1635,
24,
9,
272,
598,
6443,
275,
334,
39,
627,
284,
65,
14,
1144,
63,
6505
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
10502,
641,
31712,
18365,
7105,
4119,
26,
1780,
26,
1165,
6927,
199,
199,
32,
2502,
26,
1335,
324,
90,
199,
624,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
504,
8027,
492,
6904,
199,
646,
8027,
14,
7120,
465,
1048,
199,
646,
7026,
14,
78,
23335,
465,
302,
73,
199,
646,
6047,
13182,
465,
284,
65,
199,
199,
893,
26,
272,
492,
2386,
1569,
14,
5159,
14,
29119,
493,
465,
2833,
199,
2590,
3545,
26,
272,
492,
3367,
556,
493,
465,
2833,
199,
199,
893,
26,
492,
6277,
18,
199,
2590,
3545,
465,
325,
26,
870,
325,
421,
199,
318,
664,
63,
10090,
8,
2326,
2848,
304,
272,
408,
272,
664,
820,
12,
39,
12,
34,
1109,
574,
687,
282,
6318,
3164,
1059,
272,
408,
272,
372,
1109,
8,
2326,
2848,
59,
17,
26,
19,
467,
3193,
395,
1109,
8,
2326,
2848,
59,
19,
26,
21,
467,
3193,
395,
1109,
8,
2326,
2848,
59,
21,
26,
23,
467,
3193,
9,
421,
199,
318,
664,
63,
2326,
63,
495,
8,
50,
12,
598,
12,
699,
304,
272,
408,
272,
664,
6318,
3164,
1059,
687,
820,
12,
39,
12,
34,
574,
334,
4115,
543,
3152,
24,
1475,
9,
272,
408,
272,
340,
440,
334,
6074,
8,
50,
12,
334,
442,
12,
1846,
430,
436,
1228,
8,
39,
12,
334,
442,
12,
1846,
430,
436,
1228,
8,
39,
12,
334,
442,
12,
1846,
15206,
267,
746,
3146,
12,
283,
3205,
820,
12,
598,
436,
699,
1077,
506,
3000,
11213,
339,
340,
440,
3666,
16,
2695,
820,
2695,
5450,
9,
436,
334,
16,
2695,
598,
2695,
5450,
9,
436,
334,
288,
378,
2695,
699,
2695,
5450,
2298,
746,
1722,
12,
283,
3205,
820,
12,
598,
436,
699,
1077,
3382,
378,
436,
5450,
11213,
272,
372,
19619,
435,
6522,
904,
8,
1130,
8,
10194,
12,
334,
50,
12,
598,
12,
699,
23261,
2143,
360,
4097,
358,
421,
199,
318,
3366,
63,
18,
63,
22118,
8,
4060,
12,
24470,
4117,
26431,
556,
993,
297,
8020,
4117,
26431,
3273,
297,
24470,
16192,
29,
2299,
12,
8020,
16192,
29,
16,
304,
272,
408,
272,
3550,
2929,
1834,
315,
334,
21631,
680,
8,
1590,
14,
1635,
24,
9,
1475,
1314,
883,
506,
9080,
701,
284,
706,
1917,
272,
520,
635,
6050,
26,
1324,
1834,
12,
1077,
506,
282,
3366,
1625,
334,
1590,
14,
2245,
12,
503,
980,
14,
8,
85,
9,
442,
272,
520,
635,
24470,
4117,
26,
3164,
367,
413,
315,
314,
1625,
12,
19013,
620,
12,
284,
14,
69,
14,
3943,
556,
993,
7,
272,
520,
635,
8020,
4117,
26,
3164,
367,
378,
315,
314,
1625,
12,
19013,
620,
12,
284,
14,
69,
14,
3943,
556,
383,
556,
7,
272,
520,
635,
24470,
16192,
26,
5131,
367,
413,
315,
314,
1625,
12,
1109,
12,
378,
13,
2299,
272,
520,
635,
8020,
16192,
26,
5131,
367,
413,
315,
314,
1625,
12,
1109,
12,
378,
13,
2299,
272,
520,
1107,
26,
2929,
27261,
12,
334,
21631,
680,
8,
1590,
14,
1635,
24,
9,
1475,
12,
10144,
367,
284,
706,
1917,
272,
408,
339,
340,
6050,
14,
2271,
508,
980,
14,
2245,
26,
267,
986,
272,
916,
11602,
8,
4060,
14,
2271,
14,
466,
12,
980,
14,
4115,
304,
267,
340,
980,
14,
32374,
8,
4060,
9,
665,
378,
503,
980,
14,
65,
988,
8,
4060,
9,
690,
413,
26,
746,
1722,
12,
283,
6550,
402,
1324,
1834,
1077,
506,
1902,
378,
503,
413,
3530,
272,
587,
26,
267,
746,
3146,
12,
283,
1451,
730,
402,
1324,
1834,
1077,
506,
1902,
980,
14,
2245,
503,
3000,
3530,
339,
340,
730,
8,
23801,
16192,
9,
365,
1109,
26,
267,
340,
24470,
16192,
665,
378,
503,
24470,
16192,
690,
5450,
26,
746,
1722,
12,
283,
1110,
402,
11257,
39,
2363,
16192,
1077,
506,
3382,
378,
436,
5450,
3530,
272,
587,
26,
267,
746,
3146,
12,
283,
1451,
730,
402,
11257,
39,
2363,
16192,
1077,
506,
3000,
3530,
339,
340,
730,
8,
7451,
16192,
9,
365,
1109,
26,
267,
340,
8020,
16192,
665,
378,
503,
8020,
16192,
690,
5450,
26,
746,
1722,
12,
283,
1110,
402,
1771,
39,
2363,
16192,
1077,
506,
3382,
378,
436,
5450,
3530,
272,
587,
26,
267,
746,
3146,
12,
283,
1451,
730,
402,
1771,
39,
2363,
16192,
1077,
506,
3000,
3530,
339,
289,
50,
12,
289,
39,
12,
289,
34,
275,
664,
63,
10090,
8,
23801,
4117,
9,
272,
330,
50,
12,
330,
39,
12,
330,
34,
275,
664,
63,
10090,
8,
7451,
4117,
9,
339,
2929,
27261,
275,
980,
14,
4250,
1332,
4060,
14,
1392,
59,
16,
467,
6050,
14,
1392,
59,
17,
467,
841,
4992,
6041,
8,
1590,
14,
1635,
24,
9,
272,
2929,
27261,
59,
4060,
508,
413,
61,
275,
980,
14,
1144,
779,
70,
50,
12,
289,
39,
12,
289,
34,
12,
24470,
16192,
6575,
6041,
8,
1590,
14,
1635,
24,
9,
272,
2929,
27261,
59,
4060,
508,
378,
61,
275,
980,
14,
1144,
779,
66,
50,
12,
330,
39,
12,
330,
34,
12,
8020,
16192,
6575,
6041,
8,
1590,
14,
1635,
24,
9,
339,
372,
2929,
27261,
421,
199,
318,
6917,
63,
18,
63,
22118,
8,
4060,
12,
3164,
26431,
556,
993,
735,
272,
408,
272,
3550,
2929,
282,
1834,
315,
334,
21631,
680,
8,
1590,
14,
1635,
24,
9,
1475,
1314,
883,
506,
9080,
701,
284,
706,
1917,
272,
5131,
365,
3247,
701,
1338,
315,
314,
6050,
272,
520,
635,
6050,
26,
1324,
1834,
272,
520,
635,
5131,
6443,
26,
3634,
402,
5131,
272,
520,
635,
11257,
39,
2363,
4117,
26,
3164,
367,
413,
315,
314,
1625,
12,
19013,
620,
12,
284,
14,
69,
14,
3943,
556,
993,
7,
272,
520,
1107,
26,
2929,
27261,
12,
334,
21631,
680,
8,
1590,
14,
1635,
24,
9,
1475,
12,
10144,
367,
284,
706,
1917,
272,
408,
339,
820,
12,
598,
12,
699,
275,
664,
63,
10090,
8,
2326,
9,
339,
820,
6443,
275,
334,
50,
627,
284,
65,
14,
1144,
63,
6505,
8,
4060,
14,
6041,
8,
1590,
14,
1609,
708,
23261,
6041,
8,
1590,
14,
1635,
24,
9,
272,
598,
6443,
275,
334,
39,
627,
284,
65,
14,
1144,
63,
6505,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
coxmediagroup/django-threadedcomments
|
legacy_threadedcomments/urls.py
|
14
|
2002
|
from django.conf.urls.defaults import patterns, url
from threadedcomments.models import FreeThreadedComment
from threadedcomments import views
free = {'model' : FreeThreadedComment}
urlpatterns = patterns('',
### Comments ###
url(r'^comment/(?P<content_type>\d+)/(?P<object_id>\d+)/$', views.comment, name="tc_comment"),
url(r'^comment/(?P<content_type>\d+)/(?P<object_id>\d+)/(?P<parent_id>\d+)/$', views.comment, name="tc_comment_parent"),
url(r'^comment/(?P<object_id>\d+)/delete/$', views.comment_delete, name="tc_comment_delete"),
url(r'^comment/(?P<edit_id>\d+)/edit/$', views.comment, name="tc_comment_edit"),
### Comments (AJAX) ###
url(r'^comment/(?P<content_type>\d+)/(?P<object_id>\d+)/(?P<ajax>json|xml)/$', views.comment, name="tc_comment_ajax"),
url(r'^comment/(?P<content_type>\d+)/(?P<object_id>\d+)/(?P<parent_id>\d+)/(?P<ajax>json|xml)/$', views.comment, name="tc_comment_parent_ajax"),
url(r'^comment/(?P<edit_id>\d+)/edit/(?P<ajax>json|xml)/$', views.comment, name="tc_comment_edit_ajax"),
### Free Comments ###
url(r'^freecomment/(?P<content_type>\d+)/(?P<object_id>\d+)/$', views.free_comment, name="tc_free_comment"),
url(r'^freecomment/(?P<content_type>\d+)/(?P<object_id>\d+)/(?P<parent_id>\d+)/$', views.free_comment, name="tc_free_comment_parent"),
url(r'^freecomment/(?P<object_id>\d+)/delete/$', views.comment_delete, free, name="tc_free_comment_delete"),
url(r'^freecomment/(?P<edit_id>\d+)/edit/$', views.free_comment, name="tc_free_comment_edit"),
### Free Comments (AJAX) ###
url(r'^freecomment/(?P<content_type>\d+)/(?P<object_id>\d+)/(?P<ajax>json|xml)/$', views.free_comment, name="tc_free_comment_ajax"),
url(r'^freecomment/(?P<content_type>\d+)/(?P<object_id>\d+)/(?P<parent_id>\d+)/(?P<ajax>json|xml)/$', views.free_comment, name="tc_free_comment_parent_ajax"),
url(r'^freecomment/(?P<edit_id>\d+)/edit/(?P<ajax>json|xml)/$', views.free_comment, name="tc_free_comment_edit_ajax"),
)
|
bsd-3-clause
|
[
504,
1639,
14,
2190,
14,
3603,
14,
4322,
492,
7970,
12,
1166,
199,
504,
25396,
6223,
14,
992,
492,
2868,
31699,
7488,
199,
504,
25396,
6223,
492,
6858,
199,
199,
4624,
275,
791,
1238,
7,
520,
2868,
31699,
7488,
93,
199,
199,
20050,
275,
7970,
8594,
272,
6754,
5429,
1470,
6754,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
1708,
63,
344,
3072,
68,
18830,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
1708,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
785,
63,
344,
3072,
68,
18830,
1807,
10884,
6858,
14,
3349,
63,
1807,
12,
536,
628,
3641,
63,
3349,
63,
1807,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
3773,
63,
344,
3072,
68,
18830,
3773,
10884,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
3773,
1288,
2286,
6754,
5429,
1470,
334,
31064,
9839,
9,
6754,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
12774,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
1708,
63,
344,
3072,
68,
18830,
2229,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
1708,
63,
12774,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
3773,
63,
344,
3072,
68,
18830,
3773,
9448,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
3773,
63,
12774,
1288,
339,
6754,
2868,
5429,
1470,
6754,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
1708,
63,
344,
3072,
68,
18830,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
1708,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
785,
63,
344,
3072,
68,
18830,
1807,
10884,
6858,
14,
3349,
63,
1807,
12,
2867,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
1807,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
3773,
63,
344,
3072,
68,
18830,
3773,
10884,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
3773,
1288,
339,
6754,
2868,
5429,
1470,
334,
31064,
9839,
9,
6754,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
12774,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
1708,
63,
344,
3072,
68,
18830,
2229,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
1708,
63,
12774,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
3773,
63,
344,
3072,
68,
18830,
3773,
9448,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
3773,
63,
12774,
1288,
199,
9,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
2190,
14,
3603,
14,
4322,
492,
7970,
12,
1166,
199,
504,
25396,
6223,
14,
992,
492,
2868,
31699,
7488,
199,
504,
25396,
6223,
492,
6858,
199,
199,
4624,
275,
791,
1238,
7,
520,
2868,
31699,
7488,
93,
199,
199,
20050,
275,
7970,
8594,
272,
6754,
5429,
1470,
6754,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
1708,
63,
344,
3072,
68,
18830,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
1708,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
785,
63,
344,
3072,
68,
18830,
1807,
10884,
6858,
14,
3349,
63,
1807,
12,
536,
628,
3641,
63,
3349,
63,
1807,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
3773,
63,
344,
3072,
68,
18830,
3773,
10884,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
3773,
1288,
2286,
6754,
5429,
1470,
334,
31064,
9839,
9,
6754,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
12774,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
1708,
63,
344,
3072,
68,
18830,
2229,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
1708,
63,
12774,
1288,
272,
1166,
8,
82,
4289,
3349,
9448,
48,
28,
3773,
63,
344,
3072,
68,
18830,
3773,
9448,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
3349,
12,
536,
628,
3641,
63,
3349,
63,
3773,
63,
12774,
1288,
339,
6754,
2868,
5429,
1470,
6754,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
1708,
63,
344,
3072,
68,
18830,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
1708,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
785,
63,
344,
3072,
68,
18830,
1807,
10884,
6858,
14,
3349,
63,
1807,
12,
2867,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
1807,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
3773,
63,
344,
3072,
68,
18830,
3773,
10884,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
3773,
1288,
339,
6754,
2868,
5429,
1470,
334,
31064,
9839,
9,
6754,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
12774,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
1317,
63,
466,
3072,
68,
18830,
2229,
48,
28,
785,
63,
344,
3072,
68,
18830,
2229,
48,
28,
1708,
63,
344,
3072,
68,
18830,
2229,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
1708,
63,
12774,
1288,
272,
1166,
8,
82,
4289,
4624,
3349,
9448,
48,
28,
3773,
63,
344,
3072,
68,
18830,
3773,
9448,
48,
28,
12774,
30,
1001,
92,
1652,
2447,
4268,
6858,
14,
4624,
63,
3349,
12,
536,
628,
3641,
63,
4624,
63,
3349,
63,
3773,
63,
12774,
1288,
199,
9,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
di11igaf/flounder-kernel
|
scripts/tracing/dma-api/smmu.py
|
96
|
7013
|
"""Low-level memory management tracking"""
VERBOSITY = 0 # TODO: use logging
class Bitmap(object):
"""Just a raw bitmap for reserving the pages"""
def __init__(self, size, verbosity):
self._size = size
self._bits = 0
self._verbosity = verbosity
self._bits_allocd = 0
def _mask(self, offset, length):
"""length amount of 1's, shifted left by offset"""
assert offset >= 0, "offset < 0"
assert offset < self._size, "offset 0x%d >= size %s" % (offset, self._size)
bitstring = (1 << length) - 1
return bitstring << offset
def _indices(self, offset, length):
"""Bit numbers starting from offset"""
return range(offset, offset + length)
def alloc(self, offset, length):
"""Reserve the bits, warn if verbose and some set already"""
mask = self._mask(offset, length)
if (self._bits & mask) != 0 and self._verbosity >= 1:
print "warning: duplicate allocation"
self._bits |= mask
self._bits_allocd += length
return self._indices(offset, length)
def free(self, offset, length):
"""Free the bits, warn if verbose and some not set yet"""
mask = self._mask(offset, length)
if (self._bits & mask) != mask and self._verbosity >= 1:
print "warning: freeing freed memory, mapbits %x" % (self._bits & mask)
self._bits &= ~mask
self._bits_allocd -= length
return self._indices(offset, length)
def contains(self, offset, length):
"""Are some bits in the given range set?"""
mask = self._mask(offset, length)
return self._bits & mask
def __repr__(self):
return "<bitmap, %d/%d allocd>" % (self._bits_allocd, self._size)
class Memory(object):
"""Store and handle raw bitmaps, check mapping collisions between devices"""
PAGESHIFT = 12
PAGESIZE = 1 << PAGESHIFT
PAGEMASK = PAGESIZE - 1
def __init__(self, addr, size, asid):
"""addr: lowest possible address, size: bytes, asid: arbitrary id"""
assert (addr & self.PAGEMASK) == 0, addr
assert (size & self.PAGEMASK) == 0, size
self._addr = addr
self._size = size
self._end = addr + size
self._asid = asid
self._bitmap = Bitmap(size >> self.PAGESHIFT, VERBOSITY)
self._devmaps = {}
if VERBOSITY >= 1:
print "memory at %08x-%08x" % (addr, addr + size)
def to_bit(self, addr):
"""Address to bitmap position"""
return addr >> self.PAGESHIFT
def alloc(self, dev, addr, size):
"""Allocate (map) for the given device, verify things"""
if addr >= self._end:
if VERBOSITY >= 1:
print "warning: %s mapping beyond bitmap: %08x" % (dev, addr)
return []
if (addr & self.PAGEMASK) != 0:
if VERBOSITY >= 1:
print "warning: alloc not aligned at 0x%x, size %d (new addr 0x%x, size %d)" % (
addr, size, addr & ~self.PAGEMASK, size + (addr & self.PAGEMASK))
addr &= ~self.PAGEMASK
size += addr & self.PAGEMASK
if size < self.PAGESIZE:
size = self.PAGESIZE
for user, bmp in self._devmaps.iteritems():
if bmp.contains(self.to_bit(addr - self._addr), self.to_bit(size)):
if VERBOSITY >= 1:
print "warning: %s mapping [0x%x,0x%x) already used by %s" % (
dev, addr, addr + size, user)
devmap = self._devmaps.setdefault(dev, Bitmap(self._bitmap._size, 0))
self._alloc(devmap, addr, size)
bits = self._alloc(self._bitmap, addr, size)
return bits
def _alloc(self, bitmap, addr, size):
"""Allocate from an internal bitmap"""
return bitmap.alloc(self.to_bit(addr - self._addr), self.to_bit(size))
def free(self, dev, addr, size):
"""Free (unmap) for the given device, verify things"""
if (addr & self.PAGEMASK) != 0:
if VERBOSITY >= 1:
print "warning: free not aligned at 0x%x, size %d (new addr 0x%x, size %d)" % (
addr, size, addr & ~self.PAGEMASK, size + (addr & self.PAGEMASK))
addr &= ~self.PAGEMASK
size += addr & self.PAGEMASK
if size < self.PAGESIZE:
size = self.PAGESIZE
devmap = self._devmaps.setdefault(dev, Bitmap(self._bitmap._size, 0))
owners = []
for user, bmp in self._devmaps.iteritems():
if bmp.contains(self.to_bit(addr - self._addr), self.to_bit(size)):
owners.append((user, bmp))
if len(owners) == 0:
if VERBOSITY >= 1:
print "warning: %s freeing 0x%x that nobody owns" % (dev, addr)
elif len(owners) == 1:
if owners[0][0] != dev and VERBOSITY >= 2:
print "note: %s freeing 0x%x allocd by %s" % (
dev, addr, owners[0][0])
devmap = owners[0][1]
self._free(devmap, addr, size)
bits = self._free(self._bitmap, addr, size)
return bits
def _free(self, bitmap, addr, size):
"""Free from an internal bitmap"""
return bitmap.free(self.to_bit(addr - self._addr), self.to_bit(size))
class Device(object):
"""Keep track of allocations per device/process
This needs more tricky work for tracking inter-process maps/unmaps :(
"""
def __init__(self, name, mem):
self._name = name
self._mem = mem
self._max_alloc = 0
self._cur_alloc = 0
self._alloc_history = []
self._addresses = []
def alloc(self, addr, size):
pages = self._mem.alloc(self, addr, size)
if pages is not False:
self._cur_alloc += size
self._max_alloc = max(self._max_alloc, self._cur_alloc)
self._alloc_history.append(self._cur_alloc)
if addr in self._addresses:
if VERBOSITY >= 1:
print "warning: %s allocing dupe address %x %s" % (self._name, addr, len([x for x in self._addresses if x == addr]))
self._addresses.append(addr)
return pages
def free(self, addr, size):
pages = self._mem.free(self, addr, size)
self._cur_alloc -= size
if addr in self._addresses:
self._addresses.remove(addr)
else:
if VERBOSITY >= 1:
print "warning: %s freeing unallocated %x" % (self._name, addr)
return pages
def history_at(self, i):
return self._alloc_history[i]
@property
def name(self):
return self._name
def __str__(self):
return self.name
def __repr__(self):
return "<dev: %s>" % self.name
@property
def max_allocated(self):
return self._max_alloc
class AsidSpace(object):
# TODO: don't pre-grep by archdata but put devices' mem maps here.
pass
|
gpl-2.0
|
[
624,
10281,
13,
1896,
4402,
10041,
15161,
624,
199,
199,
2111,
34,
3100,
1922,
275,
378,
327,
3254,
26,
675,
2050,
199,
199,
533,
10199,
1130,
8,
785,
304,
272,
408,
22850,
282,
3066,
20810,
367,
295,
14717,
314,
6497,
624,
272,
347,
636,
826,
721,
277,
12,
1568,
12,
8661,
304,
267,
291,
423,
890,
275,
1568,
267,
291,
423,
5609,
275,
378,
267,
291,
423,
9833,
275,
8661,
267,
291,
423,
5609,
63,
9373,
68,
275,
378,
339,
347,
485,
2629,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
1267,
5982,
402,
413,
1159,
12,
31915,
3602,
701,
3268,
624,
267,
702,
3268,
2356,
378,
12,
298,
2743,
665,
378,
2,
267,
702,
3268,
665,
291,
423,
890,
12,
298,
2743,
378,
88,
5,
68,
2356,
1568,
450,
83,
2,
450,
334,
2743,
12,
291,
423,
890,
9,
267,
4546,
875,
275,
334,
17,
5213,
2582,
9,
446,
413,
267,
372,
4546,
875,
5213,
3268,
339,
347,
485,
4108,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
4734,
5579,
6617,
687,
3268,
624,
267,
372,
1425,
8,
2743,
12,
3268,
435,
2582,
9,
339,
347,
29447,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
25845,
314,
5821,
12,
7987,
340,
3376,
436,
2005,
663,
2575,
624,
267,
3656,
275,
291,
423,
2629,
8,
2743,
12,
2582,
9,
267,
340,
334,
277,
423,
5609,
1253,
3656,
9,
1137,
378,
436,
291,
423,
9833,
2356,
413,
26,
288,
870,
298,
3764,
26,
9250,
18723,
2,
267,
291,
423,
5609,
8901,
3656,
267,
291,
423,
5609,
63,
9373,
68,
847,
2582,
267,
372,
291,
423,
4108,
8,
2743,
12,
2582,
9,
339,
347,
2867,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
10146,
314,
5821,
12,
7987,
340,
3376,
436,
2005,
440,
663,
5966,
624,
267,
3656,
275,
291,
423,
2629,
8,
2743,
12,
2582,
9,
267,
340,
334,
277,
423,
5609,
1253,
3656,
9,
1137,
3656,
436,
291,
423,
9833,
2356,
413,
26,
288,
870,
298,
3764,
26,
2867,
316,
23694,
4402,
12,
2341,
5609,
450,
88,
2,
450,
334,
277,
423,
5609,
1253,
3656,
9,
267,
291,
423,
5609,
18415,
6146,
2629,
267,
291,
423,
5609,
63,
9373,
68,
4862,
2582,
267,
372,
291,
423,
4108,
8,
2743,
12,
2582,
9,
339,
347,
3509,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
17683,
2005,
5821,
315,
314,
1627,
1425,
663,
30196,
267,
3656,
275,
291,
423,
2629,
8,
2743,
12,
2582,
9,
267,
372,
291,
423,
5609,
1253,
3656,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
20299,
12,
450,
68,
3149,
68,
29447,
68,
4335,
450,
334,
277,
423,
5609,
63,
9373,
68,
12,
291,
423,
890,
9,
199,
199,
533,
15825,
8,
785,
304,
272,
408,
5502,
436,
2429,
3066,
4546,
8919,
12,
1104,
4412,
30063,
3382,
7256,
624,
272,
510,
5383,
11183,
2161,
275,
3144,
272,
510,
5383,
11025,
275,
413,
5213,
510,
5383,
11183,
2161,
272,
510,
1254,
2769,
7946,
275,
510,
5383,
11025,
446,
413,
339,
347,
636,
826,
721,
277,
12,
5552,
12,
1568,
12,
282,
4148,
304,
267,
408,
2697,
26,
18966,
3962,
2287,
12,
1568,
26,
2783,
12,
282,
4148,
26,
9697,
1305,
624,
267,
702,
334,
2697,
1253,
291,
14,
48,
1254,
2769,
7946,
9,
508,
378,
12,
5552,
267,
702,
334,
890,
1253,
291,
14,
48,
1254,
2769,
7946,
9,
508,
378,
12,
1568,
398,
291,
423,
2697,
275,
5552,
267,
291,
423,
890,
275,
1568,
267,
291,
423,
500,
275,
5552,
435,
1568,
267,
291,
423,
305,
344,
275,
282,
4148,
267,
291,
423,
20299,
275,
10199,
1130,
8,
890,
4331,
291,
14,
48,
5383,
11183,
2161,
12,
12348,
34,
3100,
1922,
9,
267,
291,
423,
2374,
8919,
275,
1052,
398,
340,
12348,
34,
3100,
1922,
2356,
413,
26,
288,
870,
298,
4844,
737,
450,
2036,
88,
3295,
2036,
88,
2,
450,
334,
2697,
12,
5552,
435,
1568,
9,
339,
347,
370,
63,
2075,
8,
277,
12,
5552,
304,
267,
408,
1476,
370,
20810,
3421,
624,
267,
372,
5552,
4331,
291,
14,
48,
5383,
11183,
2161,
339,
347,
29447,
8,
277,
12,
4866,
12,
5552,
12,
1568,
304,
267,
408,
22712,
334,
1130,
9,
367,
314,
1627,
2243,
12,
4911,
7645,
624,
267,
340,
5552,
2356,
291,
423,
500,
26,
288,
340,
12348,
34,
3100,
1922,
2356,
413,
26,
355,
870,
298,
3764,
26,
450,
83,
4412,
20561,
20810,
26,
450,
2036,
88,
2,
450,
334,
2374,
12,
5552,
9,
288,
372,
942,
398,
340,
334,
2697,
1253,
291,
14,
48,
1254,
2769,
7946,
9,
1137,
378,
26,
288,
340,
12348,
34,
3100,
1922,
2356,
413,
26,
355,
870,
298,
3764,
26,
29447,
440,
22569,
737,
378,
88,
5,
88,
12,
1568,
450,
68,
334,
1222,
5552,
378,
88,
5,
88,
12,
1568,
450,
68,
2924,
450,
334,
717,
5552,
12,
1568,
12,
5552,
1253,
6146,
277,
14,
48,
1254,
2769,
7946,
12,
1568,
435,
334,
2697,
1253,
291,
14,
48,
1254,
2769,
7946,
430,
288,
5552,
18415,
6146,
277,
14,
48,
1254,
2769,
7946,
288,
1568,
847,
5552,
1253,
291,
14,
48,
1254,
2769,
7946,
398,
340,
1568,
665,
291,
14,
48,
5383,
11025,
26,
288,
1568,
275,
291,
14,
48,
5383,
11025,
398,
367,
922,
12,
330,
311,
315,
291,
423,
2374,
8919,
14,
4611,
837,
288,
340,
330,
311,
14,
6134,
8,
277,
14,
475,
63,
2075,
8,
2697,
446,
291,
423,
2697,
395,
291,
14,
475,
63,
2075,
8,
890,
2298,
355,
340,
12348,
34,
3100,
1922,
2356,
413,
26,
490,
870,
298,
3764,
26,
450,
83,
4412,
359,
16,
88,
5,
88,
12,
16,
88,
5,
88,
9,
2575,
1202,
701,
450,
83,
2,
450,
334,
1169,
4866,
12,
5552,
12,
5552,
435,
1568,
12,
922,
9,
398,
4866,
1130,
275,
291,
423,
2374,
8919,
14,
5486,
8,
2374,
12,
10199,
1130,
8,
277,
423,
20299,
423,
890,
12,
378,
430,
398,
291,
423,
9373,
8,
2374,
1130,
12,
5552,
12,
1568,
9,
267,
5821,
275,
291,
423,
9373,
8,
277,
423,
20299,
12,
5552,
12,
1568,
9,
267,
372,
5821,
339,
347,
485,
9373,
8,
277,
12,
20810,
12,
5552,
12,
1568,
304,
267,
408,
22712,
687,
376,
5007
] |
[
10281,
13,
1896,
4402,
10041,
15161,
624,
199,
199,
2111,
34,
3100,
1922,
275,
378,
327,
3254,
26,
675,
2050,
199,
199,
533,
10199,
1130,
8,
785,
304,
272,
408,
22850,
282,
3066,
20810,
367,
295,
14717,
314,
6497,
624,
272,
347,
636,
826,
721,
277,
12,
1568,
12,
8661,
304,
267,
291,
423,
890,
275,
1568,
267,
291,
423,
5609,
275,
378,
267,
291,
423,
9833,
275,
8661,
267,
291,
423,
5609,
63,
9373,
68,
275,
378,
339,
347,
485,
2629,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
1267,
5982,
402,
413,
1159,
12,
31915,
3602,
701,
3268,
624,
267,
702,
3268,
2356,
378,
12,
298,
2743,
665,
378,
2,
267,
702,
3268,
665,
291,
423,
890,
12,
298,
2743,
378,
88,
5,
68,
2356,
1568,
450,
83,
2,
450,
334,
2743,
12,
291,
423,
890,
9,
267,
4546,
875,
275,
334,
17,
5213,
2582,
9,
446,
413,
267,
372,
4546,
875,
5213,
3268,
339,
347,
485,
4108,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
4734,
5579,
6617,
687,
3268,
624,
267,
372,
1425,
8,
2743,
12,
3268,
435,
2582,
9,
339,
347,
29447,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
25845,
314,
5821,
12,
7987,
340,
3376,
436,
2005,
663,
2575,
624,
267,
3656,
275,
291,
423,
2629,
8,
2743,
12,
2582,
9,
267,
340,
334,
277,
423,
5609,
1253,
3656,
9,
1137,
378,
436,
291,
423,
9833,
2356,
413,
26,
288,
870,
298,
3764,
26,
9250,
18723,
2,
267,
291,
423,
5609,
8901,
3656,
267,
291,
423,
5609,
63,
9373,
68,
847,
2582,
267,
372,
291,
423,
4108,
8,
2743,
12,
2582,
9,
339,
347,
2867,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
10146,
314,
5821,
12,
7987,
340,
3376,
436,
2005,
440,
663,
5966,
624,
267,
3656,
275,
291,
423,
2629,
8,
2743,
12,
2582,
9,
267,
340,
334,
277,
423,
5609,
1253,
3656,
9,
1137,
3656,
436,
291,
423,
9833,
2356,
413,
26,
288,
870,
298,
3764,
26,
2867,
316,
23694,
4402,
12,
2341,
5609,
450,
88,
2,
450,
334,
277,
423,
5609,
1253,
3656,
9,
267,
291,
423,
5609,
18415,
6146,
2629,
267,
291,
423,
5609,
63,
9373,
68,
4862,
2582,
267,
372,
291,
423,
4108,
8,
2743,
12,
2582,
9,
339,
347,
3509,
8,
277,
12,
3268,
12,
2582,
304,
267,
408,
17683,
2005,
5821,
315,
314,
1627,
1425,
663,
30196,
267,
3656,
275,
291,
423,
2629,
8,
2743,
12,
2582,
9,
267,
372,
291,
423,
5609,
1253,
3656,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
20299,
12,
450,
68,
3149,
68,
29447,
68,
4335,
450,
334,
277,
423,
5609,
63,
9373,
68,
12,
291,
423,
890,
9,
199,
199,
533,
15825,
8,
785,
304,
272,
408,
5502,
436,
2429,
3066,
4546,
8919,
12,
1104,
4412,
30063,
3382,
7256,
624,
272,
510,
5383,
11183,
2161,
275,
3144,
272,
510,
5383,
11025,
275,
413,
5213,
510,
5383,
11183,
2161,
272,
510,
1254,
2769,
7946,
275,
510,
5383,
11025,
446,
413,
339,
347,
636,
826,
721,
277,
12,
5552,
12,
1568,
12,
282,
4148,
304,
267,
408,
2697,
26,
18966,
3962,
2287,
12,
1568,
26,
2783,
12,
282,
4148,
26,
9697,
1305,
624,
267,
702,
334,
2697,
1253,
291,
14,
48,
1254,
2769,
7946,
9,
508,
378,
12,
5552,
267,
702,
334,
890,
1253,
291,
14,
48,
1254,
2769,
7946,
9,
508,
378,
12,
1568,
398,
291,
423,
2697,
275,
5552,
267,
291,
423,
890,
275,
1568,
267,
291,
423,
500,
275,
5552,
435,
1568,
267,
291,
423,
305,
344,
275,
282,
4148,
267,
291,
423,
20299,
275,
10199,
1130,
8,
890,
4331,
291,
14,
48,
5383,
11183,
2161,
12,
12348,
34,
3100,
1922,
9,
267,
291,
423,
2374,
8919,
275,
1052,
398,
340,
12348,
34,
3100,
1922,
2356,
413,
26,
288,
870,
298,
4844,
737,
450,
2036,
88,
3295,
2036,
88,
2,
450,
334,
2697,
12,
5552,
435,
1568,
9,
339,
347,
370,
63,
2075,
8,
277,
12,
5552,
304,
267,
408,
1476,
370,
20810,
3421,
624,
267,
372,
5552,
4331,
291,
14,
48,
5383,
11183,
2161,
339,
347,
29447,
8,
277,
12,
4866,
12,
5552,
12,
1568,
304,
267,
408,
22712,
334,
1130,
9,
367,
314,
1627,
2243,
12,
4911,
7645,
624,
267,
340,
5552,
2356,
291,
423,
500,
26,
288,
340,
12348,
34,
3100,
1922,
2356,
413,
26,
355,
870,
298,
3764,
26,
450,
83,
4412,
20561,
20810,
26,
450,
2036,
88,
2,
450,
334,
2374,
12,
5552,
9,
288,
372,
942,
398,
340,
334,
2697,
1253,
291,
14,
48,
1254,
2769,
7946,
9,
1137,
378,
26,
288,
340,
12348,
34,
3100,
1922,
2356,
413,
26,
355,
870,
298,
3764,
26,
29447,
440,
22569,
737,
378,
88,
5,
88,
12,
1568,
450,
68,
334,
1222,
5552,
378,
88,
5,
88,
12,
1568,
450,
68,
2924,
450,
334,
717,
5552,
12,
1568,
12,
5552,
1253,
6146,
277,
14,
48,
1254,
2769,
7946,
12,
1568,
435,
334,
2697,
1253,
291,
14,
48,
1254,
2769,
7946,
430,
288,
5552,
18415,
6146,
277,
14,
48,
1254,
2769,
7946,
288,
1568,
847,
5552,
1253,
291,
14,
48,
1254,
2769,
7946,
398,
340,
1568,
665,
291,
14,
48,
5383,
11025,
26,
288,
1568,
275,
291,
14,
48,
5383,
11025,
398,
367,
922,
12,
330,
311,
315,
291,
423,
2374,
8919,
14,
4611,
837,
288,
340,
330,
311,
14,
6134,
8,
277,
14,
475,
63,
2075,
8,
2697,
446,
291,
423,
2697,
395,
291,
14,
475,
63,
2075,
8,
890,
2298,
355,
340,
12348,
34,
3100,
1922,
2356,
413,
26,
490,
870,
298,
3764,
26,
450,
83,
4412,
359,
16,
88,
5,
88,
12,
16,
88,
5,
88,
9,
2575,
1202,
701,
450,
83,
2,
450,
334,
1169,
4866,
12,
5552,
12,
5552,
435,
1568,
12,
922,
9,
398,
4866,
1130,
275,
291,
423,
2374,
8919,
14,
5486,
8,
2374,
12,
10199,
1130,
8,
277,
423,
20299,
423,
890,
12,
378,
430,
398,
291,
423,
9373,
8,
2374,
1130,
12,
5552,
12,
1568,
9,
267,
5821,
275,
291,
423,
9373,
8,
277,
423,
20299,
12,
5552,
12,
1568,
9,
267,
372,
5821,
339,
347,
485,
9373,
8,
277,
12,
20810,
12,
5552,
12,
1568,
304,
267,
408,
22712,
687,
376,
5007,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
stejesh/distributed-frontera
|
distributed_frontera/backends/remote/codecs/json.py
|
2
|
5609
|
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import json
from base64 import b64decode, b64encode
def _prepare_request_message(request):
return {'url': request.url,
'method': request.method,
'headers': request.headers,
'cookies': request.cookies,
'meta': request.meta}
def _prepare_links_message(links):
return [_prepare_request_message(link) for link in links]
def _prepare_response_message(response, send_body):
return {'url': response.url,
'status_code': response.status_code,
'meta': response.meta,
'body': b64encode(response.body) if send_body else None}
class CrawlFrontierJSONEncoder(json.JSONEncoder):
def __init__(self, request_model, *a, **kw):
self._request_model = request_model
super(CrawlFrontierJSONEncoder, self).__init__(*a, **kw)
def default(self, o):
if isinstance(o, self._request_model):
return _prepare_request_message(o)
else:
return super(CrawlFrontierJSONEncoder, self).default(o)
class Encoder(CrawlFrontierJSONEncoder):
def __init__(self, request_model, *a, **kw):
super(Encoder, self).__init__(request_model, *a, **kw)
self.send_body = True if 'send_body' in kw and kw['send_body'] else False
def encode_add_seeds(self, seeds):
"""
Encodes add_seeds message
:param list seeds A list of frontier Request objects
:return bytes encoded message
"""
return self.encode({
'type': 'add_seeds',
'seeds': [_prepare_request_message(seed) for seed in seeds]
})
def encode_page_crawled(self, response, links):
"""
Encodes a page_crawled message
:param object response A frontier Response object
:param list links A list of Request objects
:return bytes encoded message
"""
return self.encode({
'type': 'page_crawled',
'r': _prepare_response_message(response, self.send_body),
'links': _prepare_links_message(links)
})
def encode_request_error(self, request, error):
"""
Encodes a request_error message
:param object request A frontier Request object
:param string error Error description
:return bytes encoded message
"""
return self.encode({
'type': 'request_error',
'r': _prepare_request_message(request),
'error': error
})
def encode_request(self, request):
return self.encode(_prepare_request_message(request))
def encode_update_score(self, fingerprint, score, url, schedule):
return self.encode({'type': 'update_score',
'fprint': fingerprint,
'score': score,
'url': url,
'schedule': schedule})
def encode_new_job_id(self, job_id):
return self.encode({
'type': 'new_job_id',
'job_id': int(job_id)
})
class Decoder(json.JSONDecoder):
def __init__(self, request_model, response_model, *a, **kw):
self._request_model = request_model
self._response_model = response_model
super(Decoder, self).__init__(*a, **kw)
def _response_from_object(self, obj):
request = self._request_model(url=obj['url'],
meta=obj['meta'])
return self._response_model(url=obj['url'],
status_code=obj['status_code'],
body=b64decode(obj['body']),
request=request)
def _request_from_object(self, obj):
return self._request_model(url=obj['url'],
method=obj['method'],
headers=obj['headers'],
cookies=obj['cookies'],
meta=obj['meta'])
def decode(self, message):
"""
Decodes the message
:param bytes message encoded message
:return tuple of message type and related objects
"""
message = super(Decoder, self).decode(message)
if message['type'] == 'page_crawled':
response = self._response_from_object(message['r'])
links = [self._request_from_object(link) for link in message['links']]
return ('page_crawled', response, links)
if message['type'] == 'request_error':
request = self._request_from_object(message['r'])
return ('request_error', request, message['error'])
if message['type'] == 'update_score':
return ('update_score', str(message['fprint']), message['score'], str(message['url']), message['schedule'])
if message['type'] == 'add_seeds':
seeds = []
for seed in message['seeds']:
request = self._request_from_object(seed)
seeds.append(request)
return ('add_seeds', seeds)
if message['type'] == 'new_job_id':
return ('new_job_id', int(message['job_id']))
return TypeError('Unknown message type')
def decode_request(self, message):
obj = super(Decoder, self).decode(message)
return self._request_model(url=obj['url'],
method=obj['method'],
headers=obj['headers'],
cookies=obj['cookies'],
meta=obj['meta'])
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
646,
2022,
199,
504,
1300,
772,
492,
330,
772,
2708,
12,
330,
772,
2143,
199,
199,
318,
485,
6726,
63,
1069,
63,
1188,
8,
1069,
304,
272,
372,
791,
633,
356,
1056,
14,
633,
12,
288,
283,
765,
356,
1056,
14,
765,
12,
288,
283,
2139,
356,
1056,
14,
2139,
12,
288,
283,
7792,
356,
1056,
14,
7792,
12,
288,
283,
2024,
356,
1056,
14,
2024,
93,
199,
199,
318,
485,
6726,
63,
4614,
63,
1188,
8,
4614,
304,
272,
372,
15500,
6726,
63,
1069,
63,
1188,
8,
1073,
9,
367,
2142,
315,
6220,
61,
199,
199,
318,
485,
6726,
63,
1310,
63,
1188,
8,
1310,
12,
3222,
63,
2030,
304,
272,
372,
791,
633,
356,
1177,
14,
633,
12,
288,
283,
1205,
63,
600,
356,
1177,
14,
1205,
63,
600,
12,
288,
283,
2024,
356,
1177,
14,
2024,
12,
288,
283,
2030,
356,
330,
772,
2143,
8,
1310,
14,
2030,
9,
340,
3222,
63,
2030,
587,
488,
93,
421,
199,
533,
445,
22910,
38,
2641,
13949,
23069,
8,
1001,
14,
23069,
304,
272,
347,
636,
826,
721,
277,
12,
1056,
63,
1238,
12,
627,
65,
12,
1011,
829,
304,
267,
291,
423,
1069,
63,
1238,
275,
1056,
63,
1238,
267,
1613,
8,
35,
22910,
38,
2641,
13949,
23069,
12,
291,
2843,
826,
9308,
65,
12,
1011,
829,
9,
339,
347,
849,
8,
277,
12,
312,
304,
267,
340,
1228,
8,
79,
12,
291,
423,
1069,
63,
1238,
304,
288,
372,
485,
6726,
63,
1069,
63,
1188,
8,
79,
9,
267,
587,
26,
288,
372,
1613,
8,
35,
22910,
38,
2641,
13949,
23069,
12,
291,
680,
885,
8,
79,
9,
421,
199,
533,
3447,
2693,
8,
35,
22910,
38,
2641,
13949,
23069,
304,
272,
347,
636,
826,
721,
277,
12,
1056,
63,
1238,
12,
627,
65,
12,
1011,
829,
304,
267,
1613,
8,
6679,
12,
291,
2843,
826,
721,
1069,
63,
1238,
12,
627,
65,
12,
1011,
829,
9,
267,
291,
14,
2254,
63,
2030,
275,
715,
340,
283,
2254,
63,
2030,
7,
315,
4775,
436,
4775,
459,
2254,
63,
2030,
418,
587,
756,
339,
347,
3752,
63,
525,
63,
5176,
83,
8,
277,
12,
26825,
304,
267,
408,
267,
3447,
6021,
1050,
63,
5176,
83,
1245,
398,
520,
635,
769,
26825,
437,
769,
402,
289,
2641,
13949,
4784,
2251,
267,
520,
1107,
2783,
5737,
1245,
267,
408,
267,
372,
291,
14,
2143,
2561,
288,
283,
466,
356,
283,
525,
63,
5176,
83,
297,
288,
283,
5176,
83,
356,
15500,
6726,
63,
1069,
63,
1188,
8,
5176,
9,
367,
6347,
315,
26825,
61,
267,
3828,
339,
347,
3752,
63,
1606,
63,
67,
1773,
1146,
8,
277,
12,
1177,
12,
6220,
304,
267,
408,
267,
3447,
6021,
282,
2034,
63,
67,
1773,
1146,
1245,
398,
520,
635,
909,
1177,
437,
289,
2641,
13949,
7232,
909,
267,
520,
635,
769,
6220,
437,
769,
402,
4784,
2251,
398,
520,
1107,
2783,
5737,
1245,
267,
408,
267,
372,
291,
14,
2143,
2561,
288,
283,
466,
356,
283,
1606,
63,
67,
1773,
1146,
297,
288,
283,
82,
356,
485,
6726,
63,
1310,
63,
1188,
8,
1310,
12,
291,
14,
2254,
63,
2030,
395,
288,
283,
4614,
356,
485,
6726,
63,
4614,
63,
1188,
8,
4614,
9,
267,
3828,
339,
347,
3752,
63,
1069,
63,
705,
8,
277,
12,
1056,
12,
1125,
304,
267,
408,
267,
3447,
6021,
282,
1056,
63,
705,
1245,
267,
520,
635,
909,
1056,
437,
289,
2641,
13949,
4784,
909,
267,
520,
635,
1059,
1125,
4520,
1369,
398,
520,
1107,
2783,
5737,
1245,
267,
408,
267,
372,
291,
14,
2143,
2561,
288,
283,
466,
356,
283,
1069,
63,
705,
297,
288,
283,
82,
356,
485,
6726,
63,
1069,
63,
1188,
8,
1069,
395,
288,
283,
705,
356,
1125,
267,
3828,
339,
347,
3752,
63,
1069,
8,
277,
12,
1056,
304,
267,
372,
291,
14,
2143,
1547,
6726,
63,
1069,
63,
1188,
8,
1069,
430,
339,
347,
3752,
63,
873,
63,
3397,
8,
277,
12,
18020,
12,
5396,
12,
1166,
12,
8732,
304,
267,
372,
291,
14,
2143,
3252,
466,
356,
283,
873,
63,
3397,
297,
1169,
283,
70,
1361,
356,
18020,
12,
1169,
283,
3397,
356,
5396,
12,
1169,
283,
633,
356,
1166,
12,
1169,
283,
7211,
356,
8732,
1552,
339,
347,
3752,
63,
1222,
63,
2423,
63,
344,
8,
277,
12,
3906,
63,
344,
304,
267,
372,
291,
14,
2143,
2561,
288,
283,
466,
356,
283,
1222,
63,
2423,
63,
344,
297,
288,
283,
2423,
63,
344,
356,
1109,
8,
2423,
63,
344,
9,
267,
3828,
421,
199,
533,
1487,
2693,
8,
1001,
14,
6243,
8326,
304,
272,
347,
636,
826,
721,
277,
12,
1056,
63,
1238,
12,
1177,
63,
1238,
12,
627,
65,
12,
1011,
829,
304,
267,
291,
423,
1069,
63,
1238,
275,
1056,
63,
1238,
267,
291,
423,
1310,
63,
1238,
275,
1177,
63,
1238,
267,
1613,
8,
8326,
12,
291,
2843,
826,
9308,
65,
12,
1011,
829,
9,
339,
347,
485,
1310,
63,
504,
63,
785,
8,
277,
12,
1559,
304,
267,
1056,
275,
291,
423,
1069,
63,
1238,
8,
633,
29,
1113,
459,
633,
995,
4228,
3404,
29,
1113,
459,
2024,
1105,
267,
372,
291,
423,
1310,
63,
1238,
8,
633,
29,
1113,
459,
633,
995,
2151,
2004,
63,
600,
29,
1113,
459,
1205,
63,
600,
995,
2151,
2396,
29,
66,
772,
2708,
8,
1113,
459,
2030,
3815,
2151,
1056,
29,
1069,
9,
339,
347,
485,
1069,
63,
504,
63,
785,
8,
277,
12,
1559,
304,
267,
372,
291,
423,
1069,
63,
1238,
8,
633,
29,
1113,
459,
633,
995,
3521,
1083,
29,
1113,
459,
765,
995,
3521,
2323,
29,
1113,
459,
2139,
995,
3521,
10049,
29,
1113,
459,
7792,
995,
3521,
3404,
29,
1113,
459,
2024,
1105,
272,
347,
4849,
8,
277,
12,
1245,
304,
267,
408,
267,
1487,
6021,
314,
1245,
398,
520,
635,
2783,
1245,
5737,
1245,
267,
520,
1107,
2008,
402,
1245,
730,
436,
4048,
2251,
267,
408,
267,
1245,
275,
1613,
8,
8326,
12,
291,
680,
2708,
8,
1188,
9,
267,
340,
1245,
459,
466,
418,
508,
283,
1606,
63,
67,
1773,
1146,
356,
288,
1177,
275
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
646,
2022,
199,
504,
1300,
772,
492,
330,
772,
2708,
12,
330,
772,
2143,
199,
199,
318,
485,
6726,
63,
1069,
63,
1188,
8,
1069,
304,
272,
372,
791,
633,
356,
1056,
14,
633,
12,
288,
283,
765,
356,
1056,
14,
765,
12,
288,
283,
2139,
356,
1056,
14,
2139,
12,
288,
283,
7792,
356,
1056,
14,
7792,
12,
288,
283,
2024,
356,
1056,
14,
2024,
93,
199,
199,
318,
485,
6726,
63,
4614,
63,
1188,
8,
4614,
304,
272,
372,
15500,
6726,
63,
1069,
63,
1188,
8,
1073,
9,
367,
2142,
315,
6220,
61,
199,
199,
318,
485,
6726,
63,
1310,
63,
1188,
8,
1310,
12,
3222,
63,
2030,
304,
272,
372,
791,
633,
356,
1177,
14,
633,
12,
288,
283,
1205,
63,
600,
356,
1177,
14,
1205,
63,
600,
12,
288,
283,
2024,
356,
1177,
14,
2024,
12,
288,
283,
2030,
356,
330,
772,
2143,
8,
1310,
14,
2030,
9,
340,
3222,
63,
2030,
587,
488,
93,
421,
199,
533,
445,
22910,
38,
2641,
13949,
23069,
8,
1001,
14,
23069,
304,
272,
347,
636,
826,
721,
277,
12,
1056,
63,
1238,
12,
627,
65,
12,
1011,
829,
304,
267,
291,
423,
1069,
63,
1238,
275,
1056,
63,
1238,
267,
1613,
8,
35,
22910,
38,
2641,
13949,
23069,
12,
291,
2843,
826,
9308,
65,
12,
1011,
829,
9,
339,
347,
849,
8,
277,
12,
312,
304,
267,
340,
1228,
8,
79,
12,
291,
423,
1069,
63,
1238,
304,
288,
372,
485,
6726,
63,
1069,
63,
1188,
8,
79,
9,
267,
587,
26,
288,
372,
1613,
8,
35,
22910,
38,
2641,
13949,
23069,
12,
291,
680,
885,
8,
79,
9,
421,
199,
533,
3447,
2693,
8,
35,
22910,
38,
2641,
13949,
23069,
304,
272,
347,
636,
826,
721,
277,
12,
1056,
63,
1238,
12,
627,
65,
12,
1011,
829,
304,
267,
1613,
8,
6679,
12,
291,
2843,
826,
721,
1069,
63,
1238,
12,
627,
65,
12,
1011,
829,
9,
267,
291,
14,
2254,
63,
2030,
275,
715,
340,
283,
2254,
63,
2030,
7,
315,
4775,
436,
4775,
459,
2254,
63,
2030,
418,
587,
756,
339,
347,
3752,
63,
525,
63,
5176,
83,
8,
277,
12,
26825,
304,
267,
408,
267,
3447,
6021,
1050,
63,
5176,
83,
1245,
398,
520,
635,
769,
26825,
437,
769,
402,
289,
2641,
13949,
4784,
2251,
267,
520,
1107,
2783,
5737,
1245,
267,
408,
267,
372,
291,
14,
2143,
2561,
288,
283,
466,
356,
283,
525,
63,
5176,
83,
297,
288,
283,
5176,
83,
356,
15500,
6726,
63,
1069,
63,
1188,
8,
5176,
9,
367,
6347,
315,
26825,
61,
267,
3828,
339,
347,
3752,
63,
1606,
63,
67,
1773,
1146,
8,
277,
12,
1177,
12,
6220,
304,
267,
408,
267,
3447,
6021,
282,
2034,
63,
67,
1773,
1146,
1245,
398,
520,
635,
909,
1177,
437,
289,
2641,
13949,
7232,
909,
267,
520,
635,
769,
6220,
437,
769,
402,
4784,
2251,
398,
520,
1107,
2783,
5737,
1245,
267,
408,
267,
372,
291,
14,
2143,
2561,
288,
283,
466,
356,
283,
1606,
63,
67,
1773,
1146,
297,
288,
283,
82,
356,
485,
6726,
63,
1310,
63,
1188,
8,
1310,
12,
291,
14,
2254,
63,
2030,
395,
288,
283,
4614,
356,
485,
6726,
63,
4614,
63,
1188,
8,
4614,
9,
267,
3828,
339,
347,
3752,
63,
1069,
63,
705,
8,
277,
12,
1056,
12,
1125,
304,
267,
408,
267,
3447,
6021,
282,
1056,
63,
705,
1245,
267,
520,
635,
909,
1056,
437,
289,
2641,
13949,
4784,
909,
267,
520,
635,
1059,
1125,
4520,
1369,
398,
520,
1107,
2783,
5737,
1245,
267,
408,
267,
372,
291,
14,
2143,
2561,
288,
283,
466,
356,
283,
1069,
63,
705,
297,
288,
283,
82,
356,
485,
6726,
63,
1069,
63,
1188,
8,
1069,
395,
288,
283,
705,
356,
1125,
267,
3828,
339,
347,
3752,
63,
1069,
8,
277,
12,
1056,
304,
267,
372,
291,
14,
2143,
1547,
6726,
63,
1069,
63,
1188,
8,
1069,
430,
339,
347,
3752,
63,
873,
63,
3397,
8,
277,
12,
18020,
12,
5396,
12,
1166,
12,
8732,
304,
267,
372,
291,
14,
2143,
3252,
466,
356,
283,
873,
63,
3397,
297,
1169,
283,
70,
1361,
356,
18020,
12,
1169,
283,
3397,
356,
5396,
12,
1169,
283,
633,
356,
1166,
12,
1169,
283,
7211,
356,
8732,
1552,
339,
347,
3752,
63,
1222,
63,
2423,
63,
344,
8,
277,
12,
3906,
63,
344,
304,
267,
372,
291,
14,
2143,
2561,
288,
283,
466,
356,
283,
1222,
63,
2423,
63,
344,
297,
288,
283,
2423,
63,
344,
356,
1109,
8,
2423,
63,
344,
9,
267,
3828,
421,
199,
533,
1487,
2693,
8,
1001,
14,
6243,
8326,
304,
272,
347,
636,
826,
721,
277,
12,
1056,
63,
1238,
12,
1177,
63,
1238,
12,
627,
65,
12,
1011,
829,
304,
267,
291,
423,
1069,
63,
1238,
275,
1056,
63,
1238,
267,
291,
423,
1310,
63,
1238,
275,
1177,
63,
1238,
267,
1613,
8,
8326,
12,
291,
2843,
826,
9308,
65,
12,
1011,
829,
9,
339,
347,
485,
1310,
63,
504,
63,
785,
8,
277,
12,
1559,
304,
267,
1056,
275,
291,
423,
1069,
63,
1238,
8,
633,
29,
1113,
459,
633,
995,
4228,
3404,
29,
1113,
459,
2024,
1105,
267,
372,
291,
423,
1310,
63,
1238,
8,
633,
29,
1113,
459,
633,
995,
2151,
2004,
63,
600,
29,
1113,
459,
1205,
63,
600,
995,
2151,
2396,
29,
66,
772,
2708,
8,
1113,
459,
2030,
3815,
2151,
1056,
29,
1069,
9,
339,
347,
485,
1069,
63,
504,
63,
785,
8,
277,
12,
1559,
304,
267,
372,
291,
423,
1069,
63,
1238,
8,
633,
29,
1113,
459,
633,
995,
3521,
1083,
29,
1113,
459,
765,
995,
3521,
2323,
29,
1113,
459,
2139,
995,
3521,
10049,
29,
1113,
459,
7792,
995,
3521,
3404,
29,
1113,
459,
2024,
1105,
272,
347,
4849,
8,
277,
12,
1245,
304,
267,
408,
267,
1487,
6021,
314,
1245,
398,
520,
635,
2783,
1245,
5737,
1245,
267,
520,
1107,
2008,
402,
1245,
730,
436,
4048,
2251,
267,
408,
267,
1245,
275,
1613,
8,
8326,
12,
291,
680,
2708,
8,
1188,
9,
267,
340,
1245,
459,
466,
418,
508,
283,
1606,
63,
67,
1773,
1146,
356,
288,
1177,
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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.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import print_function
import os
import fixtures
from pbr.hooks import files
from pbr.tests import base
class FilesConfigTest(base.BaseTestCase):
def setUp(self):
super(FilesConfigTest, self).setUp()
pkg_fixture = fixtures.PythonPackage(
"fake_package", [
("fake_module.py", b""),
("other_fake_module.py", b""),
])
self.useFixture(pkg_fixture)
pkg_etc = os.path.join(pkg_fixture.base, 'etc')
pkg_sub = os.path.join(pkg_etc, 'sub')
subpackage = os.path.join(
pkg_fixture.base, 'fake_package', 'subpackage')
os.makedirs(pkg_sub)
os.makedirs(subpackage)
with open(os.path.join(pkg_etc, "foo"), 'w') as foo_file:
foo_file.write("Foo Data")
with open(os.path.join(pkg_sub, "bar"), 'w') as foo_file:
foo_file.write("Bar Data")
with open(os.path.join(subpackage, "__init__.py"), 'w') as foo_file:
foo_file.write("# empty")
self.useFixture(base.DiveDir(pkg_fixture.base))
def test_implicit_auto_package(self):
config = dict(
files=dict(
)
)
files.FilesConfig(config, 'fake_package').run()
self.assertIn('subpackage', config['files']['packages'])
def test_auto_package(self):
config = dict(
files=dict(
packages='fake_package',
)
)
files.FilesConfig(config, 'fake_package').run()
self.assertIn('subpackage', config['files']['packages'])
def test_data_files_globbing(self):
config = dict(
files=dict(
data_files="\n etc/pbr = etc/*"
)
)
files.FilesConfig(config, 'fake_package').run()
self.assertIn(
'\netc/pbr/ = \n etc/foo\netc/pbr/sub = \n etc/sub/bar',
config['files']['data_files'])
|
gpl-3.0
|
[
3,
1898,
334,
67,
9,
6171,
27849,
13,
29471,
15290,
15878,
12,
491,
14,
48,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
747,
199,
199,
646,
15188,
199,
199,
504,
299,
3289,
14,
7922,
492,
1584,
199,
504,
299,
3289,
14,
2219,
492,
1300,
421,
199,
533,
16920,
2028,
774,
8,
1095,
14,
20760,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
5535,
2028,
774,
12,
291,
680,
5996,
342,
398,
5496,
63,
5997,
275,
15188,
14,
4718,
8599,
8,
288,
298,
3183,
63,
2491,
401,
359,
355,
1689,
3183,
63,
578,
14,
647,
401,
330,
341,
395,
355,
1689,
1848,
63,
3183,
63,
578,
14,
647,
401,
330,
341,
395,
288,
4794,
267,
291,
14,
31015,
8,
4600,
63,
5997,
9,
267,
5496,
63,
6839,
275,
747,
14,
515,
14,
904,
8,
4600,
63,
5997,
14,
1095,
12,
283,
6839,
358,
267,
5496,
63,
954,
275,
747,
14,
515,
14,
904,
8,
4600,
63,
6839,
12,
283,
954,
358,
267,
1007,
2491,
275,
747,
14,
515,
14,
904,
8,
288,
5496,
63,
5997,
14,
1095,
12,
283,
3183,
63,
2491,
297,
283,
954,
2491,
358,
267,
747,
14,
8347,
8,
4600,
63,
954,
9,
267,
747,
14,
8347,
8,
954,
2491,
9,
267,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
4600,
63,
6839,
12,
298,
1421,
1288,
283,
87,
358,
465,
3925,
63,
493,
26,
288,
3925,
63,
493,
14,
952,
480,
5686,
3918,
531,
267,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
4600,
63,
954,
12,
298,
1700,
1288,
283,
87,
358,
465,
3925,
63,
493,
26,
288,
3925,
63,
493,
14,
952,
480,
5281,
3918,
531,
267,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
954,
2491,
12,
4396,
826,
4343,
647,
1288,
283,
87,
358,
465,
3925,
63,
493,
26,
288,
3925,
63,
493,
14,
952,
10064,
2701,
531,
398,
291,
14,
31015,
8,
1095,
14,
23794,
3567,
8,
4600,
63,
5997,
14,
1095,
430,
339,
347,
511,
63,
11886,
63,
2495,
63,
2491,
8,
277,
304,
267,
1101,
275,
1211,
8,
288,
1584,
29,
807,
8,
288,
776,
267,
776,
267,
1584,
14,
5535,
2028,
8,
888,
12,
283,
3183,
63,
2491,
1959,
1065,
342,
267,
291,
14,
4080,
360,
954,
2491,
297,
1101,
459,
1725,
2545,
5154,
1105,
339,
347,
511,
63,
2495,
63,
2491,
8,
277,
304,
267,
1101,
275,
1211,
8,
288,
1584,
29,
807,
8,
355,
6117,
534,
3183,
63,
2491,
297,
288,
776,
267,
776,
267,
1584,
14,
5535,
2028,
8,
888,
12,
283,
3183,
63,
2491,
1959,
1065,
342,
267,
291,
14,
4080,
360,
954,
2491,
297,
1101,
459,
1725,
2545,
5154,
1105,
339,
347,
511,
63,
576,
63,
1725,
63,
6463,
10911,
8,
277,
304,
267,
1101,
275,
1211,
8,
288,
1584,
29,
807,
8,
355,
666,
63,
1725,
21024,
78,
221,
5423,
15,
80,
3289,
275,
5423,
6331,
2,
288,
776,
267,
776,
267,
1584,
14,
5535,
2028,
8,
888,
12,
283,
3183,
63,
2491,
1959,
1065,
342,
267,
291,
14,
4080,
8,
288,
1557,
846,
67,
15,
80,
3289,
15,
275,
971,
78,
5423,
15,
1421,
60,
846,
67,
15,
80,
3289,
15,
954,
275,
971,
78,
5423,
15,
954,
15,
1700,
297,
288,
1101,
459,
1725,
2545,
576,
63,
1725,
1105,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6171,
27849,
13,
29471,
15290,
15878,
12,
491,
14,
48,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
747,
199,
199,
646,
15188,
199,
199,
504,
299,
3289,
14,
7922,
492,
1584,
199,
504,
299,
3289,
14,
2219,
492,
1300,
421,
199,
533,
16920,
2028,
774,
8,
1095,
14,
20760,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
5535,
2028,
774,
12,
291,
680,
5996,
342,
398,
5496,
63,
5997,
275,
15188,
14,
4718,
8599,
8,
288,
298,
3183,
63,
2491,
401,
359,
355,
1689,
3183,
63,
578,
14,
647,
401,
330,
341,
395,
355,
1689,
1848,
63,
3183,
63,
578,
14,
647,
401,
330,
341,
395,
288,
4794,
267,
291,
14,
31015,
8,
4600,
63,
5997,
9,
267,
5496,
63,
6839,
275,
747,
14,
515,
14,
904,
8,
4600,
63,
5997,
14,
1095,
12,
283,
6839,
358,
267,
5496,
63,
954,
275,
747,
14,
515,
14,
904,
8,
4600,
63,
6839,
12,
283,
954,
358,
267,
1007,
2491,
275,
747,
14,
515,
14,
904,
8,
288,
5496,
63,
5997,
14,
1095,
12,
283,
3183,
63,
2491,
297,
283,
954,
2491,
358,
267,
747,
14,
8347,
8,
4600,
63,
954,
9,
267,
747,
14,
8347,
8,
954,
2491,
9,
267,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
4600,
63,
6839,
12,
298,
1421,
1288,
283,
87,
358,
465,
3925,
63,
493,
26,
288,
3925,
63,
493,
14,
952,
480,
5686,
3918,
531,
267,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
4600,
63,
954,
12,
298,
1700,
1288,
283,
87,
358,
465,
3925,
63,
493,
26,
288,
3925,
63,
493,
14,
952,
480,
5281,
3918,
531,
267,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
954,
2491,
12,
4396,
826,
4343,
647,
1288,
283,
87,
358,
465,
3925,
63,
493,
26,
288,
3925,
63,
493,
14,
952,
10064,
2701,
531,
398,
291,
14,
31015,
8,
1095,
14,
23794,
3567,
8,
4600,
63,
5997,
14,
1095,
430,
339,
347,
511,
63,
11886,
63,
2495,
63,
2491,
8,
277,
304,
267,
1101,
275,
1211,
8,
288,
1584,
29,
807,
8,
288,
776,
267,
776,
267,
1584,
14,
5535,
2028,
8,
888,
12,
283,
3183,
63,
2491,
1959,
1065,
342,
267,
291,
14,
4080,
360,
954,
2491,
297,
1101,
459,
1725,
2545,
5154,
1105,
339,
347,
511,
63,
2495,
63,
2491,
8,
277,
304,
267,
1101,
275,
1211,
8,
288,
1584,
29,
807,
8,
355,
6117,
534,
3183,
63,
2491,
297,
288,
776,
267,
776,
267,
1584,
14,
5535,
2028,
8,
888,
12,
283,
3183,
63,
2491,
1959,
1065,
342,
267,
291,
14,
4080,
360,
954,
2491,
297,
1101,
459,
1725,
2545,
5154,
1105,
339,
347,
511,
63,
576,
63,
1725,
63,
6463,
10911,
8,
277,
304,
267,
1101,
275,
1211,
8,
288,
1584,
29,
807,
8,
355,
666,
63,
1725,
21024,
78,
221,
5423,
15,
80,
3289,
275,
5423,
6331,
2,
288,
776,
267,
776,
267,
1584,
14,
5535,
2028,
8,
888,
12,
283,
3183,
63,
2491,
1959,
1065,
342,
267,
291,
14,
4080,
8,
288,
1557,
846,
67,
15,
80,
3289,
15,
275,
971,
78,
5423,
15,
1421,
60,
846,
67,
15,
80,
3289,
15,
954,
275,
971,
78,
5423,
15,
954,
15,
1700,
297,
288,
1101,
459,
1725,
2545,
576,
63,
1725,
1105,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
szopu/django
|
tests/inspectdb/models.py
|
19
|
2832
|
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
import warnings
from django.db import models
class People(models.Model):
name = models.CharField(max_length=255)
parent = models.ForeignKey('self')
class Message(models.Model):
from_field = models.ForeignKey(People, db_column='from_id')
class PeopleData(models.Model):
people_pk = models.ForeignKey(People, primary_key=True)
ssn = models.CharField(max_length=11)
class PeopleMoreData(models.Model):
people_unique = models.ForeignKey(People, unique=True)
license = models.CharField(max_length=255)
class DigitsInColumnName(models.Model):
all_digits = models.CharField(max_length=11, db_column='123')
leading_digit = models.CharField(max_length=11, db_column='4extra')
leading_digits = models.CharField(max_length=11, db_column='45extra')
class SpecialName(models.Model):
field = models.IntegerField(db_column='field')
# Underscores
field_field_0 = models.IntegerField(db_column='Field_')
field_field_1 = models.IntegerField(db_column='Field__')
field_field_2 = models.IntegerField(db_column='__field')
# Other chars
prc_x = models.IntegerField(db_column='prc(%) x')
non_ascii = models.IntegerField(db_column='tamaño')
class Meta:
db_table = "inspectdb_special.table name"
class ColumnTypes(models.Model):
id = models.AutoField(primary_key=True)
big_int_field = models.BigIntegerField()
bool_field = models.BooleanField(default=False)
null_bool_field = models.NullBooleanField()
char_field = models.CharField(max_length=10)
null_char_field = models.CharField(max_length=10, blank=True, null=True)
comma_separated_int_field = models.CommaSeparatedIntegerField(max_length=99)
date_field = models.DateField()
date_time_field = models.DateTimeField()
decimal_field = models.DecimalField(max_digits=6, decimal_places=1)
email_field = models.EmailField()
file_field = models.FileField(upload_to="unused")
file_path_field = models.FilePathField()
float_field = models.FloatField()
int_field = models.IntegerField()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
ip_address_field = models.IPAddressField()
gen_ip_adress_field = models.GenericIPAddressField(protocol="ipv4")
pos_int_field = models.PositiveIntegerField()
pos_small_int_field = models.PositiveSmallIntegerField()
slug_field = models.SlugField()
small_int_field = models.SmallIntegerField()
text_field = models.TextField()
time_field = models.TimeField()
url_field = models.URLField()
class UniqueTogether(models.Model):
field1 = models.IntegerField()
field2 = models.CharField(max_length=10)
class Meta:
unique_together = ('field1', 'field2')
|
bsd-3-clause
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
3598,
199,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
11379,
7939,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
9,
272,
1676,
275,
1709,
14,
3190,
360,
277,
358,
421,
199,
533,
6430,
8,
992,
14,
1685,
304,
272,
687,
63,
698,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
1592,
63,
2301,
534,
504,
63,
344,
358,
421,
199,
533,
11379,
7939,
1451,
8,
992,
14,
1685,
304,
272,
13135,
63,
2051,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
5062,
63,
498,
29,
549,
9,
272,
308,
5167,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
9,
421,
199,
533,
11379,
7939,
11053,
1451,
8,
992,
14,
1685,
304,
272,
13135,
63,
3235,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
3747,
29,
549,
9,
272,
4190,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
9,
421,
199,
533,
22442,
1405,
607,
4547,
985,
8,
992,
14,
1685,
304,
272,
1006,
63,
7022,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
4288,
358,
272,
9186,
63,
8573,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
20,
2911,
358,
272,
9186,
63,
7022,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
2322,
2911,
358,
421,
199,
533,
12568,
985,
8,
992,
14,
1685,
304,
272,
901,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
698,
358,
272,
327,
25010,
7107,
272,
901,
63,
698,
63,
16,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
792,
15452,
272,
901,
63,
698,
63,
17,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
792,
13766,
272,
901,
63,
698,
63,
18,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
363,
698,
358,
272,
327,
5439,
8365,
272,
299,
1195,
63,
88,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
80,
1195,
4042,
9,
671,
358,
272,
2222,
63,
4371,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
502,
391,
22692,
79,
358,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
298,
10955,
697,
63,
6664,
14,
1224,
536,
2,
421,
199,
533,
4996,
4100,
8,
992,
14,
1685,
304,
272,
1305,
275,
1709,
14,
4378,
8,
3327,
63,
498,
29,
549,
9,
272,
7282,
63,
442,
63,
698,
275,
1709,
14,
25175,
342,
272,
2155,
63,
698,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
2973,
63,
2245,
63,
698,
275,
1709,
14,
29068,
342,
272,
1495,
63,
698,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
272,
2973,
63,
1560,
63,
698,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
12,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
10029,
63,
12794,
63,
442,
63,
698,
275,
1709,
14,
25732,
20727,
3901,
8,
988,
63,
1267,
29,
1020,
9,
272,
1434,
63,
698,
275,
1709,
14,
14071,
342,
272,
1434,
63,
521,
63,
698,
275,
1709,
14,
4626,
342,
272,
6107,
63,
698,
275,
1709,
14,
15975,
8,
988,
63,
7022,
29,
22,
12,
6107,
63,
10696,
29,
17,
9,
272,
3031,
63,
698,
275,
1709,
14,
16577,
342,
272,
570,
63,
698,
275,
1709,
14,
23252,
8,
5064,
63,
475,
628,
8618,
531,
272,
570,
63,
515,
63,
698,
275,
1709,
14,
14225,
792,
342,
272,
2069,
63,
698,
275,
1709,
14,
13019,
342,
272,
1109,
63,
698,
275,
1709,
14,
3901,
342,
272,
543,
3598,
14,
9341,
63,
5451,
8,
3059,
29,
549,
9,
465,
336,
26,
267,
3598,
14,
18815,
480,
9223,
531,
267,
3384,
63,
1562,
63,
698,
275,
1709,
14,
26969,
342,
272,
3805,
63,
711,
63,
350,
753,
63,
698,
275,
1709,
14,
9417,
26969,
8,
3922,
628,
4774,
20,
531,
272,
2086,
63,
442,
63,
698,
275,
1709,
14,
8591,
342,
272,
2086,
63,
7241,
63,
442,
63,
698,
275,
1709,
14,
25197,
342,
272,
8889,
63,
698,
275,
1709,
14,
17315,
342,
272,
7425,
63,
442,
63,
698,
275,
1709,
14,
14640,
342,
272,
1318,
63,
698,
275,
1709,
14,
6254,
342,
272,
900,
63,
698,
275,
1709,
14,
27115,
342,
272,
1166,
63,
698,
275,
1709,
14,
17363,
342,
421,
199,
533,
18276,
1378,
4920,
8,
992,
14,
1685,
304,
272,
901,
17,
275,
1709,
14,
3901,
342,
272,
901,
18,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
339,
1021,
6288,
26,
267,
3747,
63,
6314,
275,
661,
698,
17,
297,
283,
698,
18,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
3598,
199,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
11379,
7939,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
9,
272,
1676,
275,
1709,
14,
3190,
360,
277,
358,
421,
199,
533,
6430,
8,
992,
14,
1685,
304,
272,
687,
63,
698,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
1592,
63,
2301,
534,
504,
63,
344,
358,
421,
199,
533,
11379,
7939,
1451,
8,
992,
14,
1685,
304,
272,
13135,
63,
2051,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
5062,
63,
498,
29,
549,
9,
272,
308,
5167,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
9,
421,
199,
533,
11379,
7939,
11053,
1451,
8,
992,
14,
1685,
304,
272,
13135,
63,
3235,
275,
1709,
14,
3190,
8,
8070,
7939,
12,
3747,
29,
549,
9,
272,
4190,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
9,
421,
199,
533,
22442,
1405,
607,
4547,
985,
8,
992,
14,
1685,
304,
272,
1006,
63,
7022,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
4288,
358,
272,
9186,
63,
8573,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
20,
2911,
358,
272,
9186,
63,
7022,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
845,
12,
1592,
63,
2301,
534,
2322,
2911,
358,
421,
199,
533,
12568,
985,
8,
992,
14,
1685,
304,
272,
901,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
698,
358,
272,
327,
25010,
7107,
272,
901,
63,
698,
63,
16,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
792,
15452,
272,
901,
63,
698,
63,
17,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
792,
13766,
272,
901,
63,
698,
63,
18,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
363,
698,
358,
272,
327,
5439,
8365,
272,
299,
1195,
63,
88,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
80,
1195,
4042,
9,
671,
358,
272,
2222,
63,
4371,
275,
1709,
14,
3901,
8,
697,
63,
2301,
534,
502,
391,
22692,
79,
358,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
298,
10955,
697,
63,
6664,
14,
1224,
536,
2,
421,
199,
533,
4996,
4100,
8,
992,
14,
1685,
304,
272,
1305,
275,
1709,
14,
4378,
8,
3327,
63,
498,
29,
549,
9,
272,
7282,
63,
442,
63,
698,
275,
1709,
14,
25175,
342,
272,
2155,
63,
698,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
2973,
63,
2245,
63,
698,
275,
1709,
14,
29068,
342,
272,
1495,
63,
698,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
272,
2973,
63,
1560,
63,
698,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
12,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
10029,
63,
12794,
63,
442,
63,
698,
275,
1709,
14,
25732,
20727,
3901,
8,
988,
63,
1267,
29,
1020,
9,
272,
1434,
63,
698,
275,
1709,
14,
14071,
342,
272,
1434,
63,
521,
63,
698,
275,
1709,
14,
4626,
342,
272,
6107,
63,
698,
275,
1709,
14,
15975,
8,
988,
63,
7022,
29,
22,
12,
6107,
63,
10696,
29,
17,
9,
272,
3031,
63,
698,
275,
1709,
14,
16577,
342,
272,
570,
63,
698,
275,
1709,
14,
23252,
8,
5064,
63,
475,
628,
8618,
531,
272,
570,
63,
515,
63,
698,
275,
1709,
14,
14225,
792,
342,
272,
2069,
63,
698,
275,
1709,
14,
13019,
342,
272,
1109,
63,
698,
275,
1709,
14,
3901,
342,
272,
543,
3598,
14,
9341,
63,
5451,
8,
3059,
29,
549,
9,
465,
336,
26,
267,
3598,
14,
18815,
480,
9223,
531,
267,
3384,
63,
1562,
63,
698,
275,
1709,
14,
26969,
342,
272,
3805,
63,
711,
63,
350,
753,
63,
698,
275,
1709,
14,
9417,
26969,
8,
3922,
628,
4774,
20,
531,
272,
2086,
63,
442,
63,
698,
275,
1709,
14,
8591,
342,
272,
2086,
63,
7241,
63,
442,
63,
698,
275,
1709,
14,
25197,
342,
272,
8889,
63,
698,
275,
1709,
14,
17315,
342,
272,
7425,
63,
442,
63,
698,
275,
1709,
14,
14640,
342,
272,
1318,
63,
698,
275,
1709,
14,
6254,
342,
272,
900,
63,
698,
275,
1709,
14,
27115,
342,
272,
1166,
63,
698,
275,
1709,
14,
17363,
342,
421,
199,
533,
18276,
1378,
4920,
8,
992,
14,
1685,
304,
272,
901,
17,
275,
1709,
14,
3901,
342,
272,
901,
18,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
339,
1021,
6288,
26,
267,
3747,
63,
6314,
275,
661,
698,
17,
297,
283,
698,
18,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ashemedai/ansible
|
lib/ansible/modules/storage/netapp/netapp_e_host.py
|
43
|
17647
|
#!/usr/bin/python
# (c) 2016, NetApp, 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.0',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = """
---
module: netapp_e_host
short_description: manage eseries hosts
description:
- Create, update, remove hosts on NetApp E-series storage arrays
version_added: '2.2'
author: Kevin Hulquest (@hulquest)
options:
api_username:
required: true
description:
- The username to authenticate with the SANtricity WebServices Proxy or embedded REST API.
api_password:
required: true
description:
- The password to authenticate with the SANtricity WebServices Proxy or embedded REST API.
api_url:
required: true
description:
- The url to the SANtricity WebServices Proxy or embedded REST API, for example C(https://prod-1.wahoo.acme.com/devmgr/v2).
validate_certs:
required: false
default: true
description:
- Should https certificates be validated?
ssid:
description:
- the id of the storage array you wish to act against
required: True
name:
description:
- If the host doesnt yet exist, the label to assign at creation time.
- If the hosts already exists, this is what is used to identify the host to apply any desired changes
required: True
host_type_index:
description:
- The index that maps to host type you wish to create. It is recommended to use the M(netapp_e_facts) module to gather this information.
Alternatively you can use the WSP portal to retrieve the information.
required: True
ports:
description:
- a list of of dictionaries of host ports you wish to associate with the newly created host
required: False
group:
description:
- the group you want the host to be a member of
required: False
"""
EXAMPLES = """
- name: Set Host Info
netapp_e_host:
ssid: "{{ ssid }}"
api_url: "{{ netapp_api_url }}"
api_username: "{{ netapp_api_username }}"
api_password: "{{ netapp_api_password }}"
name: "{{ host_name }}"
host_type_index: "{{ host_type_index }}"
"""
RETURN = """
msg:
description: Success message
returned: success
type: string
sample: The host has been created.
"""
import json
from ansible.module_utils.api import basic_auth_argument_spec
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.urls import open_url
from ansible.module_utils.six.moves.urllib.error import HTTPError
HEADERS = {
"Content-Type": "application/json",
"Accept": "application/json",
}
def request(url, data=None, headers=None, method='GET', use_proxy=True,
force=False, last_mod_time=None, timeout=10, validate_certs=True,
url_username=None, url_password=None, http_agent=None, force_basic_auth=True, ignore_errors=False):
try:
r = open_url(url=url, data=data, headers=headers, method=method, use_proxy=use_proxy,
force=force, last_mod_time=last_mod_time, timeout=timeout, validate_certs=validate_certs,
url_username=url_username, url_password=url_password, http_agent=http_agent,
force_basic_auth=force_basic_auth)
except HTTPError:
err = get_exception()
r = err.fp
try:
raw_data = r.read()
if raw_data:
data = json.loads(raw_data)
else:
raw_data is None
except:
if ignore_errors:
pass
else:
raise Exception(raw_data)
resp_code = r.getcode()
if resp_code >= 400 and not ignore_errors:
raise Exception(resp_code, data)
else:
return resp_code, data
class Host(object):
def __init__(self):
argument_spec = basic_auth_argument_spec()
argument_spec.update(dict(
api_username=dict(type='str', required=True),
api_password=dict(type='str', required=True, no_log=True),
api_url=dict(type='str', required=True),
ssid=dict(type='str', required=True),
state=dict(type='str', required=True, choices=['absent', 'present']),
group=dict(type='str', required=False),
ports=dict(type='list', required=False),
force_port=dict(type='bool', default=False),
name=dict(type='str', required=True),
host_type_index=dict(type='int', required=True)
))
self.module = AnsibleModule(argument_spec=argument_spec)
args = self.module.params
self.group = args['group']
self.ports = args['ports']
self.force_port = args['force_port']
self.name = args['name']
self.host_type_index = args['host_type_index']
self.state = args['state']
self.ssid = args['ssid']
self.url = args['api_url']
self.user = args['api_username']
self.pwd = args['api_password']
self.certs = args['validate_certs']
self.ports = args['ports']
self.post_body = dict()
if not self.url.endswith('/'):
self.url += '/'
@property
def valid_host_type(self):
try:
(rc, host_types) = request(self.url + 'storage-systems/%s/host-types' % self.ssid, url_password=self.pwd,
url_username=self.user, validate_certs=self.certs, headers=HEADERS)
except Exception:
err = get_exception()
self.module.fail_json(
msg="Failed to get host types. Array Id [%s]. Error [%s]." % (self.ssid, str(err)))
try:
match = filter(lambda host_type: host_type['index'] == self.host_type_index, host_types)[0]
return True
except IndexError:
self.module.fail_json(msg="There is no host type with index %s" % self.host_type_index)
@property
def hostports_available(self):
used_ids = list()
try:
(rc, self.available_ports) = request(self.url + 'storage-systems/%s/unassociated-host-ports' % self.ssid,
url_password=self.pwd, url_username=self.user,
validate_certs=self.certs,
headers=HEADERS)
except:
err = get_exception()
self.module.fail_json(
msg="Failed to get unassociated host ports. Array Id [%s]. Error [%s]." % (self.ssid, str(err)))
if len(self.available_ports) > 0 and len(self.ports) <= len(self.available_ports):
for port in self.ports:
for free_port in self.available_ports:
# Desired Type matches but also make sure we havent already used the ID
if not free_port['id'] in used_ids:
# update the port arg to have an id attribute
used_ids.append(free_port['id'])
break
if len(used_ids) != len(self.ports) and not self.force_port:
self.module.fail_json(
msg="There are not enough free host ports with the specified port types to proceed")
else:
return True
else:
self.module.fail_json(msg="There are no host ports available OR there are not enough unassigned host ports")
@property
def group_id(self):
if self.group:
try:
(rc, all_groups) = request(self.url + 'storage-systems/%s/host-groups' % self.ssid,
url_password=self.pwd,
url_username=self.user, validate_certs=self.certs, headers=HEADERS)
except:
err = get_exception()
self.module.fail_json(
msg="Failed to get host groups. Array Id [%s]. Error [%s]." % (self.ssid, str(err)))
try:
group_obj = filter(lambda group: group['name'] == self.group, all_groups)[0]
return group_obj['id']
except IndexError:
self.module.fail_json(msg="No group with the name: %s exists" % self.group)
else:
# Return the value equivalent of no group
return "0000000000000000000000000000000000000000"
@property
def host_exists(self):
try:
(rc, all_hosts) = request(self.url + 'storage-systems/%s/hosts' % self.ssid, url_password=self.pwd,
url_username=self.user, validate_certs=self.certs, headers=HEADERS)
except:
err = get_exception()
self.module.fail_json(
msg="Failed to determine host existence. Array Id [%s]. Error [%s]." % (self.ssid, str(err)))
self.all_hosts = all_hosts
try: # Try to grab the host object
self.host_obj = filter(lambda host: host['label'] == self.name, all_hosts)[0]
return True
except IndexError:
# Host with the name passed in does not exist
return False
@property
def needs_update(self):
needs_update = False
self.force_port_update = False
if self.host_obj['clusterRef'] != self.group_id or \
self.host_obj['hostTypeIndex'] != self.host_type_index:
needs_update = True
if self.ports:
if not self.host_obj['ports']:
needs_update = True
for arg_port in self.ports:
# First a quick check to see if the port is mapped to a different host
if not self.port_on_diff_host(arg_port):
for obj_port in self.host_obj['ports']:
if arg_port['label'] == obj_port['label']:
# Confirmed that port arg passed in exists on the host
# port_id = self.get_port_id(obj_port['label'])
if arg_port['type'] != obj_port['portId']['ioInterfaceType']:
needs_update = True
if 'iscsiChapSecret' in arg_port:
# No way to know the current secret attr, so always return True just in case
needs_update = True
else:
# If the user wants the ports to be reassigned, do it
if self.force_port:
self.force_port_update = True
needs_update = True
else:
self.module.fail_json(
msg="The port you specified:\n%s\n is associated with a different host. Specify force_port as True or try a different "
"port spec" % arg_port
)
return needs_update
def port_on_diff_host(self, arg_port):
""" Checks to see if a passed in port arg is present on a different host """
for host in self.all_hosts:
# Only check 'other' hosts
if self.host_obj['name'] != self.name:
for port in host['ports']:
# Check if the port label is found in the port dict list of each host
if arg_port['label'] == port['label']:
self.other_host = host
return True
return False
def reassign_ports(self, apply=True):
if not self.post_body:
self.post_body = dict(
portsToUpdate=dict()
)
for port in self.ports:
if self.port_on_diff_host(port):
self.post_body['portsToUpdate'].update(dict(
portRef=self.other_host['hostPortRef'],
hostRef=self.host_obj['id'],
# Doesnt yet address port identifier or chap secret
))
if apply:
try:
(rc, self.host_obj) = request(
self.url + 'storage-systems/%s/hosts/%s' % (self.ssid, self.host_obj['id']),
url_username=self.user, url_password=self.pwd, headers=HEADERS,
validate_certs=self.certs, method='POST', data=json.dumps(self.post_body))
except:
err = get_exception()
self.module.fail_json(
msg="Failed to reassign host port. Host Id [%s]. Array Id [%s]. Error [%s]." % (
self.host_obj['id'], self.ssid, str(err)))
def update_host(self):
if self.ports:
if self.hostports_available:
if self.force_port_update is True:
self.reassign_ports(apply=False)
# Make sure that only ports that arent being reassigned are passed into the ports attr
self.ports = [port for port in self.ports if not self.port_on_diff_host(port)]
self.post_body['ports'] = self.ports
if self.group:
self.post_body['groupId'] = self.group_id
self.post_body['hostType'] = dict(index=self.host_type_index)
try:
(rc, self.host_obj) = request(self.url + 'storage-systems/%s/hosts/%s' % (self.ssid, self.host_obj['id']),
url_username=self.user, url_password=self.pwd, headers=HEADERS,
validate_certs=self.certs, method='POST', data=json.dumps(self.post_body))
except:
err = get_exception()
self.module.fail_json(msg="Failed to update host. Array Id [%s]. Error [%s]." % (self.ssid, str(err)))
self.module.exit_json(changed=True, **self.host_obj)
def create_host(self):
post_body = dict(
name=self.name,
host_type=dict(index=self.host_type_index),
groupId=self.group_id,
ports=self.ports
)
if self.ports:
# Check that all supplied port args are valid
if self.hostports_available:
post_body.update(ports=self.ports)
elif not self.force_port:
self.module.fail_json(
msg="You supplied ports that are already in use. Supply force_port to True if you wish to reassign the ports")
if not self.host_exists:
try:
(rc, create_resp) = request(self.url + "storage-systems/%s/hosts" % self.ssid, method='POST',
url_username=self.user, url_password=self.pwd, validate_certs=self.certs,
data=json.dumps(post_body), headers=HEADERS)
except:
err = get_exception()
self.module.fail_json(
msg="Failed to create host. Array Id [%s]. Error [%s]." % (self.ssid, str(err)))
else:
self.module.exit_json(changed=False,
msg="Host already exists. Id [%s]. Host [%s]." % (self.ssid, self.name))
self.host_obj = create_resp
if self.ports and self.force_port:
self.reassign_ports()
self.module.exit_json(changed=True, **self.host_obj)
def remove_host(self):
try:
(rc, resp) = request(self.url + "storage-systems/%s/hosts/%s" % (self.ssid, self.host_obj['id']),
method='DELETE',
url_username=self.user, url_password=self.pwd, validate_certs=self.certs)
except:
err = get_exception()
self.module.fail_json(
msg="Failed to remote host. Host[%s]. Array Id [%s]. Error [%s]." % (self.host_obj['id'],
self.ssid,
str(err)))
def apply(self):
if self.state == 'present':
if self.host_exists:
if self.needs_update and self.valid_host_type:
self.update_host()
else:
self.module.exit_json(changed=False, msg="Host already present.", id=self.ssid, label=self.name)
elif self.valid_host_type:
self.create_host()
else:
if self.host_exists:
self.remove_host()
self.module.exit_json(changed=True, msg="Host removed.")
else:
self.module.exit_json(changed=False, msg="Host already absent.", id=self.ssid, label=self.name)
def main():
host = Host()
host.apply()
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
3,
334,
67,
9,
7800,
12,
28076,
12,
3277,
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,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
16,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
408,
199,
2595,
199,
578,
26,
15742,
63,
69,
63,
1102,
199,
3612,
63,
1802,
26,
9635,
325,
5602,
7057,
199,
1802,
26,
272,
446,
2790,
12,
1678,
12,
2813,
7057,
641,
28076,
662,
13,
5602,
4887,
6572,
199,
1023,
63,
3270,
26,
283,
18,
14,
18,
7,
199,
2502,
26,
25645,
11908,
869,
348,
613,
8593,
72,
348,
613,
9,
199,
1419,
26,
272,
2986,
63,
2473,
26,
267,
1415,
26,
2549,
267,
1369,
26,
267,
446,
710,
3434,
370,
12895,
543,
314,
428,
879,
599,
3690,
6001,
15803,
12373,
503,
12169,
14880,
3261,
14,
272,
2986,
63,
2060,
26,
267,
1415,
26,
2549,
267,
1369,
26,
267,
446,
710,
2505,
370,
12895,
543,
314,
428,
879,
599,
3690,
6001,
15803,
12373,
503,
12169,
14880,
3261,
14,
272,
2986,
63,
633,
26,
267,
1415,
26,
2549,
267,
1369,
26,
267,
446,
710,
1166,
370,
314,
428,
879,
599,
3690,
6001,
15803,
12373,
503,
12169,
14880,
3261,
12,
367,
2893,
445,
8,
2859,
921,
8788,
13,
17,
14,
758,
19112,
14,
18107,
14,
957,
15,
2374,
7755,
15,
86,
18,
680,
272,
4107,
63,
8356,
26,
267,
1415,
26,
3055,
267,
849,
26,
2549,
267,
1369,
26,
267,
446,
7719,
4178,
14512,
506,
16468,
31,
272,
25891,
26,
267,
1369,
26,
288,
446,
314,
1305,
402,
314,
4887,
1625,
1265,
13809,
370,
2454,
6169,
267,
1415,
26,
715,
272,
536,
26,
267,
1369,
26,
288,
446,
982,
314,
1591,
1630,
343,
5966,
2187,
12,
314,
1768,
370,
5090,
737,
7143,
900,
14,
288,
446,
982,
314,
7057,
2575,
3495,
12,
642,
365,
4052,
365,
1202,
370,
10405,
314,
1591,
370,
4838,
1263,
6387,
4493,
267,
1415,
26,
715,
272,
1591,
63,
466,
63,
1080,
26,
267,
1369,
26,
288,
446,
710,
1478,
626,
9033,
370,
1591,
730,
1265,
13809,
370,
1218,
14,
2779,
365,
14318,
370,
675,
314,
603,
8,
25830,
63,
69,
63,
5047,
9,
859,
370,
13082,
642,
2556,
14,
1598,
26776,
1265,
883,
675,
314,
644,
5763,
18428,
370,
8044,
314,
2556,
14,
267,
1415,
26,
715,
272,
8873,
26,
267,
1369,
26,
288,
446,
282,
769,
402,
402,
11196,
402,
1591,
8873,
1265,
13809,
370,
20133,
543,
314,
13903,
2737,
1591,
267,
1415,
26,
756,
272,
1572,
26,
267,
1369,
26,
288,
446,
314,
1572,
1265,
2934,
314,
1591,
370,
506,
282,
3653,
402,
267,
1415,
26,
756,
199,
199,
624,
199,
199,
8918,
275,
408,
272,
446,
536,
26,
2494,
10891,
10332,
489,
15742,
63,
69,
63,
1102,
26,
267,
25891,
26,
7370,
25891,
7820,
267,
2986,
63,
633,
26,
7370,
15742,
63,
1246,
63,
633,
7820,
267,
2986,
63,
2473,
26,
7370,
15742,
63,
1246,
63,
2473,
7820,
267,
2986,
63,
2060,
26,
7370,
15742,
63,
1246,
63,
2060,
7820,
267,
536,
26,
7370,
1591,
63,
354,
7820,
267,
1591,
63,
466,
63,
1080,
26,
7370,
1591,
63,
466,
63,
1080,
7820,
199,
624,
199,
199,
9677,
275,
408,
199,
1328,
26,
272,
1369,
26,
22318,
1245,
272,
2138,
26,
3182,
272,
730,
26,
1059,
272,
2690,
26,
710,
1591,
965,
2757,
2737,
14,
199,
624,
199,
646,
2022,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
1246,
492,
5678,
63,
1178,
63,
2094,
63,
1650,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
647,
5819,
1194,
492,
664,
63,
1971,
199,
504,
3242,
14,
578,
63,
1208,
14,
3603,
492,
1551,
63,
633,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
705,
492,
15050,
199,
199,
21178,
275,
469,
272,
298,
2714,
13,
804,
582,
298,
3578,
15,
1001,
401,
272,
298,
8422,
582,
298,
3578,
15,
1001,
401,
199,
93,
421,
199,
318,
1056,
8,
633,
12,
666,
29,
403,
12,
2323,
29,
403,
12,
1083,
534,
2970,
297,
675,
63,
3280,
29,
549,
12,
288,
3542,
29,
797,
12,
2061,
63,
1494,
63,
521,
29,
403,
12,
2653,
29,
709,
12,
4107,
63,
8356,
29,
549,
12,
288,
1166,
63,
2473,
29,
403,
12,
1166,
63,
2060,
29,
403,
12,
1455,
63,
4054,
29,
403,
12,
3542,
63,
4316,
63,
1178,
29,
549,
12,
3686,
63,
2550,
29,
797,
304,
272,
862,
26,
267,
519,
275,
1551,
63,
633,
8,
633,
29,
633,
12,
666,
29,
576,
12,
2323,
29,
2139,
12,
1083,
29,
765,
12,
675,
63,
3280,
29,
1180,
63,
3280,
12,
2151,
3542,
29,
3990,
12,
2061,
63,
1494,
63,
521,
29,
2019,
63,
1494,
63,
521,
12,
2653,
29,
2593,
12,
4107,
63,
8356,
29,
3502,
63,
8356,
12,
2151,
1166,
63,
2473,
29,
633,
63,
2473,
12,
1166,
63,
2060,
29,
633,
63,
2060,
12,
1455,
63,
4054,
29,
1014,
63,
4054,
12,
2151,
3542,
63,
4316,
63,
1178,
29,
3990,
63,
4316,
63,
1178,
9,
272,
871,
15050,
26,
267,
2329,
275,
664,
63,
1971,
342,
267,
519,
275
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
3,
334,
67,
9,
7800,
12,
28076,
12,
3277,
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,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
16,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
408,
199,
2595,
199,
578,
26,
15742,
63,
69,
63,
1102,
199,
3612,
63,
1802,
26,
9635,
325,
5602,
7057,
199,
1802,
26,
272,
446,
2790,
12,
1678,
12,
2813,
7057,
641,
28076,
662,
13,
5602,
4887,
6572,
199,
1023,
63,
3270,
26,
283,
18,
14,
18,
7,
199,
2502,
26,
25645,
11908,
869,
348,
613,
8593,
72,
348,
613,
9,
199,
1419,
26,
272,
2986,
63,
2473,
26,
267,
1415,
26,
2549,
267,
1369,
26,
267,
446,
710,
3434,
370,
12895,
543,
314,
428,
879,
599,
3690,
6001,
15803,
12373,
503,
12169,
14880,
3261,
14,
272,
2986,
63,
2060,
26,
267,
1415,
26,
2549,
267,
1369,
26,
267,
446,
710,
2505,
370,
12895,
543,
314,
428,
879,
599,
3690,
6001,
15803,
12373,
503,
12169,
14880,
3261,
14,
272,
2986,
63,
633,
26,
267,
1415,
26,
2549,
267,
1369,
26,
267,
446,
710,
1166,
370,
314,
428,
879,
599,
3690,
6001,
15803,
12373,
503,
12169,
14880,
3261,
12,
367,
2893,
445,
8,
2859,
921,
8788,
13,
17,
14,
758,
19112,
14,
18107,
14,
957,
15,
2374,
7755,
15,
86,
18,
680,
272,
4107,
63,
8356,
26,
267,
1415,
26,
3055,
267,
849,
26,
2549,
267,
1369,
26,
267,
446,
7719,
4178,
14512,
506,
16468,
31,
272,
25891,
26,
267,
1369,
26,
288,
446,
314,
1305,
402,
314,
4887,
1625,
1265,
13809,
370,
2454,
6169,
267,
1415,
26,
715,
272,
536,
26,
267,
1369,
26,
288,
446,
982,
314,
1591,
1630,
343,
5966,
2187,
12,
314,
1768,
370,
5090,
737,
7143,
900,
14,
288,
446,
982,
314,
7057,
2575,
3495,
12,
642,
365,
4052,
365,
1202,
370,
10405,
314,
1591,
370,
4838,
1263,
6387,
4493,
267,
1415,
26,
715,
272,
1591,
63,
466,
63,
1080,
26,
267,
1369,
26,
288,
446,
710,
1478,
626,
9033,
370,
1591,
730,
1265,
13809,
370,
1218,
14,
2779,
365,
14318,
370,
675,
314,
603,
8,
25830,
63,
69,
63,
5047,
9,
859,
370,
13082,
642,
2556,
14,
1598,
26776,
1265,
883,
675,
314,
644,
5763,
18428,
370,
8044,
314,
2556,
14,
267,
1415,
26,
715,
272,
8873,
26,
267,
1369,
26,
288,
446,
282,
769,
402,
402,
11196,
402,
1591,
8873,
1265,
13809,
370,
20133,
543,
314,
13903,
2737,
1591,
267,
1415,
26,
756,
272,
1572,
26,
267,
1369,
26,
288,
446,
314,
1572,
1265,
2934,
314,
1591,
370,
506,
282,
3653,
402,
267,
1415,
26,
756,
199,
199,
624,
199,
199,
8918,
275,
408,
272,
446,
536,
26,
2494,
10891,
10332,
489,
15742,
63,
69,
63,
1102,
26,
267,
25891,
26,
7370,
25891,
7820,
267,
2986,
63,
633,
26,
7370,
15742,
63,
1246,
63,
633,
7820,
267,
2986,
63,
2473,
26,
7370,
15742,
63,
1246,
63,
2473,
7820,
267,
2986,
63,
2060,
26,
7370,
15742,
63,
1246,
63,
2060,
7820,
267,
536,
26,
7370,
1591,
63,
354,
7820,
267,
1591,
63,
466,
63,
1080,
26,
7370,
1591,
63,
466,
63,
1080,
7820,
199,
624,
199,
199,
9677,
275,
408,
199,
1328,
26,
272,
1369,
26,
22318,
1245,
272,
2138,
26,
3182,
272,
730,
26,
1059,
272,
2690,
26,
710,
1591,
965,
2757,
2737,
14,
199,
624,
199,
646,
2022,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
1246,
492,
5678,
63,
1178,
63,
2094,
63,
1650,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
647,
5819,
1194,
492,
664,
63,
1971,
199,
504,
3242,
14,
578,
63,
1208,
14,
3603,
492,
1551,
63,
633,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
705,
492,
15050,
199,
199,
21178,
275,
469,
272,
298,
2714,
13,
804,
582,
298,
3578,
15,
1001,
401,
272,
298,
8422,
582,
298,
3578,
15,
1001,
401,
199,
93,
421,
199,
318,
1056,
8,
633,
12,
666,
29,
403,
12,
2323,
29,
403,
12,
1083,
534,
2970,
297,
675,
63,
3280,
29,
549,
12,
288,
3542,
29,
797,
12,
2061,
63,
1494,
63,
521,
29,
403,
12,
2653,
29,
709,
12,
4107,
63,
8356,
29,
549,
12,
288,
1166,
63,
2473,
29,
403,
12,
1166,
63,
2060,
29,
403,
12,
1455,
63,
4054,
29,
403,
12,
3542,
63,
4316,
63,
1178,
29,
549,
12,
3686,
63,
2550,
29,
797,
304,
272,
862,
26,
267,
519,
275,
1551,
63,
633,
8,
633,
29,
633,
12,
666,
29,
576,
12,
2323,
29,
2139,
12,
1083,
29,
765,
12,
675,
63,
3280,
29,
1180,
63,
3280,
12,
2151,
3542,
29,
3990,
12,
2061,
63,
1494,
63,
521,
29,
2019,
63,
1494,
63,
521,
12,
2653,
29,
2593,
12,
4107,
63,
8356,
29,
3502,
63,
8356,
12,
2151,
1166,
63,
2473,
29,
633,
63,
2473,
12,
1166,
63,
2060,
29,
633,
63,
2060,
12,
1455,
63,
4054,
29,
1014,
63,
4054,
12,
2151,
3542,
63,
4316,
63,
1178,
29,
3990,
63,
4316,
63,
1178,
9,
272,
871,
15050,
26,
267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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
vmonaco/rpscontest
|
agents/ga3.py
|
1
|
2188
|
import random, math
def highest(v):
return random.choice([i for i in range(len(v)) if max(v) == v[i]])
def lowest(v):
return random.choice([i for i in range(len(v)) if min(v) == v[i]])
def best(c):
return highest([c[1]-c[2], c[2]-c[0], c[0]-c[1]])
if(1):
if (input == ""):
N = 1
AR1 = 0.89
states = ["R","S","P"]
st = [0,1,2]
sdic = {"R":0, "S":1, "P":2}
table = {}
cutoff = 400
hennies = 5
res = [[0, 1, -1], [-1, 0, 1], [1, -1, 0]]
r=0
MEM2 = [3,4,5]
M = len(MEM2)*2 + 1
models = [.3,.3,1]*(len(MEM2)*2)+ [1,0.6,0.6]
state = [0] * (M*3)
yo = random.choice(st)
tu = random.choice(st)
pa = (yo, tu)
hi = [pa]
prognosis = [random.choice(st) for i in range(M*3+1)]
choices = []
else:
tu = sdic[input]
pa = (yo,tu)
hi += [pa]
state = [ AR1 * state[i] + res[prognosis[i]][tu] * models[i] for i in range(M*3)]
r = res[yo][tu]
i = 0
prop = [random.choice(st) for j in range(len(MEM2)*2)]
for m in MEM2:
if(N + 1> m):
key = tuple(hi[-m-1:-1])
if (key in table):
table[key] += [pa]
else:
table[key] = [pa]
if(N > m):
key = tuple(hi[-m:])
if (key in table):
ch = table[key]
k = len(ch)
k = max(random.choice(range(0,k)),random.choice(range(0,k)))
prop[i] = ch[k][0]
prop[i+1] = ch[k][1]
i += 2
i = -3;
for m in range(len(MEM2)):
i += 3; prognosis[i] = (prop[m])
i += 3; prognosis[i] = (prop[m+1])
prob = [0,0,0]
# triplehenny
for j in range(hennies):
prob[(hi[random.choice(range(max(0,N-cutoff),N))][1])]+=1
i += 3; prognosis[i] = (best(prob))
i += 3
assert(i==3*M)
for j in range(M):
prognosis[j*3 + 1] = (prognosis[j*3] + 1) % 3
prognosis[j*3 + 2] = (prognosis[j*3+1] + 1) % 3
best = highest(state)
yo = prognosis[best]
output = states[yo]
N = N + 1
|
bsd-3-clause
|
[
646,
2196,
12,
3473,
199,
199,
318,
15356,
8,
86,
304,
272,
372,
2196,
14,
5095,
779,
73,
367,
284,
315,
1425,
8,
552,
8,
86,
430,
340,
1390,
8,
86,
9,
508,
373,
59,
73,
3934,
199,
199,
318,
18966,
8,
86,
304,
272,
372,
2196,
14,
5095,
779,
73,
367,
284,
315,
1425,
8,
552,
8,
86,
430,
340,
1748,
8,
86,
9,
508,
373,
59,
73,
3934,
199,
199,
318,
5526,
8,
67,
304,
272,
372,
15356,
779,
67,
59,
17,
11285,
67,
59,
18,
467,
286,
59,
18,
11285,
67,
59,
16,
467,
286,
59,
16,
11285,
67,
59,
17,
3934,
199,
199,
692,
8,
17,
304,
272,
340,
334,
1210,
508,
26430,
267,
653,
275,
413,
267,
4160,
17,
275,
378,
14,
1407,
267,
6363,
275,
2097,
50,
2266,
51,
2266,
48,
937,
267,
410,
275,
359,
16,
12,
17,
12,
18,
61,
267,
308,
5000,
275,
2420,
50,
582,
16,
12,
298,
51,
582,
17,
12,
298,
48,
582,
18,
93,
267,
1817,
275,
1052,
267,
17875,
275,
8290,
267,
394,
287,
78,
1500,
275,
959,
267,
522,
275,
3474,
16,
12,
413,
12,
446,
17,
467,
5243,
17,
12,
378,
12,
413,
467,
359,
17,
12,
446,
17,
12,
378,
2677,
267,
519,
29,
16,
267,
31424,
18,
275,
359,
19,
12,
20,
12,
21,
61,
267,
603,
275,
822,
8,
10293,
18,
3342,
18,
435,
413,
267,
267,
1709,
275,
26496,
19,
18485,
19,
12,
17,
3672,
8,
552,
8,
10293,
18,
3342,
18,
6393,
359,
17,
12,
16,
14,
22,
12,
16,
14,
22,
61,
267,
1174,
275,
359,
16,
61,
627,
334,
45,
10,
19,
9,
267,
612,
79,
275,
2196,
14,
5095,
8,
270,
9,
267,
30799,
275,
2196,
14,
5095,
8,
270,
9,
398,
691,
275,
334,
16540,
12,
30799,
9,
267,
13759,
275,
359,
387,
61,
267,
557,
784,
79,
2316,
275,
359,
2355,
14,
5095,
8,
270,
9,
367,
284,
315,
1425,
8,
45,
10,
19,
11,
17,
1874,
267,
3415,
275,
942,
2378,
587,
26,
881,
30799,
275,
308,
5000,
59,
1210,
61,
881,
691,
275,
334,
16540,
12,
10963,
9,
881,
13759,
847,
359,
387,
61,
881,
1174,
275,
359,
4160,
17,
627,
1174,
59,
73,
61,
435,
522,
59,
496,
784,
79,
2316,
59,
73,
22235,
10963,
61,
627,
1709,
59,
73,
61,
367,
284,
315,
1425,
8,
45,
10,
19,
1874,
8592,
519,
275,
522,
59,
16540,
1527,
10963,
61,
2126,
2378,
284,
275,
378,
25979,
5931,
275,
221,
359,
2355,
14,
5095,
8,
270,
9,
367,
1335,
315,
1425,
8,
552,
8,
10293,
18,
3342,
18,
1874,
272,
367,
333,
315,
31424,
18,
26,
489,
340,
8,
46,
435,
413,
30,
333,
304,
267,
790,
275,
2008,
8,
5812,
1988,
77,
13,
17,
6809,
17,
566,
267,
340,
334,
498,
315,
1817,
304,
7205,
1817,
59,
498,
61,
847,
359,
387,
61,
267,
587,
26,
7205,
1817,
59,
498,
61,
275,
359,
387,
61,
489,
340,
8,
46,
690,
333,
304,
267,
790,
275,
2008,
8,
5812,
1988,
77,
5728,
398,
340,
334,
498,
315,
1817,
304,
23664,
682,
275,
1817,
59,
498,
61,
881,
1022,
275,
822,
8,
335,
9,
881,
1022,
275,
1390,
8,
2355,
14,
5095,
8,
1842,
8,
16,
12,
75,
1826,
2355,
14,
5095,
8,
1842,
8,
16,
12,
75,
1724,
1779,
8592,
5931,
59,
73,
61,
275,
682,
59,
75,
1527,
16,
61,
881,
5931,
59,
73,
11,
17,
61,
275,
682,
59,
75,
1527,
17,
61,
2541,
284,
847,
499,
489,
272,
284,
275,
446,
19,
27,
272,
367,
333,
315,
1425,
8,
552,
8,
10293,
18,
2298,
2126,
284,
847,
650,
27,
557,
784,
79,
2316,
59,
73,
61,
275,
334,
4469,
59,
77,
566,
2126,
284,
847,
650,
27,
557,
784,
79,
2316,
59,
73,
61,
275,
334,
4469,
59,
77,
11,
17,
566,
339,
5128,
275,
359,
16,
12,
16,
12,
16,
61,
339,
327,
19671,
16800,
9745,
272,
367,
1335,
315,
1425,
8,
16800,
78,
1500,
304,
267,
5128,
7528,
5812,
59,
2355,
14,
5095,
8,
1842,
8,
988,
8,
16,
12,
46,
13,
17708,
395,
46,
430,
1527,
17,
566,
2807,
29,
17,
272,
284,
847,
650,
27,
557,
784,
79,
2316,
59,
73,
61,
275,
334,
7010,
8,
6101,
430,
272,
284,
847,
650,
339,
702,
8,
73,
389,
19,
10,
45,
9,
2043,
272,
367,
1335,
315,
1425,
8,
45,
304,
267,
557,
784,
79,
2316,
59,
74,
10,
19,
435,
413,
61,
275,
334,
496,
784,
79,
2316,
59,
74,
10,
19,
61,
435,
413,
9,
450,
650,
267,
557,
784,
79,
2316,
59,
74,
10,
19,
435,
499,
61,
275,
334,
496,
784,
79,
2316,
59,
74,
10,
19,
11,
17,
61,
435,
413,
9,
450,
650,
2378,
5526,
275,
15356,
8,
929,
9,
272,
612,
79,
275,
557,
784,
79,
2316,
59,
7010,
61,
421,
2286,
1072,
275,
6363,
59,
16540,
61,
257,
5493,
653,
275,
653,
435,
413,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2196,
12,
3473,
199,
199,
318,
15356,
8,
86,
304,
272,
372,
2196,
14,
5095,
779,
73,
367,
284,
315,
1425,
8,
552,
8,
86,
430,
340,
1390,
8,
86,
9,
508,
373,
59,
73,
3934,
199,
199,
318,
18966,
8,
86,
304,
272,
372,
2196,
14,
5095,
779,
73,
367,
284,
315,
1425,
8,
552,
8,
86,
430,
340,
1748,
8,
86,
9,
508,
373,
59,
73,
3934,
199,
199,
318,
5526,
8,
67,
304,
272,
372,
15356,
779,
67,
59,
17,
11285,
67,
59,
18,
467,
286,
59,
18,
11285,
67,
59,
16,
467,
286,
59,
16,
11285,
67,
59,
17,
3934,
199,
199,
692,
8,
17,
304,
272,
340,
334,
1210,
508,
26430,
267,
653,
275,
413,
267,
4160,
17,
275,
378,
14,
1407,
267,
6363,
275,
2097,
50,
2266,
51,
2266,
48,
937,
267,
410,
275,
359,
16,
12,
17,
12,
18,
61,
267,
308,
5000,
275,
2420,
50,
582,
16,
12,
298,
51,
582,
17,
12,
298,
48,
582,
18,
93,
267,
1817,
275,
1052,
267,
17875,
275,
8290,
267,
394,
287,
78,
1500,
275,
959,
267,
522,
275,
3474,
16,
12,
413,
12,
446,
17,
467,
5243,
17,
12,
378,
12,
413,
467,
359,
17,
12,
446,
17,
12,
378,
2677,
267,
519,
29,
16,
267,
31424,
18,
275,
359,
19,
12,
20,
12,
21,
61,
267,
603,
275,
822,
8,
10293,
18,
3342,
18,
435,
413,
267,
267,
1709,
275,
26496,
19,
18485,
19,
12,
17,
3672,
8,
552,
8,
10293,
18,
3342,
18,
6393,
359,
17,
12,
16,
14,
22,
12,
16,
14,
22,
61,
267,
1174,
275,
359,
16,
61,
627,
334,
45,
10,
19,
9,
267,
612,
79,
275,
2196,
14,
5095,
8,
270,
9,
267,
30799,
275,
2196,
14,
5095,
8,
270,
9,
398,
691,
275,
334,
16540,
12,
30799,
9,
267,
13759,
275,
359,
387,
61,
267,
557,
784,
79,
2316,
275,
359,
2355,
14,
5095,
8,
270,
9,
367,
284,
315,
1425,
8,
45,
10,
19,
11,
17,
1874,
267,
3415,
275,
942,
2378,
587,
26,
881,
30799,
275,
308,
5000,
59,
1210,
61,
881,
691,
275,
334,
16540,
12,
10963,
9,
881,
13759,
847,
359,
387,
61,
881,
1174,
275,
359,
4160,
17,
627,
1174,
59,
73,
61,
435,
522,
59,
496,
784,
79,
2316,
59,
73,
22235,
10963,
61,
627,
1709,
59,
73,
61,
367,
284,
315,
1425,
8,
45,
10,
19,
1874,
8592,
519,
275,
522,
59,
16540,
1527,
10963,
61,
2126,
2378,
284,
275,
378,
25979,
5931,
275,
221,
359,
2355,
14,
5095,
8,
270,
9,
367,
1335,
315,
1425,
8,
552,
8,
10293,
18,
3342,
18,
1874,
272,
367,
333,
315,
31424,
18,
26,
489,
340,
8,
46,
435,
413,
30,
333,
304,
267,
790,
275,
2008,
8,
5812,
1988,
77,
13,
17,
6809,
17,
566,
267,
340,
334,
498,
315,
1817,
304,
7205,
1817,
59,
498,
61,
847,
359,
387,
61,
267,
587,
26,
7205,
1817,
59,
498,
61,
275,
359,
387,
61,
489,
340,
8,
46,
690,
333,
304,
267,
790,
275,
2008,
8,
5812,
1988,
77,
5728,
398,
340,
334,
498,
315,
1817,
304,
23664,
682,
275,
1817,
59,
498,
61,
881,
1022,
275,
822,
8,
335,
9,
881,
1022,
275,
1390,
8,
2355,
14,
5095,
8,
1842,
8,
16,
12,
75,
1826,
2355,
14,
5095,
8,
1842,
8,
16,
12,
75,
1724,
1779,
8592,
5931,
59,
73,
61,
275,
682,
59,
75,
1527,
16,
61,
881,
5931,
59,
73,
11,
17,
61,
275,
682,
59,
75,
1527,
17,
61,
2541,
284,
847,
499,
489,
272,
284,
275,
446,
19,
27,
272,
367,
333,
315,
1425,
8,
552,
8,
10293,
18,
2298,
2126,
284,
847,
650,
27,
557,
784,
79,
2316,
59,
73,
61,
275,
334,
4469,
59,
77,
566,
2126,
284,
847,
650,
27,
557,
784,
79,
2316,
59,
73,
61,
275,
334,
4469,
59,
77,
11,
17,
566,
339,
5128,
275,
359,
16,
12,
16,
12,
16,
61,
339,
327,
19671,
16800,
9745,
272,
367,
1335,
315,
1425,
8,
16800,
78,
1500,
304,
267,
5128,
7528,
5812,
59,
2355,
14,
5095,
8,
1842,
8,
988,
8,
16,
12,
46,
13,
17708,
395,
46,
430,
1527,
17,
566,
2807,
29,
17,
272,
284,
847,
650,
27,
557,
784,
79,
2316,
59,
73,
61,
275,
334,
7010,
8,
6101,
430,
272,
284,
847,
650,
339,
702,
8,
73,
389,
19,
10,
45,
9,
2043,
272,
367,
1335,
315,
1425,
8,
45,
304,
267,
557,
784,
79,
2316,
59,
74,
10,
19,
435,
413,
61,
275,
334,
496,
784,
79,
2316,
59,
74,
10,
19,
61,
435,
413,
9,
450,
650,
267,
557,
784,
79,
2316,
59,
74,
10,
19,
435,
499,
61,
275,
334,
496,
784,
79,
2316,
59,
74,
10,
19,
11,
17,
61,
435,
413,
9,
450,
650,
2378,
5526,
275,
15356,
8,
929,
9,
272,
612,
79,
275,
557,
784,
79,
2316,
59,
7010,
61,
421,
2286,
1072,
275,
6363,
59,
16540,
61,
257,
5493,
653,
275,
653,
435,
413,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mikewiebe-ansible/ansible
|
test/units/modules/network/f5/test_bigip_gtm_virtual_server.py
|
38
|
5700
|
# -*- coding: utf-8 -*-
#
# Copyright: (c) 2017, 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
import os
import json
import pytest
import sys
if sys.version_info < (2, 7):
pytestmark = pytest.mark.skip("F5 Ansible modules require Python >= 2.7")
from ansible.module_utils.basic import AnsibleModule
try:
from library.modules.bigip_gtm_virtual_server import ApiParameters
from library.modules.bigip_gtm_virtual_server import ModuleParameters
from library.modules.bigip_gtm_virtual_server import ModuleManager
from library.modules.bigip_gtm_virtual_server import ArgumentSpec
# In Ansible 2.8, Ansible changed import paths.
from test.units.compat import unittest
from test.units.compat.mock import Mock
from test.units.compat.mock import patch
from test.units.modules.utils import set_module_args
except ImportError:
from ansible.modules.network.f5.bigip_gtm_virtual_server import ApiParameters
from ansible.modules.network.f5.bigip_gtm_virtual_server import ModuleParameters
from ansible.modules.network.f5.bigip_gtm_virtual_server import ModuleManager
from ansible.modules.network.f5.bigip_gtm_virtual_server import ArgumentSpec
# Ansible 2.8 imports
from units.compat import unittest
from units.compat.mock import Mock
from units.compat.mock import patch
from units.modules.utils import set_module_args
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {}
def load_fixture(name):
path = os.path.join(fixture_path, name)
if path in fixture_data:
return fixture_data[path]
with open(path) as f:
data = f.read()
try:
data = json.loads(data)
except Exception:
pass
fixture_data[path] = data
return data
class TestParameters(unittest.TestCase):
def test_module_parameters(self):
args = dict(
name='foo',
server_name='server1',
address='1.1.1.1',
port=22,
translation_address='2.2.2.2',
translation_port=443,
availability_requirements=dict(
type='at_least',
at_least=2,
),
monitors=['http', 'tcp', 'gtp'],
virtual_server_dependencies=[
dict(
server='server2',
virtual_server='vs2'
)
],
link='link1',
limits=dict(
bits_enabled=True,
packets_enabled=True,
connections_enabled=True,
bits_limit=100,
packets_limit=200,
connections_limit=300
),
state='present'
)
p = ModuleParameters(params=args)
assert p.name == 'foo'
assert p.server_name == 'server1'
assert p.address == '1.1.1.1'
assert p.port == 22
assert p.translation_address == '2.2.2.2'
assert p.translation_port == 443
assert p.availability_requirement_type == 'at_least'
assert p.at_least == 2
assert p.monitors == 'min 2 of { /Common/http /Common/tcp /Common/gtp }'
assert len(p.virtual_server_dependencies) == 1
assert p.link == '/Common/link1'
assert p.bits_enabled == 'enabled'
assert p.bits_limit == 100
assert p.packets_enabled == 'enabled'
assert p.packets_limit == 200
assert p.connections_enabled == 'enabled'
assert p.connections_limit == 300
def test_api_parameters(self):
args = load_fixture('load_gtm_server_virtual_2.json')
p = ApiParameters(params=args)
assert p.name == 'vs2'
assert p.address == '6.6.6.6'
assert p.port == 8080
assert p.translation_address == 'none'
assert p.translation_port == 0
assert p.availability_requirement_type == 'all'
assert p.monitors == '/Common/gtp'
assert p.bits_enabled == 'enabled'
assert p.bits_limit == 100
assert p.packets_enabled == 'enabled'
assert p.packets_limit == 200
assert p.connections_enabled == 'enabled'
assert p.connections_limit == 300
class TestManager(unittest.TestCase):
def setUp(self):
self.spec = ArgumentSpec()
try:
self.p1 = patch('library.modules.bigip_gtm_virtual_server.module_provisioned')
self.m1 = self.p1.start()
self.m1.return_value = True
except Exception:
self.p1 = patch('ansible.modules.network.f5.bigip_gtm_virtual_server.module_provisioned')
self.m1 = self.p1.start()
self.m1.return_value = True
def tearDown(self):
self.p1.stop()
def test_create_datacenter(self, *args):
set_module_args(dict(
server_name='foo',
name='vs1',
address='1.1.1.1',
state='present',
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[False, True])
mm.create_on_device = Mock(return_value=True)
results = mm.exec_module()
assert results['changed'] is True
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
9708,
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,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
2022,
199,
646,
4613,
199,
646,
984,
199,
199,
692,
984,
14,
1023,
63,
815,
665,
334,
18,
12,
1520,
304,
272,
4613,
1657,
275,
4613,
14,
1657,
14,
2759,
480,
38,
21,
2622,
4621,
4409,
2018,
2356,
499,
14,
23,
531,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
199,
893,
26,
272,
687,
3555,
14,
3112,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
31145,
272,
687,
3555,
14,
3112,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
5673,
5976,
272,
687,
3555,
14,
3112,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
24118,
272,
687,
3555,
14,
3112,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
28405,
339,
327,
1010,
2622,
499,
14,
24,
12,
2622,
2896,
492,
3792,
14,
272,
687,
511,
14,
5260,
14,
5819,
492,
2882,
272,
687,
511,
14,
5260,
14,
5819,
14,
1805,
492,
4420,
272,
687,
511,
14,
5260,
14,
5819,
14,
1805,
492,
3371,
339,
687,
511,
14,
5260,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
199,
2590,
3545,
26,
272,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
31145,
272,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
5673,
5976,
272,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
24118,
272,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
28405,
339,
327,
2622,
499,
14,
24,
8925,
272,
687,
6204,
14,
5819,
492,
2882,
272,
687,
6204,
14,
5819,
14,
1805,
492,
4420,
272,
687,
6204,
14,
5819,
14,
1805,
492,
3371,
339,
687,
6204,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
421,
199,
5997,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
8769,
358,
199,
5997,
63,
576,
275,
1052,
421,
199,
318,
2248,
63,
5997,
8,
354,
304,
272,
931,
275,
747,
14,
515,
14,
904,
8,
5997,
63,
515,
12,
536,
9,
339,
340,
931,
315,
10949,
63,
576,
26,
267,
372,
10949,
63,
576,
59,
515,
61,
339,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
666,
275,
289,
14,
739,
342,
339,
862,
26,
267,
666,
275,
2022,
14,
3640,
8,
576,
9,
272,
871,
2186,
26,
267,
986,
339,
10949,
63,
576,
59,
515,
61,
275,
666,
272,
372,
666,
421,
199,
533,
1379,
5976,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
578,
63,
3214,
8,
277,
304,
267,
1249,
275,
1211,
8,
288,
536,
534,
1421,
297,
288,
1654,
63,
354,
534,
1000,
17,
297,
288,
2287,
534,
17,
14,
17,
14,
17,
14,
17,
297,
288,
1844,
29,
1081,
12,
288,
7761,
63,
1562,
534,
18,
14,
18,
14,
18,
14,
18,
297,
288,
7761,
63,
719,
29,
16284,
12,
288,
14962,
63,
7538,
29,
807,
8,
355,
730,
534,
292,
63,
11790,
297,
355,
737,
63,
11790,
29,
18,
12,
288,
2318,
288,
26862,
2968,
1014,
297,
283,
8815,
297,
283,
71,
683,
995,
288,
5791,
63,
1000,
63,
5714,
1524,
355,
1211,
8,
490,
1654,
534,
1000,
18,
297,
490,
5791,
63,
1000,
534,
3122,
18,
7,
355,
776,
288,
2156,
288,
2142,
534,
1073,
17,
297,
288,
10976,
29,
807,
8,
355,
5821,
63,
3827,
29,
549,
12,
355,
14593,
63,
3827,
29,
549,
12,
355,
6947,
63,
3827,
29,
549,
12,
355,
5821,
63,
3097,
29,
1960,
12,
355,
14593,
63,
3097,
29,
1840,
12,
355,
6947,
63,
3097,
29,
5863,
288,
2318,
288,
1174,
534,
1881,
7,
267,
776,
398,
299,
275,
5673,
5976,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
354,
508,
283,
1421,
7,
267,
702,
299,
14,
1000,
63,
354,
508,
283,
1000,
17,
7,
267,
702,
299,
14,
1562,
508,
283,
17,
14,
17,
14,
17,
14,
17,
7,
267,
702,
299,
14,
719,
508,
6928,
267,
702,
299,
14,
6893,
63,
1562,
508,
283,
18,
14,
18,
14,
18,
14,
18,
7,
267,
702,
299,
14,
6893,
63,
719,
508,
23865,
267,
702,
299,
14,
11856,
63,
12434,
63,
466,
508,
283,
292,
63,
11790,
7,
267,
702,
299,
14,
292,
63,
11790,
508,
499,
267,
702,
299,
14,
24048,
508,
283,
827,
499,
402,
469,
1182,
7844,
15,
1014,
1182,
7844,
15,
8815,
1182,
7844,
15,
71,
683,
789,
7,
267,
702,
822,
8,
80,
14,
2065,
63,
1000,
63,
5714,
9,
508,
413,
267,
702,
299,
14,
1073,
508,
1994,
7844,
15,
1073,
17,
7,
267,
702,
299,
14,
5609,
63,
3827,
508,
283,
3827,
7,
267,
702,
299,
14,
5609,
63,
3097,
508,
2948,
267,
702,
299,
14,
18853,
63,
3827,
508,
283,
3827,
7,
267,
702,
299,
14,
18853,
63,
3097,
508,
1926,
267,
702,
299,
14,
7995,
63,
3827,
508,
283,
3827,
7,
267,
702,
299,
14,
7995,
63,
3097,
508,
9601,
339,
347,
511,
63,
1246,
63,
3214,
8,
277,
304,
267,
1249,
275,
2248,
63,
5997,
360,
912,
63,
29611,
63,
1000,
63,
2065,
63,
18,
14,
1001,
358,
398,
299,
275,
31145,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
354,
508,
283,
3122,
18,
7,
267,
702,
299,
14,
1562,
508,
283,
22,
14,
22,
14,
22,
14,
22,
7,
267,
702,
299,
14,
719,
508,
30220,
267,
702,
299,
14,
6893,
63,
1562,
508,
283,
3592,
7,
267,
702,
299,
14,
6893,
63,
719,
508,
378,
267,
702,
299,
14,
11856,
63,
12434,
63,
466,
508,
283,
452
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
9708,
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,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
2022,
199,
646,
4613,
199,
646,
984,
199,
199,
692,
984,
14,
1023,
63,
815,
665,
334,
18,
12,
1520,
304,
272,
4613,
1657,
275,
4613,
14,
1657,
14,
2759,
480,
38,
21,
2622,
4621,
4409,
2018,
2356,
499,
14,
23,
531,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
199,
893,
26,
272,
687,
3555,
14,
3112,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
31145,
272,
687,
3555,
14,
3112,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
5673,
5976,
272,
687,
3555,
14,
3112,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
24118,
272,
687,
3555,
14,
3112,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
28405,
339,
327,
1010,
2622,
499,
14,
24,
12,
2622,
2896,
492,
3792,
14,
272,
687,
511,
14,
5260,
14,
5819,
492,
2882,
272,
687,
511,
14,
5260,
14,
5819,
14,
1805,
492,
4420,
272,
687,
511,
14,
5260,
14,
5819,
14,
1805,
492,
3371,
339,
687,
511,
14,
5260,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
199,
2590,
3545,
26,
272,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
31145,
272,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
5673,
5976,
272,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
24118,
272,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
29611,
63,
2065,
63,
1000,
492,
28405,
339,
327,
2622,
499,
14,
24,
8925,
272,
687,
6204,
14,
5819,
492,
2882,
272,
687,
6204,
14,
5819,
14,
1805,
492,
4420,
272,
687,
6204,
14,
5819,
14,
1805,
492,
3371,
339,
687,
6204,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
421,
199,
5997,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
8769,
358,
199,
5997,
63,
576,
275,
1052,
421,
199,
318,
2248,
63,
5997,
8,
354,
304,
272,
931,
275,
747,
14,
515,
14,
904,
8,
5997,
63,
515,
12,
536,
9,
339,
340,
931,
315,
10949,
63,
576,
26,
267,
372,
10949,
63,
576,
59,
515,
61,
339,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
666,
275,
289,
14,
739,
342,
339,
862,
26,
267,
666,
275,
2022,
14,
3640,
8,
576,
9,
272,
871,
2186,
26,
267,
986,
339,
10949,
63,
576,
59,
515,
61,
275,
666,
272,
372,
666,
421,
199,
533,
1379,
5976,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
578,
63,
3214,
8,
277,
304,
267,
1249,
275,
1211,
8,
288,
536,
534,
1421,
297,
288,
1654,
63,
354,
534,
1000,
17,
297,
288,
2287,
534,
17,
14,
17,
14,
17,
14,
17,
297,
288,
1844,
29,
1081,
12,
288,
7761,
63,
1562,
534,
18,
14,
18,
14,
18,
14,
18,
297,
288,
7761,
63,
719,
29,
16284,
12,
288,
14962,
63,
7538,
29,
807,
8,
355,
730,
534,
292,
63,
11790,
297,
355,
737,
63,
11790,
29,
18,
12,
288,
2318,
288,
26862,
2968,
1014,
297,
283,
8815,
297,
283,
71,
683,
995,
288,
5791,
63,
1000,
63,
5714,
1524,
355,
1211,
8,
490,
1654,
534,
1000,
18,
297,
490,
5791,
63,
1000,
534,
3122,
18,
7,
355,
776,
288,
2156,
288,
2142,
534,
1073,
17,
297,
288,
10976,
29,
807,
8,
355,
5821,
63,
3827,
29,
549,
12,
355,
14593,
63,
3827,
29,
549,
12,
355,
6947,
63,
3827,
29,
549,
12,
355,
5821,
63,
3097,
29,
1960,
12,
355,
14593,
63,
3097,
29,
1840,
12,
355,
6947,
63,
3097,
29,
5863,
288,
2318,
288,
1174,
534,
1881,
7,
267,
776,
398,
299,
275,
5673,
5976,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
354,
508,
283,
1421,
7,
267,
702,
299,
14,
1000,
63,
354,
508,
283,
1000,
17,
7,
267,
702,
299,
14,
1562,
508,
283,
17,
14,
17,
14,
17,
14,
17,
7,
267,
702,
299,
14,
719,
508,
6928,
267,
702,
299,
14,
6893,
63,
1562,
508,
283,
18,
14,
18,
14,
18,
14,
18,
7,
267,
702,
299,
14,
6893,
63,
719,
508,
23865,
267,
702,
299,
14,
11856,
63,
12434,
63,
466,
508,
283,
292,
63,
11790,
7,
267,
702,
299,
14,
292,
63,
11790,
508,
499,
267,
702,
299,
14,
24048,
508,
283,
827,
499,
402,
469,
1182,
7844,
15,
1014,
1182,
7844,
15,
8815,
1182,
7844,
15,
71,
683,
789,
7,
267,
702,
822,
8,
80,
14,
2065,
63,
1000,
63,
5714,
9,
508,
413,
267,
702,
299,
14,
1073,
508,
1994,
7844,
15,
1073,
17,
7,
267,
702,
299,
14,
5609,
63,
3827,
508,
283,
3827,
7,
267,
702,
299,
14,
5609,
63,
3097,
508,
2948,
267,
702,
299,
14,
18853,
63,
3827,
508,
283,
3827,
7,
267,
702,
299,
14,
18853,
63,
3097,
508,
1926,
267,
702,
299,
14,
7995,
63,
3827,
508,
283,
3827,
7,
267,
702,
299,
14,
7995,
63,
3097,
508,
9601,
339,
347,
511,
63,
1246,
63,
3214,
8,
277,
304,
267,
1249,
275,
2248,
63,
5997,
360,
912,
63,
29611,
63,
1000,
63,
2065,
63,
18,
14,
1001,
358,
398,
299,
275,
31145,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
354,
508,
283,
3122,
18,
7,
267,
702,
299,
14,
1562,
508,
283,
22,
14,
22,
14,
22,
14,
22,
7,
267,
702,
299,
14,
719,
508,
30220,
267,
702,
299,
14,
6893,
63,
1562,
508,
283,
3592,
7,
267,
702,
299,
14,
6893,
63,
719,
508,
378,
267,
702,
299,
14,
11856,
63,
12434,
63,
466,
508,
283,
452,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
RaJiska/Warband-PW-Punishments-Manager
|
scripts/process_items.py
|
6
|
1534
|
import process_common as pc
import process_operations as po
from header_items import *
import module_items
def process_entry(processor, txt_file, item, index):
visible_name = pc.replace_spaces(item[1])
item_meshes = item[2]
output_list = [" itm_%s %s %s %d " % (item[0], visible_name, visible_name, po.block_len(item_meshes))]
output_list.extend([" %s %d " % mesh_imod for mesh_imod in item_meshes])
stats = item[6]
output_list.append(" %d %d %d %d %f %d %d %d %d %d %d %d %d %d %d %d %d\r\n" % (item[3], item[4], item[5], item[7],
get_weight(stats), get_abundance(stats), get_head_armor(stats), get_body_armor(stats), get_leg_armor(stats),
get_difficulty(stats), get_hit_points(stats), get_speed_rating(stats), get_missile_speed(stats),
get_weapon_length(stats), get_max_ammo(stats), get_thrust_damage(stats), get_swing_damage(stats)))
item_len = len(item)
if item_len > 9:
output_list.append(" %d\r\n" % po.block_len(item[9]))
output_list.extend([" %d" % processor.process_id(item_faction, "fac") for item_faction in item[9]])
output_list.append("\r\n")
else:
output_list.append(" 0\r\n")
txt_file.write("".join(output_list))
triggers = item[8] if item_len > 8 else []
triggers = processor.process_triggers(triggers, item[0])
triggers.append("\r\n")
txt_file.write("".join(triggers))
export = po.make_export(data=module_items.items, data_name="items", tag="itm", file_name="item_kinds1",
header_format="itemsfile version 3\r\n%d\r\n", process_entry=process_entry)
|
gpl-3.0
|
[
646,
2112,
63,
2330,
465,
13171,
199,
646,
2112,
63,
8170,
465,
1115,
199,
504,
1406,
63,
1744,
492,
627,
199,
646,
859,
63,
1744,
199,
199,
318,
2112,
63,
2373,
8,
6459,
12,
9444,
63,
493,
12,
1242,
12,
1478,
304,
523,
8917,
63,
354,
275,
13171,
14,
1814,
63,
10749,
8,
1053,
59,
17,
566,
523,
1242,
63,
6480,
397,
275,
1242,
59,
18,
61,
523,
1072,
63,
513,
275,
2097,
652,
77,
4970,
83,
450,
83,
450,
83,
450,
68,
298,
450,
334,
1053,
59,
16,
467,
8917,
63,
354,
12,
8917,
63,
354,
12,
1115,
14,
1457,
63,
552,
8,
1053,
63,
6480,
397,
10524,
523,
1072,
63,
513,
14,
2880,
5234,
450,
83,
450,
68,
298,
450,
9364,
63,
1017,
364,
367,
9364,
63,
1017,
364,
315,
1242,
63,
6480,
397,
566,
523,
5020,
275,
1242,
59,
22,
61,
523,
1072,
63,
513,
14,
740,
480,
450,
68,
450,
68,
450,
68,
450,
68,
450,
70,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
60,
82,
60,
78,
2,
450,
334,
1053,
59,
19,
467,
1242,
59,
20,
467,
1242,
59,
21,
467,
1242,
59,
23,
467,
489,
664,
63,
3463,
8,
3200,
395,
664,
63,
371,
725,
554,
8,
3200,
395,
664,
63,
2993,
63,
27612,
8,
3200,
395,
664,
63,
2030,
63,
27612,
8,
3200,
395,
664,
63,
4170,
63,
27612,
8,
3200,
395,
489,
664,
63,
29801,
8,
3200,
395,
664,
63,
12948,
63,
3438,
8,
3200,
395,
664,
63,
7625,
63,
10417,
8,
3200,
395,
664,
63,
1292,
338,
274,
63,
7625,
8,
3200,
395,
489,
664,
63,
30804,
63,
1267,
8,
3200,
395,
664,
63,
988,
63,
455,
573,
8,
3200,
395,
664,
63,
273,
19622,
63,
26551,
8,
3200,
395,
664,
63,
3519,
316,
63,
26551,
8,
3200,
1724,
523,
1242,
63,
552,
275,
822,
8,
1053,
9,
523,
340,
1242,
63,
552,
690,
1749,
26,
272,
1072,
63,
513,
14,
740,
480,
450,
68,
60,
82,
60,
78,
2,
450,
1115,
14,
1457,
63,
552,
8,
1053,
59,
25,
2459,
272,
1072,
63,
513,
14,
2880,
5234,
450,
68,
2,
450,
12495,
14,
1412,
63,
344,
8,
1053,
63,
17287,
12,
298,
12668,
531,
367,
1242,
63,
17287,
315,
1242,
59,
25,
3934,
272,
1072,
63,
513,
14,
740,
4582,
82,
60,
78,
531,
523,
587,
26,
272,
1072,
63,
513,
14,
740,
480,
378,
60,
82,
60,
78,
531,
523,
9444,
63,
493,
14,
952,
31059,
904,
8,
1199,
63,
513,
430,
523,
18899,
275,
1242,
59,
24,
61,
340,
1242,
63,
552,
690,
1695,
587,
942,
523,
18899,
275,
12495,
14,
1412,
63,
26328,
8,
26328,
12,
1242,
59,
16,
566,
523,
18899,
14,
740,
4582,
82,
60,
78,
531,
523,
9444,
63,
493,
14,
952,
31059,
904,
8,
26328,
430,
199,
199,
3790,
275,
1115,
14,
1875,
63,
3790,
8,
576,
29,
578,
63,
1744,
14,
1744,
12,
666,
63,
354,
628,
1744,
401,
1947,
628,
10737,
401,
570,
63,
354,
628,
1053,
63,
5091,
83,
17,
401,
272,
1406,
63,
908,
628,
1744,
493,
1015,
650,
60,
82,
60,
78,
5,
68,
60,
82,
60,
78,
401,
2112,
63,
2373,
29,
1412,
63,
2373,
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
] |
[
2112,
63,
2330,
465,
13171,
199,
646,
2112,
63,
8170,
465,
1115,
199,
504,
1406,
63,
1744,
492,
627,
199,
646,
859,
63,
1744,
199,
199,
318,
2112,
63,
2373,
8,
6459,
12,
9444,
63,
493,
12,
1242,
12,
1478,
304,
523,
8917,
63,
354,
275,
13171,
14,
1814,
63,
10749,
8,
1053,
59,
17,
566,
523,
1242,
63,
6480,
397,
275,
1242,
59,
18,
61,
523,
1072,
63,
513,
275,
2097,
652,
77,
4970,
83,
450,
83,
450,
83,
450,
68,
298,
450,
334,
1053,
59,
16,
467,
8917,
63,
354,
12,
8917,
63,
354,
12,
1115,
14,
1457,
63,
552,
8,
1053,
63,
6480,
397,
10524,
523,
1072,
63,
513,
14,
2880,
5234,
450,
83,
450,
68,
298,
450,
9364,
63,
1017,
364,
367,
9364,
63,
1017,
364,
315,
1242,
63,
6480,
397,
566,
523,
5020,
275,
1242,
59,
22,
61,
523,
1072,
63,
513,
14,
740,
480,
450,
68,
450,
68,
450,
68,
450,
68,
450,
70,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
450,
68,
60,
82,
60,
78,
2,
450,
334,
1053,
59,
19,
467,
1242,
59,
20,
467,
1242,
59,
21,
467,
1242,
59,
23,
467,
489,
664,
63,
3463,
8,
3200,
395,
664,
63,
371,
725,
554,
8,
3200,
395,
664,
63,
2993,
63,
27612,
8,
3200,
395,
664,
63,
2030,
63,
27612,
8,
3200,
395,
664,
63,
4170,
63,
27612,
8,
3200,
395,
489,
664,
63,
29801,
8,
3200,
395,
664,
63,
12948,
63,
3438,
8,
3200,
395,
664,
63,
7625,
63,
10417,
8,
3200,
395,
664,
63,
1292,
338,
274,
63,
7625,
8,
3200,
395,
489,
664,
63,
30804,
63,
1267,
8,
3200,
395,
664,
63,
988,
63,
455,
573,
8,
3200,
395,
664,
63,
273,
19622,
63,
26551,
8,
3200,
395,
664,
63,
3519,
316,
63,
26551,
8,
3200,
1724,
523,
1242,
63,
552,
275,
822,
8,
1053,
9,
523,
340,
1242,
63,
552,
690,
1749,
26,
272,
1072,
63,
513,
14,
740,
480,
450,
68,
60,
82,
60,
78,
2,
450,
1115,
14,
1457,
63,
552,
8,
1053,
59,
25,
2459,
272,
1072,
63,
513,
14,
2880,
5234,
450,
68,
2,
450,
12495,
14,
1412,
63,
344,
8,
1053,
63,
17287,
12,
298,
12668,
531,
367,
1242,
63,
17287,
315,
1242,
59,
25,
3934,
272,
1072,
63,
513,
14,
740,
4582,
82,
60,
78,
531,
523,
587,
26,
272,
1072,
63,
513,
14,
740,
480,
378,
60,
82,
60,
78,
531,
523,
9444,
63,
493,
14,
952,
31059,
904,
8,
1199,
63,
513,
430,
523,
18899,
275,
1242,
59,
24,
61,
340,
1242,
63,
552,
690,
1695,
587,
942,
523,
18899,
275,
12495,
14,
1412,
63,
26328,
8,
26328,
12,
1242,
59,
16,
566,
523,
18899,
14,
740,
4582,
82,
60,
78,
531,
523,
9444,
63,
493,
14,
952,
31059,
904,
8,
26328,
430,
199,
199,
3790,
275,
1115,
14,
1875,
63,
3790,
8,
576,
29,
578,
63,
1744,
14,
1744,
12,
666,
63,
354,
628,
1744,
401,
1947,
628,
10737,
401,
570,
63,
354,
628,
1053,
63,
5091,
83,
17,
401,
272,
1406,
63,
908,
628,
1744,
493,
1015,
650,
60,
82,
60,
78,
5,
68,
60,
82,
60,
78,
401,
2112,
63,
2373,
29,
1412,
63,
2373,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jirikuncar/invenio
|
invenio/modules/documents/testsuite/test_api.py
|
14
|
3249
|
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2014 CERN.
#
# Invenio 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.
#
# Invenio 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 Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
import os
import shutil
import tempfile
from six import StringIO
from invenio.testsuite import make_test_suite, run_test_suite, InvenioTestCase
class TestDocumentsApi(InvenioTestCase):
def setUp(self):
from .. import api
self.app.config['DOCUMENTS_ENGINE'] = \
"invenio.modules.jsonalchemy.jsonext.engines.memory:MemoryStorage"
self.Document = api.Document
self.path = tempfile.mkdtemp()
def tearDown(self):
shutil.rmtree(self.path)
def test_document_creation(self):
"""Document creation"""
d = self.Document.create({'title': 'Document 1',
'description': 'Testing 1'})
self.assertTrue('creator' in d)
self.assertEqual(d['creator'], 0)
creation_date = d['creation_date']
modification_date = d['modification_date']
self.assertEqual(d['title'], 'Document 1')
d['title'] = 'New Document 1 Title'
e = d.update()
# Make sure that new version has new id
self.assertTrue(e['_id'] != d['_id'])
d = e
self.assertEqual(d['creation_date'], creation_date)
self.assertTrue(d['modification_date'] > modification_date)
content = 'Hello world'
# Make uri name callable
uri = lambda x: os.path.join(self.path, x['uuid'])
d.setcontents(StringIO(content), uri)
# Store the results for futher tests
uri = d['uri']
self.assertTrue(os.path.exists(uri))
self.assertEqual(d.open('rt').read(), content)
d.delete(force=True)
self.assertFalse(os.path.exists(uri))
def test_document_deletion(self):
"""Document deletion"""
d = self.Document.create({'title': 'Document 1',
'description': 'Testing 1'})
content = 'Hello world!'
source, sourcepath = tempfile.mkstemp()
with open(sourcepath, 'w+') as f:
f.write(content)
uri = os.path.join(self.path, 'test.txt')
d.setcontents(sourcepath, uri)
self.assertEqual(d.open('rt').read(), content)
d.delete()
self.assertTrue(d['deleted'])
self.assertTrue(os.path.exists(uri))
d.delete(force=True)
self.assertFalse(os.path.exists(uri))
shutil.rmtree(sourcepath, ignore_errors=True)
TEST_SUITE = make_test_suite(TestDocumentsApi)
if __name__ == '__main__':
run_test_suite(TEST_SUITE)
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
12235,
14,
199,
3,
1898,
334,
35,
9,
6927,
24354,
14,
199,
3,
199,
3,
12235,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
12235,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
3,
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,
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,
12235,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
15673,
13,
13421,
12,
8217,
14,
199,
199,
646,
747,
199,
646,
5145,
199,
646,
5549,
199,
199,
504,
3816,
492,
5228,
199,
199,
504,
13640,
14,
14239,
492,
1852,
63,
396,
63,
5768,
12,
1255,
63,
396,
63,
5768,
12,
12235,
1746,
421,
199,
533,
1379,
26872,
7394,
8,
607,
7597,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
687,
2508,
492,
2986,
267,
291,
14,
571,
14,
888,
459,
7884,
51,
63,
15956,
418,
275,
971,
288,
298,
30628,
14,
3112,
14,
1001,
6732,
14,
3596,
368,
400,
14,
30378,
14,
4844,
26,
8628,
6408,
2,
398,
291,
14,
5564,
275,
2986,
14,
5564,
267,
291,
14,
515,
275,
5549,
14,
11983,
342,
339,
347,
6766,
8,
277,
304,
267,
5145,
14,
9242,
8,
277,
14,
515,
9,
339,
347,
511,
63,
3554,
63,
8782,
8,
277,
304,
267,
408,
5564,
7143,
624,
267,
366,
275,
291,
14,
5564,
14,
981,
3252,
1213,
356,
283,
5564,
413,
297,
3303,
283,
1802,
356,
283,
9029,
413,
3071,
398,
291,
14,
1815,
360,
9986,
7,
315,
366,
9,
267,
291,
14,
629,
8,
68,
459,
9986,
995,
378,
9,
398,
7143,
63,
602,
275,
366,
459,
8782,
63,
602,
418,
267,
7100,
63,
602,
275,
366,
459,
20945,
63,
602,
418,
398,
291,
14,
629,
8,
68,
459,
1213,
995,
283,
5564,
413,
358,
398,
366,
459,
1213,
418,
275,
283,
4665,
7543,
413,
16881,
7,
267,
325,
275,
366,
14,
873,
342,
398,
327,
4155,
3238,
626,
892,
1015,
965,
892,
1305,
267,
291,
14,
1815,
8,
69,
8680,
344,
418,
1137,
366,
8680,
344,
1105,
398,
366,
275,
325,
398,
291,
14,
629,
8,
68,
459,
8782,
63,
602,
995,
7143,
63,
602,
9,
267,
291,
14,
1815,
8,
68,
459,
20945,
63,
602,
418,
690,
7100,
63,
602,
9,
398,
1564,
275,
283,
6257,
6701,
7,
267,
327,
4155,
5108,
536,
4550,
267,
5108,
275,
2400,
671,
26,
747,
14,
515,
14,
904,
8,
277,
14,
515,
12,
671,
459,
2580,
1105,
267,
366,
14,
409,
4407,
8,
6424,
8,
1317,
395,
5108,
9,
398,
327,
13874,
314,
2058,
367,
15632,
728,
2295,
267,
5108,
275,
366,
459,
2302,
418,
267,
291,
14,
1815,
8,
736,
14,
515,
14,
2444,
8,
2302,
430,
267,
291,
14,
629,
8,
68,
14,
1490,
360,
2591,
1959,
739,
1062,
1564,
9,
398,
366,
14,
1807,
8,
3990,
29,
549,
9,
267,
291,
14,
3334,
8,
736,
14,
515,
14,
2444,
8,
2302,
430,
339,
347,
511,
63,
3554,
63,
14281,
8,
277,
304,
267,
408,
5564,
14068,
624,
267,
366,
275,
291,
14,
5564,
14,
981,
3252,
1213,
356,
283,
5564,
413,
297,
3303,
283,
1802,
356,
283,
9029,
413,
3071,
398,
1564,
275,
283,
6257,
6701,
11213,
267,
1350,
12,
1350,
515,
275,
5549,
14,
17721,
342,
398,
543,
1551,
8,
1365,
515,
12,
283,
87,
13854,
465,
289,
26,
288,
289,
14,
952,
8,
1317,
9,
398,
5108,
275,
747,
14,
515,
14,
904,
8,
277,
14,
515,
12,
283,
396,
14,
2424,
358,
267,
366,
14,
409,
4407,
8,
1365,
515,
12,
5108,
9,
267,
291,
14,
629,
8,
68,
14,
1490,
360,
2591,
1959,
739,
1062,
1564,
9,
398,
366,
14,
1807,
342,
267,
291,
14,
1815,
8,
68,
459,
6062,
1105,
267,
291,
14,
1815,
8,
736,
14,
515,
14,
2444,
8,
2302,
430,
398,
366,
14,
1807,
8,
3990,
29,
549,
9,
267,
291,
14,
3334,
8,
736,
14,
515,
14,
2444,
8,
2302,
430,
398,
5145,
14,
9242,
8,
1365,
515,
12,
3686,
63,
2550,
29,
549,
9,
421,
199,
2864,
63,
6195,
4427,
275,
1852,
63,
396,
63,
5768,
8,
774,
26872,
7394,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1255,
63,
396,
63,
5768,
8,
2864,
63,
6195,
4427,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
12235,
14,
199,
3,
1898,
334,
35,
9,
6927,
24354,
14,
199,
3,
199,
3,
12235,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
12235,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
3,
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,
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,
12235,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
15673,
13,
13421,
12,
8217,
14,
199,
199,
646,
747,
199,
646,
5145,
199,
646,
5549,
199,
199,
504,
3816,
492,
5228,
199,
199,
504,
13640,
14,
14239,
492,
1852,
63,
396,
63,
5768,
12,
1255,
63,
396,
63,
5768,
12,
12235,
1746,
421,
199,
533,
1379,
26872,
7394,
8,
607,
7597,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
687,
2508,
492,
2986,
267,
291,
14,
571,
14,
888,
459,
7884,
51,
63,
15956,
418,
275,
971,
288,
298,
30628,
14,
3112,
14,
1001,
6732,
14,
3596,
368,
400,
14,
30378,
14,
4844,
26,
8628,
6408,
2,
398,
291,
14,
5564,
275,
2986,
14,
5564,
267,
291,
14,
515,
275,
5549,
14,
11983,
342,
339,
347,
6766,
8,
277,
304,
267,
5145,
14,
9242,
8,
277,
14,
515,
9,
339,
347,
511,
63,
3554,
63,
8782,
8,
277,
304,
267,
408,
5564,
7143,
624,
267,
366,
275,
291,
14,
5564,
14,
981,
3252,
1213,
356,
283,
5564,
413,
297,
3303,
283,
1802,
356,
283,
9029,
413,
3071,
398,
291,
14,
1815,
360,
9986,
7,
315,
366,
9,
267,
291,
14,
629,
8,
68,
459,
9986,
995,
378,
9,
398,
7143,
63,
602,
275,
366,
459,
8782,
63,
602,
418,
267,
7100,
63,
602,
275,
366,
459,
20945,
63,
602,
418,
398,
291,
14,
629,
8,
68,
459,
1213,
995,
283,
5564,
413,
358,
398,
366,
459,
1213,
418,
275,
283,
4665,
7543,
413,
16881,
7,
267,
325,
275,
366,
14,
873,
342,
398,
327,
4155,
3238,
626,
892,
1015,
965,
892,
1305,
267,
291,
14,
1815,
8,
69,
8680,
344,
418,
1137,
366,
8680,
344,
1105,
398,
366,
275,
325,
398,
291,
14,
629,
8,
68,
459,
8782,
63,
602,
995,
7143,
63,
602,
9,
267,
291,
14,
1815,
8,
68,
459,
20945,
63,
602,
418,
690,
7100,
63,
602,
9,
398,
1564,
275,
283,
6257,
6701,
7,
267,
327,
4155,
5108,
536,
4550,
267,
5108,
275,
2400,
671,
26,
747,
14,
515,
14,
904,
8,
277,
14,
515,
12,
671,
459,
2580,
1105,
267,
366,
14,
409,
4407,
8,
6424,
8,
1317,
395,
5108,
9,
398,
327,
13874,
314,
2058,
367,
15632,
728,
2295,
267,
5108,
275,
366,
459,
2302,
418,
267,
291,
14,
1815,
8,
736,
14,
515,
14,
2444,
8,
2302,
430,
267,
291,
14,
629,
8,
68,
14,
1490,
360,
2591,
1959,
739,
1062,
1564,
9,
398,
366,
14,
1807,
8,
3990,
29,
549,
9,
267,
291,
14,
3334,
8,
736,
14,
515,
14,
2444,
8,
2302,
430,
339,
347,
511,
63,
3554,
63,
14281,
8,
277,
304,
267,
408,
5564,
14068,
624,
267,
366,
275,
291,
14,
5564,
14,
981,
3252,
1213,
356,
283,
5564,
413,
297,
3303,
283,
1802,
356,
283,
9029,
413,
3071,
398,
1564,
275,
283,
6257,
6701,
11213,
267,
1350,
12,
1350,
515,
275,
5549,
14,
17721,
342,
398,
543,
1551,
8,
1365,
515,
12,
283,
87,
13854,
465,
289,
26,
288,
289,
14,
952,
8,
1317,
9,
398,
5108,
275,
747,
14,
515,
14,
904,
8,
277,
14,
515,
12,
283,
396,
14,
2424,
358,
267,
366,
14,
409,
4407,
8,
1365,
515,
12,
5108,
9,
267,
291,
14,
629,
8,
68,
14,
1490,
360,
2591,
1959,
739,
1062,
1564,
9,
398,
366,
14,
1807,
342,
267,
291,
14,
1815,
8,
68,
459,
6062,
1105,
267,
291,
14,
1815,
8,
736,
14,
515,
14,
2444,
8,
2302,
430,
398,
366,
14,
1807,
8,
3990,
29,
549,
9,
267,
291,
14,
3334,
8,
736,
14,
515,
14,
2444,
8,
2302,
430,
398,
5145,
14,
9242,
8,
1365,
515,
12,
3686,
63,
2550,
29,
549,
9,
421,
199,
2864,
63,
6195,
4427,
275,
1852,
63,
396,
63,
5768,
8,
774,
26872,
7394,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1255,
63,
396,
63,
5768,
8,
2864,
63,
6195,
4427,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
capitalone/cloud-custodian
|
c7n/filters/iamanalyzer.py
|
1
|
3700
|
# Copyright 2020 Kapil Thangavelu
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
from .core import ValueFilter
from c7n.exceptions import PolicyExecutionError
from c7n.manager import resources
from c7n.utils import type_schema, local_session, chunks
class AccessAnalyzer(ValueFilter):
"""Analyze resource access policies using AWS IAM Access Analyzer.
Access analyzer uses logic based reasoning to analyze embedded resource
iam access policies to determine access outside of a zone of trust.
.. code-block:: yaml
policies:
- name: s3-check
resource: aws.s3
filters:
- type: iam-analyzer
key: isPublic
value: true
"""
schema = type_schema('iam-analyzer',
analyzer={'type': 'string'}, rinherit=ValueFilter.schema)
schema_alias = True
permissions = ('access-analyzer:ListFindings', 'access-analyzer:ListAnalyzers')
supported_types = (
'AWS::IAM::Role',
'AWS::KMS::Key',
'AWS::Lambda::Function',
'AWS::Lambda::LayerVersion',
'AWS::S3::Bucket',
'AWS::SQS::Queue',
)
analysis_annotation = 'c7n:AccessAnalysis'
def process(self, resources, event=None):
client = local_session(self.manager.session_factory).client('accessanalyzer')
analyzer_arn = self.get_analyzer(client)
results = []
self.annotate = False
self.get_findings(
client, analyzer_arn,
[r for r in resources if self.analysis_annotation not in r])
for r in resources:
findings = r.get(self.analysis_annotation, [])
if not findings:
continue
elif not len(self.data) > 1:
results.append(r)
continue
found = False
for f in findings:
if self(f):
found = True
break
if found:
results.append(r)
return results
def get_findings(self, client, analyzer_arn, resources):
for resource_set in chunks(
zip(self.manager.get_arns(resources), resources),
20):
resource_set = dict(resource_set)
filters = {
'status': {'eq': ['ACTIVE']},
'resource': {'contains': list(resource_set)},
'resourceType': {'eq': [self.manager.resource_type.cfn_type]}
}
for finding in self.manager.retry(
client.list_findings,
analyzerArn=analyzer_arn, filter=filters).get('findings', ()):
r = resource_set[finding['resource']]
r.setdefault(self.analysis_annotation, []).append(finding)
def get_analyzer(self, client):
if self.data.get('analyzer'):
return self.data['analyzer']
analyzers = client.list_analyzers(type='ACCOUNT').get('analyzers', ())
found = False
for a in analyzers:
if a['status'] != 'ACTIVE':
continue
found = a
if not found:
raise PolicyExecutionError(
"policy:%s no access analyzer found in account or org analyzer specified" % (
self.manager.policy.name
))
return found['arn']
@classmethod
def register_resources(klass, registry, resource_class):
if resource_class.resource_type.cfn_type not in klass.supported_types:
return
resource_class.filter_registry.register('iam-analyzer', klass)
resources.subscribe(AccessAnalyzer.register_resources)
|
apache-2.0
|
[
3,
1898,
25455,
1804,
439,
382,
3868,
621,
65,
1090,
85,
199,
3,
1898,
710,
8142,
445,
833,
79,
6268,
6642,
14,
199,
3,
6988,
19596,
13,
3761,
13,
7544,
26,
3668,
13,
18,
14,
16,
421,
199,
504,
1275,
1018,
492,
1594,
4131,
199,
199,
504,
286,
23,
78,
14,
3924,
492,
18141,
32165,
199,
504,
286,
23,
78,
14,
2609,
492,
5944,
199,
504,
286,
23,
78,
14,
1208,
492,
730,
63,
3629,
12,
2257,
63,
1730,
12,
8291,
421,
199,
533,
11003,
17606,
8,
1110,
4131,
304,
272,
408,
8014,
806,
2073,
2879,
14118,
1808,
10168,
28155,
11003,
14279,
2282,
14,
339,
11003,
24608,
4440,
9661,
4079,
4499,
316,
370,
19897,
12169,
2073,
272,
22361,
2879,
14118,
370,
6705,
2879,
9682,
402,
282,
5718,
402,
16822,
14,
339,
2508,
1233,
13,
1457,
447,
8864,
10817,
14118,
26,
268,
446,
536,
26,
308,
19,
13,
1074,
1779,
2073,
26,
11488,
14,
83,
19,
1779,
4766,
26,
1467,
446,
730,
26,
22361,
13,
17965,
2049,
790,
26,
365,
9885,
2049,
574,
26,
2549,
339,
408,
339,
4177,
275,
730,
63,
3629,
360,
17741,
13,
17965,
297,
267,
24608,
3713,
466,
356,
283,
875,
2267,
519,
6486,
29,
1110,
4131,
14,
3629,
9,
272,
4177,
63,
3620,
275,
715,
272,
3443,
275,
661,
2732,
13,
17965,
26,
1296,
6591,
780,
297,
283,
2732,
13,
17965,
26,
1296,
8014,
90,
1192,
358,
272,
3748,
63,
1313,
275,
334,
267,
283,
13226,
447,
41,
1156,
447,
7422,
297,
267,
283,
13226,
447,
43,
3053,
447,
1197,
297,
267,
283,
13226,
447,
21350,
447,
3481,
297,
267,
283,
13226,
447,
21350,
447,
5003,
3353,
297,
267,
283,
13226,
447,
51,
19,
447,
12311,
297,
267,
283,
13226,
447,
18445,
51,
447,
3737,
297,
272,
776,
339,
11284,
63,
9340,
275,
283,
67,
23,
78,
26,
3946,
13182,
7,
339,
347,
2112,
8,
277,
12,
5944,
12,
1566,
29,
403,
304,
267,
1890,
275,
2257,
63,
1730,
8,
277,
14,
2609,
14,
1730,
63,
3702,
680,
1258,
360,
2732,
17965,
358,
267,
24608,
63,
1060,
275,
291,
14,
362,
63,
17965,
8,
1258,
9,
267,
2058,
275,
942,
267,
291,
14,
10898,
275,
756,
267,
291,
14,
362,
63,
1623,
780,
8,
288,
1890,
12,
24608,
63,
1060,
12,
288,
359,
82,
367,
519,
315,
5944,
340,
291,
14,
10466,
63,
9340,
440,
315,
519,
566,
267,
367,
519,
315,
5944,
26,
288,
2342,
780,
275,
519,
14,
362,
8,
277,
14,
10466,
63,
9340,
12,
3073,
288,
340,
440,
2342,
780,
26,
355,
1980,
288,
916,
440,
822,
8,
277,
14,
576,
9,
690,
413,
26,
355,
2058,
14,
740,
8,
82,
9,
355,
1980,
288,
1911,
275,
756,
288,
367,
289,
315,
2342,
780,
26,
355,
340,
291,
8,
70,
304,
490,
1911,
275,
715,
490,
2059,
288,
340,
1911,
26,
355,
2058,
14,
740,
8,
82,
9,
267,
372,
2058,
339,
347,
664,
63,
1623,
780,
8,
277,
12,
1890,
12,
24608,
63,
1060,
12,
5944,
304,
267,
367,
2073,
63,
409,
315,
8291,
8,
355,
3482,
8,
277,
14,
2609,
14,
362,
63,
22476,
8,
4435,
395,
5944,
395,
355,
3388,
304,
288,
2073,
63,
409,
275,
1211,
8,
1927,
63,
409,
9,
288,
4766,
275,
469,
355,
283,
1205,
356,
791,
4077,
356,
788,
10401,
14949,
355,
283,
1927,
356,
791,
6134,
356,
769,
8,
1927,
63,
409,
16658,
355,
283,
1927,
804,
356,
791,
4077,
356,
359,
277,
14,
2609,
14,
1927,
63,
466,
14,
2177,
78,
63,
466,
9420,
288,
789,
288,
367,
17196,
315,
291,
14,
2609,
14,
7154,
8,
490,
1890,
14,
513,
63,
1623,
780,
12,
490,
24608,
20498,
29,
17965,
63,
1060,
12,
2457,
29,
4273,
680,
362,
360,
1623,
780,
297,
334,
2298,
355,
519,
275,
2073,
63,
409,
59,
1623,
316,
459,
1927,
6538,
355,
519,
14,
5486,
8,
277,
14,
10466,
63,
9340,
12,
15364,
740,
8,
1623,
316,
9,
339,
347,
664,
63,
17965,
8,
277,
12,
1890,
304,
267,
340,
291,
14,
576,
14,
362,
360,
17965,
735,
288,
372,
291,
14,
576,
459,
17965,
418,
267,
5909,
90,
1192,
275,
1890,
14,
513,
63,
4797,
90,
1192,
8,
466,
534,
18928,
1959,
362,
360,
4797,
90,
1192,
297,
14515,
267,
1911,
275,
756,
267,
367,
282,
315,
5909,
90,
1192,
26,
288,
340,
282,
459,
1205,
418,
1137,
283,
10401,
356,
355,
1980,
288,
1911,
275,
282,
267,
340,
440,
1911,
26,
288,
746,
18141,
32165,
8,
355,
298,
3185,
2689,
83,
949,
2879,
24608,
1911,
315,
2933,
503,
5981,
24608,
2013,
2,
450,
334,
490,
291,
14,
2609,
14,
3185,
14,
354,
355,
5082,
267,
372,
1911,
459,
1060,
418,
339,
768,
3744,
272,
347,
2274,
63,
4435,
8,
11645,
12,
7086,
12,
2073,
63,
533,
304,
267,
340,
2073,
63,
533,
14,
1927,
63,
466,
14,
2177,
78,
63,
466,
440,
315,
8531,
14,
4946,
63,
1313,
26,
288,
372,
267,
2073,
63,
533,
14,
1541,
63,
5189,
14,
2683,
360,
17741,
13,
17965,
297,
8531,
9,
421,
199,
4435,
14,
10108,
8,
3946,
17606,
14,
2683,
63,
4435,
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
] |
[
1898,
25455,
1804,
439,
382,
3868,
621,
65,
1090,
85,
199,
3,
1898,
710,
8142,
445,
833,
79,
6268,
6642,
14,
199,
3,
6988,
19596,
13,
3761,
13,
7544,
26,
3668,
13,
18,
14,
16,
421,
199,
504,
1275,
1018,
492,
1594,
4131,
199,
199,
504,
286,
23,
78,
14,
3924,
492,
18141,
32165,
199,
504,
286,
23,
78,
14,
2609,
492,
5944,
199,
504,
286,
23,
78,
14,
1208,
492,
730,
63,
3629,
12,
2257,
63,
1730,
12,
8291,
421,
199,
533,
11003,
17606,
8,
1110,
4131,
304,
272,
408,
8014,
806,
2073,
2879,
14118,
1808,
10168,
28155,
11003,
14279,
2282,
14,
339,
11003,
24608,
4440,
9661,
4079,
4499,
316,
370,
19897,
12169,
2073,
272,
22361,
2879,
14118,
370,
6705,
2879,
9682,
402,
282,
5718,
402,
16822,
14,
339,
2508,
1233,
13,
1457,
447,
8864,
10817,
14118,
26,
268,
446,
536,
26,
308,
19,
13,
1074,
1779,
2073,
26,
11488,
14,
83,
19,
1779,
4766,
26,
1467,
446,
730,
26,
22361,
13,
17965,
2049,
790,
26,
365,
9885,
2049,
574,
26,
2549,
339,
408,
339,
4177,
275,
730,
63,
3629,
360,
17741,
13,
17965,
297,
267,
24608,
3713,
466,
356,
283,
875,
2267,
519,
6486,
29,
1110,
4131,
14,
3629,
9,
272,
4177,
63,
3620,
275,
715,
272,
3443,
275,
661,
2732,
13,
17965,
26,
1296,
6591,
780,
297,
283,
2732,
13,
17965,
26,
1296,
8014,
90,
1192,
358,
272,
3748,
63,
1313,
275,
334,
267,
283,
13226,
447,
41,
1156,
447,
7422,
297,
267,
283,
13226,
447,
43,
3053,
447,
1197,
297,
267,
283,
13226,
447,
21350,
447,
3481,
297,
267,
283,
13226,
447,
21350,
447,
5003,
3353,
297,
267,
283,
13226,
447,
51,
19,
447,
12311,
297,
267,
283,
13226,
447,
18445,
51,
447,
3737,
297,
272,
776,
339,
11284,
63,
9340,
275,
283,
67,
23,
78,
26,
3946,
13182,
7,
339,
347,
2112,
8,
277,
12,
5944,
12,
1566,
29,
403,
304,
267,
1890,
275,
2257,
63,
1730,
8,
277,
14,
2609,
14,
1730,
63,
3702,
680,
1258,
360,
2732,
17965,
358,
267,
24608,
63,
1060,
275,
291,
14,
362,
63,
17965,
8,
1258,
9,
267,
2058,
275,
942,
267,
291,
14,
10898,
275,
756,
267,
291,
14,
362,
63,
1623,
780,
8,
288,
1890,
12,
24608,
63,
1060,
12,
288,
359,
82,
367,
519,
315,
5944,
340,
291,
14,
10466,
63,
9340,
440,
315,
519,
566,
267,
367,
519,
315,
5944,
26,
288,
2342,
780,
275,
519,
14,
362,
8,
277,
14,
10466,
63,
9340,
12,
3073,
288,
340,
440,
2342,
780,
26,
355,
1980,
288,
916,
440,
822,
8,
277,
14,
576,
9,
690,
413,
26,
355,
2058,
14,
740,
8,
82,
9,
355,
1980,
288,
1911,
275,
756,
288,
367,
289,
315,
2342,
780,
26,
355,
340,
291,
8,
70,
304,
490,
1911,
275,
715,
490,
2059,
288,
340,
1911,
26,
355,
2058,
14,
740,
8,
82,
9,
267,
372,
2058,
339,
347,
664,
63,
1623,
780,
8,
277,
12,
1890,
12,
24608,
63,
1060,
12,
5944,
304,
267,
367,
2073,
63,
409,
315,
8291,
8,
355,
3482,
8,
277,
14,
2609,
14,
362,
63,
22476,
8,
4435,
395,
5944,
395,
355,
3388,
304,
288,
2073,
63,
409,
275,
1211,
8,
1927,
63,
409,
9,
288,
4766,
275,
469,
355,
283,
1205,
356,
791,
4077,
356,
788,
10401,
14949,
355,
283,
1927,
356,
791,
6134,
356,
769,
8,
1927,
63,
409,
16658,
355,
283,
1927,
804,
356,
791,
4077,
356,
359,
277,
14,
2609,
14,
1927,
63,
466,
14,
2177,
78,
63,
466,
9420,
288,
789,
288,
367,
17196,
315,
291,
14,
2609,
14,
7154,
8,
490,
1890,
14,
513,
63,
1623,
780,
12,
490,
24608,
20498,
29,
17965,
63,
1060,
12,
2457,
29,
4273,
680,
362,
360,
1623,
780,
297,
334,
2298,
355,
519,
275,
2073,
63,
409,
59,
1623,
316,
459,
1927,
6538,
355,
519,
14,
5486,
8,
277,
14,
10466,
63,
9340,
12,
15364,
740,
8,
1623,
316,
9,
339,
347,
664,
63,
17965,
8,
277,
12,
1890,
304,
267,
340,
291,
14,
576,
14,
362,
360,
17965,
735,
288,
372,
291,
14,
576,
459,
17965,
418,
267,
5909,
90,
1192,
275,
1890,
14,
513,
63,
4797,
90,
1192,
8,
466,
534,
18928,
1959,
362,
360,
4797,
90,
1192,
297,
14515,
267,
1911,
275,
756,
267,
367,
282,
315,
5909,
90,
1192,
26,
288,
340,
282,
459,
1205,
418,
1137,
283,
10401,
356,
355,
1980,
288,
1911,
275,
282,
267,
340,
440,
1911,
26,
288,
746,
18141,
32165,
8,
355,
298,
3185,
2689,
83,
949,
2879,
24608,
1911,
315,
2933,
503,
5981,
24608,
2013,
2,
450,
334,
490,
291,
14,
2609,
14,
3185,
14,
354,
355,
5082,
267,
372,
1911,
459,
1060,
418,
339,
768,
3744,
272,
347,
2274,
63,
4435,
8,
11645,
12,
7086,
12,
2073,
63,
533,
304,
267,
340,
2073,
63,
533,
14,
1927,
63,
466,
14,
2177,
78,
63,
466,
440,
315,
8531,
14,
4946,
63,
1313,
26,
288,
372,
267,
2073,
63,
533,
14,
1541,
63,
5189,
14,
2683,
360,
17741,
13,
17965,
297,
8531,
9,
421,
199,
4435,
14,
10108,
8,
3946,
17606,
14,
2683,
63,
4435,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jellydn/gschool
|
public/system/lib/bootstrap/test-infra/s3_cache.py
|
1700
|
3523
|
#!/usr/bin/env python2.7
from __future__ import absolute_import, unicode_literals, print_function, division
from sys import argv
from os import environ, stat, remove as _delete_file
from os.path import isfile, dirname, basename, abspath
from hashlib import sha256
from subprocess import check_call as run
from boto.s3.connection import S3Connection
from boto.s3.key import Key
from boto.exception import S3ResponseError
NEED_TO_UPLOAD_MARKER = '.need-to-upload'
BYTES_PER_MB = 1024 * 1024
try:
BUCKET_NAME = environ['TWBS_S3_BUCKET']
except KeyError:
raise SystemExit("TWBS_S3_BUCKET environment variable not set!")
def _sha256_of_file(filename):
hasher = sha256()
with open(filename, 'rb') as input_file:
hasher.update(input_file.read())
file_hash = hasher.hexdigest()
print('sha256({}) = {}'.format(filename, file_hash))
return file_hash
def _delete_file_quietly(filename):
try:
_delete_file(filename)
except (OSError, IOError):
pass
def _tarball_size(directory):
kib = stat(_tarball_filename_for(directory)).st_size // BYTES_PER_MB
return "{} MiB".format(kib)
def _tarball_filename_for(directory):
return abspath('./{}.tar.gz'.format(basename(directory)))
def _create_tarball(directory):
print("Creating tarball of {}...".format(directory))
run(['tar', '-czf', _tarball_filename_for(directory), '-C', dirname(directory), basename(directory)])
def _extract_tarball(directory):
print("Extracting tarball of {}...".format(directory))
run(['tar', '-xzf', _tarball_filename_for(directory), '-C', dirname(directory)])
def download(directory):
_delete_file_quietly(NEED_TO_UPLOAD_MARKER)
try:
print("Downloading {} tarball from S3...".format(friendly_name))
key.get_contents_to_filename(_tarball_filename_for(directory))
except S3ResponseError as err:
open(NEED_TO_UPLOAD_MARKER, 'a').close()
print(err)
raise SystemExit("Cached {} download failed!".format(friendly_name))
print("Downloaded {}.".format(_tarball_size(directory)))
_extract_tarball(directory)
print("{} successfully installed from cache.".format(friendly_name))
def upload(directory):
_create_tarball(directory)
print("Uploading {} tarball to S3... ({})".format(friendly_name, _tarball_size(directory)))
key.set_contents_from_filename(_tarball_filename_for(directory))
print("{} cache successfully updated.".format(friendly_name))
_delete_file_quietly(NEED_TO_UPLOAD_MARKER)
if __name__ == '__main__':
# Uses environment variables:
# AWS_ACCESS_KEY_ID -- AWS Access Key ID
# AWS_SECRET_ACCESS_KEY -- AWS Secret Access Key
argv.pop(0)
if len(argv) != 4:
raise SystemExit("USAGE: s3_cache.py <download | upload> <friendly name> <dependencies file> <directory>")
mode, friendly_name, dependencies_file, directory = argv
conn = S3Connection()
bucket = conn.lookup(BUCKET_NAME, validate=False)
if bucket is None:
raise SystemExit("Could not access bucket!")
dependencies_file_hash = _sha256_of_file(dependencies_file)
key = Key(bucket, dependencies_file_hash)
key.storage_class = 'REDUCED_REDUNDANCY'
if mode == 'download':
download(directory)
elif mode == 'upload':
if isfile(NEED_TO_UPLOAD_MARKER): # FIXME
upload(directory)
else:
print("No need to upload anything.")
else:
raise SystemExit("Unrecognized mode {!r}".format(mode))
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
18,
14,
23,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
12,
870,
63,
1593,
12,
4629,
199,
199,
504,
984,
492,
9238,
199,
504,
747,
492,
6160,
12,
5672,
12,
2813,
465,
485,
1807,
63,
493,
199,
504,
747,
14,
515,
492,
29214,
12,
9017,
12,
9593,
12,
19529,
199,
504,
8337,
492,
7793,
3912,
199,
504,
3873,
492,
1104,
63,
1250,
465,
1255,
199,
199,
504,
6055,
14,
83,
19,
14,
2105,
492,
428,
19,
3225,
199,
504,
6055,
14,
83,
19,
14,
498,
492,
2606,
199,
504,
6055,
14,
1971,
492,
428,
19,
19712,
421,
199,
28888,
63,
2566,
63,
16418,
63,
18997,
275,
1987,
9321,
13,
475,
13,
5064,
7,
199,
20352,
63,
4227,
63,
4567,
275,
6619,
627,
6619,
199,
893,
26,
272,
16331,
15244,
63,
2339,
275,
6160,
459,
16491,
11087,
63,
51,
19,
63,
20156,
418,
199,
2590,
4067,
26,
272,
746,
14838,
480,
16491,
11087,
63,
51,
19,
63,
20156,
3734,
1750,
440,
663,
9124,
421,
199,
318,
485,
4835,
3912,
63,
1618,
63,
493,
8,
1501,
304,
272,
19009,
275,
7793,
3912,
342,
272,
543,
1551,
8,
1501,
12,
283,
4848,
358,
465,
1324,
63,
493,
26,
267,
19009,
14,
873,
8,
1210,
63,
493,
14,
739,
1012,
272,
570,
63,
2227,
275,
19009,
14,
11453,
342,
272,
870,
360,
4835,
3912,
14079,
275,
9499,
908,
8,
1501,
12,
570,
63,
2227,
430,
272,
372,
570,
63,
2227,
421,
199,
318,
485,
1807,
63,
493,
63,
10243,
590,
8,
1501,
304,
272,
862,
26,
267,
485,
1807,
63,
493,
8,
1501,
9,
272,
871,
334,
16719,
12,
5925,
304,
267,
986,
421,
199,
318,
485,
18829,
63,
890,
8,
3619,
304,
272,
1022,
1892,
275,
5672,
1547,
18829,
63,
1501,
63,
509,
8,
3619,
4992,
270,
63,
890,
5001,
6515,
15472,
63,
4227,
63,
4567,
272,
372,
11491,
603,
17587,
1674,
908,
8,
75,
1892,
9,
421,
199,
318,
485,
18829,
63,
1501,
63,
509,
8,
3619,
304,
272,
372,
19529,
5175,
14698,
14,
5369,
14,
6838,
1370,
908,
8,
4846,
8,
3619,
1724,
421,
199,
318,
485,
981,
63,
18829,
8,
3619,
304,
272,
870,
480,
14380,
17641,
402,
1052,
1396,
1674,
908,
8,
3619,
430,
272,
1255,
2941,
5369,
297,
2475,
16823,
70,
297,
485,
18829,
63,
1501,
63,
509,
8,
3619,
395,
2475,
35,
297,
9017,
8,
3619,
395,
9593,
8,
3619,
3948,
421,
199,
318,
485,
5005,
63,
18829,
8,
3619,
304,
272,
870,
480,
12147,
316,
17641,
402,
1052,
1396,
1674,
908,
8,
3619,
430,
272,
1255,
2941,
5369,
297,
2475,
19196,
70,
297,
485,
18829,
63,
1501,
63,
509,
8,
3619,
395,
2475,
35,
297,
9017,
8,
3619,
3948,
421,
199,
318,
5235,
8,
3619,
304,
272,
485,
1807,
63,
493,
63,
10243,
590,
8,
28888,
63,
2566,
63,
16418,
63,
18997,
9,
272,
862,
26,
267,
870,
480,
18085,
1052,
17641,
687,
428,
19,
1396,
1674,
908,
8,
17317,
63,
354,
430,
267,
790,
14,
362,
63,
4407,
63,
475,
63,
1501,
1547,
18829,
63,
1501,
63,
509,
8,
3619,
430,
272,
871,
428,
19,
19712,
465,
2329,
26,
267,
1551,
8,
28888,
63,
2566,
63,
16418,
63,
18997,
12,
283,
65,
1959,
1600,
342,
267,
870,
8,
1508,
9,
267,
746,
14838,
480,
16138,
1052,
5235,
3405,
1,
1674,
908,
8,
17317,
63,
354,
430,
272,
870,
480,
3514,
4591,
1052,
15848,
908,
1547,
18829,
63,
890,
8,
3619,
1724,
272,
485,
5005,
63,
18829,
8,
3619,
9,
272,
870,
20794,
8792,
4903,
687,
2581,
15848,
908,
8,
17317,
63,
354,
430,
421,
199,
318,
5802,
8,
3619,
304,
272,
485,
981,
63,
18829,
8,
3619,
9,
272,
870,
480,
1721,
8786,
1052,
17641,
370,
428,
19,
1396,
11459,
25974,
908,
8,
17317,
63,
354,
12,
485,
18829,
63,
890,
8,
3619,
1724,
272,
790,
14,
409,
63,
4407,
63,
504,
63,
1501,
1547,
18829,
63,
1501,
63,
509,
8,
3619,
430,
272,
870,
20794,
2581,
8792,
4588,
15848,
908,
8,
17317,
63,
354,
430,
272,
485,
1807,
63,
493,
63,
10243,
590,
8,
28888,
63,
2566,
63,
16418,
63,
18997,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
327,
14911,
3734,
2860,
26,
272,
327,
257,
10168,
63,
11074,
63,
3078,
63,
998,
1553,
10168,
11003,
2606,
2870,
272,
327,
257,
10168,
63,
12961,
63,
11074,
63,
3078,
1553,
10168,
23580,
11003,
2606,
272,
9238,
14,
1935,
8,
16,
9,
272,
340,
822,
8,
3020,
9,
1137,
841,
26,
267,
746,
14838,
480,
20274,
26,
308,
19,
63,
1637,
14,
647,
665,
4249,
1204,
5802,
30,
665,
17317,
536,
30,
665,
5714,
570,
30,
665,
3619,
9579,
272,
818,
12,
21428,
63,
354,
12,
5124,
63,
493,
12,
2082,
275,
9238,
339,
2557,
275,
428,
19,
3225,
342,
272,
5315,
275,
2557,
14,
3892,
8,
20156,
63,
2339,
12,
4107,
29,
797,
9,
272,
340,
5315,
365,
488,
26,
267,
746,
14838,
480,
6531,
440,
2879,
5315,
9124,
339,
5124,
63,
493,
63,
2227,
275,
485,
4835,
3912,
63,
1618,
63,
493,
8,
5714,
63,
493,
9,
339,
790,
275,
2606,
8,
4623,
12,
5124,
63,
493,
63,
2227,
9,
272,
790,
14,
3494,
63,
533,
275,
283,
907,
4980,
25927,
63,
7387,
6131,
879,
15068,
7,
339,
340,
818,
508,
283,
4249,
356,
267,
5235,
8,
3619,
9,
272,
916,
818,
508,
283,
5064,
356,
267,
340,
29214,
8,
28888,
63,
2566,
63,
16418,
63,
18997,
304,
221,
327,
7600,
288,
5802,
8,
3619,
9,
267,
587,
26,
288,
870,
480,
1944,
1929,
370,
5802,
7003,
2685,
272,
587,
26,
267,
746,
14838,
480,
22517,
818,
18776,
82,
5469,
908,
8,
632,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
18,
14,
23,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
12,
870,
63,
1593,
12,
4629,
199,
199,
504,
984,
492,
9238,
199,
504,
747,
492,
6160,
12,
5672,
12,
2813,
465,
485,
1807,
63,
493,
199,
504,
747,
14,
515,
492,
29214,
12,
9017,
12,
9593,
12,
19529,
199,
504,
8337,
492,
7793,
3912,
199,
504,
3873,
492,
1104,
63,
1250,
465,
1255,
199,
199,
504,
6055,
14,
83,
19,
14,
2105,
492,
428,
19,
3225,
199,
504,
6055,
14,
83,
19,
14,
498,
492,
2606,
199,
504,
6055,
14,
1971,
492,
428,
19,
19712,
421,
199,
28888,
63,
2566,
63,
16418,
63,
18997,
275,
1987,
9321,
13,
475,
13,
5064,
7,
199,
20352,
63,
4227,
63,
4567,
275,
6619,
627,
6619,
199,
893,
26,
272,
16331,
15244,
63,
2339,
275,
6160,
459,
16491,
11087,
63,
51,
19,
63,
20156,
418,
199,
2590,
4067,
26,
272,
746,
14838,
480,
16491,
11087,
63,
51,
19,
63,
20156,
3734,
1750,
440,
663,
9124,
421,
199,
318,
485,
4835,
3912,
63,
1618,
63,
493,
8,
1501,
304,
272,
19009,
275,
7793,
3912,
342,
272,
543,
1551,
8,
1501,
12,
283,
4848,
358,
465,
1324,
63,
493,
26,
267,
19009,
14,
873,
8,
1210,
63,
493,
14,
739,
1012,
272,
570,
63,
2227,
275,
19009,
14,
11453,
342,
272,
870,
360,
4835,
3912,
14079,
275,
9499,
908,
8,
1501,
12,
570,
63,
2227,
430,
272,
372,
570,
63,
2227,
421,
199,
318,
485,
1807,
63,
493,
63,
10243,
590,
8,
1501,
304,
272,
862,
26,
267,
485,
1807,
63,
493,
8,
1501,
9,
272,
871,
334,
16719,
12,
5925,
304,
267,
986,
421,
199,
318,
485,
18829,
63,
890,
8,
3619,
304,
272,
1022,
1892,
275,
5672,
1547,
18829,
63,
1501,
63,
509,
8,
3619,
4992,
270,
63,
890,
5001,
6515,
15472,
63,
4227,
63,
4567,
272,
372,
11491,
603,
17587,
1674,
908,
8,
75,
1892,
9,
421,
199,
318,
485,
18829,
63,
1501,
63,
509,
8,
3619,
304,
272,
372,
19529,
5175,
14698,
14,
5369,
14,
6838,
1370,
908,
8,
4846,
8,
3619,
1724,
421,
199,
318,
485,
981,
63,
18829,
8,
3619,
304,
272,
870,
480,
14380,
17641,
402,
1052,
1396,
1674,
908,
8,
3619,
430,
272,
1255,
2941,
5369,
297,
2475,
16823,
70,
297,
485,
18829,
63,
1501,
63,
509,
8,
3619,
395,
2475,
35,
297,
9017,
8,
3619,
395,
9593,
8,
3619,
3948,
421,
199,
318,
485,
5005,
63,
18829,
8,
3619,
304,
272,
870,
480,
12147,
316,
17641,
402,
1052,
1396,
1674,
908,
8,
3619,
430,
272,
1255,
2941,
5369,
297,
2475,
19196,
70,
297,
485,
18829,
63,
1501,
63,
509,
8,
3619,
395,
2475,
35,
297,
9017,
8,
3619,
3948,
421,
199,
318,
5235,
8,
3619,
304,
272,
485,
1807,
63,
493,
63,
10243,
590,
8,
28888,
63,
2566,
63,
16418,
63,
18997,
9,
272,
862,
26,
267,
870,
480,
18085,
1052,
17641,
687,
428,
19,
1396,
1674,
908,
8,
17317,
63,
354,
430,
267,
790,
14,
362,
63,
4407,
63,
475,
63,
1501,
1547,
18829,
63,
1501,
63,
509,
8,
3619,
430,
272,
871,
428,
19,
19712,
465,
2329,
26,
267,
1551,
8,
28888,
63,
2566,
63,
16418,
63,
18997,
12,
283,
65,
1959,
1600,
342,
267,
870,
8,
1508,
9,
267,
746,
14838,
480,
16138,
1052,
5235,
3405,
1,
1674,
908,
8,
17317,
63,
354,
430,
272,
870,
480,
3514,
4591,
1052,
15848,
908,
1547,
18829,
63,
890,
8,
3619,
1724,
272,
485,
5005,
63,
18829,
8,
3619,
9,
272,
870,
20794,
8792,
4903,
687,
2581,
15848,
908,
8,
17317,
63,
354,
430,
421,
199,
318,
5802,
8,
3619,
304,
272,
485,
981,
63,
18829,
8,
3619,
9,
272,
870,
480,
1721,
8786,
1052,
17641,
370,
428,
19,
1396,
11459,
25974,
908,
8,
17317,
63,
354,
12,
485,
18829,
63,
890,
8,
3619,
1724,
272,
790,
14,
409,
63,
4407,
63,
504,
63,
1501,
1547,
18829,
63,
1501,
63,
509,
8,
3619,
430,
272,
870,
20794,
2581,
8792,
4588,
15848,
908,
8,
17317,
63,
354,
430,
272,
485,
1807,
63,
493,
63,
10243,
590,
8,
28888,
63,
2566,
63,
16418,
63,
18997,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
327,
14911,
3734,
2860,
26,
272,
327,
257,
10168,
63,
11074,
63,
3078,
63,
998,
1553,
10168,
11003,
2606,
2870,
272,
327,
257,
10168,
63,
12961,
63,
11074,
63,
3078,
1553,
10168,
23580,
11003,
2606,
272,
9238,
14,
1935,
8,
16,
9,
272,
340,
822,
8,
3020,
9,
1137,
841,
26,
267,
746,
14838,
480,
20274,
26,
308,
19,
63,
1637,
14,
647,
665,
4249,
1204,
5802,
30,
665,
17317,
536,
30,
665,
5714,
570,
30,
665,
3619,
9579,
272,
818,
12,
21428,
63,
354,
12,
5124,
63,
493,
12,
2082,
275,
9238,
339,
2557,
275,
428,
19,
3225,
342,
272,
5315,
275,
2557,
14,
3892,
8,
20156,
63,
2339,
12,
4107,
29,
797,
9,
272,
340,
5315,
365,
488,
26,
267,
746,
14838,
480,
6531,
440,
2879,
5315,
9124,
339,
5124,
63,
493,
63,
2227,
275,
485,
4835,
3912,
63,
1618,
63,
493,
8,
5714,
63,
493,
9,
339,
790,
275,
2606,
8,
4623,
12,
5124,
63,
493,
63,
2227,
9,
272,
790,
14,
3494,
63,
533,
275,
283,
907,
4980,
25927,
63,
7387,
6131,
879,
15068,
7,
339,
340,
818,
508,
283,
4249,
356,
267,
5235,
8,
3619,
9,
272,
916,
818,
508,
283,
5064,
356,
267,
340,
29214,
8,
28888,
63,
2566,
63,
16418,
63,
18997,
304,
221,
327,
7600,
288,
5802,
8,
3619,
9,
267,
587,
26,
288,
870,
480,
1944,
1929,
370,
5802,
7003,
2685,
272,
587,
26,
267,
746,
14838,
480,
22517,
818,
18776,
82,
5469,
908,
8,
632,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
pablohoffman/scrapy
|
scrapy/tests/test_downloader_handlers.py
|
6
|
11352
|
import os
from twisted.trial import unittest
from twisted.protocols.policies import WrappingFactory
from twisted.python.filepath import FilePath
from twisted.internet import reactor, defer
from twisted.web import server, static, util, resource
from twisted.web.test.test_webclient import ForeverTakingResource, \
NoLengthResource, HostHeaderResource, \
PayloadResource, BrokenDownloadResource
from w3lib.url import path_to_file_uri
from scrapy.core.downloader.handlers.file import FileDownloadHandler
from scrapy.core.downloader.handlers.http import HttpDownloadHandler
from scrapy.core.downloader.handlers.s3 import S3DownloadHandler
from scrapy.spider import BaseSpider
from scrapy.http import Request
from scrapy.settings import Settings
from scrapy import optional_features
class FileTestCase(unittest.TestCase):
def setUp(self):
self.tmpname = self.mktemp()
fd = open(self.tmpname + '^', 'w')
fd.write('0123456789')
fd.close()
self.download_request = FileDownloadHandler(Settings()).download_request
def test_download(self):
def _test(response):
self.assertEquals(response.url, request.url)
self.assertEquals(response.status, 200)
self.assertEquals(response.body, '0123456789')
request = Request(path_to_file_uri(self.tmpname + '^'))
assert request.url.upper().endswith('%5E')
return self.download_request(request, BaseSpider('foo')).addCallback(_test)
def test_non_existent(self):
request = Request('file://%s' % self.mktemp())
d = self.download_request(request, BaseSpider('foo'))
return self.assertFailure(d, IOError)
class HttpTestCase(unittest.TestCase):
def setUp(self):
name = self.mktemp()
os.mkdir(name)
FilePath(name).child("file").setContent("0123456789")
r = static.File(name)
r.putChild("redirect", util.Redirect("/file"))
r.putChild("wait", ForeverTakingResource())
r.putChild("nolength", NoLengthResource())
r.putChild("host", HostHeaderResource())
r.putChild("payload", PayloadResource())
r.putChild("broken", BrokenDownloadResource())
self.site = server.Site(r, timeout=None)
self.wrapper = WrappingFactory(self.site)
self.port = reactor.listenTCP(0, self.wrapper, interface='127.0.0.1')
self.portno = self.port.getHost().port
self.download_request = HttpDownloadHandler(Settings()).download_request
def tearDown(self):
return self.port.stopListening()
def getURL(self, path):
return "http://127.0.0.1:%d/%s" % (self.portno, path)
def test_download(self):
request = Request(self.getURL('file'))
d = self.download_request(request, BaseSpider('foo'))
d.addCallback(lambda r: r.body)
d.addCallback(self.assertEquals, "0123456789")
return d
def test_download_head(self):
request = Request(self.getURL('file'), method='HEAD')
d = self.download_request(request, BaseSpider('foo'))
d.addCallback(lambda r: r.body)
d.addCallback(self.assertEquals, '')
return d
def test_redirect_status(self):
request = Request(self.getURL('redirect'))
d = self.download_request(request, BaseSpider('foo'))
d.addCallback(lambda r: r.status)
d.addCallback(self.assertEquals, 302)
return d
def test_redirect_status_head(self):
request = Request(self.getURL('redirect'), method='HEAD')
d = self.download_request(request, BaseSpider('foo'))
d.addCallback(lambda r: r.status)
d.addCallback(self.assertEquals, 302)
return d
def test_timeout_download_from_spider(self):
request = Request(self.getURL('wait'), meta=dict(download_timeout=0.000001))
d = self.download_request(request, BaseSpider('foo'))
return self.assertFailure(d, defer.TimeoutError)
def test_host_header_not_in_request_headers(self):
def _test(response):
self.assertEquals(response.body, '127.0.0.1:%d' % self.portno)
self.assertEquals(request.headers, {})
request = Request(self.getURL('host'))
return self.download_request(request, BaseSpider('foo')).addCallback(_test)
def test_host_header_seted_in_request_headers(self):
def _test(response):
self.assertEquals(response.body, 'example.com')
self.assertEquals(request.headers.get('Host'), 'example.com')
request = Request(self.getURL('host'), headers={'Host': 'example.com'})
return self.download_request(request, BaseSpider('foo')).addCallback(_test)
d = self.download_request(request, BaseSpider('foo'))
d.addCallback(lambda r: r.body)
d.addCallback(self.assertEquals, 'example.com')
return d
def test_payload(self):
body = '1'*100 # PayloadResource requires body length to be 100
request = Request(self.getURL('payload'), method='POST', body=body)
d = self.download_request(request, BaseSpider('foo'))
d.addCallback(lambda r: r.body)
d.addCallback(self.assertEquals, body)
return d
class UriResource(resource.Resource):
"""Return the full uri that was requested"""
def getChild(self, path, request):
return self
def render(self, request):
return request.uri
class HttpProxyTestCase(unittest.TestCase):
def setUp(self):
site = server.Site(UriResource(), timeout=None)
wrapper = WrappingFactory(site)
self.port = reactor.listenTCP(0, wrapper, interface='127.0.0.1')
self.portno = self.port.getHost().port
self.download_request = HttpDownloadHandler(Settings()).download_request
def tearDown(self):
return self.port.stopListening()
def getURL(self, path):
return "http://127.0.0.1:%d/%s" % (self.portno, path)
def test_download_with_proxy(self):
def _test(response):
self.assertEquals(response.status, 200)
self.assertEquals(response.url, request.url)
self.assertEquals(response.body, 'https://example.com')
http_proxy = self.getURL('')
request = Request('https://example.com', meta={'proxy': http_proxy})
return self.download_request(request, BaseSpider('foo')).addCallback(_test)
def test_download_without_proxy(self):
def _test(response):
self.assertEquals(response.status, 200)
self.assertEquals(response.url, request.url)
self.assertEquals(response.body, '/path/to/resource')
request = Request(self.getURL('path/to/resource'))
return self.download_request(request, BaseSpider('foo')).addCallback(_test)
class HttpDownloadHandlerMock(object):
def __init__(self, settings):
pass
def download_request(self, request, spider):
return request
class S3TestCase(unittest.TestCase):
skip = 'boto' not in optional_features and 'missing boto library'
# test use same example keys than amazon developer guide
# http://s3.amazonaws.com/awsdocs/S3/20060301/s3-dg-20060301.pdf
# and the tests described here are the examples from that manual
AWS_ACCESS_KEY_ID = '0PN5J17HBGZHT7JJ3X82'
AWS_SECRET_ACCESS_KEY = 'uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o'
def setUp(self):
s3reqh = S3DownloadHandler(Settings(), self.AWS_ACCESS_KEY_ID, \
self.AWS_SECRET_ACCESS_KEY, \
httpdownloadhandler=HttpDownloadHandlerMock)
self.download_request = s3reqh.download_request
self.spider = BaseSpider('foo')
def test_request_signing1(self):
# gets an object from the johnsmith bucket.
req = Request('s3://johnsmith/photos/puppy.jpg',
headers={'Date': 'Tue, 27 Mar 2007 19:36:42 +0000'})
httpreq = self.download_request(req, self.spider)
self.assertEqual(httpreq.headers['Authorization'], \
'AWS 0PN5J17HBGZHT7JJ3X82:xXjDGYUmKxnwqr5KXNPGldn5LbA=')
def test_request_signing2(self):
# puts an object into the johnsmith bucket.
req = Request('s3://johnsmith/photos/puppy.jpg', method='PUT', headers={
'Content-Type': 'image/jpeg',
'Date': 'Tue, 27 Mar 2007 21:15:45 +0000',
'Content-Length': '94328',
})
httpreq = self.download_request(req, self.spider)
self.assertEqual(httpreq.headers['Authorization'], \
'AWS 0PN5J17HBGZHT7JJ3X82:hcicpDDvL9SsO6AkvxqmIWkmOuQ=')
def test_request_signing3(self):
# lists the content of the johnsmith bucket.
req = Request('s3://johnsmith/?prefix=photos&max-keys=50&marker=puppy', \
method='GET', headers={
'User-Agent': 'Mozilla/5.0',
'Date': 'Tue, 27 Mar 2007 19:42:41 +0000',
})
httpreq = self.download_request(req, self.spider)
self.assertEqual(httpreq.headers['Authorization'], \
'AWS 0PN5J17HBGZHT7JJ3X82:jsRt/rhG+Vtp88HrYL706QhE4w4=')
def test_request_signing4(self):
# fetches the access control policy sub-resource for the 'johnsmith' bucket.
req = Request('s3://johnsmith/?acl', \
method='GET', headers={'Date': 'Tue, 27 Mar 2007 19:44:46 +0000'})
httpreq = self.download_request(req, self.spider)
self.assertEqual(httpreq.headers['Authorization'], \
'AWS 0PN5J17HBGZHT7JJ3X82:thdUi9VAkzhkniLj96JIrOPGi0g=')
def test_request_signing5(self):
# deletes an object from the 'johnsmith' bucket using the
# path-style and Date alternative.
req = Request('s3://johnsmith/photos/puppy.jpg', \
method='DELETE', headers={
'Date': 'Tue, 27 Mar 2007 21:20:27 +0000',
'x-amz-date': 'Tue, 27 Mar 2007 21:20:26 +0000',
})
httpreq = self.download_request(req, self.spider)
self.assertEqual(httpreq.headers['Authorization'], \
'AWS 0PN5J17HBGZHT7JJ3X82:k3nL7gH3+PadhTEVn5Ip83xlYzk=')
def test_request_signing6(self):
# uploads an object to a CNAME style virtual hosted bucket with metadata.
req = Request('s3://static.johnsmith.net:8080/db-backup.dat.gz', \
method='PUT', headers={
'User-Agent': 'curl/7.15.5',
'Host': 'static.johnsmith.net:8080',
'Date': 'Tue, 27 Mar 2007 21:06:08 +0000',
'x-amz-acl': 'public-read',
'content-type': 'application/x-download',
'Content-MD5': '4gJE4saaMU4BqNR0kLY+lw==',
'X-Amz-Meta-ReviewedBy': 'joe@johnsmith.net,jane@johnsmith.net',
'X-Amz-Meta-FileChecksum': '0x02661779',
'X-Amz-Meta-ChecksumAlgorithm': 'crc32',
'Content-Disposition': 'attachment; filename=database.dat',
'Content-Encoding': 'gzip',
'Content-Length': '5913339',
})
httpreq = self.download_request(req, self.spider)
self.assertEqual(httpreq.headers['Authorization'], \
'AWS 0PN5J17HBGZHT7JJ3X82:C0FlOtU8Ylb9KDTpZqYkZPX91iI=')
|
bsd-3-clause
|
[
646,
747,
199,
199,
504,
7390,
14,
14443,
492,
2882,
199,
504,
7390,
14,
16541,
14,
11767,
492,
644,
15521,
2927,
199,
504,
7390,
14,
1548,
14,
7218,
492,
27961,
199,
504,
7390,
14,
4901,
492,
9655,
12,
10133,
199,
504,
7390,
14,
2520,
492,
1654,
12,
2955,
12,
4884,
12,
2073,
199,
504,
7390,
14,
2520,
14,
396,
14,
396,
63,
2520,
1258,
492,
21684,
422,
52,
11124,
4031,
12,
971,
267,
3091,
4625,
4031,
12,
10891,
2567,
4031,
12,
971,
267,
15911,
912,
4031,
12,
23804,
11950,
4031,
199,
504,
336,
19,
773,
14,
633,
492,
931,
63,
475,
63,
493,
63,
2302,
199,
199,
504,
18918,
14,
1018,
14,
22846,
14,
5586,
14,
493,
492,
3814,
11950,
2461,
199,
504,
18918,
14,
1018,
14,
22846,
14,
5586,
14,
1014,
492,
4760,
11950,
2461,
199,
504,
18918,
14,
1018,
14,
22846,
14,
5586,
14,
83,
19,
492,
428,
19,
11950,
2461,
199,
504,
18918,
14,
12856,
492,
3523,
25157,
199,
504,
18918,
14,
1014,
492,
4784,
199,
504,
18918,
14,
1751,
492,
13303,
199,
504,
18918,
492,
2716,
63,
3179,
421,
199,
533,
3814,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
2791,
354,
275,
291,
14,
22136,
342,
267,
6111,
275,
1551,
8,
277,
14,
2791,
354,
435,
14452,
297,
283,
87,
358,
267,
6111,
14,
952,
360,
11371,
358,
267,
6111,
14,
1600,
342,
267,
291,
14,
4249,
63,
1069,
275,
3814,
11950,
2461,
8,
5268,
8801,
4249,
63,
1069,
339,
347,
511,
63,
4249,
8,
277,
304,
267,
347,
485,
396,
8,
1310,
304,
288,
291,
14,
2947,
8,
1310,
14,
633,
12,
1056,
14,
633,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
12,
1926,
9,
288,
291,
14,
2947,
8,
1310,
14,
2030,
12,
283,
11371,
358,
398,
1056,
275,
4784,
8,
515,
63,
475,
63,
493,
63,
2302,
8,
277,
14,
2791,
354,
435,
14452,
1333,
267,
702,
1056,
14,
633,
14,
4142,
1252,
4130,
3508,
21,
37,
358,
267,
372,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
11103,
10053,
1547,
396,
9,
339,
347,
511,
63,
2865,
63,
15025,
8,
277,
304,
267,
1056,
275,
4784,
360,
493,
13827,
83,
7,
450,
291,
14,
22136,
1012,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
372,
291,
14,
479,
6782,
8,
68,
12,
5925,
9,
421,
199,
533,
4760,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
536,
275,
291,
14,
22136,
342,
267,
747,
14,
8215,
8,
354,
9,
267,
27961,
8,
354,
680,
1739,
480,
493,
3471,
28680,
480,
11371,
531,
267,
519,
275,
2955,
14,
1173,
8,
354,
9,
267,
519,
14,
524,
3493,
480,
4876,
401,
4884,
14,
7071,
4769,
493,
2237,
267,
519,
14,
524,
3493,
480,
2573,
401,
21684,
422,
52,
11124,
4031,
1012,
267,
519,
14,
524,
3493,
480,
889,
1267,
401,
3091,
4625,
4031,
1012,
267,
519,
14,
524,
3493,
480,
1102,
401,
10891,
2567,
4031,
1012,
267,
519,
14,
524,
3493,
480,
4749,
401,
15911,
912,
4031,
1012,
267,
519,
14,
524,
3493,
480,
15697,
401,
23804,
11950,
4031,
1012,
267,
291,
14,
2124,
275,
1654,
14,
8972,
8,
82,
12,
2653,
29,
403,
9,
267,
291,
14,
5029,
275,
644,
15521,
2927,
8,
277,
14,
2124,
9,
267,
291,
14,
719,
275,
9655,
14,
5859,
9735,
8,
16,
12,
291,
14,
5029,
12,
3217,
534,
4195,
14,
16,
14,
16,
14,
17,
358,
267,
291,
14,
719,
889,
275,
291,
14,
719,
14,
362,
4965,
1252,
719,
267,
291,
14,
4249,
63,
1069,
275,
4760,
11950,
2461,
8,
5268,
8801,
4249,
63,
1069,
339,
347,
6766,
8,
277,
304,
267,
372,
291,
14,
719,
14,
2379,
30095,
342,
339,
347,
664,
2632,
8,
277,
12,
931,
304,
267,
372,
298,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
2689,
68,
3149,
83,
2,
450,
334,
277,
14,
719,
889,
12,
931,
9,
339,
347,
511,
63,
4249,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
493,
1333,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
366,
14,
10053,
8,
2734,
519,
26,
519,
14,
2030,
9,
267,
366,
14,
10053,
8,
277,
14,
2947,
12,
298,
11371,
531,
267,
372,
366,
339,
347,
511,
63,
4249,
63,
2993,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
493,
659,
1083,
534,
5211,
358,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
366,
14,
10053,
8,
2734,
519,
26,
519,
14,
2030,
9,
267,
366,
14,
10053,
8,
277,
14,
2947,
12,
4074,
267,
372,
366,
339,
347,
511,
63,
4876,
63,
1205,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
4876,
1333,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
366,
14,
10053,
8,
2734,
519,
26,
519,
14,
1205,
9,
267,
366,
14,
10053,
8,
277,
14,
2947,
12,
11485,
9,
267,
372,
366,
339,
347,
511,
63,
4876,
63,
1205,
63,
2993,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
4876,
659,
1083,
534,
5211,
358,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
366,
14,
10053,
8,
2734,
519,
26,
519,
14,
1205,
9,
267,
366,
14,
10053,
8,
277,
14,
2947,
12,
11485,
9,
267,
372,
366,
339,
347,
511,
63,
2593,
63,
4249,
63,
504,
63,
12856,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
2573,
659,
3404,
29,
807,
8,
4249,
63,
2593,
29,
16,
14,
19983,
430,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
372,
291,
14,
479,
6782,
8,
68,
12,
10133,
14,
19382,
9,
339,
347,
511,
63,
1102,
63,
1291,
63,
1397,
63,
262,
63,
1069,
63,
2139,
8,
277,
304,
267,
347,
485,
396,
8,
1310,
304
] |
[
747,
199,
199,
504,
7390,
14,
14443,
492,
2882,
199,
504,
7390,
14,
16541,
14,
11767,
492,
644,
15521,
2927,
199,
504,
7390,
14,
1548,
14,
7218,
492,
27961,
199,
504,
7390,
14,
4901,
492,
9655,
12,
10133,
199,
504,
7390,
14,
2520,
492,
1654,
12,
2955,
12,
4884,
12,
2073,
199,
504,
7390,
14,
2520,
14,
396,
14,
396,
63,
2520,
1258,
492,
21684,
422,
52,
11124,
4031,
12,
971,
267,
3091,
4625,
4031,
12,
10891,
2567,
4031,
12,
971,
267,
15911,
912,
4031,
12,
23804,
11950,
4031,
199,
504,
336,
19,
773,
14,
633,
492,
931,
63,
475,
63,
493,
63,
2302,
199,
199,
504,
18918,
14,
1018,
14,
22846,
14,
5586,
14,
493,
492,
3814,
11950,
2461,
199,
504,
18918,
14,
1018,
14,
22846,
14,
5586,
14,
1014,
492,
4760,
11950,
2461,
199,
504,
18918,
14,
1018,
14,
22846,
14,
5586,
14,
83,
19,
492,
428,
19,
11950,
2461,
199,
504,
18918,
14,
12856,
492,
3523,
25157,
199,
504,
18918,
14,
1014,
492,
4784,
199,
504,
18918,
14,
1751,
492,
13303,
199,
504,
18918,
492,
2716,
63,
3179,
421,
199,
533,
3814,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
2791,
354,
275,
291,
14,
22136,
342,
267,
6111,
275,
1551,
8,
277,
14,
2791,
354,
435,
14452,
297,
283,
87,
358,
267,
6111,
14,
952,
360,
11371,
358,
267,
6111,
14,
1600,
342,
267,
291,
14,
4249,
63,
1069,
275,
3814,
11950,
2461,
8,
5268,
8801,
4249,
63,
1069,
339,
347,
511,
63,
4249,
8,
277,
304,
267,
347,
485,
396,
8,
1310,
304,
288,
291,
14,
2947,
8,
1310,
14,
633,
12,
1056,
14,
633,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
12,
1926,
9,
288,
291,
14,
2947,
8,
1310,
14,
2030,
12,
283,
11371,
358,
398,
1056,
275,
4784,
8,
515,
63,
475,
63,
493,
63,
2302,
8,
277,
14,
2791,
354,
435,
14452,
1333,
267,
702,
1056,
14,
633,
14,
4142,
1252,
4130,
3508,
21,
37,
358,
267,
372,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
11103,
10053,
1547,
396,
9,
339,
347,
511,
63,
2865,
63,
15025,
8,
277,
304,
267,
1056,
275,
4784,
360,
493,
13827,
83,
7,
450,
291,
14,
22136,
1012,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
372,
291,
14,
479,
6782,
8,
68,
12,
5925,
9,
421,
199,
533,
4760,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
536,
275,
291,
14,
22136,
342,
267,
747,
14,
8215,
8,
354,
9,
267,
27961,
8,
354,
680,
1739,
480,
493,
3471,
28680,
480,
11371,
531,
267,
519,
275,
2955,
14,
1173,
8,
354,
9,
267,
519,
14,
524,
3493,
480,
4876,
401,
4884,
14,
7071,
4769,
493,
2237,
267,
519,
14,
524,
3493,
480,
2573,
401,
21684,
422,
52,
11124,
4031,
1012,
267,
519,
14,
524,
3493,
480,
889,
1267,
401,
3091,
4625,
4031,
1012,
267,
519,
14,
524,
3493,
480,
1102,
401,
10891,
2567,
4031,
1012,
267,
519,
14,
524,
3493,
480,
4749,
401,
15911,
912,
4031,
1012,
267,
519,
14,
524,
3493,
480,
15697,
401,
23804,
11950,
4031,
1012,
267,
291,
14,
2124,
275,
1654,
14,
8972,
8,
82,
12,
2653,
29,
403,
9,
267,
291,
14,
5029,
275,
644,
15521,
2927,
8,
277,
14,
2124,
9,
267,
291,
14,
719,
275,
9655,
14,
5859,
9735,
8,
16,
12,
291,
14,
5029,
12,
3217,
534,
4195,
14,
16,
14,
16,
14,
17,
358,
267,
291,
14,
719,
889,
275,
291,
14,
719,
14,
362,
4965,
1252,
719,
267,
291,
14,
4249,
63,
1069,
275,
4760,
11950,
2461,
8,
5268,
8801,
4249,
63,
1069,
339,
347,
6766,
8,
277,
304,
267,
372,
291,
14,
719,
14,
2379,
30095,
342,
339,
347,
664,
2632,
8,
277,
12,
931,
304,
267,
372,
298,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
2689,
68,
3149,
83,
2,
450,
334,
277,
14,
719,
889,
12,
931,
9,
339,
347,
511,
63,
4249,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
493,
1333,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
366,
14,
10053,
8,
2734,
519,
26,
519,
14,
2030,
9,
267,
366,
14,
10053,
8,
277,
14,
2947,
12,
298,
11371,
531,
267,
372,
366,
339,
347,
511,
63,
4249,
63,
2993,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
493,
659,
1083,
534,
5211,
358,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
366,
14,
10053,
8,
2734,
519,
26,
519,
14,
2030,
9,
267,
366,
14,
10053,
8,
277,
14,
2947,
12,
4074,
267,
372,
366,
339,
347,
511,
63,
4876,
63,
1205,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
4876,
1333,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
366,
14,
10053,
8,
2734,
519,
26,
519,
14,
1205,
9,
267,
366,
14,
10053,
8,
277,
14,
2947,
12,
11485,
9,
267,
372,
366,
339,
347,
511,
63,
4876,
63,
1205,
63,
2993,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
4876,
659,
1083,
534,
5211,
358,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
366,
14,
10053,
8,
2734,
519,
26,
519,
14,
1205,
9,
267,
366,
14,
10053,
8,
277,
14,
2947,
12,
11485,
9,
267,
372,
366,
339,
347,
511,
63,
2593,
63,
4249,
63,
504,
63,
12856,
8,
277,
304,
267,
1056,
275,
4784,
8,
277,
14,
362,
2632,
360,
2573,
659,
3404,
29,
807,
8,
4249,
63,
2593,
29,
16,
14,
19983,
430,
267,
366,
275,
291,
14,
4249,
63,
1069,
8,
1069,
12,
3523,
25157,
360,
1421,
1333,
267,
372,
291,
14,
479,
6782,
8,
68,
12,
10133,
14,
19382,
9,
339,
347,
511,
63,
1102,
63,
1291,
63,
1397,
63,
262,
63,
1069,
63,
2139,
8,
277,
304,
267,
347,
485,
396,
8,
1310,
304,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
openhatch/oh-mainline
|
vendor/packages/whoosh/src/whoosh/lang/lovins.py
|
117
|
12645
|
"""This module implements the Lovins stemming algorithm. Use the ``stem()``
function::
stemmed_word = stem(word)
"""
from collections import defaultdict
# Conditions
def A(base):
# A No restrictions on stem
return True
def B(base):
# B Minimum stem length = 3
return len(base) > 2
def C(base):
# C Minimum stem length = 4
return len(base) > 3
def D(base):
# D Minimum stem length = 5
return len(base) > 4
def E(base):
# E Do not remove ending after e
return base[-1] != "e"
def F(base):
# F Minimum stem length = 3 and do not remove ending after e
return len(base) > 2 and base[-1] != "e"
def G(base):
# G Minimum stem length = 3 and remove ending only after f
return len(base) > 2 and base[-1] == "f"
def H(base):
# H Remove ending only after t or ll
c1, c2 = base[-2:]
return c2 == "t" or (c2 == "l" and c1 == "l")
def I(base):
# I Do not remove ending after o or e
c = base[-1]
return c != "o" and c != "e"
def J(base):
# J Do not remove ending after a or e
c = base[-1]
return c != "a" and c != "e"
def K(base):
# K Minimum stem length = 3 and remove ending only after l, i or u*e
c = base[-1]
cc = base[-3]
return len(base) > 2 and (c == "l" or c == "i" or (c == "e" and cc == "u"))
def L(base):
# L Do not remove ending after u, x or s, unless s follows o
c1, c2 = base[-2:]
return c2 != "u" and c2 != "x" and (c2 != "s" or c1 == "o")
def M(base):
# M Do not remove ending after a, c, e or m
c = base[-1]
return c != "a" and c != "c" and c != "e" and c != "m"
def N(base):
# N Minimum stem length = 4 after s**, elsewhere = 3
return len(base) > 3 or (len(base) == 3 and base[-1] != "s")
def O(base):
# O Remove ending only after l or i
c = base[-1]
return c == "l" or c == "i"
def P(base):
# P Do not remove ending after c
return base[-1] != "c"
def Q(base):
# Q Minimum stem length = 3 and do not remove ending after l or n
c = base[-1]
return len(base) > 2 and (c != "l" and c != "n")
def R(base):
# R Remove ending only after n or r
c = base[-1]
return c == "n" or c == "r"
def S(base):
# S Remove ending only after dr or t, unless t follows t
l2 = base[-2]
return l2 == "rd" or (base[-1] == "t" and l2 != "tt")
def T(base):
# T Remove ending only after s or t, unless t follows o
c1, c2 = base[-2:]
return c2 == "s" or (c2 == "t" and c1 != "o")
def U(base):
# U Remove ending only after l, m, n or r
c = base[-1]
return c == "l" or c == "m" or c == "n" or c == "r"
def V(base):
# V Remove ending only after c
return base[-1] == "c"
def W(base):
# W Do not remove ending after s or u
c = base[-1]
return c != "s" and c != "u"
def X(base):
# X Remove ending only after l, i or u*e
c = base[-1]
cc = base[-3]
return c == "l" or c == "i" or (c == "e" and cc == "u")
def Y(base):
# Y Remove ending only after in
return base[-2:] == "in"
def Z(base):
# Z Do not remove ending after f
return base[-1] != "f"
def a(base):
# a Remove ending only after d, f, ph, th, l, er, or, es or t
c = base[-1]
l2 = base[-2:]
return (c == "d" or c == "f" or l2 == "ph" or l2 == "th" or c == "l"
or l2 == "er" or l2 == "or" or l2 == "es" or c == "t")
def b(base):
# b Minimum stem length = 3 and do not remove ending after met or ryst
return len(base) > 2 and not (base.endswith("met")
or base.endswith("ryst"))
def c(base):
# c Remove ending only after l
return base[-1] == "l"
# Endings
m = [None] * 12
m[11] = dict((
("alistically", B),
("arizability", A),
("izationally", B)))
m[10] = dict((
("antialness", A),
("arisations", A),
("arizations", A),
("entialness", A)))
m[9] = dict((
("allically", C),
("antaneous", A),
("antiality", A),
("arisation", A),
("arization", A),
("ationally", B),
("ativeness", A),
("eableness", E),
("entations", A),
("entiality", A),
("entialize", A),
("entiation", A),
("ionalness", A),
("istically", A),
("itousness", A),
("izability", A),
("izational", A)))
m[8] = dict((
("ableness", A),
("arizable", A),
("entation", A),
("entially", A),
("eousness", A),
("ibleness", A),
("icalness", A),
("ionalism", A),
("ionality", A),
("ionalize", A),
("iousness", A),
("izations", A),
("lessness", A)))
m[7] = dict((
("ability", A),
("aically", A),
("alistic", B),
("alities", A),
("ariness", E),
("aristic", A),
("arizing", A),
("ateness", A),
("atingly", A),
("ational", B),
("atively", A),
("ativism", A),
("elihood", E),
("encible", A),
("entally", A),
("entials", A),
("entiate", A),
("entness", A),
("fulness", A),
("ibility", A),
("icalism", A),
("icalist", A),
("icality", A),
("icalize", A),
("ication", G),
("icianry", A),
("ination", A),
("ingness", A),
("ionally", A),
("isation", A),
("ishness", A),
("istical", A),
("iteness", A),
("iveness", A),
("ivistic", A),
("ivities", A),
("ization", F),
("izement", A),
("oidally", A),
("ousness", A)))
m[6] = dict((
("aceous", A),
("acious", B),
("action", G),
("alness", A),
("ancial", A),
("ancies", A),
("ancing", B),
("ariser", A),
("arized", A),
("arizer", A),
("atable", A),
("ations", B),
("atives", A),
("eature", Z),
("efully", A),
("encies", A),
("encing", A),
("ential", A),
("enting", C),
("entist", A),
("eously", A),
("ialist", A),
("iality", A),
("ialize", A),
("ically", A),
("icance", A),
("icians", A),
("icists", A),
("ifully", A),
("ionals", A),
("ionate", D),
("ioning", A),
("ionist", A),
("iously", A),
("istics", A),
("izable", E),
("lessly", A),
("nesses", A),
("oidism", A)))
m[5] = dict((
("acies", A),
("acity", A),
("aging", B),
("aical", A),
("alist", A),
("alism", B),
("ality", A),
("alize", A),
("allic", b),
("anced", B),
("ances", B),
("antic", C),
("arial", A),
("aries", A),
("arily", A),
("arity", B),
("arize", A),
("aroid", A),
("ately", A),
("ating", I),
("ation", B),
("ative", A),
("ators", A),
("atory", A),
("ature", E),
("early", Y),
("ehood", A),
("eless", A),
("elily", A),
("ement", A),
("enced", A),
("ences", A),
("eness", E),
("ening", E),
("ental", A),
("ented", C),
("ently", A),
("fully", A),
("ially", A),
("icant", A),
("ician", A),
("icide", A),
("icism", A),
("icist", A),
("icity", A),
("idine", I),
("iedly", A),
("ihood", A),
("inate", A),
("iness", A),
("ingly", B),
("inism", J),
("inity", c),
("ional", A),
("ioned", A),
("ished", A),
("istic", A),
("ities", A),
("itous", A),
("ively", A),
("ivity", A),
("izers", F),
("izing", F),
("oidal", A),
("oides", A),
("otide", A),
("ously", A)))
m[4] = dict((
("able", A),
("ably", A),
("ages", B),
("ally", B),
("ance", B),
("ancy", B),
("ants", B),
("aric", A),
("arly", K),
("ated", I),
("ates", A),
("atic", B),
("ator", A),
("ealy", Y),
("edly", E),
("eful", A),
("eity", A),
("ence", A),
("ency", A),
("ened", E),
("enly", E),
("eous", A),
("hood", A),
("ials", A),
("ians", A),
("ible", A),
("ibly", A),
("ical", A),
("ides", L),
("iers", A),
("iful", A),
("ines", M),
("ings", N),
("ions", B),
("ious", A),
("isms", B),
("ists", A),
("itic", H),
("ized", F),
("izer", F),
("less", A),
("lily", A),
("ness", A),
("ogen", A),
("ward", A),
("wise", A),
("ying", B),
("yish", A)))
m[3] = dict((
("acy", A),
("age", B),
("aic", A),
("als", b),
("ant", B),
("ars", O),
("ary", F),
("ata", A),
("ate", A),
("eal", Y),
("ear", Y),
("ely", E),
("ene", E),
("ent", C),
("ery", E),
("ese", A),
("ful", A),
("ial", A),
("ian", A),
("ics", A),
("ide", L),
("ied", A),
("ier", A),
("ies", P),
("ily", A),
("ine", M),
("ing", N),
("ion", Q),
("ish", C),
("ism", B),
("ist", A),
("ite", a),
("ity", A),
("ium", A),
("ive", A),
("ize", F),
("oid", A),
("one", R),
("ous", A)))
m[2] = dict((
("ae", A),
("al", b),
("ar", X),
("as", B),
("ed", E),
("en", F),
("es", E),
("ia", A),
("ic", A),
("is", A),
("ly", B),
("on", S),
("or", T),
("um", U),
("us", V),
("yl", R),
("s'", A),
("'s", A)))
m[1] = dict((
("a", A),
("e", A),
("i", A),
("o", A),
("s", W),
("y", B)))
def remove_ending(word):
length = len(word)
el = 11
while el > 0:
if length - el > 1:
ending = word[length - el:]
cond = m[el].get(ending)
if cond:
base = word[:length - el]
if cond(base):
return base
el -= 1
return word
_endings = (("iev", "ief"),
("uct", "uc"),
("iev", "ief"),
("uct", "uc"),
("umpt", "um"),
("rpt", "rb"),
("urs", "ur"),
("istr", "ister"),
("metr", "meter"),
("olv", "olut"),
("ul", "l", "aoi"),
("bex", "bic"),
("dex", "dic"),
("pex", "pic"),
("tex", "tic"),
("ax", "ac"),
("ex", "ec"),
("ix", "ic"),
("lux", "luc"),
("uad", "uas"),
("vad", "vas"),
("cid", "cis"),
("lid", "lis"),
("erid", "eris"),
("pand", "pans"),
("end", "ens", "s"),
("ond", "ons"),
("lud", "lus"),
("rud", "rus"),
("her", "hes", "pt"),
("mit", "mis"),
("ent", "ens", "m"),
("ert", "ers"),
("et", "es", "n"),
("yt", "ys"),
("yz", "ys"))
# Hash the ending rules by the last letter of the target ending
_endingrules = defaultdict(list)
for rule in _endings:
_endingrules[rule[0][-1]].append(rule)
_doubles = frozenset(("dd", "gg", "ll", "mm", "nn", "pp", "rr", "ss", "tt"))
def fix_ending(word):
if word[-2:] in _doubles:
word = word[:-1]
for endingrule in _endingrules[word[-1]]:
target, newend = endingrule[:2]
if word.endswith(target):
if len(endingrule) > 2:
exceptafter = endingrule[2]
c = word[0 - (len(target) + 1)]
if c in exceptafter:
return word
return word[:0 - len(target)] + newend
return word
def stem(word):
"""Returns the stemmed version of the argument string.
"""
return fix_ending(remove_ending(word))
|
agpl-3.0
|
[
624,
2765,
859,
9031,
314,
3835,
86,
3617,
17408,
14566,
5563,
14,
3645,
314,
1124,
18446,
8497,
199,
1593,
447,
339,
17408,
3594,
63,
1027,
275,
17408,
8,
1027,
9,
199,
624,
199,
199,
504,
5055,
492,
10018,
421,
199,
3,
1448,
3138,
199,
199,
318,
437,
8,
1095,
304,
272,
327,
437,
257,
3091,
24488,
641,
17408,
272,
372,
715,
421,
199,
318,
699,
8,
1095,
304,
272,
327,
699,
221,
22466,
17408,
2582,
275,
650,
272,
372,
822,
8,
1095,
9,
690,
499,
421,
199,
318,
445,
8,
1095,
304,
272,
327,
445,
221,
22466,
17408,
2582,
275,
841,
272,
372,
822,
8,
1095,
9,
690,
650,
421,
199,
318,
577,
8,
1095,
304,
272,
327,
577,
221,
22466,
17408,
2582,
275,
959,
272,
372,
822,
8,
1095,
9,
690,
841,
421,
199,
318,
662,
8,
1095,
304,
272,
327,
662,
221,
4226,
440,
2813,
13401,
2410,
325,
272,
372,
1300,
1988,
17,
61,
1137,
298,
69,
2,
421,
199,
318,
481,
8,
1095,
304,
272,
327,
481,
221,
22466,
17408,
2582,
275,
650,
436,
886,
440,
2813,
13401,
2410,
325,
272,
372,
822,
8,
1095,
9,
690,
499,
436,
1300,
1988,
17,
61,
1137,
298,
69,
2,
421,
199,
318,
598,
8,
1095,
304,
272,
327,
598,
221,
22466,
17408,
2582,
275,
650,
436,
2813,
13401,
1454,
2410,
289,
272,
372,
822,
8,
1095,
9,
690,
499,
436,
1300,
1988,
17,
61,
508,
298,
70,
2,
421,
199,
318,
869,
8,
1095,
304,
272,
327,
869,
221,
5852,
13401,
1454,
2410,
307,
503,
18338,
272,
286,
17,
12,
286,
18,
275,
1300,
1988,
18,
2938,
272,
372,
286,
18,
508,
298,
84,
2,
503,
334,
67,
18,
508,
298,
76,
2,
436,
286,
17,
508,
298,
76,
531,
421,
199,
318,
473,
8,
1095,
304,
272,
327,
473,
221,
4226,
440,
2813,
13401,
2410,
312,
503,
325,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
1137,
298,
79,
2,
436,
286,
1137,
298,
69,
2,
421,
199,
318,
1603,
8,
1095,
304,
272,
327,
1603,
221,
4226,
440,
2813,
13401,
2410,
282,
503,
325,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
1137,
298,
65,
2,
436,
286,
1137,
298,
69,
2,
421,
199,
318,
1804,
8,
1095,
304,
272,
327,
1804,
221,
22466,
17408,
2582,
275,
650,
436,
2813,
13401,
1454,
2410,
634,
12,
284,
503,
399,
10,
69,
272,
286,
275,
1300,
1988,
17,
61,
272,
7429,
275,
1300,
1988,
19,
61,
272,
372,
822,
8,
1095,
9,
690,
499,
436,
334,
67,
508,
298,
76,
2,
503,
286,
508,
298,
73,
2,
503,
334,
67,
508,
298,
69,
2,
436,
7429,
508,
298,
85,
2237,
421,
199,
318,
491,
8,
1095,
304,
272,
327,
491,
221,
4226,
440,
2813,
13401,
2410,
399,
12,
671,
503,
308,
12,
7444,
308,
11924,
312,
272,
286,
17,
12,
286,
18,
275,
1300,
1988,
18,
2938,
272,
372,
286,
18,
1137,
298,
85,
2,
436,
286,
18,
1137,
298,
88,
2,
436,
334,
67,
18,
1137,
298,
83,
2,
503,
286,
17,
508,
298,
79,
531,
421,
199,
318,
603,
8,
1095,
304,
272,
327,
603,
221,
4226,
440,
2813,
13401,
2410,
282,
12,
286,
12,
325,
503,
333,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
1137,
298,
65,
2,
436,
286,
1137,
298,
67,
2,
436,
286,
1137,
298,
69,
2,
436,
286,
1137,
298,
77,
2,
421,
199,
318,
653,
8,
1095,
304,
272,
327,
653,
221,
22466,
17408,
2582,
275,
841,
2410,
308,
538,
12,
25320,
275,
650,
272,
372,
822,
8,
1095,
9,
690,
650,
503,
334,
552,
8,
1095,
9,
508,
650,
436,
1300,
1988,
17,
61,
1137,
298,
83,
531,
421,
199,
318,
593,
8,
1095,
304,
272,
327,
593,
221,
5852,
13401,
1454,
2410,
634,
503,
284,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
508,
298,
76,
2,
503,
286,
508,
298,
73,
2,
421,
199,
318,
510,
8,
1095,
304,
272,
327,
510,
221,
4226,
440,
2813,
13401,
2410,
286,
272,
372,
1300,
1988,
17,
61,
1137,
298,
67,
2,
421,
199,
318,
1413,
8,
1095,
304,
272,
327,
1413,
221,
22466,
17408,
2582,
275,
650,
436,
886,
440,
2813,
13401,
2410,
634,
503,
302,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
822,
8,
1095,
9,
690,
499,
436,
334,
67,
1137,
298,
76,
2,
436,
286,
1137,
298,
78,
531,
421,
199,
318,
820,
8,
1095,
304,
272,
327,
820,
221,
5852,
13401,
1454,
2410,
302,
503,
519,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
508,
298,
78,
2,
503,
286,
508,
298,
82,
2,
421,
199,
318,
428,
8,
1095,
304,
272,
327,
428,
221,
5852,
13401,
1454,
2410,
16642,
503,
307,
12,
7444,
307,
11924,
307,
272,
634,
18,
275,
1300,
1988,
18,
61,
272,
372,
634,
18,
508,
298,
6883,
2,
503,
334,
1095,
1988,
17,
61,
508,
298,
84,
2,
436,
634,
18,
1137,
298,
6215,
531,
421,
199,
318,
377,
8,
1095,
304,
272,
327,
377,
221,
5852,
13401,
1454,
2410,
308,
503,
307,
12,
7444,
307,
11924,
312,
272,
286,
17,
12,
286,
18,
275,
1300,
1988,
18,
2938,
272,
372,
286,
18,
508,
298,
83,
2,
503,
334,
67,
18,
508,
298,
84,
2,
436,
286,
17,
1137,
298,
79,
531,
421,
199,
318,
738,
8,
1095,
304,
272,
327,
738,
221,
5852,
13401,
1454,
2410,
634,
12,
333,
12,
302,
503,
519,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
508,
298,
76,
2,
503,
286,
508,
298,
77,
2,
503,
286,
508,
298,
78,
2,
503,
286,
508,
298,
82,
2,
421,
199,
318,
812,
8,
1095,
304,
272,
327,
812,
221,
5852,
13401,
1454,
2410,
286,
272,
372,
1300,
1988,
17,
61,
508,
298,
67,
2,
421,
199,
318,
644,
8,
1095,
304,
272,
327,
644,
221,
4226,
440,
2813,
13401,
2410,
308,
503,
399,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
1137,
298,
83,
2,
436,
286,
1137,
298,
85,
2,
421,
199,
318,
1323,
8,
1095,
304,
272,
327,
1323,
221,
5852,
13401,
1454,
2410,
634,
12,
284,
503,
399,
10
] |
[
2765,
859,
9031,
314,
3835,
86,
3617,
17408,
14566,
5563,
14,
3645,
314,
1124,
18446,
8497,
199,
1593,
447,
339,
17408,
3594,
63,
1027,
275,
17408,
8,
1027,
9,
199,
624,
199,
199,
504,
5055,
492,
10018,
421,
199,
3,
1448,
3138,
199,
199,
318,
437,
8,
1095,
304,
272,
327,
437,
257,
3091,
24488,
641,
17408,
272,
372,
715,
421,
199,
318,
699,
8,
1095,
304,
272,
327,
699,
221,
22466,
17408,
2582,
275,
650,
272,
372,
822,
8,
1095,
9,
690,
499,
421,
199,
318,
445,
8,
1095,
304,
272,
327,
445,
221,
22466,
17408,
2582,
275,
841,
272,
372,
822,
8,
1095,
9,
690,
650,
421,
199,
318,
577,
8,
1095,
304,
272,
327,
577,
221,
22466,
17408,
2582,
275,
959,
272,
372,
822,
8,
1095,
9,
690,
841,
421,
199,
318,
662,
8,
1095,
304,
272,
327,
662,
221,
4226,
440,
2813,
13401,
2410,
325,
272,
372,
1300,
1988,
17,
61,
1137,
298,
69,
2,
421,
199,
318,
481,
8,
1095,
304,
272,
327,
481,
221,
22466,
17408,
2582,
275,
650,
436,
886,
440,
2813,
13401,
2410,
325,
272,
372,
822,
8,
1095,
9,
690,
499,
436,
1300,
1988,
17,
61,
1137,
298,
69,
2,
421,
199,
318,
598,
8,
1095,
304,
272,
327,
598,
221,
22466,
17408,
2582,
275,
650,
436,
2813,
13401,
1454,
2410,
289,
272,
372,
822,
8,
1095,
9,
690,
499,
436,
1300,
1988,
17,
61,
508,
298,
70,
2,
421,
199,
318,
869,
8,
1095,
304,
272,
327,
869,
221,
5852,
13401,
1454,
2410,
307,
503,
18338,
272,
286,
17,
12,
286,
18,
275,
1300,
1988,
18,
2938,
272,
372,
286,
18,
508,
298,
84,
2,
503,
334,
67,
18,
508,
298,
76,
2,
436,
286,
17,
508,
298,
76,
531,
421,
199,
318,
473,
8,
1095,
304,
272,
327,
473,
221,
4226,
440,
2813,
13401,
2410,
312,
503,
325,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
1137,
298,
79,
2,
436,
286,
1137,
298,
69,
2,
421,
199,
318,
1603,
8,
1095,
304,
272,
327,
1603,
221,
4226,
440,
2813,
13401,
2410,
282,
503,
325,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
1137,
298,
65,
2,
436,
286,
1137,
298,
69,
2,
421,
199,
318,
1804,
8,
1095,
304,
272,
327,
1804,
221,
22466,
17408,
2582,
275,
650,
436,
2813,
13401,
1454,
2410,
634,
12,
284,
503,
399,
10,
69,
272,
286,
275,
1300,
1988,
17,
61,
272,
7429,
275,
1300,
1988,
19,
61,
272,
372,
822,
8,
1095,
9,
690,
499,
436,
334,
67,
508,
298,
76,
2,
503,
286,
508,
298,
73,
2,
503,
334,
67,
508,
298,
69,
2,
436,
7429,
508,
298,
85,
2237,
421,
199,
318,
491,
8,
1095,
304,
272,
327,
491,
221,
4226,
440,
2813,
13401,
2410,
399,
12,
671,
503,
308,
12,
7444,
308,
11924,
312,
272,
286,
17,
12,
286,
18,
275,
1300,
1988,
18,
2938,
272,
372,
286,
18,
1137,
298,
85,
2,
436,
286,
18,
1137,
298,
88,
2,
436,
334,
67,
18,
1137,
298,
83,
2,
503,
286,
17,
508,
298,
79,
531,
421,
199,
318,
603,
8,
1095,
304,
272,
327,
603,
221,
4226,
440,
2813,
13401,
2410,
282,
12,
286,
12,
325,
503,
333,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
1137,
298,
65,
2,
436,
286,
1137,
298,
67,
2,
436,
286,
1137,
298,
69,
2,
436,
286,
1137,
298,
77,
2,
421,
199,
318,
653,
8,
1095,
304,
272,
327,
653,
221,
22466,
17408,
2582,
275,
841,
2410,
308,
538,
12,
25320,
275,
650,
272,
372,
822,
8,
1095,
9,
690,
650,
503,
334,
552,
8,
1095,
9,
508,
650,
436,
1300,
1988,
17,
61,
1137,
298,
83,
531,
421,
199,
318,
593,
8,
1095,
304,
272,
327,
593,
221,
5852,
13401,
1454,
2410,
634,
503,
284,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
508,
298,
76,
2,
503,
286,
508,
298,
73,
2,
421,
199,
318,
510,
8,
1095,
304,
272,
327,
510,
221,
4226,
440,
2813,
13401,
2410,
286,
272,
372,
1300,
1988,
17,
61,
1137,
298,
67,
2,
421,
199,
318,
1413,
8,
1095,
304,
272,
327,
1413,
221,
22466,
17408,
2582,
275,
650,
436,
886,
440,
2813,
13401,
2410,
634,
503,
302,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
822,
8,
1095,
9,
690,
499,
436,
334,
67,
1137,
298,
76,
2,
436,
286,
1137,
298,
78,
531,
421,
199,
318,
820,
8,
1095,
304,
272,
327,
820,
221,
5852,
13401,
1454,
2410,
302,
503,
519,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
508,
298,
78,
2,
503,
286,
508,
298,
82,
2,
421,
199,
318,
428,
8,
1095,
304,
272,
327,
428,
221,
5852,
13401,
1454,
2410,
16642,
503,
307,
12,
7444,
307,
11924,
307,
272,
634,
18,
275,
1300,
1988,
18,
61,
272,
372,
634,
18,
508,
298,
6883,
2,
503,
334,
1095,
1988,
17,
61,
508,
298,
84,
2,
436,
634,
18,
1137,
298,
6215,
531,
421,
199,
318,
377,
8,
1095,
304,
272,
327,
377,
221,
5852,
13401,
1454,
2410,
308,
503,
307,
12,
7444,
307,
11924,
312,
272,
286,
17,
12,
286,
18,
275,
1300,
1988,
18,
2938,
272,
372,
286,
18,
508,
298,
83,
2,
503,
334,
67,
18,
508,
298,
84,
2,
436,
286,
17,
1137,
298,
79,
531,
421,
199,
318,
738,
8,
1095,
304,
272,
327,
738,
221,
5852,
13401,
1454,
2410,
634,
12,
333,
12,
302,
503,
519,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
508,
298,
76,
2,
503,
286,
508,
298,
77,
2,
503,
286,
508,
298,
78,
2,
503,
286,
508,
298,
82,
2,
421,
199,
318,
812,
8,
1095,
304,
272,
327,
812,
221,
5852,
13401,
1454,
2410,
286,
272,
372,
1300,
1988,
17,
61,
508,
298,
67,
2,
421,
199,
318,
644,
8,
1095,
304,
272,
327,
644,
221,
4226,
440,
2813,
13401,
2410,
308,
503,
399,
272,
286,
275,
1300,
1988,
17,
61,
272,
372,
286,
1137,
298,
83,
2,
436,
286,
1137,
298,
85,
2,
421,
199,
318,
1323,
8,
1095,
304,
272,
327,
1323,
221,
5852,
13401,
1454,
2410,
634,
12,
284,
503,
399,
10,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
shyamalschandra/keras
|
keras/models.py
|
2
|
4899
|
import theano
import theano.tensor as T
import numpy as np
import optimizers
import objectives
import time, copy
from utils.generic_utils import Progbar
def standardize_y(y):
y = np.asarray(y)
if len(y.shape) == 1:
y = np.reshape(y, (len(y), 1))
return y
class Sequential(object):
def __init__(self):
self.layers = []
self.params = []
def add(self, layer):
self.layers.append(layer)
if len(self.layers) > 1:
self.layers[-1].connect(self.layers[-2])
self.params += [p for p in layer.params]
def compile(self, optimizer, loss):
self.optimizer = optimizers.get(optimizer)
self.loss = objectives.get(loss)
self.X = self.layers[0].input # input of model
# (first layer must have an "input" attribute!)
self.y_train = self.layers[-1].output(train=True)
self.y_test = self.layers[-1].output(train=False)
# output of model
self.Y = T.matrix() # TODO: support for custom output shapes
train_loss = self.loss(self.Y, self.y_train)
test_score = self.loss(self.Y, self.y_test)
updates = self.optimizer.get_updates(self.params, train_loss)
self._train = theano.function([self.X, self.Y], train_loss,
updates=updates, allow_input_downcast=True)
self._predict = theano.function([self.X], self.y_test,
allow_input_downcast=True)
self._test = theano.function([self.X, self.Y], test_score,
allow_input_downcast=True)
def train(self, X, y):
y = standardize_y(y)
loss = self._train(X, y)
return loss
def test(self, X, y):
y = standardize_y(y)
score = self._test(X, y)
return score
def fit(self, X, y, batch_size=128, nb_epoch=100, verbose=1,
validation_split=0., shuffle=True):
# If a validation split size is given (e.g. validation_split=0.2)
# then split X into smaller X and X_val,
# and split y into smaller y and y_val.
y = standardize_y(y)
do_validation = False
if validation_split > 0 and validation_split < 1:
do_validation = True
split_at = int(len(X) * (1 - validation_split))
(X, X_val) = (X[0:split_at], X[split_at:])
(y, y_val) = (y[0:split_at], y[split_at:])
if verbose:
print "Train on %d samples, validate on %d samples" % (len(y), len(y_val))
index_array = np.arange(len(X))
for epoch in range(nb_epoch):
if verbose:
print 'Epoch', epoch
if shuffle:
np.random.shuffle(index_array)
nb_batch = int(np.ceil(len(X)/float(batch_size)))
progbar = Progbar(target=len(X))
for batch_index in range(0, nb_batch):
batch_start = batch_index*batch_size
batch_end = min(len(X), (batch_index+1)*batch_size)
batch_ids = index_array[batch_start:batch_end]
X_batch = X[batch_ids]
y_batch = y[batch_ids]
loss = self._train(X_batch, y_batch)
if verbose:
is_last_batch = (batch_index == nb_batch - 1)
if not is_last_batch or not do_validation:
progbar.update(batch_end, [('loss', loss)])
else:
progbar.update(batch_end, [('loss', loss), ('val. loss', self.test(X_val, y_val))])
def predict_proba(self, X, batch_size=128):
for batch_index in range(0, len(X)/batch_size+1):
batch = range(batch_index*batch_size, min(len(X), (batch_index+1)*batch_size))
if not batch:
break
batch_preds = self._predict(X[batch])
if batch_index == 0:
shape = (len(X),) + batch_preds.shape[1:]
preds = np.zeros(shape)
preds[batch] = batch_preds
return preds
def predict_classes(self, X, batch_size=128):
proba = self.predict_proba(X, batch_size=batch_size)
# The last dimension is the one containing the class probas
classes_dim = proba.ndim - 1
if proba.shape[classes_dim] > 1:
return proba.argmax(axis=classes_dim)
else:
return (proba>0.5).astype('int32')
def evaluate(self, X, y, batch_size=128):
y = standardize_y(y)
av_score = 0.
samples = 0
for batch_index in range(0, len(X)/batch_size+1):
batch = range(batch_index*batch_size, min(len(X), (batch_index+1)*batch_size))
if not batch:
break
score = self._test(X[batch], y[batch])
av_score += len(batch)*score
samples += len(batch)
return av_score/samples
|
mit
|
[
646,
14377,
199,
646,
14377,
14,
3128,
465,
377,
199,
646,
2680,
465,
980,
199,
199,
646,
5323,
6315,
199,
646,
1559,
825,
7301,
199,
646,
900,
12,
1331,
199,
504,
3778,
14,
6767,
63,
1208,
492,
2165,
71,
1700,
199,
199,
318,
28974,
806,
63,
89,
8,
89,
304,
272,
612,
275,
980,
14,
8748,
8,
89,
9,
272,
340,
822,
8,
89,
14,
1392,
9,
508,
413,
26,
267,
612,
275,
980,
14,
5217,
8,
89,
12,
334,
552,
8,
89,
395,
413,
430,
272,
372,
612,
199,
199,
533,
3240,
9092,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
4359,
275,
942,
267,
291,
14,
1162,
275,
942,
339,
347,
1050,
8,
277,
12,
4045,
304,
267,
291,
14,
4359,
14,
740,
8,
1897,
9,
267,
340,
822,
8,
277,
14,
4359,
9,
690,
413,
26,
288,
291,
14,
4359,
1988,
17,
1055,
2242,
8,
277,
14,
4359,
1988,
18,
566,
267,
291,
14,
1162,
847,
359,
80,
367,
299,
315,
4045,
14,
1162,
61,
339,
347,
6555,
8,
277,
12,
10736,
12,
5621,
304,
267,
291,
14,
12290,
275,
5323,
6315,
14,
362,
8,
12290,
9,
267,
291,
14,
4358,
275,
1559,
825,
7301,
14,
362,
8,
4358,
9,
398,
291,
14,
56,
275,
291,
14,
4359,
59,
16,
1055,
1210,
327,
1324,
402,
1402,
4960,
327,
334,
2246,
4045,
1471,
1172,
376,
298,
1210,
2,
2225,
21866,
267,
291,
14,
89,
63,
2834,
275,
291,
14,
4359,
1988,
17,
1055,
1199,
8,
2834,
29,
549,
9,
267,
291,
14,
89,
63,
396,
275,
291,
14,
4359,
1988,
17,
1055,
1199,
8,
2834,
29,
797,
9,
398,
327,
1072,
402,
1402,
267,
291,
14,
57,
275,
377,
14,
3642,
342,
327,
3254,
26,
2291,
367,
3537,
1072,
11751,
398,
3560,
63,
4358,
275,
291,
14,
4358,
8,
277,
14,
57,
12,
291,
14,
89,
63,
2834,
9,
267,
511,
63,
3397,
275,
291,
14,
4358,
8,
277,
14,
57,
12,
291,
14,
89,
63,
396,
9,
267,
7029,
275,
291,
14,
12290,
14,
362,
63,
7618,
8,
277,
14,
1162,
12,
3560,
63,
4358,
9,
398,
291,
423,
2834,
275,
14377,
14,
1593,
779,
277,
14,
56,
12,
291,
14,
57,
467,
3560,
63,
4358,
12,
7205,
7029,
29,
7618,
12,
2040,
63,
1210,
63,
2110,
2931,
29,
549,
9,
267,
291,
423,
6892,
275,
14377,
14,
1593,
779,
277,
14,
56,
467,
291,
14,
89,
63,
396,
12,
7205,
2040,
63,
1210,
63,
2110,
2931,
29,
549,
9,
267,
291,
423,
396,
275,
14377,
14,
1593,
779,
277,
14,
56,
12,
291,
14,
57,
467,
511,
63,
3397,
12,
7205,
2040,
63,
1210,
63,
2110,
2931,
29,
549,
9,
339,
347,
3560,
8,
277,
12,
1323,
12,
612,
304,
267,
612,
275,
28974,
806,
63,
89,
8,
89,
9,
267,
5621,
275,
291,
423,
2834,
8,
56,
12,
612,
9,
267,
372,
5621,
339,
347,
511,
8,
277,
12,
1323,
12,
612,
304,
267,
612,
275,
28974,
806,
63,
89,
8,
89,
9,
267,
5396,
275,
291,
423,
396,
8,
56,
12,
612,
9,
267,
372,
5396,
339,
347,
5542,
8,
277,
12,
1323,
12,
612,
12,
3522,
63,
890,
29,
3933,
12,
8526,
63,
7367,
29,
1960,
12,
3376,
29,
17,
12,
288,
6411,
63,
1294,
29,
16,
2020,
13031,
29,
549,
304,
267,
327,
982,
282,
6411,
3715,
1568,
365,
1627,
334,
69,
14,
71,
14,
6411,
63,
1294,
29,
16,
14,
18,
9,
267,
327,
2066,
3715,
1323,
1901,
12700,
1323,
436,
1323,
63,
637,
12,
267,
327,
436,
3715,
612,
1901,
12700,
612,
436,
612,
63,
637,
14,
267,
612,
275,
28974,
806,
63,
89,
8,
89,
9,
398,
886,
63,
6136,
275,
756,
267,
340,
6411,
63,
1294,
690,
378,
436,
6411,
63,
1294,
665,
413,
26,
288,
886,
63,
6136,
275,
715,
288,
3715,
63,
292,
275,
1109,
8,
552,
8,
56,
9,
627,
334,
17,
446,
6411,
63,
1294,
430,
288,
334,
56,
12,
1323,
63,
637,
9,
275,
334,
56,
59,
16,
26,
1294,
63,
292,
467,
1323,
59,
1294,
63,
292,
5728,
288,
334,
89,
12,
612,
63,
637,
9,
275,
334,
89,
59,
16,
26,
1294,
63,
292,
467,
612,
59,
1294,
63,
292,
5728,
288,
340,
3376,
26,
355,
870,
298,
18591,
641,
450,
68,
5845,
12,
4107,
641,
450,
68,
5845,
2,
450,
334,
552,
8,
89,
395,
822,
8,
89,
63,
637,
430,
2728,
1478,
63,
1144,
275,
980,
14,
5605,
8,
552,
8,
56,
430,
267,
367,
9463,
315,
1425,
8,
4994,
63,
7367,
304,
288,
340,
3376,
26,
355,
870,
283,
29322,
297,
9463,
288,
340,
13031,
26,
355,
980,
14,
2355,
14,
11777,
8,
1080,
63,
1144,
9,
953,
8526,
63,
2912,
275,
1109,
8,
1590,
14,
14085,
8,
552,
8,
56,
2447,
1609,
8,
2912,
63,
890,
1724,
288,
13205,
1700,
275,
2165,
71,
1700,
8,
1375,
29,
552,
8,
56,
430,
288,
367,
3522,
63,
1080,
315,
1425,
8,
16,
12,
8526,
63,
2912,
304,
355,
3522,
63,
928,
275,
3522,
63,
1080,
10,
2912,
63,
890,
355,
3522,
63,
500,
275,
1748,
8,
552,
8,
56,
395,
334,
2912,
63,
1080,
11,
17,
3342,
2912,
63,
890,
9,
355,
3522,
63,
1580,
275,
1478,
63,
1144,
59,
2912,
63,
928,
26,
2912,
63,
500,
61,
2234,
1323,
63,
2912,
275,
1323,
59,
2912,
63,
1580,
61,
355,
612,
63,
2912,
275,
612,
59,
2912,
63,
1580,
61,
355,
5621,
275,
291,
423,
2834,
8,
56,
63,
2912,
12,
612,
63,
2912,
9,
14977,
340,
3376,
26,
490,
365,
63,
2019,
63,
2912,
275,
334,
2912,
63,
1080,
508,
8526,
63,
2912,
446,
413,
9,
490,
340,
440,
365,
63,
2019,
63,
2912,
503,
440,
886,
63,
6136,
26,
717,
13205,
1700,
14,
873,
8,
2912,
63,
500,
12,
4274,
4358,
297,
5621,
3948,
490,
587,
26,
717,
13205,
1700,
14,
873,
8,
2912,
63,
500,
12,
4274,
4358,
297,
5621,
395,
661,
637,
14,
5621,
297,
291,
14,
396,
8,
56,
63,
637,
12,
612,
63,
637,
18229,
15567,
347,
12610,
63,
14417,
8,
277,
12,
1323,
12,
3522,
63,
890,
29,
3933,
304,
267
] |
[
14377,
199,
646,
14377,
14,
3128,
465,
377,
199,
646,
2680,
465,
980,
199,
199,
646,
5323,
6315,
199,
646,
1559,
825,
7301,
199,
646,
900,
12,
1331,
199,
504,
3778,
14,
6767,
63,
1208,
492,
2165,
71,
1700,
199,
199,
318,
28974,
806,
63,
89,
8,
89,
304,
272,
612,
275,
980,
14,
8748,
8,
89,
9,
272,
340,
822,
8,
89,
14,
1392,
9,
508,
413,
26,
267,
612,
275,
980,
14,
5217,
8,
89,
12,
334,
552,
8,
89,
395,
413,
430,
272,
372,
612,
199,
199,
533,
3240,
9092,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
4359,
275,
942,
267,
291,
14,
1162,
275,
942,
339,
347,
1050,
8,
277,
12,
4045,
304,
267,
291,
14,
4359,
14,
740,
8,
1897,
9,
267,
340,
822,
8,
277,
14,
4359,
9,
690,
413,
26,
288,
291,
14,
4359,
1988,
17,
1055,
2242,
8,
277,
14,
4359,
1988,
18,
566,
267,
291,
14,
1162,
847,
359,
80,
367,
299,
315,
4045,
14,
1162,
61,
339,
347,
6555,
8,
277,
12,
10736,
12,
5621,
304,
267,
291,
14,
12290,
275,
5323,
6315,
14,
362,
8,
12290,
9,
267,
291,
14,
4358,
275,
1559,
825,
7301,
14,
362,
8,
4358,
9,
398,
291,
14,
56,
275,
291,
14,
4359,
59,
16,
1055,
1210,
327,
1324,
402,
1402,
4960,
327,
334,
2246,
4045,
1471,
1172,
376,
298,
1210,
2,
2225,
21866,
267,
291,
14,
89,
63,
2834,
275,
291,
14,
4359,
1988,
17,
1055,
1199,
8,
2834,
29,
549,
9,
267,
291,
14,
89,
63,
396,
275,
291,
14,
4359,
1988,
17,
1055,
1199,
8,
2834,
29,
797,
9,
398,
327,
1072,
402,
1402,
267,
291,
14,
57,
275,
377,
14,
3642,
342,
327,
3254,
26,
2291,
367,
3537,
1072,
11751,
398,
3560,
63,
4358,
275,
291,
14,
4358,
8,
277,
14,
57,
12,
291,
14,
89,
63,
2834,
9,
267,
511,
63,
3397,
275,
291,
14,
4358,
8,
277,
14,
57,
12,
291,
14,
89,
63,
396,
9,
267,
7029,
275,
291,
14,
12290,
14,
362,
63,
7618,
8,
277,
14,
1162,
12,
3560,
63,
4358,
9,
398,
291,
423,
2834,
275,
14377,
14,
1593,
779,
277,
14,
56,
12,
291,
14,
57,
467,
3560,
63,
4358,
12,
7205,
7029,
29,
7618,
12,
2040,
63,
1210,
63,
2110,
2931,
29,
549,
9,
267,
291,
423,
6892,
275,
14377,
14,
1593,
779,
277,
14,
56,
467,
291,
14,
89,
63,
396,
12,
7205,
2040,
63,
1210,
63,
2110,
2931,
29,
549,
9,
267,
291,
423,
396,
275,
14377,
14,
1593,
779,
277,
14,
56,
12,
291,
14,
57,
467,
511,
63,
3397,
12,
7205,
2040,
63,
1210,
63,
2110,
2931,
29,
549,
9,
339,
347,
3560,
8,
277,
12,
1323,
12,
612,
304,
267,
612,
275,
28974,
806,
63,
89,
8,
89,
9,
267,
5621,
275,
291,
423,
2834,
8,
56,
12,
612,
9,
267,
372,
5621,
339,
347,
511,
8,
277,
12,
1323,
12,
612,
304,
267,
612,
275,
28974,
806,
63,
89,
8,
89,
9,
267,
5396,
275,
291,
423,
396,
8,
56,
12,
612,
9,
267,
372,
5396,
339,
347,
5542,
8,
277,
12,
1323,
12,
612,
12,
3522,
63,
890,
29,
3933,
12,
8526,
63,
7367,
29,
1960,
12,
3376,
29,
17,
12,
288,
6411,
63,
1294,
29,
16,
2020,
13031,
29,
549,
304,
267,
327,
982,
282,
6411,
3715,
1568,
365,
1627,
334,
69,
14,
71,
14,
6411,
63,
1294,
29,
16,
14,
18,
9,
267,
327,
2066,
3715,
1323,
1901,
12700,
1323,
436,
1323,
63,
637,
12,
267,
327,
436,
3715,
612,
1901,
12700,
612,
436,
612,
63,
637,
14,
267,
612,
275,
28974,
806,
63,
89,
8,
89,
9,
398,
886,
63,
6136,
275,
756,
267,
340,
6411,
63,
1294,
690,
378,
436,
6411,
63,
1294,
665,
413,
26,
288,
886,
63,
6136,
275,
715,
288,
3715,
63,
292,
275,
1109,
8,
552,
8,
56,
9,
627,
334,
17,
446,
6411,
63,
1294,
430,
288,
334,
56,
12,
1323,
63,
637,
9,
275,
334,
56,
59,
16,
26,
1294,
63,
292,
467,
1323,
59,
1294,
63,
292,
5728,
288,
334,
89,
12,
612,
63,
637,
9,
275,
334,
89,
59,
16,
26,
1294,
63,
292,
467,
612,
59,
1294,
63,
292,
5728,
288,
340,
3376,
26,
355,
870,
298,
18591,
641,
450,
68,
5845,
12,
4107,
641,
450,
68,
5845,
2,
450,
334,
552,
8,
89,
395,
822,
8,
89,
63,
637,
430,
2728,
1478,
63,
1144,
275,
980,
14,
5605,
8,
552,
8,
56,
430,
267,
367,
9463,
315,
1425,
8,
4994,
63,
7367,
304,
288,
340,
3376,
26,
355,
870,
283,
29322,
297,
9463,
288,
340,
13031,
26,
355,
980,
14,
2355,
14,
11777,
8,
1080,
63,
1144,
9,
953,
8526,
63,
2912,
275,
1109,
8,
1590,
14,
14085,
8,
552,
8,
56,
2447,
1609,
8,
2912,
63,
890,
1724,
288,
13205,
1700,
275,
2165,
71,
1700,
8,
1375,
29,
552,
8,
56,
430,
288,
367,
3522,
63,
1080,
315,
1425,
8,
16,
12,
8526,
63,
2912,
304,
355,
3522,
63,
928,
275,
3522,
63,
1080,
10,
2912,
63,
890,
355,
3522,
63,
500,
275,
1748,
8,
552,
8,
56,
395,
334,
2912,
63,
1080,
11,
17,
3342,
2912,
63,
890,
9,
355,
3522,
63,
1580,
275,
1478,
63,
1144,
59,
2912,
63,
928,
26,
2912,
63,
500,
61,
2234,
1323,
63,
2912,
275,
1323,
59,
2912,
63,
1580,
61,
355,
612,
63,
2912,
275,
612,
59,
2912,
63,
1580,
61,
355,
5621,
275,
291,
423,
2834,
8,
56,
63,
2912,
12,
612,
63,
2912,
9,
14977,
340,
3376,
26,
490,
365,
63,
2019,
63,
2912,
275,
334,
2912,
63,
1080,
508,
8526,
63,
2912,
446,
413,
9,
490,
340,
440,
365,
63,
2019,
63,
2912,
503,
440,
886,
63,
6136,
26,
717,
13205,
1700,
14,
873,
8,
2912,
63,
500,
12,
4274,
4358,
297,
5621,
3948,
490,
587,
26,
717,
13205,
1700,
14,
873,
8,
2912,
63,
500,
12,
4274,
4358,
297,
5621,
395,
661,
637,
14,
5621,
297,
291,
14,
396,
8,
56,
63,
637,
12,
612,
63,
637,
18229,
15567,
347,
12610,
63,
14417,
8,
277,
12,
1323,
12,
3522,
63,
890,
29,
3933,
304,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
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1565
|
"""
7. The lookup API
This demonstrates features of the database API.
"""
from __future__ import unicode_literals
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=100)
class Meta:
ordering = ('name', )
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateTimeField()
author = models.ForeignKey(Author, blank=True, null=True)
class Meta:
ordering = ('-pub_date', 'headline')
def __str__(self):
return self.headline
class Tag(models.Model):
articles = models.ManyToManyField(Article)
name = models.CharField(max_length=100)
class Meta:
ordering = ('name', )
@python_2_unicode_compatible
class Season(models.Model):
year = models.PositiveSmallIntegerField()
gt = models.IntegerField(null=True, blank=True)
def __str__(self):
return six.text_type(self.year)
@python_2_unicode_compatible
class Game(models.Model):
season = models.ForeignKey(Season, related_name='games')
home = models.CharField(max_length=100)
away = models.CharField(max_length=100)
def __str__(self):
return "%s at %s" % (self.away, self.home)
@python_2_unicode_compatible
class Player(models.Model):
name = models.CharField(max_length=100)
games = models.ManyToManyField(Game, related_name='players')
def __str__(self):
return self.name
|
bsd-3-clause
|
[
624,
199,
23,
14,
710,
4237,
3261,
199,
199,
2765,
23789,
31216,
4534,
402,
314,
3050,
3261,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
2366,
63,
18,
63,
2975,
63,
6490,
421,
199,
533,
6529,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
339,
1021,
6288,
26,
267,
7794,
275,
661,
354,
297,
776,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
8281,
8,
992,
14,
1685,
304,
272,
21250,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
272,
7974,
63,
602,
275,
1709,
14,
4626,
342,
272,
4132,
275,
1709,
14,
3190,
8,
5949,
12,
4596,
29,
549,
12,
2973,
29,
549,
9,
339,
1021,
6288,
26,
267,
7794,
275,
12291,
5645,
63,
602,
297,
283,
11268,
358,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
11268,
421,
199,
533,
8053,
8,
992,
14,
1685,
304,
272,
23242,
275,
1709,
14,
7624,
8,
7221,
9,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
339,
1021,
6288,
26,
267,
7794,
275,
661,
354,
297,
776,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
3240,
2660,
8,
992,
14,
1685,
304,
272,
5361,
275,
1709,
14,
25197,
342,
272,
16484,
275,
1709,
14,
3901,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
3816,
14,
505,
63,
466,
8,
277,
14,
3403,
9,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
25132,
8,
992,
14,
1685,
304,
272,
14718,
275,
1709,
14,
3190,
8,
28905,
12,
4048,
63,
354,
534,
28129,
358,
272,
5629,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
272,
13437,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
2071,
83,
737,
450,
83,
2,
450,
334,
277,
14,
22703,
12,
291,
14,
4219,
9,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
25610,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
272,
9219,
83,
275,
1709,
14,
7624,
8,
11454,
12,
4048,
63,
354,
534,
20716,
358,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
23,
14,
710,
4237,
3261,
199,
199,
2765,
23789,
31216,
4534,
402,
314,
3050,
3261,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
2366,
63,
18,
63,
2975,
63,
6490,
421,
199,
533,
6529,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
339,
1021,
6288,
26,
267,
7794,
275,
661,
354,
297,
776,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
8281,
8,
992,
14,
1685,
304,
272,
21250,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
272,
7974,
63,
602,
275,
1709,
14,
4626,
342,
272,
4132,
275,
1709,
14,
3190,
8,
5949,
12,
4596,
29,
549,
12,
2973,
29,
549,
9,
339,
1021,
6288,
26,
267,
7794,
275,
12291,
5645,
63,
602,
297,
283,
11268,
358,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
11268,
421,
199,
533,
8053,
8,
992,
14,
1685,
304,
272,
23242,
275,
1709,
14,
7624,
8,
7221,
9,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
339,
1021,
6288,
26,
267,
7794,
275,
661,
354,
297,
776,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
3240,
2660,
8,
992,
14,
1685,
304,
272,
5361,
275,
1709,
14,
25197,
342,
272,
16484,
275,
1709,
14,
3901,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
3816,
14,
505,
63,
466,
8,
277,
14,
3403,
9,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
25132,
8,
992,
14,
1685,
304,
272,
14718,
275,
1709,
14,
3190,
8,
28905,
12,
4048,
63,
354,
534,
28129,
358,
272,
5629,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
272,
13437,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
2071,
83,
737,
450,
83,
2,
450,
334,
277,
14,
22703,
12,
291,
14,
4219,
9,
421,
199,
32,
1548,
63,
18,
63,
2975,
63,
6490,
199,
533,
25610,
8,
992,
14,
1685,
304,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1960,
9,
272,
9219,
83,
275,
1709,
14,
7624,
8,
11454,
12,
4048,
63,
354,
534,
20716,
358,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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
requirements/twisted/Twisted-17.1.0/build/lib.linux-x86_64-3.5/twisted/protocols/haproxy/_exceptions.py
|
16
|
1085
|
# -*- test-case-name: twisted.protocols.haproxy.test -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
HAProxy specific exceptions.
"""
import contextlib
import sys
from twisted.python import compat
class InvalidProxyHeader(Exception):
"""
The provided PROXY protocol header is invalid.
"""
class InvalidNetworkProtocol(InvalidProxyHeader):
"""
The network protocol was not one of TCP4 TCP6 or UNKNOWN.
"""
class MissingAddressData(InvalidProxyHeader):
"""
The address data is missing or incomplete.
"""
@contextlib.contextmanager
def convertError(sourceType, targetType):
"""
Convert an error into a different error type.
@param sourceType: The type of exception that should be caught and
converted.
@type sourceType: L{Exception}
@param targetType: The type of exception to which the original should be
converted.
@type targetType: L{Exception}
"""
try:
yield None
except sourceType:
compat.reraise(targetType(), sys.exc_info()[-1])
|
mit
|
[
3,
1882,
511,
13,
2546,
13,
354,
26,
7390,
14,
16541,
14,
72,
30204,
1702,
14,
396,
1882,
199,
3,
1898,
334,
67,
9,
17078,
8449,
26640,
14,
199,
3,
1666,
5113,
367,
2436,
14,
199,
199,
624,
199,
6294,
4936,
2488,
4967,
14,
199,
624,
199,
199,
646,
15502,
199,
646,
984,
199,
199,
504,
7390,
14,
1548,
492,
8434,
421,
199,
533,
6378,
4936,
2567,
8,
1726,
304,
272,
408,
272,
710,
2741,
3611,
8195,
4113,
1406,
365,
3866,
14,
272,
408,
4388,
199,
533,
6378,
4491,
3658,
8,
3364,
4936,
2567,
304,
272,
408,
272,
710,
2784,
4113,
1990,
440,
1373,
402,
13488,
20,
13488,
22,
503,
24740,
14,
272,
408,
4388,
199,
533,
15626,
1476,
1451,
8,
3364,
4936,
2567,
304,
272,
408,
272,
710,
2287,
666,
365,
4124,
503,
17110,
14,
272,
408,
4388,
199,
32,
23464,
14,
14237,
199,
318,
3957,
547,
8,
1365,
804,
12,
1347,
804,
304,
272,
408,
272,
7905,
376,
1125,
1901,
282,
3365,
1125,
730,
14,
339,
768,
635,
1350,
804,
26,
710,
730,
402,
1919,
626,
1077,
506,
15604,
436,
267,
6702,
14,
272,
768,
466,
1350,
804,
26,
491,
91,
1726,
93,
339,
768,
635,
1347,
804,
26,
710,
730,
402,
1919,
370,
1314,
314,
3379,
1077,
506,
267,
6702,
14,
272,
768,
466,
1347,
804,
26,
491,
91,
1726,
93,
272,
408,
272,
862,
26,
267,
1995,
488,
272,
871,
1350,
804,
26,
267,
8434,
14,
20614,
8,
1375,
804,
1062,
984,
14,
2804,
63,
815,
19105,
17,
566,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
511,
13,
2546,
13,
354,
26,
7390,
14,
16541,
14,
72,
30204,
1702,
14,
396,
1882,
199,
3,
1898,
334,
67,
9,
17078,
8449,
26640,
14,
199,
3,
1666,
5113,
367,
2436,
14,
199,
199,
624,
199,
6294,
4936,
2488,
4967,
14,
199,
624,
199,
199,
646,
15502,
199,
646,
984,
199,
199,
504,
7390,
14,
1548,
492,
8434,
421,
199,
533,
6378,
4936,
2567,
8,
1726,
304,
272,
408,
272,
710,
2741,
3611,
8195,
4113,
1406,
365,
3866,
14,
272,
408,
4388,
199,
533,
6378,
4491,
3658,
8,
3364,
4936,
2567,
304,
272,
408,
272,
710,
2784,
4113,
1990,
440,
1373,
402,
13488,
20,
13488,
22,
503,
24740,
14,
272,
408,
4388,
199,
533,
15626,
1476,
1451,
8,
3364,
4936,
2567,
304,
272,
408,
272,
710,
2287,
666,
365,
4124,
503,
17110,
14,
272,
408,
4388,
199,
32,
23464,
14,
14237,
199,
318,
3957,
547,
8,
1365,
804,
12,
1347,
804,
304,
272,
408,
272,
7905,
376,
1125,
1901,
282,
3365,
1125,
730,
14,
339,
768,
635,
1350,
804,
26,
710,
730,
402,
1919,
626,
1077,
506,
15604,
436,
267,
6702,
14,
272,
768,
466,
1350,
804,
26,
491,
91,
1726,
93,
339,
768,
635,
1347,
804,
26,
710,
730,
402,
1919,
370,
1314,
314,
3379,
1077,
506,
267,
6702,
14,
272,
768,
466,
1347,
804,
26,
491,
91,
1726,
93,
272,
408,
272,
862,
26,
267,
1995,
488,
272,
871,
1350,
804,
26,
267,
8434,
14,
20614,
8,
1375,
804,
1062,
984,
14,
2804,
63,
815,
19105,
17,
566,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jetzfly/LEHome
|
lib/helper/SensorHelper.py
|
2
|
4631
|
#!/usr/bin/env python
# encoding: utf-8
# Copyright 2014 Xinyu, He <legendmohe@foxmail.com>
#
# 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 threading
import json
import time
import socket
# import urllib
# import urllib2
# import zmq
from util.Res import Res
from util.log import *
class SensorHelper:
TYPE_TEMP = "T"
TYPE_HUM = "H"
TYPE_PIR = "P"
TYPE_LUM = "L"
TYPE_ALL = "A"
def __init__(self):
self._sock = None
init_json = Res.init("init.json")
try:
self.place2ip = init_json["place"]
except Exception, e:
ERROR(e)
ERROR("invaild SensorHelper init json.")
self.place2ip = {}
self._send_lock = threading.Lock()
def get_places(self):
if self.place2ip is None:
return None
return self.place2ip.keys()
def addr_for_place(self, place):
return self.place2ip.get(place, None)
def place_for_addr(self, addr):
for place in self.place2ip:
if self.place2ip[place] == addr:
return place
return None
def get_all(self, target_addr):
return self.get_sensor_value(target_addr, SensorHelper.TYPE_ALL)
def get_temp(self, target_addr):
return self.get_sensor_value(target_addr, SensorHelper.TYPE_TEMP)
def get_humidity(self, target_addr):
return self.get_sensor_value(target_addr, SensorHelper.TYPE_HUM)
def get_pir(self, target_addr):
return self.get_sensor_value(target_addr, SensorHelper.TYPE_PIR)
def get_brightness(self, target_addr):
lig = self.get_sensor_value(target_addr, SensorHelper.TYPE_LUM)
return lig
def get_sensor_value(self, addr, cmd):
try:
addr, port = addr.split(":")
port = int(port)
except Exception, e:
ERROR(e)
ERROR("invaild place address format: %s" % addr)
rep = self.send_cmd(addr, port, cmd)
return rep
def send_cmd(self, addr, port, cmd):
if cmd is None or len(cmd) == 0:
ERROR("invaild sensor cmd.")
return
DEBUG("sending cmd to place: %s:%d %s" % (addr, port, cmd))
rep = ""
with self._send_lock:
# import pdb
# pdb.set_trace()
# if self._sock is None:
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._sock.settimeout(5)
self._sock.connect((addr, port))
try:
self._sock.send(cmd)
rep = self._sock.recv(2048)
DEBUG("place rep:" + rep)
except Exception, ex:
ERROR(ex)
ERROR("can't connect to place.")
self._sock.close()
self._sock = None
return rep
def readable(self, src, cmd_type):
if src is None or len(src) == 0:
return ""
try:
if cmd_type == SensorHelper.TYPE_TEMP:
return u"温度:%s℃" % src
elif cmd_type == SensorHelper.TYPE_HUM:
return u"湿度:%s%%" % src
elif cmd_type == SensorHelper.TYPE_PIR:
return u"是否有人:%s" % u'否' if src == "0" else u'是'
elif cmd_type == SensorHelper.TYPE_LUM:
return u"光照:%s" % src
elif cmd_type == SensorHelper.TYPE_ALL:
data = src.split(",")
ret = u"温度:%s℃, 湿度:%s%%" \
% (
data[0],
data[1],
)
# ret = u"温度:%s℃, 湿度:%s%%, 是否有人:%s, 光照:%s" \
# % (
# data[0],
# data[1],
# (u'否' if data[2] == "0" else u'是'),
# data[3]
# )
return ret
except Exception, ex:
ERROR(ex)
ERROR("invaild readable src:%s" % src)
return ""
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
2644,
26,
2774,
13,
24,
199,
3,
1898,
6927,
1323,
8952,
85,
12,
5311,
665,
10231,
573,
426,
32,
9849,
1198,
14,
957,
30,
199,
3,
221,
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,
221,
199,
3,
257,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
221,
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,
421,
199,
646,
5796,
199,
646,
2022,
199,
646,
900,
199,
646,
2838,
199,
3,
492,
4011,
199,
3,
492,
4011,
18,
199,
3,
492,
26633,
199,
504,
4884,
14,
1322,
492,
3591,
199,
504,
4884,
14,
793,
492,
627,
421,
199,
533,
18474,
4433,
26,
272,
11511,
63,
12510,
275,
298,
52,
2,
272,
11511,
63,
40,
2639,
275,
298,
40,
2,
272,
11511,
63,
2252,
50,
275,
298,
48,
2,
272,
11511,
63,
44,
2639,
275,
298,
44,
2,
272,
11511,
63,
1761,
275,
298,
33,
2,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
5096,
275,
488,
267,
4205,
63,
1001,
275,
3591,
14,
826,
480,
826,
14,
1001,
531,
267,
862,
26,
288,
291,
14,
2778,
18,
711,
275,
4205,
63,
1001,
905,
2778,
937,
267,
871,
2186,
12,
325,
26,
288,
12539,
8,
69,
9,
288,
12539,
480,
262,
3042,
668,
18474,
4433,
4205,
2022,
2685,
288,
291,
14,
2778,
18,
711,
275,
1052,
398,
291,
423,
2254,
63,
831,
275,
5796,
14,
6432,
342,
339,
347,
664,
63,
10696,
8,
277,
304,
267,
340,
291,
14,
2778,
18,
711,
365,
488,
26,
288,
372,
488,
267,
372,
291,
14,
2778,
18,
711,
14,
1612,
342,
339,
347,
5552,
63,
509,
63,
2778,
8,
277,
12,
4192,
304,
267,
372,
291,
14,
2778,
18,
711,
14,
362,
8,
2778,
12,
488,
9,
339,
347,
4192,
63,
509,
63,
2697,
8,
277,
12,
5552,
304,
267,
367,
4192,
315,
291,
14,
2778,
18,
711,
26,
288,
340,
291,
14,
2778,
18,
711,
59,
2778,
61,
508,
5552,
26,
355,
372,
4192,
267,
372,
488,
339,
347,
664,
63,
452,
8,
277,
12,
1347,
63,
2697,
304,
267,
372,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
1761,
9,
339,
347,
664,
63,
808,
8,
277,
12,
1347,
63,
2697,
304,
267,
372,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
12510,
9,
339,
347,
664,
63,
31812,
8,
277,
12,
1347,
63,
2697,
304,
267,
372,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
40,
2639,
9,
339,
347,
664,
63,
80,
723,
8,
277,
12,
1347,
63,
2697,
304,
267,
372,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
2252,
50,
9,
339,
347,
664,
63,
22298,
8,
277,
12,
1347,
63,
2697,
304,
267,
1212,
71,
275,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
44,
2639,
9,
267,
372,
1212,
71,
339,
347,
664,
63,
8956,
63,
585,
8,
277,
12,
5552,
12,
2088,
304,
267,
862,
26,
288,
5552,
12,
1844,
275,
5552,
14,
1294,
20063,
288,
1844,
275,
1109,
8,
719,
9,
267,
871,
2186,
12,
325,
26,
288,
12539,
8,
69,
9,
288,
12539,
480,
262,
3042,
668,
4192,
2287,
1475,
26,
450,
83,
2,
450,
5552,
9,
267,
1833,
275,
291,
14,
2254,
63,
1760,
8,
2697,
12,
1844,
12,
2088,
9,
267,
372,
1833,
339,
347,
3222,
63,
1760,
8,
277,
12,
5552,
12,
1844,
12,
2088,
304,
267,
340,
2088,
365,
488,
503,
822,
8,
1760,
9,
508,
378,
26,
288,
12539,
480,
262,
3042,
668,
8778,
2088,
2685,
288,
372,
267,
10990,
480,
24450,
2088,
370,
4192,
26,
450,
83,
2689,
68,
450,
83,
2,
450,
334,
2697,
12,
1844,
12,
2088,
430,
398,
1833,
275,
3087,
267,
543,
291,
423,
2254,
63,
831,
26,
288,
327,
492,
10543,
288,
327,
10543,
14,
409,
63,
3446,
342,
288,
327,
340,
291,
423,
5096,
365,
488,
26,
288,
291,
423,
5096,
275,
2838,
14,
3450,
8,
3450,
14,
5699,
63,
11367,
12,
2838,
14,
9469,
63,
9484,
9,
288,
291,
423,
5096,
14,
24630,
8,
21,
9,
288,
291,
423,
5096,
14,
2242,
1332,
2697,
12,
1844,
430,
288,
862,
26,
355,
291,
423,
5096,
14,
2254,
8,
1760,
9,
355,
1833,
275,
291,
423,
5096,
14,
7637,
8,
18343,
9,
355,
10990,
480,
2778,
1833,
5424,
435,
1833,
9,
288,
871,
2186,
12,
444,
26,
355,
12539,
8,
476,
9,
355,
12539,
480,
2425,
1133,
4907,
370,
4192,
2685,
288,
291,
423,
5096,
14,
1600,
342,
288,
291,
423,
5096,
275,
488,
267,
372,
1833,
339,
347,
12701,
8,
277,
12,
2928,
12,
2088,
63,
466,
304,
267,
340,
2928,
365,
488,
503,
822,
8,
2164,
9,
508,
378,
26,
288,
372,
3087,
267,
862,
26,
288,
340,
2088,
63,
466,
508,
18474,
4433,
14,
2711,
63,
12510,
26,
355,
372,
399,
2,
163,
117,
103,
32413,
2689,
83,
159,
227,
226,
2,
450,
2928,
288,
916,
2088,
63,
466,
508,
18474,
4433,
14,
2711,
63,
40,
2639,
26,
355,
372,
399,
2,
163,
118,
124,
32413,
2689,
83,
8530,
2,
450,
2928,
288,
916,
2088,
63,
466,
508,
18474,
4433,
14,
2711,
63,
2252,
50,
26,
355,
372,
399,
2,
9729,
8197,
100,
20916,
25196,
2689,
83,
2,
450,
399,
7,
8197,
100,
7,
340,
2928,
508,
298,
16,
2,
587,
399,
7,
9729,
7
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
2644,
26,
2774,
13,
24,
199,
3,
1898,
6927,
1323,
8952,
85,
12,
5311,
665,
10231,
573,
426,
32,
9849,
1198,
14,
957,
30,
199,
3,
221,
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,
221,
199,
3,
257,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
221,
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,
421,
199,
646,
5796,
199,
646,
2022,
199,
646,
900,
199,
646,
2838,
199,
3,
492,
4011,
199,
3,
492,
4011,
18,
199,
3,
492,
26633,
199,
504,
4884,
14,
1322,
492,
3591,
199,
504,
4884,
14,
793,
492,
627,
421,
199,
533,
18474,
4433,
26,
272,
11511,
63,
12510,
275,
298,
52,
2,
272,
11511,
63,
40,
2639,
275,
298,
40,
2,
272,
11511,
63,
2252,
50,
275,
298,
48,
2,
272,
11511,
63,
44,
2639,
275,
298,
44,
2,
272,
11511,
63,
1761,
275,
298,
33,
2,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
5096,
275,
488,
267,
4205,
63,
1001,
275,
3591,
14,
826,
480,
826,
14,
1001,
531,
267,
862,
26,
288,
291,
14,
2778,
18,
711,
275,
4205,
63,
1001,
905,
2778,
937,
267,
871,
2186,
12,
325,
26,
288,
12539,
8,
69,
9,
288,
12539,
480,
262,
3042,
668,
18474,
4433,
4205,
2022,
2685,
288,
291,
14,
2778,
18,
711,
275,
1052,
398,
291,
423,
2254,
63,
831,
275,
5796,
14,
6432,
342,
339,
347,
664,
63,
10696,
8,
277,
304,
267,
340,
291,
14,
2778,
18,
711,
365,
488,
26,
288,
372,
488,
267,
372,
291,
14,
2778,
18,
711,
14,
1612,
342,
339,
347,
5552,
63,
509,
63,
2778,
8,
277,
12,
4192,
304,
267,
372,
291,
14,
2778,
18,
711,
14,
362,
8,
2778,
12,
488,
9,
339,
347,
4192,
63,
509,
63,
2697,
8,
277,
12,
5552,
304,
267,
367,
4192,
315,
291,
14,
2778,
18,
711,
26,
288,
340,
291,
14,
2778,
18,
711,
59,
2778,
61,
508,
5552,
26,
355,
372,
4192,
267,
372,
488,
339,
347,
664,
63,
452,
8,
277,
12,
1347,
63,
2697,
304,
267,
372,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
1761,
9,
339,
347,
664,
63,
808,
8,
277,
12,
1347,
63,
2697,
304,
267,
372,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
12510,
9,
339,
347,
664,
63,
31812,
8,
277,
12,
1347,
63,
2697,
304,
267,
372,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
40,
2639,
9,
339,
347,
664,
63,
80,
723,
8,
277,
12,
1347,
63,
2697,
304,
267,
372,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
2252,
50,
9,
339,
347,
664,
63,
22298,
8,
277,
12,
1347,
63,
2697,
304,
267,
1212,
71,
275,
291,
14,
362,
63,
8956,
63,
585,
8,
1375,
63,
2697,
12,
18474,
4433,
14,
2711,
63,
44,
2639,
9,
267,
372,
1212,
71,
339,
347,
664,
63,
8956,
63,
585,
8,
277,
12,
5552,
12,
2088,
304,
267,
862,
26,
288,
5552,
12,
1844,
275,
5552,
14,
1294,
20063,
288,
1844,
275,
1109,
8,
719,
9,
267,
871,
2186,
12,
325,
26,
288,
12539,
8,
69,
9,
288,
12539,
480,
262,
3042,
668,
4192,
2287,
1475,
26,
450,
83,
2,
450,
5552,
9,
267,
1833,
275,
291,
14,
2254,
63,
1760,
8,
2697,
12,
1844,
12,
2088,
9,
267,
372,
1833,
339,
347,
3222,
63,
1760,
8,
277,
12,
5552,
12,
1844,
12,
2088,
304,
267,
340,
2088,
365,
488,
503,
822,
8,
1760,
9,
508,
378,
26,
288,
12539,
480,
262,
3042,
668,
8778,
2088,
2685,
288,
372,
267,
10990,
480,
24450,
2088,
370,
4192,
26,
450,
83,
2689,
68,
450,
83,
2,
450,
334,
2697,
12,
1844,
12,
2088,
430,
398,
1833,
275,
3087,
267,
543,
291,
423,
2254,
63,
831,
26,
288,
327,
492,
10543,
288,
327,
10543,
14,
409,
63,
3446,
342,
288,
327,
340,
291,
423,
5096,
365,
488,
26,
288,
291,
423,
5096,
275,
2838,
14,
3450,
8,
3450,
14,
5699,
63,
11367,
12,
2838,
14,
9469,
63,
9484,
9,
288,
291,
423,
5096,
14,
24630,
8,
21,
9,
288,
291,
423,
5096,
14,
2242,
1332,
2697,
12,
1844,
430,
288,
862,
26,
355,
291,
423,
5096,
14,
2254,
8,
1760,
9,
355,
1833,
275,
291,
423,
5096,
14,
7637,
8,
18343,
9,
355,
10990,
480,
2778,
1833,
5424,
435,
1833,
9,
288,
871,
2186,
12,
444,
26,
355,
12539,
8,
476,
9,
355,
12539,
480,
2425,
1133,
4907,
370,
4192,
2685,
288,
291,
423,
5096,
14,
1600,
342,
288,
291,
423,
5096,
275,
488,
267,
372,
1833,
339,
347,
12701,
8,
277,
12,
2928,
12,
2088,
63,
466,
304,
267,
340,
2928,
365,
488,
503,
822,
8,
2164,
9,
508,
378,
26,
288,
372,
3087,
267,
862,
26,
288,
340,
2088,
63,
466,
508,
18474,
4433,
14,
2711,
63,
12510,
26,
355,
372,
399,
2,
163,
117,
103,
32413,
2689,
83,
159,
227,
226,
2,
450,
2928,
288,
916,
2088,
63,
466,
508,
18474,
4433,
14,
2711,
63,
40,
2639,
26,
355,
372,
399,
2,
163,
118,
124,
32413,
2689,
83,
8530,
2,
450,
2928,
288,
916,
2088,
63,
466,
508,
18474,
4433,
14,
2711,
63,
2252,
50,
26,
355,
372,
399,
2,
9729,
8197,
100,
20916,
25196,
2689,
83,
2,
450,
399,
7,
8197,
100,
7,
340,
2928,
508,
298,
16,
2,
587,
399,
7,
9729,
7,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
mykytamorachov/outpost
|
flask/lib/python2.7/site-packages/sqlalchemy/sql/operators.py
|
17
|
15743
|
# sql/operators.py
# Copyright (C) 2005-2012 the SQLAlchemy authors and contributors <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""Defines operators used in SQL expressions."""
from operator import (
and_, or_, inv, add, mul, sub, mod, truediv, lt, le, ne, gt, ge, eq, neg
)
# Py2K
from operator import (div,)
# end Py2K
from sqlalchemy.util import symbol
class Operators(object):
"""Base of comparison and logical operators.
Implements base methods :meth:`operate` and :meth:`reverse_operate`,
as well as :meth:`__and__`, :meth:`__or__`, :meth:`__invert__`.
Usually is used via its most common subclass
:class:`.ColumnOperators`.
"""
def __and__(self, other):
"""Implement the ``&`` operator.
When used with SQL expressions, results in an
AND operation, equivalent to
:func:`~.expression.and_`, that is::
a & b
is equivalent to::
from sqlalchemy import and_
and_(a, b)
Care should be taken when using ``&`` regarding
operator precedence; the ``&`` operator has the highest precedence.
The operands should be enclosed in parenthesis if they contain
further sub expressions::
(a == 2) & (b == 4)
"""
return self.operate(and_, other)
def __or__(self, other):
"""Implement the ``|`` operator.
When used with SQL expressions, results in an
OR operation, equivalent to
:func:`~.expression.or_`, that is::
a | b
is equivalent to::
from sqlalchemy import or_
or_(a, b)
Care should be taken when using ``|`` regarding
operator precedence; the ``|`` operator has the highest precedence.
The operands should be enclosed in parenthesis if they contain
further sub expressions::
(a == 2) | (b == 4)
"""
return self.operate(or_, other)
def __invert__(self):
"""Implement the ``~`` operator.
When used with SQL expressions, results in a
NOT operation, equivalent to
:func:`~.expression.not_`, that is::
~a
is equivalent to::
from sqlalchemy import not_
not_(a)
"""
return self.operate(inv)
def op(self, opstring):
"""produce a generic operator function.
e.g.::
somecolumn.op("*")(5)
produces::
somecolumn * 5
:param operator: a string which will be output as the infix operator
between this :class:`.ClauseElement` and the expression passed to the
generated function.
This function can also be used to make bitwise operators explicit. For
example::
somecolumn.op('&')(0xff)
is a bitwise AND of the value in somecolumn.
"""
def _op(b):
return self.operate(op, opstring, b)
return _op
def operate(self, op, *other, **kwargs):
"""Operate on an argument.
This is the lowest level of operation, raises
:class:`NotImplementedError` by default.
Overriding this on a subclass can allow common
behavior to be applied to all operations.
For example, overriding :class:`.ColumnOperators`
to apply ``func.lower()`` to the left and right
side::
class MyComparator(ColumnOperators):
def operate(self, op, other):
return op(func.lower(self), func.lower(other))
:param op: Operator callable.
:param \*other: the 'other' side of the operation. Will
be a single scalar for most operations.
:param \**kwargs: modifiers. These may be passed by special
operators such as :meth:`ColumnOperators.contains`.
"""
raise NotImplementedError(str(op))
def reverse_operate(self, op, other, **kwargs):
"""Reverse operate on an argument.
Usage is the same as :meth:`operate`.
"""
raise NotImplementedError(str(op))
class ColumnOperators(Operators):
"""Defines comparison and math operations.
By default all methods call down to
:meth:`Operators.operate` or :meth:`Operators.reverse_operate`
passing in the appropriate operator function from the
Python builtin ``operator`` module or
a SQLAlchemy-specific operator function from
:mod:`sqlalchemy.expression.operators`. For example
the ``__eq__`` function::
def __eq__(self, other):
return self.operate(operators.eq, other)
Where ``operators.eq`` is essentially::
def eq(a, b):
return a == b
A SQLAlchemy construct like :class:`.ColumnElement` ultimately
overrides :meth:`.Operators.operate` and others
to return further :class:`.ClauseElement` constructs,
so that the ``==`` operation above is replaced by a clause
construct.
The docstrings here will describe column-oriented
behavior of each operator. For ORM-based operators
on related objects and collections, see :class:`.RelationshipProperty.Comparator`.
"""
timetuple = None
"""Hack, allows datetime objects to be compared on the LHS."""
def __lt__(self, other):
"""Implement the ``<`` operator.
In a column context, produces the clause ``a < b``.
"""
return self.operate(lt, other)
def __le__(self, other):
"""Implement the ``<=`` operator.
In a column context, produces the clause ``a <= b``.
"""
return self.operate(le, other)
__hash__ = Operators.__hash__
def __eq__(self, other):
"""Implement the ``==`` operator.
In a column context, produces the clause ``a = b``.
If the target is ``None``, produces ``a IS NULL``.
"""
return self.operate(eq, other)
def __ne__(self, other):
"""Implement the ``!=`` operator.
In a column context, produces the clause ``a != b``.
If the target is ``None``, produces ``a IS NOT NULL``.
"""
return self.operate(ne, other)
def __gt__(self, other):
"""Implement the ``>`` operator.
In a column context, produces the clause ``a > b``.
"""
return self.operate(gt, other)
def __ge__(self, other):
"""Implement the ``>=`` operator.
In a column context, produces the clause ``a >= b``.
"""
return self.operate(ge, other)
def __neg__(self):
"""Implement the ``-`` operator.
In a column context, produces the clause ``-a``.
"""
return self.operate(neg)
def concat(self, other):
"""Implement the 'concat' operator.
In a column context, produces the clause ``a || b``,
or uses the ``concat()`` operator on MySQL.
"""
return self.operate(concat_op, other)
def like(self, other, escape=None):
"""Implement the ``like`` operator.
In a column context, produces the clause ``a LIKE other``.
"""
return self.operate(like_op, other, escape=escape)
def ilike(self, other, escape=None):
"""Implement the ``ilike`` operator.
In a column context, produces the clause ``a ILIKE other``.
"""
return self.operate(ilike_op, other, escape=escape)
def in_(self, other):
"""Implement the ``in`` operator.
In a column context, produces the clause ``a IN other``.
"other" may be a tuple/list of column expressions,
or a :func:`~.expression.select` construct.
"""
return self.operate(in_op, other)
def is_(self, other):
"""Implement the ``IS`` operator.
Normally, ``IS`` is generated automatically when comparing to a
value of ``None``, which resolves to ``NULL``. However, explicit
usage of ``IS`` may be desirable if comparing to boolean values
on certain platforms.
.. versionadded:: 0.7.9
.. seealso:: :meth:`.ColumnOperators.isnot`
"""
return self.operate(is_, other)
def isnot(self, other):
"""Implement the ``IS NOT`` operator.
Normally, ``IS NOT`` is generated automatically when comparing to a
value of ``None``, which resolves to ``NULL``. However, explicit
usage of ``IS NOT`` may be desirable if comparing to boolean values
on certain platforms.
.. versionadded:: 0.7.9
.. seealso:: :meth:`.ColumnOperators.is_`
"""
return self.operate(isnot, other)
def startswith(self, other, **kwargs):
"""Implement the ``startwith`` operator.
In a column context, produces the clause ``LIKE '<other>%'``
"""
return self.operate(startswith_op, other, **kwargs)
def endswith(self, other, **kwargs):
"""Implement the 'endswith' operator.
In a column context, produces the clause ``LIKE '%<other>'``
"""
return self.operate(endswith_op, other, **kwargs)
def contains(self, other, **kwargs):
"""Implement the 'contains' operator.
In a column context, produces the clause ``LIKE '%<other>%'``
"""
return self.operate(contains_op, other, **kwargs)
def match(self, other, **kwargs):
"""Implements the 'match' operator.
In a column context, this produces a MATCH clause, i.e.
``MATCH '<other>'``. The allowed contents of ``other``
are database backend specific.
"""
return self.operate(match_op, other, **kwargs)
def desc(self):
"""Produce a :func:`~.expression.desc` clause against the
parent object."""
return self.operate(desc_op)
def asc(self):
"""Produce a :func:`~.expression.asc` clause against the
parent object."""
return self.operate(asc_op)
def nullsfirst(self):
"""Produce a :func:`~.expression.nullsfirst` clause against the
parent object."""
return self.operate(nullsfirst_op)
def nullslast(self):
"""Produce a :func:`~.expression.nullslast` clause against the
parent object."""
return self.operate(nullslast_op)
def collate(self, collation):
"""Produce a :func:`~.expression.collate` clause against
the parent object, given the collation string."""
return self.operate(collate, collation)
def __radd__(self, other):
"""Implement the ``+`` operator in reverse.
See :meth:`__add__`.
"""
return self.reverse_operate(add, other)
def __rsub__(self, other):
"""Implement the ``-`` operator in reverse.
See :meth:`__sub__`.
"""
return self.reverse_operate(sub, other)
def __rmul__(self, other):
"""Implement the ``*`` operator in reverse.
See :meth:`__mul__`.
"""
return self.reverse_operate(mul, other)
def __rdiv__(self, other):
"""Implement the ``/`` operator in reverse.
See :meth:`__div__`.
"""
return self.reverse_operate(div, other)
def between(self, cleft, cright):
"""Produce a :func:`~.expression.between` clause against
the parent object, given the lower and upper range."""
return self.operate(between_op, cleft, cright)
def distinct(self):
"""Produce a :func:`~.expression.distinct` clause against the parent object."""
return self.operate(distinct_op)
def __add__(self, other):
"""Implement the ``+`` operator.
In a column context, produces the clause ``a + b``
if the parent object has non-string affinity.
If the parent object has a string affinity,
produces the concatenation operator, ``a || b`` -
see :meth:`concat`.
"""
return self.operate(add, other)
def __sub__(self, other):
"""Implement the ``-`` operator.
In a column context, produces the clause ``a - b``.
"""
return self.operate(sub, other)
def __mul__(self, other):
"""Implement the ``*`` operator.
In a column context, produces the clause ``a * b``.
"""
return self.operate(mul, other)
def __div__(self, other):
"""Implement the ``/`` operator.
In a column context, produces the clause ``a / b``.
"""
return self.operate(div, other)
def __mod__(self, other):
"""Implement the ``%`` operator.
In a column context, produces the clause ``a % b``.
"""
return self.operate(mod, other)
def __truediv__(self, other):
"""Implement the ``//`` operator.
In a column context, produces the clause ``a / b``.
"""
return self.operate(truediv, other)
def __rtruediv__(self, other):
"""Implement the ``//`` operator in reverse.
See :meth:`__truediv__`.
"""
return self.reverse_operate(truediv, other)
def from_():
raise NotImplementedError()
def as_():
raise NotImplementedError()
def exists():
raise NotImplementedError()
def is_(a, b):
return a.is_(b)
def isnot(a, b):
return a.isnot(b)
def collate(a, b):
return a.collate(b)
def op(a, opstring, b):
return a.op(opstring)(b)
def like_op(a, b, escape=None):
return a.like(b, escape=escape)
def notlike_op(a, b, escape=None):
return ~a.like(b, escape=escape)
def ilike_op(a, b, escape=None):
return a.ilike(b, escape=escape)
def notilike_op(a, b, escape=None):
return ~a.ilike(b, escape=escape)
def between_op(a, b, c):
return a.between(b, c)
def in_op(a, b):
return a.in_(b)
def notin_op(a, b):
return ~a.in_(b)
def distinct_op(a):
return a.distinct()
def startswith_op(a, b, escape=None):
return a.startswith(b, escape=escape)
def endswith_op(a, b, escape=None):
return a.endswith(b, escape=escape)
def contains_op(a, b, escape=None):
return a.contains(b, escape=escape)
def match_op(a, b):
return a.match(b)
def comma_op(a, b):
raise NotImplementedError()
def concat_op(a, b):
return a.concat(b)
def desc_op(a):
return a.desc()
def asc_op(a):
return a.asc()
def nullsfirst_op(a):
return a.nullsfirst()
def nullslast_op(a):
return a.nullslast()
_commutative = set([eq, ne, add, mul])
def is_commutative(op):
return op in _commutative
def is_ordering_modifier(op):
return op in (asc_op, desc_op,
nullsfirst_op, nullslast_op)
_associative = _commutative.union([concat_op, and_, or_])
_smallest = symbol('_smallest')
_largest = symbol('_largest')
_PRECEDENCE = {
from_: 15,
mul: 7,
truediv: 7,
# Py2K
div: 7,
# end Py2K
mod: 7,
neg: 7,
add: 6,
sub: 6,
concat_op: 6,
match_op: 6,
ilike_op: 5,
notilike_op: 5,
like_op: 5,
notlike_op: 5,
in_op: 5,
notin_op: 5,
is_: 5,
isnot: 5,
eq: 5,
ne: 5,
gt: 5,
lt: 5,
ge: 5,
le: 5,
between_op: 5,
distinct_op: 5,
inv: 5,
and_: 3,
or_: 2,
comma_op: -1,
collate: 7,
as_: -1,
exists: 0,
_smallest: -1000,
_largest: 1000
}
def is_precedent(operator, against):
if operator is against and operator in _associative:
return False
else:
return (_PRECEDENCE.get(operator, _PRECEDENCE[_smallest]) <=
_PRECEDENCE.get(against, _PRECEDENCE[_largest]))
|
gpl-2.0
|
[
3,
3875,
15,
12688,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
7409,
314,
14303,
11462,
436,
8417,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
23891,
10211,
1202,
315,
5385,
8455,
1041,
199,
199,
504,
4182,
492,
334,
272,
436,
3131,
503,
3131,
4572,
12,
1050,
12,
19207,
12,
1007,
12,
3413,
12,
2549,
3015,
12,
22146,
12,
1026,
12,
1279,
12,
16484,
12,
2312,
12,
3850,
12,
14158,
272,
776,
199,
199,
3,
1611,
18,
43,
199,
504,
4182,
492,
334,
3015,
4258,
199,
3,
1284,
1611,
18,
43,
199,
199,
504,
8335,
14,
1974,
492,
5272,
199,
199,
533,
6654,
2750,
8,
785,
304,
272,
408,
1563,
402,
9132,
436,
11461,
10211,
14,
339,
24664,
1300,
3102,
520,
5247,
1705,
2262,
323,
64,
436,
520,
5247,
1705,
4471,
63,
2262,
323,
3559,
272,
465,
5521,
465,
520,
5247,
1705,
363,
460,
363,
3559,
520,
5247,
1705,
363,
269,
363,
3559,
520,
5247,
1705,
363,
18957,
363,
2313,
339,
24612,
365,
1202,
4799,
2399,
4750,
2863,
5516,
272,
520,
533,
5026,
4547,
3632,
2750,
2313,
339,
408,
272,
347,
636,
460,
721,
277,
12,
1163,
304,
267,
408,
26924,
314,
1124,
6,
1040,
4182,
14,
398,
3979,
1202,
543,
5385,
8455,
12,
2058,
315,
376,
267,
2401,
3439,
12,
7353,
370,
267,
520,
1532,
18739,
5599,
14,
460,
63,
3559,
626,
365,
447,
953,
282,
1253,
330,
398,
365,
7353,
370,
447,
953,
687,
8335,
492,
436,
63,
288,
436,
2531,
65,
12,
330,
9,
398,
445,
1530,
1077,
506,
9394,
1380,
1808,
1124,
6,
1040,
12602,
267,
4182,
13823,
27,
314,
1124,
6,
1040,
4182,
965,
314,
15356,
13823,
14,
267,
710,
15163,
1077,
506,
27828,
315,
32002,
340,
2985,
1395,
267,
9848,
1007,
8455,
447,
953,
334,
65,
508,
499,
9,
1253,
334,
66,
508,
841,
9,
398,
408,
267,
372,
291,
14,
2262,
323,
8,
460,
3131,
1163,
9,
339,
347,
636,
269,
721,
277,
12,
1163,
304,
267,
408,
26924,
314,
1124,
92,
1040,
4182,
14,
398,
3979,
1202,
543,
5385,
8455,
12,
2058,
315,
376,
267,
1549,
3439,
12,
7353,
370,
267,
520,
1532,
18739,
5599,
14,
269,
63,
3559,
626,
365,
447,
953,
282,
1204,
330,
398,
365,
7353,
370,
447,
953,
687,
8335,
492,
503,
63,
288,
503,
2531,
65,
12,
330,
9,
398,
445,
1530,
1077,
506,
9394,
1380,
1808,
1124,
92,
1040,
12602,
267,
4182,
13823,
27,
314,
1124,
92,
1040,
4182,
965,
314,
15356,
13823,
14,
267,
710,
15163,
1077,
506,
27828,
315,
32002,
340,
2985,
1395,
267,
9848,
1007,
8455,
447,
953,
334,
65,
508,
499,
9,
1204,
334,
66,
508,
841,
9,
398,
408,
267,
372,
291,
14,
2262,
323,
8,
269,
3131,
1163,
9,
339,
347,
636,
18957,
721,
277,
304,
267,
408,
26924,
314,
1124,
94,
1040,
4182,
14,
398,
3979,
1202,
543,
5385,
8455,
12,
2058,
315,
282,
267,
2845,
3439,
12,
7353,
370,
267,
520,
1532,
18739,
5599,
14,
1397,
63,
3559,
626,
365,
447,
953,
6146,
65,
398,
365,
7353,
370,
447,
953,
687,
8335,
492,
440,
63,
288,
440,
2531,
65,
9,
398,
408,
267,
372,
291,
14,
2262,
323,
8,
5350,
9,
339,
347,
1687,
8,
277,
12,
1687,
875,
304,
267,
408,
7832,
282,
7809,
4182,
805,
14,
398,
325,
14,
71,
28383,
8592,
2005,
2301,
14,
411,
23124,
25232,
21,
9,
398,
16904,
447,
8592,
2005,
2301,
627,
959,
398,
520,
635,
4182,
26,
282,
1059,
1314,
911,
506,
1072,
465,
314,
315,
970,
4182,
881,
3382,
642,
520,
533,
5026,
16009,
2162,
64,
436,
314,
3965,
3032,
370,
314,
881,
4046,
805,
14,
398,
961,
805,
883,
2597,
506,
1202,
370,
1852,
31927,
10211,
5027,
14,
2104,
267,
2893,
447,
8592,
2005,
2301,
14,
411,
20040,
7533,
16,
3581,
9,
398,
365,
282,
31927,
2401,
402,
314,
574,
315,
2005,
2301,
14,
398,
408,
267,
347,
485,
411,
8,
66,
304,
288,
372,
291,
14,
2262,
323,
8,
411,
12,
1687,
875,
12,
330,
9,
267,
372,
485,
411,
339,
347,
19218,
8,
277,
12,
1687,
12,
627,
1848,
12,
1011,
958,
304,
267,
408,
3632,
323,
641,
376,
1423,
14,
398,
961,
365,
314,
18966,
2166,
402,
3439,
12,
6534,
267,
520,
533,
1705,
18097,
64,
701,
849,
14,
398,
7259,
15526,
642,
641,
282,
5516,
883,
2040,
2863,
267,
5953,
370,
506,
6781,
370,
1006,
5331,
14,
267,
2104,
2893,
12,
18972,
520,
533,
5026,
4547,
3632,
2750,
64,
267,
370,
4838,
1124,
1532,
14,
2325,
8497,
370,
314,
3602,
436,
2451,
267,
5366,
447,
953,
1021,
4932,
26636,
8,
4547,
3632,
2750,
304,
355,
347,
19218,
8,
277,
12,
1687,
12,
1163,
304,
490,
372,
1687,
8,
1532,
14,
2325,
8,
277,
395,
2562,
14,
2325,
8,
1848,
430,
398,
520,
635,
1687,
26,
221,
11013,
4550,
14,
267,
520,
635,
971,
10,
1848,
26,
314,
283,
1848,
7,
5366,
402,
314,
3439,
14,
12823,
268,
506,
282,
2849,
6917,
367,
4750,
5331,
14,
267,
520,
635,
971,
538,
958,
26,
9933,
14,
221,
5723,
1443,
506,
3032,
701,
4539,
268,
10211,
4066,
465,
520,
5247,
1705,
4547,
3632,
2750,
14,
6134,
2313,
7318,
408,
267,
746,
4279,
8,
495,
8,
411,
430,
339,
347,
3837,
63,
2262,
323,
8,
277,
12,
1687,
12,
1163,
12,
1011,
958,
304,
267,
408,
14987,
19218,
641,
376,
1423,
14,
398,
11028,
365,
314,
2011,
465,
520,
5247,
1705,
2262,
323,
2313,
398,
408,
267,
746,
4279,
8,
495,
8,
411,
430,
199,
199,
533,
4996,
3632,
2750,
8,
3632,
2750,
304,
272,
408,
23891,
9132,
436,
3473,
5331,
14,
339,
4885,
849,
1006,
3102,
1240,
3224,
370,
272,
520,
5247,
1705,
3632,
2750,
14,
2262,
323,
64,
503,
520,
5247,
1705,
3632,
2750,
14,
4471,
63,
2262,
323
] |
[
3875,
15,
12688,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
7409,
314,
14303,
11462,
436,
8417,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
23891,
10211,
1202,
315,
5385,
8455,
1041,
199,
199,
504,
4182,
492,
334,
272,
436,
3131,
503,
3131,
4572,
12,
1050,
12,
19207,
12,
1007,
12,
3413,
12,
2549,
3015,
12,
22146,
12,
1026,
12,
1279,
12,
16484,
12,
2312,
12,
3850,
12,
14158,
272,
776,
199,
199,
3,
1611,
18,
43,
199,
504,
4182,
492,
334,
3015,
4258,
199,
3,
1284,
1611,
18,
43,
199,
199,
504,
8335,
14,
1974,
492,
5272,
199,
199,
533,
6654,
2750,
8,
785,
304,
272,
408,
1563,
402,
9132,
436,
11461,
10211,
14,
339,
24664,
1300,
3102,
520,
5247,
1705,
2262,
323,
64,
436,
520,
5247,
1705,
4471,
63,
2262,
323,
3559,
272,
465,
5521,
465,
520,
5247,
1705,
363,
460,
363,
3559,
520,
5247,
1705,
363,
269,
363,
3559,
520,
5247,
1705,
363,
18957,
363,
2313,
339,
24612,
365,
1202,
4799,
2399,
4750,
2863,
5516,
272,
520,
533,
5026,
4547,
3632,
2750,
2313,
339,
408,
272,
347,
636,
460,
721,
277,
12,
1163,
304,
267,
408,
26924,
314,
1124,
6,
1040,
4182,
14,
398,
3979,
1202,
543,
5385,
8455,
12,
2058,
315,
376,
267,
2401,
3439,
12,
7353,
370,
267,
520,
1532,
18739,
5599,
14,
460,
63,
3559,
626,
365,
447,
953,
282,
1253,
330,
398,
365,
7353,
370,
447,
953,
687,
8335,
492,
436,
63,
288,
436,
2531,
65,
12,
330,
9,
398,
445,
1530,
1077,
506,
9394,
1380,
1808,
1124,
6,
1040,
12602,
267,
4182,
13823,
27,
314,
1124,
6,
1040,
4182,
965,
314,
15356,
13823,
14,
267,
710,
15163,
1077,
506,
27828,
315,
32002,
340,
2985,
1395,
267,
9848,
1007,
8455,
447,
953,
334,
65,
508,
499,
9,
1253,
334,
66,
508,
841,
9,
398,
408,
267,
372,
291,
14,
2262,
323,
8,
460,
3131,
1163,
9,
339,
347,
636,
269,
721,
277,
12,
1163,
304,
267,
408,
26924,
314,
1124,
92,
1040,
4182,
14,
398,
3979,
1202,
543,
5385,
8455,
12,
2058,
315,
376,
267,
1549,
3439,
12,
7353,
370,
267,
520,
1532,
18739,
5599,
14,
269,
63,
3559,
626,
365,
447,
953,
282,
1204,
330,
398,
365,
7353,
370,
447,
953,
687,
8335,
492,
503,
63,
288,
503,
2531,
65,
12,
330,
9,
398,
445,
1530,
1077,
506,
9394,
1380,
1808,
1124,
92,
1040,
12602,
267,
4182,
13823,
27,
314,
1124,
92,
1040,
4182,
965,
314,
15356,
13823,
14,
267,
710,
15163,
1077,
506,
27828,
315,
32002,
340,
2985,
1395,
267,
9848,
1007,
8455,
447,
953,
334,
65,
508,
499,
9,
1204,
334,
66,
508,
841,
9,
398,
408,
267,
372,
291,
14,
2262,
323,
8,
269,
3131,
1163,
9,
339,
347,
636,
18957,
721,
277,
304,
267,
408,
26924,
314,
1124,
94,
1040,
4182,
14,
398,
3979,
1202,
543,
5385,
8455,
12,
2058,
315,
282,
267,
2845,
3439,
12,
7353,
370,
267,
520,
1532,
18739,
5599,
14,
1397,
63,
3559,
626,
365,
447,
953,
6146,
65,
398,
365,
7353,
370,
447,
953,
687,
8335,
492,
440,
63,
288,
440,
2531,
65,
9,
398,
408,
267,
372,
291,
14,
2262,
323,
8,
5350,
9,
339,
347,
1687,
8,
277,
12,
1687,
875,
304,
267,
408,
7832,
282,
7809,
4182,
805,
14,
398,
325,
14,
71,
28383,
8592,
2005,
2301,
14,
411,
23124,
25232,
21,
9,
398,
16904,
447,
8592,
2005,
2301,
627,
959,
398,
520,
635,
4182,
26,
282,
1059,
1314,
911,
506,
1072,
465,
314,
315,
970,
4182,
881,
3382,
642,
520,
533,
5026,
16009,
2162,
64,
436,
314,
3965,
3032,
370,
314,
881,
4046,
805,
14,
398,
961,
805,
883,
2597,
506,
1202,
370,
1852,
31927,
10211,
5027,
14,
2104,
267,
2893,
447,
8592,
2005,
2301,
14,
411,
20040,
7533,
16,
3581,
9,
398,
365,
282,
31927,
2401,
402,
314,
574,
315,
2005,
2301,
14,
398,
408,
267,
347,
485,
411,
8,
66,
304,
288,
372,
291,
14,
2262,
323,
8,
411,
12,
1687,
875,
12,
330,
9,
267,
372,
485,
411,
339,
347,
19218,
8,
277,
12,
1687,
12,
627,
1848,
12,
1011,
958,
304,
267,
408,
3632,
323,
641,
376,
1423,
14,
398,
961,
365,
314,
18966,
2166,
402,
3439,
12,
6534,
267,
520,
533,
1705,
18097,
64,
701,
849,
14,
398,
7259,
15526,
642,
641,
282,
5516,
883,
2040,
2863,
267,
5953,
370,
506,
6781,
370,
1006,
5331,
14,
267,
2104,
2893,
12,
18972,
520,
533,
5026,
4547,
3632,
2750,
64,
267,
370,
4838,
1124,
1532,
14,
2325,
8497,
370,
314,
3602,
436,
2451,
267,
5366,
447,
953,
1021,
4932,
26636,
8,
4547,
3632,
2750,
304,
355,
347,
19218,
8,
277,
12,
1687,
12,
1163,
304,
490,
372,
1687,
8,
1532,
14,
2325,
8,
277,
395,
2562,
14,
2325,
8,
1848,
430,
398,
520,
635,
1687,
26,
221,
11013,
4550,
14,
267,
520,
635,
971,
10,
1848,
26,
314,
283,
1848,
7,
5366,
402,
314,
3439,
14,
12823,
268,
506,
282,
2849,
6917,
367,
4750,
5331,
14,
267,
520,
635,
971,
538,
958,
26,
9933,
14,
221,
5723,
1443,
506,
3032,
701,
4539,
268,
10211,
4066,
465,
520,
5247,
1705,
4547,
3632,
2750,
14,
6134,
2313,
7318,
408,
267,
746,
4279,
8,
495,
8,
411,
430,
339,
347,
3837,
63,
2262,
323,
8,
277,
12,
1687,
12,
1163,
12,
1011,
958,
304,
267,
408,
14987,
19218,
641,
376,
1423,
14,
398,
11028,
365,
314,
2011,
465,
520,
5247,
1705,
2262,
323,
2313,
398,
408,
267,
746,
4279,
8,
495,
8,
411,
430,
199,
199,
533,
4996,
3632,
2750,
8,
3632,
2750,
304,
272,
408,
23891,
9132,
436,
3473,
5331,
14,
339,
4885,
849,
1006,
3102,
1240,
3224,
370,
272,
520,
5247,
1705,
3632,
2750,
14,
2262,
323,
64,
503,
520,
5247,
1705,
3632,
2750,
14,
4471,
63,
2262,
323,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jrcarney/drupal8_site_one
|
node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py
|
1361
|
45045
|
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
r"""Code to validate and convert settings of the Microsoft build tools.
This file contains code to validate and convert settings of the Microsoft
build tools. The function ConvertToMSBuildSettings(), ValidateMSVSSettings(),
and ValidateMSBuildSettings() are the entry points.
This file was created by comparing the projects created by Visual Studio 2008
and Visual Studio 2010 for all available settings through the user interface.
The MSBuild schemas were also considered. They are typically found in the
MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
"""
import sys
import re
# Dictionaries of settings validators. The key is the tool name, the value is
# a dictionary mapping setting names to validation functions.
_msvs_validators = {}
_msbuild_validators = {}
# A dictionary of settings converters. The key is the tool name, the value is
# a dictionary mapping setting names to conversion functions.
_msvs_to_msbuild_converters = {}
# Tool name mapping from MSVS to MSBuild.
_msbuild_name_of_tool = {}
class _Tool(object):
"""Represents a tool used by MSVS or MSBuild.
Attributes:
msvs_name: The name of the tool in MSVS.
msbuild_name: The name of the tool in MSBuild.
"""
def __init__(self, msvs_name, msbuild_name):
self.msvs_name = msvs_name
self.msbuild_name = msbuild_name
def _AddTool(tool):
"""Adds a tool to the four dictionaries used to process settings.
This only defines the tool. Each setting also needs to be added.
Args:
tool: The _Tool object to be added.
"""
_msvs_validators[tool.msvs_name] = {}
_msbuild_validators[tool.msbuild_name] = {}
_msvs_to_msbuild_converters[tool.msvs_name] = {}
_msbuild_name_of_tool[tool.msvs_name] = tool.msbuild_name
def _GetMSBuildToolSettings(msbuild_settings, tool):
"""Returns an MSBuild tool dictionary. Creates it if needed."""
return msbuild_settings.setdefault(tool.msbuild_name, {})
class _Type(object):
"""Type of settings (Base class)."""
def ValidateMSVS(self, value):
"""Verifies that the value is legal for MSVS.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSVS.
"""
def ValidateMSBuild(self, value):
"""Verifies that the value is legal for MSBuild.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSBuild.
"""
def ConvertToMSBuild(self, value):
"""Returns the MSBuild equivalent of the MSVS value given.
Args:
value: the MSVS value to convert.
Returns:
the MSBuild equivalent.
Raises:
ValueError if value is not valid.
"""
return value
class _String(_Type):
"""A setting that's just a string."""
def ValidateMSVS(self, value):
if not isinstance(value, basestring):
raise ValueError('expected string; got %r' % value)
def ValidateMSBuild(self, value):
if not isinstance(value, basestring):
raise ValueError('expected string; got %r' % value)
def ConvertToMSBuild(self, value):
# Convert the macros
return ConvertVCMacrosToMSBuild(value)
class _StringList(_Type):
"""A settings that's a list of strings."""
def ValidateMSVS(self, value):
if not isinstance(value, basestring) and not isinstance(value, list):
raise ValueError('expected string list; got %r' % value)
def ValidateMSBuild(self, value):
if not isinstance(value, basestring) and not isinstance(value, list):
raise ValueError('expected string list; got %r' % value)
def ConvertToMSBuild(self, value):
# Convert the macros
if isinstance(value, list):
return [ConvertVCMacrosToMSBuild(i) for i in value]
else:
return ConvertVCMacrosToMSBuild(value)
class _Boolean(_Type):
"""Boolean settings, can have the values 'false' or 'true'."""
def _Validate(self, value):
if value != 'true' and value != 'false':
raise ValueError('expected bool; got %r' % value)
def ValidateMSVS(self, value):
self._Validate(value)
def ValidateMSBuild(self, value):
self._Validate(value)
def ConvertToMSBuild(self, value):
self._Validate(value)
return value
class _Integer(_Type):
"""Integer settings."""
def __init__(self, msbuild_base=10):
_Type.__init__(self)
self._msbuild_base = msbuild_base
def ValidateMSVS(self, value):
# Try to convert, this will raise ValueError if invalid.
self.ConvertToMSBuild(value)
def ValidateMSBuild(self, value):
# Try to convert, this will raise ValueError if invalid.
int(value, self._msbuild_base)
def ConvertToMSBuild(self, value):
msbuild_format = (self._msbuild_base == 10) and '%d' or '0x%04x'
return msbuild_format % int(value)
class _Enumeration(_Type):
"""Type of settings that is an enumeration.
In MSVS, the values are indexes like '0', '1', and '2'.
MSBuild uses text labels that are more representative, like 'Win32'.
Constructor args:
label_list: an array of MSBuild labels that correspond to the MSVS index.
In the rare cases where MSVS has skipped an index value, None is
used in the array to indicate the unused spot.
new: an array of labels that are new to MSBuild.
"""
def __init__(self, label_list, new=None):
_Type.__init__(self)
self._label_list = label_list
self._msbuild_values = set(value for value in label_list
if value is not None)
if new is not None:
self._msbuild_values.update(new)
def ValidateMSVS(self, value):
# Try to convert. It will raise an exception if not valid.
self.ConvertToMSBuild(value)
def ValidateMSBuild(self, value):
if value not in self._msbuild_values:
raise ValueError('unrecognized enumerated value %s' % value)
def ConvertToMSBuild(self, value):
index = int(value)
if index < 0 or index >= len(self._label_list):
raise ValueError('index value (%d) not in expected range [0, %d)' %
(index, len(self._label_list)))
label = self._label_list[index]
if label is None:
raise ValueError('converted value for %s not specified.' % value)
return label
# Instantiate the various generic types.
_boolean = _Boolean()
_integer = _Integer()
# For now, we don't do any special validation on these types:
_string = _String()
_file_name = _String()
_folder_name = _String()
_file_list = _StringList()
_folder_list = _StringList()
_string_list = _StringList()
# Some boolean settings went from numerical values to boolean. The
# mapping is 0: default, 1: false, 2: true.
_newly_boolean = _Enumeration(['', 'false', 'true'])
def _Same(tool, name, setting_type):
"""Defines a setting that has the same name in MSVS and MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
_Renamed(tool, name, name, setting_type)
def _Renamed(tool, msvs_name, msbuild_name, setting_type):
"""Defines a setting for which the name has changed.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting.
msbuild_name: the name of the MSBuild setting.
setting_type: the type of this setting.
"""
def _Translate(value, msbuild_settings):
msbuild_tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
msbuild_tool_settings[msbuild_name] = setting_type.ConvertToMSBuild(value)
_msvs_validators[tool.msvs_name][msvs_name] = setting_type.ValidateMSVS
_msbuild_validators[tool.msbuild_name][msbuild_name] = (
setting_type.ValidateMSBuild)
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
def _Moved(tool, settings_name, msbuild_tool_name, setting_type):
_MovedAndRenamed(tool, settings_name, msbuild_tool_name, settings_name,
setting_type)
def _MovedAndRenamed(tool, msvs_settings_name, msbuild_tool_name,
msbuild_settings_name, setting_type):
"""Defines a setting that may have moved to a new section.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_settings_name: the MSVS name of the setting.
msbuild_tool_name: the name of the MSBuild tool to place the setting under.
msbuild_settings_name: the MSBuild name of the setting.
setting_type: the type of this setting.
"""
def _Translate(value, msbuild_settings):
tool_settings = msbuild_settings.setdefault(msbuild_tool_name, {})
tool_settings[msbuild_settings_name] = setting_type.ConvertToMSBuild(value)
_msvs_validators[tool.msvs_name][msvs_settings_name] = (
setting_type.ValidateMSVS)
validator = setting_type.ValidateMSBuild
_msbuild_validators[msbuild_tool_name][msbuild_settings_name] = validator
_msvs_to_msbuild_converters[tool.msvs_name][msvs_settings_name] = _Translate
def _MSVSOnly(tool, name, setting_type):
"""Defines a setting that is only found in MSVS.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
def _Translate(unused_value, unused_msbuild_settings):
# Since this is for MSVS only settings, no translation will happen.
pass
_msvs_validators[tool.msvs_name][name] = setting_type.ValidateMSVS
_msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate
def _MSBuildOnly(tool, name, setting_type):
"""Defines a setting that is only found in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
def _Translate(value, msbuild_settings):
# Let msbuild-only properties get translated as-is from msvs_settings.
tool_settings = msbuild_settings.setdefault(tool.msbuild_name, {})
tool_settings[name] = value
_msbuild_validators[tool.msbuild_name][name] = setting_type.ValidateMSBuild
_msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate
def _ConvertedToAdditionalOption(tool, msvs_name, flag):
"""Defines a setting that's handled via a command line option in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting that if 'true' becomes a flag
flag: the flag to insert at the end of the AdditionalOptions
"""
def _Translate(value, msbuild_settings):
if value == 'true':
tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
if 'AdditionalOptions' in tool_settings:
new_flags = '%s %s' % (tool_settings['AdditionalOptions'], flag)
else:
new_flags = flag
tool_settings['AdditionalOptions'] = new_flags
_msvs_validators[tool.msvs_name][msvs_name] = _boolean.ValidateMSVS
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
def _CustomGeneratePreprocessedFile(tool, msvs_name):
def _Translate(value, msbuild_settings):
tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
if value == '0':
tool_settings['PreprocessToFile'] = 'false'
tool_settings['PreprocessSuppressLineNumbers'] = 'false'
elif value == '1': # /P
tool_settings['PreprocessToFile'] = 'true'
tool_settings['PreprocessSuppressLineNumbers'] = 'false'
elif value == '2': # /EP /P
tool_settings['PreprocessToFile'] = 'true'
tool_settings['PreprocessSuppressLineNumbers'] = 'true'
else:
raise ValueError('value must be one of [0, 1, 2]; got %s' % value)
# Create a bogus validator that looks for '0', '1', or '2'
msvs_validator = _Enumeration(['a', 'b', 'c']).ValidateMSVS
_msvs_validators[tool.msvs_name][msvs_name] = msvs_validator
msbuild_validator = _boolean.ValidateMSBuild
msbuild_tool_validators = _msbuild_validators[tool.msbuild_name]
msbuild_tool_validators['PreprocessToFile'] = msbuild_validator
msbuild_tool_validators['PreprocessSuppressLineNumbers'] = msbuild_validator
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
fix_vc_macro_slashes_regex_list = ('IntDir', 'OutDir')
fix_vc_macro_slashes_regex = re.compile(
r'(\$\((?:%s)\))(?:[\\/]+)' % "|".join(fix_vc_macro_slashes_regex_list)
)
# Regular expression to detect keys that were generated by exclusion lists
_EXCLUDED_SUFFIX_RE = re.compile('^(.*)_excluded$')
def _ValidateExclusionSetting(setting, settings, error_msg, stderr=sys.stderr):
"""Verify that 'setting' is valid if it is generated from an exclusion list.
If the setting appears to be generated from an exclusion list, the root name
is checked.
Args:
setting: A string that is the setting name to validate
settings: A dictionary where the keys are valid settings
error_msg: The message to emit in the event of error
stderr: The stream receiving the error messages.
"""
# This may be unrecognized because it's an exclusion list. If the
# setting name has the _excluded suffix, then check the root name.
unrecognized = True
m = re.match(_EXCLUDED_SUFFIX_RE, setting)
if m:
root_setting = m.group(1)
unrecognized = root_setting not in settings
if unrecognized:
# We don't know this setting. Give a warning.
print >> stderr, error_msg
def FixVCMacroSlashes(s):
"""Replace macros which have excessive following slashes.
These macros are known to have a built-in trailing slash. Furthermore, many
scripts hiccup on processing paths with extra slashes in the middle.
This list is probably not exhaustive. Add as needed.
"""
if '$' in s:
s = fix_vc_macro_slashes_regex.sub(r'\1', s)
return s
def ConvertVCMacrosToMSBuild(s):
"""Convert the the MSVS macros found in the string to the MSBuild equivalent.
This list is probably not exhaustive. Add as needed.
"""
if '$' in s:
replace_map = {
'$(ConfigurationName)': '$(Configuration)',
'$(InputDir)': '%(RelativeDir)',
'$(InputExt)': '%(Extension)',
'$(InputFileName)': '%(Filename)%(Extension)',
'$(InputName)': '%(Filename)',
'$(InputPath)': '%(Identity)',
'$(ParentName)': '$(ProjectFileName)',
'$(PlatformName)': '$(Platform)',
'$(SafeInputName)': '%(Filename)',
}
for old, new in replace_map.iteritems():
s = s.replace(old, new)
s = FixVCMacroSlashes(s)
return s
def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
"""Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+).
Args:
msvs_settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
Returns:
A dictionary of MSBuild settings. The key is either the MSBuild tool name
or the empty string (for the global settings). The values are themselves
dictionaries of settings and their values.
"""
msbuild_settings = {}
for msvs_tool_name, msvs_tool_settings in msvs_settings.iteritems():
if msvs_tool_name in _msvs_to_msbuild_converters:
msvs_tool = _msvs_to_msbuild_converters[msvs_tool_name]
for msvs_setting, msvs_value in msvs_tool_settings.iteritems():
if msvs_setting in msvs_tool:
# Invoke the translation function.
try:
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
except ValueError, e:
print >> stderr, ('Warning: while converting %s/%s to MSBuild, '
'%s' % (msvs_tool_name, msvs_setting, e))
else:
_ValidateExclusionSetting(msvs_setting,
msvs_tool,
('Warning: unrecognized setting %s/%s '
'while converting to MSBuild.' %
(msvs_tool_name, msvs_setting)),
stderr)
else:
print >> stderr, ('Warning: unrecognized tool %s while converting to '
'MSBuild.' % msvs_tool_name)
return msbuild_settings
def ValidateMSVSSettings(settings, stderr=sys.stderr):
"""Validates that the names of the settings are valid for MSVS.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
_ValidateSettings(_msvs_validators, settings, stderr)
def ValidateMSBuildSettings(settings, stderr=sys.stderr):
"""Validates that the names of the settings are valid for MSBuild.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
_ValidateSettings(_msbuild_validators, settings, stderr)
def _ValidateSettings(validators, settings, stderr):
"""Validates that the settings are valid for MSBuild or MSVS.
We currently only validate the names of the settings, not their values.
Args:
validators: A dictionary of tools and their validators.
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
for tool_name in settings:
if tool_name in validators:
tool_validators = validators[tool_name]
for setting, value in settings[tool_name].iteritems():
if setting in tool_validators:
try:
tool_validators[setting](value)
except ValueError, e:
print >> stderr, ('Warning: for %s/%s, %s' %
(tool_name, setting, e))
else:
_ValidateExclusionSetting(setting,
tool_validators,
('Warning: unrecognized setting %s/%s' %
(tool_name, setting)),
stderr)
else:
print >> stderr, ('Warning: unrecognized tool %s' % tool_name)
# MSVS and MBuild names of the tools.
_compile = _Tool('VCCLCompilerTool', 'ClCompile')
_link = _Tool('VCLinkerTool', 'Link')
_midl = _Tool('VCMIDLTool', 'Midl')
_rc = _Tool('VCResourceCompilerTool', 'ResourceCompile')
_lib = _Tool('VCLibrarianTool', 'Lib')
_manifest = _Tool('VCManifestTool', 'Manifest')
_masm = _Tool('MASM', 'MASM')
_AddTool(_compile)
_AddTool(_link)
_AddTool(_midl)
_AddTool(_rc)
_AddTool(_lib)
_AddTool(_manifest)
_AddTool(_masm)
# Add sections only found in the MSBuild settings.
_msbuild_validators[''] = {}
_msbuild_validators['ProjectReference'] = {}
_msbuild_validators['ManifestResourceCompile'] = {}
# Descriptions of the compiler options, i.e. VCCLCompilerTool in MSVS and
# ClCompile in MSBuild.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\cl.xml" for
# the schema of the MSBuild ClCompile settings.
# Options that have the same name in MSVS and MSBuild
_Same(_compile, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_compile, 'AdditionalOptions', _string_list)
_Same(_compile, 'AdditionalUsingDirectories', _folder_list) # /AI
_Same(_compile, 'AssemblerListingLocation', _file_name) # /Fa
_Same(_compile, 'BrowseInformationFile', _file_name)
_Same(_compile, 'BufferSecurityCheck', _boolean) # /GS
_Same(_compile, 'DisableLanguageExtensions', _boolean) # /Za
_Same(_compile, 'DisableSpecificWarnings', _string_list) # /wd
_Same(_compile, 'EnableFiberSafeOptimizations', _boolean) # /GT
_Same(_compile, 'EnablePREfast', _boolean) # /analyze Visible='false'
_Same(_compile, 'ExpandAttributedSource', _boolean) # /Fx
_Same(_compile, 'FloatingPointExceptions', _boolean) # /fp:except
_Same(_compile, 'ForceConformanceInForLoopScope', _boolean) # /Zc:forScope
_Same(_compile, 'ForcedIncludeFiles', _file_list) # /FI
_Same(_compile, 'ForcedUsingFiles', _file_list) # /FU
_Same(_compile, 'GenerateXMLDocumentationFiles', _boolean) # /doc
_Same(_compile, 'IgnoreStandardIncludePath', _boolean) # /X
_Same(_compile, 'MinimalRebuild', _boolean) # /Gm
_Same(_compile, 'OmitDefaultLibName', _boolean) # /Zl
_Same(_compile, 'OmitFramePointers', _boolean) # /Oy
_Same(_compile, 'PreprocessorDefinitions', _string_list) # /D
_Same(_compile, 'ProgramDataBaseFileName', _file_name) # /Fd
_Same(_compile, 'RuntimeTypeInfo', _boolean) # /GR
_Same(_compile, 'ShowIncludes', _boolean) # /showIncludes
_Same(_compile, 'SmallerTypeCheck', _boolean) # /RTCc
_Same(_compile, 'StringPooling', _boolean) # /GF
_Same(_compile, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_compile, 'TreatWChar_tAsBuiltInType', _boolean) # /Zc:wchar_t
_Same(_compile, 'UndefineAllPreprocessorDefinitions', _boolean) # /u
_Same(_compile, 'UndefinePreprocessorDefinitions', _string_list) # /U
_Same(_compile, 'UseFullPaths', _boolean) # /FC
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
_Same(_compile, 'XMLDocumentationFileName', _file_name)
_Same(_compile, 'AssemblerOutput',
_Enumeration(['NoListing',
'AssemblyCode', # /FA
'All', # /FAcs
'AssemblyAndMachineCode', # /FAc
'AssemblyAndSourceCode'])) # /FAs
_Same(_compile, 'BasicRuntimeChecks',
_Enumeration(['Default',
'StackFrameRuntimeCheck', # /RTCs
'UninitializedLocalUsageCheck', # /RTCu
'EnableFastChecks'])) # /RTC1
_Same(_compile, 'BrowseInformation',
_Enumeration(['false',
'true', # /FR
'true'])) # /Fr
_Same(_compile, 'CallingConvention',
_Enumeration(['Cdecl', # /Gd
'FastCall', # /Gr
'StdCall', # /Gz
'VectorCall'])) # /Gv
_Same(_compile, 'CompileAs',
_Enumeration(['Default',
'CompileAsC', # /TC
'CompileAsCpp'])) # /TP
_Same(_compile, 'DebugInformationFormat',
_Enumeration(['', # Disabled
'OldStyle', # /Z7
None,
'ProgramDatabase', # /Zi
'EditAndContinue'])) # /ZI
_Same(_compile, 'EnableEnhancedInstructionSet',
_Enumeration(['NotSet',
'StreamingSIMDExtensions', # /arch:SSE
'StreamingSIMDExtensions2', # /arch:SSE2
'AdvancedVectorExtensions', # /arch:AVX (vs2012+)
'NoExtensions', # /arch:IA32 (vs2012+)
# This one only exists in the new msbuild format.
'AdvancedVectorExtensions2', # /arch:AVX2 (vs2013r2+)
]))
_Same(_compile, 'ErrorReporting',
_Enumeration(['None', # /errorReport:none
'Prompt', # /errorReport:prompt
'Queue'], # /errorReport:queue
new=['Send'])) # /errorReport:send"
_Same(_compile, 'ExceptionHandling',
_Enumeration(['false',
'Sync', # /EHsc
'Async'], # /EHa
new=['SyncCThrow'])) # /EHs
_Same(_compile, 'FavorSizeOrSpeed',
_Enumeration(['Neither',
'Speed', # /Ot
'Size'])) # /Os
_Same(_compile, 'FloatingPointModel',
_Enumeration(['Precise', # /fp:precise
'Strict', # /fp:strict
'Fast'])) # /fp:fast
_Same(_compile, 'InlineFunctionExpansion',
_Enumeration(['Default',
'OnlyExplicitInline', # /Ob1
'AnySuitable'], # /Ob2
new=['Disabled'])) # /Ob0
_Same(_compile, 'Optimization',
_Enumeration(['Disabled', # /Od
'MinSpace', # /O1
'MaxSpeed', # /O2
'Full'])) # /Ox
_Same(_compile, 'RuntimeLibrary',
_Enumeration(['MultiThreaded', # /MT
'MultiThreadedDebug', # /MTd
'MultiThreadedDLL', # /MD
'MultiThreadedDebugDLL'])) # /MDd
_Same(_compile, 'StructMemberAlignment',
_Enumeration(['Default',
'1Byte', # /Zp1
'2Bytes', # /Zp2
'4Bytes', # /Zp4
'8Bytes', # /Zp8
'16Bytes'])) # /Zp16
_Same(_compile, 'WarningLevel',
_Enumeration(['TurnOffAllWarnings', # /W0
'Level1', # /W1
'Level2', # /W2
'Level3', # /W3
'Level4'], # /W4
new=['EnableAllWarnings'])) # /Wall
# Options found in MSVS that have been renamed in MSBuild.
_Renamed(_compile, 'EnableFunctionLevelLinking', 'FunctionLevelLinking',
_boolean) # /Gy
_Renamed(_compile, 'EnableIntrinsicFunctions', 'IntrinsicFunctions',
_boolean) # /Oi
_Renamed(_compile, 'KeepComments', 'PreprocessKeepComments', _boolean) # /C
_Renamed(_compile, 'ObjectFile', 'ObjectFileName', _file_name) # /Fo
_Renamed(_compile, 'OpenMP', 'OpenMPSupport', _boolean) # /openmp
_Renamed(_compile, 'PrecompiledHeaderThrough', 'PrecompiledHeaderFile',
_file_name) # Used with /Yc and /Yu
_Renamed(_compile, 'PrecompiledHeaderFile', 'PrecompiledHeaderOutputFile',
_file_name) # /Fp
_Renamed(_compile, 'UsePrecompiledHeader', 'PrecompiledHeader',
_Enumeration(['NotUsing', # VS recognized '' for this value too.
'Create', # /Yc
'Use'])) # /Yu
_Renamed(_compile, 'WarnAsError', 'TreatWarningAsError', _boolean) # /WX
_ConvertedToAdditionalOption(_compile, 'DefaultCharIsUnsigned', '/J')
# MSVS options not found in MSBuild.
_MSVSOnly(_compile, 'Detect64BitPortabilityProblems', _boolean)
_MSVSOnly(_compile, 'UseUnicodeResponseFiles', _boolean)
# MSBuild options not found in MSVS.
_MSBuildOnly(_compile, 'BuildingInIDE', _boolean)
_MSBuildOnly(_compile, 'CompileAsManaged',
_Enumeration([], new=['false',
'true'])) # /clr
_MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean) # /hotpatch
_MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean) # /MP
_MSBuildOnly(_compile, 'PreprocessOutputPath', _string) # /Fi
_MSBuildOnly(_compile, 'ProcessorNumber', _integer) # the number of processors
_MSBuildOnly(_compile, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list) # /we
_MSBuildOnly(_compile, 'UseUnicodeForAssemblerListing', _boolean) # /FAu
# Defines a setting that needs very customized processing
_CustomGeneratePreprocessedFile(_compile, 'GeneratePreprocessedFile')
# Directives for converting MSVS VCLinkerTool to MSBuild Link.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\link.xml" for
# the schema of the MSBuild Link settings.
# Options that have the same name in MSVS and MSBuild
_Same(_link, 'AdditionalDependencies', _file_list)
_Same(_link, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH
# /MANIFESTDEPENDENCY:
_Same(_link, 'AdditionalManifestDependencies', _file_list)
_Same(_link, 'AdditionalOptions', _string_list)
_Same(_link, 'AddModuleNamesToAssembly', _file_list) # /ASSEMBLYMODULE
_Same(_link, 'AllowIsolation', _boolean) # /ALLOWISOLATION
_Same(_link, 'AssemblyLinkResource', _file_list) # /ASSEMBLYLINKRESOURCE
_Same(_link, 'BaseAddress', _string) # /BASE
_Same(_link, 'CLRUnmanagedCodeCheck', _boolean) # /CLRUNMANAGEDCODECHECK
_Same(_link, 'DelayLoadDLLs', _file_list) # /DELAYLOAD
_Same(_link, 'DelaySign', _boolean) # /DELAYSIGN
_Same(_link, 'EmbedManagedResourceFile', _file_list) # /ASSEMBLYRESOURCE
_Same(_link, 'EnableUAC', _boolean) # /MANIFESTUAC
_Same(_link, 'EntryPointSymbol', _string) # /ENTRY
_Same(_link, 'ForceSymbolReferences', _file_list) # /INCLUDE
_Same(_link, 'FunctionOrder', _file_name) # /ORDER
_Same(_link, 'GenerateDebugInformation', _boolean) # /DEBUG
_Same(_link, 'GenerateMapFile', _boolean) # /MAP
_Same(_link, 'HeapCommitSize', _string)
_Same(_link, 'HeapReserveSize', _string) # /HEAP
_Same(_link, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB
_Same(_link, 'IgnoreEmbeddedIDL', _boolean) # /IGNOREIDL
_Same(_link, 'ImportLibrary', _file_name) # /IMPLIB
_Same(_link, 'KeyContainer', _file_name) # /KEYCONTAINER
_Same(_link, 'KeyFile', _file_name) # /KEYFILE
_Same(_link, 'ManifestFile', _file_name) # /ManifestFile
_Same(_link, 'MapExports', _boolean) # /MAPINFO:EXPORTS
_Same(_link, 'MapFileName', _file_name)
_Same(_link, 'MergedIDLBaseFileName', _file_name) # /IDLOUT
_Same(_link, 'MergeSections', _string) # /MERGE
_Same(_link, 'MidlCommandFile', _file_name) # /MIDL
_Same(_link, 'ModuleDefinitionFile', _file_name) # /DEF
_Same(_link, 'OutputFile', _file_name) # /OUT
_Same(_link, 'PerUserRedirection', _boolean)
_Same(_link, 'Profile', _boolean) # /PROFILE
_Same(_link, 'ProfileGuidedDatabase', _file_name) # /PGD
_Same(_link, 'ProgramDatabaseFile', _file_name) # /PDB
_Same(_link, 'RegisterOutput', _boolean)
_Same(_link, 'SetChecksum', _boolean) # /RELEASE
_Same(_link, 'StackCommitSize', _string)
_Same(_link, 'StackReserveSize', _string) # /STACK
_Same(_link, 'StripPrivateSymbols', _file_name) # /PDBSTRIPPED
_Same(_link, 'SupportUnloadOfDelayLoadedDLL', _boolean) # /DELAY:UNLOAD
_Same(_link, 'SuppressStartupBanner', _boolean) # /NOLOGO
_Same(_link, 'SwapRunFromCD', _boolean) # /SWAPRUN:CD
_Same(_link, 'TurnOffAssemblyGeneration', _boolean) # /NOASSEMBLY
_Same(_link, 'TypeLibraryFile', _file_name) # /TLBOUT
_Same(_link, 'TypeLibraryResourceID', _integer) # /TLBID
_Same(_link, 'UACUIAccess', _boolean) # /uiAccess='true'
_Same(_link, 'Version', _string) # /VERSION
_Same(_link, 'EnableCOMDATFolding', _newly_boolean) # /OPT:ICF
_Same(_link, 'FixedBaseAddress', _newly_boolean) # /FIXED
_Same(_link, 'LargeAddressAware', _newly_boolean) # /LARGEADDRESSAWARE
_Same(_link, 'OptimizeReferences', _newly_boolean) # /OPT:REF
_Same(_link, 'RandomizedBaseAddress', _newly_boolean) # /DYNAMICBASE
_Same(_link, 'TerminalServerAware', _newly_boolean) # /TSAWARE
_subsystem_enumeration = _Enumeration(
['NotSet',
'Console', # /SUBSYSTEM:CONSOLE
'Windows', # /SUBSYSTEM:WINDOWS
'Native', # /SUBSYSTEM:NATIVE
'EFI Application', # /SUBSYSTEM:EFI_APPLICATION
'EFI Boot Service Driver', # /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
'EFI ROM', # /SUBSYSTEM:EFI_ROM
'EFI Runtime', # /SUBSYSTEM:EFI_RUNTIME_DRIVER
'WindowsCE'], # /SUBSYSTEM:WINDOWSCE
new=['POSIX']) # /SUBSYSTEM:POSIX
_target_machine_enumeration = _Enumeration(
['NotSet',
'MachineX86', # /MACHINE:X86
None,
'MachineARM', # /MACHINE:ARM
'MachineEBC', # /MACHINE:EBC
'MachineIA64', # /MACHINE:IA64
None,
'MachineMIPS', # /MACHINE:MIPS
'MachineMIPS16', # /MACHINE:MIPS16
'MachineMIPSFPU', # /MACHINE:MIPSFPU
'MachineMIPSFPU16', # /MACHINE:MIPSFPU16
None,
None,
None,
'MachineSH4', # /MACHINE:SH4
None,
'MachineTHUMB', # /MACHINE:THUMB
'MachineX64']) # /MACHINE:X64
_Same(_link, 'AssemblyDebug',
_Enumeration(['',
'true', # /ASSEMBLYDEBUG
'false'])) # /ASSEMBLYDEBUG:DISABLE
_Same(_link, 'CLRImageType',
_Enumeration(['Default',
'ForceIJWImage', # /CLRIMAGETYPE:IJW
'ForcePureILImage', # /Switch="CLRIMAGETYPE:PURE
'ForceSafeILImage'])) # /Switch="CLRIMAGETYPE:SAFE
_Same(_link, 'CLRThreadAttribute',
_Enumeration(['DefaultThreadingAttribute', # /CLRTHREADATTRIBUTE:NONE
'MTAThreadingAttribute', # /CLRTHREADATTRIBUTE:MTA
'STAThreadingAttribute'])) # /CLRTHREADATTRIBUTE:STA
_Same(_link, 'DataExecutionPrevention',
_Enumeration(['',
'false', # /NXCOMPAT:NO
'true'])) # /NXCOMPAT
_Same(_link, 'Driver',
_Enumeration(['NotSet',
'Driver', # /Driver
'UpOnly', # /DRIVER:UPONLY
'WDM'])) # /DRIVER:WDM
_Same(_link, 'LinkTimeCodeGeneration',
_Enumeration(['Default',
'UseLinkTimeCodeGeneration', # /LTCG
'PGInstrument', # /LTCG:PGInstrument
'PGOptimization', # /LTCG:PGOptimize
'PGUpdate'])) # /LTCG:PGUpdate
_Same(_link, 'ShowProgress',
_Enumeration(['NotSet',
'LinkVerbose', # /VERBOSE
'LinkVerboseLib'], # /VERBOSE:Lib
new=['LinkVerboseICF', # /VERBOSE:ICF
'LinkVerboseREF', # /VERBOSE:REF
'LinkVerboseSAFESEH', # /VERBOSE:SAFESEH
'LinkVerboseCLR'])) # /VERBOSE:CLR
_Same(_link, 'SubSystem', _subsystem_enumeration)
_Same(_link, 'TargetMachine', _target_machine_enumeration)
_Same(_link, 'UACExecutionLevel',
_Enumeration(['AsInvoker', # /level='asInvoker'
'HighestAvailable', # /level='highestAvailable'
'RequireAdministrator'])) # /level='requireAdministrator'
_Same(_link, 'MinimumRequiredVersion', _string)
_Same(_link, 'TreatLinkerWarningAsErrors', _boolean) # /WX
# Options found in MSVS that have been renamed in MSBuild.
_Renamed(_link, 'ErrorReporting', 'LinkErrorReporting',
_Enumeration(['NoErrorReport', # /ERRORREPORT:NONE
'PromptImmediately', # /ERRORREPORT:PROMPT
'QueueForNextLogin'], # /ERRORREPORT:QUEUE
new=['SendErrorReport'])) # /ERRORREPORT:SEND
_Renamed(_link, 'IgnoreDefaultLibraryNames', 'IgnoreSpecificDefaultLibraries',
_file_list) # /NODEFAULTLIB
_Renamed(_link, 'ResourceOnlyDLL', 'NoEntryPoint', _boolean) # /NOENTRY
_Renamed(_link, 'SwapRunFromNet', 'SwapRunFromNET', _boolean) # /SWAPRUN:NET
_Moved(_link, 'GenerateManifest', '', _boolean)
_Moved(_link, 'IgnoreImportLibrary', '', _boolean)
_Moved(_link, 'LinkIncremental', '', _newly_boolean)
_Moved(_link, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
_Moved(_link, 'UseLibraryDependencyInputs', 'ProjectReference', _boolean)
# MSVS options not found in MSBuild.
_MSVSOnly(_link, 'OptimizeForWindows98', _newly_boolean)
_MSVSOnly(_link, 'UseUnicodeResponseFiles', _boolean)
# MSBuild options not found in MSVS.
_MSBuildOnly(_link, 'BuildingInIDE', _boolean)
_MSBuildOnly(_link, 'ImageHasSafeExceptionHandlers', _boolean) # /SAFESEH
_MSBuildOnly(_link, 'LinkDLL', _boolean) # /DLL Visible='false'
_MSBuildOnly(_link, 'LinkStatus', _boolean) # /LTCG:STATUS
_MSBuildOnly(_link, 'PreventDllBinding', _boolean) # /ALLOWBIND
_MSBuildOnly(_link, 'SupportNobindOfDelayLoadedDLL', _boolean) # /DELAY:NOBIND
_MSBuildOnly(_link, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_link, 'MSDOSStubFileName', _file_name) # /STUB Visible='false'
_MSBuildOnly(_link, 'SectionAlignment', _integer) # /ALIGN
_MSBuildOnly(_link, 'SpecifySectionAttributes', _string) # /SECTION
_MSBuildOnly(_link, 'ForceFileOutput',
_Enumeration([], new=['Enabled', # /FORCE
# /FORCE:MULTIPLE
'MultiplyDefinedSymbolOnly',
'UndefinedSymbolOnly'])) # /FORCE:UNRESOLVED
_MSBuildOnly(_link, 'CreateHotPatchableImage',
_Enumeration([], new=['Enabled', # /FUNCTIONPADMIN
'X86Image', # /FUNCTIONPADMIN:5
'X64Image', # /FUNCTIONPADMIN:6
'ItaniumImage'])) # /FUNCTIONPADMIN:16
_MSBuildOnly(_link, 'CLRSupportLastError',
_Enumeration([], new=['Enabled', # /CLRSupportLastError
'Disabled', # /CLRSupportLastError:NO
# /CLRSupportLastError:SYSTEMDLL
'SystemDlls']))
# Directives for converting VCResourceCompilerTool to ResourceCompile.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\rc.xml" for
# the schema of the MSBuild ResourceCompile settings.
_Same(_rc, 'AdditionalOptions', _string_list)
_Same(_rc, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_rc, 'Culture', _Integer(msbuild_base=16))
_Same(_rc, 'IgnoreStandardIncludePath', _boolean) # /X
_Same(_rc, 'PreprocessorDefinitions', _string_list) # /D
_Same(_rc, 'ResourceOutputFileName', _string) # /fo
_Same(_rc, 'ShowProgress', _boolean) # /v
# There is no UI in VisualStudio 2008 to set the following properties.
# However they are found in CL and other tools. Include them here for
# completeness, as they are very likely to have the same usage pattern.
_Same(_rc, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_rc, 'UndefinePreprocessorDefinitions', _string_list) # /u
# MSBuild options not found in MSVS.
_MSBuildOnly(_rc, 'NullTerminateStrings', _boolean) # /n
_MSBuildOnly(_rc, 'TrackerLogDirectory', _folder_name)
# Directives for converting VCMIDLTool to Midl.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\midl.xml" for
# the schema of the MSBuild Midl settings.
_Same(_midl, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_midl, 'AdditionalOptions', _string_list)
_Same(_midl, 'CPreprocessOptions', _string) # /cpp_opt
_Same(_midl, 'ErrorCheckAllocations', _boolean) # /error allocation
_Same(_midl, 'ErrorCheckBounds', _boolean) # /error bounds_check
_Same(_midl, 'ErrorCheckEnumRange', _boolean) # /error enum
_Same(_midl, 'ErrorCheckRefPointers', _boolean) # /error ref
_Same(_midl, 'ErrorCheckStubData', _boolean) # /error stub_data
_Same(_midl, 'GenerateStublessProxies', _boolean) # /Oicf
_Same(_midl, 'GenerateTypeLibrary', _boolean)
_Same(_midl, 'HeaderFileName', _file_name) # /h
_Same(_midl, 'IgnoreStandardIncludePath', _boolean) # /no_def_idir
_Same(_midl, 'InterfaceIdentifierFileName', _file_name) # /iid
_Same(_midl, 'MkTypLibCompatible', _boolean) # /mktyplib203
_Same(_midl, 'OutputDirectory', _string) # /out
_Same(_midl, 'PreprocessorDefinitions', _string_list) # /D
_Same(_midl, 'ProxyFileName', _file_name) # /proxy
_Same(_midl, 'RedirectOutputAndErrors', _file_name) # /o
_Same(_midl, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_midl, 'TypeLibraryName', _file_name) # /tlb
_Same(_midl, 'UndefinePreprocessorDefinitions', _string_list) # /U
_Same(_midl, 'WarnAsError', _boolean) # /WX
_Same(_midl, 'DefaultCharType',
_Enumeration(['Unsigned', # /char unsigned
'Signed', # /char signed
'Ascii'])) # /char ascii7
_Same(_midl, 'TargetEnvironment',
_Enumeration(['NotSet',
'Win32', # /env win32
'Itanium', # /env ia64
'X64'])) # /env x64
_Same(_midl, 'EnableErrorChecks',
_Enumeration(['EnableCustom',
'None', # /error none
'All'])) # /error all
_Same(_midl, 'StructMemberAlignment',
_Enumeration(['NotSet',
'1', # Zp1
'2', # Zp2
'4', # Zp4
'8'])) # Zp8
_Same(_midl, 'WarningLevel',
_Enumeration(['0', # /W0
'1', # /W1
'2', # /W2
'3', # /W3
'4'])) # /W4
_Renamed(_midl, 'DLLDataFileName', 'DllDataFileName', _file_name) # /dlldata
_Renamed(_midl, 'ValidateParameters', 'ValidateAllParameters',
_boolean) # /robust
# MSBuild options not found in MSVS.
_MSBuildOnly(_midl, 'ApplicationConfigurationMode', _boolean) # /app_config
_MSBuildOnly(_midl, 'ClientStubFile', _file_name) # /cstub
_MSBuildOnly(_midl, 'GenerateClientFiles',
_Enumeration([], new=['Stub', # /client stub
'None'])) # /client none
_MSBuildOnly(_midl, 'GenerateServerFiles',
_Enumeration([], new=['Stub', # /client stub
'None'])) # /client none
_MSBuildOnly(_midl, 'LocaleID', _integer) # /lcid DECIMAL
_MSBuildOnly(_midl, 'ServerStubFile', _file_name) # /sstub
_MSBuildOnly(_midl, 'SuppressCompilerWarnings', _boolean) # /no_warn
_MSBuildOnly(_midl, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_midl, 'TypeLibFormat',
_Enumeration([], new=['NewFormat', # /newtlb
'OldFormat'])) # /oldtlb
# Directives for converting VCLibrarianTool to Lib.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\lib.xml" for
# the schema of the MSBuild Lib settings.
_Same(_lib, 'AdditionalDependencies', _file_list)
_Same(_lib, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH
_Same(_lib, 'AdditionalOptions', _string_list)
_Same(_lib, 'ExportNamedFunctions', _string_list) # /EXPORT
_Same(_lib, 'ForceSymbolReferences', _string) # /INCLUDE
_Same(_lib, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB
_Same(_lib, 'IgnoreSpecificDefaultLibraries', _file_list) # /NODEFAULTLIB
_Same(_lib, 'ModuleDefinitionFile', _file_name) # /DEF
_Same(_lib, 'OutputFile', _file_name) # /OUT
_Same(_lib, 'SuppressStartupBanner', _boolean) # /NOLOGO
_Same(_lib, 'UseUnicodeResponseFiles', _boolean)
_Same(_lib, 'LinkTimeCodeGeneration', _boolean) # /LTCG
_Same(_lib, 'TargetMachine', _target_machine_enumeration)
# TODO(jeanluc) _link defines the same value that gets moved to
# ProjectReference. We may want to validate that they are consistent.
_Moved(_lib, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
_MSBuildOnly(_lib, 'DisplayLibrary', _string) # /LIST Visible='false'
_MSBuildOnly(_lib, 'ErrorReporting',
_Enumeration([], new=['PromptImmediately', # /ERRORREPORT:PROMPT
'QueueForNextLogin', # /ERRORREPORT:QUEUE
'SendErrorReport', # /ERRORREPORT:SEND
'NoErrorReport'])) # /ERRORREPORT:NONE
_MSBuildOnly(_lib, 'MinimumRequiredVersion', _string)
_MSBuildOnly(_lib, 'Name', _file_name) # /NAME
_MSBuildOnly(_lib, 'RemoveObjects', _file_list) # /REMOVE
_MSBuildOnly(_lib, 'SubSystem', _subsystem_enumeration)
_MSBuildOnly(_lib, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_lib, 'TreatLibWarningAsErrors', _boolean) # /WX
_MSBuildOnly(_lib, 'Verbose', _boolean)
# Directives for converting VCManifestTool to Mt.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\mt.xml" for
# the schema of the MSBuild Lib settings.
# Options that have the same name in MSVS and MSBuild
_Same(_manifest, 'AdditionalManifestFiles', _file_list) # /manifest
_Same(_manifest, 'AdditionalOptions', _string_list)
_Same(_manifest, 'AssemblyIdentity', _string) # /identity:
_Same(_manifest, 'ComponentFileName', _file_name) # /dll
_Same(_manifest, 'GenerateCatalogFiles', _boolean) # /makecdfs
_Same(_manifest, 'InputResourceManifests', _string) # /inputresource
_Same(_manifest, 'OutputManifestFile', _file_name) # /out
_Same(_manifest, 'RegistrarScriptFile', _file_name) # /rgs
_Same(_manifest, 'ReplacementsFile', _file_name) # /replacements
_Same(_manifest, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_manifest, 'TypeLibraryFile', _file_name) # /tlb:
_Same(_manifest, 'UpdateFileHashes', _boolean) # /hashupdate
_Same(_manifest, 'UpdateFileHashesSearchPath', _file_name)
_Same(_manifest, 'VerboseOutput', _boolean) # /verbose
# Options that have moved location.
_MovedAndRenamed(_manifest, 'ManifestResourceFile',
'ManifestResourceCompile',
'ResourceOutputFileName',
_file_name)
_Moved(_manifest, 'EmbedManifest', '', _boolean)
# MSVS options not found in MSBuild.
_MSVSOnly(_manifest, 'DependencyInformationFile', _file_name)
_MSVSOnly(_manifest, 'UseFAT32Workaround', _boolean)
_MSVSOnly(_manifest, 'UseUnicodeResponseFiles', _boolean)
# MSBuild options not found in MSVS.
_MSBuildOnly(_manifest, 'EnableDPIAwareness', _boolean)
_MSBuildOnly(_manifest, 'GenerateCategoryTags', _boolean) # /category
_MSBuildOnly(_manifest, 'ManifestFromManagedAssembly',
_file_name) # /managedassemblyname
_MSBuildOnly(_manifest, 'OutputResourceManifests', _string) # /outputresource
_MSBuildOnly(_manifest, 'SuppressDependencyElement', _boolean) # /nodependency
_MSBuildOnly(_manifest, 'TrackerLogDirectory', _folder_name)
# Directives for MASM.
# See "$(VCTargetsPath)\BuildCustomizations\masm.xml" for the schema of the
# MSBuild MASM settings.
# Options that have the same name in MSVS and MSBuild.
_Same(_masm, 'UseSafeExceptionHandlers', _boolean) # /safeseh
|
gpl-2.0
|
[
3,
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
82,
624,
3034,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
1900,
7249,
14,
199,
199,
2765,
570,
3509,
1233,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
199,
1506,
7249,
14,
221,
710,
805,
7905,
28361,
5268,
1062,
12134,
14206,
5268,
1062,
199,
460,
12134,
10733,
5268,
342,
787,
314,
2397,
4501,
14,
199,
199,
2765,
570,
1990,
2737,
701,
20234,
314,
11336,
2737,
701,
14702,
13225,
9079,
199,
460,
14702,
13225,
7129,
367,
1006,
2808,
2202,
4012,
314,
922,
3217,
14,
199,
1918,
21374,
32536,
4898,
2597,
8652,
14,
221,
9322,
787,
13609,
1911,
315,
314,
199,
10733,
3907,
2082,
12,
325,
14,
71,
14,
286,
3427,
9184,
16920,
334,
88,
1184,
2862,
10733,
199,
624,
199,
199,
646,
984,
199,
646,
295,
199,
199,
3,
3757,
10150,
402,
2202,
14370,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
6411,
3423,
14,
199,
63,
8338,
63,
11346,
275,
1052,
199,
63,
14087,
63,
11346,
275,
1052,
421,
199,
3,
437,
2600,
402,
2202,
23172,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
8603,
3423,
14,
199,
63,
8338,
63,
475,
63,
14087,
63,
17911,
275,
1052,
421,
199,
3,
15650,
536,
4412,
687,
13828,
370,
21374,
14,
199,
63,
14087,
63,
354,
63,
1618,
63,
3557,
275,
1052,
421,
199,
533,
485,
5157,
8,
785,
304,
523,
408,
18089,
282,
4744,
1202,
701,
13828,
503,
21374,
14,
819,
9382,
26,
489,
13795,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
13828,
14,
489,
14835,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
21374,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
13795,
63,
354,
12,
14835,
63,
354,
304,
272,
291,
14,
8338,
63,
354,
275,
13795,
63,
354,
272,
291,
14,
14087,
63,
354,
275,
14835,
63,
354,
421,
199,
318,
485,
1123,
5157,
8,
3557,
304,
523,
408,
14995,
282,
4744,
370,
314,
11648,
11196,
1202,
370,
2112,
2202,
14,
819,
961,
1454,
7890,
314,
4744,
14,
221,
7048,
4260,
2597,
4839,
370,
506,
3483,
14,
819,
3033,
26,
272,
4744,
26,
710,
485,
5157,
909,
370,
506,
3483,
14,
523,
408,
523,
485,
8338,
63,
11346,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
11346,
59,
3557,
14,
14087,
63,
354,
61,
275,
1052,
523,
485,
8338,
63,
475,
63,
14087,
63,
17911,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
354,
63,
1618,
63,
3557,
59,
3557,
14,
8338,
63,
354,
61,
275,
4744,
14,
14087,
63,
354,
421,
199,
318,
485,
26772,
5157,
5268,
8,
14087,
63,
1751,
12,
4744,
304,
523,
408,
3407,
376,
21374,
4744,
2600,
14,
221,
10560,
652,
340,
4346,
1041,
523,
372,
14835,
63,
1751,
14,
5486,
8,
3557,
14,
14087,
63,
354,
12,
5009,
421,
199,
533,
485,
804,
8,
785,
304,
523,
408,
804,
402,
2202,
334,
1563,
1021,
10477,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
13828,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
13828,
14,
272,
408,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
21374,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
21374,
14,
272,
408,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
408,
3407,
314,
21374,
7353,
402,
314,
13828,
574,
1627,
14,
339,
3033,
26,
489,
574,
26,
314,
13828,
574,
370,
3957,
14,
339,
1803,
26,
489,
314,
21374,
7353,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
14,
272,
408,
272,
372,
574,
421,
199,
533,
485,
1558,
1547,
804,
304,
523,
408,
33,
4260,
626,
1159,
2951,
282,
1059,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
32216,
1547,
804,
304,
523,
408,
33,
2202,
626,
1159,
282,
769,
402,
3326,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
340,
1228,
8,
585,
12,
769,
304,
489,
372,
359,
7306,
9454,
25402,
28361,
8,
73,
9,
367,
284,
315,
574,
61,
272,
587,
26,
489,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
4082,
1547,
804,
304,
523,
408,
4082,
2202,
12,
883,
1172,
314,
1338,
283,
3910,
7,
503,
283,
2052,
23690,
819,
347,
485,
12584,
8,
277,
12,
574,
304,
272,
340,
574,
1137,
283,
2052,
7,
436,
574,
1137,
283,
3910,
356,
489,
746,
1722,
360,
2062,
2155,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
291,
423,
12584
] |
[
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
82,
624,
3034,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
1900,
7249,
14,
199,
199,
2765,
570,
3509,
1233,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
199,
1506,
7249,
14,
221,
710,
805,
7905,
28361,
5268,
1062,
12134,
14206,
5268,
1062,
199,
460,
12134,
10733,
5268,
342,
787,
314,
2397,
4501,
14,
199,
199,
2765,
570,
1990,
2737,
701,
20234,
314,
11336,
2737,
701,
14702,
13225,
9079,
199,
460,
14702,
13225,
7129,
367,
1006,
2808,
2202,
4012,
314,
922,
3217,
14,
199,
1918,
21374,
32536,
4898,
2597,
8652,
14,
221,
9322,
787,
13609,
1911,
315,
314,
199,
10733,
3907,
2082,
12,
325,
14,
71,
14,
286,
3427,
9184,
16920,
334,
88,
1184,
2862,
10733,
199,
624,
199,
199,
646,
984,
199,
646,
295,
199,
199,
3,
3757,
10150,
402,
2202,
14370,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
6411,
3423,
14,
199,
63,
8338,
63,
11346,
275,
1052,
199,
63,
14087,
63,
11346,
275,
1052,
421,
199,
3,
437,
2600,
402,
2202,
23172,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
8603,
3423,
14,
199,
63,
8338,
63,
475,
63,
14087,
63,
17911,
275,
1052,
421,
199,
3,
15650,
536,
4412,
687,
13828,
370,
21374,
14,
199,
63,
14087,
63,
354,
63,
1618,
63,
3557,
275,
1052,
421,
199,
533,
485,
5157,
8,
785,
304,
523,
408,
18089,
282,
4744,
1202,
701,
13828,
503,
21374,
14,
819,
9382,
26,
489,
13795,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
13828,
14,
489,
14835,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
21374,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
13795,
63,
354,
12,
14835,
63,
354,
304,
272,
291,
14,
8338,
63,
354,
275,
13795,
63,
354,
272,
291,
14,
14087,
63,
354,
275,
14835,
63,
354,
421,
199,
318,
485,
1123,
5157,
8,
3557,
304,
523,
408,
14995,
282,
4744,
370,
314,
11648,
11196,
1202,
370,
2112,
2202,
14,
819,
961,
1454,
7890,
314,
4744,
14,
221,
7048,
4260,
2597,
4839,
370,
506,
3483,
14,
819,
3033,
26,
272,
4744,
26,
710,
485,
5157,
909,
370,
506,
3483,
14,
523,
408,
523,
485,
8338,
63,
11346,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
11346,
59,
3557,
14,
14087,
63,
354,
61,
275,
1052,
523,
485,
8338,
63,
475,
63,
14087,
63,
17911,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
354,
63,
1618,
63,
3557,
59,
3557,
14,
8338,
63,
354,
61,
275,
4744,
14,
14087,
63,
354,
421,
199,
318,
485,
26772,
5157,
5268,
8,
14087,
63,
1751,
12,
4744,
304,
523,
408,
3407,
376,
21374,
4744,
2600,
14,
221,
10560,
652,
340,
4346,
1041,
523,
372,
14835,
63,
1751,
14,
5486,
8,
3557,
14,
14087,
63,
354,
12,
5009,
421,
199,
533,
485,
804,
8,
785,
304,
523,
408,
804,
402,
2202,
334,
1563,
1021,
10477,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
13828,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
13828,
14,
272,
408,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
21374,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
21374,
14,
272,
408,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
408,
3407,
314,
21374,
7353,
402,
314,
13828,
574,
1627,
14,
339,
3033,
26,
489,
574,
26,
314,
13828,
574,
370,
3957,
14,
339,
1803,
26,
489,
314,
21374,
7353,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
14,
272,
408,
272,
372,
574,
421,
199,
533,
485,
1558,
1547,
804,
304,
523,
408,
33,
4260,
626,
1159,
2951,
282,
1059,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
32216,
1547,
804,
304,
523,
408,
33,
2202,
626,
1159,
282,
769,
402,
3326,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
340,
1228,
8,
585,
12,
769,
304,
489,
372,
359,
7306,
9454,
25402,
28361,
8,
73,
9,
367,
284,
315,
574,
61,
272,
587,
26,
489,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
4082,
1547,
804,
304,
523,
408,
4082,
2202,
12,
883,
1172,
314,
1338,
283,
3910,
7,
503,
283,
2052,
23690,
819,
347,
485,
12584,
8,
277,
12,
574,
304,
272,
340,
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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
] |
shakamunyi/neutron-vrrp
|
neutron/services/firewall/agents/firewall_agent_api.py
|
4
|
2820
|
# Copyright (c) 2013 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# @author: Sumit Naiksatam, sumitnaiksatam@gmail.com, Big Switch Networks, Inc.
# @author: Sridar Kandaswamy, skandasw@cisco.com, Cisco Systems, Inc.
# @author: Dan Florea, dflorea@cisco.com, Cisco Systems, Inc.
from oslo.config import cfg
from neutron.common import rpc as n_rpc
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__)
FWaaSOpts = [
cfg.StrOpt(
'driver',
default='',
help=_("Name of the FWaaS Driver")),
cfg.BoolOpt(
'enabled',
default=False,
help=_("Enable FWaaS")),
]
cfg.CONF.register_opts(FWaaSOpts, 'fwaas')
class FWaaSPluginApiMixin(n_rpc.RpcProxy):
"""Agent side of the FWaaS agent to FWaaS Plugin RPC API."""
RPC_API_VERSION = '1.0'
def __init__(self, topic, host):
super(FWaaSPluginApiMixin,
self).__init__(topic=topic,
default_version=self.RPC_API_VERSION)
self.host = host
def set_firewall_status(self, context, firewall_id, status):
"""Make a RPC to set the status of a firewall."""
return self.call(context,
self.make_msg('set_firewall_status', host=self.host,
firewall_id=firewall_id, status=status))
def firewall_deleted(self, context, firewall_id):
"""Make a RPC to indicate that the firewall resources are deleted."""
return self.call(context,
self.make_msg('firewall_deleted', host=self.host,
firewall_id=firewall_id))
class FWaaSAgentRpcCallbackMixin(object):
"""Mixin for FWaaS agent Implementations."""
def __init__(self, host):
super(FWaaSAgentRpcCallbackMixin, self).__init__(host)
def create_firewall(self, context, firewall, host):
"""Handle RPC cast from plugin to create a firewall."""
pass
def update_firewall(self, context, firewall, host):
"""Handle RPC cast from plugin to update a firewall."""
pass
def delete_firewall(self, context, firewall, host):
"""Handle RPC cast from plugin to delete a firewall."""
pass
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6171,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
3,
199,
3,
768,
2502,
26,
12094,
390,
11290,
3258,
83,
419,
77,
12,
3089,
390,
3540,
3258,
83,
419,
77,
32,
6799,
14,
957,
12,
13123,
17711,
17138,
12,
3277,
14,
199,
3,
768,
2502,
26,
428,
1677,
285,
1804,
7683,
87,
455,
89,
12,
2386,
7683,
87,
32,
19597,
14,
957,
12,
28356,
15285,
12,
3277,
14,
199,
3,
768,
2502,
26,
24747,
481,
320,
8273,
12,
4051,
320,
8273,
32,
19597,
14,
957,
12,
28356,
15285,
12,
3277,
14,
199,
199,
504,
11258,
14,
888,
492,
4810,
199,
199,
504,
8224,
14,
2330,
492,
8985,
465,
302,
63,
4354,
199,
504,
8224,
14,
8512,
14,
2330,
492,
943,
465,
2050,
199,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
19445,
2158,
4118,
8382,
275,
359,
272,
4810,
14,
19340,
8,
267,
283,
3090,
297,
267,
849,
4581,
267,
1720,
9384,
985,
402,
314,
481,
55,
2158,
51,
19447,
8150,
272,
4810,
14,
10349,
9985,
8,
267,
283,
3827,
297,
267,
849,
29,
797,
12,
267,
1720,
9384,
6476,
481,
55,
2158,
51,
8150,
199,
61,
199,
4128,
14,
3103,
14,
2683,
63,
3291,
8,
19445,
2158,
4118,
8382,
12,
283,
70,
758,
305,
358,
421,
199,
533,
481,
55,
2158,
51,
5061,
7394,
4256,
8,
78,
63,
4354,
14,
15569,
4936,
304,
272,
408,
7788,
5366,
402,
314,
481,
55,
2158,
51,
6631,
370,
481,
55,
2158,
51,
11349,
11785,
3261,
1041,
339,
11785,
63,
3735,
63,
4612,
275,
283,
17,
14,
16,
7,
339,
347,
636,
826,
721,
277,
12,
7482,
12,
1591,
304,
267,
1613,
8,
19445,
2158,
51,
5061,
7394,
4256,
12,
1598,
291,
2843,
826,
721,
5746,
29,
5746,
12,
2490,
849,
63,
1023,
29,
277,
14,
8171,
63,
3735,
63,
4612,
9,
267,
291,
14,
1102,
275,
1591,
339,
347,
663,
63,
10794,
63,
1205,
8,
277,
12,
1067,
12,
12042,
63,
344,
12,
2004,
304,
267,
408,
5483,
282,
11785,
370,
663,
314,
2004,
402,
282,
12042,
1041,
267,
372,
291,
14,
1250,
8,
1100,
12,
586,
291,
14,
1875,
63,
1328,
360,
409,
63,
10794,
63,
1205,
297,
1591,
29,
277,
14,
1102,
12,
4318,
12042,
63,
344,
29,
10794,
63,
344,
12,
2004,
29,
1205,
430,
339,
347,
12042,
63,
6062,
8,
277,
12,
1067,
12,
12042,
63,
344,
304,
267,
408,
5483,
282,
11785,
370,
6623,
626,
314,
12042,
5944,
787,
5463,
1041,
267,
372,
291,
14,
1250,
8,
1100,
12,
586,
291,
14,
1875,
63,
1328,
360,
10794,
63,
6062,
297,
1591,
29,
277,
14,
1102,
12,
4318,
12042,
63,
344,
29,
10794,
63,
344,
430,
421,
199,
533,
481,
55,
2158,
4251,
12069,
15569,
2806,
4256,
8,
785,
304,
272,
408,
4256,
367,
481,
55,
2158,
51,
6631,
22467,
1298,
1041,
339,
347,
636,
826,
721,
277,
12,
1591,
304,
398,
1613,
8,
19445,
2158,
4251,
12069,
15569,
2806,
4256,
12,
291,
2843,
826,
721,
1102,
9,
339,
347,
1218,
63,
10794,
8,
277,
12,
1067,
12,
12042,
12,
1591,
304,
267,
408,
5940,
11785,
9106,
687,
3589,
370,
1218,
282,
12042,
1041,
267,
986,
339,
347,
1678,
63,
10794,
8,
277,
12,
1067,
12,
12042,
12,
1591,
304,
267,
408,
5940,
11785,
9106,
687,
3589,
370,
1678,
282,
12042,
1041,
267,
986,
339,
347,
3145,
63,
10794,
8,
277,
12,
1067,
12,
12042,
12,
1591,
304,
267,
408,
5940,
11785,
9106,
687,
3589,
370,
3145,
282,
12042,
1041,
267,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6171,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
3,
199,
3,
768,
2502,
26,
12094,
390,
11290,
3258,
83,
419,
77,
12,
3089,
390,
3540,
3258,
83,
419,
77,
32,
6799,
14,
957,
12,
13123,
17711,
17138,
12,
3277,
14,
199,
3,
768,
2502,
26,
428,
1677,
285,
1804,
7683,
87,
455,
89,
12,
2386,
7683,
87,
32,
19597,
14,
957,
12,
28356,
15285,
12,
3277,
14,
199,
3,
768,
2502,
26,
24747,
481,
320,
8273,
12,
4051,
320,
8273,
32,
19597,
14,
957,
12,
28356,
15285,
12,
3277,
14,
199,
199,
504,
11258,
14,
888,
492,
4810,
199,
199,
504,
8224,
14,
2330,
492,
8985,
465,
302,
63,
4354,
199,
504,
8224,
14,
8512,
14,
2330,
492,
943,
465,
2050,
199,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
19445,
2158,
4118,
8382,
275,
359,
272,
4810,
14,
19340,
8,
267,
283,
3090,
297,
267,
849,
4581,
267,
1720,
9384,
985,
402,
314,
481,
55,
2158,
51,
19447,
8150,
272,
4810,
14,
10349,
9985,
8,
267,
283,
3827,
297,
267,
849,
29,
797,
12,
267,
1720,
9384,
6476,
481,
55,
2158,
51,
8150,
199,
61,
199,
4128,
14,
3103,
14,
2683,
63,
3291,
8,
19445,
2158,
4118,
8382,
12,
283,
70,
758,
305,
358,
421,
199,
533,
481,
55,
2158,
51,
5061,
7394,
4256,
8,
78,
63,
4354,
14,
15569,
4936,
304,
272,
408,
7788,
5366,
402,
314,
481,
55,
2158,
51,
6631,
370,
481,
55,
2158,
51,
11349,
11785,
3261,
1041,
339,
11785,
63,
3735,
63,
4612,
275,
283,
17,
14,
16,
7,
339,
347,
636,
826,
721,
277,
12,
7482,
12,
1591,
304,
267,
1613,
8,
19445,
2158,
51,
5061,
7394,
4256,
12,
1598,
291,
2843,
826,
721,
5746,
29,
5746,
12,
2490,
849,
63,
1023,
29,
277,
14,
8171,
63,
3735,
63,
4612,
9,
267,
291,
14,
1102,
275,
1591,
339,
347,
663,
63,
10794,
63,
1205,
8,
277,
12,
1067,
12,
12042,
63,
344,
12,
2004,
304,
267,
408,
5483,
282,
11785,
370,
663,
314,
2004,
402,
282,
12042,
1041,
267,
372,
291,
14,
1250,
8,
1100,
12,
586,
291,
14,
1875,
63,
1328,
360,
409,
63,
10794,
63,
1205,
297,
1591,
29,
277,
14,
1102,
12,
4318,
12042,
63,
344,
29,
10794,
63,
344,
12,
2004,
29,
1205,
430,
339,
347,
12042,
63,
6062,
8,
277,
12,
1067,
12,
12042,
63,
344,
304,
267,
408,
5483,
282,
11785,
370,
6623,
626,
314,
12042,
5944,
787,
5463,
1041,
267,
372,
291,
14,
1250,
8,
1100,
12,
586,
291,
14,
1875,
63,
1328,
360,
10794,
63,
6062,
297,
1591,
29,
277,
14,
1102,
12,
4318,
12042,
63,
344,
29,
10794,
63,
344,
430,
421,
199,
533,
481,
55,
2158,
4251,
12069,
15569,
2806,
4256,
8,
785,
304,
272,
408,
4256,
367,
481,
55,
2158,
51,
6631,
22467,
1298,
1041,
339,
347,
636,
826,
721,
277,
12,
1591,
304,
398,
1613,
8,
19445,
2158,
4251,
12069,
15569,
2806,
4256,
12,
291,
2843,
826,
721,
1102,
9,
339,
347,
1218,
63,
10794,
8,
277,
12,
1067,
12,
12042,
12,
1591,
304,
267,
408,
5940,
11785,
9106,
687,
3589,
370,
1218,
282,
12042,
1041,
267,
986,
339,
347,
1678,
63,
10794,
8,
277,
12,
1067,
12,
12042,
12,
1591,
304,
267,
408,
5940,
11785,
9106,
687,
3589,
370,
1678,
282,
12042,
1041,
267,
986,
339,
347,
3145,
63,
10794,
8,
277,
12,
1067,
12,
12042,
12,
1591,
304,
267,
408,
5940,
11785,
9106,
687,
3589,
370,
3145,
282,
12042,
1041,
267,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
yumingfei/virt-manager
|
virtinst/Guest.py
|
2
|
52391
|
#
# Common code for all guests
#
# Copyright 2006-2009 Red Hat, Inc.
# Jeremy Katz <katzj@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
import os
import time
import logging
import signal
import urlgrabber.progress as progress
import libvirt
import libxml2
from virtinst import util
from virtinst import CapabilitiesParser
from virtinst import support
from virtinst import XMLBuilderDomain
import virtinst
from virtinst.XMLBuilderDomain import _xml_property
from virtinst.VirtualDevice import VirtualDevice
from virtinst.VirtualDisk import VirtualDisk
from virtinst.VirtualInputDevice import VirtualInputDevice
from virtinst.VirtualCharDevice import VirtualCharDevice
from virtinst.VirtualController import VirtualControllerUSB
from virtinst.Clock import Clock
from virtinst.Seclabel import Seclabel
from virtinst.CPU import CPU
from virtinst.DomainNumatune import DomainNumatune
from virtinst.DomainFeatures import DomainFeatures
from virtinst import osdict
class Guest(XMLBuilderDomain.XMLBuilderDomain):
# OS Dictionary static variables and methods
_DEFAULTS = osdict.DEFAULTS
_OS_TYPES = osdict.OS_TYPES
_default_os_type = None
@staticmethod
def pretty_os_list():
"""
Return a strip representation of OS list for printing
"""
ret = ""
for t in Guest.list_os_types():
for v in Guest.list_os_variants(t):
ret += "%-20s : %s\n" % (v, Guest.get_os_variant_label(t, v))
return ret
@staticmethod
def list_os_types(supported=False, filtervars=None):
"""
@param filtervars: List of only variants we want to show by default
"""
vals = osdict.sort_helper(Guest._OS_TYPES)
for t in vals[:]:
if not Guest.list_os_variants(t, supported=supported,
filtervars=filtervars):
vals.remove(t)
return vals
@staticmethod
def list_os_variants(typ, sortpref=None, supported=False, filtervars=None):
"""
Return a list of sorted os variants for the passed distro type
@param sortpref: An option list of osdict 'distro' tags to
prioritize in the returned list, e.g. passing ["fedora"] will make
the sorted list have all fedora distros first
@param filtervars: List of only variants we want to show by default
"""
vals = osdict.sort_helper(Guest._OS_TYPES[typ]["variants"],
sortpref)
ret = []
for v in vals:
if filtervars:
if v not in filtervars:
continue
elif supported:
if not osdict.lookup_osdict_key(None, None,
typ, v, "supported"):
continue
ret.append(v)
return ret
@staticmethod
def get_os_type_label(typ):
return Guest._OS_TYPES[typ]["label"]
@staticmethod
def get_os_variant_label(typ, variant):
return Guest._OS_TYPES[typ]["variants"][variant]["label"]
@staticmethod
def cpuset_str_to_tuple(conn, cpuset):
return DomainNumatune.cpuset_str_to_tuple(conn, cpuset)
@staticmethod
def generate_cpuset(conn, mem):
"""
Generates a cpu pinning string based on host NUMA configuration.
If host doesn't have a suitable NUMA configuration, a RuntimeError
is thrown.
"""
caps = CapabilitiesParser.parse(conn.getCapabilities())
if caps.host.topology is None:
raise RuntimeError(_("No topology section in capabilities xml."))
cells = caps.host.topology.cells
if len(cells) <= 1:
raise RuntimeError(_("Capabilities only show <= 1 cell. "
"Not NUMA capable"))
# Capabilities tells us about the available memory 'cells' on the
# system. Each 'cell' has associated 'cpu's.
#
# Use getCellsFreeMemory to determine which 'cell' has the smallest
# amount of memory which fits the requested VM memory amount, then
# pin the VM to that 'cell's associated 'cpu's
cell_mem = conn.getCellsFreeMemory(0, len(cells))
cell_id = -1
mem = mem * 1024
for i in range(len(cells)):
if cell_mem[i] < mem:
# Cell doesn't have enough mem to fit, skip it
continue
if len(cells[i].cpus) == 0:
# No cpus to use for the cell
continue
# Find smallest cell that fits
if cell_id < 0 or cell_mem[i] < cell_mem[cell_id]:
cell_id = i
if cell_id < 0:
raise RuntimeError(_("Could not find any usable NUMA "
"cell/cpu combinations."))
# Build cpuset string
cpustr = ""
for cpu in cells[cell_id].cpus:
if cpustr != "":
cpustr += ","
cpustr += str(cpu.id)
return cpustr
def __init__(self, type=None, connection=None, hypervisorURI=None,
installer=None, parsexml=None, caps=None, conn=None):
# pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
# Set up the connection, since it is fundamental for other init
conn = conn or connection
if conn is None:
logging.debug("No conn passed to Guest, opening URI '%s'",
hypervisorURI)
conn = self._open_uri(hypervisorURI)
if conn is None:
raise RuntimeError(_("Unable to connect to hypervisor, aborting "
"installation!"))
self._name = None
self._uuid = None
self._memory = None
self._maxmemory = None
self._hugepage = None
self._vcpus = 1
self._maxvcpus = 1
self._cpuset = None
self._autostart = False
self._clock = None
self._seclabel = None
self._description = None
self._features = None
self._replace = None
self._emulator = None
self._installer = installer
self._os_type = None
self._os_variant = None
self._os_autodetect = False
# General device list. Only access through API calls (even internally)
self._devices = []
# Device list to use/alter during install process. Don't access
# directly, use internal APIs
self._install_devices = []
# The libvirt virDomain object we 'Create'
self.domain = None
self._consolechild = None
self._default_input_device = None
self._default_console_device = None
# pylint: disable=W0212
# Access to protected member _get_caps
caps = caps or (self._installer and self._installer._get_caps())
# pylint: enable=W0212
XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml,
caps=caps)
if self._is_parse():
return
if not self.installer:
i = virtinst.DistroInstaller(type=type,
conn=conn,
os_type=self._default_os_type,
caps=self._get_caps())
self.installer = i
# Add default devices (if applicable)
inp = self._get_default_input_device()
if inp:
self.add_device(inp)
self._default_input_device = inp
con = self._get_default_console_device()
con.virtinst_default = True
self.add_device(con)
self._default_console_device = con
# Need to do this after all parameter init
self._features = DomainFeatures(self.conn)
self._clock = Clock(self.conn)
self._seclabel = Seclabel(self.conn)
self._cpu = CPU(self.conn)
self._numatune = DomainNumatune(self.conn)
def _open_uri(self, uri):
# This is here so test suite can overwrite it, to make sure
# Guest is never opening anything
return libvirt.open(uri)
######################
# Property accessors #
######################
def get_installer(self):
return self._installer
def set_installer(self, val):
self._installer = val
installer = property(get_installer, set_installer)
def get_clock(self):
return self._clock
clock = property(get_clock)
def get_seclabel(self):
return self._seclabel
seclabel = property(get_seclabel)
def get_cpu(self):
return self._cpu
cpu = property(get_cpu)
def get_numatune(self):
return self._numatune
numatune = property(get_numatune)
def _get_features(self):
return self._features
features = property(_get_features)
# Domain name of the guest
def get_name(self):
return self._name
def set_name(self, val):
util.validate_name(_("Guest"), val, lencheck=True)
do_fail = False
if self.replace is not True:
try:
self.conn.lookupByName(val)
do_fail = True
except:
# Name not found
pass
if do_fail:
raise ValueError(_("Guest name '%s' is already in use.") % val)
self._name = val
name = _xml_property(get_name, set_name,
xpath="./name")
# Memory allocated to the guest. Should be given in MB
def get_memory(self):
return self._memory
def set_memory(self, val):
if not isinstance(val, int) or val <= 0:
raise ValueError(_("Memory value must be an integer greater "
"than 0"))
self._memory = val
if self.maxmemory is None or self.maxmemory < val:
self.maxmemory = val
def _xml_memory_value(self):
return int(self.memory) * 1024
memory = _xml_property(get_memory, set_memory,
xpath="./currentMemory",
get_converter=lambda s, x: int(x) / 1024,
set_converter=lambda s, x: int(x) * 1024)
# Memory allocated to the guest. Should be given in MB
def get_maxmemory(self):
return self._maxmemory
def set_maxmemory(self, val):
if not isinstance(val, int) or val <= 0:
raise ValueError(_("Max Memory value must be an integer greater "
"than 0"))
self._maxmemory = val
def _xml_maxmemory_value(self):
return int(self.maxmemory) * 1024
maxmemory = _xml_property(get_maxmemory, set_maxmemory,
xpath="./memory",
get_converter=lambda s, x: int(x) / 1024,
set_converter=lambda s, x: int(x) * 1024)
def get_hugepage(self):
return self._hugepage
def set_hugepage(self, val):
if val is None:
return val
self._hugepage = bool(val)
hugepage = _xml_property(get_hugepage, set_hugepage,
xpath="./memoryBacking/hugepages", is_bool=True)
# UUID for the guest
def get_uuid(self):
return self._uuid
def set_uuid(self, val):
val = util.validate_uuid(val)
self._uuid = val
uuid = _xml_property(get_uuid, set_uuid,
xpath="./uuid")
def __validate_cpus(self, val):
maxvcpus = util.get_max_vcpus(self.conn, self.type)
val = int(val)
if val < 1:
raise ValueError(_("Number of vcpus must be a positive integer."))
if val > maxvcpus:
raise ValueError(_("Number of vcpus must be no greater than %d "
"for this vm type.") % maxvcpus)
return val
# number of vcpus for the guest
def get_vcpus(self):
return self._vcpus
def set_vcpus(self, val):
val = self.__validate_cpus(val)
self._vcpus = val
# Don't force set maxvcpus unless already specified
if self.maxvcpus is not None and self.maxvcpus < val:
self.maxvcpus = val
def _vcpus_get_converter(self, val):
# If no current VCPUs, return maxvcpus
if not val:
val = self.maxvcpus
return int(val)
vcpus = _xml_property(get_vcpus, set_vcpus,
xpath="./vcpu/@current",
get_converter=_vcpus_get_converter)
def _get_maxvcpus(self):
return self._maxvcpus
def _set_maxvcpus(self, val):
val = self.__validate_cpus(val)
self._maxvcpus = val
maxvcpus = _xml_property(_get_maxvcpus, _set_maxvcpus,
xpath="./vcpu",
get_converter=lambda s, x: int(x))
# set phy-cpus for the guest
def get_cpuset(self):
return self._cpuset
def set_cpuset(self, val):
if val is None or val == "":
self._cpuset = None
return
DomainNumatune.validate_cpuset(self.conn, val)
self._cpuset = val
cpuset = _xml_property(get_cpuset, set_cpuset,
xpath="./vcpu/@cpuset")
# GAH! - installer.os_type = "hvm" or "xen" (aka xen paravirt)
# guest.os_type = "Solaris", "Windows", "Linux"
# FIXME: We should really rename this property to something else,
# change it throughout the codebase for readability sake, but
# maintain back compat.
def get_os_type(self):
return self._os_type
def set_os_type(self, val):
if type(val) is not str:
raise ValueError(_("OS type must be a string."))
val = val.lower()
if val in self._OS_TYPES:
if self._os_type != val:
# Invalidate variant, since it may not apply to the new os type
self._os_type = val
self._os_variant = None
else:
raise ValueError(_("OS type '%s' does not exist in our "
"dictionary") % val)
os_type = property(get_os_type, set_os_type)
def get_os_variant(self):
return self._os_variant
def set_os_variant(self, val):
if type(val) is not str:
raise ValueError(_("OS variant must be a string."))
val = val.lower()
if self.os_type:
if val in self._OS_TYPES[self.os_type]["variants"]:
self._os_variant = val
else:
raise ValueError(_("OS variant '%(var)s' does not exist in "
"our dictionary for OS type '%(ty)s'") %
{'var' : val, 'ty' : self._os_type})
else:
found = False
for ostype in self.list_os_types():
if (val in self._OS_TYPES[ostype]["variants"] and
not self._OS_TYPES[ostype]["variants"][val].get("skip")):
logging.debug("Setting os type to '%s' for variant '%s'",
ostype, val)
self.os_type = ostype
self._os_variant = val
found = True
if not found:
raise ValueError(_("Unknown OS variant '%s'" % val))
os_variant = property(get_os_variant, set_os_variant)
def set_os_autodetect(self, val):
self._os_autodetect = bool(val)
def get_os_autodetect(self):
return self._os_autodetect
os_autodetect = property(get_os_autodetect, set_os_autodetect)
# Get the current variants 'distro' tag: 'rhel', 'fedora', etc.
def get_os_distro(self):
return self._lookup_osdict_key("distro")
os_distro = property(get_os_distro)
def get_autostart(self):
return self._autostart
def set_autostart(self, val):
self._autostart = bool(val)
autostart = property(get_autostart, set_autostart,
doc="Have domain autostart when the host boots.")
def _get_description(self):
return self._description
def _set_description(self, val):
self._description = val
description = _xml_property(_get_description, _set_description,
xpath="./description")
def _get_emulator(self):
return self._emulator
def _set_emulator(self, val):
self._emulator = val
emulator = _xml_property(_get_emulator, _set_emulator,
xpath="./devices/emulator")
def _get_replace(self):
return self._replace
def _set_replace(self, val):
self._replace = bool(val)
replace = property(_get_replace, _set_replace,
doc=_("Whether we should overwrite an existing guest "
"with the same name."))
#########################
# DEPRECATED PROPERTIES #
#########################
# Hypervisor name (qemu, xen, kvm, etc.)
# Deprecated: should be pulled directly from the installer
def get_type(self):
return self._installer.type
def set_type(self, val):
self._installer.type = val
type = property(get_type, set_type)
# Deprecated: should be pulled directly from the installer
def get_arch(self):
return self.installer.arch
def set_arch(self, val):
self.installer.arch = val
arch = property(get_arch, set_arch)
# Deprecated: Should be called from the installer directly
def get_location(self):
return self._installer.location
def set_location(self, val):
self._installer.location = val
location = property(get_location, set_location)
# Deprecated: Should be called from the installer directly
def get_scratchdir(self):
return self._installer.scratchdir
scratchdir = property(get_scratchdir)
# Deprecated: Should be called from the installer directly
def get_extraargs(self):
return self._installer.extraargs
def set_extraargs(self, val):
self._installer.extraargs = val
extraargs = property(get_extraargs, set_extraargs)
# Deprecated: Should set the installer values directly
def get_cdrom(self):
return self._installer.location
def set_cdrom(self, val):
self._installer.location = val
self._installer.cdrom = True
cdrom = property(get_cdrom, set_cdrom)
########################################
# Device Add/Remove Public API methods #
########################################
def _dev_build_list(self, devtype, devlist=None):
if not devlist:
devlist = self._devices
newlist = []
for i in devlist:
if i.virtual_device_type == devtype:
newlist.append(i)
return newlist
def add_device(self, dev):
"""
Add the passed device to the guest's device list.
@param dev: VirtualDevice instance to attach to guest
"""
if not isinstance(dev, VirtualDevice):
raise ValueError(_("Must pass a VirtualDevice instance."))
if self._is_parse():
xml = dev.get_xml_config()
node = libxml2.parseDoc(xml).children
dev.set_xml_node(node)
self._add_child_node("./devices", node)
return self._add_device(dev)
def _add_device(self, dev):
devtype = dev.virtual_device_type
# If user adds a device conflicting with a default assigned device
# remove the default
if (devtype == VirtualDevice.VIRTUAL_DEV_INPUT and
self._default_input_device):
if self._default_input_device in self.get_all_devices():
self.remove_device(self._default_input_device)
self._default_input_device = None
if (devtype in [VirtualDevice.VIRTUAL_DEV_CONSOLE,
VirtualDevice.VIRTUAL_DEV_SERIAL] and
self._default_console_device):
if self._default_console_device in self.get_all_devices():
self.remove_device(self._default_console_device)
self._default_console_device = None
# Actually add the device
self._devices.append(dev)
def get_devices(self, devtype):
"""
Return a list of devices of type 'devtype' that will installed on
the guest.
@param devtype: Device type to search for (one of
VirtualDevice.virtual_device_types)
"""
devlist = self._dev_build_list(devtype)
devlist.extend(self._install_devices)
return self._dev_build_list(devtype, devlist)
def get_all_devices(self):
"""
Return a list of all devices being installed with the guest
"""
retlist = []
for devtype in VirtualDevice.virtual_device_types:
retlist.extend(self.get_devices(devtype))
return retlist
def remove_device(self, dev):
"""
Remove the passed device from the guest's device list
@param dev: VirtualDevice instance
"""
found = False
for devlist in [self._devices, self._install_devices]:
if found:
break
if dev in devlist:
devlist.remove(dev)
found = True
break
if not found:
raise ValueError(_("Did not find device %s") % str(dev))
if self._is_parse():
xpath = dev.get_xml_node_path()
if xpath:
self._remove_child_xpath(xpath)
################################
# Private xml building methods #
################################
def _parsexml(self, xml, node):
XMLBuilderDomain.XMLBuilderDomain._parsexml(self, xml, node)
device_mappings = {
"disk" : virtinst.VirtualDisk,
"interface" : virtinst.VirtualNetworkInterface,
"sound" : virtinst.VirtualAudio,
"hostdev" : virtinst.VirtualHostDevice,
"input" : virtinst.VirtualInputDevice,
"serial" : virtinst.VirtualCharDevice,
"parallel" : virtinst.VirtualCharDevice,
"console" : virtinst.VirtualCharDevice,
"channel" : virtinst.VirtualCharDevice,
"graphics" : virtinst.VirtualGraphics,
"video" : virtinst.VirtualVideoDevice,
"watchdog" : virtinst.VirtualWatchdog,
"controller": virtinst.VirtualController,
"filesystem": virtinst.VirtualFilesystem,
"smartcard" : virtinst.VirtualSmartCardDevice,
"redirdev" : virtinst.VirtualRedirDevice,
"memballoon": virtinst.VirtualMemballoon,
}
# Hand off all child element parsing to relevant classes
caps = self._get_caps()
for node in self._xml_node.children:
if node.name != "devices":
continue
children = [x for x in node.children if
(x.name in device_mappings and
x.parent == node)]
for devnode in children:
objclass = device_mappings.get(devnode.name)
if objclass == virtinst.VirtualCharDevice:
dev = objclass(self.conn, devnode.name,
parsexmlnode=devnode, caps=caps)
else:
dev = objclass(conn=self.conn,
parsexmlnode=devnode, caps=caps)
self._add_device(dev)
self._installer = virtinst.Installer.Installer(self.conn,
parsexmlnode=self._xml_node,
caps=caps)
self._features = DomainFeatures(self.conn,
parsexmlnode=self._xml_node,
caps=caps)
self._clock = Clock(self.conn, parsexmlnode=self._xml_node, caps=caps)
self._seclabel = Seclabel(self.conn, parsexmlnode=self._xml_node,
caps=caps)
self._cpu = CPU(self.conn, parsexmlnode=self._xml_node, caps=caps)
self._numatune = DomainNumatune(self.conn,
parsexmlnode=self._xml_node, caps=caps)
def _get_default_input_device(self):
"""
Return a VirtualInputDevice.
"""
if self.installer and self.installer.is_container():
return None
dev = VirtualInputDevice(self.conn)
return dev
def _get_default_console_device(self):
dev = VirtualCharDevice.get_dev_instance(self.conn,
VirtualCharDevice.DEV_CONSOLE,
VirtualCharDevice.CHAR_PTY)
return dev
def _get_device_xml(self, devs, install=True):
def do_remove_media(d):
# Keep cdrom around, but with no media attached,
# But only if we are a distro that doesn't have a multi
# stage install (aka not Windows)
return (d.virtual_device_type == VirtualDevice.VIRTUAL_DEV_DISK and
d.device == VirtualDisk.DEVICE_CDROM
and d.transient
and not install and
not self.get_continue_inst())
def do_skip_disk(d):
# Skip transient labeled non-media disks
return (d.virtual_device_type == VirtualDevice.VIRTUAL_DEV_DISK and
d.device == VirtualDisk.DEVICE_DISK
and d.transient
and not install)
# Wrapper for building disk XML, handling transient CDROMs
def get_dev_xml(dev):
origpath = None
try:
if do_skip_disk(dev):
return ""
if do_remove_media(dev):
origpath = dev.path
dev.path = None
return dev.get_xml_config()
finally:
if origpath:
dev.path = origpath
def get_vscsi_ctrl_xml():
vscsi_class = virtinst.VirtualController.get_class_for_type(
virtinst.VirtualController.CONTROLLER_TYPE_SCSI)
ctrl = vscsi_class(self.conn)
ctrl.set_address("spapr-vio")
return ctrl.get_xml_config()
xml = self._get_emulator_xml()
# Build XML
for dev in devs:
xml = util.xml_append(xml, get_dev_xml(dev))
if (dev.address.type == "spapr-vio" and
dev.virtual_device_type == VirtualDevice.VIRTUAL_DEV_DISK):
xml = util.xml_append(xml, get_vscsi_ctrl_xml())
return xml
def _get_emulator_xml(self):
emulator = self.emulator
if self.installer.is_xenpv():
return ""
if (not self.emulator and
self.installer.is_hvm() and
self.type == "xen"):
if self._get_caps().host.arch in ("x86_64"):
emulator = "/usr/lib64/xen/bin/qemu-dm"
else:
emulator = "/usr/lib/xen/bin/qemu-dm"
emu_xml = ""
if emulator is not None:
emu_xml = " <emulator>%s</emulator>" % emulator
return emu_xml
def _get_features_xml(self, features):
"""
Return features (pae, acpi, apic) xml
"""
if self.installer and self.installer.is_container():
return ""
return features.get_xml_config()
def _get_cpu_xml(self):
"""
Return <cpu> XML
"""
self.cpu.set_topology_defaults(self.vcpus)
return self.cpu.get_xml_config()
def _get_clock_xml(self):
"""
Return <clock/> xml
"""
return self.clock.get_xml_config()
def _get_seclabel_xml(self):
"""
Return <seclabel> XML
"""
xml = ""
if self.seclabel:
xml = self.seclabel.get_xml_config()
return xml
def _get_osblob(self, install):
"""
Return os, features, and clock xml (Implemented in subclass)
"""
xml = ""
osxml = self.installer.get_xml_config(self, install)
if not osxml:
return None
xml = util.xml_append(xml,
self.installer.get_xml_config(self, install))
return xml
def _get_vcpu_xml(self):
curvcpus_supported = virtinst.support.check_conn_support(
self.conn,
virtinst.support.SUPPORT_CONN_MAXVCPUS_XML)
cpuset = ""
if self.cpuset is not None:
cpuset = " cpuset='%s'" % self.cpuset
maxv = self.maxvcpus
curv = self.vcpus
curxml = ""
if maxv != curv and curvcpus_supported:
curxml = " current='%s'" % curv
else:
maxv = curv
return " <vcpu%s%s>%s</vcpu>" % (cpuset, curxml, maxv)
############################
# Install Helper functions #
############################
def _prepare_install(self, meter, dry=False):
self._install_devices = []
ignore = dry
# Fetch install media, prepare installer devices
self._installer.prepare(guest=self,
meter=meter)
# Initialize install device list
for dev in self._installer.install_devices:
self._install_devices.append(dev)
def _cleanup_install(self):
self._installer.cleanup()
def _create_devices(self, progresscb):
"""
Ensure that devices are setup
"""
for dev in self.get_all_devices():
dev.setup_dev(self.conn, progresscb)
##############
# Public API #
##############
def _get_xml_config(self, install=True, disk_boot=False):
"""
Return the full Guest xml configuration.
@param install: Whether we want the 'OS install' configuration or
the 'post-install' configuration. (Some Installers,
like the LiveCDInstaller may not have an 'install'
config.)
@type install: C{bool}
@param disk_boot: Whether we should boot off the harddisk, regardless
of our position in the install process (this is
used for 2 stage installs, where the second stage
boots off the disk. You probably don't need to touch
this.)
@type disk_boot: C{bool}
"""
# pylint: disable=W0221
# Argument number differs from overridden method
# We do a shallow copy of the device list here, and set the defaults.
# This way, default changes aren't persistent, and we don't need
# to worry about when to call set_defaults
origdevs = self.get_all_devices()
devs = []
for dev in origdevs:
devs.append(dev.copy())
tmpfeat = self.features.copy()
def get_transient_devices(devtype):
return self._dev_build_list(devtype, devs)
def remove_transient_device(device):
devs.remove(device)
# Set device defaults so we can validly generate XML
self._set_defaults(get_transient_devices,
remove_transient_device,
tmpfeat)
if install:
action = "destroy"
else:
action = "restart"
osblob_install = install
if disk_boot:
osblob_install = False
osblob = self._get_osblob(osblob_install)
if osblob_install and not self.installer.has_install_phase():
return None
desc_xml = ""
if self.description is not None:
desc = str(self.description)
desc_xml = (" <description>%s</description>" %
util.xml_escape(desc))
xml = ""
add = lambda x: util.xml_append(xml, x)
xml = add("<domain type='%s'>" % self.type)
xml = add(" <name>%s</name>" % self.name)
xml = add(" <uuid>%s</uuid>" % self.uuid)
xml = add(desc_xml)
xml = add(" <memory>%s</memory>" % (self.maxmemory * 1024))
xml = add(" <currentMemory>%s</currentMemory>" % (self.memory * 1024))
# <blkiotune>
# <memtune>
if self.hugepage is True:
xml = add(" <memoryBacking>")
xml = add(" <hugepages/>")
xml = add(" </memoryBacking>")
xml = add(self._get_vcpu_xml())
# <cputune>
xml = add(self.numatune.get_xml_config())
# <sysinfo>
# XXX: <bootloader> goes here, not in installer XML
xml = add(" %s" % osblob)
xml = add(self._get_features_xml(tmpfeat))
xml = add(self._get_cpu_xml())
xml = add(self._get_clock_xml())
xml = add(" <on_poweroff>destroy</on_poweroff>")
xml = add(" <on_reboot>%s</on_reboot>" % action)
xml = add(" <on_crash>%s</on_crash>" % action)
xml = add(" <devices>")
xml = add(self._get_device_xml(devs, install))
xml = add(" </devices>")
xml = add(self._get_seclabel_xml())
xml = add("</domain>\n")
return xml
def get_continue_inst(self):
"""
Return True if this guest requires a call to 'continue_install',
which means the OS requires a 2 stage install (windows)
"""
# If we are doing an 'import' or 'liveCD' install, there is
# no true install process, so continue install has no meaning
if not self.installer.has_install_phase():
return False
return self._lookup_osdict_key("continue")
def validate_parms(self):
"""
Do some pre-install domain validation
"""
if self.domain is not None:
raise RuntimeError(_("Domain has already been started!"))
if self.name is None or self.memory is None:
raise RuntimeError(_("Name and memory must be specified for "
"all guests!"))
if util.vm_uuid_collision(self.conn, self.uuid):
raise RuntimeError(_("The UUID you entered is already in "
"use by another guest!"))
def connect_console(self, consolecb, wait=True):
"""
Launched the passed console callback for the already defined
domain. If domain isn't running, return an error.
"""
(self.domain,
self._consolechild) = self._wait_and_connect_console(consolecb)
# If we connected the console, wait for it to finish
self._waitpid_console(self._consolechild, wait)
def terminate_console(self):
"""
Kill guest console if it is open (and actually exists), otherwise
do nothing
"""
if self._consolechild:
try:
os.kill(self._consolechild, signal.SIGKILL)
except:
pass
def domain_is_shutdown(self):
"""
Return True if the created domain object is shutdown
"""
dom = self.domain
if not dom:
return False
dominfo = dom.info()
state = dominfo[0]
cpu_time = dominfo[4]
if state == libvirt.VIR_DOMAIN_SHUTOFF:
return True
# If 'wait' was specified, the dom object we have was looked up
# before initially shutting down, which seems to bogus up the
# info data (all 0's). So, if it is bogus, assume the domain is
# shutdown. We will catch the error later.
return state == libvirt.VIR_DOMAIN_NOSTATE and cpu_time == 0
def domain_is_crashed(self):
"""
Return True if the created domain object is in a crashed state
"""
if not self.domain:
return False
dominfo = self.domain.info()
state = dominfo[0]
return state == libvirt.VIR_DOMAIN_CRASHED
##########################
# Actual install methods #
##########################
def remove_original_vm(self, force=None):
"""
Remove the existing VM with the same name if requested, or error
if there is a collision.
"""
if force is None:
force = self.replace
vm = None
try:
vm = self.conn.lookupByName(self.name)
except libvirt.libvirtError:
pass
if vm is None:
return
if not force:
raise RuntimeError(_("Domain named %s already exists!") %
self.name)
try:
logging.debug("Explicitly replacing guest '%s'", self.name)
if vm.ID() != -1:
logging.info("Destroying guest '%s'", self.name)
vm.destroy()
logging.info("Undefining guest '%s'", self.name)
vm.undefine()
except libvirt.libvirtError, e:
raise RuntimeError(_("Could not remove old vm '%s': %s") %
(self.name, str(e)))
def start_install(self, consolecb=None, meter=None, removeOld=None,
wait=True, dry=False, return_xml=False, noboot=False):
"""
Begin the guest install (stage1).
@param return_xml: Don't create the guest, just return generated XML
"""
is_initial = True
self.validate_parms()
self._consolechild = None
self._prepare_install(meter, dry)
try:
# Create devices if required (disk images, etc.)
if not dry:
self._create_devices(meter)
start_xml, final_xml = self._build_xml(is_initial)
if return_xml:
return (start_xml, final_xml)
if dry:
return
# Remove existing VM if requested
self.remove_original_vm(removeOld)
self.domain = self._create_guest(consolecb, meter, wait,
start_xml, final_xml, is_initial,
noboot)
# Set domain autostart flag if requested
self._flag_autostart()
return self.domain
finally:
self._cleanup_install()
def continue_install(self, consolecb=None, meter=None, wait=True,
dry=False, return_xml=False):
"""
Continue with stage 2 of a guest install. Only required for
guests which have the 'continue' flag set (accessed via
get_continue_inst)
"""
is_initial = False
start_xml, final_xml = self._build_xml(is_initial)
if return_xml:
return (start_xml, final_xml)
if dry:
return
return self._create_guest(consolecb, meter, wait,
start_xml, final_xml, is_initial, False)
def _build_meter(self, meter, is_initial):
if is_initial:
meter_label = _("Creating domain...")
else:
meter_label = _("Starting domain...")
if meter is None:
meter = progress.BaseMeter()
meter.start(size=None, text=meter_label)
return meter
def _build_xml(self, is_initial):
log_label = is_initial and "install" or "continue"
disk_boot = not is_initial
start_xml = self.get_xml_config(install=True, disk_boot=disk_boot)
final_xml = self.get_xml_config(install=False)
logging.debug("Generated %s XML: %s",
log_label,
(start_xml and ("\n" + start_xml) or "None required"))
logging.debug("Generated boot XML: \n%s", final_xml)
return start_xml, final_xml
def _create_guest(self, consolecb, meter, wait,
start_xml, final_xml, is_initial, noboot):
"""
Actually do the XML logging, guest defining/creating, console
launching and waiting
@param is_initial: If running initial guest creation, else we
are continuing the install
@param noboot: Don't boot guest if no install phase
"""
meter = self._build_meter(meter, is_initial)
doboot = not noboot or self.installer.has_install_phase()
if not doboot:
consolecb = None
if is_initial and doboot:
dom = self.conn.createLinux(start_xml or final_xml, 0)
else:
dom = self.conn.defineXML(start_xml or final_xml)
if doboot:
dom.create()
self.domain = dom
meter.end(0)
if doboot:
logging.debug("Started guest, connecting to console if requested")
(self.domain,
self._consolechild) = self._wait_and_connect_console(consolecb)
self.domain = self.conn.defineXML(final_xml)
if is_initial:
try:
logging.debug("XML fetched from libvirt object:\n%s",
dom.XMLDesc(0))
except Exception, e:
logging.debug("Error fetching XML from libvirt object: %s", e)
# if we connected the console, wait for it to finish
self._waitpid_console(self._consolechild, wait)
return self.conn.lookupByName(self.name)
def _wait_and_connect_console(self, consolecb):
"""
Wait for domain to appear and be running, then connect to
the console if necessary
"""
child = None
dom = _wait_for_domain(self.conn, self.name)
if dom is None:
raise RuntimeError(_("Domain has not existed. You should be "
"able to find more information in the logs"))
elif dom.ID() == -1:
raise RuntimeError(_("Domain has not run yet. You should be "
"able to find more information in the logs"))
if consolecb:
child = consolecb(dom)
return dom, child
def _waitpid_console(self, console_child, do_wait):
"""
Wait for console to close if it was launched
"""
if not console_child or not do_wait:
return
try:
os.waitpid(console_child, 0)
except OSError, (err_no, msg):
logging.debug("waitpid: %s: %s", err_no, msg)
# ensure there's time for the domain to finish destroying if the
# install has finished or the guest crashed
time.sleep(1)
def _flag_autostart(self):
"""
Set the autostart flag for self.domain if the user requested it
"""
if not self.autostart:
return
try:
self.domain.setAutostart(True)
except libvirt.libvirtError, e:
if support.is_error_nosupport(e):
logging.warn("Could not set autostart flag: libvirt "
"connection does not support autostart.")
else:
raise e
###################
# Device defaults #
###################
def set_defaults(self):
"""
Public function to set guest defaults. Things like preferred
disk bus (unless one is specified). These changes are persistent.
The install process will call a non-persistent version, so calling
this manually isn't required.
"""
self._set_defaults(self.get_devices, self.remove_device,
self.features)
def _set_hvm_defaults(self, devlist_func, features):
disktype = VirtualDevice.VIRTUAL_DEV_DISK
nettype = VirtualDevice.VIRTUAL_DEV_NET
disk_bus = self._lookup_device_param(disktype, "bus")
net_model = self._lookup_device_param(nettype, "model")
# Only overwrite params if they weren't already specified
for net in devlist_func(nettype):
if net_model and not net.model:
net.model = net_model
for disk in devlist_func(disktype):
if (disk_bus and not disk.bus and
disk.device == VirtualDisk.DEVICE_DISK):
disk.bus = disk_bus
if self.clock.offset is None:
self.clock.offset = self._lookup_osdict_key("clock")
if features["acpi"] is None:
features["acpi"] = self._lookup_osdict_key("acpi")
if features["apic"] is None:
features["apic"] = self._lookup_osdict_key("apic")
if features["pae"] is None and self._get_caps():
features["pae"] = self._get_caps().support_pae()
if (self.installer.machine is None and
self._get_caps().host.arch == "ppc64"):
self.installer.machine = "pseries"
def _set_pv_defaults(self, devlist_func, remove_func):
# Default file backed PV guests to tap driver
for d in devlist_func(VirtualDevice.VIRTUAL_DEV_DISK):
if (d.type == VirtualDisk.TYPE_FILE
and util.is_blktap_capable()
and d.driver_name is None):
d.driver_name = VirtualDisk.DRIVER_TAP
for d in devlist_func(VirtualDevice.VIRTUAL_DEV_INPUT):
if d.type == d.INPUT_TYPE_DEFAULT:
d.type = d.INPUT_TYPE_MOUSE
if d.bus == d.INPUT_BUS_DEFAULT:
d.bus = d.INPUT_BUS_XEN
for d in devlist_func(VirtualDevice.VIRTUAL_DEV_CONSOLE):
if hasattr(d, "virtinst_default"):
remove_func(d)
def add_usb_ich9_controllers(self):
ctrl = VirtualControllerUSB(self.conn,
model="ich9-ehci1")
self.add_device(ctrl)
ctrl = VirtualControllerUSB(self.conn,
model="ich9-uhci1")
ctrl.get_master().startport = 0
self.add_device(ctrl)
ctrl = VirtualControllerUSB(self.conn,
model="ich9-uhci2")
ctrl.get_master().startport = 2
self.add_device(ctrl)
ctrl = VirtualControllerUSB(self.conn,
model="ich9-uhci3")
ctrl.get_master().startport = 4
self.add_device(ctrl)
def _set_defaults(self, devlist_func, remove_func, features):
if self.installer.is_hvm():
self._set_hvm_defaults(devlist_func, features)
if self.installer.is_xenpv():
self._set_pv_defaults(devlist_func, remove_func)
soundtype = VirtualDevice.VIRTUAL_DEV_AUDIO
videotype = VirtualDevice.VIRTUAL_DEV_VIDEO
inputtype = VirtualDevice.VIRTUAL_DEV_INPUT
gfxtype = VirtualDevice.VIRTUAL_DEV_GRAPHICS
channeltype = VirtualDevice.VIRTUAL_DEV_CHANNEL
# Set default input values
input_type = self._lookup_device_param(inputtype, "type")
input_bus = self._lookup_device_param(inputtype, "bus")
for inp in devlist_func(inputtype):
if (inp.type == inp.INPUT_TYPE_DEFAULT and
inp.bus == inp.INPUT_BUS_DEFAULT):
inp.type = input_type
inp.bus = input_bus
# Generate disk targets, and set preferred disk bus
used_targets = []
for disk in devlist_func(VirtualDevice.VIRTUAL_DEV_DISK):
if not disk.bus:
if disk.device == disk.DEVICE_FLOPPY:
disk.bus = "fdc"
else:
if self.installer.is_hvm():
if (self.installer.type == "kvm" and
self.installer.machine == "pseries"):
disk.bus = "scsi"
else:
disk.bus = "ide"
elif self.installer.is_xenpv():
disk.bus = "xen"
if disk.target:
used_targets.append(disk.target)
else:
used_targets.append(disk.generate_target(used_targets))
# Set sound device model
sound_model = self._lookup_device_param(soundtype, "model")
for sound in devlist_func(soundtype):
if sound.model == sound.MODEL_DEFAULT:
sound.model = sound_model
# Set video device model
# QXL device (only if we use spice) - safe even if guest is VGA only
def has_spice():
for gfx in devlist_func(gfxtype):
if gfx.type == gfx.TYPE_SPICE:
return True
if has_spice():
video_model = "qxl"
else:
video_model = self._lookup_device_param(videotype, "model_type")
for video in devlist_func(videotype):
if video.model_type == video.MODEL_DEFAULT:
video.model_type = video_model
# Spice agent channel (only if we use spice)
def has_spice_agent():
for chn in devlist_func(channeltype):
if chn.char_type == chn.CHAR_SPICEVMC:
return True
if (has_spice() and
not has_spice_agent() and
support.check_conn_support(self.conn,
support.SUPPORT_CONN_HV_CHAR_SPICEVMC)):
agentdev = VirtualCharDevice.get_dev_instance(self.conn,
VirtualCharDevice.DEV_CHANNEL,
VirtualCharDevice.CHAR_SPICEVMC)
self.add_device(agentdev)
# Generate UUID
if self.uuid is None:
self.uuid = util.generate_uuid(self.conn)
###################################
# Guest Dictionary Helper methods #
###################################
def _is_rhel6(self):
emulator = self.emulator or ""
return (self.type in ["qemu", "kvm"] and
emulator.startswith("/usr/libexec/qemu"))
def _lookup_osdict_key(self, key):
"""
Using self.os_type and self.os_variant to find key in OSTYPES
@returns: dict value, or None if os_type/variant wasn't set
"""
return osdict.lookup_osdict_key(self.conn, self.type,
self.os_type, self.os_variant,
key)
def _lookup_device_param(self, device_key, param):
"""
Check the OS dictionary for the prefered device setting for passed
device type and param (bus, model, etc.)
"""
try:
support.set_rhel6(self._is_rhel6())
return osdict.lookup_device_param(self.conn, self.type,
self.os_type, self.os_variant,
device_key, param)
finally:
support.set_rhel6(False)
def _wait_for_domain(conn, name):
# sleep in .25 second increments until either a) we get running
# domain ID or b) it's been 5 seconds. this is so that
# we can try to gracefully handle domain restarting failures
dom = None
for ignore in range(1, int(5 / .25)): # 5 seconds, .25 second sleeps
try:
dom = conn.lookupByName(name)
if dom and dom.ID() != -1:
break
except libvirt.libvirtError, e:
logging.debug("No guest running yet: " + str(e))
dom = None
time.sleep(0.25)
return dom
|
gpl-2.0
|
[
3,
199,
3,
13964,
1233,
367,
1006,
13980,
83,
199,
3,
199,
3,
1898,
8315,
13,
8664,
221,
9572,
13002,
12,
3277,
14,
199,
3,
1603,
69,
264,
1662,
1804,
10214,
665,
75,
10214,
74,
32,
17164,
14,
957,
30,
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,
221,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
221,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
199,
3,
4828,
11315,
13,
10067,
8217,
14,
199,
199,
646,
747,
199,
646,
900,
199,
646,
2050,
199,
646,
4673,
199,
199,
646,
1166,
22090,
605,
14,
5734,
465,
6696,
199,
646,
13108,
199,
646,
15404,
18,
199,
199,
504,
18291,
1346,
270,
492,
4884,
199,
504,
18291,
1346,
270,
492,
22516,
5807,
2842,
199,
504,
18291,
1346,
270,
492,
2291,
199,
504,
18291,
1346,
270,
492,
4692,
6437,
7705,
199,
646,
18291,
1346,
270,
199,
504,
18291,
1346,
270,
14,
4317,
6437,
7705,
492,
485,
1652,
63,
1829,
199,
504,
18291,
1346,
270,
14,
8735,
2510,
492,
13311,
2510,
199,
504,
18291,
1346,
270,
14,
8735,
10690,
492,
13311,
10690,
199,
504,
18291,
1346,
270,
14,
8735,
3205,
2510,
492,
13311,
3205,
2510,
199,
504,
18291,
1346,
270,
14,
8735,
1610,
2510,
492,
13311,
1610,
2510,
199,
504,
18291,
1346,
270,
14,
8735,
7506,
492,
13311,
7506,
19919,
199,
504,
18291,
1346,
270,
14,
17387,
492,
32425,
199,
504,
18291,
1346,
270,
14,
1513,
429,
902,
492,
3240,
429,
902,
199,
504,
18291,
1346,
270,
14,
11011,
492,
11952,
199,
504,
18291,
1346,
270,
14,
7705,
5667,
292,
11474,
492,
14061,
5667,
292,
11474,
199,
504,
18291,
1346,
270,
14,
7705,
10807,
492,
14061,
10807,
199,
199,
504,
18291,
1346,
270,
492,
747,
807,
421,
199,
533,
598,
5291,
8,
4317,
6437,
7705,
14,
4317,
6437,
7705,
304,
339,
327,
4403,
11932,
2955,
2860,
436,
3102,
272,
485,
30773,
275,
747,
807,
14,
30773,
272,
485,
3100,
63,
7893,
275,
747,
807,
14,
3100,
63,
7893,
339,
485,
885,
63,
736,
63,
466,
275,
488,
339,
768,
4639,
272,
347,
7268,
63,
736,
63,
513,
837,
267,
408,
267,
1432,
282,
6202,
6025,
402,
4403,
769,
367,
16116,
267,
408,
267,
2203,
275,
3087,
267,
367,
307,
315,
598,
5291,
14,
513,
63,
736,
63,
1313,
837,
288,
367,
373,
315,
598,
5291,
14,
513,
63,
736,
63,
15680,
8,
84,
304,
355,
2203,
847,
18301,
1165,
83,
520,
450,
83,
60,
78,
2,
450,
334,
86,
12,
598,
5291,
14,
362,
63,
736,
63,
8759,
63,
1302,
8,
84,
12,
373,
430,
267,
372,
2203,
339,
768,
4639,
272,
347,
769,
63,
736,
63,
1313,
8,
4946,
29,
797,
12,
2457,
2936,
29,
403,
304,
267,
408,
267,
768,
635,
2457,
2936,
26,
3820,
402,
1454,
21169,
781,
2934,
370,
2498,
701,
849,
267,
408,
267,
5322,
275,
747,
807,
14,
3191,
63,
3676,
8,
16022,
423,
3100,
63,
7893,
9,
267,
367,
307,
315,
5322,
32734,
288,
340,
440,
598,
5291,
14,
513,
63,
736,
63,
15680,
8,
84,
12,
3748,
29,
4946,
12,
5101,
2457,
2936,
29,
1541,
2936,
304,
355,
5322,
14,
2168,
8,
84,
9,
267,
372,
5322,
339,
768,
4639,
272,
347,
769,
63,
736,
63,
15680,
8,
9749,
12,
4069,
13829,
29,
403,
12,
3748,
29,
797,
12,
2457,
2936,
29,
403,
304,
267,
408,
267,
1432,
282,
769,
402,
3355,
747,
21169,
367,
314,
3032,
20499,
730,
398,
768,
635,
4069,
13829,
26,
1626,
945,
769,
402,
747,
807,
283,
18371,
7,
3762,
370,
267,
6791,
5277,
806,
315,
314,
2138,
769,
12,
325,
14,
71,
14,
9476,
2097,
28803,
937,
911,
1852,
267,
314,
3355,
769,
1172,
1006,
23036,
11131,
2917,
4796,
1642,
267,
768,
635,
2457,
2936,
26,
3820,
402,
1454,
21169,
781,
2934,
370,
2498,
701,
849,
267,
408,
267,
5322,
275,
747,
807,
14,
3191,
63,
3676,
8,
16022,
423,
3100,
63,
7893,
59,
9749,
7541,
15680,
2255,
3303,
4069,
13829,
9,
267,
2203,
275,
942,
267,
367,
373,
315,
5322,
26,
288,
340,
2457,
2936,
26,
355,
340,
373,
440,
315,
2457,
2936,
26,
490,
1980,
288,
916,
3748,
26,
355,
340,
440,
747,
807,
14,
3892,
63,
736,
807,
63,
498,
8,
403,
12,
488,
12,
6059,
6211,
12,
373,
12,
298,
4946,
2349,
490,
1980,
953,
2203,
14,
740,
8,
86,
9,
267,
372,
2203,
339,
768,
4639,
272,
347,
664,
63,
736,
63,
466,
63,
1302,
8,
9749,
304,
267,
372,
598,
5291,
423,
3100,
63,
7893,
59,
9749,
7541,
1302,
937,
339,
768,
4639,
272,
347,
664,
63,
736,
63,
8759,
63,
1302,
8,
9749,
12,
9854,
304,
267,
372,
598,
5291,
423,
3100,
63,
7893,
59,
9749,
7541,
15680,
9210,
8759,
7541,
1302,
937,
339,
768,
4639,
272,
347,
32479,
63,
495,
63,
475,
63,
2960,
8,
1631,
12,
32479,
304,
267,
372,
14061,
5667,
292,
11474,
14,
3541,
409,
63,
495,
63,
475,
63,
2960,
8,
1631,
12,
32479,
9,
339,
768,
4639,
272,
347,
3550,
63,
3541,
409,
8,
1631,
12,
7573,
304,
267,
408,
267,
21687,
282,
5033,
10713,
1835,
1059,
4079,
641,
1591,
653,
53,
2054,
2897,
14,
398,
982,
1591,
3181,
1133,
1172,
282,
11233,
653,
53,
2054,
2897,
12,
282,
6064,
267,
365,
14031,
14,
267,
408,
267,
22053,
275,
22516,
5807,
2842,
14,
1122,
8,
1631,
14,
362,
17006,
1012,
398,
340,
22053,
14,
1102,
14,
10775
] |
[
199,
3,
13964,
1233,
367,
1006,
13980,
83,
199,
3,
199,
3,
1898,
8315,
13,
8664,
221,
9572,
13002,
12,
3277,
14,
199,
3,
1603,
69,
264,
1662,
1804,
10214,
665,
75,
10214,
74,
32,
17164,
14,
957,
30,
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,
221,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
221,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
199,
3,
4828,
11315,
13,
10067,
8217,
14,
199,
199,
646,
747,
199,
646,
900,
199,
646,
2050,
199,
646,
4673,
199,
199,
646,
1166,
22090,
605,
14,
5734,
465,
6696,
199,
646,
13108,
199,
646,
15404,
18,
199,
199,
504,
18291,
1346,
270,
492,
4884,
199,
504,
18291,
1346,
270,
492,
22516,
5807,
2842,
199,
504,
18291,
1346,
270,
492,
2291,
199,
504,
18291,
1346,
270,
492,
4692,
6437,
7705,
199,
646,
18291,
1346,
270,
199,
504,
18291,
1346,
270,
14,
4317,
6437,
7705,
492,
485,
1652,
63,
1829,
199,
504,
18291,
1346,
270,
14,
8735,
2510,
492,
13311,
2510,
199,
504,
18291,
1346,
270,
14,
8735,
10690,
492,
13311,
10690,
199,
504,
18291,
1346,
270,
14,
8735,
3205,
2510,
492,
13311,
3205,
2510,
199,
504,
18291,
1346,
270,
14,
8735,
1610,
2510,
492,
13311,
1610,
2510,
199,
504,
18291,
1346,
270,
14,
8735,
7506,
492,
13311,
7506,
19919,
199,
504,
18291,
1346,
270,
14,
17387,
492,
32425,
199,
504,
18291,
1346,
270,
14,
1513,
429,
902,
492,
3240,
429,
902,
199,
504,
18291,
1346,
270,
14,
11011,
492,
11952,
199,
504,
18291,
1346,
270,
14,
7705,
5667,
292,
11474,
492,
14061,
5667,
292,
11474,
199,
504,
18291,
1346,
270,
14,
7705,
10807,
492,
14061,
10807,
199,
199,
504,
18291,
1346,
270,
492,
747,
807,
421,
199,
533,
598,
5291,
8,
4317,
6437,
7705,
14,
4317,
6437,
7705,
304,
339,
327,
4403,
11932,
2955,
2860,
436,
3102,
272,
485,
30773,
275,
747,
807,
14,
30773,
272,
485,
3100,
63,
7893,
275,
747,
807,
14,
3100,
63,
7893,
339,
485,
885,
63,
736,
63,
466,
275,
488,
339,
768,
4639,
272,
347,
7268,
63,
736,
63,
513,
837,
267,
408,
267,
1432,
282,
6202,
6025,
402,
4403,
769,
367,
16116,
267,
408,
267,
2203,
275,
3087,
267,
367,
307,
315,
598,
5291,
14,
513,
63,
736,
63,
1313,
837,
288,
367,
373,
315,
598,
5291,
14,
513,
63,
736,
63,
15680,
8,
84,
304,
355,
2203,
847,
18301,
1165,
83,
520,
450,
83,
60,
78,
2,
450,
334,
86,
12,
598,
5291,
14,
362,
63,
736,
63,
8759,
63,
1302,
8,
84,
12,
373,
430,
267,
372,
2203,
339,
768,
4639,
272,
347,
769,
63,
736,
63,
1313,
8,
4946,
29,
797,
12,
2457,
2936,
29,
403,
304,
267,
408,
267,
768,
635,
2457,
2936,
26,
3820,
402,
1454,
21169,
781,
2934,
370,
2498,
701,
849,
267,
408,
267,
5322,
275,
747,
807,
14,
3191,
63,
3676,
8,
16022,
423,
3100,
63,
7893,
9,
267,
367,
307,
315,
5322,
32734,
288,
340,
440,
598,
5291,
14,
513,
63,
736,
63,
15680,
8,
84,
12,
3748,
29,
4946,
12,
5101,
2457,
2936,
29,
1541,
2936,
304,
355,
5322,
14,
2168,
8,
84,
9,
267,
372,
5322,
339,
768,
4639,
272,
347,
769,
63,
736,
63,
15680,
8,
9749,
12,
4069,
13829,
29,
403,
12,
3748,
29,
797,
12,
2457,
2936,
29,
403,
304,
267,
408,
267,
1432,
282,
769,
402,
3355,
747,
21169,
367,
314,
3032,
20499,
730,
398,
768,
635,
4069,
13829,
26,
1626,
945,
769,
402,
747,
807,
283,
18371,
7,
3762,
370,
267,
6791,
5277,
806,
315,
314,
2138,
769,
12,
325,
14,
71,
14,
9476,
2097,
28803,
937,
911,
1852,
267,
314,
3355,
769,
1172,
1006,
23036,
11131,
2917,
4796,
1642,
267,
768,
635,
2457,
2936,
26,
3820,
402,
1454,
21169,
781,
2934,
370,
2498,
701,
849,
267,
408,
267,
5322,
275,
747,
807,
14,
3191,
63,
3676,
8,
16022,
423,
3100,
63,
7893,
59,
9749,
7541,
15680,
2255,
3303,
4069,
13829,
9,
267,
2203,
275,
942,
267,
367,
373,
315,
5322,
26,
288,
340,
2457,
2936,
26,
355,
340,
373,
440,
315,
2457,
2936,
26,
490,
1980,
288,
916,
3748,
26,
355,
340,
440,
747,
807,
14,
3892,
63,
736,
807,
63,
498,
8,
403,
12,
488,
12,
6059,
6211,
12,
373,
12,
298,
4946,
2349,
490,
1980,
953,
2203,
14,
740,
8,
86,
9,
267,
372,
2203,
339,
768,
4639,
272,
347,
664,
63,
736,
63,
466,
63,
1302,
8,
9749,
304,
267,
372,
598,
5291,
423,
3100,
63,
7893,
59,
9749,
7541,
1302,
937,
339,
768,
4639,
272,
347,
664,
63,
736,
63,
8759,
63,
1302,
8,
9749,
12,
9854,
304,
267,
372,
598,
5291,
423,
3100,
63,
7893,
59,
9749,
7541,
15680,
9210,
8759,
7541,
1302,
937,
339,
768,
4639,
272,
347,
32479,
63,
495,
63,
475,
63,
2960,
8,
1631,
12,
32479,
304,
267,
372,
14061,
5667,
292,
11474,
14,
3541,
409,
63,
495,
63,
475,
63,
2960,
8,
1631,
12,
32479,
9,
339,
768,
4639,
272,
347,
3550,
63,
3541,
409,
8,
1631,
12,
7573,
304,
267,
408,
267,
21687,
282,
5033,
10713,
1835,
1059,
4079,
641,
1591,
653,
53,
2054,
2897,
14,
398,
982,
1591,
3181,
1133,
1172,
282,
11233,
653,
53,
2054,
2897,
12,
282,
6064,
267,
365,
14031,
14,
267,
408,
267,
22053,
275,
22516,
5807,
2842,
14,
1122,
8,
1631,
14,
362,
17006,
1012,
398,
340,
22053,
14,
1102,
14,
10775,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
richardcs/ansible
|
test/units/modules/network/slxos/test_slxos_command.py
|
30
|
4734
|
#
# (c) 2018 Extreme Networks 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/>.
#
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json
from units.compat.mock import patch
from ansible.modules.network.slxos import slxos_command
from units.modules.utils import set_module_args
from .slxos_module import TestSlxosModule, load_fixture
class TestSlxosCommandModule(TestSlxosModule):
module = slxos_command
def setUp(self):
super(TestSlxosCommandModule, self).setUp()
self.mock_run_commands = patch('ansible.modules.network.slxos.slxos_command.run_commands')
self.run_commands = self.mock_run_commands.start()
def tearDown(self):
super(TestSlxosCommandModule, self).tearDown()
self.mock_run_commands.stop()
def load_fixtures(self, commands=None):
def load_from_file(*args, **kwargs):
module, commands = args
output = list()
for item in commands:
try:
obj = json.loads(item['command'])
command = obj['command']
except ValueError:
command = item['command']
filename = str(command).replace(' ', '_')
output.append(load_fixture(filename))
return output
self.run_commands.side_effect = load_from_file
def test_slxos_command_simple(self):
set_module_args(dict(commands=['show version']))
result = self.execute_module()
self.assertEqual(len(result['stdout']), 1)
self.assertTrue(result['stdout'][0].startswith('SLX-OS Operating System Software'))
def test_slxos_command_multiple(self):
set_module_args(dict(commands=['show version', 'show version']))
result = self.execute_module()
self.assertEqual(len(result['stdout']), 2)
self.assertTrue(result['stdout'][0].startswith('SLX-OS Operating System Software'))
def test_slxos_command_wait_for(self):
wait_for = 'result[0] contains "SLX-OS Operating System Software"'
set_module_args(dict(commands=['show version'], wait_for=wait_for))
self.execute_module()
def test_slxos_command_wait_for_fails(self):
wait_for = 'result[0] contains "test string"'
set_module_args(dict(commands=['show version'], wait_for=wait_for))
self.execute_module(failed=True)
self.assertEqual(self.run_commands.call_count, 10)
def test_slxos_command_retries(self):
wait_for = 'result[0] contains "test string"'
set_module_args(dict(commands=['show version'], wait_for=wait_for, retries=2))
self.execute_module(failed=True)
self.assertEqual(self.run_commands.call_count, 2)
def test_slxos_command_match_any(self):
wait_for = ['result[0] contains "SLX-OS"',
'result[0] contains "test string"']
set_module_args(dict(commands=['show version'], wait_for=wait_for, match='any'))
self.execute_module()
def test_slxos_command_match_all(self):
wait_for = ['result[0] contains "SLX-OS"',
'result[0] contains "SLX-OS Operating System Software"']
set_module_args(dict(commands=['show version'], wait_for=wait_for, match='all'))
self.execute_module()
def test_slxos_command_match_all_failure(self):
wait_for = ['result[0] contains "SLX-OS Operating System Software"',
'result[0] contains "test string"']
commands = ['show version', 'show version']
set_module_args(dict(commands=commands, wait_for=wait_for, match='all'))
self.execute_module(failed=True)
def test_slxos_command_configure_error(self):
commands = ['configure terminal']
set_module_args({
'commands': commands,
'_ansible_check_mode': True,
})
result = self.execute_module(failed=True)
self.assertEqual(
result['msg'],
'slxos_command does not support running config mode commands. '
'Please use slxos_config instead'
)
|
gpl-3.0
|
[
3,
199,
3,
334,
67,
9,
14894,
7255,
17817,
17138,
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,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
2022,
199,
199,
504,
6204,
14,
5819,
14,
1805,
492,
3371,
199,
504,
3242,
14,
3112,
14,
1200,
14,
2482,
22101,
492,
5340,
22101,
63,
1531,
199,
504,
6204,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
199,
504,
1275,
2482,
22101,
63,
578,
492,
1379,
11592,
22101,
2377,
12,
2248,
63,
5997,
421,
199,
533,
1379,
11592,
22101,
3110,
2377,
8,
774,
11592,
22101,
2377,
304,
339,
859,
275,
5340,
22101,
63,
1531,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
11592,
22101,
3110,
2377,
12,
291,
680,
5996,
342,
398,
291,
14,
1805,
63,
1065,
63,
4405,
275,
3371,
360,
4853,
14,
3112,
14,
1200,
14,
2482,
22101,
14,
2482,
22101,
63,
1531,
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,
11592,
22101,
3110,
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,
398,
347,
2248,
63,
504,
63,
493,
2031,
589,
12,
1011,
958,
304,
288,
859,
12,
3718,
275,
1249,
288,
1072,
275,
769,
342,
953,
367,
1242,
315,
3718,
26,
355,
862,
26,
490,
1559,
275,
2022,
14,
3640,
8,
1053,
459,
1531,
1105,
490,
1414,
275,
1559,
459,
1531,
418,
355,
871,
1722,
26,
490,
1414,
275,
1242,
459,
1531,
418,
355,
1788,
275,
620,
8,
1531,
680,
1814,
360,
1656,
18962,
355,
1072,
14,
740,
8,
912,
63,
5997,
8,
1501,
430,
288,
372,
1072,
398,
291,
14,
1065,
63,
4405,
14,
2441,
63,
5881,
275,
2248,
63,
504,
63,
493,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
4129,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
5156,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
552,
8,
1099,
459,
2703,
3815,
413,
9,
267,
291,
14,
1815,
8,
1099,
459,
2703,
3488,
16,
1055,
2460,
360,
4929,
56,
13,
3100,
6654,
1958,
6187,
2290,
1333,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
6048,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
297,
283,
2384,
1015,
5156,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
552,
8,
1099,
459,
2703,
3815,
499,
9,
267,
291,
14,
1815,
8,
1099,
459,
2703,
3488,
16,
1055,
2460,
360,
4929,
56,
13,
3100,
6654,
1958,
6187,
2290,
1333,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
2573,
63,
509,
8,
277,
304,
267,
3618,
63,
509,
275,
283,
1099,
59,
16,
61,
3509,
298,
4929,
56,
13,
3100,
6654,
1958,
6187,
2290,
4507,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
430,
267,
291,
14,
2526,
63,
578,
342,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
2573,
63,
509,
63,
15762,
8,
277,
304,
267,
3618,
63,
509,
275,
283,
1099,
59,
16,
61,
3509,
298,
396,
1059,
4507,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
430,
267,
291,
14,
2526,
63,
578,
8,
4892,
29,
549,
9,
267,
291,
14,
629,
8,
277,
14,
1065,
63,
4405,
14,
1250,
63,
835,
12,
1616,
9,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
10937,
8,
277,
304,
267,
3618,
63,
509,
275,
283,
1099,
59,
16,
61,
3509,
298,
396,
1059,
4507,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
12,
10086,
29,
18,
430,
267,
291,
14,
2526,
63,
578,
8,
4892,
29,
549,
9,
267,
291,
14,
629,
8,
277,
14,
1065,
63,
4405,
14,
1250,
63,
835,
12,
499,
9,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
1431,
63,
1629,
8,
277,
304,
267,
3618,
63,
509,
275,
788,
1099,
59,
16,
61,
3509,
298,
4929,
56,
13,
3100,
6949,
490,
283,
1099,
59,
16,
61,
3509,
298,
396,
1059,
2,
418,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
12,
1336,
534,
1629,
1333,
267,
291,
14,
2526,
63,
578,
342,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
1431,
63,
452,
8,
277,
304,
267,
3618,
63,
509,
275,
788,
1099,
59,
16,
61,
3509,
298,
4929,
56,
13,
3100,
6949,
490,
283,
1099,
59,
16,
61,
3509,
298,
4929,
56,
13,
3100,
6654,
1958,
6187,
2290,
2,
418,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
12,
1336,
534,
452,
1333,
267,
291,
14,
2526,
63,
578,
342,
339,
347,
511,
63,
2482
] |
[
199,
3,
334,
67,
9,
14894,
7255,
17817,
17138,
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,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
2022,
199,
199,
504,
6204,
14,
5819,
14,
1805,
492,
3371,
199,
504,
3242,
14,
3112,
14,
1200,
14,
2482,
22101,
492,
5340,
22101,
63,
1531,
199,
504,
6204,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
199,
504,
1275,
2482,
22101,
63,
578,
492,
1379,
11592,
22101,
2377,
12,
2248,
63,
5997,
421,
199,
533,
1379,
11592,
22101,
3110,
2377,
8,
774,
11592,
22101,
2377,
304,
339,
859,
275,
5340,
22101,
63,
1531,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
11592,
22101,
3110,
2377,
12,
291,
680,
5996,
342,
398,
291,
14,
1805,
63,
1065,
63,
4405,
275,
3371,
360,
4853,
14,
3112,
14,
1200,
14,
2482,
22101,
14,
2482,
22101,
63,
1531,
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,
11592,
22101,
3110,
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,
398,
347,
2248,
63,
504,
63,
493,
2031,
589,
12,
1011,
958,
304,
288,
859,
12,
3718,
275,
1249,
288,
1072,
275,
769,
342,
953,
367,
1242,
315,
3718,
26,
355,
862,
26,
490,
1559,
275,
2022,
14,
3640,
8,
1053,
459,
1531,
1105,
490,
1414,
275,
1559,
459,
1531,
418,
355,
871,
1722,
26,
490,
1414,
275,
1242,
459,
1531,
418,
355,
1788,
275,
620,
8,
1531,
680,
1814,
360,
1656,
18962,
355,
1072,
14,
740,
8,
912,
63,
5997,
8,
1501,
430,
288,
372,
1072,
398,
291,
14,
1065,
63,
4405,
14,
2441,
63,
5881,
275,
2248,
63,
504,
63,
493,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
4129,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
5156,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
552,
8,
1099,
459,
2703,
3815,
413,
9,
267,
291,
14,
1815,
8,
1099,
459,
2703,
3488,
16,
1055,
2460,
360,
4929,
56,
13,
3100,
6654,
1958,
6187,
2290,
1333,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
6048,
8,
277,
304,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
297,
283,
2384,
1015,
5156,
267,
754,
275,
291,
14,
2526,
63,
578,
342,
267,
291,
14,
629,
8,
552,
8,
1099,
459,
2703,
3815,
499,
9,
267,
291,
14,
1815,
8,
1099,
459,
2703,
3488,
16,
1055,
2460,
360,
4929,
56,
13,
3100,
6654,
1958,
6187,
2290,
1333,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
2573,
63,
509,
8,
277,
304,
267,
3618,
63,
509,
275,
283,
1099,
59,
16,
61,
3509,
298,
4929,
56,
13,
3100,
6654,
1958,
6187,
2290,
4507,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
430,
267,
291,
14,
2526,
63,
578,
342,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
2573,
63,
509,
63,
15762,
8,
277,
304,
267,
3618,
63,
509,
275,
283,
1099,
59,
16,
61,
3509,
298,
396,
1059,
4507,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
430,
267,
291,
14,
2526,
63,
578,
8,
4892,
29,
549,
9,
267,
291,
14,
629,
8,
277,
14,
1065,
63,
4405,
14,
1250,
63,
835,
12,
1616,
9,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
10937,
8,
277,
304,
267,
3618,
63,
509,
275,
283,
1099,
59,
16,
61,
3509,
298,
396,
1059,
4507,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
12,
10086,
29,
18,
430,
267,
291,
14,
2526,
63,
578,
8,
4892,
29,
549,
9,
267,
291,
14,
629,
8,
277,
14,
1065,
63,
4405,
14,
1250,
63,
835,
12,
499,
9,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
1431,
63,
1629,
8,
277,
304,
267,
3618,
63,
509,
275,
788,
1099,
59,
16,
61,
3509,
298,
4929,
56,
13,
3100,
6949,
490,
283,
1099,
59,
16,
61,
3509,
298,
396,
1059,
2,
418,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
12,
1336,
534,
1629,
1333,
267,
291,
14,
2526,
63,
578,
342,
339,
347,
511,
63,
2482,
22101,
63,
1531,
63,
1431,
63,
452,
8,
277,
304,
267,
3618,
63,
509,
275,
788,
1099,
59,
16,
61,
3509,
298,
4929,
56,
13,
3100,
6949,
490,
283,
1099,
59,
16,
61,
3509,
298,
4929,
56,
13,
3100,
6654,
1958,
6187,
2290,
2,
418,
267,
663,
63,
578,
63,
589,
8,
807,
8,
4405,
2968,
2384,
1015,
995,
3618,
63,
509,
29,
2573,
63,
509,
12,
1336,
534,
452,
1333,
267,
291,
14,
2526,
63,
578,
342,
339,
347,
511,
63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
1,
1,
1,
1
] |
yuzie007/ph_analysis
|
ph_analysis/structure/displacements.py
|
1
|
3767
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
print_function, unicode_literals)
import numpy as np
import pandas as pd
__author__ = 'Yuji Ikeda'
__version__ = '0.1.0'
def create_statistical_functions():
return [
('sum', np.sum),
('avg.', np.average),
('s.d.', lambda x: np.std(x, ddof=0)),
('abs._sum', lambda x: np.sum(np.abs(x))),
('abs._avg.', lambda x: np.average(np.abs(x))),
('abs._s.d.', lambda x: np.std(np.abs(x), ddof=0)),
]
def create_data_stat(data, keys, properties):
"""
:param data: pandas.DataFrame
:param keys: List of strings
:param properties: List of strings
:return:
"""
functions = create_statistical_functions()
return data.groupby(keys, sort=False).agg(functions)[properties]
class Displacements(object):
def __init__(self, atoms, atoms_ideal):
self._atoms = atoms
self._atoms_ideal = atoms_ideal
self._initialize_data()
def _initialize_data(self):
data = pd.DataFrame()
data['symbol'] = self._atoms.get_chemical_symbols()
data['atom'] = ''
data = data.reset_index() # data['index'] is created
self._data = data
def run(self):
self.calculate_displacements()
self.write()
def _calculate_origin(self):
positions = self._atoms.get_scaled_positions()
positions_ideal = self._atoms_ideal.get_scaled_positions()
diff = positions - positions_ideal
diff -= np.rint(diff)
return np.average(diff, axis=0)
def calculate_displacements(self):
atoms = self._atoms
atoms_ideal =self._atoms_ideal
origin = self._calculate_origin()
positions = atoms.get_scaled_positions()
positions_ideal = atoms_ideal.get_scaled_positions()
diff = positions - (positions_ideal + origin)
diff -= np.rint(diff)
diff = np.dot(diff, atoms.get_cell()) # frac -> A
displacements = np.sqrt(np.sum(diff ** 2, axis=1))
self._data['displacement'] = displacements
def write(self):
filename = self._create_filename()
data = self._data
properties = ['displacement']
with open(filename, 'w') as f:
f.write(self._create_header())
f.write('{:<22s}{:<18s}'.format('#', 'displacements_(A)'))
f.write('\n')
for i, x in data.iterrows():
f.write('atom ')
f.write('{:11d}'.format(x['index']))
f.write(' {:5s}'.format(x['symbol']))
f.write('{:18.12f}'.format(x['displacement']))
f.write('\n')
f.write('\n')
# Write statistics for all atoms
data_stat = create_data_stat(data, 'atom', properties)
for k0, x in data_stat.iterrows():
for k1, v in x.iteritems():
f.write('{:16}'.format(k1[1]))
f.write(' {:5s}'.format(k0))
f.write('{:18.12f}'.format(v))
f.write('\n')
f.write('\n')
# Write statistics for each symbol
data_stat = create_data_stat(data, 'symbol', properties)
for k0, x in data_stat.iterrows():
for k1, v in x.iteritems():
f.write('{:16s}'.format(k1[1]))
f.write(' {:5s}'.format(k0))
f.write('{:18.12f}'.format(v))
f.write('\n')
f.write('\n')
def _create_header(self):
return ''
def _create_filename(self):
return 'displacements.dat'
def get_data(self):
return self._data
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
717,
870,
63,
1593,
12,
2649,
63,
5955,
9,
199,
646,
2680,
465,
980,
199,
646,
10634,
465,
6454,
199,
199,
363,
2502,
363,
275,
283,
24388,
8047,
473,
25503,
65,
7,
199,
363,
1023,
363,
275,
283,
16,
14,
17,
14,
16,
7,
421,
199,
318,
1218,
63,
1207,
30364,
63,
5777,
837,
272,
372,
359,
267,
661,
1838,
297,
980,
14,
1838,
395,
267,
661,
8595,
3130,
980,
14,
8536,
395,
267,
661,
83,
14,
68,
3130,
2400,
671,
26,
980,
14,
1516,
8,
88,
12,
29180,
29,
16,
1826,
267,
661,
2101,
423,
1838,
297,
2400,
671,
26,
980,
14,
1838,
8,
1590,
14,
2101,
8,
88,
11508,
267,
661,
2101,
423,
8595,
3130,
2400,
671,
26,
980,
14,
8536,
8,
1590,
14,
2101,
8,
88,
11508,
267,
661,
2101,
423,
83,
14,
68,
3130,
2400,
671,
26,
980,
14,
1516,
8,
1590,
14,
2101,
8,
88,
395,
29180,
29,
16,
1826,
272,
1622,
421,
199,
318,
1218,
63,
576,
63,
3736,
8,
576,
12,
2883,
12,
4382,
304,
272,
408,
339,
520,
635,
666,
26,
10634,
14,
9205,
272,
520,
635,
2883,
26,
3820,
402,
3326,
272,
520,
635,
4382,
26,
3820,
402,
3326,
272,
520,
1107,
26,
272,
408,
272,
3423,
275,
1218,
63,
1207,
30364,
63,
5777,
342,
272,
372,
666,
14,
16968,
8,
1612,
12,
4069,
29,
797,
680,
13452,
8,
5777,
2788,
3282,
61,
421,
199,
533,
5289,
2778,
1470,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
14503,
12,
14503,
63,
32564,
304,
267,
291,
423,
11521,
275,
14503,
267,
291,
423,
11521,
63,
32564,
275,
14503,
63,
32564,
267,
291,
423,
8489,
63,
576,
342,
339,
347,
485,
8489,
63,
576,
8,
277,
304,
267,
666,
275,
6454,
14,
9205,
342,
267,
666,
459,
5155,
418,
275,
291,
423,
11521,
14,
362,
63,
24448,
2652,
63,
7450,
342,
267,
666,
459,
4188,
418,
275,
2125,
267,
666,
275,
666,
14,
3958,
63,
1080,
342,
221,
327,
666,
459,
1080,
418,
365,
2737,
267,
291,
423,
576,
275,
666,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
12063,
63,
13654,
1071,
1470,
342,
267,
291,
14,
952,
342,
339,
347,
485,
12063,
63,
6493,
8,
277,
304,
267,
12266,
275,
291,
423,
11521,
14,
362,
63,
15120,
63,
12658,
342,
267,
12266,
63,
32564,
275,
291,
423,
11521,
63,
32564,
14,
362,
63,
15120,
63,
12658,
342,
267,
3915,
275,
12266,
446,
12266,
63,
32564,
267,
3915,
4862,
980,
14,
672,
8,
3028,
9,
267,
372,
980,
14,
8536,
8,
3028,
12,
3114,
29,
16,
9,
339,
347,
8671,
63,
13654,
1071,
1470,
8,
277,
304,
267,
14503,
275,
291,
423,
11521,
267,
14503,
63,
32564,
275,
277,
423,
11521,
63,
32564,
398,
6330,
275,
291,
423,
12063,
63,
6493,
342,
398,
12266,
275,
14503,
14,
362,
63,
15120,
63,
12658,
342,
267,
12266,
63,
32564,
275,
14503,
63,
32564,
14,
362,
63,
15120,
63,
12658,
342,
267,
3915,
275,
12266,
446,
334,
12658,
63,
32564,
435,
6330,
9,
267,
3915,
4862,
980,
14,
672,
8,
3028,
9,
267,
3915,
275,
980,
14,
3287,
8,
3028,
12,
14503,
14,
362,
63,
3890,
1012,
221,
327,
25028,
1035,
437,
267,
9628,
1071,
1470,
275,
980,
14,
5079,
8,
1590,
14,
1838,
8,
3028,
1011,
499,
12,
3114,
29,
17,
430,
398,
291,
423,
576,
459,
13654,
27350,
418,
275,
9628,
1071,
1470,
339,
347,
2218,
8,
277,
304,
267,
1788,
275,
291,
423,
981,
63,
1501,
342,
267,
666,
275,
291,
423,
576,
398,
4382,
275,
788,
13654,
27350,
418,
398,
543,
1551,
8,
1501,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
952,
8,
277,
423,
981,
63,
1291,
1012,
288,
289,
14,
952,
11117,
16875,
1081,
83,
8847,
16875,
1085,
83,
5285,
908,
7863,
297,
283,
13654,
1071,
1470,
2531,
33,
9,
1333,
288,
289,
14,
952,
2258,
78,
358,
288,
367,
284,
12,
671,
315,
666,
14,
1661,
3838,
837,
355,
289,
14,
952,
360,
4188,
5320,
355,
289,
14,
952,
11117,
26,
845,
68,
5285,
908,
8,
88,
459,
1080,
5156,
355,
289,
14,
952,
360,
19850,
21,
83,
5285,
908,
8,
88,
459,
5155,
5156,
355,
289,
14,
952,
11117,
26,
1085,
14,
713,
70,
5285,
908,
8,
88,
459,
13654,
27350,
5156,
355,
289,
14,
952,
2258,
78,
358,
953,
289,
14,
952,
2258,
78,
358,
953,
327,
6990,
11076,
367,
1006,
14503,
288,
666,
63,
3736,
275,
1218,
63,
576,
63,
3736,
8,
576,
12,
283,
4188,
297,
4382,
9,
288,
367,
1022,
16,
12,
671,
315,
666,
63,
3736,
14,
1661,
3838,
837,
355,
367,
1022,
17,
12,
373,
315,
671,
14,
4611,
837,
490,
289,
14,
952,
11117,
26,
975,
5285,
908,
8,
75,
17,
59,
17,
2459,
490,
289,
14,
952,
360,
19850,
21,
83,
5285,
908,
8,
75,
16,
430,
490,
289,
14,
952,
11117,
26,
1085,
14,
713,
70,
5285,
908,
8,
86,
430,
490,
289,
14,
952,
2258,
78,
358,
355,
289,
14,
952,
2258,
78,
358,
953,
327,
6990,
11076,
367,
1924,
5272,
288,
666,
63,
3736,
275,
1218,
63,
576,
63,
3736,
8,
576,
12,
283,
5155,
297,
4382,
9,
288,
367,
1022,
16,
12,
671,
315,
666,
63,
3736,
14,
1661,
3838,
837,
355,
367,
1022,
17,
12,
373,
315,
671,
14,
4611,
837,
490,
289,
14,
952,
11117,
26,
975,
83,
5285,
908,
8,
75,
17,
59,
17,
2459,
490,
289,
14,
952,
360,
19850,
21,
83,
5285,
908,
8,
75,
16,
430,
490,
289,
14,
952,
11117,
26,
1085,
14,
713,
70,
5285,
908,
8,
86,
430,
490,
289,
14,
952,
2258,
78,
358,
355,
289,
14,
952,
2258,
78,
358,
339,
347,
485,
981,
63,
1291,
8,
277,
304,
267,
372,
2125,
339,
347,
485,
981,
63,
1501,
8,
277,
304,
267,
372,
283,
13654,
1071,
1470,
14,
4616,
7,
339,
347,
664,
63,
576,
8,
277,
304,
267,
372,
291,
423,
576,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
717,
870,
63,
1593,
12,
2649,
63,
5955,
9,
199,
646,
2680,
465,
980,
199,
646,
10634,
465,
6454,
199,
199,
363,
2502,
363,
275,
283,
24388,
8047,
473,
25503,
65,
7,
199,
363,
1023,
363,
275,
283,
16,
14,
17,
14,
16,
7,
421,
199,
318,
1218,
63,
1207,
30364,
63,
5777,
837,
272,
372,
359,
267,
661,
1838,
297,
980,
14,
1838,
395,
267,
661,
8595,
3130,
980,
14,
8536,
395,
267,
661,
83,
14,
68,
3130,
2400,
671,
26,
980,
14,
1516,
8,
88,
12,
29180,
29,
16,
1826,
267,
661,
2101,
423,
1838,
297,
2400,
671,
26,
980,
14,
1838,
8,
1590,
14,
2101,
8,
88,
11508,
267,
661,
2101,
423,
8595,
3130,
2400,
671,
26,
980,
14,
8536,
8,
1590,
14,
2101,
8,
88,
11508,
267,
661,
2101,
423,
83,
14,
68,
3130,
2400,
671,
26,
980,
14,
1516,
8,
1590,
14,
2101,
8,
88,
395,
29180,
29,
16,
1826,
272,
1622,
421,
199,
318,
1218,
63,
576,
63,
3736,
8,
576,
12,
2883,
12,
4382,
304,
272,
408,
339,
520,
635,
666,
26,
10634,
14,
9205,
272,
520,
635,
2883,
26,
3820,
402,
3326,
272,
520,
635,
4382,
26,
3820,
402,
3326,
272,
520,
1107,
26,
272,
408,
272,
3423,
275,
1218,
63,
1207,
30364,
63,
5777,
342,
272,
372,
666,
14,
16968,
8,
1612,
12,
4069,
29,
797,
680,
13452,
8,
5777,
2788,
3282,
61,
421,
199,
533,
5289,
2778,
1470,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
14503,
12,
14503,
63,
32564,
304,
267,
291,
423,
11521,
275,
14503,
267,
291,
423,
11521,
63,
32564,
275,
14503,
63,
32564,
267,
291,
423,
8489,
63,
576,
342,
339,
347,
485,
8489,
63,
576,
8,
277,
304,
267,
666,
275,
6454,
14,
9205,
342,
267,
666,
459,
5155,
418,
275,
291,
423,
11521,
14,
362,
63,
24448,
2652,
63,
7450,
342,
267,
666,
459,
4188,
418,
275,
2125,
267,
666,
275,
666,
14,
3958,
63,
1080,
342,
221,
327,
666,
459,
1080,
418,
365,
2737,
267,
291,
423,
576,
275,
666,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
12063,
63,
13654,
1071,
1470,
342,
267,
291,
14,
952,
342,
339,
347,
485,
12063,
63,
6493,
8,
277,
304,
267,
12266,
275,
291,
423,
11521,
14,
362,
63,
15120,
63,
12658,
342,
267,
12266,
63,
32564,
275,
291,
423,
11521,
63,
32564,
14,
362,
63,
15120,
63,
12658,
342,
267,
3915,
275,
12266,
446,
12266,
63,
32564,
267,
3915,
4862,
980,
14,
672,
8,
3028,
9,
267,
372,
980,
14,
8536,
8,
3028,
12,
3114,
29,
16,
9,
339,
347,
8671,
63,
13654,
1071,
1470,
8,
277,
304,
267,
14503,
275,
291,
423,
11521,
267,
14503,
63,
32564,
275,
277,
423,
11521,
63,
32564,
398,
6330,
275,
291,
423,
12063,
63,
6493,
342,
398,
12266,
275,
14503,
14,
362,
63,
15120,
63,
12658,
342,
267,
12266,
63,
32564,
275,
14503,
63,
32564,
14,
362,
63,
15120,
63,
12658,
342,
267,
3915,
275,
12266,
446,
334,
12658,
63,
32564,
435,
6330,
9,
267,
3915,
4862,
980,
14,
672,
8,
3028,
9,
267,
3915,
275,
980,
14,
3287,
8,
3028,
12,
14503,
14,
362,
63,
3890,
1012,
221,
327,
25028,
1035,
437,
267,
9628,
1071,
1470,
275,
980,
14,
5079,
8,
1590,
14,
1838,
8,
3028,
1011,
499,
12,
3114,
29,
17,
430,
398,
291,
423,
576,
459,
13654,
27350,
418,
275,
9628,
1071,
1470,
339,
347,
2218,
8,
277,
304,
267,
1788,
275,
291,
423,
981,
63,
1501,
342,
267,
666,
275,
291,
423,
576,
398,
4382,
275,
788,
13654,
27350,
418,
398,
543,
1551,
8,
1501,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
952,
8,
277,
423,
981,
63,
1291,
1012,
288,
289,
14,
952,
11117,
16875,
1081,
83,
8847,
16875,
1085,
83,
5285,
908,
7863,
297,
283,
13654,
1071,
1470,
2531,
33,
9,
1333,
288,
289,
14,
952,
2258,
78,
358,
288,
367,
284,
12,
671,
315,
666,
14,
1661,
3838,
837,
355,
289,
14,
952,
360,
4188,
5320,
355,
289,
14,
952,
11117,
26,
845,
68,
5285,
908,
8,
88,
459,
1080,
5156,
355,
289,
14,
952,
360,
19850,
21,
83,
5285,
908,
8,
88,
459,
5155,
5156,
355,
289,
14,
952,
11117,
26,
1085,
14,
713,
70,
5285,
908,
8,
88,
459,
13654,
27350,
5156,
355,
289,
14,
952,
2258,
78,
358,
953,
289,
14,
952,
2258,
78,
358,
953,
327,
6990,
11076,
367,
1006,
14503,
288,
666,
63,
3736,
275,
1218,
63,
576,
63,
3736,
8,
576,
12,
283,
4188,
297,
4382,
9,
288,
367,
1022,
16,
12,
671,
315,
666,
63,
3736,
14,
1661,
3838,
837,
355,
367,
1022,
17,
12,
373,
315,
671,
14,
4611,
837,
490,
289,
14,
952,
11117,
26,
975,
5285,
908,
8,
75,
17,
59,
17,
2459,
490,
289,
14,
952,
360,
19850,
21,
83,
5285,
908,
8,
75,
16,
430,
490,
289,
14,
952,
11117,
26,
1085,
14,
713,
70,
5285,
908,
8,
86,
430,
490,
289,
14,
952,
2258,
78,
358,
355,
289,
14,
952,
2258,
78,
358,
953,
327,
6990,
11076,
367,
1924,
5272,
288,
666,
63,
3736,
275,
1218,
63,
576,
63,
3736,
8,
576,
12,
283,
5155,
297,
4382,
9,
288,
367,
1022,
16,
12,
671,
315,
666,
63,
3736,
14,
1661,
3838,
837,
355,
367,
1022,
17,
12,
373,
315,
671,
14,
4611,
837,
490,
289,
14,
952,
11117,
26,
975,
83,
5285,
908,
8,
75,
17,
59,
17,
2459,
490,
289,
14,
952,
360,
19850,
21,
83,
5285,
908,
8,
75,
16,
430,
490,
289,
14,
952,
11117,
26,
1085,
14,
713,
70,
5285,
908,
8,
86,
430,
490,
289,
14,
952,
2258,
78,
358,
355,
289,
14,
952,
2258,
78,
358,
339,
347,
485,
981,
63,
1291,
8,
277,
304,
267,
372,
2125,
339,
347,
485,
981,
63,
1501,
8,
277,
304,
267,
372,
283,
13654,
1071,
1470,
14,
4616,
7,
339,
347,
664,
63,
576,
8,
277,
304,
267,
372,
291,
423,
576,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1836
|
# -*- coding:utf-8 -*-
'''
测试注册用户
'''
import sys
import os
sys.path.append(os.getcwd())
from pycate.model import MInfo
import unittest
class SimpleWidgetTestCase(unittest.TestCase):
def setUp(self):
# from model.info_model import MInfo
# con = pymongo.Connection('localhost')
# self.db = con[config.mg_cfg['dbname']]
# self.db.authenticate(config.mg_cfg['dbuser'], config.mg_cfg['dbpass'])
cityid = 'changchun1'
# self.tab_info = self.db['jdhby_{0}'.format(cityid)]
self.minfo = MInfo(cityid)
class DefaultWidgetSizeTestCase(SimpleWidgetTestCase):
def runTest(self):
self.id_test = 'sadf'
post_data = {'def_uid': self.id_test, 'dsaf':'dasfvzc',
'dsa':'24klj'}
self.minfo.insert_data(post_data)
assert ( self.minfo.get_by_id(self.id_test) == post_data )
assert ( self.minfo.get_by_id('tt') is None )
# self.tab_info = self.db['jdhby_{0}'.format(cityid)]
def tearDown(self):
# self.muser.delete_by_user('value1')
self.minfo.delete_by_uid(self.id_test)
pass
class DefaultWidgetSizeTestCase2(SimpleWidgetTestCase):
def runTest(self):
self.id_test = 'sadfsadf'
post_data = {'def_uid': self.id_test, 'dsaf':'dasfvzc',
'dsa':'24klj', 'views':1}
self.minfo.insert_data(post_data)
for i in range(100):
self.minfo.update_view_count(self.id_test)
views = self.minfo.get_by_id(self.id_test)['views']
assert ( views == 101 )
# self.tab_info = self.db['jdhby_{0}'.format(cityid)]
def tearDown(self):
# self.muser.delete_by_user('value1')
self.minfo.delete_by_uid(self.id_test)
pass
|
mit
|
[
3,
1882,
2803,
26,
1624,
13,
24,
1882,
202,
199,
2344,
202,
199,
19451,
234,
8400,
244,
20021,
102,
17950,
235,
22445,
202,
199,
2344,
202,
199,
646,
984,
202,
199,
646,
747,
2999,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
9458,
1012,
2999,
199,
504,
1134,
1411,
14,
1238,
492,
603,
2354,
2999,
199,
646,
2882,
2999,
199,
533,
5870,
3339,
1746,
8,
2796,
14,
1746,
304,
1128,
347,
3613,
8,
277,
304,
1039,
327,
687,
1402,
14,
815,
63,
1238,
492,
603,
2354,
1039,
327,
406,
275,
21878,
14,
3225,
360,
5967,
358,
1039,
327,
291,
14,
697,
275,
406,
59,
888,
14,
6649,
63,
4128,
459,
13238,
6538,
1039,
327,
291,
14,
697,
14,
13975,
8,
888,
14,
6649,
63,
4128,
459,
68,
464,
332,
995,
1101,
14,
6649,
63,
4128,
459,
697,
1529,
1105,
1039,
14492,
344,
275,
283,
335,
621,
335,
324,
17,
7,
1039,
327,
291,
14,
2902,
63,
815,
275,
291,
14,
697,
459,
74,
7821,
991,
7348,
16,
5285,
908,
8,
3690,
344,
1874,
1039,
291,
14,
77,
815,
275,
603,
2354,
8,
3690,
344,
9,
2999,
199,
533,
3758,
3339,
2320,
1746,
8,
3184,
3339,
1746,
304,
18801,
347,
29779,
8,
277,
304,
1039,
291,
14,
344,
63,
396,
275,
283,
83,
24642,
7,
1039,
2963,
63,
576,
275,
791,
318,
63,
1535,
356,
291,
14,
344,
63,
396,
12,
283,
795,
2756,
5242,
24315,
13692,
26698,
297,
27843,
283,
24760,
5242,
1194,
9503,
74,
936,
1039,
291,
14,
77,
815,
14,
3176,
63,
576,
8,
1932,
63,
576,
9,
1039,
702,
334,
291,
14,
77,
815,
14,
362,
63,
991,
63,
344,
8,
277,
14,
344,
63,
396,
9,
508,
2963,
63,
576,
776,
1039,
702,
334,
291,
14,
77,
815,
14,
362,
63,
991,
63,
344,
360,
6215,
358,
365,
488,
776,
1039,
327,
291,
14,
2902,
63,
815,
275,
291,
14,
697,
459,
74,
7821,
991,
7348,
16,
5285,
908,
8,
3690,
344,
1874,
1128,
347,
6766,
8,
277,
304,
1039,
327,
291,
14,
77,
751,
14,
1807,
63,
991,
63,
751,
360,
585,
17,
358,
1039,
291,
14,
77,
815,
14,
1807,
63,
991,
63,
1535,
8,
277,
14,
344,
63,
396,
9,
1039,
986,
2999,
199,
533,
3758,
3339,
2320,
1746,
18,
8,
3184,
3339,
1746,
304,
18801,
347,
29779,
8,
277,
304,
1039,
291,
14,
344,
63,
396,
275,
283,
83,
350,
2319,
24642,
7,
1039,
2963,
63,
576,
275,
791,
318,
63,
1535,
356,
291,
14,
344,
63,
396,
12,
283,
795,
2756,
5242,
24315,
13692,
26698,
297,
27843,
283,
24760,
5242,
1194,
9503,
74,
297,
283,
4196,
356,
17,
93,
1039,
291,
14,
77,
815,
14,
3176,
63,
576,
8,
1932,
63,
576,
9,
1039,
367,
284,
315,
1425,
8,
1960,
304,
1675,
291,
14,
77,
815,
14,
873,
63,
1345,
63,
835,
8,
277,
14,
344,
63,
396,
9,
1039,
6858,
275,
291,
14,
77,
815,
14,
362,
63,
991,
63,
344,
8,
277,
14,
344,
63,
396,
11820,
4196,
418,
1039,
702,
334,
6858,
508,
14313,
776,
1039,
327,
291,
14,
2902,
63,
815,
275,
291,
14,
697,
459,
74,
7821,
991,
7348,
16,
5285,
908,
8,
3690,
344,
1874,
1128,
347,
6766,
8,
277,
304,
1039,
327,
291,
14,
77,
751,
14,
1807,
63,
991,
63,
751,
360,
585,
17,
358,
1039,
291,
14,
77,
815,
14,
1807,
63,
991,
63,
1535,
8,
277,
14,
344,
63,
396,
9,
1039,
986,
10060,
10060,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
1624,
13,
24,
1882,
202,
199,
2344,
202,
199,
19451,
234,
8400,
244,
20021,
102,
17950,
235,
22445,
202,
199,
2344,
202,
199,
646,
984,
202,
199,
646,
747,
2999,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
9458,
1012,
2999,
199,
504,
1134,
1411,
14,
1238,
492,
603,
2354,
2999,
199,
646,
2882,
2999,
199,
533,
5870,
3339,
1746,
8,
2796,
14,
1746,
304,
1128,
347,
3613,
8,
277,
304,
1039,
327,
687,
1402,
14,
815,
63,
1238,
492,
603,
2354,
1039,
327,
406,
275,
21878,
14,
3225,
360,
5967,
358,
1039,
327,
291,
14,
697,
275,
406,
59,
888,
14,
6649,
63,
4128,
459,
13238,
6538,
1039,
327,
291,
14,
697,
14,
13975,
8,
888,
14,
6649,
63,
4128,
459,
68,
464,
332,
995,
1101,
14,
6649,
63,
4128,
459,
697,
1529,
1105,
1039,
14492,
344,
275,
283,
335,
621,
335,
324,
17,
7,
1039,
327,
291,
14,
2902,
63,
815,
275,
291,
14,
697,
459,
74,
7821,
991,
7348,
16,
5285,
908,
8,
3690,
344,
1874,
1039,
291,
14,
77,
815,
275,
603,
2354,
8,
3690,
344,
9,
2999,
199,
533,
3758,
3339,
2320,
1746,
8,
3184,
3339,
1746,
304,
18801,
347,
29779,
8,
277,
304,
1039,
291,
14,
344,
63,
396,
275,
283,
83,
24642,
7,
1039,
2963,
63,
576,
275,
791,
318,
63,
1535,
356,
291,
14,
344,
63,
396,
12,
283,
795,
2756,
5242,
24315,
13692,
26698,
297,
27843,
283,
24760,
5242,
1194,
9503,
74,
936,
1039,
291,
14,
77,
815,
14,
3176,
63,
576,
8,
1932,
63,
576,
9,
1039,
702,
334,
291,
14,
77,
815,
14,
362,
63,
991,
63,
344,
8,
277,
14,
344,
63,
396,
9,
508,
2963,
63,
576,
776,
1039,
702,
334,
291,
14,
77,
815,
14,
362,
63,
991,
63,
344,
360,
6215,
358,
365,
488,
776,
1039,
327,
291,
14,
2902,
63,
815,
275,
291,
14,
697,
459,
74,
7821,
991,
7348,
16,
5285,
908,
8,
3690,
344,
1874,
1128,
347,
6766,
8,
277,
304,
1039,
327,
291,
14,
77,
751,
14,
1807,
63,
991,
63,
751,
360,
585,
17,
358,
1039,
291,
14,
77,
815,
14,
1807,
63,
991,
63,
1535,
8,
277,
14,
344,
63,
396,
9,
1039,
986,
2999,
199,
533,
3758,
3339,
2320,
1746,
18,
8,
3184,
3339,
1746,
304,
18801,
347,
29779,
8,
277,
304,
1039,
291,
14,
344,
63,
396,
275,
283,
83,
350,
2319,
24642,
7,
1039,
2963,
63,
576,
275,
791,
318,
63,
1535,
356,
291,
14,
344,
63,
396,
12,
283,
795,
2756,
5242,
24315,
13692,
26698,
297,
27843,
283,
24760,
5242,
1194,
9503,
74,
297,
283,
4196,
356,
17,
93,
1039,
291,
14,
77,
815,
14,
3176,
63,
576,
8,
1932,
63,
576,
9,
1039,
367,
284,
315,
1425,
8,
1960,
304,
1675,
291,
14,
77,
815,
14,
873,
63,
1345,
63,
835,
8,
277,
14,
344,
63,
396,
9,
1039,
6858,
275,
291,
14,
77,
815,
14,
362,
63,
991,
63,
344,
8,
277,
14,
344,
63,
396,
11820,
4196,
418,
1039,
702,
334,
6858,
508,
14313,
776,
1039,
327,
291,
14,
2902,
63,
815,
275,
291,
14,
697,
459,
74,
7821,
991,
7348,
16,
5285,
908,
8,
3690,
344,
1874,
1128,
347,
6766,
8,
277,
304,
1039,
327,
291,
14,
77,
751,
14,
1807,
63,
991,
63,
751,
360,
585,
17,
358,
1039,
291,
14,
77,
815,
14,
1807,
63,
991,
63,
1535,
8,
277,
14,
344,
63,
396,
9,
1039,
986,
10060,
10060,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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/lr-wpan/bindings/modulegen__gcc_ILP32.py
|
10
|
485946
|
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.lr_wpan', cpp_namespace='::ns3')
return root_module
def register_types(module):
root_module = module.get_root()
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanTxOption [enumeration]
module.add_enum('LrWpanTxOption', ['TX_OPTION_NONE', 'TX_OPTION_ACK', 'TX_OPTION_GTS', 'TX_OPTION_INDIRECT'])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMacState [enumeration]
module.add_enum('LrWpanMacState', ['MAC_IDLE', 'MAC_CSMA', 'MAC_SENDING', 'MAC_ACK_PENDING', 'CHANNEL_ACCESS_FAILURE', 'CHANNEL_IDLE', 'SET_PHY_TX_ON'])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanAddressMode [enumeration]
module.add_enum('LrWpanAddressMode', ['NO_PANID_ADDR', 'ADDR_MODE_RESERVED', 'SHORT_ADDR', 'EXT_ADDR'])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanAssociationStatus [enumeration]
module.add_enum('LrWpanAssociationStatus', ['ASSOCIATED', 'PAN_AT_CAPACITY', 'PAN_ACCESS_DENIED', 'ASSOCIATED_WITHOUT_ADDRESS', 'DISASSOCIATED'])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMcpsDataConfirmStatus [enumeration]
module.add_enum('LrWpanMcpsDataConfirmStatus', ['IEEE_802_15_4_SUCCESS', 'IEEE_802_15_4_TRANSACTION_OVERFLOW', 'IEEE_802_15_4_TRANSACTION_EXPIRED', 'IEEE_802_15_4_CHANNEL_ACCESS_FAILURE', 'IEEE_802_15_4_INVALID_ADDRESS', 'IEEE_802_15_4_INVALID_GTS', 'IEEE_802_15_4_NO_ACK', 'IEEE_802_15_4_COUNTER_ERROR', 'IEEE_802_15_4_FRAME_TOO_LONG', 'IEEE_802_15_4_UNAVAILABLE_KEY', 'IEEE_802_15_4_UNSUPPORTED_SECURITY', 'IEEE_802_15_4_INVALID_PARAMETER'])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyOption [enumeration]
module.add_enum('LrWpanPhyOption', ['IEEE_802_15_4_868MHZ_BPSK', 'IEEE_802_15_4_915MHZ_BPSK', 'IEEE_802_15_4_868MHZ_ASK', 'IEEE_802_15_4_915MHZ_ASK', 'IEEE_802_15_4_868MHZ_OQPSK', 'IEEE_802_15_4_915MHZ_OQPSK', 'IEEE_802_15_4_2_4GHZ_OQPSK', 'IEEE_802_15_4_INVALID_PHY_OPTION'])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyEnumeration [enumeration]
module.add_enum('LrWpanPhyEnumeration', ['IEEE_802_15_4_PHY_BUSY', 'IEEE_802_15_4_PHY_BUSY_RX', 'IEEE_802_15_4_PHY_BUSY_TX', 'IEEE_802_15_4_PHY_FORCE_TRX_OFF', 'IEEE_802_15_4_PHY_IDLE', 'IEEE_802_15_4_PHY_INVALID_PARAMETER', 'IEEE_802_15_4_PHY_RX_ON', 'IEEE_802_15_4_PHY_SUCCESS', 'IEEE_802_15_4_PHY_TRX_OFF', 'IEEE_802_15_4_PHY_TX_ON', 'IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE', 'IEEE_802_15_4_PHY_READ_ONLY', 'IEEE_802_15_4_PHY_UNSPECIFIED'])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPibAttributeIdentifier [enumeration]
module.add_enum('LrWpanPibAttributeIdentifier', ['phyCurrentChannel', 'phyChannelsSupported', 'phyTransmitPower', 'phyCCAMode', 'phyCurrentPage', 'phyMaxFrameDuration', 'phySHRDuration', 'phySymbolsPerOctet'])
## 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')
## trace-helper.h (module 'network'): ns3::AsciiTraceHelper [class]
module.add_class('AsciiTraceHelper', import_from_module='ns.network')
## trace-helper.h (module 'network'): ns3::AsciiTraceHelperForDevice [class]
module.add_class('AsciiTraceHelperForDevice', allow_subclassing=True, 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')
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeAccessor> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::AttributeAccessor'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeChecker> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::AttributeChecker'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeValue> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::AttributeValue'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::CallbackImplBase> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::CallbackImplBase'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::EventImpl> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::EventImpl'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::Hash::Implementation> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::Hash::Implementation'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> [struct]
module.add_class('DefaultDeleter', template_parameters=['ns3::LrWpanInterferenceHelper'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::NixVector> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::NixVector'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::OutputStreamWrapper> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::OutputStreamWrapper'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::Packet> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::Packet'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::SpectrumSignalParameters> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::SpectrumSignalParameters'])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::TraceSourceAccessor> [struct]
module.add_class('DefaultDeleter', import_from_module='ns.core', template_parameters=['ns3::TraceSourceAccessor'])
## event-id.h (module 'core'): ns3::EventId [class]
module.add_class('EventId', 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')
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanEdPower [struct]
module.add_class('LrWpanEdPower')
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyDataAndSymbolRates [struct]
module.add_class('LrWpanPhyDataAndSymbolRates')
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes [struct]
module.add_class('LrWpanPhyPibAttributes')
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPpduHeaderSymbolNumber [struct]
module.add_class('LrWpanPhyPpduHeaderSymbolNumber')
## lr-wpan-spectrum-value-helper.h (module 'lr-wpan'): ns3::LrWpanSpectrumValueHelper [class]
module.add_class('LrWpanSpectrumValueHelper')
## mac16-address.h (module 'network'): ns3::Mac16Address [class]
module.add_class('Mac16Address', import_from_module='ns.network')
## mac16-address.h (module 'network'): ns3::Mac16Address [class]
root_module['ns3::Mac16Address'].implicitly_converts_to(root_module['ns3::Address'])
## 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'])
## mac64-address.h (module 'network'): ns3::Mac64Address [class]
module.add_class('Mac64Address', import_from_module='ns.network')
## mac64-address.h (module 'network'): ns3::Mac64Address [class]
root_module['ns3::Mac64Address'].implicitly_converts_to(root_module['ns3::Address'])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataConfirmParams [struct]
module.add_class('McpsDataConfirmParams')
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams [struct]
module.add_class('McpsDataIndicationParams')
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams [struct]
module.add_class('McpsDataRequestParams')
## net-device-container.h (module 'network'): ns3::NetDeviceContainer [class]
module.add_class('NetDeviceContainer', import_from_module='ns.network')
## node-container.h (module 'network'): ns3::NodeContainer [class]
module.add_class('NodeContainer', import_from_module='ns.network')
## 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')
## object-factory.h (module 'core'): ns3::ObjectFactory [class]
module.add_class('ObjectFactory', 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::ItemType [enumeration]
module.add_enum('ItemType', ['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'])
## pcap-file.h (module 'network'): ns3::PcapFile [class]
module.add_class('PcapFile', import_from_module='ns.network')
## trace-helper.h (module 'network'): ns3::PcapHelper [class]
module.add_class('PcapHelper', import_from_module='ns.network')
## trace-helper.h (module 'network'): ns3::PcapHelper::DataLinkType [enumeration]
module.add_enum('DataLinkType', ['DLT_NULL', 'DLT_EN10MB', 'DLT_PPP', 'DLT_RAW', 'DLT_IEEE802_11', 'DLT_LINUX_SLL', 'DLT_PRISM_HEADER', 'DLT_IEEE802_11_RADIO', 'DLT_IEEE802_15_4', 'DLT_NETLINK'], outer_class=root_module['ns3::PcapHelper'], import_from_module='ns.network')
## trace-helper.h (module 'network'): ns3::PcapHelperForDevice [class]
module.add_class('PcapHelperForDevice', allow_subclassing=True, import_from_module='ns.network')
## sequence-number.h (module 'network'): ns3::SequenceNumber<unsigned char, signed char> [class]
module.add_class('SequenceNumber8', import_from_module='ns.network')
## 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'))
## simulator.h (module 'core'): ns3::Simulator [class]
module.add_class('Simulator', destructor_visibility='private', import_from_module='ns.core')
## simulator.h (module 'core'): ns3::Simulator [enumeration]
module.add_enum('', ['NO_CONTEXT'], outer_class=root_module['ns3::Simulator'], import_from_module='ns.core')
## 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')
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanMacState> [class]
module.add_class('TracedValue', import_from_module='ns.core', template_parameters=['ns3::LrWpanMacState'])
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanPhyEnumeration> [class]
module.add_class('TracedValue', import_from_module='ns.core', template_parameters=['ns3::LrWpanPhyEnumeration'])
## 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-128.h (module 'core'): ns3::int64x64_t [class]
module.add_class('int64x64_t', import_from_module='ns.core')
## int64x64-128.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'])
## lr-wpan-helper.h (module 'lr-wpan'): ns3::LrWpanHelper [class]
module.add_class('LrWpanHelper', parent=[root_module['ns3::PcapHelperForDevice'], root_module['ns3::AsciiTraceHelperForDevice']])
## lr-wpan-lqi-tag.h (module 'lr-wpan'): ns3::LrWpanLqiTag [class]
module.add_class('LrWpanLqiTag', parent=root_module['ns3::Tag'])
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::LrWpanMacHeader [class]
module.add_class('LrWpanMacHeader', parent=root_module['ns3::Header'])
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::LrWpanMacHeader::LrWpanMacType [enumeration]
module.add_enum('LrWpanMacType', ['LRWPAN_MAC_BEACON', 'LRWPAN_MAC_DATA', 'LRWPAN_MAC_ACKNOWLEDGMENT', 'LRWPAN_MAC_COMMAND', 'LRWPAN_MAC_RESERVED'], outer_class=root_module['ns3::LrWpanMacHeader'])
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::LrWpanMacHeader::AddrModeType [enumeration]
module.add_enum('AddrModeType', ['NOADDR', 'RESADDR', 'SHORTADDR', 'EXTADDR'], outer_class=root_module['ns3::LrWpanMacHeader'])
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::LrWpanMacHeader::KeyIdModeType [enumeration]
module.add_enum('KeyIdModeType', ['IMPLICIT', 'NOKEYSOURCE', 'SHORTKEYSOURCE', 'LONGKEYSOURCE'], outer_class=root_module['ns3::LrWpanMacHeader'])
## 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'])
## pcap-file-wrapper.h (module 'network'): ns3::PcapFileWrapper [class]
module.add_class('PcapFileWrapper', import_from_module='ns.network', parent=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::EventImpl, ns3::empty, ns3::DefaultDeleter<ns3::EventImpl> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::EventImpl', 'ns3::empty', 'ns3::DefaultDeleter<ns3::EventImpl>'], 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::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, template_parameters=['ns3::LrWpanInterferenceHelper', 'ns3::empty', 'ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper>'], 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::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::OutputStreamWrapper', 'ns3::empty', 'ns3::DefaultDeleter<ns3::OutputStreamWrapper>'], 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::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter<ns3::SpectrumSignalParameters> > [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::SpectrumSignalParameters', 'ns3::empty', 'ns3::DefaultDeleter<ns3::SpectrumSignalParameters>'], 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'))
## spectrum-phy.h (module 'spectrum'): ns3::SpectrumPhy [class]
module.add_class('SpectrumPhy', import_from_module='ns.spectrum', parent=root_module['ns3::Object'])
## spectrum-signal-parameters.h (module 'spectrum'): ns3::SpectrumSignalParameters [struct]
module.add_class('SpectrumSignalParameters', import_from_module='ns.spectrum', parent=root_module['ns3::SimpleRefCount< ns3::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter<ns3::SpectrumSignalParameters> >'])
## 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> >'])
## boolean.h (module 'core'): ns3::BooleanChecker [class]
module.add_class('BooleanChecker', import_from_module='ns.core', parent=root_module['ns3::AttributeChecker'])
## boolean.h (module 'core'): ns3::BooleanValue [class]
module.add_class('BooleanValue', import_from_module='ns.core', parent=root_module['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'])
## double.h (module 'core'): ns3::DoubleValue [class]
module.add_class('DoubleValue', 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'])
## enum.h (module 'core'): ns3::EnumChecker [class]
module.add_class('EnumChecker', import_from_module='ns.core', parent=root_module['ns3::AttributeChecker'])
## enum.h (module 'core'): ns3::EnumValue [class]
module.add_class('EnumValue', import_from_module='ns.core', parent=root_module['ns3::AttributeValue'])
## event-impl.h (module 'core'): ns3::EventImpl [class]
module.add_class('EventImpl', import_from_module='ns.core', parent=root_module['ns3::SimpleRefCount< ns3::EventImpl, ns3::empty, ns3::DefaultDeleter<ns3::EventImpl> >'])
## integer.h (module 'core'): ns3::IntegerValue [class]
module.add_class('IntegerValue', 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'])
## lr-wpan-csmaca.h (module 'lr-wpan'): ns3::LrWpanCsmaCa [class]
module.add_class('LrWpanCsmaCa', parent=root_module['ns3::Object'])
## lr-wpan-error-model.h (module 'lr-wpan'): ns3::LrWpanErrorModel [class]
module.add_class('LrWpanErrorModel', parent=root_module['ns3::Object'])
## lr-wpan-interference-helper.h (module 'lr-wpan'): ns3::LrWpanInterferenceHelper [class]
module.add_class('LrWpanInterferenceHelper', parent=root_module['ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >'])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac [class]
module.add_class('LrWpanMac', parent=root_module['ns3::Object'])
## lr-wpan-mac-trailer.h (module 'lr-wpan'): ns3::LrWpanMacTrailer [class]
module.add_class('LrWpanMacTrailer', parent=root_module['ns3::Trailer'])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhy [class]
module.add_class('LrWpanPhy', parent=root_module['ns3::SpectrumPhy'])
## lr-wpan-spectrum-signal-parameters.h (module 'lr-wpan'): ns3::LrWpanSpectrumSignalParameters [struct]
module.add_class('LrWpanSpectrumSignalParameters', parent=root_module['ns3::SpectrumSignalParameters'])
## mac16-address.h (module 'network'): ns3::Mac16AddressChecker [class]
module.add_class('Mac16AddressChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker'])
## mac16-address.h (module 'network'): ns3::Mac16AddressValue [class]
module.add_class('Mac16AddressValue', 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'])
## mac64-address.h (module 'network'): ns3::Mac64AddressChecker [class]
module.add_class('Mac64AddressChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker'])
## mac64-address.h (module 'network'): ns3::Mac64AddressValue [class]
module.add_class('Mac64AddressValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue'])
## net-device.h (module 'network'): ns3::NetDevice [class]
module.add_class('NetDevice', import_from_module='ns.network', parent=root_module['ns3::Object'])
## net-device.h (module 'network'): ns3::NetDevice::PacketType [enumeration]
module.add_enum('PacketType', ['PACKET_HOST', 'NS3_PACKET_HOST', 'PACKET_BROADCAST', 'NS3_PACKET_BROADCAST', 'PACKET_MULTICAST', 'NS3_PACKET_MULTICAST', 'PACKET_OTHERHOST', 'NS3_PACKET_OTHERHOST'], outer_class=root_module['ns3::NetDevice'], import_from_module='ns.network')
## 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> >'])
## node.h (module 'network'): ns3::Node [class]
module.add_class('Node', import_from_module='ns.network', parent=root_module['ns3::Object'])
## object-factory.h (module 'core'): ns3::ObjectFactoryChecker [class]
module.add_class('ObjectFactoryChecker', import_from_module='ns.core', parent=root_module['ns3::AttributeChecker'])
## object-factory.h (module 'core'): ns3::ObjectFactoryValue [class]
module.add_class('ObjectFactoryValue', import_from_module='ns.core', parent=root_module['ns3::AttributeValue'])
## output-stream-wrapper.h (module 'network'): ns3::OutputStreamWrapper [class]
module.add_class('OutputStreamWrapper', import_from_module='ns.network', parent=root_module['ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >'])
## 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'])
## uinteger.h (module 'core'): ns3::UintegerValue [class]
module.add_class('UintegerValue', 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'])
## callback.h (module 'core'): ns3::CallbackImpl<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['bool', 'ns3::Ptr<ns3::NetDevice>', 'ns3::Ptr<const ns3::Packet>', 'unsigned short', 'const ns3::Address &', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['ns3::ObjectBase *', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::LrWpanMacState', 'ns3::LrWpanMacState', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::LrWpanPhyEnumeration', 'ns3::LrWpanPhyEnumeration', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', template_parameters=['void', 'ns3::McpsDataConfirmParams', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', template_parameters=['void', 'ns3::McpsDataIndicationParams', 'ns3::Ptr<ns3::Packet>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::Ptr<const ns3::Packet>', 'double', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::Ptr<const ns3::Packet>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::Ptr<const ns3::Packet>', 'unsigned char', 'unsigned char', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::Ptr<ns3::NetDevice>', 'ns3::Ptr<const ns3::Packet>', 'unsigned short', 'const ns3::Address &', 'const ns3::Address &', 'ns3::NetDevice::PacketType', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::Ptr<ns3::NetDevice>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::Time', 'ns3::LrWpanPhyEnumeration', 'ns3::LrWpanPhyEnumeration', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> [class]
module.add_class('CallbackImpl', import_from_module='ns.core', template_parameters=['void', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], parent=root_module['ns3::CallbackImplBase'])
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::LrWpanNetDevice [class]
module.add_class('LrWpanNetDevice', parent=root_module['ns3::NetDevice'])
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::LrWpanMacStateCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::LrWpanMacStateCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::LrWpanMacStateCallback&')
typehandlers.add_type_alias(u'ns3::LrWpanTxOption', u'ns3::LrWpanTxOption')
typehandlers.add_type_alias(u'ns3::LrWpanTxOption*', u'ns3::LrWpanTxOption*')
typehandlers.add_type_alias(u'ns3::LrWpanTxOption&', u'ns3::LrWpanTxOption&')
typehandlers.add_type_alias(u'ns3::LrWpanMacState', u'ns3::LrWpanMacState')
typehandlers.add_type_alias(u'ns3::LrWpanMacState*', u'ns3::LrWpanMacState*')
typehandlers.add_type_alias(u'ns3::LrWpanMacState&', u'ns3::LrWpanMacState&')
typehandlers.add_type_alias(u'ns3::LrWpanAddressMode', u'ns3::LrWpanAddressMode')
typehandlers.add_type_alias(u'ns3::LrWpanAddressMode*', u'ns3::LrWpanAddressMode*')
typehandlers.add_type_alias(u'ns3::LrWpanAddressMode&', u'ns3::LrWpanAddressMode&')
typehandlers.add_type_alias(u'ns3::LrWpanAssociationStatus', u'ns3::LrWpanAssociationStatus')
typehandlers.add_type_alias(u'ns3::LrWpanAssociationStatus*', u'ns3::LrWpanAssociationStatus*')
typehandlers.add_type_alias(u'ns3::LrWpanAssociationStatus&', u'ns3::LrWpanAssociationStatus&')
typehandlers.add_type_alias(u'ns3::LrWpanMcpsDataConfirmStatus', u'ns3::LrWpanMcpsDataConfirmStatus')
typehandlers.add_type_alias(u'ns3::LrWpanMcpsDataConfirmStatus*', u'ns3::LrWpanMcpsDataConfirmStatus*')
typehandlers.add_type_alias(u'ns3::LrWpanMcpsDataConfirmStatus&', u'ns3::LrWpanMcpsDataConfirmStatus&')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::McpsDataConfirmCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::McpsDataConfirmCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::McpsDataConfirmCallback&')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::McpsDataIndicationParams, ns3::Ptr< ns3::Packet >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::McpsDataIndicationCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::McpsDataIndicationParams, ns3::Ptr< ns3::Packet >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::McpsDataIndicationCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::McpsDataIndicationParams, ns3::Ptr< ns3::Packet >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::McpsDataIndicationCallback&')
typehandlers.add_type_alias(u'ns3::LrWpanEdPower', u'ns3::LrWpanEdPower')
typehandlers.add_type_alias(u'ns3::LrWpanEdPower*', u'ns3::LrWpanEdPower*')
typehandlers.add_type_alias(u'ns3::LrWpanEdPower&', u'ns3::LrWpanEdPower&')
module.add_typedef(root_module['ns3::LrWpanEdPower'], 'LrWpanEdPower')
typehandlers.add_type_alias(u'ns3::LrWpanPhyDataAndSymbolRates', u'ns3::LrWpanPhyDataAndSymbolRates')
typehandlers.add_type_alias(u'ns3::LrWpanPhyDataAndSymbolRates*', u'ns3::LrWpanPhyDataAndSymbolRates*')
typehandlers.add_type_alias(u'ns3::LrWpanPhyDataAndSymbolRates&', u'ns3::LrWpanPhyDataAndSymbolRates&')
module.add_typedef(root_module['ns3::LrWpanPhyDataAndSymbolRates'], 'LrWpanPhyDataAndSymbolRates')
typehandlers.add_type_alias(u'ns3::LrWpanPhyPpduHeaderSymbolNumber', u'ns3::LrWpanPhyPpduHeaderSymbolNumber')
typehandlers.add_type_alias(u'ns3::LrWpanPhyPpduHeaderSymbolNumber*', u'ns3::LrWpanPhyPpduHeaderSymbolNumber*')
typehandlers.add_type_alias(u'ns3::LrWpanPhyPpduHeaderSymbolNumber&', u'ns3::LrWpanPhyPpduHeaderSymbolNumber&')
module.add_typedef(root_module['ns3::LrWpanPhyPpduHeaderSymbolNumber'], 'LrWpanPhyPpduHeaderSymbolNumber')
typehandlers.add_type_alias(u'ns3::LrWpanPhyOption', u'ns3::LrWpanPhyOption')
typehandlers.add_type_alias(u'ns3::LrWpanPhyOption*', u'ns3::LrWpanPhyOption*')
typehandlers.add_type_alias(u'ns3::LrWpanPhyOption&', u'ns3::LrWpanPhyOption&')
typehandlers.add_type_alias(u'ns3::LrWpanPhyEnumeration', u'ns3::LrWpanPhyEnumeration')
typehandlers.add_type_alias(u'ns3::LrWpanPhyEnumeration*', u'ns3::LrWpanPhyEnumeration*')
typehandlers.add_type_alias(u'ns3::LrWpanPhyEnumeration&', u'ns3::LrWpanPhyEnumeration&')
typehandlers.add_type_alias(u'ns3::LrWpanPibAttributeIdentifier', u'ns3::LrWpanPibAttributeIdentifier')
typehandlers.add_type_alias(u'ns3::LrWpanPibAttributeIdentifier*', u'ns3::LrWpanPibAttributeIdentifier*')
typehandlers.add_type_alias(u'ns3::LrWpanPibAttributeIdentifier&', u'ns3::LrWpanPibAttributeIdentifier&')
typehandlers.add_type_alias(u'ns3::LrWpanPhyPibAttributes', u'ns3::LrWpanPhyPibAttributes')
typehandlers.add_type_alias(u'ns3::LrWpanPhyPibAttributes*', u'ns3::LrWpanPhyPibAttributes*')
typehandlers.add_type_alias(u'ns3::LrWpanPhyPibAttributes&', u'ns3::LrWpanPhyPibAttributes&')
module.add_typedef(root_module['ns3::LrWpanPhyPibAttributes'], 'LrWpanPhyPibAttributes')
typehandlers.add_type_alias(u'ns3::Callback< void, unsigned int, ns3::Ptr< ns3::Packet >, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::PdDataIndicationCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, unsigned int, ns3::Ptr< ns3::Packet >, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::PdDataIndicationCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, unsigned int, ns3::Ptr< ns3::Packet >, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::PdDataIndicationCallback&')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::PdDataConfirmCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::PdDataConfirmCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::PdDataConfirmCallback&')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::PlmeCcaConfirmCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::PlmeCcaConfirmCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::PlmeCcaConfirmCallback&')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::PlmeEdConfirmCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::PlmeEdConfirmCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::PlmeEdConfirmCallback&')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::LrWpanPhyPibAttributes *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::PlmeGetAttributeConfirmCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::LrWpanPhyPibAttributes *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::PlmeGetAttributeConfirmCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::LrWpanPhyPibAttributes *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::PlmeGetAttributeConfirmCallback&')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::PlmeSetTRXStateConfirmCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::PlmeSetTRXStateConfirmCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::PlmeSetTRXStateConfirmCallback&')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', u'ns3::PlmeSetAttributeConfirmCallback')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >*', u'ns3::PlmeSetAttributeConfirmCallback*')
typehandlers.add_type_alias(u'ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >&', u'ns3::PlmeSetAttributeConfirmCallback&')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned int, int >', u'ns3::SequenceNumber32')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned int, int >*', u'ns3::SequenceNumber32*')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned int, int >&', u'ns3::SequenceNumber32&')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned short, short >', u'ns3::SequenceNumber16')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned short, short >*', u'ns3::SequenceNumber16*')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned short, short >&', u'ns3::SequenceNumber16&')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned char, signed char >', u'ns3::SequenceNumber8')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned char, signed char >*', u'ns3::SequenceNumber8*')
typehandlers.add_type_alias(u'ns3::SequenceNumber< unsigned char, signed char >&', u'ns3::SequenceNumber8&')
## 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)
## Register a nested module for the namespace internal
nested_module = module.add_cpp_namespace('internal')
register_types_ns3_internal(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 const )', u'ns3::Hash::Hash32Function_ptr')
typehandlers.add_type_alias(u'uint32_t ( * ) ( char const *, size_t const )*', u'ns3::Hash::Hash32Function_ptr*')
typehandlers.add_type_alias(u'uint32_t ( * ) ( char const *, size_t const )&', u'ns3::Hash::Hash32Function_ptr&')
typehandlers.add_type_alias(u'uint64_t ( * ) ( char const *, size_t const )', u'ns3::Hash::Hash64Function_ptr')
typehandlers.add_type_alias(u'uint64_t ( * ) ( char const *, size_t const )*', u'ns3::Hash::Hash64Function_ptr*')
typehandlers.add_type_alias(u'uint64_t ( * ) ( char const *, size_t const )&', 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 ( * ) ( bool, bool )', u'ns3::TracedValueCallback::Bool')
typehandlers.add_type_alias(u'void ( * ) ( bool, bool )*', u'ns3::TracedValueCallback::Bool*')
typehandlers.add_type_alias(u'void ( * ) ( bool, bool )&', u'ns3::TracedValueCallback::Bool&')
typehandlers.add_type_alias(u'void ( * ) ( int8_t, int8_t )', u'ns3::TracedValueCallback::Int8')
typehandlers.add_type_alias(u'void ( * ) ( int8_t, int8_t )*', u'ns3::TracedValueCallback::Int8*')
typehandlers.add_type_alias(u'void ( * ) ( int8_t, int8_t )&', u'ns3::TracedValueCallback::Int8&')
typehandlers.add_type_alias(u'void ( * ) ( uint8_t, uint8_t )', u'ns3::TracedValueCallback::Uint8')
typehandlers.add_type_alias(u'void ( * ) ( uint8_t, uint8_t )*', u'ns3::TracedValueCallback::Uint8*')
typehandlers.add_type_alias(u'void ( * ) ( uint8_t, uint8_t )&', u'ns3::TracedValueCallback::Uint8&')
typehandlers.add_type_alias(u'void ( * ) ( int16_t, int16_t )', u'ns3::TracedValueCallback::Int16')
typehandlers.add_type_alias(u'void ( * ) ( int16_t, int16_t )*', u'ns3::TracedValueCallback::Int16*')
typehandlers.add_type_alias(u'void ( * ) ( int16_t, int16_t )&', u'ns3::TracedValueCallback::Int16&')
typehandlers.add_type_alias(u'void ( * ) ( uint16_t, uint16_t )', u'ns3::TracedValueCallback::Uint16')
typehandlers.add_type_alias(u'void ( * ) ( uint16_t, uint16_t )*', u'ns3::TracedValueCallback::Uint16*')
typehandlers.add_type_alias(u'void ( * ) ( uint16_t, uint16_t )&', u'ns3::TracedValueCallback::Uint16&')
typehandlers.add_type_alias(u'void ( * ) ( int32_t, int32_t )', u'ns3::TracedValueCallback::Int32')
typehandlers.add_type_alias(u'void ( * ) ( int32_t, int32_t )*', u'ns3::TracedValueCallback::Int32*')
typehandlers.add_type_alias(u'void ( * ) ( int32_t, int32_t )&', u'ns3::TracedValueCallback::Int32&')
typehandlers.add_type_alias(u'void ( * ) ( uint32_t, uint32_t )', u'ns3::TracedValueCallback::Uint32')
typehandlers.add_type_alias(u'void ( * ) ( uint32_t, uint32_t )*', u'ns3::TracedValueCallback::Uint32*')
typehandlers.add_type_alias(u'void ( * ) ( uint32_t, uint32_t )&', u'ns3::TracedValueCallback::Uint32&')
typehandlers.add_type_alias(u'void ( * ) ( double, double )', u'ns3::TracedValueCallback::Double')
typehandlers.add_type_alias(u'void ( * ) ( double, double )*', u'ns3::TracedValueCallback::Double*')
typehandlers.add_type_alias(u'void ( * ) ( double, double )&', u'ns3::TracedValueCallback::Double&')
typehandlers.add_type_alias(u'void ( * ) ( )', u'ns3::TracedValueCallback::Void')
typehandlers.add_type_alias(u'void ( * ) ( )*', u'ns3::TracedValueCallback::Void*')
typehandlers.add_type_alias(u'void ( * ) ( )&', u'ns3::TracedValueCallback::Void&')
typehandlers.add_type_alias(u'void ( * ) ( ns3::LrWpanMacState, ns3::LrWpanMacState )', u'ns3::TracedValueCallback::LrWpanMacState')
typehandlers.add_type_alias(u'void ( * ) ( ns3::LrWpanMacState, ns3::LrWpanMacState )*', u'ns3::TracedValueCallback::LrWpanMacState*')
typehandlers.add_type_alias(u'void ( * ) ( ns3::LrWpanMacState, ns3::LrWpanMacState )&', u'ns3::TracedValueCallback::LrWpanMacState&')
typehandlers.add_type_alias(u'void ( * ) ( ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration )', u'ns3::TracedValueCallback::LrWpanPhyEnumeration')
typehandlers.add_type_alias(u'void ( * ) ( ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration )*', u'ns3::TracedValueCallback::LrWpanPhyEnumeration*')
typehandlers.add_type_alias(u'void ( * ) ( ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration )&', u'ns3::TracedValueCallback::LrWpanPhyEnumeration&')
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&')
typehandlers.add_type_alias(u'void ( * ) ( ns3::SequenceNumber32, ns3::SequenceNumber32 )', u'ns3::TracedValueCallback::SequenceNumber32')
typehandlers.add_type_alias(u'void ( * ) ( ns3::SequenceNumber32, ns3::SequenceNumber32 )*', u'ns3::TracedValueCallback::SequenceNumber32*')
typehandlers.add_type_alias(u'void ( * ) ( ns3::SequenceNumber32, ns3::SequenceNumber32 )&', u'ns3::TracedValueCallback::SequenceNumber32&')
def register_types_ns3_internal(module):
root_module = module.get_root()
def register_methods(root_module):
register_Ns3Address_methods(root_module, root_module['ns3::Address'])
register_Ns3AsciiTraceHelper_methods(root_module, root_module['ns3::AsciiTraceHelper'])
register_Ns3AsciiTraceHelperForDevice_methods(root_module, root_module['ns3::AsciiTraceHelperForDevice'])
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_Ns3DefaultDeleter__Ns3AttributeAccessor_methods(root_module, root_module['ns3::DefaultDeleter< ns3::AttributeAccessor >'])
register_Ns3DefaultDeleter__Ns3AttributeChecker_methods(root_module, root_module['ns3::DefaultDeleter< ns3::AttributeChecker >'])
register_Ns3DefaultDeleter__Ns3AttributeValue_methods(root_module, root_module['ns3::DefaultDeleter< ns3::AttributeValue >'])
register_Ns3DefaultDeleter__Ns3CallbackImplBase_methods(root_module, root_module['ns3::DefaultDeleter< ns3::CallbackImplBase >'])
register_Ns3DefaultDeleter__Ns3EventImpl_methods(root_module, root_module['ns3::DefaultDeleter< ns3::EventImpl >'])
register_Ns3DefaultDeleter__Ns3HashImplementation_methods(root_module, root_module['ns3::DefaultDeleter< ns3::Hash::Implementation >'])
register_Ns3DefaultDeleter__Ns3LrWpanInterferenceHelper_methods(root_module, root_module['ns3::DefaultDeleter< ns3::LrWpanInterferenceHelper >'])
register_Ns3DefaultDeleter__Ns3NixVector_methods(root_module, root_module['ns3::DefaultDeleter< ns3::NixVector >'])
register_Ns3DefaultDeleter__Ns3OutputStreamWrapper_methods(root_module, root_module['ns3::DefaultDeleter< ns3::OutputStreamWrapper >'])
register_Ns3DefaultDeleter__Ns3Packet_methods(root_module, root_module['ns3::DefaultDeleter< ns3::Packet >'])
register_Ns3DefaultDeleter__Ns3SpectrumSignalParameters_methods(root_module, root_module['ns3::DefaultDeleter< ns3::SpectrumSignalParameters >'])
register_Ns3DefaultDeleter__Ns3TraceSourceAccessor_methods(root_module, root_module['ns3::DefaultDeleter< ns3::TraceSourceAccessor >'])
register_Ns3EventId_methods(root_module, root_module['ns3::EventId'])
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_Ns3LrWpanEdPower_methods(root_module, root_module['ns3::LrWpanEdPower'])
register_Ns3LrWpanPhyDataAndSymbolRates_methods(root_module, root_module['ns3::LrWpanPhyDataAndSymbolRates'])
register_Ns3LrWpanPhyPibAttributes_methods(root_module, root_module['ns3::LrWpanPhyPibAttributes'])
register_Ns3LrWpanPhyPpduHeaderSymbolNumber_methods(root_module, root_module['ns3::LrWpanPhyPpduHeaderSymbolNumber'])
register_Ns3LrWpanSpectrumValueHelper_methods(root_module, root_module['ns3::LrWpanSpectrumValueHelper'])
register_Ns3Mac16Address_methods(root_module, root_module['ns3::Mac16Address'])
register_Ns3Mac48Address_methods(root_module, root_module['ns3::Mac48Address'])
register_Ns3Mac64Address_methods(root_module, root_module['ns3::Mac64Address'])
register_Ns3McpsDataConfirmParams_methods(root_module, root_module['ns3::McpsDataConfirmParams'])
register_Ns3McpsDataIndicationParams_methods(root_module, root_module['ns3::McpsDataIndicationParams'])
register_Ns3McpsDataRequestParams_methods(root_module, root_module['ns3::McpsDataRequestParams'])
register_Ns3NetDeviceContainer_methods(root_module, root_module['ns3::NetDeviceContainer'])
register_Ns3NodeContainer_methods(root_module, root_module['ns3::NodeContainer'])
register_Ns3ObjectBase_methods(root_module, root_module['ns3::ObjectBase'])
register_Ns3ObjectDeleter_methods(root_module, root_module['ns3::ObjectDeleter'])
register_Ns3ObjectFactory_methods(root_module, root_module['ns3::ObjectFactory'])
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_Ns3PcapFile_methods(root_module, root_module['ns3::PcapFile'])
register_Ns3PcapHelper_methods(root_module, root_module['ns3::PcapHelper'])
register_Ns3PcapHelperForDevice_methods(root_module, root_module['ns3::PcapHelperForDevice'])
register_Ns3SequenceNumber8_methods(root_module, root_module['ns3::SequenceNumber8'])
register_Ns3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_methods(root_module, root_module['ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter >'])
register_Ns3Simulator_methods(root_module, root_module['ns3::Simulator'])
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_Ns3TracedValue__Ns3LrWpanMacState_methods(root_module, root_module['ns3::TracedValue< ns3::LrWpanMacState >'])
register_Ns3TracedValue__Ns3LrWpanPhyEnumeration_methods(root_module, root_module['ns3::TracedValue< ns3::LrWpanPhyEnumeration >'])
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_Ns3LrWpanHelper_methods(root_module, root_module['ns3::LrWpanHelper'])
register_Ns3LrWpanLqiTag_methods(root_module, root_module['ns3::LrWpanLqiTag'])
register_Ns3LrWpanMacHeader_methods(root_module, root_module['ns3::LrWpanMacHeader'])
register_Ns3Object_methods(root_module, root_module['ns3::Object'])
register_Ns3ObjectAggregateIterator_methods(root_module, root_module['ns3::Object::AggregateIterator'])
register_Ns3PcapFileWrapper_methods(root_module, root_module['ns3::PcapFileWrapper'])
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__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::EventImpl, ns3::empty, ns3::DefaultDeleter<ns3::EventImpl> >'])
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__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >'])
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__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >'])
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__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter<ns3::SpectrumSignalParameters> >'])
register_Ns3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> >'])
register_Ns3SpectrumPhy_methods(root_module, root_module['ns3::SpectrumPhy'])
register_Ns3SpectrumSignalParameters_methods(root_module, root_module['ns3::SpectrumSignalParameters'])
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_Ns3BooleanChecker_methods(root_module, root_module['ns3::BooleanChecker'])
register_Ns3BooleanValue_methods(root_module, root_module['ns3::BooleanValue'])
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_Ns3DoubleValue_methods(root_module, root_module['ns3::DoubleValue'])
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_Ns3EnumChecker_methods(root_module, root_module['ns3::EnumChecker'])
register_Ns3EnumValue_methods(root_module, root_module['ns3::EnumValue'])
register_Ns3EventImpl_methods(root_module, root_module['ns3::EventImpl'])
register_Ns3IntegerValue_methods(root_module, root_module['ns3::IntegerValue'])
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_Ns3LrWpanCsmaCa_methods(root_module, root_module['ns3::LrWpanCsmaCa'])
register_Ns3LrWpanErrorModel_methods(root_module, root_module['ns3::LrWpanErrorModel'])
register_Ns3LrWpanInterferenceHelper_methods(root_module, root_module['ns3::LrWpanInterferenceHelper'])
register_Ns3LrWpanMac_methods(root_module, root_module['ns3::LrWpanMac'])
register_Ns3LrWpanMacTrailer_methods(root_module, root_module['ns3::LrWpanMacTrailer'])
register_Ns3LrWpanPhy_methods(root_module, root_module['ns3::LrWpanPhy'])
register_Ns3LrWpanSpectrumSignalParameters_methods(root_module, root_module['ns3::LrWpanSpectrumSignalParameters'])
register_Ns3Mac16AddressChecker_methods(root_module, root_module['ns3::Mac16AddressChecker'])
register_Ns3Mac16AddressValue_methods(root_module, root_module['ns3::Mac16AddressValue'])
register_Ns3Mac48AddressChecker_methods(root_module, root_module['ns3::Mac48AddressChecker'])
register_Ns3Mac48AddressValue_methods(root_module, root_module['ns3::Mac48AddressValue'])
register_Ns3Mac64AddressChecker_methods(root_module, root_module['ns3::Mac64AddressChecker'])
register_Ns3Mac64AddressValue_methods(root_module, root_module['ns3::Mac64AddressValue'])
register_Ns3NetDevice_methods(root_module, root_module['ns3::NetDevice'])
register_Ns3NixVector_methods(root_module, root_module['ns3::NixVector'])
register_Ns3Node_methods(root_module, root_module['ns3::Node'])
register_Ns3ObjectFactoryChecker_methods(root_module, root_module['ns3::ObjectFactoryChecker'])
register_Ns3ObjectFactoryValue_methods(root_module, root_module['ns3::ObjectFactoryValue'])
register_Ns3OutputStreamWrapper_methods(root_module, root_module['ns3::OutputStreamWrapper'])
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_Ns3UintegerValue_methods(root_module, root_module['ns3::UintegerValue'])
register_Ns3AddressChecker_methods(root_module, root_module['ns3::AddressChecker'])
register_Ns3AddressValue_methods(root_module, root_module['ns3::AddressValue'])
register_Ns3CallbackImpl__Bool_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Ns3ObjectBase___star___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3LrWpanMacState_Ns3LrWpanMacState_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Double_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_char_Unsigned_char_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Const_ns3Address___amp___Ns3NetDevicePacketType_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3Time_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3CallbackImpl__Void_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, root_module['ns3::CallbackImpl< void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >'])
register_Ns3LrWpanNetDevice_methods(root_module, root_module['ns3::LrWpanNetDevice'])
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_binary_comparison_operator('<')
cls.add_output_stream_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) [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_Ns3AsciiTraceHelper_methods(root_module, cls):
## trace-helper.h (module 'network'): ns3::AsciiTraceHelper::AsciiTraceHelper(ns3::AsciiTraceHelper const & arg0) [constructor]
cls.add_constructor([param('ns3::AsciiTraceHelper const &', 'arg0')])
## trace-helper.h (module 'network'): ns3::AsciiTraceHelper::AsciiTraceHelper() [constructor]
cls.add_constructor([])
## trace-helper.h (module 'network'): ns3::Ptr<ns3::OutputStreamWrapper> ns3::AsciiTraceHelper::CreateFileStream(std::string filename, std::ios_base::openmode filemode=std::ios_base::out) [member function]
cls.add_method('CreateFileStream',
'ns3::Ptr< ns3::OutputStreamWrapper >',
[param('std::string', 'filename'), param('std::ios_base::openmode', 'filemode', default_value='std::ios_base::out')])
## trace-helper.h (module 'network'): static void ns3::AsciiTraceHelper::DefaultDequeueSinkWithContext(ns3::Ptr<ns3::OutputStreamWrapper> file, std::string context, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('DefaultDequeueSinkWithContext',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'file'), param('std::string', 'context'), param('ns3::Ptr< ns3::Packet const >', 'p')],
is_static=True)
## trace-helper.h (module 'network'): static void ns3::AsciiTraceHelper::DefaultDequeueSinkWithoutContext(ns3::Ptr<ns3::OutputStreamWrapper> file, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('DefaultDequeueSinkWithoutContext',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'file'), param('ns3::Ptr< ns3::Packet const >', 'p')],
is_static=True)
## trace-helper.h (module 'network'): static void ns3::AsciiTraceHelper::DefaultDropSinkWithContext(ns3::Ptr<ns3::OutputStreamWrapper> file, std::string context, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('DefaultDropSinkWithContext',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'file'), param('std::string', 'context'), param('ns3::Ptr< ns3::Packet const >', 'p')],
is_static=True)
## trace-helper.h (module 'network'): static void ns3::AsciiTraceHelper::DefaultDropSinkWithoutContext(ns3::Ptr<ns3::OutputStreamWrapper> file, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('DefaultDropSinkWithoutContext',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'file'), param('ns3::Ptr< ns3::Packet const >', 'p')],
is_static=True)
## trace-helper.h (module 'network'): static void ns3::AsciiTraceHelper::DefaultEnqueueSinkWithContext(ns3::Ptr<ns3::OutputStreamWrapper> file, std::string context, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('DefaultEnqueueSinkWithContext',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'file'), param('std::string', 'context'), param('ns3::Ptr< ns3::Packet const >', 'p')],
is_static=True)
## trace-helper.h (module 'network'): static void ns3::AsciiTraceHelper::DefaultEnqueueSinkWithoutContext(ns3::Ptr<ns3::OutputStreamWrapper> file, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('DefaultEnqueueSinkWithoutContext',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'file'), param('ns3::Ptr< ns3::Packet const >', 'p')],
is_static=True)
## trace-helper.h (module 'network'): static void ns3::AsciiTraceHelper::DefaultReceiveSinkWithContext(ns3::Ptr<ns3::OutputStreamWrapper> file, std::string context, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('DefaultReceiveSinkWithContext',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'file'), param('std::string', 'context'), param('ns3::Ptr< ns3::Packet const >', 'p')],
is_static=True)
## trace-helper.h (module 'network'): static void ns3::AsciiTraceHelper::DefaultReceiveSinkWithoutContext(ns3::Ptr<ns3::OutputStreamWrapper> file, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('DefaultReceiveSinkWithoutContext',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'file'), param('ns3::Ptr< ns3::Packet const >', 'p')],
is_static=True)
## trace-helper.h (module 'network'): std::string ns3::AsciiTraceHelper::GetFilenameFromDevice(std::string prefix, ns3::Ptr<ns3::NetDevice> device, bool useObjectNames=true) [member function]
cls.add_method('GetFilenameFromDevice',
'std::string',
[param('std::string', 'prefix'), param('ns3::Ptr< ns3::NetDevice >', 'device'), param('bool', 'useObjectNames', default_value='true')])
## trace-helper.h (module 'network'): std::string ns3::AsciiTraceHelper::GetFilenameFromInterfacePair(std::string prefix, ns3::Ptr<ns3::Object> object, uint32_t interface, bool useObjectNames=true) [member function]
cls.add_method('GetFilenameFromInterfacePair',
'std::string',
[param('std::string', 'prefix'), param('ns3::Ptr< ns3::Object >', 'object'), param('uint32_t', 'interface'), param('bool', 'useObjectNames', default_value='true')])
return
def register_Ns3AsciiTraceHelperForDevice_methods(root_module, cls):
## trace-helper.h (module 'network'): ns3::AsciiTraceHelperForDevice::AsciiTraceHelperForDevice(ns3::AsciiTraceHelperForDevice const & arg0) [constructor]
cls.add_constructor([param('ns3::AsciiTraceHelperForDevice const &', 'arg0')])
## trace-helper.h (module 'network'): ns3::AsciiTraceHelperForDevice::AsciiTraceHelperForDevice() [constructor]
cls.add_constructor([])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(std::string prefix, ns3::Ptr<ns3::NetDevice> nd, bool explicitFilename=false) [member function]
cls.add_method('EnableAscii',
'void',
[param('std::string', 'prefix'), param('ns3::Ptr< ns3::NetDevice >', 'nd'), param('bool', 'explicitFilename', default_value='false')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(ns3::Ptr<ns3::OutputStreamWrapper> stream, ns3::Ptr<ns3::NetDevice> nd) [member function]
cls.add_method('EnableAscii',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream'), param('ns3::Ptr< ns3::NetDevice >', 'nd')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(std::string prefix, std::string ndName, bool explicitFilename=false) [member function]
cls.add_method('EnableAscii',
'void',
[param('std::string', 'prefix'), param('std::string', 'ndName'), param('bool', 'explicitFilename', default_value='false')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(ns3::Ptr<ns3::OutputStreamWrapper> stream, std::string ndName) [member function]
cls.add_method('EnableAscii',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream'), param('std::string', 'ndName')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(std::string prefix, ns3::NetDeviceContainer d) [member function]
cls.add_method('EnableAscii',
'void',
[param('std::string', 'prefix'), param('ns3::NetDeviceContainer', 'd')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(ns3::Ptr<ns3::OutputStreamWrapper> stream, ns3::NetDeviceContainer d) [member function]
cls.add_method('EnableAscii',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream'), param('ns3::NetDeviceContainer', 'd')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(std::string prefix, ns3::NodeContainer n) [member function]
cls.add_method('EnableAscii',
'void',
[param('std::string', 'prefix'), param('ns3::NodeContainer', 'n')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(ns3::Ptr<ns3::OutputStreamWrapper> stream, ns3::NodeContainer n) [member function]
cls.add_method('EnableAscii',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream'), param('ns3::NodeContainer', 'n')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(std::string prefix, uint32_t nodeid, uint32_t deviceid, bool explicitFilename) [member function]
cls.add_method('EnableAscii',
'void',
[param('std::string', 'prefix'), param('uint32_t', 'nodeid'), param('uint32_t', 'deviceid'), param('bool', 'explicitFilename')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAscii(ns3::Ptr<ns3::OutputStreamWrapper> stream, uint32_t nodeid, uint32_t deviceid) [member function]
cls.add_method('EnableAscii',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream'), param('uint32_t', 'nodeid'), param('uint32_t', 'deviceid')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAsciiAll(std::string prefix) [member function]
cls.add_method('EnableAsciiAll',
'void',
[param('std::string', 'prefix')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAsciiAll(ns3::Ptr<ns3::OutputStreamWrapper> stream) [member function]
cls.add_method('EnableAsciiAll',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')])
## trace-helper.h (module 'network'): void ns3::AsciiTraceHelperForDevice::EnableAsciiInternal(ns3::Ptr<ns3::OutputStreamWrapper> stream, std::string prefix, ns3::Ptr<ns3::NetDevice> nd, bool explicitFilename) [member function]
cls.add_method('EnableAsciiInternal',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream'), param('std::string', 'prefix'), param('ns3::Ptr< ns3::NetDevice >', 'nd'), param('bool', 'explicitFilename')],
is_pure_virtual=True, is_virtual=True)
return
def register_Ns3AttributeConstructionList_methods(root_module, cls):
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::AttributeConstructionList(ns3::AttributeConstructionList const & arg0) [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<const ns3::AttributeChecker> 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'): ns3::AttributeConstructionList::CIterator ns3::AttributeConstructionList::Begin() const [member function]
cls.add_method('Begin',
'ns3::AttributeConstructionList::CIterator',
[],
is_const=True)
## attribute-construction-list.h (module 'core'): ns3::AttributeConstructionList::CIterator ns3::AttributeConstructionList::End() const [member function]
cls.add_method('End',
'ns3::AttributeConstructionList::CIterator',
[],
is_const=True)
## attribute-construction-list.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::AttributeConstructionList::Find(ns3::Ptr<const ns3::AttributeChecker> 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) [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(ns3::Buffer const & o) [constructor]
cls.add_constructor([param('ns3::Buffer const &', 'o')])
## 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'): 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) [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) [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) [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) [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) [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) [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) [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_Ns3DefaultDeleter__Ns3AttributeAccessor_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeAccessor>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeAccessor>::DefaultDeleter(ns3::DefaultDeleter<ns3::AttributeAccessor> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::AttributeAccessor > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::AttributeAccessor>::Delete(ns3::AttributeAccessor * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::AttributeAccessor *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3AttributeChecker_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeChecker>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeChecker>::DefaultDeleter(ns3::DefaultDeleter<ns3::AttributeChecker> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::AttributeChecker > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::AttributeChecker>::Delete(ns3::AttributeChecker * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::AttributeChecker *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3AttributeValue_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeValue>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::AttributeValue>::DefaultDeleter(ns3::DefaultDeleter<ns3::AttributeValue> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::AttributeValue > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::AttributeValue>::Delete(ns3::AttributeValue * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::AttributeValue *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3CallbackImplBase_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::CallbackImplBase>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::CallbackImplBase>::DefaultDeleter(ns3::DefaultDeleter<ns3::CallbackImplBase> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::CallbackImplBase > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::CallbackImplBase>::Delete(ns3::CallbackImplBase * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::CallbackImplBase *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3EventImpl_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::EventImpl>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::EventImpl>::DefaultDeleter(ns3::DefaultDeleter<ns3::EventImpl> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::EventImpl > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::EventImpl>::Delete(ns3::EventImpl * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::EventImpl *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3HashImplementation_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::Hash::Implementation>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::Hash::Implementation>::DefaultDeleter(ns3::DefaultDeleter<ns3::Hash::Implementation> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::Hash::Implementation > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::Hash::Implementation>::Delete(ns3::Hash::Implementation * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::Hash::Implementation *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3LrWpanInterferenceHelper_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper>::DefaultDeleter(ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::LrWpanInterferenceHelper > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper>::Delete(ns3::LrWpanInterferenceHelper * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::LrWpanInterferenceHelper *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3NixVector_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::NixVector>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::NixVector>::DefaultDeleter(ns3::DefaultDeleter<ns3::NixVector> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::NixVector > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::NixVector>::Delete(ns3::NixVector * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::NixVector *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3OutputStreamWrapper_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::OutputStreamWrapper>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::OutputStreamWrapper>::DefaultDeleter(ns3::DefaultDeleter<ns3::OutputStreamWrapper> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::OutputStreamWrapper > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::OutputStreamWrapper>::Delete(ns3::OutputStreamWrapper * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::OutputStreamWrapper *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3Packet_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::Packet>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::Packet>::DefaultDeleter(ns3::DefaultDeleter<ns3::Packet> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::Packet > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::Packet>::Delete(ns3::Packet * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::Packet *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3SpectrumSignalParameters_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::SpectrumSignalParameters>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::SpectrumSignalParameters>::DefaultDeleter(ns3::DefaultDeleter<ns3::SpectrumSignalParameters> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::SpectrumSignalParameters > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::SpectrumSignalParameters>::Delete(ns3::SpectrumSignalParameters * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::SpectrumSignalParameters *', 'object')],
is_static=True)
return
def register_Ns3DefaultDeleter__Ns3TraceSourceAccessor_methods(root_module, cls):
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::TraceSourceAccessor>::DefaultDeleter() [constructor]
cls.add_constructor([])
## default-deleter.h (module 'core'): ns3::DefaultDeleter<ns3::TraceSourceAccessor>::DefaultDeleter(ns3::DefaultDeleter<ns3::TraceSourceAccessor> const & arg0) [constructor]
cls.add_constructor([param('ns3::DefaultDeleter< ns3::TraceSourceAccessor > const &', 'arg0')])
## default-deleter.h (module 'core'): static void ns3::DefaultDeleter<ns3::TraceSourceAccessor>::Delete(ns3::TraceSourceAccessor * object) [member function]
cls.add_method('Delete',
'void',
[param('ns3::TraceSourceAccessor *', 'object')],
is_static=True)
return
def register_Ns3EventId_methods(root_module, cls):
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('!=')
cls.add_binary_comparison_operator('<')
## event-id.h (module 'core'): ns3::EventId::EventId(ns3::EventId const & arg0) [constructor]
cls.add_constructor([param('ns3::EventId const &', 'arg0')])
## event-id.h (module 'core'): ns3::EventId::EventId() [constructor]
cls.add_constructor([])
## event-id.h (module 'core'): ns3::EventId::EventId(ns3::Ptr<ns3::EventImpl> const & impl, uint64_t ts, uint32_t context, uint32_t uid) [constructor]
cls.add_constructor([param('ns3::Ptr< ns3::EventImpl > const &', 'impl'), param('uint64_t', 'ts'), param('uint32_t', 'context'), param('uint32_t', 'uid')])
## event-id.h (module 'core'): void ns3::EventId::Cancel() [member function]
cls.add_method('Cancel',
'void',
[])
## event-id.h (module 'core'): uint32_t ns3::EventId::GetContext() const [member function]
cls.add_method('GetContext',
'uint32_t',
[],
is_const=True)
## event-id.h (module 'core'): uint64_t ns3::EventId::GetTs() const [member function]
cls.add_method('GetTs',
'uint64_t',
[],
is_const=True)
## event-id.h (module 'core'): uint32_t ns3::EventId::GetUid() const [member function]
cls.add_method('GetUid',
'uint32_t',
[],
is_const=True)
## event-id.h (module 'core'): bool ns3::EventId::IsExpired() const [member function]
cls.add_method('IsExpired',
'bool',
[],
is_const=True)
## event-id.h (module 'core'): bool ns3::EventId::IsRunning() const [member function]
cls.add_method('IsRunning',
'bool',
[],
is_const=True)
## event-id.h (module 'core'): ns3::EventImpl * ns3::EventId::PeekEventImpl() const [member function]
cls.add_method('PeekEventImpl',
'ns3::EventImpl *',
[],
is_const=True)
return
def register_Ns3Hasher_methods(root_module, cls):
## hash.h (module 'core'): ns3::Hasher::Hasher(ns3::Hasher const & arg0) [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_output_stream_operator()
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('!=')
cls.add_binary_comparison_operator('<')
## ipv4-address.h (module 'network'): ns3::Ipv4Address::Ipv4Address(ns3::Ipv4Address const & arg0) [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_output_stream_operator()
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('!=')
## ipv4-address.h (module 'network'): ns3::Ipv4Mask::Ipv4Mask(ns3::Ipv4Mask const & arg0) [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_output_stream_operator()
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_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) [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',
[],
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_output_stream_operator()
cls.add_binary_comparison_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) [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_Ns3LrWpanEdPower_methods(root_module, cls):
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanEdPower() [constructor]
cls.add_constructor([])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanEdPower(ns3::LrWpanEdPower const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanEdPower const &', 'arg0')])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanEdPower::averagePower [variable]
cls.add_instance_attribute('averagePower', 'double', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanEdPower::lastUpdate [variable]
cls.add_instance_attribute('lastUpdate', 'ns3::Time', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanEdPower::measurementLength [variable]
cls.add_instance_attribute('measurementLength', 'ns3::Time', is_const=False)
return
def register_Ns3LrWpanPhyDataAndSymbolRates_methods(root_module, cls):
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyDataAndSymbolRates() [constructor]
cls.add_constructor([])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyDataAndSymbolRates(ns3::LrWpanPhyDataAndSymbolRates const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanPhyDataAndSymbolRates const &', 'arg0')])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyDataAndSymbolRates::bitRate [variable]
cls.add_instance_attribute('bitRate', 'double', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyDataAndSymbolRates::symbolRate [variable]
cls.add_instance_attribute('symbolRate', 'double', is_const=False)
return
def register_Ns3LrWpanPhyPibAttributes_methods(root_module, cls):
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes() [constructor]
cls.add_constructor([])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes(ns3::LrWpanPhyPibAttributes const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanPhyPibAttributes const &', 'arg0')])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes::phyCCAMode [variable]
cls.add_instance_attribute('phyCCAMode', 'uint8_t', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes::phyChannelsSupported [variable]
cls.add_instance_attribute('phyChannelsSupported', 'uint32_t [ 32 ]', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes::phyCurrentChannel [variable]
cls.add_instance_attribute('phyCurrentChannel', 'uint8_t', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes::phyCurrentPage [variable]
cls.add_instance_attribute('phyCurrentPage', 'uint32_t', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes::phyMaxFrameDuration [variable]
cls.add_instance_attribute('phyMaxFrameDuration', 'uint32_t', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes::phySHRDuration [variable]
cls.add_instance_attribute('phySHRDuration', 'uint32_t', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes::phySymbolsPerOctet [variable]
cls.add_instance_attribute('phySymbolsPerOctet', 'double', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPibAttributes::phyTransmitPower [variable]
cls.add_instance_attribute('phyTransmitPower', 'uint8_t', is_const=False)
return
def register_Ns3LrWpanPhyPpduHeaderSymbolNumber_methods(root_module, cls):
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPpduHeaderSymbolNumber() [constructor]
cls.add_constructor([])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPpduHeaderSymbolNumber(ns3::LrWpanPhyPpduHeaderSymbolNumber const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanPhyPpduHeaderSymbolNumber const &', 'arg0')])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPpduHeaderSymbolNumber::phr [variable]
cls.add_instance_attribute('phr', 'double', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPpduHeaderSymbolNumber::shrPreamble [variable]
cls.add_instance_attribute('shrPreamble', 'double', is_const=False)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhyPpduHeaderSymbolNumber::shrSfd [variable]
cls.add_instance_attribute('shrSfd', 'double', is_const=False)
return
def register_Ns3LrWpanSpectrumValueHelper_methods(root_module, cls):
## lr-wpan-spectrum-value-helper.h (module 'lr-wpan'): ns3::LrWpanSpectrumValueHelper::LrWpanSpectrumValueHelper(ns3::LrWpanSpectrumValueHelper const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanSpectrumValueHelper const &', 'arg0')])
## lr-wpan-spectrum-value-helper.h (module 'lr-wpan'): ns3::LrWpanSpectrumValueHelper::LrWpanSpectrumValueHelper() [constructor]
cls.add_constructor([])
## lr-wpan-spectrum-value-helper.h (module 'lr-wpan'): ns3::Ptr<ns3::SpectrumValue> ns3::LrWpanSpectrumValueHelper::CreateNoisePowerSpectralDensity(uint32_t channel) [member function]
cls.add_method('CreateNoisePowerSpectralDensity',
'ns3::Ptr< ns3::SpectrumValue >',
[param('uint32_t', 'channel')])
## lr-wpan-spectrum-value-helper.h (module 'lr-wpan'): ns3::Ptr<ns3::SpectrumValue> ns3::LrWpanSpectrumValueHelper::CreateTxPowerSpectralDensity(double txPower, uint32_t channel) [member function]
cls.add_method('CreateTxPowerSpectralDensity',
'ns3::Ptr< ns3::SpectrumValue >',
[param('double', 'txPower'), param('uint32_t', 'channel')])
## lr-wpan-spectrum-value-helper.h (module 'lr-wpan'): static double ns3::LrWpanSpectrumValueHelper::TotalAvgPower(ns3::Ptr<const ns3::SpectrumValue> psd, uint32_t channel) [member function]
cls.add_method('TotalAvgPower',
'double',
[param('ns3::Ptr< ns3::SpectrumValue const >', 'psd'), param('uint32_t', 'channel')],
is_static=True)
return
def register_Ns3Mac16Address_methods(root_module, cls):
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('!=')
cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
## mac16-address.h (module 'network'): ns3::Mac16Address::Mac16Address(ns3::Mac16Address const & arg0) [constructor]
cls.add_constructor([param('ns3::Mac16Address const &', 'arg0')])
## mac16-address.h (module 'network'): ns3::Mac16Address::Mac16Address() [constructor]
cls.add_constructor([])
## mac16-address.h (module 'network'): ns3::Mac16Address::Mac16Address(char const * str) [constructor]
cls.add_constructor([param('char const *', 'str')])
## mac16-address.h (module 'network'): static ns3::Mac16Address ns3::Mac16Address::Allocate() [member function]
cls.add_method('Allocate',
'ns3::Mac16Address',
[],
is_static=True)
## mac16-address.h (module 'network'): static ns3::Mac16Address ns3::Mac16Address::ConvertFrom(ns3::Address const & address) [member function]
cls.add_method('ConvertFrom',
'ns3::Mac16Address',
[param('ns3::Address const &', 'address')],
is_static=True)
## mac16-address.h (module 'network'): void ns3::Mac16Address::CopyFrom(uint8_t const * buffer) [member function]
cls.add_method('CopyFrom',
'void',
[param('uint8_t const *', 'buffer')])
## mac16-address.h (module 'network'): void ns3::Mac16Address::CopyTo(uint8_t * buffer) const [member function]
cls.add_method('CopyTo',
'void',
[param('uint8_t *', 'buffer')],
is_const=True)
## mac16-address.h (module 'network'): static bool ns3::Mac16Address::IsMatchingType(ns3::Address const & address) [member function]
cls.add_method('IsMatchingType',
'bool',
[param('ns3::Address const &', 'address')],
is_static=True)
return
def register_Ns3Mac48Address_methods(root_module, cls):
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('!=')
cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
## mac48-address.h (module 'network'): ns3::Mac48Address::Mac48Address(ns3::Mac48Address const & arg0) [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_Ns3Mac64Address_methods(root_module, cls):
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('!=')
cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
## mac64-address.h (module 'network'): ns3::Mac64Address::Mac64Address(ns3::Mac64Address const & arg0) [constructor]
cls.add_constructor([param('ns3::Mac64Address const &', 'arg0')])
## mac64-address.h (module 'network'): ns3::Mac64Address::Mac64Address() [constructor]
cls.add_constructor([])
## mac64-address.h (module 'network'): ns3::Mac64Address::Mac64Address(char const * str) [constructor]
cls.add_constructor([param('char const *', 'str')])
## mac64-address.h (module 'network'): static ns3::Mac64Address ns3::Mac64Address::Allocate() [member function]
cls.add_method('Allocate',
'ns3::Mac64Address',
[],
is_static=True)
## mac64-address.h (module 'network'): static ns3::Mac64Address ns3::Mac64Address::ConvertFrom(ns3::Address const & address) [member function]
cls.add_method('ConvertFrom',
'ns3::Mac64Address',
[param('ns3::Address const &', 'address')],
is_static=True)
## mac64-address.h (module 'network'): void ns3::Mac64Address::CopyFrom(uint8_t const * buffer) [member function]
cls.add_method('CopyFrom',
'void',
[param('uint8_t const *', 'buffer')])
## mac64-address.h (module 'network'): void ns3::Mac64Address::CopyTo(uint8_t * buffer) const [member function]
cls.add_method('CopyTo',
'void',
[param('uint8_t *', 'buffer')],
is_const=True)
## mac64-address.h (module 'network'): static bool ns3::Mac64Address::IsMatchingType(ns3::Address const & address) [member function]
cls.add_method('IsMatchingType',
'bool',
[param('ns3::Address const &', 'address')],
is_static=True)
return
def register_Ns3McpsDataConfirmParams_methods(root_module, cls):
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataConfirmParams::McpsDataConfirmParams() [constructor]
cls.add_constructor([])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataConfirmParams::McpsDataConfirmParams(ns3::McpsDataConfirmParams const & arg0) [constructor]
cls.add_constructor([param('ns3::McpsDataConfirmParams const &', 'arg0')])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataConfirmParams::m_msduHandle [variable]
cls.add_instance_attribute('m_msduHandle', 'uint8_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataConfirmParams::m_status [variable]
cls.add_instance_attribute('m_status', 'ns3::LrWpanMcpsDataConfirmStatus', is_const=False)
return
def register_Ns3McpsDataIndicationParams_methods(root_module, cls):
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::McpsDataIndicationParams() [constructor]
cls.add_constructor([])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::McpsDataIndicationParams(ns3::McpsDataIndicationParams const & arg0) [constructor]
cls.add_constructor([param('ns3::McpsDataIndicationParams const &', 'arg0')])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::m_dsn [variable]
cls.add_instance_attribute('m_dsn', 'uint8_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::m_dstAddr [variable]
cls.add_instance_attribute('m_dstAddr', 'ns3::Mac16Address', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::m_dstAddrMode [variable]
cls.add_instance_attribute('m_dstAddrMode', 'uint8_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::m_dstPanId [variable]
cls.add_instance_attribute('m_dstPanId', 'uint16_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::m_mpduLinkQuality [variable]
cls.add_instance_attribute('m_mpduLinkQuality', 'uint8_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::m_srcAddr [variable]
cls.add_instance_attribute('m_srcAddr', 'ns3::Mac16Address', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::m_srcAddrMode [variable]
cls.add_instance_attribute('m_srcAddrMode', 'uint8_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataIndicationParams::m_srcPanId [variable]
cls.add_instance_attribute('m_srcPanId', 'uint16_t', is_const=False)
return
def register_Ns3McpsDataRequestParams_methods(root_module, cls):
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams::McpsDataRequestParams(ns3::McpsDataRequestParams const & arg0) [constructor]
cls.add_constructor([param('ns3::McpsDataRequestParams const &', 'arg0')])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams::McpsDataRequestParams() [constructor]
cls.add_constructor([])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams::m_dstAddr [variable]
cls.add_instance_attribute('m_dstAddr', 'ns3::Mac16Address', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams::m_dstAddrMode [variable]
cls.add_instance_attribute('m_dstAddrMode', 'ns3::LrWpanAddressMode', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams::m_dstPanId [variable]
cls.add_instance_attribute('m_dstPanId', 'uint16_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams::m_msduHandle [variable]
cls.add_instance_attribute('m_msduHandle', 'uint8_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams::m_srcAddrMode [variable]
cls.add_instance_attribute('m_srcAddrMode', 'ns3::LrWpanAddressMode', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::McpsDataRequestParams::m_txOptions [variable]
cls.add_instance_attribute('m_txOptions', 'uint8_t', is_const=False)
return
def register_Ns3NetDeviceContainer_methods(root_module, cls):
## net-device-container.h (module 'network'): ns3::NetDeviceContainer::NetDeviceContainer(ns3::NetDeviceContainer const & arg0) [constructor]
cls.add_constructor([param('ns3::NetDeviceContainer const &', 'arg0')])
## net-device-container.h (module 'network'): ns3::NetDeviceContainer::NetDeviceContainer() [constructor]
cls.add_constructor([])
## net-device-container.h (module 'network'): ns3::NetDeviceContainer::NetDeviceContainer(ns3::Ptr<ns3::NetDevice> dev) [constructor]
cls.add_constructor([param('ns3::Ptr< ns3::NetDevice >', 'dev')])
## net-device-container.h (module 'network'): ns3::NetDeviceContainer::NetDeviceContainer(std::string devName) [constructor]
cls.add_constructor([param('std::string', 'devName')])
## net-device-container.h (module 'network'): ns3::NetDeviceContainer::NetDeviceContainer(ns3::NetDeviceContainer const & a, ns3::NetDeviceContainer const & b) [constructor]
cls.add_constructor([param('ns3::NetDeviceContainer const &', 'a'), param('ns3::NetDeviceContainer const &', 'b')])
## net-device-container.h (module 'network'): void ns3::NetDeviceContainer::Add(ns3::NetDeviceContainer other) [member function]
cls.add_method('Add',
'void',
[param('ns3::NetDeviceContainer', 'other')])
## net-device-container.h (module 'network'): void ns3::NetDeviceContainer::Add(ns3::Ptr<ns3::NetDevice> device) [member function]
cls.add_method('Add',
'void',
[param('ns3::Ptr< ns3::NetDevice >', 'device')])
## net-device-container.h (module 'network'): void ns3::NetDeviceContainer::Add(std::string deviceName) [member function]
cls.add_method('Add',
'void',
[param('std::string', 'deviceName')])
## net-device-container.h (module 'network'): ns3::NetDeviceContainer::Iterator ns3::NetDeviceContainer::Begin() const [member function]
cls.add_method('Begin',
'ns3::NetDeviceContainer::Iterator',
[],
is_const=True)
## net-device-container.h (module 'network'): ns3::NetDeviceContainer::Iterator ns3::NetDeviceContainer::End() const [member function]
cls.add_method('End',
'ns3::NetDeviceContainer::Iterator',
[],
is_const=True)
## net-device-container.h (module 'network'): ns3::Ptr<ns3::NetDevice> ns3::NetDeviceContainer::Get(uint32_t i) const [member function]
cls.add_method('Get',
'ns3::Ptr< ns3::NetDevice >',
[param('uint32_t', 'i')],
is_const=True)
## net-device-container.h (module 'network'): uint32_t ns3::NetDeviceContainer::GetN() const [member function]
cls.add_method('GetN',
'uint32_t',
[],
is_const=True)
return
def register_Ns3NodeContainer_methods(root_module, cls):
## node-container.h (module 'network'): ns3::NodeContainer::NodeContainer(ns3::NodeContainer const & arg0) [constructor]
cls.add_constructor([param('ns3::NodeContainer const &', 'arg0')])
## node-container.h (module 'network'): ns3::NodeContainer::NodeContainer() [constructor]
cls.add_constructor([])
## node-container.h (module 'network'): ns3::NodeContainer::NodeContainer(ns3::Ptr<ns3::Node> node) [constructor]
cls.add_constructor([param('ns3::Ptr< ns3::Node >', 'node')])
## node-container.h (module 'network'): ns3::NodeContainer::NodeContainer(std::string nodeName) [constructor]
cls.add_constructor([param('std::string', 'nodeName')])
## node-container.h (module 'network'): ns3::NodeContainer::NodeContainer(ns3::NodeContainer const & a, ns3::NodeContainer const & b) [constructor]
cls.add_constructor([param('ns3::NodeContainer const &', 'a'), param('ns3::NodeContainer const &', 'b')])
## node-container.h (module 'network'): ns3::NodeContainer::NodeContainer(ns3::NodeContainer const & a, ns3::NodeContainer const & b, ns3::NodeContainer const & c) [constructor]
cls.add_constructor([param('ns3::NodeContainer const &', 'a'), param('ns3::NodeContainer const &', 'b'), param('ns3::NodeContainer const &', 'c')])
## node-container.h (module 'network'): ns3::NodeContainer::NodeContainer(ns3::NodeContainer const & a, ns3::NodeContainer const & b, ns3::NodeContainer const & c, ns3::NodeContainer const & d) [constructor]
cls.add_constructor([param('ns3::NodeContainer const &', 'a'), param('ns3::NodeContainer const &', 'b'), param('ns3::NodeContainer const &', 'c'), param('ns3::NodeContainer const &', 'd')])
## node-container.h (module 'network'): ns3::NodeContainer::NodeContainer(ns3::NodeContainer const & a, ns3::NodeContainer const & b, ns3::NodeContainer const & c, ns3::NodeContainer const & d, ns3::NodeContainer const & e) [constructor]
cls.add_constructor([param('ns3::NodeContainer const &', 'a'), param('ns3::NodeContainer const &', 'b'), param('ns3::NodeContainer const &', 'c'), param('ns3::NodeContainer const &', 'd'), param('ns3::NodeContainer const &', 'e')])
## node-container.h (module 'network'): void ns3::NodeContainer::Add(ns3::NodeContainer other) [member function]
cls.add_method('Add',
'void',
[param('ns3::NodeContainer', 'other')])
## node-container.h (module 'network'): void ns3::NodeContainer::Add(ns3::Ptr<ns3::Node> node) [member function]
cls.add_method('Add',
'void',
[param('ns3::Ptr< ns3::Node >', 'node')])
## node-container.h (module 'network'): void ns3::NodeContainer::Add(std::string nodeName) [member function]
cls.add_method('Add',
'void',
[param('std::string', 'nodeName')])
## node-container.h (module 'network'): ns3::NodeContainer::Iterator ns3::NodeContainer::Begin() const [member function]
cls.add_method('Begin',
'ns3::NodeContainer::Iterator',
[],
is_const=True)
## node-container.h (module 'network'): void ns3::NodeContainer::Create(uint32_t n) [member function]
cls.add_method('Create',
'void',
[param('uint32_t', 'n')])
## node-container.h (module 'network'): void ns3::NodeContainer::Create(uint32_t n, uint32_t systemId) [member function]
cls.add_method('Create',
'void',
[param('uint32_t', 'n'), param('uint32_t', 'systemId')])
## node-container.h (module 'network'): ns3::NodeContainer::Iterator ns3::NodeContainer::End() const [member function]
cls.add_method('End',
'ns3::NodeContainer::Iterator',
[],
is_const=True)
## node-container.h (module 'network'): ns3::Ptr<ns3::Node> ns3::NodeContainer::Get(uint32_t i) const [member function]
cls.add_method('Get',
'ns3::Ptr< ns3::Node >',
[param('uint32_t', 'i')],
is_const=True)
## node-container.h (module 'network'): static ns3::NodeContainer ns3::NodeContainer::GetGlobal() [member function]
cls.add_method('GetGlobal',
'ns3::NodeContainer',
[],
is_static=True)
## node-container.h (module 'network'): uint32_t ns3::NodeContainer::GetN() const [member function]
cls.add_method('GetN',
'uint32_t',
[],
is_const=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) [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) [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_Ns3ObjectFactory_methods(root_module, cls):
cls.add_output_stream_operator()
## object-factory.h (module 'core'): ns3::ObjectFactory::ObjectFactory(ns3::ObjectFactory const & arg0) [constructor]
cls.add_constructor([param('ns3::ObjectFactory const &', 'arg0')])
## object-factory.h (module 'core'): ns3::ObjectFactory::ObjectFactory() [constructor]
cls.add_constructor([])
## object-factory.h (module 'core'): ns3::ObjectFactory::ObjectFactory(std::string typeId) [constructor]
cls.add_constructor([param('std::string', 'typeId')])
## object-factory.h (module 'core'): ns3::Ptr<ns3::Object> ns3::ObjectFactory::Create() const [member function]
cls.add_method('Create',
'ns3::Ptr< ns3::Object >',
[],
is_const=True)
## object-factory.h (module 'core'): ns3::TypeId ns3::ObjectFactory::GetTypeId() const [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_const=True)
## object-factory.h (module 'core'): void ns3::ObjectFactory::Set(std::string name, ns3::AttributeValue const & value) [member function]
cls.add_method('Set',
'void',
[param('std::string', 'name'), param('ns3::AttributeValue const &', 'value')])
## object-factory.h (module 'core'): void ns3::ObjectFactory::SetTypeId(ns3::TypeId tid) [member function]
cls.add_method('SetTypeId',
'void',
[param('ns3::TypeId', 'tid')])
## object-factory.h (module 'core'): void ns3::ObjectFactory::SetTypeId(char const * tid) [member function]
cls.add_method('SetTypeId',
'void',
[param('char const *', 'tid')])
## object-factory.h (module 'core'): void ns3::ObjectFactory::SetTypeId(std::string tid) [member function]
cls.add_method('SetTypeId',
'void',
[param('std::string', 'tid')])
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) [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) [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)
## packet-metadata.h (module 'network'): ns3::PacketMetadata::Item::type [variable]
cls.add_instance_attribute('type', 'ns3::PacketMetadata::Item::ItemType', 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) [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) [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) [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) [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) [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 [ 1 ]', 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::size [variable]
cls.add_instance_attribute('size', 'uint32_t', 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_Ns3PcapFile_methods(root_module, cls):
## pcap-file.h (module 'network'): ns3::PcapFile::PcapFile() [constructor]
cls.add_constructor([])
## pcap-file.h (module 'network'): void ns3::PcapFile::Clear() [member function]
cls.add_method('Clear',
'void',
[])
## pcap-file.h (module 'network'): void ns3::PcapFile::Close() [member function]
cls.add_method('Close',
'void',
[])
## pcap-file.h (module 'network'): static bool ns3::PcapFile::Diff(std::string const & f1, std::string const & f2, uint32_t & sec, uint32_t & usec, uint32_t & packets, uint32_t snapLen=ns3::PcapFile::SNAPLEN_DEFAULT) [member function]
cls.add_method('Diff',
'bool',
[param('std::string const &', 'f1'), param('std::string const &', 'f2'), param('uint32_t &', 'sec'), param('uint32_t &', 'usec'), param('uint32_t &', 'packets'), param('uint32_t', 'snapLen', default_value='ns3::PcapFile::SNAPLEN_DEFAULT')],
is_static=True)
## pcap-file.h (module 'network'): bool ns3::PcapFile::Eof() const [member function]
cls.add_method('Eof',
'bool',
[],
is_const=True)
## pcap-file.h (module 'network'): bool ns3::PcapFile::Fail() const [member function]
cls.add_method('Fail',
'bool',
[],
is_const=True)
## pcap-file.h (module 'network'): uint32_t ns3::PcapFile::GetDataLinkType() [member function]
cls.add_method('GetDataLinkType',
'uint32_t',
[])
## pcap-file.h (module 'network'): uint32_t ns3::PcapFile::GetMagic() [member function]
cls.add_method('GetMagic',
'uint32_t',
[])
## pcap-file.h (module 'network'): uint32_t ns3::PcapFile::GetSigFigs() [member function]
cls.add_method('GetSigFigs',
'uint32_t',
[])
## pcap-file.h (module 'network'): uint32_t ns3::PcapFile::GetSnapLen() [member function]
cls.add_method('GetSnapLen',
'uint32_t',
[])
## pcap-file.h (module 'network'): bool ns3::PcapFile::GetSwapMode() [member function]
cls.add_method('GetSwapMode',
'bool',
[])
## pcap-file.h (module 'network'): int32_t ns3::PcapFile::GetTimeZoneOffset() [member function]
cls.add_method('GetTimeZoneOffset',
'int32_t',
[])
## pcap-file.h (module 'network'): uint16_t ns3::PcapFile::GetVersionMajor() [member function]
cls.add_method('GetVersionMajor',
'uint16_t',
[])
## pcap-file.h (module 'network'): uint16_t ns3::PcapFile::GetVersionMinor() [member function]
cls.add_method('GetVersionMinor',
'uint16_t',
[])
## pcap-file.h (module 'network'): void ns3::PcapFile::Init(uint32_t dataLinkType, uint32_t snapLen=ns3::PcapFile::SNAPLEN_DEFAULT, int32_t timeZoneCorrection=ns3::PcapFile::ZONE_DEFAULT, bool swapMode=false, bool nanosecMode=false) [member function]
cls.add_method('Init',
'void',
[param('uint32_t', 'dataLinkType'), param('uint32_t', 'snapLen', default_value='ns3::PcapFile::SNAPLEN_DEFAULT'), param('int32_t', 'timeZoneCorrection', default_value='ns3::PcapFile::ZONE_DEFAULT'), param('bool', 'swapMode', default_value='false'), param('bool', 'nanosecMode', default_value='false')])
## pcap-file.h (module 'network'): bool ns3::PcapFile::IsNanoSecMode() [member function]
cls.add_method('IsNanoSecMode',
'bool',
[])
## pcap-file.h (module 'network'): void ns3::PcapFile::Open(std::string const & filename, std::ios_base::openmode mode) [member function]
cls.add_method('Open',
'void',
[param('std::string const &', 'filename'), param('std::ios_base::openmode', 'mode')])
## pcap-file.h (module 'network'): void ns3::PcapFile::Read(uint8_t * const data, uint32_t maxBytes, uint32_t & tsSec, uint32_t & tsUsec, uint32_t & inclLen, uint32_t & origLen, uint32_t & readLen) [member function]
cls.add_method('Read',
'void',
[param('uint8_t * const', 'data'), param('uint32_t', 'maxBytes'), param('uint32_t &', 'tsSec'), param('uint32_t &', 'tsUsec'), param('uint32_t &', 'inclLen'), param('uint32_t &', 'origLen'), param('uint32_t &', 'readLen')])
## pcap-file.h (module 'network'): void ns3::PcapFile::Write(uint32_t tsSec, uint32_t tsUsec, uint8_t const * const data, uint32_t totalLen) [member function]
cls.add_method('Write',
'void',
[param('uint32_t', 'tsSec'), param('uint32_t', 'tsUsec'), param('uint8_t const * const', 'data'), param('uint32_t', 'totalLen')])
## pcap-file.h (module 'network'): void ns3::PcapFile::Write(uint32_t tsSec, uint32_t tsUsec, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('Write',
'void',
[param('uint32_t', 'tsSec'), param('uint32_t', 'tsUsec'), param('ns3::Ptr< ns3::Packet const >', 'p')])
## pcap-file.h (module 'network'): void ns3::PcapFile::Write(uint32_t tsSec, uint32_t tsUsec, ns3::Header const & header, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('Write',
'void',
[param('uint32_t', 'tsSec'), param('uint32_t', 'tsUsec'), param('ns3::Header const &', 'header'), param('ns3::Ptr< ns3::Packet const >', 'p')])
## pcap-file.h (module 'network'): ns3::PcapFile::SNAPLEN_DEFAULT [variable]
cls.add_static_attribute('SNAPLEN_DEFAULT', 'uint32_t const', is_const=True)
## pcap-file.h (module 'network'): ns3::PcapFile::ZONE_DEFAULT [variable]
cls.add_static_attribute('ZONE_DEFAULT', 'int32_t const', is_const=True)
return
def register_Ns3PcapHelper_methods(root_module, cls):
## trace-helper.h (module 'network'): ns3::PcapHelper::PcapHelper(ns3::PcapHelper const & arg0) [constructor]
cls.add_constructor([param('ns3::PcapHelper const &', 'arg0')])
## trace-helper.h (module 'network'): ns3::PcapHelper::PcapHelper() [constructor]
cls.add_constructor([])
## trace-helper.h (module 'network'): ns3::Ptr<ns3::PcapFileWrapper> ns3::PcapHelper::CreateFile(std::string filename, std::ios_base::openmode filemode, ns3::PcapHelper::DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits<unsigned int>::max(), int32_t tzCorrection=0) [member function]
cls.add_method('CreateFile',
'ns3::Ptr< ns3::PcapFileWrapper >',
[param('std::string', 'filename'), param('std::ios_base::openmode', 'filemode'), param('ns3::PcapHelper::DataLinkType', 'dataLinkType'), param('uint32_t', 'snapLen', default_value='std::numeric_limits<unsigned int>::max()'), param('int32_t', 'tzCorrection', default_value='0')])
## trace-helper.h (module 'network'): std::string ns3::PcapHelper::GetFilenameFromDevice(std::string prefix, ns3::Ptr<ns3::NetDevice> device, bool useObjectNames=true) [member function]
cls.add_method('GetFilenameFromDevice',
'std::string',
[param('std::string', 'prefix'), param('ns3::Ptr< ns3::NetDevice >', 'device'), param('bool', 'useObjectNames', default_value='true')])
## trace-helper.h (module 'network'): std::string ns3::PcapHelper::GetFilenameFromInterfacePair(std::string prefix, ns3::Ptr<ns3::Object> object, uint32_t interface, bool useObjectNames=true) [member function]
cls.add_method('GetFilenameFromInterfacePair',
'std::string',
[param('std::string', 'prefix'), param('ns3::Ptr< ns3::Object >', 'object'), param('uint32_t', 'interface'), param('bool', 'useObjectNames', default_value='true')])
return
def register_Ns3PcapHelperForDevice_methods(root_module, cls):
## trace-helper.h (module 'network'): ns3::PcapHelperForDevice::PcapHelperForDevice(ns3::PcapHelperForDevice const & arg0) [constructor]
cls.add_constructor([param('ns3::PcapHelperForDevice const &', 'arg0')])
## trace-helper.h (module 'network'): ns3::PcapHelperForDevice::PcapHelperForDevice() [constructor]
cls.add_constructor([])
## trace-helper.h (module 'network'): void ns3::PcapHelperForDevice::EnablePcap(std::string prefix, ns3::Ptr<ns3::NetDevice> nd, bool promiscuous=false, bool explicitFilename=false) [member function]
cls.add_method('EnablePcap',
'void',
[param('std::string', 'prefix'), param('ns3::Ptr< ns3::NetDevice >', 'nd'), param('bool', 'promiscuous', default_value='false'), param('bool', 'explicitFilename', default_value='false')])
## trace-helper.h (module 'network'): void ns3::PcapHelperForDevice::EnablePcap(std::string prefix, std::string ndName, bool promiscuous=false, bool explicitFilename=false) [member function]
cls.add_method('EnablePcap',
'void',
[param('std::string', 'prefix'), param('std::string', 'ndName'), param('bool', 'promiscuous', default_value='false'), param('bool', 'explicitFilename', default_value='false')])
## trace-helper.h (module 'network'): void ns3::PcapHelperForDevice::EnablePcap(std::string prefix, ns3::NetDeviceContainer d, bool promiscuous=false) [member function]
cls.add_method('EnablePcap',
'void',
[param('std::string', 'prefix'), param('ns3::NetDeviceContainer', 'd'), param('bool', 'promiscuous', default_value='false')])
## trace-helper.h (module 'network'): void ns3::PcapHelperForDevice::EnablePcap(std::string prefix, ns3::NodeContainer n, bool promiscuous=false) [member function]
cls.add_method('EnablePcap',
'void',
[param('std::string', 'prefix'), param('ns3::NodeContainer', 'n'), param('bool', 'promiscuous', default_value='false')])
## trace-helper.h (module 'network'): void ns3::PcapHelperForDevice::EnablePcap(std::string prefix, uint32_t nodeid, uint32_t deviceid, bool promiscuous=false) [member function]
cls.add_method('EnablePcap',
'void',
[param('std::string', 'prefix'), param('uint32_t', 'nodeid'), param('uint32_t', 'deviceid'), param('bool', 'promiscuous', default_value='false')])
## trace-helper.h (module 'network'): void ns3::PcapHelperForDevice::EnablePcapAll(std::string prefix, bool promiscuous=false) [member function]
cls.add_method('EnablePcapAll',
'void',
[param('std::string', 'prefix'), param('bool', 'promiscuous', default_value='false')])
## trace-helper.h (module 'network'): void ns3::PcapHelperForDevice::EnablePcapInternal(std::string prefix, ns3::Ptr<ns3::NetDevice> nd, bool promiscuous, bool explicitFilename) [member function]
cls.add_method('EnablePcapInternal',
'void',
[param('std::string', 'prefix'), param('ns3::Ptr< ns3::NetDevice >', 'nd'), param('bool', 'promiscuous'), param('bool', 'explicitFilename')],
is_pure_virtual=True, is_virtual=True)
return
def register_Ns3SequenceNumber8_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
cls.add_binary_numeric_operator('+', root_module['ns3::SequenceNumber8'], root_module['ns3::SequenceNumber8'], param('ns3::SequenceNumber< unsigned char, signed char > const &', u'right'))
cls.add_binary_numeric_operator('+', root_module['ns3::SequenceNumber8'], root_module['ns3::SequenceNumber8'], param('signed char', u'right'))
cls.add_inplace_numeric_operator('+=', param('signed char', u'right'))
cls.add_binary_numeric_operator('-', root_module['ns3::SequenceNumber8'], root_module['ns3::SequenceNumber8'], param('signed char', u'right'))
cls.add_inplace_numeric_operator('-=', param('signed char', u'right'))
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>')
cls.add_binary_comparison_operator('>=')
## sequence-number.h (module 'network'): ns3::SequenceNumber<unsigned char, signed char>::SequenceNumber() [constructor]
cls.add_constructor([])
## sequence-number.h (module 'network'): ns3::SequenceNumber<unsigned char, signed char>::SequenceNumber(unsigned char value) [constructor]
cls.add_constructor([param('unsigned char', 'value')])
## sequence-number.h (module 'network'): ns3::SequenceNumber<unsigned char, signed char>::SequenceNumber(ns3::SequenceNumber<unsigned char, signed char> const & value) [constructor]
cls.add_constructor([param('ns3::SequenceNumber< unsigned char, signed char > const &', 'value')])
## sequence-number.h (module 'network'): unsigned char ns3::SequenceNumber<unsigned char, signed char>::GetValue() const [member function]
cls.add_method('GetValue',
'unsigned char',
[],
is_const=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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter > const &', 'o')])
return
def register_Ns3Simulator_methods(root_module, cls):
## simulator.h (module 'core'): ns3::Simulator::Simulator(ns3::Simulator const & arg0) [constructor]
cls.add_constructor([param('ns3::Simulator const &', 'arg0')])
## simulator.h (module 'core'): static void ns3::Simulator::Cancel(ns3::EventId const & id) [member function]
cls.add_method('Cancel',
'void',
[param('ns3::EventId const &', 'id')],
is_static=True)
## simulator.h (module 'core'): static void ns3::Simulator::Destroy() [member function]
cls.add_method('Destroy',
'void',
[],
is_static=True)
## simulator.h (module 'core'): static uint32_t ns3::Simulator::GetContext() [member function]
cls.add_method('GetContext',
'uint32_t',
[],
is_static=True)
## simulator.h (module 'core'): static ns3::Time ns3::Simulator::GetDelayLeft(ns3::EventId const & id) [member function]
cls.add_method('GetDelayLeft',
'ns3::Time',
[param('ns3::EventId const &', 'id')],
is_static=True)
## simulator.h (module 'core'): static ns3::Ptr<ns3::SimulatorImpl> ns3::Simulator::GetImplementation() [member function]
cls.add_method('GetImplementation',
'ns3::Ptr< ns3::SimulatorImpl >',
[],
is_static=True)
## simulator.h (module 'core'): static ns3::Time ns3::Simulator::GetMaximumSimulationTime() [member function]
cls.add_method('GetMaximumSimulationTime',
'ns3::Time',
[],
is_static=True)
## simulator.h (module 'core'): static uint32_t ns3::Simulator::GetSystemId() [member function]
cls.add_method('GetSystemId',
'uint32_t',
[],
is_static=True)
## simulator.h (module 'core'): static bool ns3::Simulator::IsExpired(ns3::EventId const & id) [member function]
cls.add_method('IsExpired',
'bool',
[param('ns3::EventId const &', 'id')],
is_static=True)
## simulator.h (module 'core'): static bool ns3::Simulator::IsFinished() [member function]
cls.add_method('IsFinished',
'bool',
[],
is_static=True)
## simulator.h (module 'core'): static ns3::Time ns3::Simulator::Now() [member function]
cls.add_method('Now',
'ns3::Time',
[],
is_static=True)
## simulator.h (module 'core'): static void ns3::Simulator::Remove(ns3::EventId const & id) [member function]
cls.add_method('Remove',
'void',
[param('ns3::EventId const &', 'id')],
is_static=True)
## simulator.h (module 'core'): static void ns3::Simulator::SetImplementation(ns3::Ptr<ns3::SimulatorImpl> impl) [member function]
cls.add_method('SetImplementation',
'void',
[param('ns3::Ptr< ns3::SimulatorImpl >', 'impl')],
is_static=True)
## simulator.h (module 'core'): static void ns3::Simulator::SetScheduler(ns3::ObjectFactory schedulerFactory) [member function]
cls.add_method('SetScheduler',
'void',
[param('ns3::ObjectFactory', 'schedulerFactory')],
is_static=True)
## simulator.h (module 'core'): static void ns3::Simulator::Stop() [member function]
cls.add_method('Stop',
'void',
[],
is_static=True)
## simulator.h (module 'core'): static void ns3::Simulator::Stop(ns3::Time const & delay) [member function]
cls.add_method('Stop',
'void',
[param('ns3::Time const &', 'delay')],
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) [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) [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 v) [member function]
cls.add_method('WriteU16',
'void',
[param('uint16_t', 'v')])
## tag-buffer.h (module 'network'): void ns3::TagBuffer::WriteU32(uint32_t v) [member function]
cls.add_method('WriteU32',
'void',
[param('uint32_t', 'v')])
## 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) [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_Ns3TracedValue__Ns3LrWpanMacState_methods(root_module, cls):
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanMacState>::TracedValue() [constructor]
cls.add_constructor([])
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanMacState>::TracedValue(ns3::TracedValue<ns3::LrWpanMacState> const & o) [constructor]
cls.add_constructor([param('ns3::TracedValue< ns3::LrWpanMacState > const &', 'o')])
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanMacState>::TracedValue(ns3::LrWpanMacState const & v) [constructor]
cls.add_constructor([param('ns3::LrWpanMacState const &', 'v')])
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanMacState>::TracedValue(ns3::TracedValue<ns3::LrWpanMacState> const & other) [constructor]
cls.add_constructor([param('ns3::TracedValue< ns3::LrWpanMacState > const &', 'other')])
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanMacState>::TracedValue(ns3::TracedValue<ns3::LrWpanMacState> const & other) [constructor]
cls.add_constructor([param('ns3::TracedValue< ns3::LrWpanMacState > const &', 'other')])
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanMacState>::Connect(ns3::CallbackBase const & cb, std::string path) [member function]
cls.add_method('Connect',
'void',
[param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')])
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanMacState>::ConnectWithoutContext(ns3::CallbackBase const & cb) [member function]
cls.add_method('ConnectWithoutContext',
'void',
[param('ns3::CallbackBase const &', 'cb')])
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanMacState>::Disconnect(ns3::CallbackBase const & cb, std::string path) [member function]
cls.add_method('Disconnect',
'void',
[param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')])
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanMacState>::DisconnectWithoutContext(ns3::CallbackBase const & cb) [member function]
cls.add_method('DisconnectWithoutContext',
'void',
[param('ns3::CallbackBase const &', 'cb')])
## traced-value.h (module 'core'): ns3::LrWpanMacState ns3::TracedValue<ns3::LrWpanMacState>::Get() const [member function]
cls.add_method('Get',
'ns3::LrWpanMacState',
[],
is_const=True)
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanMacState>::Set(ns3::LrWpanMacState const & v) [member function]
cls.add_method('Set',
'void',
[param('ns3::LrWpanMacState const &', 'v')])
return
def register_Ns3TracedValue__Ns3LrWpanPhyEnumeration_methods(root_module, cls):
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanPhyEnumeration>::TracedValue() [constructor]
cls.add_constructor([])
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanPhyEnumeration>::TracedValue(ns3::TracedValue<ns3::LrWpanPhyEnumeration> const & o) [constructor]
cls.add_constructor([param('ns3::TracedValue< ns3::LrWpanPhyEnumeration > const &', 'o')])
## traced-value.h (module 'core'): ns3::TracedValue<ns3::LrWpanPhyEnumeration>::TracedValue(ns3::LrWpanPhyEnumeration const & v) [constructor]
cls.add_constructor([param('ns3::LrWpanPhyEnumeration const &', 'v')])
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanPhyEnumeration>::Connect(ns3::CallbackBase const & cb, std::string path) [member function]
cls.add_method('Connect',
'void',
[param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')])
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanPhyEnumeration>::ConnectWithoutContext(ns3::CallbackBase const & cb) [member function]
cls.add_method('ConnectWithoutContext',
'void',
[param('ns3::CallbackBase const &', 'cb')])
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanPhyEnumeration>::Disconnect(ns3::CallbackBase const & cb, std::string path) [member function]
cls.add_method('Disconnect',
'void',
[param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')])
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanPhyEnumeration>::DisconnectWithoutContext(ns3::CallbackBase const & cb) [member function]
cls.add_method('DisconnectWithoutContext',
'void',
[param('ns3::CallbackBase const &', 'cb')])
## traced-value.h (module 'core'): ns3::LrWpanPhyEnumeration ns3::TracedValue<ns3::LrWpanPhyEnumeration>::Get() const [member function]
cls.add_method('Get',
'ns3::LrWpanPhyEnumeration',
[],
is_const=True)
## traced-value.h (module 'core'): void ns3::TracedValue<ns3::LrWpanPhyEnumeration>::Set(ns3::LrWpanPhyEnumeration const & v) [member function]
cls.add_method('Set',
'void',
[param('ns3::LrWpanPhyEnumeration const &', 'v')])
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) [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<const ns3::AttributeAccessor> accessor, ns3::Ptr<const ns3::AttributeChecker> checker, ns3::TypeId::SupportLevel supportLevel=::ns3::TypeId::SupportLevel::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::SupportLevel::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<const ns3::AttributeAccessor> accessor, ns3::Ptr<const ns3::AttributeChecker> checker, ns3::TypeId::SupportLevel supportLevel=::ns3::TypeId::SupportLevel::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::SupportLevel::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<const ns3::TraceSourceAccessor> accessor) [member function]
cls.add_method('AddTraceSource',
'ns3::TypeId',
[param('std::string', 'name'), param('std::string', 'help'), param('ns3::Ptr< ns3::TraceSourceAccessor const >', 'accessor')])
## type-id.h (module 'core'): ns3::TypeId ns3::TypeId::AddTraceSource(std::string name, std::string help, ns3::Ptr<const ns3::TraceSourceAccessor> accessor, std::string callback, ns3::TypeId::SupportLevel supportLevel=::ns3::TypeId::SupportLevel::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::SupportLevel::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'): ns3::TypeId::hash_t ns3::TypeId::GetHash() const [member function]
cls.add_method('GetHash',
'ns3::TypeId::hash_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(ns3::TypeId::hash_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(ns3::TypeId::hash_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<const ns3::TraceSourceAccessor> 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<const ns3::TraceSourceAccessor> 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<const ns3::AttributeValue> 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) [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)
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) [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) [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_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_output_stream_operator()
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_unary_numeric_operator('-')
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t() [constructor]
cls.add_constructor([])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(double const value) [constructor]
cls.add_constructor([param('double const', 'value')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(long double const value) [constructor]
cls.add_constructor([param('long double const', 'value')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(int const v) [constructor]
cls.add_constructor([param('int const', 'v')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(long int const v) [constructor]
cls.add_constructor([param('long int const', 'v')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(long long int const v) [constructor]
cls.add_constructor([param('long long int const', 'v')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(unsigned int const v) [constructor]
cls.add_constructor([param('unsigned int const', 'v')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(long unsigned int const v) [constructor]
cls.add_constructor([param('long unsigned int const', 'v')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(long long unsigned int const v) [constructor]
cls.add_constructor([param('long long unsigned int const', 'v')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(int64_t const hi, uint64_t const lo) [constructor]
cls.add_constructor([param('int64_t const', 'hi'), param('uint64_t const', 'lo')])
## int64x64-128.h (module 'core'): ns3::int64x64_t::int64x64_t(ns3::int64x64_t const & o) [constructor]
cls.add_constructor([param('ns3::int64x64_t const &', 'o')])
## int64x64-128.h (module 'core'): double ns3::int64x64_t::GetDouble() const [member function]
cls.add_method('GetDouble',
'double',
[],
is_const=True)
## int64x64-128.h (module 'core'): int64_t ns3::int64x64_t::GetHigh() const [member function]
cls.add_method('GetHigh',
'int64_t',
[],
is_const=True)
## int64x64-128.h (module 'core'): uint64_t ns3::int64x64_t::GetLow() const [member function]
cls.add_method('GetLow',
'uint64_t',
[],
is_const=True)
## int64x64-128.h (module 'core'): static ns3::int64x64_t ns3::int64x64_t::Invert(uint64_t const v) [member function]
cls.add_method('Invert',
'ns3::int64x64_t',
[param('uint64_t const', 'v')],
is_static=True)
## int64x64-128.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-128.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) [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) [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_Ns3LrWpanHelper_methods(root_module, cls):
## lr-wpan-helper.h (module 'lr-wpan'): ns3::LrWpanHelper::LrWpanHelper() [constructor]
cls.add_constructor([])
## lr-wpan-helper.h (module 'lr-wpan'): ns3::LrWpanHelper::LrWpanHelper(bool useMultiModelSpectrumChannel) [constructor]
cls.add_constructor([param('bool', 'useMultiModelSpectrumChannel')])
## lr-wpan-helper.h (module 'lr-wpan'): ns3::Ptr<ns3::SpectrumChannel> ns3::LrWpanHelper::GetChannel() [member function]
cls.add_method('GetChannel',
'ns3::Ptr< ns3::SpectrumChannel >',
[])
## lr-wpan-helper.h (module 'lr-wpan'): void ns3::LrWpanHelper::SetChannel(ns3::Ptr<ns3::SpectrumChannel> channel) [member function]
cls.add_method('SetChannel',
'void',
[param('ns3::Ptr< ns3::SpectrumChannel >', 'channel')])
## lr-wpan-helper.h (module 'lr-wpan'): void ns3::LrWpanHelper::SetChannel(std::string channelName) [member function]
cls.add_method('SetChannel',
'void',
[param('std::string', 'channelName')])
## lr-wpan-helper.h (module 'lr-wpan'): void ns3::LrWpanHelper::AddMobility(ns3::Ptr<ns3::LrWpanPhy> phy, ns3::Ptr<ns3::MobilityModel> m) [member function]
cls.add_method('AddMobility',
'void',
[param('ns3::Ptr< ns3::LrWpanPhy >', 'phy'), param('ns3::Ptr< ns3::MobilityModel >', 'm')])
## lr-wpan-helper.h (module 'lr-wpan'): ns3::NetDeviceContainer ns3::LrWpanHelper::Install(ns3::NodeContainer c) [member function]
cls.add_method('Install',
'ns3::NetDeviceContainer',
[param('ns3::NodeContainer', 'c')])
## lr-wpan-helper.h (module 'lr-wpan'): void ns3::LrWpanHelper::AssociateToPan(ns3::NetDeviceContainer c, uint16_t panId) [member function]
cls.add_method('AssociateToPan',
'void',
[param('ns3::NetDeviceContainer', 'c'), param('uint16_t', 'panId')])
## lr-wpan-helper.h (module 'lr-wpan'): void ns3::LrWpanHelper::EnableLogComponents() [member function]
cls.add_method('EnableLogComponents',
'void',
[])
## lr-wpan-helper.h (module 'lr-wpan'): static std::string ns3::LrWpanHelper::LrWpanPhyEnumerationPrinter(ns3::LrWpanPhyEnumeration e) [member function]
cls.add_method('LrWpanPhyEnumerationPrinter',
'std::string',
[param('ns3::LrWpanPhyEnumeration', 'e')],
is_static=True)
## lr-wpan-helper.h (module 'lr-wpan'): static std::string ns3::LrWpanHelper::LrWpanMacStatePrinter(ns3::LrWpanMacState e) [member function]
cls.add_method('LrWpanMacStatePrinter',
'std::string',
[param('ns3::LrWpanMacState', 'e')],
is_static=True)
## lr-wpan-helper.h (module 'lr-wpan'): int64_t ns3::LrWpanHelper::AssignStreams(ns3::NetDeviceContainer c, int64_t stream) [member function]
cls.add_method('AssignStreams',
'int64_t',
[param('ns3::NetDeviceContainer', 'c'), param('int64_t', 'stream')])
## lr-wpan-helper.h (module 'lr-wpan'): void ns3::LrWpanHelper::EnablePcapInternal(std::string prefix, ns3::Ptr<ns3::NetDevice> nd, bool promiscuous, bool explicitFilename) [member function]
cls.add_method('EnablePcapInternal',
'void',
[param('std::string', 'prefix'), param('ns3::Ptr< ns3::NetDevice >', 'nd'), param('bool', 'promiscuous'), param('bool', 'explicitFilename')],
visibility='private', is_virtual=True)
## lr-wpan-helper.h (module 'lr-wpan'): void ns3::LrWpanHelper::EnableAsciiInternal(ns3::Ptr<ns3::OutputStreamWrapper> stream, std::string prefix, ns3::Ptr<ns3::NetDevice> nd, bool explicitFilename) [member function]
cls.add_method('EnableAsciiInternal',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream'), param('std::string', 'prefix'), param('ns3::Ptr< ns3::NetDevice >', 'nd'), param('bool', 'explicitFilename')],
visibility='private', is_virtual=True)
return
def register_Ns3LrWpanLqiTag_methods(root_module, cls):
## lr-wpan-lqi-tag.h (module 'lr-wpan'): ns3::LrWpanLqiTag::LrWpanLqiTag(ns3::LrWpanLqiTag const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanLqiTag const &', 'arg0')])
## lr-wpan-lqi-tag.h (module 'lr-wpan'): ns3::LrWpanLqiTag::LrWpanLqiTag() [constructor]
cls.add_constructor([])
## lr-wpan-lqi-tag.h (module 'lr-wpan'): ns3::LrWpanLqiTag::LrWpanLqiTag(uint8_t lqi) [constructor]
cls.add_constructor([param('uint8_t', 'lqi')])
## lr-wpan-lqi-tag.h (module 'lr-wpan'): void ns3::LrWpanLqiTag::Deserialize(ns3::TagBuffer i) [member function]
cls.add_method('Deserialize',
'void',
[param('ns3::TagBuffer', 'i')],
is_virtual=True)
## lr-wpan-lqi-tag.h (module 'lr-wpan'): uint8_t ns3::LrWpanLqiTag::Get() const [member function]
cls.add_method('Get',
'uint8_t',
[],
is_const=True)
## lr-wpan-lqi-tag.h (module 'lr-wpan'): ns3::TypeId ns3::LrWpanLqiTag::GetInstanceTypeId() const [member function]
cls.add_method('GetInstanceTypeId',
'ns3::TypeId',
[],
is_const=True, is_virtual=True)
## lr-wpan-lqi-tag.h (module 'lr-wpan'): uint32_t ns3::LrWpanLqiTag::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_const=True, is_virtual=True)
## lr-wpan-lqi-tag.h (module 'lr-wpan'): static ns3::TypeId ns3::LrWpanLqiTag::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## lr-wpan-lqi-tag.h (module 'lr-wpan'): void ns3::LrWpanLqiTag::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_const=True, is_virtual=True)
## lr-wpan-lqi-tag.h (module 'lr-wpan'): void ns3::LrWpanLqiTag::Serialize(ns3::TagBuffer i) const [member function]
cls.add_method('Serialize',
'void',
[param('ns3::TagBuffer', 'i')],
is_const=True, is_virtual=True)
## lr-wpan-lqi-tag.h (module 'lr-wpan'): void ns3::LrWpanLqiTag::Set(uint8_t lqi) [member function]
cls.add_method('Set',
'void',
[param('uint8_t', 'lqi')])
return
def register_Ns3LrWpanMacHeader_methods(root_module, cls):
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::LrWpanMacHeader::LrWpanMacHeader(ns3::LrWpanMacHeader const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanMacHeader const &', 'arg0')])
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::LrWpanMacHeader::LrWpanMacHeader() [constructor]
cls.add_constructor([])
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::LrWpanMacHeader::LrWpanMacHeader(ns3::LrWpanMacHeader::LrWpanMacType wpanMacType, uint8_t seqNum) [constructor]
cls.add_constructor([param('ns3::LrWpanMacHeader::LrWpanMacType', 'wpanMacType'), param('uint8_t', 'seqNum')])
## lr-wpan-mac-header.h (module 'lr-wpan'): uint32_t ns3::LrWpanMacHeader::Deserialize(ns3::Buffer::Iterator start) [member function]
cls.add_method('Deserialize',
'uint32_t',
[param('ns3::Buffer::Iterator', 'start')],
is_virtual=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetDstAddrMode() const [member function]
cls.add_method('GetDstAddrMode',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint16_t ns3::LrWpanMacHeader::GetDstPanId() const [member function]
cls.add_method('GetDstPanId',
'uint16_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::Mac64Address ns3::LrWpanMacHeader::GetExtDstAddr() const [member function]
cls.add_method('GetExtDstAddr',
'ns3::Mac64Address',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::Mac64Address ns3::LrWpanMacHeader::GetExtSrcAddr() const [member function]
cls.add_method('GetExtSrcAddr',
'ns3::Mac64Address',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint16_t ns3::LrWpanMacHeader::GetFrameControl() const [member function]
cls.add_method('GetFrameControl',
'uint16_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetFrameVer() const [member function]
cls.add_method('GetFrameVer',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint32_t ns3::LrWpanMacHeader::GetFrmCounter() const [member function]
cls.add_method('GetFrmCounter',
'uint32_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetFrmCtrlRes() const [member function]
cls.add_method('GetFrmCtrlRes',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::TypeId ns3::LrWpanMacHeader::GetInstanceTypeId() const [member function]
cls.add_method('GetInstanceTypeId',
'ns3::TypeId',
[],
is_const=True, is_virtual=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetKeyIdIndex() const [member function]
cls.add_method('GetKeyIdIndex',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetKeyIdMode() const [member function]
cls.add_method('GetKeyIdMode',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint32_t ns3::LrWpanMacHeader::GetKeyIdSrc32() const [member function]
cls.add_method('GetKeyIdSrc32',
'uint32_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint64_t ns3::LrWpanMacHeader::GetKeyIdSrc64() const [member function]
cls.add_method('GetKeyIdSrc64',
'uint64_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetSecControl() const [member function]
cls.add_method('GetSecControl',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetSecCtrlReserved() const [member function]
cls.add_method('GetSecCtrlReserved',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetSecLevel() const [member function]
cls.add_method('GetSecLevel',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetSeqNum() const [member function]
cls.add_method('GetSeqNum',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint32_t ns3::LrWpanMacHeader::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_const=True, is_virtual=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::Mac16Address ns3::LrWpanMacHeader::GetShortDstAddr() const [member function]
cls.add_method('GetShortDstAddr',
'ns3::Mac16Address',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::Mac16Address ns3::LrWpanMacHeader::GetShortSrcAddr() const [member function]
cls.add_method('GetShortSrcAddr',
'ns3::Mac16Address',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint8_t ns3::LrWpanMacHeader::GetSrcAddrMode() const [member function]
cls.add_method('GetSrcAddrMode',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): uint16_t ns3::LrWpanMacHeader::GetSrcPanId() const [member function]
cls.add_method('GetSrcPanId',
'uint16_t',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): ns3::LrWpanMacHeader::LrWpanMacType ns3::LrWpanMacHeader::GetType() const [member function]
cls.add_method('GetType',
'ns3::LrWpanMacHeader::LrWpanMacType',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): static ns3::TypeId ns3::LrWpanMacHeader::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): bool ns3::LrWpanMacHeader::IsAckReq() const [member function]
cls.add_method('IsAckReq',
'bool',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): bool ns3::LrWpanMacHeader::IsAcknowledgment() const [member function]
cls.add_method('IsAcknowledgment',
'bool',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): bool ns3::LrWpanMacHeader::IsBeacon() const [member function]
cls.add_method('IsBeacon',
'bool',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): bool ns3::LrWpanMacHeader::IsCommand() const [member function]
cls.add_method('IsCommand',
'bool',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): bool ns3::LrWpanMacHeader::IsData() const [member function]
cls.add_method('IsData',
'bool',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): bool ns3::LrWpanMacHeader::IsFrmPend() const [member function]
cls.add_method('IsFrmPend',
'bool',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): bool ns3::LrWpanMacHeader::IsPanIdComp() const [member function]
cls.add_method('IsPanIdComp',
'bool',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): bool ns3::LrWpanMacHeader::IsSecEnable() const [member function]
cls.add_method('IsSecEnable',
'bool',
[],
is_const=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_const=True, is_virtual=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::Serialize(ns3::Buffer::Iterator start) const [member function]
cls.add_method('Serialize',
'void',
[param('ns3::Buffer::Iterator', 'start')],
is_const=True, is_virtual=True)
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetAckReq() [member function]
cls.add_method('SetAckReq',
'void',
[])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetDstAddrFields(uint16_t panId, ns3::Mac16Address addr) [member function]
cls.add_method('SetDstAddrFields',
'void',
[param('uint16_t', 'panId'), param('ns3::Mac16Address', 'addr')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetDstAddrFields(uint16_t panId, ns3::Mac64Address addr) [member function]
cls.add_method('SetDstAddrFields',
'void',
[param('uint16_t', 'panId'), param('ns3::Mac64Address', 'addr')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetDstAddrMode(uint8_t addrMode) [member function]
cls.add_method('SetDstAddrMode',
'void',
[param('uint8_t', 'addrMode')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetFrameControl(uint16_t frameControl) [member function]
cls.add_method('SetFrameControl',
'void',
[param('uint16_t', 'frameControl')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetFrameVer(uint8_t ver) [member function]
cls.add_method('SetFrameVer',
'void',
[param('uint8_t', 'ver')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetFrmCounter(uint32_t frmCntr) [member function]
cls.add_method('SetFrmCounter',
'void',
[param('uint32_t', 'frmCntr')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetFrmCtrlRes(uint8_t res) [member function]
cls.add_method('SetFrmCtrlRes',
'void',
[param('uint8_t', 'res')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetFrmPend() [member function]
cls.add_method('SetFrmPend',
'void',
[])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetKeyId(uint8_t keyIndex) [member function]
cls.add_method('SetKeyId',
'void',
[param('uint8_t', 'keyIndex')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetKeyId(uint32_t keySrc, uint8_t keyIndex) [member function]
cls.add_method('SetKeyId',
'void',
[param('uint32_t', 'keySrc'), param('uint8_t', 'keyIndex')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetKeyId(uint64_t keySrc, uint8_t keyIndex) [member function]
cls.add_method('SetKeyId',
'void',
[param('uint64_t', 'keySrc'), param('uint8_t', 'keyIndex')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetKeyIdMode(uint8_t keyIdMode) [member function]
cls.add_method('SetKeyIdMode',
'void',
[param('uint8_t', 'keyIdMode')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetNoAckReq() [member function]
cls.add_method('SetNoAckReq',
'void',
[])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetNoFrmPend() [member function]
cls.add_method('SetNoFrmPend',
'void',
[])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetNoPanIdComp() [member function]
cls.add_method('SetNoPanIdComp',
'void',
[])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetPanIdComp() [member function]
cls.add_method('SetPanIdComp',
'void',
[])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSecControl(uint8_t secLevel) [member function]
cls.add_method('SetSecControl',
'void',
[param('uint8_t', 'secLevel')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSecCtrlReserved(uint8_t res) [member function]
cls.add_method('SetSecCtrlReserved',
'void',
[param('uint8_t', 'res')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSecDisable() [member function]
cls.add_method('SetSecDisable',
'void',
[])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSecEnable() [member function]
cls.add_method('SetSecEnable',
'void',
[])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSecLevel(uint8_t secLevel) [member function]
cls.add_method('SetSecLevel',
'void',
[param('uint8_t', 'secLevel')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSeqNum(uint8_t seqNum) [member function]
cls.add_method('SetSeqNum',
'void',
[param('uint8_t', 'seqNum')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSrcAddrFields(uint16_t panId, ns3::Mac16Address addr) [member function]
cls.add_method('SetSrcAddrFields',
'void',
[param('uint16_t', 'panId'), param('ns3::Mac16Address', 'addr')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSrcAddrFields(uint16_t panId, ns3::Mac64Address addr) [member function]
cls.add_method('SetSrcAddrFields',
'void',
[param('uint16_t', 'panId'), param('ns3::Mac64Address', 'addr')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetSrcAddrMode(uint8_t addrMode) [member function]
cls.add_method('SetSrcAddrMode',
'void',
[param('uint8_t', 'addrMode')])
## lr-wpan-mac-header.h (module 'lr-wpan'): void ns3::LrWpanMacHeader::SetType(ns3::LrWpanMacHeader::LrWpanMacType wpanMacType) [member function]
cls.add_method('SetType',
'void',
[param('ns3::LrWpanMacHeader::LrWpanMacType', 'wpanMacType')])
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) [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) [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<const ns3::Object> ns3::Object::AggregateIterator::Next() [member function]
cls.add_method('Next',
'ns3::Ptr< ns3::Object const >',
[])
return
def register_Ns3PcapFileWrapper_methods(root_module, cls):
## pcap-file-wrapper.h (module 'network'): static ns3::TypeId ns3::PcapFileWrapper::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## pcap-file-wrapper.h (module 'network'): ns3::PcapFileWrapper::PcapFileWrapper() [constructor]
cls.add_constructor([])
## pcap-file-wrapper.h (module 'network'): bool ns3::PcapFileWrapper::Fail() const [member function]
cls.add_method('Fail',
'bool',
[],
is_const=True)
## pcap-file-wrapper.h (module 'network'): bool ns3::PcapFileWrapper::Eof() const [member function]
cls.add_method('Eof',
'bool',
[],
is_const=True)
## pcap-file-wrapper.h (module 'network'): void ns3::PcapFileWrapper::Clear() [member function]
cls.add_method('Clear',
'void',
[])
## pcap-file-wrapper.h (module 'network'): void ns3::PcapFileWrapper::Open(std::string const & filename, std::ios_base::openmode mode) [member function]
cls.add_method('Open',
'void',
[param('std::string const &', 'filename'), param('std::ios_base::openmode', 'mode')])
## pcap-file-wrapper.h (module 'network'): void ns3::PcapFileWrapper::Close() [member function]
cls.add_method('Close',
'void',
[])
## pcap-file-wrapper.h (module 'network'): void ns3::PcapFileWrapper::Init(uint32_t dataLinkType, uint32_t snapLen=std::numeric_limits<unsigned int>::max(), int32_t tzCorrection=ns3::PcapFile::ZONE_DEFAULT) [member function]
cls.add_method('Init',
'void',
[param('uint32_t', 'dataLinkType'), param('uint32_t', 'snapLen', default_value='std::numeric_limits<unsigned int>::max()'), param('int32_t', 'tzCorrection', default_value='ns3::PcapFile::ZONE_DEFAULT')])
## pcap-file-wrapper.h (module 'network'): void ns3::PcapFileWrapper::Write(ns3::Time t, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('Write',
'void',
[param('ns3::Time', 't'), param('ns3::Ptr< ns3::Packet const >', 'p')])
## pcap-file-wrapper.h (module 'network'): void ns3::PcapFileWrapper::Write(ns3::Time t, ns3::Header const & header, ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('Write',
'void',
[param('ns3::Time', 't'), param('ns3::Header const &', 'header'), param('ns3::Ptr< ns3::Packet const >', 'p')])
## pcap-file-wrapper.h (module 'network'): void ns3::PcapFileWrapper::Write(ns3::Time t, uint8_t const * buffer, uint32_t length) [member function]
cls.add_method('Write',
'void',
[param('ns3::Time', 't'), param('uint8_t const *', 'buffer'), param('uint32_t', 'length')])
## pcap-file-wrapper.h (module 'network'): ns3::Ptr<ns3::Packet> ns3::PcapFileWrapper::Read(ns3::Time & t) [member function]
cls.add_method('Read',
'ns3::Ptr< ns3::Packet >',
[param('ns3::Time &', 't')])
## pcap-file-wrapper.h (module 'network'): uint32_t ns3::PcapFileWrapper::GetMagic() [member function]
cls.add_method('GetMagic',
'uint32_t',
[])
## pcap-file-wrapper.h (module 'network'): uint16_t ns3::PcapFileWrapper::GetVersionMajor() [member function]
cls.add_method('GetVersionMajor',
'uint16_t',
[])
## pcap-file-wrapper.h (module 'network'): uint16_t ns3::PcapFileWrapper::GetVersionMinor() [member function]
cls.add_method('GetVersionMinor',
'uint16_t',
[])
## pcap-file-wrapper.h (module 'network'): int32_t ns3::PcapFileWrapper::GetTimeZoneOffset() [member function]
cls.add_method('GetTimeZoneOffset',
'int32_t',
[])
## pcap-file-wrapper.h (module 'network'): uint32_t ns3::PcapFileWrapper::GetSigFigs() [member function]
cls.add_method('GetSigFigs',
'uint32_t',
[])
## pcap-file-wrapper.h (module 'network'): uint32_t ns3::PcapFileWrapper::GetSnapLen() [member function]
cls.add_method('GetSnapLen',
'uint32_t',
[])
## pcap-file-wrapper.h (module 'network'): uint32_t ns3::PcapFileWrapper::GetDataLinkType() [member function]
cls.add_method('GetDataLinkType',
'uint32_t',
[])
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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter< ns3::AttributeAccessor > > const &', 'o')])
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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter< ns3::AttributeChecker > > const &', 'o')])
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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter< ns3::AttributeValue > > const &', 'o')])
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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter< ns3::CallbackImplBase > > const &', 'o')])
return
def register_Ns3SimpleRefCount__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::EventImpl, ns3::empty, ns3::DefaultDeleter<ns3::EventImpl> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::EventImpl, ns3::empty, ns3::DefaultDeleter<ns3::EventImpl> >::SimpleRefCount(ns3::SimpleRefCount<ns3::EventImpl, ns3::empty, ns3::DefaultDeleter<ns3::EventImpl> > const & o) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::EventImpl, ns3::empty, ns3::DefaultDeleter< ns3::EventImpl > > const &', 'o')])
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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter< ns3::Hash::Implementation > > const &', 'o')])
return
def register_Ns3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >::SimpleRefCount(ns3::SimpleRefCount<ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> > const & o) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter< ns3::LrWpanInterferenceHelper > > const &', 'o')])
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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter< ns3::NixVector > > const &', 'o')])
return
def register_Ns3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >::SimpleRefCount(ns3::SimpleRefCount<ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> > const & o) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter< ns3::OutputStreamWrapper > > const &', 'o')])
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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::Packet, ns3::empty, ns3::DefaultDeleter< ns3::Packet > > const &', 'o')])
return
def register_Ns3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt___methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter<ns3::SpectrumSignalParameters> >::SimpleRefCount() [constructor]
cls.add_constructor([])
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter<ns3::SpectrumSignalParameters> >::SimpleRefCount(ns3::SimpleRefCount<ns3::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter<ns3::SpectrumSignalParameters> > const & o) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter< ns3::SpectrumSignalParameters > > const &', 'o')])
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) [constructor]
cls.add_constructor([param('ns3::SimpleRefCount< ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter< ns3::TraceSourceAccessor > > const &', 'o')])
return
def register_Ns3SpectrumPhy_methods(root_module, cls):
## spectrum-phy.h (module 'spectrum'): ns3::SpectrumPhy::SpectrumPhy() [constructor]
cls.add_constructor([])
## spectrum-phy.h (module 'spectrum'): static ns3::TypeId ns3::SpectrumPhy::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## spectrum-phy.h (module 'spectrum'): void ns3::SpectrumPhy::SetDevice(ns3::Ptr<ns3::NetDevice> d) [member function]
cls.add_method('SetDevice',
'void',
[param('ns3::Ptr< ns3::NetDevice >', 'd')],
is_pure_virtual=True, is_virtual=True)
## spectrum-phy.h (module 'spectrum'): ns3::Ptr<ns3::NetDevice> ns3::SpectrumPhy::GetDevice() const [member function]
cls.add_method('GetDevice',
'ns3::Ptr< ns3::NetDevice >',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## spectrum-phy.h (module 'spectrum'): void ns3::SpectrumPhy::SetMobility(ns3::Ptr<ns3::MobilityModel> m) [member function]
cls.add_method('SetMobility',
'void',
[param('ns3::Ptr< ns3::MobilityModel >', 'm')],
is_pure_virtual=True, is_virtual=True)
## spectrum-phy.h (module 'spectrum'): ns3::Ptr<ns3::MobilityModel> ns3::SpectrumPhy::GetMobility() [member function]
cls.add_method('GetMobility',
'ns3::Ptr< ns3::MobilityModel >',
[],
is_pure_virtual=True, is_virtual=True)
## spectrum-phy.h (module 'spectrum'): void ns3::SpectrumPhy::SetChannel(ns3::Ptr<ns3::SpectrumChannel> c) [member function]
cls.add_method('SetChannel',
'void',
[param('ns3::Ptr< ns3::SpectrumChannel >', 'c')],
is_pure_virtual=True, is_virtual=True)
## spectrum-phy.h (module 'spectrum'): ns3::Ptr<const ns3::SpectrumModel> ns3::SpectrumPhy::GetRxSpectrumModel() const [member function]
cls.add_method('GetRxSpectrumModel',
'ns3::Ptr< ns3::SpectrumModel const >',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## spectrum-phy.h (module 'spectrum'): ns3::Ptr<ns3::AntennaModel> ns3::SpectrumPhy::GetRxAntenna() [member function]
cls.add_method('GetRxAntenna',
'ns3::Ptr< ns3::AntennaModel >',
[],
is_pure_virtual=True, is_virtual=True)
## spectrum-phy.h (module 'spectrum'): void ns3::SpectrumPhy::StartRx(ns3::Ptr<ns3::SpectrumSignalParameters> params) [member function]
cls.add_method('StartRx',
'void',
[param('ns3::Ptr< ns3::SpectrumSignalParameters >', 'params')],
is_pure_virtual=True, is_virtual=True)
return
def register_Ns3SpectrumSignalParameters_methods(root_module, cls):
## spectrum-signal-parameters.h (module 'spectrum'): ns3::SpectrumSignalParameters::SpectrumSignalParameters() [constructor]
cls.add_constructor([])
## spectrum-signal-parameters.h (module 'spectrum'): ns3::SpectrumSignalParameters::SpectrumSignalParameters(ns3::SpectrumSignalParameters const & p) [constructor]
cls.add_constructor([param('ns3::SpectrumSignalParameters const &', 'p')])
## spectrum-signal-parameters.h (module 'spectrum'): ns3::Ptr<ns3::SpectrumSignalParameters> ns3::SpectrumSignalParameters::Copy() [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::SpectrumSignalParameters >',
[],
is_virtual=True)
## spectrum-signal-parameters.h (module 'spectrum'): ns3::SpectrumSignalParameters::psd [variable]
cls.add_instance_attribute('psd', 'ns3::Ptr< ns3::SpectrumValue >', is_const=False)
## spectrum-signal-parameters.h (module 'spectrum'): ns3::SpectrumSignalParameters::duration [variable]
cls.add_instance_attribute('duration', 'ns3::Time', is_const=False)
## spectrum-signal-parameters.h (module 'spectrum'): ns3::SpectrumSignalParameters::txPhy [variable]
cls.add_instance_attribute('txPhy', 'ns3::Ptr< ns3::SpectrumPhy >', is_const=False)
## spectrum-signal-parameters.h (module 'spectrum'): ns3::SpectrumSignalParameters::txAntenna [variable]
cls.add_instance_attribute('txAntenna', 'ns3::Ptr< ns3::AntennaModel >', is_const=False)
return
def register_Ns3Time_methods(root_module, cls):
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('!=')
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('>=')
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('>')
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_numeric_operator('/', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
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()
## nstime.h (module 'core'): ns3::Time::Time() [constructor]
cls.add_constructor([])
## nstime.h (module 'core'): ns3::Time::Time(ns3::Time const & o) [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) [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) [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) [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) [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) [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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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_Ns3BooleanChecker_methods(root_module, cls):
## boolean.h (module 'core'): ns3::BooleanChecker::BooleanChecker() [constructor]
cls.add_constructor([])
## boolean.h (module 'core'): ns3::BooleanChecker::BooleanChecker(ns3::BooleanChecker const & arg0) [constructor]
cls.add_constructor([param('ns3::BooleanChecker const &', 'arg0')])
return
def register_Ns3BooleanValue_methods(root_module, cls):
cls.add_output_stream_operator()
## boolean.h (module 'core'): ns3::BooleanValue::BooleanValue(ns3::BooleanValue const & arg0) [constructor]
cls.add_constructor([param('ns3::BooleanValue const &', 'arg0')])
## boolean.h (module 'core'): ns3::BooleanValue::BooleanValue() [constructor]
cls.add_constructor([])
## boolean.h (module 'core'): ns3::BooleanValue::BooleanValue(bool value) [constructor]
cls.add_constructor([param('bool', 'value')])
## boolean.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::BooleanValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## boolean.h (module 'core'): bool ns3::BooleanValue::DeserializeFromString(std::string value, ns3::Ptr<const ns3::AttributeChecker> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## boolean.h (module 'core'): bool ns3::BooleanValue::Get() const [member function]
cls.add_method('Get',
'bool',
[],
is_const=True)
## boolean.h (module 'core'): std::string ns3::BooleanValue::SerializeToString(ns3::Ptr<const ns3::AttributeChecker> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## boolean.h (module 'core'): void ns3::BooleanValue::Set(bool value) [member function]
cls.add_method('Set',
'void',
[param('bool', 'value')])
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) [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) [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<const ns3::CallbackImplBase> 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')
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::ObjectBase*'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'void'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::LrWpanPhyEnumeration'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::LrWpanMacState'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::Ptr<ns3::Packet const> '])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'double'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::Time'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'unsigned char'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::McpsDataIndicationParams'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::Ptr<ns3::Packet> '])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::McpsDataConfirmParams'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::Ptr<ns3::NetDevice> '])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'unsigned short'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::Address const&'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'ns3::NetDevice::PacketType'])
## callback.h (module 'core'): static std::string ns3::CallbackImplBase::GetCppTypeid() [member function]
cls.add_method('GetCppTypeid',
'std::string',
[],
is_static=True, visibility='protected', template_parameters=[u'bool'])
return
def register_Ns3CallbackValue_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackValue::CallbackValue(ns3::CallbackValue const & arg0) [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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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_Ns3DoubleValue_methods(root_module, cls):
## double.h (module 'core'): ns3::DoubleValue::DoubleValue() [constructor]
cls.add_constructor([])
## double.h (module 'core'): ns3::DoubleValue::DoubleValue(double const & value) [constructor]
cls.add_constructor([param('double const &', 'value')])
## double.h (module 'core'): ns3::DoubleValue::DoubleValue(ns3::DoubleValue const & arg0) [constructor]
cls.add_constructor([param('ns3::DoubleValue const &', 'arg0')])
## double.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::DoubleValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## double.h (module 'core'): bool ns3::DoubleValue::DeserializeFromString(std::string value, ns3::Ptr<const ns3::AttributeChecker> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## double.h (module 'core'): double ns3::DoubleValue::Get() const [member function]
cls.add_method('Get',
'double',
[],
is_const=True)
## double.h (module 'core'): std::string ns3::DoubleValue::SerializeToString(ns3::Ptr<const ns3::AttributeChecker> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## double.h (module 'core'): void ns3::DoubleValue::Set(double const & value) [member function]
cls.add_method('Set',
'void',
[param('double const &', 'value')])
return
def register_Ns3EmptyAttributeAccessor_methods(root_module, cls):
## attribute.h (module 'core'): ns3::EmptyAttributeAccessor::EmptyAttributeAccessor(ns3::EmptyAttributeAccessor const & arg0) [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) [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) [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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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_Ns3EnumChecker_methods(root_module, cls):
## enum.h (module 'core'): ns3::EnumChecker::EnumChecker(ns3::EnumChecker const & arg0) [constructor]
cls.add_constructor([param('ns3::EnumChecker const &', 'arg0')])
## enum.h (module 'core'): ns3::EnumChecker::EnumChecker() [constructor]
cls.add_constructor([])
## enum.h (module 'core'): void ns3::EnumChecker::Add(int value, std::string name) [member function]
cls.add_method('Add',
'void',
[param('int', 'value'), param('std::string', 'name')])
## enum.h (module 'core'): void ns3::EnumChecker::AddDefault(int value, std::string name) [member function]
cls.add_method('AddDefault',
'void',
[param('int', 'value'), param('std::string', 'name')])
## enum.h (module 'core'): bool ns3::EnumChecker::Check(ns3::AttributeValue const & value) const [member function]
cls.add_method('Check',
'bool',
[param('ns3::AttributeValue const &', 'value')],
is_const=True, is_virtual=True)
## enum.h (module 'core'): bool ns3::EnumChecker::Copy(ns3::AttributeValue const & src, ns3::AttributeValue & dst) const [member function]
cls.add_method('Copy',
'bool',
[param('ns3::AttributeValue const &', 'src'), param('ns3::AttributeValue &', 'dst')],
is_const=True, is_virtual=True)
## enum.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::EnumChecker::Create() const [member function]
cls.add_method('Create',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## enum.h (module 'core'): std::string ns3::EnumChecker::GetUnderlyingTypeInformation() const [member function]
cls.add_method('GetUnderlyingTypeInformation',
'std::string',
[],
is_const=True, is_virtual=True)
## enum.h (module 'core'): std::string ns3::EnumChecker::GetValueTypeName() const [member function]
cls.add_method('GetValueTypeName',
'std::string',
[],
is_const=True, is_virtual=True)
## enum.h (module 'core'): bool ns3::EnumChecker::HasUnderlyingTypeInformation() const [member function]
cls.add_method('HasUnderlyingTypeInformation',
'bool',
[],
is_const=True, is_virtual=True)
return
def register_Ns3EnumValue_methods(root_module, cls):
## enum.h (module 'core'): ns3::EnumValue::EnumValue(ns3::EnumValue const & arg0) [constructor]
cls.add_constructor([param('ns3::EnumValue const &', 'arg0')])
## enum.h (module 'core'): ns3::EnumValue::EnumValue() [constructor]
cls.add_constructor([])
## enum.h (module 'core'): ns3::EnumValue::EnumValue(int value) [constructor]
cls.add_constructor([param('int', 'value')])
## enum.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::EnumValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## enum.h (module 'core'): bool ns3::EnumValue::DeserializeFromString(std::string value, ns3::Ptr<const ns3::AttributeChecker> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## enum.h (module 'core'): int ns3::EnumValue::Get() const [member function]
cls.add_method('Get',
'int',
[],
is_const=True)
## enum.h (module 'core'): std::string ns3::EnumValue::SerializeToString(ns3::Ptr<const ns3::AttributeChecker> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## enum.h (module 'core'): void ns3::EnumValue::Set(int value) [member function]
cls.add_method('Set',
'void',
[param('int', 'value')])
return
def register_Ns3EventImpl_methods(root_module, cls):
## event-impl.h (module 'core'): ns3::EventImpl::EventImpl(ns3::EventImpl const & arg0) [constructor]
cls.add_constructor([param('ns3::EventImpl const &', 'arg0')])
## event-impl.h (module 'core'): ns3::EventImpl::EventImpl() [constructor]
cls.add_constructor([])
## event-impl.h (module 'core'): void ns3::EventImpl::Cancel() [member function]
cls.add_method('Cancel',
'void',
[])
## event-impl.h (module 'core'): void ns3::EventImpl::Invoke() [member function]
cls.add_method('Invoke',
'void',
[])
## event-impl.h (module 'core'): bool ns3::EventImpl::IsCancelled() [member function]
cls.add_method('IsCancelled',
'bool',
[])
## event-impl.h (module 'core'): void ns3::EventImpl::Notify() [member function]
cls.add_method('Notify',
'void',
[],
is_pure_virtual=True, visibility='protected', is_virtual=True)
return
def register_Ns3IntegerValue_methods(root_module, cls):
## integer.h (module 'core'): ns3::IntegerValue::IntegerValue() [constructor]
cls.add_constructor([])
## integer.h (module 'core'): ns3::IntegerValue::IntegerValue(int64_t const & value) [constructor]
cls.add_constructor([param('int64_t const &', 'value')])
## integer.h (module 'core'): ns3::IntegerValue::IntegerValue(ns3::IntegerValue const & arg0) [constructor]
cls.add_constructor([param('ns3::IntegerValue const &', 'arg0')])
## integer.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::IntegerValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## integer.h (module 'core'): bool ns3::IntegerValue::DeserializeFromString(std::string value, ns3::Ptr<const ns3::AttributeChecker> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## integer.h (module 'core'): int64_t ns3::IntegerValue::Get() const [member function]
cls.add_method('Get',
'int64_t',
[],
is_const=True)
## integer.h (module 'core'): std::string ns3::IntegerValue::SerializeToString(ns3::Ptr<const ns3::AttributeChecker> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## integer.h (module 'core'): void ns3::IntegerValue::Set(int64_t const & value) [member function]
cls.add_method('Set',
'void',
[param('int64_t const &', 'value')])
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) [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::Ipv4Address const & value) [constructor]
cls.add_constructor([param('ns3::Ipv4Address const &', 'value')])
## ipv4-address.h (module 'network'): ns3::Ipv4AddressValue::Ipv4AddressValue(ns3::Ipv4AddressValue const & arg0) [constructor]
cls.add_constructor([param('ns3::Ipv4AddressValue const &', 'arg0')])
## 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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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) [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::Ipv4Mask const & value) [constructor]
cls.add_constructor([param('ns3::Ipv4Mask const &', 'value')])
## ipv4-address.h (module 'network'): ns3::Ipv4MaskValue::Ipv4MaskValue(ns3::Ipv4MaskValue const & arg0) [constructor]
cls.add_constructor([param('ns3::Ipv4MaskValue const &', 'arg0')])
## 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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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) [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::Ipv6Address const & value) [constructor]
cls.add_constructor([param('ns3::Ipv6Address const &', 'value')])
## ipv6-address.h (module 'network'): ns3::Ipv6AddressValue::Ipv6AddressValue(ns3::Ipv6AddressValue const & arg0) [constructor]
cls.add_constructor([param('ns3::Ipv6AddressValue const &', 'arg0')])
## 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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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) [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::Ipv6Prefix const & value) [constructor]
cls.add_constructor([param('ns3::Ipv6Prefix const &', 'value')])
## ipv6-address.h (module 'network'): ns3::Ipv6PrefixValue::Ipv6PrefixValue(ns3::Ipv6PrefixValue const & arg0) [constructor]
cls.add_constructor([param('ns3::Ipv6PrefixValue const &', 'arg0')])
## 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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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_Ns3LrWpanCsmaCa_methods(root_module, cls):
## lr-wpan-csmaca.h (module 'lr-wpan'): static ns3::TypeId ns3::LrWpanCsmaCa::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): ns3::LrWpanCsmaCa::LrWpanCsmaCa() [constructor]
cls.add_constructor([])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::SetMac(ns3::Ptr<ns3::LrWpanMac> mac) [member function]
cls.add_method('SetMac',
'void',
[param('ns3::Ptr< ns3::LrWpanMac >', 'mac')])
## lr-wpan-csmaca.h (module 'lr-wpan'): ns3::Ptr<ns3::LrWpanMac> ns3::LrWpanCsmaCa::GetMac() const [member function]
cls.add_method('GetMac',
'ns3::Ptr< ns3::LrWpanMac >',
[],
is_const=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::SetSlottedCsmaCa() [member function]
cls.add_method('SetSlottedCsmaCa',
'void',
[])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::SetUnSlottedCsmaCa() [member function]
cls.add_method('SetUnSlottedCsmaCa',
'void',
[])
## lr-wpan-csmaca.h (module 'lr-wpan'): bool ns3::LrWpanCsmaCa::IsSlottedCsmaCa() const [member function]
cls.add_method('IsSlottedCsmaCa',
'bool',
[],
is_const=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): bool ns3::LrWpanCsmaCa::IsUnSlottedCsmaCa() const [member function]
cls.add_method('IsUnSlottedCsmaCa',
'bool',
[],
is_const=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::SetMacMinBE(uint8_t macMinBE) [member function]
cls.add_method('SetMacMinBE',
'void',
[param('uint8_t', 'macMinBE')])
## lr-wpan-csmaca.h (module 'lr-wpan'): uint8_t ns3::LrWpanCsmaCa::GetMacMinBE() const [member function]
cls.add_method('GetMacMinBE',
'uint8_t',
[],
is_const=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::SetMacMaxBE(uint8_t macMaxBE) [member function]
cls.add_method('SetMacMaxBE',
'void',
[param('uint8_t', 'macMaxBE')])
## lr-wpan-csmaca.h (module 'lr-wpan'): uint8_t ns3::LrWpanCsmaCa::GetMacMaxBE() const [member function]
cls.add_method('GetMacMaxBE',
'uint8_t',
[],
is_const=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::SetMacMaxCSMABackoffs(uint8_t macMaxCSMABackoffs) [member function]
cls.add_method('SetMacMaxCSMABackoffs',
'void',
[param('uint8_t', 'macMaxCSMABackoffs')])
## lr-wpan-csmaca.h (module 'lr-wpan'): uint8_t ns3::LrWpanCsmaCa::GetMacMaxCSMABackoffs() const [member function]
cls.add_method('GetMacMaxCSMABackoffs',
'uint8_t',
[],
is_const=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::SetUnitBackoffPeriod(uint64_t unitBackoffPeriod) [member function]
cls.add_method('SetUnitBackoffPeriod',
'void',
[param('uint64_t', 'unitBackoffPeriod')])
## lr-wpan-csmaca.h (module 'lr-wpan'): uint64_t ns3::LrWpanCsmaCa::GetUnitBackoffPeriod() const [member function]
cls.add_method('GetUnitBackoffPeriod',
'uint64_t',
[],
is_const=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): ns3::Time ns3::LrWpanCsmaCa::GetTimeToNextSlot() const [member function]
cls.add_method('GetTimeToNextSlot',
'ns3::Time',
[],
is_const=True)
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::Start() [member function]
cls.add_method('Start',
'void',
[])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::Cancel() [member function]
cls.add_method('Cancel',
'void',
[])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::RandomBackoffDelay() [member function]
cls.add_method('RandomBackoffDelay',
'void',
[])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::CanProceed() [member function]
cls.add_method('CanProceed',
'void',
[])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::RequestCCA() [member function]
cls.add_method('RequestCCA',
'void',
[])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::PlmeCcaConfirm(ns3::LrWpanPhyEnumeration status) [member function]
cls.add_method('PlmeCcaConfirm',
'void',
[param('ns3::LrWpanPhyEnumeration', 'status')])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::SetLrWpanMacStateCallback(ns3::LrWpanMacStateCallback macState) [member function]
cls.add_method('SetLrWpanMacStateCallback',
'void',
[param('ns3::Callback< void, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'macState')])
## lr-wpan-csmaca.h (module 'lr-wpan'): int64_t ns3::LrWpanCsmaCa::AssignStreams(int64_t stream) [member function]
cls.add_method('AssignStreams',
'int64_t',
[param('int64_t', 'stream')])
## lr-wpan-csmaca.h (module 'lr-wpan'): uint8_t ns3::LrWpanCsmaCa::GetNB() [member function]
cls.add_method('GetNB',
'uint8_t',
[])
## lr-wpan-csmaca.h (module 'lr-wpan'): void ns3::LrWpanCsmaCa::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
[],
visibility='private', is_virtual=True)
return
def register_Ns3LrWpanErrorModel_methods(root_module, cls):
## lr-wpan-error-model.h (module 'lr-wpan'): ns3::LrWpanErrorModel::LrWpanErrorModel(ns3::LrWpanErrorModel const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanErrorModel const &', 'arg0')])
## lr-wpan-error-model.h (module 'lr-wpan'): ns3::LrWpanErrorModel::LrWpanErrorModel() [constructor]
cls.add_constructor([])
## lr-wpan-error-model.h (module 'lr-wpan'): double ns3::LrWpanErrorModel::GetChunkSuccessRate(double snr, uint32_t nbits) const [member function]
cls.add_method('GetChunkSuccessRate',
'double',
[param('double', 'snr'), param('uint32_t', 'nbits')],
is_const=True)
## lr-wpan-error-model.h (module 'lr-wpan'): static ns3::TypeId ns3::LrWpanErrorModel::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
return
def register_Ns3LrWpanInterferenceHelper_methods(root_module, cls):
## lr-wpan-interference-helper.h (module 'lr-wpan'): ns3::LrWpanInterferenceHelper::LrWpanInterferenceHelper(ns3::Ptr<const ns3::SpectrumModel> spectrumModel) [constructor]
cls.add_constructor([param('ns3::Ptr< ns3::SpectrumModel const >', 'spectrumModel')])
## lr-wpan-interference-helper.h (module 'lr-wpan'): bool ns3::LrWpanInterferenceHelper::AddSignal(ns3::Ptr<const ns3::SpectrumValue> signal) [member function]
cls.add_method('AddSignal',
'bool',
[param('ns3::Ptr< ns3::SpectrumValue const >', 'signal')])
## lr-wpan-interference-helper.h (module 'lr-wpan'): bool ns3::LrWpanInterferenceHelper::RemoveSignal(ns3::Ptr<const ns3::SpectrumValue> signal) [member function]
cls.add_method('RemoveSignal',
'bool',
[param('ns3::Ptr< ns3::SpectrumValue const >', 'signal')])
## lr-wpan-interference-helper.h (module 'lr-wpan'): void ns3::LrWpanInterferenceHelper::ClearSignals() [member function]
cls.add_method('ClearSignals',
'void',
[])
## lr-wpan-interference-helper.h (module 'lr-wpan'): ns3::Ptr<ns3::SpectrumValue> ns3::LrWpanInterferenceHelper::GetSignalPsd() const [member function]
cls.add_method('GetSignalPsd',
'ns3::Ptr< ns3::SpectrumValue >',
[],
is_const=True)
## lr-wpan-interference-helper.h (module 'lr-wpan'): ns3::Ptr<const ns3::SpectrumModel> ns3::LrWpanInterferenceHelper::GetSpectrumModel() const [member function]
cls.add_method('GetSpectrumModel',
'ns3::Ptr< ns3::SpectrumModel const >',
[],
is_const=True)
return
def register_Ns3LrWpanMac_methods(root_module, cls):
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::LrWpanMac(ns3::LrWpanMac const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanMac const &', 'arg0')])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::LrWpanMac() [constructor]
cls.add_constructor([])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanAssociationStatus ns3::LrWpanMac::GetAssociationStatus() const [member function]
cls.add_method('GetAssociationStatus',
'ns3::LrWpanAssociationStatus',
[],
is_const=True)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::Mac64Address ns3::LrWpanMac::GetExtendedAddress() const [member function]
cls.add_method('GetExtendedAddress',
'ns3::Mac64Address',
[],
is_const=True)
## lr-wpan-mac.h (module 'lr-wpan'): uint64_t ns3::LrWpanMac::GetMacAckWaitDuration() const [member function]
cls.add_method('GetMacAckWaitDuration',
'uint64_t',
[],
is_const=True)
## lr-wpan-mac.h (module 'lr-wpan'): uint8_t ns3::LrWpanMac::GetMacMaxFrameRetries() const [member function]
cls.add_method('GetMacMaxFrameRetries',
'uint8_t',
[],
is_const=True)
## lr-wpan-mac.h (module 'lr-wpan'): uint16_t ns3::LrWpanMac::GetPanId() const [member function]
cls.add_method('GetPanId',
'uint16_t',
[],
is_const=True)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::Ptr<ns3::LrWpanPhy> ns3::LrWpanMac::GetPhy() [member function]
cls.add_method('GetPhy',
'ns3::Ptr< ns3::LrWpanPhy >',
[])
## lr-wpan-mac.h (module 'lr-wpan'): bool ns3::LrWpanMac::GetRxOnWhenIdle() [member function]
cls.add_method('GetRxOnWhenIdle',
'bool',
[])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::Mac16Address ns3::LrWpanMac::GetShortAddress() const [member function]
cls.add_method('GetShortAddress',
'ns3::Mac16Address',
[],
is_const=True)
## lr-wpan-mac.h (module 'lr-wpan'): static ns3::TypeId ns3::LrWpanMac::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::McpsDataRequest(ns3::McpsDataRequestParams params, ns3::Ptr<ns3::Packet> p) [member function]
cls.add_method('McpsDataRequest',
'void',
[param('ns3::McpsDataRequestParams', 'params'), param('ns3::Ptr< ns3::Packet >', 'p')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::PdDataConfirm(ns3::LrWpanPhyEnumeration status) [member function]
cls.add_method('PdDataConfirm',
'void',
[param('ns3::LrWpanPhyEnumeration', 'status')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::PdDataIndication(uint32_t psduLength, ns3::Ptr<ns3::Packet> p, uint8_t lqi) [member function]
cls.add_method('PdDataIndication',
'void',
[param('uint32_t', 'psduLength'), param('ns3::Ptr< ns3::Packet >', 'p'), param('uint8_t', 'lqi')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::PlmeCcaConfirm(ns3::LrWpanPhyEnumeration status) [member function]
cls.add_method('PlmeCcaConfirm',
'void',
[param('ns3::LrWpanPhyEnumeration', 'status')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::PlmeEdConfirm(ns3::LrWpanPhyEnumeration status, uint8_t energyLevel) [member function]
cls.add_method('PlmeEdConfirm',
'void',
[param('ns3::LrWpanPhyEnumeration', 'status'), param('uint8_t', 'energyLevel')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::PlmeGetAttributeConfirm(ns3::LrWpanPhyEnumeration status, ns3::LrWpanPibAttributeIdentifier id, ns3::LrWpanPhyPibAttributes * attribute) [member function]
cls.add_method('PlmeGetAttributeConfirm',
'void',
[param('ns3::LrWpanPhyEnumeration', 'status'), param('ns3::LrWpanPibAttributeIdentifier', 'id'), param('ns3::LrWpanPhyPibAttributes *', 'attribute')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::PlmeSetAttributeConfirm(ns3::LrWpanPhyEnumeration status, ns3::LrWpanPibAttributeIdentifier id) [member function]
cls.add_method('PlmeSetAttributeConfirm',
'void',
[param('ns3::LrWpanPhyEnumeration', 'status'), param('ns3::LrWpanPibAttributeIdentifier', 'id')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::PlmeSetTRXStateConfirm(ns3::LrWpanPhyEnumeration status) [member function]
cls.add_method('PlmeSetTRXStateConfirm',
'void',
[param('ns3::LrWpanPhyEnumeration', 'status')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetAssociationStatus(ns3::LrWpanAssociationStatus status) [member function]
cls.add_method('SetAssociationStatus',
'void',
[param('ns3::LrWpanAssociationStatus', 'status')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetCsmaCa(ns3::Ptr<ns3::LrWpanCsmaCa> csmaCa) [member function]
cls.add_method('SetCsmaCa',
'void',
[param('ns3::Ptr< ns3::LrWpanCsmaCa >', 'csmaCa')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetExtendedAddress(ns3::Mac64Address address) [member function]
cls.add_method('SetExtendedAddress',
'void',
[param('ns3::Mac64Address', 'address')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetLrWpanMacState(ns3::LrWpanMacState macState) [member function]
cls.add_method('SetLrWpanMacState',
'void',
[param('ns3::LrWpanMacState', 'macState')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetMacMaxFrameRetries(uint8_t retries) [member function]
cls.add_method('SetMacMaxFrameRetries',
'void',
[param('uint8_t', 'retries')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetMcpsDataConfirmCallback(ns3::McpsDataConfirmCallback c) [member function]
cls.add_method('SetMcpsDataConfirmCallback',
'void',
[param('ns3::Callback< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetMcpsDataIndicationCallback(ns3::McpsDataIndicationCallback c) [member function]
cls.add_method('SetMcpsDataIndicationCallback',
'void',
[param('ns3::Callback< void, ns3::McpsDataIndicationParams, ns3::Ptr< ns3::Packet >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetPanId(uint16_t panId) [member function]
cls.add_method('SetPanId',
'void',
[param('uint16_t', 'panId')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetPhy(ns3::Ptr<ns3::LrWpanPhy> phy) [member function]
cls.add_method('SetPhy',
'void',
[param('ns3::Ptr< ns3::LrWpanPhy >', 'phy')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetRxOnWhenIdle(bool rxOnWhenIdle) [member function]
cls.add_method('SetRxOnWhenIdle',
'void',
[param('bool', 'rxOnWhenIdle')])
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::SetShortAddress(ns3::Mac16Address address) [member function]
cls.add_method('SetShortAddress',
'void',
[param('ns3::Mac16Address', 'address')])
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::aMinMPDUOverhead [variable]
cls.add_static_attribute('aMinMPDUOverhead', 'uint32_t const', is_const=True)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_aBaseSlotDuration [variable]
cls.add_instance_attribute('m_aBaseSlotDuration', 'uint64_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_aBaseSuperframeDuration [variable]
cls.add_instance_attribute('m_aBaseSuperframeDuration', 'uint64_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_aNumSuperframeSlots [variable]
cls.add_instance_attribute('m_aNumSuperframeSlots', 'uint64_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macBeaconOrder [variable]
cls.add_instance_attribute('m_macBeaconOrder', 'uint64_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macBeaconTxTime [variable]
cls.add_instance_attribute('m_macBeaconTxTime', 'uint64_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macDsn [variable]
cls.add_instance_attribute('m_macDsn', 'ns3::SequenceNumber8', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macMaxFrameRetries [variable]
cls.add_instance_attribute('m_macMaxFrameRetries', 'uint8_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macPanId [variable]
cls.add_instance_attribute('m_macPanId', 'uint16_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macPromiscuousMode [variable]
cls.add_instance_attribute('m_macPromiscuousMode', 'bool', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macRxOnWhenIdle [variable]
cls.add_instance_attribute('m_macRxOnWhenIdle', 'bool', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macSuperframeOrder [variable]
cls.add_instance_attribute('m_macSuperframeOrder', 'uint64_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): ns3::LrWpanMac::m_macSyncSymbolOffset [variable]
cls.add_instance_attribute('m_macSyncSymbolOffset', 'uint64_t', is_const=False)
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
[],
visibility='protected', is_virtual=True)
## lr-wpan-mac.h (module 'lr-wpan'): void ns3::LrWpanMac::DoInitialize() [member function]
cls.add_method('DoInitialize',
'void',
[],
visibility='protected', is_virtual=True)
return
def register_Ns3LrWpanMacTrailer_methods(root_module, cls):
## lr-wpan-mac-trailer.h (module 'lr-wpan'): ns3::LrWpanMacTrailer::LrWpanMacTrailer(ns3::LrWpanMacTrailer const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanMacTrailer const &', 'arg0')])
## lr-wpan-mac-trailer.h (module 'lr-wpan'): ns3::LrWpanMacTrailer::LrWpanMacTrailer() [constructor]
cls.add_constructor([])
## lr-wpan-mac-trailer.h (module 'lr-wpan'): bool ns3::LrWpanMacTrailer::CheckFcs(ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('CheckFcs',
'bool',
[param('ns3::Ptr< ns3::Packet const >', 'p')])
## lr-wpan-mac-trailer.h (module 'lr-wpan'): uint32_t ns3::LrWpanMacTrailer::Deserialize(ns3::Buffer::Iterator start) [member function]
cls.add_method('Deserialize',
'uint32_t',
[param('ns3::Buffer::Iterator', 'start')],
is_virtual=True)
## lr-wpan-mac-trailer.h (module 'lr-wpan'): void ns3::LrWpanMacTrailer::EnableFcs(bool enable) [member function]
cls.add_method('EnableFcs',
'void',
[param('bool', 'enable')])
## lr-wpan-mac-trailer.h (module 'lr-wpan'): uint16_t ns3::LrWpanMacTrailer::GetFcs() const [member function]
cls.add_method('GetFcs',
'uint16_t',
[],
is_const=True)
## lr-wpan-mac-trailer.h (module 'lr-wpan'): ns3::TypeId ns3::LrWpanMacTrailer::GetInstanceTypeId() const [member function]
cls.add_method('GetInstanceTypeId',
'ns3::TypeId',
[],
is_const=True, is_virtual=True)
## lr-wpan-mac-trailer.h (module 'lr-wpan'): uint32_t ns3::LrWpanMacTrailer::GetSerializedSize() const [member function]
cls.add_method('GetSerializedSize',
'uint32_t',
[],
is_const=True, is_virtual=True)
## lr-wpan-mac-trailer.h (module 'lr-wpan'): static ns3::TypeId ns3::LrWpanMacTrailer::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## lr-wpan-mac-trailer.h (module 'lr-wpan'): bool ns3::LrWpanMacTrailer::IsFcsEnabled() [member function]
cls.add_method('IsFcsEnabled',
'bool',
[])
## lr-wpan-mac-trailer.h (module 'lr-wpan'): void ns3::LrWpanMacTrailer::Print(std::ostream & os) const [member function]
cls.add_method('Print',
'void',
[param('std::ostream &', 'os')],
is_const=True, is_virtual=True)
## lr-wpan-mac-trailer.h (module 'lr-wpan'): void ns3::LrWpanMacTrailer::Serialize(ns3::Buffer::Iterator start) const [member function]
cls.add_method('Serialize',
'void',
[param('ns3::Buffer::Iterator', 'start')],
is_const=True, is_virtual=True)
## lr-wpan-mac-trailer.h (module 'lr-wpan'): void ns3::LrWpanMacTrailer::SetFcs(ns3::Ptr<const ns3::Packet> p) [member function]
cls.add_method('SetFcs',
'void',
[param('ns3::Ptr< ns3::Packet const >', 'p')])
## lr-wpan-mac-trailer.h (module 'lr-wpan'): ns3::LrWpanMacTrailer::LR_WPAN_MAC_FCS_LENGTH [variable]
cls.add_static_attribute('LR_WPAN_MAC_FCS_LENGTH', 'uint16_t const', is_const=True)
return
def register_Ns3LrWpanPhy_methods(root_module, cls):
## lr-wpan-phy.h (module 'lr-wpan'): static ns3::TypeId ns3::LrWpanPhy::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhy::aMaxPhyPacketSize [variable]
cls.add_static_attribute('aMaxPhyPacketSize', 'uint32_t const', is_const=True)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhy::aTurnaroundTime [variable]
cls.add_static_attribute('aTurnaroundTime', 'uint32_t const', is_const=True)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::LrWpanPhy::LrWpanPhy() [constructor]
cls.add_constructor([])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetMobility(ns3::Ptr<ns3::MobilityModel> m) [member function]
cls.add_method('SetMobility',
'void',
[param('ns3::Ptr< ns3::MobilityModel >', 'm')],
is_virtual=True)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::Ptr<ns3::MobilityModel> ns3::LrWpanPhy::GetMobility() [member function]
cls.add_method('GetMobility',
'ns3::Ptr< ns3::MobilityModel >',
[],
is_virtual=True)
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetChannel(ns3::Ptr<ns3::SpectrumChannel> c) [member function]
cls.add_method('SetChannel',
'void',
[param('ns3::Ptr< ns3::SpectrumChannel >', 'c')],
is_virtual=True)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::Ptr<ns3::SpectrumChannel> ns3::LrWpanPhy::GetChannel() [member function]
cls.add_method('GetChannel',
'ns3::Ptr< ns3::SpectrumChannel >',
[])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetDevice(ns3::Ptr<ns3::NetDevice> d) [member function]
cls.add_method('SetDevice',
'void',
[param('ns3::Ptr< ns3::NetDevice >', 'd')],
is_virtual=True)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::Ptr<ns3::NetDevice> ns3::LrWpanPhy::GetDevice() const [member function]
cls.add_method('GetDevice',
'ns3::Ptr< ns3::NetDevice >',
[],
is_const=True, is_virtual=True)
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetAntenna(ns3::Ptr<ns3::AntennaModel> a) [member function]
cls.add_method('SetAntenna',
'void',
[param('ns3::Ptr< ns3::AntennaModel >', 'a')])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::Ptr<ns3::AntennaModel> ns3::LrWpanPhy::GetRxAntenna() [member function]
cls.add_method('GetRxAntenna',
'ns3::Ptr< ns3::AntennaModel >',
[],
is_virtual=True)
## lr-wpan-phy.h (module 'lr-wpan'): ns3::Ptr<const ns3::SpectrumModel> ns3::LrWpanPhy::GetRxSpectrumModel() const [member function]
cls.add_method('GetRxSpectrumModel',
'ns3::Ptr< ns3::SpectrumModel const >',
[],
is_const=True, is_virtual=True)
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetTxPowerSpectralDensity(ns3::Ptr<ns3::SpectrumValue> txPsd) [member function]
cls.add_method('SetTxPowerSpectralDensity',
'void',
[param('ns3::Ptr< ns3::SpectrumValue >', 'txPsd')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetNoisePowerSpectralDensity(ns3::Ptr<const ns3::SpectrumValue> noisePsd) [member function]
cls.add_method('SetNoisePowerSpectralDensity',
'void',
[param('ns3::Ptr< ns3::SpectrumValue const >', 'noisePsd')])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::Ptr<const ns3::SpectrumValue> ns3::LrWpanPhy::GetNoisePowerSpectralDensity() [member function]
cls.add_method('GetNoisePowerSpectralDensity',
'ns3::Ptr< ns3::SpectrumValue const >',
[])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::StartRx(ns3::Ptr<ns3::SpectrumSignalParameters> params) [member function]
cls.add_method('StartRx',
'void',
[param('ns3::Ptr< ns3::SpectrumSignalParameters >', 'params')],
is_virtual=True)
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::PdDataRequest(uint32_t const psduLength, ns3::Ptr<ns3::Packet> p) [member function]
cls.add_method('PdDataRequest',
'void',
[param('uint32_t const', 'psduLength'), param('ns3::Ptr< ns3::Packet >', 'p')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::PlmeCcaRequest() [member function]
cls.add_method('PlmeCcaRequest',
'void',
[])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::PlmeEdRequest() [member function]
cls.add_method('PlmeEdRequest',
'void',
[])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::PlmeGetAttributeRequest(ns3::LrWpanPibAttributeIdentifier id) [member function]
cls.add_method('PlmeGetAttributeRequest',
'void',
[param('ns3::LrWpanPibAttributeIdentifier', 'id')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::PlmeSetTRXStateRequest(ns3::LrWpanPhyEnumeration state) [member function]
cls.add_method('PlmeSetTRXStateRequest',
'void',
[param('ns3::LrWpanPhyEnumeration', 'state')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::PlmeSetAttributeRequest(ns3::LrWpanPibAttributeIdentifier id, ns3::LrWpanPhyPibAttributes * attribute) [member function]
cls.add_method('PlmeSetAttributeRequest',
'void',
[param('ns3::LrWpanPibAttributeIdentifier', 'id'), param('ns3::LrWpanPhyPibAttributes *', 'attribute')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetPdDataIndicationCallback(ns3::PdDataIndicationCallback c) [member function]
cls.add_method('SetPdDataIndicationCallback',
'void',
[param('ns3::Callback< void, unsigned int, ns3::Ptr< ns3::Packet >, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetPdDataConfirmCallback(ns3::PdDataConfirmCallback c) [member function]
cls.add_method('SetPdDataConfirmCallback',
'void',
[param('ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetPlmeCcaConfirmCallback(ns3::PlmeCcaConfirmCallback c) [member function]
cls.add_method('SetPlmeCcaConfirmCallback',
'void',
[param('ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetPlmeEdConfirmCallback(ns3::PlmeEdConfirmCallback c) [member function]
cls.add_method('SetPlmeEdConfirmCallback',
'void',
[param('ns3::Callback< void, ns3::LrWpanPhyEnumeration, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetPlmeGetAttributeConfirmCallback(ns3::PlmeGetAttributeConfirmCallback c) [member function]
cls.add_method('SetPlmeGetAttributeConfirmCallback',
'void',
[param('ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::LrWpanPhyPibAttributes *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetPlmeSetTRXStateConfirmCallback(ns3::PlmeSetTRXStateConfirmCallback c) [member function]
cls.add_method('SetPlmeSetTRXStateConfirmCallback',
'void',
[param('ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetPlmeSetAttributeConfirmCallback(ns3::PlmeSetAttributeConfirmCallback c) [member function]
cls.add_method('SetPlmeSetAttributeConfirmCallback',
'void',
[param('ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'c')])
## lr-wpan-phy.h (module 'lr-wpan'): double ns3::LrWpanPhy::GetDataOrSymbolRate(bool isData) [member function]
cls.add_method('GetDataOrSymbolRate',
'double',
[param('bool', 'isData')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::SetErrorModel(ns3::Ptr<ns3::LrWpanErrorModel> e) [member function]
cls.add_method('SetErrorModel',
'void',
[param('ns3::Ptr< ns3::LrWpanErrorModel >', 'e')])
## lr-wpan-phy.h (module 'lr-wpan'): ns3::Ptr<ns3::LrWpanErrorModel> ns3::LrWpanPhy::GetErrorModel() const [member function]
cls.add_method('GetErrorModel',
'ns3::Ptr< ns3::LrWpanErrorModel >',
[],
is_const=True)
## lr-wpan-phy.h (module 'lr-wpan'): uint64_t ns3::LrWpanPhy::GetPhySHRDuration() const [member function]
cls.add_method('GetPhySHRDuration',
'uint64_t',
[],
is_const=True)
## lr-wpan-phy.h (module 'lr-wpan'): double ns3::LrWpanPhy::GetPhySymbolsPerOctet() const [member function]
cls.add_method('GetPhySymbolsPerOctet',
'double',
[],
is_const=True)
## lr-wpan-phy.h (module 'lr-wpan'): int64_t ns3::LrWpanPhy::AssignStreams(int64_t stream) [member function]
cls.add_method('AssignStreams',
'int64_t',
[param('int64_t', 'stream')])
## lr-wpan-phy.h (module 'lr-wpan'): void ns3::LrWpanPhy::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
[],
visibility='private', is_virtual=True)
return
def register_Ns3LrWpanSpectrumSignalParameters_methods(root_module, cls):
## lr-wpan-spectrum-signal-parameters.h (module 'lr-wpan'): ns3::Ptr<ns3::SpectrumSignalParameters> ns3::LrWpanSpectrumSignalParameters::Copy() [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::SpectrumSignalParameters >',
[],
is_virtual=True)
## lr-wpan-spectrum-signal-parameters.h (module 'lr-wpan'): ns3::LrWpanSpectrumSignalParameters::LrWpanSpectrumSignalParameters() [constructor]
cls.add_constructor([])
## lr-wpan-spectrum-signal-parameters.h (module 'lr-wpan'): ns3::LrWpanSpectrumSignalParameters::LrWpanSpectrumSignalParameters(ns3::LrWpanSpectrumSignalParameters const & p) [constructor]
cls.add_constructor([param('ns3::LrWpanSpectrumSignalParameters const &', 'p')])
## lr-wpan-spectrum-signal-parameters.h (module 'lr-wpan'): ns3::LrWpanSpectrumSignalParameters::packetBurst [variable]
cls.add_instance_attribute('packetBurst', 'ns3::Ptr< ns3::PacketBurst >', is_const=False)
return
def register_Ns3Mac16AddressChecker_methods(root_module, cls):
## mac16-address.h (module 'network'): ns3::Mac16AddressChecker::Mac16AddressChecker() [constructor]
cls.add_constructor([])
## mac16-address.h (module 'network'): ns3::Mac16AddressChecker::Mac16AddressChecker(ns3::Mac16AddressChecker const & arg0) [constructor]
cls.add_constructor([param('ns3::Mac16AddressChecker const &', 'arg0')])
return
def register_Ns3Mac16AddressValue_methods(root_module, cls):
## mac16-address.h (module 'network'): ns3::Mac16AddressValue::Mac16AddressValue() [constructor]
cls.add_constructor([])
## mac16-address.h (module 'network'): ns3::Mac16AddressValue::Mac16AddressValue(ns3::Mac16Address const & value) [constructor]
cls.add_constructor([param('ns3::Mac16Address const &', 'value')])
## mac16-address.h (module 'network'): ns3::Mac16AddressValue::Mac16AddressValue(ns3::Mac16AddressValue const & arg0) [constructor]
cls.add_constructor([param('ns3::Mac16AddressValue const &', 'arg0')])
## mac16-address.h (module 'network'): ns3::Ptr<ns3::AttributeValue> ns3::Mac16AddressValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## mac16-address.h (module 'network'): bool ns3::Mac16AddressValue::DeserializeFromString(std::string value, ns3::Ptr<const ns3::AttributeChecker> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## mac16-address.h (module 'network'): ns3::Mac16Address ns3::Mac16AddressValue::Get() const [member function]
cls.add_method('Get',
'ns3::Mac16Address',
[],
is_const=True)
## mac16-address.h (module 'network'): std::string ns3::Mac16AddressValue::SerializeToString(ns3::Ptr<const ns3::AttributeChecker> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## mac16-address.h (module 'network'): void ns3::Mac16AddressValue::Set(ns3::Mac16Address const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Mac16Address 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) [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::Mac48Address const & value) [constructor]
cls.add_constructor([param('ns3::Mac48Address const &', 'value')])
## mac48-address.h (module 'network'): ns3::Mac48AddressValue::Mac48AddressValue(ns3::Mac48AddressValue const & arg0) [constructor]
cls.add_constructor([param('ns3::Mac48AddressValue const &', 'arg0')])
## 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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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_Ns3Mac64AddressChecker_methods(root_module, cls):
## mac64-address.h (module 'network'): ns3::Mac64AddressChecker::Mac64AddressChecker() [constructor]
cls.add_constructor([])
## mac64-address.h (module 'network'): ns3::Mac64AddressChecker::Mac64AddressChecker(ns3::Mac64AddressChecker const & arg0) [constructor]
cls.add_constructor([param('ns3::Mac64AddressChecker const &', 'arg0')])
return
def register_Ns3Mac64AddressValue_methods(root_module, cls):
## mac64-address.h (module 'network'): ns3::Mac64AddressValue::Mac64AddressValue() [constructor]
cls.add_constructor([])
## mac64-address.h (module 'network'): ns3::Mac64AddressValue::Mac64AddressValue(ns3::Mac64Address const & value) [constructor]
cls.add_constructor([param('ns3::Mac64Address const &', 'value')])
## mac64-address.h (module 'network'): ns3::Mac64AddressValue::Mac64AddressValue(ns3::Mac64AddressValue const & arg0) [constructor]
cls.add_constructor([param('ns3::Mac64AddressValue const &', 'arg0')])
## mac64-address.h (module 'network'): ns3::Ptr<ns3::AttributeValue> ns3::Mac64AddressValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## mac64-address.h (module 'network'): bool ns3::Mac64AddressValue::DeserializeFromString(std::string value, ns3::Ptr<const ns3::AttributeChecker> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## mac64-address.h (module 'network'): ns3::Mac64Address ns3::Mac64AddressValue::Get() const [member function]
cls.add_method('Get',
'ns3::Mac64Address',
[],
is_const=True)
## mac64-address.h (module 'network'): std::string ns3::Mac64AddressValue::SerializeToString(ns3::Ptr<const ns3::AttributeChecker> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## mac64-address.h (module 'network'): void ns3::Mac64AddressValue::Set(ns3::Mac64Address const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::Mac64Address const &', 'value')])
return
def register_Ns3NetDevice_methods(root_module, cls):
## net-device.h (module 'network'): ns3::NetDevice::NetDevice() [constructor]
cls.add_constructor([])
## net-device.h (module 'network'): ns3::NetDevice::NetDevice(ns3::NetDevice const & arg0) [constructor]
cls.add_constructor([param('ns3::NetDevice const &', 'arg0')])
## net-device.h (module 'network'): void ns3::NetDevice::AddLinkChangeCallback(ns3::Callback<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> callback) [member function]
cls.add_method('AddLinkChangeCallback',
'void',
[param('ns3::Callback< void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): ns3::Address ns3::NetDevice::GetAddress() const [member function]
cls.add_method('GetAddress',
'ns3::Address',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): ns3::Address ns3::NetDevice::GetBroadcast() const [member function]
cls.add_method('GetBroadcast',
'ns3::Address',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): ns3::Ptr<ns3::Channel> ns3::NetDevice::GetChannel() const [member function]
cls.add_method('GetChannel',
'ns3::Ptr< ns3::Channel >',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): uint32_t ns3::NetDevice::GetIfIndex() const [member function]
cls.add_method('GetIfIndex',
'uint32_t',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): uint16_t ns3::NetDevice::GetMtu() const [member function]
cls.add_method('GetMtu',
'uint16_t',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): ns3::Address ns3::NetDevice::GetMulticast(ns3::Ipv4Address multicastGroup) const [member function]
cls.add_method('GetMulticast',
'ns3::Address',
[param('ns3::Ipv4Address', 'multicastGroup')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): ns3::Address ns3::NetDevice::GetMulticast(ns3::Ipv6Address addr) const [member function]
cls.add_method('GetMulticast',
'ns3::Address',
[param('ns3::Ipv6Address', 'addr')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): ns3::Ptr<ns3::Node> ns3::NetDevice::GetNode() const [member function]
cls.add_method('GetNode',
'ns3::Ptr< ns3::Node >',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): static ns3::TypeId ns3::NetDevice::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## net-device.h (module 'network'): bool ns3::NetDevice::IsBridge() const [member function]
cls.add_method('IsBridge',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::IsBroadcast() const [member function]
cls.add_method('IsBroadcast',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::IsLinkUp() const [member function]
cls.add_method('IsLinkUp',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::IsMulticast() const [member function]
cls.add_method('IsMulticast',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::IsPointToPoint() const [member function]
cls.add_method('IsPointToPoint',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::NeedsArp() const [member function]
cls.add_method('NeedsArp',
'bool',
[],
is_pure_virtual=True, is_const=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::Send(ns3::Ptr<ns3::Packet> packet, ns3::Address const & dest, uint16_t protocolNumber) [member function]
cls.add_method('Send',
'bool',
[param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Address const &', 'dest'), param('uint16_t', 'protocolNumber')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::SendFrom(ns3::Ptr<ns3::Packet> packet, ns3::Address const & source, ns3::Address const & dest, uint16_t protocolNumber) [member function]
cls.add_method('SendFrom',
'bool',
[param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Address const &', 'source'), param('ns3::Address const &', 'dest'), param('uint16_t', 'protocolNumber')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): void ns3::NetDevice::SetAddress(ns3::Address address) [member function]
cls.add_method('SetAddress',
'void',
[param('ns3::Address', 'address')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): void ns3::NetDevice::SetIfIndex(uint32_t const index) [member function]
cls.add_method('SetIfIndex',
'void',
[param('uint32_t const', 'index')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::SetMtu(uint16_t const mtu) [member function]
cls.add_method('SetMtu',
'bool',
[param('uint16_t const', 'mtu')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): void ns3::NetDevice::SetNode(ns3::Ptr<ns3::Node> node) [member function]
cls.add_method('SetNode',
'void',
[param('ns3::Ptr< ns3::Node >', 'node')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): void ns3::NetDevice::SetPromiscReceiveCallback(ns3::NetDevice::PromiscReceiveCallback cb) [member function]
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::Address const &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty >', 'cb')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): void ns3::NetDevice::SetReceiveCallback(ns3::NetDevice::ReceiveCallback cb) [member function]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'cb')],
is_pure_virtual=True, is_virtual=True)
## net-device.h (module 'network'): bool ns3::NetDevice::SupportsSendFrom() const [member function]
cls.add_method('SupportsSendFrom',
'bool',
[],
is_pure_virtual=True, is_const=True, 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) [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_Ns3Node_methods(root_module, cls):
## node.h (module 'network'): ns3::Node::Node(ns3::Node const & arg0) [constructor]
cls.add_constructor([param('ns3::Node const &', 'arg0')])
## node.h (module 'network'): ns3::Node::Node() [constructor]
cls.add_constructor([])
## node.h (module 'network'): ns3::Node::Node(uint32_t systemId) [constructor]
cls.add_constructor([param('uint32_t', 'systemId')])
## node.h (module 'network'): uint32_t ns3::Node::AddApplication(ns3::Ptr<ns3::Application> application) [member function]
cls.add_method('AddApplication',
'uint32_t',
[param('ns3::Ptr< ns3::Application >', 'application')])
## node.h (module 'network'): uint32_t ns3::Node::AddDevice(ns3::Ptr<ns3::NetDevice> device) [member function]
cls.add_method('AddDevice',
'uint32_t',
[param('ns3::Ptr< ns3::NetDevice >', 'device')])
## node.h (module 'network'): static bool ns3::Node::ChecksumEnabled() [member function]
cls.add_method('ChecksumEnabled',
'bool',
[],
is_static=True)
## node.h (module 'network'): ns3::Ptr<ns3::Application> ns3::Node::GetApplication(uint32_t index) const [member function]
cls.add_method('GetApplication',
'ns3::Ptr< ns3::Application >',
[param('uint32_t', 'index')],
is_const=True)
## node.h (module 'network'): ns3::Ptr<ns3::NetDevice> ns3::Node::GetDevice(uint32_t index) const [member function]
cls.add_method('GetDevice',
'ns3::Ptr< ns3::NetDevice >',
[param('uint32_t', 'index')],
is_const=True)
## node.h (module 'network'): uint32_t ns3::Node::GetId() const [member function]
cls.add_method('GetId',
'uint32_t',
[],
is_const=True)
## node.h (module 'network'): ns3::Time ns3::Node::GetLocalTime() const [member function]
cls.add_method('GetLocalTime',
'ns3::Time',
[],
is_const=True)
## node.h (module 'network'): uint32_t ns3::Node::GetNApplications() const [member function]
cls.add_method('GetNApplications',
'uint32_t',
[],
is_const=True)
## node.h (module 'network'): uint32_t ns3::Node::GetNDevices() const [member function]
cls.add_method('GetNDevices',
'uint32_t',
[],
is_const=True)
## node.h (module 'network'): uint32_t ns3::Node::GetSystemId() const [member function]
cls.add_method('GetSystemId',
'uint32_t',
[],
is_const=True)
## node.h (module 'network'): static ns3::TypeId ns3::Node::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## node.h (module 'network'): void ns3::Node::RegisterDeviceAdditionListener(ns3::Node::DeviceAdditionListener listener) [member function]
cls.add_method('RegisterDeviceAdditionListener',
'void',
[param('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'listener')])
## node.h (module 'network'): void ns3::Node::RegisterProtocolHandler(ns3::Node::ProtocolHandler handler, uint16_t protocolType, ns3::Ptr<ns3::NetDevice> device, bool promiscuous=false) [member function]
cls.add_method('RegisterProtocolHandler',
'void',
[param('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::Address const &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty >', 'handler'), param('uint16_t', 'protocolType'), param('ns3::Ptr< ns3::NetDevice >', 'device'), param('bool', 'promiscuous', default_value='false')])
## node.h (module 'network'): void ns3::Node::UnregisterDeviceAdditionListener(ns3::Node::DeviceAdditionListener listener) [member function]
cls.add_method('UnregisterDeviceAdditionListener',
'void',
[param('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'listener')])
## node.h (module 'network'): void ns3::Node::UnregisterProtocolHandler(ns3::Node::ProtocolHandler handler) [member function]
cls.add_method('UnregisterProtocolHandler',
'void',
[param('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::Address const &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty >', 'handler')])
## node.h (module 'network'): void ns3::Node::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
[],
visibility='protected', is_virtual=True)
## node.h (module 'network'): void ns3::Node::DoInitialize() [member function]
cls.add_method('DoInitialize',
'void',
[],
visibility='protected', is_virtual=True)
return
def register_Ns3ObjectFactoryChecker_methods(root_module, cls):
## object-factory.h (module 'core'): ns3::ObjectFactoryChecker::ObjectFactoryChecker() [constructor]
cls.add_constructor([])
## object-factory.h (module 'core'): ns3::ObjectFactoryChecker::ObjectFactoryChecker(ns3::ObjectFactoryChecker const & arg0) [constructor]
cls.add_constructor([param('ns3::ObjectFactoryChecker const &', 'arg0')])
return
def register_Ns3ObjectFactoryValue_methods(root_module, cls):
## object-factory.h (module 'core'): ns3::ObjectFactoryValue::ObjectFactoryValue() [constructor]
cls.add_constructor([])
## object-factory.h (module 'core'): ns3::ObjectFactoryValue::ObjectFactoryValue(ns3::ObjectFactory const & value) [constructor]
cls.add_constructor([param('ns3::ObjectFactory const &', 'value')])
## object-factory.h (module 'core'): ns3::ObjectFactoryValue::ObjectFactoryValue(ns3::ObjectFactoryValue const & arg0) [constructor]
cls.add_constructor([param('ns3::ObjectFactoryValue const &', 'arg0')])
## object-factory.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::ObjectFactoryValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## object-factory.h (module 'core'): bool ns3::ObjectFactoryValue::DeserializeFromString(std::string value, ns3::Ptr<const ns3::AttributeChecker> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## object-factory.h (module 'core'): ns3::ObjectFactory ns3::ObjectFactoryValue::Get() const [member function]
cls.add_method('Get',
'ns3::ObjectFactory',
[],
is_const=True)
## object-factory.h (module 'core'): std::string ns3::ObjectFactoryValue::SerializeToString(ns3::Ptr<const ns3::AttributeChecker> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## object-factory.h (module 'core'): void ns3::ObjectFactoryValue::Set(ns3::ObjectFactory const & value) [member function]
cls.add_method('Set',
'void',
[param('ns3::ObjectFactory const &', 'value')])
return
def register_Ns3OutputStreamWrapper_methods(root_module, cls):
## output-stream-wrapper.h (module 'network'): ns3::OutputStreamWrapper::OutputStreamWrapper(ns3::OutputStreamWrapper const & arg0) [constructor]
cls.add_constructor([param('ns3::OutputStreamWrapper const &', 'arg0')])
## output-stream-wrapper.h (module 'network'): ns3::OutputStreamWrapper::OutputStreamWrapper(std::string filename, std::ios_base::openmode filemode) [constructor]
cls.add_constructor([param('std::string', 'filename'), param('std::ios_base::openmode', 'filemode')])
## output-stream-wrapper.h (module 'network'): ns3::OutputStreamWrapper::OutputStreamWrapper(std::ostream * os) [constructor]
cls.add_constructor([param('std::ostream *', 'os')])
## output-stream-wrapper.h (module 'network'): std::ostream * ns3::OutputStreamWrapper::GetStream() [member function]
cls.add_method('GetStream',
'std::ostream *',
[])
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) [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::Time const & value) [constructor]
cls.add_constructor([param('ns3::Time const &', 'value')])
## nstime.h (module 'core'): ns3::TimeValue::TimeValue(ns3::TimeValue const & arg0) [constructor]
cls.add_constructor([param('ns3::TimeValue const &', 'arg0')])
## 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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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) [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::TypeId const & value) [constructor]
cls.add_constructor([param('ns3::TypeId const &', 'value')])
## type-id.h (module 'core'): ns3::TypeIdValue::TypeIdValue(ns3::TypeIdValue const & arg0) [constructor]
cls.add_constructor([param('ns3::TypeIdValue const &', 'arg0')])
## 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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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_Ns3UintegerValue_methods(root_module, cls):
## uinteger.h (module 'core'): ns3::UintegerValue::UintegerValue() [constructor]
cls.add_constructor([])
## uinteger.h (module 'core'): ns3::UintegerValue::UintegerValue(uint64_t const & value) [constructor]
cls.add_constructor([param('uint64_t const &', 'value')])
## uinteger.h (module 'core'): ns3::UintegerValue::UintegerValue(ns3::UintegerValue const & arg0) [constructor]
cls.add_constructor([param('ns3::UintegerValue const &', 'arg0')])
## uinteger.h (module 'core'): ns3::Ptr<ns3::AttributeValue> ns3::UintegerValue::Copy() const [member function]
cls.add_method('Copy',
'ns3::Ptr< ns3::AttributeValue >',
[],
is_const=True, is_virtual=True)
## uinteger.h (module 'core'): bool ns3::UintegerValue::DeserializeFromString(std::string value, ns3::Ptr<const ns3::AttributeChecker> checker) [member function]
cls.add_method('DeserializeFromString',
'bool',
[param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_virtual=True)
## uinteger.h (module 'core'): uint64_t ns3::UintegerValue::Get() const [member function]
cls.add_method('Get',
'uint64_t',
[],
is_const=True)
## uinteger.h (module 'core'): std::string ns3::UintegerValue::SerializeToString(ns3::Ptr<const ns3::AttributeChecker> checker) const [member function]
cls.add_method('SerializeToString',
'std::string',
[param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')],
is_const=True, is_virtual=True)
## uinteger.h (module 'core'): void ns3::UintegerValue::Set(uint64_t const & value) [member function]
cls.add_method('Set',
'void',
[param('uint64_t 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) [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::Address const & value) [constructor]
cls.add_constructor([param('ns3::Address const &', 'value')])
## address.h (module 'network'): ns3::AddressValue::AddressValue(ns3::AddressValue const & arg0) [constructor]
cls.add_constructor([param('ns3::AddressValue const &', 'arg0')])
## 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<const ns3::AttributeChecker> 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<const ns3::AttributeChecker> 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_Ns3CallbackImpl__Bool_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): bool ns3::CallbackImpl<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::Ptr<ns3::NetDevice> arg0, ns3::Ptr<const ns3::Packet> arg1, short unsigned int arg2, ns3::Address const & arg3) [member operator]
cls.add_method('operator()',
'bool',
[param('ns3::Ptr< ns3::NetDevice >', 'arg0'), param('ns3::Ptr< ns3::Packet const >', 'arg1'), param('short unsigned int', 'arg2'), param('ns3::Address const &', 'arg3')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Ns3ObjectBase___star___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): ns3::ObjectBase * ns3::CallbackImpl<ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()() [member operator]
cls.add_method('operator()',
'ns3::ObjectBase *',
[],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3LrWpanMacState_Ns3LrWpanMacState_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::LrWpanMacState arg0, ns3::LrWpanMacState arg1) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::LrWpanMacState', 'arg0'), param('ns3::LrWpanMacState', 'arg1')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::LrWpanPhyEnumeration arg0, ns3::LrWpanPhyEnumeration arg1) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::LrWpanPhyEnumeration', 'arg0'), param('ns3::LrWpanPhyEnumeration', 'arg1')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::McpsDataConfirmParams arg0) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::McpsDataConfirmParams', 'arg0')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::McpsDataIndicationParams, ns3::Ptr< ns3::Packet >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::McpsDataIndicationParams arg0, ns3::Ptr<ns3::Packet> arg1) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::McpsDataIndicationParams', 'arg0'), param('ns3::Ptr< ns3::Packet >', 'arg1')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Double_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::Ptr< ns3::Packet const >, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::Ptr<const ns3::Packet> arg0, double arg1) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::Ptr< ns3::Packet const >', 'arg0'), param('double', 'arg1')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::Ptr< ns3::Packet const >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::Ptr<const ns3::Packet> arg0) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::Ptr< ns3::Packet const >', 'arg0')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_char_Unsigned_char_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::Ptr< ns3::Packet const >, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::Ptr<const ns3::Packet> arg0, unsigned char arg1, unsigned char arg2) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::Ptr< ns3::Packet const >', 'arg0'), param('unsigned char', 'arg1'), param('unsigned char', 'arg2')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Const_ns3Address___amp___Ns3NetDevicePacketType_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::Address const &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::Ptr<ns3::NetDevice> arg0, ns3::Ptr<const ns3::Packet> arg1, short unsigned int arg2, ns3::Address const & arg3, ns3::Address const & arg4, ns3::NetDevice::PacketType arg5) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::Ptr< ns3::NetDevice >', 'arg0'), param('ns3::Ptr< ns3::Packet const >', 'arg1'), param('short unsigned int', 'arg2'), param('ns3::Address const &', 'arg3'), param('ns3::Address const &', 'arg4'), param('ns3::NetDevice::PacketType', 'arg5')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::Ptr< ns3::NetDevice >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::Ptr<ns3::NetDevice> arg0) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::Ptr< ns3::NetDevice >', 'arg0')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3Time_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()(ns3::Time arg0, ns3::LrWpanPhyEnumeration arg1, ns3::LrWpanPhyEnumeration arg2) [member operator]
cls.add_method('operator()',
'void',
[param('ns3::Time', 'arg0'), param('ns3::LrWpanPhyEnumeration', 'arg1'), param('ns3::LrWpanPhyEnumeration', 'arg2')],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3CallbackImpl__Void_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods(root_module, cls):
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl() [constructor]
cls.add_constructor([])
## callback.h (module 'core'): ns3::CallbackImpl<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::CallbackImpl(ns3::CallbackImpl<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> const & arg0) [constructor]
cls.add_constructor([param('ns3::CallbackImpl< void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > const &', 'arg0')])
## callback.h (module 'core'): static std::string ns3::CallbackImpl<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::DoGetTypeid() [member function]
cls.add_method('DoGetTypeid',
'std::string',
[],
is_static=True)
## callback.h (module 'core'): std::string ns3::CallbackImpl<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::GetTypeid() const [member function]
cls.add_method('GetTypeid',
'std::string',
[],
is_const=True, is_virtual=True)
## callback.h (module 'core'): void ns3::CallbackImpl<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator()() [member operator]
cls.add_method('operator()',
'void',
[],
is_pure_virtual=True, is_virtual=True, custom_name=u'__call__')
return
def register_Ns3LrWpanNetDevice_methods(root_module, cls):
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::LrWpanNetDevice::LrWpanNetDevice(ns3::LrWpanNetDevice const & arg0) [constructor]
cls.add_constructor([param('ns3::LrWpanNetDevice const &', 'arg0')])
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::LrWpanNetDevice::LrWpanNetDevice() [constructor]
cls.add_constructor([])
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::AddLinkChangeCallback(ns3::Callback<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> callback) [member function]
cls.add_method('AddLinkChangeCallback',
'void',
[param('ns3::Callback< void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): int64_t ns3::LrWpanNetDevice::AssignStreams(int64_t stream) [member function]
cls.add_method('AssignStreams',
'int64_t',
[param('int64_t', 'stream')])
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Address ns3::LrWpanNetDevice::GetAddress() const [member function]
cls.add_method('GetAddress',
'ns3::Address',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Address ns3::LrWpanNetDevice::GetBroadcast() const [member function]
cls.add_method('GetBroadcast',
'ns3::Address',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Ptr<ns3::Channel> ns3::LrWpanNetDevice::GetChannel() const [member function]
cls.add_method('GetChannel',
'ns3::Ptr< ns3::Channel >',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Ptr<ns3::LrWpanCsmaCa> ns3::LrWpanNetDevice::GetCsmaCa() const [member function]
cls.add_method('GetCsmaCa',
'ns3::Ptr< ns3::LrWpanCsmaCa >',
[],
is_const=True)
## lr-wpan-net-device.h (module 'lr-wpan'): uint32_t ns3::LrWpanNetDevice::GetIfIndex() const [member function]
cls.add_method('GetIfIndex',
'uint32_t',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Ptr<ns3::LrWpanMac> ns3::LrWpanNetDevice::GetMac() const [member function]
cls.add_method('GetMac',
'ns3::Ptr< ns3::LrWpanMac >',
[],
is_const=True)
## lr-wpan-net-device.h (module 'lr-wpan'): uint16_t ns3::LrWpanNetDevice::GetMtu() const [member function]
cls.add_method('GetMtu',
'uint16_t',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Address ns3::LrWpanNetDevice::GetMulticast(ns3::Ipv4Address multicastGroup) const [member function]
cls.add_method('GetMulticast',
'ns3::Address',
[param('ns3::Ipv4Address', 'multicastGroup')],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Address ns3::LrWpanNetDevice::GetMulticast(ns3::Ipv6Address addr) const [member function]
cls.add_method('GetMulticast',
'ns3::Address',
[param('ns3::Ipv6Address', 'addr')],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Ptr<ns3::Node> ns3::LrWpanNetDevice::GetNode() const [member function]
cls.add_method('GetNode',
'ns3::Ptr< ns3::Node >',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): ns3::Ptr<ns3::LrWpanPhy> ns3::LrWpanNetDevice::GetPhy() const [member function]
cls.add_method('GetPhy',
'ns3::Ptr< ns3::LrWpanPhy >',
[],
is_const=True)
## lr-wpan-net-device.h (module 'lr-wpan'): static ns3::TypeId ns3::LrWpanNetDevice::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::IsBridge() const [member function]
cls.add_method('IsBridge',
'bool',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::IsBroadcast() const [member function]
cls.add_method('IsBroadcast',
'bool',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::IsLinkUp() const [member function]
cls.add_method('IsLinkUp',
'bool',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::IsMulticast() const [member function]
cls.add_method('IsMulticast',
'bool',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::IsPointToPoint() const [member function]
cls.add_method('IsPointToPoint',
'bool',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::McpsDataIndication(ns3::McpsDataIndicationParams params, ns3::Ptr<ns3::Packet> pkt) [member function]
cls.add_method('McpsDataIndication',
'void',
[param('ns3::McpsDataIndicationParams', 'params'), param('ns3::Ptr< ns3::Packet >', 'pkt')])
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::NeedsArp() const [member function]
cls.add_method('NeedsArp',
'bool',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::Send(ns3::Ptr<ns3::Packet> packet, ns3::Address const & dest, uint16_t protocolNumber) [member function]
cls.add_method('Send',
'bool',
[param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Address const &', 'dest'), param('uint16_t', 'protocolNumber')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::SendFrom(ns3::Ptr<ns3::Packet> packet, ns3::Address const & source, ns3::Address const & dest, uint16_t protocolNumber) [member function]
cls.add_method('SendFrom',
'bool',
[param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Address const &', 'source'), param('ns3::Address const &', 'dest'), param('uint16_t', 'protocolNumber')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetAddress(ns3::Address address) [member function]
cls.add_method('SetAddress',
'void',
[param('ns3::Address', 'address')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetChannel(ns3::Ptr<ns3::SpectrumChannel> channel) [member function]
cls.add_method('SetChannel',
'void',
[param('ns3::Ptr< ns3::SpectrumChannel >', 'channel')])
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetCsmaCa(ns3::Ptr<ns3::LrWpanCsmaCa> csmaca) [member function]
cls.add_method('SetCsmaCa',
'void',
[param('ns3::Ptr< ns3::LrWpanCsmaCa >', 'csmaca')])
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetIfIndex(uint32_t const index) [member function]
cls.add_method('SetIfIndex',
'void',
[param('uint32_t const', 'index')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetMac(ns3::Ptr<ns3::LrWpanMac> mac) [member function]
cls.add_method('SetMac',
'void',
[param('ns3::Ptr< ns3::LrWpanMac >', 'mac')])
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::SetMtu(uint16_t const mtu) [member function]
cls.add_method('SetMtu',
'bool',
[param('uint16_t const', 'mtu')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetNode(ns3::Ptr<ns3::Node> node) [member function]
cls.add_method('SetNode',
'void',
[param('ns3::Ptr< ns3::Node >', 'node')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetPhy(ns3::Ptr<ns3::LrWpanPhy> phy) [member function]
cls.add_method('SetPhy',
'void',
[param('ns3::Ptr< ns3::LrWpanPhy >', 'phy')])
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetPromiscReceiveCallback(ns3::NetDevice::PromiscReceiveCallback cb) [member function]
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::Address const &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::SetReceiveCallback(ns3::NetDevice::ReceiveCallback cb) [member function]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): bool ns3::LrWpanNetDevice::SupportsSendFrom() const [member function]
cls.add_method('SupportsSendFrom',
'bool',
[],
is_const=True, is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
[],
visibility='private', is_virtual=True)
## lr-wpan-net-device.h (module 'lr-wpan'): void ns3::LrWpanNetDevice::DoInitialize() [member function]
cls.add_method('DoInitialize',
'void',
[],
visibility='private', is_virtual=True)
return
def register_Ns3HashImplementation_methods(root_module, cls):
## hash-function.h (module 'core'): ns3::Hash::Implementation::Implementation(ns3::Hash::Implementation const & arg0) [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) [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) [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) [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) [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)
register_functions_ns3_internal(module.get_submodule('internal'), 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 register_functions_ns3_internal(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,
7493,
63,
87,
10384,
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,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
8052,
2602,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
8052,
2602,
297,
788,
10051,
63,
13352,
63,
9185,
297,
283,
10051,
63,
13352,
63,
3099,
297,
283,
10051,
63,
13352,
63,
8391,
51,
297,
283,
10051,
63,
13352,
63,
568,
6098,
1105,
272,
925,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
3399,
2223,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
3399,
2223,
297,
788,
9410,
63,
23715,
297,
283,
9410,
63,
3298,
2054,
297,
283,
9410,
63,
51,
15219,
297,
283,
9410,
63,
3099,
63,
21243,
297,
283,
14833,
63,
11074,
63,
13989,
297,
283,
14833,
63,
23715,
297,
283,
3597,
63,
9791,
57,
63,
10051,
63,
615,
1105,
272,
925,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
1476,
1385,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
1476,
1385,
297,
788,
2826,
63,
26685,
998,
63,
7803,
297,
283,
7803,
63,
6963,
63,
26933,
297,
283,
13003,
63,
7803,
297,
283,
2472,
63,
7803,
1105,
272,
925,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
18662,
3694,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
18662,
3694,
297,
788,
3755,
47,
3553,
6989,
297,
283,
26685,
63,
619,
63,
8549,
1348,
1922,
297,
283,
26685,
63,
11074,
63,
23282,
29848,
297,
283,
3755,
47,
3553,
6989,
63,
29946,
63,
12368,
297,
283,
6178,
3755,
47,
3553,
6989,
1105,
272,
925,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
45,
67,
1190,
1451,
26857,
3694,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
45,
67,
1190,
1451,
26857,
3694,
297,
788,
32692,
63,
11366,
63,
1046,
63,
20,
63,
12779,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
12191,
10052,
63,
14336,
17114,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
12191,
10052,
63,
25632,
7387,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
14833,
63,
11074,
63,
13989,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9692,
63,
12368,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9692,
63,
8391,
51,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
2826,
63,
3099,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
23049,
63,
3170,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
12683,
63,
30947,
63,
12375,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
1734,
17377,
63,
3078,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
1734,
15925,
63,
13554,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9692,
63,
14472,
1105,
272,
925,
13645,
13,
87,
10384,
13,
6581,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
6678,
2602,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
6678,
2602,
297,
788,
32692,
63,
11366,
63,
1046,
63,
20,
63,
15430,
45,
25955,
63,
34,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
32532,
45,
25955,
63,
34,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
15430,
45,
25955,
63,
7946,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
32532,
45,
25955,
63,
7946,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
15430,
45,
25955,
63,
47,
49,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
32532,
45,
25955,
63,
47,
49,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
18,
63,
20,
39,
25955,
63,
47,
49,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9692,
63,
9791,
57,
63,
13352,
1105,
272,
925,
13645,
13,
87,
10384,
13,
6581,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
6678,
13425,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
6678,
13425,
297,
788,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
24753,
57,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
24753,
57,
63,
15361,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
24753,
57,
63,
10051,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
27240,
63,
1766,
56,
63,
7517,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
23715,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
9692,
63,
14472,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
15361,
63,
615,
297,
283,
32692,
63,
11366
] |
[
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,
7493,
63,
87,
10384,
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,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
8052,
2602,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
8052,
2602,
297,
788,
10051,
63,
13352,
63,
9185,
297,
283,
10051,
63,
13352,
63,
3099,
297,
283,
10051,
63,
13352,
63,
8391,
51,
297,
283,
10051,
63,
13352,
63,
568,
6098,
1105,
272,
925,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
3399,
2223,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
3399,
2223,
297,
788,
9410,
63,
23715,
297,
283,
9410,
63,
3298,
2054,
297,
283,
9410,
63,
51,
15219,
297,
283,
9410,
63,
3099,
63,
21243,
297,
283,
14833,
63,
11074,
63,
13989,
297,
283,
14833,
63,
23715,
297,
283,
3597,
63,
9791,
57,
63,
10051,
63,
615,
1105,
272,
925,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
1476,
1385,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
1476,
1385,
297,
788,
2826,
63,
26685,
998,
63,
7803,
297,
283,
7803,
63,
6963,
63,
26933,
297,
283,
13003,
63,
7803,
297,
283,
2472,
63,
7803,
1105,
272,
925,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
18662,
3694,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
18662,
3694,
297,
788,
3755,
47,
3553,
6989,
297,
283,
26685,
63,
619,
63,
8549,
1348,
1922,
297,
283,
26685,
63,
11074,
63,
23282,
29848,
297,
283,
3755,
47,
3553,
6989,
63,
29946,
63,
12368,
297,
283,
6178,
3755,
47,
3553,
6989,
1105,
272,
925,
13645,
13,
87,
10384,
13,
3088,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
45,
67,
1190,
1451,
26857,
3694,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
45,
67,
1190,
1451,
26857,
3694,
297,
788,
32692,
63,
11366,
63,
1046,
63,
20,
63,
12779,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
12191,
10052,
63,
14336,
17114,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
12191,
10052,
63,
25632,
7387,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
14833,
63,
11074,
63,
13989,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9692,
63,
12368,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9692,
63,
8391,
51,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
2826,
63,
3099,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
23049,
63,
3170,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
12683,
63,
30947,
63,
12375,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
1734,
17377,
63,
3078,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
1734,
15925,
63,
13554,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9692,
63,
14472,
1105,
272,
925,
13645,
13,
87,
10384,
13,
6581,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
6678,
2602,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
6678,
2602,
297,
788,
32692,
63,
11366,
63,
1046,
63,
20,
63,
15430,
45,
25955,
63,
34,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
32532,
45,
25955,
63,
34,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
15430,
45,
25955,
63,
7946,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
32532,
45,
25955,
63,
7946,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
15430,
45,
25955,
63,
47,
49,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
32532,
45,
25955,
63,
47,
49,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
18,
63,
20,
39,
25955,
63,
47,
49,
5067,
43,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9692,
63,
9791,
57,
63,
13352,
1105,
272,
925,
13645,
13,
87,
10384,
13,
6581,
14,
72,
334,
578,
283,
7493,
13,
87,
10384,
735,
700,
19,
447,
44,
82,
55,
10384,
6678,
13425,
359,
14130,
61,
272,
859,
14,
525,
63,
4869,
360,
44,
82,
55,
10384,
6678,
13425,
297,
788,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
24753,
57,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
24753,
57,
63,
15361,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
24753,
57,
63,
10051,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
27240,
63,
1766,
56,
63,
7517,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
23715,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
9692,
63,
14472,
297,
283,
32692,
63,
11366,
63,
1046,
63,
20,
63,
9791,
57,
63,
15361,
63,
615,
297,
283,
32692,
63,
11366,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
rackerlabs/rackspace-sdk-plugin
|
rackspace/tests/unit/monitoring/v1/test_notification_plan.py
|
2
|
2212
|
# 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 testtools
from rackspace.monitoring.v1 import notification_plan
EXAMPLE = {
"id": "np2JTlcpCs",
"label": "Notification Plan 1",
"critical_state": [],
"warning_state": [],
"ok_state": [],
"active_suppressions": [],
"scheduled_suppressions": [],
"created_at": 1405916469945,
"updated_at": 1405916469945,
"metadata": {}
}
class TestNotificationPlan(testtools.TestCase):
def test_basic(self):
sot = notification_plan.NotificationPlan()
self.assertEqual('values', sot.resources_key)
self.assertEqual('notification_plans', sot.base_path)
self.assertEqual("cloudMonitoring", sot.service.service_name)
self.assertTrue(sot.allow_create)
self.assertTrue(sot.allow_delete)
self.assertTrue(sot.allow_list)
self.assertTrue(sot.allow_retrieve)
self.assertTrue(sot.allow_update)
def test_make_it(self):
sot = notification_plan.NotificationPlan(EXAMPLE)
self.assertEqual(EXAMPLE['active_suppressions'],
sot.active_suppressions)
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
self.assertEqual(EXAMPLE['label'], sot.name)
self.assertEqual(EXAMPLE['metadata'], sot.metadata)
self.assertEqual(EXAMPLE['critical_state'], sot.recipients_on_critical)
self.assertEqual(EXAMPLE['ok_state'], sot.recipients_on_ok)
self.assertEqual(EXAMPLE['warning_state'], sot.recipients_on_warning)
self.assertEqual(EXAMPLE['scheduled_suppressions'],
sot.scheduled_suppressions)
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
apache-2.0
|
[
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
646,
30741,
199,
199,
504,
660,
346,
2638,
14,
20554,
14,
86,
17,
492,
6955,
63,
5140,
421,
199,
26900,
275,
469,
272,
298,
344,
582,
298,
1590,
18,
42,
52,
76,
1850,
13912,
401,
272,
298,
1302,
582,
298,
11598,
32427,
413,
401,
272,
298,
13138,
63,
929,
582,
990,
272,
298,
3764,
63,
929,
582,
990,
272,
298,
745,
63,
929,
582,
990,
272,
298,
2682,
63,
8621,
6274,
582,
990,
272,
298,
19274,
63,
8621,
6274,
582,
990,
272,
298,
3966,
63,
292,
582,
22796,
1427,
8982,
30688,
2322,
12,
272,
298,
5334,
63,
292,
582,
22796,
1427,
8982,
30688,
2322,
12,
272,
298,
2343,
582,
1052,
199,
93,
421,
199,
533,
1379,
11598,
13375,
8,
396,
2537,
14,
1746,
304,
272,
347,
511,
63,
4316,
8,
277,
304,
267,
308,
357,
275,
6955,
63,
5140,
14,
11598,
13375,
342,
267,
291,
14,
629,
360,
1459,
297,
308,
357,
14,
4435,
63,
498,
9,
267,
291,
14,
629,
360,
6761,
63,
1168,
796,
297,
308,
357,
14,
1095,
63,
515,
9,
267,
291,
14,
629,
480,
4091,
13189,
316,
401,
308,
357,
14,
1364,
14,
1364,
63,
354,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
981,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
1807,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
513,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
14270,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
873,
9,
339,
347,
511,
63,
1875,
63,
390,
8,
277,
304,
267,
308,
357,
275,
6955,
63,
5140,
14,
11598,
13375,
8,
26900,
9,
267,
291,
14,
629,
8,
26900,
459,
2682,
63,
8621,
6274,
995,
586,
308,
357,
14,
2682,
63,
8621,
6274,
9,
267,
291,
14,
629,
8,
26900,
459,
3966,
63,
292,
995,
308,
357,
14,
3966,
63,
292,
9,
267,
291,
14,
629,
8,
26900,
459,
1302,
995,
308,
357,
14,
354,
9,
267,
291,
14,
629,
8,
26900,
459,
2343,
995,
308,
357,
14,
2343,
9,
267,
291,
14,
629,
8,
26900,
459,
13138,
63,
929,
995,
308,
357,
14,
18323,
63,
265,
63,
13138,
9,
267,
291,
14,
629,
8,
26900,
459,
745,
63,
929,
995,
308,
357,
14,
18323,
63,
265,
63,
745,
9,
267,
291,
14,
629,
8,
26900,
459,
3764,
63,
929,
995,
308,
357,
14,
18323,
63,
265,
63,
3764,
9,
267,
291,
14,
629,
8,
26900,
459,
19274,
63,
8621,
6274,
995,
586,
308,
357,
14,
19274,
63,
8621,
6274,
9,
267,
291,
14,
629,
8,
26900,
459,
5334,
63,
292,
995,
308,
357,
14,
5334,
63,
292,
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
] |
[
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
646,
30741,
199,
199,
504,
660,
346,
2638,
14,
20554,
14,
86,
17,
492,
6955,
63,
5140,
421,
199,
26900,
275,
469,
272,
298,
344,
582,
298,
1590,
18,
42,
52,
76,
1850,
13912,
401,
272,
298,
1302,
582,
298,
11598,
32427,
413,
401,
272,
298,
13138,
63,
929,
582,
990,
272,
298,
3764,
63,
929,
582,
990,
272,
298,
745,
63,
929,
582,
990,
272,
298,
2682,
63,
8621,
6274,
582,
990,
272,
298,
19274,
63,
8621,
6274,
582,
990,
272,
298,
3966,
63,
292,
582,
22796,
1427,
8982,
30688,
2322,
12,
272,
298,
5334,
63,
292,
582,
22796,
1427,
8982,
30688,
2322,
12,
272,
298,
2343,
582,
1052,
199,
93,
421,
199,
533,
1379,
11598,
13375,
8,
396,
2537,
14,
1746,
304,
272,
347,
511,
63,
4316,
8,
277,
304,
267,
308,
357,
275,
6955,
63,
5140,
14,
11598,
13375,
342,
267,
291,
14,
629,
360,
1459,
297,
308,
357,
14,
4435,
63,
498,
9,
267,
291,
14,
629,
360,
6761,
63,
1168,
796,
297,
308,
357,
14,
1095,
63,
515,
9,
267,
291,
14,
629,
480,
4091,
13189,
316,
401,
308,
357,
14,
1364,
14,
1364,
63,
354,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
981,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
1807,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
513,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
14270,
9,
267,
291,
14,
1815,
8,
83,
357,
14,
3306,
63,
873,
9,
339,
347,
511,
63,
1875,
63,
390,
8,
277,
304,
267,
308,
357,
275,
6955,
63,
5140,
14,
11598,
13375,
8,
26900,
9,
267,
291,
14,
629,
8,
26900,
459,
2682,
63,
8621,
6274,
995,
586,
308,
357,
14,
2682,
63,
8621,
6274,
9,
267,
291,
14,
629,
8,
26900,
459,
3966,
63,
292,
995,
308,
357,
14,
3966,
63,
292,
9,
267,
291,
14,
629,
8,
26900,
459,
1302,
995,
308,
357,
14,
354,
9,
267,
291,
14,
629,
8,
26900,
459,
2343,
995,
308,
357,
14,
2343,
9,
267,
291,
14,
629,
8,
26900,
459,
13138,
63,
929,
995,
308,
357,
14,
18323,
63,
265,
63,
13138,
9,
267,
291,
14,
629,
8,
26900,
459,
745,
63,
929,
995,
308,
357,
14,
18323,
63,
265,
63,
745,
9,
267,
291,
14,
629,
8,
26900,
459,
3764,
63,
929,
995,
308,
357,
14,
18323,
63,
265,
63,
3764,
9,
267,
291,
14,
629,
8,
26900,
459,
19274,
63,
8621,
6274,
995,
586,
308,
357,
14,
19274,
63,
8621,
6274,
9,
267,
291,
14,
629,
8,
26900,
459,
5334,
63,
292,
995,
308,
357,
14,
5334,
63,
292,
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,
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
0,
0
] |
ViennaRNA/forgi
|
test/forgi/threedee/model/coarse_grain_test.py
|
1
|
34193
|
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
from builtins import range
import warnings
import unittest
import sys
import itertools as it
import copy
import time
import math
import logging
import os.path
import os
import shutil
import contextlib
try:
from unittest.mock import patch
except ImportError:
from mock import patch
import numpy as np
import numpy.testing as nptest
import forgi.threedee.model.coarse_grain as ftmc
import forgi.graph.bulge_graph as fgb
import forgi.threedee.model.similarity as ftme
import forgi.threedee.utilities.graph_pdb as ftug
import forgi.threedee.utilities.vector as ftuv
import forgi.utilities.debug as fud
from forgi.utilities.stuff import make_temp_directory
from ...graph import bulge_graph_test as tfgb
log = logging.getLogger(__name__)
@contextlib.contextmanager
def ignore_warnings():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
yield None
def cg_from_sg(cg, sg):
'''
Create a coarse-grain structure from a subgraph.
@param cg: The original structure
@param sg: The list of elements that are in the subgraph
'''
new_cg = ftmc.cg_from_sg(cg, sg)
return new_cg
for d in sg:
new_cg.defines[d] = cg.defines[d]
if d in cg.coords.keys():
new_cg.coords[d] = cg.coords[d]
if d in cg.twists.keys():
new_cg.twists[d] = cg.twists[d]
if d in cg.longrange.keys():
new_cg.longrange[d] = cg.longrange[d]
for x in cg.edges[d]:
if x in new_cg.defines.keys():
new_cg.edges[d].add(x)
new_cg.edges[x].add(d)
return new_cg
def mock_run_mc_annotate(original_function):
"""
Caching of MC-Annotate output for speedup
"""
def mocked_run_mc_annotate(filename, subprocess_kwargs):
new_fn = os.path.split(filename)[1]
new_fn += ".mcAnnotate.out"
try:
with open(os.path.join("test", "forgi", "threedee", "data", new_fn)) as f:
lines = f.readlines()
log.error("Using cached MC-Annotate output")
except IOError: # on py3 this is an alias of oserror
lines = original_function(filename, subprocess_kwargs)
with open(os.path.join("test", "forgi", "threedee", "data", new_fn), "w") as f:
print("\n".join(lines), file=f)
log.info("Returning lines: %s", lines)
return lines
return mocked_run_mc_annotate
def mocked_read_config():
"""
Require MC-Annotate for consistency. If not installed, tests should be skipped.
"""
if not ftmc.which("MC-Annotate"):
raise unittest.SkipTest("This Test requires MC-Annotate for consistency.")
else:
return {"PDB_ANNOTATION_TOOL": "MC-Annotate"}
@patch('forgi.config.read_config', mocked_read_config)
@patch('forgi.threedee.model.coarse_grain._run_mc_annotate',
mock_run_mc_annotate(ftmc._run_mc_annotate))
class CoarseGrainIoTest(tfgb.GraphVerification):
def check_cg_integrity(self, cg):
self.assertGreater(len(list(cg.stem_iterator())), 0)
for s in cg.stem_iterator():
edges = list(cg.edges[s])
if len(edges) < 2:
continue
multiloops = False
for e in edges:
if e[0] != 'i':
multiloops = True
if multiloops:
continue
self.assertFalse(np.allclose(cg.coords[edges[0]][0],
cg.coords[edges[1]][0]))
self.assertFalse(np.allclose(cg.coords[edges[0]][0],
cg.coords[edges[1]][1]))
self.assertFalse(np.allclose(cg.coords[edges[0]][1],
cg.coords[edges[1]][0]))
self.assertFalse(np.allclose(cg.coords[edges[0]][1],
cg.coords[edges[1]][1]))
def test_dssr_backslash_in_filename(self):
"""
DSSR puts the input filename in the JSON, which makes the JSON invalid,
if a backslash is in it. We patch the DSSR JSON before parsing.
"""
with make_temp_directory() as d:
# On Windows, bla is a directory, and the backslash is
# part of the path,
# on decent operating systems,
# the backslash is part of the filename.
filename=os.path.join(d, "bla\\something.pdb")
dir, rest = os.path.split(filename)
# On Windows, make the directory bla, on Linux do nothing
try:
os.makedirs(dir)
except OSError:
# Directory exists
pass
shutil.copy('test/forgi/threedee/data/1y26.pdb', filename)
try:
# Make sure we do not raise any error.
cg, = ftmc.CoarseGrainRNA.from_pdb(filename,
annotation_tool="DSSR")
except ftmc.AnnotationToolNotInstalled:
self.skipTest("This Test requires DSSR")
self.check_graph_integrity(cg)
self.assertGreater(len(cg.defines), 2)
def test_from_mmcif(self):
import Bio.PDB as bpdb
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1Y26.cif')
cg2, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/1y26.pdb')
self.assertEqual(cg.defines, cg2.defines)
self.assertGreater(len(cg.defines), 3)
for d in cg.defines:
nptest.assert_almost_equal(cg.coords[d], cg2.coords[d])
def test_from_mmcif_missing_residues(self):
import Bio.PDB as bpdb
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/2x1f.cif', load_chains="B")
cg2, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/2X1F.pdb', load_chains="B")
log.error(cg.seq._missing_nts)
self.assertEqual(len(cg.seq._missing_nts), 3)
self.assertEqual(len(cg2.seq._missing_nts), 3)
self.assertEqual(cg.seq, cg2.seq)
def test_from_pdb(self):
import time
now = time.time()
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/4GV9.pdb', load_chains='E')
log.error(time.time() - now)
now = time.time()
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/RS_363_S_5.pdb')
log.error(time.time() - now)
now = time.time()
self.check_cg_integrity(cg)
log.error(time.time() - now)
now = time.time()
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/RS_118_S_0.pdb')
log.error(time.time() - now)
now = time.time()
self.check_cg_integrity(cg)
log.error(time.time() - now)
now = time.time()
self.assertTrue(len(cg.defines) > 1)
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/ideal_1_4_5_8.pdb')
self.check_cg_integrity(cg)
log.error(time.time() - now)
now = time.time()
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/ideal_1_4_5_8.pdb')
log.error(time.time() - now)
now = time.time()
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/1y26_missing.pdb')
self.check_cg_integrity(cg)
log.error(time.time() - now)
now = time.time()
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1y26_two_chains.pdb',
load_chains='Y')
self.assertEqual(len(cg.defines), 1)
self.assertIn("f0", cg.defines)
self.assertEqual(cg.seq, "U")
log.error(time.time() - now)
now = time.time()
# commented out for 3 ec speedup
# cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1X8W.pdb',
# load_chains='A')
# self.check_cg_integrity(cg)
#log.error (time.time()-now); now=time.time()
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/1FJG_reduced.pdb')
self.check_cg_integrity(cg)
log.error(time.time() - now)
now = time.time()
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1y26.pdb')
log.error(time.time() - now)
now = time.time()
def test_file_with_numeric_chain_id(self):
# Numeric chain ids
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/3J7A_part.pdb', load_chains=["7"])
self.check_cg_integrity(cg)
self.assertEqual(cg.seq._seqids[0].chain, '7')
def test_from_pdb_cofold(self):
# 1FUF triggers the if fromA.chain != fromB.chain clause in _are_adjacent_basepairs
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1FUF.pdb',
dissolve_length_one_stems=True)
self.check_cg_integrity(cg)
def verify_multiple_chains(self, cg, single_chain_cgs):
log.warning("Backbone in %s breaks after %s",
cg.name, cg.backbone_breaks_after)
self.assertEqual(len(cg.backbone_breaks_after),
len(single_chain_cgs) - 1)
self.assertEqual(cg.seq_length, sum(
x.seq_length for x in single_chain_cgs))
# There might be stems spanning multiple chains.
self.assertGreaterEqual(len([s for s in cg.defines if s[0] == "s"]), len(
[s for c in single_chain_cgs for s in c.defines if s[0] == "s"]))
self.assertEqual(cg.seq, "&".join(str(x.seq)
for x in single_chain_cgs))
def test_from_pdb_f_in_second_chain(self):
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/4GV9.pdb', load_chains=None)
self.assertEqual(set(cg.defines.keys()), set(["t0", "s0", "f0"]))
def test_from_pdb_multiple(self):
cgE, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/4GV9.pdb', load_chains='E')
cgF, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/4GV9.pdb', load_chains='F')
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/4GV9.pdb', load_chains=None)
self.assertEqual(set(cg.chains.keys()), set(["E", "F"]))
self.assertEqual(len(cg.backbone_breaks_after), 1)
bp = cg.backbone_breaks_after[0]
self.assertEqual(bp, 3)
self.assertEqual(cg.seq[:bp], cgE.seq)
self.assertEqual(cg.seq[1:bp], cgE.seq)
self.assertEqual(cg.seq[bp + 1:], cgF.seq)
self.verify_multiple_chains(cg, [cgE, cgF])
cgA, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/3CQS.pdb', load_chains='A')
cgB, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/3CQS.pdb', load_chains='B')
cgC, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/3CQS.pdb', load_chains='C')
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/3CQS.pdb', load_chains=None)
log.warning("cg now has %s cutpoints: %s", len(
cg.seq._breaks_after), cg.backbone_breaks_after)
self.verify_multiple_chains(cg, [cgA, cgB, cgC])
def test_multiple_chain_to_cg(self):
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/4GV9.pdb', load_chains=None)
log.debug("======= FIRST IS LOADED =========")
cg_str = cg.to_cg_string()
log.debug("\n" + cg_str)
print(cg_str)
cg2 = ftmc.CoarseGrainRNA.from_bg_string(cg_str)
self.assertEqual(cg.defines, cg2.defines)
self.assertLess(ftme.cg_rmsd(cg, cg2), 10**-6)
self.assertEqual(cg.backbone_breaks_after, cg2.backbone_breaks_after)
cg, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/3CQS.pdb', load_chains=None)
cg.log(logging.WARNING)
cg_str = cg.to_cg_string()
cg2 = ftmc.CoarseGrainRNA.from_bg_string(cg_str)
self.assertEqual(cg.defines, cg2.defines)
# This only looks at stems
self.assertLess(ftme.cg_rmsd(cg, cg2), 10**-6)
self.assertEqual(cg.backbone_breaks_after, cg2.backbone_breaks_after)
def test_connected_cgs_from_pdb(self):
cgs = ftmc.CoarseGrainRNA.from_pdb("test/forgi/threedee/data/1DUQ.pdb")
self.assertEqual(len(cgs), 4)
# This PDB file contains 4 similar RNA dimers
self.assertEqual(cgs[0].name, "1DUQ_A-B")
self.assertEqual(cgs[1].name, "1DUQ_C-D")
self.assertEqual(cgs[2].name, "1DUQ_E-F")
self.assertEqual(cgs[3].name, "1DUQ_G-H")
self.assertEqual(cgs[0].defines, cgs[2].defines)
self.assertEqual(cgs[1].defines, cgs[3].defines)
def test_multiple_models_in_file(self):
with self.assertWarns(UserWarning) if hasattr(self, 'assertWarns') else ignore_warnings():
cgs = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1byj.pdb')
self.assertEqual(len(cgs), 1) # Only look at first model!
def test_annotating_with_dssr(self):
pass
class CoarseGrainTest(tfgb.GraphVerification):
'''
Simple tests for the BulgeGraph data structure.
For now the main objective is to make sure that a graph is created
and nothing crashes in the process. In the future, test cases for
bugs should be added here.
'''
def setUp(self):
self.longMessage = True
def check_cg_integrity(self, cg):
for s in cg.stem_iterator():
edges = list(cg.edges[s])
if len(edges) < 2:
continue
multiloops = False
for e in edges:
if e[0] != 'i':
multiloops = True
if multiloops:
continue
self.assertFalse(np.allclose(cg.coords[edges[0]][0],
cg.coords[edges[1]][0]))
self.assertFalse(np.allclose(cg.coords[edges[0]][0],
cg.coords[edges[1]][1]))
self.assertFalse(np.allclose(cg.coords[edges[0]][1],
cg.coords[edges[1]][0]))
self.assertFalse(np.allclose(cg.coords[edges[0]][1],
cg.coords[edges[1]][1]))
def compare_bg_to_cg(self, bg, cg):
for d in bg.defines.keys():
self.assertTrue(d in cg.defines.keys())
self.assertTrue(bg.defines[d] == cg.defines[d])
for e in bg.edges.keys():
self.assertTrue(e in cg.edges.keys())
self.assertTrue(bg.edges[e] == cg.edges[e])
def test_get_node_from_residue_num(self):
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1X8W.pdb',
load_chains='A', dissolve_length_one_stems=True)
self.check_cg_integrity(cg)
elem_name = cg.get_node_from_residue_num(1)
cg.log()
self.assertEqual(elem_name, "f0")
def test_from_cg(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
self.check_graph_integrity(cg)
self.check_cg_integrity(cg)
# self.assertEqual(len(cg.coords), 8)
for key in cg.defines.keys():
self.assertTrue(key in cg.coords)
def test_from_and_to_cgstring(self):
cg1 = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
cg1.project_from = np.array([1, 2, 3.5])
stri = cg1.to_cg_string()
cg2 = ftmc.CoarseGrainRNA.from_bg_string(stri)
for key in set(cg1.defines):
self.assertTrue(key in cg2.defines)
self.assertTrue(key in cg2.coords)
nptest.assert_allclose(cg1.defines[key], cg2.defines[key])
nptest.assert_allclose(cg1.coords[key][0], cg2.coords[key][0])
nptest.assert_allclose(cg1.coords[key][1], cg2.coords[key][1])
for key in set(cg2.defines):
self.assertTrue(key in cg1.defines)
self.assertTrue(key in cg1.coords)
nptest.assert_allclose(cg1.defines[key], cg2.defines[key])
nptest.assert_allclose(cg1.coords[key][0], cg2.coords[key][0])
nptest.assert_allclose(cg1.coords[key][1], cg2.coords[key][1])
nptest.assert_allclose(cg1.project_from, cg2.project_from)
def test_to_and_from_cgstring_vres(self):
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2mis.pdb')
cg.add_all_virtual_residues()
cgstri = cg.to_cg_string()
self.assertIn("vres", cgstri)
cg2 = ftmc.CoarseGrainRNA.from_bg_string(cgstri)
self.assertEqual(
len(cg2.vposs["h0"]), cg2.defines["h0"][1] - cg2.defines["h0"][0] + 1)
self.assertLess(ftuv.vec_distance(
cg.vposs["h0"][0], cg2.vposs["h0"][0]), 10**-8)
self.assertLess(ftuv.vec_distance(
cg.vposs["i0"][2], cg2.vposs["i0"][2]), 10**-8)
def test_get_bulge_angle_stats_core(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
self.check_graph_integrity(cg)
for d in cg.mloop_iterator():
cg.get_bulge_angle_stats(d)
def test_get_bulge_angle_stats_for_start(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
s1, s2 = cg.get_bulge_angle_stats("start")
def test_read_longrange_interactions(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
self.check_graph_integrity(cg)
self.assertGreater(len(cg.longrange), 0)
def test_radius_of_gyration(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
self.check_graph_integrity(cg)
rog = cg.radius_of_gyration()
self.assertGreater(rog, 0.)
maxDist = max(ftuv.vec_distance(p0, p1) for p0, p1 in it.combinations(cg.coords._coordinates, 2))
estimated_radius_circum_cricle = maxDist / 2
# NOTE: The ROG is 0.77 times the radius of the circumcircle, for m->inf many points
# in a 3D unit sphere with the nth point placed at radius (n/m)**1/3
self.assertLess(rog, estimated_radius_circum_cricle * 0.77)
def test_radius_of_gyration_different_methods(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
rog_fast = cg.radius_of_gyration(method="fast")
rog_vres = cg.radius_of_gyration(method="vres")
print(rog_fast, rog_vres, rog_fast - rog_vres, file=sys.stderr)
self.assertGreater(abs(rog_fast - rog_vres), 0, msg="Different methods for ROG calculation "
"producting the exactly same result? Something seems to be wrong.")
self.assertLess(abs(rog_fast - rog_vres), 3, msg="Different methods for ROG calculation "
"should produce roughly the same result.")
def test_radius_of_gyration_no_stems(self):
cg, = ftmc.CoarseGrainRNA.from_fasta_text("AUCG\n....")
cg.coords["f0"] = [0, 0, 0.], [12., 1, 1]
self.assertTrue(math.isnan(cg.radius_of_gyration()))
def test_get_sides(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1gid.cg')
self.check_graph_integrity(cg)
self.check_cg_integrity(cg)
log.info(cg.to_dotbracket_string())
log.info(cg.to_element_string(True))
# The file 1gid.cg still starts with f1, not f0
(s1b, s1e) = cg.get_sides('s0', 'f1')
(s1b, s1e) = cg.get_sides('s8', 't1')
'''
def test_cg_from_sg(self):
bg = ftmc.CoarseGrainRNA(
dotbracket_str='.(((((..(((.(((((((.((.((((..((((((....))))))..)))).)).))........(((((.....((((...((((....))))...))))...))))).))))).)))...)))))')
self.check_graph_integrity(bg)
# bg = cgb.BulgeGraph(dotbracket_str='.(((((........)))))..((((((((.(((.((...........((((((..(((((.((((((((..(((..)))...((((....)))).....))))))))..)))))................((((((...........))))))..((...(((((((...((((((..)))))).....((......))....)))))))...(((((((((.........))))))))).(((....))).))..........(((((.(((((.......))))))))))..........))))..))............(((.((((((((...((.......))...))))))..))))).........((((((((((((..(((((((((......))))))..))).((((.......)))).....)))))..))..))).))....((...............))....))..)))))))))))...')
for j in range(40):
sg = bg.random_subgraph()
new_cg = cg_from_sg(bg, sg)
for i in it.chain(new_cg.iloop_iterator(), new_cg.mloop_iterator()):
c = new_cg.connections(i)
if len(c) != 2:
self.assertEqual(len(c), 2)
'''
def test_get_stem_stats(self):
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2mis.pdb')
cg.get_stem_stats("s0")
def test_get_angle_stats(self):
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2mis.pdb')
for d in cg.defines:
if d[0] in "mi":
cg.get_bulge_angle_stats(d)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1byj.pdb')
for d in cg.defines:
if d[0] in "mi":
cg.get_bulge_angle_stats(d)
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2QBZ.pdb')
for d in cg.defines:
if d[0] in "mi":
cg.get_bulge_angle_stats(d)
def test_get_loop_stat(self):
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2mis.pdb')
cg.get_loop_stat("h0")
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/4GXY_A.cg') # Contains a loop with r=0
self.check_graph_integrity(cg)
self.check_cg_integrity(cg)
cg.get_loop_stat('h3')
def test_length_one_stems(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1byj.pdb',
remove_pseudoknots=False)
self.check_graph_integrity(cg)
self.check_cg_integrity(cg)
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2QBZ.pdb',
remove_pseudoknots=False)
self.check_graph_integrity(cg)
self.check_cg_integrity(cg)
def test_pseudoknot(self):
#cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/1ymo.pdb')
# self.check_graph_integrity(cg)
# self.check_cg_integrity(cg)
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/3D0U_A.cg')
self.check_graph_integrity(cg)
self.check_cg_integrity(cg)
cg.traverse_graph()
self.assertEqual(cg.get_angle_type("i3"), 1)
def test_small_molecule(self):
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2X1F.pdb')
log.info(cg.to_dotbracket_string())
log.info(cg.to_element_string(True))
log.info("COORDS {}".format(cg.coords))
self.assertTrue('f0' in cg.coords)
def test_longrange_iterator(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
interactions = list(cg.longrange_iterator())
self.assertEqual(len(interactions), 4)
self.assertTrue(('i0', 's0') in interactions)
def test_longrange_distance(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
dist = cg.element_physical_distance('h0', 'h1')
self.assertTrue(dist < 10)
def test_total_length(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
self.assertEqual(cg.total_length(), cg.seq_length)
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2X1F.pdb')
self.assertEqual(cg.total_length(), cg.seq_length)
cg = ftmc.CoarseGrainRNA.from_dotbracket('..((..((...))..))..((..))..')
self.assertEqual(cg.total_length(), cg.seq_length)
self.assertEqual(cg.total_length(), 27)
def test_get_load_coordinates(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
coords = cg.get_coordinates_array()
new_cg = copy.deepcopy(cg)
for key in new_cg.coords:
new_cg.coords[key] = [0, 0, 0], [0, 0, 0]
new_cg.load_coordinates_array(coords)
for key in new_cg.coords:
for i in range(len(new_cg.coords[key])):
nptest.assert_allclose(new_cg.coords[key][i],
cg.coords[key][i])
"""
def test_is_stacking(self):
cg = ftmc.CoarseGrainRNA.from_bg_file('test/forgi/threedee/data/3way.cg')
self.assertFalse(cg.is_stacking("m0")) #Distance
self.assertFalse(cg.is_stacking("m1")) #distance
self.assertFalse(cg.is_stacking("m2")) #shear angle
def test_is_stacking2(self):
cg = ftmc.CoarseGrainRNA.from_bg_file('test/forgi/threedee/data/1I9V_noPK.cg')
self.assertFalse(cg.is_stacking("m0"))
self.assertFalse(cg.is_stacking("m2"))
self.assertTrue(cg.is_stacking("m1"))
"""
def test_coords_from_direction(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1I9V_noPK.cg')
cg_old = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1I9V_noPK.cg')
coords = cg.get_coordinates_array()
directions = coords[1::2] - coords[0::2]
cg._init_coords()
cg.coords_from_directions(directions)
# self.assertAlmostEqual(ftme.cg_rmsd(cg, cg_old), 0) #This only looks at stems
# The coordinates should be the same as before except for a constant offset
new_coords = cg.get_coordinates_array()
offset = (coords - new_coords)
print(offset)
# I use allclose, because it uses broadcasting
assert np.allclose(offset, offset[0])
def test_coords_from_direction_with_pseudoknot(self):
# This tests the case where the link is inserted from reverse direction.
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/3D0U_A.cg')
cg_old = copy.deepcopy(cg)
coords = cg.get_coordinates_array()
directions = cg.coords_to_directions()
cg._init_coords()
cg.twists = cg_old.twists
log.info("len(coords):{}, len(directions):{}, len(defines):{}".format(
len(coords), len(directions), len(cg.defines)))
cg.coords_from_directions(directions)
self.assertLess(ftme.cg_rmsd(cg, cg_old), 10**-6)
new_coords = cg.get_coordinates_array()
offset = (coords - new_coords)
assert np.allclose(offset, offset[0])
@unittest.skip("It is hard to do the subgraph thing correctly in a way consistent with the RNA model. Thus it has been disabled in the current release!")
def test_cg_from_sg_invalid_subgraph_breaking_m(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/3D0U_A.cg')
"""
/s3 --h1
m1 |
/ |
s0 m2
\ |
m0 |
\s1--i0--s2--h0
"""
split_ml = ["s0", "m0", "s1"]
with self.assertRaises(Exception):
ftmc.cg_from_sg(cg, split_ml)
@unittest.skip("It is hard to do the subgraph thing correctly in a way consistent with the RNA model. Thus it has been disabled in the current release!")
def test_cg_from_sg_breaking_after_i(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/3D0U_A.cg')
"""
/s3 --h1
m1 |
/ |
s0 m2
\ |
m0 |
\s1--i0--s2--h0
"""
split_ml = ["s0", "m0", "s1", "m2", "s3", "m1", "h1", "i0"]
sg = ftmc.cg_from_sg(cg, split_ml)
self.check_graph_integrity(sg)
@unittest.skip("It is hard to do the subgraph thing correctly in a way consistent with the RNA model. Thus it has been disabled in the current release!")
def test_cg_from_sg_breaking_after_s(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/3D0U_A.cg')
"""
/s3 --h1
m1 |
/ |
s0 m2
\ |
m0 |
\s1--i0--s2--h0
"""
split_ml = ["s0", "m0", "s1", "m2", "s3", "m1", "h1"]
sg = ftmc.cg_from_sg(cg, split_ml)
self.check_graph_integrity(sg)
class TestVirtualAtoms(unittest.TestCase):
def setUp(self):
self.longMessage = True
@unittest.skip("This test currently fails. Should be fixed in version 0.5")
def test_virtual_atoms_only_single_stranded(self):
cg, = ftmc.CoarseGrainRNA.from_pdb('test/forgi/threedee/data/2X1F.pdb')
va = cg.virtual_atoms(1)
self.assertIn("C1'", va) # C1' should be always present
def test_virtual_atoms_stem_distance_to_pairing_partner(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
va1 = cg.virtual_atoms(1)
va2 = cg.virtual_atoms(cg.pairing_partner(1))
self.assertLess(ftuv.vec_distance(
va1["C1'"], va2["C1'"]), 25, msg="Virtual atoms too far apart")
self.assertGreater(ftuv.vec_distance(
va1["C1'"], va2["C1'"]), 8, msg="Virtual atoms too close")
def test_virtual_atoms_stem_distance_to_stacked_base(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
va1 = cg.virtual_atoms(1)
va2 = cg.virtual_atoms(2)
self.assertLess(ftuv.vec_distance(
va1["C1'"], va2["C1'"]), 10, msg="Virtual atoms too far apart")
self.assertGreater(ftuv.vec_distance(
va1["C1'"], va2["C1'"]), 2, msg="Virtual atoms too close")
def test_virtuel_atom_caching_is_reset(self):
cg = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
va_old = cg.virtual_atoms(1)["C1'"]
# Stay orthogonal to twists
cg.coords["s0"] = cg.coords["s0"][0] + \
(cg.coords["s0"][1] - cg.coords["s0"][0]) * 0.5, cg.coords["s0"][1]
va_new = cg.virtual_atoms(1)["C1'"]
self.assertTrue(np.any(np.not_equal(va_old, va_new)),
msg="A stale virtual atom position was used.")
class RotationTranslationTest(unittest.TestCase):
def setUp(self):
self.cg1 = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.cg2, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/1byj.pdb')
def test_rotate_keeps_RMSD_zero0(self):
cg1_rot = copy.deepcopy(self.cg1)
cg1_rot.rotate(30, unit="degrees")
cg1_rot.rotate(-30, unit="degrees")
self.assertLess(ftme.cg_rmsd(self.cg1, cg1_rot), 10**-6)
def test_rotate_keeps_RMSD_zero(self):
cg1_rot = copy.deepcopy(self.cg1)
cg1_rot.rotate(30, unit="degrees")
# This currently uses virtual atoms, thus takes twists into account.
self.assertLess(ftme.cg_rmsd(self.cg1, cg1_rot), 10**-6)
cg2_rot = copy.deepcopy(self.cg2)
cg2_rot.rotate(45, unit="degrees")
a,b = self.cg2.get_ordered_virtual_residue_poss(True)
log.warning("------------------------")
c,d = cg2_rot.get_ordered_virtual_residue_poss(True)
c2 = np.dot(c, ftuv.rotation_matrix("x", math.radians(-45)).T)
log.warning("==================================")
for i, coord in enumerate(a):
if any(abs(coord-c2[i])>10**-4):
log.warning("%s %s %s %s",coord, b[i], c2[i], d[i])
self.assertLess(ftme.cg_rmsd(self.cg2, cg2_rot), 10**-6)
class StericValueTest(unittest.TestCase):
def setUp(self):
self.cg1 = ftmc.CoarseGrainRNA.from_bg_file(
'test/forgi/threedee/data/1y26.cg')
self.cg2, = ftmc.CoarseGrainRNA.from_pdb(
'test/forgi/threedee/data/1byj.pdb')
@unittest.skip("Manual test")
def test_stericValue_1(self):
print("m0, m1, m2", self.cg1.steric_value(["m0", "m1", "m2"]))
from_ = np.amin(self.cg1.coords._coordinates)
to_ = np.amax(self.cg1.coords._coordinates)
x, y, z = np.mgrid[from_:to_:4, from_:to_:4, from_:to_:4]
from mayavi import mlab
s = np.zeros_like(x)
for i, j, k in np.ndindex(x.shape):
s[i, j, k] = self.cg1.steric_value(
np.array([x[i, j, k], y[i, j, k], z[i, j, k]]), "r**-3")
#mlab.contour3d(x,y,z,s, contours= [0.5, 1, 2, 5], opacity=0.3)
src = mlab.pipeline.scalar_field(x, y, z, s)
mlab.pipeline.volume(src)
#mlab.pipeline.iso_surface(src, contours=[0.1, ], opacity=0.3)
#mlab.pipeline.iso_surface(src, contours=[0.5, ], opacity=0.7)
#mlab.pipeline.iso_surface(src, contours=[1, ])
colors = {"s": (0, 1, 0), "h": (0, 0, 1), "m": (1, 0, 0), "i": (
1, 1, 0), "f": (0.5, 0.5, 0.5), "t": (0.5, 0.5, 0.5)}
for d in self.cg1.defines:
x = self.cg1.coords[d][0][0], self.cg1.coords[d][1][0]
y = self.cg1.coords[d][0][1], self.cg1.coords[d][1][1]
z = self.cg1.coords[d][0][2], self.cg1.coords[d][1][2]
mlab.plot3d(x, y, z, tube_radius=2, color=colors[d[0]])
mlab.show()
assert False
|
gpl-3.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
636,
2443,
363,
492,
4629,
199,
199,
504,
12963,
492,
1425,
199,
199,
646,
3598,
199,
646,
2882,
199,
646,
984,
199,
646,
7975,
465,
652,
199,
646,
1331,
199,
646,
900,
199,
646,
3473,
199,
646,
2050,
199,
646,
747,
14,
515,
199,
646,
747,
199,
646,
5145,
199,
646,
15502,
199,
199,
893,
26,
272,
687,
2882,
14,
1805,
492,
3371,
199,
2590,
3545,
26,
272,
687,
1683,
492,
3371,
199,
199,
646,
2680,
465,
980,
199,
646,
2680,
14,
4776,
465,
980,
396,
199,
199,
646,
367,
6153,
14,
10480,
11192,
14,
1238,
14,
331,
30672,
63,
926,
262,
465,
18133,
5466,
199,
646,
367,
6153,
14,
2180,
14,
25792,
303,
63,
2180,
465,
289,
4908,
199,
646,
367,
6153,
14,
10480,
11192,
14,
1238,
14,
21965,
465,
18133,
278,
199,
646,
367,
6153,
14,
10480,
11192,
14,
16355,
14,
2180,
63,
10511,
465,
18133,
1518,
199,
646,
367,
6153,
14,
10480,
11192,
14,
16355,
14,
4106,
465,
18133,
9154,
199,
646,
367,
6153,
14,
16355,
14,
1757,
465,
289,
1181,
199,
504,
367,
6153,
14,
16355,
14,
14573,
492,
1852,
63,
808,
63,
3619,
199,
504,
2263,
2180,
492,
330,
348,
303,
63,
2180,
63,
396,
465,
2833,
4908,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
32,
23464,
14,
14237,
199,
318,
3686,
63,
5451,
837,
272,
543,
3598,
14,
9341,
63,
5451,
837,
267,
3598,
14,
18815,
480,
4247,
531,
267,
1995,
488,
199,
199,
318,
19711,
63,
504,
63,
1226,
8,
12595,
12,
12578,
304,
272,
1449,
272,
2790,
282,
512,
30672,
13,
926,
262,
5523,
687,
282,
23649,
14,
339,
768,
635,
19711,
26,
710,
3379,
5523,
272,
768,
635,
12578,
26,
710,
769,
402,
4008,
626,
787,
315,
314,
23649,
272,
1449,
272,
892,
63,
12595,
275,
18133,
5466,
14,
12595,
63,
504,
63,
1226,
8,
12595,
12,
12578,
9,
272,
372,
892,
63,
12595,
339,
367,
366,
315,
12578,
26,
267,
892,
63,
12595,
14,
14334,
59,
68,
61,
275,
19711,
14,
14334,
59,
68,
61,
398,
340,
366,
315,
19711,
14,
8032,
14,
1612,
837,
288,
892,
63,
12595,
14,
8032,
59,
68,
61,
275,
19711,
14,
8032,
59,
68,
61,
267,
340,
366,
315,
19711,
14,
8122,
1670,
14,
1612,
837,
288,
892,
63,
12595,
14,
8122,
1670,
59,
68,
61,
275,
19711,
14,
8122,
1670,
59,
68,
61,
267,
340,
366,
315,
19711,
14,
2809,
1842,
14,
1612,
837,
288,
892,
63,
12595,
14,
2809,
1842,
59,
68,
61,
275,
19711,
14,
2809,
1842,
59,
68,
61,
398,
367,
671,
315,
19711,
14,
6929,
59,
68,
2189,
288,
340,
671,
315,
892,
63,
12595,
14,
14334,
14,
1612,
837,
355,
892,
63,
12595,
14,
6929,
59,
68,
1055,
525,
8,
88,
9,
355,
892,
63,
12595,
14,
6929,
59,
88,
1055,
525,
8,
68,
9,
339,
372,
892,
63,
12595,
421,
199,
318,
1683,
63,
1065,
63,
5466,
63,
10898,
8,
5043,
63,
1593,
304,
272,
408,
272,
445,
23302,
402,
32685,
13,
21761,
323,
1072,
367,
8112,
384,
272,
408,
272,
347,
16991,
63,
1065,
63,
5466,
63,
10898,
8,
1501,
12,
3873,
63,
958,
304,
267,
892,
63,
2324,
275,
747,
14,
515,
14,
1294,
8,
1501,
2788,
17,
61,
267,
892,
63,
2324,
847,
3680,
5466,
21761,
323,
14,
548,
2,
267,
862,
26,
288,
543,
1551,
8,
736,
14,
515,
14,
904,
480,
396,
401,
298,
509,
6153,
401,
298,
10480,
11192,
401,
298,
576,
401,
892,
63,
2324,
430,
465,
289,
26,
355,
2385,
275,
289,
14,
9684,
342,
288,
943,
14,
705,
480,
10369,
6328,
32685,
13,
21761,
323,
1072,
531,
267,
871,
5925,
26,
221,
327,
641,
1134,
19,
642,
365,
376,
5162,
402,
312,
332,
451,
288,
2385,
275,
3379,
63,
1593,
8,
1501,
12,
3873,
63,
958,
9,
288,
543,
1551,
8,
736,
14,
515,
14,
904,
480,
396,
401,
298,
509,
6153,
401,
298,
10480,
11192,
401,
298,
576,
401,
892,
63,
2324,
395,
298,
87,
531,
465,
289,
26,
355,
870,
4582,
78,
1674,
904,
8,
1278,
395,
570,
29,
70,
9,
267,
943,
14,
815,
480,
1767,
316,
2385,
26,
450,
83,
401,
2385,
9,
267,
372,
2385,
272,
372,
16991,
63,
1065,
63,
5466,
63,
10898,
421,
199,
318,
16991,
63,
739,
63,
888,
837,
272,
408,
272,
18513,
32685,
13,
21761,
323,
367,
17754,
14,
982,
440,
4903,
12,
2295,
1077,
506,
9645,
14,
272,
408,
272,
340,
440,
18133,
5466,
14,
6777,
480,
7608,
13,
21761,
323,
2349,
267,
746,
2882,
14,
25755,
480,
2765,
1379,
5074,
32685,
13,
21761,
323,
367,
17754,
2685,
272,
587,
26,
267,
372,
2420,
32641,
63,
879,
4609,
2594,
63,
9731,
582,
298,
7608,
13,
21761,
323,
3570,
421,
199,
32,
2068,
360,
509,
6153,
14,
888,
14,
739,
63,
888,
297,
16991,
63,
739,
63,
888,
9,
199,
32,
2068,
360,
509,
6153,
14,
10480,
11192,
14,
1238,
14,
331,
30672,
63,
926,
262,
423,
1065,
63,
5466,
63,
10898,
297,
2126,
1683,
63,
1065,
63,
5466,
63,
10898,
8,
856,
5466,
423,
1065,
63,
5466,
63,
10898,
430,
199,
533,
1849,
30672,
5761,
262,
16512,
774,
8,
3249,
4908,
14,
4578,
22595,
304,
272,
347,
1104,
63,
12595,
63,
5707,
12997,
8,
277,
12,
19711,
304,
267,
291,
14,
15070,
8,
552,
8,
513,
8,
12595,
14,
18446,
63,
5778,
22606,
378,
9,
267,
367,
308,
315,
19711,
14,
18446,
63,
5778,
837,
288,
8207,
275,
769,
8,
12595,
14,
6929,
59,
83,
566,
288,
340,
822,
8,
6929,
9,
665,
499,
26,
355,
1980,
953,
3510,
22412,
275,
756,
288,
367,
325,
315,
8207,
26,
355,
340,
325,
59,
16,
61,
1137,
283,
73,
356,
490,
3510,
22412,
275,
715,
953,
340,
3510,
22412,
26,
355,
1980,
953,
291,
14,
3334,
8,
1590,
14,
7520,
8,
12595,
14,
8032,
59,
6929,
59,
16,
22235,
16,
467,
1460,
19711,
14,
8032,
59,
6929,
59,
17,
22235,
16,
2459,
288,
291,
14,
3334,
8,
1590,
14,
7520,
8,
12595,
14,
8032,
59,
6929,
59,
16,
22235
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
636,
2443,
363,
492,
4629,
199,
199,
504,
12963,
492,
1425,
199,
199,
646,
3598,
199,
646,
2882,
199,
646,
984,
199,
646,
7975,
465,
652,
199,
646,
1331,
199,
646,
900,
199,
646,
3473,
199,
646,
2050,
199,
646,
747,
14,
515,
199,
646,
747,
199,
646,
5145,
199,
646,
15502,
199,
199,
893,
26,
272,
687,
2882,
14,
1805,
492,
3371,
199,
2590,
3545,
26,
272,
687,
1683,
492,
3371,
199,
199,
646,
2680,
465,
980,
199,
646,
2680,
14,
4776,
465,
980,
396,
199,
199,
646,
367,
6153,
14,
10480,
11192,
14,
1238,
14,
331,
30672,
63,
926,
262,
465,
18133,
5466,
199,
646,
367,
6153,
14,
2180,
14,
25792,
303,
63,
2180,
465,
289,
4908,
199,
646,
367,
6153,
14,
10480,
11192,
14,
1238,
14,
21965,
465,
18133,
278,
199,
646,
367,
6153,
14,
10480,
11192,
14,
16355,
14,
2180,
63,
10511,
465,
18133,
1518,
199,
646,
367,
6153,
14,
10480,
11192,
14,
16355,
14,
4106,
465,
18133,
9154,
199,
646,
367,
6153,
14,
16355,
14,
1757,
465,
289,
1181,
199,
504,
367,
6153,
14,
16355,
14,
14573,
492,
1852,
63,
808,
63,
3619,
199,
504,
2263,
2180,
492,
330,
348,
303,
63,
2180,
63,
396,
465,
2833,
4908,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
32,
23464,
14,
14237,
199,
318,
3686,
63,
5451,
837,
272,
543,
3598,
14,
9341,
63,
5451,
837,
267,
3598,
14,
18815,
480,
4247,
531,
267,
1995,
488,
199,
199,
318,
19711,
63,
504,
63,
1226,
8,
12595,
12,
12578,
304,
272,
1449,
272,
2790,
282,
512,
30672,
13,
926,
262,
5523,
687,
282,
23649,
14,
339,
768,
635,
19711,
26,
710,
3379,
5523,
272,
768,
635,
12578,
26,
710,
769,
402,
4008,
626,
787,
315,
314,
23649,
272,
1449,
272,
892,
63,
12595,
275,
18133,
5466,
14,
12595,
63,
504,
63,
1226,
8,
12595,
12,
12578,
9,
272,
372,
892,
63,
12595,
339,
367,
366,
315,
12578,
26,
267,
892,
63,
12595,
14,
14334,
59,
68,
61,
275,
19711,
14,
14334,
59,
68,
61,
398,
340,
366,
315,
19711,
14,
8032,
14,
1612,
837,
288,
892,
63,
12595,
14,
8032,
59,
68,
61,
275,
19711,
14,
8032,
59,
68,
61,
267,
340,
366,
315,
19711,
14,
8122,
1670,
14,
1612,
837,
288,
892,
63,
12595,
14,
8122,
1670,
59,
68,
61,
275,
19711,
14,
8122,
1670,
59,
68,
61,
267,
340,
366,
315,
19711,
14,
2809,
1842,
14,
1612,
837,
288,
892,
63,
12595,
14,
2809,
1842,
59,
68,
61,
275,
19711,
14,
2809,
1842,
59,
68,
61,
398,
367,
671,
315,
19711,
14,
6929,
59,
68,
2189,
288,
340,
671,
315,
892,
63,
12595,
14,
14334,
14,
1612,
837,
355,
892,
63,
12595,
14,
6929,
59,
68,
1055,
525,
8,
88,
9,
355,
892,
63,
12595,
14,
6929,
59,
88,
1055,
525,
8,
68,
9,
339,
372,
892,
63,
12595,
421,
199,
318,
1683,
63,
1065,
63,
5466,
63,
10898,
8,
5043,
63,
1593,
304,
272,
408,
272,
445,
23302,
402,
32685,
13,
21761,
323,
1072,
367,
8112,
384,
272,
408,
272,
347,
16991,
63,
1065,
63,
5466,
63,
10898,
8,
1501,
12,
3873,
63,
958,
304,
267,
892,
63,
2324,
275,
747,
14,
515,
14,
1294,
8,
1501,
2788,
17,
61,
267,
892,
63,
2324,
847,
3680,
5466,
21761,
323,
14,
548,
2,
267,
862,
26,
288,
543,
1551,
8,
736,
14,
515,
14,
904,
480,
396,
401,
298,
509,
6153,
401,
298,
10480,
11192,
401,
298,
576,
401,
892,
63,
2324,
430,
465,
289,
26,
355,
2385,
275,
289,
14,
9684,
342,
288,
943,
14,
705,
480,
10369,
6328,
32685,
13,
21761,
323,
1072,
531,
267,
871,
5925,
26,
221,
327,
641,
1134,
19,
642,
365,
376,
5162,
402,
312,
332,
451,
288,
2385,
275,
3379,
63,
1593,
8,
1501,
12,
3873,
63,
958,
9,
288,
543,
1551,
8,
736,
14,
515,
14,
904,
480,
396,
401,
298,
509,
6153,
401,
298,
10480,
11192,
401,
298,
576,
401,
892,
63,
2324,
395,
298,
87,
531,
465,
289,
26,
355,
870,
4582,
78,
1674,
904,
8,
1278,
395,
570,
29,
70,
9,
267,
943,
14,
815,
480,
1767,
316,
2385,
26,
450,
83,
401,
2385,
9,
267,
372,
2385,
272,
372,
16991,
63,
1065,
63,
5466,
63,
10898,
421,
199,
318,
16991,
63,
739,
63,
888,
837,
272,
408,
272,
18513,
32685,
13,
21761,
323,
367,
17754,
14,
982,
440,
4903,
12,
2295,
1077,
506,
9645,
14,
272,
408,
272,
340,
440,
18133,
5466,
14,
6777,
480,
7608,
13,
21761,
323,
2349,
267,
746,
2882,
14,
25755,
480,
2765,
1379,
5074,
32685,
13,
21761,
323,
367,
17754,
2685,
272,
587,
26,
267,
372,
2420,
32641,
63,
879,
4609,
2594,
63,
9731,
582,
298,
7608,
13,
21761,
323,
3570,
421,
199,
32,
2068,
360,
509,
6153,
14,
888,
14,
739,
63,
888,
297,
16991,
63,
739,
63,
888,
9,
199,
32,
2068,
360,
509,
6153,
14,
10480,
11192,
14,
1238,
14,
331,
30672,
63,
926,
262,
423,
1065,
63,
5466,
63,
10898,
297,
2126,
1683,
63,
1065,
63,
5466,
63,
10898,
8,
856,
5466,
423,
1065,
63,
5466,
63,
10898,
430,
199,
533,
1849,
30672,
5761,
262,
16512,
774,
8,
3249,
4908,
14,
4578,
22595,
304,
272,
347,
1104,
63,
12595,
63,
5707,
12997,
8,
277,
12,
19711,
304,
267,
291,
14,
15070,
8,
552,
8,
513,
8,
12595,
14,
18446,
63,
5778,
22606,
378,
9,
267,
367,
308,
315,
19711,
14,
18446,
63,
5778,
837,
288,
8207,
275,
769,
8,
12595,
14,
6929,
59,
83,
566,
288,
340,
822,
8,
6929,
9,
665,
499,
26,
355,
1980,
953,
3510,
22412,
275,
756,
288,
367,
325,
315,
8207,
26,
355,
340,
325,
59,
16,
61,
1137,
283,
73,
356,
490,
3510,
22412,
275,
715,
953,
340,
3510,
22412,
26,
355,
1980,
953,
291,
14,
3334,
8,
1590,
14,
7520,
8,
12595,
14,
8032,
59,
6929,
59,
16,
22235,
16,
467,
1460,
19711,
14,
8032,
59,
6929,
59,
17,
22235,
16,
2459,
288,
291,
14,
3334,
8,
1590,
14,
7520,
8,
12595,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
wreckJ/intellij-community
|
python/helpers/pydev/pydev_ipython_console.py
|
42
|
2469
|
import sys
from pydev_console_utils import BaseInterpreterInterface
import os
os.environ['TERM'] = 'emacs' #to use proper page_more() for paging
# Uncomment to force PyDev standard shell.
# raise ImportError()
from pydev_ipython_console_011 import get_pydev_frontend
#=======================================================================================================================
# InterpreterInterface
#=======================================================================================================================
class InterpreterInterface(BaseInterpreterInterface):
'''
The methods in this class should be registered in the xml-rpc server.
'''
def __init__(self, host, client_port, mainThread):
BaseInterpreterInterface.__init__(self, mainThread)
self.client_port = client_port
self.host = host
self.interpreter = get_pydev_frontend(host, client_port)
self._input_error_printed = False
self.notification_succeeded = False
self.notification_tries = 0
self.notification_max_tries = 3
self.notify_about_magic()
def get_greeting_msg(self):
return self.interpreter.get_greeting_msg()
def doAddExec(self, codeFragment):
self.notify_about_magic()
if (codeFragment.text.rstrip().endswith('??')):
print('IPython-->')
try:
res = bool(self.interpreter.addExec(codeFragment.text))
finally:
if (codeFragment.text.rstrip().endswith('??')):
print('<--IPython')
return res
def getNamespace(self):
return self.interpreter.getNamespace()
def getCompletions(self, text, act_tok):
return self.interpreter.getCompletions(text, act_tok)
def close(self):
sys.exit(0)
def notify_about_magic(self):
if not self.notification_succeeded:
self.notification_tries+=1
if self.notification_tries>self.notification_max_tries:
return
completions = self.getCompletions("%", "%")
magic_commands = [x[0] for x in completions]
server = self.get_server()
if server is not None:
try:
server.NotifyAboutMagic(magic_commands, self.interpreter.is_automagic())
self.notification_succeeded = True
except :
self.notification_succeeded = False
|
apache-2.0
|
[
646,
984,
199,
504,
29240,
63,
6614,
63,
1208,
492,
3523,
2620,
26499,
4267,
199,
199,
646,
747,
199,
199,
736,
14,
2314,
459,
16718,
418,
275,
283,
69,
19309,
7,
327,
475,
675,
5576,
2034,
63,
6878,
342,
367,
299,
7407,
421,
199,
3,
1910,
3349,
370,
3542,
1611,
12680,
4465,
5218,
14,
199,
3,
746,
3545,
342,
199,
199,
504,
29240,
63,
22691,
63,
6614,
63,
13059,
492,
664,
63,
23996,
63,
18062,
199,
199,
14813,
12813,
18673,
199,
3,
6551,
26499,
4267,
199,
14813,
12813,
18673,
199,
533,
6551,
26499,
4267,
8,
1563,
2620,
26499,
4267,
304,
272,
1449,
267,
710,
3102,
315,
642,
1021,
1077,
506,
7264,
315,
314,
2748,
13,
4354,
1654,
14,
272,
1449,
339,
347,
636,
826,
721,
277,
12,
1591,
12,
1890,
63,
719,
12,
2446,
4436,
304,
267,
3523,
2620,
26499,
4267,
855,
826,
721,
277,
12,
2446,
4436,
9,
267,
291,
14,
1258,
63,
719,
275,
1890,
63,
719,
267,
291,
14,
1102,
275,
1591,
267,
291,
14,
20244,
275,
664,
63,
23996,
63,
18062,
8,
1102,
12,
1890,
63,
719,
9,
267,
291,
423,
1210,
63,
705,
63,
27131,
275,
756,
267,
291,
14,
6761,
63,
20003,
275,
756,
267,
291,
14,
6761,
63,
6264,
275,
378,
267,
291,
14,
6761,
63,
988,
63,
6264,
275,
650,
398,
291,
14,
6814,
63,
10254,
63,
11523,
342,
339,
347,
664,
63,
71,
23457,
63,
1328,
8,
277,
304,
267,
372,
291,
14,
20244,
14,
362,
63,
71,
23457,
63,
1328,
342,
339,
347,
886,
1123,
4858,
8,
277,
12,
1233,
11080,
304,
267,
291,
14,
6814,
63,
10254,
63,
11523,
342,
267,
340,
334,
600,
11080,
14,
505,
14,
6735,
1252,
4130,
360,
10674,
8109,
288,
870,
360,
1772,
11361,
306,
5971,
267,
862,
26,
288,
522,
275,
2155,
8,
277,
14,
20244,
14,
525,
4858,
8,
600,
11080,
14,
505,
430,
267,
3753,
26,
288,
340,
334,
600,
11080,
14,
505,
14,
6735,
1252,
4130,
360,
10674,
8109,
355,
870,
4827,
306,
1772,
11361,
358,
398,
372,
522,
2378,
347,
664,
8814,
8,
277,
304,
267,
372,
291,
14,
20244,
14,
362,
8814,
342,
2378,
347,
664,
6600,
852,
8,
277,
12,
1318,
12,
2454,
63,
9305,
304,
267,
372,
291,
14,
20244,
14,
362,
6600,
852,
8,
505,
12,
2454,
63,
9305,
9,
339,
347,
4002,
8,
277,
304,
267,
984,
14,
2224,
8,
16,
9,
2378,
347,
11705,
63,
10254,
63,
11523,
8,
277,
304,
267,
340,
440,
291,
14,
6761,
63,
20003,
26,
288,
291,
14,
6761,
63,
6264,
10365,
17,
288,
340,
291,
14,
6761,
63,
6264,
30,
277,
14,
6761,
63,
988,
63,
6264,
26,
355,
372,
288,
31516,
275,
291,
14,
362,
6600,
852,
3647,
401,
2071,
531,
288,
10628,
63,
4405,
275,
359,
88,
59,
16,
61,
367,
671,
315,
31516,
61,
953,
1654,
275,
291,
14,
362,
63,
1000,
342,
953,
340,
1654,
365,
440,
488,
26,
355,
862,
26,
490,
1654,
14,
8645,
18816,
45,
6573,
8,
11523,
63,
4405,
12,
291,
14,
20244,
14,
374,
63,
2495,
11523,
1012,
490,
291,
14,
6761,
63,
20003,
275,
715,
355,
871,
520,
490,
291,
14,
6761,
63,
20003,
275,
756,
28154,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
984,
199,
504,
29240,
63,
6614,
63,
1208,
492,
3523,
2620,
26499,
4267,
199,
199,
646,
747,
199,
199,
736,
14,
2314,
459,
16718,
418,
275,
283,
69,
19309,
7,
327,
475,
675,
5576,
2034,
63,
6878,
342,
367,
299,
7407,
421,
199,
3,
1910,
3349,
370,
3542,
1611,
12680,
4465,
5218,
14,
199,
3,
746,
3545,
342,
199,
199,
504,
29240,
63,
22691,
63,
6614,
63,
13059,
492,
664,
63,
23996,
63,
18062,
199,
199,
14813,
12813,
18673,
199,
3,
6551,
26499,
4267,
199,
14813,
12813,
18673,
199,
533,
6551,
26499,
4267,
8,
1563,
2620,
26499,
4267,
304,
272,
1449,
267,
710,
3102,
315,
642,
1021,
1077,
506,
7264,
315,
314,
2748,
13,
4354,
1654,
14,
272,
1449,
339,
347,
636,
826,
721,
277,
12,
1591,
12,
1890,
63,
719,
12,
2446,
4436,
304,
267,
3523,
2620,
26499,
4267,
855,
826,
721,
277,
12,
2446,
4436,
9,
267,
291,
14,
1258,
63,
719,
275,
1890,
63,
719,
267,
291,
14,
1102,
275,
1591,
267,
291,
14,
20244,
275,
664,
63,
23996,
63,
18062,
8,
1102,
12,
1890,
63,
719,
9,
267,
291,
423,
1210,
63,
705,
63,
27131,
275,
756,
267,
291,
14,
6761,
63,
20003,
275,
756,
267,
291,
14,
6761,
63,
6264,
275,
378,
267,
291,
14,
6761,
63,
988,
63,
6264,
275,
650,
398,
291,
14,
6814,
63,
10254,
63,
11523,
342,
339,
347,
664,
63,
71,
23457,
63,
1328,
8,
277,
304,
267,
372,
291,
14,
20244,
14,
362,
63,
71,
23457,
63,
1328,
342,
339,
347,
886,
1123,
4858,
8,
277,
12,
1233,
11080,
304,
267,
291,
14,
6814,
63,
10254,
63,
11523,
342,
267,
340,
334,
600,
11080,
14,
505,
14,
6735,
1252,
4130,
360,
10674,
8109,
288,
870,
360,
1772,
11361,
306,
5971,
267,
862,
26,
288,
522,
275,
2155,
8,
277,
14,
20244,
14,
525,
4858,
8,
600,
11080,
14,
505,
430,
267,
3753,
26,
288,
340,
334,
600,
11080,
14,
505,
14,
6735,
1252,
4130,
360,
10674,
8109,
355,
870,
4827,
306,
1772,
11361,
358,
398,
372,
522,
2378,
347,
664,
8814,
8,
277,
304,
267,
372,
291,
14,
20244,
14,
362,
8814,
342,
2378,
347,
664,
6600,
852,
8,
277,
12,
1318,
12,
2454,
63,
9305,
304,
267,
372,
291,
14,
20244,
14,
362,
6600,
852,
8,
505,
12,
2454,
63,
9305,
9,
339,
347,
4002,
8,
277,
304,
267,
984,
14,
2224,
8,
16,
9,
2378,
347,
11705,
63,
10254,
63,
11523,
8,
277,
304,
267,
340,
440,
291,
14,
6761,
63,
20003,
26,
288,
291,
14,
6761,
63,
6264,
10365,
17,
288,
340,
291,
14,
6761,
63,
6264,
30,
277,
14,
6761,
63,
988,
63,
6264,
26,
355,
372,
288,
31516,
275,
291,
14,
362,
6600,
852,
3647,
401,
2071,
531,
288,
10628,
63,
4405,
275,
359,
88,
59,
16,
61,
367,
671,
315,
31516,
61,
953,
1654,
275,
291,
14,
362,
63,
1000,
342,
953,
340,
1654,
365,
440,
488,
26,
355,
862,
26,
490,
1654,
14,
8645,
18816,
45,
6573,
8,
11523,
63,
4405,
12,
291,
14,
20244,
14,
374,
63,
2495,
11523,
1012,
490,
291,
14,
6761,
63,
20003,
275,
715,
355,
871,
520,
490,
291,
14,
6761,
63,
20003,
275,
756,
28154,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
neerajvashistha/pa-dude
|
lib/python2.7/site-packages/_pytest/recwarn.py
|
178
|
7203
|
""" recording warnings during test function execution. """
import inspect
import _pytest._code
import py
import sys
import warnings
import pytest
@pytest.yield_fixture
def recwarn(request):
"""Return a WarningsRecorder instance that provides these methods:
* ``pop(category=None)``: return last warning matching the category.
* ``clear()``: clear list of warnings
See http://docs.python.org/library/warnings.html for information
on warning categories.
"""
wrec = WarningsRecorder()
with wrec:
warnings.simplefilter('default')
yield wrec
def pytest_namespace():
return {'deprecated_call': deprecated_call,
'warns': warns}
def deprecated_call(func=None, *args, **kwargs):
""" assert that calling ``func(*args, **kwargs)`` triggers a
``DeprecationWarning`` or ``PendingDeprecationWarning``.
This function can be used as a context manager::
>>> with deprecated_call():
... myobject.deprecated_method()
Note: we cannot use WarningsRecorder here because it is still subject
to the mechanism that prevents warnings of the same type from being
triggered twice for the same module. See #1190.
"""
if not func:
return WarningsChecker(expected_warning=DeprecationWarning)
categories = []
def warn_explicit(message, category, *args, **kwargs):
categories.append(category)
old_warn_explicit(message, category, *args, **kwargs)
def warn(message, category=None, *args, **kwargs):
if isinstance(message, Warning):
categories.append(message.__class__)
else:
categories.append(category)
old_warn(message, category, *args, **kwargs)
old_warn = warnings.warn
old_warn_explicit = warnings.warn_explicit
warnings.warn_explicit = warn_explicit
warnings.warn = warn
try:
ret = func(*args, **kwargs)
finally:
warnings.warn_explicit = old_warn_explicit
warnings.warn = old_warn
deprecation_categories = (DeprecationWarning, PendingDeprecationWarning)
if not any(issubclass(c, deprecation_categories) for c in categories):
__tracebackhide__ = True
raise AssertionError("%r did not produce DeprecationWarning" % (func,))
return ret
def warns(expected_warning, *args, **kwargs):
"""Assert that code raises a particular class of warning.
Specifically, the input @expected_warning can be a warning class or
tuple of warning classes, and the code must return that warning
(if a single class) or one of those warnings (if a tuple).
This helper produces a list of ``warnings.WarningMessage`` objects,
one for each warning raised.
This function can be used as a context manager, or any of the other ways
``pytest.raises`` can be used::
>>> with warns(RuntimeWarning):
... warnings.warn("my warning", RuntimeWarning)
"""
wcheck = WarningsChecker(expected_warning)
if not args:
return wcheck
elif isinstance(args[0], str):
code, = args
assert isinstance(code, str)
frame = sys._getframe(1)
loc = frame.f_locals.copy()
loc.update(kwargs)
with wcheck:
code = _pytest._code.Source(code).compile()
py.builtin.exec_(code, frame.f_globals, loc)
else:
func = args[0]
with wcheck:
return func(*args[1:], **kwargs)
class RecordedWarning(object):
def __init__(self, message, category, filename, lineno, file, line):
self.message = message
self.category = category
self.filename = filename
self.lineno = lineno
self.file = file
self.line = line
class WarningsRecorder(object):
"""A context manager to record raised warnings.
Adapted from `warnings.catch_warnings`.
"""
def __init__(self, module=None):
self._module = sys.modules['warnings'] if module is None else module
self._entered = False
self._list = []
@property
def list(self):
"""The list of recorded warnings."""
return self._list
def __getitem__(self, i):
"""Get a recorded warning by index."""
return self._list[i]
def __iter__(self):
"""Iterate through the recorded warnings."""
return iter(self._list)
def __len__(self):
"""The number of recorded warnings."""
return len(self._list)
def pop(self, cls=Warning):
"""Pop the first recorded warning, raise exception if not exists."""
for i, w in enumerate(self._list):
if issubclass(w.category, cls):
return self._list.pop(i)
__tracebackhide__ = True
raise AssertionError("%r not found in warning list" % cls)
def clear(self):
"""Clear the list of recorded warnings."""
self._list[:] = []
def __enter__(self):
if self._entered:
__tracebackhide__ = True
raise RuntimeError("Cannot enter %r twice" % self)
self._entered = True
self._filters = self._module.filters
self._module.filters = self._filters[:]
self._showwarning = self._module.showwarning
def showwarning(message, category, filename, lineno,
file=None, line=None):
self._list.append(RecordedWarning(
message, category, filename, lineno, file, line))
# still perform old showwarning functionality
self._showwarning(
message, category, filename, lineno, file=file, line=line)
self._module.showwarning = showwarning
# allow the same warning to be raised more than once
self._module.simplefilter('always')
return self
def __exit__(self, *exc_info):
if not self._entered:
__tracebackhide__ = True
raise RuntimeError("Cannot exit %r without entering first" % self)
self._module.filters = self._filters
self._module.showwarning = self._showwarning
class WarningsChecker(WarningsRecorder):
def __init__(self, expected_warning=None, module=None):
super(WarningsChecker, self).__init__(module=module)
msg = ("exceptions must be old-style classes or "
"derived from Warning, not %s")
if isinstance(expected_warning, tuple):
for exc in expected_warning:
if not inspect.isclass(exc):
raise TypeError(msg % type(exc))
elif inspect.isclass(expected_warning):
expected_warning = (expected_warning,)
elif expected_warning is not None:
raise TypeError(msg % type(expected_warning))
self.expected_warning = expected_warning
def __exit__(self, *exc_info):
super(WarningsChecker, self).__exit__(*exc_info)
# only check if we're not currently handling an exception
if all(a is None for a in exc_info):
if self.expected_warning is not None:
if not any(r.category in self.expected_warning for r in self):
__tracebackhide__ = True
pytest.fail("DID NOT WARN")
|
mit
|
[
624,
20952,
3598,
5309,
511,
805,
6451,
14,
408,
199,
199,
646,
6485,
199,
199,
646,
485,
4462,
423,
600,
199,
646,
1134,
199,
646,
984,
199,
646,
3598,
199,
646,
4613,
421,
199,
32,
4462,
14,
11481,
63,
5997,
199,
318,
6488,
4050,
8,
1069,
304,
272,
408,
1767,
282,
644,
2627,
497,
16940,
1256,
626,
6571,
3520,
3102,
26,
339,
627,
1124,
1935,
8,
3710,
29,
403,
9719,
26,
372,
2061,
5721,
4877,
314,
4637,
14,
272,
627,
1124,
3584,
8497,
26,
5436,
769,
402,
3598,
339,
1666,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
5451,
14,
1360,
367,
2556,
272,
641,
5721,
9695,
14,
272,
408,
272,
336,
2761,
275,
644,
2627,
497,
16940,
342,
272,
543,
336,
2761,
26,
267,
3598,
14,
18815,
360,
885,
358,
267,
1995,
336,
2761,
421,
199,
318,
4613,
63,
3251,
837,
272,
372,
791,
6667,
63,
1250,
356,
5906,
63,
1250,
12,
288,
283,
19811,
356,
3429,
561,
93,
421,
199,
318,
5906,
63,
1250,
8,
1532,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
702,
626,
6358,
1124,
1532,
2031,
589,
12,
1011,
958,
9719,
18899,
282,
272,
1124,
15561,
1040,
503,
1124,
15960,
15561,
4345,
339,
961,
805,
883,
506,
1202,
465,
282,
1067,
5256,
447,
398,
1306,
543,
5906,
63,
1250,
837,
267,
2263,
259,
3002,
785,
14,
6667,
63,
765,
342,
339,
3390,
26,
781,
3913,
675,
644,
2627,
497,
16940,
2348,
2952,
652,
365,
5139,
5420,
272,
370,
314,
14729,
626,
21925,
3598,
402,
314,
2011,
730,
687,
3769,
272,
15572,
13373,
367,
314,
2011,
859,
14,
1666,
327,
845,
2710,
14,
272,
408,
272,
340,
440,
2562,
26,
267,
372,
644,
2627,
3048,
8,
2062,
63,
3764,
29,
15561,
9,
339,
9695,
275,
942,
339,
347,
7987,
63,
10306,
8,
1188,
12,
4637,
12,
627,
589,
12,
1011,
958,
304,
267,
9695,
14,
740,
8,
3710,
9,
267,
2269,
63,
4050,
63,
10306,
8,
1188,
12,
4637,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
7987,
8,
1188,
12,
4637,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
1228,
8,
1188,
12,
15902,
304,
288,
9695,
14,
740,
8,
1188,
855,
533,
3368,
267,
587,
26,
288,
9695,
14,
740,
8,
3710,
9,
267,
2269,
63,
4050,
8,
1188,
12,
4637,
12,
627,
589,
12,
1011,
958,
9,
339,
2269,
63,
4050,
275,
3598,
14,
4050,
272,
2269,
63,
4050,
63,
10306,
275,
3598,
14,
4050,
63,
10306,
272,
3598,
14,
4050,
63,
10306,
275,
7987,
63,
10306,
272,
3598,
14,
4050,
275,
7987,
272,
862,
26,
267,
2203,
275,
2562,
2031,
589,
12,
1011,
958,
9,
272,
3753,
26,
267,
3598,
14,
4050,
63,
10306,
275,
2269,
63,
4050,
63,
10306,
267,
3598,
14,
4050,
275,
2269,
63,
4050,
272,
17831,
63,
8906,
275,
334,
15561,
12,
29216,
15561,
9,
272,
340,
440,
1263,
8,
20179,
8,
67,
12,
17831,
63,
8906,
9,
367,
286,
315,
9695,
304,
267,
636,
6894,
8191,
363,
275,
715,
267,
746,
9070,
3647,
82,
8103,
440,
7389,
13413,
2,
450,
334,
1532,
4641,
272,
372,
2203,
421,
199,
318,
3429,
561,
8,
2062,
63,
3764,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
9699,
626,
1233,
6534,
282,
6770,
1021,
402,
5721,
14,
339,
30836,
12,
314,
1324,
768,
2062,
63,
3764,
883,
506,
282,
5721,
1021,
503,
272,
2008,
402,
5721,
3992,
12,
436,
314,
1233,
1471,
372,
626,
5721,
272,
334,
692,
282,
2849,
1021,
9,
503,
1373,
402,
5204,
3598,
334,
692,
282,
2008,
680,
339,
961,
5922,
16904,
282,
769,
402,
1124,
5451,
14,
3849,
2209,
1040,
2251,
12,
272,
1373,
367,
1924,
5721,
4915,
14,
339,
961,
805,
883,
506,
1202,
465,
282,
1067,
5256,
12,
503,
1263,
402,
314,
1163,
15217,
272,
1124,
4462,
14,
3536,
1040,
883,
506,
1202,
447,
398,
1306,
543,
3429,
561,
8,
14357,
3849,
304,
267,
2263,
259,
3598,
14,
4050,
480,
1662,
5721,
401,
25178,
9,
272,
408,
272,
336,
1074,
275,
644,
2627,
3048,
8,
2062,
63,
3764,
9,
272,
340,
440,
1249,
26,
267,
372,
336,
1074,
272,
916,
1228,
8,
589,
59,
16,
467,
620,
304,
267,
1233,
12,
275,
1249,
267,
702,
1228,
8,
600,
12,
620,
9,
267,
2787,
275,
984,
423,
20912,
8,
17,
9,
267,
4355,
275,
2787,
14,
70,
63,
9350,
14,
1574,
342,
267,
4355,
14,
873,
8,
958,
9,
398,
543,
336,
1074,
26,
288,
1233,
275,
485,
4462,
423,
600,
14,
2980,
8,
600,
680,
2014,
342,
288,
1134,
14,
5351,
14,
1628,
2531,
600,
12,
2787,
14,
70,
63,
8473,
12,
4355,
9,
272,
587,
26,
267,
2562,
275,
1249,
59,
16,
61,
267,
543,
336,
1074,
26,
288,
372,
2562,
2031,
589,
59,
17,
8429,
1011,
958,
9,
421,
199,
533,
799,
15402,
3849,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1245,
12,
4637,
12,
1788,
12,
5874,
12,
570,
12,
1004,
304,
267,
291,
14,
1188,
275,
1245,
267,
291,
14,
3710,
275,
4637,
267,
291,
14,
1501,
275,
1788,
267,
291,
14,
3469,
275,
5874,
267,
291,
14,
493,
275,
570,
267,
291,
14,
604,
275,
1004,
421,
199,
533,
644,
2627,
497,
16940,
8,
785,
304,
272,
408,
33,
1067,
5256,
370,
2777,
4915,
3598,
14,
339,
4431,
18309,
687,
658,
5451,
14,
9341,
63,
5451,
2313,
272,
408,
339,
347,
636,
826,
721,
277,
12,
859,
29,
403,
304,
267,
291,
423,
578,
275,
984,
14,
3112,
459,
5451,
418,
340,
859,
365,
488,
587,
859,
267,
291,
423,
287,
3014,
275,
756,
267,
291,
423,
513,
275,
942,
339,
768,
1829,
272,
347,
769,
8,
277,
304,
267,
408,
1918,
769,
402,
18894,
3598,
1041,
267,
372,
291,
423,
513,
339,
347,
636,
6095,
721,
277,
12,
284,
304,
267,
408,
1002,
282,
18894,
5721,
701,
1478,
1041,
267,
372,
291,
423,
513,
59,
73,
61,
339,
347,
636,
1661,
721,
277,
304,
267,
408,
3315,
323,
4012,
314,
18894,
3598,
1041,
267,
372,
2740,
8,
277,
423,
513,
9,
339,
347,
636,
552,
721,
277,
304,
267,
408,
1918,
1329,
402,
18894,
3598,
1041,
267,
372
] |
[
20952,
3598,
5309,
511,
805,
6451,
14,
408,
199,
199,
646,
6485,
199,
199,
646,
485,
4462,
423,
600,
199,
646,
1134,
199,
646,
984,
199,
646,
3598,
199,
646,
4613,
421,
199,
32,
4462,
14,
11481,
63,
5997,
199,
318,
6488,
4050,
8,
1069,
304,
272,
408,
1767,
282,
644,
2627,
497,
16940,
1256,
626,
6571,
3520,
3102,
26,
339,
627,
1124,
1935,
8,
3710,
29,
403,
9719,
26,
372,
2061,
5721,
4877,
314,
4637,
14,
272,
627,
1124,
3584,
8497,
26,
5436,
769,
402,
3598,
339,
1666,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
5451,
14,
1360,
367,
2556,
272,
641,
5721,
9695,
14,
272,
408,
272,
336,
2761,
275,
644,
2627,
497,
16940,
342,
272,
543,
336,
2761,
26,
267,
3598,
14,
18815,
360,
885,
358,
267,
1995,
336,
2761,
421,
199,
318,
4613,
63,
3251,
837,
272,
372,
791,
6667,
63,
1250,
356,
5906,
63,
1250,
12,
288,
283,
19811,
356,
3429,
561,
93,
421,
199,
318,
5906,
63,
1250,
8,
1532,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
702,
626,
6358,
1124,
1532,
2031,
589,
12,
1011,
958,
9719,
18899,
282,
272,
1124,
15561,
1040,
503,
1124,
15960,
15561,
4345,
339,
961,
805,
883,
506,
1202,
465,
282,
1067,
5256,
447,
398,
1306,
543,
5906,
63,
1250,
837,
267,
2263,
259,
3002,
785,
14,
6667,
63,
765,
342,
339,
3390,
26,
781,
3913,
675,
644,
2627,
497,
16940,
2348,
2952,
652,
365,
5139,
5420,
272,
370,
314,
14729,
626,
21925,
3598,
402,
314,
2011,
730,
687,
3769,
272,
15572,
13373,
367,
314,
2011,
859,
14,
1666,
327,
845,
2710,
14,
272,
408,
272,
340,
440,
2562,
26,
267,
372,
644,
2627,
3048,
8,
2062,
63,
3764,
29,
15561,
9,
339,
9695,
275,
942,
339,
347,
7987,
63,
10306,
8,
1188,
12,
4637,
12,
627,
589,
12,
1011,
958,
304,
267,
9695,
14,
740,
8,
3710,
9,
267,
2269,
63,
4050,
63,
10306,
8,
1188,
12,
4637,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
7987,
8,
1188,
12,
4637,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
1228,
8,
1188,
12,
15902,
304,
288,
9695,
14,
740,
8,
1188,
855,
533,
3368,
267,
587,
26,
288,
9695,
14,
740,
8,
3710,
9,
267,
2269,
63,
4050,
8,
1188,
12,
4637,
12,
627,
589,
12,
1011,
958,
9,
339,
2269,
63,
4050,
275,
3598,
14,
4050,
272,
2269,
63,
4050,
63,
10306,
275,
3598,
14,
4050,
63,
10306,
272,
3598,
14,
4050,
63,
10306,
275,
7987,
63,
10306,
272,
3598,
14,
4050,
275,
7987,
272,
862,
26,
267,
2203,
275,
2562,
2031,
589,
12,
1011,
958,
9,
272,
3753,
26,
267,
3598,
14,
4050,
63,
10306,
275,
2269,
63,
4050,
63,
10306,
267,
3598,
14,
4050,
275,
2269,
63,
4050,
272,
17831,
63,
8906,
275,
334,
15561,
12,
29216,
15561,
9,
272,
340,
440,
1263,
8,
20179,
8,
67,
12,
17831,
63,
8906,
9,
367,
286,
315,
9695,
304,
267,
636,
6894,
8191,
363,
275,
715,
267,
746,
9070,
3647,
82,
8103,
440,
7389,
13413,
2,
450,
334,
1532,
4641,
272,
372,
2203,
421,
199,
318,
3429,
561,
8,
2062,
63,
3764,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
9699,
626,
1233,
6534,
282,
6770,
1021,
402,
5721,
14,
339,
30836,
12,
314,
1324,
768,
2062,
63,
3764,
883,
506,
282,
5721,
1021,
503,
272,
2008,
402,
5721,
3992,
12,
436,
314,
1233,
1471,
372,
626,
5721,
272,
334,
692,
282,
2849,
1021,
9,
503,
1373,
402,
5204,
3598,
334,
692,
282,
2008,
680,
339,
961,
5922,
16904,
282,
769,
402,
1124,
5451,
14,
3849,
2209,
1040,
2251,
12,
272,
1373,
367,
1924,
5721,
4915,
14,
339,
961,
805,
883,
506,
1202,
465,
282,
1067,
5256,
12,
503,
1263,
402,
314,
1163,
15217,
272,
1124,
4462,
14,
3536,
1040,
883,
506,
1202,
447,
398,
1306,
543,
3429,
561,
8,
14357,
3849,
304,
267,
2263,
259,
3598,
14,
4050,
480,
1662,
5721,
401,
25178,
9,
272,
408,
272,
336,
1074,
275,
644,
2627,
3048,
8,
2062,
63,
3764,
9,
272,
340,
440,
1249,
26,
267,
372,
336,
1074,
272,
916,
1228,
8,
589,
59,
16,
467,
620,
304,
267,
1233,
12,
275,
1249,
267,
702,
1228,
8,
600,
12,
620,
9,
267,
2787,
275,
984,
423,
20912,
8,
17,
9,
267,
4355,
275,
2787,
14,
70,
63,
9350,
14,
1574,
342,
267,
4355,
14,
873,
8,
958,
9,
398,
543,
336,
1074,
26,
288,
1233,
275,
485,
4462,
423,
600,
14,
2980,
8,
600,
680,
2014,
342,
288,
1134,
14,
5351,
14,
1628,
2531,
600,
12,
2787,
14,
70,
63,
8473,
12,
4355,
9,
272,
587,
26,
267,
2562,
275,
1249,
59,
16,
61,
267,
543,
336,
1074,
26,
288,
372,
2562,
2031,
589,
59,
17,
8429,
1011,
958,
9,
421,
199,
533,
799,
15402,
3849,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1245,
12,
4637,
12,
1788,
12,
5874,
12,
570,
12,
1004,
304,
267,
291,
14,
1188,
275,
1245,
267,
291,
14,
3710,
275,
4637,
267,
291,
14,
1501,
275,
1788,
267,
291,
14,
3469,
275,
5874,
267,
291,
14,
493,
275,
570,
267,
291,
14,
604,
275,
1004,
421,
199,
533,
644,
2627,
497,
16940,
8,
785,
304,
272,
408,
33,
1067,
5256,
370,
2777,
4915,
3598,
14,
339,
4431,
18309,
687,
658,
5451,
14,
9341,
63,
5451,
2313,
272,
408,
339,
347,
636,
826,
721,
277,
12,
859,
29,
403,
304,
267,
291,
423,
578,
275,
984,
14,
3112,
459,
5451,
418,
340,
859,
365,
488,
587,
859,
267,
291,
423,
287,
3014,
275,
756,
267,
291,
423,
513,
275,
942,
339,
768,
1829,
272,
347,
769,
8,
277,
304,
267,
408,
1918,
769,
402,
18894,
3598,
1041,
267,
372,
291,
423,
513,
339,
347,
636,
6095,
721,
277,
12,
284,
304,
267,
408,
1002,
282,
18894,
5721,
701,
1478,
1041,
267,
372,
291,
423,
513,
59,
73,
61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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
] |
0x46616c6b/ansible
|
lib/ansible/modules/cloud/amazon/ecs_task.py
|
25
|
11904
|
#!/usr/bin/python
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
DOCUMENTATION = '''
---
module: ecs_task
short_description: run, start or stop a task in ecs
description:
- Creates or deletes instances of task definitions.
version_added: "2.0"
author: Mark Chance(@Java1Guy)
requirements: [ json, boto, botocore, boto3 ]
options:
operation:
description:
- Which task operation to execute
required: True
choices: ['run', 'start', 'stop']
cluster:
description:
- The name of the cluster to run the task on
required: False
task_definition:
description:
- The task definition to start or run
required: False
overrides:
description:
- A dictionary of values to pass to the new instances
required: False
count:
description:
- How many new instances to start
required: False
task:
description:
- The task to stop
required: False
container_instances:
description:
- The list of container instances on which to deploy the task
required: False
started_by:
description:
- A value showing who or what started the task (for informational purposes)
required: False
extends_documentation_fragment:
- aws
- ec2
'''
EXAMPLES = '''
# Simple example of run task
- name: Run task
ecs_task:
operation: run
cluster: console-sample-app-static-cluster
task_definition: console-sample-app-static-taskdef
count: 1
started_by: ansible_user
register: task_output
# Simple example of start task
- name: Start a task
ecs_task:
operation: start
cluster: console-sample-app-static-cluster
task_definition: console-sample-app-static-taskdef
task: "arn:aws:ecs:us-west-2:172139249013:task/3f8353d1-29a8-4689-bbf6-ad79937ffe8a"
container_instances:
- arn:aws:ecs:us-west-2:172139249013:container-instance/79c23f22-876c-438a-bddf-55c98a3538a8
started_by: ansible_user
register: task_output
- name: Stop a task
ecs_task:
operation: stop
cluster: console-sample-app-static-cluster
task_definition: console-sample-app-static-taskdef
task: "arn:aws:ecs:us-west-2:172139249013:task/3f8353d1-29a8-4689-bbf6-ad79937ffe8a"
'''
RETURN = '''
task:
description: details about the tast that was started
returned: success
type: complex
contains:
taskArn:
description: The Amazon Resource Name (ARN) that identifies the task.
returned: always
type: string
clusterArn:
description: The Amazon Resource Name (ARN) of the of the cluster that hosts the task.
returned: only when details is true
type: string
taskDefinitionArn:
description: The Amazon Resource Name (ARN) of the task definition.
returned: only when details is true
type: string
containerInstanceArn:
description: The Amazon Resource Name (ARN) of the container running the task.
returned: only when details is true
type: string
overrides:
description: The container overrides set for this task.
returned: only when details is true
type: list of complex
lastStatus:
description: The last recorded status of the task.
returned: only when details is true
type: string
desiredStatus:
description: The desired status of the task.
returned: only when details is true
type: string
containers:
description: The container details.
returned: only when details is true
type: list of complex
startedBy:
description: The used who started the task.
returned: only when details is true
type: string
stoppedReason:
description: The reason why the task was stopped.
returned: only when details is true
type: string
createdAt:
description: The timestamp of when the task was created.
returned: only when details is true
type: string
startedAt:
description: The timestamp of when the task was started.
returned: only when details is true
type: string
stoppedAt:
description: The timestamp of when the task was stopped.
returned: only when details is true
type: string
'''
try:
import boto
import botocore
HAS_BOTO = True
except ImportError:
HAS_BOTO = False
try:
import boto3
HAS_BOTO3 = True
except ImportError:
HAS_BOTO3 = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
class EcsExecManager:
"""Handles ECS Tasks"""
def __init__(self, module):
self.module = module
try:
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
if not region:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
except boto.exception.NoAuthHandlerFound as e:
module.fail_json(msg="Can't authorize connection - %s " % str(e))
def list_tasks(self, cluster_name, service_name, status):
response = self.ecs.list_tasks(
cluster=cluster_name,
family=service_name,
desiredStatus=status
)
if len(response['taskArns'])>0:
for c in response['taskArns']:
if c.endswith(service_name):
return c
return None
def run_task(self, cluster, task_definition, overrides, count, startedBy):
if overrides is None:
overrides = dict()
response = self.ecs.run_task(
cluster=cluster,
taskDefinition=task_definition,
overrides=overrides,
count=count,
startedBy=startedBy)
# include tasks and failures
return response['tasks']
def start_task(self, cluster, task_definition, overrides, container_instances, startedBy):
args = dict()
if cluster:
args['cluster'] = cluster
if task_definition:
args['taskDefinition']=task_definition
if overrides:
args['overrides']=overrides
if container_instances:
args['containerInstances']=container_instances
if startedBy:
args['startedBy']=startedBy
response = self.ecs.start_task(**args)
# include tasks and failures
return response['tasks']
def stop_task(self, cluster, task):
response = self.ecs.stop_task(cluster=cluster, task=task)
return response['task']
def main():
argument_spec = ec2_argument_spec()
argument_spec.update(dict(
operation=dict(required=True, choices=['run', 'start', 'stop'] ),
cluster=dict(required=False, type='str' ), # R S P
task_definition=dict(required=False, type='str' ), # R* S*
overrides=dict(required=False, type='dict'), # R S
count=dict(required=False, type='int' ), # R
task=dict(required=False, type='str' ), # P*
container_instances=dict(required=False, type='list'), # S*
started_by=dict(required=False, type='str' ) # R S
))
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
# Validate Requirements
if not HAS_BOTO:
module.fail_json(msg='boto is required.')
if not HAS_BOTO3:
module.fail_json(msg='boto3 is required.')
# Validate Inputs
if module.params['operation'] == 'run':
if not 'task_definition' in module.params and module.params['task_definition'] is None:
module.fail_json(msg="To run a task, a task_definition must be specified")
task_to_list = module.params['task_definition']
status_type = "RUNNING"
if module.params['operation'] == 'start':
if not 'task_definition' in module.params and module.params['task_definition'] is None:
module.fail_json(msg="To start a task, a task_definition must be specified")
if not 'container_instances' in module.params and module.params['container_instances'] is None:
module.fail_json(msg="To start a task, container instances must be specified")
task_to_list = module.params['task']
status_type = "RUNNING"
if module.params['operation'] == 'stop':
if not 'task' in module.params and module.params['task'] is None:
module.fail_json(msg="To stop a task, a task must be specified")
if not 'task_definition' in module.params and module.params['task_definition'] is None:
module.fail_json(msg="To stop a task, a task definition must be specified")
task_to_list = module.params['task_definition']
status_type = "STOPPED"
service_mgr = EcsExecManager(module)
existing = service_mgr.list_tasks(module.params['cluster'], task_to_list, status_type)
results = dict(changed=False)
if module.params['operation'] == 'run':
if existing:
# TBD - validate the rest of the details
results['task']=existing
else:
if not module.check_mode:
results['task'] = service_mgr.run_task(
module.params['cluster'],
module.params['task_definition'],
module.params['overrides'],
module.params['count'],
module.params['started_by'])
results['changed'] = True
elif module.params['operation'] == 'start':
if existing:
# TBD - validate the rest of the details
results['task']=existing
else:
if not module.check_mode:
results['task'] = service_mgr.start_task(
module.params['cluster'],
module.params['task_definition'],
module.params['overrides'],
module.params['container_instances'],
module.params['started_by']
)
results['changed'] = True
elif module.params['operation'] == 'stop':
if existing:
results['task']=existing
else:
if not module.check_mode:
# it exists, so we should delete it and mark changed.
# return info about the cluster deleted
results['task'] = service_mgr.stop_task(
module.params['cluster'],
module.params['task']
)
results['changed'] = True
module.exit_json(**results)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
8490,
63,
8314,
275,
791,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
297,
490,
283,
1023,
356,
283,
17,
14,
16,
936,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
325,
1259,
63,
1765,
199,
3612,
63,
1802,
26,
1255,
12,
1343,
503,
3631,
282,
2120,
315,
325,
1259,
199,
1802,
26,
272,
446,
10560,
503,
21812,
4454,
402,
2120,
10269,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
2502,
26,
7173,
2799,
554,
8,
32,
12576,
17,
11548,
89,
9,
199,
7538,
26,
359,
2022,
12,
6055,
12,
21199,
12,
6055,
19,
1622,
199,
1419,
26,
272,
3439,
26,
267,
1369,
26,
288,
446,
26058,
2120,
3439,
370,
5341,
267,
1415,
26,
715,
267,
3415,
26,
788,
1065,
297,
283,
928,
297,
283,
2379,
418,
272,
4350,
26,
267,
1369,
26,
288,
446,
710,
536,
402,
314,
4350,
370,
1255,
314,
2120,
641,
267,
1415,
26,
756,
272,
2120,
63,
7463,
26,
267,
1369,
26,
288,
446,
710,
2120,
5492,
370,
1343,
503,
1255,
267,
1415,
26,
756,
272,
10580,
26,
267,
1369,
26,
288,
446,
437,
2600,
402,
1338,
370,
986,
370,
314,
892,
4454,
267,
1415,
26,
756,
272,
2338,
26,
267,
1369,
26,
288,
446,
7494,
5002,
892,
4454,
370,
1343,
267,
1415,
26,
756,
272,
2120,
26,
267,
1369,
26,
288,
446,
710,
2120,
370,
3631,
267,
1415,
26,
756,
272,
3970,
63,
5990,
26,
267,
1369,
26,
288,
446,
710,
769,
402,
3970,
4454,
641,
1314,
370,
12287,
314,
2120,
267,
1415,
26,
756,
272,
8239,
63,
991,
26,
267,
1369,
26,
288,
446,
437,
574,
21207,
3963,
503,
4052,
8239,
314,
2120,
334,
509,
2556,
279,
12901,
9,
267,
1415,
26,
756,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
11488,
272,
446,
7062,
18,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5870,
2893,
402,
1255,
2120,
199,
13,
536,
26,
3378,
2120,
523,
325,
1259,
63,
1765,
26,
272,
3439,
26,
1255,
272,
4350,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
4201,
272,
2120,
63,
7463,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
1765,
318,
272,
2338,
26,
413,
272,
8239,
63,
991,
26,
3242,
63,
751,
523,
2274,
26,
2120,
63,
1199,
199,
199,
3,
5870,
2893,
402,
1343,
2120,
199,
199,
13,
536,
26,
7707,
282,
2120,
523,
325,
1259,
63,
1765,
26,
489,
3439,
26,
1343,
489,
4350,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
4201,
489,
2120,
63,
7463,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
1765,
318,
489,
2120,
26,
298,
1060,
26,
7231,
26,
23075,
26,
527,
13,
19082,
13,
18,
26,
10419,
7491,
11032,
13264,
26,
1765,
15,
19,
70,
24,
15355,
68,
17,
13,
1398,
65,
24,
13,
2466,
1407,
13,
31319,
22,
13,
350,
31486,
1401,
2026,
24,
65,
2,
489,
3970,
63,
5990,
26,
489,
446,
601,
78,
26,
7231,
26,
23075,
26,
527,
13,
19082,
13,
18,
26,
10419,
7491,
11032,
13264,
26,
3600,
13,
842,
15,
1965,
67,
1789,
70,
1081,
13,
14690,
67,
13,
31352,
65,
13,
26293,
70,
13,
1229,
67,
2905,
65,
1276,
1703,
65,
24,
489,
8239,
63,
991,
26,
3242,
63,
751,
523,
2274,
26,
2120,
63,
1199,
199,
199,
13,
536,
26,
8015,
282,
2120,
523,
325,
1259,
63,
1765,
26,
489,
3439,
26,
3631,
489,
4350,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
4201,
489,
2120,
63,
7463,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
1765,
318,
489,
2120,
26,
298,
1060,
26,
7231,
26,
23075,
26,
527,
13,
19082,
13,
18,
26,
10419,
7491,
11032,
13264,
26,
1765,
15,
19,
70,
24,
15355,
68,
17,
13,
1398,
65,
24,
13,
2466,
1407,
13,
31319,
22,
13,
350,
31486,
1401,
2026,
24,
65,
2,
199,
2344,
199,
9677,
275,
1449,
199,
1765,
26,
272,
1369,
26,
2436,
3595,
314,
307,
1810,
626,
1990,
8239,
272,
2138,
26,
3182,
272,
730,
26,
6114,
272,
3509,
26,
267,
2120,
20498,
26,
288,
1369,
26,
710,
14347,
7337,
2812,
334,
26513,
9,
626,
22975,
314,
2120,
14,
288,
2138,
26,
3544,
288,
730,
26,
1059,
267,
4350,
20498,
26,
288,
1369,
26,
710,
14347,
7337,
2812,
334,
26513,
9,
402,
314,
402,
314,
4350,
626,
7057,
314,
2120,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
1059,
267,
2120,
10701,
20498,
26,
288,
1369,
26,
710,
14347,
7337,
2812,
334,
26513,
9,
402,
314,
2120,
5492,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
1059,
267,
3970,
3244,
20498,
26,
288,
1369,
26,
710,
14347,
7337,
2812,
334,
26513,
9,
402,
314,
3970,
3879,
314,
2120,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
1059,
267,
10580,
26,
288,
1369,
26,
710,
3970,
10580,
663,
367,
642,
2120,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
769,
402,
6114,
267,
2061,
3694,
26,
288,
1369,
26,
710,
2061,
18894,
2004,
402,
314,
2120,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
1059,
267,
6387,
3694,
26,
288,
1369,
26
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
8490,
63,
8314,
275,
791,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
297,
490,
283,
1023,
356,
283,
17,
14,
16,
936,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
325,
1259,
63,
1765,
199,
3612,
63,
1802,
26,
1255,
12,
1343,
503,
3631,
282,
2120,
315,
325,
1259,
199,
1802,
26,
272,
446,
10560,
503,
21812,
4454,
402,
2120,
10269,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
2502,
26,
7173,
2799,
554,
8,
32,
12576,
17,
11548,
89,
9,
199,
7538,
26,
359,
2022,
12,
6055,
12,
21199,
12,
6055,
19,
1622,
199,
1419,
26,
272,
3439,
26,
267,
1369,
26,
288,
446,
26058,
2120,
3439,
370,
5341,
267,
1415,
26,
715,
267,
3415,
26,
788,
1065,
297,
283,
928,
297,
283,
2379,
418,
272,
4350,
26,
267,
1369,
26,
288,
446,
710,
536,
402,
314,
4350,
370,
1255,
314,
2120,
641,
267,
1415,
26,
756,
272,
2120,
63,
7463,
26,
267,
1369,
26,
288,
446,
710,
2120,
5492,
370,
1343,
503,
1255,
267,
1415,
26,
756,
272,
10580,
26,
267,
1369,
26,
288,
446,
437,
2600,
402,
1338,
370,
986,
370,
314,
892,
4454,
267,
1415,
26,
756,
272,
2338,
26,
267,
1369,
26,
288,
446,
7494,
5002,
892,
4454,
370,
1343,
267,
1415,
26,
756,
272,
2120,
26,
267,
1369,
26,
288,
446,
710,
2120,
370,
3631,
267,
1415,
26,
756,
272,
3970,
63,
5990,
26,
267,
1369,
26,
288,
446,
710,
769,
402,
3970,
4454,
641,
1314,
370,
12287,
314,
2120,
267,
1415,
26,
756,
272,
8239,
63,
991,
26,
267,
1369,
26,
288,
446,
437,
574,
21207,
3963,
503,
4052,
8239,
314,
2120,
334,
509,
2556,
279,
12901,
9,
267,
1415,
26,
756,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
11488,
272,
446,
7062,
18,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5870,
2893,
402,
1255,
2120,
199,
13,
536,
26,
3378,
2120,
523,
325,
1259,
63,
1765,
26,
272,
3439,
26,
1255,
272,
4350,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
4201,
272,
2120,
63,
7463,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
1765,
318,
272,
2338,
26,
413,
272,
8239,
63,
991,
26,
3242,
63,
751,
523,
2274,
26,
2120,
63,
1199,
199,
199,
3,
5870,
2893,
402,
1343,
2120,
199,
199,
13,
536,
26,
7707,
282,
2120,
523,
325,
1259,
63,
1765,
26,
489,
3439,
26,
1343,
489,
4350,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
4201,
489,
2120,
63,
7463,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
1765,
318,
489,
2120,
26,
298,
1060,
26,
7231,
26,
23075,
26,
527,
13,
19082,
13,
18,
26,
10419,
7491,
11032,
13264,
26,
1765,
15,
19,
70,
24,
15355,
68,
17,
13,
1398,
65,
24,
13,
2466,
1407,
13,
31319,
22,
13,
350,
31486,
1401,
2026,
24,
65,
2,
489,
3970,
63,
5990,
26,
489,
446,
601,
78,
26,
7231,
26,
23075,
26,
527,
13,
19082,
13,
18,
26,
10419,
7491,
11032,
13264,
26,
3600,
13,
842,
15,
1965,
67,
1789,
70,
1081,
13,
14690,
67,
13,
31352,
65,
13,
26293,
70,
13,
1229,
67,
2905,
65,
1276,
1703,
65,
24,
489,
8239,
63,
991,
26,
3242,
63,
751,
523,
2274,
26,
2120,
63,
1199,
199,
199,
13,
536,
26,
8015,
282,
2120,
523,
325,
1259,
63,
1765,
26,
489,
3439,
26,
3631,
489,
4350,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
4201,
489,
2120,
63,
7463,
26,
8559,
13,
3271,
13,
571,
13,
1986,
13,
1765,
318,
489,
2120,
26,
298,
1060,
26,
7231,
26,
23075,
26,
527,
13,
19082,
13,
18,
26,
10419,
7491,
11032,
13264,
26,
1765,
15,
19,
70,
24,
15355,
68,
17,
13,
1398,
65,
24,
13,
2466,
1407,
13,
31319,
22,
13,
350,
31486,
1401,
2026,
24,
65,
2,
199,
2344,
199,
9677,
275,
1449,
199,
1765,
26,
272,
1369,
26,
2436,
3595,
314,
307,
1810,
626,
1990,
8239,
272,
2138,
26,
3182,
272,
730,
26,
6114,
272,
3509,
26,
267,
2120,
20498,
26,
288,
1369,
26,
710,
14347,
7337,
2812,
334,
26513,
9,
626,
22975,
314,
2120,
14,
288,
2138,
26,
3544,
288,
730,
26,
1059,
267,
4350,
20498,
26,
288,
1369,
26,
710,
14347,
7337,
2812,
334,
26513,
9,
402,
314,
402,
314,
4350,
626,
7057,
314,
2120,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
1059,
267,
2120,
10701,
20498,
26,
288,
1369,
26,
710,
14347,
7337,
2812,
334,
26513,
9,
402,
314,
2120,
5492,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
1059,
267,
3970,
3244,
20498,
26,
288,
1369,
26,
710,
14347,
7337,
2812,
334,
26513,
9,
402,
314,
3970,
3879,
314,
2120,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
1059,
267,
10580,
26,
288,
1369,
26,
710,
3970,
10580,
663,
367,
642,
2120,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
769,
402,
6114,
267,
2061,
3694,
26,
288,
1369,
26,
710,
2061,
18894,
2004,
402,
314,
2120,
14,
288,
2138,
26,
1454,
1380,
2436,
365,
2549,
288,
730,
26,
1059,
267,
6387,
3694,
26,
288,
1369,
26,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
quininer/isperdal
|
isperdal/node.py
|
1
|
9290
|
from copy import copy
from asyncio import async, coroutine, iscoroutinefunction
from functools import reduce
from types import FunctionType
from traceback import format_exc
from .request import Request
from .response import Response
from .adapter import AioHTTPServer
from .utils import Result, Ok, Err, unok
codes = {
302: coroutine(
lambda this, req, res, err:
res.header("Location", err).ok()
),
400: coroutine(
lambda this, req, res, err:
res.push("400 {}".format(err)).ok()
),
404: coroutine(
lambda this, req, res, err:
res.push("404 {}".format(err)).ok()
),
500: coroutine(
lambda this, req, res, err:
print(err) or res.push(
err if this.debug else "500 Unknown Error"
).ok()
)
}
class Node(str):
"""
Microwave Node.
"""
debug = True
def __init__(self, *args, **kwargs):
"""
init node.
+ node str.
"""
self.subnode = []
self.handles = {
m: [] for m in (
'OPTION',
'GET',
'HEAD',
'POST',
'PUT',
'DELETE',
'TRACE',
'CONNECT',
'PATCH'
)
}
self.codes = {}
def copy(self, name):
node = Node(name)
node.subnode = self.subnode
node.handles = self.handles
node.codes = self.codes
return node
def route(self, *nodes, methods=('HEAD', 'GET', 'POST')):
"""
The basic route map.
+ *nodes<node> multiple node object.
+ methods<tuple> iterables, value is `self.handles` key.
- <function> wrap function
+ *handles multiple handle function.
| this node object.
| req Request object.
| res Response object.
@ Result object.
- self self node.
"""
def add_route(*handles):
for node in nodes:
self.then(node).all(methods)(*handles)
return self
return add_route
def all(self, methods=None):
"""
Add handle method for the node.
+ methods<tuple> iterables, value is `self.handles` key.
- <function> wrap function
...
"""
def all_wrap(*handles):
for method in (methods or self.handles.keys()):
self.handles[method.upper()].extend(map((
lambda handle:
coroutine(handle)
if (
isinstance(handle, FunctionType) and
not iscoroutinefunction(handle)
) else
handle
), handles))
return self
return all_wrap
def add(self, node):
"""
Add a subnode.
+ node<node> node object.
- self self node.
"""
if node in self.subnode:
exist = self.subnode[self.subnode.index(node)]
for m in node.handles:
exist.handles[m].extend(node.handles[m])
for n in node.subnode:
exist.add(n)
else:
self.subnode.append(node)
return self
def then(self, node):
"""
Add a subnode, then..
+ node<node> node object.
- <node> node.
"""
self.add(node)
return self.subnode[self.subnode.index(node)]
def __truediv__(self, node):
return [
self if self.endswith("/") else self.copy("{}/".format(self)),
node
]
def __rtruediv__(self, nodes):
return [
node if node.endswith("/") else node.copy("{}/".format(node))
for node in nodes
] + [self]
def append(self, nodes, methods=('HEAD', 'GET', 'POST')):
"""
Add multiple subnode, then..
+ *nodes<node> multiple node object.
+ methods<tuple> iterables, value is `self.handles` key.
- <function> wrap function
...
"""
def append_wrap(*handles):
reduce(
(lambda x, y: x.then(y)),
[self] + nodes
).all(methods)(*handles)
return self
return append_wrap
def get(self, *nodes):
"""
Add GET method handles to node.
+ *nodes<node> multiple node object.
- <function> wrap function
...
"""
return self.route(*nodes, methods=('GET',))
def head(self, *nodes):
return self.route(*nodes, methods=('HEAD',))
def post(self, *nodes):
return self.route(*nodes, methods=('POST',))
def err(self, *codes):
"""
Add Error handles.
+ *codes<int> multiple status code.
- <function> wrap function
+ handle handle function.
| this node object.
| req Request object.
| res Response object.
| err Error message.
@ Result object.
- self self node.
"""
def add_err(handle):
for code in codes:
self.codes[code] = (
handle
if iscoroutinefunction(handle) else
coroutine(handle)
)
return self
return add_err
@coroutine
def trigger(self, req, res, code, message):
"""
Error trigger.
&asyncio
+ req Request object.
+ res Response object.
+ code<int> status code.
+ err<T> Error message.
- Result object.
"""
res.status(code)
result = yield from (
self.codes if code in self.codes else codes
)[code](self, req, res, message)
return result
@coroutine
def handler(self, req, res, branches):
"""
Request handle.
"""
try:
if req.method not in self.handles:
raise res.status(400).err("Method can't understand.")
for handle in self.handles[req.method]:
if isinstance(handle, type):
# and issubclass(handle, WebSocket):
if not req.env.get('websocket'):
continue
result = yield from handle(self, req, res)()
else:
result = yield from handle(self, req, res)
# NOTE: why? Python 3.4- always returns None???
if isinstance(result, Result):
if result.is_ok():
return result
else:
raise result
if branches:
nextnode = branches.pop(0)
for node in self.subnode:
if node.startswith(":!"):
req._rest[node[2:]] = "".join(
[nextnode] + branches
)
elif node.startswith(":"):
if node.endswith("/") != nextnode.endswith("/"):
continue
req._rest[node[1:].rstrip("/")] = nextnode.rstrip("/")
elif nextnode != node:
continue
result = yield from node.handler(req, res, copy(branches))
if isinstance(result, Ok):
return result
if not res.done:
raise res.status(404).err("Not Found")
else:
return res.ok()
except Err as err:
if res.status_code in self.codes:
result = yield from self.trigger(
req, res, res.status_code, err.err()
)
if isinstance(result, Ok):
return result
raise err
@coroutine
def start(self, req, res):
try:
result = yield from self.handler(req, res, copy(req.branches))
except Exception as err:
if isinstance(err, Err) and res.status_code in codes:
result = yield from self.trigger(
req, res, res.status_code, err.err()
)
else:
result = yield from self.trigger(req, res, 500, format_exc())
return result
def __call__(self, env, start_response):
req, res = Request(env), Response(start_response)
return async(unok(
self.start(req, res)
if req.branches.pop(0) == self else
self.trigger(req, res, 400, "URL Error")
))
def run(self, host="127.0.0.1", port=8000, debug=True, ssl=()):
Node.debug = debug
AioHTTPServer(host, port, debug, ssl).run(self.__call__)
|
mit
|
[
504,
1331,
492,
1331,
199,
504,
16195,
492,
5316,
12,
1970,
13242,
12,
365,
16675,
1593,
199,
504,
9143,
492,
7114,
199,
504,
2943,
492,
6801,
804,
199,
504,
5190,
492,
1475,
63,
2804,
199,
199,
504,
1275,
1069,
492,
4784,
199,
504,
1275,
1310,
492,
7232,
199,
504,
1275,
10394,
492,
437,
2308,
14938,
199,
504,
1275,
1208,
492,
10695,
12,
20049,
12,
221,
5432,
12,
625,
745,
421,
199,
6021,
275,
469,
272,
11485,
26,
1970,
13242,
8,
267,
2400,
642,
12,
2648,
12,
522,
12,
2329,
26,
288,
522,
14,
1291,
480,
6592,
401,
2329,
680,
745,
342,
272,
2318,
272,
8290,
26,
1970,
13242,
8,
267,
2400,
642,
12,
2648,
12,
522,
12,
2329,
26,
288,
522,
14,
5335,
480,
5303,
8352,
908,
8,
1508,
4992,
745,
342,
272,
2318,
272,
7901,
26,
1970,
13242,
8,
267,
2400,
642,
12,
2648,
12,
522,
12,
2329,
26,
288,
522,
14,
5335,
480,
5188,
8352,
908,
8,
1508,
4992,
745,
342,
272,
2318,
272,
6891,
26,
1970,
13242,
8,
267,
2400,
642,
12,
2648,
12,
522,
12,
2329,
26,
288,
870,
8,
1508,
9,
503,
522,
14,
5335,
8,
355,
2329,
340,
642,
14,
1757,
587,
298,
5783,
14831,
4520,
2,
288,
7092,
745,
342,
272,
776,
199,
93,
421,
199,
533,
5013,
8,
495,
304,
272,
408,
272,
27022,
10024,
5013,
14,
272,
408,
339,
3105,
275,
715,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
4205,
1031,
14,
398,
435,
1031,
3515,
620,
14,
267,
408,
267,
291,
14,
954,
932,
275,
942,
267,
291,
14,
16947,
275,
469,
288,
333,
26,
942,
367,
333,
315,
334,
355,
283,
13352,
297,
355,
283,
2970,
297,
355,
283,
5211,
297,
355,
283,
4030,
297,
355,
283,
4013,
297,
355,
283,
7014,
297,
355,
283,
20112,
297,
355,
283,
14657,
297,
355,
283,
17073,
7,
288,
776,
267,
789,
267,
291,
14,
6021,
275,
1052,
339,
347,
1331,
8,
277,
12,
536,
304,
267,
1031,
275,
5013,
8,
354,
9,
267,
1031,
14,
954,
932,
275,
291,
14,
954,
932,
267,
1031,
14,
16947,
275,
291,
14,
16947,
267,
1031,
14,
6021,
275,
291,
14,
6021,
267,
372,
1031,
339,
347,
7475,
8,
277,
12,
627,
2415,
12,
3102,
7782,
5211,
297,
283,
2970,
297,
283,
4030,
8109,
267,
408,
267,
710,
5678,
7475,
2341,
14,
398,
435,
627,
2415,
28,
932,
30,
3515,
3663,
1031,
909,
14,
267,
435,
3102,
28,
2960,
30,
263,
6076,
83,
12,
574,
365,
658,
277,
14,
16947,
64,
790,
14,
398,
446,
665,
1593,
30,
259,
4816,
805,
288,
435,
627,
16947,
420,
3663,
2429,
805,
14,
355,
1204,
642,
3515,
1031,
909,
14,
355,
1204,
2648,
3698,
4784,
909,
14,
355,
1204,
522,
3698,
7232,
909,
14,
2234,
768,
10695,
909,
14,
953,
446,
291,
3515,
291,
1031,
14,
267,
408,
267,
347,
1050,
63,
4449,
2031,
16947,
304,
288,
367,
1031,
315,
3380,
26,
355,
291,
14,
12726,
8,
932,
680,
452,
8,
2474,
25967,
16947,
9,
288,
372,
291,
267,
372,
1050,
63,
4449,
339,
347,
1006,
8,
277,
12,
3102,
29,
403,
304,
267,
408,
267,
2654,
2429,
1083,
367,
314,
1031,
14,
398,
435,
3102,
28,
2960,
30,
263,
6076,
83,
12,
574,
365,
658,
277,
14,
16947,
64,
790,
14,
398,
446,
665,
1593,
30,
3322,
4816,
805,
288,
2263,
267,
408,
267,
347,
1006,
63,
3823,
2031,
16947,
304,
288,
367,
1083,
315,
334,
2474,
503,
291,
14,
16947,
14,
1612,
5109,
355,
291,
14,
16947,
59,
765,
14,
4142,
342,
1055,
2880,
8,
1130,
1332,
490,
2400,
2429,
26,
717,
1970,
13242,
8,
2479,
9,
717,
340,
334,
1169,
1228,
8,
2479,
12,
6801,
804,
9,
436,
1169,
440,
365,
16675,
1593,
8,
2479,
9,
717,
776,
587,
717,
2429,
355,
2318,
10022,
430,
288,
372,
291,
267,
372,
1006,
63,
3823,
339,
347,
1050,
8,
277,
12,
1031,
304,
267,
408,
267,
2654,
282,
1007,
932,
14,
398,
435,
1031,
28,
932,
30,
3322,
1031,
909,
14,
398,
446,
291,
8295,
291,
1031,
14,
267,
408,
267,
340,
1031,
315,
291,
14,
954,
932,
26,
288,
2187,
275,
291,
14,
954,
932,
59,
277,
14,
954,
932,
14,
1080,
8,
932,
1874,
288,
367,
333,
315,
1031,
14,
16947,
26,
355,
2187,
14,
16947,
59,
77,
1055,
2880,
8,
932,
14,
16947,
59,
77,
566,
953,
367,
302,
315,
1031,
14,
954,
932,
26,
355,
2187,
14,
525,
8,
78,
9,
267,
587,
26,
288,
291,
14,
954,
932,
14,
740,
8,
932,
9,
398,
372,
291,
339,
347,
2066,
8,
277,
12,
1031,
304,
267,
408,
267,
2654,
282,
1007,
932,
12,
2066,
703,
398,
435,
1031,
28,
932,
30,
3322,
1031,
909,
14,
398,
446,
665,
932,
30,
4483,
1031,
14,
267,
408,
267,
291,
14,
525,
8,
932,
9,
267,
372,
291,
14,
954,
932,
59,
277,
14,
954,
932,
14,
1080,
8,
932,
1874,
339,
347,
636,
22062,
721,
277,
12,
1031,
304,
267,
372,
359,
288,
291,
340,
291,
14,
4130,
19031,
587,
291,
14,
1574,
20794,
15,
1674,
908,
8,
277,
1826,
288,
1031,
267,
1622,
339,
347,
636,
82,
22062,
721,
277,
12,
3380,
304,
267,
372,
359,
288,
1031,
340,
1031,
14,
4130,
19031,
587,
1031,
14,
1574,
20794,
15,
1674,
908,
8,
932,
430,
288,
367,
1031,
315,
3380,
267,
1622,
435,
359,
277,
61,
339,
347,
5666,
8,
277,
12,
3380,
12,
3102,
7782,
5211,
297,
283,
2970,
297,
283,
4030,
8109,
267,
408,
267,
2654,
3663,
1007,
932,
12,
2066,
703,
398,
435,
627,
2415,
28,
932,
30,
3515,
3663,
1031,
909,
14,
267,
435,
3102,
28,
2960,
30,
263,
6076,
83,
12,
574,
365,
658,
277,
14,
16947,
64,
790,
14,
398,
446,
665,
1593,
30,
259,
4816,
805,
288,
2263,
267,
408,
267,
347,
5666,
63,
3823,
2031,
16947,
304,
288,
7114,
8,
355,
334,
2734,
671,
12,
612,
26,
671,
14,
12726,
8,
89,
1826,
355,
359,
277,
61,
435,
3380,
288,
7092,
452,
8,
2474,
25967,
16947,
9,
288,
372,
291,
267,
372,
5666,
63,
3823,
339,
347,
664,
8,
277,
12,
627
] |
[
1331,
492,
1331,
199,
504,
16195,
492,
5316,
12,
1970,
13242,
12,
365,
16675,
1593,
199,
504,
9143,
492,
7114,
199,
504,
2943,
492,
6801,
804,
199,
504,
5190,
492,
1475,
63,
2804,
199,
199,
504,
1275,
1069,
492,
4784,
199,
504,
1275,
1310,
492,
7232,
199,
504,
1275,
10394,
492,
437,
2308,
14938,
199,
504,
1275,
1208,
492,
10695,
12,
20049,
12,
221,
5432,
12,
625,
745,
421,
199,
6021,
275,
469,
272,
11485,
26,
1970,
13242,
8,
267,
2400,
642,
12,
2648,
12,
522,
12,
2329,
26,
288,
522,
14,
1291,
480,
6592,
401,
2329,
680,
745,
342,
272,
2318,
272,
8290,
26,
1970,
13242,
8,
267,
2400,
642,
12,
2648,
12,
522,
12,
2329,
26,
288,
522,
14,
5335,
480,
5303,
8352,
908,
8,
1508,
4992,
745,
342,
272,
2318,
272,
7901,
26,
1970,
13242,
8,
267,
2400,
642,
12,
2648,
12,
522,
12,
2329,
26,
288,
522,
14,
5335,
480,
5188,
8352,
908,
8,
1508,
4992,
745,
342,
272,
2318,
272,
6891,
26,
1970,
13242,
8,
267,
2400,
642,
12,
2648,
12,
522,
12,
2329,
26,
288,
870,
8,
1508,
9,
503,
522,
14,
5335,
8,
355,
2329,
340,
642,
14,
1757,
587,
298,
5783,
14831,
4520,
2,
288,
7092,
745,
342,
272,
776,
199,
93,
421,
199,
533,
5013,
8,
495,
304,
272,
408,
272,
27022,
10024,
5013,
14,
272,
408,
339,
3105,
275,
715,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
4205,
1031,
14,
398,
435,
1031,
3515,
620,
14,
267,
408,
267,
291,
14,
954,
932,
275,
942,
267,
291,
14,
16947,
275,
469,
288,
333,
26,
942,
367,
333,
315,
334,
355,
283,
13352,
297,
355,
283,
2970,
297,
355,
283,
5211,
297,
355,
283,
4030,
297,
355,
283,
4013,
297,
355,
283,
7014,
297,
355,
283,
20112,
297,
355,
283,
14657,
297,
355,
283,
17073,
7,
288,
776,
267,
789,
267,
291,
14,
6021,
275,
1052,
339,
347,
1331,
8,
277,
12,
536,
304,
267,
1031,
275,
5013,
8,
354,
9,
267,
1031,
14,
954,
932,
275,
291,
14,
954,
932,
267,
1031,
14,
16947,
275,
291,
14,
16947,
267,
1031,
14,
6021,
275,
291,
14,
6021,
267,
372,
1031,
339,
347,
7475,
8,
277,
12,
627,
2415,
12,
3102,
7782,
5211,
297,
283,
2970,
297,
283,
4030,
8109,
267,
408,
267,
710,
5678,
7475,
2341,
14,
398,
435,
627,
2415,
28,
932,
30,
3515,
3663,
1031,
909,
14,
267,
435,
3102,
28,
2960,
30,
263,
6076,
83,
12,
574,
365,
658,
277,
14,
16947,
64,
790,
14,
398,
446,
665,
1593,
30,
259,
4816,
805,
288,
435,
627,
16947,
420,
3663,
2429,
805,
14,
355,
1204,
642,
3515,
1031,
909,
14,
355,
1204,
2648,
3698,
4784,
909,
14,
355,
1204,
522,
3698,
7232,
909,
14,
2234,
768,
10695,
909,
14,
953,
446,
291,
3515,
291,
1031,
14,
267,
408,
267,
347,
1050,
63,
4449,
2031,
16947,
304,
288,
367,
1031,
315,
3380,
26,
355,
291,
14,
12726,
8,
932,
680,
452,
8,
2474,
25967,
16947,
9,
288,
372,
291,
267,
372,
1050,
63,
4449,
339,
347,
1006,
8,
277,
12,
3102,
29,
403,
304,
267,
408,
267,
2654,
2429,
1083,
367,
314,
1031,
14,
398,
435,
3102,
28,
2960,
30,
263,
6076,
83,
12,
574,
365,
658,
277,
14,
16947,
64,
790,
14,
398,
446,
665,
1593,
30,
3322,
4816,
805,
288,
2263,
267,
408,
267,
347,
1006,
63,
3823,
2031,
16947,
304,
288,
367,
1083,
315,
334,
2474,
503,
291,
14,
16947,
14,
1612,
5109,
355,
291,
14,
16947,
59,
765,
14,
4142,
342,
1055,
2880,
8,
1130,
1332,
490,
2400,
2429,
26,
717,
1970,
13242,
8,
2479,
9,
717,
340,
334,
1169,
1228,
8,
2479,
12,
6801,
804,
9,
436,
1169,
440,
365,
16675,
1593,
8,
2479,
9,
717,
776,
587,
717,
2429,
355,
2318,
10022,
430,
288,
372,
291,
267,
372,
1006,
63,
3823,
339,
347,
1050,
8,
277,
12,
1031,
304,
267,
408,
267,
2654,
282,
1007,
932,
14,
398,
435,
1031,
28,
932,
30,
3322,
1031,
909,
14,
398,
446,
291,
8295,
291,
1031,
14,
267,
408,
267,
340,
1031,
315,
291,
14,
954,
932,
26,
288,
2187,
275,
291,
14,
954,
932,
59,
277,
14,
954,
932,
14,
1080,
8,
932,
1874,
288,
367,
333,
315,
1031,
14,
16947,
26,
355,
2187,
14,
16947,
59,
77,
1055,
2880,
8,
932,
14,
16947,
59,
77,
566,
953,
367,
302,
315,
1031,
14,
954,
932,
26,
355,
2187,
14,
525,
8,
78,
9,
267,
587,
26,
288,
291,
14,
954,
932,
14,
740,
8,
932,
9,
398,
372,
291,
339,
347,
2066,
8,
277,
12,
1031,
304,
267,
408,
267,
2654,
282,
1007,
932,
12,
2066,
703,
398,
435,
1031,
28,
932,
30,
3322,
1031,
909,
14,
398,
446,
665,
932,
30,
4483,
1031,
14,
267,
408,
267,
291,
14,
525,
8,
932,
9,
267,
372,
291,
14,
954,
932,
59,
277,
14,
954,
932,
14,
1080,
8,
932,
1874,
339,
347,
636,
22062,
721,
277,
12,
1031,
304,
267,
372,
359,
288,
291,
340,
291,
14,
4130,
19031,
587,
291,
14,
1574,
20794,
15,
1674,
908,
8,
277,
1826,
288,
1031,
267,
1622,
339,
347,
636,
82,
22062,
721,
277,
12,
3380,
304,
267,
372,
359,
288,
1031,
340,
1031,
14,
4130,
19031,
587,
1031,
14,
1574,
20794,
15,
1674,
908,
8,
932,
430,
288,
367,
1031,
315,
3380,
267,
1622,
435,
359,
277,
61,
339,
347,
5666,
8,
277,
12,
3380,
12,
3102,
7782,
5211,
297,
283,
2970,
297,
283,
4030,
8109,
267,
408,
267,
2654,
3663,
1007,
932,
12,
2066,
703,
398,
435,
627,
2415,
28,
932,
30,
3515,
3663,
1031,
909,
14,
267,
435,
3102,
28,
2960,
30,
263,
6076,
83,
12,
574,
365,
658,
277,
14,
16947,
64,
790,
14,
398,
446,
665,
1593,
30,
259,
4816,
805,
288,
2263,
267,
408,
267,
347,
5666,
63,
3823,
2031,
16947,
304,
288,
7114,
8,
355,
334,
2734,
671,
12,
612,
26,
671,
14,
12726,
8,
89,
1826,
355,
359,
277,
61,
435,
3380,
288,
7092,
452,
8,
2474,
25967,
16947,
9,
288,
372,
291,
267,
372,
5666,
63,
3823,
339,
347,
664,
8,
277,
12,
627,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
porduna/weblabdeusto
|
server/launch/sample_balanced2_concurrent_experiments/main_machine/lab_and_experiment/experiment59/server_config.py
|
968
|
1526
|
#!/usr/bin/env python
#-*-*- encoding: utf-8 -*-*-
weblab_xilinx_experiment_xilinx_device = 'FPGA'
weblab_xilinx_experiment_port_number = 1
# This should be something like this:
# import os as _os
# xilinx_home = _os.getenv('XILINX_HOME')
# if xilinx_home == None:
# if _os.name == 'nt':
# xilinx_home = r'C:\Program Files\Xilinx'
# elif _os.name == 'posix':
# xilinx_home = r"/home/nctrun/Xilinx"
#
# if _os.name == 'nt':
# xilinx_impact_full_path = [xilinx_home + r'\bin\nt\impact']
# elif _os.name == 'posix':
# xilinx_impact_full_path = [xilinx_home + r'/bin/lin/impact']
# But for testing we are going to fake it:
xilinx_home = "."
xilinx_impact_full_path = ["python","./tests/unit/weblab/experiment/devices/xilinx_impact/fake_impact.py" ]
xilinx_device_to_program = 'XilinxImpact' # 'JTagBlazer', 'DigilentAdept'
xilinx_device_to_send_commands = 'SerialPort' # 'HttpDevice'
digilent_adept_full_path = ["python","./test/unit/weblab/experiment/devices/digilent_adept/fake_digilent_adept.py" ]
digilent_adept_batch_content = """something with the variable $FILE"""
xilinx_http_device_ip_FPGA = "192.168.50.138"
xilinx_http_device_port_FPGA = 80
xilinx_http_device_app_FPGA = ""
xilinx_batch_content_FPGA = """setMode -bs
setCable -port auto
addDevice -position 1 -file $FILE
Program -p 1
exit
"""
# Though it is not really a FPGA, the webcam url var name depends on the device,
# specified above.
fpga_webcam_url = '''https://www.weblab.deusto.es/webcam/fpga0/image.jpg'''
|
bsd-2-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
13,
1837,
1837,
2644,
26,
2774,
13,
24,
1882,
1837,
199,
199,
2520,
5561,
63,
88,
382,
5092,
63,
10873,
63,
88,
382,
5092,
63,
1782,
275,
283,
17095,
9741,
7,
199,
2520,
5561,
63,
88,
382,
5092,
63,
10873,
63,
719,
63,
1955,
257,
275,
413,
199,
199,
3,
961,
1077,
506,
6020,
2839,
642,
26,
199,
3,
492,
747,
465,
485,
736,
199,
3,
671,
382,
5092,
63,
4219,
275,
485,
736,
14,
12959,
360,
56,
1193,
568,
56,
63,
9524,
358,
199,
3,
340,
671,
382,
5092,
63,
4219,
508,
488,
26,
199,
3,
257,
340,
485,
736,
14,
354,
508,
283,
343,
356,
199,
3,
755,
671,
382,
5092,
63,
4219,
275,
519,
7,
35,
3427,
9184,
16920,
60,
56,
382,
5092,
7,
199,
3,
257,
916,
485,
736,
14,
354,
508,
283,
9228,
356,
199,
3,
755,
671,
382,
5092,
63,
4219,
275,
519,
15313,
4219,
15,
78,
319,
1065,
15,
56,
382,
5092,
2,
199,
3,
221,
199,
3,
340,
485,
736,
14,
354,
508,
283,
343,
356,
199,
3,
257,
671,
382,
5092,
63,
31822,
63,
2861,
63,
515,
275,
359,
88,
382,
5092,
63,
4219,
435,
519,
1154,
1393,
60,
343,
60,
31822,
418,
199,
3,
916,
485,
736,
14,
354,
508,
283,
9228,
356,
199,
3,
257,
671,
382,
5092,
63,
31822,
63,
2861,
63,
515,
275,
359,
88,
382,
5092,
63,
4219,
435,
519,
9807,
1393,
15,
472,
15,
31822,
418,
199,
199,
3,
11017,
367,
5343,
781,
787,
9995,
370,
4026,
652,
26,
199,
199,
88,
382,
5092,
63,
4219,
275,
14530,
199,
88,
382,
5092,
63,
31822,
63,
2861,
63,
515,
275,
2097,
1548,
401,
1674,
15,
2219,
15,
3248,
15,
2520,
5561,
15,
10873,
15,
6410,
15,
88,
382,
5092,
63,
31822,
15,
3183,
63,
31822,
14,
647,
2,
1622,
199,
199,
88,
382,
5092,
63,
1782,
63,
475,
63,
6815,
275,
283,
56,
382,
5092,
8499,
2442,
7,
327,
283,
42,
1931,
34,
416,
2282,
297,
283,
17107,
441,
343,
33,
271,
541,
7,
199,
88,
382,
5092,
63,
1782,
63,
475,
63,
2254,
63,
4405,
275,
283,
3571,
4313,
7,
327,
283,
5779,
2510,
7,
199,
199,
18367,
441,
343,
63,
9587,
541,
63,
2861,
63,
515,
275,
2097,
1548,
401,
1674,
15,
396,
15,
3248,
15,
2520,
5561,
15,
10873,
15,
6410,
15,
18367,
441,
343,
63,
9587,
541,
15,
3183,
63,
18367,
441,
343,
63,
9587,
541,
14,
647,
2,
1622,
199,
18367,
441,
343,
63,
9587,
541,
63,
2912,
63,
1317,
275,
408,
10297,
543,
314,
1750,
2672,
3817,
624,
199,
199,
88,
382,
5092,
63,
1014,
63,
1782,
63,
711,
63,
17095,
9741,
263,
275,
298,
5756,
14,
6568,
14,
1400,
14,
8527,
2,
199,
88,
382,
5092,
63,
1014,
63,
1782,
63,
719,
63,
17095,
9741,
420,
275,
5939,
199,
88,
382,
5092,
63,
1014,
63,
1782,
63,
571,
63,
17095,
9741,
755,
275,
3087,
199,
199,
88,
382,
5092,
63,
2912,
63,
1317,
63,
17095,
9741,
275,
408,
409,
1385,
446,
1533,
199,
409,
35,
461,
446,
719,
2599,
199,
525,
2510,
446,
3124,
413,
446,
493,
2672,
3817,
199,
9184,
446,
80,
413,
199,
2224,
199,
624,
199,
199,
3,
18049,
3080,
652,
365,
440,
7710,
282,
481,
48,
9741,
12,
314,
3330,
15176,
1166,
2729,
536,
8350,
641,
314,
2243,
12,
199,
3,
2013,
3432,
14,
199,
3997,
5294,
63,
2520,
15176,
63,
633,
275,
1449,
2859,
921,
1544,
14,
2520,
5561,
14,
271,
833,
79,
14,
397,
15,
2520,
15176,
15,
3997,
5294,
16,
15,
1569,
14,
8476,
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,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
13,
1837,
1837,
2644,
26,
2774,
13,
24,
1882,
1837,
199,
199,
2520,
5561,
63,
88,
382,
5092,
63,
10873,
63,
88,
382,
5092,
63,
1782,
275,
283,
17095,
9741,
7,
199,
2520,
5561,
63,
88,
382,
5092,
63,
10873,
63,
719,
63,
1955,
257,
275,
413,
199,
199,
3,
961,
1077,
506,
6020,
2839,
642,
26,
199,
3,
492,
747,
465,
485,
736,
199,
3,
671,
382,
5092,
63,
4219,
275,
485,
736,
14,
12959,
360,
56,
1193,
568,
56,
63,
9524,
358,
199,
3,
340,
671,
382,
5092,
63,
4219,
508,
488,
26,
199,
3,
257,
340,
485,
736,
14,
354,
508,
283,
343,
356,
199,
3,
755,
671,
382,
5092,
63,
4219,
275,
519,
7,
35,
3427,
9184,
16920,
60,
56,
382,
5092,
7,
199,
3,
257,
916,
485,
736,
14,
354,
508,
283,
9228,
356,
199,
3,
755,
671,
382,
5092,
63,
4219,
275,
519,
15313,
4219,
15,
78,
319,
1065,
15,
56,
382,
5092,
2,
199,
3,
221,
199,
3,
340,
485,
736,
14,
354,
508,
283,
343,
356,
199,
3,
257,
671,
382,
5092,
63,
31822,
63,
2861,
63,
515,
275,
359,
88,
382,
5092,
63,
4219,
435,
519,
1154,
1393,
60,
343,
60,
31822,
418,
199,
3,
916,
485,
736,
14,
354,
508,
283,
9228,
356,
199,
3,
257,
671,
382,
5092,
63,
31822,
63,
2861,
63,
515,
275,
359,
88,
382,
5092,
63,
4219,
435,
519,
9807,
1393,
15,
472,
15,
31822,
418,
199,
199,
3,
11017,
367,
5343,
781,
787,
9995,
370,
4026,
652,
26,
199,
199,
88,
382,
5092,
63,
4219,
275,
14530,
199,
88,
382,
5092,
63,
31822,
63,
2861,
63,
515,
275,
2097,
1548,
401,
1674,
15,
2219,
15,
3248,
15,
2520,
5561,
15,
10873,
15,
6410,
15,
88,
382,
5092,
63,
31822,
15,
3183,
63,
31822,
14,
647,
2,
1622,
199,
199,
88,
382,
5092,
63,
1782,
63,
475,
63,
6815,
275,
283,
56,
382,
5092,
8499,
2442,
7,
327,
283,
42,
1931,
34,
416,
2282,
297,
283,
17107,
441,
343,
33,
271,
541,
7,
199,
88,
382,
5092,
63,
1782,
63,
475,
63,
2254,
63,
4405,
275,
283,
3571,
4313,
7,
327,
283,
5779,
2510,
7,
199,
199,
18367,
441,
343,
63,
9587,
541,
63,
2861,
63,
515,
275,
2097,
1548,
401,
1674,
15,
396,
15,
3248,
15,
2520,
5561,
15,
10873,
15,
6410,
15,
18367,
441,
343,
63,
9587,
541,
15,
3183,
63,
18367,
441,
343,
63,
9587,
541,
14,
647,
2,
1622,
199,
18367,
441,
343,
63,
9587,
541,
63,
2912,
63,
1317,
275,
408,
10297,
543,
314,
1750,
2672,
3817,
624,
199,
199,
88,
382,
5092,
63,
1014,
63,
1782,
63,
711,
63,
17095,
9741,
263,
275,
298,
5756,
14,
6568,
14,
1400,
14,
8527,
2,
199,
88,
382,
5092,
63,
1014,
63,
1782,
63,
719,
63,
17095,
9741,
420,
275,
5939,
199,
88,
382,
5092,
63,
1014,
63,
1782,
63,
571,
63,
17095,
9741,
755,
275,
3087,
199,
199,
88,
382,
5092,
63,
2912,
63,
1317,
63,
17095,
9741,
275,
408,
409,
1385,
446,
1533,
199,
409,
35,
461,
446,
719,
2599,
199,
525,
2510,
446,
3124,
413,
446,
493,
2672,
3817,
199,
9184,
446,
80,
413,
199,
2224,
199,
624,
199,
199,
3,
18049,
3080,
652,
365,
440,
7710,
282,
481,
48,
9741,
12,
314,
3330,
15176,
1166,
2729,
536,
8350,
641,
314,
2243,
12,
199,
3,
2013,
3432,
14,
199,
3997,
5294,
63,
2520,
15176,
63,
633,
275,
1449,
2859,
921,
1544,
14,
2520,
5561,
14,
271,
833,
79,
14,
397,
15,
2520,
15176,
15,
3997,
5294,
16,
15,
1569,
14,
8476,
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,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
sudheesh001/pontoon
|
pontoon/base/tests/test_helpers.py
|
1
|
1622
|
from datetime import timedelta
from django_nose.tools import assert_equal
from pontoon.base.templatetags.helpers import format_datetime, format_timedelta
from pontoon.base.tests import TestCase
from pontoon.base.utils import aware_datetime
class FormatDatetimeTests(TestCase):
def test_format_datetime_none(self):
assert_equal(format_datetime(None), '---')
def test_format_datetime_custom(self):
datetime = aware_datetime(2015, 1, 1, 5, 7)
assert_equal(format_datetime(datetime, '%H:%M'), '05:07')
def test_format_builtin(self):
"""
Test that there exist built-in formats. We're not interested in
testing "all" of them, just that the capability exists.
"""
with self.settings(TIME_ZONE='UTC'):
datetime = aware_datetime(2015, 1, 1, 5, 7)
assert_equal(format_datetime(datetime, 'time'), '05:07 UTC')
class FormatTimedeltaTests(TestCase):
def test_format_timedelta_none(self):
assert_equal(format_timedelta(None), '---')
def test_format_timedelta_seconds(self):
assert_equal(format_timedelta(timedelta(seconds=5)), '5 seconds')
def test_format_timedelta_minutes(self):
duration = timedelta(minutes=1, seconds=7)
assert_equal(format_timedelta(duration), '1 minutes, 7 seconds')
def test_format_timedelta_days(self):
duration = timedelta(days=2, minutes=1, seconds=8)
assert_equal(format_timedelta(duration), '2 days, 1 minutes, 8 seconds')
def test_format_timedelta_0(self):
assert_equal(format_timedelta(timedelta(seconds=0)), '0 seconds')
|
bsd-3-clause
|
[
504,
2197,
492,
6871,
199,
199,
504,
1639,
63,
21085,
14,
2537,
492,
702,
63,
1452,
199,
199,
504,
299,
26296,
265,
14,
1095,
14,
1160,
2969,
14,
7546,
492,
1475,
63,
2083,
12,
1475,
63,
7473,
199,
504,
299,
26296,
265,
14,
1095,
14,
2219,
492,
7640,
199,
504,
299,
26296,
265,
14,
1095,
14,
1208,
492,
20381,
63,
2083,
421,
199,
533,
9701,
19636,
2925,
8,
1746,
304,
272,
347,
511,
63,
908,
63,
2083,
63,
3592,
8,
277,
304,
267,
702,
63,
1452,
8,
908,
63,
2083,
8,
403,
395,
283,
2595,
358,
339,
347,
511,
63,
908,
63,
2083,
63,
4229,
8,
277,
304,
267,
2197,
275,
20381,
63,
2083,
8,
7806,
12,
413,
12,
413,
12,
959,
12,
1520,
9,
267,
702,
63,
1452,
8,
908,
63,
2083,
8,
2083,
12,
1543,
40,
2689,
45,
659,
283,
1717,
26,
1780,
358,
339,
347,
511,
63,
908,
63,
5351,
8,
277,
304,
267,
408,
267,
1379,
626,
2337,
2187,
6137,
13,
262,
6752,
14,
2136,
3984,
440,
22201,
315,
267,
5343,
298,
452,
2,
402,
3062,
12,
2951,
626,
314,
19854,
3495,
14,
267,
408,
267,
543,
291,
14,
1751,
8,
4961,
63,
15353,
534,
11288,
735,
288,
2197,
275,
20381,
63,
2083,
8,
7806,
12,
413,
12,
413,
12,
959,
12,
1520,
9,
267,
702,
63,
1452,
8,
908,
63,
2083,
8,
2083,
12,
283,
521,
659,
283,
1717,
26,
1780,
12174,
358,
421,
199,
533,
9701,
1366,
3136,
2925,
8,
1746,
304,
272,
347,
511,
63,
908,
63,
7473,
63,
3592,
8,
277,
304,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
403,
395,
283,
2595,
358,
339,
347,
511,
63,
908,
63,
7473,
63,
4515,
8,
277,
304,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
7473,
8,
4515,
29,
21,
1826,
283,
21,
4696,
358,
339,
347,
511,
63,
908,
63,
7473,
63,
10430,
8,
277,
304,
267,
7373,
275,
6871,
8,
10430,
29,
17,
12,
4696,
29,
23,
9,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
5553,
395,
283,
17,
9395,
12,
1520,
4696,
358,
339,
347,
511,
63,
908,
63,
7473,
63,
4899,
8,
277,
304,
267,
7373,
275,
6871,
8,
4899,
29,
18,
12,
9395,
29,
17,
12,
4696,
29,
24,
9,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
5553,
395,
283,
18,
7609,
12,
413,
9395,
12,
1695,
4696,
358,
339,
347,
511,
63,
908,
63,
7473,
63,
16,
8,
277,
304,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
7473,
8,
4515,
29,
16,
1826,
283,
16,
4696,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2197,
492,
6871,
199,
199,
504,
1639,
63,
21085,
14,
2537,
492,
702,
63,
1452,
199,
199,
504,
299,
26296,
265,
14,
1095,
14,
1160,
2969,
14,
7546,
492,
1475,
63,
2083,
12,
1475,
63,
7473,
199,
504,
299,
26296,
265,
14,
1095,
14,
2219,
492,
7640,
199,
504,
299,
26296,
265,
14,
1095,
14,
1208,
492,
20381,
63,
2083,
421,
199,
533,
9701,
19636,
2925,
8,
1746,
304,
272,
347,
511,
63,
908,
63,
2083,
63,
3592,
8,
277,
304,
267,
702,
63,
1452,
8,
908,
63,
2083,
8,
403,
395,
283,
2595,
358,
339,
347,
511,
63,
908,
63,
2083,
63,
4229,
8,
277,
304,
267,
2197,
275,
20381,
63,
2083,
8,
7806,
12,
413,
12,
413,
12,
959,
12,
1520,
9,
267,
702,
63,
1452,
8,
908,
63,
2083,
8,
2083,
12,
1543,
40,
2689,
45,
659,
283,
1717,
26,
1780,
358,
339,
347,
511,
63,
908,
63,
5351,
8,
277,
304,
267,
408,
267,
1379,
626,
2337,
2187,
6137,
13,
262,
6752,
14,
2136,
3984,
440,
22201,
315,
267,
5343,
298,
452,
2,
402,
3062,
12,
2951,
626,
314,
19854,
3495,
14,
267,
408,
267,
543,
291,
14,
1751,
8,
4961,
63,
15353,
534,
11288,
735,
288,
2197,
275,
20381,
63,
2083,
8,
7806,
12,
413,
12,
413,
12,
959,
12,
1520,
9,
267,
702,
63,
1452,
8,
908,
63,
2083,
8,
2083,
12,
283,
521,
659,
283,
1717,
26,
1780,
12174,
358,
421,
199,
533,
9701,
1366,
3136,
2925,
8,
1746,
304,
272,
347,
511,
63,
908,
63,
7473,
63,
3592,
8,
277,
304,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
403,
395,
283,
2595,
358,
339,
347,
511,
63,
908,
63,
7473,
63,
4515,
8,
277,
304,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
7473,
8,
4515,
29,
21,
1826,
283,
21,
4696,
358,
339,
347,
511,
63,
908,
63,
7473,
63,
10430,
8,
277,
304,
267,
7373,
275,
6871,
8,
10430,
29,
17,
12,
4696,
29,
23,
9,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
5553,
395,
283,
17,
9395,
12,
1520,
4696,
358,
339,
347,
511,
63,
908,
63,
7473,
63,
4899,
8,
277,
304,
267,
7373,
275,
6871,
8,
4899,
29,
18,
12,
9395,
29,
17,
12,
4696,
29,
24,
9,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
5553,
395,
283,
18,
7609,
12,
413,
9395,
12,
1695,
4696,
358,
339,
347,
511,
63,
908,
63,
7473,
63,
16,
8,
277,
304,
267,
702,
63,
1452,
8,
908,
63,
7473,
8,
7473,
8,
4515,
29,
16,
1826,
283,
16,
4696,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
zhangf911/common
|
test/dev/system_id_test.py
|
5
|
1127
|
import unittest
from biicode.common.dev.system_id import SystemID
from biicode.common.settings.version import Version
class SystemIDTest(unittest.TestCase):
def setUp(self):
self.sut = SystemID("open_gl", "CPP")
def test_set_generic_system(self):
self.sut.set_generic_system()
self.assertEquals(self.sut.language_version, Version())
def test_version_id_setter_exception(self):
self.assertRaises(ValueError, self.sut.version_id, 1)
def test_version_id_setter_with_version_instance(self):
self.sut.version_id = Version()
def test_version_id_setter_with_string(self):
self.sut.version_id = "1"
def test_language_version_id_setter_with_version_instance(self):
self.sut.language_version = Version()
self.assertEquals(self.sut.language_version, Version())
def test_language_version_id_setter_with_string(self):
self.sut.language_version = "1"
self.assertEquals(self.sut.language_version, Version("1"))
def test_equal(self):
self.assertTrue(self.sut == self.sut)
self.assertFalse(self.sut == 1)
|
mit
|
[
646,
2882,
199,
199,
504,
12111,
1525,
14,
2330,
14,
2374,
14,
2253,
63,
344,
492,
6187,
998,
199,
504,
12111,
1525,
14,
2330,
14,
1751,
14,
1023,
492,
3394,
421,
199,
533,
6187,
998,
774,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
83,
337,
275,
6187,
998,
480,
1490,
63,
3528,
401,
298,
14533,
531,
339,
347,
511,
63,
409,
63,
6767,
63,
2253,
8,
277,
304,
267,
291,
14,
83,
337,
14,
409,
63,
6767,
63,
2253,
342,
267,
291,
14,
2947,
8,
277,
14,
83,
337,
14,
3671,
63,
1023,
12,
3394,
1012,
339,
347,
511,
63,
1023,
63,
344,
63,
8345,
63,
1971,
8,
277,
304,
267,
291,
14,
1855,
8,
3393,
12,
291,
14,
83,
337,
14,
1023,
63,
344,
12,
413,
9,
339,
347,
511,
63,
1023,
63,
344,
63,
8345,
63,
1045,
63,
1023,
63,
842,
8,
277,
304,
267,
291,
14,
83,
337,
14,
1023,
63,
344,
275,
3394,
342,
339,
347,
511,
63,
1023,
63,
344,
63,
8345,
63,
1045,
63,
875,
8,
277,
304,
267,
291,
14,
83,
337,
14,
1023,
63,
344,
275,
298,
17,
2,
339,
347,
511,
63,
3671,
63,
1023,
63,
344,
63,
8345,
63,
1045,
63,
1023,
63,
842,
8,
277,
304,
267,
291,
14,
83,
337,
14,
3671,
63,
1023,
275,
3394,
342,
267,
291,
14,
2947,
8,
277,
14,
83,
337,
14,
3671,
63,
1023,
12,
3394,
1012,
339,
347,
511,
63,
3671,
63,
1023,
63,
344,
63,
8345,
63,
1045,
63,
875,
8,
277,
304,
267,
291,
14,
83,
337,
14,
3671,
63,
1023,
275,
298,
17,
2,
267,
291,
14,
2947,
8,
277,
14,
83,
337,
14,
3671,
63,
1023,
12,
3394,
480,
17,
2237,
339,
347,
511,
63,
1452,
8,
277,
304,
267,
291,
14,
1815,
8,
277,
14,
83,
337,
508,
291,
14,
83,
337,
9,
267,
291,
14,
3334,
8,
277,
14,
83,
337,
508,
413,
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
] |
[
2882,
199,
199,
504,
12111,
1525,
14,
2330,
14,
2374,
14,
2253,
63,
344,
492,
6187,
998,
199,
504,
12111,
1525,
14,
2330,
14,
1751,
14,
1023,
492,
3394,
421,
199,
533,
6187,
998,
774,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
83,
337,
275,
6187,
998,
480,
1490,
63,
3528,
401,
298,
14533,
531,
339,
347,
511,
63,
409,
63,
6767,
63,
2253,
8,
277,
304,
267,
291,
14,
83,
337,
14,
409,
63,
6767,
63,
2253,
342,
267,
291,
14,
2947,
8,
277,
14,
83,
337,
14,
3671,
63,
1023,
12,
3394,
1012,
339,
347,
511,
63,
1023,
63,
344,
63,
8345,
63,
1971,
8,
277,
304,
267,
291,
14,
1855,
8,
3393,
12,
291,
14,
83,
337,
14,
1023,
63,
344,
12,
413,
9,
339,
347,
511,
63,
1023,
63,
344,
63,
8345,
63,
1045,
63,
1023,
63,
842,
8,
277,
304,
267,
291,
14,
83,
337,
14,
1023,
63,
344,
275,
3394,
342,
339,
347,
511,
63,
1023,
63,
344,
63,
8345,
63,
1045,
63,
875,
8,
277,
304,
267,
291,
14,
83,
337,
14,
1023,
63,
344,
275,
298,
17,
2,
339,
347,
511,
63,
3671,
63,
1023,
63,
344,
63,
8345,
63,
1045,
63,
1023,
63,
842,
8,
277,
304,
267,
291,
14,
83,
337,
14,
3671,
63,
1023,
275,
3394,
342,
267,
291,
14,
2947,
8,
277,
14,
83,
337,
14,
3671,
63,
1023,
12,
3394,
1012,
339,
347,
511,
63,
3671,
63,
1023,
63,
344,
63,
8345,
63,
1045,
63,
875,
8,
277,
304,
267,
291,
14,
83,
337,
14,
3671,
63,
1023,
275,
298,
17,
2,
267,
291,
14,
2947,
8,
277,
14,
83,
337,
14,
3671,
63,
1023,
12,
3394,
480,
17,
2237,
339,
347,
511,
63,
1452,
8,
277,
304,
267,
291,
14,
1815,
8,
277,
14,
83,
337,
508,
291,
14,
83,
337,
9,
267,
291,
14,
3334,
8,
277,
14,
83,
337,
508,
413,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tbronchain/shadowsocks
|
shadowsocks/encrypt.py
|
990
|
5180
|
#!/usr/bin/env python
#
# Copyright 2012-2015 clowwindy
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import, division, print_function, \
with_statement
import os
import sys
import hashlib
import logging
from shadowsocks import common
from shadowsocks.crypto import rc4_md5, openssl, sodium, table
method_supported = {}
method_supported.update(rc4_md5.ciphers)
method_supported.update(openssl.ciphers)
method_supported.update(sodium.ciphers)
method_supported.update(table.ciphers)
def random_string(length):
return os.urandom(length)
cached_keys = {}
def try_cipher(key, method=None):
Encryptor(key, method)
def EVP_BytesToKey(password, key_len, iv_len):
# equivalent to OpenSSL's EVP_BytesToKey() with count 1
# so that we make the same key and iv as nodejs version
cached_key = '%s-%d-%d' % (password, key_len, iv_len)
r = cached_keys.get(cached_key, None)
if r:
return r
m = []
i = 0
while len(b''.join(m)) < (key_len + iv_len):
md5 = hashlib.md5()
data = password
if i > 0:
data = m[i - 1] + password
md5.update(data)
m.append(md5.digest())
i += 1
ms = b''.join(m)
key = ms[:key_len]
iv = ms[key_len:key_len + iv_len]
cached_keys[cached_key] = (key, iv)
return key, iv
class Encryptor(object):
def __init__(self, key, method):
self.key = key
self.method = method
self.iv = None
self.iv_sent = False
self.cipher_iv = b''
self.decipher = None
method = method.lower()
self._method_info = self.get_method_info(method)
if self._method_info:
self.cipher = self.get_cipher(key, method, 1,
random_string(self._method_info[1]))
else:
logging.error('method %s not supported' % method)
sys.exit(1)
def get_method_info(self, method):
method = method.lower()
m = method_supported.get(method)
return m
def iv_len(self):
return len(self.cipher_iv)
def get_cipher(self, password, method, op, iv):
password = common.to_bytes(password)
m = self._method_info
if m[0] > 0:
key, iv_ = EVP_BytesToKey(password, m[0], m[1])
else:
# key_length == 0 indicates we should use the key directly
key, iv = password, b''
iv = iv[:m[1]]
if op == 1:
# this iv is for cipher not decipher
self.cipher_iv = iv[:m[1]]
return m[2](method, key, iv, op)
def encrypt(self, buf):
if len(buf) == 0:
return buf
if self.iv_sent:
return self.cipher.update(buf)
else:
self.iv_sent = True
return self.cipher_iv + self.cipher.update(buf)
def decrypt(self, buf):
if len(buf) == 0:
return buf
if self.decipher is None:
decipher_iv_len = self._method_info[1]
decipher_iv = buf[:decipher_iv_len]
self.decipher = self.get_cipher(self.key, self.method, 0,
iv=decipher_iv)
buf = buf[decipher_iv_len:]
if len(buf) == 0:
return buf
return self.decipher.update(buf)
def encrypt_all(password, method, op, data):
result = []
method = method.lower()
(key_len, iv_len, m) = method_supported[method]
if key_len > 0:
key, _ = EVP_BytesToKey(password, key_len, iv_len)
else:
key = password
if op:
iv = random_string(iv_len)
result.append(iv)
else:
iv = data[:iv_len]
data = data[iv_len:]
cipher = m(method, key, iv, op)
result.append(cipher.update(data))
return b''.join(result)
CIPHERS_TO_TEST = [
'aes-128-cfb',
'aes-256-cfb',
'rc4-md5',
'salsa20',
'chacha20',
'table',
]
def test_encryptor():
from os import urandom
plain = urandom(10240)
for method in CIPHERS_TO_TEST:
logging.warn(method)
encryptor = Encryptor(b'key', method)
decryptor = Encryptor(b'key', method)
cipher = encryptor.encrypt(plain)
plain2 = decryptor.decrypt(cipher)
assert plain == plain2
def test_encrypt_all():
from os import urandom
plain = urandom(10240)
for method in CIPHERS_TO_TEST:
logging.warn(method)
cipher = encrypt_all(b'key', method, 1, plain)
plain2 = encrypt_all(b'key', method, 0, cipher)
assert plain == plain2
if __name__ == '__main__':
test_encrypt_all()
test_encryptor()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
6029,
13,
7806,
286,
674,
11530,
89,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
971,
272,
543,
63,
6242,
199,
199,
646,
747,
199,
646,
984,
199,
646,
8337,
199,
646,
2050,
199,
199,
504,
15084,
21234,
492,
2863,
199,
504,
15084,
21234,
14,
10316,
492,
4819,
20,
63,
1064,
21,
12,
1551,
4266,
12,
880,
12980,
12,
1817,
421,
199,
765,
63,
4946,
275,
1052,
199,
765,
63,
4946,
14,
873,
8,
1195,
20,
63,
1064,
21,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
14837,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
1152,
12980,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
1224,
14,
27426,
9,
421,
199,
318,
2196,
63,
875,
8,
1267,
304,
272,
372,
747,
14,
22776,
8,
1267,
9,
421,
199,
5245,
63,
1612,
275,
1052,
421,
199,
318,
862,
63,
9231,
8,
498,
12,
1083,
29,
403,
304,
272,
3447,
4997,
269,
8,
498,
12,
1083,
9,
421,
199,
318,
662,
14159,
63,
5571,
1378,
1197,
8,
2060,
12,
790,
63,
552,
12,
18831,
63,
552,
304,
272,
327,
7353,
370,
14296,
1159,
662,
14159,
63,
5571,
1378,
1197,
342,
543,
2338,
413,
272,
327,
880,
626,
781,
1852,
314,
2011,
790,
436,
18831,
465,
1031,
3596,
1015,
272,
6328,
63,
498,
275,
1543,
83,
3295,
68,
3295,
68,
7,
450,
334,
2060,
12,
790,
63,
552,
12,
18831,
63,
552,
9,
272,
519,
275,
6328,
63,
1612,
14,
362,
8,
5245,
63,
498,
12,
488,
9,
272,
340,
519,
26,
267,
372,
519,
272,
333,
275,
942,
272,
284,
275,
378,
272,
1830,
822,
8,
66,
17067,
904,
8,
77,
430,
665,
334,
498,
63,
552,
435,
18831,
63,
552,
304,
267,
6128,
21,
275,
8337,
14,
1064,
21,
342,
267,
666,
275,
2505,
267,
340,
284,
690,
378,
26,
288,
666,
275,
333,
59,
73,
446,
413,
61,
435,
2505,
267,
6128,
21,
14,
873,
8,
576,
9,
267,
333,
14,
740,
8,
1064,
21,
14,
5671,
1012,
267,
284,
847,
413,
272,
6605,
275,
330,
17067,
904,
8,
77,
9,
272,
790,
275,
6605,
1491,
498,
63,
552,
61,
272,
18831,
275,
6605,
59,
498,
63,
552,
26,
498,
63,
552,
435,
18831,
63,
552,
61,
272,
6328,
63,
1612,
59,
5245,
63,
498,
61,
275,
334,
498,
12,
18831,
9,
272,
372,
790,
12,
18831,
421,
199,
533,
3447,
4997,
269,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
790,
12,
1083,
304,
267,
291,
14,
498,
275,
790,
267,
291,
14,
765,
275,
1083,
267,
291,
14,
1003,
275,
488,
267,
291,
14,
1003,
63,
1150,
275,
756,
267,
291,
14,
9231,
63,
1003,
275,
330,
891,
267,
291,
14,
271,
9231,
275,
488,
267,
1083,
275,
1083,
14,
2325,
342,
267,
291,
423,
765,
63,
815,
275,
291,
14,
362,
63,
765,
63,
815,
8,
765,
9,
267,
340,
291,
423,
765,
63,
815,
26,
288,
291,
14,
9231,
275,
291,
14,
362,
63,
9231,
8,
498,
12,
1083,
12,
413,
12,
5101,
2196,
63,
875,
8,
277,
423,
765,
63,
815,
59,
17,
2459,
267,
587,
26,
288,
2050,
14,
705,
360,
765,
450,
83,
440,
3748,
7,
450,
1083,
9,
288,
984,
14,
2224,
8,
17,
9,
339,
347,
664,
63,
765,
63,
815,
8,
277,
12,
1083,
304,
267,
1083,
275,
1083,
14,
2325,
342,
267,
333,
275,
1083,
63,
4946,
14,
362,
8,
765,
9,
267,
372,
333,
339,
347,
18831,
63,
552,
8,
277,
304,
267,
372,
822,
8,
277,
14,
9231,
63,
1003,
9,
339,
347,
664,
63,
9231,
8,
277,
12,
2505,
12,
1083,
12,
1687,
12,
18831,
304,
267,
2505,
275,
2863,
14,
475,
63,
2394,
8,
2060,
9,
267,
333,
275,
291,
423,
765,
63,
815,
267,
340,
333,
59,
16,
61,
690,
378,
26,
288,
790,
12,
18831,
63,
275,
662,
14159,
63,
5571,
1378,
1197,
8,
2060,
12,
333,
59,
16,
467,
333,
59,
17,
566,
267,
587,
26,
288,
327,
790,
63,
1267,
508,
378,
9126,
781,
1077,
675,
314,
790,
5370,
288,
790,
12,
18831,
275,
2505,
12,
330,
891,
398,
18831,
275,
18831,
1491,
77,
59,
17,
2677,
267,
340,
1687,
508,
413,
26,
288,
327,
642,
18831,
365,
367,
10830,
440,
477,
9231,
288,
291,
14,
9231,
63,
1003,
275,
18831,
1491,
77,
59,
17,
2677,
267,
372,
333,
59,
18,
8738,
765,
12,
790,
12,
18831,
12,
1687,
9,
339,
347,
14645,
8,
277,
12,
4123,
304,
267,
340,
822,
8,
1436,
9,
508,
378,
26,
288,
372,
4123,
267,
340,
291,
14,
1003,
63,
1150,
26,
288,
372,
291,
14,
9231,
14,
873,
8,
1436,
9,
267,
587,
26,
288,
291,
14,
1003,
63,
1150,
275,
715,
288,
372,
291,
14,
9231,
63,
1003,
435,
291,
14,
9231,
14,
873,
8,
1436,
9,
339,
347,
20090,
8,
277,
12,
4123,
304,
267,
340,
822,
8,
1436,
9,
508,
378,
26,
288,
372,
4123,
267,
340,
291,
14,
271,
9231,
365,
488,
26,
288,
477,
9231,
63,
1003,
63,
552,
275,
291,
423,
765,
63,
815,
59,
17,
61,
288,
477,
9231,
63,
1003,
275,
4123,
1491,
271,
9231,
63,
1003,
63,
552,
61,
288,
291,
14,
271,
9231,
275,
291,
14,
362
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
6029,
13,
7806,
286,
674,
11530,
89,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
971,
272,
543,
63,
6242,
199,
199,
646,
747,
199,
646,
984,
199,
646,
8337,
199,
646,
2050,
199,
199,
504,
15084,
21234,
492,
2863,
199,
504,
15084,
21234,
14,
10316,
492,
4819,
20,
63,
1064,
21,
12,
1551,
4266,
12,
880,
12980,
12,
1817,
421,
199,
765,
63,
4946,
275,
1052,
199,
765,
63,
4946,
14,
873,
8,
1195,
20,
63,
1064,
21,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
14837,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
1152,
12980,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
1224,
14,
27426,
9,
421,
199,
318,
2196,
63,
875,
8,
1267,
304,
272,
372,
747,
14,
22776,
8,
1267,
9,
421,
199,
5245,
63,
1612,
275,
1052,
421,
199,
318,
862,
63,
9231,
8,
498,
12,
1083,
29,
403,
304,
272,
3447,
4997,
269,
8,
498,
12,
1083,
9,
421,
199,
318,
662,
14159,
63,
5571,
1378,
1197,
8,
2060,
12,
790,
63,
552,
12,
18831,
63,
552,
304,
272,
327,
7353,
370,
14296,
1159,
662,
14159,
63,
5571,
1378,
1197,
342,
543,
2338,
413,
272,
327,
880,
626,
781,
1852,
314,
2011,
790,
436,
18831,
465,
1031,
3596,
1015,
272,
6328,
63,
498,
275,
1543,
83,
3295,
68,
3295,
68,
7,
450,
334,
2060,
12,
790,
63,
552,
12,
18831,
63,
552,
9,
272,
519,
275,
6328,
63,
1612,
14,
362,
8,
5245,
63,
498,
12,
488,
9,
272,
340,
519,
26,
267,
372,
519,
272,
333,
275,
942,
272,
284,
275,
378,
272,
1830,
822,
8,
66,
17067,
904,
8,
77,
430,
665,
334,
498,
63,
552,
435,
18831,
63,
552,
304,
267,
6128,
21,
275,
8337,
14,
1064,
21,
342,
267,
666,
275,
2505,
267,
340,
284,
690,
378,
26,
288,
666,
275,
333,
59,
73,
446,
413,
61,
435,
2505,
267,
6128,
21,
14,
873,
8,
576,
9,
267,
333,
14,
740,
8,
1064,
21,
14,
5671,
1012,
267,
284,
847,
413,
272,
6605,
275,
330,
17067,
904,
8,
77,
9,
272,
790,
275,
6605,
1491,
498,
63,
552,
61,
272,
18831,
275,
6605,
59,
498,
63,
552,
26,
498,
63,
552,
435,
18831,
63,
552,
61,
272,
6328,
63,
1612,
59,
5245,
63,
498,
61,
275,
334,
498,
12,
18831,
9,
272,
372,
790,
12,
18831,
421,
199,
533,
3447,
4997,
269,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
790,
12,
1083,
304,
267,
291,
14,
498,
275,
790,
267,
291,
14,
765,
275,
1083,
267,
291,
14,
1003,
275,
488,
267,
291,
14,
1003,
63,
1150,
275,
756,
267,
291,
14,
9231,
63,
1003,
275,
330,
891,
267,
291,
14,
271,
9231,
275,
488,
267,
1083,
275,
1083,
14,
2325,
342,
267,
291,
423,
765,
63,
815,
275,
291,
14,
362,
63,
765,
63,
815,
8,
765,
9,
267,
340,
291,
423,
765,
63,
815,
26,
288,
291,
14,
9231,
275,
291,
14,
362,
63,
9231,
8,
498,
12,
1083,
12,
413,
12,
5101,
2196,
63,
875,
8,
277,
423,
765,
63,
815,
59,
17,
2459,
267,
587,
26,
288,
2050,
14,
705,
360,
765,
450,
83,
440,
3748,
7,
450,
1083,
9,
288,
984,
14,
2224,
8,
17,
9,
339,
347,
664,
63,
765,
63,
815,
8,
277,
12,
1083,
304,
267,
1083,
275,
1083,
14,
2325,
342,
267,
333,
275,
1083,
63,
4946,
14,
362,
8,
765,
9,
267,
372,
333,
339,
347,
18831,
63,
552,
8,
277,
304,
267,
372,
822,
8,
277,
14,
9231,
63,
1003,
9,
339,
347,
664,
63,
9231,
8,
277,
12,
2505,
12,
1083,
12,
1687,
12,
18831,
304,
267,
2505,
275,
2863,
14,
475,
63,
2394,
8,
2060,
9,
267,
333,
275,
291,
423,
765,
63,
815,
267,
340,
333,
59,
16,
61,
690,
378,
26,
288,
790,
12,
18831,
63,
275,
662,
14159,
63,
5571,
1378,
1197,
8,
2060,
12,
333,
59,
16,
467,
333,
59,
17,
566,
267,
587,
26,
288,
327,
790,
63,
1267,
508,
378,
9126,
781,
1077,
675,
314,
790,
5370,
288,
790,
12,
18831,
275,
2505,
12,
330,
891,
398,
18831,
275,
18831,
1491,
77,
59,
17,
2677,
267,
340,
1687,
508,
413,
26,
288,
327,
642,
18831,
365,
367,
10830,
440,
477,
9231,
288,
291,
14,
9231,
63,
1003,
275,
18831,
1491,
77,
59,
17,
2677,
267,
372,
333,
59,
18,
8738,
765,
12,
790,
12,
18831,
12,
1687,
9,
339,
347,
14645,
8,
277,
12,
4123,
304,
267,
340,
822,
8,
1436,
9,
508,
378,
26,
288,
372,
4123,
267,
340,
291,
14,
1003,
63,
1150,
26,
288,
372,
291,
14,
9231,
14,
873,
8,
1436,
9,
267,
587,
26,
288,
291,
14,
1003,
63,
1150,
275,
715,
288,
372,
291,
14,
9231,
63,
1003,
435,
291,
14,
9231,
14,
873,
8,
1436,
9,
339,
347,
20090,
8,
277,
12,
4123,
304,
267,
340,
822,
8,
1436,
9,
508,
378,
26,
288,
372,
4123,
267,
340,
291,
14,
271,
9231,
365,
488,
26,
288,
477,
9231,
63,
1003,
63,
552,
275,
291,
423,
765,
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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
] |
YzPaul3/h2o-3
|
h2o-algos/src/test/java/hex/example/workflowtest.py
|
19
|
7922
|
import h2o
# Explore a typical Data Science workflow with H2O and Python
#
# Goal: assist the manager of CitiBike of NYC to load-balance the bicycles
# across the CitiBike network of stations, by predicting the number of bike
# trips taken from the station every day. Use 10 million rows of historical
# data, and eventually add weather data.
# Connect to a cluster
h2o.init()
# Pick either the big or the small demo.
# Big data is 10M rows
small_test = ["bigdata/laptop/citibike-nyc/2013-10.csv"]
big_test = ["bigdata/laptop/citibike-nyc/2013-07.csv",
"bigdata/laptop/citibike-nyc/2013-08.csv",
"bigdata/laptop/citibike-nyc/2013-09.csv",
"bigdata/laptop/citibike-nyc/2013-10.csv",
"bigdata/laptop/citibike-nyc/2013-11.csv",
"bigdata/laptop/citibike-nyc/2013-12.csv",
"bigdata/laptop/citibike-nyc/2014-01.csv",
"bigdata/laptop/citibike-nyc/2014-02.csv",
"bigdata/laptop/citibike-nyc/2014-03.csv",
"bigdata/laptop/citibike-nyc/2014-04.csv",
"bigdata/laptop/citibike-nyc/2014-05.csv",
"bigdata/laptop/citibike-nyc/2014-06.csv",
"bigdata/laptop/citibike-nyc/2014-07.csv",
"bigdata/laptop/citibike-nyc/2014-08.csv"]
# ----------
# 1- Load data - 1 row per bicycle trip. Has columns showing the start and end
# station, trip duration and trip start time and day. The larger dataset
# totals about 10 million rows
print "Import and Parse bike data"
data = h2o.import_frame(path=big_test)
# ----------
# 2- light data munging: group the bike starts per-day, converting the 10M rows
# of trips to about 140,000 station&day combos - predicting the number of trip
# starts per-station-per-day.
# Convert start time to: Day since the Epoch
startime = data["starttime"]
secsPerDay=1000*60*60*24
data["Days"] = (startime/secsPerDay).floor()
data.describe()
# Now do a monster Group-By. Count bike starts per-station per-day. Ends up
# with about 340 stations times 400 days (140,000 rows). This is what we want
# to predict.
ddplycols=["Days","start station name"]
bpd = h2o.ddply(data[ddplycols],ddplycols,"(%nrow)") # Compute bikes-per-day
bpd["C1"]._name = "bikes" # Rename column from generic name
# Quantiles: the data is fairly unbalanced; some station/day combos are wildly
# more popular than others.
print "Quantiles of bikes-per-day"
bpd["bikes"].quantile().show()
# A little feature engineering
# Add in month-of-year (seasonality; fewer bike rides in winter than summer)
secs = bpd["Days"]*secsPerDay
bpd["Month"] = secs.month()
# Add in day-of-week (work-week; more bike rides on Sunday than Monday)
bpd["DayOfWeek"] = secs.dayOfWeek()
print "Bikes-Per-Day"
bpd.describe()
# ----------
# 3- Fit a model on train; using test as validation
# Function for doing class test/train/holdout split
def split_fit_predict(data):
# Classic Test/Train split
r = data['Days'].runif() # Random UNIForm numbers, one per row
train = data[ r < 0.6]
test = data[(0.6 <= r) & (r < 0.9)]
hold = data[ 0.9 <= r ]
print "Training data has",train.ncol(),"columns and",train.nrow(),"rows, test has",test.nrow(),"rows, holdout has",hold.nrow()
# Run GBM
gbm = h2o.gbm(x =train.drop("bikes"),
y =train ["bikes"],
validation_x=test .drop("bikes"),
validation_y=test ["bikes"],
ntrees=500, # 500 works well
max_depth=6,
min_rows=10,
nbins=20,
learn_rate=0.1)
#gbm.show()
# Run GLM
glm = h2o.glm(x =train.drop("bikes"),
y =train ["bikes"],
validation_x=test .drop("bikes"),
validation_y=test ["bikes"],
drop_na20_cols=True)
#glm.show()
# ----------
# 4- Score on holdout set & report
train_r2_gbm = gbm.model_performance(train).r2()
test_r2_gbm = gbm.model_performance(test ).r2()
hold_r2_gbm = gbm.model_performance(hold ).r2()
print "GBM R2 TRAIN=",train_r2_gbm,", R2 TEST=",test_r2_gbm,", R2 HOLDOUT=",hold_r2_gbm
train_r2_glm = glm.model_performance(train).r2()
test_r2_glm = glm.model_performance(test ).r2()
hold_r2_glm = glm.model_performance(hold ).r2()
print "GLM R2 TRAIN=",train_r2_glm,", R2 TEST=",test_r2_glm,", R2 HOLDOUT=",hold_r2_glm
# --------------
# Split the data (into test & train), fit some models and predict on the holdout data
split_fit_predict(bpd)
# Here we see an r^2 of 0.91 for GBM, and 0.71 for GLM. This means given just
# the station, the month, and the day-of-week we can predict 90% of the
# variance of the bike-trip-starts.
# ----------
# 5- Now lets add some weather
# Load weather data
wthr1 = h2o.import_frame(path=["bigdata/laptop/citibike-nyc/31081_New_York_City__Hourly_2013.csv",
"bigdata/laptop/citibike-nyc/31081_New_York_City__Hourly_2014.csv"])
# Peek at the data
wthr1.describe()
# Lots of columns in there! Lets plan on converting to time-since-epoch to do
# a 'join' with the bike data, plus gather weather info that might affect
# cyclists - rain, snow, temperature. Alas, drop the "snow" column since it's
# all NA's. Also add in dew point and humidity just in case. Slice out just
# the columns of interest and drop the rest.
wthr2 = wthr1["Year Local","Month Local","Day Local","Hour Local","Dew Point (C)","Humidity Fraction","Precipitation One Hour (mm)","Temperature (C)","Weather Code 1/ Description"]
wthr2["Precipitation One Hour (mm)"]._name = "Rain (mm)" # Shorter column name
wthr2["Weather Code 1/ Description"]._name = "WC1" # Shorter column name
wthr2.describe()
# Much better!
# Lets make daily averages - which will be another group-by - and filter down to
# day-time bicycle weather (i.e., I'm ignoring the temperature at midnight here
# assuming there are fewer bike rides at midnight. There's a Better Way to do
# this, but I'm just making easy baby steps).
## Filtering first, between 7:00 and 19:00 (7am to 7pm). Note: want to do
## pythonic 7 <= col <= 19, but cannot overload the double-ended range operator
## (probably turns into a boolean operator over 2 exprs, but cannot overload the
## boolean)
#wthr3 = wthr2[ (7 <= wthr2["Hour Local"]) & (wthr2["Hour Local"] <= 19)]
#wthr3.describe()
## A quick check at the row count shows we chopped out about half the rows
## (since we chopped half the hours), and the min and max for the Hour column is
## in the range from 7am to 7pm.
# Filter down to the weather at Noon
wthr3 = wthr2[ wthr2["Hour Local"]==12 ]
# Lets now get Days since the epoch... we'll convert year/month/day into Epoch
# time, and then back to Epoch days. Need zero-based month and days, but have
# 1-based.
wthr3["msec"] = h2o.H2OVec.mktime(year=wthr3["Year Local"], month=wthr3["Month Local"]-1, day=wthr3["Day Local"]-1, hour=wthr3["Hour Local"])
secsPerDay=1000*60*60*24
wthr3["Days"] = (wthr3["msec"]/secsPerDay).floor()
wthr3.describe()
# msec looks sane (numbers like 1.3e12 are in the correct range for msec since
# 1970). Epoch Days matches closely with the epoch day numbers from the
# CitiBike dataset.
# Lets drop off the extra time columns to make a easy-to-handle dataset.
wthr4 = wthr3.drop("Year Local").drop("Month Local").drop("Day Local").drop("Hour Local").drop("msec")
# Also, most rain numbers are missing - lets assume those are zero rain days
rain = wthr4["Rain (mm)"]
rain[rain == None ] = 0
# ----------
# 6 - Join the weather data-per-day to the bike-starts-per-day
print "Merge Daily Weather with Bikes-Per-Day"
bpd_with_weather = bpd.merge(wthr4,allLeft=True,allRite=False)
bpd_with_weather.describe()
bpd_with_weather.show()
# 7 - Test/Train split again, model build again, this time with weather
split_fit_predict(bpd_with_weather)
|
apache-2.0
|
[
646,
394,
18,
79,
199,
199,
3,
7910,
28037,
282,
25780,
3918,
27491,
10431,
543,
869,
18,
47,
436,
2018,
199,
3,
199,
3,
3971,
279,
26,
465,
11734,
314,
5256,
402,
445,
5277,
34,
7455,
402,
653,
57,
35,
370,
2248,
13,
7358,
314,
330,
530,
89,
2265,
83,
199,
3,
9371,
314,
445,
5277,
34,
7455,
2784,
402,
410,
1298,
12,
701,
12610,
316,
314,
1329,
402,
330,
7455,
199,
3,
3229,
1190,
9394,
687,
314,
16518,
4036,
5382,
14,
221,
3645,
1616,
15949,
265,
4730,
402,
32530,
199,
3,
666,
12,
436,
21356,
1050,
29643,
666,
14,
421,
199,
3,
15175,
370,
282,
4350,
199,
72,
18,
79,
14,
826,
342,
199,
199,
3,
16568,
1902,
314,
7282,
503,
314,
7425,
14779,
14,
199,
3,
13123,
666,
365,
1616,
45,
4730,
199,
7241,
63,
396,
275,
2097,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
709,
14,
4737,
937,
199,
5076,
63,
396,
275,
257,
2097,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
1780,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
2036,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
1643,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
709,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
845,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
713,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
614,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
996,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
1644,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
966,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
1717,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
1690,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
1780,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
2036,
14,
4737,
937,
199,
199,
3,
4143,
199,
199,
3,
413,
13,
7190,
666,
446,
413,
1962,
1126,
330,
530,
89,
2265,
18038,
14,
221,
13481,
4362,
21207,
314,
1343,
436,
1284,
199,
3,
16518,
12,
18038,
7373,
436,
18038,
1343,
900,
436,
5382,
14,
221,
710,
12142,
4789,
199,
3,
23576,
3595,
1616,
15949,
265,
4730,
199,
1361,
298,
6295,
436,
6077,
330,
7455,
666,
2,
199,
576,
275,
394,
18,
79,
14,
646,
63,
1943,
8,
515,
29,
5076,
63,
396,
9,
421,
199,
3,
4143,
199,
199,
3,
499,
13,
10540,
666,
333,
324,
1540,
26,
1572,
314,
330,
7455,
9174,
1126,
13,
2977,
12,
13806,
314,
1616,
45,
4730,
199,
3,
402,
3229,
1190,
370,
3595,
22796,
12,
1493,
16518,
6,
2977,
20972,
83,
446,
12610,
316,
314,
1329,
402,
18038,
199,
3,
9174,
1126,
13,
10600,
13,
529,
13,
2977,
14,
199,
199,
3,
7905,
1343,
900,
370,
26,
28358,
3967,
314,
662,
5132,
199,
7848,
521,
275,
666,
905,
32183,
937,
199,
4855,
2623,
12631,
29,
5279,
10,
2259,
10,
2259,
10,
1194,
199,
576,
905,
25589,
937,
275,
334,
7848,
521,
15,
4855,
2623,
12631,
680,
11289,
342,
199,
576,
14,
11935,
342,
199,
199,
3,
7356,
886,
282,
3485,
11652,
5611,
13,
2175,
14,
221,
14826,
330,
7455,
9174,
1126,
13,
10600,
1126,
13,
2977,
14,
221,
3447,
795,
1536,
199,
3,
543,
3595,
650,
2167,
410,
1298,
5431,
8290,
7609,
334,
10037,
12,
1493,
4730,
680,
221,
961,
365,
4052,
781,
2934,
199,
3,
370,
12610,
14,
199,
617,
19786,
4574,
6270,
25589,
2266,
928,
16518,
536,
937,
199,
66,
8961,
275,
394,
18,
79,
14,
617,
19786,
8,
576,
59,
617,
19786,
4574,
467,
617,
19786,
4574,
4589,
4042,
78,
1143,
6320,
221,
327,
8354,
330,
3258,
397,
13,
529,
13,
2977,
199,
66,
8961,
905,
35,
17,
937,
423,
354,
275,
298,
66,
3258,
397,
2,
327,
22756,
2763,
687,
7809,
536,
199,
199,
3,
5843,
4466,
2978,
26,
314,
666,
365,
28092,
590,
625,
18923,
27,
2005,
16518,
15,
2977,
20972,
83,
787,
336,
668,
590,
199,
3,
1655,
4560,
2238,
2419,
11789,
14,
199,
1361,
298,
2371,
4466,
2978,
402,
330,
3258,
397,
13,
529,
13,
2977,
2,
199,
66,
8961,
905,
66,
3258,
397,
4140,
29249,
1252,
2384,
342,
199,
199,
3,
437,
12050,
3878,
6869,
15663,
199,
3,
2654,
315,
5794,
13,
1618,
13,
3403,
334,
12605,
6712,
27,
27392,
330,
7455,
221,
2188,
83,
315,
336,
1058,
2419,
3089,
2626,
9,
199,
4855,
275,
330,
8961,
905,
25589,
937,
10,
4855,
2623,
12631,
199,
66,
8961,
905,
14306,
937,
258,
275,
20091,
14,
4482,
342,
199,
3,
2654,
315,
5382,
13,
1618,
13,
6419,
334,
800,
13,
6419,
27,
1655,
330,
7455,
221,
2188,
83,
641,
428,
24759,
2419,
32740,
9,
199,
66,
8961,
905,
12631,
3466,
20995,
937,
275,
20091,
14,
2977,
3466,
20995,
342,
199,
1361,
298,
34,
3258,
397,
13,
2623,
13,
12631,
2,
199,
66,
8961,
14,
11935,
342,
421,
199,
3,
4143,
199,
3,
650,
13,
25971,
282,
1402,
641,
3560,
27,
1808,
511,
465,
6411,
199,
199,
3,
6801,
367,
9689,
1021,
511,
15,
2834,
15,
12239,
548,
3715,
199,
318,
3715,
63,
3269,
63,
6892,
8
] |
[
394,
18,
79,
199,
199,
3,
7910,
28037,
282,
25780,
3918,
27491,
10431,
543,
869,
18,
47,
436,
2018,
199,
3,
199,
3,
3971,
279,
26,
465,
11734,
314,
5256,
402,
445,
5277,
34,
7455,
402,
653,
57,
35,
370,
2248,
13,
7358,
314,
330,
530,
89,
2265,
83,
199,
3,
9371,
314,
445,
5277,
34,
7455,
2784,
402,
410,
1298,
12,
701,
12610,
316,
314,
1329,
402,
330,
7455,
199,
3,
3229,
1190,
9394,
687,
314,
16518,
4036,
5382,
14,
221,
3645,
1616,
15949,
265,
4730,
402,
32530,
199,
3,
666,
12,
436,
21356,
1050,
29643,
666,
14,
421,
199,
3,
15175,
370,
282,
4350,
199,
72,
18,
79,
14,
826,
342,
199,
199,
3,
16568,
1902,
314,
7282,
503,
314,
7425,
14779,
14,
199,
3,
13123,
666,
365,
1616,
45,
4730,
199,
7241,
63,
396,
275,
2097,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
709,
14,
4737,
937,
199,
5076,
63,
396,
275,
257,
2097,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
1780,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
2036,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
1643,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
709,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
845,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
6965,
13,
713,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
614,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
996,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
1644,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
966,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
1717,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
1690,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
1780,
14,
4737,
401,
1598,
298,
5076,
576,
15,
416,
541,
411,
15,
559,
280,
4492,
415,
13,
9745,
67,
15,
7280,
13,
2036,
14,
4737,
937,
199,
199,
3,
4143,
199,
199,
3,
413,
13,
7190,
666,
446,
413,
1962,
1126,
330,
530,
89,
2265,
18038,
14,
221,
13481,
4362,
21207,
314,
1343,
436,
1284,
199,
3,
16518,
12,
18038,
7373,
436,
18038,
1343,
900,
436,
5382,
14,
221,
710,
12142,
4789,
199,
3,
23576,
3595,
1616,
15949,
265,
4730,
199,
1361,
298,
6295,
436,
6077,
330,
7455,
666,
2,
199,
576,
275,
394,
18,
79,
14,
646,
63,
1943,
8,
515,
29,
5076,
63,
396,
9,
421,
199,
3,
4143,
199,
199,
3,
499,
13,
10540,
666,
333,
324,
1540,
26,
1572,
314,
330,
7455,
9174,
1126,
13,
2977,
12,
13806,
314,
1616,
45,
4730,
199,
3,
402,
3229,
1190,
370,
3595,
22796,
12,
1493,
16518,
6,
2977,
20972,
83,
446,
12610,
316,
314,
1329,
402,
18038,
199,
3,
9174,
1126,
13,
10600,
13,
529,
13,
2977,
14,
199,
199,
3,
7905,
1343,
900,
370,
26,
28358,
3967,
314,
662,
5132,
199,
7848,
521,
275,
666,
905,
32183,
937,
199,
4855,
2623,
12631,
29,
5279,
10,
2259,
10,
2259,
10,
1194,
199,
576,
905,
25589,
937,
275,
334,
7848,
521,
15,
4855,
2623,
12631,
680,
11289,
342,
199,
576,
14,
11935,
342,
199,
199,
3,
7356,
886,
282,
3485,
11652,
5611,
13,
2175,
14,
221,
14826,
330,
7455,
9174,
1126,
13,
10600,
1126,
13,
2977,
14,
221,
3447,
795,
1536,
199,
3,
543,
3595,
650,
2167,
410,
1298,
5431,
8290,
7609,
334,
10037,
12,
1493,
4730,
680,
221,
961,
365,
4052,
781,
2934,
199,
3,
370,
12610,
14,
199,
617,
19786,
4574,
6270,
25589,
2266,
928,
16518,
536,
937,
199,
66,
8961,
275,
394,
18,
79,
14,
617,
19786,
8,
576,
59,
617,
19786,
4574,
467,
617,
19786,
4574,
4589,
4042,
78,
1143,
6320,
221,
327,
8354,
330,
3258,
397,
13,
529,
13,
2977,
199,
66,
8961,
905,
35,
17,
937,
423,
354,
275,
298,
66,
3258,
397,
2,
327,
22756,
2763,
687,
7809,
536,
199,
199,
3,
5843,
4466,
2978,
26,
314,
666,
365,
28092,
590,
625,
18923,
27,
2005,
16518,
15,
2977,
20972,
83,
787,
336,
668,
590,
199,
3,
1655,
4560,
2238,
2419,
11789,
14,
199,
1361,
298,
2371,
4466,
2978,
402,
330,
3258,
397,
13,
529,
13,
2977,
2,
199,
66,
8961,
905,
66,
3258,
397,
4140,
29249,
1252,
2384,
342,
199,
199,
3,
437,
12050,
3878,
6869,
15663,
199,
3,
2654,
315,
5794,
13,
1618,
13,
3403,
334,
12605,
6712,
27,
27392,
330,
7455,
221,
2188,
83,
315,
336,
1058,
2419,
3089,
2626,
9,
199,
4855,
275,
330,
8961,
905,
25589,
937,
10,
4855,
2623,
12631,
199,
66,
8961,
905,
14306,
937,
258,
275,
20091,
14,
4482,
342,
199,
3,
2654,
315,
5382,
13,
1618,
13,
6419,
334,
800,
13,
6419,
27,
1655,
330,
7455,
221,
2188,
83,
641,
428,
24759,
2419,
32740,
9,
199,
66,
8961,
905,
12631,
3466,
20995,
937,
275,
20091,
14,
2977,
3466,
20995,
342,
199,
1361,
298,
34,
3258,
397,
13,
2623,
13,
12631,
2,
199,
66,
8961,
14,
11935,
342,
421,
199,
3,
4143,
199,
3,
650,
13,
25971,
282,
1402,
641,
3560,
27,
1808,
511,
465,
6411,
199,
199,
3,
6801,
367,
9689,
1021,
511,
15,
2834,
15,
12239,
548,
3715,
199,
318,
3715,
63,
3269,
63,
6892,
8,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tectronics/evennia
|
src/server/migrations/0002_fix_config_value.py
|
2
|
9134
|
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models, utils
import pickle
class Migration(DataMigration):
def forwards(self, orm):
"Write your forwards methods here."
# we are fixing a situation were the serverconfig value last_initial_setup_step was left at 1 instead of -1
# as it should (due to a bug in the setter). This causes db errors as the initial_setup thinks it needs to
# run again.
try:
if orm['objects.ObjectDB'].objects.filter(id=1) and orm["objects.ObjectDB"].objects.filter(id=2):
# only an issue the critical objects have already been created
conf = orm.ServerConfig.objects.filter(db_key="last_initial_setup_step")
if conf:
conf = conf[0]
if pickle.loads(str(conf.db_value)) == 1:
# this shouldn't be 1 if objects already exists. This is the bug. Fix the error.
conf.db_value = pickle.dumps(-1)
conf.save()
except utils.DatabaseError:
# this will happen if we start the db from scratch (in which case this migration fix is not needed)
db.commit_transaction()
db.start_transaction()
pass
def backwards(self, orm):
"Write your backwards methods here."
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'objects.alias': {
'Meta': {'object_name': 'Alias'},
'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['objects.ObjectDB']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'objects.nick': {
'Meta': {'unique_together': "(('db_nick', 'db_type', 'db_obj'),)", 'object_name': 'Nick'},
'db_nick': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['objects.ObjectDB']"}),
'db_real': ('django.db.models.fields.TextField', [], {}),
'db_type': ('django.db.models.fields.CharField', [], {'default': "'inputline'", 'max_length': '16', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'objects.objattribute': {
'Meta': {'object_name': 'ObjAttribute'},
'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['objects.ObjectDB']"}),
'db_value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'objects.objectdb': {
'Meta': {'object_name': 'ObjectDB'},
'db_cmdset_storage': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'db_destination': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'destinations_set'", 'null': 'True', 'to': "orm['objects.ObjectDB']"}),
'db_home': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'homes_set'", 'null': 'True', 'to': "orm['objects.ObjectDB']"}),
'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'db_location': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locations_set'", 'null': 'True', 'to': "orm['objects.ObjectDB']"}),
'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
'db_player': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['players.PlayerDB']", 'null': 'True', 'blank': 'True'}),
'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'players.playerdb': {
'Meta': {'object_name': 'PlayerDB'},
'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['objects.ObjectDB']", 'null': 'True'}),
'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'})
},
'server.serverconfig': {
'Meta': {'object_name': 'ServerConfig'},
'db_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}),
'db_value': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
}
}
complete_apps = ['objects', 'server']
|
bsd-3-clause
|
[
3,
2644,
26,
2774,
13,
24,
199,
646,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
3918,
9816,
199,
504,
1639,
14,
697,
492,
1709,
12,
3778,
199,
646,
5927,
221,
421,
199,
533,
12090,
8,
1451,
9816,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
17465,
3102,
2348,
2122,
2728,
327,
781,
787,
5325,
316,
282,
25781,
4898,
314,
1654,
888,
574,
2061,
63,
2747,
63,
2758,
63,
2926,
1990,
3602,
737,
413,
3140,
402,
446,
17,
267,
327,
465,
652,
1077,
334,
11933,
370,
282,
6519,
315,
314,
18743,
680,
961,
14486,
1592,
2552,
465,
314,
2536,
63,
2758,
13516,
83,
652,
4839,
370,
4960,
327,
1255,
4020,
14,
221,
2728,
862,
26,
288,
340,
9813,
459,
1462,
14,
1692,
2846,
2278,
1462,
14,
1541,
8,
344,
29,
17,
9,
436,
9813,
905,
1462,
14,
1692,
2846,
4140,
1462,
14,
1541,
8,
344,
29,
18,
304,
355,
327,
1454,
376,
4976,
314,
19698,
2251,
1172,
2575,
2757,
2737,
355,
3743,
275,
9813,
14,
3120,
2028,
14,
1462,
14,
1541,
8,
697,
63,
498,
628,
2019,
63,
2747,
63,
2758,
63,
2926,
531,
355,
340,
3743,
26,
490,
3743,
275,
3743,
59,
16,
61,
490,
340,
5927,
14,
3640,
8,
495,
8,
2190,
14,
697,
63,
585,
430,
508,
413,
26,
717,
327,
642,
9296,
1133,
506,
413,
340,
2251,
2575,
3495,
14,
961,
365,
314,
6519,
14,
14811,
314,
1125,
14,
717,
3743,
14,
697,
63,
585,
275,
5927,
14,
4180,
2801,
17,
9,
717,
3743,
14,
2117,
342,
267,
871,
3778,
14,
25198,
26,
288,
327,
642,
911,
5992,
340,
781,
1343,
314,
1592,
687,
28975,
334,
262,
1314,
1930,
642,
8367,
5325,
365,
440,
4346,
9,
288,
1592,
14,
3543,
63,
5945,
342,
288,
1592,
14,
928,
63,
5945,
342,
288,
986,
2378,
347,
8552,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
8552,
3102,
2348,
2122,
2378,
1709,
275,
469,
267,
283,
1178,
14,
923,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
2448,
2267,
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,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1257,
1604,
288,
283,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
3071,
267,
1660,
267,
283,
1178,
14,
5693,
356,
469,
288,
283,
3396,
356,
791,
7128,
356,
16111,
1317,
63,
466,
363,
571,
63,
1302,
297,
283,
1317,
63,
466,
363,
1238,
297,
283,
11879,
18106,
283,
3235,
63,
6314,
356,
9510,
1317,
63,
466,
297,
283,
11879,
9878,
283,
785,
63,
354,
356,
283,
7980,
2267,
288,
283,
11879,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1960,
1604,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
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,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
3071,
267,
1660,
267,
283,
1178,
14,
751,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1899,
2267,
288,
283,
602,
63,
11806,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2123,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
16577,
297,
990,
791,
988,
63,
1267,
356,
283,
2194,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2246,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2634,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
2448,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
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,
374,
63,
2682,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
549,
1604,
288,
283,
374,
63,
7018,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
374,
63,
11434,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
2019,
63,
2886,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2019,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
3933,
1604,
288,
283,
751,
63,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2473,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1216,
3071,
267,
1660,
267,
283,
10778,
14,
20735,
356,
469,
288,
283,
3396,
356,
791,
7128,
356,
16111,
354,
21099,
283,
3235,
63
] |
[
2644,
26,
2774,
13,
24,
199,
646,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
3918,
9816,
199,
504,
1639,
14,
697,
492,
1709,
12,
3778,
199,
646,
5927,
221,
421,
199,
533,
12090,
8,
1451,
9816,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
17465,
3102,
2348,
2122,
2728,
327,
781,
787,
5325,
316,
282,
25781,
4898,
314,
1654,
888,
574,
2061,
63,
2747,
63,
2758,
63,
2926,
1990,
3602,
737,
413,
3140,
402,
446,
17,
267,
327,
465,
652,
1077,
334,
11933,
370,
282,
6519,
315,
314,
18743,
680,
961,
14486,
1592,
2552,
465,
314,
2536,
63,
2758,
13516,
83,
652,
4839,
370,
4960,
327,
1255,
4020,
14,
221,
2728,
862,
26,
288,
340,
9813,
459,
1462,
14,
1692,
2846,
2278,
1462,
14,
1541,
8,
344,
29,
17,
9,
436,
9813,
905,
1462,
14,
1692,
2846,
4140,
1462,
14,
1541,
8,
344,
29,
18,
304,
355,
327,
1454,
376,
4976,
314,
19698,
2251,
1172,
2575,
2757,
2737,
355,
3743,
275,
9813,
14,
3120,
2028,
14,
1462,
14,
1541,
8,
697,
63,
498,
628,
2019,
63,
2747,
63,
2758,
63,
2926,
531,
355,
340,
3743,
26,
490,
3743,
275,
3743,
59,
16,
61,
490,
340,
5927,
14,
3640,
8,
495,
8,
2190,
14,
697,
63,
585,
430,
508,
413,
26,
717,
327,
642,
9296,
1133,
506,
413,
340,
2251,
2575,
3495,
14,
961,
365,
314,
6519,
14,
14811,
314,
1125,
14,
717,
3743,
14,
697,
63,
585,
275,
5927,
14,
4180,
2801,
17,
9,
717,
3743,
14,
2117,
342,
267,
871,
3778,
14,
25198,
26,
288,
327,
642,
911,
5992,
340,
781,
1343,
314,
1592,
687,
28975,
334,
262,
1314,
1930,
642,
8367,
5325,
365,
440,
4346,
9,
288,
1592,
14,
3543,
63,
5945,
342,
288,
1592,
14,
928,
63,
5945,
342,
288,
986,
2378,
347,
8552,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
8552,
3102,
2348,
2122,
2378,
1709,
275,
469,
267,
283,
1178,
14,
923,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
2448,
2267,
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,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1257,
1604,
288,
283,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
3071,
267,
1660,
267,
283,
1178,
14,
5693,
356,
469,
288,
283,
3396,
356,
791,
7128,
356,
16111,
1317,
63,
466,
363,
571,
63,
1302,
297,
283,
1317,
63,
466,
363,
1238,
297,
283,
11879,
18106,
283,
3235,
63,
6314,
356,
9510,
1317,
63,
466,
297,
283,
11879,
9878,
283,
785,
63,
354,
356,
283,
7980,
2267,
288,
283,
11879,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1960,
1604,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
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,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
3071,
267,
1660,
267,
283,
1178,
14,
751,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1899,
2267,
288,
283,
602,
63,
11806,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2123,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
16577,
297,
990,
791,
988,
63,
1267,
356,
283,
2194,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2246,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2634,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
2448,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
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,
374,
63,
2682,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
549,
1604,
288,
283,
374,
63,
7018,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
374,
63,
11434,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
2019,
63,
2886,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2019,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
3933,
1604,
288,
283,
751,
63,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2473,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1216,
3071,
267,
1660,
267,
283,
10778,
14,
20735,
356,
469,
288,
283,
3396,
356,
791,
7128,
356,
16111,
354,
21099,
283,
3235,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
vFense/vFenseAgent-nix
|
agent/deps/rpm6/Python-2.7.5/lib/python2.7/test/test_threadedtempfile.py
|
111
|
2214
|
"""
Create and delete FILES_PER_THREAD temp files (via tempfile.TemporaryFile)
in each of NUM_THREADS threads, recording the number of successes and
failures. A failure is a bug in tempfile, and may be due to:
+ Trying to create more than one tempfile with the same name.
+ Trying to delete a tempfile that doesn't still exist.
+ Something we've never seen before.
By default, NUM_THREADS == 20 and FILES_PER_THREAD == 50. This is enough to
create about 150 failures per run under Win98SE in 2.0, and runs pretty
quickly. Guido reports needing to boost FILES_PER_THREAD to 500 before
provoking a 2.0 failure under Linux.
"""
NUM_THREADS = 20
FILES_PER_THREAD = 50
import tempfile
from test.test_support import threading_setup, threading_cleanup, run_unittest, import_module
threading = import_module('threading')
import unittest
import StringIO
from traceback import print_exc
startEvent = threading.Event()
class TempFileGreedy(threading.Thread):
error_count = 0
ok_count = 0
def run(self):
self.errors = StringIO.StringIO()
startEvent.wait()
for i in range(FILES_PER_THREAD):
try:
f = tempfile.TemporaryFile("w+b")
f.close()
except:
self.error_count += 1
print_exc(file=self.errors)
else:
self.ok_count += 1
class ThreadedTempFileTest(unittest.TestCase):
def test_main(self):
threads = []
thread_info = threading_setup()
for i in range(NUM_THREADS):
t = TempFileGreedy()
threads.append(t)
t.start()
startEvent.set()
ok = 0
errors = []
for t in threads:
t.join()
ok += t.ok_count
if t.error_count:
errors.append(str(t.getName()) + str(t.errors.getvalue()))
threading_cleanup(*thread_info)
msg = "Errors: errors %d ok %d\n%s" % (len(errors), ok,
'\n'.join(errors))
self.assertEqual(errors, [], msg)
self.assertEqual(ok, NUM_THREADS * FILES_PER_THREAD)
def test_main():
run_unittest(ThreadedTempFileTest)
if __name__ == "__main__":
test_main()
|
lgpl-3.0
|
[
624,
199,
2499,
436,
3145,
16444,
654,
63,
4227,
63,
16103,
2388,
1584,
334,
12897,
5549,
14,
13271,
9,
199,
262,
1924,
402,
11576,
63,
16103,
51,
7183,
12,
20952,
314,
1329,
402,
24830,
436,
199,
9968,
14,
221,
437,
5988,
365,
282,
6519,
315,
5549,
12,
436,
1443,
506,
7037,
370,
26,
199,
199,
11,
7649,
316,
370,
1218,
1655,
2419,
1373,
5549,
543,
314,
2011,
536,
14,
199,
11,
7649,
316,
370,
3145,
282,
5549,
626,
3181,
1133,
5139,
2187,
14,
199,
11,
27173,
781,
9064,
7078,
6775,
2544,
14,
199,
199,
2175,
849,
12,
11576,
63,
16103,
51,
508,
3388,
436,
16444,
654,
63,
4227,
63,
16103,
508,
5238,
14,
221,
961,
365,
8321,
370,
199,
981,
3595,
14711,
9081,
1126,
1255,
1334,
13036,
2905,
899,
315,
499,
14,
16,
12,
436,
7858,
7268,
199,
13239,
590,
14,
598,
1535,
79,
13924,
1929,
316,
370,
20198,
16444,
654,
63,
4227,
63,
16103,
370,
6891,
2544,
199,
20397,
17967,
282,
499,
14,
16,
5988,
1334,
10130,
14,
199,
624,
199,
199,
7125,
63,
16103,
51,
275,
3388,
199,
9472,
63,
4227,
63,
16103,
275,
5238,
199,
199,
646,
5549,
199,
199,
504,
511,
14,
396,
63,
4058,
492,
5796,
63,
2758,
12,
5796,
63,
7661,
12,
1255,
63,
2796,
12,
492,
63,
578,
199,
12562,
275,
492,
63,
578,
360,
12562,
358,
199,
646,
2882,
199,
646,
5228,
199,
504,
5190,
492,
870,
63,
2804,
199,
199,
928,
2390,
275,
5796,
14,
2390,
342,
199,
199,
533,
12540,
1173,
39,
24737,
8,
12562,
14,
4436,
304,
272,
1125,
63,
835,
275,
378,
272,
4112,
63,
835,
275,
378,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
2550,
275,
5228,
14,
6424,
342,
267,
1343,
2390,
14,
2573,
342,
267,
367,
284,
315,
1425,
8,
9472,
63,
4227,
63,
16103,
304,
288,
862,
26,
355,
289,
275,
5549,
14,
13271,
480,
87,
11,
66,
531,
355,
289,
14,
1600,
342,
288,
871,
26,
355,
291,
14,
705,
63,
835,
847,
413,
355,
870,
63,
2804,
8,
493,
29,
277,
14,
2550,
9,
288,
587,
26,
355,
291,
14,
745,
63,
835,
847,
413,
421,
199,
533,
3868,
11698,
6530,
1173,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
973,
8,
277,
304,
267,
7183,
275,
942,
267,
2462,
63,
815,
275,
5796,
63,
2758,
342,
398,
367,
284,
315,
1425,
8,
7125,
63,
16103,
51,
304,
288,
307,
275,
12540,
1173,
39,
24737,
342,
288,
7183,
14,
740,
8,
84,
9,
288,
307,
14,
928,
342,
398,
1343,
2390,
14,
409,
342,
398,
4112,
275,
378,
267,
2552,
275,
942,
267,
367,
307,
315,
7183,
26,
288,
307,
14,
904,
342,
288,
4112,
847,
307,
14,
745,
63,
835,
288,
340,
307,
14,
705,
63,
835,
26,
355,
2552,
14,
740,
8,
495,
8,
84,
14,
16405,
1012,
435,
620,
8,
84,
14,
2550,
14,
7150,
4059,
398,
5796,
63,
7661,
2031,
2671,
63,
815,
9,
398,
1499,
275,
298,
9298,
26,
2552,
450,
68,
4112,
450,
68,
60,
78,
5,
83,
2,
450,
334,
552,
8,
2550,
395,
4112,
12,
288,
1557,
78,
1370,
904,
8,
2550,
430,
267,
291,
14,
629,
8,
2550,
12,
990,
1499,
9,
267,
291,
14,
629,
8,
745,
12,
11576,
63,
16103,
51,
627,
16444,
654,
63,
4227,
63,
16103,
9,
199,
199,
318,
511,
63,
973,
837,
272,
1255,
63,
2796,
8,
31699,
6530,
1173,
774,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
511,
63,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
2499,
436,
3145,
16444,
654,
63,
4227,
63,
16103,
2388,
1584,
334,
12897,
5549,
14,
13271,
9,
199,
262,
1924,
402,
11576,
63,
16103,
51,
7183,
12,
20952,
314,
1329,
402,
24830,
436,
199,
9968,
14,
221,
437,
5988,
365,
282,
6519,
315,
5549,
12,
436,
1443,
506,
7037,
370,
26,
199,
199,
11,
7649,
316,
370,
1218,
1655,
2419,
1373,
5549,
543,
314,
2011,
536,
14,
199,
11,
7649,
316,
370,
3145,
282,
5549,
626,
3181,
1133,
5139,
2187,
14,
199,
11,
27173,
781,
9064,
7078,
6775,
2544,
14,
199,
199,
2175,
849,
12,
11576,
63,
16103,
51,
508,
3388,
436,
16444,
654,
63,
4227,
63,
16103,
508,
5238,
14,
221,
961,
365,
8321,
370,
199,
981,
3595,
14711,
9081,
1126,
1255,
1334,
13036,
2905,
899,
315,
499,
14,
16,
12,
436,
7858,
7268,
199,
13239,
590,
14,
598,
1535,
79,
13924,
1929,
316,
370,
20198,
16444,
654,
63,
4227,
63,
16103,
370,
6891,
2544,
199,
20397,
17967,
282,
499,
14,
16,
5988,
1334,
10130,
14,
199,
624,
199,
199,
7125,
63,
16103,
51,
275,
3388,
199,
9472,
63,
4227,
63,
16103,
275,
5238,
199,
199,
646,
5549,
199,
199,
504,
511,
14,
396,
63,
4058,
492,
5796,
63,
2758,
12,
5796,
63,
7661,
12,
1255,
63,
2796,
12,
492,
63,
578,
199,
12562,
275,
492,
63,
578,
360,
12562,
358,
199,
646,
2882,
199,
646,
5228,
199,
504,
5190,
492,
870,
63,
2804,
199,
199,
928,
2390,
275,
5796,
14,
2390,
342,
199,
199,
533,
12540,
1173,
39,
24737,
8,
12562,
14,
4436,
304,
272,
1125,
63,
835,
275,
378,
272,
4112,
63,
835,
275,
378,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
2550,
275,
5228,
14,
6424,
342,
267,
1343,
2390,
14,
2573,
342,
267,
367,
284,
315,
1425,
8,
9472,
63,
4227,
63,
16103,
304,
288,
862,
26,
355,
289,
275,
5549,
14,
13271,
480,
87,
11,
66,
531,
355,
289,
14,
1600,
342,
288,
871,
26,
355,
291,
14,
705,
63,
835,
847,
413,
355,
870,
63,
2804,
8,
493,
29,
277,
14,
2550,
9,
288,
587,
26,
355,
291,
14,
745,
63,
835,
847,
413,
421,
199,
533,
3868,
11698,
6530,
1173,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
973,
8,
277,
304,
267,
7183,
275,
942,
267,
2462,
63,
815,
275,
5796,
63,
2758,
342,
398,
367,
284,
315,
1425,
8,
7125,
63,
16103,
51,
304,
288,
307,
275,
12540,
1173,
39,
24737,
342,
288,
7183,
14,
740,
8,
84,
9,
288,
307,
14,
928,
342,
398,
1343,
2390,
14,
409,
342,
398,
4112,
275,
378,
267,
2552,
275,
942,
267,
367,
307,
315,
7183,
26,
288,
307,
14,
904,
342,
288,
4112,
847,
307,
14,
745,
63,
835,
288,
340,
307,
14,
705,
63,
835,
26,
355,
2552,
14,
740,
8,
495,
8,
84,
14,
16405,
1012,
435,
620,
8,
84,
14,
2550,
14,
7150,
4059,
398,
5796,
63,
7661,
2031,
2671,
63,
815,
9,
398,
1499,
275,
298,
9298,
26,
2552,
450,
68,
4112,
450,
68,
60,
78,
5,
83,
2,
450,
334,
552,
8,
2550,
395,
4112,
12,
288,
1557,
78,
1370,
904,
8,
2550,
430,
267,
291,
14,
629,
8,
2550,
12,
990,
1499,
9,
267,
291,
14,
629,
8,
745,
12,
11576,
63,
16103,
51,
627,
16444,
654,
63,
4227,
63,
16103,
9,
199,
199,
318,
511,
63,
973,
837,
272,
1255,
63,
2796,
8,
31699,
6530,
1173,
774,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
511,
63,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
RazerM/logbook
|
logbook/__init__.py
|
3
|
1722
|
# -*- coding: utf-8 -*-
"""
logbook
~~~~~~~
Simple logging library that aims to support desktop, command line
and web applications alike.
:copyright: (c) 2010 by Armin Ronacher, Georg Brandl.
:license: BSD, see LICENSE for more details.
"""
import os
from .base import (
LogRecord, Logger, LoggerGroup, NestedSetup, Processor, Flags,
get_level_name, lookup_level, dispatch_record, CRITICAL, ERROR, WARNING,
NOTICE, INFO, DEBUG, TRACE, NOTSET, set_datetime_format)
from .handlers import (
Handler, StreamHandler, FileHandler, MonitoringFileHandler, StderrHandler,
RotatingFileHandler, TimedRotatingFileHandler, TestHandler, MailHandler,
GMailHandler, SyslogHandler, NullHandler, NTEventLogHandler,
create_syshandler, StringFormatter, StringFormatterHandlerMixin,
HashingHandlerMixin, LimitingHandlerMixin, WrapperHandler,
FingersCrossedHandler, GroupHandler)
from . import compat
# create an anonymous default logger and provide all important
# methods of that logger as global functions
_default_logger = Logger('Generic')
_default_logger.suppress_dispatcher = True
trace = _default_logger.trace
debug = _default_logger.debug
info = _default_logger.info
warn = _default_logger.warn
warning = _default_logger.warning
notice = _default_logger.notice
error = _default_logger.error
exception = _default_logger.exception
catch_exceptions = _default_logger.catch_exceptions
critical = _default_logger.critical
log = _default_logger.log
del _default_logger
# install a default global handler
if os.environ.get('LOGBOOK_INSTALL_DEFAULT_HANDLER'):
default_handler = StderrHandler()
default_handler.push_application()
from .__version__ import __version__
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
943,
2706,
272,
221,
2878,
23597,
339,
5870,
2050,
3555,
626,
282,
11171,
370,
2291,
19763,
12,
1414,
1004,
272,
436,
3330,
13103,
741,
7455,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
1952,
827,
32472,
19728,
12,
5346,
1308,
699,
3759,
76,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
199,
646,
747,
199,
504,
1275,
1095,
492,
334,
272,
5297,
5433,
12,
15996,
12,
15996,
2448,
12,
23137,
8555,
12,
221,
31500,
12,
24870,
12,
272,
664,
63,
1896,
63,
354,
12,
4237,
63,
1896,
12,
7634,
63,
3059,
12,
17101,
19223,
12,
12539,
12,
14750,
12,
272,
12840,
12,
24008,
12,
10990,
12,
9074,
4121,
12,
2845,
3597,
12,
663,
63,
2083,
63,
908,
9,
199,
504,
1275,
5586,
492,
334,
272,
18599,
12,
8271,
2461,
12,
3814,
2461,
12,
26504,
316,
21982,
12,
1933,
2303,
2461,
12,
272,
20423,
1958,
21982,
12,
4703,
68,
14728,
1958,
21982,
12,
1379,
2461,
12,
18027,
2461,
12,
272,
598,
13681,
2461,
12,
28766,
793,
2461,
12,
12119,
2461,
12,
23350,
2390,
2445,
2461,
12,
272,
1218,
63,
1274,
2232,
12,
2624,
7772,
12,
2624,
7772,
2461,
4256,
12,
272,
16101,
316,
2461,
4256,
12,
22672,
316,
2461,
4256,
12,
21947,
2461,
12,
272,
481,
316,
1192,
35,
4796,
939,
2461,
12,
5611,
2461,
9,
199,
504,
1275,
492,
8434,
421,
199,
3,
1218,
376,
16535,
849,
2512,
436,
5647,
1006,
11012,
199,
3,
3102,
402,
626,
2512,
465,
2288,
3423,
199,
63,
885,
63,
2921,
275,
15996,
360,
9417,
358,
199,
63,
885,
63,
2921,
14,
17381,
63,
14913,
275,
715,
199,
3446,
275,
485,
885,
63,
2921,
14,
3446,
199,
1757,
275,
485,
885,
63,
2921,
14,
1757,
199,
815,
275,
485,
885,
63,
2921,
14,
815,
199,
4050,
275,
485,
885,
63,
2921,
14,
4050,
199,
3764,
275,
485,
885,
63,
2921,
14,
3764,
199,
20556,
275,
485,
885,
63,
2921,
14,
20556,
199,
705,
275,
485,
885,
63,
2921,
14,
705,
199,
1971,
275,
485,
885,
63,
2921,
14,
1971,
199,
9341,
63,
3924,
275,
485,
885,
63,
2921,
14,
9341,
63,
3924,
199,
13138,
275,
485,
885,
63,
2921,
14,
13138,
199,
793,
275,
485,
885,
63,
2921,
14,
793,
199,
2264,
485,
885,
63,
2921,
421,
199,
3,
3907,
282,
849,
2288,
3016,
199,
692,
747,
14,
2314,
14,
362,
360,
4947,
21155,
63,
16811,
63,
3472,
63,
30872,
735,
272,
849,
63,
2232,
275,
1933,
2303,
2461,
342,
272,
849,
63,
2232,
14,
5335,
63,
3578,
342,
199,
199,
504,
221,
855,
1023,
363,
492,
636,
1023,
363,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
943,
2706,
272,
221,
2878,
23597,
339,
5870,
2050,
3555,
626,
282,
11171,
370,
2291,
19763,
12,
1414,
1004,
272,
436,
3330,
13103,
741,
7455,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
1952,
827,
32472,
19728,
12,
5346,
1308,
699,
3759,
76,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
199,
646,
747,
199,
504,
1275,
1095,
492,
334,
272,
5297,
5433,
12,
15996,
12,
15996,
2448,
12,
23137,
8555,
12,
221,
31500,
12,
24870,
12,
272,
664,
63,
1896,
63,
354,
12,
4237,
63,
1896,
12,
7634,
63,
3059,
12,
17101,
19223,
12,
12539,
12,
14750,
12,
272,
12840,
12,
24008,
12,
10990,
12,
9074,
4121,
12,
2845,
3597,
12,
663,
63,
2083,
63,
908,
9,
199,
504,
1275,
5586,
492,
334,
272,
18599,
12,
8271,
2461,
12,
3814,
2461,
12,
26504,
316,
21982,
12,
1933,
2303,
2461,
12,
272,
20423,
1958,
21982,
12,
4703,
68,
14728,
1958,
21982,
12,
1379,
2461,
12,
18027,
2461,
12,
272,
598,
13681,
2461,
12,
28766,
793,
2461,
12,
12119,
2461,
12,
23350,
2390,
2445,
2461,
12,
272,
1218,
63,
1274,
2232,
12,
2624,
7772,
12,
2624,
7772,
2461,
4256,
12,
272,
16101,
316,
2461,
4256,
12,
22672,
316,
2461,
4256,
12,
21947,
2461,
12,
272,
481,
316,
1192,
35,
4796,
939,
2461,
12,
5611,
2461,
9,
199,
504,
1275,
492,
8434,
421,
199,
3,
1218,
376,
16535,
849,
2512,
436,
5647,
1006,
11012,
199,
3,
3102,
402,
626,
2512,
465,
2288,
3423,
199,
63,
885,
63,
2921,
275,
15996,
360,
9417,
358,
199,
63,
885,
63,
2921,
14,
17381,
63,
14913,
275,
715,
199,
3446,
275,
485,
885,
63,
2921,
14,
3446,
199,
1757,
275,
485,
885,
63,
2921,
14,
1757,
199,
815,
275,
485,
885,
63,
2921,
14,
815,
199,
4050,
275,
485,
885,
63,
2921,
14,
4050,
199,
3764,
275,
485,
885,
63,
2921,
14,
3764,
199,
20556,
275,
485,
885,
63,
2921,
14,
20556,
199,
705,
275,
485,
885,
63,
2921,
14,
705,
199,
1971,
275,
485,
885,
63,
2921,
14,
1971,
199,
9341,
63,
3924,
275,
485,
885,
63,
2921,
14,
9341,
63,
3924,
199,
13138,
275,
485,
885,
63,
2921,
14,
13138,
199,
793,
275,
485,
885,
63,
2921,
14,
793,
199,
2264,
485,
885,
63,
2921,
421,
199,
3,
3907,
282,
849,
2288,
3016,
199,
692,
747,
14,
2314,
14,
362,
360,
4947,
21155,
63,
16811,
63,
3472,
63,
30872,
735,
272,
849,
63,
2232,
275,
1933,
2303,
2461,
342,
272,
849,
63,
2232,
14,
5335,
63,
3578,
342,
199,
199,
504,
221,
855,
1023,
363,
492,
636,
1023,
363,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jlspyaozhongkai/Uter
|
third_party_backup/Python-2.7.9/Lib/curses/has_key.py
|
154
|
5627
|
#
# Emulation of has_key() function for platforms that don't use ncurses
#
import _curses
# Table mapping curses keys to the terminfo capability name
_capability_names = {
_curses.KEY_A1: 'ka1',
_curses.KEY_A3: 'ka3',
_curses.KEY_B2: 'kb2',
_curses.KEY_BACKSPACE: 'kbs',
_curses.KEY_BEG: 'kbeg',
_curses.KEY_BTAB: 'kcbt',
_curses.KEY_C1: 'kc1',
_curses.KEY_C3: 'kc3',
_curses.KEY_CANCEL: 'kcan',
_curses.KEY_CATAB: 'ktbc',
_curses.KEY_CLEAR: 'kclr',
_curses.KEY_CLOSE: 'kclo',
_curses.KEY_COMMAND: 'kcmd',
_curses.KEY_COPY: 'kcpy',
_curses.KEY_CREATE: 'kcrt',
_curses.KEY_CTAB: 'kctab',
_curses.KEY_DC: 'kdch1',
_curses.KEY_DL: 'kdl1',
_curses.KEY_DOWN: 'kcud1',
_curses.KEY_EIC: 'krmir',
_curses.KEY_END: 'kend',
_curses.KEY_ENTER: 'kent',
_curses.KEY_EOL: 'kel',
_curses.KEY_EOS: 'ked',
_curses.KEY_EXIT: 'kext',
_curses.KEY_F0: 'kf0',
_curses.KEY_F1: 'kf1',
_curses.KEY_F10: 'kf10',
_curses.KEY_F11: 'kf11',
_curses.KEY_F12: 'kf12',
_curses.KEY_F13: 'kf13',
_curses.KEY_F14: 'kf14',
_curses.KEY_F15: 'kf15',
_curses.KEY_F16: 'kf16',
_curses.KEY_F17: 'kf17',
_curses.KEY_F18: 'kf18',
_curses.KEY_F19: 'kf19',
_curses.KEY_F2: 'kf2',
_curses.KEY_F20: 'kf20',
_curses.KEY_F21: 'kf21',
_curses.KEY_F22: 'kf22',
_curses.KEY_F23: 'kf23',
_curses.KEY_F24: 'kf24',
_curses.KEY_F25: 'kf25',
_curses.KEY_F26: 'kf26',
_curses.KEY_F27: 'kf27',
_curses.KEY_F28: 'kf28',
_curses.KEY_F29: 'kf29',
_curses.KEY_F3: 'kf3',
_curses.KEY_F30: 'kf30',
_curses.KEY_F31: 'kf31',
_curses.KEY_F32: 'kf32',
_curses.KEY_F33: 'kf33',
_curses.KEY_F34: 'kf34',
_curses.KEY_F35: 'kf35',
_curses.KEY_F36: 'kf36',
_curses.KEY_F37: 'kf37',
_curses.KEY_F38: 'kf38',
_curses.KEY_F39: 'kf39',
_curses.KEY_F4: 'kf4',
_curses.KEY_F40: 'kf40',
_curses.KEY_F41: 'kf41',
_curses.KEY_F42: 'kf42',
_curses.KEY_F43: 'kf43',
_curses.KEY_F44: 'kf44',
_curses.KEY_F45: 'kf45',
_curses.KEY_F46: 'kf46',
_curses.KEY_F47: 'kf47',
_curses.KEY_F48: 'kf48',
_curses.KEY_F49: 'kf49',
_curses.KEY_F5: 'kf5',
_curses.KEY_F50: 'kf50',
_curses.KEY_F51: 'kf51',
_curses.KEY_F52: 'kf52',
_curses.KEY_F53: 'kf53',
_curses.KEY_F54: 'kf54',
_curses.KEY_F55: 'kf55',
_curses.KEY_F56: 'kf56',
_curses.KEY_F57: 'kf57',
_curses.KEY_F58: 'kf58',
_curses.KEY_F59: 'kf59',
_curses.KEY_F6: 'kf6',
_curses.KEY_F60: 'kf60',
_curses.KEY_F61: 'kf61',
_curses.KEY_F62: 'kf62',
_curses.KEY_F63: 'kf63',
_curses.KEY_F7: 'kf7',
_curses.KEY_F8: 'kf8',
_curses.KEY_F9: 'kf9',
_curses.KEY_FIND: 'kfnd',
_curses.KEY_HELP: 'khlp',
_curses.KEY_HOME: 'khome',
_curses.KEY_IC: 'kich1',
_curses.KEY_IL: 'kil1',
_curses.KEY_LEFT: 'kcub1',
_curses.KEY_LL: 'kll',
_curses.KEY_MARK: 'kmrk',
_curses.KEY_MESSAGE: 'kmsg',
_curses.KEY_MOVE: 'kmov',
_curses.KEY_NEXT: 'knxt',
_curses.KEY_NPAGE: 'knp',
_curses.KEY_OPEN: 'kopn',
_curses.KEY_OPTIONS: 'kopt',
_curses.KEY_PPAGE: 'kpp',
_curses.KEY_PREVIOUS: 'kprv',
_curses.KEY_PRINT: 'kprt',
_curses.KEY_REDO: 'krdo',
_curses.KEY_REFERENCE: 'kref',
_curses.KEY_REFRESH: 'krfr',
_curses.KEY_REPLACE: 'krpl',
_curses.KEY_RESTART: 'krst',
_curses.KEY_RESUME: 'kres',
_curses.KEY_RIGHT: 'kcuf1',
_curses.KEY_SAVE: 'ksav',
_curses.KEY_SBEG: 'kBEG',
_curses.KEY_SCANCEL: 'kCAN',
_curses.KEY_SCOMMAND: 'kCMD',
_curses.KEY_SCOPY: 'kCPY',
_curses.KEY_SCREATE: 'kCRT',
_curses.KEY_SDC: 'kDC',
_curses.KEY_SDL: 'kDL',
_curses.KEY_SELECT: 'kslt',
_curses.KEY_SEND: 'kEND',
_curses.KEY_SEOL: 'kEOL',
_curses.KEY_SEXIT: 'kEXT',
_curses.KEY_SF: 'kind',
_curses.KEY_SFIND: 'kFND',
_curses.KEY_SHELP: 'kHLP',
_curses.KEY_SHOME: 'kHOM',
_curses.KEY_SIC: 'kIC',
_curses.KEY_SLEFT: 'kLFT',
_curses.KEY_SMESSAGE: 'kMSG',
_curses.KEY_SMOVE: 'kMOV',
_curses.KEY_SNEXT: 'kNXT',
_curses.KEY_SOPTIONS: 'kOPT',
_curses.KEY_SPREVIOUS: 'kPRV',
_curses.KEY_SPRINT: 'kPRT',
_curses.KEY_SR: 'kri',
_curses.KEY_SREDO: 'kRDO',
_curses.KEY_SREPLACE: 'kRPL',
_curses.KEY_SRIGHT: 'kRIT',
_curses.KEY_SRSUME: 'kRES',
_curses.KEY_SSAVE: 'kSAV',
_curses.KEY_SSUSPEND: 'kSPD',
_curses.KEY_STAB: 'khts',
_curses.KEY_SUNDO: 'kUND',
_curses.KEY_SUSPEND: 'kspd',
_curses.KEY_UNDO: 'kund',
_curses.KEY_UP: 'kcuu1'
}
def has_key(ch):
if isinstance(ch, str):
ch = ord(ch)
# Figure out the correct capability name for the keycode.
capability_name = _capability_names.get(ch)
if capability_name is None:
return False
#Check the current terminal description for that capability;
#if present, return true, else return false.
if _curses.tigetstr( capability_name ):
return True
else:
return False
if __name__ == '__main__':
# Compare the output of this implementation and the ncurses has_key,
# on platforms where has_key is already available
try:
L = []
_curses.initscr()
for key in _capability_names.keys():
system = key in _curses
python = has_key(key)
if system != python:
L.append( 'Mismatch for key %s, system=%i, Python=%i'
% (_curses.keyname( key ), system, python) )
finally:
_curses.endwin()
for i in L: print i
|
gpl-3.0
|
[
199,
3,
199,
3,
662,
7720,
402,
965,
63,
498,
342,
805,
367,
10677,
626,
2793,
1133,
675,
302,
12026,
199,
3,
199,
199,
646,
485,
12026,
199,
199,
3,
6957,
4412,
15429,
2883,
370,
314,
6707,
815,
19854,
536,
199,
199,
63,
21181,
63,
1247,
275,
469,
272,
485,
12026,
14,
3078,
63,
33,
17,
26,
283,
7351,
17,
297,
272,
485,
12026,
14,
3078,
63,
33,
19,
26,
283,
7351,
19,
297,
272,
485,
12026,
14,
3078,
63,
34,
18,
26,
283,
7862,
18,
297,
272,
485,
12026,
14,
3078,
63,
7111,
11658,
26,
283,
75,
1533,
297,
272,
485,
12026,
14,
3078,
63,
34,
4680,
26,
283,
75,
26349,
297,
272,
485,
12026,
14,
3078,
63,
34,
10129,
26,
283,
75,
2894,
84,
297,
272,
485,
12026,
14,
3078,
63,
35,
17,
26,
283,
75,
67,
17,
297,
272,
485,
12026,
14,
3078,
63,
35,
19,
26,
283,
75,
67,
19,
297,
272,
485,
12026,
14,
3078,
63,
20707,
26,
283,
75,
2425,
297,
272,
485,
12026,
14,
3078,
63,
11206,
1217,
26,
283,
5973,
3776,
297,
272,
485,
12026,
14,
3078,
63,
20706,
26,
283,
75,
31553,
297,
272,
485,
12026,
14,
3078,
63,
18219,
26,
283,
75,
1251,
297,
272,
485,
12026,
14,
3078,
63,
10761,
26,
283,
75,
1760,
297,
272,
485,
12026,
14,
3078,
63,
16188,
26,
283,
75,
25644,
297,
272,
485,
12026,
14,
3078,
63,
8366,
26,
283,
75,
16617,
297,
272,
485,
12026,
14,
3078,
63,
1028,
1217,
26,
283,
75,
319,
371,
297,
272,
485,
12026,
14,
3078,
63,
5196,
26,
283,
25606,
335,
17,
297,
272,
485,
12026,
14,
3078,
63,
8045,
26,
283,
75,
5030,
17,
297,
272,
485,
12026,
14,
3078,
63,
8819,
26,
283,
75,
67,
1181,
17,
297,
272,
485,
12026,
14,
3078,
63,
37,
948,
26,
283,
75,
5682,
723,
297,
272,
485,
12026,
14,
3078,
63,
3902,
26,
283,
75,
500,
297,
272,
485,
12026,
14,
3078,
63,
12533,
26,
283,
75,
484,
297,
272,
485,
12026,
14,
3078,
63,
37,
2228,
26,
283,
75,
352,
297,
272,
485,
12026,
14,
3078,
63,
37,
3100,
26,
283,
25503,
297,
272,
485,
12026,
14,
3078,
63,
17219,
26,
283,
415,
400,
297,
272,
485,
12026,
14,
3078,
63,
38,
16,
26,
283,
16791,
16,
297,
272,
485,
12026,
14,
3078,
63,
38,
17,
26,
283,
16791,
17,
297,
272,
485,
12026,
14,
3078,
63,
38,
709,
26,
283,
16791,
709,
297,
272,
485,
12026,
14,
3078,
63,
38,
845,
26,
283,
16791,
845,
297,
272,
485,
12026,
14,
3078,
63,
38,
713,
26,
283,
16791,
713,
297,
272,
485,
12026,
14,
3078,
63,
38,
969,
26,
283,
16791,
969,
297,
272,
485,
12026,
14,
3078,
63,
38,
1079,
26,
283,
16791,
1079,
297,
272,
485,
12026,
14,
3078,
63,
38,
1046,
26,
283,
16791,
1046,
297,
272,
485,
12026,
14,
3078,
63,
38,
975,
26,
283,
16791,
975,
297,
272,
485,
12026,
14,
3078,
63,
38,
1196,
26,
283,
16791,
1196,
297,
272,
485,
12026,
14,
3078,
63,
38,
1085,
26,
283,
16791,
1085,
297,
272,
485,
12026,
14,
3078,
63,
38,
1167,
26,
283,
16791,
1167,
297,
272,
485,
12026,
14,
3078,
63,
38,
18,
26,
283,
16791,
18,
297,
272,
485,
12026,
14,
3078,
63,
38,
1165,
26,
283,
16791,
1165,
297,
272,
485,
12026,
14,
3078,
63,
38,
2025,
26,
283,
16791,
2025,
297,
272,
485,
12026,
14,
3078,
63,
38,
1081,
26,
283,
16791,
1081,
297,
272,
485,
12026,
14,
3078,
63,
38,
1789,
26,
283,
16791,
1789,
297,
272,
485,
12026,
14,
3078,
63,
38,
1194,
26,
283,
16791,
1194,
297,
272,
485,
12026,
14,
3078,
63,
38,
821,
26,
283,
16791,
821,
297,
272,
485,
12026,
14,
3078,
63,
38,
1479,
26,
283,
16791,
1479,
297,
272,
485,
12026,
14,
3078,
63,
38,
1465,
26,
283,
16791,
1465,
297,
272,
485,
12026,
14,
3078,
63,
38,
1651,
26,
283,
16791,
1651,
297,
272,
485,
12026,
14,
3078,
63,
38,
1398,
26,
283,
16791,
1398,
297,
272,
485,
12026,
14,
3078,
63,
38,
19,
26,
283,
16791,
19,
297,
272,
485,
12026,
14,
3078,
63,
38,
1216,
26,
283,
16791,
1216,
297,
272,
485,
12026,
14,
3078,
63,
38,
2192,
26,
283,
16791,
2192,
297,
272,
485,
12026,
14,
3078,
63,
38,
708,
26,
283,
16791,
708,
297,
272,
485,
12026,
14,
3078,
63,
38,
1153,
26,
283,
16791,
1153,
297,
272,
485,
12026,
14,
3078,
63,
38,
1082,
26,
283,
16791,
1082,
297,
272,
485,
12026,
14,
3078,
63,
38,
1276,
26,
283,
16791,
1276,
297,
272,
485,
12026,
14,
3078,
63,
38,
1344,
26,
283,
16791,
1344,
297,
272,
485,
12026,
14,
3078,
63,
38,
1401,
26,
283,
16791,
1401,
297,
272,
485,
12026,
14,
3078,
63,
38,
1703,
26,
283,
16791,
1703,
297,
272,
485,
12026,
14,
3078,
63,
38,
1355,
26,
283,
16791,
1355,
297,
272,
485,
12026,
14,
3078,
63,
38,
20,
26,
283,
16791,
20,
297,
272,
485,
12026,
14,
3078,
63,
38,
2167,
26,
283,
16791,
2167,
297,
272,
485,
12026,
14,
3078,
63,
38,
2953,
26,
283,
16791,
2953,
297,
272,
485,
12026,
14,
3078,
63,
38,
2260,
26,
283,
16791,
2260,
297,
272,
485,
12026,
14,
3078,
63,
38,
2824,
26,
283,
16791,
2824,
297,
272,
485,
12026,
14,
3078,
63,
38,
1602,
26,
283,
16791,
1602,
297,
272,
485,
12026,
14,
3078,
63,
38,
2322,
26,
283,
16791,
2322,
297,
272,
485,
12026,
14,
3078,
63,
38,
2466,
26,
283,
16791,
2466,
297,
272,
485,
12026,
14,
3078,
63,
38,
2417,
26,
283,
16791,
2417,
297,
272,
485,
12026,
14,
3078,
63,
38,
2006,
26,
283,
16791,
2006,
297,
272,
485,
12026,
14,
3078,
63,
38,
1887,
26,
283,
16791,
1887,
297,
272,
485,
12026,
14,
3078,
63,
38,
21,
26,
283,
16791,
21,
297,
272,
485,
12026,
14,
3078,
63,
38,
1400,
26,
283,
16791,
1400,
297,
272,
485,
12026,
14,
3078,
63,
38,
2869,
26,
283,
16791,
2869,
297,
272,
485,
12026,
14,
3078,
63,
38,
2528,
26,
283,
16791,
2528,
297,
272,
485,
12026,
14,
3078,
63,
38,
2481,
26,
283,
16791,
2481,
297,
272,
485,
12026,
14,
3078
] |
[
3,
199,
3,
662,
7720,
402,
965,
63,
498,
342,
805,
367,
10677,
626,
2793,
1133,
675,
302,
12026,
199,
3,
199,
199,
646,
485,
12026,
199,
199,
3,
6957,
4412,
15429,
2883,
370,
314,
6707,
815,
19854,
536,
199,
199,
63,
21181,
63,
1247,
275,
469,
272,
485,
12026,
14,
3078,
63,
33,
17,
26,
283,
7351,
17,
297,
272,
485,
12026,
14,
3078,
63,
33,
19,
26,
283,
7351,
19,
297,
272,
485,
12026,
14,
3078,
63,
34,
18,
26,
283,
7862,
18,
297,
272,
485,
12026,
14,
3078,
63,
7111,
11658,
26,
283,
75,
1533,
297,
272,
485,
12026,
14,
3078,
63,
34,
4680,
26,
283,
75,
26349,
297,
272,
485,
12026,
14,
3078,
63,
34,
10129,
26,
283,
75,
2894,
84,
297,
272,
485,
12026,
14,
3078,
63,
35,
17,
26,
283,
75,
67,
17,
297,
272,
485,
12026,
14,
3078,
63,
35,
19,
26,
283,
75,
67,
19,
297,
272,
485,
12026,
14,
3078,
63,
20707,
26,
283,
75,
2425,
297,
272,
485,
12026,
14,
3078,
63,
11206,
1217,
26,
283,
5973,
3776,
297,
272,
485,
12026,
14,
3078,
63,
20706,
26,
283,
75,
31553,
297,
272,
485,
12026,
14,
3078,
63,
18219,
26,
283,
75,
1251,
297,
272,
485,
12026,
14,
3078,
63,
10761,
26,
283,
75,
1760,
297,
272,
485,
12026,
14,
3078,
63,
16188,
26,
283,
75,
25644,
297,
272,
485,
12026,
14,
3078,
63,
8366,
26,
283,
75,
16617,
297,
272,
485,
12026,
14,
3078,
63,
1028,
1217,
26,
283,
75,
319,
371,
297,
272,
485,
12026,
14,
3078,
63,
5196,
26,
283,
25606,
335,
17,
297,
272,
485,
12026,
14,
3078,
63,
8045,
26,
283,
75,
5030,
17,
297,
272,
485,
12026,
14,
3078,
63,
8819,
26,
283,
75,
67,
1181,
17,
297,
272,
485,
12026,
14,
3078,
63,
37,
948,
26,
283,
75,
5682,
723,
297,
272,
485,
12026,
14,
3078,
63,
3902,
26,
283,
75,
500,
297,
272,
485,
12026,
14,
3078,
63,
12533,
26,
283,
75,
484,
297,
272,
485,
12026,
14,
3078,
63,
37,
2228,
26,
283,
75,
352,
297,
272,
485,
12026,
14,
3078,
63,
37,
3100,
26,
283,
25503,
297,
272,
485,
12026,
14,
3078,
63,
17219,
26,
283,
415,
400,
297,
272,
485,
12026,
14,
3078,
63,
38,
16,
26,
283,
16791,
16,
297,
272,
485,
12026,
14,
3078,
63,
38,
17,
26,
283,
16791,
17,
297,
272,
485,
12026,
14,
3078,
63,
38,
709,
26,
283,
16791,
709,
297,
272,
485,
12026,
14,
3078,
63,
38,
845,
26,
283,
16791,
845,
297,
272,
485,
12026,
14,
3078,
63,
38,
713,
26,
283,
16791,
713,
297,
272,
485,
12026,
14,
3078,
63,
38,
969,
26,
283,
16791,
969,
297,
272,
485,
12026,
14,
3078,
63,
38,
1079,
26,
283,
16791,
1079,
297,
272,
485,
12026,
14,
3078,
63,
38,
1046,
26,
283,
16791,
1046,
297,
272,
485,
12026,
14,
3078,
63,
38,
975,
26,
283,
16791,
975,
297,
272,
485,
12026,
14,
3078,
63,
38,
1196,
26,
283,
16791,
1196,
297,
272,
485,
12026,
14,
3078,
63,
38,
1085,
26,
283,
16791,
1085,
297,
272,
485,
12026,
14,
3078,
63,
38,
1167,
26,
283,
16791,
1167,
297,
272,
485,
12026,
14,
3078,
63,
38,
18,
26,
283,
16791,
18,
297,
272,
485,
12026,
14,
3078,
63,
38,
1165,
26,
283,
16791,
1165,
297,
272,
485,
12026,
14,
3078,
63,
38,
2025,
26,
283,
16791,
2025,
297,
272,
485,
12026,
14,
3078,
63,
38,
1081,
26,
283,
16791,
1081,
297,
272,
485,
12026,
14,
3078,
63,
38,
1789,
26,
283,
16791,
1789,
297,
272,
485,
12026,
14,
3078,
63,
38,
1194,
26,
283,
16791,
1194,
297,
272,
485,
12026,
14,
3078,
63,
38,
821,
26,
283,
16791,
821,
297,
272,
485,
12026,
14,
3078,
63,
38,
1479,
26,
283,
16791,
1479,
297,
272,
485,
12026,
14,
3078,
63,
38,
1465,
26,
283,
16791,
1465,
297,
272,
485,
12026,
14,
3078,
63,
38,
1651,
26,
283,
16791,
1651,
297,
272,
485,
12026,
14,
3078,
63,
38,
1398,
26,
283,
16791,
1398,
297,
272,
485,
12026,
14,
3078,
63,
38,
19,
26,
283,
16791,
19,
297,
272,
485,
12026,
14,
3078,
63,
38,
1216,
26,
283,
16791,
1216,
297,
272,
485,
12026,
14,
3078,
63,
38,
2192,
26,
283,
16791,
2192,
297,
272,
485,
12026,
14,
3078,
63,
38,
708,
26,
283,
16791,
708,
297,
272,
485,
12026,
14,
3078,
63,
38,
1153,
26,
283,
16791,
1153,
297,
272,
485,
12026,
14,
3078,
63,
38,
1082,
26,
283,
16791,
1082,
297,
272,
485,
12026,
14,
3078,
63,
38,
1276,
26,
283,
16791,
1276,
297,
272,
485,
12026,
14,
3078,
63,
38,
1344,
26,
283,
16791,
1344,
297,
272,
485,
12026,
14,
3078,
63,
38,
1401,
26,
283,
16791,
1401,
297,
272,
485,
12026,
14,
3078,
63,
38,
1703,
26,
283,
16791,
1703,
297,
272,
485,
12026,
14,
3078,
63,
38,
1355,
26,
283,
16791,
1355,
297,
272,
485,
12026,
14,
3078,
63,
38,
20,
26,
283,
16791,
20,
297,
272,
485,
12026,
14,
3078,
63,
38,
2167,
26,
283,
16791,
2167,
297,
272,
485,
12026,
14,
3078,
63,
38,
2953,
26,
283,
16791,
2953,
297,
272,
485,
12026,
14,
3078,
63,
38,
2260,
26,
283,
16791,
2260,
297,
272,
485,
12026,
14,
3078,
63,
38,
2824,
26,
283,
16791,
2824,
297,
272,
485,
12026,
14,
3078,
63,
38,
1602,
26,
283,
16791,
1602,
297,
272,
485,
12026,
14,
3078,
63,
38,
2322,
26,
283,
16791,
2322,
297,
272,
485,
12026,
14,
3078,
63,
38,
2466,
26,
283,
16791,
2466,
297,
272,
485,
12026,
14,
3078,
63,
38,
2417,
26,
283,
16791,
2417,
297,
272,
485,
12026,
14,
3078,
63,
38,
2006,
26,
283,
16791,
2006,
297,
272,
485,
12026,
14,
3078,
63,
38,
1887,
26,
283,
16791,
1887,
297,
272,
485,
12026,
14,
3078,
63,
38,
21,
26,
283,
16791,
21,
297,
272,
485,
12026,
14,
3078,
63,
38,
1400,
26,
283,
16791,
1400,
297,
272,
485,
12026,
14,
3078,
63,
38,
2869,
26,
283,
16791,
2869,
297,
272,
485,
12026,
14,
3078,
63,
38,
2528,
26,
283,
16791,
2528,
297,
272,
485,
12026,
14,
3078,
63,
38,
2481,
26,
283,
16791,
2481,
297,
272,
485,
12026,
14,
3078,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Antiun/odoo
|
addons/mail/tests/test_mail_features.py
|
172
|
59265
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from ..mail_mail import mail_mail
from ..mail_thread import mail_thread
from .common import TestMail
from openerp.tools import mute_logger, email_split, html2plaintext
from openerp.tools.mail import html_sanitize
class test_mail(TestMail):
def test_000_alias_setup(self):
""" Test basic mail.alias setup works, before trying to use them for routing """
cr, uid = self.cr, self.uid
self.user_valentin_id = self.res_users.create(cr, uid,
{'name': 'Valentin Cognito', 'email': 'valentin.cognito@gmail.com', 'login': 'valentin.cognito', 'alias_name': 'valentin.cognito'})
self.user_valentin = self.res_users.browse(cr, uid, self.user_valentin_id)
self.assertEquals(self.user_valentin.alias_name, self.user_valentin.login, "Login should be used as alias")
self.user_pagan_id = self.res_users.create(cr, uid,
{'name': 'Pagan Le Marchant', 'email': 'plmarchant@gmail.com', 'login': 'plmarchant@gmail.com', 'alias_name': 'plmarchant@gmail.com'})
self.user_pagan = self.res_users.browse(cr, uid, self.user_pagan_id)
self.assertEquals(self.user_pagan.alias_name, 'plmarchant', "If login is an email, the alias should keep only the local part")
self.user_barty_id = self.res_users.create(cr, uid,
{'name': 'Bartholomew Ironside', 'email': 'barty@gmail.com', 'login': 'b4r+_#_R3wl$$', 'alias_name': 'b4r+_#_R3wl$$'})
self.user_barty = self.res_users.browse(cr, uid, self.user_barty_id)
self.assertEquals(self.user_barty.alias_name, 'b4r+_-_r3wl-', 'Disallowed chars should be replaced by hyphens')
def test_00_followers_function_field(self):
""" Tests designed for the many2many function field 'follower_ids'.
We will test to perform writes using the many2many commands 0, 3, 4,
5 and 6. """
cr, uid, user_admin, partner_bert_id, group_pigs = self.cr, self.uid, self.user_admin, self.partner_bert_id, self.group_pigs
# Data: create 'disturbing' values in mail.followers: same res_id, other res_model; same res_model, other res_id
group_dummy_id = self.mail_group.create(cr, uid,
{'name': 'Dummy group'}, {'mail_create_nolog': True})
self.mail_followers.create(cr, uid,
{'res_model': 'mail.thread', 'res_id': self.group_pigs_id, 'partner_id': partner_bert_id})
self.mail_followers.create(cr, uid,
{'res_model': 'mail.group', 'res_id': group_dummy_id, 'partner_id': partner_bert_id})
# Pigs just created: should be only Admin as follower
follower_ids = set([follower.id for follower in group_pigs.message_follower_ids])
self.assertEqual(follower_ids, set([user_admin.partner_id.id]), 'Admin should be the only Pigs fan')
# Subscribe Bert through a '4' command
group_pigs.write({'message_follower_ids': [(4, partner_bert_id)]})
group_pigs.refresh()
follower_ids = set([follower.id for follower in group_pigs.message_follower_ids])
self.assertEqual(follower_ids, set([partner_bert_id, user_admin.partner_id.id]), 'Bert and Admin should be the only Pigs fans')
# Unsubscribe Bert through a '3' command
group_pigs.write({'message_follower_ids': [(3, partner_bert_id)]})
group_pigs.refresh()
follower_ids = set([follower.id for follower in group_pigs.message_follower_ids])
self.assertEqual(follower_ids, set([user_admin.partner_id.id]), 'Admin should be the only Pigs fan')
# Set followers through a '6' command
group_pigs.write({'message_follower_ids': [(6, 0, [partner_bert_id])]})
group_pigs.refresh()
follower_ids = set([follower.id for follower in group_pigs.message_follower_ids])
self.assertEqual(follower_ids, set([partner_bert_id]), 'Bert should be the only Pigs fan')
# Add a follower created on the fly through a '0' command
group_pigs.write({'message_follower_ids': [(0, 0, {'name': 'Patrick Fiori'})]})
partner_patrick_id = self.res_partner.search(cr, uid, [('name', '=', 'Patrick Fiori')])[0]
group_pigs.refresh()
follower_ids = set([follower.id for follower in group_pigs.message_follower_ids])
self.assertEqual(follower_ids, set([partner_bert_id, partner_patrick_id]), 'Bert and Patrick should be the only Pigs fans')
# Finally, unlink through a '5' command
group_pigs.write({'message_follower_ids': [(5, 0)]})
group_pigs.refresh()
follower_ids = set([follower.id for follower in group_pigs.message_follower_ids])
self.assertFalse(follower_ids, 'Pigs group should not have fans anymore')
# Test dummy data has not been altered
fol_obj_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.thread'), ('res_id', '=', self.group_pigs_id)])
follower_ids = set([follower.partner_id.id for follower in self.mail_followers.browse(cr, uid, fol_obj_ids)])
self.assertEqual(follower_ids, set([partner_bert_id]), 'Bert should be the follower of dummy mail.thread data')
fol_obj_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', group_dummy_id)])
follower_ids = set([follower.partner_id.id for follower in self.mail_followers.browse(cr, uid, fol_obj_ids)])
self.assertEqual(follower_ids, set([partner_bert_id, user_admin.partner_id.id]), 'Bert and Admin should be the followers of dummy mail.group data')
def test_05_message_followers_and_subtypes(self):
""" Tests designed for the subscriber API as well as message subtypes """
cr, uid, user_admin, user_raoul, group_pigs = self.cr, self.uid, self.user_admin, self.user_raoul, self.group_pigs
# Data: message subtypes
self.mail_message_subtype.create(cr, uid, {'name': 'mt_mg_def', 'default': True, 'res_model': 'mail.group'})
self.mail_message_subtype.create(cr, uid, {'name': 'mt_other_def', 'default': True, 'res_model': 'crm.lead'})
self.mail_message_subtype.create(cr, uid, {'name': 'mt_all_def', 'default': True, 'res_model': False})
mt_mg_nodef = self.mail_message_subtype.create(cr, uid, {'name': 'mt_mg_nodef', 'default': False, 'res_model': 'mail.group'})
mt_all_nodef = self.mail_message_subtype.create(cr, uid, {'name': 'mt_all_nodef', 'default': False, 'res_model': False})
default_group_subtypes = self.mail_message_subtype.search(cr, uid, [('default', '=', True), '|', ('res_model', '=', 'mail.group'), ('res_model', '=', False)])
# ----------------------------------------
# CASE1: test subscriptions with subtypes
# ----------------------------------------
# Do: subscribe Raoul, should have default subtypes
group_pigs.message_subscribe_users([user_raoul.id])
group_pigs.refresh()
# Test: 2 followers (Admin and Raoul)
follower_ids = [follower.id for follower in group_pigs.message_follower_ids]
self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]),
'message_subscribe: Admin and Raoul should be the only 2 Pigs fans')
# Raoul follows default subtypes
fol_ids = self.mail_followers.search(cr, uid, [
('res_model', '=', 'mail.group'),
('res_id', '=', self.group_pigs_id),
('partner_id', '=', user_raoul.partner_id.id)
])
fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0]
fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids])
self.assertEqual(set(fol_subtype_ids), set(default_group_subtypes),
'message_subscribe: Raoul subscription subtypes are incorrect, should be all default ones')
# Do: subscribe Raoul with specified new subtypes
group_pigs.message_subscribe_users([user_raoul.id], subtype_ids=[mt_mg_nodef])
# Test: 2 followers (Admin and Raoul)
follower_ids = [follower.id for follower in group_pigs.message_follower_ids]
self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]),
'message_subscribe: Admin and Raoul should be the only 2 Pigs fans')
# Test: 2 lines in mail.followers (no duplicate for Raoul)
fol_ids = self.mail_followers.search(cr, uid, [
('res_model', '=', 'mail.group'),
('res_id', '=', self.group_pigs_id),
])
self.assertEqual(len(fol_ids), 2,
'message_subscribe: subscribing an already-existing follower should not create new entries in mail.followers')
# Test: Raoul follows only specified subtypes
fol_ids = self.mail_followers.search(cr, uid, [
('res_model', '=', 'mail.group'),
('res_id', '=', self.group_pigs_id),
('partner_id', '=', user_raoul.partner_id.id)
])
fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0]
fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids])
self.assertEqual(set(fol_subtype_ids), set([mt_mg_nodef]),
'message_subscribe: Raoul subscription subtypes are incorrect, should be only specified')
# Do: Subscribe Raoul without specified subtypes: should not erase existing subscription subtypes
group_pigs.message_subscribe_users([user_raoul.id, user_raoul.id])
group_pigs.message_subscribe_users([user_raoul.id])
group_pigs.refresh()
# Test: 2 followers (Admin and Raoul)
follower_ids = [follower.id for follower in group_pigs.message_follower_ids]
self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]),
'message_subscribe: Admin and Raoul should be the only 2 Pigs fans')
# Test: Raoul follows default subtypes
fol_ids = self.mail_followers.search(cr, uid, [
('res_model', '=', 'mail.group'),
('res_id', '=', self.group_pigs_id),
('partner_id', '=', user_raoul.partner_id.id)
])
fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0]
fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids])
self.assertEqual(set(fol_subtype_ids), set([mt_mg_nodef]),
'message_subscribe: Raoul subscription subtypes are incorrect, should be only specified')
# Do: Unsubscribe Raoul twice through message_unsubscribe_users
group_pigs.message_unsubscribe_users([user_raoul.id, user_raoul.id])
group_pigs.refresh()
# Test: 1 follower (Admin)
follower_ids = [follower.id for follower in group_pigs.message_follower_ids]
self.assertEqual(follower_ids, [user_admin.partner_id.id], 'Admin must be the only Pigs fan')
# Test: 1 lines in mail.followers (no duplicate for Raoul)
fol_ids = self.mail_followers.search(cr, uid, [
('res_model', '=', 'mail.group'),
('res_id', '=', self.group_pigs_id)
])
self.assertEqual(len(fol_ids), 1,
'message_subscribe: group should have only 1 entry in mail.follower for 1 follower')
# Do: subscribe Admin with subtype_ids
group_pigs.message_subscribe_users([uid], [mt_mg_nodef, mt_all_nodef])
fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_admin.partner_id.id)])
fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0]
fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids])
self.assertEqual(set(fol_subtype_ids), set([mt_mg_nodef, mt_all_nodef]), 'subscription subtypes are incorrect')
# ----------------------------------------
# CASE2: test mail_thread fields
# ----------------------------------------
subtype_data = group_pigs._get_subscription_data(None, None)[group_pigs.id]['message_subtype_data']
self.assertEqual(set(subtype_data.keys()), set(['Discussions', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect')
self.assertFalse(subtype_data['Discussions']['followed'], 'Admin should not follow Discussions in pigs')
self.assertTrue(subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs')
self.assertTrue(subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs')
def test_11_notification_url(self):
""" Tests designed to test the URL added in notification emails. """
cr, uid, group_pigs = self.cr, self.uid, self.group_pigs
# Test URL formatting
base_url = self.registry('ir.config_parameter').get_param(cr, uid, 'web.base.url')
# Partner data
partner_raoul = self.res_partner.browse(cr, uid, self.partner_raoul_id)
partner_bert_id = self.res_partner.create(cr, uid, {'name': 'bert'})
partner_bert = self.res_partner.browse(cr, uid, partner_bert_id)
# Mail data
mail_mail_id = self.mail_mail.create(cr, uid, {'state': 'exception'})
mail = self.mail_mail.browse(cr, uid, mail_mail_id)
# Test: link for nobody -> None
url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail)
self.assertEqual(url, None,
'notification email: mails not send to a specific partner should not have any URL')
# Test: link for partner -> None
url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail, partner=partner_bert)
self.assertEqual(url, None,
'notification email: mails send to a not-user partner should not have any URL')
# Test: link for user -> signin
url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail, partner=partner_raoul)
self.assertIn(base_url, url,
'notification email: link should contain web.base.url')
self.assertIn('db=%s' % cr.dbname, url,
'notification email: link should contain database name')
self.assertIn('action=mail.action_mail_redirect', url,
'notification email: link should contain the redirect action')
self.assertIn('login=%s' % partner_raoul.user_ids[0].login, url,
'notification email: link should contain the user login')
# Test: link for user -> with model and res_id
mail_mail_id = self.mail_mail.create(cr, uid, {'model': 'mail.group', 'res_id': group_pigs.id})
mail = self.mail_mail.browse(cr, uid, mail_mail_id)
url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail, partner=partner_raoul)
self.assertIn(base_url, url,
'notification email: link should contain web.base.url')
self.assertIn('db=%s' % cr.dbname, url,
'notification email: link should contain database name')
self.assertIn('action=mail.action_mail_redirect', url,
'notification email: link should contain the redirect action')
self.assertIn('login=%s' % partner_raoul.user_ids[0].login, url,
'notification email: link should contain the user login')
self.assertIn('model=mail.group', url,
'notification email: link should contain the model when having not notification email on a record')
self.assertIn('res_id=%s' % group_pigs.id, url,
'notification email: link should contain the res_id when having not notification email on a record')
# Test: link for user -> with model and res_id
mail_mail_id = self.mail_mail.create(cr, uid, {'notification': True, 'model': 'mail.group', 'res_id': group_pigs.id})
mail = self.mail_mail.browse(cr, uid, mail_mail_id)
url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail, partner=partner_raoul)
self.assertIn(base_url, url,
'notification email: link should contain web.base.url')
self.assertIn('db=%s' % cr.dbname, url,
'notification email: link should contain database name')
self.assertIn('action=mail.action_mail_redirect', url,
'notification email: link should contain the redirect action')
self.assertIn('login=%s' % partner_raoul.user_ids[0].login, url,
'notification email: link should contain the user login')
self.assertIn('message_id=%s' % mail.mail_message_id.id, url,
'notification email: link based on message should contain the mail_message id')
self.assertNotIn('model=mail.group', url,
'notification email: link based on message should not contain model')
self.assertNotIn('res_id=%s' % group_pigs.id, url,
'notification email: link based on message should not contain res_id')
@mute_logger('openerp.addons.mail.mail_thread', 'openerp.models')
def test_12_inbox_redirection(self):
""" Tests designed to test the inbox redirection of emails notification URLs. """
cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs
model, act_id = self.ir_model_data.get_object_reference(cr, uid, 'mail', 'action_mail_inbox_feeds')
# Data: post a message on pigs
msg_id = self.group_pigs.message_post(body='My body', partner_ids=[self.partner_bert_id], type='comment', subtype='mail.mt_comment')
# No specific parameters -> should redirect to Inbox
action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_raoul_id, {'params': {}})
self.assertEqual(
action.get('type'), 'ir.actions.client',
'URL redirection: action without parameters should redirect to client action Inbox'
)
self.assertEqual(
action.get('id'), act_id,
'URL redirection: action without parameters should redirect to client action Inbox'
)
# Raoul has read access to Pigs -> should redirect to form view of Pigs
action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_raoul_id, {'params': {'message_id': msg_id}})
self.assertEqual(
action.get('type'), 'ir.actions.act_window',
'URL redirection: action with message_id for read-accredited user should redirect to Pigs'
)
self.assertEqual(
action.get('res_id'), group_pigs.id,
'URL redirection: action with message_id for read-accredited user should redirect to Pigs'
)
action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_raoul_id, {'params': {'model': 'mail.group', 'res_id': group_pigs.id}})
self.assertEqual(
action.get('type'), 'ir.actions.act_window',
'URL redirection: action with message_id for read-accredited user should redirect to Pigs'
)
self.assertEqual(
action.get('res_id'), group_pigs.id,
'URL redirection: action with message_id for read-accredited user should redirect to Pigs'
)
# Bert has no read access to Pigs -> should redirect to Inbox
action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_bert_id, {'params': {'message_id': msg_id}})
self.assertEqual(
action.get('type'), 'ir.actions.client',
'URL redirection: action without parameters should redirect to client action Inbox'
)
self.assertEqual(
action.get('id'), act_id,
'URL redirection: action without parameters should redirect to client action Inbox'
)
action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_bert_id, {'params': {'model': 'mail.group', 'res_id': group_pigs.id}})
self.assertEqual(
action.get('type'), 'ir.actions.client',
'URL redirection: action without parameters should redirect to client action Inbox'
)
self.assertEqual(
action.get('id'), act_id,
'URL redirection: action without parameters should redirect to client action Inbox'
)
def test_20_message_post(self):
""" Tests designed for message_post. """
cr, uid, user_raoul, group_pigs = self.cr, self.uid, self.user_raoul, self.group_pigs
# --------------------------------------------------
# Data creation
# --------------------------------------------------
# 0 - Update existing users-partners
self.res_users.write(cr, uid, [uid], {'email': 'a@a', 'notify_email': 'always'})
self.res_users.write(cr, uid, [self.user_raoul_id], {'email': 'r@r'})
# 1 - Bert Tartopoils, with email, should receive emails for comments and emails
p_b_id = self.res_partner.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'b@b'})
# 2 - Carine Poilvache, with email, should receive emails for emails
p_c_id = self.res_partner.create(cr, uid, {'name': 'Carine Poilvache', 'email': 'c@c', 'notify_email': 'none'})
# 3 - Dédé Grosbedon, without email, to test email verification; should receive emails for every message
p_d_id = self.res_partner.create(cr, uid, {'name': 'Dédé Grosbedon', 'email': 'd@d', 'notify_email': 'always'})
# 4 - Attachments
attach1_id = self.ir_attachment.create(cr, user_raoul.id, {
'name': 'Attach1', 'datas_fname': 'Attach1',
'datas': 'bWlncmF0aW9uIHRlc3Q=',
'res_model': 'mail.compose.message', 'res_id': 0})
attach2_id = self.ir_attachment.create(cr, user_raoul.id, {
'name': 'Attach2', 'datas_fname': 'Attach2',
'datas': 'bWlncmF0aW9uIHRlc3Q=',
'res_model': 'mail.compose.message', 'res_id': 0})
attach3_id = self.ir_attachment.create(cr, user_raoul.id, {
'name': 'Attach3', 'datas_fname': 'Attach3',
'datas': 'bWlncmF0aW9uIHRlc3Q=',
'res_model': 'mail.compose.message', 'res_id': 0})
# 5 - Mail data
_subject = 'Pigs'
_mail_subject = 'Re: %s' % (group_pigs.name)
_body1 = '<p>Pigs rules</p>'
_body2 = '<html>Pigs rocks</html>'
_attachments = [
('List1', 'My first attachment'),
('List2', 'My second attachment')
]
# --------------------------------------------------
# CASE1: post comment + partners + attachments
# --------------------------------------------------
# Data: set alias_domain to see emails with alias
self.registry('ir.config_parameter').set_param(self.cr, self.uid, 'mail.catchall.domain', 'schlouby.fr')
# Data: change Pigs name to test reply_to
self.mail_group.write(cr, uid, [self.group_pigs_id], {'name': '"Pigs" !ù $%-'})
# Do: subscribe Raoul
new_follower_ids = [self.partner_raoul_id]
group_pigs.message_subscribe(new_follower_ids)
# Test: group followers = Raoul + uid
group_fids = [follower.id for follower in group_pigs.message_follower_ids]
test_fids = new_follower_ids + [self.partner_admin_id]
self.assertEqual(set(test_fids), set(group_fids),
'message_subscribe: incorrect followers after subscribe')
# Do: Raoul message_post on Pigs
self._init_mock_build_email()
msg1_id = self.mail_group.message_post(cr, user_raoul.id, self.group_pigs_id,
body=_body1, subject=_subject, partner_ids=[p_b_id, p_c_id],
attachment_ids=[attach1_id, attach2_id], attachments=_attachments,
type='comment', subtype='mt_comment')
msg = self.mail_message.browse(cr, uid, msg1_id)
msg_message_id = msg.message_id
msg_pids = [partner.id for partner in msg.notified_partner_ids]
msg_aids = [attach.id for attach in msg.attachment_ids]
sent_emails = self._build_email_kwargs_list
# Test: mail_message: subject and body not modified
self.assertEqual(_subject, msg.subject, 'message_post: mail.message subject incorrect')
self.assertEqual(_body1, msg.body, 'message_post: mail.message body incorrect')
# Test: mail_message: notified_partner_ids = group followers + partner_ids - author
test_pids = set([self.partner_admin_id, p_b_id, p_c_id])
self.assertEqual(test_pids, set(msg_pids), 'message_post: mail.message notified partners incorrect')
# Test: mail_message: attachments (4, attachment_ids + attachments)
test_aids = set([attach1_id, attach2_id])
msg_attach_names = set([attach.name for attach in msg.attachment_ids])
test_attach_names = set(['Attach1', 'Attach2', 'List1', 'List2'])
self.assertEqual(len(msg_aids), 4,
'message_post: mail.message wrong number of attachments')
self.assertEqual(msg_attach_names, test_attach_names,
'message_post: mail.message attachments incorrectly added')
self.assertTrue(test_aids.issubset(set(msg_aids)),
'message_post: mail.message attachments duplicated')
for attach in msg.attachment_ids:
self.assertEqual(attach.res_model, 'mail.group',
'message_post: mail.message attachments were not linked to the document')
self.assertEqual(attach.res_id, group_pigs.id,
'message_post: mail.message attachments were not linked to the document')
if 'List' in attach.name:
self.assertIn((attach.name, attach.datas.decode('base64')), _attachments,
'message_post: mail.message attachment name / data incorrect')
dl_attach = self.mail_message.download_attachment(cr, user_raoul.id, id_message=msg.id, attachment_id=attach.id)
self.assertIn((dl_attach['filename'], dl_attach['base64'].decode('base64')), _attachments,
'message_post: mail.message download_attachment is incorrect')
# Test: followers: same as before (author was already subscribed)
group_pigs.refresh()
group_fids = [follower.id for follower in group_pigs.message_follower_ids]
test_fids = new_follower_ids + [self.partner_admin_id]
self.assertEqual(set(test_fids), set(group_fids),
'message_post: wrong followers after posting')
# Test: mail_mail: notifications have been deleted
self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg1_id)]),
'message_post: mail.mail notifications should have been auto-deleted!')
# Test: notifications emails: to a and b, c is email only, r is author
test_emailto = ['Administrator <a@a>', 'Bert Tartopoils <b@b>']
# test_emailto = ['"Followers of -Pigs-" <a@a>', '"Followers of -Pigs-" <b@b>']
self.assertEqual(len(sent_emails), 2,
'message_post: notification emails wrong number of send emails')
self.assertEqual(set([m['email_to'][0] for m in sent_emails]), set(test_emailto),
'message_post: notification emails wrong recipients (email_to)')
for sent_email in sent_emails:
self.assertEqual(sent_email['email_from'], 'Raoul Grosbedon <raoul@schlouby.fr>',
'message_post: notification email wrong email_from: should use alias of sender')
self.assertEqual(len(sent_email['email_to']), 1,
'message_post: notification email sent to more than one email address instead of a precise partner')
self.assertIn(sent_email['email_to'][0], test_emailto,
'message_post: notification email email_to incorrect')
self.assertEqual(sent_email['reply_to'], u'"YourCompany \\"Pigs\\" !ù $%-" <group+pigs@schlouby.fr>',
'message_post: notification email reply_to incorrect')
self.assertEqual(_subject, sent_email['subject'],
'message_post: notification email subject incorrect')
self.assertIn(_body1, sent_email['body'],
'message_post: notification email body incorrect')
self.assertIn('Pigs rules', sent_email['body_alternative'],
'message_post: notification email body alternative should contain the body')
self.assertNotIn('<p>', sent_email['body_alternative'],
'message_post: notification email body alternative still contains html')
self.assertFalse(sent_email['references'],
'message_post: references should be False when sending a message that is not a reply')
# Test: notification linked to this message = group followers = notified_partner_ids
notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg1_id)])
notif_pids = set([notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)])
self.assertEqual(notif_pids, test_pids,
'message_post: mail.message created mail.notification incorrect')
# Data: Pigs name back to normal
self.mail_group.write(cr, uid, [self.group_pigs_id], {'name': 'Pigs'})
# --------------------------------------------------
# CASE2: reply + parent_id + parent notification
# --------------------------------------------------
# Data: remove alias_domain to see emails with alias
param_ids = self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.domain')])
self.registry('ir.config_parameter').unlink(cr, uid, param_ids)
# Do: Raoul message_post on Pigs
self._init_mock_build_email()
msg2_id = self.mail_group.message_post(cr, user_raoul.id, self.group_pigs_id,
body=_body2, type='email', subtype='mt_comment',
partner_ids=[p_d_id], parent_id=msg1_id, attachment_ids=[attach3_id],
context={'mail_post_autofollow': True})
msg = self.mail_message.browse(cr, uid, msg2_id)
msg_pids = [partner.id for partner in msg.notified_partner_ids]
msg_aids = [attach.id for attach in msg.attachment_ids]
sent_emails = self._build_email_kwargs_list
# Test: mail_message: subject is False, body, parent_id is msg_id
self.assertEqual(msg.subject, False, 'message_post: mail.message subject incorrect')
self.assertEqual(msg.body, html_sanitize(_body2), 'message_post: mail.message body incorrect')
self.assertEqual(msg.parent_id.id, msg1_id, 'message_post: mail.message parent_id incorrect')
# Test: mail_message: notified_partner_ids = group followers
test_pids = [self.partner_admin_id, p_d_id]
self.assertEqual(set(test_pids), set(msg_pids), 'message_post: mail.message partners incorrect')
# Test: mail_message: notifications linked to this message = group followers = notified_partner_ids
notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg2_id)])
notif_pids = [notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)]
self.assertEqual(set(test_pids), set(notif_pids), 'message_post: mail.message notification partners incorrect')
# Test: mail_mail: notifications deleted
self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg2_id)]), 'mail.mail notifications should have been auto-deleted!')
# Test: emails send by server (to a, b, c, d)
test_emailto = [u'Administrator <a@a>', u'Bert Tartopoils <b@b>', u'Carine Poilvache <c@c>', u'D\xe9d\xe9 Grosbedon <d@d>']
# test_emailto = [u'"Followers of Pigs" <a@a>', u'"Followers of Pigs" <b@b>', u'"Followers of Pigs" <c@c>', u'"Followers of Pigs" <d@d>']
# self.assertEqual(len(sent_emails), 3, 'sent_email number of sent emails incorrect')
for sent_email in sent_emails:
self.assertEqual(sent_email['email_from'], 'Raoul Grosbedon <r@r>',
'message_post: notification email wrong email_from: should use email of sender when no alias domain set')
self.assertEqual(len(sent_email['email_to']), 1,
'message_post: notification email sent to more than one email address instead of a precise partner')
self.assertIn(sent_email['email_to'][0], test_emailto,
'message_post: notification email email_to incorrect')
self.assertEqual(email_split(sent_email['reply_to']), ['r@r'], # was '"Followers of Pigs" <r@r>', but makes no sense
'message_post: notification email reply_to incorrect: should have raoul email')
self.assertEqual(_mail_subject, sent_email['subject'],
'message_post: notification email subject incorrect')
self.assertIn(html_sanitize(_body2), sent_email['body'],
'message_post: notification email does not contain the body')
self.assertIn('Pigs rocks', sent_email['body_alternative'],
'message_post: notification email body alternative should contain the body')
self.assertNotIn('<p>', sent_email['body_alternative'],
'message_post: notification email body alternative still contains html')
self.assertIn(msg_message_id, sent_email['references'],
'message_post: notification email references lacks parent message message_id')
# Test: attachments + download
for attach in msg.attachment_ids:
self.assertEqual(attach.res_model, 'mail.group',
'message_post: mail.message attachment res_model incorrect')
self.assertEqual(attach.res_id, self.group_pigs_id,
'message_post: mail.message attachment res_id incorrect')
# Test: Dédé has been notified -> should also have been notified of the parent message
msg = self.mail_message.browse(cr, uid, msg1_id)
msg_pids = set([partner.id for partner in msg.notified_partner_ids])
test_pids = set([self.partner_admin_id, p_b_id, p_c_id, p_d_id])
self.assertEqual(test_pids, msg_pids, 'message_post: mail.message parent notification not created')
# Do: reply to last message
msg3_id = self.mail_group.message_post(cr, user_raoul.id, self.group_pigs_id, body='Test', parent_id=msg2_id)
msg = self.mail_message.browse(cr, uid, msg3_id)
# Test: check that its parent will be the first message
self.assertEqual(msg.parent_id.id, msg1_id, 'message_post did not flatten the thread structure')
def test_25_message_compose_wizard(self):
""" Tests designed for the mail.compose.message wizard. """
cr, uid, user_raoul, group_pigs = self.cr, self.uid, self.user_raoul, self.group_pigs
mail_compose = self.registry('mail.compose.message')
# --------------------------------------------------
# Data creation
# --------------------------------------------------
# 0 - Update existing users-partners
self.res_users.write(cr, uid, [uid], {'email': 'a@a'})
self.res_users.write(cr, uid, [self.user_raoul_id], {'email': 'r@r'})
# 1 - Bert Tartopoils, with email, should receive emails for comments and emails
p_b_id = self.res_partner.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'b@b'})
# 2 - Carine Poilvache, with email, should receive emails for emails
p_c_id = self.res_partner.create(cr, uid, {'name': 'Carine Poilvache', 'email': 'c@c', 'notify_email': 'always'})
# 3 - Dédé Grosbedon, without email, to test email verification; should receive emails for every message
p_d_id = self.res_partner.create(cr, uid, {'name': 'Dédé Grosbedon', 'email': 'd@d', 'notify_email': 'always'})
# 4 - Create a Bird mail.group, that will be used to test mass mailing
group_bird_id = self.mail_group.create(cr, uid,
{
'name': 'Bird',
'description': 'Bird resistance',
}, context={'mail_create_nolog': True})
group_bird = self.mail_group.browse(cr, uid, group_bird_id)
# 5 - Mail data
_subject = 'Pigs'
_body = 'Pigs <b>rule</b>'
_reply_subject = 'Re: %s' % _subject
_attachments = [
{'name': 'First', 'datas_fname': 'first.txt', 'datas': 'My first attachment'.encode('base64')},
{'name': 'Second', 'datas_fname': 'second.txt', 'datas': 'My second attachment'.encode('base64')}
]
_attachments_test = [('first.txt', 'My first attachment'), ('second.txt', 'My second attachment')]
# 6 - Subscribe Bert to Pigs
group_pigs.message_subscribe([p_b_id])
# --------------------------------------------------
# CASE1: wizard + partners + context keys
# --------------------------------------------------
# Do: Raoul wizard-composes on Pigs with auto-follow for partners, not for author
compose_id = mail_compose.create(cr, user_raoul.id,
{
'subject': _subject,
'body': _body,
'partner_ids': [(4, p_c_id), (4, p_d_id)],
}, context={
'default_composition_mode': 'comment',
'default_model': 'mail.group',
'default_res_id': self.group_pigs_id,
})
compose = mail_compose.browse(cr, uid, compose_id)
# Test: mail.compose.message: composition_mode, model, res_id
self.assertEqual(compose.composition_mode, 'comment', 'compose wizard: mail.compose.message incorrect composition_mode')
self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model')
self.assertEqual(compose.res_id, self.group_pigs_id, 'compose wizard: mail.compose.message incorrect res_id')
# Do: Post the comment
mail_compose.send_mail(cr, user_raoul.id, [compose_id], {'mail_post_autofollow': True, 'mail_create_nosubscribe': True})
group_pigs.refresh()
message = group_pigs.message_ids[0]
# Test: mail.group: followers (c and d added by auto follow key; raoul not added by nosubscribe key)
pigs_pids = [p.id for p in group_pigs.message_follower_ids]
test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id]
self.assertEqual(set(pigs_pids), set(test_pids),
'compose wizard: mail_post_autofollow and mail_create_nosubscribe context keys not correctly taken into account')
# Test: mail.message: subject, body inside p
self.assertEqual(message.subject, _subject, 'compose wizard: mail.message incorrect subject')
self.assertEqual(message.body, '<p>%s</p>' % _body, 'compose wizard: mail.message incorrect body')
# Test: mail.message: notified_partner_ids = admin + bert (followers) + c + d (recipients)
msg_pids = [partner.id for partner in message.notified_partner_ids]
test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id]
self.assertEqual(set(msg_pids), set(test_pids),
'compose wizard: mail.message notified_partner_ids incorrect')
# --------------------------------------------------
# CASE2: reply + attachments
# --------------------------------------------------
# Do: Reply with attachments
compose_id = mail_compose.create(cr, user_raoul.id,
{
'attachment_ids': [(0, 0, _attachments[0]), (0, 0, _attachments[1])]
}, context={
'default_composition_mode': 'comment',
'default_res_id': self.group_pigs_id,
'default_parent_id': message.id
})
compose = mail_compose.browse(cr, uid, compose_id)
# Test: mail.compose.message: model, res_id, parent_id
self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model')
self.assertEqual(compose.res_id, self.group_pigs_id, 'compose wizard: mail.compose.message incorrect res_id')
self.assertEqual(compose.parent_id.id, message.id, 'compose wizard: mail.compose.message incorrect parent_id')
# Test: mail.compose.message: subject as Re:.., body, parent_id
self.assertEqual(compose.subject, _reply_subject, 'compose wizard: mail.compose.message incorrect subject')
self.assertFalse(compose.body, 'compose wizard: mail.compose.message body should not contain parent message body')
self.assertEqual(compose.parent_id and compose.parent_id.id, message.id, 'compose wizard: mail.compose.message parent_id incorrect')
# Test: mail.compose.message: attachments
for attach in compose.attachment_ids:
self.assertIn((attach.datas_fname, attach.datas.decode('base64')), _attachments_test,
'compose wizard: mail.message attachment name / data incorrect')
# --------------------------------------------------
# CASE3: mass_mail on Pigs and Bird
# --------------------------------------------------
# Do: Compose in mass_mail_mode on pigs and bird
compose_id = mail_compose.create(
cr, user_raoul.id, {
'subject': _subject,
'body': '${object.description}',
'partner_ids': [(4, p_c_id), (4, p_d_id)],
}, context={
'default_composition_mode': 'mass_mail',
'default_model': 'mail.group',
'default_res_id': False,
'active_ids': [self.group_pigs_id, group_bird_id],
})
compose = mail_compose.browse(cr, uid, compose_id)
# Do: Post the comment, get created message for each group
mail_compose.send_mail(cr, user_raoul.id, [compose_id], context={
'default_res_id': -1,
'active_ids': [self.group_pigs_id, group_bird_id]
})
# check mail_mail
mail_mail_ids = self.mail_mail.search(cr, uid, [('subject', '=', _subject)])
for mail_mail in self.mail_mail.browse(cr, uid, mail_mail_ids):
self.assertEqual(set([p.id for p in mail_mail.recipient_ids]), set([p_c_id, p_d_id]),
'compose wizard: mail_mail mass mailing: mail.mail in mass mail incorrect recipients')
# check logged messages
group_pigs.refresh()
group_bird.refresh()
message1 = group_pigs.message_ids[0]
message2 = group_bird.message_ids[0]
# Test: Pigs and Bird did receive their message
test_msg_ids = self.mail_message.search(cr, uid, [], limit=2)
self.assertIn(message1.id, test_msg_ids, 'compose wizard: Pigs did not receive its mass mailing message')
self.assertIn(message2.id, test_msg_ids, 'compose wizard: Bird did not receive its mass mailing message')
# Test: mail.message: subject, body, subtype, notified partners (nobody + specific recipients)
self.assertEqual(message1.subject, _subject,
'compose wizard: message_post: mail.message in mass mail subject incorrect')
self.assertEqual(message1.body, '<p>%s</p>' % group_pigs.description,
'compose wizard: message_post: mail.message in mass mail body incorrect')
# self.assertEqual(set([p.id for p in message1.notified_partner_ids]), set([p_c_id, p_d_id]),
# 'compose wizard: message_post: mail.message in mass mail incorrect notified partners')
self.assertEqual(message2.subject, _subject,
'compose wizard: message_post: mail.message in mass mail subject incorrect')
self.assertEqual(message2.body, '<p>%s</p>' % group_bird.description,
'compose wizard: message_post: mail.message in mass mail body incorrect')
# self.assertEqual(set([p.id for p in message2.notified_partner_ids]), set([p_c_id, p_d_id]),
# 'compose wizard: message_post: mail.message in mass mail incorrect notified partners')
# Test: mail.group followers: author not added as follower in mass mail mode
pigs_pids = [p.id for p in group_pigs.message_follower_ids]
test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id]
self.assertEqual(set(pigs_pids), set(test_pids),
'compose wizard: mail_post_autofollow and mail_create_nosubscribe context keys not correctly taken into account')
bird_pids = [p.id for p in group_bird.message_follower_ids]
test_pids = [self.partner_admin_id]
self.assertEqual(set(bird_pids), set(test_pids),
'compose wizard: mail_post_autofollow and mail_create_nosubscribe context keys not correctly taken into account')
# Do: Compose in mass_mail, coming from list_view, we have an active_domain that should be supported
compose_id = mail_compose.create(cr, user_raoul.id,
{
'subject': _subject,
'body': '${object.description}',
'partner_ids': [(4, p_c_id), (4, p_d_id)],
}, context={
'default_composition_mode': 'mass_mail',
'default_model': 'mail.group',
'default_res_id': False,
'active_ids': [self.group_pigs_id],
'active_domain': [('name', 'in', ['Pigs', 'Bird'])],
})
compose = mail_compose.browse(cr, uid, compose_id)
# Do: Post the comment, get created message for each group
mail_compose.send_mail(
cr, user_raoul.id, [compose_id], context={
'default_res_id': -1,
'active_ids': [self.group_pigs_id, group_bird_id]
})
group_pigs.refresh()
group_bird.refresh()
message1 = group_pigs.message_ids[0]
message2 = group_bird.message_ids[0]
# Test: Pigs and Bird did receive their message
test_msg_ids = self.mail_message.search(cr, uid, [], limit=2)
self.assertIn(message1.id, test_msg_ids, 'compose wizard: Pigs did not receive its mass mailing message')
self.assertIn(message2.id, test_msg_ids, 'compose wizard: Bird did not receive its mass mailing message')
def test_30_needaction(self):
""" Tests for mail.message needaction. """
cr, uid, user_admin, user_raoul, group_pigs = self.cr, self.uid, self.user_admin, self.user_raoul, self.group_pigs
na_admin_base = self.mail_message._needaction_count(cr, uid, domain=[])
na_demo_base = self.mail_message._needaction_count(cr, user_raoul.id, domain=[])
# Test: number of unread notification = needaction on mail.message
notif_ids = self.mail_notification.search(cr, uid, [
('partner_id', '=', user_admin.partner_id.id),
('is_read', '=', False)
])
na_count = self.mail_message._needaction_count(cr, uid, domain=[])
self.assertEqual(len(notif_ids), na_count, 'unread notifications count does not match needaction count')
# Do: post 2 message on group_pigs as admin, 3 messages as demo user
for dummy in range(2):
group_pigs.message_post(body='My Body', subtype='mt_comment')
raoul_pigs = group_pigs.sudo(user_raoul)
for dummy in range(3):
raoul_pigs.message_post(body='My Demo Body', subtype='mt_comment')
# Test: admin has 3 new notifications (from demo), and 3 new needaction
notif_ids = self.mail_notification.search(cr, uid, [
('partner_id', '=', user_admin.partner_id.id),
('is_read', '=', False)
])
self.assertEqual(len(notif_ids), na_admin_base + 3, 'Admin should have 3 new unread notifications')
na_admin = self.mail_message._needaction_count(cr, uid, domain=[])
na_admin_group = self.mail_message._needaction_count(cr, uid, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)])
self.assertEqual(na_admin, na_admin_base + 3, 'Admin should have 3 new needaction')
self.assertEqual(na_admin_group, 3, 'Admin should have 3 needaction related to Pigs')
# Test: demo has 0 new notifications (not a follower, not receiving its own messages), and 0 new needaction
notif_ids = self.mail_notification.search(cr, uid, [
('partner_id', '=', user_raoul.partner_id.id),
('is_read', '=', False)
])
self.assertEqual(len(notif_ids), na_demo_base + 0, 'Demo should have 0 new unread notifications')
na_demo = self.mail_message._needaction_count(cr, user_raoul.id, domain=[])
na_demo_group = self.mail_message._needaction_count(cr, user_raoul.id, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)])
self.assertEqual(na_demo, na_demo_base + 0, 'Demo should have 0 new needaction')
self.assertEqual(na_demo_group, 0, 'Demo should have 0 needaction related to Pigs')
def test_40_track_field(self):
""" Testing auto tracking of fields. """
def _strip_string_spaces(body):
return body.replace(' ', '').replace('\n', '')
# Data: subscribe Raoul to Pigs, because he will change the public attribute and may loose access to the record
cr, uid = self.cr, self.uid
self.mail_group.message_subscribe_users(cr, uid, [self.group_pigs_id], [self.user_raoul_id])
# Data: res.users.group, to test group_public_id automatic logging
group_system_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_system')
group_system_id = group_system_ref and group_system_ref[1] or False
# Data: custom subtypes
mt_private_id = self.mail_message_subtype.create(cr, uid, {'name': 'private', 'description': 'Private public'})
self.ir_model_data.create(cr, uid, {'name': 'mt_private', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_private_id})
mt_name_supername_id = self.mail_message_subtype.create(cr, uid, {'name': 'name_supername', 'description': 'Supername name'})
self.ir_model_data.create(cr, uid, {'name': 'mt_name_supername', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_name_supername_id})
mt_group_public_set_id = self.mail_message_subtype.create(cr, uid, {'name': 'group_public_set', 'description': 'Group set'})
self.ir_model_data.create(cr, uid, {'name': 'mt_group_public_set', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_group_public_set_id})
mt_group_public_id = self.mail_message_subtype.create(cr, uid, {'name': 'group_public', 'description': 'Group changed'})
self.ir_model_data.create(cr, uid, {'name': 'mt_group_public', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_group_public_id})
# Data: alter mail_group model for testing purposes (test on classic, selection and many2one fields)
cls = type(self.mail_group)
self.assertNotIn('_track', cls.__dict__)
cls._track = {
'public': {
'mail.mt_private': lambda self, cr, uid, obj, ctx=None: obj.public == 'private',
},
'name': {
'mail.mt_name_supername': lambda self, cr, uid, obj, ctx=None: obj.name == 'supername',
},
'group_public_id': {
'mail.mt_group_public_set': lambda self, cr, uid, obj, ctx=None: obj.group_public_id,
'mail.mt_group_public': lambda self, cr, uid, obj, ctx=None: True,
},
}
visibility = {'public': 'onchange', 'name': 'always', 'group_public_id': 'onchange'}
for key in visibility:
self.assertFalse(hasattr(getattr(cls, key), 'track_visibility'))
getattr(cls, key).track_visibility = visibility[key]
@self.addCleanup
def cleanup():
delattr(cls, '_track')
for key in visibility:
del getattr(cls, key).track_visibility
# Test: change name -> always tracked, not related to a subtype
self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'public': 'public'})
self.group_pigs.refresh()
self.assertEqual(len(self.group_pigs.message_ids), 1, 'tracked: a message should have been produced')
# Test: first produced message: no subtype, name change tracked
last_msg = self.group_pigs.message_ids[-1]
self.assertFalse(last_msg.subtype_id, 'tracked: message should not have been linked to a subtype')
self.assertIn(u'SelectedGroupOnly\u2192Public', _strip_string_spaces(last_msg.body), 'tracked: message body incorrect')
self.assertIn('Pigs', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold always tracked field')
# Test: change name as supername, public as private -> 2 subtypes
self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'name': 'supername', 'public': 'private'})
self.group_pigs.refresh()
self.assertEqual(len(self.group_pigs.message_ids), 3, 'tracked: two messages should have been produced')
# Test: first produced message: mt_name_supername
last_msg = self.group_pigs.message_ids[-2]
self.assertEqual(last_msg.subtype_id.id, mt_private_id, 'tracked: message should be linked to mt_private subtype')
self.assertIn('Private public', last_msg.body, 'tracked: message body does not hold the subtype description')
self.assertIn(u'Pigs\u2192supername', _strip_string_spaces(last_msg.body), 'tracked: message body incorrect')
# Test: second produced message: mt_name_supername
last_msg = self.group_pigs.message_ids[-3]
self.assertEqual(last_msg.subtype_id.id, mt_name_supername_id, 'tracked: message should be linked to mt_name_supername subtype')
self.assertIn('Supername name', last_msg.body, 'tracked: message body does not hold the subtype description')
self.assertIn(u'Public\u2192Private', _strip_string_spaces(last_msg.body), 'tracked: message body incorrect')
self.assertIn(u'Pigs\u2192supername', _strip_string_spaces(last_msg.body), 'tracked feature: message body does not hold always tracked field')
# Test: change public as public, group_public_id -> 2 subtypes, name always tracked
self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'public': 'public', 'group_public_id': group_system_id})
self.group_pigs.refresh()
self.assertEqual(len(self.group_pigs.message_ids), 5, 'tracked: one message should have been produced')
# Test: first produced message: mt_group_public_set_id, with name always tracked, public tracked on change
last_msg = self.group_pigs.message_ids[-4]
self.assertEqual(last_msg.subtype_id.id, mt_group_public_set_id, 'tracked: message should be linked to mt_group_public_set_id')
self.assertIn('Group set', last_msg.body, 'tracked: message body does not hold the subtype description')
self.assertIn(u'Private\u2192Public', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold changed tracked field')
self.assertIn(u'HumanResources/Employee\u2192Administration/Settings', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold always tracked field')
# Test: second produced message: mt_group_public_id, with name always tracked, public tracked on change
last_msg = self.group_pigs.message_ids[-5]
self.assertEqual(last_msg.subtype_id.id, mt_group_public_id, 'tracked: message should be linked to mt_group_public_id')
self.assertIn('Group changed', last_msg.body, 'tracked: message body does not hold the subtype description')
self.assertIn(u'Private\u2192Public', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold changed tracked field')
self.assertIn(u'HumanResources/Employee\u2192Administration/Settings', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold always tracked field')
# Test: change group_public_id to False -> 1 subtype, name always tracked
self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'group_public_id': False})
self.group_pigs.refresh()
self.assertEqual(len(self.group_pigs.message_ids), 6, 'tracked: one message should have been produced')
# Test: first produced message: mt_group_public_set_id, with name always tracked, public tracked on change
last_msg = self.group_pigs.message_ids[-6]
self.assertEqual(last_msg.subtype_id.id, mt_group_public_id, 'tracked: message should be linked to mt_group_public_id')
self.assertIn('Group changed', last_msg.body, 'tracked: message body does not hold the subtype description')
self.assertIn(u'Administration/Settings\u2192', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold always tracked field')
# Test: change not tracked field, no tracking message
self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'description': 'Dummy'})
self.group_pigs.refresh()
self.assertEqual(len(self.group_pigs.message_ids), 6, 'tracked: No message should have been produced')
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
23813,
24636,
199,
3,
259,
1898,
334,
67,
9,
6029,
13,
2566,
11655,
7653,
428,
14,
33,
14,
665,
1014,
921,
11267,
14,
957,
30,
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,
2508,
1198,
63,
1198,
492,
6016,
63,
1198,
199,
504,
2508,
1198,
63,
2671,
492,
6016,
63,
2671,
199,
504,
1275,
2330,
492,
1379,
13681,
199,
504,
5166,
14,
2537,
492,
333,
938,
63,
2921,
12,
3031,
63,
1294,
12,
3517,
18,
17426,
199,
504,
5166,
14,
2537,
14,
1198,
492,
3517,
63,
18177,
199,
199,
533,
511,
63,
1198,
8,
774,
13681,
304,
339,
347,
511,
63,
1493,
63,
3620,
63,
2758,
8,
277,
304,
267,
408,
1379,
5678,
6016,
14,
3620,
3272,
5419,
12,
2544,
9936,
370,
675,
3062,
367,
14870,
408,
267,
2467,
12,
1747,
275,
291,
14,
1556,
12,
291,
14,
1535,
267,
291,
14,
751,
63,
86,
6078,
262,
63,
344,
275,
291,
14,
470,
63,
3707,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
354,
356,
283,
54,
6078,
262,
1849,
784,
24308,
297,
283,
2123,
356,
283,
86,
6078,
262,
14,
6862,
24308,
32,
6799,
14,
957,
297,
283,
2886,
356,
283,
86,
6078,
262,
14,
6862,
24308,
297,
283,
3620,
63,
354,
356,
283,
86,
6078,
262,
14,
6862,
24308,
3071,
267,
291,
14,
751,
63,
86,
6078,
262,
275,
291,
14,
470,
63,
3707,
14,
4570,
8,
1556,
12,
1747,
12,
291,
14,
751,
63,
86,
6078,
262,
63,
344,
9,
267,
291,
14,
2947,
8,
277,
14,
751,
63,
86,
6078,
262,
14,
3620,
63,
354,
12,
291,
14,
751,
63,
86,
6078,
262,
14,
2886,
12,
298,
8880,
1077,
506,
1202,
465,
5162,
531,
398,
291,
14,
751,
63,
15351,
290,
63,
344,
275,
291,
14,
470,
63,
3707,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
354,
356,
283,
23862,
290,
7005,
603,
1047,
867,
297,
283,
2123,
356,
283,
1168,
77,
1047,
867,
32,
6799,
14,
957,
297,
283,
2886,
356,
283,
1168,
77,
1047,
867,
32,
6799,
14,
957,
297,
283,
3620,
63,
354,
356,
283,
1168,
77,
1047,
867,
32,
6799,
14,
957,
3071,
267,
291,
14,
751,
63,
15351,
290,
275,
291,
14,
470,
63,
3707,
14,
4570,
8,
1556,
12,
1747,
12,
291,
14,
751,
63,
15351,
290,
63,
344,
9,
267,
291,
14,
2947,
8,
277,
14,
751,
63,
15351,
290,
14,
3620,
63,
354,
12,
283,
1168,
77,
1047,
867,
297,
298,
3917,
4676,
365,
376,
3031,
12,
314,
5162,
1077,
4215,
1454,
314,
2257,
1777,
531,
398,
291,
14,
751,
63,
1700,
369,
63,
344,
275,
291,
14,
470,
63,
3707,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
354,
356,
283,
5281,
273,
79,
320,
278,
87,
473,
2641,
2441,
297,
283,
2123,
356,
283,
1700,
369,
32,
6799,
14,
957,
297,
283,
2886,
356,
283,
66,
20,
82,
6416,
20930,
50,
19,
20159,
4,
4268,
283,
3620,
63,
354,
356,
283,
66,
20,
82,
6416,
20930,
50,
19,
20159,
23174,
3071,
267,
291,
14,
751,
63,
1700,
369,
275,
291,
14,
470,
63,
3707,
14,
4570,
8,
1556,
12,
1747,
12,
291,
14,
751,
63,
1700,
369,
63,
344,
9,
267,
291,
14,
2947,
8,
277,
14,
751,
63,
1700,
369,
14,
3620,
63,
354,
12,
283,
66,
20,
82,
6416,
13,
63,
82,
19,
20159,
14382,
283,
2825,
6541,
8365,
1077,
506,
8717,
701,
7188,
27920,
358,
339,
347,
511,
63,
383,
63,
22648,
63,
1593,
63,
698,
8,
277,
304,
267,
408,
6496,
19829,
367,
314,
5002,
18,
3479,
805,
901,
283,
25615,
63,
1580,
1370,
288,
2136,
911,
511,
370,
5147,
14511,
1808,
314,
5002,
18,
3479,
3718,
378,
12,
650,
12,
841,
12,
288,
959,
436,
1227,
14,
408,
267,
2467,
12,
1747,
12,
922,
63,
2113,
12,
5854,
63,
12504,
63,
344,
12,
1572,
63,
20389,
275,
291,
14,
1556,
12,
291,
14,
1535,
12,
291,
14,
751,
63,
2113,
12,
291,
14,
3899,
63,
12504,
63,
344,
12,
291,
14,
923,
63,
20389,
398,
327,
3918,
26,
1218,
283,
2686,
300,
10911,
7,
1338,
315,
6016,
14,
22648,
26,
2011,
522,
63,
344,
12,
1163,
522,
63,
1238,
27,
2011,
522,
63,
1238,
12,
1163,
522,
63,
344,
267,
1572,
63,
5869,
63,
344,
275,
291,
14,
1198,
63,
923,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
354,
356,
283,
11324,
1572,
2267,
791,
1198,
63,
981,
63,
889,
793,
356,
715,
1552,
267,
291,
14,
1198,
63,
22648,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
470,
63,
1238,
356,
283,
1198,
14,
2671,
297,
283,
470,
63,
344,
356,
291,
14,
923,
63,
20389,
63,
344,
12,
283,
3899,
63,
344,
356,
5854,
63,
12504,
63,
344,
1552,
267,
291,
14,
1198,
63,
22648,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
470,
63,
1238,
356,
283,
1198,
14,
923,
297,
283,
470,
63,
344,
356,
1572,
63,
5869,
63,
344,
12,
283,
3899,
63,
344,
356,
5854,
63,
12504,
63,
344,
1552,
398,
327,
19835,
458,
2951,
2737,
26,
1077,
506
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
23813,
24636,
199,
3,
259,
1898,
334,
67,
9,
6029,
13,
2566,
11655,
7653,
428,
14,
33,
14,
665,
1014,
921,
11267,
14,
957,
30,
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,
2508,
1198,
63,
1198,
492,
6016,
63,
1198,
199,
504,
2508,
1198,
63,
2671,
492,
6016,
63,
2671,
199,
504,
1275,
2330,
492,
1379,
13681,
199,
504,
5166,
14,
2537,
492,
333,
938,
63,
2921,
12,
3031,
63,
1294,
12,
3517,
18,
17426,
199,
504,
5166,
14,
2537,
14,
1198,
492,
3517,
63,
18177,
199,
199,
533,
511,
63,
1198,
8,
774,
13681,
304,
339,
347,
511,
63,
1493,
63,
3620,
63,
2758,
8,
277,
304,
267,
408,
1379,
5678,
6016,
14,
3620,
3272,
5419,
12,
2544,
9936,
370,
675,
3062,
367,
14870,
408,
267,
2467,
12,
1747,
275,
291,
14,
1556,
12,
291,
14,
1535,
267,
291,
14,
751,
63,
86,
6078,
262,
63,
344,
275,
291,
14,
470,
63,
3707,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
354,
356,
283,
54,
6078,
262,
1849,
784,
24308,
297,
283,
2123,
356,
283,
86,
6078,
262,
14,
6862,
24308,
32,
6799,
14,
957,
297,
283,
2886,
356,
283,
86,
6078,
262,
14,
6862,
24308,
297,
283,
3620,
63,
354,
356,
283,
86,
6078,
262,
14,
6862,
24308,
3071,
267,
291,
14,
751,
63,
86,
6078,
262,
275,
291,
14,
470,
63,
3707,
14,
4570,
8,
1556,
12,
1747,
12,
291,
14,
751,
63,
86,
6078,
262,
63,
344,
9,
267,
291,
14,
2947,
8,
277,
14,
751,
63,
86,
6078,
262,
14,
3620,
63,
354,
12,
291,
14,
751,
63,
86,
6078,
262,
14,
2886,
12,
298,
8880,
1077,
506,
1202,
465,
5162,
531,
398,
291,
14,
751,
63,
15351,
290,
63,
344,
275,
291,
14,
470,
63,
3707,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
354,
356,
283,
23862,
290,
7005,
603,
1047,
867,
297,
283,
2123,
356,
283,
1168,
77,
1047,
867,
32,
6799,
14,
957,
297,
283,
2886,
356,
283,
1168,
77,
1047,
867,
32,
6799,
14,
957,
297,
283,
3620,
63,
354,
356,
283,
1168,
77,
1047,
867,
32,
6799,
14,
957,
3071,
267,
291,
14,
751,
63,
15351,
290,
275,
291,
14,
470,
63,
3707,
14,
4570,
8,
1556,
12,
1747,
12,
291,
14,
751,
63,
15351,
290,
63,
344,
9,
267,
291,
14,
2947,
8,
277,
14,
751,
63,
15351,
290,
14,
3620,
63,
354,
12,
283,
1168,
77,
1047,
867,
297,
298,
3917,
4676,
365,
376,
3031,
12,
314,
5162,
1077,
4215,
1454,
314,
2257,
1777,
531,
398,
291,
14,
751,
63,
1700,
369,
63,
344,
275,
291,
14,
470,
63,
3707,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
354,
356,
283,
5281,
273,
79,
320,
278,
87,
473,
2641,
2441,
297,
283,
2123,
356,
283,
1700,
369,
32,
6799,
14,
957,
297,
283,
2886,
356,
283,
66,
20,
82,
6416,
20930,
50,
19,
20159,
4,
4268,
283,
3620,
63,
354,
356,
283,
66,
20,
82,
6416,
20930,
50,
19,
20159,
23174,
3071,
267,
291,
14,
751,
63,
1700,
369,
275,
291,
14,
470,
63,
3707,
14,
4570,
8,
1556,
12,
1747,
12,
291,
14,
751,
63,
1700,
369,
63,
344,
9,
267,
291,
14,
2947,
8,
277,
14,
751,
63,
1700,
369,
14,
3620,
63,
354,
12,
283,
66,
20,
82,
6416,
13,
63,
82,
19,
20159,
14382,
283,
2825,
6541,
8365,
1077,
506,
8717,
701,
7188,
27920,
358,
339,
347,
511,
63,
383,
63,
22648,
63,
1593,
63,
698,
8,
277,
304,
267,
408,
6496,
19829,
367,
314,
5002,
18,
3479,
805,
901,
283,
25615,
63,
1580,
1370,
288,
2136,
911,
511,
370,
5147,
14511,
1808,
314,
5002,
18,
3479,
3718,
378,
12,
650,
12,
841,
12,
288,
959,
436,
1227,
14,
408,
267,
2467,
12,
1747,
12,
922,
63,
2113,
12,
5854,
63,
12504,
63,
344,
12,
1572,
63,
20389,
275,
291,
14,
1556,
12,
291,
14,
1535,
12,
291,
14,
751,
63,
2113,
12,
291,
14,
3899,
63,
12504,
63,
344,
12,
291,
14,
923,
63,
20389,
398,
327,
3918,
26,
1218,
283,
2686,
300,
10911,
7,
1338,
315,
6016,
14,
22648,
26,
2011,
522,
63,
344,
12,
1163,
522,
63,
1238,
27,
2011,
522,
63,
1238,
12,
1163,
522,
63,
344,
267,
1572,
63,
5869,
63,
344,
275,
291,
14,
1198,
63,
923,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
354,
356,
283,
11324,
1572,
2267,
791,
1198,
63,
981,
63,
889,
793,
356,
715,
1552,
267,
291,
14,
1198,
63,
22648,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
470,
63,
1238,
356,
283,
1198,
14,
2671,
297,
283,
470,
63,
344,
356,
291,
14,
923,
63,
20389,
63,
344,
12,
283,
3899,
63,
344,
356,
5854,
63,
12504,
63,
344,
1552,
267,
291,
14,
1198,
63,
22648,
14,
981,
8,
1556,
12,
1747,
12,
288,
791,
470,
63,
1238,
356,
283,
1198,
14,
923,
297,
283,
470,
63,
344,
356,
1572,
63,
5869,
63,
344,
12,
283,
3899,
63,
344,
356,
5854,
63,
12504,
63,
344,
1552,
398,
327,
19835,
458,
2951,
2737,
26,
1077,
506,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
JioCloud/tempest
|
tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
|
35
|
1269
|
# Copyright 2014 NEC Corporation. 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.
set_get_flavor_extra_specs = {
'status_code': [200],
'response_body': {
'type': 'object',
'properties': {
'extra_specs': {
'type': 'object',
'patternProperties': {
'^[a-zA-Z0-9_\-\. :]+$': {'type': 'string'}
}
}
},
'additionalProperties': False,
'required': ['extra_specs']
}
}
set_get_flavor_extra_specs_key = {
'status_code': [200],
'response_body': {
'type': 'object',
'patternProperties': {
'^[a-zA-Z0-9_\-\. :]+$': {'type': 'string'}
}
}
}
|
apache-2.0
|
[
3,
1898,
6927,
653,
4220,
11098,
14,
221,
2900,
4481,
4644,
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,
409,
63,
362,
63,
6081,
63,
2911,
63,
7273,
275,
469,
272,
283,
1205,
63,
600,
356,
359,
1840,
467,
272,
283,
1310,
63,
2030,
356,
469,
267,
283,
466,
356,
283,
785,
297,
267,
283,
3282,
356,
469,
288,
283,
2911,
63,
7273,
356,
469,
355,
283,
466,
356,
283,
785,
297,
355,
283,
3401,
8516,
356,
469,
490,
14452,
59,
65,
13,
6353,
13,
58,
16,
13,
25,
18005,
2696,
14,
520,
2807,
4,
356,
791,
466,
356,
283,
875,
936,
355,
789,
288,
789,
267,
1660,
267,
283,
8460,
8516,
356,
756,
12,
267,
283,
2427,
356,
788,
2911,
63,
7273,
418,
272,
789,
199,
93,
199,
199,
409,
63,
362,
63,
6081,
63,
2911,
63,
7273,
63,
498,
275,
469,
272,
283,
1205,
63,
600,
356,
359,
1840,
467,
272,
283,
1310,
63,
2030,
356,
469,
267,
283,
466,
356,
283,
785,
297,
267,
283,
3401,
8516,
356,
469,
288,
14452,
59,
65,
13,
6353,
13,
58,
16,
13,
25,
18005,
2696,
14,
520,
2807,
4,
356,
791,
466,
356,
283,
875,
936,
267,
789,
272,
789,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6927,
653,
4220,
11098,
14,
221,
2900,
4481,
4644,
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,
409,
63,
362,
63,
6081,
63,
2911,
63,
7273,
275,
469,
272,
283,
1205,
63,
600,
356,
359,
1840,
467,
272,
283,
1310,
63,
2030,
356,
469,
267,
283,
466,
356,
283,
785,
297,
267,
283,
3282,
356,
469,
288,
283,
2911,
63,
7273,
356,
469,
355,
283,
466,
356,
283,
785,
297,
355,
283,
3401,
8516,
356,
469,
490,
14452,
59,
65,
13,
6353,
13,
58,
16,
13,
25,
18005,
2696,
14,
520,
2807,
4,
356,
791,
466,
356,
283,
875,
936,
355,
789,
288,
789,
267,
1660,
267,
283,
8460,
8516,
356,
756,
12,
267,
283,
2427,
356,
788,
2911,
63,
7273,
418,
272,
789,
199,
93,
199,
199,
409,
63,
362,
63,
6081,
63,
2911,
63,
7273,
63,
498,
275,
469,
272,
283,
1205,
63,
600,
356,
359,
1840,
467,
272,
283,
1310,
63,
2030,
356,
469,
267,
283,
466,
356,
283,
785,
297,
267,
283,
3401,
8516,
356,
469,
288,
14452,
59,
65,
13,
6353,
13,
58,
16,
13,
25,
18005,
2696,
14,
520,
2807,
4,
356,
791,
466,
356,
283,
875,
936,
267,
789,
272,
789,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
DroneBuster/ardupilot
|
libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_parse.py
|
44
|
2704
|
#!/usr/bin/env python
'''
extra DMA mapping tables from a stm32 datasheet
This assumes a csv file extracted from the datasheet using tablula:
https://github.com/tabulapdf/tabula
'''
import sys, csv, os
def parse_dma_table(fname, table):
dma_num = 1
csvt = csv.reader(open(fname,'rb'))
i = 0
last_channel = -1
for row in csvt:
if len(row) > 1 and row[1].startswith('Channel '):
row = row[1:]
if not row[0].startswith('Channel '):
continue
channel = int(row[0].split(' ')[1])
if channel < last_channel:
dma_num += 1
last_channel = channel
for stream in range(8):
s = row[stream+1]
s = s.replace('_\r', '_')
s = s.replace('\r_', '_')
if s == '-':
continue
keys = s.split()
for k in keys:
brace = k.find('(')
if brace != -1:
k = k[:brace]
if k not in table:
table[k] = []
table[k] += [(dma_num, stream, channel)]
def error(str):
'''show an error and exit'''
print("Error: " + str)
sys.exit(1)
def check_full_table(table):
'''check the table is not missing rows or columns
we should have at least one entry in every row and one entry in every colum of each dma table
'''
stream_mask = [0,0]
channel_mask = [0,0]
for k in table:
for v in table[k]:
(engine,stream,channel) = v
if engine > 2 or engine < 1:
error("Bad entry for %s: %s" % (k, v))
stream_mask[engine-1] |= 1<<stream
channel_mask[engine-1] |= 1<<channel
for i in range(2):
for c in range(8):
if not ((1<<c) & channel_mask[i]):
error("Missing channel %u for dma table %u" % (c, i))
if not ((1<<c) & stream_mask[i]):
error("Missing stream %u for dma table %u" % (c, i))
table = {}
if len(sys.argv) != 2:
print("Error: expected a CSV files and output file")
sys.exit(1)
parse_dma_table(sys.argv[1], table)
check_full_table(table)
sys.stdout.write("DMA_Map = {\n");
sys.stdout.write('\t# format is (DMA_TABLE, StreamNum, Channel)\n')
sys.stdout.write('\t# extracted from %s\n' % os.path.basename(sys.argv[1]))
for k in sorted(table.iterkeys()):
s = '"%s"' % k
sys.stdout.write('\t%-10s\t:\t[' % s)
for i in range(len(table[k])):
sys.stdout.write("(%u,%u,%u)" % (table[k][i][0], table[k][i][1], table[k][i][2]))
if i < len(table[k])-1:
sys.stdout.write(",")
sys.stdout.write("],\n")
sys.stdout.write("}\n");
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
2344,
199,
2911,
577,
2054,
4412,
6716,
687,
282,
410,
77,
708,
15012,
3797,
199,
199,
2765,
15194,
282,
7392,
570,
12509,
687,
314,
15012,
3797,
1808,
5174,
76,
7586,
26,
199,
4178,
921,
5031,
14,
957,
15,
2902,
348,
439,
1587,
15,
2902,
7586,
199,
199,
2344,
199,
199,
646,
984,
12,
7392,
12,
747,
199,
199,
318,
2198,
63,
68,
391,
63,
1224,
8,
5252,
12,
1817,
304,
272,
366,
391,
63,
1507,
275,
413,
272,
7392,
84,
275,
7392,
14,
5503,
8,
1490,
8,
5252,
2584,
4848,
1333,
272,
284,
275,
378,
272,
2061,
63,
2775,
275,
446,
17,
272,
367,
1962,
315,
7392,
84,
26,
267,
340,
822,
8,
1143,
9,
690,
413,
436,
1962,
59,
17,
1055,
2460,
360,
5358,
18927,
288,
1962,
275,
1962,
59,
17,
2938,
267,
340,
440,
1962,
59,
16,
1055,
2460,
360,
5358,
18927,
288,
1980,
267,
3623,
275,
1109,
8,
1143,
59,
16,
1055,
1294,
360,
27618,
17,
566,
267,
340,
3623,
665,
2061,
63,
2775,
26,
288,
366,
391,
63,
1507,
847,
413,
267,
2061,
63,
2775,
275,
3623,
267,
367,
2547,
315,
1425,
8,
24,
304,
288,
308,
275,
1962,
59,
1745,
11,
17,
61,
288,
308,
275,
308,
14,
1814,
6412,
60,
82,
297,
18962,
288,
308,
275,
308,
14,
1814,
2258,
82,
14474,
18962,
288,
340,
308,
508,
20905,
355,
1980,
288,
2883,
275,
308,
14,
1294,
342,
288,
367,
1022,
315,
2883,
26,
355,
23549,
275,
1022,
14,
1623,
14097,
358,
355,
340,
23549,
1137,
446,
17,
26,
490,
1022,
275,
1022,
1491,
22359,
61,
355,
340,
1022,
440,
315,
1817,
26,
490,
1817,
59,
75,
61,
275,
942,
355,
1817,
59,
75,
61,
847,
3842,
68,
391,
63,
1507,
12,
2547,
12,
3623,
1874,
199,
199,
318,
1125,
8,
495,
304,
272,
1449,
2384,
376,
1125,
436,
4458,
2344,
272,
870,
480,
547,
26,
298,
435,
620,
9,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
318,
1104,
63,
2861,
63,
1224,
8,
1224,
304,
272,
1449,
1074,
314,
1817,
365,
440,
4124,
4730,
503,
4362,
2126,
781,
1077,
1172,
737,
5210,
1373,
2397,
315,
4036,
1962,
436,
1373,
2397,
315,
4036,
1048,
453,
402,
1924,
366,
391,
1817,
272,
1449,
272,
2547,
63,
2629,
275,
359,
16,
12,
16,
61,
272,
3623,
63,
2629,
275,
359,
16,
12,
16,
61,
272,
367,
1022,
315,
1817,
26,
267,
367,
373,
315,
1817,
59,
75,
2189,
288,
334,
3908,
12,
1745,
12,
2775,
9,
275,
373,
288,
340,
6869,
690,
499,
503,
6869,
665,
413,
26,
355,
1125,
480,
5725,
2397,
367,
450,
83,
26,
450,
83,
2,
450,
334,
75,
12,
373,
430,
288,
2547,
63,
2629,
59,
3908,
13,
17,
61,
8901,
413,
8999,
1745,
288,
3623,
63,
2629,
59,
3908,
13,
17,
61,
8901,
413,
8999,
2775,
272,
367,
284,
315,
1425,
8,
18,
304,
267,
367,
286,
315,
1425,
8,
24,
304,
288,
340,
440,
3666,
17,
8999,
67,
9,
1253,
3623,
63,
2629,
59,
73,
4682,
355,
1125,
480,
7718,
3623,
450,
85,
367,
366,
391,
1817,
450,
85,
2,
450,
334,
67,
12,
284,
430,
288,
340,
440,
3666,
17,
8999,
67,
9,
1253,
2547,
63,
2629,
59,
73,
4682,
355,
1125,
480,
7718,
2547,
450,
85,
367,
366,
391,
1817,
450,
85,
2,
450,
334,
67,
12,
284,
430,
16872,
199,
1224,
275,
1052,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
1137,
499,
26,
272,
870,
480,
547,
26,
1420,
282,
14689,
1584,
436,
1072,
570,
531,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
1122,
63,
68,
391,
63,
1224,
8,
1274,
14,
3020,
59,
17,
467,
1817,
9,
199,
199,
1074,
63,
2861,
63,
1224,
8,
1224,
9,
199,
199,
1274,
14,
2703,
14,
952,
480,
36,
2054,
63,
2956,
275,
9459,
78,
3547,
199,
1274,
14,
2703,
14,
952,
2258,
84,
3,
1475,
365,
334,
36,
2054,
63,
8723,
12,
8271,
5667,
12,
17270,
2862,
78,
358,
199,
1274,
14,
2703,
14,
952,
2258,
84,
3,
12509,
687,
450,
83,
60,
78,
7,
450,
747,
14,
515,
14,
4846,
8,
1274,
14,
3020,
59,
17,
2459,
199,
199,
509,
1022,
315,
3355,
8,
1224,
14,
16007,
5109,
272,
308,
275,
18253,
83,
4507,
450,
1022,
272,
984,
14,
2703,
14,
952,
2258,
84,
5,
13,
709,
83,
60,
84,
3427,
84,
459,
450,
308,
9,
272,
367,
284,
315,
1425,
8,
552,
8,
1224,
59,
75,
18710,
267,
984,
14,
2703,
14,
952,
480,
4042,
85,
8719,
85,
8719,
85,
2924,
450,
334,
1224,
59,
75,
1527,
73,
1527,
16,
467,
1817,
59,
75,
1527,
73,
1527,
17,
467,
1817,
59,
75,
1527,
73,
1527,
18,
2459,
267,
340,
284,
665,
822,
8,
1224,
59,
75,
566,
13,
17,
26,
288,
984,
14,
2703,
14,
952,
20324,
272,
984,
14,
2703,
14,
952,
480,
26670,
78,
531,
199,
1274,
14,
2703,
14,
952,
480,
4988,
78,
3547,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
2344,
199,
2911,
577,
2054,
4412,
6716,
687,
282,
410,
77,
708,
15012,
3797,
199,
199,
2765,
15194,
282,
7392,
570,
12509,
687,
314,
15012,
3797,
1808,
5174,
76,
7586,
26,
199,
4178,
921,
5031,
14,
957,
15,
2902,
348,
439,
1587,
15,
2902,
7586,
199,
199,
2344,
199,
199,
646,
984,
12,
7392,
12,
747,
199,
199,
318,
2198,
63,
68,
391,
63,
1224,
8,
5252,
12,
1817,
304,
272,
366,
391,
63,
1507,
275,
413,
272,
7392,
84,
275,
7392,
14,
5503,
8,
1490,
8,
5252,
2584,
4848,
1333,
272,
284,
275,
378,
272,
2061,
63,
2775,
275,
446,
17,
272,
367,
1962,
315,
7392,
84,
26,
267,
340,
822,
8,
1143,
9,
690,
413,
436,
1962,
59,
17,
1055,
2460,
360,
5358,
18927,
288,
1962,
275,
1962,
59,
17,
2938,
267,
340,
440,
1962,
59,
16,
1055,
2460,
360,
5358,
18927,
288,
1980,
267,
3623,
275,
1109,
8,
1143,
59,
16,
1055,
1294,
360,
27618,
17,
566,
267,
340,
3623,
665,
2061,
63,
2775,
26,
288,
366,
391,
63,
1507,
847,
413,
267,
2061,
63,
2775,
275,
3623,
267,
367,
2547,
315,
1425,
8,
24,
304,
288,
308,
275,
1962,
59,
1745,
11,
17,
61,
288,
308,
275,
308,
14,
1814,
6412,
60,
82,
297,
18962,
288,
308,
275,
308,
14,
1814,
2258,
82,
14474,
18962,
288,
340,
308,
508,
20905,
355,
1980,
288,
2883,
275,
308,
14,
1294,
342,
288,
367,
1022,
315,
2883,
26,
355,
23549,
275,
1022,
14,
1623,
14097,
358,
355,
340,
23549,
1137,
446,
17,
26,
490,
1022,
275,
1022,
1491,
22359,
61,
355,
340,
1022,
440,
315,
1817,
26,
490,
1817,
59,
75,
61,
275,
942,
355,
1817,
59,
75,
61,
847,
3842,
68,
391,
63,
1507,
12,
2547,
12,
3623,
1874,
199,
199,
318,
1125,
8,
495,
304,
272,
1449,
2384,
376,
1125,
436,
4458,
2344,
272,
870,
480,
547,
26,
298,
435,
620,
9,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
318,
1104,
63,
2861,
63,
1224,
8,
1224,
304,
272,
1449,
1074,
314,
1817,
365,
440,
4124,
4730,
503,
4362,
2126,
781,
1077,
1172,
737,
5210,
1373,
2397,
315,
4036,
1962,
436,
1373,
2397,
315,
4036,
1048,
453,
402,
1924,
366,
391,
1817,
272,
1449,
272,
2547,
63,
2629,
275,
359,
16,
12,
16,
61,
272,
3623,
63,
2629,
275,
359,
16,
12,
16,
61,
272,
367,
1022,
315,
1817,
26,
267,
367,
373,
315,
1817,
59,
75,
2189,
288,
334,
3908,
12,
1745,
12,
2775,
9,
275,
373,
288,
340,
6869,
690,
499,
503,
6869,
665,
413,
26,
355,
1125,
480,
5725,
2397,
367,
450,
83,
26,
450,
83,
2,
450,
334,
75,
12,
373,
430,
288,
2547,
63,
2629,
59,
3908,
13,
17,
61,
8901,
413,
8999,
1745,
288,
3623,
63,
2629,
59,
3908,
13,
17,
61,
8901,
413,
8999,
2775,
272,
367,
284,
315,
1425,
8,
18,
304,
267,
367,
286,
315,
1425,
8,
24,
304,
288,
340,
440,
3666,
17,
8999,
67,
9,
1253,
3623,
63,
2629,
59,
73,
4682,
355,
1125,
480,
7718,
3623,
450,
85,
367,
366,
391,
1817,
450,
85,
2,
450,
334,
67,
12,
284,
430,
288,
340,
440,
3666,
17,
8999,
67,
9,
1253,
2547,
63,
2629,
59,
73,
4682,
355,
1125,
480,
7718,
2547,
450,
85,
367,
366,
391,
1817,
450,
85,
2,
450,
334,
67,
12,
284,
430,
16872,
199,
1224,
275,
1052,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
1137,
499,
26,
272,
870,
480,
547,
26,
1420,
282,
14689,
1584,
436,
1072,
570,
531,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
1122,
63,
68,
391,
63,
1224,
8,
1274,
14,
3020,
59,
17,
467,
1817,
9,
199,
199,
1074,
63,
2861,
63,
1224,
8,
1224,
9,
199,
199,
1274,
14,
2703,
14,
952,
480,
36,
2054,
63,
2956,
275,
9459,
78,
3547,
199,
1274,
14,
2703,
14,
952,
2258,
84,
3,
1475,
365,
334,
36,
2054,
63,
8723,
12,
8271,
5667,
12,
17270,
2862,
78,
358,
199,
1274,
14,
2703,
14,
952,
2258,
84,
3,
12509,
687,
450,
83,
60,
78,
7,
450,
747,
14,
515,
14,
4846,
8,
1274,
14,
3020,
59,
17,
2459,
199,
199,
509,
1022,
315,
3355,
8,
1224,
14,
16007,
5109,
272,
308,
275,
18253,
83,
4507,
450,
1022,
272,
984,
14,
2703,
14,
952,
2258,
84,
5,
13,
709,
83,
60,
84,
3427,
84,
459,
450,
308,
9,
272,
367,
284,
315,
1425,
8,
552,
8,
1224,
59,
75,
18710,
267,
984,
14,
2703,
14,
952,
480,
4042,
85,
8719,
85,
8719,
85,
2924,
450,
334,
1224,
59,
75,
1527,
73,
1527,
16,
467,
1817,
59,
75,
1527,
73,
1527,
17,
467,
1817,
59,
75,
1527,
73,
1527,
18,
2459,
267,
340,
284,
665,
822,
8,
1224,
59,
75,
566,
13,
17,
26,
288,
984,
14,
2703,
14,
952,
20324,
272,
984,
14,
2703,
14,
952,
480,
26670,
78,
531,
199,
1274,
14,
2703,
14,
952,
480,
4988,
78,
3547,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jrha/aquilon
|
lib/python2.6/aquilon/aqdb/model/model.py
|
2
|
2735
|
# -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# ex: set expandtab softtabstop=4 shiftwidth=4:
#
# Copyright (C) 2008,2009,2010,2011,2012,2013 Contributor
#
# 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.
""" basic construct of model = vendor name + product name """
from datetime import datetime
from sqlalchemy import (Integer, DateTime, Sequence, String, Column, ForeignKey,
UniqueConstraint)
from sqlalchemy.orm import relation, object_session, deferred
from aquilon.exceptions_ import AquilonError
from aquilon.aqdb.model import Base, Vendor
from aquilon.aqdb.column_types.aqstr import AqStr
class Model(Base):
""" Vendor and Model are representations of the various manufacturers and
the asset inventory of the kinds of machines we use in the plant """
__tablename__ = 'model'
id = Column(Integer, Sequence('model_id_seq'), primary_key=True)
name = Column(AqStr(64), nullable=False)
vendor_id = Column(Integer, ForeignKey('vendor.id',
name='model_vendor_fk'),
nullable=False)
machine_type = Column(AqStr(16), nullable=False)
creation_date = deferred(Column(DateTime, default=datetime.now,
nullable=False))
comments = Column(String(255))
vendor = relation(Vendor)
__table_args__ = (UniqueConstraint(vendor_id, name,
name='model_vendor_name_uk'),)
def __format__(self, format_spec):
instance = "%s/%s" % (self.vendor.name, self.name)
return self.format_helper(format_spec, instance)
@classmethod
def default_nic_model(cls, session):
# TODO: make this configurable
return cls.get_unique(session, machine_type='nic', name='generic_nic',
vendor='generic', compel=AquilonError)
@property
def nic_model(self):
if self.machine_specs:
return self.machine_specs.nic_model
session = object_session(self)
return self.default_nic_model(session)
model = Model.__table__ # pylint: disable=C0103
model.info['unique_fields'] = ['name', 'vendor']
model.info['extra_search_fields'] = ['machine_type']
|
apache-2.0
|
[
3,
1882,
286,
647,
13,
3724,
13,
1896,
26,
841,
27,
4363,
13,
8741,
13,
632,
26,
32644,
1882,
199,
3,
444,
26,
663,
26414,
25966,
29,
20,
20105,
29,
20,
26,
199,
3,
199,
3,
1898,
334,
35,
9,
9079,
12,
8664,
12,
6542,
12,
8128,
12,
7409,
12,
6965,
221,
17636,
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,
624,
5678,
6982,
402,
1402,
275,
20868,
536,
435,
3336,
536,
408,
199,
199,
504,
2197,
492,
2197,
199,
199,
504,
8335,
492,
334,
2674,
12,
13686,
12,
10975,
12,
2624,
12,
4996,
12,
12718,
12,
717,
18276,
8463,
9,
199,
199,
504,
8335,
14,
1025,
492,
5850,
12,
909,
63,
1730,
12,
12309,
199,
199,
504,
282,
392,
382,
265,
14,
3924,
63,
492,
437,
392,
382,
265,
547,
199,
504,
282,
392,
382,
265,
14,
30030,
697,
14,
1238,
492,
3523,
12,
812,
7454,
199,
504,
282,
392,
382,
265,
14,
30030,
697,
14,
2301,
63,
1313,
14,
30030,
495,
492,
437,
81,
2848,
421,
199,
533,
5822,
8,
1563,
304,
272,
408,
812,
7454,
436,
5822,
787,
30580,
402,
314,
7750,
2169,
17391,
2393,
436,
272,
314,
8977,
8200,
402,
314,
24241,
402,
20601,
781,
675,
315,
314,
1620,
867,
408,
272,
636,
10983,
363,
275,
283,
1238,
7,
339,
1305,
275,
4996,
8,
2674,
12,
10975,
360,
1238,
63,
344,
63,
3610,
659,
5062,
63,
498,
29,
549,
9,
272,
536,
275,
4996,
8,
33,
81,
2848,
8,
772,
395,
7854,
29,
797,
9,
339,
20868,
63,
344,
275,
4996,
8,
2674,
12,
12718,
360,
9884,
14,
344,
297,
5644,
536,
534,
1238,
63,
9884,
63,
9010,
659,
2432,
7854,
29,
797,
9,
272,
6844,
63,
466,
275,
4996,
8,
33,
81,
2848,
8,
975,
395,
7854,
29,
797,
9,
339,
7143,
63,
602,
275,
12309,
8,
4547,
8,
3926,
12,
849,
29,
2083,
14,
2131,
12,
2511,
7854,
29,
797,
430,
272,
6786,
275,
4996,
8,
1558,
8,
2299,
430,
339,
20868,
275,
5850,
8,
27111,
9,
339,
636,
1224,
63,
589,
363,
275,
334,
11427,
8463,
8,
9884,
63,
344,
12,
536,
12,
4318,
536,
534,
1238,
63,
9884,
63,
354,
63,
3210,
659,
9,
339,
347,
636,
908,
721,
277,
12,
1475,
63,
1650,
304,
267,
1256,
275,
2071,
83,
3149,
83,
2,
450,
334,
277,
14,
9884,
14,
354,
12,
291,
14,
354,
9,
267,
372,
291,
14,
908,
63,
3676,
8,
908,
63,
1650,
12,
1256,
9,
339,
768,
3744,
272,
347,
849,
63,
12165,
63,
1238,
8,
1886,
12,
2351,
304,
267,
327,
3254,
26,
1852,
642,
30241,
267,
372,
843,
14,
362,
63,
3235,
8,
1730,
12,
6844,
63,
466,
534,
12165,
297,
536,
534,
6767,
63,
12165,
297,
2892,
20868,
534,
6767,
297,
1013,
352,
29,
33,
392,
382,
265,
547,
9,
339,
768,
1829,
272,
347,
14304,
63,
1238,
8,
277,
304,
267,
340,
291,
14,
6744,
63,
7273,
26,
288,
372,
291,
14,
6744,
63,
7273,
14,
12165,
63,
1238,
398,
2351,
275,
909,
63,
1730,
8,
277,
9,
267,
372,
291,
14,
885,
63,
12165,
63,
1238,
8,
1730,
9,
199,
199,
1238,
275,
5822,
855,
1224,
363,
221,
327,
4287,
26,
3507,
29,
35,
28399,
199,
1238,
14,
815,
459,
3235,
63,
955,
418,
275,
788,
354,
297,
283,
9884,
418,
199,
1238,
14,
815,
459,
2911,
63,
1733,
63,
955,
418,
275,
788,
6744,
63,
466,
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
] |
[
1882,
286,
647,
13,
3724,
13,
1896,
26,
841,
27,
4363,
13,
8741,
13,
632,
26,
32644,
1882,
199,
3,
444,
26,
663,
26414,
25966,
29,
20,
20105,
29,
20,
26,
199,
3,
199,
3,
1898,
334,
35,
9,
9079,
12,
8664,
12,
6542,
12,
8128,
12,
7409,
12,
6965,
221,
17636,
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,
624,
5678,
6982,
402,
1402,
275,
20868,
536,
435,
3336,
536,
408,
199,
199,
504,
2197,
492,
2197,
199,
199,
504,
8335,
492,
334,
2674,
12,
13686,
12,
10975,
12,
2624,
12,
4996,
12,
12718,
12,
717,
18276,
8463,
9,
199,
199,
504,
8335,
14,
1025,
492,
5850,
12,
909,
63,
1730,
12,
12309,
199,
199,
504,
282,
392,
382,
265,
14,
3924,
63,
492,
437,
392,
382,
265,
547,
199,
504,
282,
392,
382,
265,
14,
30030,
697,
14,
1238,
492,
3523,
12,
812,
7454,
199,
504,
282,
392,
382,
265,
14,
30030,
697,
14,
2301,
63,
1313,
14,
30030,
495,
492,
437,
81,
2848,
421,
199,
533,
5822,
8,
1563,
304,
272,
408,
812,
7454,
436,
5822,
787,
30580,
402,
314,
7750,
2169,
17391,
2393,
436,
272,
314,
8977,
8200,
402,
314,
24241,
402,
20601,
781,
675,
315,
314,
1620,
867,
408,
272,
636,
10983,
363,
275,
283,
1238,
7,
339,
1305,
275,
4996,
8,
2674,
12,
10975,
360,
1238,
63,
344,
63,
3610,
659,
5062,
63,
498,
29,
549,
9,
272,
536,
275,
4996,
8,
33,
81,
2848,
8,
772,
395,
7854,
29,
797,
9,
339,
20868,
63,
344,
275,
4996,
8,
2674,
12,
12718,
360,
9884,
14,
344,
297,
5644,
536,
534,
1238,
63,
9884,
63,
9010,
659,
2432,
7854,
29,
797,
9,
272,
6844,
63,
466,
275,
4996,
8,
33,
81,
2848,
8,
975,
395,
7854,
29,
797,
9,
339,
7143,
63,
602,
275,
12309,
8,
4547,
8,
3926,
12,
849,
29,
2083,
14,
2131,
12,
2511,
7854,
29,
797,
430,
272,
6786,
275,
4996,
8,
1558,
8,
2299,
430,
339,
20868,
275,
5850,
8,
27111,
9,
339,
636,
1224,
63,
589,
363,
275,
334,
11427,
8463,
8,
9884,
63,
344,
12,
536,
12,
4318,
536,
534,
1238,
63,
9884,
63,
354,
63,
3210,
659,
9,
339,
347,
636,
908,
721,
277,
12,
1475,
63,
1650,
304,
267,
1256,
275,
2071,
83,
3149,
83,
2,
450,
334,
277,
14,
9884,
14,
354,
12,
291,
14,
354,
9,
267,
372,
291,
14,
908,
63,
3676,
8,
908,
63,
1650,
12,
1256,
9,
339,
768,
3744,
272,
347,
849,
63,
12165,
63,
1238,
8,
1886,
12,
2351,
304,
267,
327,
3254,
26,
1852,
642,
30241,
267,
372,
843,
14,
362,
63,
3235,
8,
1730,
12,
6844,
63,
466,
534,
12165,
297,
536,
534,
6767,
63,
12165,
297,
2892,
20868,
534,
6767,
297,
1013,
352,
29,
33,
392,
382,
265,
547,
9,
339,
768,
1829,
272,
347,
14304,
63,
1238,
8,
277,
304,
267,
340,
291,
14,
6744,
63,
7273,
26,
288,
372,
291,
14,
6744,
63,
7273,
14,
12165,
63,
1238,
398,
2351,
275,
909,
63,
1730,
8,
277,
9,
267,
372,
291,
14,
885,
63,
12165,
63,
1238,
8,
1730,
9,
199,
199,
1238,
275,
5822,
855,
1224,
363,
221,
327,
4287,
26,
3507,
29,
35,
28399,
199,
1238,
14,
815,
459,
3235,
63,
955,
418,
275,
788,
354,
297,
283,
9884,
418,
199,
1238,
14,
815,
459,
2911,
63,
1733,
63,
955,
418,
275,
788,
6744,
63,
466,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ctoher/pymatgen
|
pymatgen/io/qchemio.py
|
3
|
78861
|
# coding: utf-8
from __future__ import unicode_literals
import textwrap
"""
This module implements input and output processing from QChem.
"""
import copy
import re
import numpy as np
from string import Template
import six
from monty.io import zopen
from pymatgen.core.operations import SymmOp
from pymatgen.core.structure import Molecule
from pymatgen.core.units import Energy, FloatWithUnit
from pymatgen.serializers.json_coders import PMGSONable
from pymatgen.util.coord_utils import get_angle
from six.moves import map, zip
__author__ = "Xiaohui Qu"
__copyright__ = "Copyright 2013, The Electrolyte Genome Project"
__version__ = "0.1"
__maintainer__ = "Xiaohui Qu"
__email__ = "xhqu1981@gmail.com"
__date__ = "11/4/13"
class QcTask(PMGSONable):
"""
An object representing a QChem input file.
Args:
molecule: The input molecule. If it is None of string "read",
QChem will read geometry from checkpoint file. If it is a
Molecule object, QcInput will convert it into Cartesian
coordinates. Valid values: pymatgen Molecule object, "read", None
Defaults to None.
charge (int): Charge of the molecule. If None, charge on molecule is
used. Defaults to None.
spin_multiplicity (int): Spin multiplicity of molecule. Defaults to
None, which means that the spin multiplicity is set to 1 if the
molecule has no unpaired electrons and to 2 if there are
unpaired electrons.
jobtype (str): The type the QChem job. "SP" for Single Point Energy,
"opt" for geometry optimization, "freq" for
vibrational frequency.
title (str): Comments for the job. Defaults to None. Which means the
$comment section will be discarded.
exchange (str): The exchange methods of the theory. Examples including:
"B" (in pure BLYP), "PW91", "PBE", "TPSS".
Defaults to "HF".
This parameter can also be common names of hybrid
functionals, such as B3LYP, TPSSh, XYGJOS. In such cases,
the correlation parameter should be left as None.
correlation (str): The correlation level of the theory. Example
including: "MP2", "RI-MP2", "CCSD(T)", "LYP", "PBE", "TPSS"
Defaults to None.
basis_set (str/dict): The basis set.
If it is a dict, each element can use different basis set.
aux_basis_set (str/dict): Auxiliary basis set. For methods,
like RI-MP2, XYG3, OXYJ-OS, auxiliary basis set is required.
If it is a dict, each element can use different auxiliary
basis set.
ecp: Effective core potential (ECP) to be used.
If it is a dict, each element can use different ECP.
rem_params (dict): The parameters supposed to write in the $rem
section. Dict of key/value pairs.
Example: {"scf_algorithm": "diis_gdm", "scf_max_cycles": 100}
optional_params (dict): The parameter for keywords other than $rem
section. Dict of key/value pairs.
Example: {"basis": {"Li": "cc-PVTZ", "B": "aug-cc-PVTZ",
"F": "aug-cc-PVTZ"} "ecp": {"Cd": "srsc", "Br": "srlc"}}
ghost_atom (list): List of ghost atoms indices. Indices start from 0.
The ghost atom will be represented in of the form of @element_symmbol
"""
optional_keywords_list = {"basis", "basis2", "ecp", "empirical_dispersion",
"external_charges", "force_field_params",
"intracule", "isotopes", "aux_basis",
"localized_diabatization", "multipole_field",
"nbo", "occupied", "swap_occupied_virtual", "opt",
"pcm", "pcm_solvent", "plots", "qm_atoms", "svp",
"svpirf", "van_der_waals", "xc_functional",
"cdft", "efp_fragments", "efp_params", "alist"}
alternative_keys = {"job_type": "jobtype",
"symmetry_ignore": "sym_ignore",
"scf_max_cycles": "max_scf_cycles"}
alternative_values = {"optimization": "opt",
"frequency": "freq"}
zmat_patt = re.compile("^(\w+)*([\s,]+(\w+)[\s,]+(\w+))*[\-\.\s,\w]*$")
xyz_patt = re.compile("^(\w+)[\s,]+([\d\.eE\-]+)[\s,]+([\d\.eE\-]+)[\s,]+"
"([\d\.eE\-]+)[\-\.\s,\w.]*$")
def __init__(self, molecule=None, charge=None, spin_multiplicity=None,
jobtype='SP', title=None, exchange="HF", correlation=None,
basis_set="6-31+G*", aux_basis_set=None, ecp=None,
rem_params=None, optional_params=None, ghost_atoms=None):
self.mol = copy.deepcopy(molecule) if molecule else "read"
self.charge = charge
self.spin_multiplicity = spin_multiplicity
if isinstance(self.mol, six.string_types):
self.mol = self.mol.lower()
if self.mol != "read":
raise ValueError('The only accept text value for mol is "read"')
elif isinstance(self.mol, list):
for m in self.mol:
if not isinstance(m, Molecule):
raise ValueError("In case of type list, every element of mol must be a pymatgen Molecule")
if self.charge is None or self.spin_multiplicity is None:
raise ValueError("For fragments molecule section input, charge and spin_multiplicity "
"must be specificed")
total_charge = sum([m.charge for m in self.mol])
total_unpaired_electron = sum([m.spin_multiplicity-1 for m in self.mol])
if total_charge != self.charge:
raise ValueError("The charge of the molecule doesn't equal to the sum of the fragment charges")
if total_unpaired_electron % 2 != (self.spin_multiplicity - 1) % 2:
raise ValueError("Spin multiplicity of molecule and fragments doesn't match")
elif isinstance(self.mol, Molecule):
self.charge = charge if charge is not None else self.mol.charge
ghost_nelectrons = 0
if ghost_atoms:
for i in ghost_atoms:
site = self.mol.sites[i]
for sp, amt in site.species_and_occu.items():
ghost_nelectrons += sp.Z * amt
nelectrons = self.mol.charge + self.mol.nelectrons - ghost_nelectrons - self.charge
if spin_multiplicity is not None:
self.spin_multiplicity = spin_multiplicity
if (nelectrons + spin_multiplicity) % 2 != 1:
raise ValueError("Charge of {} and spin multiplicity of {} "
"is not possible for this molecule"
.format(self.charge, spin_multiplicity))
else:
self.spin_multiplicity = 1 if nelectrons % 2 == 0 else 2
else:
raise ValueError("The molecule must be a pymatgen Molecule "
"object or read/None or list of pymatgen Molecule")
if (self.charge is None) != (self.spin_multiplicity is None):
raise ValueError("spin multiplicity must be set together")
if self.charge is not None and isinstance(self.mol, Molecule) and not ghost_atoms:
self.mol.set_charge_and_spin(self.charge, self.spin_multiplicity)
self.params = dict()
if title is not None:
self.params["comment"] = self._wrap_comment(title)
if "rem" not in self.params:
self.params["rem"] = dict()
self.params["rem"]["exchange"] = exchange.lower()
available_jobtypes = {"sp", "opt", "ts", "freq", "force", "rpath",
"nmr", "bsse", "eda", "pes_scan", "fsm", "aimd",
"pimc", "makeefp"}
jt = jobtype.lower()
if jt in self.alternative_values:
jt = self.alternative_values[jt]
if jt not in available_jobtypes:
raise ValueError("Job type " + jobtype + " is not supported yet")
self.params["rem"]["jobtype"] = jobtype.lower()
if correlation is not None:
self.params["rem"]["correlation"] = correlation.lower()
if rem_params is not None:
for k, v in rem_params.items():
k = k.lower()
if k in self.alternative_keys:
k = self.alternative_keys[k]
if isinstance(v, six.string_types):
v = str(v).lower()
if v in self.alternative_values:
# noinspection PyTypeChecker
v = self.alternative_values[v]
self.params["rem"][k] = v
elif isinstance(v, int) or isinstance(v, float):
self.params["rem"][k] = v
else:
raise ValueError("The value in $rem can only be Integer "
"or string")
if optional_params:
op_key = set([k.lower() for k in optional_params.keys()])
if len(op_key - self.optional_keywords_list) > 0:
invalid_keys = op_key - self.optional_keywords_list
raise ValueError(','.join(['$' + k for k in invalid_keys]) +
'is not a valid optional section')
self.params.update(optional_params)
self.set_basis_set(basis_set)
if aux_basis_set is None:
if self._aux_basis_required():
if isinstance(self.params["rem"]["basis"], six.string_types):
if self.params["rem"]["basis"].startswith("6-31+g"):
self.set_auxiliary_basis_set("rimp2-aug-cc-pvdz")
elif self.params["rem"]["basis"].startswith("6-311+g"):
self.set_auxiliary_basis_set("rimp2-aug-cc-pvtz")
if "aux_basis" not in self.params["rem"]:
raise ValueError("Auxiliary basis set is missing")
else:
self.set_auxiliary_basis_set(aux_basis_set)
if ecp:
self.set_ecp(ecp)
self.ghost_atoms = ghost_atoms
if self.ghost_atoms:
if not isinstance(self.ghost_atoms, list):
raise ValueError("ghost_atoms must be a list of integers")
for atom in self.ghost_atoms:
if not isinstance(atom, int):
raise ValueError("Each element of ghost atom list must an integer")
def _aux_basis_required(self):
if self.params["rem"]["exchange"] in ['xygjos', 'xyg3', 'lxygjos']:
return True
if 'correlation' in self.params["rem"]:
if self.params["rem"]["correlation"].startswith("ri"):
return True
def set_basis_set(self, basis_set):
if isinstance(basis_set, six.string_types):
self.params["rem"]["basis"] = str(basis_set).lower()
if basis_set.lower() not in ["gen", "mixed"]:
self.params.pop("basis", None)
elif isinstance(basis_set, dict):
self.params["rem"]["basis"] = "gen"
bs = dict()
for element, basis in basis_set.items():
bs[element.strip().capitalize()] = basis.lower()
self.params["basis"] = bs
if self.mol:
mol_elements = set([site.species_string for site
in self.mol.sites])
basis_elements = set(self.params["basis"].keys())
if len(mol_elements - basis_elements) > 0:
raise ValueError("The basis set for elements " +
", ".join(
list(mol_elements - basis_elements)) +
" is missing")
if len(basis_elements - mol_elements) > 0:
raise ValueError("Basis set error: the molecule "
"doesn't contain element " +
", ".join(basis_elements - mol_elements))
elif isinstance(basis_set, list):
self.params["rem"]["basis"] = "mixed"
bs = [(a[0].capitalize(), a[1].lower()) for a in basis_set]
self.params["basis"] = bs
if len(self.mol) != len(basis_set):
raise ValueError("Must specific a basis set for every atom")
mol_elements = [site.species_string for site in self.mol.sites]
basis_elements = [a[0] for a in bs]
if mol_elements != basis_elements:
raise ValueError("Elements in molecule and mixed basis set don't match")
else:
raise Exception('Can\'t handle type "{}"'.format(type(basis_set)))
def set_partial_hessian_atoms(self, alist, phess=1):
for a in alist:
if not isinstance(a, int):
raise ValueError("the parament alist must a list of atom indices")
self.params["rem"]["n_sol"] = len(alist)
if phess == 1:
self.params["rem"]["phess"] = True
else:
self.params["rem"]["phess"] = phess
self.params["rem"]["jobtype"] = "freq"
self.params["alist"] = alist
def set_basis2(self, basis2_basis_set):
if isinstance(basis2_basis_set, six.string_types):
self.params["rem"]["basis2"] = basis2_basis_set.lower()
if basis2_basis_set.lower() not in ["basis2_gen", "basis2_mixed"]:
self.params.pop("basis2", None)
elif isinstance(basis2_basis_set, dict):
self.params["rem"]["basis2"] = "basis2_gen"
bs = dict()
for element, basis in basis2_basis_set.items():
bs[element.strip().capitalize()] = basis.lower()
self.params["basis2"] = bs
if self.mol:
mol_elements = set([site.species_string for site
in self.mol.sites])
basis_elements = set(self.params["basis2"].keys())
if len(mol_elements - basis_elements) > 0:
raise ValueError("The BASIS2 basis set for "
"elements " +
", ".join(
list(mol_elements - basis_elements)) +
" is missing")
if len(basis_elements - mol_elements) > 0:
raise ValueError("BASIS2 basis set error: the "
"molecule doesn't contain element " +
", ".join(basis_elements - mol_elements))
elif isinstance(basis2_basis_set, list):
self.params["rem"]["basis2"] = "basis2_mixed"
bs = [(a[0].capitalize(), a[1].lower()) for a in basis2_basis_set]
self.params["basis2"] = bs
if len(self.mol) != len(basis2_basis_set):
raise ValueError("Must specific a BASIS2 basis set for every atom")
mol_elements = [site.species_string for site in self.mol.sites]
basis_elements = [a[0] for a in bs]
if mol_elements != basis_elements:
raise ValueError("Elements in molecule and mixed basis set don't match")
else:
raise Exception('Can\'t handle type "{}"'.format(type(basis2_basis_set)))
def set_auxiliary_basis_set(self, aux_basis_set):
if isinstance(aux_basis_set, six.string_types):
self.params["rem"]["aux_basis"] = aux_basis_set.lower()
if aux_basis_set.lower() not in ["gen", "mixed"]:
self.params.pop("aux_basis", None)
elif isinstance(aux_basis_set, dict):
self.params["rem"]["aux_basis"] = "gen"
bs = dict()
for element, basis in aux_basis_set.items():
bs[element.strip().capitalize()] = basis.lower()
self.params["aux_basis"] = bs
if self.mol:
mol_elements = set([site.species_string for site
in self.mol.sites])
basis_elements = set(self.params["aux_basis"].keys())
if len(mol_elements - basis_elements) > 0:
raise ValueError("The auxiliary basis set for "
"elements " +
", ".join(
list(mol_elements - basis_elements)) +
" is missing")
if len(basis_elements - mol_elements) > 0:
raise ValueError("Auxiliary asis set error: the "
"molecule doesn't contain element " +
", ".join(basis_elements - mol_elements))
elif isinstance(aux_basis_set, list):
self.params["rem"]["aux_basis"] = "mixed"
bs = [(a[0].capitalize(), a[1].lower()) for a in aux_basis_set]
self.params["aux_basis"] = bs
if len(self.mol) != len(aux_basis_set):
raise ValueError("Must specific a auxiliary basis set for every atom")
mol_elements = [site.species_string for site in self.mol.sites]
basis_elements = [a[0] for a in bs]
if mol_elements != basis_elements:
raise ValueError("Elements in molecule and mixed basis set don't match")
else:
raise Exception('Can\'t handle type "{}"'.format(type(aux_basis_set)))
def set_ecp(self, ecp):
if isinstance(ecp, six.string_types):
self.params["rem"]["ecp"] = ecp.lower()
elif isinstance(ecp, dict):
self.params["rem"]["ecp"] = "gen"
potentials = dict()
for element, p in ecp.items():
potentials[element.strip().capitalize()] = p.lower()
self.params["ecp"] = potentials
if self.mol:
mol_elements = set([site.species_string for site
in self.mol.sites])
ecp_elements = set(self.params["ecp"].keys())
if len(ecp_elements - mol_elements) > 0:
raise ValueError("ECP error: the molecule "
"doesn't contain element " +
", ".join(ecp_elements - mol_elements))
@property
def molecule(self):
return self.mol
def set_memory(self, total=None, static=None):
"""
Set the maxium allowed memory.
Args:
total: The total memory. Integer. Unit: MBytes. If set to None,
this parameter will be neglected.
static: The static memory. Integer. Unit MBytes. If set to None,
this parameterwill be neglected.
"""
if total:
self.params["rem"]["mem_total"] = total
if static:
self.params["rem"]["mem_static"] = static
def set_max_num_of_scratch_files(self, num=16):
"""
In QChem, the size of a single scratch is limited 2GB. By default,
the max number of scratich is 16, which is cooresponding to 32GB
scratch space. If you want to use more scratch disk space, you need
to increase the number of scratch files:
Args:
num: The max number of the scratch files. (Integer)
"""
self.params["rem"]["max_sub_file_num"] = num
def set_scf_algorithm_and_iterations(self, algorithm="diis",
iterations=50):
"""
Set algorithm used for converging SCF and max number of SCF iterations.
Args:
algorithm: The algorithm used for converging SCF. (str)
iterations: The max number of SCF iterations. (Integer)
"""
available_algorithms = {"diis", "dm", "diis_dm", "diis_gdm", "gdm",
"rca", "rca_diis", "roothaan"}
if algorithm.lower() not in available_algorithms:
raise ValueError("Algorithm " + algorithm +
" is not available in QChem")
self.params["rem"]["scf_algorithm"] = algorithm.lower()
self.params["rem"]["max_scf_cycles"] = iterations
def set_scf_convergence_threshold(self, exponent=8):
"""
SCF is considered converged when the wavefunction error is less than
10**(-exponent).
In QChem, the default values are:
5 For single point energy calculations.
7 For geometry optimizations and vibrational analysis.
8 For SSG calculations
Args:
exponent: The exponent of the threshold. (Integer)
"""
self.params["rem"]["scf_convergence"] = exponent
def set_integral_threshold(self, thresh=12):
"""
Cutoff for neglect of two electron integrals. 10−THRESH (THRESH <= 14).
In QChem, the default values are:
8 For single point energies.
10 For optimizations and frequency calculations.
14 For coupled-cluster calculations.
Args:
thresh: The exponent of the threshold. (Integer)
"""
self.params["rem"]["thresh"] = thresh
def set_dft_grid(self, radical_points=128, angular_points=302,
grid_type="Lebedev"):
"""
Set the grid for DFT numerical integrations.
Args:
radical_points: Radical points. (Integer)
angular_points: Angular points. (Integer)
grid_type: The type of of the grid. There are two standard grids:
SG-1 and SG-0. The other two supported grids are "Lebedev" and
"Gauss-Legendre"
"""
available_lebedev_angular_points = {6, 18, 26, 38, 50, 74, 86, 110, 146,
170, 194, 230, 266, 302, 350, 434,
590, 770, 974, 1202, 1454, 1730,
2030, 2354, 2702, 3074, 3470, 3890,
4334, 4802, 5294}
if grid_type.lower() == "sg-0":
self.params["rem"]["xc_grid"] = 0
elif grid_type.lower() == "sg-1":
self.params["rem"]["xc_grid"] = 1
elif grid_type.lower() == "lebedev":
if angular_points not in available_lebedev_angular_points:
raise ValueError(str(angular_points) + " is not a valid "
"Lebedev angular points number")
self.params["rem"]["xc_grid"] = "{rp:06d}{ap:06d}".format(
rp=radical_points, ap=angular_points)
elif grid_type.lower() == "gauss-legendre":
self.params["rem"]["xc_grid"] = "-{rp:06d}{ap:06d}".format(
rp=radical_points, ap=angular_points)
else:
raise ValueError("Grid type " + grid_type + " is not supported "
"currently")
def set_scf_initial_guess(self, guess="SAD"):
"""
Set initial guess method to be used for SCF
Args:
guess: The initial guess method. (str)
"""
availabel_guesses = {"core", "sad", "gwh", "read", "fragmo"}
if guess.lower() not in availabel_guesses:
raise ValueError("The guess method " + guess + " is not supported "
"yet")
self.params["rem"]["scf_guess"] = guess.lower()
def set_geom_max_iterations(self, iterations):
"""
Set the max iterations of geometry optimization.
Args:
iterations: the maximum iterations of geometry optimization.
(Integer)
"""
self.params["rem"]["geom_opt_max_cycles"] = iterations
def set_geom_opt_coords_type(self, coords_type="internal_switch"):
"""
Set the coordinates system used in geometry optimization.
"cartesian" --- always cartesian coordinates.
"internal" --- always internal coordinates.
"internal-switch" --- try internal coordinates first, if fails, switch
to cartesian coordinates.
"z-matrix" --- always z-matrix coordinates.
"z-matrix-switch" --- try z-matrix first, if fails, switch to
cartesian coordinates.
Args:
coords_type: The type of the coordinates. (str)
"""
coords_map = {"cartesian": 0, "internal": 1, "internal-switch": -1,
"z-matrix": 2, "z-matrix-switch": -2}
if coords_type.lower() not in set(coords_map.keys()):
raise ValueError("Coodinate system " + coords_type + " is not "
"supported yet")
else:
self.params["rem"]["geom_opt_coords"] = \
coords_map[coords_type.lower()]
def scale_geom_opt_threshold(self, gradient=0.1, displacement=0.1,
energy=0.1):
"""
Adjust the convergence criteria of geometry optimization.
Args:
gradient: the scale factor for gradient criteria. If less than
1.0, you are tightening the threshold. The base value is
300 × 10E−6
displacement: the scale factor for atomic displacement. If less
then 1.0, you are tightening the threshold. The base value is
1200 × 10E−6
energy: the scale factor for energy change between successive
iterations. If less than 1.0, you are tightening the
threshold. The base value is 100 × 10E−8.
"""
if gradient < 1.0/(300-1) or displacement < 1.0/(1200-1) or \
energy < 1.0/(100-1):
raise ValueError("The geometry optimization convergence criteria "
"is too tight")
self.params["rem"]["geom_opt_tol_gradient"] = int(gradient * 300)
self.params["rem"]["geom_opt_tol_displacement"] = int(displacement *
1200)
self.params["rem"]["geom_opt_tol_energy"] = int(energy * 100)
def set_geom_opt_use_gdiis(self, subspace_size=None):
"""
Use GDIIS algorithm in geometry optimization.
Args:
subspace_size: The size of the DIIS subsapce. None for default
value. The default value is min(NDEG, NATOMS, 4) NDEG = number
of moleculardegrees of freedom.
"""
subspace_size = subspace_size if subspace_size is not None else -1
self.params["rem"]["geom_opt_max_diis"] = subspace_size
def disable_symmetry(self):
"""
Turn the symmetry off.
"""
self.params["rem"]["sym_ignore"] = True
self.params["rem"]["symmetry"] = False
def use_cosmo(self, dielectric_constant=78.4):
"""
Set the solvent model to COSMO.
Args:
dielectric_constant: the dielectric constant for the solvent.
"""
self.params["rem"]["solvent_method"] = "cosmo"
self.params["rem"]["solvent_dielectric"] = dielectric_constant
def use_pcm(self, pcm_params=None, solvent_params=None,
radii_force_field=None):
"""
Set the solvent model to PCM. Default parameters are trying to comply to
gaussian default value
Args:
pcm_params (dict): The parameters of "$pcm" section.
solvent_params (dict): The parameters of "pcm_solvent" section
radii_force_field (str): The force fied used to set the solute
radii. Default to UFF.
"""
self.params["pcm"] = dict()
self.params["pcm_solvent"] = dict()
default_pcm_params = {"Theory": "SSVPE",
"vdwScale": 1.1,
"Radii": "UFF"}
if not solvent_params:
solvent_params = {"Dielectric": 78.3553}
if pcm_params:
for k, v in pcm_params.items():
self.params["pcm"][k.lower()] = v.lower() \
if isinstance(v, six.string_types) else v
for k, v in default_pcm_params.items():
if k.lower() not in self.params["pcm"].keys():
self.params["pcm"][k.lower()] = v.lower() \
if isinstance(v, six.string_types) else v
for k, v in solvent_params.items():
self.params["pcm_solvent"][k.lower()] = v.lower() \
if isinstance(v, six.string_types) else copy.deepcopy(v)
self.params["rem"]["solvent_method"] = "pcm"
if radii_force_field:
self.params["pcm"]["radii"] = "bondi"
self.params["rem"]["force_fied"] = radii_force_field.lower()
def __str__(self):
sections = ["comment", "molecule", "rem"] + \
sorted(list(self.optional_keywords_list))
lines = []
for sec in sections:
if sec in self.params or sec == "molecule":
foramt_sec = self.__getattribute__("_format_" + sec)
lines.append("$" + sec)
lines.extend(foramt_sec())
lines.append("$end")
lines.append('\n')
return '\n'.join(lines)
@classmethod
def _wrap_comment(cls, comment):
ml_section_start = comment.find('<')
if ml_section_start >= 0:
title_section = comment[0:ml_section_start]
ml_section = comment[ml_section_start:]
else:
title_section = comment
ml_section = ''
wrapped_title_lines = textwrap.wrap(title_section.strip(), width=70, initial_indent=' ')
wrapped_ml_lines = []
for l in ml_section.splitlines():
if len(l) > 70:
wrapped_ml_lines.extend(textwrap.wrap(l.strip(), width=70, initial_indent=' '))
else:
wrapped_ml_lines.append(l)
return '\n'.join(wrapped_title_lines + wrapped_ml_lines)
def _format_comment(self):
return self._wrap_comment(self.params["comment"]).splitlines()
def _format_alist(self):
return [" {}".format(x) for x in self.params["alist"]]
def _format_molecule(self):
lines = []
def inner_format_mol(m2, index_base):
mol_lines = []
for i, site in enumerate(m2.sites):
ghost = "@" if self.ghost_atoms \
and i + index_base in self.ghost_atoms else ""
atom = "{ghost:s}{element:s}".format(ghost=ghost,
element=site.species_string)
mol_lines.append(" {atom:<4} {x:>17.8f} {y:>17.8f} "
"{z:>17.8f}".format(atom=atom, x=site.x,
y=site.y, z=site.z))
return mol_lines
if self.charge is not None:
lines.append(" {charge:d} {multi:d}".format(charge=self
.charge, multi=self.spin_multiplicity))
if isinstance(self.mol, six.string_types) and self.mol == "read":
lines.append(" read")
elif isinstance(self.mol, list):
starting_index = 0
for m in self.mol:
lines.append("--")
lines.append(" {charge:d} {multi:d}".format(
charge=m.charge, multi=m.spin_multiplicity))
lines.extend(inner_format_mol(m, starting_index))
starting_index += len(m)
else:
lines.extend(inner_format_mol(self.mol, 0))
return lines
def _format_rem(self):
rem_format_template = Template(" {name:>$name_width} = "
"{value}")
name_width = 0
for name, value in self.params["rem"].items():
if len(name) > name_width:
name_width = len(name)
rem = rem_format_template.substitute(name_width=name_width)
lines = []
all_keys = set(self.params["rem"].keys())
priority_keys = ["jobtype", "exchange", "basis"]
additional_keys = all_keys - set(priority_keys)
ordered_keys = priority_keys + sorted(list(additional_keys))
for name in ordered_keys:
value = self.params["rem"][name]
lines.append(rem.format(name=name, value=value))
return lines
def _format_basis(self):
lines = []
if isinstance(self.params["basis"], dict):
for element in sorted(self.params["basis"].keys()):
basis = self.params["basis"][element]
lines.append(" " + element)
lines.append(" " + basis)
lines.append(" ****")
elif isinstance(self.params["basis"], list):
for i, (element, bs) in enumerate(self.params["basis"]):
lines.append(" {element:2s} {number:3d}".format(element=element, number=i+1))
lines.append(" {}".format(bs))
lines.append(" ****")
return lines
def _format_aux_basis(self):
lines = []
if isinstance(self.params["aux_basis"], dict):
for element in sorted(self.params["aux_basis"].keys()):
basis = self.params["aux_basis"][element]
lines.append(" " + element)
lines.append(" " + basis)
lines.append(" ****")
else:
for i, (element, bs) in enumerate(self.params["aux_basis"]):
lines.append(" {element:2s} {number:3d}".format(element=element, number=i+1))
lines.append(" {}".format(bs))
lines.append(" ****")
return lines
def _format_basis2(self):
lines = []
if isinstance(self.params["basis2"], dict):
for element in sorted(self.params["basis2"].keys()):
basis = self.params["basis2"][element]
lines.append(" " + element)
lines.append(" " + basis)
lines.append(" ****")
else:
for i, (element, bs) in enumerate(self.params["basis2"]):
lines.append(" {element:2s} {number:3d}".format(element=element, number=i+1))
lines.append(" {}".format(bs))
lines.append(" ****")
return lines
def _format_ecp(self):
lines = []
for element in sorted(self.params["ecp"].keys()):
ecp = self.params["ecp"][element]
lines.append(" " + element)
lines.append(" " + ecp)
lines.append(" ****")
return lines
def _format_pcm(self):
pcm_format_template = Template(" {name:>$name_width} "
"{value}")
name_width = 0
for name in self.params["pcm"].keys():
if len(name) > name_width:
name_width = len(name)
rem = pcm_format_template.substitute(name_width=name_width)
lines = []
for name in sorted(self.params["pcm"].keys()):
value = self.params["pcm"][name]
lines.append(rem.format(name=name, value=value))
return lines
def _format_pcm_solvent(self):
pp_format_template = Template(" {name:>$name_width} "
"{value}")
name_width = 0
for name in self.params["pcm_solvent"].keys():
if len(name) > name_width:
name_width = len(name)
rem = pp_format_template.substitute(name_width=name_width)
lines = []
all_keys = set(self.params["pcm_solvent"].keys())
priority_keys = []
for k in ["dielectric", "nonels", "nsolventatoms", "solventatom"]:
if k in all_keys:
priority_keys.append(k)
additional_keys = all_keys - set(priority_keys)
ordered_keys = priority_keys + sorted(list(additional_keys))
for name in ordered_keys:
value = self.params["pcm_solvent"][name]
if name == "solventatom":
for v in copy.deepcopy(value):
value = "{:<4d} {:<4d} {:<4d} {:4.2f}".format(*v)
lines.append(rem.format(name=name, value=value))
continue
lines.append(rem.format(name=name, value=value))
return lines
def as_dict(self):
if isinstance(self.mol, six.string_types):
mol_dict = self.mol
elif isinstance(self.mol, Molecule):
mol_dict = self.mol.as_dict()
elif isinstance(self.mol, list):
mol_dict = [m.as_dict() for m in self.mol]
else:
raise ValueError('Unknow molecule type "{}"'.format(type(self.mol)))
d = {"@module": self.__class__.__module__,
"@class": self.__class__.__name__,
"molecule": mol_dict,
"charge": self.charge,
"spin_multiplicity": self.spin_multiplicity,
"params": self.params}
if self.ghost_atoms:
d["ghost_atoms"] = self.ghost_atoms
return d
@classmethod
def from_dict(cls, d):
if d["molecule"] == "read":
mol = "read"
elif isinstance(d["molecule"], dict):
mol = Molecule.from_dict(d["molecule"])
elif isinstance(d["molecule"], list):
mol = [Molecule.from_dict(m) for m in d["molecule"]]
else:
raise ValueError('Unknow molecule type "{}"'.format(type(d["molecule"])))
jobtype = d["params"]["rem"]["jobtype"]
title = d["params"].get("comment", None)
exchange = d["params"]["rem"]["exchange"]
correlation = d["params"]["rem"].get("correlation", None)
basis_set = d["params"]["rem"]["basis"]
aux_basis_set = d["params"]["rem"].get("aux_basis", None)
ecp = d["params"]["rem"].get("ecp", None)
ghost_atoms = d.get("ghost_atoms", None)
optional_params = None
op_keys = set(d["params"].keys()) - {"comment", "rem"}
if len(op_keys) > 0:
optional_params = dict()
for k in op_keys:
optional_params[k] = d["params"][k]
return QcTask(molecule=mol, charge=d["charge"],
spin_multiplicity=d["spin_multiplicity"],
jobtype=jobtype, title=title,
exchange=exchange, correlation=correlation,
basis_set=basis_set, aux_basis_set=aux_basis_set,
ecp=ecp, rem_params=d["params"]["rem"],
optional_params=optional_params,
ghost_atoms=ghost_atoms)
def write_file(self, filename):
with zopen(filename, "wt") as f:
f.write(self.__str__())
@classmethod
def from_file(cls, filename):
with zopen(filename, "rt") as f:
return cls.from_string(f.read())
@classmethod
def from_string(cls, contents):
"""
Creates QcInput from a string.
Args:
contents: String representing a QChem input file.
Returns:
QcInput object
"""
mol = None
charge = None
spin_multiplicity = None
params = dict()
lines = contents.split('\n')
parse_section = False
section_name = None
section_text = []
ghost_atoms = None
for line_num, line in enumerate(lines):
l = line.strip().lower()
if len(l) == 0:
continue
if (not parse_section) and (l == "$end" or not l.startswith("$")):
raise ValueError("Format error, parsing failed")
if parse_section and l != "$end":
section_text.append(line)
if l.startswith("$") and not parse_section:
parse_section = True
section_name = l[1:]
available_sections = ["comment", "molecule", "rem"] + \
sorted(list(cls.optional_keywords_list))
if section_name not in available_sections:
raise ValueError("Unrecognized keyword " + line.strip() +
" at line " + str(line_num))
if section_name in params:
raise ValueError("duplicated keyword " + line.strip() +
"at line " + str(line_num))
if parse_section and l == "$end":
func_name = "_parse_" + section_name
if func_name not in QcTask.__dict__:
raise Exception(func_name + " is not implemented yet, "
"please implement it")
parse_func = QcTask.__dict__[func_name].__get__(None, QcTask)
if section_name == "molecule":
mol, charge, spin_multiplicity, ghost_atoms = parse_func(section_text)
else:
d = parse_func(section_text)
params[section_name] = d
parse_section = False
section_name = None
section_text = []
if parse_section:
raise ValueError("Format error. " + section_name + " is not "
"terminated")
jobtype = params["rem"]["jobtype"]
title = params.get("comment", None)
exchange = params["rem"].get("exchange", "hf")
correlation = params["rem"].get("correlation", None)
basis_set = params["rem"]["basis"]
aux_basis_set = params["rem"].get("aux_basis", None)
ecp = params["rem"].get("ecp", None)
optional_params = None
op_keys = set(params.keys()) - {"comment", "rem"}
if len(op_keys) > 0:
optional_params = dict()
for k in op_keys:
optional_params[k] = params[k]
return QcTask(molecule=mol, charge=charge,
spin_multiplicity=spin_multiplicity,
jobtype=jobtype, title=title,
exchange=exchange, correlation=correlation,
basis_set=basis_set, aux_basis_set=aux_basis_set,
ecp=ecp, rem_params=params["rem"],
optional_params=optional_params,
ghost_atoms=ghost_atoms)
@classmethod
def _parse_comment(cls, contents):
return '\n'.join(contents).strip()
@classmethod
def _parse_coords(cls, coord_lines):
"""
Helper method to parse coordinates. Copied from GaussianInput class.
"""
paras = {}
var_pattern = re.compile("^([A-Za-z]+\S*)[\s=,]+([\d\-\.]+)$")
for l in coord_lines:
m = var_pattern.match(l.strip())
if m:
paras[m.group(1)] = float(m.group(2))
species = []
coords = []
# Stores whether a Zmatrix format is detected. Once a zmatrix format
# is detected, it is assumed for the remaining of the parsing.
zmode = False
for l in coord_lines:
l = l.strip()
if not l:
break
if (not zmode) and cls.xyz_patt.match(l):
m = cls.xyz_patt.match(l)
species.append(m.group(1))
toks = re.split("[,\s]+", l.strip())
if len(toks) > 4:
coords.append(list(map(float, toks[2:5])))
else:
coords.append(list(map(float, toks[1:4])))
elif cls.zmat_patt.match(l):
zmode = True
toks = re.split("[,\s]+", l.strip())
species.append(toks[0])
toks.pop(0)
if len(toks) == 0:
coords.append(np.array([0.0, 0.0, 0.0]))
else:
nn = []
parameters = []
while len(toks) > 1:
ind = toks.pop(0)
data = toks.pop(0)
try:
nn.append(int(ind))
except ValueError:
nn.append(species.index(ind) + 1)
try:
val = float(data)
parameters.append(val)
except ValueError:
if data.startswith("-"):
parameters.append(-paras[data[1:]])
else:
parameters.append(paras[data])
if len(nn) == 1:
coords.append(np.array(
[0.0, 0.0, float(parameters[0])]))
elif len(nn) == 2:
coords1 = coords[nn[0] - 1]
coords2 = coords[nn[1] - 1]
bl = parameters[0]
angle = parameters[1]
axis = [0, 1, 0]
op = SymmOp.from_origin_axis_angle(coords1, axis,
angle, False)
coord = op.operate(coords2)
vec = coord - coords1
coord = vec * bl / np.linalg.norm(vec) + coords1
coords.append(coord)
elif len(nn) == 3:
coords1 = coords[nn[0] - 1]
coords2 = coords[nn[1] - 1]
coords3 = coords[nn[2] - 1]
bl = parameters[0]
angle = parameters[1]
dih = parameters[2]
v1 = coords3 - coords2
v2 = coords1 - coords2
axis = np.cross(v1, v2)
op = SymmOp.from_origin_axis_angle(
coords1, axis, angle, False)
coord = op.operate(coords2)
v1 = coord - coords1
v2 = coords1 - coords2
v3 = np.cross(v1, v2)
adj = get_angle(v3, axis)
axis = coords1 - coords2
op = SymmOp.from_origin_axis_angle(
coords1, axis, dih - adj, False)
coord = op.operate(coord)
vec = coord - coords1
coord = vec * bl / np.linalg.norm(vec) + coords1
coords.append(coord)
def parse_species(sp_str):
"""
The species specification can take many forms. E.g.,
simple integers representing atomic numbers ("8"),
actual species string ("C") or a labelled species ("C1").
Sometimes, the species string is also not properly capitalized,
e.g, ("c1"). This method should take care of these known formats.
"""
try:
return int(sp_str)
except ValueError:
sp = re.sub("\d", "", sp_str)
return sp.capitalize()
species = list(map(parse_species, species))
return Molecule(species, coords)
@classmethod
def _parse_molecule(cls, contents):
def parse_ghost_indices(coord_text_lines):
no_ghost_text = [l.replace("@", "") for l in coord_text_lines]
ghosts = []
for index, l in enumerate(coord_text_lines):
l = l.strip()
if not l:
break
if "@" in l:
ghosts.append(index)
return ghosts, no_ghost_text
text = copy.deepcopy(contents[:2])
charge_multi_pattern = re.compile('\s*(?P<charge>'
'[-+]?\d+)\s+(?P<multi>\d+)')
line = text.pop(0)
m = charge_multi_pattern.match(line)
if m:
charge = int(m.group("charge"))
spin_multiplicity = int(m.group("multi"))
line = text.pop(0)
else:
charge = None
spin_multiplicity = None
if line.strip().lower() == "read":
return "read", charge, spin_multiplicity, None
elif charge is None or spin_multiplicity is None:
raise ValueError("Charge or spin multiplicity is not found")
else:
if contents[1].strip()[0:2] == "--":
chunks = "\n".join(contents[2:]).split("--\n")
mol = []
ghost_atoms = []
starting_index = 0
for chunk in chunks:
frag_contents = chunk.split("\n")
m = charge_multi_pattern.match(frag_contents[0])
if m:
fragment_charge = int(m.group("charge"))
fragment_spin_multiplicity = int(m.group("multi"))
else:
raise Exception("charge and spin multiplicity must be specified for each fragment")
gh, coord_lines = parse_ghost_indices(frag_contents[1:])
fragment = cls._parse_coords(coord_lines)
fragment.set_charge_and_spin(fragment_charge, fragment_spin_multiplicity)
mol.append(fragment)
ghost_atoms.extend([i+starting_index for i in gh])
starting_index += len(fragment)
else:
ghost_atoms, coord_lines = parse_ghost_indices(contents[1:])
mol = cls._parse_coords(coord_lines)
if len(ghost_atoms) == 0:
mol.set_charge_and_spin(charge, spin_multiplicity)
ghost_atoms = ghost_atoms if len(ghost_atoms) > 0 else None
return mol, charge, spin_multiplicity, ghost_atoms
@classmethod
def _parse_rem(cls, contents):
d = dict()
int_pattern = re.compile('^[-+]?\d+$')
float_pattern = re.compile('^[-+]?\d+\.\d+([eE][-+]?\d+)?$')
for line in contents:
tokens = line.strip().replace("=", ' ').split()
if len(tokens) < 2:
raise ValueError("Can't parse $rem section, there should be "
"at least two field: key and value!")
k1, v = tokens[:2]
k2 = k1.lower()
if k2 in cls.alternative_keys:
k2 = cls.alternative_keys[k2]
if v in cls.alternative_values:
v = cls.alternative_values
if k2 == "xc_grid":
d[k2] = v
elif v == "True":
d[k2] = True
elif v == "False":
d[k2] = False
elif int_pattern.match(v):
d[k2] = int(v)
elif float_pattern.match(v):
d[k2] = float(v)
else:
d[k2] = v.lower()
return d
@classmethod
def _parse_aux_basis(cls, contents):
if len(contents) % 3 != 0:
raise ValueError("Auxiliary basis set section format error")
chunks = zip(*[iter(contents)]*3)
t = contents[0].split()
if len(t) == 2 and int(t[1]) > 0:
bs = []
for i, ch in enumerate(chunks):
element, number = ch[0].split()
basis = ch[1]
if int(number) != i+1:
raise ValueError("Atom order number doesn't match in $aux_basis section")
bs.append((element.strip().capitalize(), basis.strip().lower()))
else:
bs = dict()
for ch in chunks:
element, basis = ch[:2]
bs[element.strip().capitalize()] = basis.strip().lower()
return bs
@classmethod
def _parse_basis2(cls, contents):
if len(contents) % 3 != 0:
raise ValueError("Auxiliary basis set section format error")
chunks = zip(*[iter(contents)]*3)
t = contents[0].split()
if len(t) == 2 and int(t[1]) > 0:
bs = []
for i, ch in enumerate(chunks):
element, number = ch[0].split()
basis = ch[1]
if int(number) != i+1:
raise ValueError("Atom order number doesn't match in $aux_basis section")
bs.append((element.strip().capitalize(), basis.strip().lower()))
else:
bs = dict()
for ch in chunks:
element, basis = ch[:2]
bs[element.strip().capitalize()] = basis.strip().lower()
return bs
@classmethod
def _parse_basis(cls, contents):
if len(contents) % 3 != 0:
raise ValueError("Basis set section format error")
chunks = zip(*[iter(contents)]*3)
t = contents[0].split()
if len(t) == 2 and int(t[1]) > 0:
bs = []
for i, ch in enumerate(chunks):
element, number = ch[0].split()
basis = ch[1]
if int(number) != i+1:
raise ValueError("Atom order number doesn't match in $basis section")
bs.append((element.strip().capitalize(), basis.strip().lower()))
else:
bs = dict()
for ch in chunks:
element, basis = ch[:2]
bs[element.strip().capitalize()] = basis.strip().lower()
return bs
@classmethod
def _parse_ecp(cls, contents):
if len(contents) % 3 != 0:
raise ValueError("ECP section format error")
chunks = zip(*[iter(contents)]*3)
d = dict()
for ch in chunks:
element, ecp = ch[:2]
d[element.strip().capitalize()] = ecp.strip().lower()
return d
@classmethod
def _parse_alist(cls, contents):
atom_list = []
for line in contents:
atom_list.extend([int(x) for x in line.split()])
return atom_list
@classmethod
def _parse_pcm(cls, contents):
d = dict()
int_pattern = re.compile('^[-+]?\d+$')
float_pattern = re.compile('^[-+]?\d+\.\d+([eE][-+]?\d+)?$')
for line in contents:
tokens = line.strip().replace("=", ' ').split()
if len(tokens) < 2:
raise ValueError("Can't parse $pcm section, there should be "
"at least two field: key and value!")
k1, v = tokens[:2]
k2 = k1.lower()
if k2 in cls.alternative_keys:
k2 = cls.alternative_keys[k2]
if v in cls.alternative_values:
v = cls.alternative_values
if v == "True":
d[k2] = True
elif v == "False":
d[k2] = False
elif int_pattern.match(v):
d[k2] = int(v)
elif float_pattern.match(v):
d[k2] = float(v)
else:
d[k2] = v.lower()
return d
@classmethod
def _parse_pcm_solvent(cls, contents):
d = dict()
int_pattern = re.compile('^[-+]?\d+$')
float_pattern = re.compile('^[-+]?\d+\.\d+([eE][-+]?\d+)?$')
for line in contents:
tokens = line.strip().replace("=", ' ').split()
if len(tokens) < 2:
raise ValueError("Can't parse $pcm_solvent section, "
"there should be at least two field: "
"key and value!")
k1, v = tokens[:2]
k2 = k1.lower()
if k2 in cls.alternative_keys:
k2 = cls.alternative_keys[k2]
if v in cls.alternative_values:
v = cls.alternative_values
if k2 == "solventatom":
v = [int(i) for i in tokens[1:4]]
# noinspection PyTypeChecker
v.append(float(tokens[4]))
if k2 not in d:
d[k2] = [v]
else:
d[k2].append(v)
elif v == "True":
d[k2] = True
elif v == "False":
d[k2] = False
elif int_pattern.match(v):
d[k2] = int(v)
elif float_pattern.match(v):
d[k2] = float(v)
else:
d[k2] = v.lower()
return d
class QcInput(PMGSONable):
"""
An object representing a multiple step QChem input file.
Args:
jobs: The QChem jobs (List of QcInput object)
"""
def __init__(self, jobs):
jobs = jobs if isinstance(jobs, list) else [jobs]
for j in jobs:
if not isinstance(j, QcTask):
raise ValueError("jobs must be a list QcInput object")
self.jobs = jobs
def __str__(self):
return "\n@@@\n\n\n".join([str(j) for j in self.jobs])
def write_file(self, filename):
with zopen(filename, "wt") as f:
f.write(self.__str__())
def as_dict(self):
return {"@module": self.__class__.__module__,
"@class": self.__class__.__name__,
"jobs": [j.as_dict() for j in self.jobs]}
@classmethod
def from_dict(cls, d):
jobs = [QcTask.from_dict(j) for j in d["jobs"]]
return QcInput(jobs)
@classmethod
def from_string(cls, contents):
qc_contents = contents.split("@@@")
jobs = [QcTask.from_string(cont) for cont in qc_contents]
return QcInput(jobs)
@classmethod
def from_file(cls, filename):
with zopen(filename, "rt") as f:
return cls.from_string(f.read())
class QcOutput(object):
kcal_per_mol_2_eV = 4.3363E-2
def __init__(self, filename):
self.filename = filename
with zopen(filename, "rt") as f:
data = f.read()
chunks = re.split("\n\nRunning Job \d+ of \d+ \S+", data)
# noinspection PyTypeChecker
self.data = list(map(self._parse_job, chunks))
@property
def final_energy(self):
return self.data[-1]["energies"][-1][-1]
@property
def final_structure(self):
return self.data[-1]["molecules"][-1]
@classmethod
def _expected_successful_pattern(cls, qctask):
text = ["Convergence criterion met"]
if "correlation" in qctask.params["rem"]:
if "ccsd" in qctask.params["rem"]["correlation"]\
or "qcisd" in qctask.params["rem"]["correlation"]:
text.append('CC.*converged')
if qctask.params["rem"]["jobtype"] == "opt"\
or qctask.params["rem"]["jobtype"] == "ts":
text.append("OPTIMIZATION CONVERGED")
if qctask.params["rem"]["jobtype"] == "freq":
text.append("VIBRATIONAL ANALYSIS")
if qctask.params["rem"]["jobtype"] == "gradient":
text.append("Gradient of SCF Energy")
return text
@classmethod
def _parse_job(cls, output):
scf_energy_pattern = re.compile("Total energy in the final basis set ="
"\s+(?P<energy>-\d+\.\d+)")
corr_energy_pattern = re.compile("(?P<name>[A-Z\-\(\)0-9]+)\s+"
"([tT]otal\s+)?[eE]nergy\s+=\s+"
"(?P<energy>-\d+\.\d+)")
coord_pattern = re.compile("\s*\d+\s+(?P<element>[A-Z][a-zH]*)\s+"
"(?P<x>\-?\d+\.\d+)\s+"
"(?P<y>\-?\d+\.\d+)\s+"
"(?P<z>\-?\d+\.\d+)")
num_ele_pattern = re.compile("There are\s+(?P<alpha>\d+)\s+alpha "
"and\s+(?P<beta>\d+)\s+beta electrons")
total_charge_pattern = re.compile("Sum of atomic charges ="
"\s+(?P<charge>\-?\d+\.\d+)")
scf_iter_pattern = re.compile("\d+\s*(?P<energy>\-\d+\.\d+)\s+"
"(?P<diis_error>\d+\.\d+E[-+]\d+)")
zpe_pattern = re.compile("Zero point vibrational energy:"
"\s+(?P<zpe>\d+\.\d+)\s+kcal/mol")
thermal_corr_pattern = re.compile("(?P<name>\S.*\S):\s+"
"(?P<correction>\d+\.\d+)\s+"
"k?cal/mol")
detailed_charge_pattern = re.compile("(Ground-State )?(?P<method>\w+)( Net)?"
" Atomic Charges")
nbo_charge_pattern = re.compile("(?P<element>[A-Z][a-z]{0,2})\s*(?P<no>\d+)\s+(?P<charge>\-?\d\.\d+)"
"\s+(?P<core>\-?\d+\.\d+)\s+(?P<valence>\-?\d+\.\d+)"
"\s+(?P<rydberg>\-?\d+\.\d+)\s+(?P<total>\-?\d+\.\d+)"
"(\s+(?P<spin>\-?\d\.\d+))?")
nbo_wavefunction_type_pattern = re.compile("This is an? (?P<type>\w+\-\w+) NBO calculation")
bsse_pattern = re.compile("DE, kJ/mol\s+(?P<raw_be>\-?\d+\.?\d+([eE]\d+)?)\s+"
"(?P<corrected_be>\-?\d+\.?\d+([eE]\d+)?)")
float_pattern = re.compile("\-?\d+\.?\d+([eE]\d+)?$")
error_defs = (
(re.compile("Convergence failure"), "Bad SCF convergence"),
(re.compile("Coordinates do not transform within specified "
"threshold"), "autoz error"),
(re.compile("MAXIMUM OPTIMIZATION CYCLES REACHED"),
"Geometry optimization failed"),
(re.compile("\s+[Nn][Aa][Nn]\s+"), "NAN values"),
(re.compile("energy\s+=\s*(\*)+"), "Numerical disaster"),
(re.compile("NewFileMan::OpenFile\(\):\s+nopenfiles=\d+\s+"
"maxopenfiles=\d+s+errno=\d+"), "Open file error"),
(re.compile("Application \d+ exit codes: 1[34]\d+"), "Exit Code 134"),
(re.compile("Negative overlap matrix eigenvalue. Tighten integral "
"threshold \(REM_THRESH\)!"), "Negative Eigen"),
(re.compile("Unable to allocate requested memory in mega_alloc"),
"Insufficient static memory"),
(re.compile("Application \d+ exit signals: Killed"),
"Killed"),
(re.compile("UNABLE TO DETERMINE Lamda IN FormD"),
"Lamda Determination Failed"),
(re.compile("Job too small. Please specify .*CPSCF_NSEG"),
"Freq Job Too Small"),
(re.compile("Not enough total memory"),
"Not Enough Total Memory"),
)
energies = []
scf_iters = []
coords = []
species = []
molecules = []
gradients = []
freqs = []
vib_freqs = []
vib_modes = []
grad_comp = None
errors = []
parse_input = False
parse_coords = False
parse_scf_iter = False
parse_gradient = False
parse_freq = False
parse_modes = False
qctask_lines = []
qctask = None
jobtype = None
charge = None
spin_multiplicity = None
thermal_corr = dict()
properly_terminated = False
pop_method = None
parse_charge = False
nbo_available = False
nbo_charge_header = None
parse_nbo_charge = False
charges = dict()
scf_successful = False
opt_successful = False
parse_alpha_homo = False
parse_alpha_lumo = False
parse_beta_homo = False
parse_beta_lumo = False
current_alpha_homo = None
current_alpha_lumo = None
current_beta_homo = None
homo_lumo = []
bsse = None
hiershfiled_pop = False
for line in output.split("\n"):
for ep, message in error_defs:
if ep.search(line):
errors.append(message)
if parse_input:
if "-" * 50 in line:
if len(qctask_lines) == 0:
continue
else:
qctask = QcTask.from_string('\n'.join(qctask_lines))
jobtype = qctask.params["rem"]["jobtype"]
parse_input = False
continue
qctask_lines.append(line)
elif parse_coords:
if "-" * 50 in line:
if len(coords) == 0:
continue
else:
if qctask and qctask.ghost_atoms:
if isinstance(qctask.mol, Molecule):
for i in qctask.ghost_atoms:
species[i] = qctask.mol.sites[i].specie.symbol
molecules.append(Molecule(species, coords))
coords = []
species = []
parse_coords = False
continue
if "Atom" in line:
continue
m = coord_pattern.match(line)
coords.append([float(m.group("x")), float(m.group("y")),
float(m.group("z"))])
species.append(m.group("element"))
elif parse_scf_iter:
if "SCF time: CPU" in line:
parse_scf_iter = False
continue
if 'Convergence criterion met' in line:
scf_successful = True
m = scf_iter_pattern.search(line)
if m:
scf_iters[-1].append((float(m.group("energy")),
float(m.group("diis_error"))))
elif parse_gradient:
if "Max gradient component" in line:
gradients[-1]["max_gradient"] = \
float(line.split("=")[1])
if grad_comp:
if len(grad_comp) == 3:
gradients[-1]["gradients"].extend(zip(*grad_comp))
else:
raise Exception("Gradient section parsing failed")
continue
elif "RMS gradient" in line:
gradients[-1]["rms_gradient"] = \
float(line.split("=")[1])
parse_gradient = False
grad_comp = None
continue
elif "." not in line:
if grad_comp:
if len(grad_comp) == 3:
gradients[-1]["gradients"].extend(zip(*grad_comp))
else:
raise Exception("Gradient section parsing failed")
grad_comp = []
else:
grad_line_token = list(line)
grad_crowd = False
grad_line_final = line
for i in range(5, len(line), 12):
c = grad_line_token[i]
if not c.isspace():
grad_crowd = True
if ' ' in grad_line_token[i+1: i+6+1] or \
len(grad_line_token[i+1: i+6+1]) < 6:
continue
grad_line_token[i-1] = ' '
if grad_crowd:
grad_line_final = ''.join(grad_line_token)
grad_comp.append([float(x) for x
in grad_line_final.strip().split()[1:]])
elif parse_freq:
if parse_modes:
if "TransDip" in line:
parse_modes = False
for freq, mode in zip(vib_freqs, zip(*vib_modes)):
freqs.append({"frequency": freq,
"vib_mode": mode})
vib_modes = []
continue
dis_flat = [float(x) for x in line.strip().split()[1:]]
dis_atom = zip(*([iter(dis_flat)]*3))
vib_modes.append(dis_atom)
if "STANDARD THERMODYNAMIC QUANTITIES" in line\
or "Imaginary Frequencies" in line:
parse_freq = False
continue
if "Frequency:" in line:
vib_freqs = [float(vib) for vib
in line.strip().strip().split()[1:]]
elif "X Y Z" in line:
parse_modes = True
continue
elif parse_charge:
if '-'*20 in line:
if len(charges[pop_method]) == 0:
continue
else:
pop_method = None
parse_charge = False
else:
if len(line.strip()) == 0 or\
'Atom' in line:
continue
else:
charges[pop_method].append(float(line.split()[2]))
elif parse_nbo_charge:
if '-'*20 in line:
if len(charges[pop_method]) == 0:
continue
elif "="*20 in line:
pop_method = None
parse_nbo_charge = False
else:
m = nbo_charge_pattern.search(line)
if m:
charges[pop_method].append(float(m.group("charge")))
else:
raise Exception("Can't find NBO charges")
elif parse_alpha_homo:
if "-- Occupied --" in line:
continue
elif "-- Virtual --" in line:
parse_alpha_homo = False
parse_alpha_lumo = True
continue
else:
tokens = line.split()
m = float_pattern.search(tokens[-1])
if m:
current_alpha_homo = float(m.group(0))
continue
elif parse_alpha_lumo:
current_alpha_lumo = float(line.split()[0])
parse_alpha_lumo = False
continue
elif parse_beta_homo:
if "-- Occupied --" in line:
continue
elif "-- Virtual --" in line:
parse_beta_homo = False
parse_beta_lumo = True
continue
else:
tokens = line.split()
m = float_pattern.search(tokens[-1])
if m:
current_beta_homo = float(m.group(0))
continue
elif parse_beta_lumo:
current_beta_lumo = float(line.split()[0])
parse_beta_lumo = False
current_homo = max([current_alpha_homo, current_beta_homo])
current_lumo = min([current_alpha_lumo, current_beta_lumo])
homo_lumo.append([Energy(current_homo, "Ha").to("eV"),
Energy(current_lumo, "Ha").to("eV")])
current_alpha_homo = None
current_alpha_lumo = None
current_beta_homo = None
continue
elif "-" * 50 in line and not (current_alpha_lumo is None):
homo_lumo.append([Energy(current_alpha_homo, "Ha").to("eV"),
Energy(current_alpha_lumo, "Ha").to("eV")])
current_alpha_homo = None
current_alpha_lumo = None
current_beta_homo = None
continue
else:
if spin_multiplicity is None:
m = num_ele_pattern.search(line)
if m:
spin_multiplicity = int(m.group("alpha")) - \
int(m.group("beta")) + 1
if charge is None:
m = total_charge_pattern.search(line)
if m:
charge = int(float(m.group("charge")))
if jobtype and jobtype == "freq":
m = zpe_pattern.search(line)
if m:
zpe = float(m.group("zpe"))
thermal_corr["ZPE"] = zpe
m = thermal_corr_pattern.search(line)
if m:
thermal_corr[m.group("name")] = \
float(m.group("correction"))
m = bsse_pattern.search(line)
if m:
raw_be = float(m.group("raw_be"))
corrected_be = float(m.group("corrected_be"))
bsse_fwu = FloatWithUnit(raw_be - corrected_be, "kJ mol^-1")
bsse = bsse_fwu.to('eV atom^-1').real
name = None
energy = None
m = scf_energy_pattern.search(line)
if m:
name = "SCF"
energy = Energy(m.group("energy"), "Ha").to("eV")
m = corr_energy_pattern.search(line)
if m and m.group("name") != "SCF":
name = m.group("name")
energy = Energy(m.group("energy"), "Ha").to("eV")
m = detailed_charge_pattern.search(line)
if m:
pop_method = m.group("method").lower()
parse_charge = True
charges[pop_method] = []
if nbo_available:
if nbo_charge_header is None:
m = nbo_wavefunction_type_pattern.search(line)
if m:
nbo_wavefunction_type = m.group("type")
nbo_charge_header_dict = {
"closed-shell": "Atom No Charge Core "
"Valence Rydberg Total",
"open-shell": "Atom No Charge Core "
"Valence Rydberg Total Density"}
nbo_charge_header = nbo_charge_header_dict[nbo_wavefunction_type]
continue
if nbo_charge_header in line:
pop_method = "nbo"
parse_nbo_charge = True
charges[pop_method] = []
if "N A T U R A L B O N D O R B I T A L A N A L Y S I S" in line:
nbo_available = True
if name and energy:
energies.append(tuple([name, energy]))
if "User input:" in line:
parse_input = True
elif "Standard Nuclear Orientation (Angstroms)" in line:
parse_coords = True
elif "Performing Hirshfeld population analysis" in line:
hiershfiled_pop = True
elif "Hirshfeld: atomic densities completed" in line:
hiershfiled_pop = False
elif ("Cycle Energy DIIS Error" in line
or "Cycle Energy RMS Gradient" in line)\
and not hiershfiled_pop:
parse_scf_iter = True
scf_iters.append([])
scf_successful = False
elif "Gradient of SCF Energy" in line:
parse_gradient = True
gradients.append({"gradients": []})
elif "VIBRATIONAL ANALYSIS" in line:
parse_freq = True
elif "Alpha MOs" in line:
parse_alpha_homo = True
parse_alpha_lumo = False
elif "Beta MOs" in line:
parse_beta_homo = True
parse_beta_lumo = False
elif "Thank you very much for using Q-Chem." in line:
properly_terminated = True
elif "OPTIMIZATION CONVERGED" in line:
opt_successful = True
if charge is None:
errors.append("Molecular charge is not found")
elif spin_multiplicity is None:
errors.append("Molecular spin multipilicity is not found")
else:
for mol in molecules:
if qctask is None or qctask.ghost_atoms is None:
mol.set_charge_and_spin(charge, spin_multiplicity)
for k in thermal_corr.keys():
v = thermal_corr[k]
if "Entropy" in k:
v *= cls.kcal_per_mol_2_eV * 1.0E-3
else:
v *= cls.kcal_per_mol_2_eV
thermal_corr[k] = v
solvent_method = "NA"
if qctask:
if "solvent_method" in qctask.params["rem"]:
solvent_method = qctask.params["rem"]["solvent_method"]
else:
errors.append("No input text")
if not scf_successful:
if 'Bad SCF convergence' not in errors:
errors.append('Bad SCF convergence')
if jobtype == 'opt':
if not opt_successful:
if 'Geometry optimization failed' not in errors:
errors.append('Geometry optimization failed')
if len(errors) == 0:
for text in cls._expected_successful_pattern(qctask):
success_pattern = re.compile(text)
if not success_pattern.search(output):
errors.append("Can't find text to indicate success")
data = {
"jobtype": jobtype,
"energies": energies,
"HOMO/LUMOs": homo_lumo,
"bsse": bsse,
'charges': charges,
"corrections": thermal_corr,
"molecules": molecules,
"errors": errors,
"has_error": len(errors) > 0,
"frequencies": freqs,
"gradients": gradients,
"input": qctask,
"gracefully_terminated": properly_terminated,
"scf_iteration_energies": scf_iters,
"solvent_method": solvent_method
}
return data
|
mit
|
[
3,
2803,
26,
2774,
13,
24,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
13390,
199,
199,
624,
199,
2765,
859,
9031,
1324,
436,
1072,
6661,
687,
1413,
20335,
77,
14,
199,
624,
199,
199,
646,
1331,
199,
646,
295,
199,
646,
2680,
465,
980,
199,
504,
1059,
492,
5458,
199,
199,
646,
3816,
199,
199,
504,
3485,
369,
14,
2308,
492,
1315,
1490,
199,
504,
1134,
30649,
14,
1018,
14,
8170,
492,
5515,
596,
4619,
199,
504,
1134,
30649,
14,
1018,
14,
6976,
492,
3930,
14413,
199,
504,
1134,
30649,
14,
1018,
14,
5260,
492,
662,
1372,
4312,
12,
11140,
3007,
5072,
199,
504,
1134,
30649,
14,
12844,
14,
1001,
63,
2693,
83,
492,
510,
26255,
3377,
461,
199,
504,
1134,
30649,
14,
1974,
14,
7988,
63,
1208,
492,
664,
63,
4593,
199,
504,
3816,
14,
4912,
492,
2341,
12,
3482,
199,
199,
363,
2502,
363,
275,
298,
56,
18939,
26988,
5843,
2,
199,
363,
7307,
363,
275,
298,
7384,
6171,
12,
710,
662,
1264,
293,
590,
266,
18870,
1377,
7290,
2,
199,
363,
1023,
363,
275,
298,
16,
14,
17,
2,
199,
363,
26665,
363,
275,
298,
56,
18939,
26988,
5843,
2,
199,
363,
2123,
363,
275,
298,
29426,
392,
1167,
2835,
32,
6799,
14,
957,
2,
199,
363,
602,
363,
275,
298,
845,
15,
20,
15,
969,
2,
421,
199,
533,
1413,
67,
4476,
8,
10793,
39,
3377,
461,
304,
272,
408,
272,
1626,
909,
6144,
282,
1413,
20335,
77,
1324,
570,
14,
339,
3033,
26,
267,
26350,
26,
710,
1324,
26350,
14,
982,
652,
365,
488,
402,
1059,
298,
739,
401,
288,
1413,
20335,
77,
911,
1586,
3400,
687,
9997,
570,
14,
982,
652,
365,
282,
288,
3930,
14413,
909,
12,
1413,
67,
3205,
911,
3957,
652,
1901,
14243,
19157,
288,
8983,
14,
4821,
1338,
26,
1134,
30649,
3930,
14413,
909,
12,
298,
739,
401,
488,
288,
7827,
370,
488,
14,
267,
11204,
334,
442,
304,
2799,
4430,
402,
314,
26350,
14,
982,
488,
12,
11204,
641,
26350,
365,
288,
1202,
14,
7827,
370,
488,
14,
267,
20749,
63,
8016,
20976,
334,
442,
304,
428,
7751,
8897,
20976,
402,
26350,
14,
7827,
370,
288,
488,
12,
1314,
4910,
626,
314,
20749,
8897,
20976,
365,
663,
370,
413,
340,
314,
288,
26350,
965,
949,
625,
29796,
325,
16728,
83,
436,
370,
499,
340,
2337,
787,
288,
625,
29796,
325,
16728,
83,
14,
267,
3906,
466,
334,
495,
304,
710,
730,
314,
1413,
20335,
77,
3906,
14,
298,
5763,
2,
367,
13050,
7584,
662,
1372,
4312,
12,
288,
298,
2992,
2,
367,
3400,
13712,
12,
298,
5646,
2,
367,
288,
1321,
66,
21005,
9857,
14,
267,
2538,
334,
495,
304,
5429,
1470,
367,
314,
3906,
14,
7827,
370,
488,
14,
26058,
4910,
314,
288,
2672,
3349,
3420,
911,
506,
22002,
14,
267,
15343,
334,
495,
304,
710,
15343,
3102,
402,
314,
30629,
14,
6058,
5893,
26,
288,
298,
34,
2,
334,
262,
15111,
699,
6084,
48,
395,
298,
10780,
3328,
401,
298,
48,
6773,
401,
298,
6495,
2300,
1674,
288,
7827,
370,
298,
25500,
1674,
288,
961,
2725,
883,
2597,
506,
2863,
1561,
402,
7188,
14601,
288,
805,
2551,
12,
4066,
465,
699,
19,
6084,
48,
12,
24328,
2300,
72,
12,
1323,
57,
39,
42,
3100,
14,
1010,
4066,
5560,
12,
288,
314,
21280,
2725,
1077,
506,
3602,
465,
488,
14,
267,
21280,
334,
495,
304,
710,
21280,
2166,
402,
314,
30629,
14,
5679,
288,
5893,
26,
298,
1658,
18,
401,
298,
6129,
13,
1658,
18,
401,
298,
2571,
3693,
8,
52,
4186,
298,
6084,
48,
401,
298,
48,
6773,
401,
298,
6495,
2300,
2,
288,
7827,
370,
488,
14,
267,
5597,
63,
409,
334,
495,
15,
807,
304,
710,
5597,
663,
14,
288,
982,
652,
365,
282,
1211,
12,
1924,
1819,
883,
675,
3365,
5597,
663,
14,
267,
11593,
63,
19220,
63,
409,
334,
495,
15,
807,
304,
437,
2521,
20524,
5597,
663,
14,
2104,
3102,
12,
288,
2839,
820,
41,
13,
1658,
18,
12,
1323,
57,
39,
19,
12,
593,
8195,
42,
13,
3100,
12,
31407,
5597,
663,
365,
1415,
14,
288,
982,
652,
365,
282,
1211,
12,
1924,
1819,
883,
675,
3365,
31407,
288,
5597,
663,
14,
267,
325,
1850,
26,
662,
556,
6850,
6170,
12330,
334,
37,
2890,
9,
370,
506,
1202,
14,
288,
982,
652,
365,
282,
1211,
12,
1924,
1819,
883,
675,
3365,
662,
2890,
14,
267,
18798,
63,
1162,
334,
807,
304,
710,
2633,
20042,
370,
2218,
315,
314,
2672,
13179,
288,
3420,
14,
7448,
402,
790,
15,
585,
6342,
14,
288,
5679,
26,
2420,
27441,
63,
8833,
582,
298,
328,
374,
63,
71,
6428,
401,
298,
27441,
63,
988,
63,
23356,
582,
2948,
93,
267,
2716,
63,
1162,
334,
807,
304,
710,
2725,
367,
7681,
1163,
2419,
2672,
13179,
288,
3420,
14,
7448,
402,
790,
15,
585,
6342,
14,
288,
5679,
26,
2420,
19220,
582,
2420,
13009,
582,
298,
2055,
13,
48,
8156,
58,
401,
298,
34,
582,
298,
20669,
13,
2055,
13,
48,
8156,
58,
401,
288,
298,
38,
582,
298,
20669,
13,
2055,
13,
48,
8156,
58,
3570,
298,
825,
80,
582,
2420,
27643,
582,
298,
5474,
551,
401,
298,
12771,
582,
298,
83,
4308,
67,
32655,
267,
486,
1102,
63,
4188,
334,
513,
304,
3820,
402,
486,
1102,
14503,
4918,
14,
1010,
12503,
1343,
687,
378,
14,
288,
710,
486,
1102,
6222,
911,
506,
11159,
315,
402,
314,
1824,
402,
768,
2108,
63,
1786,
596,
23484,
272,
408,
339,
2716,
63,
7511,
63,
513,
275,
2420,
19220,
401,
298,
19220,
18,
401,
298,
825,
80,
401,
298,
2109,
73,
8825,
63,
2297,
529,
438,
401,
2892,
298,
5159,
63,
1560,
3389,
401,
298,
3990,
63,
698,
63,
1162,
401,
2892,
298,
442,
6457,
443,
401,
298,
374,
3459,
22020,
401,
298,
10962,
63,
19220,
401,
2892,
298,
22729,
63,
328,
371,
2159,
13362,
401,
298,
3029,
25903,
63,
698,
401,
2892,
298,
78,
656,
401,
298,
27256,
5299,
401,
298,
9286,
63,
27256,
5299,
63,
2065,
401,
298,
2992,
401,
2892,
298,
2352,
77,
401,
298,
2352,
77,
63,
7873,
782,
401,
298,
13701,
401,
298,
17976,
63,
11521,
401,
298,
2772,
80,
401,
2892,
298,
2772
] |
[
2803,
26,
2774,
13,
24,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
13390,
199,
199,
624,
199,
2765,
859,
9031,
1324,
436,
1072,
6661,
687,
1413,
20335,
77,
14,
199,
624,
199,
199,
646,
1331,
199,
646,
295,
199,
646,
2680,
465,
980,
199,
504,
1059,
492,
5458,
199,
199,
646,
3816,
199,
199,
504,
3485,
369,
14,
2308,
492,
1315,
1490,
199,
504,
1134,
30649,
14,
1018,
14,
8170,
492,
5515,
596,
4619,
199,
504,
1134,
30649,
14,
1018,
14,
6976,
492,
3930,
14413,
199,
504,
1134,
30649,
14,
1018,
14,
5260,
492,
662,
1372,
4312,
12,
11140,
3007,
5072,
199,
504,
1134,
30649,
14,
12844,
14,
1001,
63,
2693,
83,
492,
510,
26255,
3377,
461,
199,
504,
1134,
30649,
14,
1974,
14,
7988,
63,
1208,
492,
664,
63,
4593,
199,
504,
3816,
14,
4912,
492,
2341,
12,
3482,
199,
199,
363,
2502,
363,
275,
298,
56,
18939,
26988,
5843,
2,
199,
363,
7307,
363,
275,
298,
7384,
6171,
12,
710,
662,
1264,
293,
590,
266,
18870,
1377,
7290,
2,
199,
363,
1023,
363,
275,
298,
16,
14,
17,
2,
199,
363,
26665,
363,
275,
298,
56,
18939,
26988,
5843,
2,
199,
363,
2123,
363,
275,
298,
29426,
392,
1167,
2835,
32,
6799,
14,
957,
2,
199,
363,
602,
363,
275,
298,
845,
15,
20,
15,
969,
2,
421,
199,
533,
1413,
67,
4476,
8,
10793,
39,
3377,
461,
304,
272,
408,
272,
1626,
909,
6144,
282,
1413,
20335,
77,
1324,
570,
14,
339,
3033,
26,
267,
26350,
26,
710,
1324,
26350,
14,
982,
652,
365,
488,
402,
1059,
298,
739,
401,
288,
1413,
20335,
77,
911,
1586,
3400,
687,
9997,
570,
14,
982,
652,
365,
282,
288,
3930,
14413,
909,
12,
1413,
67,
3205,
911,
3957,
652,
1901,
14243,
19157,
288,
8983,
14,
4821,
1338,
26,
1134,
30649,
3930,
14413,
909,
12,
298,
739,
401,
488,
288,
7827,
370,
488,
14,
267,
11204,
334,
442,
304,
2799,
4430,
402,
314,
26350,
14,
982,
488,
12,
11204,
641,
26350,
365,
288,
1202,
14,
7827,
370,
488,
14,
267,
20749,
63,
8016,
20976,
334,
442,
304,
428,
7751,
8897,
20976,
402,
26350,
14,
7827,
370,
288,
488,
12,
1314,
4910,
626,
314,
20749,
8897,
20976,
365,
663,
370,
413,
340,
314,
288,
26350,
965,
949,
625,
29796,
325,
16728,
83,
436,
370,
499,
340,
2337,
787,
288,
625,
29796,
325,
16728,
83,
14,
267,
3906,
466,
334,
495,
304,
710,
730,
314,
1413,
20335,
77,
3906,
14,
298,
5763,
2,
367,
13050,
7584,
662,
1372,
4312,
12,
288,
298,
2992,
2,
367,
3400,
13712,
12,
298,
5646,
2,
367,
288,
1321,
66,
21005,
9857,
14,
267,
2538,
334,
495,
304,
5429,
1470,
367,
314,
3906,
14,
7827,
370,
488,
14,
26058,
4910,
314,
288,
2672,
3349,
3420,
911,
506,
22002,
14,
267,
15343,
334,
495,
304,
710,
15343,
3102,
402,
314,
30629,
14,
6058,
5893,
26,
288,
298,
34,
2,
334,
262,
15111,
699,
6084,
48,
395,
298,
10780,
3328,
401,
298,
48,
6773,
401,
298,
6495,
2300,
1674,
288,
7827,
370,
298,
25500,
1674,
288,
961,
2725,
883,
2597,
506,
2863,
1561,
402,
7188,
14601,
288,
805,
2551,
12,
4066,
465,
699,
19,
6084,
48,
12,
24328,
2300,
72,
12,
1323,
57,
39,
42,
3100,
14,
1010,
4066,
5560,
12,
288,
314,
21280,
2725,
1077,
506,
3602,
465,
488,
14,
267,
21280,
334,
495,
304,
710,
21280,
2166,
402,
314,
30629,
14,
5679,
288,
5893,
26,
298,
1658,
18,
401,
298,
6129,
13,
1658,
18,
401,
298,
2571,
3693,
8,
52,
4186,
298,
6084,
48,
401,
298,
48,
6773,
401,
298,
6495,
2300,
2,
288,
7827,
370,
488,
14,
267,
5597,
63,
409,
334,
495,
15,
807,
304,
710,
5597,
663,
14,
288,
982,
652,
365,
282,
1211,
12,
1924,
1819,
883,
675,
3365,
5597,
663,
14,
267,
11593,
63,
19220,
63,
409,
334,
495,
15,
807,
304,
437,
2521,
20524,
5597,
663,
14,
2104,
3102,
12,
288,
2839,
820,
41,
13,
1658,
18,
12,
1323,
57,
39,
19,
12,
593,
8195,
42,
13,
3100,
12,
31407,
5597,
663,
365,
1415,
14,
288,
982,
652,
365,
282,
1211,
12,
1924,
1819,
883,
675,
3365,
31407,
288,
5597,
663,
14,
267,
325,
1850,
26,
662,
556,
6850,
6170,
12330,
334,
37,
2890,
9,
370,
506,
1202,
14,
288,
982,
652,
365,
282,
1211,
12,
1924,
1819,
883,
675,
3365,
662,
2890,
14,
267,
18798,
63,
1162,
334,
807,
304,
710,
2633,
20042,
370,
2218,
315,
314,
2672,
13179,
288,
3420,
14,
7448,
402,
790,
15,
585,
6342,
14,
288,
5679,
26,
2420,
27441,
63,
8833,
582,
298,
328,
374,
63,
71,
6428,
401,
298,
27441,
63,
988,
63,
23356,
582,
2948,
93,
267,
2716,
63,
1162,
334,
807,
304,
710,
2725,
367,
7681,
1163,
2419,
2672,
13179,
288,
3420,
14,
7448,
402,
790,
15,
585,
6342,
14,
288,
5679,
26,
2420,
19220,
582,
2420,
13009,
582,
298,
2055,
13,
48,
8156,
58,
401,
298,
34,
582,
298,
20669,
13,
2055,
13,
48,
8156,
58,
401,
288,
298,
38,
582,
298,
20669,
13,
2055,
13,
48,
8156,
58,
3570,
298,
825,
80,
582,
2420,
27643,
582,
298,
5474,
551,
401,
298,
12771,
582,
298,
83,
4308,
67,
32655,
267,
486,
1102,
63,
4188,
334,
513,
304,
3820,
402,
486,
1102,
14503,
4918,
14,
1010,
12503,
1343,
687,
378,
14,
288,
710,
486,
1102,
6222,
911,
506,
11159,
315,
402,
314,
1824,
402,
768,
2108,
63,
1786,
596,
23484,
272,
408,
339,
2716,
63,
7511,
63,
513,
275,
2420,
19220,
401,
298,
19220,
18,
401,
298,
825,
80,
401,
298,
2109,
73,
8825,
63,
2297,
529,
438,
401,
2892,
298,
5159,
63,
1560,
3389,
401,
298,
3990,
63,
698,
63,
1162,
401,
2892,
298,
442,
6457,
443,
401,
298,
374,
3459,
22020,
401,
298,
10962,
63,
19220,
401,
2892,
298,
22729,
63,
328,
371,
2159,
13362,
401,
298,
3029,
25903,
63,
698,
401,
2892,
298,
78,
656,
401,
298,
27256,
5299,
401,
298,
9286,
63,
27256,
5299,
63,
2065,
401,
298,
2992,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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
] |
sonaht/ansible
|
test/units/module_utils/facts/base.py
|
118
|
2325
|
# base unit test classes for ansible/module_utils/facts/ tests
# -*- coding: utf-8 -*-
#
# 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)
__metaclass__ = type
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
class BaseFactsTest(unittest.TestCase):
# just a base class, not an actual test
__test__ = False
gather_subset = ['all']
valid_subsets = None
fact_namespace = None
collector_class = None
# a dict ansible_facts. Some fact collectors depend on facts gathered by
# other collectors (like 'ansible_architecture' or 'ansible_system') which
# can be passed via the collected_facts arg to collect()
collected_facts = None
def _mock_module(self):
mock_module = Mock()
mock_module.params = {'gather_subset': self.gather_subset,
'gather_timeout': 5,
'filter': '*'}
mock_module.get_bin_path = Mock(return_value=None)
return mock_module
def test_collect(self):
module = self._mock_module()
fact_collector = self.collector_class()
facts_dict = fact_collector.collect(module=module, collected_facts=self.collected_facts)
self.assertIsInstance(facts_dict, dict)
return facts_dict
def test_collect_with_namespace(self):
module = self._mock_module()
fact_collector = self.collector_class()
facts_dict = fact_collector.collect_with_namespace(module=module,
collected_facts=self.collected_facts)
self.assertIsInstance(facts_dict, dict)
return facts_dict
|
gpl-3.0
|
[
3,
1300,
4137,
511,
3992,
367,
3242,
15,
578,
63,
1208,
15,
5047,
15,
2295,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
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,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
504,
3242,
14,
5819,
14,
2219,
14,
1805,
492,
4420,
421,
199,
533,
3523,
25821,
774,
8,
2796,
14,
1746,
304,
272,
327,
2951,
282,
1300,
1021,
12,
440,
376,
3503,
511,
272,
636,
396,
363,
275,
756,
339,
13082,
63,
9401,
275,
788,
452,
418,
272,
1686,
63,
23060,
275,
488,
272,
10572,
63,
3251,
275,
488,
272,
14910,
63,
533,
275,
488,
339,
327,
282,
1211,
3242,
63,
5047,
14,
6601,
10572,
14910,
83,
11687,
641,
9036,
16072,
31051,
701,
272,
327,
1163,
14910,
83,
334,
2930,
283,
4853,
63,
19134,
7,
503,
283,
4853,
63,
2253,
358,
1314,
272,
327,
883,
506,
3032,
4799,
314,
13736,
63,
5047,
1680,
370,
8775,
342,
272,
13736,
63,
5047,
275,
488,
339,
347,
485,
1805,
63,
578,
8,
277,
304,
267,
1683,
63,
578,
275,
4420,
342,
267,
1683,
63,
578,
14,
1162,
275,
791,
13737,
63,
9401,
356,
291,
14,
13737,
63,
9401,
12,
2892,
283,
13737,
63,
2593,
356,
959,
12,
2892,
283,
1541,
356,
6438,
936,
267,
1683,
63,
578,
14,
362,
63,
1393,
63,
515,
275,
4420,
8,
1107,
63,
585,
29,
403,
9,
267,
372,
1683,
63,
578,
339,
347,
511,
63,
7112,
8,
277,
304,
267,
859,
275,
291,
423,
1805,
63,
578,
342,
267,
10572,
63,
10946,
275,
291,
14,
10946,
63,
533,
342,
267,
9036,
63,
807,
275,
10572,
63,
10946,
14,
7112,
8,
578,
29,
578,
12,
13736,
63,
5047,
29,
277,
14,
22766,
63,
5047,
9,
267,
291,
14,
6926,
8,
5047,
63,
807,
12,
1211,
9,
267,
372,
9036,
63,
807,
339,
347,
511,
63,
7112,
63,
1045,
63,
3251,
8,
277,
304,
267,
859,
275,
291,
423,
1805,
63,
578,
342,
267,
10572,
63,
10946,
275,
291,
14,
10946,
63,
533,
342,
267,
9036,
63,
807,
275,
10572,
63,
10946,
14,
7112,
63,
1045,
63,
3251,
8,
578,
29,
578,
12,
15491,
13736,
63,
5047,
29,
277,
14,
22766,
63,
5047,
9,
267,
291,
14,
6926,
8,
5047,
63,
807,
12,
1211,
9,
267,
372,
9036,
63,
807,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1300,
4137,
511,
3992,
367,
3242,
15,
578,
63,
1208,
15,
5047,
15,
2295,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
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,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
504,
3242,
14,
5819,
14,
2219,
14,
1805,
492,
4420,
421,
199,
533,
3523,
25821,
774,
8,
2796,
14,
1746,
304,
272,
327,
2951,
282,
1300,
1021,
12,
440,
376,
3503,
511,
272,
636,
396,
363,
275,
756,
339,
13082,
63,
9401,
275,
788,
452,
418,
272,
1686,
63,
23060,
275,
488,
272,
10572,
63,
3251,
275,
488,
272,
14910,
63,
533,
275,
488,
339,
327,
282,
1211,
3242,
63,
5047,
14,
6601,
10572,
14910,
83,
11687,
641,
9036,
16072,
31051,
701,
272,
327,
1163,
14910,
83,
334,
2930,
283,
4853,
63,
19134,
7,
503,
283,
4853,
63,
2253,
358,
1314,
272,
327,
883,
506,
3032,
4799,
314,
13736,
63,
5047,
1680,
370,
8775,
342,
272,
13736,
63,
5047,
275,
488,
339,
347,
485,
1805,
63,
578,
8,
277,
304,
267,
1683,
63,
578,
275,
4420,
342,
267,
1683,
63,
578,
14,
1162,
275,
791,
13737,
63,
9401,
356,
291,
14,
13737,
63,
9401,
12,
2892,
283,
13737,
63,
2593,
356,
959,
12,
2892,
283,
1541,
356,
6438,
936,
267,
1683,
63,
578,
14,
362,
63,
1393,
63,
515,
275,
4420,
8,
1107,
63,
585,
29,
403,
9,
267,
372,
1683,
63,
578,
339,
347,
511,
63,
7112,
8,
277,
304,
267,
859,
275,
291,
423,
1805,
63,
578,
342,
267,
10572,
63,
10946,
275,
291,
14,
10946,
63,
533,
342,
267,
9036,
63,
807,
275,
10572,
63,
10946,
14,
7112,
8,
578,
29,
578,
12,
13736,
63,
5047,
29,
277,
14,
22766,
63,
5047,
9,
267,
291,
14,
6926,
8,
5047,
63,
807,
12,
1211,
9,
267,
372,
9036,
63,
807,
339,
347,
511,
63,
7112,
63,
1045,
63,
3251,
8,
277,
304,
267,
859,
275,
291,
423,
1805,
63,
578,
342,
267,
10572,
63,
10946,
275,
291,
14,
10946,
63,
533,
342,
267,
9036,
63,
807,
275,
10572,
63,
10946,
14,
7112,
63,
1045,
63,
3251,
8,
578,
29,
578,
12,
15491,
13736,
63,
5047,
29,
277,
14,
22766,
63,
5047,
9,
267,
291,
14,
6926,
8,
5047,
63,
807,
12,
1211,
9,
267,
372,
9036,
63,
807,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
irudayarajisawa/django-cms
|
setup.py
|
13
|
1526
|
from setuptools import setup, find_packages
import os
import cms
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Application Frameworks',
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
]
setup(
author="Patrick Lauber",
author_email="digi@treepy.com",
name='django-cms',
version=cms.__version__,
description='An Advanced Django CMS',
long_description=open(os.path.join(os.path.dirname(__file__), 'README.rst')).read(),
url='https://www.django-cms.org/',
license='BSD License',
platforms=['OS Independent'],
classifiers=CLASSIFIERS,
install_requires=[
'Django>=1.6,<1.9',
'django-classy-tags>=0.5',
'html5lib<0.9999',
'django-treebeard==3.0',
'django-sekizai>=0.7',
'djangocms-admin-style'
],
extras_require={
'south': ['south>=1.0.0'],
},
packages=find_packages(exclude=["project", "project.*"]),
include_package_data=True,
zip_safe=False,
test_suite='runtests.main',
)
|
bsd-3-clause
|
[
504,
9116,
492,
3272,
12,
2342,
63,
5154,
199,
646,
747,
199,
646,
19240,
421,
199,
31163,
1976,
3960,
275,
359,
272,
283,
23753,
9795,
3800,
959,
446,
24114,
15,
933,
461,
297,
272,
283,
8263,
3800,
6001,
9711,
297,
272,
283,
16442,
3800,
5634,
297,
272,
283,
23910,
23975,
3800,
23493,
297,
272,
283,
3761,
3800,
25718,
26330,
3800,
6289,
844,
297,
272,
283,
23699,
6187,
3800,
4403,
1010,
7106,
297,
272,
283,
11411,
8466,
3800,
2018,
297,
272,
283,
12157,
3800,
22026,
3800,
644,
11178,
15,
2856,
3800,
21907,
6646,
297,
272,
283,
12157,
3800,
2290,
15290,
297,
272,
283,
12157,
3800,
2290,
15290,
3800,
31454,
3800,
13515,
11726,
12243,
297,
272,
298,
11411,
8466,
3800,
2018,
3800,
499,
14,
22,
401,
272,
298,
11411,
8466,
3800,
2018,
3800,
499,
14,
23,
401,
272,
298,
11411,
8466,
3800,
2018,
3800,
650,
14,
19,
401,
272,
298,
11411,
8466,
3800,
2018,
3800,
650,
14,
20,
401,
199,
61,
199,
199,
2758,
8,
272,
4132,
628,
48,
292,
27091,
7964,
10400,
401,
272,
4132,
63,
2123,
628,
328,
6153,
32,
2350,
647,
14,
957,
401,
272,
536,
534,
1176,
13,
10781,
297,
272,
1015,
29,
10781,
855,
1023,
3108,
272,
1369,
534,
2493,
32445,
5634,
29554,
297,
272,
1846,
63,
1802,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
18195,
14,
8332,
11103,
739,
1062,
272,
1166,
534,
2859,
921,
1544,
14,
1176,
13,
10781,
14,
1308,
3678,
272,
4190,
534,
15400,
844,
297,
272,
10677,
2968,
3100,
1010,
7106,
995,
272,
19137,
29,
31163,
1976,
3960,
12,
272,
3907,
63,
6537,
1524,
267,
283,
9323,
8119,
17,
14,
22,
30027,
17,
14,
25,
297,
267,
283,
1176,
13,
533,
89,
13,
2969,
8119,
16,
14,
21,
297,
267,
283,
1360,
21,
773,
28,
16,
14,
5008,
297,
267,
283,
1176,
13,
2350,
15283,
389,
19,
14,
16,
297,
267,
283,
1176,
13,
261,
75,
565,
5789,
8119,
16,
14,
23,
297,
267,
283,
12816,
679,
706,
13,
2113,
13,
2487,
7,
272,
2156,
272,
13751,
63,
4365,
3126,
267,
283,
22607,
356,
788,
22607,
8119,
17,
14,
16,
14,
16,
995,
272,
1660,
272,
6117,
29,
1623,
63,
5154,
8,
5473,
6270,
1715,
401,
298,
1715,
2795,
10252,
272,
2387,
63,
2491,
63,
576,
29,
549,
12,
272,
3482,
63,
3489,
29,
797,
12,
272,
511,
63,
5768,
534,
1065,
2219,
14,
973,
297,
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
] |
[
9116,
492,
3272,
12,
2342,
63,
5154,
199,
646,
747,
199,
646,
19240,
421,
199,
31163,
1976,
3960,
275,
359,
272,
283,
23753,
9795,
3800,
959,
446,
24114,
15,
933,
461,
297,
272,
283,
8263,
3800,
6001,
9711,
297,
272,
283,
16442,
3800,
5634,
297,
272,
283,
23910,
23975,
3800,
23493,
297,
272,
283,
3761,
3800,
25718,
26330,
3800,
6289,
844,
297,
272,
283,
23699,
6187,
3800,
4403,
1010,
7106,
297,
272,
283,
11411,
8466,
3800,
2018,
297,
272,
283,
12157,
3800,
22026,
3800,
644,
11178,
15,
2856,
3800,
21907,
6646,
297,
272,
283,
12157,
3800,
2290,
15290,
297,
272,
283,
12157,
3800,
2290,
15290,
3800,
31454,
3800,
13515,
11726,
12243,
297,
272,
298,
11411,
8466,
3800,
2018,
3800,
499,
14,
22,
401,
272,
298,
11411,
8466,
3800,
2018,
3800,
499,
14,
23,
401,
272,
298,
11411,
8466,
3800,
2018,
3800,
650,
14,
19,
401,
272,
298,
11411,
8466,
3800,
2018,
3800,
650,
14,
20,
401,
199,
61,
199,
199,
2758,
8,
272,
4132,
628,
48,
292,
27091,
7964,
10400,
401,
272,
4132,
63,
2123,
628,
328,
6153,
32,
2350,
647,
14,
957,
401,
272,
536,
534,
1176,
13,
10781,
297,
272,
1015,
29,
10781,
855,
1023,
3108,
272,
1369,
534,
2493,
32445,
5634,
29554,
297,
272,
1846,
63,
1802,
29,
1490,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
18195,
14,
8332,
11103,
739,
1062,
272,
1166,
534,
2859,
921,
1544,
14,
1176,
13,
10781,
14,
1308,
3678,
272,
4190,
534,
15400,
844,
297,
272,
10677,
2968,
3100,
1010,
7106,
995,
272,
19137,
29,
31163,
1976,
3960,
12,
272,
3907,
63,
6537,
1524,
267,
283,
9323,
8119,
17,
14,
22,
30027,
17,
14,
25,
297,
267,
283,
1176,
13,
533,
89,
13,
2969,
8119,
16,
14,
21,
297,
267,
283,
1360,
21,
773,
28,
16,
14,
5008,
297,
267,
283,
1176,
13,
2350,
15283,
389,
19,
14,
16,
297,
267,
283,
1176,
13,
261,
75,
565,
5789,
8119,
16,
14,
23,
297,
267,
283,
12816,
679,
706,
13,
2113,
13,
2487,
7,
272,
2156,
272,
13751,
63,
4365,
3126,
267,
283,
22607,
356,
788,
22607,
8119,
17,
14,
16,
14,
16,
995,
272,
1660,
272,
6117,
29,
1623,
63,
5154,
8,
5473,
6270,
1715,
401,
298,
1715,
2795,
10252,
272,
2387,
63,
2491,
63,
576,
29,
549,
12,
272,
3482,
63,
3489,
29,
797,
12,
272,
511,
63,
5768,
534,
1065,
2219,
14,
973,
297,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
marcwebbie/youtube-dl
|
youtube_dl/extractor/radiofrance.py
|
91
|
2089
|
# coding: utf-8
from __future__ import unicode_literals
import re
from .common import InfoExtractor
class RadioFranceIE(InfoExtractor):
_VALID_URL = r'^https?://maison\.radiofrance\.fr/radiovisions/(?P<id>[^?#]+)'
IE_NAME = 'radiofrance'
_TEST = {
'url': 'http://maison.radiofrance.fr/radiovisions/one-one',
'md5': 'bdbb28ace95ed0e04faab32ba3160daf',
'info_dict': {
'id': 'one-one',
'ext': 'ogg',
'title': 'One to one',
'description': "Plutôt que d'imaginer la radio de demain comme technologie ou comme création de contenu, je veux montrer que quelles que soient ses évolutions, j'ai l'intime conviction que la radio continuera d'être un grand média de proximité pour les auditeurs.",
'uploader': 'Thomas Hercouët',
},
}
def _real_extract(self, url):
m = re.match(self._VALID_URL, url)
video_id = m.group('id')
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'<h1>(.*?)</h1>', webpage, 'title')
description = self._html_search_regex(
r'<div class="bloc_page_wrapper"><div class="text">(.*?)</div>',
webpage, 'description', fatal=False)
uploader = self._html_search_regex(
r'<div class="credit"> © (.*?)</div>',
webpage, 'uploader', fatal=False)
formats_str = self._html_search_regex(
r'class="jp-jplayer[^"]*" data-source="([^"]+)">',
webpage, 'audio URLs')
formats = [
{
'format_id': fm[0],
'url': fm[1],
'vcodec': 'none',
'preference': i,
}
for i, fm in
enumerate(re.findall(r"([a-z0-9]+)\s*:\s*'([^']+)'", formats_str))
]
self._sort_formats(formats)
return {
'id': video_id,
'title': title,
'formats': formats,
'description': description,
'uploader': uploader,
}
|
unlicense
|
[
3,
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1275,
2330,
492,
21298,
421,
199,
533,
13514,
13848,
554,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
4289,
2859,
14144,
391,
28287,
4537,
12841,
1618,
31331,
4537,
4391,
15,
11905,
13193,
9448,
48,
28,
344,
13489,
31,
3,
29716,
272,
15292,
63,
2339,
275,
283,
12841,
1618,
31331,
7,
339,
485,
2864,
275,
469,
267,
283,
633,
356,
283,
1014,
921,
391,
28287,
14,
12841,
1618,
31331,
14,
4391,
15,
11905,
13193,
15,
368,
13,
368,
297,
267,
283,
1064,
21,
356,
283,
27178,
66,
1651,
7984,
2720,
379,
16,
69,
966,
667,
371,
708,
2470,
19,
8488,
31990,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
368,
13,
368,
297,
288,
283,
832,
356,
283,
24798,
297,
288,
283,
1213,
356,
283,
4395,
370,
1373,
297,
288,
283,
1802,
356,
298,
3714,
337,
128,
113,
84,
17414,
366,
7,
11744,
903,
281,
1127,
22008,
477,
477,
973,
2414,
278,
1565,
10575,
793,
1873,
29934,
2414,
278,
2467,
5741,
425,
477,
406,
724,
85,
12,
1335,
69,
11199,
2521,
333,
1888,
3859,
17414,
17414,
76,
2978,
17414,
880,
6792,
2217,
26785,
5650,
8653,
12,
1335,
7,
5789,
634,
7,
262,
521,
406,
433,
414,
17414,
1127,
22008,
9832,
14262,
65,
366,
7,
28413,
18468,
625,
26881,
333,
5741,
2391,
477,
10645,
1017,
390,
5741,
299,
567,
23487,
10576,
328,
266,
21050,
4765,
288,
283,
13671,
356,
283,
52,
526,
5892,
18769,
331,
85,
128,
105,
84,
297,
267,
1660,
272,
789,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
333,
275,
295,
14,
1431,
8,
277,
423,
5600,
63,
2632,
12,
1166,
9,
267,
3991,
63,
344,
275,
333,
14,
923,
360,
344,
358,
398,
9248,
275,
291,
423,
4249,
63,
12022,
8,
633,
12,
3991,
63,
344,
9,
267,
2538,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
82,
7601,
72,
17,
13661,
6697,
15939,
72,
17,
4206,
9248,
12,
283,
1213,
358,
267,
1369,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
519,
7601,
3015,
1021,
628,
66,
2102,
63,
1606,
63,
5029,
8186,
3015,
1021,
628,
505,
1743,
17140,
15939,
3015,
4206,
288,
9248,
12,
283,
1802,
297,
14294,
29,
797,
9,
267,
25257,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
519,
7601,
3015,
1021,
628,
9365,
21608,
10758,
15337,
10758,
15337,
1574,
15337,
10758,
27,
17140,
15939,
3015,
4206,
288,
9248,
12,
283,
13671,
297,
14294,
29,
797,
9,
398,
6752,
63,
495,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
519,
7,
533,
628,
11538,
13,
74,
6147,
25153,
12469,
666,
13,
1365,
24296,
8771,
1743,
297,
288,
9248,
12,
283,
8130,
10867,
358,
267,
6752,
275,
359,
288,
469,
355,
283,
908,
63,
344,
356,
20831,
59,
16,
467,
355,
283,
633,
356,
20831,
59,
17,
467,
355,
283,
86,
9276,
356,
283,
3592,
297,
355,
283,
14994,
356,
284,
12,
288,
789,
288,
367,
284,
12,
20831,
315,
288,
3874,
8,
264,
14,
6452,
8,
82,
2,
779,
65,
13,
90,
16,
13,
25,
18096,
83,
10,
3427,
83,
10223,
7059,
21899,
3171,
401,
6752,
63,
495,
430,
267,
1622,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
372,
469,
288,
283,
344,
356,
3991,
63,
344,
12,
288,
283,
1213,
356,
2538,
12,
288,
283,
6321,
356,
6752,
12,
288,
283,
1802,
356,
1369,
12,
288,
283,
13671,
356,
25257,
12,
267,
789,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1275,
2330,
492,
21298,
421,
199,
533,
13514,
13848,
554,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
4289,
2859,
14144,
391,
28287,
4537,
12841,
1618,
31331,
4537,
4391,
15,
11905,
13193,
9448,
48,
28,
344,
13489,
31,
3,
29716,
272,
15292,
63,
2339,
275,
283,
12841,
1618,
31331,
7,
339,
485,
2864,
275,
469,
267,
283,
633,
356,
283,
1014,
921,
391,
28287,
14,
12841,
1618,
31331,
14,
4391,
15,
11905,
13193,
15,
368,
13,
368,
297,
267,
283,
1064,
21,
356,
283,
27178,
66,
1651,
7984,
2720,
379,
16,
69,
966,
667,
371,
708,
2470,
19,
8488,
31990,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
368,
13,
368,
297,
288,
283,
832,
356,
283,
24798,
297,
288,
283,
1213,
356,
283,
4395,
370,
1373,
297,
288,
283,
1802,
356,
298,
3714,
337,
128,
113,
84,
17414,
366,
7,
11744,
903,
281,
1127,
22008,
477,
477,
973,
2414,
278,
1565,
10575,
793,
1873,
29934,
2414,
278,
2467,
5741,
425,
477,
406,
724,
85,
12,
1335,
69,
11199,
2521,
333,
1888,
3859,
17414,
17414,
76,
2978,
17414,
880,
6792,
2217,
26785,
5650,
8653,
12,
1335,
7,
5789,
634,
7,
262,
521,
406,
433,
414,
17414,
1127,
22008,
9832,
14262,
65,
366,
7,
28413,
18468,
625,
26881,
333,
5741,
2391,
477,
10645,
1017,
390,
5741,
299,
567,
23487,
10576,
328,
266,
21050,
4765,
288,
283,
13671,
356,
283,
52,
526,
5892,
18769,
331,
85,
128,
105,
84,
297,
267,
1660,
272,
789,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
333,
275,
295,
14,
1431,
8,
277,
423,
5600,
63,
2632,
12,
1166,
9,
267,
3991,
63,
344,
275,
333,
14,
923,
360,
344,
358,
398,
9248,
275,
291,
423,
4249,
63,
12022,
8,
633,
12,
3991,
63,
344,
9,
267,
2538,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
82,
7601,
72,
17,
13661,
6697,
15939,
72,
17,
4206,
9248,
12,
283,
1213,
358,
267,
1369,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
519,
7601,
3015,
1021,
628,
66,
2102,
63,
1606,
63,
5029,
8186,
3015,
1021,
628,
505,
1743,
17140,
15939,
3015,
4206,
288,
9248,
12,
283,
1802,
297,
14294,
29,
797,
9,
267,
25257,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
519,
7601,
3015,
1021,
628,
9365,
21608,
10758,
15337,
10758,
15337,
1574,
15337,
10758,
27,
17140,
15939,
3015,
4206,
288,
9248,
12,
283,
13671,
297,
14294,
29,
797,
9,
398,
6752,
63,
495,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
519,
7,
533,
628,
11538,
13,
74,
6147,
25153,
12469,
666,
13,
1365,
24296,
8771,
1743,
297,
288,
9248,
12,
283,
8130,
10867,
358,
267,
6752,
275,
359,
288,
469,
355,
283,
908,
63,
344,
356,
20831,
59,
16,
467,
355,
283,
633,
356,
20831,
59,
17,
467,
355,
283,
86,
9276,
356,
283,
3592,
297,
355,
283,
14994,
356,
284,
12,
288,
789,
288,
367,
284,
12,
20831,
315,
288,
3874,
8,
264,
14,
6452,
8,
82,
2,
779,
65,
13,
90,
16,
13,
25,
18096,
83,
10,
3427,
83,
10223,
7059,
21899,
3171,
401,
6752,
63,
495,
430,
267,
1622,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
372,
469,
288,
283,
344,
356,
3991,
63,
344,
12,
288,
283,
1213,
356,
2538,
12,
288,
283,
6321,
356,
6752,
12,
288,
283,
1802,
356,
1369,
12,
288,
283,
13671,
356,
25257,
12,
267,
789,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
borysiasty/inasafe
|
safe_extras/parameters/collection_parameter.py
|
8
|
6931
|
# coding=utf-8
"""Collection Parameter abstract base class0."""
import abc
from generic_parameter import GenericParameter
from parameter_exceptions import (
CollectionLengthError, InvalidMinimumError, InvalidMaximumError)
class CollectionParameter(GenericParameter):
"""A subclass of generic parameter that accepts collections only.
This is a base class for List, Dict etc. parameters which share some
functionality.
.. versionadded:: 2.2
"""
# Indicate that this is an abstract base class
__metaclass__ = abc.ABCMeta
def __init__(self, guid=None):
"""Constructor.
:param guid: Optional unique identifier for this parameter. If none
is specified one will be generated using python hash. This guid
will be used when storing parameters in the registry.
:type guid: str
"""
super(CollectionParameter, self).__init__(guid)
self._minimum_item_count = None
self._maximum_item_count = None
self._element_type = None
@property
def minimum_item_count(self):
"""Property for minimum allowed item count."""
return self._minimum_item_count
@minimum_item_count.setter
def minimum_item_count(self, minimum_count):
"""Define the minimum number of item in the parameter.
:param minimum_count: Minimum number of items that may be
selected. Defaults to 1.
:type minimum_count: int
"""
# If maximum is not set, we can set minimum regardless
if self._maximum_item_count is None:
self._minimum_item_count = minimum_count
return
# Otherwise it must be less than maximum
if minimum_count < self._maximum_item_count:
self._minimum_item_count = minimum_count
return
self._minimum_item_count = minimum_count
raise InvalidMinimumError(
'Minimum item count must be less than maximum')
@property
def maximum_item_count(self):
"""Property for maximum allowed item count."""
return self._maximum_item_count
@maximum_item_count.setter
def maximum_item_count(self, maximum_count):
"""Define the maximum allowed number of items that can be selected.
:param maximum_count: Maximum number of items that may be selected.
Defaults to 1.
:type maximum_count: int
"""
# If maximum is not set, we can set minimum regardless
if self._maximum_item_count is None:
self._maximum_item_count = maximum_count
return
# Otherwise it must be less than maximum
if maximum_count > self._minimum_item_count:
self._maximum_item_count = maximum_count
return
raise InvalidMaximumError('Maximum must be greater than minimum')
def count(self):
"""Obtain the number of element in the list.
:returns: The number of elements.
:rtype: int
"""
return len(self._value)
@property
def element_type(self):
"""Property for the allowed type for elements in the list.
The element type determines if the list should be composed of strings,
ints, floats etc.
"""
return self._element_type
@element_type.setter
def element_type(self, element_type):
"""Define the allowed type for elements in the list.
:param element_type: The element type determines if the list should be
composed of strings, ints, floats etc.
:type element_type: string, int, float
"""
self._element_type = element_type
def check_types(self, value):
"""
Helper to check the type of the value and its elements.
:param value: The list of values set for this parameter.
:type value: str, bool, integer, float, list, dict
:raises: TypeError
"""
# Checking that the type of _value is the same as the expected _value
if not isinstance(value, self.expected_type):
message = (
'The type of the value is [%s] but a [%s] is expected.' % (
str(type(value)), str(self.expected_type)))
raise TypeError(message)
if isinstance(value, dict):
inspected_values = [value[key] for key in value.keys()]
elif isinstance(value, list):
inspected_values = value
else:
message = 'The value type is not a collection type'
raise TypeError(message)
self._check_sub_values(inspected_values)
def _check_sub_values(self, values):
for element in values:
if isinstance(element, dict) or isinstance(element, list):
self._check_sub_values(element)
elif not isinstance(element, self.element_type):
message = (
'The type of the element is [%s] but an [%s] is expected.'
% (str(type(element)), str(self.element_type)))
raise TypeError(message)
def check_length(self, value):
"""Check if the supplied container is within acceptable length limits.
:raises: CollectionLengthError
"""
if (self._maximum_item_count is None and
self._minimum_item_count is None):
return
length = len(value)
minimum = self.minimum_item_count
maximum = self.maximum_item_count
message = (
'%i elements were found in the collection%s, there should be '
'at least %i element(s) and no more than %i element(s).' %
(
length,
'' if self.name is None else ' "' + self.name + '"',
0 if minimum is None else minimum,
999 if maximum is None else maximum
))
# If maximum is not set, we can set minimum regardless
if length > maximum:
raise CollectionLengthError(message)
# Also it must not be less than minimum
if length < minimum:
raise CollectionLengthError(message)
@property
def value(self):
"""Property for value of this parameter."""
if self._value is None:
self._value = []
return self._value
@value.setter
def value(self, value):
"""Define the current value for the parameter.
Need to check the type of each element.
:param value: The collection of values set for this parameter.
:type value: dict, list
:raises: TypeError, CollectionLengthError
"""
self.check_types(value)
self.check_length(value)
self._value = value
def __len__(self):
return self.value.__len__()
def __getitem__(self, i):
return self.value[i]
def __setitem__(self, i, val):
return self.value.__setitem__(i, val)
|
gpl-3.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
199,
624,
7768,
12009,
9006,
1300,
1021,
16,
1041,
199,
646,
13022,
199,
199,
504,
7809,
63,
5329,
492,
8307,
4720,
199,
504,
2725,
63,
3924,
492,
334,
272,
18003,
4625,
547,
12,
6378,
12092,
547,
12,
6378,
10915,
547,
9,
421,
199,
533,
18003,
4720,
8,
9417,
4720,
304,
272,
408,
33,
5516,
402,
7809,
2725,
626,
11479,
5055,
1454,
14,
339,
961,
365,
282,
1300,
1021,
367,
3820,
12,
7448,
5423,
14,
2633,
1314,
8663,
2005,
272,
9330,
14,
339,
2508,
7445,
447,
499,
14,
18,
272,
408,
272,
327,
1010,
10188,
626,
642,
365,
376,
9006,
1300,
1021,
272,
636,
6577,
363,
275,
13022,
14,
22254,
339,
347,
636,
826,
721,
277,
12,
15593,
29,
403,
304,
267,
408,
11447,
14,
398,
520,
635,
15593,
26,
4879,
3747,
5148,
367,
642,
2725,
14,
982,
7179,
288,
365,
2013,
1373,
911,
506,
4046,
1808,
2366,
2631,
14,
961,
15593,
288,
911,
506,
1202,
1380,
16915,
2633,
315,
314,
7086,
14,
267,
520,
466,
15593,
26,
620,
267,
408,
267,
1613,
8,
7768,
4720,
12,
291,
2843,
826,
721,
9473,
9,
267,
291,
423,
10700,
63,
1053,
63,
835,
275,
488,
267,
291,
423,
11555,
63,
1053,
63,
835,
275,
488,
267,
291,
423,
2108,
63,
466,
275,
488,
339,
768,
1829,
272,
347,
7481,
63,
1053,
63,
835,
8,
277,
304,
267,
408,
3697,
367,
7481,
4370,
1242,
2338,
1041,
267,
372,
291,
423,
10700,
63,
1053,
63,
835,
339,
768,
10700,
63,
1053,
63,
835,
14,
8345,
272,
347,
7481,
63,
1053,
63,
835,
8,
277,
12,
7481,
63,
835,
304,
267,
408,
16213,
314,
7481,
1329,
402,
1242,
315,
314,
2725,
14,
398,
520,
635,
7481,
63,
835,
26,
22466,
1329,
402,
2974,
626,
1443,
506,
288,
4895,
14,
7827,
370,
413,
14,
267,
520,
466,
7481,
63,
835,
26,
1109,
267,
408,
267,
327,
982,
5696,
365,
440,
663,
12,
781,
883,
663,
7481,
15270,
267,
340,
291,
423,
11555,
63,
1053,
63,
835,
365,
488,
26,
288,
291,
423,
10700,
63,
1053,
63,
835,
275,
7481,
63,
835,
288,
372,
267,
327,
6630,
652,
1471,
506,
6656,
2419,
5696,
267,
340,
7481,
63,
835,
665,
291,
423,
11555,
63,
1053,
63,
835,
26,
288,
291,
423,
10700,
63,
1053,
63,
835,
275,
7481,
63,
835,
288,
372,
398,
291,
423,
10700,
63,
1053,
63,
835,
275,
7481,
63,
835,
267,
746,
6378,
12092,
547,
8,
288,
283,
12092,
1242,
2338,
1471,
506,
6656,
2419,
5696,
358,
339,
768,
1829,
272,
347,
5696,
63,
1053,
63,
835,
8,
277,
304,
267,
408,
3697,
367,
5696,
4370,
1242,
2338,
1041,
267,
372,
291,
423,
11555,
63,
1053,
63,
835,
339,
768,
11555,
63,
1053,
63,
835,
14,
8345,
272,
347,
5696,
63,
1053,
63,
835,
8,
277,
12,
5696,
63,
835,
304,
267,
408,
16213,
314,
5696,
4370,
1329,
402,
2974,
626,
883,
506,
4895,
14,
398,
520,
635,
5696,
63,
835,
26,
14212,
1329,
402,
2974,
626,
1443,
506,
4895,
14,
288,
7827,
370,
413,
14,
267,
520,
466,
5696,
63,
835,
26,
1109,
267,
408,
267,
327,
982,
5696,
365,
440,
663,
12,
781,
883,
663,
7481,
15270,
267,
340,
291,
423,
11555,
63,
1053,
63,
835,
365,
488,
26,
288,
291,
423,
11555,
63,
1053,
63,
835,
275,
5696,
63,
835,
288,
372,
267,
327,
6630,
652,
1471,
506,
6656,
2419,
5696,
267,
340,
5696,
63,
835,
690,
291,
423,
10700,
63,
1053,
63,
835,
26,
288,
291,
423,
11555,
63,
1053,
63,
835,
275,
5696,
63,
835,
288,
372,
267,
746,
6378,
10915,
547,
360,
10915,
1471,
506,
8932,
2419,
7481,
358,
339,
347,
2338,
8,
277,
304,
267,
408,
11394,
877,
314,
1329,
402,
1819,
315,
314,
769,
14,
398,
520,
5808,
26,
710,
1329,
402,
4008,
14,
267,
520,
4500,
26,
1109,
267,
408,
267,
372,
822,
8,
277,
423,
585,
9,
339,
768,
1829,
272,
347,
1819,
63,
466,
8,
277,
304,
267,
408,
3697,
367,
314,
4370,
730,
367,
4008,
315,
314,
769,
14,
398,
710,
1819,
730,
16756,
340,
314,
769,
1077,
506,
26356,
402,
3326,
12,
267,
14526,
12,
15657,
5423,
14,
398,
408,
267,
372,
291,
423,
2108,
63,
466,
339,
768,
2108,
63,
466,
14,
8345,
272,
347,
1819,
63,
466,
8,
277,
12,
1819,
63,
466,
304,
267,
408,
16213,
314,
4370,
730,
367,
4008,
315,
314,
769,
14,
398,
520,
635,
1819,
63,
466,
26,
710,
1819,
730,
16756,
340,
314,
769,
1077,
506,
288,
26356,
402,
3326,
12,
14526,
12,
15657,
5423,
14,
267,
520,
466,
1819,
63,
466,
26,
1059,
12,
1109,
12,
2069,
267,
408,
267,
291,
423,
2108,
63,
466,
275,
1819,
63,
466,
339,
347,
1104,
63,
1313,
8,
277,
12,
574,
304,
267,
408,
267,
11642,
370,
1104,
314,
730,
402,
314,
574,
436,
2399,
4008,
14,
398,
520,
635,
574,
26,
710,
769,
402,
1338,
663,
367,
642,
2725,
14,
267,
520,
466,
574,
26,
620,
12,
2155,
12,
3000,
12,
2069,
12,
769,
12,
1211,
398,
520,
3536,
26,
3146,
267,
408,
267,
327,
25109,
626,
314,
730,
402,
485,
585,
365,
314,
2011,
465,
314,
1420,
485,
585,
267,
340,
440,
1228,
8,
585,
12,
291,
14,
2062,
63,
466,
304,
288,
1245,
275,
334,
355,
283,
1918,
730,
402,
314,
574,
365,
8978,
83,
61,
1325,
282,
8978,
83,
61,
365,
1420,
3530,
450,
334,
490,
620,
8,
466,
8,
585,
1826,
620,
8,
277,
14,
2062,
63,
466,
1724,
288,
746,
3146,
8,
1188,
9,
398,
340,
1228,
8,
585,
12,
1211,
304,
288,
5261,
1043,
63,
1459,
275,
359,
585,
59,
498,
61,
367,
790,
315,
574,
14,
1612,
5106,
267,
916,
1228,
8,
585,
12,
769,
304,
288,
5261,
1043,
63,
1459,
275,
574,
267,
587,
26,
288,
1245,
275,
283,
1918,
574,
730,
365,
440,
282,
3245,
730,
7,
288,
746,
3146,
8,
1188,
9,
398,
291,
423,
1074,
63,
954,
63,
1459,
8,
3617,
1043,
63,
1459,
9,
339,
347,
485,
1074,
63,
954,
63,
1459,
8,
277,
12,
1338,
304,
267,
367,
1819,
315,
1338,
26,
288,
340,
1228,
8,
2108,
12,
1211
] |
[
2803,
29,
1624,
13,
24,
199,
199,
624,
7768,
12009,
9006,
1300,
1021,
16,
1041,
199,
646,
13022,
199,
199,
504,
7809,
63,
5329,
492,
8307,
4720,
199,
504,
2725,
63,
3924,
492,
334,
272,
18003,
4625,
547,
12,
6378,
12092,
547,
12,
6378,
10915,
547,
9,
421,
199,
533,
18003,
4720,
8,
9417,
4720,
304,
272,
408,
33,
5516,
402,
7809,
2725,
626,
11479,
5055,
1454,
14,
339,
961,
365,
282,
1300,
1021,
367,
3820,
12,
7448,
5423,
14,
2633,
1314,
8663,
2005,
272,
9330,
14,
339,
2508,
7445,
447,
499,
14,
18,
272,
408,
272,
327,
1010,
10188,
626,
642,
365,
376,
9006,
1300,
1021,
272,
636,
6577,
363,
275,
13022,
14,
22254,
339,
347,
636,
826,
721,
277,
12,
15593,
29,
403,
304,
267,
408,
11447,
14,
398,
520,
635,
15593,
26,
4879,
3747,
5148,
367,
642,
2725,
14,
982,
7179,
288,
365,
2013,
1373,
911,
506,
4046,
1808,
2366,
2631,
14,
961,
15593,
288,
911,
506,
1202,
1380,
16915,
2633,
315,
314,
7086,
14,
267,
520,
466,
15593,
26,
620,
267,
408,
267,
1613,
8,
7768,
4720,
12,
291,
2843,
826,
721,
9473,
9,
267,
291,
423,
10700,
63,
1053,
63,
835,
275,
488,
267,
291,
423,
11555,
63,
1053,
63,
835,
275,
488,
267,
291,
423,
2108,
63,
466,
275,
488,
339,
768,
1829,
272,
347,
7481,
63,
1053,
63,
835,
8,
277,
304,
267,
408,
3697,
367,
7481,
4370,
1242,
2338,
1041,
267,
372,
291,
423,
10700,
63,
1053,
63,
835,
339,
768,
10700,
63,
1053,
63,
835,
14,
8345,
272,
347,
7481,
63,
1053,
63,
835,
8,
277,
12,
7481,
63,
835,
304,
267,
408,
16213,
314,
7481,
1329,
402,
1242,
315,
314,
2725,
14,
398,
520,
635,
7481,
63,
835,
26,
22466,
1329,
402,
2974,
626,
1443,
506,
288,
4895,
14,
7827,
370,
413,
14,
267,
520,
466,
7481,
63,
835,
26,
1109,
267,
408,
267,
327,
982,
5696,
365,
440,
663,
12,
781,
883,
663,
7481,
15270,
267,
340,
291,
423,
11555,
63,
1053,
63,
835,
365,
488,
26,
288,
291,
423,
10700,
63,
1053,
63,
835,
275,
7481,
63,
835,
288,
372,
267,
327,
6630,
652,
1471,
506,
6656,
2419,
5696,
267,
340,
7481,
63,
835,
665,
291,
423,
11555,
63,
1053,
63,
835,
26,
288,
291,
423,
10700,
63,
1053,
63,
835,
275,
7481,
63,
835,
288,
372,
398,
291,
423,
10700,
63,
1053,
63,
835,
275,
7481,
63,
835,
267,
746,
6378,
12092,
547,
8,
288,
283,
12092,
1242,
2338,
1471,
506,
6656,
2419,
5696,
358,
339,
768,
1829,
272,
347,
5696,
63,
1053,
63,
835,
8,
277,
304,
267,
408,
3697,
367,
5696,
4370,
1242,
2338,
1041,
267,
372,
291,
423,
11555,
63,
1053,
63,
835,
339,
768,
11555,
63,
1053,
63,
835,
14,
8345,
272,
347,
5696,
63,
1053,
63,
835,
8,
277,
12,
5696,
63,
835,
304,
267,
408,
16213,
314,
5696,
4370,
1329,
402,
2974,
626,
883,
506,
4895,
14,
398,
520,
635,
5696,
63,
835,
26,
14212,
1329,
402,
2974,
626,
1443,
506,
4895,
14,
288,
7827,
370,
413,
14,
267,
520,
466,
5696,
63,
835,
26,
1109,
267,
408,
267,
327,
982,
5696,
365,
440,
663,
12,
781,
883,
663,
7481,
15270,
267,
340,
291,
423,
11555,
63,
1053,
63,
835,
365,
488,
26,
288,
291,
423,
11555,
63,
1053,
63,
835,
275,
5696,
63,
835,
288,
372,
267,
327,
6630,
652,
1471,
506,
6656,
2419,
5696,
267,
340,
5696,
63,
835,
690,
291,
423,
10700,
63,
1053,
63,
835,
26,
288,
291,
423,
11555,
63,
1053,
63,
835,
275,
5696,
63,
835,
288,
372,
267,
746,
6378,
10915,
547,
360,
10915,
1471,
506,
8932,
2419,
7481,
358,
339,
347,
2338,
8,
277,
304,
267,
408,
11394,
877,
314,
1329,
402,
1819,
315,
314,
769,
14,
398,
520,
5808,
26,
710,
1329,
402,
4008,
14,
267,
520,
4500,
26,
1109,
267,
408,
267,
372,
822,
8,
277,
423,
585,
9,
339,
768,
1829,
272,
347,
1819,
63,
466,
8,
277,
304,
267,
408,
3697,
367,
314,
4370,
730,
367,
4008,
315,
314,
769,
14,
398,
710,
1819,
730,
16756,
340,
314,
769,
1077,
506,
26356,
402,
3326,
12,
267,
14526,
12,
15657,
5423,
14,
398,
408,
267,
372,
291,
423,
2108,
63,
466,
339,
768,
2108,
63,
466,
14,
8345,
272,
347,
1819,
63,
466,
8,
277,
12,
1819,
63,
466,
304,
267,
408,
16213,
314,
4370,
730,
367,
4008,
315,
314,
769,
14,
398,
520,
635,
1819,
63,
466,
26,
710,
1819,
730,
16756,
340,
314,
769,
1077,
506,
288,
26356,
402,
3326,
12,
14526,
12,
15657,
5423,
14,
267,
520,
466,
1819,
63,
466,
26,
1059,
12,
1109,
12,
2069,
267,
408,
267,
291,
423,
2108,
63,
466,
275,
1819,
63,
466,
339,
347,
1104,
63,
1313,
8,
277,
12,
574,
304,
267,
408,
267,
11642,
370,
1104,
314,
730,
402,
314,
574,
436,
2399,
4008,
14,
398,
520,
635,
574,
26,
710,
769,
402,
1338,
663,
367,
642,
2725,
14,
267,
520,
466,
574,
26,
620,
12,
2155,
12,
3000,
12,
2069,
12,
769,
12,
1211,
398,
520,
3536,
26,
3146,
267,
408,
267,
327,
25109,
626,
314,
730,
402,
485,
585,
365,
314,
2011,
465,
314,
1420,
485,
585,
267,
340,
440,
1228,
8,
585,
12,
291,
14,
2062,
63,
466,
304,
288,
1245,
275,
334,
355,
283,
1918,
730,
402,
314,
574,
365,
8978,
83,
61,
1325,
282,
8978,
83,
61,
365,
1420,
3530,
450,
334,
490,
620,
8,
466,
8,
585,
1826,
620,
8,
277,
14,
2062,
63,
466,
1724,
288,
746,
3146,
8,
1188,
9,
398,
340,
1228,
8,
585,
12,
1211,
304,
288,
5261,
1043,
63,
1459,
275,
359,
585,
59,
498,
61,
367,
790,
315,
574,
14,
1612,
5106,
267,
916,
1228,
8,
585,
12,
769,
304,
288,
5261,
1043,
63,
1459,
275,
574,
267,
587,
26,
288,
1245,
275,
283,
1918,
574,
730,
365,
440,
282,
3245,
730,
7,
288,
746,
3146,
8,
1188,
9,
398,
291,
423,
1074,
63,
954,
63,
1459,
8,
3617,
1043,
63,
1459,
9,
339,
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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
] |
luisibanez/SahanaEden
|
modules/geopy/units.py
|
84
|
2311
|
import math
from geopy import util
# Angles
def degrees(radians=0, arcminutes=0, arcseconds=0):
deg = 0.
if radians:
deg = math.degrees(radians)
if arcminutes:
deg += arcminutes / arcmin(degrees=1.)
if arcseconds:
deg += arcseconds / arcsec(degrees=1.)
return deg
def radians(degrees=0, arcminutes=0, arcseconds=0):
if arcminutes:
degrees += arcminutes / arcmin(degrees=1.)
if arcseconds:
degrees += arcseconds / arcsec(degrees=1.)
return math.radians(degrees)
def arcminutes(degrees=0, radians=0, arcseconds=0):
if radians:
degrees += math.degrees(radians)
if arcseconds:
degrees += arcseconds / arcsec(degrees=1.)
return degrees * 60.
def arcseconds(degrees=0, radians=0, arcminutes=0):
if radians:
degrees += math.degrees(radians)
if arcminutes:
degrees += arcminutes / arcmin(degrees=1.)
return degrees * 3600.
rad = radians
arcmin = arcminutes
arcsec = arcseconds
# Lengths
def kilometers(meters=0, miles=0, feet=0, nautical=0):
km = 0.
if meters:
km += meters / 1000.
if feet:
miles += feet / ft(1.)
if nautical:
km += nautical / nm(1.)
km += miles * 1.609344
return km
def meters(kilometers=0, miles=0, feet=0, nautical=0):
meters = 0.
kilometers += km(nautical=nautical, miles=miles, feet=feet)
meters += kilometers * 1000.
return meters
def miles(kilometers=0, meters=0, feet=0, nautical=0):
mi = 0.
if nautical:
kilometers += nautical / nm(1.)
if feet:
mi += feet / ft(1.)
if meters:
kilometers += meters / 1000.
mi += kilometers * 0.621371192
return mi
def feet(kilometers=0, meters=0, miles=0, nautical=0):
ft = 0.
if nautical:
kilometers += nautical / nm(1.)
if meters:
kilometers += meters / 1000.
if kilometers:
miles += mi(kilometers=kilometers)
ft += miles * 5280
return ft
def nautical(kilometers=0, meters=0, miles=0, feet=0):
nm = 0.
if feet:
miles += feet / ft(1.)
if miles:
kilometers += km(miles=miles)
if meters:
kilometers += meters / 1000.
nm += kilometers / 1.852
return nm
km = kilometers
m = meters
mi = miles
ft = feet
nm = nautical
|
mit
|
[
646,
3473,
199,
504,
2312,
927,
492,
4884,
199,
199,
3,
1626,
27033,
199,
199,
318,
14358,
8,
22946,
29,
16,
12,
14972,
10430,
29,
16,
12,
14972,
4515,
29,
16,
304,
272,
7926,
275,
378,
14,
272,
340,
26874,
26,
267,
7926,
275,
3473,
14,
20251,
8,
22946,
9,
272,
340,
14972,
10430,
26,
267,
7926,
847,
14972,
10430,
1182,
14972,
827,
8,
20251,
29,
17,
4959,
272,
340,
14972,
4515,
26,
267,
7926,
847,
14972,
4515,
1182,
14972,
3321,
8,
20251,
29,
17,
4959,
272,
372,
7926,
199,
199,
318,
26874,
8,
20251,
29,
16,
12,
14972,
10430,
29,
16,
12,
14972,
4515,
29,
16,
304,
272,
340,
14972,
10430,
26,
267,
14358,
847,
14972,
10430,
1182,
14972,
827,
8,
20251,
29,
17,
4959,
272,
340,
14972,
4515,
26,
267,
14358,
847,
14972,
4515,
1182,
14972,
3321,
8,
20251,
29,
17,
4959,
272,
372,
3473,
14,
22946,
8,
20251,
9,
199,
199,
318,
14972,
10430,
8,
20251,
29,
16,
12,
26874,
29,
16,
12,
14972,
4515,
29,
16,
304,
272,
340,
26874,
26,
267,
14358,
847,
3473,
14,
20251,
8,
22946,
9,
272,
340,
14972,
4515,
26,
267,
14358,
847,
14972,
4515,
1182,
14972,
3321,
8,
20251,
29,
17,
4959,
272,
372,
14358,
627,
5212,
14,
199,
199,
318,
14972,
4515,
8,
20251,
29,
16,
12,
26874,
29,
16,
12,
14972,
10430,
29,
16,
304,
272,
340,
26874,
26,
267,
14358,
847,
3473,
14,
20251,
8,
22946,
9,
272,
340,
14972,
10430,
26,
267,
14358,
847,
14972,
10430,
1182,
14972,
827,
8,
20251,
29,
17,
4959,
272,
372,
14358,
627,
15751,
14,
199,
199,
9525,
275,
26874,
199,
9912,
827,
275,
14972,
10430,
199,
9912,
3321,
275,
14972,
4515,
199,
199,
3,
19893,
83,
199,
199,
318,
1022,
11737,
20893,
8,
20893,
29,
16,
12,
333,
22894,
29,
16,
12,
1964,
386,
29,
16,
12,
302,
3844,
3294,
29,
16,
304,
272,
16155,
275,
378,
14,
272,
340,
24808,
26,
267,
16155,
847,
24808,
1182,
5198,
14,
272,
340,
1964,
386,
26,
267,
333,
22894,
847,
1964,
386,
1182,
18133,
8,
17,
4959,
272,
340,
302,
3844,
3294,
26,
267,
16155,
847,
302,
3844,
3294,
1182,
16751,
8,
17,
4959,
272,
16155,
847,
333,
22894,
627,
413,
14,
14520,
10875,
272,
372,
16155,
199,
199,
318,
24808,
8,
8810,
320,
20893,
29,
16,
12,
333,
22894,
29,
16,
12,
1964,
386,
29,
16,
12,
302,
3844,
3294,
29,
16,
304,
272,
24808,
275,
378,
14,
272,
1022,
11737,
20893,
847,
16155,
8,
3540,
85,
3294,
29,
3540,
85,
3294,
12,
333,
22894,
29,
77,
22894,
12,
1964,
386,
29,
771,
386,
9,
272,
24808,
847,
1022,
11737,
20893,
627,
5198,
14,
272,
372,
24808,
199,
199,
318,
333,
22894,
8,
8810,
320,
20893,
29,
16,
12,
24808,
29,
16,
12,
1964,
386,
29,
16,
12,
302,
3844,
3294,
29,
16,
304,
272,
10684,
275,
378,
14,
272,
340,
302,
3844,
3294,
26,
267,
1022,
11737,
20893,
847,
302,
3844,
3294,
1182,
16751,
8,
17,
4959,
272,
340,
1964,
386,
26,
267,
10684,
847,
1964,
386,
1182,
18133,
8,
17,
4959,
272,
340,
24808,
26,
267,
1022,
11737,
20893,
847,
24808,
1182,
5198,
14,
272,
10684,
847,
1022,
11737,
20893,
627,
378,
14,
2789,
7498,
845,
2942,
272,
372,
10684,
199,
199,
318,
1964,
386,
8,
8810,
320,
20893,
29,
16,
12,
24808,
29,
16,
12,
333,
22894,
29,
16,
12,
302,
3844,
3294,
29,
16,
304,
272,
18133,
275,
378,
14,
272,
340,
302,
3844,
3294,
26,
267,
1022,
11737,
20893,
847,
302,
3844,
3294,
1182,
16751,
8,
17,
4959,
272,
340,
24808,
26,
267,
1022,
11737,
20893,
847,
24808,
1182,
5198,
14,
272,
340,
1022,
11737,
20893,
26,
267,
333,
22894,
847,
10684,
8,
8810,
320,
20893,
29,
8810,
320,
20893,
9,
272,
18133,
847,
333,
22894,
627,
14589,
1257,
272,
372,
18133,
199,
199,
318,
302,
3844,
3294,
8,
8810,
320,
20893,
29,
16,
12,
24808,
29,
16,
12,
333,
22894,
29,
16,
12,
1964,
386,
29,
16,
304,
272,
16751,
275,
378,
14,
272,
340,
1964,
386,
26,
267,
333,
22894,
847,
1964,
386,
1182,
18133,
8,
17,
4959,
272,
340,
333,
22894,
26,
267,
1022,
11737,
20893,
847,
16155,
8,
77,
22894,
29,
77,
22894,
9,
272,
340,
24808,
26,
267,
1022,
11737,
20893,
847,
24808,
1182,
5198,
14,
272,
16751,
847,
1022,
11737,
20893,
1182,
413,
14,
22719,
272,
372,
16751,
199,
199,
14595,
275,
1022,
11737,
20893,
199,
77,
275,
24808,
199,
2664,
275,
333,
22894,
199,
856,
275,
1964,
386,
199,
10756,
275,
302,
3844,
3294,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
3473,
199,
504,
2312,
927,
492,
4884,
199,
199,
3,
1626,
27033,
199,
199,
318,
14358,
8,
22946,
29,
16,
12,
14972,
10430,
29,
16,
12,
14972,
4515,
29,
16,
304,
272,
7926,
275,
378,
14,
272,
340,
26874,
26,
267,
7926,
275,
3473,
14,
20251,
8,
22946,
9,
272,
340,
14972,
10430,
26,
267,
7926,
847,
14972,
10430,
1182,
14972,
827,
8,
20251,
29,
17,
4959,
272,
340,
14972,
4515,
26,
267,
7926,
847,
14972,
4515,
1182,
14972,
3321,
8,
20251,
29,
17,
4959,
272,
372,
7926,
199,
199,
318,
26874,
8,
20251,
29,
16,
12,
14972,
10430,
29,
16,
12,
14972,
4515,
29,
16,
304,
272,
340,
14972,
10430,
26,
267,
14358,
847,
14972,
10430,
1182,
14972,
827,
8,
20251,
29,
17,
4959,
272,
340,
14972,
4515,
26,
267,
14358,
847,
14972,
4515,
1182,
14972,
3321,
8,
20251,
29,
17,
4959,
272,
372,
3473,
14,
22946,
8,
20251,
9,
199,
199,
318,
14972,
10430,
8,
20251,
29,
16,
12,
26874,
29,
16,
12,
14972,
4515,
29,
16,
304,
272,
340,
26874,
26,
267,
14358,
847,
3473,
14,
20251,
8,
22946,
9,
272,
340,
14972,
4515,
26,
267,
14358,
847,
14972,
4515,
1182,
14972,
3321,
8,
20251,
29,
17,
4959,
272,
372,
14358,
627,
5212,
14,
199,
199,
318,
14972,
4515,
8,
20251,
29,
16,
12,
26874,
29,
16,
12,
14972,
10430,
29,
16,
304,
272,
340,
26874,
26,
267,
14358,
847,
3473,
14,
20251,
8,
22946,
9,
272,
340,
14972,
10430,
26,
267,
14358,
847,
14972,
10430,
1182,
14972,
827,
8,
20251,
29,
17,
4959,
272,
372,
14358,
627,
15751,
14,
199,
199,
9525,
275,
26874,
199,
9912,
827,
275,
14972,
10430,
199,
9912,
3321,
275,
14972,
4515,
199,
199,
3,
19893,
83,
199,
199,
318,
1022,
11737,
20893,
8,
20893,
29,
16,
12,
333,
22894,
29,
16,
12,
1964,
386,
29,
16,
12,
302,
3844,
3294,
29,
16,
304,
272,
16155,
275,
378,
14,
272,
340,
24808,
26,
267,
16155,
847,
24808,
1182,
5198,
14,
272,
340,
1964,
386,
26,
267,
333,
22894,
847,
1964,
386,
1182,
18133,
8,
17,
4959,
272,
340,
302,
3844,
3294,
26,
267,
16155,
847,
302,
3844,
3294,
1182,
16751,
8,
17,
4959,
272,
16155,
847,
333,
22894,
627,
413,
14,
14520,
10875,
272,
372,
16155,
199,
199,
318,
24808,
8,
8810,
320,
20893,
29,
16,
12,
333,
22894,
29,
16,
12,
1964,
386,
29,
16,
12,
302,
3844,
3294,
29,
16,
304,
272,
24808,
275,
378,
14,
272,
1022,
11737,
20893,
847,
16155,
8,
3540,
85,
3294,
29,
3540,
85,
3294,
12,
333,
22894,
29,
77,
22894,
12,
1964,
386,
29,
771,
386,
9,
272,
24808,
847,
1022,
11737,
20893,
627,
5198,
14,
272,
372,
24808,
199,
199,
318,
333,
22894,
8,
8810,
320,
20893,
29,
16,
12,
24808,
29,
16,
12,
1964,
386,
29,
16,
12,
302,
3844,
3294,
29,
16,
304,
272,
10684,
275,
378,
14,
272,
340,
302,
3844,
3294,
26,
267,
1022,
11737,
20893,
847,
302,
3844,
3294,
1182,
16751,
8,
17,
4959,
272,
340,
1964,
386,
26,
267,
10684,
847,
1964,
386,
1182,
18133,
8,
17,
4959,
272,
340,
24808,
26,
267,
1022,
11737,
20893,
847,
24808,
1182,
5198,
14,
272,
10684,
847,
1022,
11737,
20893,
627,
378,
14,
2789,
7498,
845,
2942,
272,
372,
10684,
199,
199,
318,
1964,
386,
8,
8810,
320,
20893,
29,
16,
12,
24808,
29,
16,
12,
333,
22894,
29,
16,
12,
302,
3844,
3294,
29,
16,
304,
272,
18133,
275,
378,
14,
272,
340,
302,
3844,
3294,
26,
267,
1022,
11737,
20893,
847,
302,
3844,
3294,
1182,
16751,
8,
17,
4959,
272,
340,
24808,
26,
267,
1022,
11737,
20893,
847,
24808,
1182,
5198,
14,
272,
340,
1022,
11737,
20893,
26,
267,
333,
22894,
847,
10684,
8,
8810,
320,
20893,
29,
8810,
320,
20893,
9,
272,
18133,
847,
333,
22894,
627,
14589,
1257,
272,
372,
18133,
199,
199,
318,
302,
3844,
3294,
8,
8810,
320,
20893,
29,
16,
12,
24808,
29,
16,
12,
333,
22894,
29,
16,
12,
1964,
386,
29,
16,
304,
272,
16751,
275,
378,
14,
272,
340,
1964,
386,
26,
267,
333,
22894,
847,
1964,
386,
1182,
18133,
8,
17,
4959,
272,
340,
333,
22894,
26,
267,
1022,
11737,
20893,
847,
16155,
8,
77,
22894,
29,
77,
22894,
9,
272,
340,
24808,
26,
267,
1022,
11737,
20893,
847,
24808,
1182,
5198,
14,
272,
16751,
847,
1022,
11737,
20893,
1182,
413,
14,
22719,
272,
372,
16751,
199,
199,
14595,
275,
1022,
11737,
20893,
199,
77,
275,
24808,
199,
2664,
275,
333,
22894,
199,
856,
275,
1964,
386,
199,
10756,
275,
302,
3844,
3294,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
archilogic-ch/three.js
|
utils/exporters/blender/addons/io_three/exporter/api/animation.py
|
177
|
16103
|
"""
Module for handling the parsing of skeletal animation data.
"""
import math
import mathutils
from bpy import data, context
from .. import constants, logger
def pose_animation(armature, options):
"""Query armature animation using pose bones
:param armature:
:param options:
:returns: list dictionaries containing animationdata
:rtype: [{}, {}, ...]
"""
logger.debug("animation.pose_animation(%s)", armature)
func = _parse_pose_action
return _parse_action(func, armature, options)
def rest_animation(armature, options):
"""Query armature animation (REST position)
:param armature:
:param options:
:returns: list dictionaries containing animationdata
:rtype: [{}, {}, ...]
"""
logger.debug("animation.rest_animation(%s)", armature)
func = _parse_rest_action
return _parse_action(func, armature, options)
def _parse_action(func, armature, options):
"""
:param func:
:param armature:
:param options:
"""
animations = []
logger.info("Parsing %d actions", len(data.actions))
for action in data.actions:
logger.info("Parsing action %s", action.name)
animation = func(action, armature, options)
animations.append(animation)
return animations
def _parse_rest_action(action, armature, options):
"""
:param action:
:param armature:
:param options:
"""
end_frame = action.frame_range[1]
start_frame = action.frame_range[0]
frame_length = end_frame - start_frame
rot = armature.matrix_world.decompose()[1]
rotation_matrix = rot.to_matrix()
hierarchy = []
parent_index = -1
frame_step = options.get(constants.FRAME_STEP, 1)
fps = context.scene.render.fps
start = int(start_frame)
end = int(end_frame / frame_step) + 1
for bone in armature.data.bones:
# I believe this was meant to skip control bones, may
# not be useful. needs more testing
if bone.use_deform is False:
logger.info("Skipping animation data for bone %s", bone.name)
continue
logger.info("Parsing animation data for bone %s", bone.name)
keys = []
for frame in range(start, end):
computed_frame = frame * frame_step
pos, pchange = _position(bone, computed_frame,
action, armature.matrix_world)
rot, rchange = _rotation(bone, computed_frame,
action, rotation_matrix)
rot = _normalize_quaternion(rot)
pos_x, pos_y, pos_z = pos.x, pos.z, -pos.y
rot_x, rot_y, rot_z, rot_w = rot.x, rot.z, -rot.y, rot.w
if frame == start_frame:
time = (frame * frame_step - start_frame) / fps
# @TODO: missing scale values
keyframe = {
constants.TIME: time,
constants.POS: [pos_x, pos_y, pos_z],
constants.ROT: [rot_x, rot_y, rot_z, rot_w],
constants.SCL: [1, 1, 1]
}
keys.append(keyframe)
# END-FRAME: needs pos, rot and scl attributes
# with animation length (required frame)
elif frame == end_frame / frame_step:
time = frame_length / fps
keyframe = {
constants.TIME: time,
constants.POS: [pos_x, pos_y, pos_z],
constants.ROT: [rot_x, rot_y, rot_z, rot_w],
constants.SCL: [1, 1, 1]
}
keys.append(keyframe)
# MIDDLE-FRAME: needs only one of the attributes,
# can be an empty frame (optional frame)
elif pchange is True or rchange is True:
time = (frame * frame_step - start_frame) / fps
if pchange is True and rchange is True:
keyframe = {
constants.TIME: time,
constants.POS: [pos_x, pos_y, pos_z],
constants.ROT: [rot_x, rot_y, rot_z, rot_w]
}
elif pchange is True:
keyframe = {
constants.TIME: time,
constants.POS: [pos_x, pos_y, pos_z]
}
elif rchange is True:
keyframe = {
constants.TIME: time,
constants.ROT: [rot_x, rot_y, rot_z, rot_w]
}
keys.append(keyframe)
hierarchy.append({
constants.KEYS: keys,
constants.PARENT: parent_index
})
parent_index += 1
animation = {
constants.HIERARCHY: hierarchy,
constants.LENGTH: frame_length / fps,
constants.FPS: fps,
constants.NAME: action.name
}
return animation
def _parse_pose_action(action, armature, options):
"""
:param action:
:param armature:
:param options:
"""
# @TODO: this seems to fail in batch mode meaning the
# user has to have th GUI open. need to improve
# this logic to allow batch processing, if Blender
# chooses to behave....
current_context = context.area.type
context.area.type = 'DOPESHEET_EDITOR'
context.space_data.mode = 'ACTION'
context.area.spaces.active.action = action
armature_matrix = armature.matrix_world
fps = context.scene.render.fps
end_frame = action.frame_range[1]
start_frame = action.frame_range[0]
frame_length = end_frame - start_frame
frame_step = options.get(constants.FRAME_STEP, 1)
used_frames = int(frame_length / frame_step) + 1
keys = []
channels_location = []
channels_rotation = []
channels_scale = []
for pose_bone in armature.pose.bones:
logger.info("Processing channels for %s",
pose_bone.bone.name)
keys.append([])
channels_location.append(
_find_channels(action,
pose_bone.bone,
'location'))
channels_rotation.append(
_find_channels(action,
pose_bone.bone,
'rotation_quaternion'))
channels_rotation.append(
_find_channels(action,
pose_bone.bone,
'rotation_euler'))
channels_scale.append(
_find_channels(action,
pose_bone.bone,
'scale'))
frame_step = options[constants.FRAME_STEP]
frame_index_as_time = options[constants.FRAME_INDEX_AS_TIME]
for frame_index in range(0, used_frames):
if frame_index == used_frames - 1:
frame = end_frame
else:
frame = start_frame + frame_index * frame_step
logger.info("Processing frame %d", frame)
time = frame - start_frame
if frame_index_as_time is False:
time = time / fps
context.scene.frame_set(frame)
bone_index = 0
def has_keyframe_at(channels, frame):
"""
:param channels:
:param frame:
"""
def find_keyframe_at(channel, frame):
"""
:param channel:
:param frame:
"""
for keyframe in channel.keyframe_points:
if keyframe.co[0] == frame:
return keyframe
return None
for channel in channels:
if not find_keyframe_at(channel, frame) is None:
return True
return False
for pose_bone in armature.pose.bones:
logger.info("Processing bone %s", pose_bone.bone.name)
if pose_bone.parent is None:
bone_matrix = armature_matrix * pose_bone.matrix
else:
parent_matrix = armature_matrix * pose_bone.parent.matrix
bone_matrix = armature_matrix * pose_bone.matrix
bone_matrix = parent_matrix.inverted() * bone_matrix
pos, rot, scl = bone_matrix.decompose()
rot = _normalize_quaternion(rot)
pchange = True or has_keyframe_at(
channels_location[bone_index], frame)
rchange = True or has_keyframe_at(
channels_rotation[bone_index], frame)
schange = True or has_keyframe_at(
channels_scale[bone_index], frame)
pos = (pos.x, pos.z, -pos.y)
rot = (rot.x, rot.z, -rot.y, rot.w)
scl = (scl.x, scl.z, scl.y)
keyframe = {constants.TIME: time}
if frame == start_frame or frame == end_frame:
keyframe.update({
constants.POS: pos,
constants.ROT: rot,
constants.SCL: scl
})
elif any([pchange, rchange, schange]):
if pchange is True:
keyframe[constants.POS] = pos
if rchange is True:
keyframe[constants.ROT] = rot
if schange is True:
keyframe[constants.SCL] = scl
if len(keyframe.keys()) > 1:
logger.info("Recording keyframe data for %s %s",
pose_bone.bone.name, str(keyframe))
keys[bone_index].append(keyframe)
else:
logger.info("No anim data to record for %s",
pose_bone.bone.name)
bone_index += 1
hierarchy = []
bone_index = 0
for pose_bone in armature.pose.bones:
hierarchy.append({
constants.PARENT: bone_index - 1,
constants.KEYS: keys[bone_index]
})
bone_index += 1
if frame_index_as_time is False:
frame_length = frame_length / fps
context.scene.frame_set(start_frame)
context.area.type = current_context
animation = {
constants.HIERARCHY: hierarchy,
constants.LENGTH: frame_length,
constants.FPS: fps,
constants.NAME: action.name
}
return animation
def _find_channels(action, bone, channel_type):
"""
:param action:
:param bone:
:param channel_type:
"""
result = []
if len(action.groups):
group_index = -1
for index, group in enumerate(action.groups):
if group.name == bone.name:
group_index = index
# @TODO: break?
if group_index > -1:
for channel in action.groups[group_index].channels:
if channel_type in channel.data_path:
result.append(channel)
else:
bone_label = '"%s"' % bone.name
for channel in action.fcurves:
data_path = [bone_label in channel.data_path,
channel_type in channel.data_path]
if all(data_path):
result.append(channel)
return result
def _position(bone, frame, action, armature_matrix):
"""
:param bone:
:param frame:
:param action:
:param armature_matrix:
"""
position = mathutils.Vector((0, 0, 0))
change = False
ngroups = len(action.groups)
if ngroups > 0:
index = 0
for i in range(ngroups):
if action.groups[i].name == bone.name:
index = i
for channel in action.groups[index].channels:
if "location" in channel.data_path:
has_changed = _handle_position_channel(
channel, frame, position)
change = change or has_changed
else:
bone_label = '"%s"' % bone.name
for channel in action.fcurves:
data_path = channel.data_path
if bone_label in data_path and "location" in data_path:
has_changed = _handle_position_channel(
channel, frame, position)
change = change or has_changed
position = position * bone.matrix_local.inverted()
if bone.parent is None:
position.x += bone.head.x
position.y += bone.head.y
position.z += bone.head.z
else:
parent = bone.parent
parent_matrix = parent.matrix_local.inverted()
diff = parent.tail_local - parent.head_local
position.x += (bone.head * parent_matrix).x + diff.x
position.y += (bone.head * parent_matrix).y + diff.y
position.z += (bone.head * parent_matrix).z + diff.z
return armature_matrix*position, change
def _rotation(bone, frame, action, armature_matrix):
"""
:param bone:
:param frame:
:param action:
:param armature_matrix:
"""
# TODO: calculate rotation also from rotation_euler channels
rotation = mathutils.Vector((0, 0, 0, 1))
change = False
ngroups = len(action.groups)
# animation grouped by bones
if ngroups > 0:
index = -1
for i in range(ngroups):
if action.groups[i].name == bone.name:
index = i
if index > -1:
for channel in action.groups[index].channels:
if "quaternion" in channel.data_path:
has_changed = _handle_rotation_channel(
channel, frame, rotation)
change = change or has_changed
# animation in raw fcurves
else:
bone_label = '"%s"' % bone.name
for channel in action.fcurves:
data_path = channel.data_path
if bone_label in data_path and "quaternion" in data_path:
has_changed = _handle_rotation_channel(
channel, frame, rotation)
change = change or has_changed
rot3 = rotation.to_3d()
rotation.xyz = rot3 * bone.matrix_local.inverted()
rotation.xyz = armature_matrix * rotation.xyz
return rotation, change
def _handle_rotation_channel(channel, frame, rotation):
"""
:param channel:
:param frame:
:param rotation:
"""
change = False
if channel.array_index in [0, 1, 2, 3]:
for keyframe in channel.keyframe_points:
if keyframe.co[0] == frame:
change = True
value = channel.evaluate(frame)
if channel.array_index == 1:
rotation.x = value
elif channel.array_index == 2:
rotation.y = value
elif channel.array_index == 3:
rotation.z = value
elif channel.array_index == 0:
rotation.w = value
return change
def _handle_position_channel(channel, frame, position):
"""
:param channel:
:param frame:
:param position:
"""
change = False
if channel.array_index in [0, 1, 2]:
for keyframe in channel.keyframe_points:
if keyframe.co[0] == frame:
change = True
value = channel.evaluate(frame)
if channel.array_index == 0:
position.x = value
if channel.array_index == 1:
position.y = value
if channel.array_index == 2:
position.z = value
return change
def _quaternion_length(quat):
"""Calculate the length of a quaternion
:param quat: Blender quaternion object
:rtype: float
"""
return math.sqrt(quat.x * quat.x + quat.y * quat.y +
quat.z * quat.z + quat.w * quat.w)
def _normalize_quaternion(quat):
"""Normalize a quaternion
:param quat: Blender quaternion object
:returns: generic quaternion enum object with normalized values
:rtype: object
"""
enum = type('Enum', (), {'x': 0, 'y': 0, 'z': 0, 'w': 1})
length = _quaternion_length(quat)
if length is not 0:
length = 1 / length
enum.x = quat.x * length
enum.y = quat.y * length
enum.z = quat.z * length
enum.w = quat.w * length
return enum
|
mit
|
[
624,
199,
2377,
367,
7252,
314,
6057,
402,
18380,
2723,
279,
24154,
666,
14,
199,
624,
199,
199,
646,
3473,
199,
646,
3473,
1208,
199,
504,
20575,
492,
666,
12,
1067,
199,
504,
2508,
492,
5262,
12,
2512,
421,
199,
318,
1115,
261,
63,
22228,
8,
285,
19925,
12,
1511,
304,
272,
408,
3227,
601,
19925,
24154,
1808,
1115,
261,
330,
4548,
339,
520,
635,
601,
19925,
26,
272,
520,
635,
1511,
26,
272,
520,
5808,
26,
769,
11196,
3035,
24154,
576,
272,
520,
4500,
26,
8910,
1386,
5479,
21214,
339,
408,
272,
2512,
14,
1757,
480,
22228,
14,
4070,
63,
22228,
4042,
83,
4186,
601,
19925,
9,
272,
2562,
275,
485,
1122,
63,
4070,
63,
1287,
272,
372,
485,
1122,
63,
1287,
8,
1532,
12,
601,
19925,
12,
1511,
9,
421,
199,
318,
4618,
63,
22228,
8,
285,
19925,
12,
1511,
304,
272,
408,
3227,
601,
19925,
24154,
334,
15740,
3421,
9,
339,
520,
635,
601,
19925,
26,
272,
520,
635,
1511,
26,
272,
520,
5808,
26,
769,
11196,
3035,
24154,
576,
272,
520,
4500,
26,
8910,
1386,
5479,
21214,
339,
408,
272,
2512,
14,
1757,
480,
22228,
14,
3911,
63,
22228,
4042,
83,
4186,
601,
19925,
9,
272,
2562,
275,
485,
1122,
63,
3911,
63,
1287,
272,
372,
485,
1122,
63,
1287,
8,
1532,
12,
601,
19925,
12,
1511,
9,
421,
199,
318,
485,
1122,
63,
1287,
8,
1532,
12,
601,
19925,
12,
1511,
304,
272,
408,
339,
520,
635,
2562,
26,
272,
520,
635,
601,
19925,
26,
272,
520,
635,
1511,
26,
339,
408,
272,
376,
11744,
852,
275,
942,
272,
2512,
14,
815,
480,
17412,
450,
68,
5445,
401,
822,
8,
576,
14,
3723,
430,
272,
367,
1595,
315,
666,
14,
3723,
26,
267,
2512,
14,
815,
480,
17412,
1595,
450,
83,
401,
1595,
14,
354,
9,
267,
24154,
275,
2562,
8,
1287,
12,
601,
19925,
12,
1511,
9,
267,
376,
11744,
852,
14,
740,
8,
22228,
9,
272,
372,
376,
11744,
852,
421,
199,
318,
485,
1122,
63,
3911,
63,
1287,
8,
1287,
12,
601,
19925,
12,
1511,
304,
272,
408,
339,
520,
635,
1595,
26,
272,
520,
635,
601,
19925,
26,
272,
520,
635,
1511,
26,
339,
408,
272,
1284,
63,
1943,
275,
1595,
14,
1943,
63,
1842,
59,
17,
61,
272,
1343,
63,
1943,
275,
1595,
14,
1943,
63,
1842,
59,
16,
61,
272,
2787,
63,
1267,
275,
1284,
63,
1943,
446,
1343,
63,
1943,
272,
7513,
275,
601,
19925,
14,
3642,
63,
7617,
14,
271,
12607,
3430,
17,
61,
272,
13038,
63,
3642,
275,
7513,
14,
475,
63,
3642,
342,
272,
14446,
275,
942,
272,
1676,
63,
1080,
275,
446,
17,
272,
2787,
63,
2926,
275,
1511,
14,
362,
8,
5559,
14,
12683,
63,
17988,
12,
413,
9,
272,
289,
1190,
275,
1067,
14,
10436,
14,
3352,
14,
24709,
339,
1343,
275,
1109,
8,
928,
63,
1943,
9,
272,
1284,
275,
1109,
8,
500,
63,
1943,
1182,
2787,
63,
2926,
9,
435,
413,
339,
367,
28120,
315,
601,
19925,
14,
576,
14,
66,
4548,
26,
267,
327,
473,
506,
317,
4754,
642,
1990,
18329,
370,
3372,
3304,
330,
4548,
12,
1443,
267,
327,
440,
506,
2997,
14,
4839,
1655,
5343,
267,
340,
28120,
14,
1180,
63,
318,
1025,
365,
756,
26,
288,
2512,
14,
815,
480,
18297,
24154,
666,
367,
28120,
450,
83,
401,
28120,
14,
354,
9,
288,
1980,
398,
2512,
14,
815,
480,
17412,
24154,
666,
367,
28120,
450,
83,
401,
28120,
14,
354,
9,
398,
2883,
275,
942,
267,
367,
2787,
315,
1425,
8,
928,
12,
1284,
304,
288,
9235,
63,
1943,
275,
2787,
627,
2787,
63,
2926,
288,
2086,
12,
299,
1461,
275,
485,
3124,
8,
21134,
12,
9235,
63,
1943,
12,
3660,
1595,
12,
601,
19925,
14,
3642,
63,
7617,
9,
288,
7513,
12,
519,
1461,
275,
485,
15362,
8,
21134,
12,
9235,
63,
1943,
12,
3660,
1595,
12,
13038,
63,
3642,
9,
288,
7513,
275,
485,
7721,
63,
392,
28945,
8,
4571,
9,
953,
2086,
63,
88,
12,
2086,
63,
89,
12,
2086,
63,
90,
275,
2086,
14,
88,
12,
2086,
14,
90,
12,
446,
1712,
14,
89,
288,
7513,
63,
88,
12,
7513,
63,
89,
12,
7513,
63,
90,
12,
7513,
63,
87,
275,
7513,
14,
88,
12,
7513,
14,
90,
12,
446,
4571,
14,
89,
12,
7513,
14,
87,
953,
340,
2787,
508,
1343,
63,
1943,
26,
2234,
900,
275,
334,
1943,
627,
2787,
63,
2926,
446,
1343,
63,
1943,
9,
1182,
289,
1190,
355,
327,
768,
11768,
26,
4124,
4666,
1338,
355,
790,
1943,
275,
469,
490,
5262,
14,
4961,
26,
900,
12,
490,
5262,
14,
9263,
26,
359,
1712,
63,
88,
12,
2086,
63,
89,
12,
2086,
63,
90,
467,
490,
5262,
14,
31075,
26,
359,
4571,
63,
88,
12,
7513,
63,
89,
12,
7513,
63,
90,
12,
7513,
63,
87,
467,
490,
5262,
14,
51,
1981,
26,
359,
17,
12,
413,
12,
413,
61,
355,
789,
355,
2883,
14,
740,
8,
498,
1943,
9,
953,
327,
7729,
13,
12683,
26,
4839,
2086,
12,
7513,
436,
29794,
3004,
288,
327,
543,
24154,
2582,
334,
2427,
2787,
9,
953,
916,
2787,
508,
1284,
63,
1943,
1182,
2787,
63,
2926,
26,
2234,
900,
275,
2787,
63,
1267,
1182,
289,
1190,
355,
790,
1943,
275,
469,
490,
5262,
14,
4961,
26,
900,
12,
490,
5262,
14,
9263,
26,
359,
1712,
63,
88,
12,
2086,
63,
89,
12,
2086,
63,
90,
467,
490,
5262,
14,
31075,
26,
359,
4571,
63,
88,
12,
7513,
63,
89,
12,
7513,
63,
90,
12,
7513,
63,
87,
467,
490,
5262,
14,
51,
1981,
26,
359,
17,
12,
413,
12,
413,
61,
355,
789,
355,
2883,
14,
740,
8,
498,
1943,
9,
953,
327,
30041,
13,
12683,
26,
4839,
1454,
1373,
402,
314,
3004,
12,
288,
327,
883,
506,
376,
2701,
2787,
334,
4144,
2787,
9,
953,
916,
299,
1461,
365,
715,
503,
519,
1461,
365,
715,
26,
2234,
900,
275,
334,
1943,
627,
2787,
63,
2926,
446,
1343,
63,
1943,
9,
1182,
289,
1190,
2234,
340,
299,
1461,
365,
715,
436,
519,
1461,
365,
715,
26,
490,
790,
1943,
275,
469,
717,
5262,
14,
4961,
26,
900,
12,
717,
5262,
14,
9263,
26,
359
] |
[
199,
2377,
367,
7252,
314,
6057,
402,
18380,
2723,
279,
24154,
666,
14,
199,
624,
199,
199,
646,
3473,
199,
646,
3473,
1208,
199,
504,
20575,
492,
666,
12,
1067,
199,
504,
2508,
492,
5262,
12,
2512,
421,
199,
318,
1115,
261,
63,
22228,
8,
285,
19925,
12,
1511,
304,
272,
408,
3227,
601,
19925,
24154,
1808,
1115,
261,
330,
4548,
339,
520,
635,
601,
19925,
26,
272,
520,
635,
1511,
26,
272,
520,
5808,
26,
769,
11196,
3035,
24154,
576,
272,
520,
4500,
26,
8910,
1386,
5479,
21214,
339,
408,
272,
2512,
14,
1757,
480,
22228,
14,
4070,
63,
22228,
4042,
83,
4186,
601,
19925,
9,
272,
2562,
275,
485,
1122,
63,
4070,
63,
1287,
272,
372,
485,
1122,
63,
1287,
8,
1532,
12,
601,
19925,
12,
1511,
9,
421,
199,
318,
4618,
63,
22228,
8,
285,
19925,
12,
1511,
304,
272,
408,
3227,
601,
19925,
24154,
334,
15740,
3421,
9,
339,
520,
635,
601,
19925,
26,
272,
520,
635,
1511,
26,
272,
520,
5808,
26,
769,
11196,
3035,
24154,
576,
272,
520,
4500,
26,
8910,
1386,
5479,
21214,
339,
408,
272,
2512,
14,
1757,
480,
22228,
14,
3911,
63,
22228,
4042,
83,
4186,
601,
19925,
9,
272,
2562,
275,
485,
1122,
63,
3911,
63,
1287,
272,
372,
485,
1122,
63,
1287,
8,
1532,
12,
601,
19925,
12,
1511,
9,
421,
199,
318,
485,
1122,
63,
1287,
8,
1532,
12,
601,
19925,
12,
1511,
304,
272,
408,
339,
520,
635,
2562,
26,
272,
520,
635,
601,
19925,
26,
272,
520,
635,
1511,
26,
339,
408,
272,
376,
11744,
852,
275,
942,
272,
2512,
14,
815,
480,
17412,
450,
68,
5445,
401,
822,
8,
576,
14,
3723,
430,
272,
367,
1595,
315,
666,
14,
3723,
26,
267,
2512,
14,
815,
480,
17412,
1595,
450,
83,
401,
1595,
14,
354,
9,
267,
24154,
275,
2562,
8,
1287,
12,
601,
19925,
12,
1511,
9,
267,
376,
11744,
852,
14,
740,
8,
22228,
9,
272,
372,
376,
11744,
852,
421,
199,
318,
485,
1122,
63,
3911,
63,
1287,
8,
1287,
12,
601,
19925,
12,
1511,
304,
272,
408,
339,
520,
635,
1595,
26,
272,
520,
635,
601,
19925,
26,
272,
520,
635,
1511,
26,
339,
408,
272,
1284,
63,
1943,
275,
1595,
14,
1943,
63,
1842,
59,
17,
61,
272,
1343,
63,
1943,
275,
1595,
14,
1943,
63,
1842,
59,
16,
61,
272,
2787,
63,
1267,
275,
1284,
63,
1943,
446,
1343,
63,
1943,
272,
7513,
275,
601,
19925,
14,
3642,
63,
7617,
14,
271,
12607,
3430,
17,
61,
272,
13038,
63,
3642,
275,
7513,
14,
475,
63,
3642,
342,
272,
14446,
275,
942,
272,
1676,
63,
1080,
275,
446,
17,
272,
2787,
63,
2926,
275,
1511,
14,
362,
8,
5559,
14,
12683,
63,
17988,
12,
413,
9,
272,
289,
1190,
275,
1067,
14,
10436,
14,
3352,
14,
24709,
339,
1343,
275,
1109,
8,
928,
63,
1943,
9,
272,
1284,
275,
1109,
8,
500,
63,
1943,
1182,
2787,
63,
2926,
9,
435,
413,
339,
367,
28120,
315,
601,
19925,
14,
576,
14,
66,
4548,
26,
267,
327,
473,
506,
317,
4754,
642,
1990,
18329,
370,
3372,
3304,
330,
4548,
12,
1443,
267,
327,
440,
506,
2997,
14,
4839,
1655,
5343,
267,
340,
28120,
14,
1180,
63,
318,
1025,
365,
756,
26,
288,
2512,
14,
815,
480,
18297,
24154,
666,
367,
28120,
450,
83,
401,
28120,
14,
354,
9,
288,
1980,
398,
2512,
14,
815,
480,
17412,
24154,
666,
367,
28120,
450,
83,
401,
28120,
14,
354,
9,
398,
2883,
275,
942,
267,
367,
2787,
315,
1425,
8,
928,
12,
1284,
304,
288,
9235,
63,
1943,
275,
2787,
627,
2787,
63,
2926,
288,
2086,
12,
299,
1461,
275,
485,
3124,
8,
21134,
12,
9235,
63,
1943,
12,
3660,
1595,
12,
601,
19925,
14,
3642,
63,
7617,
9,
288,
7513,
12,
519,
1461,
275,
485,
15362,
8,
21134,
12,
9235,
63,
1943,
12,
3660,
1595,
12,
13038,
63,
3642,
9,
288,
7513,
275,
485,
7721,
63,
392,
28945,
8,
4571,
9,
953,
2086,
63,
88,
12,
2086,
63,
89,
12,
2086,
63,
90,
275,
2086,
14,
88,
12,
2086,
14,
90,
12,
446,
1712,
14,
89,
288,
7513,
63,
88,
12,
7513,
63,
89,
12,
7513,
63,
90,
12,
7513,
63,
87,
275,
7513,
14,
88,
12,
7513,
14,
90,
12,
446,
4571,
14,
89,
12,
7513,
14,
87,
953,
340,
2787,
508,
1343,
63,
1943,
26,
2234,
900,
275,
334,
1943,
627,
2787,
63,
2926,
446,
1343,
63,
1943,
9,
1182,
289,
1190,
355,
327,
768,
11768,
26,
4124,
4666,
1338,
355,
790,
1943,
275,
469,
490,
5262,
14,
4961,
26,
900,
12,
490,
5262,
14,
9263,
26,
359,
1712,
63,
88,
12,
2086,
63,
89,
12,
2086,
63,
90,
467,
490,
5262,
14,
31075,
26,
359,
4571,
63,
88,
12,
7513,
63,
89,
12,
7513,
63,
90,
12,
7513,
63,
87,
467,
490,
5262,
14,
51,
1981,
26,
359,
17,
12,
413,
12,
413,
61,
355,
789,
355,
2883,
14,
740,
8,
498,
1943,
9,
953,
327,
7729,
13,
12683,
26,
4839,
2086,
12,
7513,
436,
29794,
3004,
288,
327,
543,
24154,
2582,
334,
2427,
2787,
9,
953,
916,
2787,
508,
1284,
63,
1943,
1182,
2787,
63,
2926,
26,
2234,
900,
275,
2787,
63,
1267,
1182,
289,
1190,
355,
790,
1943,
275,
469,
490,
5262,
14,
4961,
26,
900,
12,
490,
5262,
14,
9263,
26,
359,
1712,
63,
88,
12,
2086,
63,
89,
12,
2086,
63,
90,
467,
490,
5262,
14,
31075,
26,
359,
4571,
63,
88,
12,
7513,
63,
89,
12,
7513,
63,
90,
12,
7513,
63,
87,
467,
490,
5262,
14,
51,
1981,
26,
359,
17,
12,
413,
12,
413,
61,
355,
789,
355,
2883,
14,
740,
8,
498,
1943,
9,
953,
327,
30041,
13,
12683,
26,
4839,
1454,
1373,
402,
314,
3004,
12,
288,
327,
883,
506,
376,
2701,
2787,
334,
4144,
2787,
9,
953,
916,
299,
1461,
365,
715,
503,
519,
1461,
365,
715,
26,
2234,
900,
275,
334,
1943,
627,
2787,
63,
2926,
446,
1343,
63,
1943,
9,
1182,
289,
1190,
2234,
340,
299,
1461,
365,
715,
436,
519,
1461,
365,
715,
26,
490,
790,
1943,
275,
469,
717,
5262,
14,
4961,
26,
900,
12,
717,
5262,
14,
9263,
26,
359,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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/formats.py
|
118
|
2086
|
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals
# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'd F Y' # 25 Ottobre 2006
TIME_FORMAT = 'H:i:s' # 14:30:59
DATETIME_FORMAT = 'l d F Y H:i:s' # Mercoledì 25 Ottobre 2006 14:30:59
YEAR_MONTH_FORMAT = 'F Y' # Ottobre 2006
MONTH_DAY_FORMAT = 'j/F' # 10/2006
SHORT_DATE_FORMAT = 'd/m/Y' # 25/12/2009
SHORT_DATETIME_FORMAT = 'd/m/Y H:i:s' # 25/10/2009 14:30:59
FIRST_DAY_OF_WEEK = 1 # Lunedì
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
DATE_INPUT_FORMATS = (
'%d/%m/%Y', '%Y/%m/%d', # '25/10/2006', '2008/10/25'
'%d-%m-%Y', '%Y-%m-%d', # '25-10-2006', '2008-10-25'
'%d-%m-%y', '%d/%m/%y', # '25-10-06', '25/10/06'
)
DATETIME_INPUT_FORMATS = (
'%d/%m/%Y %H:%M:%S', # '25/10/2006 14:30:59'
'%d/%m/%Y %H:%M:%S.%f', # '25/10/2006 14:30:59.000200'
'%d/%m/%Y %H:%M', # '25/10/2006 14:30'
'%d/%m/%Y', # '25/10/2006'
'%d/%m/%y %H:%M:%S', # '25/10/06 14:30:59'
'%d/%m/%y %H:%M:%S.%f', # '25/10/06 14:30:59.000200'
'%d/%m/%y %H:%M', # '25/10/06 14:30'
'%d/%m/%y', # '25/10/06'
'%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59'
'%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200'
'%Y-%m-%d %H:%M', # '2006-10-25 14:30'
'%Y-%m-%d', # '2006-10-25'
'%d-%m-%Y %H:%M:%S', # '25-10-2006 14:30:59'
'%d-%m-%Y %H:%M:%S.%f', # '25-10-2006 14:30:59.000200'
'%d-%m-%Y %H:%M', # '25-10-2006 14:30'
'%d-%m-%Y', # '25-10-2006'
'%d-%m-%y %H:%M:%S', # '25-10-06 14:30:59'
'%d-%m-%y %H:%M:%S.%f', # '25-10-06 14:30:59.000200'
'%d-%m-%y %H:%M', # '25-10-06 14:30'
'%d-%m-%y', # '25-10-06'
)
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = '.'
NUMBER_GROUPING = 3
|
apache-2.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
3,
710,
20841,
4807,
3326,
675,
314,
5634,
1434,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
5876,
15,
10372,
12645,
602,
199,
5390,
63,
4807,
275,
283,
68,
481,
1488,
7,
327,
5661,
593,
84,
475,
10205,
8315,
199,
4961,
63,
4807,
275,
283,
40,
26,
73,
26,
83,
7,
327,
4329,
26,
1216,
26,
1427,
199,
12488,
63,
4807,
275,
283,
76,
366,
481,
1488,
869,
26,
73,
26,
83,
7,
327,
18880,
331,
1146,
128,
106,
5661,
593,
84,
475,
10205,
8315,
4329,
26,
1216,
26,
1427,
199,
19216,
63,
16413,
63,
4807,
275,
283,
38,
1488,
7,
327,
593,
84,
475,
10205,
8315,
199,
16413,
63,
11655,
63,
4807,
275,
283,
74,
15,
38,
7,
327,
1616,
15,
7968,
199,
13003,
63,
5390,
63,
4807,
275,
283,
68,
15,
77,
15,
57,
7,
327,
5661,
15,
713,
15,
8664,
199,
13003,
63,
12488,
63,
4807,
275,
283,
68,
15,
77,
15,
57,
869,
26,
73,
26,
83,
7,
327,
5661,
15,
709,
15,
8664,
4329,
26,
1216,
26,
1427,
199,
12903,
63,
11655,
63,
3359,
63,
24929,
275,
413,
327,
491,
324,
379,
128,
106,
199,
199,
3,
710,
20841,
7321,
63,
14019,
3326,
675,
314,
2018,
14053,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
2083,
14,
1360,
3,
6205,
13,
9866,
13,
17537,
199,
5390,
63,
7321,
63,
14019,
275,
334,
272,
1543,
68,
3149,
77,
3149,
57,
297,
1543,
57,
3149,
77,
3149,
68,
297,
221,
327,
283,
821,
15,
709,
15,
7968,
297,
283,
9300,
15,
709,
15,
821,
7,
272,
1543,
68,
3295,
77,
3295,
57,
297,
1543,
57,
3295,
77,
3295,
68,
297,
221,
327,
283,
821,
13,
709,
13,
7968,
297,
283,
9300,
13,
709,
13,
821,
7,
272,
1543,
68,
3295,
77,
3295,
89,
297,
1543,
68,
3149,
77,
3149,
89,
297,
221,
327,
283,
821,
13,
709,
13,
1690,
297,
283,
821,
15,
709,
15,
1690,
7,
199,
9,
199,
12488,
63,
7321,
63,
14019,
275,
334,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
7,
272,
1543,
68,
3149,
77,
3149,
57,
297,
4519,
327,
283,
821,
15,
709,
15,
7968,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
7,
272,
1543,
68,
3149,
77,
3149,
89,
297,
4519,
327,
283,
821,
15,
709,
15,
1690,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
297,
263,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
7,
272,
1543,
57,
3295,
77,
3295,
68,
297,
4519,
327,
283,
7968,
13,
709,
13,
821,
7,
272,
1543,
68,
3295,
77,
3295,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
13,
709,
13,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3295,
77,
3295,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
13,
709,
13,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3295,
77,
3295,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
13,
709,
13,
7968,
4329,
26,
1216,
7,
272,
1543,
68,
3295,
77,
3295,
57,
297,
4519,
327,
283,
821,
13,
709,
13,
7968,
7,
272,
1543,
68,
3295,
77,
3295,
89,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
13,
709,
13,
1690,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3295,
77,
3295,
89,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
13,
709,
13,
1690,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3295,
77,
3295,
89,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
13,
709,
13,
1690,
4329,
26,
1216,
7,
272,
1543,
68,
3295,
77,
3295,
89,
297,
4519,
327,
283,
821,
13,
709,
13,
1690,
7,
199,
9,
199,
23925,
63,
15828,
275,
13647,
199,
28714,
63,
15828,
275,
7815,
199,
9190,
63,
7823,
1206,
275,
650,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
3,
710,
20841,
4807,
3326,
675,
314,
5634,
1434,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
5876,
15,
10372,
12645,
602,
199,
5390,
63,
4807,
275,
283,
68,
481,
1488,
7,
327,
5661,
593,
84,
475,
10205,
8315,
199,
4961,
63,
4807,
275,
283,
40,
26,
73,
26,
83,
7,
327,
4329,
26,
1216,
26,
1427,
199,
12488,
63,
4807,
275,
283,
76,
366,
481,
1488,
869,
26,
73,
26,
83,
7,
327,
18880,
331,
1146,
128,
106,
5661,
593,
84,
475,
10205,
8315,
4329,
26,
1216,
26,
1427,
199,
19216,
63,
16413,
63,
4807,
275,
283,
38,
1488,
7,
327,
593,
84,
475,
10205,
8315,
199,
16413,
63,
11655,
63,
4807,
275,
283,
74,
15,
38,
7,
327,
1616,
15,
7968,
199,
13003,
63,
5390,
63,
4807,
275,
283,
68,
15,
77,
15,
57,
7,
327,
5661,
15,
713,
15,
8664,
199,
13003,
63,
12488,
63,
4807,
275,
283,
68,
15,
77,
15,
57,
869,
26,
73,
26,
83,
7,
327,
5661,
15,
709,
15,
8664,
4329,
26,
1216,
26,
1427,
199,
12903,
63,
11655,
63,
3359,
63,
24929,
275,
413,
327,
491,
324,
379,
128,
106,
199,
199,
3,
710,
20841,
7321,
63,
14019,
3326,
675,
314,
2018,
14053,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
2083,
14,
1360,
3,
6205,
13,
9866,
13,
17537,
199,
5390,
63,
7321,
63,
14019,
275,
334,
272,
1543,
68,
3149,
77,
3149,
57,
297,
1543,
57,
3149,
77,
3149,
68,
297,
221,
327,
283,
821,
15,
709,
15,
7968,
297,
283,
9300,
15,
709,
15,
821,
7,
272,
1543,
68,
3295,
77,
3295,
57,
297,
1543,
57,
3295,
77,
3295,
68,
297,
221,
327,
283,
821,
13,
709,
13,
7968,
297,
283,
9300,
13,
709,
13,
821,
7,
272,
1543,
68,
3295,
77,
3295,
89,
297,
1543,
68,
3149,
77,
3149,
89,
297,
221,
327,
283,
821,
13,
709,
13,
1690,
297,
283,
821,
15,
709,
15,
1690,
7,
199,
9,
199,
12488,
63,
7321,
63,
14019,
275,
334,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3149,
77,
3149,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
7,
272,
1543,
68,
3149,
77,
3149,
57,
297,
4519,
327,
283,
821,
15,
709,
15,
7968,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3149,
77,
3149,
89,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
7,
272,
1543,
68,
3149,
77,
3149,
89,
297,
4519,
327,
283,
821,
15,
709,
15,
1690,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
297,
263,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
7,
272,
1543,
57,
3295,
77,
3295,
68,
297,
4519,
327,
283,
7968,
13,
709,
13,
821,
7,
272,
1543,
68,
3295,
77,
3295,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
13,
709,
13,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3295,
77,
3295,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
13,
709,
13,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3295,
77,
3295,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
13,
709,
13,
7968,
4329,
26,
1216,
7,
272,
1543,
68,
3295,
77,
3295,
57,
297,
4519,
327,
283,
821,
13,
709,
13,
7968,
7,
272,
1543,
68,
3295,
77,
3295,
89,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
13,
709,
13,
1690,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
3295,
77,
3295,
89,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
13,
709,
13,
1690,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
3295,
77,
3295,
89,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
13,
709,
13,
1690,
4329,
26,
1216,
7,
272,
1543,
68,
3295,
77,
3295,
89,
297,
4519,
327,
283,
821,
13,
709,
13,
1690,
7,
199,
9,
199,
23925,
63,
15828,
275,
13647,
199,
28714,
63,
15828,
275,
7815,
199,
9190,
63,
7823,
1206,
275,
650,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
omardroubi/Artificial-Intelligence
|
Projects/Project3/reinforcement/featureExtractors.py
|
8
|
3703
|
# featureExtractors.py
# --------------------
# Licensing Information: You are free to use or extend these projects for
# educational purposes provided that (1) you do not distribute or publish
# solutions, (2) you retain this notice, and (3) you provide clear
# attribution to UC Berkeley, including a link to http://ai.berkeley.edu.
#
# Attribution Information: The Pacman AI projects were developed at UC Berkeley.
# The core projects and autograders were primarily created by John DeNero
# (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu).
# Student side autograding was added by Brad Miller, Nick Hay, and
# Pieter Abbeel (pabbeel@cs.berkeley.edu).
"Feature extractors for Pacman game states"
from game import Directions, Actions
import util
class FeatureExtractor:
def getFeatures(self, state, action):
"""
Returns a dict from features to counts
Usually, the count will just be 1.0 for
indicator functions.
"""
util.raiseNotDefined()
class IdentityExtractor(FeatureExtractor):
def getFeatures(self, state, action):
feats = util.Counter()
feats[(state,action)] = 1.0
return feats
class CoordinateExtractor(FeatureExtractor):
def getFeatures(self, state, action):
feats = util.Counter()
feats[state] = 1.0
feats['x=%d' % state[0]] = 1.0
feats['y=%d' % state[0]] = 1.0
feats['action=%s' % action] = 1.0
return feats
def closestFood(pos, food, walls):
"""
closestFood -- this is similar to the function that we have
worked on in the search project; here its all in one place
"""
fringe = [(pos[0], pos[1], 0)]
expanded = set()
while fringe:
pos_x, pos_y, dist = fringe.pop(0)
if (pos_x, pos_y) in expanded:
continue
expanded.add((pos_x, pos_y))
# if we find a food at this location then exit
if food[pos_x][pos_y]:
return dist
# otherwise spread out from the location to its neighbours
nbrs = Actions.getLegalNeighbors((pos_x, pos_y), walls)
for nbr_x, nbr_y in nbrs:
fringe.append((nbr_x, nbr_y, dist+1))
# no food found
return None
class SimpleExtractor(FeatureExtractor):
"""
Returns simple features for a basic reflex Pacman:
- whether food will be eaten
- how far away the next food is
- whether a ghost collision is imminent
- whether a ghost is one step away
"""
def getFeatures(self, state, action):
# extract the grid of food and wall locations and get the ghost locations
food = state.getFood()
walls = state.getWalls()
ghosts = state.getGhostPositions()
features = util.Counter()
features["bias"] = 1.0
# compute the location of pacman after he takes the action
x, y = state.getPacmanPosition()
dx, dy = Actions.directionToVector(action)
next_x, next_y = int(x + dx), int(y + dy)
# count the number of ghosts 1-step away
features["#-of-ghosts-1-step-away"] = sum((next_x, next_y) in Actions.getLegalNeighbors(g, walls) for g in ghosts)
# if there is no danger of ghosts then add the food feature
if not features["#-of-ghosts-1-step-away"] and food[next_x][next_y]:
features["eats-food"] = 1.0
dist = closestFood((next_x, next_y), food, walls)
if dist is not None:
# make the distance a number less than one otherwise the update
# will diverge wildly
features["closest-food"] = float(dist) / (walls.width * walls.height)
features.divideAll(10.0)
return features
|
apache-2.0
|
[
3,
3878,
11039,
83,
14,
647,
199,
3,
10652,
375,
199,
3,
491,
530,
25843,
17064,
26,
221,
2047,
787,
2867,
370,
675,
503,
12247,
3520,
11336,
367,
199,
3,
3988,
947,
6279,
12901,
2741,
626,
334,
17,
9,
1265,
886,
440,
11207,
503,
2780,
199,
3,
24886,
12,
334,
18,
9,
1265,
8074,
642,
4245,
12,
436,
334,
19,
9,
1265,
5647,
5436,
199,
3,
737,
15980,
370,
738,
35,
23207,
415,
15515,
12,
5893,
282,
2142,
370,
1455,
921,
5789,
14,
605,
415,
15515,
14,
8654,
14,
199,
3,
221,
199,
3,
2854,
15980,
17064,
26,
710,
510,
645,
1237,
437,
41,
11336,
4898,
477,
27813,
737,
738,
35,
23207,
415,
15515,
14,
199,
3,
710,
6170,
11336,
436,
2599,
926,
7735,
4898,
1979,
30468,
2737,
701,
17815,
1487,
46,
3478,
199,
3,
334,
848,
3478,
32,
1259,
14,
605,
415,
15515,
14,
8654,
9,
436,
24747,
1804,
274,
262,
334,
23572,
262,
32,
1259,
14,
605,
415,
15515,
14,
8654,
680,
199,
3,
17246,
5366,
2599,
16050,
1990,
3483,
701,
699,
9525,
603,
19576,
12,
653,
2000,
869,
1187,
12,
436,
199,
3,
510,
1873,
351,
8351,
1235,
352,
334,
80,
371,
1235,
352,
32,
1259,
14,
605,
415,
15515,
14,
8654,
680,
421,
199,
2,
5968,
2402,
13451,
367,
510,
645,
1237,
9219,
6363,
2,
199,
199,
504,
9219,
492,
25596,
2452,
12,
24367,
199,
646,
4884,
199,
199,
533,
13407,
11039,
26,
272,
347,
664,
10807,
8,
277,
12,
1174,
12,
1595,
304,
267,
408,
881,
1803,
282,
1211,
687,
4534,
370,
8242,
881,
24612,
12,
314,
2338,
911,
2951,
506,
413,
14,
16,
367,
881,
16385,
3423,
14,
267,
408,
267,
4884,
14,
3730,
1763,
18718,
342,
199,
199,
533,
22034,
11039,
8,
5968,
11039,
304,
272,
347,
664,
10807,
8,
277,
12,
1174,
12,
1595,
304,
267,
1964,
1956,
275,
4884,
14,
11348,
342,
267,
1964,
1956,
7528,
929,
12,
1287,
1874,
275,
413,
14,
16,
267,
372,
1964,
1956,
199,
199,
533,
25334,
323,
11039,
8,
5968,
11039,
304,
272,
347,
664,
10807,
8,
277,
12,
1174,
12,
1595,
304,
267,
1964,
1956,
275,
4884,
14,
11348,
342,
267,
1964,
1956,
59,
929,
61,
275,
413,
14,
16,
267,
1964,
1956,
459,
88,
2458,
68,
7,
450,
1174,
59,
16,
2677,
275,
413,
14,
16,
267,
1964,
1956,
459,
89,
2458,
68,
7,
450,
1174,
59,
16,
2677,
275,
413,
14,
16,
267,
1964,
1956,
459,
1287,
2458,
83,
7,
450,
1595,
61,
275,
413,
14,
16,
267,
372,
1964,
1956,
199,
199,
318,
18284,
15563,
364,
8,
1712,
12,
7090,
364,
12,
19882,
83,
304,
272,
408,
272,
18284,
15563,
364,
1553,
642,
365,
8545,
370,
314,
805,
626,
781,
1172,
272,
26731,
641,
315,
314,
2754,
2199,
27,
2348,
2399,
1006,
315,
1373,
4192,
272,
408,
272,
9513,
17081,
275,
3842,
1712,
59,
16,
467,
2086,
59,
17,
467,
378,
1874,
272,
11507,
275,
663,
342,
272,
1830,
9513,
17081,
26,
267,
2086,
63,
88,
12,
2086,
63,
89,
12,
2917,
275,
9513,
17081,
14,
1935,
8,
16,
9,
267,
340,
334,
1712,
63,
88,
12,
2086,
63,
89,
9,
315,
11507,
26,
288,
1980,
267,
11507,
14,
525,
1332,
1712,
63,
88,
12,
2086,
63,
89,
430,
267,
327,
340,
781,
2342,
282,
7090,
364,
737,
642,
2909,
2066,
4458,
267,
340,
7090,
364,
59,
1712,
63,
88,
1527,
1712,
63,
89,
2189,
288,
372,
2917,
267,
327,
4257,
308,
8984,
734,
687,
314,
2909,
370,
2399,
1279,
4594,
16363,
267,
8526,
2393,
275,
24367,
14,
362,
13257,
279,
20011,
1332,
1712,
63,
88,
12,
2086,
63,
89,
395,
19882,
83,
9,
267,
367,
31646,
63,
88,
12,
31646,
63,
89,
315,
8526,
2393,
26,
288,
9513,
17081,
14,
740,
1332,
23299,
63,
88,
12,
31646,
63,
89,
12,
2917,
11,
17,
430,
272,
327,
949,
7090,
364,
1911,
272,
372,
488,
199,
199,
533,
5870,
11039,
8,
5968,
11039,
304,
272,
408,
272,
1803,
3486,
4534,
367,
282,
5678,
2984,
3113,
510,
645,
1237,
26,
272,
446,
3775,
7090,
364,
911,
506,
325,
323,
78,
272,
446,
4212,
12474,
13437,
314,
2163,
7090,
364,
365,
272,
446,
3775,
282,
486,
1102,
25061,
365,
25531,
262,
484,
272,
446,
3775,
282,
486,
1102,
365,
1373,
3650,
13437,
272,
408,
339,
347,
664,
10807,
8,
277,
12,
1174,
12,
1595,
304,
267,
327,
5536,
314,
6068,
402,
7090,
364,
436,
19882,
9918,
436,
664,
314,
486,
1102,
9918,
267,
7090,
364,
275,
1174,
14,
362,
15563,
364,
342,
267,
19882,
83,
275,
1174,
14,
362,
18018,
83,
342,
267,
486,
5146,
275,
1174,
14,
362,
39,
1102,
32650,
342,
398,
4534,
275,
4884,
14,
11348,
342,
398,
4534,
905,
8160,
937,
275,
413,
14,
16,
398,
327,
4526,
314,
2909,
402,
299,
645,
1237,
2410,
946,
6181,
314,
1595,
267,
671,
12,
612,
275,
1174,
14,
362,
48,
645,
1237,
5625,
342,
267,
11868,
12,
13119,
275,
24367,
14,
6874,
1378,
3646,
8,
1287,
9,
267,
2163,
63,
88,
12,
2163,
63,
89,
275,
1109,
8,
88,
435,
11868,
395,
1109,
8,
89,
435,
13119,
9,
398,
327,
2338,
314,
1329,
402,
486,
5146,
413,
13,
2926,
13437,
267,
4534,
905,
3,
13,
1618,
13,
71,
5146,
13,
17,
13,
2926,
13,
22703,
937,
275,
3089,
1332,
2184,
63,
88,
12,
2163,
63,
89,
9,
315,
24367,
14,
362,
13257,
279,
20011,
8,
71,
12,
19882,
83,
9,
367,
486,
315,
486,
5146,
9,
398,
327,
340,
2337,
365,
949,
366,
12974,
402,
486,
5146,
2066,
1050,
314,
7090,
364,
3878,
267,
340,
440,
4534,
905,
3,
13,
1618,
13,
71,
5146,
13,
17,
13,
2926,
13,
22703,
937,
436,
7090,
364,
59,
2184,
63,
88,
1527,
2184,
63,
89,
2189,
288,
4534,
905,
69,
1956,
13,
22120,
937,
275,
413,
14,
16,
398,
2917,
275,
18284,
15563,
364,
1332,
2184,
63,
88,
12,
2163,
63,
89,
395,
7090,
364,
12,
19882,
83,
9,
267,
340,
2917,
365,
440,
488,
26,
288,
327,
1852,
314,
6033,
282,
1329,
6656,
2419,
1373,
4257,
314,
1678,
288,
327,
911,
487,
422,
303,
336,
668,
590,
288,
4534,
905,
22061,
13,
22120,
937,
275,
2069,
8,
2686
] |
[
3878,
11039,
83,
14,
647,
199,
3,
10652,
375,
199,
3,
491,
530,
25843,
17064,
26,
221,
2047,
787,
2867,
370,
675,
503,
12247,
3520,
11336,
367,
199,
3,
3988,
947,
6279,
12901,
2741,
626,
334,
17,
9,
1265,
886,
440,
11207,
503,
2780,
199,
3,
24886,
12,
334,
18,
9,
1265,
8074,
642,
4245,
12,
436,
334,
19,
9,
1265,
5647,
5436,
199,
3,
737,
15980,
370,
738,
35,
23207,
415,
15515,
12,
5893,
282,
2142,
370,
1455,
921,
5789,
14,
605,
415,
15515,
14,
8654,
14,
199,
3,
221,
199,
3,
2854,
15980,
17064,
26,
710,
510,
645,
1237,
437,
41,
11336,
4898,
477,
27813,
737,
738,
35,
23207,
415,
15515,
14,
199,
3,
710,
6170,
11336,
436,
2599,
926,
7735,
4898,
1979,
30468,
2737,
701,
17815,
1487,
46,
3478,
199,
3,
334,
848,
3478,
32,
1259,
14,
605,
415,
15515,
14,
8654,
9,
436,
24747,
1804,
274,
262,
334,
23572,
262,
32,
1259,
14,
605,
415,
15515,
14,
8654,
680,
199,
3,
17246,
5366,
2599,
16050,
1990,
3483,
701,
699,
9525,
603,
19576,
12,
653,
2000,
869,
1187,
12,
436,
199,
3,
510,
1873,
351,
8351,
1235,
352,
334,
80,
371,
1235,
352,
32,
1259,
14,
605,
415,
15515,
14,
8654,
680,
421,
199,
2,
5968,
2402,
13451,
367,
510,
645,
1237,
9219,
6363,
2,
199,
199,
504,
9219,
492,
25596,
2452,
12,
24367,
199,
646,
4884,
199,
199,
533,
13407,
11039,
26,
272,
347,
664,
10807,
8,
277,
12,
1174,
12,
1595,
304,
267,
408,
881,
1803,
282,
1211,
687,
4534,
370,
8242,
881,
24612,
12,
314,
2338,
911,
2951,
506,
413,
14,
16,
367,
881,
16385,
3423,
14,
267,
408,
267,
4884,
14,
3730,
1763,
18718,
342,
199,
199,
533,
22034,
11039,
8,
5968,
11039,
304,
272,
347,
664,
10807,
8,
277,
12,
1174,
12,
1595,
304,
267,
1964,
1956,
275,
4884,
14,
11348,
342,
267,
1964,
1956,
7528,
929,
12,
1287,
1874,
275,
413,
14,
16,
267,
372,
1964,
1956,
199,
199,
533,
25334,
323,
11039,
8,
5968,
11039,
304,
272,
347,
664,
10807,
8,
277,
12,
1174,
12,
1595,
304,
267,
1964,
1956,
275,
4884,
14,
11348,
342,
267,
1964,
1956,
59,
929,
61,
275,
413,
14,
16,
267,
1964,
1956,
459,
88,
2458,
68,
7,
450,
1174,
59,
16,
2677,
275,
413,
14,
16,
267,
1964,
1956,
459,
89,
2458,
68,
7,
450,
1174,
59,
16,
2677,
275,
413,
14,
16,
267,
1964,
1956,
459,
1287,
2458,
83,
7,
450,
1595,
61,
275,
413,
14,
16,
267,
372,
1964,
1956,
199,
199,
318,
18284,
15563,
364,
8,
1712,
12,
7090,
364,
12,
19882,
83,
304,
272,
408,
272,
18284,
15563,
364,
1553,
642,
365,
8545,
370,
314,
805,
626,
781,
1172,
272,
26731,
641,
315,
314,
2754,
2199,
27,
2348,
2399,
1006,
315,
1373,
4192,
272,
408,
272,
9513,
17081,
275,
3842,
1712,
59,
16,
467,
2086,
59,
17,
467,
378,
1874,
272,
11507,
275,
663,
342,
272,
1830,
9513,
17081,
26,
267,
2086,
63,
88,
12,
2086,
63,
89,
12,
2917,
275,
9513,
17081,
14,
1935,
8,
16,
9,
267,
340,
334,
1712,
63,
88,
12,
2086,
63,
89,
9,
315,
11507,
26,
288,
1980,
267,
11507,
14,
525,
1332,
1712,
63,
88,
12,
2086,
63,
89,
430,
267,
327,
340,
781,
2342,
282,
7090,
364,
737,
642,
2909,
2066,
4458,
267,
340,
7090,
364,
59,
1712,
63,
88,
1527,
1712,
63,
89,
2189,
288,
372,
2917,
267,
327,
4257,
308,
8984,
734,
687,
314,
2909,
370,
2399,
1279,
4594,
16363,
267,
8526,
2393,
275,
24367,
14,
362,
13257,
279,
20011,
1332,
1712,
63,
88,
12,
2086,
63,
89,
395,
19882,
83,
9,
267,
367,
31646,
63,
88,
12,
31646,
63,
89,
315,
8526,
2393,
26,
288,
9513,
17081,
14,
740,
1332,
23299,
63,
88,
12,
31646,
63,
89,
12,
2917,
11,
17,
430,
272,
327,
949,
7090,
364,
1911,
272,
372,
488,
199,
199,
533,
5870,
11039,
8,
5968,
11039,
304,
272,
408,
272,
1803,
3486,
4534,
367,
282,
5678,
2984,
3113,
510,
645,
1237,
26,
272,
446,
3775,
7090,
364,
911,
506,
325,
323,
78,
272,
446,
4212,
12474,
13437,
314,
2163,
7090,
364,
365,
272,
446,
3775,
282,
486,
1102,
25061,
365,
25531,
262,
484,
272,
446,
3775,
282,
486,
1102,
365,
1373,
3650,
13437,
272,
408,
339,
347,
664,
10807,
8,
277,
12,
1174,
12,
1595,
304,
267,
327,
5536,
314,
6068,
402,
7090,
364,
436,
19882,
9918,
436,
664,
314,
486,
1102,
9918,
267,
7090,
364,
275,
1174,
14,
362,
15563,
364,
342,
267,
19882,
83,
275,
1174,
14,
362,
18018,
83,
342,
267,
486,
5146,
275,
1174,
14,
362,
39,
1102,
32650,
342,
398,
4534,
275,
4884,
14,
11348,
342,
398,
4534,
905,
8160,
937,
275,
413,
14,
16,
398,
327,
4526,
314,
2909,
402,
299,
645,
1237,
2410,
946,
6181,
314,
1595,
267,
671,
12,
612,
275,
1174,
14,
362,
48,
645,
1237,
5625,
342,
267,
11868,
12,
13119,
275,
24367,
14,
6874,
1378,
3646,
8,
1287,
9,
267,
2163,
63,
88,
12,
2163,
63,
89,
275,
1109,
8,
88,
435,
11868,
395,
1109,
8,
89,
435,
13119,
9,
398,
327,
2338,
314,
1329,
402,
486,
5146,
413,
13,
2926,
13437,
267,
4534,
905,
3,
13,
1618,
13,
71,
5146,
13,
17,
13,
2926,
13,
22703,
937,
275,
3089,
1332,
2184,
63,
88,
12,
2163,
63,
89,
9,
315,
24367,
14,
362,
13257,
279,
20011,
8,
71,
12,
19882,
83,
9,
367,
486,
315,
486,
5146,
9,
398,
327,
340,
2337,
365,
949,
366,
12974,
402,
486,
5146,
2066,
1050,
314,
7090,
364,
3878,
267,
340,
440,
4534,
905,
3,
13,
1618,
13,
71,
5146,
13,
17,
13,
2926,
13,
22703,
937,
436,
7090,
364,
59,
2184,
63,
88,
1527,
2184,
63,
89,
2189,
288,
4534,
905,
69,
1956,
13,
22120,
937,
275,
413,
14,
16,
398,
2917,
275,
18284,
15563,
364,
1332,
2184,
63,
88,
12,
2163,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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
] |
tdtrask/ansible
|
contrib/inventory/nsot.py
|
117
|
9825
|
#!/usr/bin/env python
'''
nsot
====
Ansible Dynamic Inventory to pull hosts from NSoT, a flexible CMDB by Dropbox
Features
--------
* Define host groups in form of NSoT device attribute criteria
* All parameters defined by the spec as of 2015-09-05 are supported.
+ ``--list``: Returns JSON hash of host groups -> hosts and top-level
``_meta`` -> ``hostvars`` which correspond to all device attributes.
Group vars can be specified in the YAML configuration, noted below.
+ ``--host <hostname>``: Returns JSON hash where every item is a device
attribute.
* In addition to all attributes assigned to resource being returned, script
will also append ``site_id`` and ``id`` as facts to utilize.
Confguration
------------
Since it'd be annoying and failure prone to guess where you're configuration
file is, use ``NSOT_INVENTORY_CONFIG`` to specify the path to it.
This file should adhere to the YAML spec. All top-level variable must be
desired Ansible group-name hashed with single 'query' item to define the NSoT
attribute query.
Queries follow the normal NSoT query syntax, `shown here`_
.. _shown here: https://github.com/dropbox/pynsot#set-queries
.. code:: yaml
routers:
query: 'deviceType=ROUTER'
vars:
a: b
c: d
juniper_fw:
query: 'deviceType=FIREWALL manufacturer=JUNIPER'
not_f10:
query: '-manufacturer=FORCE10'
The inventory will automatically use your ``.pynsotrc`` like normal pynsot from
cli would, so make sure that's configured appropriately.
.. note::
Attributes I'm showing above are influenced from ones that the Trigger
project likes. As is the spirit of NSoT, use whichever attributes work best
for your workflow.
If config file is blank or absent, the following default groups will be
created:
* ``routers``: deviceType=ROUTER
* ``switches``: deviceType=SWITCH
* ``firewalls``: deviceType=FIREWALL
These are likely not useful for everyone so please use the configuration. :)
.. note::
By default, resources will only be returned for what your default
site is set for in your ``~/.pynsotrc``.
If you want to specify, add an extra key under the group for ``site: n``.
Output Examples
---------------
Here are some examples shown from just calling the command directly::
$ NSOT_INVENTORY_CONFIG=$PWD/test.yaml ansible_nsot --list | jq '.'
{
"routers": {
"hosts": [
"test1.example.com"
],
"vars": {
"cool_level": "very",
"group": "routers"
}
},
"firewalls": {
"hosts": [
"test2.example.com"
],
"vars": {
"cool_level": "enough",
"group": "firewalls"
}
},
"_meta": {
"hostvars": {
"test2.example.com": {
"make": "SRX",
"site_id": 1,
"id": 108
},
"test1.example.com": {
"make": "MX80",
"site_id": 1,
"id": 107
}
}
},
"rtr_and_fw": {
"hosts": [
"test1.example.com",
"test2.example.com"
],
"vars": {}
}
}
$ NSOT_INVENTORY_CONFIG=$PWD/test.yaml ansible_nsot --host test1 | jq '.'
{
"make": "MX80",
"site_id": 1,
"id": 107
}
'''
from __future__ import print_function
import sys
import os
import pkg_resources
import argparse
import json
import yaml
from textwrap import dedent
from pynsot.client import get_api_client
from pynsot.app import HttpServerError
from click.exceptions import UsageError
from six import string_types
def warning(*objs):
print("WARNING: ", *objs, file=sys.stderr)
class NSoTInventory(object):
'''NSoT Client object for gather inventory'''
def __init__(self):
self.config = dict()
config_env = os.environ.get('NSOT_INVENTORY_CONFIG')
if config_env:
try:
config_file = os.path.abspath(config_env)
except IOError: # If file non-existent, use default config
self._config_default()
except Exception as e:
sys.exit('%s\n' % e)
with open(config_file) as f:
try:
self.config.update(yaml.safe_load(f))
except TypeError: # If empty file, use default config
warning('Empty config file')
self._config_default()
except Exception as e:
sys.exit('%s\n' % e)
else: # Use defaults if env var missing
self._config_default()
self.groups = self.config.keys()
self.client = get_api_client()
self._meta = {'hostvars': dict()}
def _config_default(self):
default_yaml = '''
---
routers:
query: deviceType=ROUTER
switches:
query: deviceType=SWITCH
firewalls:
query: deviceType=FIREWALL
'''
self.config = yaml.safe_load(dedent(default_yaml))
def do_list(self):
'''Direct callback for when ``--list`` is provided
Relies on the configuration generated from init to run
_inventory_group()
'''
inventory = dict()
for group, contents in self.config.items():
group_response = self._inventory_group(group, contents)
inventory.update(group_response)
inventory.update({'_meta': self._meta})
return json.dumps(inventory)
def do_host(self, host):
return json.dumps(self._hostvars(host))
def _hostvars(self, host):
'''Return dictionary of all device attributes
Depending on number of devices in NSoT, could be rather slow since this
has to request every device resource to filter through
'''
device = [i for i in self.client.devices.get()
if host in i['hostname']][0]
attributes = device['attributes']
attributes.update({'site_id': device['site_id'], 'id': device['id']})
return attributes
def _inventory_group(self, group, contents):
'''Takes a group and returns inventory for it as dict
:param group: Group name
:type group: str
:param contents: The contents of the group's YAML config
:type contents: dict
contents param should look like::
{
'query': 'xx',
'vars':
'a': 'b'
}
Will return something like::
{ group: {
hosts: [],
vars: {},
}
'''
query = contents.get('query')
hostvars = contents.get('vars', dict())
site = contents.get('site', dict())
obj = {group: dict()}
obj[group]['hosts'] = []
obj[group]['vars'] = hostvars
try:
assert isinstance(query, string_types)
except:
sys.exit('ERR: Group queries must be a single string\n'
' Group: %s\n'
' Query: %s\n' % (group, query)
)
try:
if site:
site = self.client.sites(site)
devices = site.devices.query.get(query=query)
else:
devices = self.client.devices.query.get(query=query)
except HttpServerError as e:
if '500' in str(e.response):
_site = 'Correct site id?'
_attr = 'Queried attributes actually exist?'
questions = _site + '\n' + _attr
sys.exit('ERR: 500 from server.\n%s' % questions)
else:
raise
except UsageError:
sys.exit('ERR: Could not connect to server. Running?')
# Would do a list comprehension here, but would like to save code/time
# and also acquire attributes in this step
for host in devices:
# Iterate through each device that matches query, assign hostname
# to the group's hosts array and then use this single iteration as
# a chance to update self._meta which will be used in the final
# return
hostname = host['hostname']
obj[group]['hosts'].append(hostname)
attributes = host['attributes']
attributes.update({'site_id': host['site_id'], 'id': host['id']})
self._meta['hostvars'].update({hostname: attributes})
return obj
def parse_args():
desc = __doc__.splitlines()[4] # Just to avoid being redundant
# Establish parser with options and error out if no action provided
parser = argparse.ArgumentParser(
description=desc,
conflict_handler='resolve',
)
# Arguments
#
# Currently accepting (--list | -l) and (--host | -h)
# These must not be allowed together
parser.add_argument(
'--list', '-l',
help='Print JSON object containing hosts to STDOUT',
action='store_true',
dest='list_', # Avoiding syntax highlighting for list
)
parser.add_argument(
'--host', '-h',
help='Print JSON object containing hostvars for <host>',
action='store',
)
args = parser.parse_args()
if not args.list_ and not args.host: # Require at least one option
parser.exit(status=1, message='No action requested')
if args.list_ and args.host: # Do not allow multiple options
parser.exit(status=1, message='Too many actions requested')
return args
def main():
'''Set up argument handling and callback routing'''
args = parse_args()
client = NSoTInventory()
# Callback condition
if args.list_:
print(client.do_list())
elif args.host:
print(client.do_host(args.host))
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
2344,
199,
561,
357,
199,
532,
199,
199,
10047,
21907,
19337,
370,
10299,
7057,
687,
653,
5158,
52,
12,
282,
26841,
445,
45,
2846,
701,
18110,
1977,
199,
199,
10807,
199,
518,
199,
199,
10,
13930,
1591,
4652,
315,
1824,
402,
653,
5158,
52,
2243,
2225,
15647,
199,
199,
10,
2900,
2633,
3247,
701,
314,
3158,
465,
402,
6900,
13,
1643,
13,
1717,
787,
3748,
14,
819,
435,
1124,
306,
513,
18983,
1803,
4840,
2631,
402,
1591,
4652,
1035,
7057,
436,
2746,
13,
1896,
272,
24507,
2024,
1040,
1035,
1124,
23265,
1040,
1314,
17118,
370,
1006,
2243,
3004,
14,
339,
5611,
6802,
883,
506,
2013,
315,
314,
18916,
2897,
12,
949,
471,
5084,
14,
819,
435,
1124,
306,
1102,
665,
4269,
30,
18983,
1803,
4840,
2631,
2382,
4036,
1242,
365,
282,
2243,
272,
2225,
14,
199,
199,
10,
1010,
10234,
370,
1006,
3004,
7943,
370,
2073,
3769,
2138,
12,
2884,
523,
911,
2597,
5666,
1124,
2124,
63,
344,
1040,
436,
1124,
344,
1040,
465,
9036,
370,
7678,
13559,
14,
421,
199,
8930,
71,
1542,
199,
4559,
199,
199,
24430,
652,
5121,
506,
22984,
22440,
436,
5988,
5448,
368,
370,
9519,
2382,
1265,
3984,
2897,
199,
493,
365,
12,
675,
1124,
2709,
1387,
63,
568,
4554,
5347,
63,
5569,
1040,
370,
4165,
314,
931,
370,
652,
14,
199,
199,
2765,
570,
1077,
1503,
1681,
370,
314,
18916,
3158,
14,
2900,
2746,
13,
1896,
1750,
1471,
506,
199,
16035,
2622,
1572,
13,
354,
19871,
543,
2849,
283,
1131,
7,
1242,
370,
5627,
314,
653,
5158,
52,
199,
3215,
1827,
14,
199,
199,
13611,
2035,
314,
3293,
653,
5158,
52,
1827,
6302,
12,
658,
24422,
2348,
18417,
199,
199,
703,
485,
24422,
2348,
26,
4178,
921,
5031,
14,
957,
15,
32118,
15,
647,
561,
357,
3,
409,
13,
10590,
199,
199,
703,
1233,
447,
8864,
8410,
24464,
26,
1362,
1827,
26,
283,
1782,
804,
29,
19281,
7,
1362,
6802,
26,
2126,
282,
26,
330,
2126,
286,
26,
366,
8410,
1335,
5411,
529,
63,
8835,
26,
1362,
1827,
26,
283,
1782,
804,
29,
1976,
907,
55,
1761,
2169,
21087,
29,
42,
1734,
1772,
540,
7,
8410,
440,
63,
70,
709,
26,
1362,
1827,
26,
2475,
32214,
29,
27240,
709,
7,
199,
199,
1918,
8200,
911,
5847,
675,
2195,
21502,
647,
561,
357,
1195,
1040,
2839,
3293,
1134,
561,
357,
687,
199,
2764,
3955,
12,
880,
1852,
3238,
626,
1159,
7526,
22497,
14,
199,
199,
703,
5317,
447,
339,
9382,
473,
6704,
21207,
3432,
787,
315,
24585,
68,
687,
7869,
626,
314,
24015,
272,
2199,
1212,
9246,
14,
3709,
365,
314,
19441,
11133,
402,
653,
5158,
52,
12,
675,
704,
73,
595,
422,
3004,
1736,
5526,
272,
367,
2195,
10431,
14,
199,
199,
3917,
1101,
570,
365,
4596,
503,
9552,
12,
314,
2569,
849,
4652,
911,
506,
199,
3966,
26,
199,
199,
10,
1124,
17292,
18983,
31343,
29,
19281,
199,
10,
1124,
32332,
18983,
31343,
29,
18079,
199,
10,
1124,
10794,
83,
18983,
31343,
29,
1976,
907,
55,
1761,
199,
199,
20676,
787,
12060,
440,
2997,
367,
4036,
368,
880,
8749,
675,
314,
2897,
14,
32428,
199,
199,
703,
5317,
447,
339,
4885,
849,
12,
5944,
911,
1454,
506,
2138,
367,
4052,
2195,
849,
272,
4770,
365,
663,
367,
315,
2195,
1124,
94,
8083,
647,
561,
357,
1195,
4345,
339,
982,
1265,
2934,
370,
4165,
12,
1050,
376,
2402,
790,
1334,
314,
1572,
367,
1124,
2124,
26,
302,
4345,
199,
199,
2959,
6058,
199,
18964,
199,
199,
21741,
787,
2005,
7251,
9164,
687,
2951,
6358,
314,
1414,
5370,
447,
8410,
2672,
9380,
1387,
63,
568,
4554,
5347,
63,
5569,
28617,
10780,
36,
15,
396,
14,
5963,
3242,
63,
561,
357,
1553,
513,
1204,
1335,
81,
7815,
2043,
469,
1362,
298,
17292,
582,
469,
2126,
298,
5146,
582,
359,
268,
298,
396,
17,
14,
2694,
14,
957,
2,
2126,
2156,
2126,
298,
2936,
582,
469,
268,
298,
18499,
63,
1896,
582,
298,
2588,
401,
268,
298,
923,
582,
298,
17292,
2,
2126,
789,
1362,
1660,
1362,
298,
10794,
83,
582,
469,
2126,
298,
5146,
582,
359,
268,
298,
396,
18,
14,
2694,
14,
957,
2,
2126,
2156,
2126,
298,
2936,
582,
469,
268,
298,
18499,
63,
1896,
582,
298,
30881,
401,
268,
298,
923,
582,
298,
10794,
83,
2,
2126,
789,
1362,
1660,
1362,
2668,
2024,
582,
469,
2126,
298,
23265,
582,
469,
268,
298,
396,
18,
14,
2694,
14,
957,
582,
469,
1779,
298,
1875,
582,
298,
5943,
56,
401,
1779,
298,
2124,
63,
344,
582,
413,
12,
1779,
298,
344,
582,
24579,
268,
1660,
268,
298,
396,
17,
14,
2694,
14,
957,
582,
469,
1779,
298,
1875,
582,
298,
17401,
1257,
401,
1779,
298,
2124,
63,
344,
582,
413,
12,
1779,
298,
344,
582,
23543,
268,
789,
2126,
789,
1362,
1660,
1362,
298,
82,
454,
63,
460,
63,
8835,
582,
469,
2126,
298,
5146,
582,
359,
268,
298,
396,
17,
14,
2694,
14,
957,
401,
268,
298,
396,
18,
14,
2694,
14,
957,
2,
2126,
2156,
2126,
298,
2936,
582,
1052,
1362,
789,
2043,
789,
27974,
2672,
9380,
1387,
63,
568,
4554,
5347,
63,
5569,
28617,
10780,
36,
15,
396,
14,
5963,
3242,
63,
561,
357,
1553,
1102,
511,
17,
1204,
1335,
81,
7815,
2043,
469,
489,
298,
1875,
582,
298,
17401,
1257,
401,
489,
298,
2124,
63,
344,
582,
413,
12,
489,
298,
344,
582,
23543,
2043,
789,
199,
199,
2344,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
646,
984,
199,
646,
747,
199,
646,
5496,
63,
4435,
199,
646,
7534,
199,
646,
2022,
199,
646,
8864,
199,
504,
13390,
492,
22622,
199,
504,
1134,
561,
357,
14,
1258,
492,
664,
63,
1246,
63,
1258,
199,
504,
1134,
561,
357,
14,
571,
492,
4760,
17692,
199,
504,
8968,
14,
3924,
492,
11028,
547,
199,
199,
504,
3816,
492,
1059,
63,
1313,
421,
199,
318,
5721,
2031,
8718,
304,
272,
870,
480,
9171,
26,
3872,
627,
8718,
12,
570,
29,
1274,
14,
3083,
9,
421,
199,
533,
653,
5158,
52,
19304,
8,
785,
304,
272,
1449,
2709,
79,
52,
6810,
909,
367,
13082,
8200,
2344,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
2344,
199,
561,
357,
199,
532,
199,
199,
10047,
21907,
19337,
370,
10299,
7057,
687,
653,
5158,
52,
12,
282,
26841,
445,
45,
2846,
701,
18110,
1977,
199,
199,
10807,
199,
518,
199,
199,
10,
13930,
1591,
4652,
315,
1824,
402,
653,
5158,
52,
2243,
2225,
15647,
199,
199,
10,
2900,
2633,
3247,
701,
314,
3158,
465,
402,
6900,
13,
1643,
13,
1717,
787,
3748,
14,
819,
435,
1124,
306,
513,
18983,
1803,
4840,
2631,
402,
1591,
4652,
1035,
7057,
436,
2746,
13,
1896,
272,
24507,
2024,
1040,
1035,
1124,
23265,
1040,
1314,
17118,
370,
1006,
2243,
3004,
14,
339,
5611,
6802,
883,
506,
2013,
315,
314,
18916,
2897,
12,
949,
471,
5084,
14,
819,
435,
1124,
306,
1102,
665,
4269,
30,
18983,
1803,
4840,
2631,
2382,
4036,
1242,
365,
282,
2243,
272,
2225,
14,
199,
199,
10,
1010,
10234,
370,
1006,
3004,
7943,
370,
2073,
3769,
2138,
12,
2884,
523,
911,
2597,
5666,
1124,
2124,
63,
344,
1040,
436,
1124,
344,
1040,
465,
9036,
370,
7678,
13559,
14,
421,
199,
8930,
71,
1542,
199,
4559,
199,
199,
24430,
652,
5121,
506,
22984,
22440,
436,
5988,
5448,
368,
370,
9519,
2382,
1265,
3984,
2897,
199,
493,
365,
12,
675,
1124,
2709,
1387,
63,
568,
4554,
5347,
63,
5569,
1040,
370,
4165,
314,
931,
370,
652,
14,
199,
199,
2765,
570,
1077,
1503,
1681,
370,
314,
18916,
3158,
14,
2900,
2746,
13,
1896,
1750,
1471,
506,
199,
16035,
2622,
1572,
13,
354,
19871,
543,
2849,
283,
1131,
7,
1242,
370,
5627,
314,
653,
5158,
52,
199,
3215,
1827,
14,
199,
199,
13611,
2035,
314,
3293,
653,
5158,
52,
1827,
6302,
12,
658,
24422,
2348,
18417,
199,
199,
703,
485,
24422,
2348,
26,
4178,
921,
5031,
14,
957,
15,
32118,
15,
647,
561,
357,
3,
409,
13,
10590,
199,
199,
703,
1233,
447,
8864,
8410,
24464,
26,
1362,
1827,
26,
283,
1782,
804,
29,
19281,
7,
1362,
6802,
26,
2126,
282,
26,
330,
2126,
286,
26,
366,
8410,
1335,
5411,
529,
63,
8835,
26,
1362,
1827,
26,
283,
1782,
804,
29,
1976,
907,
55,
1761,
2169,
21087,
29,
42,
1734,
1772,
540,
7,
8410,
440,
63,
70,
709,
26,
1362,
1827,
26,
2475,
32214,
29,
27240,
709,
7,
199,
199,
1918,
8200,
911,
5847,
675,
2195,
21502,
647,
561,
357,
1195,
1040,
2839,
3293,
1134,
561,
357,
687,
199,
2764,
3955,
12,
880,
1852,
3238,
626,
1159,
7526,
22497,
14,
199,
199,
703,
5317,
447,
339,
9382,
473,
6704,
21207,
3432,
787,
315,
24585,
68,
687,
7869,
626,
314,
24015,
272,
2199,
1212,
9246,
14,
3709,
365,
314,
19441,
11133,
402,
653,
5158,
52,
12,
675,
704,
73,
595,
422,
3004,
1736,
5526,
272,
367,
2195,
10431,
14,
199,
199,
3917,
1101,
570,
365,
4596,
503,
9552,
12,
314,
2569,
849,
4652,
911,
506,
199,
3966,
26,
199,
199,
10,
1124,
17292,
18983,
31343,
29,
19281,
199,
10,
1124,
32332,
18983,
31343,
29,
18079,
199,
10,
1124,
10794,
83,
18983,
31343,
29,
1976,
907,
55,
1761,
199,
199,
20676,
787,
12060,
440,
2997,
367,
4036,
368,
880,
8749,
675,
314,
2897,
14,
32428,
199,
199,
703,
5317,
447,
339,
4885,
849,
12,
5944,
911,
1454,
506,
2138,
367,
4052,
2195,
849,
272,
4770,
365,
663,
367,
315,
2195,
1124,
94,
8083,
647,
561,
357,
1195,
4345,
339,
982,
1265,
2934,
370,
4165,
12,
1050,
376,
2402,
790,
1334,
314,
1572,
367,
1124,
2124,
26,
302,
4345,
199,
199,
2959,
6058,
199,
18964,
199,
199,
21741,
787,
2005,
7251,
9164,
687,
2951,
6358,
314,
1414,
5370,
447,
8410,
2672,
9380,
1387,
63,
568,
4554,
5347,
63,
5569,
28617,
10780,
36,
15,
396,
14,
5963,
3242,
63,
561,
357,
1553,
513,
1204,
1335,
81,
7815,
2043,
469,
1362,
298,
17292,
582,
469,
2126,
298,
5146,
582,
359,
268,
298,
396,
17,
14,
2694,
14,
957,
2,
2126,
2156,
2126,
298,
2936,
582,
469,
268,
298,
18499,
63,
1896,
582,
298,
2588,
401,
268,
298,
923,
582,
298,
17292,
2,
2126,
789,
1362,
1660,
1362,
298,
10794,
83,
582,
469,
2126,
298,
5146,
582,
359,
268,
298,
396,
18,
14,
2694,
14,
957,
2,
2126,
2156,
2126,
298,
2936,
582,
469,
268,
298,
18499,
63,
1896,
582,
298,
30881,
401,
268,
298,
923,
582,
298,
10794,
83,
2,
2126,
789,
1362,
1660,
1362,
2668,
2024,
582,
469,
2126,
298,
23265,
582,
469,
268,
298,
396,
18,
14,
2694,
14,
957,
582,
469,
1779,
298,
1875,
582,
298,
5943,
56,
401,
1779,
298,
2124,
63,
344,
582,
413,
12,
1779,
298,
344,
582,
24579,
268,
1660,
268,
298,
396,
17,
14,
2694,
14,
957,
582,
469,
1779,
298,
1875,
582,
298,
17401,
1257,
401,
1779,
298,
2124,
63,
344,
582,
413,
12,
1779,
298,
344,
582,
23543,
268,
789,
2126,
789,
1362,
1660,
1362,
298,
82,
454,
63,
460,
63,
8835,
582,
469,
2126,
298,
5146,
582,
359,
268,
298,
396,
17,
14,
2694,
14,
957,
401,
268,
298,
396,
18,
14,
2694,
14,
957,
2,
2126,
2156,
2126,
298,
2936,
582,
1052,
1362,
789,
2043,
789,
27974,
2672,
9380,
1387,
63,
568,
4554,
5347,
63,
5569,
28617,
10780,
36,
15,
396,
14,
5963,
3242,
63,
561,
357,
1553,
1102,
511,
17,
1204,
1335,
81,
7815,
2043,
469,
489,
298,
1875,
582,
298,
17401,
1257,
401,
489,
298,
2124,
63,
344,
582,
413,
12,
489,
298,
344,
582,
23543,
2043,
789,
199,
199,
2344,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
646,
984,
199,
646,
747,
199,
646,
5496,
63,
4435,
199,
646,
7534,
199,
646,
2022,
199,
646,
8864,
199,
504,
13390,
492,
22622,
199,
504,
1134,
561,
357,
14,
1258,
492,
664,
63,
1246,
63,
1258,
199,
504,
1134,
561,
357,
14,
571,
492,
4760,
17692,
199,
504,
8968,
14,
3924,
492,
11028,
547,
199,
199,
504,
3816,
492,
1059,
63,
1313,
421,
199,
318,
5721,
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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
] |
Kilves/finnchan
|
chan/middleware.py
|
1
|
1108
|
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from django.db import connection
import pytz
from django.utils import timezone
from django.utils.deprecation import MiddlewareMixin
class SqlPrintMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
sqltime = 0 # Variable to store execution time
for query in connection.queries:
sqltime += float(query["time"]) # Add the time that the query took to the total
# len(connection.queries) = total number of queries
print("Page {} render: {}sec for {} queries".format(request.path.encode("utf-8"), sqltime, len(connection.queries)))
return response
class TimezoneMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
tzname = "Europe/Helsinki"
if tzname:
timezone.activate(pytz.timezone(tzname))
print("activated tz "+tzname)
else:
timezone.deactivate()
print("deactivated tz")
response = self.get_response(request)
return response
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
9094,
13,
24,
1882,
199,
199,
504,
1639,
14,
697,
492,
1950,
199,
646,
15444,
199,
504,
1639,
14,
1208,
492,
7137,
199,
504,
1639,
14,
1208,
14,
15383,
492,
603,
3551,
4256,
199,
199,
533,
428,
1710,
5375,
6608,
8,
785,
304,
199,
198,
318,
636,
826,
721,
277,
12,
664,
63,
1310,
304,
507,
198,
277,
14,
362,
63,
1310,
275,
664,
63,
1310,
8299,
198,
318,
636,
1250,
721,
277,
12,
1056,
304,
9068,
198,
1310,
275,
291,
14,
362,
63,
1310,
8,
1069,
9,
507,
198,
3009,
521,
275,
378,
327,
4905,
370,
3877,
6451,
900,
507,
198,
509,
1827,
315,
1950,
14,
10590,
26,
686,
198,
3009,
521,
847,
2069,
8,
1131,
905,
521,
3135,
221,
327,
2654,
314,
900,
626,
314,
1827,
27221,
370,
314,
3141,
523,
267,
327,
822,
8,
2105,
14,
10590,
9,
275,
3141,
1329,
402,
9212,
507,
198,
1361,
480,
3276,
1052,
3795,
26,
1052,
3321,
367,
1052,
9212,
1674,
908,
8,
1069,
14,
515,
14,
2143,
480,
1624,
13,
24,
1288,
3875,
521,
12,
822,
8,
2105,
14,
10590,
1724,
523,
507,
198,
1107,
1177,
199,
199,
533,
4703,
2619,
6608,
8,
785,
304,
199,
198,
318,
636,
826,
721,
277,
12,
664,
63,
1310,
304,
507,
198,
277,
14,
362,
63,
1310,
275,
664,
63,
1310,
8299,
198,
318,
636,
1250,
721,
277,
12,
1056,
304,
9068,
198,
20027,
275,
298,
15201,
15,
40,
352,
11279,
73,
2,
507,
198,
692,
28054,
26,
686,
198,
7145,
14,
8222,
8,
21948,
14,
7145,
8,
20027,
430,
686,
198,
1361,
480,
18218,
5823,
7210,
20027,
9,
507,
198,
2836,
26,
686,
198,
7145,
14,
24891,
342,
686,
198,
1361,
480,
271,
18218,
5823,
531,
1585,
507,
198,
1310,
275,
291,
14,
362,
63,
1310,
8,
1069,
9,
507,
198,
1107,
1177,
18118,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
9094,
13,
24,
1882,
199,
199,
504,
1639,
14,
697,
492,
1950,
199,
646,
15444,
199,
504,
1639,
14,
1208,
492,
7137,
199,
504,
1639,
14,
1208,
14,
15383,
492,
603,
3551,
4256,
199,
199,
533,
428,
1710,
5375,
6608,
8,
785,
304,
199,
198,
318,
636,
826,
721,
277,
12,
664,
63,
1310,
304,
507,
198,
277,
14,
362,
63,
1310,
275,
664,
63,
1310,
8299,
198,
318,
636,
1250,
721,
277,
12,
1056,
304,
9068,
198,
1310,
275,
291,
14,
362,
63,
1310,
8,
1069,
9,
507,
198,
3009,
521,
275,
378,
327,
4905,
370,
3877,
6451,
900,
507,
198,
509,
1827,
315,
1950,
14,
10590,
26,
686,
198,
3009,
521,
847,
2069,
8,
1131,
905,
521,
3135,
221,
327,
2654,
314,
900,
626,
314,
1827,
27221,
370,
314,
3141,
523,
267,
327,
822,
8,
2105,
14,
10590,
9,
275,
3141,
1329,
402,
9212,
507,
198,
1361,
480,
3276,
1052,
3795,
26,
1052,
3321,
367,
1052,
9212,
1674,
908,
8,
1069,
14,
515,
14,
2143,
480,
1624,
13,
24,
1288,
3875,
521,
12,
822,
8,
2105,
14,
10590,
1724,
523,
507,
198,
1107,
1177,
199,
199,
533,
4703,
2619,
6608,
8,
785,
304,
199,
198,
318,
636,
826,
721,
277,
12,
664,
63,
1310,
304,
507,
198,
277,
14,
362,
63,
1310,
275,
664,
63,
1310,
8299,
198,
318,
636,
1250,
721,
277,
12,
1056,
304,
9068,
198,
20027,
275,
298,
15201,
15,
40,
352,
11279,
73,
2,
507,
198,
692,
28054,
26,
686,
198,
7145,
14,
8222,
8,
21948,
14,
7145,
8,
20027,
430,
686,
198,
1361,
480,
18218,
5823,
7210,
20027,
9,
507,
198,
2836,
26,
686,
198,
7145,
14,
24891,
342,
686,
198,
1361,
480,
271,
18218,
5823,
531,
1585,
507,
198,
1310,
275,
291,
14,
362,
63,
1310,
8,
1069,
9,
507,
198,
1107,
1177,
18118,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
ehuelsmann/openipam
|
openIPAM/pydhcplib/pydhcplib/dhcp_packet.py
|
1
|
8561
|
# Anemon Dhcp
# Copyright (C) 2005 Mathieu Ignacio -- mignacio@april.org
#
# 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 St, Fifth Floor, Boston, MA 02110-1301, USA
import operator
from struct import unpack
from struct import pack
from dhcp_basic_packet import *
from dhcp_constants import *
from type_ipv4 import ipv4
from type_strlist import strlist
class DhcpPacket(DhcpBasicPacket):
def set_sender(self, sender):
self.sender = sender
def get_sender( self ):
return self.sender
def set_recv_interface( self, info ):
self.recv_interface = info
def get_recv_interface( self ):
return self.recv_interface
# Useful function for debugging
def PrintHeaders(self):
print "# Header fields\n"
print "readable_dhcp_headers = {"
for opt in ['op','htype','hlen','hops','xid','secs','flags',
'ciaddr','yiaddr','siaddr','giaddr','chaddr','sname','file'] :
begin = DhcpFields[opt][0]
end = DhcpFields[opt][0]+DhcpFields[opt][1]
data = self.packet_data[begin:end]
if DhcpFieldsTypes[opt] == "int" : result = str(data[0])
if DhcpFieldsTypes[opt] == "int2" : result = str(data[0]*256+data[0])
if DhcpFieldsTypes[opt] == "int4" : result = str(ipv4(data).int())
if DhcpFieldsTypes[opt] == "str" : result = strlist(data).str()
if DhcpFieldsTypes[opt] == "ipv4" : result = ipv4(data).str()
if DhcpFieldsTypes[opt] == "hwmac" : result = "".join(map(chr,data))
line = "\t'"+opt+"':"+str(data)+",\t# "+result
print line
print "\t'end':'true'}"
# Useful function for debugging
def PrintOptions(self):
print "# Options fields"
print "readable_dhcp_options = {"
for opt in self.options_data.keys():
data = self.options_data[opt]
result = ""
optnum = DhcpOptions[opt]
if DhcpOptionsTypes[optnum] == "char" : result = str(data[0])
if DhcpOptionsTypes[optnum] == "16-bits" : result = str(data[0]*256+data[0])
if DhcpOptionsTypes[optnum] == "32bits" : result = str(ipv4(data).int())
if DhcpOptionsTypes[optnum] == "string" : result = strlist(data).str()
if DhcpOptionsTypes[optnum] == "ipv4" : result = ipv4(data).str()
if DhcpOptionsTypes[optnum] == "ipv4+" :
for i in range(0,len(data),4) :
if len(data[i:i+4]) == 4 :
result += ipv4(data[i:i+4]).str() + " - "
line = "\t'"+opt+"':"+str(data)+",\t# "+result
print line
print "\t'end':'true'}"
# FIXME: This is called from IsDhcpSomethingPacket, but is this really
# needed? Or maybe this testing should be done in
# DhcpBasicPacket.DecodePacket().
# Test Packet Type
def IsDhcpSomethingPacket(self,type):
if self.IsDhcpPacket() == False : return False
if self.IsOption("dhcp_message_type") == False : return False
if self.GetOption("dhcp_message_type") != type : return False
return True
def IsDhcpDiscoverPacket(self):
return self.IsDhcpSomethingPacket([1])
def IsDhcpOfferPacket(self):
return self.IsDhcpSomethingPacket([2])
def IsDhcpRequestPacket(self):
return self.IsDhcpSomethingPacket([3])
def IsDhcpDeclinePacket(self):
return self.IsDhcpSomethingPacket([4])
def IsDhcpAckPacket(self):
return self.IsDhcpSomethingPacket([5])
def IsDhcpNackPacket(self):
return self.IsDhcpSomethingPacket([6])
def IsDhcpReleasePacket(self):
return self.IsDhcpSomethingPacket([7])
def IsDhcpInformPacket(self):
return self.IsDhcpSomethingPacket([8])
def GetMultipleOptions(self,options=()):
result = {}
for each in options:
result[each] = self.GetOption(each)
return result
def SetMultipleOptions(self,options={}):
for each in options.keys():
self.SetOption(each,options[each])
# Creating Response Packet
# Server-side functions
# From RFC 2132 page 28/29
def CreateDhcpOfferPacketFrom(self,src): # src = discover packet
self.set_sender(src.get_sender())
self.SetOption("htype",src.GetOption("htype"))
self.SetOption("xid",src.GetOption("xid"))
self.SetOption("flags",src.GetOption("flags"))
self.SetOption("giaddr",src.GetOption("giaddr"))
self.SetOption("chaddr",src.GetOption("chaddr"))
self.TransformToDhcpOfferPacket()
self.SetOption("ip_address_lease_time",src.GetOption("ip_address_lease_time"))
self.set_recv_interface( src.get_recv_interface() )
def TransformToDhcpOfferPacket(self):
self.SetOption("dhcp_message_type",[2])
self.SetOption("op",[2])
self.SetOption("hlen",[6])
self.DeleteOption("secs")
self.DeleteOption("ciaddr")
self.DeleteOption("request_ip_address")
self.DeleteOption("parameter_request_list")
self.DeleteOption("client_identifier")
self.DeleteOption("maximum_message_size")
""" Dhcp ACK packet creation """
def CreateDhcpAckPacketFrom(self,src): # src = request or inform packet
self.set_sender(src.get_sender())
self.SetOption("htype",src.GetOption("htype"))
self.SetOption("xid",src.GetOption("xid"))
self.SetOption("ciaddr",src.GetOption("ciaddr"))
self.SetOption("flags",src.GetOption("flags"))
self.SetOption("giaddr",src.GetOption("giaddr"))
self.SetOption("chaddr",src.GetOption("chaddr"))
self.TransformToDhcpAckPacket()
self.SetOption("ip_address_lease_time",src.GetOption("ip_address_lease_time"))
self.set_recv_interface( src.get_recv_interface() )
def TransformToDhcpAckPacket(self): # src = request or inform packet
self.SetOption("op",[2])
self.SetOption("hlen",[6])
self.SetOption("dhcp_message_type",[5])
self.DeleteOption("secs")
self.DeleteOption("request_ip_address")
self.DeleteOption("parameter_request_list")
self.DeleteOption("client_identifier")
self.DeleteOption("maximum_message_size")
""" Dhcp NACK packet creation """
def CreateDhcpNackPacketFrom(self,src): # src = request or inform packet
self.set_sender(src.get_sender())
self.SetOption("htype",src.GetOption("htype"))
self.SetOption("xid",src.GetOption("xid"))
self.SetOption("flags",src.GetOption("flags"))
self.SetOption("giaddr",src.GetOption("giaddr"))
self.SetOption("chaddr",src.GetOption("chaddr"))
self.TransformToDhcpNackPacket()
self.set_recv_interface( src.get_recv_interface() )
def TransformToDhcpNackPacket(self):
self.SetOption("op",[2])
self.SetOption("hlen",[6])
self.DeleteOption("secs")
self.DeleteOption("ciaddr")
self.DeleteOption("yiaddr")
self.DeleteOption("siaddr")
self.DeleteOption("sname")
self.DeleteOption("file")
self.DeleteOption("request_ip_address")
self.DeleteOption("ip_address_lease_time")
self.DeleteOption("parameter_request_list")
self.DeleteOption("client_identifier")
self.DeleteOption("maximum_message_size")
self.SetOption("dhcp_message_type",[6])
""" GetClientIdentifier """
def GetClientIdentifier(self) :
if self.IsOption("client_identifier") :
return self.GetOption("client_identifier")
return []
def GetGiaddr(self) :
return self.GetOption("giaddr")
def GetHardwareAddress(self) :
length = self.GetOption("hlen")[0]
full_hw = self.GetOption("chaddr")
if length!=[] and length<len(full_hw) : return full_hw[0:length]
return full_hw
|
gpl-3.0
|
[
3,
437,
685,
2106,
577,
14968,
199,
3,
1898,
334,
35,
9,
11811,
21066,
29364,
20489,
65,
10377,
1553,
333,
1030,
65,
10377,
32,
439,
10363,
14,
1308,
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,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
12,
8217,
199,
199,
646,
4182,
199,
504,
2702,
492,
7787,
199,
504,
2702,
492,
1706,
199,
504,
19064,
63,
4316,
63,
6253,
492,
627,
199,
504,
19064,
63,
5559,
492,
627,
199,
504,
730,
63,
4774,
20,
492,
3278,
20,
199,
504,
730,
63,
495,
513,
492,
620,
513,
199,
533,
577,
14968,
2726,
8,
36,
14968,
6845,
2726,
304,
339,
347,
663,
63,
8114,
8,
277,
12,
8904,
304,
267,
291,
14,
8114,
275,
8904,
339,
347,
664,
63,
8114,
8,
291,
3461,
267,
372,
291,
14,
8114,
339,
347,
663,
63,
7637,
63,
3266,
8,
291,
12,
2256,
3461,
267,
291,
14,
7637,
63,
3266,
275,
2256,
339,
347,
664,
63,
7637,
63,
3266,
8,
291,
3461,
267,
372,
291,
14,
7637,
63,
3266,
339,
327,
18491,
805,
367,
10201,
272,
347,
9101,
9883,
8,
277,
304,
267,
870,
5426,
10240,
1504,
60,
78,
2,
267,
870,
298,
11875,
63,
10801,
63,
2139,
275,
2420,
267,
367,
2450,
315,
221,
788,
411,
1673,
72,
466,
1673,
72,
552,
1673,
72,
1483,
1673,
21352,
1673,
4855,
1673,
2469,
297,
2151,
283,
559,
2697,
1673,
21643,
2697,
1673,
338,
2697,
1673,
6153,
2697,
1673,
335,
2697,
1673,
27469,
1673,
493,
418,
520,
288,
5386,
275,
577,
14968,
7304,
59,
2992,
1527,
16,
61,
288,
1284,
275,
577,
14968,
7304,
59,
2992,
1527,
16,
2807,
36,
14968,
7304,
59,
2992,
1527,
17,
61,
288,
666,
275,
291,
14,
6253,
63,
576,
59,
5037,
26,
500,
61,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
442,
2,
520,
754,
275,
620,
8,
576,
59,
16,
566,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
442,
18,
2,
520,
754,
275,
620,
8,
576,
59,
16,
3672,
3912,
11,
576,
59,
16,
566,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
442,
20,
2,
520,
754,
275,
620,
8,
4774,
20,
8,
576,
680,
442,
1012,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
495,
2,
520,
754,
275,
620,
513,
8,
576,
680,
495,
342,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
4774,
20,
2,
520,
754,
275,
3278,
20,
8,
576,
680,
495,
342,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
8090,
3088,
2,
520,
754,
275,
10587,
904,
8,
1130,
8,
10194,
12,
576,
430,
953,
1004,
275,
1867,
84,
4065,
11,
2992,
5207,
356,
7709,
495,
8,
576,
6393,
22260,
84,
3,
7210,
1099,
288,
870,
1004,
267,
870,
1867,
84,
7,
500,
5242,
2052,
936,
2,
339,
327,
18491,
805,
367,
10201,
272,
347,
9101,
4558,
8,
277,
304,
267,
870,
5426,
8394,
1504,
2,
267,
870,
298,
11875,
63,
10801,
63,
1419,
275,
2420,
267,
367,
2450,
315,
291,
14,
1419,
63,
576,
14,
1612,
837,
288,
666,
275,
291,
14,
1419,
63,
576,
59,
2992,
61,
288,
754,
275,
3087,
288,
2450,
1507,
221,
275,
577,
14968,
4558,
59,
2992,
61,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
1560,
2,
520,
754,
275,
620,
8,
576,
59,
16,
566,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
975,
13,
5609,
2,
520,
754,
275,
620,
8,
576,
59,
16,
3672,
3912,
11,
576,
59,
16,
566,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
708,
5609,
2,
520,
754,
275,
620,
8,
4774,
20,
8,
576,
680,
442,
1012,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
875,
2,
520,
754,
275,
620,
513,
8,
576,
680,
495,
342,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
4774,
20,
2,
520,
754,
275,
3278,
20,
8,
576,
680,
495,
342,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
4774,
20,
5207,
520,
355,
367,
284,
315,
1425,
8,
16,
12,
552,
8,
576,
395,
20,
9,
520,
490,
340,
822,
8,
576,
59,
73,
26,
73,
11,
20,
566,
508,
841,
520,
717,
754,
847,
3278,
20,
8,
576,
59,
73,
26,
73,
11,
20,
6575,
495,
342,
435,
298,
446,
298,
288,
1004,
275,
1867,
84,
4065,
11,
2992,
5207,
356,
7709,
495,
8,
576,
6393,
22260,
84,
3,
7210,
1099,
288,
870,
1004,
267,
870,
1867,
84,
7,
500,
5242,
2052,
936,
2,
268,
10798,
272,
327,
7600,
26,
961,
365,
2797,
687,
6596,
36,
14968,
20641,
2726,
12,
1325,
365,
642,
7710,
272,
327,
4346,
31,
221,
4236,
11703,
642,
5343,
1077,
506,
4224,
315,
272,
327,
577,
14968,
6845,
2726,
14,
9400,
2726,
1252,
339,
327,
1379,
31782,
2434,
272,
347,
6596,
36,
14968,
20641,
2726,
8,
277,
12,
466,
304,
267,
340,
291,
14,
1831,
36,
14968,
2726,
342,
508,
756,
520,
372,
756,
267,
340,
291,
14,
1831,
2602,
480,
10801,
63,
1188,
63,
466,
531,
508,
756,
520,
372,
756,
267,
340,
291,
14,
1002,
2602,
480,
10801,
63,
1188,
63,
466,
531,
1137,
730,
520
] |
[
437,
685,
2106,
577,
14968,
199,
3,
1898,
334,
35,
9,
11811,
21066,
29364,
20489,
65,
10377,
1553,
333,
1030,
65,
10377,
32,
439,
10363,
14,
1308,
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,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
12,
8217,
199,
199,
646,
4182,
199,
504,
2702,
492,
7787,
199,
504,
2702,
492,
1706,
199,
504,
19064,
63,
4316,
63,
6253,
492,
627,
199,
504,
19064,
63,
5559,
492,
627,
199,
504,
730,
63,
4774,
20,
492,
3278,
20,
199,
504,
730,
63,
495,
513,
492,
620,
513,
199,
533,
577,
14968,
2726,
8,
36,
14968,
6845,
2726,
304,
339,
347,
663,
63,
8114,
8,
277,
12,
8904,
304,
267,
291,
14,
8114,
275,
8904,
339,
347,
664,
63,
8114,
8,
291,
3461,
267,
372,
291,
14,
8114,
339,
347,
663,
63,
7637,
63,
3266,
8,
291,
12,
2256,
3461,
267,
291,
14,
7637,
63,
3266,
275,
2256,
339,
347,
664,
63,
7637,
63,
3266,
8,
291,
3461,
267,
372,
291,
14,
7637,
63,
3266,
339,
327,
18491,
805,
367,
10201,
272,
347,
9101,
9883,
8,
277,
304,
267,
870,
5426,
10240,
1504,
60,
78,
2,
267,
870,
298,
11875,
63,
10801,
63,
2139,
275,
2420,
267,
367,
2450,
315,
221,
788,
411,
1673,
72,
466,
1673,
72,
552,
1673,
72,
1483,
1673,
21352,
1673,
4855,
1673,
2469,
297,
2151,
283,
559,
2697,
1673,
21643,
2697,
1673,
338,
2697,
1673,
6153,
2697,
1673,
335,
2697,
1673,
27469,
1673,
493,
418,
520,
288,
5386,
275,
577,
14968,
7304,
59,
2992,
1527,
16,
61,
288,
1284,
275,
577,
14968,
7304,
59,
2992,
1527,
16,
2807,
36,
14968,
7304,
59,
2992,
1527,
17,
61,
288,
666,
275,
291,
14,
6253,
63,
576,
59,
5037,
26,
500,
61,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
442,
2,
520,
754,
275,
620,
8,
576,
59,
16,
566,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
442,
18,
2,
520,
754,
275,
620,
8,
576,
59,
16,
3672,
3912,
11,
576,
59,
16,
566,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
442,
20,
2,
520,
754,
275,
620,
8,
4774,
20,
8,
576,
680,
442,
1012,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
495,
2,
520,
754,
275,
620,
513,
8,
576,
680,
495,
342,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
4774,
20,
2,
520,
754,
275,
3278,
20,
8,
576,
680,
495,
342,
288,
340,
577,
14968,
7304,
4100,
59,
2992,
61,
508,
298,
8090,
3088,
2,
520,
754,
275,
10587,
904,
8,
1130,
8,
10194,
12,
576,
430,
953,
1004,
275,
1867,
84,
4065,
11,
2992,
5207,
356,
7709,
495,
8,
576,
6393,
22260,
84,
3,
7210,
1099,
288,
870,
1004,
267,
870,
1867,
84,
7,
500,
5242,
2052,
936,
2,
339,
327,
18491,
805,
367,
10201,
272,
347,
9101,
4558,
8,
277,
304,
267,
870,
5426,
8394,
1504,
2,
267,
870,
298,
11875,
63,
10801,
63,
1419,
275,
2420,
267,
367,
2450,
315,
291,
14,
1419,
63,
576,
14,
1612,
837,
288,
666,
275,
291,
14,
1419,
63,
576,
59,
2992,
61,
288,
754,
275,
3087,
288,
2450,
1507,
221,
275,
577,
14968,
4558,
59,
2992,
61,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
1560,
2,
520,
754,
275,
620,
8,
576,
59,
16,
566,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
975,
13,
5609,
2,
520,
754,
275,
620,
8,
576,
59,
16,
3672,
3912,
11,
576,
59,
16,
566,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
708,
5609,
2,
520,
754,
275,
620,
8,
4774,
20,
8,
576,
680,
442,
1012,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
875,
2,
520,
754,
275,
620,
513,
8,
576,
680,
495,
342,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
4774,
20,
2,
520,
754,
275,
3278,
20,
8,
576,
680,
495,
342,
288,
340,
577,
14968,
4558,
4100,
59,
2992,
1507,
61,
508,
298,
4774,
20,
5207,
520,
355,
367,
284,
315,
1425,
8,
16,
12,
552,
8,
576,
395,
20,
9,
520,
490,
340,
822,
8,
576,
59,
73,
26,
73,
11,
20,
566,
508,
841,
520,
717,
754,
847,
3278,
20,
8,
576,
59,
73,
26,
73,
11,
20,
6575,
495,
342,
435,
298,
446,
298,
288,
1004,
275,
1867,
84,
4065,
11,
2992,
5207,
356,
7709,
495,
8,
576,
6393,
22260,
84,
3,
7210,
1099,
288,
870,
1004,
267,
870,
1867,
84,
7,
500,
5242,
2052,
936,
2,
268,
10798,
272,
327,
7600,
26,
961,
365,
2797,
687,
6596,
36,
14968,
20641,
2726,
12,
1325,
365,
642,
7710,
272,
327,
4346,
31,
221,
4236,
11703,
642,
5343,
1077,
506,
4224,
315,
272,
327,
577,
14968,
6845,
2726,
14,
9400,
2726,
1252,
339,
327,
1379,
31782,
2434,
272,
347,
6596,
36,
14968,
20641,
2726,
8,
277,
12,
466,
304,
267,
340,
291,
14,
1831,
36,
14968,
2726,
342,
508,
756,
520,
372,
756,
267,
340,
291,
14,
1831,
2602,
480,
10801,
63,
1188,
63,
466,
531,
508,
756,
520,
372,
756,
267,
340,
291,
14,
1002,
2602,
480,
10801,
63,
1188,
63,
466,
531,
1137,
730,
520,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
krisys/django
|
django/conf/locale/sk/formats.py
|
504
|
1173
|
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals
# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'j. F Y'
TIME_FORMAT = 'G:i'
DATETIME_FORMAT = 'j. F Y G:i'
YEAR_MONTH_FORMAT = 'F Y'
MONTH_DAY_FORMAT = 'j. F'
SHORT_DATE_FORMAT = 'd.m.Y'
SHORT_DATETIME_FORMAT = 'd.m.Y G:i'
FIRST_DAY_OF_WEEK = 1 # Monday
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
DATE_INPUT_FORMATS = [
'%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06'
'%y-%m-%d', # '06-10-25'
# '%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006'
]
DATETIME_INPUT_FORMATS = [
'%d.%m.%Y %H:%M:%S', # '25.10.2006 14:30:59'
'%d.%m.%Y %H:%M:%S.%f', # '25.10.2006 14:30:59.000200'
'%d.%m.%Y %H:%M', # '25.10.2006 14:30'
'%d.%m.%Y', # '25.10.2006'
]
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = '\xa0' # non-breaking space
NUMBER_GROUPING = 3
|
bsd-3-clause
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
3,
710,
20841,
4807,
3326,
675,
314,
5634,
1434,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
5876,
15,
10372,
12645,
602,
199,
5390,
63,
4807,
275,
283,
74,
14,
481,
1488,
7,
199,
4961,
63,
4807,
275,
283,
39,
26,
73,
7,
199,
12488,
63,
4807,
275,
283,
74,
14,
481,
1488,
598,
26,
73,
7,
199,
19216,
63,
16413,
63,
4807,
275,
283,
38,
1488,
7,
199,
16413,
63,
11655,
63,
4807,
275,
283,
74,
14,
481,
7,
199,
13003,
63,
5390,
63,
4807,
275,
283,
68,
14,
77,
14,
57,
7,
199,
13003,
63,
12488,
63,
4807,
275,
283,
68,
14,
77,
14,
57,
598,
26,
73,
7,
199,
12903,
63,
11655,
63,
3359,
63,
24929,
275,
413,
221,
327,
32740,
199,
199,
3,
710,
20841,
7321,
63,
14019,
3326,
675,
314,
2018,
14053,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
2083,
14,
1360,
3,
6205,
13,
9866,
13,
17537,
199,
5390,
63,
7321,
63,
14019,
275,
359,
272,
1543,
68,
4111,
77,
4111,
57,
297,
1543,
68,
4111,
77,
4111,
89,
297,
258,
327,
283,
821,
14,
709,
14,
7968,
297,
283,
821,
14,
709,
14,
1690,
7,
272,
1543,
89,
3295,
77,
3295,
68,
297,
463,
327,
283,
1690,
13,
709,
13,
821,
7,
272,
327,
1543,
68,
14,
450,
34,
450,
57,
297,
1543,
68,
14,
450,
66,
14,
450,
57,
297,
221,
327,
283,
821,
14,
18365,
22459,
8315,
297,
283,
821,
14,
18365,
14,
8315,
7,
199,
61,
199,
12488,
63,
7321,
63,
14019,
275,
359,
272,
1543,
68,
4111,
77,
4111,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
14,
709,
14,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
4111,
77,
4111,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
14,
709,
14,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
4111,
77,
4111,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
14,
709,
14,
7968,
4329,
26,
1216,
7,
272,
1543,
68,
4111,
77,
4111,
57,
297,
4519,
327,
283,
821,
14,
709,
14,
7968,
7,
199,
61,
199,
23925,
63,
15828,
275,
13647,
199,
28714,
63,
15828,
275,
1557,
1800,
16,
7,
221,
327,
2222,
13,
4785,
316,
4601,
199,
9190,
63,
7823,
1206,
275,
650,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
3,
710,
20841,
4807,
3326,
675,
314,
5634,
1434,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
5876,
15,
10372,
12645,
602,
199,
5390,
63,
4807,
275,
283,
74,
14,
481,
1488,
7,
199,
4961,
63,
4807,
275,
283,
39,
26,
73,
7,
199,
12488,
63,
4807,
275,
283,
74,
14,
481,
1488,
598,
26,
73,
7,
199,
19216,
63,
16413,
63,
4807,
275,
283,
38,
1488,
7,
199,
16413,
63,
11655,
63,
4807,
275,
283,
74,
14,
481,
7,
199,
13003,
63,
5390,
63,
4807,
275,
283,
68,
14,
77,
14,
57,
7,
199,
13003,
63,
12488,
63,
4807,
275,
283,
68,
14,
77,
14,
57,
598,
26,
73,
7,
199,
12903,
63,
11655,
63,
3359,
63,
24929,
275,
413,
221,
327,
32740,
199,
199,
3,
710,
20841,
7321,
63,
14019,
3326,
675,
314,
2018,
14053,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
2083,
14,
1360,
3,
6205,
13,
9866,
13,
17537,
199,
5390,
63,
7321,
63,
14019,
275,
359,
272,
1543,
68,
4111,
77,
4111,
57,
297,
1543,
68,
4111,
77,
4111,
89,
297,
258,
327,
283,
821,
14,
709,
14,
7968,
297,
283,
821,
14,
709,
14,
1690,
7,
272,
1543,
89,
3295,
77,
3295,
68,
297,
463,
327,
283,
1690,
13,
709,
13,
821,
7,
272,
327,
1543,
68,
14,
450,
34,
450,
57,
297,
1543,
68,
14,
450,
66,
14,
450,
57,
297,
221,
327,
283,
821,
14,
18365,
22459,
8315,
297,
283,
821,
14,
18365,
14,
8315,
7,
199,
61,
199,
12488,
63,
7321,
63,
14019,
275,
359,
272,
1543,
68,
4111,
77,
4111,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
821,
14,
709,
14,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
68,
4111,
77,
4111,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
821,
14,
709,
14,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
68,
4111,
77,
4111,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
821,
14,
709,
14,
7968,
4329,
26,
1216,
7,
272,
1543,
68,
4111,
77,
4111,
57,
297,
4519,
327,
283,
821,
14,
709,
14,
7968,
7,
199,
61,
199,
23925,
63,
15828,
275,
13647,
199,
28714,
63,
15828,
275,
1557,
1800,
16,
7,
221,
327,
2222,
13,
4785,
316,
4601,
199,
9190,
63,
7823,
1206,
275,
650,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
FujitsuEnablingSoftwareTechnologyGmbH/tempest
|
tempest/api/object_storage/test_crossdomain.py
|
4
|
2175
|
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.api.object_storage import base
from tempest.common import custom_matchers
from tempest import test
class CrossdomainTest(base.BaseObjectTest):
@classmethod
def resource_setup(cls):
super(CrossdomainTest, cls).resource_setup()
cls.xml_start = '<?xml version="1.0"?>\n' \
'<!DOCTYPE cross-domain-policy SYSTEM ' \
'"http://www.adobe.com/xml/dtds/cross-domain-policy.' \
'dtd" >\n<cross-domain-policy>\n'
cls.xml_end = "</cross-domain-policy>"
def setUp(self):
super(CrossdomainTest, self).setUp()
# Turning http://.../v1/foobar into http://.../
self.account_client.skip_path()
@test.attr('gate')
@test.idempotent_id('d1b8b031-b622-4010-82f9-ff78a9e915c7')
@test.requires_ext(extension='crossdomain', service='object')
def test_get_crossdomain_policy(self):
resp, body = self.account_client.get("crossdomain.xml", {})
self.assertTrue(body.startswith(self.xml_start) and
body.endswith(self.xml_end))
# The target of the request is not any Swift resource. Therefore, the
# existence of response header is checked without a custom matcher.
self.assertIn('content-length', resp)
self.assertIn('content-type', resp)
self.assertIn('x-trans-id', resp)
self.assertIn('date', resp)
# Check only the format of common headers with custom matcher
self.assertThat(resp, custom_matchers.AreAllWellFormatted())
|
apache-2.0
|
[
3,
1898,
334,
35,
9,
6171,
325,
1944,
6278,
26124,
665,
606,
25843,
32,
287,
79,
6278,
14,
957,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
24076,
14,
1246,
14,
785,
63,
3494,
492,
1300,
199,
504,
24076,
14,
2330,
492,
3537,
63,
1431,
1192,
199,
504,
24076,
492,
511,
421,
199,
533,
28965,
2261,
774,
8,
1095,
14,
1563,
1692,
774,
304,
339,
768,
3744,
272,
347,
2073,
63,
2758,
8,
1886,
304,
267,
1613,
8,
14072,
2261,
774,
12,
843,
680,
1927,
63,
2758,
342,
398,
843,
14,
1652,
63,
928,
275,
2650,
31,
1652,
1015,
628,
17,
14,
16,
14863,
3072,
78,
7,
971,
717,
2650,
1,
16556,
8059,
13,
2261,
13,
3185,
20859,
283,
971,
717,
5522,
1014,
921,
1544,
14,
5129,
1235,
14,
957,
15,
1652,
15,
3583,
795,
15,
7925,
13,
2261,
13,
3185,
3530,
971,
717,
283,
15662,
2,
690,
60,
78,
28,
7925,
13,
2261,
13,
3185,
3072,
78,
7,
398,
843,
14,
1652,
63,
500,
275,
15683,
7925,
13,
2261,
13,
3185,
4335,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
14072,
2261,
774,
12,
291,
680,
5996,
342,
398,
327,
16147,
316,
1455,
921,
1396,
15,
86,
17,
15,
9664,
1901,
1455,
921,
1396,
15,
267,
291,
14,
2048,
63,
1258,
14,
2759,
63,
515,
342,
339,
768,
396,
14,
962,
360,
3237,
358,
272,
768,
396,
14,
21307,
63,
344,
360,
68,
17,
66,
24,
66,
19225,
13,
66,
30603,
13,
8854,
16,
13,
2564,
70,
25,
13,
556,
2277,
65,
25,
69,
32532,
67,
23,
358,
272,
768,
396,
14,
6537,
63,
832,
8,
3435,
534,
7925,
2261,
297,
2435,
534,
785,
358,
272,
347,
511,
63,
362,
63,
7925,
2261,
63,
3185,
8,
277,
304,
267,
3085,
12,
2396,
275,
291,
14,
2048,
63,
1258,
14,
362,
480,
7925,
2261,
14,
1652,
401,
5009,
398,
291,
14,
1815,
8,
2030,
14,
2460,
8,
277,
14,
1652,
63,
928,
9,
436,
717,
2396,
14,
4130,
8,
277,
14,
1652,
63,
500,
430,
398,
327,
710,
1347,
402,
314,
1056,
365,
440,
1263,
16666,
2949,
2073,
14,
21039,
12,
314,
267,
327,
23780,
402,
1177,
1406,
365,
7923,
1928,
282,
3537,
15990,
14,
267,
291,
14,
4080,
360,
1317,
13,
1267,
297,
3085,
9,
267,
291,
14,
4080,
360,
1317,
13,
466,
297,
3085,
9,
267,
291,
14,
4080,
360,
88,
13,
1515,
13,
344,
297,
3085,
9,
267,
291,
14,
4080,
360,
602,
297,
3085,
9,
267,
327,
2670,
1454,
314,
1475,
402,
2863,
2323,
543,
3537,
15990,
267,
291,
14,
27433,
8,
4518,
12,
3537,
63,
1431,
1192,
14,
17683,
2422,
55,
1697,
31602,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
35,
9,
6171,
325,
1944,
6278,
26124,
665,
606,
25843,
32,
287,
79,
6278,
14,
957,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
24076,
14,
1246,
14,
785,
63,
3494,
492,
1300,
199,
504,
24076,
14,
2330,
492,
3537,
63,
1431,
1192,
199,
504,
24076,
492,
511,
421,
199,
533,
28965,
2261,
774,
8,
1095,
14,
1563,
1692,
774,
304,
339,
768,
3744,
272,
347,
2073,
63,
2758,
8,
1886,
304,
267,
1613,
8,
14072,
2261,
774,
12,
843,
680,
1927,
63,
2758,
342,
398,
843,
14,
1652,
63,
928,
275,
2650,
31,
1652,
1015,
628,
17,
14,
16,
14863,
3072,
78,
7,
971,
717,
2650,
1,
16556,
8059,
13,
2261,
13,
3185,
20859,
283,
971,
717,
5522,
1014,
921,
1544,
14,
5129,
1235,
14,
957,
15,
1652,
15,
3583,
795,
15,
7925,
13,
2261,
13,
3185,
3530,
971,
717,
283,
15662,
2,
690,
60,
78,
28,
7925,
13,
2261,
13,
3185,
3072,
78,
7,
398,
843,
14,
1652,
63,
500,
275,
15683,
7925,
13,
2261,
13,
3185,
4335,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
14072,
2261,
774,
12,
291,
680,
5996,
342,
398,
327,
16147,
316,
1455,
921,
1396,
15,
86,
17,
15,
9664,
1901,
1455,
921,
1396,
15,
267,
291,
14,
2048,
63,
1258,
14,
2759,
63,
515,
342,
339,
768,
396,
14,
962,
360,
3237,
358,
272,
768,
396,
14,
21307,
63,
344,
360,
68,
17,
66,
24,
66,
19225,
13,
66,
30603,
13,
8854,
16,
13,
2564,
70,
25,
13,
556,
2277,
65,
25,
69,
32532,
67,
23,
358,
272,
768,
396,
14,
6537,
63,
832,
8,
3435,
534,
7925,
2261,
297,
2435,
534,
785,
358,
272,
347,
511,
63,
362,
63,
7925,
2261,
63,
3185,
8,
277,
304,
267,
3085,
12,
2396,
275,
291,
14,
2048,
63,
1258,
14,
362,
480,
7925,
2261,
14,
1652,
401,
5009,
398,
291,
14,
1815,
8,
2030,
14,
2460,
8,
277,
14,
1652,
63,
928,
9,
436,
717,
2396,
14,
4130,
8,
277,
14,
1652,
63,
500,
430,
398,
327,
710,
1347,
402,
314,
1056,
365,
440,
1263,
16666,
2949,
2073,
14,
21039,
12,
314,
267,
327,
23780,
402,
1177,
1406,
365,
7923,
1928,
282,
3537,
15990,
14,
267,
291,
14,
4080,
360,
1317,
13,
1267,
297,
3085,
9,
267,
291,
14,
4080,
360,
1317,
13,
466,
297,
3085,
9,
267,
291,
14,
4080,
360,
88,
13,
1515,
13,
344,
297,
3085,
9,
267,
291,
14,
4080,
360,
602,
297,
3085,
9,
267,
327,
2670,
1454,
314,
1475,
402,
2863,
2323,
543,
3537,
15990,
267,
291,
14,
27433,
8,
4518,
12,
3537,
63,
1431,
1192,
14,
17683,
2422,
55,
1697,
31602,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Snuzzo/dlx_kernel
|
tools/perf/python/twatch.py
|
7370
|
1334
|
#! /usr/bin/python
# -*- python -*-
# -*- coding: utf-8 -*-
# twatch - Experimental use of the perf python interface
# Copyright (C) 2011 Arnaldo Carvalho de Melo <acme@redhat.com>
#
# This application 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; version 2.
#
# This application 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.
import perf
def main():
cpus = perf.cpu_map()
threads = perf.thread_map()
evsel = perf.evsel(task = 1, comm = 1, mmap = 0,
wakeup_events = 1, watermark = 1,
sample_id_all = 1,
sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_TID)
evsel.open(cpus = cpus, threads = threads);
evlist = perf.evlist(cpus, threads)
evlist.add(evsel)
evlist.mmap()
while True:
evlist.poll(timeout = -1)
for cpu in cpus:
event = evlist.read_on_cpu(cpu)
if not event:
continue
print "cpu: %2d, pid: %4d, tid: %4d" % (event.sample_cpu,
event.sample_pid,
event.sample_tid),
print event
if __name__ == '__main__':
main()
|
gpl-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2366,
1882,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
257,
307,
6821,
446,
23997,
279,
675,
402,
314,
8582,
2366,
3217,
199,
3,
257,
1898,
334,
35,
9,
7760,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
199,
3,
257,
961,
4223,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
257,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
257,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1015,
499,
14,
199,
3,
199,
3,
257,
961,
4223,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
257,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
257,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
257,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
199,
646,
8582,
199,
199,
318,
2446,
837,
199,
198,
8896,
275,
8582,
14,
3541,
63,
1130,
342,
199,
198,
6962,
275,
8582,
14,
2671,
63,
1130,
342,
199,
198,
6857,
5891,
275,
8582,
14,
6857,
5891,
8,
1765,
275,
413,
12,
1923,
275,
413,
12,
21991,
275,
378,
12,
1585,
257,
21560,
384,
63,
4368,
275,
413,
12,
22834,
1657,
275,
413,
12,
1585,
257,
2690,
63,
344,
63,
452,
275,
413,
12,
1585,
257,
2690,
63,
466,
275,
8582,
14,
15827,
63,
27081,
1204,
8582,
14,
15827,
63,
52,
998,
1204,
8582,
14,
15827,
63,
11011,
1204,
8582,
14,
15827,
63,
52,
998,
9,
199,
198,
6857,
5891,
14,
1490,
8,
8896,
275,
24174,
12,
7183,
275,
7183,
2736,
199,
198,
6857,
513,
275,
8582,
14,
6857,
513,
8,
8896,
12,
7183,
9,
199,
198,
6857,
513,
14,
525,
8,
6857,
5891,
9,
199,
198,
6857,
513,
14,
20671,
342,
199,
198,
6710,
715,
26,
507,
198,
6857,
513,
14,
6843,
8,
2593,
275,
446,
17,
9,
507,
198,
509,
5033,
315,
24174,
26,
686,
198,
1430,
275,
8145,
513,
14,
739,
63,
265,
63,
3541,
8,
3541,
9,
686,
198,
692,
440,
1566,
26,
1585,
198,
6958,
686,
198,
1361,
298,
3541,
26,
450,
18,
68,
12,
4422,
26,
450,
20,
68,
12,
11559,
26,
450,
20,
68,
2,
450,
334,
1430,
14,
3271,
63,
3541,
12,
11674,
198,
1430,
14,
3271,
63,
3150,
12,
11674,
198,
1430,
14,
3271,
63,
5700,
395,
686,
198,
1361,
1566,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1182,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2366,
1882,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
257,
307,
6821,
446,
23997,
279,
675,
402,
314,
8582,
2366,
3217,
199,
3,
257,
1898,
334,
35,
9,
7760,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
199,
3,
257,
961,
4223,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
257,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
257,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1015,
499,
14,
199,
3,
199,
3,
257,
961,
4223,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
257,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
257,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
257,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
199,
646,
8582,
199,
199,
318,
2446,
837,
199,
198,
8896,
275,
8582,
14,
3541,
63,
1130,
342,
199,
198,
6962,
275,
8582,
14,
2671,
63,
1130,
342,
199,
198,
6857,
5891,
275,
8582,
14,
6857,
5891,
8,
1765,
275,
413,
12,
1923,
275,
413,
12,
21991,
275,
378,
12,
1585,
257,
21560,
384,
63,
4368,
275,
413,
12,
22834,
1657,
275,
413,
12,
1585,
257,
2690,
63,
344,
63,
452,
275,
413,
12,
1585,
257,
2690,
63,
466,
275,
8582,
14,
15827,
63,
27081,
1204,
8582,
14,
15827,
63,
52,
998,
1204,
8582,
14,
15827,
63,
11011,
1204,
8582,
14,
15827,
63,
52,
998,
9,
199,
198,
6857,
5891,
14,
1490,
8,
8896,
275,
24174,
12,
7183,
275,
7183,
2736,
199,
198,
6857,
513,
275,
8582,
14,
6857,
513,
8,
8896,
12,
7183,
9,
199,
198,
6857,
513,
14,
525,
8,
6857,
5891,
9,
199,
198,
6857,
513,
14,
20671,
342,
199,
198,
6710,
715,
26,
507,
198,
6857,
513,
14,
6843,
8,
2593,
275,
446,
17,
9,
507,
198,
509,
5033,
315,
24174,
26,
686,
198,
1430,
275,
8145,
513,
14,
739,
63,
265,
63,
3541,
8,
3541,
9,
686,
198,
692,
440,
1566,
26,
1585,
198,
6958,
686,
198,
1361,
298,
3541,
26,
450,
18,
68,
12,
4422,
26,
450,
20,
68,
12,
11559,
26,
450,
20,
68,
2,
450,
334,
1430,
14,
3271,
63,
3541,
12,
11674,
198,
1430,
14,
3271,
63,
3150,
12,
11674,
198,
1430,
14,
3271,
63,
5700,
395,
686,
198,
1361,
1566,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
dealien/Red-Magician
|
cogs/customcom.py
|
1
|
7261
|
from discord.ext import commands
from .utils.dataIO import dataIO
from .utils import checks
from .utils.chat_formatting import pagify, box
import os
import re
class CustomCommands:
"""Custom commands
Creates commands used to display text"""
def __init__(self, bot):
self.bot = bot
self.file_path = "data/customcom/commands.json"
self.c_commands = dataIO.load_json(self.file_path)
@commands.group(aliases=["cc"], pass_context=True, no_pm=True)
async def customcom(self, ctx):
"""Custom commands management"""
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
@customcom.command(name="add", pass_context=True)
@checks.mod_or_permissions(administrator=True)
async def cc_add(self, ctx, command: str, *, text):
"""Adds a custom command
Example:
[p]customcom add yourcommand Text you want
CCs can be enhanced with arguments:
https://dealien.github.io/Red-Magician-Docs/red_guide_command_args/
"""
server = ctx.message.server
command = command.lower()
if command in self.bot.commands:
await self.bot.say("That command is already a standard command.")
return
if server.id not in self.c_commands:
self.c_commands[server.id] = {}
cmdlist = self.c_commands[server.id]
if command not in cmdlist:
cmdlist[command] = text
self.c_commands[server.id] = cmdlist
dataIO.save_json(self.file_path, self.c_commands)
await self.bot.say("Custom command successfully added.")
else:
await self.bot.say("This command already exists. Use "
"`{}customcom edit` to edit it."
"".format(ctx.prefix))
@customcom.command(name="edit", pass_context=True)
@checks.mod_or_permissions(administrator=True)
async def cc_edit(self, ctx, command: str, *, text):
"""Edits a custom command
Example:
[p]customcom edit yourcommand Text you want
"""
server = ctx.message.server
command = command.lower()
if server.id in self.c_commands:
cmdlist = self.c_commands[server.id]
if command in cmdlist:
cmdlist[command] = text
self.c_commands[server.id] = cmdlist
dataIO.save_json(self.file_path, self.c_commands)
await self.bot.say("Custom command successfully edited.")
else:
await self.bot.say("That command doesn't exist. Use "
"`{}customcom add` to add it."
"".format(ctx.prefix))
else:
await self.bot.say("There are no custom commands in this server."
" Use `{}customcom add` to start adding some."
"".format(ctx.prefix))
@customcom.command(name="delete", pass_context=True)
@checks.mod_or_permissions(administrator=True)
async def cc_delete(self, ctx, command: str):
"""Deletes a custom command
Example:
[p]customcom delete yourcommand"""
server = ctx.message.server
command = command.lower()
if server.id in self.c_commands:
cmdlist = self.c_commands[server.id]
if command in cmdlist:
cmdlist.pop(command, None)
self.c_commands[server.id] = cmdlist
dataIO.save_json(self.file_path, self.c_commands)
await self.bot.say("Custom command successfully deleted.")
else:
await self.bot.say("That command doesn't exist.")
else:
await self.bot.say("There are no custom commands in this server."
" Use `{}customcom add` to start adding some."
"".format(ctx.prefix))
@customcom.command(name="list", pass_context=True)
async def cc_list(self, ctx):
"""Shows custom commands list"""
server = ctx.message.server
commands = self.c_commands.get(server.id, {})
if not commands:
await self.bot.say("There are no custom commands in this server."
" Use `{}customcom add` to start adding some."
"".format(ctx.prefix))
return
commands = ", ".join([ctx.prefix + c for c in sorted(commands)])
commands = "Custom commands:\n\n" + commands
if len(commands) < 1500:
await self.bot.say(box(commands))
else:
for page in pagify(commands, delims=[" ", "\n"]):
await self.bot.whisper(box(page))
async def on_message(self, message):
if len(message.content) < 2 or message.channel.is_private:
return
server = message.server
prefix = self.get_prefix(message)
if not prefix:
return
if server.id in self.c_commands and self.bot.user_allowed(message):
cmdlist = self.c_commands[server.id]
cmd = message.content[len(prefix):]
if cmd in cmdlist:
cmd = cmdlist[cmd]
cmd = self.format_cc(cmd, message)
await self.bot.send_message(message.channel, cmd)
elif cmd.lower() in cmdlist:
cmd = cmdlist[cmd.lower()]
cmd = self.format_cc(cmd, message)
await self.bot.send_message(message.channel, cmd)
def get_prefix(self, message):
for p in self.bot.settings.get_prefixes(message.server):
if message.content.startswith(p):
return p
return False
def format_cc(self, command, message):
results = re.findall("\{([^}]+)\}", command)
for result in results:
param = self.transform_parameter(result, message)
command = command.replace("{" + result + "}", param)
return command
def transform_parameter(self, result, message):
"""
For security reasons only specific objects are allowed
Internals are ignored
"""
raw_result = "{" + result + "}"
objects = {
"message": message,
"author": message.author,
"channel": message.channel,
"server": message.server
}
if result in objects:
return str(objects[result])
try:
first, second = result.split(".")
except ValueError:
return raw_result
if first in objects and not second.startswith("_"):
first = objects[first]
else:
return raw_result
return str(getattr(first, second, raw_result))
def check_folders():
if not os.path.exists("data/customcom"):
print("Creating data/customcom folder...")
os.makedirs("data/customcom")
def check_files():
f = "data/customcom/commands.json"
if not dataIO.is_valid_json(f):
print("Creating empty commands.json...")
dataIO.save_json(f, {})
def setup(bot):
check_folders()
check_files()
bot.add_cog(CustomCommands(bot))
|
gpl-3.0
|
[
504,
4339,
2181,
14,
832,
492,
3718,
199,
504,
1275,
1208,
14,
576,
2090,
492,
666,
2090,
199,
504,
1275,
1208,
492,
5920,
199,
504,
1275,
1208,
14,
10289,
63,
20034,
492,
9881,
2021,
12,
5689,
199,
646,
747,
199,
646,
295,
421,
199,
533,
8388,
14680,
26,
272,
408,
7223,
3718,
339,
10560,
3718,
1202,
370,
2929,
1318,
624,
339,
347,
636,
826,
721,
277,
12,
5888,
304,
267,
291,
14,
3018,
275,
5888,
267,
291,
14,
493,
63,
515,
275,
298,
576,
15,
4229,
957,
15,
4405,
14,
1001,
2,
267,
291,
14,
67,
63,
4405,
275,
666,
2090,
14,
912,
63,
1001,
8,
277,
14,
493,
63,
515,
9,
339,
768,
4405,
14,
923,
8,
8602,
6270,
2055,
2255,
986,
63,
1100,
29,
549,
12,
949,
63,
7073,
29,
549,
9,
272,
5316,
347,
3537,
957,
8,
277,
12,
4027,
304,
267,
408,
7223,
3718,
10041,
624,
267,
340,
4027,
14,
5350,
7620,
63,
954,
1531,
365,
488,
26,
288,
5517,
291,
14,
3018,
14,
2254,
63,
1760,
63,
3437,
8,
3799,
9,
339,
768,
4229,
957,
14,
1531,
8,
354,
628,
525,
401,
986,
63,
1100,
29,
549,
9,
272,
768,
8625,
14,
1494,
63,
269,
63,
6060,
8,
2113,
14710,
29,
549,
9,
272,
5316,
347,
7429,
63,
525,
8,
277,
12,
4027,
12,
1414,
26,
620,
12,
9889,
1318,
304,
267,
408,
14995,
282,
3537,
1414,
398,
5679,
26,
267,
359,
80,
61,
4229,
957,
1050,
2195,
1531,
4516,
1265,
2934,
398,
445,
13912,
883,
506,
655,
24384,
543,
2368,
26,
267,
4178,
921,
271,
10874,
287,
14,
5031,
14,
2308,
15,
10858,
13,
45,
6573,
5653,
13,
27858,
15,
581,
63,
17348,
63,
1531,
63,
589,
15,
267,
408,
267,
1654,
275,
4027,
14,
1188,
14,
1000,
267,
1414,
275,
1414,
14,
2325,
342,
267,
340,
1414,
315,
291,
14,
3018,
14,
4405,
26,
288,
5517,
291,
14,
3018,
14,
19787,
480,
17231,
1414,
365,
2575,
282,
4465,
1414,
2685,
288,
372,
267,
340,
1654,
14,
344,
440,
315,
291,
14,
67,
63,
4405,
26,
288,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
275,
1052,
267,
2088,
513,
275,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
267,
340,
1414,
440,
315,
2088,
513,
26,
288,
2088,
513,
59,
1531,
61,
275,
1318,
288,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
275,
2088,
513,
288,
666,
2090,
14,
2117,
63,
1001,
8,
277,
14,
493,
63,
515,
12,
291,
14,
67,
63,
4405,
9,
288,
5517,
291,
14,
3018,
14,
19787,
480,
7223,
1414,
8792,
3483,
2685,
267,
587,
26,
288,
5517,
291,
14,
3018,
14,
19787,
480,
2765,
1414,
2575,
3495,
14,
3645,
298,
3044,
24505,
2440,
4229,
957,
5283,
64,
370,
5283,
652,
2122,
3044,
10587,
908,
8,
3799,
14,
1861,
430,
339,
768,
4229,
957,
14,
1531,
8,
354,
628,
3773,
401,
986,
63,
1100,
29,
549,
9,
272,
768,
8625,
14,
1494,
63,
269,
63,
6060,
8,
2113,
14710,
29,
549,
9,
272,
5316,
347,
7429,
63,
3773,
8,
277,
12,
4027,
12,
1414,
26,
620,
12,
9889,
1318,
304,
267,
408,
37,
15256,
282,
3537,
1414,
398,
5679,
26,
267,
359,
80,
61,
4229,
957,
5283,
2195,
1531,
4516,
1265,
2934,
267,
408,
267,
1654,
275,
4027,
14,
1188,
14,
1000,
267,
1414,
275,
1414,
14,
2325,
342,
267,
340,
1654,
14,
344,
315,
291,
14,
67,
63,
4405,
26,
288,
2088,
513,
275,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
288,
340,
1414,
315,
2088,
513,
26,
355,
2088,
513,
59,
1531,
61,
275,
1318,
355,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
275,
2088,
513,
355,
666,
2090,
14,
2117,
63,
1001,
8,
277,
14,
493,
63,
515,
12,
291,
14,
67,
63,
4405,
9,
355,
5517,
291,
14,
3018,
14,
19787,
480,
7223,
1414,
8792,
21062,
2685,
288,
587,
26,
355,
5517,
291,
14,
3018,
14,
19787,
480,
17231,
1414,
3181,
1133,
2187,
14,
3645,
298,
3521,
24505,
2440,
4229,
957,
1050,
64,
370,
1050,
652,
2122,
3521,
10587,
908,
8,
3799,
14,
1861,
430,
267,
587,
26,
288,
5517,
291,
14,
3018,
14,
19787,
480,
10924,
787,
949,
3537,
3718,
315,
642,
1654,
2122,
3044,
298,
3645,
658,
2440,
4229,
957,
1050,
64,
370,
1343,
7791,
2005,
2122,
3044,
10587,
908,
8,
3799,
14,
1861,
430,
339,
768,
4229,
957,
14,
1531,
8,
354,
628,
1807,
401,
986,
63,
1100,
29,
549,
9,
272,
768,
8625,
14,
1494,
63,
269,
63,
6060,
8,
2113,
14710,
29,
549,
9,
272,
5316,
347,
7429,
63,
1807,
8,
277,
12,
4027,
12,
1414,
26,
620,
304,
267,
408,
26372,
282,
3537,
1414,
398,
5679,
26,
267,
359,
80,
61,
4229,
957,
3145,
2195,
1531,
624,
267,
1654,
275,
4027,
14,
1188,
14,
1000,
267,
1414,
275,
1414,
14,
2325,
342,
267,
340,
1654,
14,
344,
315,
291,
14,
67,
63,
4405,
26,
288,
2088,
513,
275,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
288,
340,
1414,
315,
2088,
513,
26,
355,
2088,
513,
14,
1935,
8,
1531,
12,
488,
9,
355,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
275,
2088,
513,
355,
666,
2090,
14,
2117,
63,
1001,
8,
277,
14,
493,
63,
515,
12,
291,
14,
67,
63,
4405,
9,
355,
5517,
291,
14,
3018,
14,
19787,
480,
7223,
1414,
8792,
5463,
2685,
288,
587,
26,
355,
5517,
291,
14,
3018,
14,
19787,
480,
17231,
1414,
3181,
1133,
2187,
2685,
267,
587,
26,
288,
5517,
291,
14,
3018,
14,
19787,
480,
10924,
787,
949,
3537,
3718,
315,
642,
1654,
2122,
3044,
298,
3645,
658,
2440,
4229,
957,
1050,
64,
370,
1343,
7791,
2005,
2122,
3044,
10587,
908,
8,
3799,
14,
1861,
430,
339,
768,
4229,
957,
14,
1531,
8,
354,
628,
513,
401,
986,
63,
1100,
29,
549,
9,
272,
5316,
347,
7429,
63,
513,
8,
277,
12,
4027,
304,
267,
408,
6824,
83,
3537,
3718,
769,
624,
267,
1654,
275,
4027,
14,
1188,
14,
1000,
267,
3718,
275,
291,
14,
67,
63,
4405,
14,
362,
8,
1000,
14,
344,
12,
5009,
398,
340,
440,
3718,
26,
288,
5517,
291
] |
[
4339,
2181,
14,
832,
492,
3718,
199,
504,
1275,
1208,
14,
576,
2090,
492,
666,
2090,
199,
504,
1275,
1208,
492,
5920,
199,
504,
1275,
1208,
14,
10289,
63,
20034,
492,
9881,
2021,
12,
5689,
199,
646,
747,
199,
646,
295,
421,
199,
533,
8388,
14680,
26,
272,
408,
7223,
3718,
339,
10560,
3718,
1202,
370,
2929,
1318,
624,
339,
347,
636,
826,
721,
277,
12,
5888,
304,
267,
291,
14,
3018,
275,
5888,
267,
291,
14,
493,
63,
515,
275,
298,
576,
15,
4229,
957,
15,
4405,
14,
1001,
2,
267,
291,
14,
67,
63,
4405,
275,
666,
2090,
14,
912,
63,
1001,
8,
277,
14,
493,
63,
515,
9,
339,
768,
4405,
14,
923,
8,
8602,
6270,
2055,
2255,
986,
63,
1100,
29,
549,
12,
949,
63,
7073,
29,
549,
9,
272,
5316,
347,
3537,
957,
8,
277,
12,
4027,
304,
267,
408,
7223,
3718,
10041,
624,
267,
340,
4027,
14,
5350,
7620,
63,
954,
1531,
365,
488,
26,
288,
5517,
291,
14,
3018,
14,
2254,
63,
1760,
63,
3437,
8,
3799,
9,
339,
768,
4229,
957,
14,
1531,
8,
354,
628,
525,
401,
986,
63,
1100,
29,
549,
9,
272,
768,
8625,
14,
1494,
63,
269,
63,
6060,
8,
2113,
14710,
29,
549,
9,
272,
5316,
347,
7429,
63,
525,
8,
277,
12,
4027,
12,
1414,
26,
620,
12,
9889,
1318,
304,
267,
408,
14995,
282,
3537,
1414,
398,
5679,
26,
267,
359,
80,
61,
4229,
957,
1050,
2195,
1531,
4516,
1265,
2934,
398,
445,
13912,
883,
506,
655,
24384,
543,
2368,
26,
267,
4178,
921,
271,
10874,
287,
14,
5031,
14,
2308,
15,
10858,
13,
45,
6573,
5653,
13,
27858,
15,
581,
63,
17348,
63,
1531,
63,
589,
15,
267,
408,
267,
1654,
275,
4027,
14,
1188,
14,
1000,
267,
1414,
275,
1414,
14,
2325,
342,
267,
340,
1414,
315,
291,
14,
3018,
14,
4405,
26,
288,
5517,
291,
14,
3018,
14,
19787,
480,
17231,
1414,
365,
2575,
282,
4465,
1414,
2685,
288,
372,
267,
340,
1654,
14,
344,
440,
315,
291,
14,
67,
63,
4405,
26,
288,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
275,
1052,
267,
2088,
513,
275,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
267,
340,
1414,
440,
315,
2088,
513,
26,
288,
2088,
513,
59,
1531,
61,
275,
1318,
288,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
275,
2088,
513,
288,
666,
2090,
14,
2117,
63,
1001,
8,
277,
14,
493,
63,
515,
12,
291,
14,
67,
63,
4405,
9,
288,
5517,
291,
14,
3018,
14,
19787,
480,
7223,
1414,
8792,
3483,
2685,
267,
587,
26,
288,
5517,
291,
14,
3018,
14,
19787,
480,
2765,
1414,
2575,
3495,
14,
3645,
298,
3044,
24505,
2440,
4229,
957,
5283,
64,
370,
5283,
652,
2122,
3044,
10587,
908,
8,
3799,
14,
1861,
430,
339,
768,
4229,
957,
14,
1531,
8,
354,
628,
3773,
401,
986,
63,
1100,
29,
549,
9,
272,
768,
8625,
14,
1494,
63,
269,
63,
6060,
8,
2113,
14710,
29,
549,
9,
272,
5316,
347,
7429,
63,
3773,
8,
277,
12,
4027,
12,
1414,
26,
620,
12,
9889,
1318,
304,
267,
408,
37,
15256,
282,
3537,
1414,
398,
5679,
26,
267,
359,
80,
61,
4229,
957,
5283,
2195,
1531,
4516,
1265,
2934,
267,
408,
267,
1654,
275,
4027,
14,
1188,
14,
1000,
267,
1414,
275,
1414,
14,
2325,
342,
267,
340,
1654,
14,
344,
315,
291,
14,
67,
63,
4405,
26,
288,
2088,
513,
275,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
288,
340,
1414,
315,
2088,
513,
26,
355,
2088,
513,
59,
1531,
61,
275,
1318,
355,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
275,
2088,
513,
355,
666,
2090,
14,
2117,
63,
1001,
8,
277,
14,
493,
63,
515,
12,
291,
14,
67,
63,
4405,
9,
355,
5517,
291,
14,
3018,
14,
19787,
480,
7223,
1414,
8792,
21062,
2685,
288,
587,
26,
355,
5517,
291,
14,
3018,
14,
19787,
480,
17231,
1414,
3181,
1133,
2187,
14,
3645,
298,
3521,
24505,
2440,
4229,
957,
1050,
64,
370,
1050,
652,
2122,
3521,
10587,
908,
8,
3799,
14,
1861,
430,
267,
587,
26,
288,
5517,
291,
14,
3018,
14,
19787,
480,
10924,
787,
949,
3537,
3718,
315,
642,
1654,
2122,
3044,
298,
3645,
658,
2440,
4229,
957,
1050,
64,
370,
1343,
7791,
2005,
2122,
3044,
10587,
908,
8,
3799,
14,
1861,
430,
339,
768,
4229,
957,
14,
1531,
8,
354,
628,
1807,
401,
986,
63,
1100,
29,
549,
9,
272,
768,
8625,
14,
1494,
63,
269,
63,
6060,
8,
2113,
14710,
29,
549,
9,
272,
5316,
347,
7429,
63,
1807,
8,
277,
12,
4027,
12,
1414,
26,
620,
304,
267,
408,
26372,
282,
3537,
1414,
398,
5679,
26,
267,
359,
80,
61,
4229,
957,
3145,
2195,
1531,
624,
267,
1654,
275,
4027,
14,
1188,
14,
1000,
267,
1414,
275,
1414,
14,
2325,
342,
267,
340,
1654,
14,
344,
315,
291,
14,
67,
63,
4405,
26,
288,
2088,
513,
275,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
288,
340,
1414,
315,
2088,
513,
26,
355,
2088,
513,
14,
1935,
8,
1531,
12,
488,
9,
355,
291,
14,
67,
63,
4405,
59,
1000,
14,
344,
61,
275,
2088,
513,
355,
666,
2090,
14,
2117,
63,
1001,
8,
277,
14,
493,
63,
515,
12,
291,
14,
67,
63,
4405,
9,
355,
5517,
291,
14,
3018,
14,
19787,
480,
7223,
1414,
8792,
5463,
2685,
288,
587,
26,
355,
5517,
291,
14,
3018,
14,
19787,
480,
17231,
1414,
3181,
1133,
2187,
2685,
267,
587,
26,
288,
5517,
291,
14,
3018,
14,
19787,
480,
10924,
787,
949,
3537,
3718,
315,
642,
1654,
2122,
3044,
298,
3645,
658,
2440,
4229,
957,
1050,
64,
370,
1343,
7791,
2005,
2122,
3044,
10587,
908,
8,
3799,
14,
1861,
430,
339,
768,
4229,
957,
14,
1531,
8,
354,
628,
513,
401,
986,
63,
1100,
29,
549,
9,
272,
5316,
347,
7429,
63,
513,
8,
277,
12,
4027,
304,
267,
408,
6824,
83,
3537,
3718,
769,
624,
267,
1654,
275,
4027,
14,
1188,
14,
1000,
267,
3718,
275,
291,
14,
67,
63,
4405,
14,
362,
8,
1000,
14,
344,
12,
5009,
398,
340,
440,
3718,
26,
288,
5517,
291,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
cosmiclattes/TPBviz
|
torrent/lib/python2.7/site-packages/django/core/management/commands/makemessages.py
|
98
|
18250
|
import fnmatch
import glob
import io
import os
import re
import sys
from itertools import dropwhile
from optparse import make_option
import django
from django.core.management.base import CommandError, NoArgsCommand
from django.core.management.utils import (handle_extensions, find_command,
popen_wrapper)
from django.utils.encoding import force_str
from django.utils.functional import total_ordering
from django.utils.text import get_text_list
from django.utils.jslex import prepare_js_for_gettext
plural_forms_re = re.compile(r'^(?P<value>"Plural-Forms.+?\\n")\s*$', re.MULTILINE | re.DOTALL)
STATUS_OK = 0
def check_programs(*programs):
for program in programs:
if find_command(program) is None:
raise CommandError("Can't find %s. Make sure you have GNU "
"gettext tools 0.15 or newer installed." % program)
@total_ordering
class TranslatableFile(object):
def __init__(self, dirpath, file_name):
self.file = file_name
self.dirpath = dirpath
def __repr__(self):
return "<TranslatableFile: %s>" % os.sep.join([self.dirpath, self.file])
def __eq__(self, other):
return self.dirpath == other.dirpath and self.file == other.file
def __lt__(self, other):
if self.dirpath == other.dirpath:
return self.file < other.file
return self.dirpath < other.dirpath
def process(self, command, potfile, domain, keep_pot=False):
"""
Extract translatable literals from self.file for :param domain:
creating or updating the :param potfile: POT file.
Uses the xgettext GNU gettext utility.
"""
from django.utils.translation import templatize
if command.verbosity > 1:
command.stdout.write('processing file %s in %s\n' % (self.file, self.dirpath))
_, file_ext = os.path.splitext(self.file)
if domain == 'djangojs' and file_ext in command.extensions:
is_templatized = True
orig_file = os.path.join(self.dirpath, self.file)
with open(orig_file) as fp:
src_data = fp.read()
src_data = prepare_js_for_gettext(src_data)
thefile = '%s.c' % self.file
work_file = os.path.join(self.dirpath, thefile)
with open(work_file, "w") as fp:
fp.write(src_data)
args = [
'xgettext',
'-d', domain,
'--language=C',
'--keyword=gettext_noop',
'--keyword=gettext_lazy',
'--keyword=ngettext_lazy:1,2',
'--keyword=pgettext:1c,2',
'--keyword=npgettext:1c,2,3',
'--from-code=UTF-8',
'--add-comments=Translators',
'--output=-'
]
if command.wrap:
args.append(command.wrap)
if command.location:
args.append(command.location)
args.append(work_file)
elif domain == 'django' and (file_ext == '.py' or file_ext in command.extensions):
thefile = self.file
orig_file = os.path.join(self.dirpath, self.file)
is_templatized = file_ext in command.extensions
if is_templatized:
with open(orig_file, "rU") as fp:
src_data = fp.read()
thefile = '%s.py' % self.file
content = templatize(src_data, orig_file[2:])
with open(os.path.join(self.dirpath, thefile), "w") as fp:
fp.write(content)
work_file = os.path.join(self.dirpath, thefile)
args = [
'xgettext',
'-d', domain,
'--language=Python',
'--keyword=gettext_noop',
'--keyword=gettext_lazy',
'--keyword=ngettext_lazy:1,2',
'--keyword=ugettext_noop',
'--keyword=ugettext_lazy',
'--keyword=ungettext_lazy:1,2',
'--keyword=pgettext:1c,2',
'--keyword=npgettext:1c,2,3',
'--keyword=pgettext_lazy:1c,2',
'--keyword=npgettext_lazy:1c,2,3',
'--from-code=UTF-8',
'--add-comments=Translators',
'--output=-'
]
if command.wrap:
args.append(command.wrap)
if command.location:
args.append(command.location)
args.append(work_file)
else:
return
msgs, errors, status = popen_wrapper(args)
if errors:
if status != STATUS_OK:
if is_templatized:
os.unlink(work_file)
if not keep_pot and os.path.exists(potfile):
os.unlink(potfile)
raise CommandError(
"errors happened while running xgettext on %s\n%s" %
(self.file, errors))
elif command.verbosity > 0:
# Print warnings
command.stdout.write(errors)
if msgs:
if is_templatized:
# Remove '.py' suffix
if os.name =='nt':
# Preserve '.\' prefix on Windows to respect gettext behavior
old = '#: ' + work_file
new = '#: ' + orig_file
else:
old = '#: ' + work_file[2:]
new = '#: ' + orig_file[2:]
msgs = msgs.replace(old, new)
write_pot_file(potfile, msgs)
if is_templatized:
os.unlink(work_file)
def write_pot_file(potfile, msgs):
"""
Write the :param potfile: POT file with the :param msgs: contents,
previously making sure its format is valid.
"""
if os.path.exists(potfile):
# Strip the header
msgs = '\n'.join(dropwhile(len, msgs.split('\n')))
else:
msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
with open(potfile, 'a') as fp:
fp.write(msgs)
class Command(NoArgsCommand):
option_list = NoArgsCommand.option_list + (
make_option('--locale', '-l', default=None, dest='locale', action='append',
help='Creates or updates the message files for the given locale(s) (e.g. pt_BR). '
'Can be used multiple times.'),
make_option('--domain', '-d', default='django', dest='domain',
help='The domain of the message files (default: "django").'),
make_option('--all', '-a', action='store_true', dest='all',
default=False, help='Updates the message files for all existing locales.'),
make_option('--extension', '-e', dest='extensions',
help='The file extension(s) to examine (default: "html,txt", or "js" if the domain is "djangojs"). Separate multiple extensions with commas, or use -e multiple times.',
action='append'),
make_option('--symlinks', '-s', action='store_true', dest='symlinks',
default=False, help='Follows symlinks to directories when examining source code and templates for translation strings.'),
make_option('--ignore', '-i', action='append', dest='ignore_patterns',
default=[], metavar='PATTERN', help='Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.'),
make_option('--no-default-ignore', action='store_false', dest='use_default_ignore_patterns',
default=True, help="Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'."),
make_option('--no-wrap', action='store_true', dest='no_wrap',
default=False, help="Don't break long message lines into several lines."),
make_option('--no-location', action='store_true', dest='no_location',
default=False, help="Don't write '#: filename:line' lines."),
make_option('--no-obsolete', action='store_true', dest='no_obsolete',
default=False, help="Remove obsolete message strings."),
make_option('--keep-pot', action='store_true', dest='keep_pot',
default=False, help="Keep .pot file after making messages. Useful when debugging."),
)
help = ("Runs over the entire source tree of the current directory and "
"pulls out all strings marked for translation. It creates (or updates) a message "
"file in the conf/locale (in the django tree) or locale (for projects and "
"applications) directory.\n\nYou must run this command with one of either the "
"--locale or --all options.")
requires_model_validation = False
leave_locale_alone = True
def handle_noargs(self, *args, **options):
locale = options.get('locale')
self.domain = options.get('domain')
self.verbosity = int(options.get('verbosity'))
process_all = options.get('all')
extensions = options.get('extensions')
self.symlinks = options.get('symlinks')
ignore_patterns = options.get('ignore_patterns')
if options.get('use_default_ignore_patterns'):
ignore_patterns += ['CVS', '.*', '*~', '*.pyc']
self.ignore_patterns = list(set(ignore_patterns))
self.wrap = '--no-wrap' if options.get('no_wrap') else ''
self.location = '--no-location' if options.get('no_location') else ''
self.no_obsolete = options.get('no_obsolete')
self.keep_pot = options.get('keep_pot')
if self.domain not in ('django', 'djangojs'):
raise CommandError("currently makemessages only supports domains "
"'django' and 'djangojs'")
if self.domain == 'djangojs':
exts = extensions if extensions else ['js']
else:
exts = extensions if extensions else ['html', 'txt']
self.extensions = handle_extensions(exts)
if (locale is None and not process_all) or self.domain is None:
raise CommandError("Type '%s help %s' for usage information." % (
os.path.basename(sys.argv[0]), sys.argv[1]))
if self.verbosity > 1:
self.stdout.write('examining files with the extensions: %s\n'
% get_text_list(list(self.extensions), 'and'))
# Need to ensure that the i18n framework is enabled
from django.conf import settings
if settings.configured:
settings.USE_I18N = True
else:
settings.configure(USE_I18N = True)
self.invoked_for_django = False
if os.path.isdir(os.path.join('conf', 'locale')):
localedir = os.path.abspath(os.path.join('conf', 'locale'))
self.invoked_for_django = True
# Ignoring all contrib apps
self.ignore_patterns += ['contrib/*']
elif os.path.isdir('locale'):
localedir = os.path.abspath('locale')
else:
raise CommandError("This script should be run from the Django Git "
"tree or your project or app tree. If you did indeed run it "
"from the Git checkout or your project or application, "
"maybe you are just missing the conf/locale (in the django "
"tree) or locale (for project and application) directory? It "
"is not created automatically, you have to create it by hand "
"if you want to enable i18n for your project or application.")
check_programs('xgettext')
potfile = self.build_pot_file(localedir)
# Build po files for each selected locale
locales = []
if locale is not None:
locales = locale
elif process_all:
locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir))
locales = [os.path.basename(l) for l in locale_dirs]
if locales:
check_programs('msguniq', 'msgmerge', 'msgattrib')
try:
for locale in locales:
if self.verbosity > 0:
self.stdout.write("processing locale %s\n" % locale)
self.write_po_file(potfile, locale)
finally:
if not self.keep_pot and os.path.exists(potfile):
os.unlink(potfile)
def build_pot_file(self, localedir):
file_list = self.find_files(".")
potfile = os.path.join(localedir, '%s.pot' % str(self.domain))
if os.path.exists(potfile):
# Remove a previous undeleted potfile, if any
os.unlink(potfile)
for f in file_list:
try:
f.process(self, potfile, self.domain, self.keep_pot)
except UnicodeDecodeError:
self.stdout.write("UnicodeDecodeError: skipped file %s in %s" % (f.file, f.dirpath))
return potfile
def find_files(self, root):
"""
Helper method to get all files in the given root.
"""
def is_ignored(path, ignore_patterns):
"""
Check if the given path should be ignored or not.
"""
filename = os.path.basename(path)
ignore = lambda pattern: fnmatch.fnmatchcase(filename, pattern)
return any(ignore(pattern) for pattern in ignore_patterns)
dir_suffix = '%s*' % os.sep
norm_patterns = [p[:-len(dir_suffix)] if p.endswith(dir_suffix) else p for p in self.ignore_patterns]
all_files = []
for dirpath, dirnames, filenames in os.walk(root, topdown=True, followlinks=self.symlinks):
for dirname in dirnames[:]:
if is_ignored(os.path.normpath(os.path.join(dirpath, dirname)), norm_patterns):
dirnames.remove(dirname)
if self.verbosity > 1:
self.stdout.write('ignoring directory %s\n' % dirname)
for filename in filenames:
if is_ignored(os.path.normpath(os.path.join(dirpath, filename)), self.ignore_patterns):
if self.verbosity > 1:
self.stdout.write('ignoring file %s in %s\n' % (filename, dirpath))
else:
all_files.append(TranslatableFile(dirpath, filename))
return sorted(all_files)
def write_po_file(self, potfile, locale):
"""
Creates or updates the PO file for self.domain and :param locale:.
Uses contents of the existing :param potfile:.
Uses mguniq, msgmerge, and msgattrib GNU gettext utilities.
"""
args = ['msguniq', '--to-code=utf-8']
if self.wrap:
args.append(self.wrap)
if self.location:
args.append(self.location)
args.append(potfile)
msgs, errors, status = popen_wrapper(args)
if errors:
if status != STATUS_OK:
raise CommandError(
"errors happened while running msguniq\n%s" % errors)
elif self.verbosity > 0:
self.stdout.write(errors)
basedir = os.path.join(os.path.dirname(potfile), locale, 'LC_MESSAGES')
if not os.path.isdir(basedir):
os.makedirs(basedir)
pofile = os.path.join(basedir, '%s.po' % str(self.domain))
if os.path.exists(pofile):
with open(potfile, 'w') as fp:
fp.write(msgs)
args = ['msgmerge', '-q']
if self.wrap:
args.append(self.wrap)
if self.location:
args.append(self.location)
args.extend([pofile, potfile])
msgs, errors, status = popen_wrapper(args)
if errors:
if status != STATUS_OK:
raise CommandError(
"errors happened while running msgmerge\n%s" % errors)
elif self.verbosity > 0:
self.stdout.write(errors)
elif not self.invoked_for_django:
msgs = self.copy_plural_forms(msgs, locale)
msgs = msgs.replace(
"#. #-#-#-#-# %s.pot (PACKAGE VERSION) #-#-#-#-#\n" % self.domain, "")
with open(pofile, 'w') as fp:
fp.write(msgs)
if self.no_obsolete:
args = ['msgattrib', '-o', pofile, '--no-obsolete']
if self.wrap:
args.append(self.wrap)
if self.location:
args.append(self.location)
args.append(pofile)
msgs, errors, status = popen_wrapper(args)
if errors:
if status != STATUS_OK:
raise CommandError(
"errors happened while running msgattrib\n%s" % errors)
elif self.verbosity > 0:
self.stdout.write(errors)
def copy_plural_forms(self, msgs, locale):
"""
Copies plural forms header contents from a Django catalog of locale to
the msgs string, inserting it at the right place. msgs should be the
contents of a newly created .po file.
"""
django_dir = os.path.normpath(os.path.join(os.path.dirname(django.__file__)))
if self.domain == 'djangojs':
domains = ('djangojs', 'django')
else:
domains = ('django',)
for domain in domains:
django_po = os.path.join(django_dir, 'conf', 'locale', locale, 'LC_MESSAGES', '%s.po' % domain)
if os.path.exists(django_po):
with io.open(django_po, 'rU', encoding='utf-8') as fp:
m = plural_forms_re.search(fp.read())
if m:
plural_form_line = force_str(m.group('value'))
if self.verbosity > 1:
self.stdout.write("copying plural forms: %s\n" % plural_form_line)
lines = []
found = False
for line in msgs.split('\n'):
if not found and (not line or plural_forms_re.search(line)):
line = '%s\n' % plural_form_line
found = True
lines.append(line)
msgs = '\n'.join(lines)
break
return msgs
|
gpl-3.0
|
[
646,
15951,
199,
646,
5739,
199,
646,
5890,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
504,
7975,
492,
5978,
6710,
199,
504,
8691,
492,
1852,
63,
1422,
199,
199,
646,
1639,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
14393,
12,
3091,
6213,
3110,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1208,
492,
334,
2479,
63,
5359,
12,
2342,
63,
1531,
12,
272,
17758,
63,
5029,
9,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
495,
199,
504,
1639,
14,
1208,
14,
15481,
492,
3141,
63,
7128,
199,
504,
1639,
14,
1208,
14,
505,
492,
664,
63,
505,
63,
513,
199,
504,
1639,
14,
1208,
14,
3596,
3113,
492,
9275,
63,
3596,
63,
509,
63,
5152,
199,
199,
10019,
63,
3351,
63,
264,
275,
295,
14,
2014,
8,
82,
24550,
48,
28,
585,
4335,
3714,
4889,
13,
26028,
11198,
1103,
78,
27681,
83,
32125,
295,
14,
16661,
1204,
295,
14,
16504,
9,
199,
6305,
63,
3593,
275,
378,
421,
199,
318,
1104,
63,
28464,
2031,
28464,
304,
272,
367,
2240,
315,
18572,
26,
267,
340,
2342,
63,
1531,
8,
6815,
9,
365,
488,
26,
288,
746,
14393,
480,
6049,
1133,
2342,
450,
83,
14,
4155,
3238,
1265,
1172,
1664,
298,
490,
298,
5152,
7249,
378,
14,
1046,
503,
15666,
4903,
2122,
450,
2240,
9,
421,
199,
32,
2923,
63,
7128,
199,
533,
6266,
25099,
1173,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
20648,
12,
570,
63,
354,
304,
267,
291,
14,
493,
275,
570,
63,
354,
267,
291,
14,
17254,
275,
20648,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
3188,
25099,
1173,
26,
450,
83,
4335,
450,
747,
14,
4127,
14,
904,
779,
277,
14,
17254,
12,
291,
14,
493,
566,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
372,
291,
14,
17254,
508,
1163,
14,
17254,
436,
291,
14,
493,
508,
1163,
14,
493,
339,
347,
636,
4116,
721,
277,
12,
1163,
304,
267,
340,
291,
14,
17254,
508,
1163,
14,
17254,
26,
288,
372,
291,
14,
493,
665,
1163,
14,
493,
267,
372,
291,
14,
17254,
665,
1163,
14,
17254,
339,
347,
2112,
8,
277,
12,
1414,
12,
27701,
493,
12,
2881,
12,
4215,
63,
14173,
29,
797,
304,
267,
408,
267,
12892,
1752,
25099,
18041,
687,
291,
14,
493,
367,
520,
635,
2881,
26,
267,
6425,
503,
12928,
314,
520,
635,
27701,
493,
26,
510,
1387,
570,
14,
398,
14911,
314,
671,
5152,
1664,
9796,
11420,
14,
267,
408,
398,
687,
1639,
14,
1208,
14,
6893,
492,
2388,
416,
30510,
398,
340,
1414,
14,
9833,
690,
413,
26,
288,
1414,
14,
2703,
14,
952,
360,
6338,
570,
450,
83,
315,
450,
83,
60,
78,
7,
450,
334,
277,
14,
493,
12,
291,
14,
17254,
430,
267,
5501,
570,
63,
832,
275,
747,
14,
515,
14,
7973,
8,
277,
14,
493,
9,
267,
340,
2881,
508,
283,
1176,
3596,
7,
436,
570,
63,
832,
315,
1414,
14,
5359,
26,
288,
365,
63,
808,
416,
22927,
275,
715,
288,
2306,
63,
493,
275,
747,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
291,
14,
493,
9,
288,
543,
1551,
8,
2981,
63,
493,
9,
465,
4090,
26,
355,
2928,
63,
576,
275,
4090,
14,
739,
342,
288,
2928,
63,
576,
275,
9275,
63,
3596,
63,
509,
63,
5152,
8,
2164,
63,
576,
9,
288,
314,
493,
275,
1543,
83,
14,
67,
7,
450,
291,
14,
493,
288,
1736,
63,
493,
275,
747,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
314,
493,
9,
288,
543,
1551,
8,
800,
63,
493,
12,
298,
87,
531,
465,
4090,
26,
355,
4090,
14,
952,
8,
2164,
63,
576,
9,
288,
1249,
275,
359,
355,
283,
88,
5152,
297,
355,
2475,
68,
297,
2881,
12,
355,
2850,
3671,
29,
35,
297,
355,
2850,
6691,
29,
5152,
63,
12921,
297,
355,
2850,
6691,
29,
5152,
63,
6395,
297,
355,
2850,
6691,
29,
28234,
63,
6395,
26,
17,
12,
18,
297,
355,
2850,
6691,
29,
80,
5152,
26,
17,
67,
12,
18,
297,
355,
2850,
6691,
29,
1590,
5152,
26,
17,
67,
12,
18,
12,
19,
297,
355,
2850,
504,
13,
600,
29,
6610,
13,
24,
297,
355,
2850,
525,
13,
6223,
29,
3188,
20830,
297,
355,
2850,
1199,
4022,
7,
288,
1622,
288,
340,
1414,
14,
3823,
26,
355,
1249,
14,
740,
8,
1531,
14,
3823,
9,
288,
340,
1414,
14,
1985,
26,
355,
1249,
14,
740,
8,
1531,
14,
1985,
9,
288,
1249,
14,
740,
8,
800,
63,
493,
9,
267,
916,
2881,
508,
283,
1176,
7,
436,
334,
493,
63,
832,
508,
1987,
647,
7,
503,
570,
63,
832,
315,
1414,
14,
5359,
304,
288,
314,
493,
275,
291,
14,
493,
288,
2306,
63,
493,
275,
747,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
291,
14,
493,
9,
288,
365,
63,
808,
416,
22927,
275,
570,
63,
832,
315,
1414,
14,
5359,
288,
340,
365,
63,
808,
416,
22927,
26,
355,
543,
1551,
8,
2981,
63,
493,
12,
298,
28978,
531,
465,
4090,
26,
490,
2928,
63,
576,
275,
4090,
14,
739,
342,
355,
314,
493,
275,
1543,
83,
14,
647,
7,
450,
291,
14,
493,
355,
1564,
275,
2388,
416,
30510,
8,
2164,
63,
576,
12,
2306,
63,
493,
59,
18,
5728,
355,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
314,
493,
395,
298,
87,
531,
465,
4090,
26,
490,
4090,
14,
952,
8,
1317,
9,
288,
1736,
63,
493,
275,
747,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
314,
493,
9,
288,
1249,
275,
359,
355,
283,
88,
5152,
297,
355,
2475,
68,
297,
2881,
12,
355,
2850,
3671,
29,
4718,
297,
355,
2850,
6691,
29,
5152,
63,
12921,
297,
355,
2850,
6691,
29,
5152,
63,
6395,
297,
355,
2850,
6691,
29,
28234,
63,
6395,
26,
17,
12,
18,
297,
355,
2850,
6691,
29,
23499,
63,
12921,
297,
355,
2850,
6691,
29,
23499,
63,
6395,
297,
355,
2850,
6691,
29,
324,
5152,
63,
6395,
26,
17,
12,
18,
297,
355,
2850,
6691,
29,
80,
5152,
26,
17,
67,
12,
18,
297,
355,
2850,
6691,
29,
1590
] |
[
15951,
199,
646,
5739,
199,
646,
5890,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
504,
7975,
492,
5978,
6710,
199,
504,
8691,
492,
1852,
63,
1422,
199,
199,
646,
1639,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
14393,
12,
3091,
6213,
3110,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1208,
492,
334,
2479,
63,
5359,
12,
2342,
63,
1531,
12,
272,
17758,
63,
5029,
9,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
495,
199,
504,
1639,
14,
1208,
14,
15481,
492,
3141,
63,
7128,
199,
504,
1639,
14,
1208,
14,
505,
492,
664,
63,
505,
63,
513,
199,
504,
1639,
14,
1208,
14,
3596,
3113,
492,
9275,
63,
3596,
63,
509,
63,
5152,
199,
199,
10019,
63,
3351,
63,
264,
275,
295,
14,
2014,
8,
82,
24550,
48,
28,
585,
4335,
3714,
4889,
13,
26028,
11198,
1103,
78,
27681,
83,
32125,
295,
14,
16661,
1204,
295,
14,
16504,
9,
199,
6305,
63,
3593,
275,
378,
421,
199,
318,
1104,
63,
28464,
2031,
28464,
304,
272,
367,
2240,
315,
18572,
26,
267,
340,
2342,
63,
1531,
8,
6815,
9,
365,
488,
26,
288,
746,
14393,
480,
6049,
1133,
2342,
450,
83,
14,
4155,
3238,
1265,
1172,
1664,
298,
490,
298,
5152,
7249,
378,
14,
1046,
503,
15666,
4903,
2122,
450,
2240,
9,
421,
199,
32,
2923,
63,
7128,
199,
533,
6266,
25099,
1173,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
20648,
12,
570,
63,
354,
304,
267,
291,
14,
493,
275,
570,
63,
354,
267,
291,
14,
17254,
275,
20648,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
3188,
25099,
1173,
26,
450,
83,
4335,
450,
747,
14,
4127,
14,
904,
779,
277,
14,
17254,
12,
291,
14,
493,
566,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
372,
291,
14,
17254,
508,
1163,
14,
17254,
436,
291,
14,
493,
508,
1163,
14,
493,
339,
347,
636,
4116,
721,
277,
12,
1163,
304,
267,
340,
291,
14,
17254,
508,
1163,
14,
17254,
26,
288,
372,
291,
14,
493,
665,
1163,
14,
493,
267,
372,
291,
14,
17254,
665,
1163,
14,
17254,
339,
347,
2112,
8,
277,
12,
1414,
12,
27701,
493,
12,
2881,
12,
4215,
63,
14173,
29,
797,
304,
267,
408,
267,
12892,
1752,
25099,
18041,
687,
291,
14,
493,
367,
520,
635,
2881,
26,
267,
6425,
503,
12928,
314,
520,
635,
27701,
493,
26,
510,
1387,
570,
14,
398,
14911,
314,
671,
5152,
1664,
9796,
11420,
14,
267,
408,
398,
687,
1639,
14,
1208,
14,
6893,
492,
2388,
416,
30510,
398,
340,
1414,
14,
9833,
690,
413,
26,
288,
1414,
14,
2703,
14,
952,
360,
6338,
570,
450,
83,
315,
450,
83,
60,
78,
7,
450,
334,
277,
14,
493,
12,
291,
14,
17254,
430,
267,
5501,
570,
63,
832,
275,
747,
14,
515,
14,
7973,
8,
277,
14,
493,
9,
267,
340,
2881,
508,
283,
1176,
3596,
7,
436,
570,
63,
832,
315,
1414,
14,
5359,
26,
288,
365,
63,
808,
416,
22927,
275,
715,
288,
2306,
63,
493,
275,
747,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
291,
14,
493,
9,
288,
543,
1551,
8,
2981,
63,
493,
9,
465,
4090,
26,
355,
2928,
63,
576,
275,
4090,
14,
739,
342,
288,
2928,
63,
576,
275,
9275,
63,
3596,
63,
509,
63,
5152,
8,
2164,
63,
576,
9,
288,
314,
493,
275,
1543,
83,
14,
67,
7,
450,
291,
14,
493,
288,
1736,
63,
493,
275,
747,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
314,
493,
9,
288,
543,
1551,
8,
800,
63,
493,
12,
298,
87,
531,
465,
4090,
26,
355,
4090,
14,
952,
8,
2164,
63,
576,
9,
288,
1249,
275,
359,
355,
283,
88,
5152,
297,
355,
2475,
68,
297,
2881,
12,
355,
2850,
3671,
29,
35,
297,
355,
2850,
6691,
29,
5152,
63,
12921,
297,
355,
2850,
6691,
29,
5152,
63,
6395,
297,
355,
2850,
6691,
29,
28234,
63,
6395,
26,
17,
12,
18,
297,
355,
2850,
6691,
29,
80,
5152,
26,
17,
67,
12,
18,
297,
355,
2850,
6691,
29,
1590,
5152,
26,
17,
67,
12,
18,
12,
19,
297,
355,
2850,
504,
13,
600,
29,
6610,
13,
24,
297,
355,
2850,
525,
13,
6223,
29,
3188,
20830,
297,
355,
2850,
1199,
4022,
7,
288,
1622,
288,
340,
1414,
14,
3823,
26,
355,
1249,
14,
740,
8,
1531,
14,
3823,
9,
288,
340,
1414,
14,
1985,
26,
355,
1249,
14,
740,
8,
1531,
14,
1985,
9,
288,
1249,
14,
740,
8,
800,
63,
493,
9,
267,
916,
2881,
508,
283,
1176,
7,
436,
334,
493,
63,
832,
508,
1987,
647,
7,
503,
570,
63,
832,
315,
1414,
14,
5359,
304,
288,
314,
493,
275,
291,
14,
493,
288,
2306,
63,
493,
275,
747,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
291,
14,
493,
9,
288,
365,
63,
808,
416,
22927,
275,
570,
63,
832,
315,
1414,
14,
5359,
288,
340,
365,
63,
808,
416,
22927,
26,
355,
543,
1551,
8,
2981,
63,
493,
12,
298,
28978,
531,
465,
4090,
26,
490,
2928,
63,
576,
275,
4090,
14,
739,
342,
355,
314,
493,
275,
1543,
83,
14,
647,
7,
450,
291,
14,
493,
355,
1564,
275,
2388,
416,
30510,
8,
2164,
63,
576,
12,
2306,
63,
493,
59,
18,
5728,
355,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
314,
493,
395,
298,
87,
531,
465,
4090,
26,
490,
4090,
14,
952,
8,
1317,
9,
288,
1736,
63,
493,
275,
747,
14,
515,
14,
904,
8,
277,
14,
17254,
12,
314,
493,
9,
288,
1249,
275,
359,
355,
283,
88,
5152,
297,
355,
2475,
68,
297,
2881,
12,
355,
2850,
3671,
29,
4718,
297,
355,
2850,
6691,
29,
5152,
63,
12921,
297,
355,
2850,
6691,
29,
5152,
63,
6395,
297,
355,
2850,
6691,
29,
28234,
63,
6395,
26,
17,
12,
18,
297,
355,
2850,
6691,
29,
23499,
63,
12921,
297,
355,
2850,
6691,
29,
23499,
63,
6395,
297,
355,
2850,
6691,
29,
324,
5152,
63,
6395,
26,
17,
12,
18,
297,
355,
2850,
6691,
29,
80,
5152,
26,
17,
67,
12,
18,
297,
355,
2850,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
1,
1,
1,
1,
1,
1
] |
optima-ict/odoo
|
doc/_extensions/github_link.py
|
229
|
3484
|
import inspect
import importlib
import os.path
from urlparse import urlunsplit
"""
* adds github_link(mode) context variable: provides URL (in relevant mode) of
current document on github
* if sphinx.ext.linkcode is enabled, automatically generates github linkcode
links (by setting config.linkcode_resolve)
Settings
========
* ``github_user``, username/organisation under which the project lives
* ``github_project``, name of the project on github
* (optional) ``version``, github branch to link to (default: master)
Notes
=====
* provided ``linkcode_resolve`` only supports Python domain
* generates https github links
* explicitly imports ``openerp``, so useless for anyone else
"""
def setup(app):
app.add_config_value('github_user', None, 'env')
app.add_config_value('github_project', None, 'env')
app.connect('html-page-context', add_doc_link)
def linkcode_resolve(domain, info):
""" Resolves provided object to corresponding github URL
"""
# TODO: js?
if domain != 'py':
return None
if not (app.config.github_user and app.config.github_project):
return None
module, fullname = info['module'], info['fullname']
# TODO: attributes/properties don't have modules, maybe try to look
# them up based on their cached host object?
if not module:
return None
obj = importlib.import_module(module)
for item in fullname.split('.'):
obj = getattr(obj, item, None)
if obj is None:
return None
# get original from decorated methods
try: obj = getattr(obj, '_orig')
except AttributeError: pass
try:
obj_source_path = inspect.getsourcefile(obj)
_, line = inspect.getsourcelines(obj)
except (TypeError, IOError):
# obj doesn't have a module, or something
return None
import openerp
# FIXME: make finding project root project-independent
project_root = os.path.join(os.path.dirname(openerp.__file__), '..')
return make_github_link(
app,
os.path.relpath(obj_source_path, project_root),
line)
app.config.linkcode_resolve = linkcode_resolve
def make_github_link(app, path, line=None, mode="blob"):
config = app.config
urlpath = "/{user}/{project}/{mode}/{branch}/{path}".format(
user=config.github_user,
project=config.github_project,
branch=config.version or 'master',
path=path,
mode=mode,
)
return urlunsplit((
'https',
'github.com',
urlpath,
'',
'' if line is None else 'L%d' % line
))
def add_doc_link(app, pagename, templatename, context, doctree):
""" Add github_link function linking to the current page on github """
if not app.config.github_user and app.config.github_project:
return
# FIXME: find other way to recover current document's source suffix
# in Sphinx 1.3 it's possible to have mutliple source suffixes and that
# may be useful in the future
source_suffix = app.config.source_suffix
source_suffix = source_suffix if isinstance(source_suffix, basestring) else source_suffix[0]
# can't use functools.partial because 3rd positional is line not mode
context['github_link'] = lambda mode='edit': make_github_link(
app, 'doc/%s%s' % (pagename, source_suffix), mode=mode)
|
agpl-3.0
|
[
646,
6485,
199,
646,
14802,
199,
646,
747,
14,
515,
199,
504,
7097,
492,
1166,
30038,
199,
199,
624,
199,
10,
9584,
12869,
63,
1073,
8,
632,
9,
1067,
1750,
26,
6571,
2851,
334,
262,
12082,
818,
9,
402,
523,
1453,
2213,
641,
12869,
199,
10,
340,
15882,
14,
832,
14,
1073,
600,
365,
5223,
12,
5847,
12821,
12869,
2142,
600,
523,
6220,
334,
991,
4260,
1101,
14,
1073,
600,
63,
6983,
9,
199,
199,
5268,
199,
763,
199,
199,
10,
1124,
5031,
63,
751,
4542,
3434,
15,
17425,
1334,
1314,
314,
2199,
27576,
199,
10,
1124,
5031,
63,
1715,
4542,
536,
402,
314,
2199,
641,
12869,
199,
10,
334,
4144,
9,
1124,
1023,
4542,
12869,
5246,
370,
2142,
370,
334,
885,
26,
5288,
9,
199,
199,
18685,
199,
19989,
199,
199,
10,
2741,
1124,
1073,
600,
63,
6983,
1040,
1454,
5171,
2018,
2881,
199,
10,
12821,
4178,
12869,
6220,
199,
10,
7662,
8925,
1124,
11267,
4542,
880,
31291,
367,
29165,
587,
199,
624,
199,
199,
318,
3272,
8,
571,
304,
272,
1145,
14,
525,
63,
888,
63,
585,
360,
5031,
63,
751,
297,
488,
12,
283,
1813,
358,
272,
1145,
14,
525,
63,
888,
63,
585,
360,
5031,
63,
1715,
297,
488,
12,
283,
1813,
358,
272,
1145,
14,
2242,
360,
1360,
13,
1606,
13,
1100,
297,
1050,
63,
1301,
63,
1073,
9,
339,
347,
2142,
600,
63,
6983,
8,
2261,
12,
2256,
304,
267,
408,
3591,
393,
2310,
2741,
909,
370,
5226,
12869,
2851,
267,
408,
267,
327,
3254,
26,
8586,
31,
267,
340,
2881,
1137,
283,
647,
356,
288,
372,
488,
267,
340,
440,
334,
571,
14,
888,
14,
5031,
63,
751,
436,
1145,
14,
888,
14,
5031,
63,
1715,
304,
288,
372,
488,
398,
859,
12,
11064,
275,
2256,
459,
578,
995,
2256,
459,
9930,
418,
267,
327,
3254,
26,
3004,
15,
3282,
2793,
1133,
1172,
4621,
12,
11703,
862,
370,
3648,
267,
327,
755,
3062,
1536,
4079,
641,
3932,
6328,
1591,
909,
31,
267,
340,
440,
859,
26,
288,
372,
488,
398,
1559,
275,
14802,
14,
646,
63,
578,
8,
578,
9,
267,
367,
1242,
315,
11064,
14,
1294,
26461,
288,
1559,
275,
2519,
8,
1113,
12,
1242,
12,
488,
9,
398,
340,
1559,
365,
488,
26,
288,
372,
488,
398,
327,
664,
3379,
687,
16225,
3102,
267,
862,
26,
1559,
275,
2519,
8,
1113,
12,
2513,
2981,
358,
267,
871,
4281,
26,
986,
398,
862,
26,
288,
1559,
63,
1365,
63,
515,
275,
6485,
14,
362,
32666,
8,
1113,
9,
288,
5501,
1004,
275,
6485,
14,
362,
1365,
1278,
8,
1113,
9,
267,
871,
334,
4333,
12,
5925,
304,
288,
327,
1559,
3181,
1133,
1172,
282,
859,
12,
503,
6020,
288,
372,
488,
398,
492,
5166,
267,
327,
7600,
26,
1852,
17196,
2199,
1738,
2199,
13,
26083,
267,
2199,
63,
1231,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
11267,
855,
493,
10139,
11541,
358,
267,
372,
1852,
63,
5031,
63,
1073,
8,
288,
1145,
12,
288,
747,
14,
515,
14,
12405,
8,
1113,
63,
1365,
63,
515,
12,
2199,
63,
1231,
395,
288,
1004,
9,
272,
1145,
14,
888,
14,
1073,
600,
63,
6983,
275,
2142,
600,
63,
6983,
199,
199,
318,
1852,
63,
5031,
63,
1073,
8,
571,
12,
931,
12,
1004,
29,
403,
12,
818,
628,
6582,
2349,
272,
1101,
275,
1145,
14,
888,
339,
1166,
515,
275,
3286,
91,
751,
16152,
1715,
16152,
632,
16152,
4694,
16152,
515,
5469,
908,
8,
267,
922,
29,
888,
14,
5031,
63,
751,
12,
267,
2199,
29,
888,
14,
5031,
63,
1715,
12,
267,
5246,
29,
888,
14,
1023,
503,
283,
4133,
297,
267,
931,
29,
515,
12,
267,
818,
29,
632,
12,
272,
776,
272,
372,
1166,
30038,
1332,
267,
283,
2859,
297,
267,
283,
5031,
14,
957,
297,
267,
1166,
515,
12,
267,
3260,
267,
2125,
340,
1004,
365,
488,
587,
283,
44,
5,
68,
7,
450,
1004,
272,
5082,
199,
199,
318,
1050,
63,
1301,
63,
1073,
8,
571,
12,
9881,
17604,
12,
1978,
354,
12,
1067,
12,
886,
16970,
304,
272,
408,
2654,
12869,
63,
1073,
805,
25833,
370,
314,
1453,
2034,
641,
12869,
408,
272,
340,
440,
1145,
14,
888,
14,
5031,
63,
751,
436,
1145,
14,
888,
14,
5031,
63,
1715,
26,
267,
372,
339,
327,
7600,
26,
2342,
1163,
4340,
370,
22803,
1453,
2213,
1159,
1350,
4739,
272,
327,
315,
10229,
413,
14,
19,
652,
1159,
3962,
370,
1172,
8567,
3587,
274,
1350,
19475,
436,
626,
272,
327,
1443,
506,
2997,
315,
314,
6466,
272,
1350,
63,
4511,
275,
1145,
14,
888,
14,
1365,
63,
4511,
272,
1350,
63,
4511,
275,
1350,
63,
4511,
340,
1228,
8,
1365,
63,
4511,
12,
7116,
9,
587,
1350,
63,
4511,
59,
16,
61,
272,
327,
883,
1133,
675,
9143,
14,
6672,
2952,
650,
6883,
11333,
365,
1004,
440,
818,
272,
1067,
459,
5031,
63,
1073,
418,
275,
2400,
818,
534,
3773,
356,
1852,
63,
5031,
63,
1073,
8,
267,
1145,
12,
283,
1301,
3149,
83,
5,
83,
7,
450,
334,
387,
2268,
313,
12,
1350,
63,
4511,
395,
818,
29,
632,
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
] |
[
6485,
199,
646,
14802,
199,
646,
747,
14,
515,
199,
504,
7097,
492,
1166,
30038,
199,
199,
624,
199,
10,
9584,
12869,
63,
1073,
8,
632,
9,
1067,
1750,
26,
6571,
2851,
334,
262,
12082,
818,
9,
402,
523,
1453,
2213,
641,
12869,
199,
10,
340,
15882,
14,
832,
14,
1073,
600,
365,
5223,
12,
5847,
12821,
12869,
2142,
600,
523,
6220,
334,
991,
4260,
1101,
14,
1073,
600,
63,
6983,
9,
199,
199,
5268,
199,
763,
199,
199,
10,
1124,
5031,
63,
751,
4542,
3434,
15,
17425,
1334,
1314,
314,
2199,
27576,
199,
10,
1124,
5031,
63,
1715,
4542,
536,
402,
314,
2199,
641,
12869,
199,
10,
334,
4144,
9,
1124,
1023,
4542,
12869,
5246,
370,
2142,
370,
334,
885,
26,
5288,
9,
199,
199,
18685,
199,
19989,
199,
199,
10,
2741,
1124,
1073,
600,
63,
6983,
1040,
1454,
5171,
2018,
2881,
199,
10,
12821,
4178,
12869,
6220,
199,
10,
7662,
8925,
1124,
11267,
4542,
880,
31291,
367,
29165,
587,
199,
624,
199,
199,
318,
3272,
8,
571,
304,
272,
1145,
14,
525,
63,
888,
63,
585,
360,
5031,
63,
751,
297,
488,
12,
283,
1813,
358,
272,
1145,
14,
525,
63,
888,
63,
585,
360,
5031,
63,
1715,
297,
488,
12,
283,
1813,
358,
272,
1145,
14,
2242,
360,
1360,
13,
1606,
13,
1100,
297,
1050,
63,
1301,
63,
1073,
9,
339,
347,
2142,
600,
63,
6983,
8,
2261,
12,
2256,
304,
267,
408,
3591,
393,
2310,
2741,
909,
370,
5226,
12869,
2851,
267,
408,
267,
327,
3254,
26,
8586,
31,
267,
340,
2881,
1137,
283,
647,
356,
288,
372,
488,
267,
340,
440,
334,
571,
14,
888,
14,
5031,
63,
751,
436,
1145,
14,
888,
14,
5031,
63,
1715,
304,
288,
372,
488,
398,
859,
12,
11064,
275,
2256,
459,
578,
995,
2256,
459,
9930,
418,
267,
327,
3254,
26,
3004,
15,
3282,
2793,
1133,
1172,
4621,
12,
11703,
862,
370,
3648,
267,
327,
755,
3062,
1536,
4079,
641,
3932,
6328,
1591,
909,
31,
267,
340,
440,
859,
26,
288,
372,
488,
398,
1559,
275,
14802,
14,
646,
63,
578,
8,
578,
9,
267,
367,
1242,
315,
11064,
14,
1294,
26461,
288,
1559,
275,
2519,
8,
1113,
12,
1242,
12,
488,
9,
398,
340,
1559,
365,
488,
26,
288,
372,
488,
398,
327,
664,
3379,
687,
16225,
3102,
267,
862,
26,
1559,
275,
2519,
8,
1113,
12,
2513,
2981,
358,
267,
871,
4281,
26,
986,
398,
862,
26,
288,
1559,
63,
1365,
63,
515,
275,
6485,
14,
362,
32666,
8,
1113,
9,
288,
5501,
1004,
275,
6485,
14,
362,
1365,
1278,
8,
1113,
9,
267,
871,
334,
4333,
12,
5925,
304,
288,
327,
1559,
3181,
1133,
1172,
282,
859,
12,
503,
6020,
288,
372,
488,
398,
492,
5166,
267,
327,
7600,
26,
1852,
17196,
2199,
1738,
2199,
13,
26083,
267,
2199,
63,
1231,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
11267,
855,
493,
10139,
11541,
358,
267,
372,
1852,
63,
5031,
63,
1073,
8,
288,
1145,
12,
288,
747,
14,
515,
14,
12405,
8,
1113,
63,
1365,
63,
515,
12,
2199,
63,
1231,
395,
288,
1004,
9,
272,
1145,
14,
888,
14,
1073,
600,
63,
6983,
275,
2142,
600,
63,
6983,
199,
199,
318,
1852,
63,
5031,
63,
1073,
8,
571,
12,
931,
12,
1004,
29,
403,
12,
818,
628,
6582,
2349,
272,
1101,
275,
1145,
14,
888,
339,
1166,
515,
275,
3286,
91,
751,
16152,
1715,
16152,
632,
16152,
4694,
16152,
515,
5469,
908,
8,
267,
922,
29,
888,
14,
5031,
63,
751,
12,
267,
2199,
29,
888,
14,
5031,
63,
1715,
12,
267,
5246,
29,
888,
14,
1023,
503,
283,
4133,
297,
267,
931,
29,
515,
12,
267,
818,
29,
632,
12,
272,
776,
272,
372,
1166,
30038,
1332,
267,
283,
2859,
297,
267,
283,
5031,
14,
957,
297,
267,
1166,
515,
12,
267,
3260,
267,
2125,
340,
1004,
365,
488,
587,
283,
44,
5,
68,
7,
450,
1004,
272,
5082,
199,
199,
318,
1050,
63,
1301,
63,
1073,
8,
571,
12,
9881,
17604,
12,
1978,
354,
12,
1067,
12,
886,
16970,
304,
272,
408,
2654,
12869,
63,
1073,
805,
25833,
370,
314,
1453,
2034,
641,
12869,
408,
272,
340,
440,
1145,
14,
888,
14,
5031,
63,
751,
436,
1145,
14,
888,
14,
5031,
63,
1715,
26,
267,
372,
339,
327,
7600,
26,
2342,
1163,
4340,
370,
22803,
1453,
2213,
1159,
1350,
4739,
272,
327,
315,
10229,
413,
14,
19,
652,
1159,
3962,
370,
1172,
8567,
3587,
274,
1350,
19475,
436,
626,
272,
327,
1443,
506,
2997,
315,
314,
6466,
272,
1350,
63,
4511,
275,
1145,
14,
888,
14,
1365,
63,
4511,
272,
1350,
63,
4511,
275,
1350,
63,
4511,
340,
1228,
8,
1365,
63,
4511,
12,
7116,
9,
587,
1350,
63,
4511,
59,
16,
61,
272,
327,
883,
1133,
675,
9143,
14,
6672,
2952,
650,
6883,
11333,
365,
1004,
440,
818,
272,
1067,
459,
5031,
63,
1073,
418,
275,
2400,
818,
534,
3773,
356,
1852,
63,
5031,
63,
1073,
8,
267,
1145,
12,
283,
1301,
3149,
83,
5,
83,
7,
450,
334,
387,
2268,
313,
12,
1350,
63,
4511,
395,
818,
29,
632,
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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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
] |
SEC-i/ecoControl
|
server/functions.py
|
1
|
3643
|
import logging
from datetime import datetime
import dateutil.relativedelta
from django.core.exceptions import ObjectDoesNotExist
from django.core.cache import cache
from django.utils.timezone import utc
from models import Device, Configuration, DeviceConfiguration, Sensor, SensorValue, SensorValueDaily
logger = logging.getLogger('django')
CACHE_TIMEOUT = 120 # seconds
def get_latest_value(device, key):
sensor = Sensor.objects.get(device=device, key=key)
sensor_value = SensorValue.objects.filter(
sensor=sensor).latest('timestamp')
return sensor_value.value
def get_latest_value_with_unit(device, key):
sensor = Sensor.objects.get(device=device, key=key)
sensor_value = SensorValue.objects.filter(
sensor=sensor).latest('timestamp')
return '%s %s' % (round(sensor_value.value, 2), sensor.unit)
def get_configuration(key, cached=True):
config = cache.get(key)
if config is None or not cached:
config = Configuration.objects.get(key=key)
cache.set(key, config, CACHE_TIMEOUT)
return parse_value(config)
def get_device_configuration(device, key):
configs = cache.get(key + str(device.id))
if configs is None:
configs = DeviceConfiguration.objects.filter(device=device)
cache.set(key + str(device.id), configs, CACHE_TIMEOUT)
for config in configs:
if config.key == key:
return parse_value(config)
def get_configurations():
configurations = {}
for config in Configuration.objects.filter(internal=False):
configurations[config.key] = {
'value': config.value,
'type': config.value_type,
'unit': config.unit
}
return [(0, configurations)]
def get_device_configurations(tunable=None):
output = []
for device in Device.objects.all():
configurations = {}
configuration_queryset = DeviceConfiguration.objects.filter(
device=device)
if tunable is not None:
configuration_queryset = configuration_queryset.filter(
tunable=tunable)
for config in configuration_queryset:
configurations[config.key] = {
'device': config.device.name,
'value': config.value,
'type': config.value_type,
'unit': config.unit
}
if len(configurations) > 0:
output += [(device.id, configurations)]
return output
def get_past_time(years=0, months=0, days=0, use_view=False):
output_time = datetime.now()
if use_view:
_class = SensorValueDaily
else:
_class = SensorValue
try:
output_time = _class.objects.latest('timestamp').timestamp
except _class.DoesNotExist:
pass
output_time += dateutil.relativedelta.relativedelta(years=-years, months=-months, days=-days)
return output_time.replace(tzinfo=utc)
def parse_value(config):
try:
if config.value_type == DeviceConfiguration.STR:
return str(config.value)
elif config.value_type == DeviceConfiguration.INT:
return int(config.value)
elif config.value_type == DeviceConfiguration.FLOAT:
return float(config.value)
elif config.value_type == DeviceConfiguration.BOOL:
return config.value == "True"
else:
logger.warning(
"Couldn't determine type of %s (%s)" % (config.value, config.value_type))
except ValueError:
logger.warning("ValueError parsing %s to %s" %
(config.value, config.value_type))
return str(config.value)
|
mit
|
[
646,
2050,
199,
504,
2197,
492,
2197,
199,
646,
22208,
14,
32300,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
24803,
199,
504,
1639,
14,
1018,
14,
1637,
492,
2581,
199,
504,
1639,
14,
1208,
14,
7145,
492,
19314,
199,
199,
504,
1709,
492,
12272,
12,
11595,
12,
12272,
5688,
12,
18474,
12,
18474,
1110,
12,
18474,
1110,
36,
17550,
421,
199,
2921,
275,
2050,
14,
5572,
360,
1176,
358,
199,
8677,
63,
8899,
275,
13960,
221,
327,
4696,
421,
199,
318,
664,
63,
7410,
63,
585,
8,
1782,
12,
790,
304,
272,
8778,
275,
18474,
14,
1462,
14,
362,
8,
1782,
29,
1782,
12,
790,
29,
498,
9,
272,
8778,
63,
585,
275,
18474,
1110,
14,
1462,
14,
1541,
8,
267,
8778,
29,
8956,
680,
7410,
360,
3954,
358,
272,
372,
8778,
63,
585,
14,
585,
421,
199,
318,
664,
63,
7410,
63,
585,
63,
1045,
63,
3248,
8,
1782,
12,
790,
304,
272,
8778,
275,
18474,
14,
1462,
14,
362,
8,
1782,
29,
1782,
12,
790,
29,
498,
9,
272,
8778,
63,
585,
275,
18474,
1110,
14,
1462,
14,
1541,
8,
267,
8778,
29,
8956,
680,
7410,
360,
3954,
358,
272,
372,
1543,
83,
450,
83,
7,
450,
334,
2363,
8,
8956,
63,
585,
14,
585,
12,
499,
395,
8778,
14,
3248,
9,
421,
199,
318,
664,
63,
4758,
8,
498,
12,
6328,
29,
549,
304,
272,
1101,
275,
2581,
14,
362,
8,
498,
9,
272,
340,
1101,
365,
488,
503,
440,
6328,
26,
267,
1101,
275,
11595,
14,
1462,
14,
362,
8,
498,
29,
498,
9,
267,
2581,
14,
409,
8,
498,
12,
1101,
12,
7240,
4576,
63,
8899,
9,
272,
372,
2198,
63,
585,
8,
888,
9,
421,
199,
318,
664,
63,
1782,
63,
4758,
8,
1782,
12,
790,
304,
272,
11585,
275,
2581,
14,
362,
8,
498,
435,
620,
8,
1782,
14,
344,
430,
272,
340,
11585,
365,
488,
26,
267,
11585,
275,
12272,
5688,
14,
1462,
14,
1541,
8,
1782,
29,
1782,
9,
267,
2581,
14,
409,
8,
498,
435,
620,
8,
1782,
14,
344,
395,
11585,
12,
7240,
4576,
63,
8899,
9,
272,
367,
1101,
315,
11585,
26,
267,
340,
1101,
14,
498,
508,
790,
26,
288,
372,
2198,
63,
585,
8,
888,
9,
421,
199,
318,
664,
63,
10057,
837,
272,
13422,
275,
1052,
272,
367,
1101,
315,
11595,
14,
1462,
14,
1541,
8,
4672,
29,
797,
304,
267,
13422,
59,
888,
14,
498,
61,
275,
469,
288,
283,
585,
356,
1101,
14,
585,
12,
288,
283,
466,
356,
1101,
14,
585,
63,
466,
12,
288,
283,
3248,
356,
1101,
14,
3248,
267,
789,
272,
372,
3842,
16,
12,
13422,
1874,
421,
199,
318,
664,
63,
1782,
63,
10057,
8,
10032,
461,
29,
403,
304,
272,
1072,
275,
942,
272,
367,
2243,
315,
12272,
14,
1462,
14,
452,
837,
267,
13422,
275,
1052,
267,
2897,
63,
7924,
275,
12272,
5688,
14,
1462,
14,
1541,
8,
288,
2243,
29,
1782,
9,
267,
340,
15486,
461,
365,
440,
488,
26,
288,
2897,
63,
7924,
275,
2897,
63,
7924,
14,
1541,
8,
355,
15486,
461,
29,
10032,
461,
9,
398,
367,
1101,
315,
2897,
63,
7924,
26,
288,
13422,
59,
888,
14,
498,
61,
275,
469,
355,
283,
1782,
356,
1101,
14,
1782,
14,
354,
12,
355,
283,
585,
356,
1101,
14,
585,
12,
355,
283,
466,
356,
1101,
14,
585,
63,
466,
12,
355,
283,
3248,
356,
1101,
14,
3248,
288,
789,
267,
340,
822,
8,
10057,
9,
690,
378,
26,
288,
1072,
847,
3842,
1782,
14,
344,
12,
13422,
1874,
339,
372,
1072,
421,
199,
318,
664,
63,
18597,
63,
521,
8,
18431,
29,
16,
12,
20096,
29,
16,
12,
7609,
29,
16,
12,
675,
63,
1345,
29,
797,
304,
272,
1072,
63,
521,
275,
2197,
14,
2131,
342,
339,
340,
675,
63,
1345,
26,
267,
485,
533,
275,
18474,
1110,
36,
17550,
272,
587,
26,
267,
485,
533,
275,
18474,
1110,
339,
862,
26,
267,
1072,
63,
521,
275,
485,
533,
14,
1462,
14,
7410,
360,
3954,
1959,
3954,
272,
871,
485,
533,
14,
7400,
26,
267,
986,
339,
1072,
63,
521,
847,
22208,
14,
32300,
14,
32300,
8,
18431,
4022,
18431,
12,
20096,
4022,
16745,
12,
7609,
4022,
4899,
9,
272,
372,
1072,
63,
521,
14,
1814,
8,
9374,
29,
5834,
9,
421,
199,
318,
2198,
63,
585,
8,
888,
304,
272,
862,
26,
267,
340,
1101,
14,
585,
63,
466,
508,
12272,
5688,
14,
3027,
26,
288,
372,
620,
8,
888,
14,
585,
9,
267,
916,
1101,
14,
585,
63,
466,
508,
12272,
5688,
14,
2919,
26,
288,
372,
1109,
8,
888,
14,
585,
9,
267,
916,
1101,
14,
585,
63,
466,
508,
12272,
5688,
14,
11783,
26,
288,
372,
2069,
8,
888,
14,
585,
9,
267,
916,
1101,
14,
585,
63,
466,
508,
12272,
5688,
14,
16026,
26,
288,
372,
1101,
14,
585,
508,
298,
549,
2,
267,
587,
26,
288,
2512,
14,
3764,
8,
355,
298,
20485,
1133,
6705,
730,
402,
450,
83,
4366,
83,
2924,
450,
334,
888,
14,
585,
12,
1101,
14,
585,
63,
466,
430,
272,
871,
1722,
26,
267,
2512,
14,
3764,
480,
3393,
6057,
450,
83,
370,
450,
83,
2,
450,
2432,
334,
888,
14,
585,
12,
1101,
14,
585,
63,
466,
430,
272,
372,
620,
8,
888,
14,
585,
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
] |
[
2050,
199,
504,
2197,
492,
2197,
199,
646,
22208,
14,
32300,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
24803,
199,
504,
1639,
14,
1018,
14,
1637,
492,
2581,
199,
504,
1639,
14,
1208,
14,
7145,
492,
19314,
199,
199,
504,
1709,
492,
12272,
12,
11595,
12,
12272,
5688,
12,
18474,
12,
18474,
1110,
12,
18474,
1110,
36,
17550,
421,
199,
2921,
275,
2050,
14,
5572,
360,
1176,
358,
199,
8677,
63,
8899,
275,
13960,
221,
327,
4696,
421,
199,
318,
664,
63,
7410,
63,
585,
8,
1782,
12,
790,
304,
272,
8778,
275,
18474,
14,
1462,
14,
362,
8,
1782,
29,
1782,
12,
790,
29,
498,
9,
272,
8778,
63,
585,
275,
18474,
1110,
14,
1462,
14,
1541,
8,
267,
8778,
29,
8956,
680,
7410,
360,
3954,
358,
272,
372,
8778,
63,
585,
14,
585,
421,
199,
318,
664,
63,
7410,
63,
585,
63,
1045,
63,
3248,
8,
1782,
12,
790,
304,
272,
8778,
275,
18474,
14,
1462,
14,
362,
8,
1782,
29,
1782,
12,
790,
29,
498,
9,
272,
8778,
63,
585,
275,
18474,
1110,
14,
1462,
14,
1541,
8,
267,
8778,
29,
8956,
680,
7410,
360,
3954,
358,
272,
372,
1543,
83,
450,
83,
7,
450,
334,
2363,
8,
8956,
63,
585,
14,
585,
12,
499,
395,
8778,
14,
3248,
9,
421,
199,
318,
664,
63,
4758,
8,
498,
12,
6328,
29,
549,
304,
272,
1101,
275,
2581,
14,
362,
8,
498,
9,
272,
340,
1101,
365,
488,
503,
440,
6328,
26,
267,
1101,
275,
11595,
14,
1462,
14,
362,
8,
498,
29,
498,
9,
267,
2581,
14,
409,
8,
498,
12,
1101,
12,
7240,
4576,
63,
8899,
9,
272,
372,
2198,
63,
585,
8,
888,
9,
421,
199,
318,
664,
63,
1782,
63,
4758,
8,
1782,
12,
790,
304,
272,
11585,
275,
2581,
14,
362,
8,
498,
435,
620,
8,
1782,
14,
344,
430,
272,
340,
11585,
365,
488,
26,
267,
11585,
275,
12272,
5688,
14,
1462,
14,
1541,
8,
1782,
29,
1782,
9,
267,
2581,
14,
409,
8,
498,
435,
620,
8,
1782,
14,
344,
395,
11585,
12,
7240,
4576,
63,
8899,
9,
272,
367,
1101,
315,
11585,
26,
267,
340,
1101,
14,
498,
508,
790,
26,
288,
372,
2198,
63,
585,
8,
888,
9,
421,
199,
318,
664,
63,
10057,
837,
272,
13422,
275,
1052,
272,
367,
1101,
315,
11595,
14,
1462,
14,
1541,
8,
4672,
29,
797,
304,
267,
13422,
59,
888,
14,
498,
61,
275,
469,
288,
283,
585,
356,
1101,
14,
585,
12,
288,
283,
466,
356,
1101,
14,
585,
63,
466,
12,
288,
283,
3248,
356,
1101,
14,
3248,
267,
789,
272,
372,
3842,
16,
12,
13422,
1874,
421,
199,
318,
664,
63,
1782,
63,
10057,
8,
10032,
461,
29,
403,
304,
272,
1072,
275,
942,
272,
367,
2243,
315,
12272,
14,
1462,
14,
452,
837,
267,
13422,
275,
1052,
267,
2897,
63,
7924,
275,
12272,
5688,
14,
1462,
14,
1541,
8,
288,
2243,
29,
1782,
9,
267,
340,
15486,
461,
365,
440,
488,
26,
288,
2897,
63,
7924,
275,
2897,
63,
7924,
14,
1541,
8,
355,
15486,
461,
29,
10032,
461,
9,
398,
367,
1101,
315,
2897,
63,
7924,
26,
288,
13422,
59,
888,
14,
498,
61,
275,
469,
355,
283,
1782,
356,
1101,
14,
1782,
14,
354,
12,
355,
283,
585,
356,
1101,
14,
585,
12,
355,
283,
466,
356,
1101,
14,
585,
63,
466,
12,
355,
283,
3248,
356,
1101,
14,
3248,
288,
789,
267,
340,
822,
8,
10057,
9,
690,
378,
26,
288,
1072,
847,
3842,
1782,
14,
344,
12,
13422,
1874,
339,
372,
1072,
421,
199,
318,
664,
63,
18597,
63,
521,
8,
18431,
29,
16,
12,
20096,
29,
16,
12,
7609,
29,
16,
12,
675,
63,
1345,
29,
797,
304,
272,
1072,
63,
521,
275,
2197,
14,
2131,
342,
339,
340,
675,
63,
1345,
26,
267,
485,
533,
275,
18474,
1110,
36,
17550,
272,
587,
26,
267,
485,
533,
275,
18474,
1110,
339,
862,
26,
267,
1072,
63,
521,
275,
485,
533,
14,
1462,
14,
7410,
360,
3954,
1959,
3954,
272,
871,
485,
533,
14,
7400,
26,
267,
986,
339,
1072,
63,
521,
847,
22208,
14,
32300,
14,
32300,
8,
18431,
4022,
18431,
12,
20096,
4022,
16745,
12,
7609,
4022,
4899,
9,
272,
372,
1072,
63,
521,
14,
1814,
8,
9374,
29,
5834,
9,
421,
199,
318,
2198,
63,
585,
8,
888,
304,
272,
862,
26,
267,
340,
1101,
14,
585,
63,
466,
508,
12272,
5688,
14,
3027,
26,
288,
372,
620,
8,
888,
14,
585,
9,
267,
916,
1101,
14,
585,
63,
466,
508,
12272,
5688,
14,
2919,
26,
288,
372,
1109,
8,
888,
14,
585,
9,
267,
916,
1101,
14,
585,
63,
466,
508,
12272,
5688,
14,
11783,
26,
288,
372,
2069,
8,
888,
14,
585,
9,
267,
916,
1101,
14,
585,
63,
466,
508,
12272,
5688,
14,
16026,
26,
288,
372,
1101,
14,
585,
508,
298,
549,
2,
267,
587,
26,
288,
2512,
14,
3764,
8,
355,
298,
20485,
1133,
6705,
730,
402,
450,
83,
4366,
83,
2924,
450,
334,
888,
14,
585,
12,
1101,
14,
585,
63,
466,
430,
272,
871,
1722,
26,
267,
2512,
14,
3764,
480,
3393,
6057,
450,
83,
370,
450,
83,
2,
450,
2432,
334,
888,
14,
585,
12,
1101,
14,
585,
63,
466,
430,
272,
372,
620,
8,
888,
14,
585,
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,
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
] |
fedelemantuano/thug
|
samples/steps/misc.py
|
2
|
1121
|
import sys
import os
from behave import *
from behave.log_capture import capture
THUG = os.path.dirname(os.path.abspath(__file__)).split("samples")[0]
MISC = os.path.join(THUG, 'samples', 'misc')
sys.path.append(os.path.join(THUG, 'src'))
from thug.ThugAPI.ThugAPI import ThugAPI
class Misc(ThugAPI):
def __init__(self, context):
ThugAPI.__init__(self)
self.misc = list()
for row in context.table:
self.misc.append(row)
def _run_step(self, context, exploit):
sample = os.path.join(MISC, exploit[0])
self.set_useragent('win7ie90')
self.set_events('click,storage')
self.disable_cert_logging()
self.log_init(sample)
self.run_local(sample)
for assertion in exploit[1].split(","):
assert assertion in context.log_capture.getvalue()
def run_step(self, context):
for misc in self.misc:
self._run_step(context, misc)
@given('set of misc')
def step_impl(context):
global misc
misc = Misc(context)
@capture
@then('run misc')
def step_impl(context):
misc.run_step(context)
|
gpl-2.0
|
[
646,
984,
199,
646,
747,
199,
504,
24062,
492,
627,
199,
504,
24062,
14,
793,
63,
12685,
492,
12296,
199,
199,
2080,
10134,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
363,
4992,
1294,
480,
3356,
9981,
16,
61,
199,
9674,
35,
275,
747,
14,
515,
14,
904,
8,
2080,
10134,
12,
283,
3356,
297,
283,
9923,
358,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
2080,
10134,
12,
283,
2164,
1333,
199,
199,
504,
294,
1518,
14,
2719,
1518,
3735,
14,
2719,
1518,
3735,
492,
3868,
1518,
3735,
199,
199,
533,
603,
10840,
8,
2719,
1518,
3735,
304,
272,
347,
636,
826,
721,
277,
12,
1067,
304,
267,
3868,
1518,
3735,
855,
826,
721,
277,
9,
398,
291,
14,
9923,
275,
769,
342,
267,
367,
1962,
315,
1067,
14,
1224,
26,
288,
291,
14,
9923,
14,
740,
8,
1143,
9,
339,
347,
485,
1065,
63,
2926,
8,
277,
12,
1067,
12,
15868,
390,
304,
267,
2690,
275,
747,
14,
515,
14,
904,
8,
9674,
35,
12,
15868,
390,
59,
16,
566,
398,
291,
14,
409,
63,
751,
4054,
360,
2676,
23,
1873,
2710,
358,
267,
291,
14,
409,
63,
4368,
360,
4891,
12,
3494,
358,
267,
291,
14,
5993,
63,
4736,
63,
4806,
342,
267,
291,
14,
793,
63,
826,
8,
3271,
9,
267,
291,
14,
1065,
63,
1832,
8,
3271,
9,
398,
367,
14412,
315,
15868,
390,
59,
17,
1055,
1294,
8,
2266,
304,
288,
702,
14412,
315,
1067,
14,
793,
63,
12685,
14,
7150,
342,
339,
347,
1255,
63,
2926,
8,
277,
12,
1067,
304,
267,
367,
18576,
315,
291,
14,
9923,
26,
288,
291,
423,
1065,
63,
2926,
8,
1100,
12,
18576,
9,
199,
199,
32,
11809,
360,
409,
402,
18576,
358,
199,
318,
3650,
63,
5472,
8,
1100,
304,
272,
2288,
18576,
5591,
18576,
275,
603,
10840,
8,
1100,
9,
199,
199,
32,
12685,
199,
32,
12726,
360,
1065,
18576,
358,
199,
318,
3650,
63,
5472,
8,
1100,
304,
272,
18576,
14,
1065,
63,
2926,
8,
1100,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
984,
199,
646,
747,
199,
504,
24062,
492,
627,
199,
504,
24062,
14,
793,
63,
12685,
492,
12296,
199,
199,
2080,
10134,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
363,
4992,
1294,
480,
3356,
9981,
16,
61,
199,
9674,
35,
275,
747,
14,
515,
14,
904,
8,
2080,
10134,
12,
283,
3356,
297,
283,
9923,
358,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
2080,
10134,
12,
283,
2164,
1333,
199,
199,
504,
294,
1518,
14,
2719,
1518,
3735,
14,
2719,
1518,
3735,
492,
3868,
1518,
3735,
199,
199,
533,
603,
10840,
8,
2719,
1518,
3735,
304,
272,
347,
636,
826,
721,
277,
12,
1067,
304,
267,
3868,
1518,
3735,
855,
826,
721,
277,
9,
398,
291,
14,
9923,
275,
769,
342,
267,
367,
1962,
315,
1067,
14,
1224,
26,
288,
291,
14,
9923,
14,
740,
8,
1143,
9,
339,
347,
485,
1065,
63,
2926,
8,
277,
12,
1067,
12,
15868,
390,
304,
267,
2690,
275,
747,
14,
515,
14,
904,
8,
9674,
35,
12,
15868,
390,
59,
16,
566,
398,
291,
14,
409,
63,
751,
4054,
360,
2676,
23,
1873,
2710,
358,
267,
291,
14,
409,
63,
4368,
360,
4891,
12,
3494,
358,
267,
291,
14,
5993,
63,
4736,
63,
4806,
342,
267,
291,
14,
793,
63,
826,
8,
3271,
9,
267,
291,
14,
1065,
63,
1832,
8,
3271,
9,
398,
367,
14412,
315,
15868,
390,
59,
17,
1055,
1294,
8,
2266,
304,
288,
702,
14412,
315,
1067,
14,
793,
63,
12685,
14,
7150,
342,
339,
347,
1255,
63,
2926,
8,
277,
12,
1067,
304,
267,
367,
18576,
315,
291,
14,
9923,
26,
288,
291,
423,
1065,
63,
2926,
8,
1100,
12,
18576,
9,
199,
199,
32,
11809,
360,
409,
402,
18576,
358,
199,
318,
3650,
63,
5472,
8,
1100,
304,
272,
2288,
18576,
5591,
18576,
275,
603,
10840,
8,
1100,
9,
199,
199,
32,
12685,
199,
32,
12726,
360,
1065,
18576,
358,
199,
318,
3650,
63,
5472,
8,
1100,
304,
272,
18576,
14,
1065,
63,
2926,
8,
1100,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
yamila-moreno/api-example
|
src/tests/conftest.py
|
1
|
1237
|
import pytest
from sqlalchemy_utils import database_exists, create_database, drop_database
from repositories.config import Base
from repositories.config import engine
from repositories.session import session_manager
@pytest.fixture(scope="session", autouse=True)
def create_db(request):
print("\n===> Create and synchro database")
# drop database if exist
if database_exists(engine.url):
drop_database(engine.url)
# create a new database for testing purposes
create_database(engine.url)
# setting the new database
Base.metadata.create_all(engine)
def drop_db():
print("\n===> Drop database")
# dropdb at the end of the session
drop_database(engine.url)
request.addfinalizer(drop_db)
@pytest.fixture(scope="function", autouse=True)
def create_session_and_trunc_tables(request):
session_manager.create_session()
trunc_all_tables()
def end_session():
session_manager.commit_session()
session_manager.close_session()
request.addfinalizer(end_session)
def trunc_all_tables():
from repositories.config import metadata
for table in reversed(metadata.sorted_tables):
session_manager.session.execute(table.delete())
|
gpl-3.0
|
[
646,
4613,
199,
504,
8335,
63,
1208,
492,
3050,
63,
2444,
12,
1218,
63,
4659,
12,
5978,
63,
4659,
199,
199,
504,
23737,
14,
888,
492,
3523,
199,
504,
23737,
14,
888,
492,
6869,
199,
504,
23737,
14,
1730,
492,
2351,
63,
2609,
421,
199,
32,
4462,
14,
5997,
8,
2645,
628,
1730,
401,
6384,
7130,
29,
549,
9,
199,
318,
1218,
63,
697,
8,
1069,
304,
272,
870,
4582,
78,
5918,
30,
2790,
436,
308,
5654,
293,
3050,
531,
339,
327,
5978,
3050,
340,
2187,
272,
340,
3050,
63,
2444,
8,
3908,
14,
633,
304,
267,
5978,
63,
4659,
8,
3908,
14,
633,
9,
339,
327,
1218,
282,
892,
3050,
367,
5343,
12901,
272,
1218,
63,
4659,
8,
3908,
14,
633,
9,
339,
327,
4260,
314,
892,
3050,
272,
3523,
14,
2343,
14,
981,
63,
452,
8,
3908,
9,
339,
347,
5978,
63,
697,
837,
267,
870,
4582,
78,
5918,
30,
18110,
3050,
531,
267,
327,
5978,
697,
737,
314,
1284,
402,
314,
2351,
267,
5978,
63,
4659,
8,
3908,
14,
633,
9,
339,
1056,
14,
525,
30092,
8,
4824,
63,
697,
9,
421,
199,
32,
4462,
14,
5997,
8,
2645,
628,
1593,
401,
6384,
7130,
29,
549,
9,
199,
318,
1218,
63,
1730,
63,
460,
63,
8208,
63,
5987,
8,
1069,
304,
272,
2351,
63,
2609,
14,
981,
63,
1730,
342,
272,
8181,
67,
63,
452,
63,
5987,
342,
339,
347,
1284,
63,
1730,
837,
267,
2351,
63,
2609,
14,
3543,
63,
1730,
342,
267,
2351,
63,
2609,
14,
1600,
63,
1730,
342,
339,
1056,
14,
525,
30092,
8,
500,
63,
1730,
9,
421,
199,
318,
8181,
67,
63,
452,
63,
5987,
837,
272,
687,
23737,
14,
888,
492,
3341,
272,
367,
1817,
315,
10822,
8,
2343,
14,
5917,
63,
5987,
304,
267,
2351,
63,
2609,
14,
1730,
14,
2526,
8,
1224,
14,
1807,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4613,
199,
504,
8335,
63,
1208,
492,
3050,
63,
2444,
12,
1218,
63,
4659,
12,
5978,
63,
4659,
199,
199,
504,
23737,
14,
888,
492,
3523,
199,
504,
23737,
14,
888,
492,
6869,
199,
504,
23737,
14,
1730,
492,
2351,
63,
2609,
421,
199,
32,
4462,
14,
5997,
8,
2645,
628,
1730,
401,
6384,
7130,
29,
549,
9,
199,
318,
1218,
63,
697,
8,
1069,
304,
272,
870,
4582,
78,
5918,
30,
2790,
436,
308,
5654,
293,
3050,
531,
339,
327,
5978,
3050,
340,
2187,
272,
340,
3050,
63,
2444,
8,
3908,
14,
633,
304,
267,
5978,
63,
4659,
8,
3908,
14,
633,
9,
339,
327,
1218,
282,
892,
3050,
367,
5343,
12901,
272,
1218,
63,
4659,
8,
3908,
14,
633,
9,
339,
327,
4260,
314,
892,
3050,
272,
3523,
14,
2343,
14,
981,
63,
452,
8,
3908,
9,
339,
347,
5978,
63,
697,
837,
267,
870,
4582,
78,
5918,
30,
18110,
3050,
531,
267,
327,
5978,
697,
737,
314,
1284,
402,
314,
2351,
267,
5978,
63,
4659,
8,
3908,
14,
633,
9,
339,
1056,
14,
525,
30092,
8,
4824,
63,
697,
9,
421,
199,
32,
4462,
14,
5997,
8,
2645,
628,
1593,
401,
6384,
7130,
29,
549,
9,
199,
318,
1218,
63,
1730,
63,
460,
63,
8208,
63,
5987,
8,
1069,
304,
272,
2351,
63,
2609,
14,
981,
63,
1730,
342,
272,
8181,
67,
63,
452,
63,
5987,
342,
339,
347,
1284,
63,
1730,
837,
267,
2351,
63,
2609,
14,
3543,
63,
1730,
342,
267,
2351,
63,
2609,
14,
1600,
63,
1730,
342,
339,
1056,
14,
525,
30092,
8,
500,
63,
1730,
9,
421,
199,
318,
8181,
67,
63,
452,
63,
5987,
837,
272,
687,
23737,
14,
888,
492,
3341,
272,
367,
1817,
315,
10822,
8,
2343,
14,
5917,
63,
5987,
304,
267,
2351,
63,
2609,
14,
1730,
14,
2526,
8,
1224,
14,
1807,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
repotvsupertuga/repo
|
plugin.video.TVsupertuga/resources/lib/sources/einthusan_mv.py
|
6
|
3567
|
# -*- coding: utf-8 -*-
'''
Exodus Add-on
Copyright (C) 2016 Exodus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import re,urllib,urllib2,urlparse,StringIO,gzip,json
from resources.lib.modules import cleantitle
from resources.lib.modules import client
class source:
def __init__(self):
self.language = ['en']
self.domains = ['einthusan.com', 'einthusan.tv']
self.base_link = 'https://einthusan.tv'
self.search_link = '/movie/results/?lang=%s&query=%s'
self.movie_link = '/movie/watch/%s/'
def request(self, url):
try:
req = urllib2.Request(url)
req.add_header('User-Agent', client.randomagent())
res = urllib2.urlopen(req)
r = res.read() if not res.info().getheader('Content-Encoding') == 'gzip' else gzip.GzipFile(fileobj=StringIO.StringIO(res.read())).read()
res.close()
return r
except:
return
def movie(self, imdb, title, year):
try:
langMap = {'hi':'hindi', 'ta':'tamil', 'te':'telugu', 'ml':'malayalam', 'kn':'kannada', 'bn':'bengali', 'mr':'marathi', 'pa':'punjabi'}
lang = 'http://www.imdb.com/title/%s/' % imdb
lang = client.request(lang)
lang = re.findall('href\s*=\s*[\'|\"](.+?)[\'|\"]', lang)
lang = [i for i in lang if 'primary_language' in i]
lang = [urlparse.parse_qs(urlparse.urlparse(i).query) for i in lang]
lang = [i['primary_language'] for i in lang if 'primary_language' in i]
lang = langMap[lang[0][0]]
q = self.search_link % (lang, urllib.quote_plus(title))
q = urlparse.urljoin(self.base_link, q)
t = cleantitle.get(title)
r = self.request(q)
r = client.parseDOM(r, 'li')
r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'h3'), client.parseDOM(i, 'div', attrs = {'class': 'info'})) for i in r]
r = [(i[0][0], i[1][0], i[2][0]) for i in r if i[0] and i[1] and i[2]]
r = [(re.findall('(\d+)', i[0]), i[1], re.findall('(\d{4})', i[2])) for i in r]
r = [(i[0][0], i[1], i[2][0]) for i in r if i[0] and i[2]]
r = [i[0] for i in r if t == cleantitle.get(i[1]) and year == i[2]][0]
url = str(r)
return url
except:
return
def sources(self, url, hostDict, hostprDict):
try:
sources = []
if url == None: return sources
url = self.movie_link % url
url = urlparse.urljoin(self.base_link, url)
return sources
r = self.request(url)
sources.append({'source': 'einthusan', 'quality': 'HD', 'provider': 'Einthusan', 'url': url, 'direct': True, 'debridonly': False})
return sources
except:
return sources
def resolve(self, url):
return url
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
2344,
272,
1316,
364,
527,
2654,
13,
265,
272,
1898,
334,
35,
9,
7800,
1316,
364,
527,
339,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
272,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
272,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
272,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
339,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
272,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
272,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
272,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
339,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
272,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
2344,
421,
199,
646,
295,
12,
4078,
12,
4078,
18,
12,
10290,
12,
6424,
12,
12256,
12,
1001,
199,
199,
504,
5944,
14,
773,
14,
3112,
492,
3633,
1213,
199,
504,
5944,
14,
773,
14,
3112,
492,
1890,
421,
199,
533,
1350,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
3671,
275,
788,
287,
418,
267,
291,
14,
9756,
275,
788,
69,
262,
273,
527,
290,
14,
957,
297,
283,
69,
262,
273,
527,
290,
14,
6993,
418,
267,
291,
14,
1095,
63,
1073,
275,
283,
2859,
921,
69,
262,
273,
527,
290,
14,
6993,
7,
267,
291,
14,
1733,
63,
1073,
275,
1994,
10888,
15,
2604,
10197,
4159,
2458,
83,
6,
1131,
2458,
83,
7,
267,
291,
14,
10888,
63,
1073,
275,
1994,
10888,
15,
6821,
3149,
83,
4805,
2378,
347,
1056,
8,
277,
12,
1166,
304,
267,
862,
26,
288,
2648,
275,
4011,
18,
14,
2017,
8,
633,
9,
288,
2648,
14,
525,
63,
1291,
360,
1899,
13,
7788,
297,
1890,
14,
3759,
79,
5615,
484,
1012,
288,
522,
275,
4011,
18,
14,
10890,
8,
2103,
9,
288,
519,
275,
522,
14,
739,
342,
340,
440,
522,
14,
815,
1252,
19958,
360,
2714,
13,
7630,
358,
508,
283,
12256,
7,
587,
11756,
14,
29827,
8,
9234,
29,
6424,
14,
6424,
8,
470,
14,
739,
4059,
14,
739,
342,
288,
522,
14,
1600,
342,
288,
372,
519,
267,
871,
26,
288,
372,
2378,
347,
14360,
8,
277,
12,
18232,
12,
2538,
12,
5361,
304,
267,
862,
26,
288,
6339,
2956,
275,
791,
5812,
5242,
72,
3558,
297,
283,
502,
5242,
84,
455,
382,
297,
283,
266,
5242,
14146,
1518,
85,
297,
283,
757,
5242,
2174,
1187,
279,
455,
297,
283,
18974,
5242,
75,
1189,
10641,
297,
283,
10472,
5242,
66,
22329,
297,
283,
13118,
5242,
4584,
1619,
73,
297,
283,
387,
5242,
80,
324,
74,
14677,
936,
953,
6339,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1213,
3149,
83,
4805,
450,
18232,
288,
6339,
275,
1890,
14,
1069,
8,
4159,
9,
288,
6339,
275,
295,
14,
6452,
360,
6399,
60,
83,
23440,
83,
23033,
3985,
6113,
937,
28149,
2788,
3985,
6113,
23793,
6339,
9,
288,
6339,
275,
359,
73,
367,
284,
315,
6339,
340,
283,
3327,
63,
3671,
7,
315,
284,
61,
288,
6339,
275,
359,
10290,
14,
1122,
63,
6177,
8,
10290,
14,
10290,
8,
73,
680,
1131,
9,
367,
284,
315,
6339,
61,
288,
6339,
275,
359,
73,
459,
3327,
63,
3671,
418,
367,
284,
315,
6339,
340,
283,
3327,
63,
3671,
7,
315,
284,
61,
288,
6339,
275,
6339,
2956,
59,
4159,
59,
16,
1527,
16,
2677,
953,
1894,
275,
291,
14,
1733,
63,
1073,
450,
334,
4159,
12,
4011,
14,
3513,
63,
6666,
8,
1213,
430,
288,
1894,
275,
7097,
14,
17755,
8,
277,
14,
1095,
63,
1073,
12,
1894,
9,
953,
307,
275,
3633,
1213,
14,
362,
8,
1213,
9,
953,
519,
275,
291,
14,
1069,
8,
81,
9,
953,
519,
275,
1890,
14,
24438,
8,
82,
12,
283,
317,
358,
288,
519,
275,
3842,
1258,
14,
24438,
8,
73,
12,
283,
65,
297,
2203,
534,
6399,
659,
1890,
14,
24438,
8,
73,
12,
283,
72,
19,
659,
1890,
14,
24438,
8,
73,
12,
283,
3015,
297,
3290,
275,
791,
533,
356,
283,
815,
20219,
367,
284,
315,
519,
61,
288,
519,
275,
3842,
73,
59,
16,
1527,
16,
467,
284,
59,
17,
1527,
16,
467,
284,
59,
18,
1527,
16,
566,
367,
284,
315,
519,
340,
284,
59,
16,
61,
436,
284,
59,
17,
61,
436,
284,
59,
18,
2677,
288,
519,
275,
3842,
264,
14,
6452,
360,
2961,
68,
14705,
284,
59,
16,
2522,
284,
59,
17,
467,
295,
14,
6452,
360,
2961,
68,
91,
20,
25583,
284,
59,
18,
2459,
367,
284,
315,
519,
61,
288,
519,
275,
3842,
73,
59,
16,
1527,
16,
467,
284,
59,
17,
467,
284,
59,
18,
1527,
16,
566,
367,
284,
315,
519,
340,
284,
59,
16,
61,
436,
284,
59,
18,
2677,
288,
519,
275,
359,
73,
59,
16,
61,
367,
284,
315,
519,
340,
307,
508,
3633,
1213,
14,
362,
8,
73,
59,
17,
566,
436,
5361,
508,
284,
59,
18,
22235,
16,
61,
953,
1166,
275,
620,
8,
82,
9,
288,
372,
1166,
267,
871,
26,
288,
372,
2378,
347,
5274,
8,
277,
12,
1166,
12,
1591,
2141,
12,
1591,
2700,
2141,
304,
267,
862,
26,
288,
5274,
275,
942,
953,
340,
1166,
508,
488,
26,
372,
5274,
953,
1166,
275,
291,
14,
10888,
63,
1073,
450,
1166,
288,
1166,
275,
7097,
14,
17755,
8,
277,
14,
1095,
63,
1073,
12,
1166,
9,
953,
372,
5274,
953,
519,
275,
291,
14,
1069,
8,
633,
9,
953,
5274,
14,
740,
3252,
1365,
356,
283,
69,
262,
273,
527,
290,
297,
283,
9161,
356,
283,
14903,
297,
283,
3780,
356,
283,
37,
262,
273,
527,
290,
297,
283,
633,
356,
1166,
12,
283,
2275,
356,
715,
12,
283,
271,
14601,
2118,
356,
756,
1552,
288,
372,
5274,
267,
871,
26,
288,
372,
5274,
2378,
347,
7512,
8,
277,
12,
1166,
304,
267,
372,
1166,
4388,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
2344,
272,
1316,
364,
527,
2654,
13,
265,
272,
1898,
334,
35,
9,
7800,
1316,
364,
527,
339,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
272,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
272,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
272,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
339,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
272,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
272,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
272,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
339,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
272,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
2344,
421,
199,
646,
295,
12,
4078,
12,
4078,
18,
12,
10290,
12,
6424,
12,
12256,
12,
1001,
199,
199,
504,
5944,
14,
773,
14,
3112,
492,
3633,
1213,
199,
504,
5944,
14,
773,
14,
3112,
492,
1890,
421,
199,
533,
1350,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
3671,
275,
788,
287,
418,
267,
291,
14,
9756,
275,
788,
69,
262,
273,
527,
290,
14,
957,
297,
283,
69,
262,
273,
527,
290,
14,
6993,
418,
267,
291,
14,
1095,
63,
1073,
275,
283,
2859,
921,
69,
262,
273,
527,
290,
14,
6993,
7,
267,
291,
14,
1733,
63,
1073,
275,
1994,
10888,
15,
2604,
10197,
4159,
2458,
83,
6,
1131,
2458,
83,
7,
267,
291,
14,
10888,
63,
1073,
275,
1994,
10888,
15,
6821,
3149,
83,
4805,
2378,
347,
1056,
8,
277,
12,
1166,
304,
267,
862,
26,
288,
2648,
275,
4011,
18,
14,
2017,
8,
633,
9,
288,
2648,
14,
525,
63,
1291,
360,
1899,
13,
7788,
297,
1890,
14,
3759,
79,
5615,
484,
1012,
288,
522,
275,
4011,
18,
14,
10890,
8,
2103,
9,
288,
519,
275,
522,
14,
739,
342,
340,
440,
522,
14,
815,
1252,
19958,
360,
2714,
13,
7630,
358,
508,
283,
12256,
7,
587,
11756,
14,
29827,
8,
9234,
29,
6424,
14,
6424,
8,
470,
14,
739,
4059,
14,
739,
342,
288,
522,
14,
1600,
342,
288,
372,
519,
267,
871,
26,
288,
372,
2378,
347,
14360,
8,
277,
12,
18232,
12,
2538,
12,
5361,
304,
267,
862,
26,
288,
6339,
2956,
275,
791,
5812,
5242,
72,
3558,
297,
283,
502,
5242,
84,
455,
382,
297,
283,
266,
5242,
14146,
1518,
85,
297,
283,
757,
5242,
2174,
1187,
279,
455,
297,
283,
18974,
5242,
75,
1189,
10641,
297,
283,
10472,
5242,
66,
22329,
297,
283,
13118,
5242,
4584,
1619,
73,
297,
283,
387,
5242,
80,
324,
74,
14677,
936,
953,
6339,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1213,
3149,
83,
4805,
450,
18232,
288,
6339,
275,
1890,
14,
1069,
8,
4159,
9,
288,
6339,
275,
295,
14,
6452,
360,
6399,
60,
83,
23440,
83,
23033,
3985,
6113,
937,
28149,
2788,
3985,
6113,
23793,
6339,
9,
288,
6339,
275,
359,
73,
367,
284,
315,
6339,
340,
283,
3327,
63,
3671,
7,
315,
284,
61,
288,
6339,
275,
359,
10290,
14,
1122,
63,
6177,
8,
10290,
14,
10290,
8,
73,
680,
1131,
9,
367,
284,
315,
6339,
61,
288,
6339,
275,
359,
73,
459,
3327,
63,
3671,
418,
367,
284,
315,
6339,
340,
283,
3327,
63,
3671,
7,
315,
284,
61,
288,
6339,
275,
6339,
2956,
59,
4159,
59,
16,
1527,
16,
2677,
953,
1894,
275,
291,
14,
1733,
63,
1073,
450,
334,
4159,
12,
4011,
14,
3513,
63,
6666,
8,
1213,
430,
288,
1894,
275,
7097,
14,
17755,
8,
277,
14,
1095,
63,
1073,
12,
1894,
9,
953,
307,
275,
3633,
1213,
14,
362,
8,
1213,
9,
953,
519,
275,
291,
14,
1069,
8,
81,
9,
953,
519,
275,
1890,
14,
24438,
8,
82,
12,
283,
317,
358,
288,
519,
275,
3842,
1258,
14,
24438,
8,
73,
12,
283,
65,
297,
2203,
534,
6399,
659,
1890,
14,
24438,
8,
73,
12,
283,
72,
19,
659,
1890,
14,
24438,
8,
73,
12,
283,
3015,
297,
3290,
275,
791,
533,
356,
283,
815,
20219,
367,
284,
315,
519,
61,
288,
519,
275,
3842,
73,
59,
16,
1527,
16,
467,
284,
59,
17,
1527,
16,
467,
284,
59,
18,
1527,
16,
566,
367,
284,
315,
519,
340,
284,
59,
16,
61,
436,
284,
59,
17,
61,
436,
284,
59,
18,
2677,
288,
519,
275,
3842,
264,
14,
6452,
360,
2961,
68,
14705,
284,
59,
16,
2522,
284,
59,
17,
467,
295,
14,
6452,
360,
2961,
68,
91,
20,
25583,
284,
59,
18,
2459,
367,
284,
315,
519,
61,
288,
519,
275,
3842,
73,
59,
16,
1527,
16,
467,
284,
59,
17,
467,
284,
59,
18,
1527,
16,
566,
367,
284,
315,
519,
340,
284,
59,
16,
61,
436,
284,
59,
18,
2677,
288,
519,
275,
359,
73,
59,
16,
61,
367,
284,
315,
519,
340,
307,
508,
3633,
1213,
14,
362,
8,
73,
59,
17,
566,
436,
5361,
508,
284,
59,
18,
22235,
16,
61,
953,
1166,
275,
620,
8,
82,
9,
288,
372,
1166,
267,
871,
26,
288,
372,
2378,
347,
5274,
8,
277,
12,
1166,
12,
1591,
2141,
12,
1591,
2700,
2141,
304,
267,
862,
26,
288,
5274,
275,
942,
953,
340,
1166,
508,
488,
26,
372,
5274,
953,
1166,
275,
291,
14,
10888,
63,
1073,
450,
1166,
288,
1166,
275,
7097,
14,
17755,
8,
277,
14,
1095,
63,
1073,
12,
1166,
9,
953,
372,
5274,
953,
519,
275,
291,
14,
1069,
8,
633,
9,
953,
5274,
14,
740,
3252,
1365,
356,
283,
69,
262,
273,
527,
290,
297,
283,
9161,
356,
283,
14903,
297,
283,
3780,
356,
283,
37,
262,
273,
527,
290,
297,
283,
633,
356,
1166,
12,
283,
2275,
356,
715,
12,
283,
271,
14601,
2118,
356,
756,
1552,
288,
372,
5274,
267,
871,
26,
288,
372,
5274,
2378,
347,
7512,
8,
277,
12,
1166,
304,
267,
372,
1166,
4388,
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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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
radicalbit/ambari
|
ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/FALCON/package/scripts/falcon.py
|
3
|
3046
|
"""
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from resource_management import *
def falcon(type, action = None):
import params
if action == 'config':
Directory(params.falcon_pid_dir,
owner=params.falcon_user
)
Directory(params.falcon_log_dir,
owner=params.falcon_user
)
Directory(params.falcon_webapp_dir,
owner=params.falcon_user
)
Directory(params.falcon_home,
owner=params.falcon_user
)
File(params.falcon_conf_dir + '/falcon-env.sh',
content=Template('falcon-env.sh.j2')
)
PropertiesFile(params.falcon_conf_dir + '/client.properties',
properties=params.falcon_client_properties,
mode=0644
)
PropertiesFile(params.falcon_conf_dir + '/runtime.properties',
properties=params.falcon_runtime_properties,
mode=0644
)
PropertiesFile(params.falcon_conf_dir + '/startup.properties',
properties=params.falcon_startup_properties,
mode=0644
)
if type == 'server':
if action == 'config':
if params.store_uri[0:4] == "hdfs":
params.HdfsDirectory(params.store_uri,
action="create_delayed",
owner=params.falcon_user,
mode=0755
)
params.HdfsDirectory(params.flacon_apps_dir,
action="create_delayed",
owner=params.falcon_user,
mode=0777#TODO change to proper mode
)
params.HdfsDirectory(None, action="create")
Directory(params.falcon_local_dir,
owner=params.falcon_user,
create_parents = True
)
if params.falcon_embeddedmq_enabled == True:
Directory(params.falcon_embeddedmq_data,
owner=params.falcon_user,
create_parents = True
)
if action == 'start':
Execute(format('{falcon_home}/bin/falcon-start -port {falcon_port}'),
user=params.falcon_user
)
if action == 'stop':
Execute(format('{falcon_home}/bin/falcon-stop'),
user=params.falcon_user
)
File(params.server_pid_file,
action='delete'
)
|
apache-2.0
|
[
624,
199,
31661,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
269,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
16832,
543,
642,
1736,
367,
4722,
2556,
199,
1135,
1005,
316,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
475,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
2,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
1045,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
339,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
199,
624,
199,
199,
504,
2073,
63,
8110,
492,
627,
199,
199,
318,
289,
279,
388,
8,
466,
12,
1595,
275,
488,
304,
523,
492,
1862,
523,
340,
1595,
508,
283,
888,
356,
272,
15191,
8,
1162,
14,
70,
279,
388,
63,
3150,
63,
694,
12,
1598,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
272,
776,
272,
15191,
8,
1162,
14,
70,
279,
388,
63,
793,
63,
694,
12,
1598,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
272,
776,
272,
15191,
8,
1162,
14,
70,
279,
388,
63,
22632,
63,
694,
12,
1598,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
272,
776,
272,
15191,
8,
1162,
14,
70,
279,
388,
63,
4219,
12,
1598,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
272,
776,
272,
3814,
8,
1162,
14,
70,
279,
388,
63,
2190,
63,
694,
435,
1994,
70,
279,
388,
13,
1813,
14,
609,
297,
268,
1564,
29,
4231,
360,
70,
279,
388,
13,
1813,
14,
609,
14,
74,
18,
358,
272,
776,
272,
19329,
1173,
8,
1162,
14,
70,
279,
388,
63,
2190,
63,
694,
435,
1994,
1258,
14,
3282,
297,
673,
4382,
29,
1162,
14,
70,
279,
388,
63,
1258,
63,
3282,
12,
673,
818,
29,
16,
10893,
272,
776,
272,
19329,
1173,
8,
1162,
14,
70,
279,
388,
63,
2190,
63,
694,
435,
1994,
7726,
14,
3282,
297,
673,
4382,
29,
1162,
14,
70,
279,
388,
63,
7726,
63,
3282,
12,
673,
818,
29,
16,
10893,
272,
776,
272,
19329,
1173,
8,
1162,
14,
70,
279,
388,
63,
2190,
63,
694,
435,
1994,
16480,
14,
3282,
297,
673,
4382,
29,
1162,
14,
70,
279,
388,
63,
16480,
63,
3282,
12,
673,
818,
29,
16,
10893,
272,
776,
523,
340,
730,
508,
283,
1000,
356,
272,
340,
1595,
508,
283,
888,
356,
489,
340,
1862,
14,
1617,
63,
2302,
59,
16,
26,
20,
61,
508,
298,
19055,
582,
267,
1862,
14,
40,
10434,
6231,
8,
1162,
14,
1617,
63,
2302,
12,
2490,
1595,
628,
981,
63,
21830,
401,
2490,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
12,
2490,
818,
29,
1780,
1229,
267,
776,
489,
1862,
14,
40,
10434,
6231,
8,
1162,
14,
14163,
388,
63,
5181,
63,
694,
12,
2574,
1595,
628,
981,
63,
21830,
401,
2574,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
12,
2574,
818,
29,
16,
11956,
3,
11768,
1570,
370,
5576,
818,
489,
776,
489,
1862,
14,
40,
10434,
6231,
8,
403,
12,
1595,
628,
981,
531,
489,
15191,
8,
1162,
14,
70,
279,
388,
63,
1832,
63,
694,
12,
355,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
12,
355,
1218,
63,
8859,
275,
715,
489,
776,
489,
340,
1862,
14,
70,
279,
388,
63,
18757,
8334,
63,
3827,
508,
715,
26,
267,
15191,
8,
1162,
14,
70,
279,
388,
63,
18757,
8334,
63,
576,
12,
2116,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
12,
2116,
1218,
63,
8859,
275,
715,
267,
776,
339,
340,
1595,
508,
283,
928,
356,
489,
17009,
8,
908,
11117,
70,
279,
388,
63,
4219,
5995,
1393,
15,
70,
279,
388,
13,
928,
446,
719,
469,
70,
279,
388,
63,
719,
93,
659,
1598,
922,
29,
1162,
14,
70,
279,
388,
63,
751,
489,
776,
272,
340,
1595,
508,
283,
2379,
356,
489,
17009,
8,
908,
11117,
70,
279,
388,
63,
4219,
5995,
1393,
15,
70,
279,
388,
13,
2379,
659,
1598,
922,
29,
1162,
14,
70,
279,
388,
63,
751,
489,
776,
489,
3814,
8,
1162,
14,
1000,
63,
3150,
63,
493,
12,
1779,
1595,
534,
1807,
7,
489,
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
] |
[
199,
31661,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
269,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
16832,
543,
642,
1736,
367,
4722,
2556,
199,
1135,
1005,
316,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
475,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
2,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
1045,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
339,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
199,
624,
199,
199,
504,
2073,
63,
8110,
492,
627,
199,
199,
318,
289,
279,
388,
8,
466,
12,
1595,
275,
488,
304,
523,
492,
1862,
523,
340,
1595,
508,
283,
888,
356,
272,
15191,
8,
1162,
14,
70,
279,
388,
63,
3150,
63,
694,
12,
1598,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
272,
776,
272,
15191,
8,
1162,
14,
70,
279,
388,
63,
793,
63,
694,
12,
1598,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
272,
776,
272,
15191,
8,
1162,
14,
70,
279,
388,
63,
22632,
63,
694,
12,
1598,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
272,
776,
272,
15191,
8,
1162,
14,
70,
279,
388,
63,
4219,
12,
1598,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
272,
776,
272,
3814,
8,
1162,
14,
70,
279,
388,
63,
2190,
63,
694,
435,
1994,
70,
279,
388,
13,
1813,
14,
609,
297,
268,
1564,
29,
4231,
360,
70,
279,
388,
13,
1813,
14,
609,
14,
74,
18,
358,
272,
776,
272,
19329,
1173,
8,
1162,
14,
70,
279,
388,
63,
2190,
63,
694,
435,
1994,
1258,
14,
3282,
297,
673,
4382,
29,
1162,
14,
70,
279,
388,
63,
1258,
63,
3282,
12,
673,
818,
29,
16,
10893,
272,
776,
272,
19329,
1173,
8,
1162,
14,
70,
279,
388,
63,
2190,
63,
694,
435,
1994,
7726,
14,
3282,
297,
673,
4382,
29,
1162,
14,
70,
279,
388,
63,
7726,
63,
3282,
12,
673,
818,
29,
16,
10893,
272,
776,
272,
19329,
1173,
8,
1162,
14,
70,
279,
388,
63,
2190,
63,
694,
435,
1994,
16480,
14,
3282,
297,
673,
4382,
29,
1162,
14,
70,
279,
388,
63,
16480,
63,
3282,
12,
673,
818,
29,
16,
10893,
272,
776,
523,
340,
730,
508,
283,
1000,
356,
272,
340,
1595,
508,
283,
888,
356,
489,
340,
1862,
14,
1617,
63,
2302,
59,
16,
26,
20,
61,
508,
298,
19055,
582,
267,
1862,
14,
40,
10434,
6231,
8,
1162,
14,
1617,
63,
2302,
12,
2490,
1595,
628,
981,
63,
21830,
401,
2490,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
12,
2490,
818,
29,
1780,
1229,
267,
776,
489,
1862,
14,
40,
10434,
6231,
8,
1162,
14,
14163,
388,
63,
5181,
63,
694,
12,
2574,
1595,
628,
981,
63,
21830,
401,
2574,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
12,
2574,
818,
29,
16,
11956,
3,
11768,
1570,
370,
5576,
818,
489,
776,
489,
1862,
14,
40,
10434,
6231,
8,
403,
12,
1595,
628,
981,
531,
489,
15191,
8,
1162,
14,
70,
279,
388,
63,
1832,
63,
694,
12,
355,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
12,
355,
1218,
63,
8859,
275,
715,
489,
776,
489,
340,
1862,
14,
70,
279,
388,
63,
18757,
8334,
63,
3827,
508,
715,
26,
267,
15191,
8,
1162,
14,
70,
279,
388,
63,
18757,
8334,
63,
576,
12,
2116,
5771,
29,
1162,
14,
70,
279,
388,
63,
751,
12,
2116,
1218,
63,
8859,
275,
715,
267,
776,
339,
340,
1595,
508,
283,
928,
356,
489,
17009,
8,
908,
11117,
70,
279,
388,
63,
4219,
5995,
1393,
15,
70,
279,
388,
13,
928,
446,
719,
469,
70,
279,
388,
63,
719,
93,
659,
1598,
922,
29,
1162,
14,
70,
279,
388,
63,
751,
489,
776,
272,
340,
1595,
508,
283,
2379,
356,
489,
17009,
8,
908,
11117,
70,
279,
388,
63,
4219,
5995,
1393,
15,
70,
279,
388,
13,
2379,
659,
1598,
922,
29,
1162,
14,
70,
279,
388,
63,
751,
489,
776,
489,
3814,
8,
1162,
14,
1000,
63,
3150,
63,
493,
12,
1779,
1595,
534,
1807,
7,
489,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
wangyum/tensorflow
|
tensorflow/python/debug/cli/tensor_format.py
|
28
|
16452
|
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Format tensors (ndarrays) for screen display and navigation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
import re
import numpy as np
from six.moves import xrange # pylint: disable=redefined-builtin
from tensorflow.python.debug.cli import debugger_cli_common
from tensorflow.python.debug.lib import debug_data
_NUMPY_OMISSION = "...,"
_NUMPY_DEFAULT_EDGE_ITEMS = 3
_NUMBER_REGEX = re.compile(r"[-+]?([0-9][-+0-9eE\.]+|nan|inf)(\s|,|\])")
BEGIN_INDICES_KEY = "i0"
OMITTED_INDICES_KEY = "omitted"
DEFAULT_TENSOR_ELEMENT_HIGHLIGHT_FONT_ATTR = "bold"
class HighlightOptions(object):
"""Options for highlighting elements of a tensor."""
def __init__(self,
criterion,
description=None,
font_attr=DEFAULT_TENSOR_ELEMENT_HIGHLIGHT_FONT_ATTR):
"""Constructor of HighlightOptions.
Args:
criterion: (callable) A callable of the following signature:
def to_highlight(X):
# Args:
# X: The tensor to highlight elements in.
#
# Returns:
# (boolean ndarray) A boolean ndarray of the same shape as X
# indicating which elements are to be highlighted (iff True).
This callable will be used as the argument of np.argwhere() to
determine which elements of the tensor are to be highlighted.
description: (str) Description of the highlight criterion embodied by
criterion.
font_attr: (str) Font attribute to be applied to the
highlighted elements.
"""
self.criterion = criterion
self.description = description
self.font_attr = font_attr
def format_tensor(tensor,
tensor_label,
include_metadata=False,
np_printoptions=None,
highlight_options=None):
"""Generate a RichTextLines object showing a tensor in formatted style.
Args:
tensor: The tensor to be displayed, as a numpy ndarray or other
appropriate format (e.g., None representing uninitialized tensors).
tensor_label: A label for the tensor, as a string. If set to None, will
suppress the tensor name line in the return value.
include_metadata: Whether metadata such as dtype and shape are to be
included in the formatted text.
np_printoptions: A dictionary of keyword arguments that are passed to a
call of np.set_printoptions() to set the text format for display numpy
ndarrays.
highlight_options: (HighlightOptions) options for highlighting elements
of the tensor.
Returns:
A RichTextLines object. Its annotation field has line-by-line markups to
indicate which indices in the array the first element of each line
corresponds to.
"""
lines = []
font_attr_segs = {}
if tensor_label is not None:
lines.append("Tensor \"%s\":" % tensor_label)
suffix = tensor_label.split(":")[-1]
if suffix.isdigit():
# Suffix is a number. Assume it is the output slot index.
font_attr_segs[0] = [(8, 8 + len(tensor_label), "bold")]
else:
# Suffix is not a number. It is auxiliary information such as the debug
# op type. In this case, highlight the suffix with a different color.
debug_op_len = len(suffix)
proper_len = len(tensor_label) - debug_op_len - 1
font_attr_segs[0] = [
(8, 8 + proper_len, "bold"),
(8 + proper_len + 1, 8 + proper_len + 1 + debug_op_len, "yellow")
]
if isinstance(tensor, debug_data.InconvertibleTensorProto):
if lines:
lines.append("")
lines.extend(str(tensor).split("\n"))
return debugger_cli_common.RichTextLines(lines)
elif not isinstance(tensor, np.ndarray):
# If tensor is not a np.ndarray, return simple text-line representation of
# the object without annotations.
if lines:
lines.append("")
lines.extend(repr(tensor).split("\n"))
return debugger_cli_common.RichTextLines(lines)
if include_metadata:
lines.append(" dtype: %s" % str(tensor.dtype))
lines.append(" shape: %s" % str(tensor.shape))
if lines:
lines.append("")
hlines = len(lines)
# Apply custom string formatting options for numpy ndarray.
if np_printoptions is not None:
np.set_printoptions(**np_printoptions)
array_lines = repr(tensor).split("\n")
lines.extend(array_lines)
if tensor.dtype.type is not np.string_:
# Parse array lines to get beginning indices for each line.
# TODO(cais): Currently, we do not annotate string-type tensors due to
# difficulty in escaping sequences. Address this issue.
annotations = _annotate_ndarray_lines(
array_lines, tensor, np_printoptions=np_printoptions, offset=hlines)
formatted = debugger_cli_common.RichTextLines(
lines, font_attr_segs=font_attr_segs, annotations=annotations)
# Perform optional highlighting.
if highlight_options is not None:
indices_list = list(np.argwhere(highlight_options.criterion(tensor)))
total_elements = np.size(tensor)
highlight_summary = "Highlighted%s: %d of %d element(s) (%.2f%%)" % (
"(%s)" % highlight_options.description if highlight_options.description
else "", len(indices_list), total_elements,
len(indices_list) / float(total_elements) * 100.0)
formatted.lines[0] += " " + highlight_summary
if indices_list:
indices_list = [list(indices) for indices in indices_list]
are_omitted, rows, start_cols, end_cols = locate_tensor_element(
formatted, indices_list)
for is_omitted, row, start_col, end_col in zip(are_omitted, rows,
start_cols, end_cols):
if is_omitted or start_col is None or end_col is None:
continue
if row in formatted.font_attr_segs:
formatted.font_attr_segs[row].append(
(start_col, end_col, highlight_options.font_attr))
else:
formatted.font_attr_segs[row] = [(start_col, end_col,
highlight_options.font_attr)]
return formatted
def _annotate_ndarray_lines(
array_lines, tensor, np_printoptions=None, offset=0):
"""Generate annotations for line-by-line begin indices of tensor text.
Parse the numpy-generated text representation of a numpy ndarray to
determine the indices of the first element of each text line (if any
element is present in the line).
For example, given the following multi-line ndarray text representation:
["array([[ 0. , 0.0625, 0.125 , 0.1875],",
" [ 0.25 , 0.3125, 0.375 , 0.4375],",
" [ 0.5 , 0.5625, 0.625 , 0.6875],",
" [ 0.75 , 0.8125, 0.875 , 0.9375]])"]
the generate annotation will be:
{0: {BEGIN_INDICES_KEY: [0, 0]},
1: {BEGIN_INDICES_KEY: [1, 0]},
2: {BEGIN_INDICES_KEY: [2, 0]},
3: {BEGIN_INDICES_KEY: [3, 0]}}
Args:
array_lines: Text lines representing the tensor, as a list of str.
tensor: The tensor being formatted as string.
np_printoptions: A dictionary of keyword arguments that are passed to a
call of np.set_printoptions().
offset: Line number offset applied to the line indices in the returned
annotation.
Returns:
An annotation as a dict.
"""
if np_printoptions and "edgeitems" in np_printoptions:
edge_items = np_printoptions["edgeitems"]
else:
edge_items = _NUMPY_DEFAULT_EDGE_ITEMS
annotations = {}
# Put metadata about the tensor in the annotations["tensor_metadata"].
annotations["tensor_metadata"] = {
"dtype": tensor.dtype, "shape": tensor.shape}
dims = np.shape(tensor)
ndims = len(dims)
if ndims == 0:
# No indices for a 0D tensor.
return annotations
curr_indices = [0] * len(dims)
curr_dim = 0
for i in xrange(len(array_lines)):
line = array_lines[i].strip()
if not line:
# Skip empty lines, which can appear for >= 3D arrays.
continue
if line == _NUMPY_OMISSION:
annotations[offset + i] = {OMITTED_INDICES_KEY: copy.copy(curr_indices)}
curr_indices[curr_dim - 1] = dims[curr_dim - 1] - edge_items
else:
num_lbrackets = line.count("[") # TODO(cais): String array escaping.
num_rbrackets = line.count("]")
curr_dim += num_lbrackets - num_rbrackets
annotations[offset + i] = {BEGIN_INDICES_KEY: copy.copy(curr_indices)}
if num_rbrackets == 0:
line_content = line[line.rfind("[") + 1:]
num_elements = line_content.count(",")
curr_indices[curr_dim - 1] += num_elements
else:
if curr_dim > 0:
curr_indices[curr_dim - 1] += 1
for k in xrange(curr_dim, ndims):
curr_indices[k] = 0
return annotations
def locate_tensor_element(formatted, indices):
"""Locate a tensor element in formatted text lines, given element indices.
Given a RichTextLines object representing a tensor and indices of the sought
element, return the row number at which the element is located (if exists).
Args:
formatted: A RichTextLines object containing formatted text lines
representing the tensor.
indices: Indices of the sought element, as a list of int or a list of list
of int. The former case is for a single set of indices to look up,
whereas the latter case is for looking up a batch of indices sets at once.
In the latter case, the indices must be in ascending order, or a
ValueError will be raised.
Returns:
1) A boolean indicating whether the element falls into an omitted line.
2) Row index.
3) Column start index, i.e., the first column in which the representation
of the specified tensor starts, if it can be determined. If it cannot
be determined (e.g., due to ellipsis), None.
4) Column end index, i.e., the column right after the last column that
represents the specified tensor. Iff it cannot be determined, None.
For return values described above are based on a single set of indices to
look up. In the case of batch mode (multiple sets of indices), the return
values will be lists of the types described above.
Raises:
AttributeError: If:
Input argument "formatted" does not have the required annotations.
ValueError: If:
1) Indices do not match the dimensions of the tensor, or
2) Indices exceed sizes of the tensor, or
3) Indices contain negative value(s).
4) If in batch mode, and if not all sets of indices are in ascending
order.
"""
if isinstance(indices[0], list):
indices_list = indices
input_batch = True
else:
indices_list = [indices]
input_batch = False
# Check that tensor_metadata is available.
if "tensor_metadata" not in formatted.annotations:
raise AttributeError("tensor_metadata is not available in annotations.")
# Sanity check on input argument.
_validate_indices_list(indices_list, formatted)
dims = formatted.annotations["tensor_metadata"]["shape"]
batch_size = len(indices_list)
lines = formatted.lines
annot = formatted.annotations
prev_r = 0
prev_line = ""
prev_indices = [0] * len(dims)
# Initialize return values
are_omitted = [None] * batch_size
row_indices = [None] * batch_size
start_columns = [None] * batch_size
end_columns = [None] * batch_size
batch_pos = 0 # Current position in the batch.
for r in xrange(len(lines)):
if r not in annot:
continue
if BEGIN_INDICES_KEY in annot[r]:
indices_key = BEGIN_INDICES_KEY
elif OMITTED_INDICES_KEY in annot[r]:
indices_key = OMITTED_INDICES_KEY
matching_indices_list = [
ind for ind in indices_list[batch_pos:]
if prev_indices <= ind < annot[r][indices_key]
]
if matching_indices_list:
num_matches = len(matching_indices_list)
match_start_columns, match_end_columns = _locate_elements_in_line(
prev_line, matching_indices_list, prev_indices)
start_columns[batch_pos:batch_pos + num_matches] = match_start_columns
end_columns[batch_pos:batch_pos + num_matches] = match_end_columns
are_omitted[batch_pos:batch_pos + num_matches] = [
OMITTED_INDICES_KEY in annot[prev_r]
] * num_matches
row_indices[batch_pos:batch_pos + num_matches] = [prev_r] * num_matches
batch_pos += num_matches
if batch_pos >= batch_size:
break
prev_r = r
prev_line = lines[r]
prev_indices = annot[r][indices_key]
if batch_pos < batch_size:
matching_indices_list = indices_list[batch_pos:]
num_matches = len(matching_indices_list)
match_start_columns, match_end_columns = _locate_elements_in_line(
prev_line, matching_indices_list, prev_indices)
start_columns[batch_pos:batch_pos + num_matches] = match_start_columns
end_columns[batch_pos:batch_pos + num_matches] = match_end_columns
are_omitted[batch_pos:batch_pos + num_matches] = [
OMITTED_INDICES_KEY in annot[prev_r]
] * num_matches
row_indices[batch_pos:batch_pos + num_matches] = [prev_r] * num_matches
if input_batch:
return are_omitted, row_indices, start_columns, end_columns
else:
return are_omitted[0], row_indices[0], start_columns[0], end_columns[0]
def _validate_indices_list(indices_list, formatted):
prev_ind = None
for ind in indices_list:
# Check indices match tensor dimensions.
dims = formatted.annotations["tensor_metadata"]["shape"]
if len(ind) != len(dims):
raise ValueError("Dimensions mismatch: requested: %d; actual: %d" %
(len(ind), len(dims)))
# Check indices is within size limits.
for req_idx, siz in zip(ind, dims):
if req_idx >= siz:
raise ValueError("Indices exceed tensor dimensions.")
if req_idx < 0:
raise ValueError("Indices contain negative value(s).")
# Check indices are in ascending order.
if prev_ind and ind < prev_ind:
raise ValueError("Input indices sets are not in ascending order.")
prev_ind = ind
def _locate_elements_in_line(line, indices_list, ref_indices):
"""Determine the start and end indices of an element in a line.
Args:
line: (str) the line in which the element is to be sought.
indices_list: (list of list of int) list of indices of the element to
search for. Assumes that the indices in the batch are unique and sorted
in ascending order.
ref_indices: (list of int) reference indices, i.e., the indices of the
first element represented in the line.
Returns:
start_columns: (list of int) start column indices, if found. If not found,
None.
end_columns: (list of int) end column indices, if found. If not found,
None.
If found, the element is represented in the left-closed-right-open interval
[start_column, end_column].
"""
batch_size = len(indices_list)
offsets = [indices[-1] - ref_indices[-1] for indices in indices_list]
start_columns = [None] * batch_size
end_columns = [None] * batch_size
if _NUMPY_OMISSION in line:
ellipsis_index = line.find(_NUMPY_OMISSION)
else:
ellipsis_index = len(line)
matches_iter = re.finditer(_NUMBER_REGEX, line)
batch_pos = 0
offset_counter = 0
for match in matches_iter:
if match.start() > ellipsis_index:
# Do not attempt to search beyond ellipsis.
break
if offset_counter == offsets[batch_pos]:
start_columns[batch_pos] = match.start()
# Remove the final comma, right bracket, or whitespace.
end_columns[batch_pos] = match.end() - 1
batch_pos += 1
if batch_pos >= batch_size:
break
offset_counter += 1
return start_columns, end_columns
|
apache-2.0
|
[
3,
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
3484,
10519,
334,
977,
10095,
9,
367,
6426,
2929,
436,
19191,
1041,
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,
1331,
199,
646,
295,
199,
199,
646,
2680,
465,
980,
199,
504,
3816,
14,
4912,
492,
4945,
221,
327,
4287,
26,
3507,
29,
27913,
13,
5351,
199,
199,
504,
3228,
14,
1548,
14,
1757,
14,
2764,
492,
14958,
63,
2764,
63,
2330,
199,
504,
3228,
14,
1548,
14,
1757,
14,
773,
492,
3105,
63,
576,
199,
199,
63,
1440,
1658,
57,
63,
7474,
20291,
275,
298,
1396,
4589,
199,
63,
1440,
1658,
57,
63,
3472,
63,
1149,
4962,
63,
10439,
51,
275,
650,
199,
199,
63,
9190,
63,
10710,
275,
295,
14,
2014,
8,
82,
2,
27371,
11843,
779,
16,
13,
25,
1527,
6793,
16,
13,
25,
20565,
4537,
2807,
92,
4304,
92,
4904,
10127,
83,
18712,
6113,
566,
531,
199,
199,
15947,
63,
3192,
7040,
63,
3078,
275,
298,
73,
16,
2,
199,
7474,
20779,
1149,
63,
3192,
7040,
63,
3078,
275,
298,
19007,
471,
2,
199,
199,
3472,
63,
52,
17850,
63,
12535,
63,
17624,
21613,
63,
18398,
63,
5280,
275,
298,
9771,
2,
421,
199,
533,
16332,
4040,
4558,
8,
785,
304,
523,
408,
4558,
367,
22437,
4008,
402,
282,
2345,
1041,
819,
347,
636,
826,
721,
277,
12,
2049,
17392,
12,
2049,
1369,
29,
403,
12,
2049,
5023,
63,
962,
29,
3472,
63,
52,
17850,
63,
12535,
63,
17624,
21613,
63,
18398,
63,
5280,
304,
272,
408,
11447,
402,
16332,
4040,
4558,
14,
339,
3033,
26,
489,
17392,
26,
334,
8296,
9,
437,
4550,
402,
314,
2569,
4955,
26,
267,
347,
370,
63,
14337,
8,
56,
304,
881,
327,
3033,
26,
881,
327,
257,
1323,
26,
710,
2345,
370,
11850,
4008,
315,
14,
881,
327,
881,
327,
1803,
26,
881,
327,
257,
334,
4871,
6800,
9,
437,
5046,
6800,
402,
314,
2011,
2215,
465,
1323,
881,
327,
257,
9297,
1314,
4008,
787,
370,
506,
4721,
27883,
334,
15126,
715,
680,
267,
961,
4550,
911,
506,
1202,
465,
314,
1423,
402,
980,
14,
1273,
4509,
342,
370,
267,
6705,
1314,
4008,
402,
314,
2345,
787,
370,
506,
4721,
27883,
14,
489,
1369,
26,
334,
495,
9,
11994,
402,
314,
11850,
17392,
18564,
656,
328,
379,
701,
267,
17392,
14,
489,
5023,
63,
962,
26,
334,
495,
9,
26159,
2225,
370,
506,
6781,
370,
314,
267,
4721,
27883,
4008,
14,
339,
408,
339,
291,
14,
21418,
275,
17392,
272,
291,
14,
1802,
275,
1369,
272,
291,
14,
4246,
63,
962,
275,
5023,
63,
962,
421,
199,
318,
1475,
63,
3128,
8,
3128,
12,
2116,
2345,
63,
1302,
12,
2116,
2387,
63,
2343,
29,
797,
12,
2116,
980,
63,
1361,
1419,
29,
403,
12,
2116,
11850,
63,
1419,
29,
403,
304,
523,
408,
6864,
282,
820,
16445,
9863,
909,
21207,
282,
2345,
315,
7871,
3449,
14,
819,
3033,
26,
272,
2345,
26,
710,
2345,
370,
506,
9080,
12,
465,
282,
2680,
6800,
503,
1163,
489,
5827,
1475,
334,
69,
14,
71,
2020,
488,
6144,
625,
12486,
10519,
680,
272,
2345,
63,
1302,
26,
437,
1768,
367,
314,
2345,
12,
465,
282,
1059,
14,
982,
663,
370,
488,
12,
911,
489,
15678,
314,
2345,
536,
1004,
315,
314,
372,
574,
14,
272,
2387,
63,
2343,
26,
7480,
3341,
4066,
465,
2152,
436,
2215,
787,
370,
506,
489,
5120,
315,
314,
7871,
1318,
14,
272,
980,
63,
1361,
1419,
26,
437,
2600,
402,
4252,
2368,
626,
787,
3032,
370,
282,
489,
1240,
402,
980,
14,
409,
63,
1361,
1419,
342,
370,
663,
314,
1318,
1475,
367,
2929,
2680,
489,
302,
4460,
4814,
14,
272,
11850,
63,
1419,
26,
334,
11688,
4040,
4558,
9,
1511,
367,
22437,
4008,
489,
402,
314,
2345,
14,
819,
1803,
26,
272,
437,
820,
16445,
9863,
909,
14,
22940,
11262,
901,
965,
1004,
13,
991,
13,
604,
9189,
83,
370,
272,
6623,
1314,
4918,
315,
314,
1625,
314,
1642,
1819,
402,
1924,
1004,
272,
13718,
370,
14,
523,
408,
523,
2385,
275,
942,
523,
5023,
63,
962,
63,
23712,
275,
1052,
819,
340,
2345,
63,
1302,
365,
440,
488,
26,
272,
2385,
14,
740,
480,
3861,
18321,
83,
60,
5122,
450,
2345,
63,
1302,
9,
272,
4739,
275,
2345,
63,
1302,
14,
1294,
20063,
1988,
17,
61,
272,
340,
4739,
14,
13896,
837,
489,
327,
428,
2875,
365,
282,
1329,
14,
16269,
652,
365,
314,
1072,
9348,
1478,
14,
489,
5023,
63,
962,
63,
23712,
59,
16,
61,
275,
3842,
24,
12,
1695,
435,
822,
8,
3128,
63,
1302,
395,
298,
9771,
11323,
272,
587,
26,
489,
327,
428,
2875,
365,
440,
282,
1329,
14,
2779,
365,
31407,
2556,
4066,
465,
314,
3105,
489,
327,
1687,
730,
14,
1010,
642,
1930,
12,
11850,
314,
4739,
543,
282,
3365,
3164,
14,
489,
3105,
63,
411,
63,
552,
275,
822,
8,
4511,
9,
489,
5576,
63,
552,
275,
822,
8,
3128,
63,
1302,
9,
446,
3105,
63,
411,
63,
552,
446,
413,
489,
5023,
63,
962,
63,
23712,
59,
16,
61,
275,
359,
881,
334,
24,
12,
1695,
435,
5576,
63,
552,
12,
298,
9771,
1288,
881,
334,
24,
435,
5576,
63,
552,
435,
413,
12,
1695,
435,
5576,
63,
552,
435,
413,
435,
3105,
63
] |
[
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
3484,
10519,
334,
977,
10095,
9,
367,
6426,
2929,
436,
19191,
1041,
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,
1331,
199,
646,
295,
199,
199,
646,
2680,
465,
980,
199,
504,
3816,
14,
4912,
492,
4945,
221,
327,
4287,
26,
3507,
29,
27913,
13,
5351,
199,
199,
504,
3228,
14,
1548,
14,
1757,
14,
2764,
492,
14958,
63,
2764,
63,
2330,
199,
504,
3228,
14,
1548,
14,
1757,
14,
773,
492,
3105,
63,
576,
199,
199,
63,
1440,
1658,
57,
63,
7474,
20291,
275,
298,
1396,
4589,
199,
63,
1440,
1658,
57,
63,
3472,
63,
1149,
4962,
63,
10439,
51,
275,
650,
199,
199,
63,
9190,
63,
10710,
275,
295,
14,
2014,
8,
82,
2,
27371,
11843,
779,
16,
13,
25,
1527,
6793,
16,
13,
25,
20565,
4537,
2807,
92,
4304,
92,
4904,
10127,
83,
18712,
6113,
566,
531,
199,
199,
15947,
63,
3192,
7040,
63,
3078,
275,
298,
73,
16,
2,
199,
7474,
20779,
1149,
63,
3192,
7040,
63,
3078,
275,
298,
19007,
471,
2,
199,
199,
3472,
63,
52,
17850,
63,
12535,
63,
17624,
21613,
63,
18398,
63,
5280,
275,
298,
9771,
2,
421,
199,
533,
16332,
4040,
4558,
8,
785,
304,
523,
408,
4558,
367,
22437,
4008,
402,
282,
2345,
1041,
819,
347,
636,
826,
721,
277,
12,
2049,
17392,
12,
2049,
1369,
29,
403,
12,
2049,
5023,
63,
962,
29,
3472,
63,
52,
17850,
63,
12535,
63,
17624,
21613,
63,
18398,
63,
5280,
304,
272,
408,
11447,
402,
16332,
4040,
4558,
14,
339,
3033,
26,
489,
17392,
26,
334,
8296,
9,
437,
4550,
402,
314,
2569,
4955,
26,
267,
347,
370,
63,
14337,
8,
56,
304,
881,
327,
3033,
26,
881,
327,
257,
1323,
26,
710,
2345,
370,
11850,
4008,
315,
14,
881,
327,
881,
327,
1803,
26,
881,
327,
257,
334,
4871,
6800,
9,
437,
5046,
6800,
402,
314,
2011,
2215,
465,
1323,
881,
327,
257,
9297,
1314,
4008,
787,
370,
506,
4721,
27883,
334,
15126,
715,
680,
267,
961,
4550,
911,
506,
1202,
465,
314,
1423,
402,
980,
14,
1273,
4509,
342,
370,
267,
6705,
1314,
4008,
402,
314,
2345,
787,
370,
506,
4721,
27883,
14,
489,
1369,
26,
334,
495,
9,
11994,
402,
314,
11850,
17392,
18564,
656,
328,
379,
701,
267,
17392,
14,
489,
5023,
63,
962,
26,
334,
495,
9,
26159,
2225,
370,
506,
6781,
370,
314,
267,
4721,
27883,
4008,
14,
339,
408,
339,
291,
14,
21418,
275,
17392,
272,
291,
14,
1802,
275,
1369,
272,
291,
14,
4246,
63,
962,
275,
5023,
63,
962,
421,
199,
318,
1475,
63,
3128,
8,
3128,
12,
2116,
2345,
63,
1302,
12,
2116,
2387,
63,
2343,
29,
797,
12,
2116,
980,
63,
1361,
1419,
29,
403,
12,
2116,
11850,
63,
1419,
29,
403,
304,
523,
408,
6864,
282,
820,
16445,
9863,
909,
21207,
282,
2345,
315,
7871,
3449,
14,
819,
3033,
26,
272,
2345,
26,
710,
2345,
370,
506,
9080,
12,
465,
282,
2680,
6800,
503,
1163,
489,
5827,
1475,
334,
69,
14,
71,
2020,
488,
6144,
625,
12486,
10519,
680,
272,
2345,
63,
1302,
26,
437,
1768,
367,
314,
2345,
12,
465,
282,
1059,
14,
982,
663,
370,
488,
12,
911,
489,
15678,
314,
2345,
536,
1004,
315,
314,
372,
574,
14,
272,
2387,
63,
2343,
26,
7480,
3341,
4066,
465,
2152,
436,
2215,
787,
370,
506,
489,
5120,
315,
314,
7871,
1318,
14,
272,
980,
63,
1361,
1419,
26,
437,
2600,
402,
4252,
2368,
626,
787,
3032,
370,
282,
489,
1240,
402,
980,
14,
409,
63,
1361,
1419,
342,
370,
663,
314,
1318,
1475,
367,
2929,
2680,
489,
302,
4460,
4814,
14,
272,
11850,
63,
1419,
26,
334,
11688,
4040,
4558,
9,
1511,
367,
22437,
4008,
489,
402,
314,
2345,
14,
819,
1803,
26,
272,
437,
820,
16445,
9863,
909,
14,
22940,
11262,
901,
965,
1004,
13,
991,
13,
604,
9189,
83,
370,
272,
6623,
1314,
4918,
315,
314,
1625,
314,
1642,
1819,
402,
1924,
1004,
272,
13718,
370,
14,
523,
408,
523,
2385,
275,
942,
523,
5023,
63,
962,
63,
23712,
275,
1052,
819,
340,
2345,
63,
1302,
365,
440,
488,
26,
272,
2385,
14,
740,
480,
3861,
18321,
83,
60,
5122,
450,
2345,
63,
1302,
9,
272,
4739,
275,
2345,
63,
1302,
14,
1294,
20063,
1988,
17,
61,
272,
340,
4739,
14,
13896,
837,
489,
327,
428,
2875,
365,
282,
1329,
14,
16269,
652,
365,
314,
1072,
9348,
1478,
14,
489,
5023,
63,
962,
63,
23712,
59,
16,
61,
275,
3842,
24,
12,
1695,
435,
822,
8,
3128,
63,
1302,
395,
298,
9771,
11323,
272,
587,
26,
489,
327,
428,
2875,
365,
440,
282,
1329,
14,
2779,
365,
31407,
2556,
4066,
465,
314,
3105,
489,
327,
1687,
730,
14,
1010,
642,
1930,
12,
11850,
314,
4739,
543,
282,
3365,
3164,
14,
489,
3105,
63,
411,
63,
552,
275,
822,
8,
4511,
9,
489,
5576,
63,
552,
275,
822,
8,
3128,
63,
1302,
9,
446,
3105,
63,
411,
63,
552,
446,
413,
489,
5023,
63,
962,
63,
23712,
59,
16,
61,
275,
359,
881,
334,
24,
12,
1695,
435,
5576,
63,
552,
12,
298,
9771,
1288,
881,
334,
24,
435,
5576,
63,
552,
435,
413,
12,
1695,
435,
5576,
63,
552,
435,
413,
435,
3105,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
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2spr-stock-galaxy-rush
|
tools/perf/scripts/python/sched-migration.py
|
11215
|
11670
|
#!/usr/bin/python
#
# Cpu task migration overview toy
#
# Copyright (C) 2010 Frederic Weisbecker <fweisbec@gmail.com>
#
# perf script event handlers have been generated by perf script -g python
#
# This software is distributed under the terms of the GNU General
# Public License ("GPL") version 2 as published by the Free Software
# Foundation.
import os
import sys
from collections import defaultdict
from UserList import UserList
sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
sys.path.append('scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import *
from Core import *
from SchedGui import *
threads = { 0 : "idle"}
def thread_name(pid):
return "%s:%d" % (threads[pid], pid)
class RunqueueEventUnknown:
@staticmethod
def color():
return None
def __repr__(self):
return "unknown"
class RunqueueEventSleep:
@staticmethod
def color():
return (0, 0, 0xff)
def __init__(self, sleeper):
self.sleeper = sleeper
def __repr__(self):
return "%s gone to sleep" % thread_name(self.sleeper)
class RunqueueEventWakeup:
@staticmethod
def color():
return (0xff, 0xff, 0)
def __init__(self, wakee):
self.wakee = wakee
def __repr__(self):
return "%s woke up" % thread_name(self.wakee)
class RunqueueEventFork:
@staticmethod
def color():
return (0, 0xff, 0)
def __init__(self, child):
self.child = child
def __repr__(self):
return "new forked task %s" % thread_name(self.child)
class RunqueueMigrateIn:
@staticmethod
def color():
return (0, 0xf0, 0xff)
def __init__(self, new):
self.new = new
def __repr__(self):
return "task migrated in %s" % thread_name(self.new)
class RunqueueMigrateOut:
@staticmethod
def color():
return (0xff, 0, 0xff)
def __init__(self, old):
self.old = old
def __repr__(self):
return "task migrated out %s" % thread_name(self.old)
class RunqueueSnapshot:
def __init__(self, tasks = [0], event = RunqueueEventUnknown()):
self.tasks = tuple(tasks)
self.event = event
def sched_switch(self, prev, prev_state, next):
event = RunqueueEventUnknown()
if taskState(prev_state) == "R" and next in self.tasks \
and prev in self.tasks:
return self
if taskState(prev_state) != "R":
event = RunqueueEventSleep(prev)
next_tasks = list(self.tasks[:])
if prev in self.tasks:
if taskState(prev_state) != "R":
next_tasks.remove(prev)
elif taskState(prev_state) == "R":
next_tasks.append(prev)
if next not in next_tasks:
next_tasks.append(next)
return RunqueueSnapshot(next_tasks, event)
def migrate_out(self, old):
if old not in self.tasks:
return self
next_tasks = [task for task in self.tasks if task != old]
return RunqueueSnapshot(next_tasks, RunqueueMigrateOut(old))
def __migrate_in(self, new, event):
if new in self.tasks:
self.event = event
return self
next_tasks = self.tasks[:] + tuple([new])
return RunqueueSnapshot(next_tasks, event)
def migrate_in(self, new):
return self.__migrate_in(new, RunqueueMigrateIn(new))
def wake_up(self, new):
return self.__migrate_in(new, RunqueueEventWakeup(new))
def wake_up_new(self, new):
return self.__migrate_in(new, RunqueueEventFork(new))
def load(self):
""" Provide the number of tasks on the runqueue.
Don't count idle"""
return len(self.tasks) - 1
def __repr__(self):
ret = self.tasks.__repr__()
ret += self.origin_tostring()
return ret
class TimeSlice:
def __init__(self, start, prev):
self.start = start
self.prev = prev
self.end = start
# cpus that triggered the event
self.event_cpus = []
if prev is not None:
self.total_load = prev.total_load
self.rqs = prev.rqs.copy()
else:
self.rqs = defaultdict(RunqueueSnapshot)
self.total_load = 0
def __update_total_load(self, old_rq, new_rq):
diff = new_rq.load() - old_rq.load()
self.total_load += diff
def sched_switch(self, ts_list, prev, prev_state, next, cpu):
old_rq = self.prev.rqs[cpu]
new_rq = old_rq.sched_switch(prev, prev_state, next)
if old_rq is new_rq:
return
self.rqs[cpu] = new_rq
self.__update_total_load(old_rq, new_rq)
ts_list.append(self)
self.event_cpus = [cpu]
def migrate(self, ts_list, new, old_cpu, new_cpu):
if old_cpu == new_cpu:
return
old_rq = self.prev.rqs[old_cpu]
out_rq = old_rq.migrate_out(new)
self.rqs[old_cpu] = out_rq
self.__update_total_load(old_rq, out_rq)
new_rq = self.prev.rqs[new_cpu]
in_rq = new_rq.migrate_in(new)
self.rqs[new_cpu] = in_rq
self.__update_total_load(new_rq, in_rq)
ts_list.append(self)
if old_rq is not out_rq:
self.event_cpus.append(old_cpu)
self.event_cpus.append(new_cpu)
def wake_up(self, ts_list, pid, cpu, fork):
old_rq = self.prev.rqs[cpu]
if fork:
new_rq = old_rq.wake_up_new(pid)
else:
new_rq = old_rq.wake_up(pid)
if new_rq is old_rq:
return
self.rqs[cpu] = new_rq
self.__update_total_load(old_rq, new_rq)
ts_list.append(self)
self.event_cpus = [cpu]
def next(self, t):
self.end = t
return TimeSlice(t, self)
class TimeSliceList(UserList):
def __init__(self, arg = []):
self.data = arg
def get_time_slice(self, ts):
if len(self.data) == 0:
slice = TimeSlice(ts, TimeSlice(-1, None))
else:
slice = self.data[-1].next(ts)
return slice
def find_time_slice(self, ts):
start = 0
end = len(self.data)
found = -1
searching = True
while searching:
if start == end or start == end - 1:
searching = False
i = (end + start) / 2
if self.data[i].start <= ts and self.data[i].end >= ts:
found = i
end = i
continue
if self.data[i].end < ts:
start = i
elif self.data[i].start > ts:
end = i
return found
def set_root_win(self, win):
self.root_win = win
def mouse_down(self, cpu, t):
idx = self.find_time_slice(t)
if idx == -1:
return
ts = self[idx]
rq = ts.rqs[cpu]
raw = "CPU: %d\n" % cpu
raw += "Last event : %s\n" % rq.event.__repr__()
raw += "Timestamp : %d.%06d\n" % (ts.start / (10 ** 9), (ts.start % (10 ** 9)) / 1000)
raw += "Duration : %6d us\n" % ((ts.end - ts.start) / (10 ** 6))
raw += "Load = %d\n" % rq.load()
for t in rq.tasks:
raw += "%s \n" % thread_name(t)
self.root_win.update_summary(raw)
def update_rectangle_cpu(self, slice, cpu):
rq = slice.rqs[cpu]
if slice.total_load != 0:
load_rate = rq.load() / float(slice.total_load)
else:
load_rate = 0
red_power = int(0xff - (0xff * load_rate))
color = (0xff, red_power, red_power)
top_color = None
if cpu in slice.event_cpus:
top_color = rq.event.color()
self.root_win.paint_rectangle_zone(cpu, color, top_color, slice.start, slice.end)
def fill_zone(self, start, end):
i = self.find_time_slice(start)
if i == -1:
return
for i in xrange(i, len(self.data)):
timeslice = self.data[i]
if timeslice.start > end:
return
for cpu in timeslice.rqs:
self.update_rectangle_cpu(timeslice, cpu)
def interval(self):
if len(self.data) == 0:
return (0, 0)
return (self.data[0].start, self.data[-1].end)
def nr_rectangles(self):
last_ts = self.data[-1]
max_cpu = 0
for cpu in last_ts.rqs:
if cpu > max_cpu:
max_cpu = cpu
return max_cpu
class SchedEventProxy:
def __init__(self):
self.current_tsk = defaultdict(lambda : -1)
self.timeslices = TimeSliceList()
def sched_switch(self, headers, prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio):
""" Ensure the task we sched out this cpu is really the one
we logged. Otherwise we may have missed traces """
on_cpu_task = self.current_tsk[headers.cpu]
if on_cpu_task != -1 and on_cpu_task != prev_pid:
print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \
(headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid)
threads[prev_pid] = prev_comm
threads[next_pid] = next_comm
self.current_tsk[headers.cpu] = next_pid
ts = self.timeslices.get_time_slice(headers.ts())
ts.sched_switch(self.timeslices, prev_pid, prev_state, next_pid, headers.cpu)
def migrate(self, headers, pid, prio, orig_cpu, dest_cpu):
ts = self.timeslices.get_time_slice(headers.ts())
ts.migrate(self.timeslices, pid, orig_cpu, dest_cpu)
def wake_up(self, headers, comm, pid, success, target_cpu, fork):
if success == 0:
return
ts = self.timeslices.get_time_slice(headers.ts())
ts.wake_up(self.timeslices, pid, target_cpu, fork)
def trace_begin():
global parser
parser = SchedEventProxy()
def trace_end():
app = wx.App(False)
timeslices = parser.timeslices
frame = RootFrame(timeslices, "Migration")
app.MainLoop()
def sched__sched_stat_runtime(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, runtime, vruntime):
pass
def sched__sched_stat_iowait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, delay):
pass
def sched__sched_stat_sleep(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, delay):
pass
def sched__sched_stat_wait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, delay):
pass
def sched__sched_process_fork(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
parent_comm, parent_pid, child_comm, child_pid):
pass
def sched__sched_process_wait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio):
pass
def sched__sched_process_exit(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio):
pass
def sched__sched_process_free(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio):
pass
def sched__sched_migrate_task(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio, orig_cpu,
dest_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
parser.migrate(headers, pid, prio, orig_cpu, dest_cpu)
def sched__sched_switch(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
parser.sched_switch(headers, prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio)
def sched__sched_wakeup_new(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio, success,
target_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
parser.wake_up(headers, comm, pid, success, target_cpu, 1)
def sched__sched_wakeup(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio, success,
target_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
parser.wake_up(headers, comm, pid, success, target_cpu, 0)
def sched__sched_wait_task(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid, prio):
pass
def sched__sched_kthread_stop_ret(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
ret):
pass
def sched__sched_kthread_stop(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
comm, pid):
pass
def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs,
common_pid, common_comm):
pass
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
445,
3165,
2120,
8367,
23503,
31239,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
8582,
2884,
1566,
8297,
1172,
2757,
4046,
701,
8582,
2884,
446,
71,
2366,
199,
3,
199,
3,
961,
2032,
365,
1854,
1334,
314,
2895,
402,
314,
1664,
1696,
199,
3,
1684,
844,
1689,
12006,
531,
1015,
499,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
14,
421,
199,
646,
747,
199,
646,
984,
199,
199,
504,
5055,
492,
10018,
199,
504,
28639,
492,
28639,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
199,
198,
9807,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
1274,
14,
515,
14,
740,
360,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
11672,
492,
627,
199,
504,
428,
1809,
4324,
492,
627,
421,
199,
6962,
275,
469,
378,
520,
298,
12000,
3570,
199,
199,
318,
2462,
63,
354,
8,
3150,
304,
199,
198,
1107,
2071,
83,
2689,
68,
2,
450,
334,
6962,
59,
3150,
467,
4422,
9,
199,
199,
533,
25406,
5912,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
488,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
5187,
2,
199,
199,
533,
25406,
17306,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
26220,
15033,
304,
507,
198,
277,
14,
23042,
15033,
275,
26220,
15033,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
21737,
370,
9435,
2,
450,
2462,
63,
354,
8,
277,
14,
23042,
15033,
9,
199,
199,
533,
25406,
23424,
384,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
21560,
69,
304,
507,
198,
277,
14,
15181,
69,
275,
21560,
69,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
336,
79,
415,
1536,
2,
450,
2462,
63,
354,
8,
277,
14,
15181,
69,
9,
199,
199,
533,
25406,
1858,
75,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
1982,
304,
507,
198,
277,
14,
1739,
275,
1982,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1222,
14926,
379,
2120,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1739,
9,
199,
199,
533,
17664,
26641,
607,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
1949,
16,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
892,
304,
507,
198,
277,
14,
1222,
275,
892,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
315,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1222,
9,
199,
199,
533,
17664,
26641,
2204,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
2269,
304,
507,
198,
277,
14,
1753,
275,
2269,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
734,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1753,
9,
199,
199,
533,
17664,
12038,
26,
199,
198,
318,
636,
826,
721,
277,
12,
6527,
275,
359,
16,
467,
1566,
275,
25406,
5912,
5109,
507,
198,
277,
14,
5054,
275,
2008,
8,
5054,
9,
507,
198,
277,
14,
1430,
275,
1566,
421,
198,
318,
10286,
63,
5656,
8,
277,
12,
5071,
12,
5071,
63,
929,
12,
2163,
304,
507,
198,
1430,
275,
25406,
5912,
342,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
2,
436,
2163,
315,
291,
14,
5054,
971,
686,
198,
460,
5071,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
686,
198,
1430,
275,
25406,
17306,
8,
5701,
9,
2742,
198,
2184,
63,
5054,
275,
769,
8,
277,
14,
5054,
1491,
566,
507,
198,
692,
5071,
315,
291,
14,
5054,
26,
686,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
1585,
198,
2184,
63,
5054,
14,
2168,
8,
5701,
9,
507,
198,
4164,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
582,
686,
198,
2184,
63,
5054,
14,
740,
8,
5701,
9,
2742,
198,
692,
2163,
440,
315,
2163,
63,
5054,
26,
686,
198,
2184,
63,
5054,
14,
740,
8,
2184,
9,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
548,
8,
277,
12,
2269,
304,
507,
198,
692,
2269,
440,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
359,
1765,
367,
2120,
315,
291,
14,
5054,
340,
2120,
1137,
2269,
61,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
17664,
26641,
2204,
8,
1753,
430,
421,
198,
318,
636,
8462,
63,
262,
8,
277,
12,
892,
12,
1566,
304,
507,
198,
692,
892,
315,
291,
14,
5054,
26,
686,
198,
277,
14,
1430,
275,
1566,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
291,
14,
5054,
5873,
435,
2008,
779,
1222,
566,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
262,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
17664,
26641,
607,
8,
1222,
430,
421,
198,
318,
21560,
63,
384,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
445,
3165,
2120,
8367,
23503,
31239,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
8582,
2884,
1566,
8297,
1172,
2757,
4046,
701,
8582,
2884,
446,
71,
2366,
199,
3,
199,
3,
961,
2032,
365,
1854,
1334,
314,
2895,
402,
314,
1664,
1696,
199,
3,
1684,
844,
1689,
12006,
531,
1015,
499,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
14,
421,
199,
646,
747,
199,
646,
984,
199,
199,
504,
5055,
492,
10018,
199,
504,
28639,
492,
28639,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
199,
198,
9807,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
1274,
14,
515,
14,
740,
360,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
11672,
492,
627,
199,
504,
428,
1809,
4324,
492,
627,
421,
199,
6962,
275,
469,
378,
520,
298,
12000,
3570,
199,
199,
318,
2462,
63,
354,
8,
3150,
304,
199,
198,
1107,
2071,
83,
2689,
68,
2,
450,
334,
6962,
59,
3150,
467,
4422,
9,
199,
199,
533,
25406,
5912,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
488,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
5187,
2,
199,
199,
533,
25406,
17306,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
26220,
15033,
304,
507,
198,
277,
14,
23042,
15033,
275,
26220,
15033,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
21737,
370,
9435,
2,
450,
2462,
63,
354,
8,
277,
14,
23042,
15033,
9,
199,
199,
533,
25406,
23424,
384,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
21560,
69,
304,
507,
198,
277,
14,
15181,
69,
275,
21560,
69,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
336,
79,
415,
1536,
2,
450,
2462,
63,
354,
8,
277,
14,
15181,
69,
9,
199,
199,
533,
25406,
1858,
75,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
1982,
304,
507,
198,
277,
14,
1739,
275,
1982,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1222,
14926,
379,
2120,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1739,
9,
199,
199,
533,
17664,
26641,
607,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
1949,
16,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
892,
304,
507,
198,
277,
14,
1222,
275,
892,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
315,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1222,
9,
199,
199,
533,
17664,
26641,
2204,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
2269,
304,
507,
198,
277,
14,
1753,
275,
2269,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
734,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1753,
9,
199,
199,
533,
17664,
12038,
26,
199,
198,
318,
636,
826,
721,
277,
12,
6527,
275,
359,
16,
467,
1566,
275,
25406,
5912,
5109,
507,
198,
277,
14,
5054,
275,
2008,
8,
5054,
9,
507,
198,
277,
14,
1430,
275,
1566,
421,
198,
318,
10286,
63,
5656,
8,
277,
12,
5071,
12,
5071,
63,
929,
12,
2163,
304,
507,
198,
1430,
275,
25406,
5912,
342,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
2,
436,
2163,
315,
291,
14,
5054,
971,
686,
198,
460,
5071,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
686,
198,
1430,
275,
25406,
17306,
8,
5701,
9,
2742,
198,
2184,
63,
5054,
275,
769,
8,
277,
14,
5054,
1491,
566,
507,
198,
692,
5071,
315,
291,
14,
5054,
26,
686,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
1585,
198,
2184,
63,
5054,
14,
2168,
8,
5701,
9,
507,
198,
4164,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
582,
686,
198,
2184,
63,
5054,
14,
740,
8,
5701,
9,
2742,
198,
692,
2163,
440,
315,
2163,
63,
5054,
26,
686,
198,
2184,
63,
5054,
14,
740,
8,
2184,
9,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
548,
8,
277,
12,
2269,
304,
507,
198,
692,
2269,
440,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
359,
1765,
367,
2120,
315,
291,
14,
5054,
340,
2120,
1137,
2269,
61,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
17664,
26641,
2204,
8,
1753,
430,
421,
198,
318,
636,
8462,
63,
262,
8,
277,
12,
892,
12,
1566,
304,
507,
198,
692,
892,
315,
291,
14,
5054,
26,
686,
198,
277,
14,
1430,
275,
1566,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
291,
14,
5054,
5873,
435,
2008,
779,
1222,
566,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
262,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
17664,
26641,
607,
8,
1222,
430,
421,
198,
318,
21560,
63,
384,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
asser/django
|
django/contrib/gis/gdal/layer.py
|
477
|
8693
|
from ctypes import byref, c_double
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope
from django.contrib.gis.gdal.error import (
GDALException, OGRIndexError, SRSException,
)
from django.contrib.gis.gdal.feature import Feature
from django.contrib.gis.gdal.field import OGRFieldTypes
from django.contrib.gis.gdal.geometries import OGRGeometry
from django.contrib.gis.gdal.geomtype import OGRGeomType
from django.contrib.gis.gdal.prototypes import (
ds as capi, geom as geom_api, srs as srs_api,
)
from django.contrib.gis.gdal.srs import SpatialReference
from django.utils import six
from django.utils.encoding import force_bytes, force_text
from django.utils.six.moves import range
# For more information, see the OGR C API source code:
# http://www.gdal.org/ogr/ogr__api_8h.html
#
# The OGR_L_* routines are relevant here.
class Layer(GDALBase):
"A class that wraps an OGR Layer, needs to be instantiated from a DataSource object."
def __init__(self, layer_ptr, ds):
"""
Initializes on an OGR C pointer to the Layer and the `DataSource` object
that owns this layer. The `DataSource` object is required so that a
reference to it is kept with this Layer. This prevents garbage
collection of the `DataSource` while this Layer is still active.
"""
if not layer_ptr:
raise GDALException('Cannot create Layer, invalid pointer given')
self.ptr = layer_ptr
self._ds = ds
self._ldefn = capi.get_layer_defn(self._ptr)
# Does the Layer support random reading?
self._random_read = self.test_capability(b'RandomRead')
def __getitem__(self, index):
"Gets the Feature at the specified index."
if isinstance(index, six.integer_types):
# An integer index was given -- we cannot do a check based on the
# number of features because the beginning and ending feature IDs
# are not guaranteed to be 0 and len(layer)-1, respectively.
if index < 0:
raise OGRIndexError('Negative indices are not allowed on OGR Layers.')
return self._make_feature(index)
elif isinstance(index, slice):
# A slice was given
start, stop, stride = index.indices(self.num_feat)
return [self._make_feature(fid) for fid in range(start, stop, stride)]
else:
raise TypeError('Integers and slices may only be used when indexing OGR Layers.')
def __iter__(self):
"Iterates over each Feature in the Layer."
# ResetReading() must be called before iteration is to begin.
capi.reset_reading(self._ptr)
for i in range(self.num_feat):
yield Feature(capi.get_next_feature(self._ptr), self)
def __len__(self):
"The length is the number of features."
return self.num_feat
def __str__(self):
"The string name of the layer."
return self.name
def _make_feature(self, feat_id):
"""
Helper routine for __getitem__ that constructs a Feature from the given
Feature ID. If the OGR Layer does not support random-access reading,
then each feature of the layer will be incremented through until the
a Feature is found matching the given feature ID.
"""
if self._random_read:
# If the Layer supports random reading, return.
try:
return Feature(capi.get_feature(self.ptr, feat_id), self)
except GDALException:
pass
else:
# Random access isn't supported, have to increment through
# each feature until the given feature ID is encountered.
for feat in self:
if feat.fid == feat_id:
return feat
# Should have returned a Feature, raise an OGRIndexError.
raise OGRIndexError('Invalid feature id: %s.' % feat_id)
# #### Layer properties ####
@property
def extent(self):
"Returns the extent (an Envelope) of this layer."
env = OGREnvelope()
capi.get_extent(self.ptr, byref(env), 1)
return Envelope(env)
@property
def name(self):
"Returns the name of this layer in the Data Source."
name = capi.get_fd_name(self._ldefn)
return force_text(name, self._ds.encoding, strings_only=True)
@property
def num_feat(self, force=1):
"Returns the number of features in the Layer."
return capi.get_feature_count(self.ptr, force)
@property
def num_fields(self):
"Returns the number of fields in the Layer."
return capi.get_field_count(self._ldefn)
@property
def geom_type(self):
"Returns the geometry type (OGRGeomType) of the Layer."
return OGRGeomType(capi.get_fd_geom_type(self._ldefn))
@property
def srs(self):
"Returns the Spatial Reference used in this Layer."
try:
ptr = capi.get_layer_srs(self.ptr)
return SpatialReference(srs_api.clone_srs(ptr))
except SRSException:
return None
@property
def fields(self):
"""
Returns a list of string names corresponding to each of the Fields
available in this Layer.
"""
return [force_text(capi.get_field_name(capi.get_field_defn(self._ldefn, i)),
self._ds.encoding, strings_only=True)
for i in range(self.num_fields)]
@property
def field_types(self):
"""
Returns a list of the types of fields in this Layer. For example,
the list [OFTInteger, OFTReal, OFTString] would be returned for
an OGR layer that had an integer, a floating-point, and string
fields.
"""
return [OGRFieldTypes[capi.get_field_type(capi.get_field_defn(self._ldefn, i))]
for i in range(self.num_fields)]
@property
def field_widths(self):
"Returns a list of the maximum field widths for the features."
return [capi.get_field_width(capi.get_field_defn(self._ldefn, i))
for i in range(self.num_fields)]
@property
def field_precisions(self):
"Returns the field precisions for the features."
return [capi.get_field_precision(capi.get_field_defn(self._ldefn, i))
for i in range(self.num_fields)]
def _get_spatial_filter(self):
try:
return OGRGeometry(geom_api.clone_geom(capi.get_spatial_filter(self.ptr)))
except GDALException:
return None
def _set_spatial_filter(self, filter):
if isinstance(filter, OGRGeometry):
capi.set_spatial_filter(self.ptr, filter.ptr)
elif isinstance(filter, (tuple, list)):
if not len(filter) == 4:
raise ValueError('Spatial filter list/tuple must have 4 elements.')
# Map c_double onto params -- if a bad type is passed in it
# will be caught here.
xmin, ymin, xmax, ymax = map(c_double, filter)
capi.set_spatial_filter_rect(self.ptr, xmin, ymin, xmax, ymax)
elif filter is None:
capi.set_spatial_filter(self.ptr, None)
else:
raise TypeError('Spatial filter must be either an OGRGeometry instance, a 4-tuple, or None.')
spatial_filter = property(_get_spatial_filter, _set_spatial_filter)
# #### Layer Methods ####
def get_fields(self, field_name):
"""
Returns a list containing the given field name for every Feature
in the Layer.
"""
if field_name not in self.fields:
raise GDALException('invalid field name: %s' % field_name)
return [feat.get(field_name) for feat in self]
def get_geoms(self, geos=False):
"""
Returns a list containing the OGRGeometry for every Feature in
the Layer.
"""
if geos:
from django.contrib.gis.geos import GEOSGeometry
return [GEOSGeometry(feat.geom.wkb) for feat in self]
else:
return [feat.geom for feat in self]
def test_capability(self, capability):
"""
Returns a bool indicating whether the this Layer supports the given
capability (a string). Valid capability strings include:
'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter',
'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions',
'DeleteFeature', and 'FastSetNextByIndex'.
"""
return bool(capi.test_capability(self.ptr, force_bytes(capability)))
|
bsd-3-clause
|
[
504,
5577,
492,
15968,
12,
286,
63,
3157,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1095,
492,
15801,
1563,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
19707,
492,
29143,
12,
19746,
907,
78,
10658,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
705,
492,
334,
272,
15801,
1726,
12,
10904,
12129,
12,
12765,
21686,
12,
199,
9,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
4445,
492,
13407,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
698,
492,
10904,
792,
4100,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
21626,
492,
24220,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
6481,
466,
492,
25756,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
16141,
83,
492,
334,
272,
6364,
465,
13648,
12,
9671,
465,
9671,
63,
1246,
12,
16191,
465,
16191,
63,
1246,
12,
199,
9,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
12722,
492,
24324,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
12,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
421,
199,
3,
2104,
1655,
2556,
12,
1937,
314,
10904,
445,
3261,
1350,
1233,
26,
199,
3,
221,
1455,
921,
1544,
14,
11600,
14,
1308,
15,
14945,
15,
14945,
363,
1246,
63,
24,
72,
14,
1360,
199,
3,
199,
3,
710,
10904,
63,
44,
15192,
14975,
787,
12082,
2348,
14,
199,
533,
11915,
8,
17835,
1563,
304,
272,
298,
33,
1021,
626,
14018,
376,
10904,
11915,
12,
4839,
370,
506,
17544,
687,
282,
24300,
909,
2122,
339,
347,
636,
826,
721,
277,
12,
4045,
63,
4695,
12,
6364,
304,
267,
408,
267,
6026,
6491,
641,
376,
10904,
445,
7849,
370,
314,
11915,
436,
314,
658,
16693,
64,
909,
267,
626,
22182,
561,
642,
4045,
14,
221,
710,
658,
16693,
64,
909,
365,
1415,
880,
626,
282,
267,
3659,
370,
652,
365,
16204,
543,
642,
11915,
14,
221,
961,
21925,
17516,
267,
3245,
402,
314,
658,
16693,
64,
1830,
642,
11915,
365,
5139,
4702,
14,
267,
408,
267,
340,
440,
4045,
63,
4695,
26,
288,
746,
15801,
1726,
360,
6612,
1218,
11915,
12,
3866,
7849,
1627,
358,
267,
291,
14,
4695,
275,
4045,
63,
4695,
267,
291,
423,
795,
275,
6364,
267,
291,
423,
76,
27950,
275,
13648,
14,
362,
63,
1897,
63,
27950,
8,
277,
423,
4695,
9,
267,
327,
12078,
314,
11915,
2291,
2196,
7664,
31,
267,
291,
423,
2355,
63,
739,
275,
291,
14,
396,
63,
21181,
8,
66,
7,
3883,
3284,
358,
339,
347,
636,
6095,
721,
277,
12,
1478,
304,
267,
298,
14426,
314,
13407,
737,
314,
2013,
1478,
2122,
267,
340,
1228,
8,
1080,
12,
3816,
14,
4115,
63,
1313,
304,
288,
327,
1626,
3000,
1478,
1990,
1627,
1553,
781,
3913,
886,
282,
1104,
4079,
641,
314,
288,
327,
1329,
402,
4534,
2952,
314,
9608,
436,
13401,
3878,
11449,
288,
327,
787,
440,
17334,
370,
506,
378,
436,
822,
8,
1897,
7216,
17,
12,
17342,
14,
288,
340,
1478,
665,
378,
26,
355,
746,
10904,
12129,
360,
15562,
4918,
787,
440,
4370,
641,
10904,
9366,
1192,
2659,
288,
372,
291,
423,
1875,
63,
4445,
8,
1080,
9,
267,
916,
1228,
8,
1080,
12,
6014,
304,
288,
327,
437,
6014,
1990,
1627,
288,
1343,
12,
3631,
12,
7345,
275,
1478,
14,
4108,
8,
277,
14,
1507,
63,
11873,
9,
288,
372,
359,
277,
423,
1875,
63,
4445,
8,
9430,
9,
367,
8289,
315,
1425,
8,
928,
12,
3631,
12,
7345,
1874,
267,
587,
26,
288,
746,
3146,
360,
2674,
83,
436,
17184,
1443,
1454,
506,
1202,
1380,
16356,
10904,
9366,
1192,
2659,
339,
347,
636,
1661,
721,
277,
304,
267,
298,
3315,
2335,
1806,
1924,
13407,
315,
314,
11915,
2122,
267,
327,
15510,
20568,
342,
1471,
506,
2797,
2544,
8494,
365,
370,
5386,
14,
267,
13648,
14,
3958,
63,
19332,
8,
277,
423,
4695,
9,
267,
367,
284,
315,
1425,
8,
277,
14,
1507,
63,
11873,
304,
288,
1995,
13407,
8,
14145,
14,
362,
63,
2184,
63,
4445,
8,
277,
423,
4695,
395,
291,
9,
339,
347,
636,
552,
721,
277,
304,
267,
298,
1918,
2582,
365,
314,
1329,
402,
4534,
2122,
267,
372,
291,
14,
1507,
63,
11873,
339,
347,
636,
495,
721,
277,
304,
267,
298,
1918,
1059,
536,
402,
314,
4045,
2122,
267,
372,
291,
14,
354,
339,
347,
485,
1875,
63,
4445,
8,
277,
12,
13953,
63,
344,
304,
267,
408,
267,
11642,
12981,
367,
636,
6095,
363,
626,
21638,
282,
13407,
687,
314,
1627,
267,
13407,
2870,
14,
221,
982,
314,
10904,
11915,
1630,
440,
2291,
2196,
13,
2732,
7664,
12,
267,
2066,
1924,
3878,
402,
314,
4045,
911,
506,
10035,
2509,
4012,
5133,
314,
267,
282,
13407,
365,
1911,
4877,
314,
1627,
3878,
2870,
14,
267,
408,
267,
340,
291,
423,
2355,
63,
739,
26,
288,
327,
982,
314,
11915,
5171,
2196,
7664,
12,
372,
14,
288,
862,
26,
355,
372,
13407,
8,
14145,
14,
362,
63,
4445,
8,
277,
14,
4695,
12,
13953,
63,
344,
395,
291,
9,
288,
871,
15801,
1726,
26,
355,
986,
267,
587,
26,
288,
327,
9571,
2879,
5712,
1133,
3748,
12,
1172,
370,
11609,
4012,
288,
327,
1924,
3878,
5133,
314,
1627,
3878,
2870,
365,
14556,
14,
288,
367,
13953,
315,
291,
26,
355,
340,
13953,
14,
9430,
508,
13953,
63,
344,
26,
490,
372,
13953,
267,
327,
7719,
1172,
2138,
282,
13407,
12,
746,
376,
10904,
12129,
14,
267,
746,
10904,
12129,
360,
3364,
3878,
1305,
26,
450,
83,
3530,
450,
13953,
63,
344,
9,
339,
327,
14055,
11915,
4382,
14055,
272,
768,
1829,
272,
347,
13675,
8,
277,
304,
267,
298,
3407,
314,
13675,
334,
290,
29143,
9,
402,
642,
4045,
2122,
267,
2589,
275,
19746,
907,
78,
10658,
342,
267,
13648,
14,
362,
63,
11599,
8,
277,
14,
4695,
12,
15968,
8,
1813,
395,
413,
9,
267,
372,
29143,
8,
1813,
9,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
298,
3407,
314,
536,
402,
642,
4045,
315,
314,
3918,
5800,
2122,
267,
536,
275,
13648,
14,
362,
63,
2592,
63,
354,
8
] |
[
5577,
492,
15968,
12,
286,
63,
3157,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1095,
492,
15801,
1563,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
19707,
492,
29143,
12,
19746,
907,
78,
10658,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
705,
492,
334,
272,
15801,
1726,
12,
10904,
12129,
12,
12765,
21686,
12,
199,
9,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
4445,
492,
13407,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
698,
492,
10904,
792,
4100,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
21626,
492,
24220,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
6481,
466,
492,
25756,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
16141,
83,
492,
334,
272,
6364,
465,
13648,
12,
9671,
465,
9671,
63,
1246,
12,
16191,
465,
16191,
63,
1246,
12,
199,
9,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
12722,
492,
24324,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
12,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
421,
199,
3,
2104,
1655,
2556,
12,
1937,
314,
10904,
445,
3261,
1350,
1233,
26,
199,
3,
221,
1455,
921,
1544,
14,
11600,
14,
1308,
15,
14945,
15,
14945,
363,
1246,
63,
24,
72,
14,
1360,
199,
3,
199,
3,
710,
10904,
63,
44,
15192,
14975,
787,
12082,
2348,
14,
199,
533,
11915,
8,
17835,
1563,
304,
272,
298,
33,
1021,
626,
14018,
376,
10904,
11915,
12,
4839,
370,
506,
17544,
687,
282,
24300,
909,
2122,
339,
347,
636,
826,
721,
277,
12,
4045,
63,
4695,
12,
6364,
304,
267,
408,
267,
6026,
6491,
641,
376,
10904,
445,
7849,
370,
314,
11915,
436,
314,
658,
16693,
64,
909,
267,
626,
22182,
561,
642,
4045,
14,
221,
710,
658,
16693,
64,
909,
365,
1415,
880,
626,
282,
267,
3659,
370,
652,
365,
16204,
543,
642,
11915,
14,
221,
961,
21925,
17516,
267,
3245,
402,
314,
658,
16693,
64,
1830,
642,
11915,
365,
5139,
4702,
14,
267,
408,
267,
340,
440,
4045,
63,
4695,
26,
288,
746,
15801,
1726,
360,
6612,
1218,
11915,
12,
3866,
7849,
1627,
358,
267,
291,
14,
4695,
275,
4045,
63,
4695,
267,
291,
423,
795,
275,
6364,
267,
291,
423,
76,
27950,
275,
13648,
14,
362,
63,
1897,
63,
27950,
8,
277,
423,
4695,
9,
267,
327,
12078,
314,
11915,
2291,
2196,
7664,
31,
267,
291,
423,
2355,
63,
739,
275,
291,
14,
396,
63,
21181,
8,
66,
7,
3883,
3284,
358,
339,
347,
636,
6095,
721,
277,
12,
1478,
304,
267,
298,
14426,
314,
13407,
737,
314,
2013,
1478,
2122,
267,
340,
1228,
8,
1080,
12,
3816,
14,
4115,
63,
1313,
304,
288,
327,
1626,
3000,
1478,
1990,
1627,
1553,
781,
3913,
886,
282,
1104,
4079,
641,
314,
288,
327,
1329,
402,
4534,
2952,
314,
9608,
436,
13401,
3878,
11449,
288,
327,
787,
440,
17334,
370,
506,
378,
436,
822,
8,
1897,
7216,
17,
12,
17342,
14,
288,
340,
1478,
665,
378,
26,
355,
746,
10904,
12129,
360,
15562,
4918,
787,
440,
4370,
641,
10904,
9366,
1192,
2659,
288,
372,
291,
423,
1875,
63,
4445,
8,
1080,
9,
267,
916,
1228,
8,
1080,
12,
6014,
304,
288,
327,
437,
6014,
1990,
1627,
288,
1343,
12,
3631,
12,
7345,
275,
1478,
14,
4108,
8,
277,
14,
1507,
63,
11873,
9,
288,
372,
359,
277,
423,
1875,
63,
4445,
8,
9430,
9,
367,
8289,
315,
1425,
8,
928,
12,
3631,
12,
7345,
1874,
267,
587,
26,
288,
746,
3146,
360,
2674,
83,
436,
17184,
1443,
1454,
506,
1202,
1380,
16356,
10904,
9366,
1192,
2659,
339,
347,
636,
1661,
721,
277,
304,
267,
298,
3315,
2335,
1806,
1924,
13407,
315,
314,
11915,
2122,
267,
327,
15510,
20568,
342,
1471,
506,
2797,
2544,
8494,
365,
370,
5386,
14,
267,
13648,
14,
3958,
63,
19332,
8,
277,
423,
4695,
9,
267,
367,
284,
315,
1425,
8,
277,
14,
1507,
63,
11873,
304,
288,
1995,
13407,
8,
14145,
14,
362,
63,
2184,
63,
4445,
8,
277,
423,
4695,
395,
291,
9,
339,
347,
636,
552,
721,
277,
304,
267,
298,
1918,
2582,
365,
314,
1329,
402,
4534,
2122,
267,
372,
291,
14,
1507,
63,
11873,
339,
347,
636,
495,
721,
277,
304,
267,
298,
1918,
1059,
536,
402,
314,
4045,
2122,
267,
372,
291,
14,
354,
339,
347,
485,
1875,
63,
4445,
8,
277,
12,
13953,
63,
344,
304,
267,
408,
267,
11642,
12981,
367,
636,
6095,
363,
626,
21638,
282,
13407,
687,
314,
1627,
267,
13407,
2870,
14,
221,
982,
314,
10904,
11915,
1630,
440,
2291,
2196,
13,
2732,
7664,
12,
267,
2066,
1924,
3878,
402,
314,
4045,
911,
506,
10035,
2509,
4012,
5133,
314,
267,
282,
13407,
365,
1911,
4877,
314,
1627,
3878,
2870,
14,
267,
408,
267,
340,
291,
423,
2355,
63,
739,
26,
288,
327,
982,
314,
11915,
5171,
2196,
7664,
12,
372,
14,
288,
862,
26,
355,
372,
13407,
8,
14145,
14,
362,
63,
4445,
8,
277,
14,
4695,
12,
13953,
63,
344,
395,
291,
9,
288,
871,
15801,
1726,
26,
355,
986,
267,
587,
26,
288,
327,
9571,
2879,
5712,
1133,
3748,
12,
1172,
370,
11609,
4012,
288,
327,
1924,
3878,
5133,
314,
1627,
3878,
2870,
365,
14556,
14,
288,
367,
13953,
315,
291,
26,
355,
340,
13953,
14,
9430,
508,
13953,
63,
344,
26,
490,
372,
13953,
267,
327,
7719,
1172,
2138,
282,
13407,
12,
746,
376,
10904,
12129,
14,
267,
746,
10904,
12129,
360,
3364,
3878,
1305,
26,
450,
83,
3530,
450,
13953,
63,
344,
9,
339,
327,
14055,
11915,
4382,
14055,
272,
768,
1829,
272,
347,
13675,
8,
277,
304,
267,
298,
3407,
314,
13675,
334,
290,
29143,
9,
402,
642,
4045,
2122,
267,
2589,
275,
19746,
907,
78,
10658,
342,
267,
13648,
14,
362,
63,
11599,
8,
277,
14,
4695,
12,
15968,
8,
1813,
395,
413,
9,
267,
372,
29143,
8,
1813,
9,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
298,
3407,
314,
536,
402,
642,
4045,
315,
314,
3918,
5800,
2122,
267,
536,
275,
13648,
14,
362,
63,
2592,
63,
354,
8,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
hugobowne/scikit-learn
|
examples/svm/plot_oneclass.py
|
80
|
2338
|
"""
==========================================
One-class SVM with non-linear kernel (RBF)
==========================================
An example using a one-class SVM for novelty detection.
:ref:`One-class SVM <svm_outlier_detection>` is an unsupervised
algorithm that learns a decision function for novelty detection:
classifying new data as similar or different to the training set.
"""
print(__doc__)
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.font_manager
from sklearn import svm
xx, yy = np.meshgrid(np.linspace(-5, 5, 500), np.linspace(-5, 5, 500))
# Generate train data
X = 0.3 * np.random.randn(100, 2)
X_train = np.r_[X + 2, X - 2]
# Generate some regular novel observations
X = 0.3 * np.random.randn(20, 2)
X_test = np.r_[X + 2, X - 2]
# Generate some abnormal novel observations
X_outliers = np.random.uniform(low=-4, high=4, size=(20, 2))
# fit the model
clf = svm.OneClassSVM(nu=0.1, kernel="rbf", gamma=0.1)
clf.fit(X_train)
y_pred_train = clf.predict(X_train)
y_pred_test = clf.predict(X_test)
y_pred_outliers = clf.predict(X_outliers)
n_error_train = y_pred_train[y_pred_train == -1].size
n_error_test = y_pred_test[y_pred_test == -1].size
n_error_outliers = y_pred_outliers[y_pred_outliers == 1].size
# plot the line, the points, and the nearest vectors to the plane
Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
plt.title("Novelty Detection")
plt.contourf(xx, yy, Z, levels=np.linspace(Z.min(), 0, 7), cmap=plt.cm.PuBu)
a = plt.contour(xx, yy, Z, levels=[0], linewidths=2, colors='darkred')
plt.contourf(xx, yy, Z, levels=[0, Z.max()], colors='palevioletred')
s = 40
b1 = plt.scatter(X_train[:, 0], X_train[:, 1], c='white', s=s)
b2 = plt.scatter(X_test[:, 0], X_test[:, 1], c='blueviolet', s=s)
c = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c='gold', s=s)
plt.axis('tight')
plt.xlim((-5, 5))
plt.ylim((-5, 5))
plt.legend([a.collections[0], b1, b2, c],
["learned frontier", "training observations",
"new regular observations", "new abnormal observations"],
loc="upper left",
prop=matplotlib.font_manager.FontProperties(size=11))
plt.xlabel(
"error train: %d/200 ; errors novel regular: %d/40 ; "
"errors novel abnormal: %d/40"
% (n_error_train, n_error_test, n_error_outliers))
plt.show()
|
bsd-3-clause
|
[
624,
199,
2486,
17575,
199,
4395,
13,
533,
428,
6849,
543,
2222,
13,
6676,
5114,
334,
50,
12659,
9,
199,
2486,
17575,
199,
199,
2493,
2893,
1808,
282,
1373,
13,
533,
428,
6849,
367,
949,
1090,
369,
15212,
14,
199,
199,
26,
1121,
1705,
4395,
13,
533,
428,
6849,
665,
16820,
63,
548,
5697,
63,
11934,
8637,
365,
376,
625,
4792,
17311,
199,
8833,
626,
1026,
22476,
282,
14692,
805,
367,
949,
1090,
369,
15212,
26,
199,
12334,
1399,
316,
892,
666,
465,
8545,
503,
3365,
370,
314,
6093,
663,
14,
199,
624,
199,
1361,
3460,
1301,
3368,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
8027,
14,
4246,
63,
2609,
199,
504,
6357,
492,
23044,
199,
199,
2154,
12,
20435,
275,
980,
14,
6480,
3825,
8,
1590,
14,
11649,
2801,
21,
12,
959,
12,
6891,
395,
980,
14,
11649,
2801,
21,
12,
959,
12,
6891,
430,
199,
3,
7958,
3560,
666,
199,
56,
275,
378,
14,
19,
627,
980,
14,
2355,
14,
10843,
8,
1960,
12,
499,
9,
199,
56,
63,
2834,
275,
980,
14,
82,
9925,
56,
435,
499,
12,
1323,
446,
499,
61,
199,
3,
7958,
2005,
5578,
949,
1090,
19739,
199,
56,
275,
378,
14,
19,
627,
980,
14,
2355,
14,
10843,
8,
1165,
12,
499,
9,
199,
56,
63,
396,
275,
980,
14,
82,
9925,
56,
435,
499,
12,
1323,
446,
499,
61,
199,
3,
7958,
2005,
2236,
3302,
949,
1090,
19739,
199,
56,
63,
28622,
275,
980,
14,
2355,
14,
8830,
8,
674,
4022,
20,
12,
4721,
29,
20,
12,
1568,
2687,
1165,
12,
499,
430,
199,
199,
3,
5542,
314,
1402,
199,
9694,
275,
23044,
14,
4395,
2543,
29389,
8,
4850,
29,
16,
14,
17,
12,
5114,
628,
25853,
401,
10169,
29,
16,
14,
17,
9,
199,
9694,
14,
3269,
8,
56,
63,
2834,
9,
199,
89,
63,
5991,
63,
2834,
275,
6975,
14,
6892,
8,
56,
63,
2834,
9,
199,
89,
63,
5991,
63,
396,
275,
6975,
14,
6892,
8,
56,
63,
396,
9,
199,
89,
63,
5991,
63,
28622,
275,
6975,
14,
6892,
8,
56,
63,
28622,
9,
199,
78,
63,
705,
63,
2834,
275,
612,
63,
5991,
63,
2834,
59,
89,
63,
5991,
63,
2834,
508,
446,
17,
1055,
890,
199,
78,
63,
705,
63,
396,
275,
612,
63,
5991,
63,
396,
59,
89,
63,
5991,
63,
396,
508,
446,
17,
1055,
890,
199,
78,
63,
705,
63,
28622,
275,
612,
63,
5991,
63,
28622,
59,
89,
63,
5991,
63,
28622,
508,
413,
1055,
890,
199,
199,
3,
5137,
314,
1004,
12,
314,
4501,
12,
436,
314,
17173,
11102,
370,
314,
16388,
199,
58,
275,
6975,
14,
16622,
63,
1593,
8,
1590,
14,
67,
9925,
2154,
14,
11186,
1062,
20435,
14,
11186,
9383,
199,
58,
275,
3107,
14,
5217,
8,
2154,
14,
1392,
9,
199,
199,
6003,
14,
1213,
480,
1944,
1090,
369,
1487,
5860,
531,
199,
6003,
14,
17798,
70,
8,
2154,
12,
20435,
12,
3107,
12,
11106,
29,
1590,
14,
11649,
8,
58,
14,
827,
1062,
378,
12,
1520,
395,
14920,
29,
6003,
14,
4400,
14,
26607,
1713,
9,
199,
65,
275,
4488,
14,
17798,
8,
2154,
12,
20435,
12,
3107,
12,
11106,
1524,
16,
467,
21213,
83,
29,
18,
12,
9229,
534,
13625,
581,
358,
199,
6003,
14,
17798,
70,
8,
2154,
12,
20435,
12,
3107,
12,
11106,
1524,
16,
12,
3107,
14,
988,
15618,
9229,
534,
387,
274,
32052,
2723,
581,
358,
199,
199,
83,
275,
6335,
199,
66,
17,
275,
4488,
14,
13512,
8,
56,
63,
2834,
3981,
378,
467,
1323,
63,
2834,
3981,
413,
467,
286,
534,
7510,
297,
308,
29,
83,
9,
199,
66,
18,
275,
4488,
14,
13512,
8,
56,
63,
396,
3981,
378,
467,
1323,
63,
396,
3981,
413,
467,
286,
534,
6304,
32052,
2723,
297,
308,
29,
83,
9,
199,
67,
275,
4488,
14,
13512,
8,
56,
63,
28622,
3981,
378,
467,
1323,
63,
28622,
3981,
413,
467,
286,
534,
23628,
297,
308,
29,
83,
9,
199,
6003,
14,
3127,
360,
23787,
358,
199,
6003,
14,
18512,
18138,
21,
12,
959,
430,
199,
6003,
14,
18123,
18138,
21,
12,
959,
430,
199,
6003,
14,
10231,
779,
65,
14,
7882,
59,
16,
467,
330,
17,
12,
330,
18,
12,
286,
467,
1779,
2097,
4643,
379,
289,
2641,
13949,
401,
298,
7588,
19739,
401,
288,
298,
1222,
5578,
19739,
401,
298,
1222,
2236,
3302,
19739,
2255,
1779,
4355,
628,
4142,
3602,
401,
1779,
5931,
29,
16440,
14,
4246,
63,
2609,
14,
6986,
8516,
8,
890,
29,
845,
430,
199,
6003,
14,
14168,
8,
272,
298,
705,
3560,
26,
450,
68,
15,
1840,
8700,
2552,
949,
1090,
5578,
26,
450,
68,
15,
2167,
8700,
298,
272,
298,
2550,
949,
1090,
2236,
3302,
26,
450,
68,
15,
2167,
2,
272,
450,
334,
78,
63,
705,
63,
2834,
12,
302,
63,
705,
63,
396,
12,
302,
63,
705,
63,
28622,
430,
199,
6003,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
2486,
17575,
199,
4395,
13,
533,
428,
6849,
543,
2222,
13,
6676,
5114,
334,
50,
12659,
9,
199,
2486,
17575,
199,
199,
2493,
2893,
1808,
282,
1373,
13,
533,
428,
6849,
367,
949,
1090,
369,
15212,
14,
199,
199,
26,
1121,
1705,
4395,
13,
533,
428,
6849,
665,
16820,
63,
548,
5697,
63,
11934,
8637,
365,
376,
625,
4792,
17311,
199,
8833,
626,
1026,
22476,
282,
14692,
805,
367,
949,
1090,
369,
15212,
26,
199,
12334,
1399,
316,
892,
666,
465,
8545,
503,
3365,
370,
314,
6093,
663,
14,
199,
624,
199,
1361,
3460,
1301,
3368,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
8027,
14,
4246,
63,
2609,
199,
504,
6357,
492,
23044,
199,
199,
2154,
12,
20435,
275,
980,
14,
6480,
3825,
8,
1590,
14,
11649,
2801,
21,
12,
959,
12,
6891,
395,
980,
14,
11649,
2801,
21,
12,
959,
12,
6891,
430,
199,
3,
7958,
3560,
666,
199,
56,
275,
378,
14,
19,
627,
980,
14,
2355,
14,
10843,
8,
1960,
12,
499,
9,
199,
56,
63,
2834,
275,
980,
14,
82,
9925,
56,
435,
499,
12,
1323,
446,
499,
61,
199,
3,
7958,
2005,
5578,
949,
1090,
19739,
199,
56,
275,
378,
14,
19,
627,
980,
14,
2355,
14,
10843,
8,
1165,
12,
499,
9,
199,
56,
63,
396,
275,
980,
14,
82,
9925,
56,
435,
499,
12,
1323,
446,
499,
61,
199,
3,
7958,
2005,
2236,
3302,
949,
1090,
19739,
199,
56,
63,
28622,
275,
980,
14,
2355,
14,
8830,
8,
674,
4022,
20,
12,
4721,
29,
20,
12,
1568,
2687,
1165,
12,
499,
430,
199,
199,
3,
5542,
314,
1402,
199,
9694,
275,
23044,
14,
4395,
2543,
29389,
8,
4850,
29,
16,
14,
17,
12,
5114,
628,
25853,
401,
10169,
29,
16,
14,
17,
9,
199,
9694,
14,
3269,
8,
56,
63,
2834,
9,
199,
89,
63,
5991,
63,
2834,
275,
6975,
14,
6892,
8,
56,
63,
2834,
9,
199,
89,
63,
5991,
63,
396,
275,
6975,
14,
6892,
8,
56,
63,
396,
9,
199,
89,
63,
5991,
63,
28622,
275,
6975,
14,
6892,
8,
56,
63,
28622,
9,
199,
78,
63,
705,
63,
2834,
275,
612,
63,
5991,
63,
2834,
59,
89,
63,
5991,
63,
2834,
508,
446,
17,
1055,
890,
199,
78,
63,
705,
63,
396,
275,
612,
63,
5991,
63,
396,
59,
89,
63,
5991,
63,
396,
508,
446,
17,
1055,
890,
199,
78,
63,
705,
63,
28622,
275,
612,
63,
5991,
63,
28622,
59,
89,
63,
5991,
63,
28622,
508,
413,
1055,
890,
199,
199,
3,
5137,
314,
1004,
12,
314,
4501,
12,
436,
314,
17173,
11102,
370,
314,
16388,
199,
58,
275,
6975,
14,
16622,
63,
1593,
8,
1590,
14,
67,
9925,
2154,
14,
11186,
1062,
20435,
14,
11186,
9383,
199,
58,
275,
3107,
14,
5217,
8,
2154,
14,
1392,
9,
199,
199,
6003,
14,
1213,
480,
1944,
1090,
369,
1487,
5860,
531,
199,
6003,
14,
17798,
70,
8,
2154,
12,
20435,
12,
3107,
12,
11106,
29,
1590,
14,
11649,
8,
58,
14,
827,
1062,
378,
12,
1520,
395,
14920,
29,
6003,
14,
4400,
14,
26607,
1713,
9,
199,
65,
275,
4488,
14,
17798,
8,
2154,
12,
20435,
12,
3107,
12,
11106,
1524,
16,
467,
21213,
83,
29,
18,
12,
9229,
534,
13625,
581,
358,
199,
6003,
14,
17798,
70,
8,
2154,
12,
20435,
12,
3107,
12,
11106,
1524,
16,
12,
3107,
14,
988,
15618,
9229,
534,
387,
274,
32052,
2723,
581,
358,
199,
199,
83,
275,
6335,
199,
66,
17,
275,
4488,
14,
13512,
8,
56,
63,
2834,
3981,
378,
467,
1323,
63,
2834,
3981,
413,
467,
286,
534,
7510,
297,
308,
29,
83,
9,
199,
66,
18,
275,
4488,
14,
13512,
8,
56,
63,
396,
3981,
378,
467,
1323,
63,
396,
3981,
413,
467,
286,
534,
6304,
32052,
2723,
297,
308,
29,
83,
9,
199,
67,
275,
4488,
14,
13512,
8,
56,
63,
28622,
3981,
378,
467,
1323,
63,
28622,
3981,
413,
467,
286,
534,
23628,
297,
308,
29,
83,
9,
199,
6003,
14,
3127,
360,
23787,
358,
199,
6003,
14,
18512,
18138,
21,
12,
959,
430,
199,
6003,
14,
18123,
18138,
21,
12,
959,
430,
199,
6003,
14,
10231,
779,
65,
14,
7882,
59,
16,
467,
330,
17,
12,
330,
18,
12,
286,
467,
1779,
2097,
4643,
379,
289,
2641,
13949,
401,
298,
7588,
19739,
401,
288,
298,
1222,
5578,
19739,
401,
298,
1222,
2236,
3302,
19739,
2255,
1779,
4355,
628,
4142,
3602,
401,
1779,
5931,
29,
16440,
14,
4246,
63,
2609,
14,
6986,
8516,
8,
890,
29,
845,
430,
199,
6003,
14,
14168,
8,
272,
298,
705,
3560,
26,
450,
68,
15,
1840,
8700,
2552,
949,
1090,
5578,
26,
450,
68,
15,
2167,
8700,
298,
272,
298,
2550,
949,
1090,
2236,
3302,
26,
450,
68,
15,
2167,
2,
272,
450,
334,
78,
63,
705,
63,
2834,
12,
302,
63,
705,
63,
396,
12,
302,
63,
705,
63,
28622,
430,
199,
6003,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sphoebs/rockshell
|
simplejson/tests/__init__.py
|
29
|
3029
|
from __future__ import absolute_import
import unittest
import doctest
import sys
class NoExtensionTestSuite(unittest.TestSuite):
def run(self, result):
import simplejson
simplejson._toggle_speedups(False)
result = unittest.TestSuite.run(self, result)
simplejson._toggle_speedups(True)
return result
class TestMissingSpeedups(unittest.TestCase):
def runTest(self):
if hasattr(sys, 'pypy_translation_info'):
"PyPy doesn't need speedups! :)"
elif hasattr(self, 'skipTest'):
self.skipTest('_speedups.so is missing!')
def additional_tests(suite=None):
import simplejson
import simplejson.encoder
import simplejson.decoder
if suite is None:
suite = unittest.TestSuite()
for mod in (simplejson, simplejson.encoder, simplejson.decoder):
suite.addTest(doctest.DocTestSuite(mod))
suite.addTest(doctest.DocFileSuite('../../index.rst'))
return suite
def all_tests_suite():
def get_suite():
return additional_tests(
unittest.TestLoader().loadTestsFromNames([
'simplejson.tests.test_bitsize_int_as_string',
'simplejson.tests.test_bigint_as_string',
'simplejson.tests.test_check_circular',
'simplejson.tests.test_decode',
'simplejson.tests.test_default',
'simplejson.tests.test_dump',
'simplejson.tests.test_encode_basestring_ascii',
'simplejson.tests.test_encode_for_html',
'simplejson.tests.test_errors',
'simplejson.tests.test_fail',
'simplejson.tests.test_float',
'simplejson.tests.test_indent',
'simplejson.tests.test_pass1',
'simplejson.tests.test_pass2',
'simplejson.tests.test_pass3',
'simplejson.tests.test_recursion',
'simplejson.tests.test_scanstring',
'simplejson.tests.test_separators',
'simplejson.tests.test_speedups',
'simplejson.tests.test_unicode',
'simplejson.tests.test_decimal',
'simplejson.tests.test_tuple',
'simplejson.tests.test_namedtuple',
'simplejson.tests.test_tool',
'simplejson.tests.test_for_json',
]))
suite = get_suite()
import simplejson
if simplejson._import_c_make_encoder() is None:
suite.addTest(TestMissingSpeedups())
else:
suite = unittest.TestSuite([
suite,
NoExtensionTestSuite([get_suite()]),
])
return suite
def main():
runner = unittest.TextTestRunner(verbosity=1 + sys.argv.count('-v'))
suite = all_tests_suite()
raise SystemExit(not runner.run(suite).wasSuccessful())
if __name__ == '__main__':
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
main()
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
646,
2882,
199,
646,
8868,
199,
646,
984,
421,
199,
533,
3091,
6382,
10591,
8,
2796,
14,
10591,
304,
272,
347,
1255,
8,
277,
12,
754,
304,
267,
492,
13804,
267,
13804,
423,
13396,
63,
7625,
15203,
8,
797,
9,
267,
754,
275,
2882,
14,
10591,
14,
1065,
8,
277,
12,
754,
9,
267,
13804,
423,
13396,
63,
7625,
15203,
8,
549,
9,
267,
372,
754,
421,
199,
533,
1379,
7718,
15146,
15203,
8,
2796,
14,
1746,
304,
272,
347,
29779,
8,
277,
304,
267,
340,
2688,
8,
1274,
12,
283,
20233,
63,
6893,
63,
815,
735,
288,
298,
2713,
2713,
3181,
1133,
1929,
8112,
15203,
1,
520,
2924,
267,
916,
2688,
8,
277,
12,
283,
23809,
735,
288,
291,
14,
23809,
6412,
7625,
15203,
14,
1152,
365,
4124,
10916,
421,
199,
318,
4722,
63,
2219,
8,
5768,
29,
403,
304,
272,
492,
13804,
272,
492,
13804,
14,
9347,
272,
492,
13804,
14,
8813,
272,
340,
5241,
365,
488,
26,
267,
5241,
275,
2882,
14,
10591,
342,
272,
367,
3413,
315,
334,
4129,
1001,
12,
13804,
14,
9347,
12,
13804,
14,
8813,
304,
267,
5241,
14,
15714,
8,
11390,
14,
3768,
10591,
8,
1494,
430,
272,
5241,
14,
15714,
8,
11390,
14,
3768,
1173,
6207,
360,
9707,
1080,
14,
8332,
1333,
272,
372,
5241,
421,
199,
318,
1006,
63,
2219,
63,
5768,
837,
272,
347,
664,
63,
5768,
837,
267,
372,
4722,
63,
2219,
8,
288,
2882,
14,
15824,
1252,
28730,
779,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2075,
890,
63,
442,
63,
305,
63,
875,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
24884,
63,
305,
63,
875,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1074,
63,
23022,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2708,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
885,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2724,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2143,
63,
17628,
63,
4371,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2143,
63,
509,
63,
1360,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2550,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1633,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1609,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
3724,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1529,
17,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1529,
18,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1529,
19,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
21314,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
6282,
875,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
29862,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
7625,
15203,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2975,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
6355,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2960,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
18921,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
3557,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
509,
63,
1001,
297,
288,
22979,
272,
5241,
275,
664,
63,
5768,
342,
272,
492,
13804,
272,
340,
13804,
423,
646,
63,
67,
63,
1875,
63,
9347,
342,
365,
488,
26,
267,
5241,
14,
15714,
8,
774,
7718,
15146,
15203,
1012,
272,
587,
26,
267,
5241,
275,
2882,
14,
10591,
779,
288,
5241,
12,
288,
3091,
6382,
10591,
779,
362,
63,
5768,
342,
2522,
267,
4794,
272,
372,
5241,
421,
199,
318,
2446,
837,
272,
7876,
275,
2882,
14,
24285,
8,
9833,
29,
17,
435,
984,
14,
3020,
14,
835,
3654,
86,
1333,
272,
5241,
275,
1006,
63,
2219,
63,
5768,
342,
272,
746,
14838,
8,
1397,
7876,
14,
1065,
8,
5768,
680,
10274,
20839,
1012,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
492,
747,
272,
492,
984,
272,
984,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
1724,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
646,
2882,
199,
646,
8868,
199,
646,
984,
421,
199,
533,
3091,
6382,
10591,
8,
2796,
14,
10591,
304,
272,
347,
1255,
8,
277,
12,
754,
304,
267,
492,
13804,
267,
13804,
423,
13396,
63,
7625,
15203,
8,
797,
9,
267,
754,
275,
2882,
14,
10591,
14,
1065,
8,
277,
12,
754,
9,
267,
13804,
423,
13396,
63,
7625,
15203,
8,
549,
9,
267,
372,
754,
421,
199,
533,
1379,
7718,
15146,
15203,
8,
2796,
14,
1746,
304,
272,
347,
29779,
8,
277,
304,
267,
340,
2688,
8,
1274,
12,
283,
20233,
63,
6893,
63,
815,
735,
288,
298,
2713,
2713,
3181,
1133,
1929,
8112,
15203,
1,
520,
2924,
267,
916,
2688,
8,
277,
12,
283,
23809,
735,
288,
291,
14,
23809,
6412,
7625,
15203,
14,
1152,
365,
4124,
10916,
421,
199,
318,
4722,
63,
2219,
8,
5768,
29,
403,
304,
272,
492,
13804,
272,
492,
13804,
14,
9347,
272,
492,
13804,
14,
8813,
272,
340,
5241,
365,
488,
26,
267,
5241,
275,
2882,
14,
10591,
342,
272,
367,
3413,
315,
334,
4129,
1001,
12,
13804,
14,
9347,
12,
13804,
14,
8813,
304,
267,
5241,
14,
15714,
8,
11390,
14,
3768,
10591,
8,
1494,
430,
272,
5241,
14,
15714,
8,
11390,
14,
3768,
1173,
6207,
360,
9707,
1080,
14,
8332,
1333,
272,
372,
5241,
421,
199,
318,
1006,
63,
2219,
63,
5768,
837,
272,
347,
664,
63,
5768,
837,
267,
372,
4722,
63,
2219,
8,
288,
2882,
14,
15824,
1252,
28730,
779,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2075,
890,
63,
442,
63,
305,
63,
875,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
24884,
63,
305,
63,
875,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1074,
63,
23022,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2708,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
885,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2724,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2143,
63,
17628,
63,
4371,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2143,
63,
509,
63,
1360,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2550,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1633,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1609,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
3724,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1529,
17,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1529,
18,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
1529,
19,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
21314,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
6282,
875,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
29862,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
7625,
15203,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2975,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
6355,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
2960,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
18921,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
3557,
297,
355,
283,
4129,
1001,
14,
2219,
14,
396,
63,
509,
63,
1001,
297,
288,
22979,
272,
5241,
275,
664,
63,
5768,
342,
272,
492,
13804,
272,
340,
13804,
423,
646,
63,
67,
63,
1875,
63,
9347,
342,
365,
488,
26,
267,
5241,
14,
15714,
8,
774,
7718,
15146,
15203,
1012,
272,
587,
26,
267,
5241,
275,
2882,
14,
10591,
779,
288,
5241,
12,
288,
3091,
6382,
10591,
779,
362,
63,
5768,
342,
2522,
267,
4794,
272,
372,
5241,
421,
199,
318,
2446,
837,
272,
7876,
275,
2882,
14,
24285,
8,
9833,
29,
17,
435,
984,
14,
3020,
14,
835,
3654,
86,
1333,
272,
5241,
275,
1006,
63,
2219,
63,
5768,
342,
272,
746,
14838,
8,
1397,
7876,
14,
1065,
8,
5768,
680,
10274,
20839,
1012,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
492,
747,
272,
492,
984,
272,
984,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
1724,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tragiclifestories/django
|
django/contrib/redirects/migrations/0001_initial.py
|
142
|
1271
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sites', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Redirect',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('site', models.ForeignKey(to='sites.Site', to_field='id')),
('old_path', models.CharField(help_text="This should be an absolute path, excluding the domain name. Example: '/events/search/'.", max_length=200, verbose_name='redirect from', db_index=True)),
('new_path', models.CharField(help_text="This can be either an absolute path (as above) or a full URL starting with 'http://'.", max_length=200, verbose_name='redirect to', blank=True)),
],
options={
'ordering': ('old_path',),
'unique_together': set([('site', 'old_path')]),
'db_table': 'django_redirect',
'verbose_name': 'redirect',
'verbose_name_plural': 'redirects',
},
bases=(models.Model,),
),
]
|
bsd-3-clause
|
[
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,
8619,
297,
283,
4183,
63,
2747,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
14907,
8,
288,
536,
534,
7071,
297,
288,
1504,
1524,
355,
661,
344,
297,
1709,
14,
4378,
8,
3832,
63,
354,
534,
998,
297,
8437,
29,
797,
12,
2599,
63,
3966,
29,
549,
12,
5062,
63,
498,
29,
549,
1826,
355,
661,
2124,
297,
1709,
14,
3190,
8,
475,
534,
8619,
14,
8972,
297,
370,
63,
698,
534,
344,
3855,
355,
661,
1753,
63,
515,
297,
1709,
14,
2183,
8,
3437,
63,
505,
628,
2765,
1077,
506,
376,
3679,
931,
12,
28529,
314,
2881,
536,
14,
5679,
26,
1994,
4368,
15,
1733,
15,
30532,
1390,
63,
1267,
29,
1840,
12,
3376,
63,
354,
534,
4876,
687,
297,
1592,
63,
1080,
29,
549,
1826,
355,
661,
1222,
63,
515,
297,
1709,
14,
2183,
8,
3437,
63,
505,
628,
2765,
883,
506,
1902,
376,
3679,
931,
334,
305,
3432,
9,
503,
282,
2615,
2851,
6617,
543,
283,
1014,
921,
30532,
1390,
63,
1267,
29,
1840,
12,
3376,
63,
354,
534,
4876,
370,
297,
4596,
29,
549,
1826,
288,
2156,
288,
1511,
3126,
355,
283,
7128,
356,
661,
1753,
63,
515,
5529,
355,
283,
3235,
63,
6314,
356,
663,
8318,
2124,
297,
283,
1753,
63,
515,
22864,
355,
283,
697,
63,
1224,
356,
283,
1176,
63,
4876,
297,
355,
283,
3832,
63,
354,
356,
283,
4876,
297,
355,
283,
3832,
63,
354,
63,
10019,
356,
283,
13607,
297,
288,
1660,
288,
9768,
2687,
992,
14,
1685,
4706,
267,
2318,
272,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
504,
1639,
14,
697,
492,
6180,
12,
1709,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
8619,
297,
283,
4183,
63,
2747,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
14907,
8,
288,
536,
534,
7071,
297,
288,
1504,
1524,
355,
661,
344,
297,
1709,
14,
4378,
8,
3832,
63,
354,
534,
998,
297,
8437,
29,
797,
12,
2599,
63,
3966,
29,
549,
12,
5062,
63,
498,
29,
549,
1826,
355,
661,
2124,
297,
1709,
14,
3190,
8,
475,
534,
8619,
14,
8972,
297,
370,
63,
698,
534,
344,
3855,
355,
661,
1753,
63,
515,
297,
1709,
14,
2183,
8,
3437,
63,
505,
628,
2765,
1077,
506,
376,
3679,
931,
12,
28529,
314,
2881,
536,
14,
5679,
26,
1994,
4368,
15,
1733,
15,
30532,
1390,
63,
1267,
29,
1840,
12,
3376,
63,
354,
534,
4876,
687,
297,
1592,
63,
1080,
29,
549,
1826,
355,
661,
1222,
63,
515,
297,
1709,
14,
2183,
8,
3437,
63,
505,
628,
2765,
883,
506,
1902,
376,
3679,
931,
334,
305,
3432,
9,
503,
282,
2615,
2851,
6617,
543,
283,
1014,
921,
30532,
1390,
63,
1267,
29,
1840,
12,
3376,
63,
354,
534,
4876,
370,
297,
4596,
29,
549,
1826,
288,
2156,
288,
1511,
3126,
355,
283,
7128,
356,
661,
1753,
63,
515,
5529,
355,
283,
3235,
63,
6314,
356,
663,
8318,
2124,
297,
283,
1753,
63,
515,
22864,
355,
283,
697,
63,
1224,
356,
283,
1176,
63,
4876,
297,
355,
283,
3832,
63,
354,
356,
283,
4876,
297,
355,
283,
3832,
63,
354,
63,
10019,
356,
283,
13607,
297,
288,
1660,
288,
9768,
2687,
992,
14,
1685,
4706,
267,
2318,
272,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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~~~~
Pygments lexers for JVM languages.
:copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
this, combined, default, words
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation
from pygments.util import shebang_matches
from pygments import unistring as uni
__all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer',
'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'ClojureScriptLexer',
'KotlinLexer', 'XtendLexer', 'AspectJLexer', 'CeylonLexer',
'PigLexer', 'GoloLexer', 'JasminLexer']
class JavaLexer(RegexLexer):
"""
For `Java <http://www.sun.com/java/>`_ source code.
"""
name = 'Java'
aliases = ['java']
filenames = ['*.java']
mimetypes = ['text/x-java']
flags = re.MULTILINE | re.DOTALL | re.UNICODE
tokens = {
'root': [
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*.*?\*/', Comment.Multiline),
# keywords: go before method names to avoid lexing "throw new XYZ"
# as a method signature
(r'(assert|break|case|catch|continue|default|do|else|finally|for|'
r'if|goto|instanceof|new|return|switch|this|throw|try|while)\b',
Keyword),
# method names
(r'((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)' # return arguments
r'((?:[^\W\d]|\$)[\w$]*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'@[^\W\d][\w.]*', Name.Decorator),
(r'(abstract|const|enum|extends|final|implements|native|private|'
r'protected|public|static|strictfp|super|synchronized|throws|'
r'transient|volatile)\b', Keyword.Declaration),
(r'(boolean|byte|char|double|float|int|long|short|void)\b',
Keyword.Type),
(r'(package)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'(true|false|null)\b', Keyword.Constant),
(r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 'class'),
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
(r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Operator, Name.Attribute)),
(r'^\s*([^\W\d]|\$)[\w$]*:', Name.Label),
(r'([^\W\d]|\$)[\w$]*', Name),
(r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+(_+[0-9]+)*L?', Number.Integer),
(r'\n', Text)
],
'class': [
(r'([^\W\d]|\$)[\w$]*', Name.Class, '#pop')
],
'import': [
(r'[\w.]+\*?', Name.Namespace, '#pop')
],
}
class AspectJLexer(JavaLexer):
"""
For `AspectJ <http://www.eclipse.org/aspectj/>`_ source code.
.. versionadded:: 1.6
"""
name = 'AspectJ'
aliases = ['aspectj']
filenames = ['*.aj']
mimetypes = ['text/x-aspectj']
aj_keywords = set((
'aspect', 'pointcut', 'privileged', 'call', 'execution',
'initialization', 'preinitialization', 'handler', 'get', 'set',
'staticinitialization', 'target', 'args', 'within', 'withincode',
'cflow', 'cflowbelow', 'annotation', 'before', 'after', 'around',
'proceed', 'throwing', 'returning', 'adviceexecution', 'declare',
'parents', 'warning', 'error', 'soft', 'precedence', 'thisJoinPoint',
'thisJoinPointStaticPart', 'thisEnclosingJoinPointStaticPart',
'issingleton', 'perthis', 'pertarget', 'percflow', 'percflowbelow',
'pertypewithin', 'lock', 'unlock', 'thisAspectInstance'
))
aj_inter_type = set(('parents:', 'warning:', 'error:', 'soft:', 'precedence:'))
aj_inter_type_annotation = set(('@type', '@method', '@constructor', '@field'))
def get_tokens_unprocessed(self, text):
for index, token, value in JavaLexer.get_tokens_unprocessed(self, text):
if token is Name and value in self.aj_keywords:
yield index, Keyword, value
elif token is Name.Label and value in self.aj_inter_type:
yield index, Keyword, value[:-1]
yield index, Operator, value[-1]
elif token is Name.Decorator and value in self.aj_inter_type_annotation:
yield index, Keyword, value
else:
yield index, token, value
class ScalaLexer(RegexLexer):
"""
For `Scala <http://www.scala-lang.org>`_ source code.
"""
name = 'Scala'
aliases = ['scala']
filenames = ['*.scala']
mimetypes = ['text/x-scala']
flags = re.MULTILINE | re.DOTALL
# don't use raw unicode strings!
op = (u'[-~\\^\\*!%&\\\\<>\\|+=:/?@\u00a6-\u00a7\u00a9\u00ac\u00ae\u00b0-\u00b1'
u'\u00b6\u00d7\u00f7\u03f6\u0482\u0606-\u0608\u060e-\u060f\u06e9'
u'\u06fd-\u06fe\u07f6\u09fa\u0b70\u0bf3-\u0bf8\u0bfa\u0c7f\u0cf1-\u0cf2'
u'\u0d79\u0f01-\u0f03\u0f13-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38'
u'\u0fbe-\u0fc5\u0fc7-\u0fcf\u109e-\u109f\u1360\u1390-\u1399\u1940'
u'\u19e0-\u19ff\u1b61-\u1b6a\u1b74-\u1b7c\u2044\u2052\u207a-\u207c'
u'\u208a-\u208c\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118'
u'\u211e-\u2123\u2125\u2127\u2129\u212e\u213a-\u213b\u2140-\u2144'
u'\u214a-\u214d\u214f\u2190-\u2328\u232b-\u244a\u249c-\u24e9\u2500-\u2767'
u'\u2794-\u27c4\u27c7-\u27e5\u27f0-\u2982\u2999-\u29d7\u29dc-\u29fb'
u'\u29fe-\u2b54\u2ce5-\u2cea\u2e80-\u2ffb\u3004\u3012-\u3013\u3020'
u'\u3036-\u3037\u303e-\u303f\u3190-\u3191\u3196-\u319f\u31c0-\u31e3'
u'\u3200-\u321e\u322a-\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff'
u'\u4dc0-\u4dff\ua490-\ua4c6\ua828-\ua82b\ufb29\ufdfd\ufe62\ufe64-\ufe66'
u'\uff0b\uff1c-\uff1e\uff5c\uff5e\uffe2\uffe4\uffe8-\uffee\ufffc-\ufffd]+')
letter = (u'[a-zA-Z\\$_\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6'
u'\u00f8-\u02af\u0370-\u0373\u0376-\u0377\u037b-\u037d\u0386'
u'\u0388-\u03f5\u03f7-\u0481\u048a-\u0556\u0561-\u0587\u05d0-\u05f2'
u'\u0621-\u063f\u0641-\u064a\u066e-\u066f\u0671-\u06d3\u06d5'
u'\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5'
u'\u07b1\u07ca-\u07ea\u0904-\u0939\u093d\u0950\u0958-\u0961'
u'\u0972-\u097f\u0985-\u09b9\u09bd\u09ce\u09dc-\u09e1\u09f0-\u09f1'
u'\u0a05-\u0a39\u0a59-\u0a5e\u0a72-\u0a74\u0a85-\u0ab9\u0abd'
u'\u0ad0-\u0ae1\u0b05-\u0b39\u0b3d\u0b5c-\u0b61\u0b71\u0b83-\u0bb9'
u'\u0bd0\u0c05-\u0c3d\u0c58-\u0c61\u0c85-\u0cb9\u0cbd\u0cde-\u0ce1'
u'\u0d05-\u0d3d\u0d60-\u0d61\u0d7a-\u0d7f\u0d85-\u0dc6\u0e01-\u0e30'
u'\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0eb0\u0eb2-\u0eb3\u0ebd-\u0ec4'
u'\u0edc-\u0f00\u0f40-\u0f6c\u0f88-\u0f8b\u1000-\u102a\u103f'
u'\u1050-\u1055\u105a-\u105d\u1061\u1065-\u1066\u106e-\u1070'
u'\u1075-\u1081\u108e\u10a0-\u10fa\u1100-\u135a\u1380-\u138f'
u'\u13a0-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u16ee-\u1711'
u'\u1720-\u1731\u1740-\u1751\u1760-\u1770\u1780-\u17b3\u17dc'
u'\u1820-\u1842\u1844-\u18a8\u18aa-\u191c\u1950-\u19a9\u19c1-\u19c7'
u'\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae-\u1baf'
u'\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c77\u1d00-\u1d2b\u1d62-\u1d77'
u'\u1d79-\u1d9a\u1e00-\u1fbc\u1fbe\u1fc2-\u1fcc\u1fd0-\u1fdb'
u'\u1fe0-\u1fec\u1ff2-\u1ffc\u2071\u207f\u2102\u2107\u210a-\u2113'
u'\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139'
u'\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c7c'
u'\u2c80-\u2ce4\u2d00-\u2d65\u2d80-\u2dde\u3006-\u3007\u3021-\u3029'
u'\u3038-\u303a\u303c\u3041-\u3096\u309f\u30a1-\u30fa\u30ff-\u318e'
u'\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\ua014\ua016-\ua48c'
u'\ua500-\ua60b\ua610-\ua61f\ua62a-\ua66e\ua680-\ua697\ua722-\ua76f'
u'\ua771-\ua787\ua78b-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822'
u'\ua840-\ua873\ua882-\ua8b3\ua90a-\ua925\ua930-\ua946\uaa00-\uaa28'
u'\uaa40-\uaa42\uaa44-\uaa4b\uac00-\ud7a3\uf900-\ufb1d\ufb1f-\ufb28'
u'\ufb2a-\ufd3d\ufd50-\ufdfb\ufe70-\ufefc\uff21-\uff3a\uff41-\uff5a'
u'\uff66-\uff6f\uff71-\uff9d\uffa0-\uffdc]')
upper = (u'[A-Z\\$_\u00c0-\u00d6\u00d8-\u00de\u0100\u0102\u0104\u0106\u0108'
u'\u010a\u010c\u010e\u0110\u0112\u0114\u0116\u0118\u011a\u011c'
u'\u011e\u0120\u0122\u0124\u0126\u0128\u012a\u012c\u012e\u0130'
u'\u0132\u0134\u0136\u0139\u013b\u013d\u013f\u0141\u0143\u0145'
u'\u0147\u014a\u014c\u014e\u0150\u0152\u0154\u0156\u0158\u015a'
u'\u015c\u015e\u0160\u0162\u0164\u0166\u0168\u016a\u016c\u016e'
u'\u0170\u0172\u0174\u0176\u0178-\u0179\u017b\u017d\u0181-\u0182'
u'\u0184\u0186-\u0187\u0189-\u018b\u018e-\u0191\u0193-\u0194'
u'\u0196-\u0198\u019c-\u019d\u019f-\u01a0\u01a2\u01a4\u01a6-\u01a7'
u'\u01a9\u01ac\u01ae-\u01af\u01b1-\u01b3\u01b5\u01b7-\u01b8\u01bc'
u'\u01c4\u01c7\u01ca\u01cd\u01cf\u01d1\u01d3\u01d5\u01d7\u01d9'
u'\u01db\u01de\u01e0\u01e2\u01e4\u01e6\u01e8\u01ea\u01ec\u01ee'
u'\u01f1\u01f4\u01f6-\u01f8\u01fa\u01fc\u01fe\u0200\u0202\u0204'
u'\u0206\u0208\u020a\u020c\u020e\u0210\u0212\u0214\u0216\u0218'
u'\u021a\u021c\u021e\u0220\u0222\u0224\u0226\u0228\u022a\u022c'
u'\u022e\u0230\u0232\u023a-\u023b\u023d-\u023e\u0241\u0243-\u0246'
u'\u0248\u024a\u024c\u024e\u0370\u0372\u0376\u0386\u0388-\u038f'
u'\u0391-\u03ab\u03cf\u03d2-\u03d4\u03d8\u03da\u03dc\u03de\u03e0'
u'\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7'
u'\u03f9-\u03fa\u03fd-\u042f\u0460\u0462\u0464\u0466\u0468\u046a'
u'\u046c\u046e\u0470\u0472\u0474\u0476\u0478\u047a\u047c\u047e'
u'\u0480\u048a\u048c\u048e\u0490\u0492\u0494\u0496\u0498\u049a'
u'\u049c\u049e\u04a0\u04a2\u04a4\u04a6\u04a8\u04aa\u04ac\u04ae'
u'\u04b0\u04b2\u04b4\u04b6\u04b8\u04ba\u04bc\u04be\u04c0-\u04c1'
u'\u04c3\u04c5\u04c7\u04c9\u04cb\u04cd\u04d0\u04d2\u04d4\u04d6'
u'\u04d8\u04da\u04dc\u04de\u04e0\u04e2\u04e4\u04e6\u04e8\u04ea'
u'\u04ec\u04ee\u04f0\u04f2\u04f4\u04f6\u04f8\u04fa\u04fc\u04fe'
u'\u0500\u0502\u0504\u0506\u0508\u050a\u050c\u050e\u0510\u0512'
u'\u0514\u0516\u0518\u051a\u051c\u051e\u0520\u0522\u0531-\u0556'
u'\u10a0-\u10c5\u1e00\u1e02\u1e04\u1e06\u1e08\u1e0a\u1e0c\u1e0e'
u'\u1e10\u1e12\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1e1e\u1e20\u1e22'
u'\u1e24\u1e26\u1e28\u1e2a\u1e2c\u1e2e\u1e30\u1e32\u1e34\u1e36'
u'\u1e38\u1e3a\u1e3c\u1e3e\u1e40\u1e42\u1e44\u1e46\u1e48\u1e4a'
u'\u1e4c\u1e4e\u1e50\u1e52\u1e54\u1e56\u1e58\u1e5a\u1e5c\u1e5e'
u'\u1e60\u1e62\u1e64\u1e66\u1e68\u1e6a\u1e6c\u1e6e\u1e70\u1e72'
u'\u1e74\u1e76\u1e78\u1e7a\u1e7c\u1e7e\u1e80\u1e82\u1e84\u1e86'
u'\u1e88\u1e8a\u1e8c\u1e8e\u1e90\u1e92\u1e94\u1e9e\u1ea0\u1ea2'
u'\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6'
u'\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6\u1ec8\u1eca'
u'\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede'
u'\u1ee0\u1ee2\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0\u1ef2'
u'\u1ef4\u1ef6\u1ef8\u1efa\u1efc\u1efe\u1f08-\u1f0f\u1f18-\u1f1d'
u'\u1f28-\u1f2f\u1f38-\u1f3f\u1f48-\u1f4d\u1f59-\u1f5f'
u'\u1f68-\u1f6f\u1fb8-\u1fbb\u1fc8-\u1fcb\u1fd8-\u1fdb'
u'\u1fe8-\u1fec\u1ff8-\u1ffb\u2102\u2107\u210b-\u210d\u2110-\u2112'
u'\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u2130-\u2133'
u'\u213e-\u213f\u2145\u2183\u2c00-\u2c2e\u2c60\u2c62-\u2c64\u2c67'
u'\u2c69\u2c6b\u2c6d-\u2c6f\u2c72\u2c75\u2c80\u2c82\u2c84\u2c86'
u'\u2c88\u2c8a\u2c8c\u2c8e\u2c90\u2c92\u2c94\u2c96\u2c98\u2c9a'
u'\u2c9c\u2c9e\u2ca0\u2ca2\u2ca4\u2ca6\u2ca8\u2caa\u2cac\u2cae'
u'\u2cb0\u2cb2\u2cb4\u2cb6\u2cb8\u2cba\u2cbc\u2cbe\u2cc0\u2cc2'
u'\u2cc4\u2cc6\u2cc8\u2cca\u2ccc\u2cce\u2cd0\u2cd2\u2cd4\u2cd6'
u'\u2cd8\u2cda\u2cdc\u2cde\u2ce0\u2ce2\ua640\ua642\ua644\ua646'
u'\ua648\ua64a\ua64c\ua64e\ua650\ua652\ua654\ua656\ua658\ua65a'
u'\ua65c\ua65e\ua662\ua664\ua666\ua668\ua66a\ua66c\ua680\ua682'
u'\ua684\ua686\ua688\ua68a\ua68c\ua68e\ua690\ua692\ua694\ua696'
u'\ua722\ua724\ua726\ua728\ua72a\ua72c\ua72e\ua732\ua734\ua736'
u'\ua738\ua73a\ua73c\ua73e\ua740\ua742\ua744\ua746\ua748\ua74a'
u'\ua74c\ua74e\ua750\ua752\ua754\ua756\ua758\ua75a\ua75c\ua75e'
u'\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b'
u'\ua77d-\ua77e\ua780\ua782\ua784\ua786\ua78b\uff21-\uff3a]')
idrest = u'%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op)
letter_letter_digit = u'%s(?:%s|\d)*' % (letter, letter)
tokens = {
'root': [
# method names
(r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'),
(u"'%s" % idrest, Text.Symbol),
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*', Comment.Multiline, 'comment'),
(u'@%s' % idrest, Name.Decorator),
(u'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|'
u'f(?:inal(?:ly)?|or(?:Some)?)|i(?:f|mplicit)|'
u'lazy|match|new|override|pr(?:ivate|otected)'
u'|re(?:quires|turn)|s(?:ealed|uper)|'
u't(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\\b|'
u'(<[%:-]|=>|>:|[#=@_\u21D2\u2190])(\\b|(?=\\s)|$)', Keyword),
(u':(?!%s)' % op, Keyword, 'type'),
(u'%s%s\\b' % (upper, idrest), Name.Class),
(r'(true|false|null)\b', Keyword.Constant),
(r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
(r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
(r'""".*?"""(?!")', String),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
(r'[fs]"""', String, 'interptriplestring'), # interpolated strings
(r'[fs]"', String, 'interpstring'), # interpolated strings
(r'raw"(\\\\|\\"|[^"])*"', String), # raw strings
# (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
# Name.Attribute)),
(idrest, Name),
(r'`[^`]+`', Name),
(r'\[', Operator, 'typeparam'),
(r'[(){};,.#]', Operator),
(op, Operator),
(r'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?',
Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+L?', Number.Integer),
(r'\n', Text)
],
'class': [
(u'(%s|%s|`[^`]+`)(\\s*)(\\[)' % (idrest, op),
bygroups(Name.Class, Text, Operator), 'typeparam'),
(r'\s+', Text),
(r'\{', Operator, '#pop'),
(r'\(', Operator, '#pop'),
(r'//.*?\n', Comment.Single, '#pop'),
(u'%s|%s|`[^`]+`' % (idrest, op), Name.Class, '#pop'),
],
'type': [
(r'\s+', Text),
(r'<[%:]|>:|[#_]|forSome|type', Keyword),
(u'([,);}]|=>|=|\u21d2)(\\s*)', bygroups(Operator, Text), '#pop'),
(r'[({]', Operator, '#push'),
(u'((?:%s|%s|`[^`]+`)(?:\\.(?:%s|%s|`[^`]+`))*)(\\s*)(\\[)' %
(idrest, op, idrest, op),
bygroups(Keyword.Type, Text, Operator), ('#pop', 'typeparam')),
(u'((?:%s|%s|`[^`]+`)(?:\\.(?:%s|%s|`[^`]+`))*)(\\s*)$' %
(idrest, op, idrest, op),
bygroups(Keyword.Type, Text), '#pop'),
(r'//.*?\n', Comment.Single, '#pop'),
(u'\\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
],
'typeparam': [
(r'[\s,]+', Text),
(u'<[%:]|=>|>:|[#_\u21D2]|forSome|type', Keyword),
(r'([\])}])', Operator, '#pop'),
(r'[(\[{]', Operator, '#push'),
(u'\\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
],
'comment': [
(r'[^/*]+', Comment.Multiline),
(r'/\*', Comment.Multiline, '#push'),
(r'\*/', Comment.Multiline, '#pop'),
(r'[*/]', Comment.Multiline)
],
'import': [
(u'(%s|\\.)+' % idrest, Name.Namespace, '#pop')
],
'interpstringcommon': [
(r'[^"$\\]+', String),
(r'\$\$', String),
(r'\$' + letter_letter_digit, String.Interpol),
(r'\$\{', String.Interpol, 'interpbrace'),
(r'\\.', String),
],
'interptriplestring': [
(r'"""(?!")', String, '#pop'),
(r'"', String),
include('interpstringcommon'),
],
'interpstring': [
(r'"', String, '#pop'),
include('interpstringcommon'),
],
'interpbrace': [
(r'\}', String.Interpol, '#pop'),
(r'\{', String.Interpol, '#push'),
include('root'),
],
}
class GosuLexer(RegexLexer):
"""
For Gosu source code.
.. versionadded:: 1.5
"""
name = 'Gosu'
aliases = ['gosu']
filenames = ['*.gs', '*.gsx', '*.gsp', '*.vark']
mimetypes = ['text/x-gosu']
flags = re.MULTILINE | re.DOTALL
tokens = {
'root': [
# method names
(r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # modifiers etc.
r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*.*?\*/', Comment.Multiline),
(r'@[a-zA-Z_][\w.]*', Name.Decorator),
(r'(in|as|typeof|statictypeof|typeis|typeas|if|else|foreach|for|'
r'index|while|do|continue|break|return|try|catch|finally|this|'
r'throw|new|switch|case|default|eval|super|outer|classpath|'
r'using)\b', Keyword),
(r'(var|delegate|construct|function|private|internal|protected|'
r'public|abstract|override|final|static|extends|transient|'
r'implements|represents|readonly)\b', Keyword.Declaration),
(r'(property\s+)(get|set)?', Keyword.Declaration),
(r'(boolean|byte|char|double|float|int|long|short|void|block)\b',
Keyword.Type),
(r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
(r'(true|false|null|NaN|Infinity)\b', Keyword.Constant),
(r'(class|interface|enhancement|enum)(\s+)([a-zA-Z_]\w*)',
bygroups(Keyword.Declaration, Text, Name.Class)),
(r'(uses)(\s+)([\w.]+\*?)',
bygroups(Keyword.Namespace, Text, Name.Namespace)),
(r'"', String, 'string'),
(r'(\??[.#])([a-zA-Z_]\w*)',
bygroups(Operator, Name.Attribute)),
(r'(:)([a-zA-Z_]\w*)',
bygroups(Operator, Name.Attribute)),
(r'[a-zA-Z_$]\w*', Name),
(r'and|or|not|[\\~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'[0-9]+', Number.Integer),
(r'\n', Text)
],
'templateText': [
(r'(\\<)|(\\\$)', String),
(r'(<%@\s+)(extends|params)',
bygroups(Operator, Name.Decorator), 'stringTemplate'),
(r'<%!--.*?--%>', Comment.Multiline),
(r'(<%)|(<%=)', Operator, 'stringTemplate'),
(r'\$\{', Operator, 'stringTemplateShorthand'),
(r'.', String)
],
'string': [
(r'"', String, '#pop'),
include('templateText')
],
'stringTemplate': [
(r'"', String, 'string'),
(r'%>', Operator, '#pop'),
include('root')
],
'stringTemplateShorthand': [
(r'"', String, 'string'),
(r'\{', Operator, 'stringTemplateShorthand'),
(r'\}', Operator, '#pop'),
include('root')
],
}
class GosuTemplateLexer(Lexer):
"""
For Gosu templates.
.. versionadded:: 1.5
"""
name = 'Gosu Template'
aliases = ['gst']
filenames = ['*.gst']
mimetypes = ['text/x-gosu-template']
def get_tokens_unprocessed(self, text):
lexer = GosuLexer()
stack = ['templateText']
for item in lexer.get_tokens_unprocessed(text, stack):
yield item
class GroovyLexer(RegexLexer):
"""
For `Groovy <http://groovy.codehaus.org/>`_ source code.
.. versionadded:: 1.5
"""
name = 'Groovy'
aliases = ['groovy']
filenames = ['*.groovy']
mimetypes = ['text/x-groovy']
flags = re.MULTILINE | re.DOTALL
tokens = {
'root': [
# Groovy allows a file to start with a shebang
(r'#!(.*?)$', Comment.Preproc, 'base'),
default('base'),
],
'base': [
# method names
(r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*.*?\*/', Comment.Multiline),
(r'@[a-zA-Z_][\w.]*', Name.Decorator),
(r'(assert|break|case|catch|continue|default|do|else|finally|for|'
r'if|goto|instanceof|new|return|switch|this|throw|try|while|in|as)\b',
Keyword),
(r'(abstract|const|enum|extends|final|implements|native|private|'
r'protected|public|static|strictfp|super|synchronized|throws|'
r'transient|volatile)\b', Keyword.Declaration),
(r'(def|boolean|byte|char|double|float|int|long|short|void)\b',
Keyword.Type),
(r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
(r'(true|false|null)\b', Keyword.Constant),
(r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text),
'class'),
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'""".*?"""', String.Double),
(r"'''.*?'''", String.Single),
(r'"(\\\\|\\"|[^"])*"', String.Double),
(r"'(\\\\|\\'|[^'])*'", String.Single),
(r'\$/((?!/\$).)*/\$', String),
(r'/(\\\\|\\"|[^/])*/', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
(r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
(r'[a-zA-Z_]\w*:', Name.Label),
(r'[a-zA-Z_$]\w*', Name),
(r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+L?', Number.Integer),
(r'\n', Text)
],
'class': [
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[\w.]+\*?', Name.Namespace, '#pop')
],
}
def analyse_text(text):
return shebang_matches(text, r'groovy')
class IokeLexer(RegexLexer):
"""
For `Ioke <http://ioke.org/>`_ (a strongly typed, dynamic,
prototype based programming language) source.
.. versionadded:: 1.4
"""
name = 'Ioke'
filenames = ['*.ik']
aliases = ['ioke', 'ik']
mimetypes = ['text/x-iokesrc']
tokens = {
'interpolatableText': [
(r'(\\b|\\e|\\t|\\n|\\f|\\r|\\"|\\\\|\\#|\\\Z|\\u[0-9a-fA-F]{1,4}'
r'|\\[0-3]?[0-7]?[0-7])', String.Escape),
(r'#\{', Punctuation, 'textInterpolationRoot')
],
'text': [
(r'(?<!\\)"', String, '#pop'),
include('interpolatableText'),
(r'[^"]', String)
],
'documentation': [
(r'(?<!\\)"', String.Doc, '#pop'),
include('interpolatableText'),
(r'[^"]', String.Doc)
],
'textInterpolationRoot': [
(r'\}', Punctuation, '#pop'),
include('root')
],
'slashRegexp': [
(r'(?<!\\)/[oxpniums]*', String.Regex, '#pop'),
include('interpolatableText'),
(r'\\/', String.Regex),
(r'[^/]', String.Regex)
],
'squareRegexp': [
(r'(?<!\\)][oxpniums]*', String.Regex, '#pop'),
include('interpolatableText'),
(r'\\]', String.Regex),
(r'[^\]]', String.Regex)
],
'squareText': [
(r'(?<!\\)]', String, '#pop'),
include('interpolatableText'),
(r'[^\]]', String)
],
'root': [
(r'\n', Text),
(r'\s+', Text),
# Comments
(r';(.*?)\n', Comment),
(r'\A#!(.*?)\n', Comment),
# Regexps
(r'#/', String.Regex, 'slashRegexp'),
(r'#r\[', String.Regex, 'squareRegexp'),
# Symbols
(r':[\w!:?]+', String.Symbol),
(r'[\w!:?]+:(?![\w!?])', String.Other),
(r':"(\\\\|\\"|[^"])*"', String.Symbol),
# Documentation
(r'((?<=fn\()|(?<=fnx\()|(?<=method\()|(?<=macro\()|(?<=lecro\()'
r'|(?<=syntax\()|(?<=dmacro\()|(?<=dlecro\()|(?<=dlecrox\()'
r'|(?<=dsyntax\())\s*"', String.Doc, 'documentation'),
# Text
(r'"', String, 'text'),
(r'#\[', String, 'squareText'),
# Mimic
(r'\w[\w!:?]+(?=\s*=.*mimic\s)', Name.Entity),
# Assignment
(r'[a-zA-Z_][\w!:?]*(?=[\s]*[+*/-]?=[^=].*($|\.))',
Name.Variable),
# keywords
(r'(break|cond|continue|do|ensure|for|for:dict|for:set|if|let|'
r'loop|p:for|p:for:dict|p:for:set|return|unless|until|while|'
r'with)(?![\w!:?])', Keyword.Reserved),
# Origin
(r'(eval|mimic|print|println)(?![\w!:?])', Keyword),
# Base
(r'(cell\?|cellNames|cellOwner\?|cellOwner|cells|cell|'
r'documentation|hash|identity|mimic|removeCell\!|undefineCell\!)'
r'(?![\w!:?])', Keyword),
# Ground
(r'(stackTraceAsText)(?![\w!:?])', Keyword),
# DefaultBehaviour Literals
(r'(dict|list|message|set)(?![\w!:?])', Keyword.Reserved),
# DefaultBehaviour Case
(r'(case|case:and|case:else|case:nand|case:nor|case:not|case:or|'
r'case:otherwise|case:xor)(?![\w!:?])', Keyword.Reserved),
# DefaultBehaviour Reflection
(r'(asText|become\!|derive|freeze\!|frozen\?|in\?|is\?|kind\?|'
r'mimic\!|mimics|mimics\?|prependMimic\!|removeAllMimics\!|'
r'removeMimic\!|same\?|send|thaw\!|uniqueHexId)'
r'(?![\w!:?])', Keyword),
# DefaultBehaviour Aspects
(r'(after|around|before)(?![\w!:?])', Keyword.Reserved),
# DefaultBehaviour
(r'(kind|cellDescriptionDict|cellSummary|genSym|inspect|notice)'
r'(?![\w!:?])', Keyword),
(r'(use|destructuring)', Keyword.Reserved),
# DefaultBehavior BaseBehavior
(r'(cell\?|cellOwner\?|cellOwner|cellNames|cells|cell|'
r'documentation|identity|removeCell!|undefineCell)'
r'(?![\w!:?])', Keyword),
# DefaultBehavior Internal
(r'(internal:compositeRegexp|internal:concatenateText|'
r'internal:createDecimal|internal:createNumber|'
r'internal:createRegexp|internal:createText)'
r'(?![\w!:?])', Keyword.Reserved),
# DefaultBehaviour Conditions
(r'(availableRestarts|bind|error\!|findRestart|handle|'
r'invokeRestart|rescue|restart|signal\!|warn\!)'
r'(?![\w!:?])', Keyword.Reserved),
# constants
(r'(nil|false|true)(?![\w!:?])', Name.Constant),
# names
(r'(Arity|Base|Call|Condition|DateTime|Aspects|Pointcut|'
r'Assignment|BaseBehavior|Boolean|Case|AndCombiner|Else|'
r'NAndCombiner|NOrCombiner|NotCombiner|OrCombiner|XOrCombiner|'
r'Conditions|Definitions|FlowControl|Internal|Literals|'
r'Reflection|DefaultMacro|DefaultMethod|DefaultSyntax|Dict|'
r'FileSystem|Ground|Handler|Hook|IO|IokeGround|Struct|'
r'LexicalBlock|LexicalMacro|List|Message|Method|Mixins|'
r'NativeMethod|Number|Origin|Pair|Range|Reflector|Regexp Match|'
r'Regexp|Rescue|Restart|Runtime|Sequence|Set|Symbol|'
r'System|Text|Tuple)(?![\w!:?])', Name.Builtin),
# functions
(u'(generateMatchMethod|aliasMethod|\u03bb|\u028E|fnx|fn|method|'
u'dmacro|dlecro|syntax|macro|dlecrox|lecrox|lecro|syntax)'
u'(?![\w!:?])', Name.Function),
# Numbers
(r'-?0[xX][0-9a-fA-F]+', Number.Hex),
(r'-?(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
(r'-?\d+', Number.Integer),
(r'#\(', Punctuation),
# Operators
(r'(&&>>|\|\|>>|\*\*>>|:::|::|\.\.\.|===|\*\*>|\*\*=|&&>|&&=|'
r'\|\|>|\|\|=|\->>|\+>>|!>>|<>>>|<>>|&>>|%>>|#>>|@>>|/>>|\*>>|'
r'\?>>|\|>>|\^>>|~>>|\$>>|=>>|<<=|>>=|<=>|<\->|=~|!~|=>|\+\+|'
r'\-\-|<=|>=|==|!=|&&|\.\.|\+=|\-=|\*=|\/=|%=|&=|\^=|\|=|<\-|'
r'\+>|!>|<>|&>|%>|#>|\@>|\/>|\*>|\?>|\|>|\^>|~>|\$>|<\->|\->|'
r'<<|>>|\*\*|\?\||\?&|\|\||>|<|\*|\/|%|\+|\-|&|\^|\||=|\$|!|~|'
u'\\?|#|\u2260|\u2218|\u2208|\u2209)', Operator),
(r'(and|nand|or|xor|nor|return|import)(?![\w!?])',
Operator),
# Punctuation
(r'(\`\`|\`|\'\'|\'|\.|\,|@@|@|\[|\]|\(|\)|\{|\})', Punctuation),
# kinds
(r'[A-Z][\w!:?]*', Name.Class),
# default cellnames
(r'[a-z_][\w!:?]*', Name)
]
}
class ClojureLexer(RegexLexer):
"""
Lexer for `Clojure <http://clojure.org/>`_ source code.
.. versionadded:: 0.11
"""
name = 'Clojure'
aliases = ['clojure', 'clj']
filenames = ['*.clj']
mimetypes = ['text/x-clojure', 'application/x-clojure']
special_forms = (
'.', 'def', 'do', 'fn', 'if', 'let', 'new', 'quote', 'var', 'loop'
)
# It's safe to consider 'ns' a declaration thing because it defines a new
# namespace.
declarations = (
'def-', 'defn', 'defn-', 'defmacro', 'defmulti', 'defmethod',
'defstruct', 'defonce', 'declare', 'definline', 'definterface',
'defprotocol', 'defrecord', 'deftype', 'defproject', 'ns'
)
builtins = (
'*', '+', '-', '->', '/', '<', '<=', '=', '==', '>', '>=', '..',
'accessor', 'agent', 'agent-errors', 'aget', 'alength', 'all-ns',
'alter', 'and', 'append-child', 'apply', 'array-map', 'aset',
'aset-boolean', 'aset-byte', 'aset-char', 'aset-double', 'aset-float',
'aset-int', 'aset-long', 'aset-short', 'assert', 'assoc', 'await',
'await-for', 'bean', 'binding', 'bit-and', 'bit-not', 'bit-or',
'bit-shift-left', 'bit-shift-right', 'bit-xor', 'boolean', 'branch?',
'butlast', 'byte', 'cast', 'char', 'children', 'class',
'clear-agent-errors', 'comment', 'commute', 'comp', 'comparator',
'complement', 'concat', 'conj', 'cons', 'constantly', 'cond', 'if-not',
'construct-proxy', 'contains?', 'count', 'create-ns', 'create-struct',
'cycle', 'dec', 'deref', 'difference', 'disj', 'dissoc', 'distinct',
'doall', 'doc', 'dorun', 'doseq', 'dosync', 'dotimes', 'doto',
'double', 'down', 'drop', 'drop-while', 'edit', 'end?', 'ensure',
'eval', 'every?', 'false?', 'ffirst', 'file-seq', 'filter', 'find',
'find-doc', 'find-ns', 'find-var', 'first', 'float', 'flush', 'for',
'fnseq', 'frest', 'gensym', 'get-proxy-class', 'get',
'hash-map', 'hash-set', 'identical?', 'identity', 'if-let', 'import',
'in-ns', 'inc', 'index', 'insert-child', 'insert-left', 'insert-right',
'inspect-table', 'inspect-tree', 'instance?', 'int', 'interleave',
'intersection', 'into', 'into-array', 'iterate', 'join', 'key', 'keys',
'keyword', 'keyword?', 'last', 'lazy-cat', 'lazy-cons', 'left',
'lefts', 'line-seq', 'list*', 'list', 'load', 'load-file',
'locking', 'long', 'loop', 'macroexpand', 'macroexpand-1',
'make-array', 'make-node', 'map', 'map-invert', 'map?', 'mapcat',
'max', 'max-key', 'memfn', 'merge', 'merge-with', 'meta', 'min',
'min-key', 'name', 'namespace', 'neg?', 'new', 'newline', 'next',
'nil?', 'node', 'not', 'not-any?', 'not-every?', 'not=', 'ns-imports',
'ns-interns', 'ns-map', 'ns-name', 'ns-publics', 'ns-refers',
'ns-resolve', 'ns-unmap', 'nth', 'nthrest', 'or', 'parse', 'partial',
'path', 'peek', 'pop', 'pos?', 'pr', 'pr-str', 'print', 'print-str',
'println', 'println-str', 'prn', 'prn-str', 'project', 'proxy',
'proxy-mappings', 'quot', 'rand', 'rand-int', 'range', 're-find',
're-groups', 're-matcher', 're-matches', 're-pattern', 're-seq',
'read', 'read-line', 'reduce', 'ref', 'ref-set', 'refer', 'rem',
'remove', 'remove-method', 'remove-ns', 'rename', 'rename-keys',
'repeat', 'replace', 'replicate', 'resolve', 'rest', 'resultset-seq',
'reverse', 'rfirst', 'right', 'rights', 'root', 'rrest', 'rseq',
'second', 'select', 'select-keys', 'send', 'send-off', 'seq',
'seq-zip', 'seq?', 'set', 'short', 'slurp', 'some', 'sort',
'sort-by', 'sorted-map', 'sorted-map-by', 'sorted-set',
'special-symbol?', 'split-at', 'split-with', 'str', 'string?',
'struct', 'struct-map', 'subs', 'subvec', 'symbol', 'symbol?',
'sync', 'take', 'take-nth', 'take-while', 'test', 'time', 'to-array',
'to-array-2d', 'tree-seq', 'true?', 'union', 'up', 'update-proxy',
'val', 'vals', 'var-get', 'var-set', 'var?', 'vector', 'vector-zip',
'vector?', 'when', 'when-first', 'when-let', 'when-not',
'with-local-vars', 'with-meta', 'with-open', 'with-out-str',
'xml-seq', 'xml-zip', 'zero?', 'zipmap', 'zipper')
# valid names for identifiers
# well, names can only not consist fully of numbers
# but this should be good enough for now
# TODO / should divide keywords/symbols into namespace/rest
# but that's hard, so just pretend / is part of the name
valid_name = r'(?!#)[\w!$%*+<=>?/.#-]+'
tokens = {
'root': [
# the comments - always starting with semicolon
# and going to the end of the line
(r';.*$', Comment.Single),
# whitespaces - usually not relevant
(r'[,\s]+', Text),
# numbers
(r'-?\d+\.\d+', Number.Float),
(r'-?\d+', Number.Integer),
(r'0x-?[abcdef\d]+', Number.Hex),
# strings, symbols and characters
(r'"(\\\\|\\"|[^"])*"', String),
(r"'" + valid_name, String.Symbol),
(r"\\(.|[a-z]+)", String.Char),
# keywords
(r'::?#?' + valid_name, String.Symbol),
# special operators
(r'~@|[`\'#^~&@]', Operator),
# highlight the special forms
(words(special_forms, suffix=' '), Keyword),
# Technically, only the special forms are 'keywords'. The problem
# is that only treating them as keywords means that things like
# 'defn' and 'ns' need to be highlighted as builtins. This is ugly
# and weird for most styles. So, as a compromise we're going to
# highlight them as Keyword.Declarations.
(words(declarations, suffix=' '), Keyword.Declaration),
# highlight the builtins
(words(builtins, suffix=' '), Name.Builtin),
# the remaining functions
(r'(?<=\()' + valid_name, Name.Function),
# find the remaining variables
(valid_name, Name.Variable),
# Clojure accepts vector notation
(r'(\[|\])', Punctuation),
# Clojure accepts map notation
(r'(\{|\})', Punctuation),
# the famous parentheses!
(r'(\(|\))', Punctuation),
],
}
class ClojureScriptLexer(ClojureLexer):
"""
Lexer for `ClojureScript <http://clojure.org/clojurescript>`_
source code.
.. versionadded:: 2.0
"""
name = 'ClojureScript'
aliases = ['clojurescript', 'cljs']
filenames = ['*.cljs']
mimetypes = ['text/x-clojurescript', 'application/x-clojurescript']
class TeaLangLexer(RegexLexer):
"""
For `Tea <http://teatrove.org/>`_ source code. Only used within a
TeaTemplateLexer.
.. versionadded:: 1.5
"""
flags = re.MULTILINE | re.DOTALL
tokens = {
'root': [
# method names
(r'^(\s*(?:[a-zA-Z_][\w\.\[\]]*\s+)+?)' # return arguments
r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*.*?\*/', Comment.Multiline),
(r'@[a-zA-Z_][\w\.]*', Name.Decorator),
(r'(and|break|else|foreach|if|in|not|or|reverse)\b',
Keyword),
(r'(as|call|define)\b', Keyword.Declaration),
(r'(true|false|null)\b', Keyword.Constant),
(r'(template)(\s+)', bygroups(Keyword.Declaration, Text), 'template'),
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'"(\\\\|\\"|[^"])*"', String),
(r'\'(\\\\|\\\'|[^\'])*\'', String),
(r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
(r'[a-zA-Z_]\w*:', Name.Label),
(r'[a-zA-Z_\$]\w*', Name),
(r'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+L?', Number.Integer),
(r'\n', Text)
],
'template': [
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[\w.]+\*?', Name.Namespace, '#pop')
],
}
class CeylonLexer(RegexLexer):
"""
For `Ceylon <http://ceylon-lang.org/>`_ source code.
.. versionadded:: 1.6
"""
name = 'Ceylon'
aliases = ['ceylon']
filenames = ['*.ceylon']
mimetypes = ['text/x-ceylon']
flags = re.MULTILINE | re.DOTALL
#: optional Comment or Whitespace
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
tokens = {
'root': [
# method names
(r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*', Comment.Multiline, 'comment'),
(r'(variable|shared|abstract|doc|by|formal|actual|late|native)',
Name.Decorator),
(r'(break|case|catch|continue|default|else|finally|for|in|'
r'variable|if|return|switch|this|throw|try|while|is|exists|dynamic|'
r'nonempty|then|outer|assert)\b', Keyword),
(r'(abstracts|extends|satisfies|adapts|'
r'super|given|of|out|assign|'
r'transient|volatile)\b', Keyword.Declaration),
(r'(function|value|void)\b',
Keyword.Type),
(r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
(r'(true|false|null)\b', Keyword.Constant),
(r'(class|interface|object|alias)(\s+)',
bygroups(Keyword.Declaration, Text), 'class'),
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'", String.Char),
(r'".*``.*``.*"', String.Interpol),
(r'(\.)([a-z_]\w*)',
bygroups(Operator, Name.Attribute)),
(r'[a-zA-Z_]\w*:', Name.Label),
(r'[a-zA-Z_]\w*', Name),
(r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
(r'\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
(r'\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
Number.Float),
(r'[0-9][0-9]*\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
(r'[0-9][0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
Number.Float),
(r'#([0-9a-fA-F]{4})(_[0-9a-fA-F]{4})+', Number.Hex),
(r'#[0-9a-fA-F]+', Number.Hex),
(r'\$([01]{4})(_[01]{4})+', Number.Bin),
(r'\$[01]+', Number.Bin),
(r'\d{1,3}(_\d{3})+[kMGTP]?', Number.Integer),
(r'[0-9]+[kMGTP]?', Number.Integer),
(r'\n', Text)
],
'class': [
(r'[A-Za-z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[a-z][\w.]*',
Name.Namespace, '#pop')
],
'comment': [
(r'[^*/]', Comment.Multiline),
(r'/\*', Comment.Multiline, '#push'),
(r'\*/', Comment.Multiline, '#pop'),
(r'[*/]', Comment.Multiline)
],
}
class KotlinLexer(RegexLexer):
"""
For `Kotlin <http://kotlin.jetbrains.org/>`_
source code.
.. versionadded:: 1.5
"""
name = 'Kotlin'
aliases = ['kotlin']
filenames = ['*.kt']
mimetypes = ['text/x-kotlin']
flags = re.MULTILINE | re.DOTALL | re.UNICODE
kt_name = ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' +
'[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc', 'Cf',
'Mn', 'Mc') + ']*')
kt_id = '(' + kt_name + '|`' + kt_name + '`)'
tokens = {
'root': [
(r'^\s*\[.*?\]', Name.Attribute),
(r'[^\S\n]+', Text),
(r'\\\n', Text), # line continuation
(r'//.*?\n', Comment.Single),
(r'/[*].*?[*]/', Comment.Multiline),
(r'\n', Text),
(r'::|!!|\?[:.]', Operator),
(r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
(r'[{}]', Punctuation),
(r'@"(""|[^"])*"', String),
(r'"(\\\\|\\"|[^"\n])*["\n]', String),
(r"'\\.'|'[^\\]'", String.Char),
(r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFL]?|"
r"0[xX][0-9a-fA-F]+[Ll]?", Number),
(r'(class)(\s+)(object)', bygroups(Keyword, Text, Keyword)),
(r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'),
(r'(package|import)(\s+)', bygroups(Keyword, Text), 'package'),
(r'(val|var)(\s+)', bygroups(Keyword, Text), 'property'),
(r'(fun)(\s+)', bygroups(Keyword, Text), 'function'),
(r'(abstract|annotation|as|break|by|catch|class|continue|do|else|'
r'enum|false|final|finally|for|fun|get|if|import|in|inner|'
r'internal|is|null|object|open|out|override|package|private|'
r'protected|public|reified|return|set|super|this|throw|trait|'
r'true|try|type|val|var|vararg|when|where|while|This)\b', Keyword),
(kt_id, Name),
],
'package': [
(r'\S+', Name.Namespace, '#pop')
],
'class': [
(kt_id, Name.Class, '#pop')
],
'property': [
(kt_id, Name.Property, '#pop')
],
'function': [
(kt_id, Name.Function, '#pop')
],
}
class XtendLexer(RegexLexer):
"""
For `Xtend <http://xtend-lang.org/>`_ source code.
.. versionadded:: 1.6
"""
name = 'Xtend'
aliases = ['xtend']
filenames = ['*.xtend']
mimetypes = ['text/x-xtend']
flags = re.MULTILINE | re.DOTALL
tokens = {
'root': [
# method names
(r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
r'([a-zA-Z_$][\w$]*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*.*?\*/', Comment.Multiline),
(r'@[a-zA-Z_][\w.]*', Name.Decorator),
(r'(assert|break|case|catch|continue|default|do|else|finally|for|'
r'if|goto|instanceof|new|return|switch|this|throw|try|while|IF|'
r'ELSE|ELSEIF|ENDIF|FOR|ENDFOR|SEPARATOR|BEFORE|AFTER)\b',
Keyword),
(r'(def|abstract|const|enum|extends|final|implements|native|private|'
r'protected|public|static|strictfp|super|synchronized|throws|'
r'transient|volatile)\b', Keyword.Declaration),
(r'(boolean|byte|char|double|float|int|long|short|void)\b',
Keyword.Type),
(r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
(r'(true|false|null)\b', Keyword.Constant),
(r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text),
'class'),
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r"(''')", String, 'template'),
(u'(\u00BB)', String, 'template'),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'(\\\\|\\'|[^'])*'", String),
(r'[a-zA-Z_]\w*:', Name.Label),
(r'[a-zA-Z_$]\w*', Name),
(r'[~^*!%&\[\](){}<>\|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+L?', Number.Integer),
(r'\n', Text)
],
'class': [
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[\w.]+\*?', Name.Namespace, '#pop')
],
'template': [
(r"'''", String, '#pop'),
(u'\u00AB', String, '#pop'),
(r'.', String)
],
}
class PigLexer(RegexLexer):
"""
For `Pig Latin <https://pig.apache.org/>`_ source code.
.. versionadded:: 2.0
"""
name = 'Pig'
aliases = ['pig']
filenames = ['*.pig']
mimetypes = ['text/x-pig']
flags = re.MULTILINE | re.IGNORECASE
tokens = {
'root': [
(r'\s+', Text),
(r'--.*', Comment),
(r'/\*[\w\W]*?\*/', Comment.Multiline),
(r'\\\n', Text),
(r'\\', Text),
(r'\'(?:\\[ntbrf\\\']|\\u[0-9a-f]{4}|[^\'\\\n\r])*\'', String),
include('keywords'),
include('types'),
include('builtins'),
include('punct'),
include('operators'),
(r'[0-9]*\.[0-9]+(e[0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-f]+', Number.Hex),
(r'[0-9]+L?', Number.Integer),
(r'\n', Text),
(r'([a-z_]\w*)(\s*)(\()',
bygroups(Name.Function, Text, Punctuation)),
(r'[()#:]', Text),
(r'[^(:#\'")\s]+', Text),
(r'\S+\s+', Text) # TODO: make tests pass without \s+
],
'keywords': [
(r'(assert|and|any|all|arrange|as|asc|bag|by|cache|CASE|cat|cd|cp|'
r'%declare|%default|define|dense|desc|describe|distinct|du|dump|'
r'eval|exex|explain|filter|flatten|foreach|full|generate|group|'
r'help|if|illustrate|import|inner|input|into|is|join|kill|left|'
r'limit|load|ls|map|matches|mkdir|mv|not|null|onschema|or|order|'
r'outer|output|parallel|pig|pwd|quit|register|returns|right|rm|'
r'rmf|rollup|run|sample|set|ship|split|stderr|stdin|stdout|store|'
r'stream|through|union|using|void)\b', Keyword)
],
'builtins': [
(r'(AVG|BinStorage|cogroup|CONCAT|copyFromLocal|copyToLocal|COUNT|'
r'cross|DIFF|MAX|MIN|PigDump|PigStorage|SIZE|SUM|TextLoader|'
r'TOKENIZE)\b', Name.Builtin)
],
'types': [
(r'(bytearray|BIGINTEGER|BIGDECIMAL|chararray|datetime|double|float|'
r'int|long|tuple)\b', Keyword.Type)
],
'punct': [
(r'[;(){}\[\]]', Punctuation),
],
'operators': [
(r'[#=,./%+\-?]', Operator),
(r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
(r'(==|<=|<|>=|>|!=)', Operator),
],
}
class GoloLexer(RegexLexer):
"""
For `Golo <http://golo-lang.org/>`_ source code.
.. versionadded:: 2.0
"""
name = 'Golo'
filenames = ['*.golo']
aliases = ['golo']
tokens = {
'root': [
(r'[^\S\n]+', Text),
(r'#.*$', Comment),
(r'(\^|\.\.\.|:|\?:|->|==|!=|=|\+|\*|%|/|<=|<|>=|>|=|\.)',
Operator),
(r'(?<=[^-])(-)(?=[^-])', Operator),
(r'(?<=[^`])(is|isnt|and|or|not|oftype|in|orIfNull)\b', Operator.Word),
(r'[]{}|(),[]', Punctuation),
(r'(module|import)(\s+)',
bygroups(Keyword.Namespace, Text),
'modname'),
(r'\b([a-zA-Z_][\w$.]*)(::)', bygroups(Name.Namespace, Punctuation)),
(r'\b([a-zA-Z_][\w$]*(?:\.[a-zA-Z_][\w$]*)+)\b', Name.Namespace),
(r'(let|var)(\s+)',
bygroups(Keyword.Declaration, Text),
'varname'),
(r'(struct)(\s+)',
bygroups(Keyword.Declaration, Text),
'structname'),
(r'(function)(\s+)',
bygroups(Keyword.Declaration, Text),
'funcname'),
(r'(null|true|false)\b', Keyword.Constant),
(r'(augment|pimp'
r'|if|else|case|match|return'
r'|case|when|then|otherwise'
r'|while|for|foreach'
r'|try|catch|finally|throw'
r'|local'
r'|continue|break)\b', Keyword),
(r'(map|array|list|set|vector|tuple)(\[)',
bygroups(Name.Builtin, Punctuation)),
(r'(print|println|readln|raise|fun'
r'|asInterfaceInstance)\b', Name.Builtin),
(r'(`?[a-zA-Z_][\w$]*)(\()',
bygroups(Name.Function, Punctuation)),
(r'-?[\d_]*\.[\d_]*([eE][+-]?\d[\d_]*)?F?', Number.Float),
(r'0[0-7]+j?', Number.Oct),
(r'0[xX][a-fA-F0-9]+', Number.Hex),
(r'-?\d[\d_]*L', Number.Integer.Long),
(r'-?\d[\d_]*', Number.Integer),
('`?[a-zA-Z_][\w$]*', Name),
(r'@[a-zA-Z_][\w$.]*', Name.Decorator),
(r'"""', String, combined('stringescape', 'triplestring')),
(r'"', String, combined('stringescape', 'doublestring')),
(r"'", String, combined('stringescape', 'singlestring')),
(r'----((.|\n)*?)----', String.Doc)
],
'funcname': [
(r'`?[a-zA-Z_][\w$]*', Name.Function, '#pop'),
],
'modname': [
(r'[a-zA-Z_][\w$.]*\*?', Name.Namespace, '#pop')
],
'structname': [
(r'`?[\w.]+\*?', Name.Class, '#pop')
],
'varname': [
(r'`?[a-zA-Z_][\w$]*', Name.Variable, '#pop'),
],
'string': [
(r'[^\\\'"\n]+', String),
(r'[\'"\\]', String)
],
'stringescape': [
(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
],
'triplestring': [
(r'"""', String, '#pop'),
include('string'),
(r'\n', String),
],
'doublestring': [
(r'"', String.Double, '#pop'),
include('string'),
],
'singlestring': [
(r"'", String, '#pop'),
include('string'),
],
'operators': [
(r'[#=,./%+\-?]', Operator),
(r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
(r'(==|<=|<|>=|>|!=)', Operator),
],
}
class JasminLexer(RegexLexer):
"""
For `Jasmin <http://jasmin.sourceforge.net/>`_ assembly code.
.. versionadded:: 2.0
"""
name = 'Jasmin'
aliases = ['jasmin', 'jasminxt']
filenames = ['*.j']
_whitespace = r' \n\t\r'
_ws = r'(?:[%s]+)' % _whitespace
_separator = r'%s:=' % _whitespace
_break = r'(?=[%s]|$)' % _separator
_name = r'[^%s]+' % _separator
_unqualified_name = r'(?:[^%s.;\[/]+)' % _separator
tokens = {
'default': [
(r'\n', Text, '#pop'),
(r"'", String.Single, ('#pop', 'quote')),
(r'"', String.Double, 'string'),
(r'=', Punctuation),
(r':', Punctuation, 'label'),
(_ws, Text),
(r';.*', Comment.Single),
(r'(\$[-+])?0x-?[\da-fA-F]+%s' % _break, Number.Hex),
(r'(\$[-+]|\+)?-?\d+%s' % _break, Number.Integer),
(r'-?(\d+\.\d*|\.\d+)([eE][-+]?\d+)?[fFdD]?'
r'[\x00-\x08\x0b\x0c\x0e-\x1f]*%s' % _break, Number.Float),
(r'\$%s' % _name, Name.Variable),
# Directives
(r'\.annotation%s' % _break, Keyword.Reserved, 'annotation'),
(r'(\.attribute|\.bytecode|\.debug|\.deprecated|\.enclosing|'
r'\.interface|\.line|\.signature|\.source|\.stack|\.var|abstract|'
r'annotation|bridge|class|default|enum|field|final|fpstrict|'
r'interface|native|private|protected|public|signature|static|'
r'synchronized|synthetic|transient|varargs|volatile)%s' % _break,
Keyword.Reserved),
(r'\.catch%s' % _break, Keyword.Reserved, 'caught-exception'),
(r'(\.class|\.implements|\.inner|\.super|inner|invisible|'
r'invisibleparam|outer|visible|visibleparam)%s' % _break,
Keyword.Reserved, 'class/convert-dots'),
(r'\.field%s' % _break, Keyword.Reserved,
('descriptor/convert-dots', 'field')),
(r'(\.end|\.limit|use)%s' % _break, Keyword.Reserved,
'no-verification'),
(r'\.method%s' % _break, Keyword.Reserved, 'method'),
(r'\.set%s' % _break, Keyword.Reserved, 'var'),
(r'\.throws%s' % _break, Keyword.Reserved, 'exception'),
(r'(from|offset|to|using)%s' % _break, Keyword.Reserved, 'label'),
(r'is%s' % _break, Keyword.Reserved,
('descriptor/convert-dots', 'var')),
(r'(locals|stack)%s' % _break, Keyword.Reserved, 'verification'),
(r'method%s' % _break, Keyword.Reserved, 'enclosing-method'),
# Instructions
(words((
'aaload', 'aastore', 'aconst_null', 'aload', 'aload_0', 'aload_1', 'aload_2',
'aload_3', 'aload_w', 'areturn', 'arraylength', 'astore', 'astore_0', 'astore_1',
'astore_2', 'astore_3', 'astore_w', 'athrow', 'baload', 'bastore', 'bipush',
'breakpoint', 'caload', 'castore', 'd2f', 'd2i', 'd2l', 'dadd', 'daload', 'dastore',
'dcmpg', 'dcmpl', 'dconst_0', 'dconst_1', 'ddiv', 'dload', 'dload_0', 'dload_1',
'dload_2', 'dload_3', 'dload_w', 'dmul', 'dneg', 'drem', 'dreturn', 'dstore', 'dstore_0',
'dstore_1', 'dstore_2', 'dstore_3', 'dstore_w', 'dsub', 'dup', 'dup2', 'dup2_x1',
'dup2_x2', 'dup_x1', 'dup_x2', 'f2d', 'f2i', 'f2l', 'fadd', 'faload', 'fastore', 'fcmpg',
'fcmpl', 'fconst_0', 'fconst_1', 'fconst_2', 'fdiv', 'fload', 'fload_0', 'fload_1',
'fload_2', 'fload_3', 'fload_w', 'fmul', 'fneg', 'frem', 'freturn', 'fstore', 'fstore_0',
'fstore_1', 'fstore_2', 'fstore_3', 'fstore_w', 'fsub', 'i2b', 'i2c', 'i2d', 'i2f', 'i2l',
'i2s', 'iadd', 'iaload', 'iand', 'iastore', 'iconst_0', 'iconst_1', 'iconst_2',
'iconst_3', 'iconst_4', 'iconst_5', 'iconst_m1', 'idiv', 'iinc', 'iinc_w', 'iload',
'iload_0', 'iload_1', 'iload_2', 'iload_3', 'iload_w', 'imul', 'ineg', 'int2byte',
'int2char', 'int2short', 'ior', 'irem', 'ireturn', 'ishl', 'ishr', 'istore', 'istore_0',
'istore_1', 'istore_2', 'istore_3', 'istore_w', 'isub', 'iushr', 'ixor', 'l2d', 'l2f',
'l2i', 'ladd', 'laload', 'land', 'lastore', 'lcmp', 'lconst_0', 'lconst_1', 'ldc2_w',
'ldiv', 'lload', 'lload_0', 'lload_1', 'lload_2', 'lload_3', 'lload_w', 'lmul', 'lneg',
'lookupswitch', 'lor', 'lrem', 'lreturn', 'lshl', 'lshr', 'lstore', 'lstore_0',
'lstore_1', 'lstore_2', 'lstore_3', 'lstore_w', 'lsub', 'lushr', 'lxor',
'monitorenter', 'monitorexit', 'nop', 'pop', 'pop2', 'ret', 'ret_w', 'return', 'saload',
'sastore', 'sipush', 'swap'), suffix=_break), Keyword.Reserved),
(r'(anewarray|checkcast|instanceof|ldc|ldc_w|new)%s' % _break,
Keyword.Reserved, 'class/no-dots'),
(r'invoke(dynamic|interface|nonvirtual|special|'
r'static|virtual)%s' % _break, Keyword.Reserved,
'invocation'),
(r'(getfield|putfield)%s' % _break, Keyword.Reserved,
('descriptor/no-dots', 'field')),
(r'(getstatic|putstatic)%s' % _break, Keyword.Reserved,
('descriptor/no-dots', 'static')),
(words((
'goto', 'goto_w', 'if_acmpeq', 'if_acmpne', 'if_icmpeq',
'if_icmpge', 'if_icmpgt', 'if_icmple', 'if_icmplt', 'if_icmpne',
'ifeq', 'ifge', 'ifgt', 'ifle', 'iflt', 'ifne', 'ifnonnull',
'ifnull', 'jsr', 'jsr_w'), suffix=_break),
Keyword.Reserved, 'label'),
(r'(multianewarray|newarray)%s' % _break, Keyword.Reserved,
'descriptor/convert-dots'),
(r'tableswitch%s' % _break, Keyword.Reserved, 'table')
],
'quote': [
(r"'", String.Single, '#pop'),
(r'\\u[\da-fA-F]{4}', String.Escape),
(r"[^'\\]+", String.Single)
],
'string': [
(r'"', String.Double, '#pop'),
(r'\\([nrtfb"\'\\]|u[\da-fA-F]{4}|[0-3]?[0-7]{1,2})',
String.Escape),
(r'[^"\\]+', String.Double)
],
'root': [
(r'\n+', Text),
(r"'", String.Single, 'quote'),
include('default'),
(r'(%s)([ \t\r]*)(:)' % _name,
bygroups(Name.Label, Text, Punctuation)),
(_name, String.Other)
],
'annotation': [
(r'\n', Text, ('#pop', 'annotation-body')),
(r'default%s' % _break, Keyword.Reserved,
('#pop', 'annotation-default')),
include('default')
],
'annotation-body': [
(r'\n+', Text),
(r'\.end%s' % _break, Keyword.Reserved, '#pop'),
include('default'),
(_name, String.Other, ('annotation-items', 'descriptor/no-dots'))
],
'annotation-default': [
(r'\n+', Text),
(r'\.end%s' % _break, Keyword.Reserved, '#pop'),
include('default'),
default(('annotation-items', 'descriptor/no-dots'))
],
'annotation-items': [
(r"'", String.Single, 'quote'),
include('default'),
(_name, String.Other)
],
'caught-exception': [
(r'all%s' % _break, Keyword, '#pop'),
include('exception')
],
'class/convert-dots': [
include('default'),
(r'(L)((?:%s[/.])*)(%s)(;)' % (_unqualified_name, _name),
bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
'#pop'),
(r'((?:%s[/.])*)(%s)' % (_unqualified_name, _name),
bygroups(Name.Namespace, Name.Class), '#pop')
],
'class/no-dots': [
include('default'),
(r'\[+', Punctuation, ('#pop', 'descriptor/no-dots')),
(r'(L)((?:%s/)*)(%s)(;)' % (_unqualified_name, _name),
bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
'#pop'),
(r'((?:%s/)*)(%s)' % (_unqualified_name, _name),
bygroups(Name.Namespace, Name.Class), '#pop')
],
'descriptor/convert-dots': [
include('default'),
(r'\[+', Punctuation),
(r'(L)((?:%s[/.])*)(%s?)(;)' % (_unqualified_name, _name),
bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
'#pop'),
(r'[^%s\[)L]+' % _separator, Keyword.Type, '#pop'),
default('#pop')
],
'descriptor/no-dots': [
include('default'),
(r'\[+', Punctuation),
(r'(L)((?:%s/)*)(%s)(;)' % (_unqualified_name, _name),
bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
'#pop'),
(r'[^%s\[)L]+' % _separator, Keyword.Type, '#pop'),
default('#pop')
],
'descriptors/convert-dots': [
(r'\)', Punctuation, '#pop'),
default('descriptor/convert-dots')
],
'enclosing-method': [
(_ws, Text),
(r'(?=[^%s]*\()' % _separator, Text, ('#pop', 'invocation')),
default(('#pop', 'class/convert-dots'))
],
'exception': [
include('default'),
(r'((?:%s[/.])*)(%s)' % (_unqualified_name, _name),
bygroups(Name.Namespace, Name.Exception), '#pop')
],
'field': [
(r'static%s' % _break, Keyword.Reserved, ('#pop', 'static')),
include('default'),
(r'((?:%s[/.](?=[^%s]*[/.]))*)(%s[/.])?(%s)' %
(_unqualified_name, _separator, _unqualified_name, _name),
bygroups(Name.Namespace, Name.Class, Name.Variable.Instance),
'#pop')
],
'invocation': [
include('default'),
(r'((?:%s[/.](?=[^%s(]*[/.]))*)(%s[/.])?(%s)(\()' %
(_unqualified_name, _separator, _unqualified_name, _name),
bygroups(Name.Namespace, Name.Class, Name.Function, Punctuation),
('#pop', 'descriptor/convert-dots', 'descriptors/convert-dots',
'descriptor/convert-dots'))
],
'label': [
include('default'),
(_name, Name.Label, '#pop')
],
'method': [
include('default'),
(r'(%s)(\()' % _name, bygroups(Name.Function, Punctuation),
('#pop', 'descriptor/convert-dots', 'descriptors/convert-dots',
'descriptor/convert-dots'))
],
'no-verification': [
(r'(locals|method|stack)%s' % _break, Keyword.Reserved, '#pop'),
include('default')
],
'static': [
include('default'),
(r'((?:%s[/.](?=[^%s]*[/.]))*)(%s[/.])?(%s)' %
(_unqualified_name, _separator, _unqualified_name, _name),
bygroups(Name.Namespace, Name.Class, Name.Variable.Class), '#pop')
],
'table': [
(r'\n+', Text),
(r'default%s' % _break, Keyword.Reserved, '#pop'),
include('default'),
(_name, Name.Label)
],
'var': [
include('default'),
(_name, Name.Variable, '#pop')
],
'verification': [
include('default'),
(r'(Double|Float|Integer|Long|Null|Top|UninitializedThis)%s' %
_break, Keyword, '#pop'),
(r'Object%s' % _break, Keyword, ('#pop', 'class/no-dots')),
(r'Uninitialized%s' % _break, Keyword, ('#pop', 'label'))
]
}
def analyse_text(text):
score = 0
if re.search(r'^\s*\.class\s', text, re.MULTILINE):
score += 0.5
if re.search(r'^\s*[a-z]+_[a-z]+\b', text, re.MULTILINE):
score += 0.3
if re.search(r'^\s*\.(attribute|bytecode|debug|deprecated|enclosing|'
r'inner|interface|limit|set|signature|stack)\b', text,
re.MULTILINE):
score += 0.6
return score
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
14,
15813,
272,
18294,
23597,
339,
14493,
7103,
1192,
367,
1603,
6849,
10815,
14,
339,
520,
7307,
26,
1898,
8315,
13,
7280,
701,
314,
14493,
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,
13277,
14,
11729,
492,
21125,
12,
12939,
5838,
12,
2387,
12,
10259,
12,
1808,
12,
971,
272,
642,
12,
12149,
12,
849,
12,
5932,
199,
504,
13277,
14,
1418,
492,
4516,
12,
6819,
12,
11013,
12,
6431,
12,
2812,
12,
2624,
12,
971,
272,
4860,
12,
10357,
199,
504,
13277,
14,
1974,
492,
25591,
63,
6742,
199,
504,
13277,
492,
15439,
875,
465,
15439,
199,
199,
363,
452,
363,
275,
788,
12576,
5838,
297,
283,
10249,
65,
5838,
297,
283,
39,
736,
85,
5838,
297,
283,
39,
736,
85,
4231,
5838,
297,
1779,
283,
39,
293,
8822,
89,
5838,
297,
283,
16512,
415,
5838,
297,
283,
3337,
74,
608,
5838,
297,
283,
3337,
74,
608,
5229,
5838,
297,
1779,
283,
43,
357,
472,
5838,
297,
283,
56,
7169,
5838,
297,
283,
2822,
1764,
42,
5838,
297,
283,
35,
14655,
5298,
5838,
297,
1779,
283,
48,
528,
5838,
297,
283,
7250,
320,
5838,
297,
283,
42,
305,
827,
5838,
418,
421,
199,
533,
9586,
5838,
8,
19856,
304,
272,
408,
272,
2104,
658,
12576,
665,
1014,
921,
1544,
14,
11846,
14,
957,
15,
6138,
3133,
18417,
1350,
1233,
14,
272,
408,
339,
536,
275,
283,
12576,
7,
272,
5481,
275,
788,
6138,
418,
272,
6203,
275,
17855,
6138,
418,
272,
13290,
275,
788,
505,
15,
88,
13,
6138,
418,
339,
3285,
275,
295,
14,
16661,
1204,
295,
14,
16504,
1204,
295,
14,
12819,
339,
4645,
275,
469,
267,
283,
1231,
356,
359,
288,
334,
82,
29538,
51,
60,
78,
11529,
4516,
395,
288,
334,
82,
28866,
21040,
78,
297,
6819,
14,
7200,
395,
288,
334,
82,
32575,
10,
21040,
10,
3678,
6819,
14,
18933,
395,
288,
327,
7681,
26,
2621,
2544,
1083,
1561,
370,
5126,
7103,
316,
298,
11964,
892,
1323,
26184,
2,
288,
327,
465,
282,
1083,
4955,
288,
334,
82,
6774,
479,
92,
4785,
92,
2546,
92,
9341,
92,
6958,
92,
885,
92,
1117,
92,
2836,
92,
15172,
92,
509,
5227,
1467,
519,
7,
692,
92,
14867,
92,
842,
1618,
92,
1222,
92,
1107,
92,
5656,
92,
3749,
92,
11964,
92,
893,
92,
6710,
2862,
66,
297,
1467,
6431,
395,
288,
327,
1083,
1561,
288,
334,
82,
7,
17304,
26,
5169,
16045,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
3134,
7023,
61,
4,
16137,
25739,
83,
11,
6393,
31,
3171,
221,
327,
372,
2368,
1467,
519,
7,
17304,
26,
16045,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
3672,
3171,
8295,
327,
1083,
536,
1467,
519,
13445,
83,
10,
10127,
19633,
19242,
327,
4955,
1343,
1467,
10259,
8,
4941,
8,
3749,
395,
2812,
14,
3481,
12,
4516,
12,
11013,
1826,
288,
334,
82,
20812,
16045,
55,
60,
68,
30679,
87,
14,
22952,
2812,
14,
14946,
395,
288,
334,
82,
6774,
6198,
92,
1297,
92,
4869,
92,
11036,
92,
5094,
92,
24900,
92,
6106,
92,
4239,
5227,
1467,
519,
7,
6798,
92,
3455,
92,
1986,
92,
4768,
3997,
92,
4792,
92,
16473,
1759,
92,
32229,
5227,
1467,
519,
1133,
1312,
14928,
92,
32059,
2862,
66,
297,
6431,
14,
17737,
395,
288,
334,
82,
6774,
4871,
92,
4414,
92,
1560,
92,
3157,
92,
1609,
92,
442,
92,
2809,
92,
3612,
92,
1647,
2862,
66,
297,
1467,
6431,
14,
804,
395,
288,
334,
82,
6774,
2491,
10127,
83,
14705,
10259,
8,
10650,
14,
8814,
12,
4516,
395,
283,
646,
659,
288,
334,
82,
6774,
2052,
92,
3910,
92,
2307,
2862,
66,
297,
6431,
14,
9737,
395,
288,
334,
82,
6774,
533,
92,
3266,
10127,
83,
14705,
10259,
8,
10650,
14,
17737,
12,
4516,
395,
283,
533,
659,
288,
334,
82,
6774,
646,
10127,
83,
14705,
10259,
8,
10650,
14,
8814,
12,
4516,
395,
283,
646,
659,
288,
334,
82,
4065,
30082,
92,
15022,
23629,
3135,
10,
6949,
2624,
395,
288,
334,
82,
4507,
1103,
3530,
92,
16122,
1103,
6616,
5227,
1103,
85,
59,
16,
13,
25,
65,
13,
13753,
13,
38,
8194,
20,
93,
4662,
2624,
14,
1610,
395,
288,
334,
82,
13445,
4959,
17304,
26,
16045,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
3672,
3196,
10259,
8,
7961,
12,
2812,
14,
1646,
1826,
288,
334,
82,
15542,
83,
10,
21690,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
3672,
6536,
2812,
14,
4314,
395,
288,
334,
82,
7,
21690,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
22952,
2812,
395,
288,
334,
82,
3894,
94,
62,
10,
1,
5,
28103,
7023,
32702,
2440,
16137,
92,
10365,
26,
27,
18485,
10197,
13,
4300,
11013,
395,
288,
334,
82,
3894,
16,
13,
25,
1527,
16,
13,
25,
3672,
27658,
16,
13,
25,
2807,
779,
20565,
1527,
16,
13,
25,
23763,
59,
2592,
61,
7044,
4860,
14,
5136,
395,
288,
334,
82,
7,
16,
88,
59,
16,
13,
25,
65,
13,
13753,
13,
38,
11529,
4860,
14,
10373,
395,
288,
334,
82,
3894,
16,
13,
25,
2807,
1547,
21324,
16,
13,
25,
2807,
3342,
44,
7044,
4860,
14,
2674,
395,
288,
334,
82,
1154,
78,
297,
4516,
9,
267,
2156,
267,
283,
533,
356,
359,
288,
334,
82,
7,
21690,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
22952,
2812,
14,
2543,
12,
3943,
1935,
358,
267,
2156,
267,
283,
646,
356,
359,
288,
334,
82,
22123,
87,
14,
24621,
10,
7044,
2812,
14,
8814,
12,
3943,
1935,
358,
267,
2156,
272,
789,
421,
199,
533,
3709,
1764,
42,
5838,
8,
12576,
5838,
304,
272,
408,
272,
2104,
658,
2822,
1764,
42,
665,
1014,
921,
1544,
14,
825,
3587,
261,
14,
1308,
15,
18658,
74,
3133,
18417,
1350,
1233,
14,
339,
2508,
7445,
447,
413,
14,
22,
272,
408,
339,
536,
275,
283,
2822,
1764,
42,
7,
272,
5481,
275,
788,
18658,
74,
418,
272,
6203,
275,
17855,
9091,
418,
272,
13290,
275,
788,
505,
15,
88,
13,
18658,
74,
418
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
14,
15813,
272,
18294,
23597,
339,
14493,
7103,
1192,
367,
1603,
6849,
10815,
14,
339,
520,
7307,
26,
1898,
8315,
13,
7280,
701,
314,
14493,
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,
13277,
14,
11729,
492,
21125,
12,
12939,
5838,
12,
2387,
12,
10259,
12,
1808,
12,
971,
272,
642,
12,
12149,
12,
849,
12,
5932,
199,
504,
13277,
14,
1418,
492,
4516,
12,
6819,
12,
11013,
12,
6431,
12,
2812,
12,
2624,
12,
971,
272,
4860,
12,
10357,
199,
504,
13277,
14,
1974,
492,
25591,
63,
6742,
199,
504,
13277,
492,
15439,
875,
465,
15439,
199,
199,
363,
452,
363,
275,
788,
12576,
5838,
297,
283,
10249,
65,
5838,
297,
283,
39,
736,
85,
5838,
297,
283,
39,
736,
85,
4231,
5838,
297,
1779,
283,
39,
293,
8822,
89,
5838,
297,
283,
16512,
415,
5838,
297,
283,
3337,
74,
608,
5838,
297,
283,
3337,
74,
608,
5229,
5838,
297,
1779,
283,
43,
357,
472,
5838,
297,
283,
56,
7169,
5838,
297,
283,
2822,
1764,
42,
5838,
297,
283,
35,
14655,
5298,
5838,
297,
1779,
283,
48,
528,
5838,
297,
283,
7250,
320,
5838,
297,
283,
42,
305,
827,
5838,
418,
421,
199,
533,
9586,
5838,
8,
19856,
304,
272,
408,
272,
2104,
658,
12576,
665,
1014,
921,
1544,
14,
11846,
14,
957,
15,
6138,
3133,
18417,
1350,
1233,
14,
272,
408,
339,
536,
275,
283,
12576,
7,
272,
5481,
275,
788,
6138,
418,
272,
6203,
275,
17855,
6138,
418,
272,
13290,
275,
788,
505,
15,
88,
13,
6138,
418,
339,
3285,
275,
295,
14,
16661,
1204,
295,
14,
16504,
1204,
295,
14,
12819,
339,
4645,
275,
469,
267,
283,
1231,
356,
359,
288,
334,
82,
29538,
51,
60,
78,
11529,
4516,
395,
288,
334,
82,
28866,
21040,
78,
297,
6819,
14,
7200,
395,
288,
334,
82,
32575,
10,
21040,
10,
3678,
6819,
14,
18933,
395,
288,
327,
7681,
26,
2621,
2544,
1083,
1561,
370,
5126,
7103,
316,
298,
11964,
892,
1323,
26184,
2,
288,
327,
465,
282,
1083,
4955,
288,
334,
82,
6774,
479,
92,
4785,
92,
2546,
92,
9341,
92,
6958,
92,
885,
92,
1117,
92,
2836,
92,
15172,
92,
509,
5227,
1467,
519,
7,
692,
92,
14867,
92,
842,
1618,
92,
1222,
92,
1107,
92,
5656,
92,
3749,
92,
11964,
92,
893,
92,
6710,
2862,
66,
297,
1467,
6431,
395,
288,
327,
1083,
1561,
288,
334,
82,
7,
17304,
26,
5169,
16045,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
3134,
7023,
61,
4,
16137,
25739,
83,
11,
6393,
31,
3171,
221,
327,
372,
2368,
1467,
519,
7,
17304,
26,
16045,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
3672,
3171,
8295,
327,
1083,
536,
1467,
519,
13445,
83,
10,
10127,
19633,
19242,
327,
4955,
1343,
1467,
10259,
8,
4941,
8,
3749,
395,
2812,
14,
3481,
12,
4516,
12,
11013,
1826,
288,
334,
82,
20812,
16045,
55,
60,
68,
30679,
87,
14,
22952,
2812,
14,
14946,
395,
288,
334,
82,
6774,
6198,
92,
1297,
92,
4869,
92,
11036,
92,
5094,
92,
24900,
92,
6106,
92,
4239,
5227,
1467,
519,
7,
6798,
92,
3455,
92,
1986,
92,
4768,
3997,
92,
4792,
92,
16473,
1759,
92,
32229,
5227,
1467,
519,
1133,
1312,
14928,
92,
32059,
2862,
66,
297,
6431,
14,
17737,
395,
288,
334,
82,
6774,
4871,
92,
4414,
92,
1560,
92,
3157,
92,
1609,
92,
442,
92,
2809,
92,
3612,
92,
1647,
2862,
66,
297,
1467,
6431,
14,
804,
395,
288,
334,
82,
6774,
2491,
10127,
83,
14705,
10259,
8,
10650,
14,
8814,
12,
4516,
395,
283,
646,
659,
288,
334,
82,
6774,
2052,
92,
3910,
92,
2307,
2862,
66,
297,
6431,
14,
9737,
395,
288,
334,
82,
6774,
533,
92,
3266,
10127,
83,
14705,
10259,
8,
10650,
14,
17737,
12,
4516,
395,
283,
533,
659,
288,
334,
82,
6774,
646,
10127,
83,
14705,
10259,
8,
10650,
14,
8814,
12,
4516,
395,
283,
646,
659,
288,
334,
82,
4065,
30082,
92,
15022,
23629,
3135,
10,
6949,
2624,
395,
288,
334,
82,
4507,
1103,
3530,
92,
16122,
1103,
6616,
5227,
1103,
85,
59,
16,
13,
25,
65,
13,
13753,
13,
38,
8194,
20,
93,
4662,
2624,
14,
1610,
395,
288,
334,
82,
13445,
4959,
17304,
26,
16045,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
3672,
3196,
10259,
8,
7961,
12,
2812,
14,
1646,
1826,
288,
334,
82,
15542,
83,
10,
21690,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
3672,
6536,
2812,
14,
4314,
395,
288,
334,
82,
7,
21690,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
22952,
2812,
395,
288,
334,
82,
3894,
94,
62,
10,
1,
5,
28103,
7023,
32702,
2440,
16137,
92,
10365,
26,
27,
18485,
10197,
13,
4300,
11013,
395,
288,
334,
82,
3894,
16,
13,
25,
1527,
16,
13,
25,
3672,
27658,
16,
13,
25,
2807,
779,
20565,
1527,
16,
13,
25,
23763,
59,
2592,
61,
7044,
4860,
14,
5136,
395,
288,
334,
82,
7,
16,
88,
59,
16,
13,
25,
65,
13,
13753,
13,
38,
11529,
4860,
14,
10373,
395,
288,
334,
82,
3894,
16,
13,
25,
2807,
1547,
21324,
16,
13,
25,
2807,
3342,
44,
7044,
4860,
14,
2674,
395,
288,
334,
82,
1154,
78,
297,
4516,
9,
267,
2156,
267,
283,
533,
356,
359,
288,
334,
82,
7,
21690,
55,
60,
68,
61,
6113,
4,
2788,
60,
87,
4,
22952,
2812,
14,
2543,
12,
3943,
1935,
358,
267,
2156,
267,
283,
646,
356,
359,
288,
334,
82,
22123,
87,
14,
24621,
10,
7044,
2812,
14,
8814,
12,
3943,
1935,
358,
267,
2156,
272,
789,
421,
199,
533,
3709,
1764,
42,
5838,
8,
12576,
5838,
304,
272,
408,
272,
2104,
658,
2822,
1764,
42,
665,
1014,
921,
1544,
14,
825,
3587,
261,
14,
1308,
15,
18658,
74,
3133,
18417,
1350,
1233,
14,
339,
2508,
7445,
447,
413,
14,
22,
272,
408,
339,
536,
275,
283,
2822,
1764,
42,
7,
272,
5481,
275,
788,
18658,
74,
418,
272,
6203,
275,
17855,
9091,
418,
272,
13290,
275,
788,
505,
15,
88,
13,
18658,
74,
418,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
n0m4dz/odoo
|
addons/crm/wizard/crm_phonecall_to_phonecall.py
|
337
|
4535
|
# -*- 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
from openerp.tools.translate import _
import time
class crm_phonecall2phonecall(osv.osv_memory):
_name = 'crm.phonecall2phonecall'
_description = 'Phonecall To Phonecall'
_columns = {
'name' : fields.char('Call summary', required=True, select=1),
'user_id' : fields.many2one('res.users',"Assign To"),
'contact_name':fields.char('Contact'),
'phone':fields.char('Phone'),
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="['|',('section_id','=',False),('section_id','=',section_id),\
('object_id.model', '=', 'crm.phonecall')]"),
'date': fields.datetime('Date'),
'section_id':fields.many2one('crm.case.section','Sales Team'),
'action': fields.selection([('schedule','Schedule a call'), ('log','Log a call')], 'Action', required=True),
'partner_id' : fields.many2one('res.partner', "Partner"),
'note':fields.text('Note')
}
def action_cancel(self, cr, uid, ids, context=None):
"""
Closes Phonecall to Phonecall form
"""
return {'type':'ir.actions.act_window_close'}
def action_schedule(self, cr, uid, ids, context=None):
value = {}
if context is None:
context = {}
phonecall = self.pool.get('crm.phonecall')
phonecall_ids = context and context.get('active_ids') or []
for this in self.browse(cr, uid, ids, context=context):
phocall_ids = phonecall.schedule_another_phonecall(cr, uid, phonecall_ids, this.date, this.name, \
this.user_id and this.user_id.id or False, \
this.section_id and this.section_id.id or False, \
this.categ_id and this.categ_id.id or False, \
action=this.action, context=context)
return phonecall.redirect_phonecall_view(cr, uid, phocall_ids[phonecall_ids[0]], context=context)
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
"""
res = super(crm_phonecall2phonecall, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False
res.update({'action': 'schedule', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
if record_id:
phonecall = self.pool.get('crm.phonecall').browse(cr, uid, record_id, context=context)
categ_id = False
data_obj = self.pool.get('ir.model.data')
try:
res_id = data_obj._get_id(cr, uid, 'crm', 'categ_phone2')
categ_id = data_obj.browse(cr, uid, res_id, context=context).res_id
except ValueError:
pass
if 'name' in fields:
res.update({'name': phonecall.name})
if 'user_id' in fields:
res.update({'user_id': phonecall.user_id and phonecall.user_id.id or False})
if 'date' in fields:
res.update({'date': False})
if 'section_id' in fields:
res.update({'section_id': phonecall.section_id and phonecall.section_id.id or False})
if 'categ_id' in fields:
res.update({'categ_id': categ_id})
if 'partner_id' in fields:
res.update({'partner_id': phonecall.partner_id and phonecall.partner_id.id or False})
return res
# 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,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
646,
900,
199,
199,
533,
2467,
77,
63,
9339,
1250,
18,
9339,
1250,
8,
4795,
14,
4795,
63,
4844,
304,
272,
485,
354,
275,
283,
15213,
14,
9339,
1250,
18,
9339,
1250,
7,
272,
485,
1802,
275,
283,
15199,
1250,
4005,
27585,
1250,
7,
339,
485,
3406,
275,
469,
267,
283,
354,
7,
520,
1504,
14,
1560,
360,
2176,
6212,
297,
1415,
29,
549,
12,
3504,
29,
17,
395,
267,
283,
751,
63,
344,
7,
520,
1504,
14,
3479,
18,
368,
360,
470,
14,
3707,
297,
2,
9595,
4005,
1288,
267,
283,
7811,
63,
354,
356,
955,
14,
1560,
360,
14499,
659,
267,
283,
9339,
356,
955,
14,
1560,
360,
15199,
659,
267,
283,
3533,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
15213,
14,
2546,
14,
3533,
297,
283,
7841,
297,
971,
355,
2881,
628,
459,
26320,
360,
2792,
63,
344,
18937,
797,
11169,
2792,
63,
344,
18937,
2792,
63,
344,
26323,
355,
661,
785,
63,
344,
14,
1238,
297,
6291,
283,
15213,
14,
9339,
1250,
5440,
1288,
4960,
283,
602,
356,
1504,
14,
2083,
360,
2506,
659,
267,
283,
2792,
63,
344,
356,
955,
14,
3479,
18,
368,
360,
15213,
14,
2546,
14,
2792,
1673,
18220,
11682,
659,
267,
283,
1287,
356,
1504,
14,
5592,
8318,
7211,
1673,
15535,
282,
1240,
659,
661,
793,
1673,
2445,
282,
1240,
2665,
283,
3310,
297,
1415,
29,
549,
395,
267,
283,
3899,
63,
344,
7,
520,
1504,
14,
3479,
18,
368,
360,
470,
14,
3899,
297,
298,
24120,
1288,
267,
283,
4610,
356,
955,
14,
505,
360,
7443,
358,
272,
789,
2378,
347,
1595,
63,
6406,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
408,
267,
5980,
874,
27585,
1250,
370,
27585,
1250,
1824,
267,
408,
267,
372,
791,
466,
5242,
723,
14,
3723,
14,
2442,
63,
3806,
63,
1600,
936,
339,
347,
1595,
63,
7211,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
574,
275,
1052,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
14617,
1250,
275,
291,
14,
2293,
14,
362,
360,
15213,
14,
9339,
1250,
358,
267,
14617,
1250,
63,
1580,
275,
1067,
436,
1067,
14,
362,
360,
2682,
63,
1580,
358,
503,
942,
267,
367,
642,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
288,
299,
526,
1250,
63,
1580,
275,
14617,
1250,
14,
7211,
63,
13565,
63,
9339,
1250,
8,
1556,
12,
1747,
12,
14617,
1250,
63,
1580,
12,
642,
14,
602,
12,
642,
14,
354,
12,
971,
490,
642,
14,
751,
63,
344,
436,
642,
14,
751,
63,
344,
14,
344,
503,
756,
12,
971,
490,
642,
14,
2792,
63,
344,
436,
642,
14,
2792,
63,
344,
14,
344,
503,
756,
12,
971,
490,
642,
14,
3533,
63,
344,
436,
642,
14,
3533,
63,
344,
14,
344,
503,
756,
12,
971,
490,
1595,
29,
3749,
14,
1287,
12,
1067,
29,
1100,
9,
398,
372,
14617,
1250,
14,
4876,
63,
9339,
1250,
63,
1345,
8,
1556,
12,
1747,
12,
299,
526,
1250,
63,
1580,
59,
9339,
1250,
63,
1580,
59,
16,
2365,
1067,
29,
1100,
9,
2286,
347,
849,
63,
362,
8,
277,
12,
2467,
12,
1747,
12,
1504,
12,
1067,
29,
403,
304,
267,
408,
267,
961,
805,
7545,
849,
1338,
2728,
408,
267,
522,
275,
1613,
8,
15213,
63,
9339,
1250,
18,
9339,
1250,
12,
291,
680,
885,
63,
362,
8,
1556,
12,
1747,
12,
1504,
12,
1067,
29,
1100,
9,
267,
2777,
63,
344,
275,
1067,
436,
1067,
14,
362,
360,
2682,
63,
344,
297,
756,
9,
503,
756,
267,
522,
14,
873,
3252,
1287,
356,
283,
7211,
297,
283,
602,
356,
900,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
22220,
267,
340,
2777,
63,
344,
26,
288,
14617,
1250,
275,
291,
14,
2293,
14,
362,
360,
15213,
14,
9339,
1250,
1959,
4570,
8,
1556,
12,
1747,
12,
2777,
63,
344,
12,
1067,
29,
1100,
9,
953,
7737,
63,
344,
275,
756,
288,
666,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
723,
14,
1238,
14,
576,
358,
288,
862,
26,
355,
522,
63,
344,
275,
666,
63,
1113,
423,
362,
63,
344,
8,
1556,
12,
1747,
12,
283,
15213,
297,
283,
3533,
63,
9339,
18,
358,
355,
7737,
63,
344,
275,
666,
63,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
522,
63,
344,
12,
1067,
29,
1100,
680,
470,
63,
344,
288,
871,
1722,
26,
355,
986,
953,
340,
283,
354,
7,
315,
1504,
26,
355,
522,
14,
873,
3252,
354,
356,
14617,
1250,
14,
354,
1552,
288,
340,
283,
751,
63,
344,
7,
315,
1504,
26,
355,
522,
14,
873,
3252,
751,
63,
344,
356,
14617,
1250,
14,
751,
63,
344,
436,
14617,
1250
] |
[
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,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
646,
900,
199,
199,
533,
2467,
77,
63,
9339,
1250,
18,
9339,
1250,
8,
4795,
14,
4795,
63,
4844,
304,
272,
485,
354,
275,
283,
15213,
14,
9339,
1250,
18,
9339,
1250,
7,
272,
485,
1802,
275,
283,
15199,
1250,
4005,
27585,
1250,
7,
339,
485,
3406,
275,
469,
267,
283,
354,
7,
520,
1504,
14,
1560,
360,
2176,
6212,
297,
1415,
29,
549,
12,
3504,
29,
17,
395,
267,
283,
751,
63,
344,
7,
520,
1504,
14,
3479,
18,
368,
360,
470,
14,
3707,
297,
2,
9595,
4005,
1288,
267,
283,
7811,
63,
354,
356,
955,
14,
1560,
360,
14499,
659,
267,
283,
9339,
356,
955,
14,
1560,
360,
15199,
659,
267,
283,
3533,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
15213,
14,
2546,
14,
3533,
297,
283,
7841,
297,
971,
355,
2881,
628,
459,
26320,
360,
2792,
63,
344,
18937,
797,
11169,
2792,
63,
344,
18937,
2792,
63,
344,
26323,
355,
661,
785,
63,
344,
14,
1238,
297,
6291,
283,
15213,
14,
9339,
1250,
5440,
1288,
4960,
283,
602,
356,
1504,
14,
2083,
360,
2506,
659,
267,
283,
2792,
63,
344,
356,
955,
14,
3479,
18,
368,
360,
15213,
14,
2546,
14,
2792,
1673,
18220,
11682,
659,
267,
283,
1287,
356,
1504,
14,
5592,
8318,
7211,
1673,
15535,
282,
1240,
659,
661,
793,
1673,
2445,
282,
1240,
2665,
283,
3310,
297,
1415,
29,
549,
395,
267,
283,
3899,
63,
344,
7,
520,
1504,
14,
3479,
18,
368,
360,
470,
14,
3899,
297,
298,
24120,
1288,
267,
283,
4610,
356,
955,
14,
505,
360,
7443,
358,
272,
789,
2378,
347,
1595,
63,
6406,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
408,
267,
5980,
874,
27585,
1250,
370,
27585,
1250,
1824,
267,
408,
267,
372,
791,
466,
5242,
723,
14,
3723,
14,
2442,
63,
3806,
63,
1600,
936,
339,
347,
1595,
63,
7211,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
574,
275,
1052,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
14617,
1250,
275,
291,
14,
2293,
14,
362,
360,
15213,
14,
9339,
1250,
358,
267,
14617,
1250,
63,
1580,
275,
1067,
436,
1067,
14,
362,
360,
2682,
63,
1580,
358,
503,
942,
267,
367,
642,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
288,
299,
526,
1250,
63,
1580,
275,
14617,
1250,
14,
7211,
63,
13565,
63,
9339,
1250,
8,
1556,
12,
1747,
12,
14617,
1250,
63,
1580,
12,
642,
14,
602,
12,
642,
14,
354,
12,
971,
490,
642,
14,
751,
63,
344,
436,
642,
14,
751,
63,
344,
14,
344,
503,
756,
12,
971,
490,
642,
14,
2792,
63,
344,
436,
642,
14,
2792,
63,
344,
14,
344,
503,
756,
12,
971,
490,
642,
14,
3533,
63,
344,
436,
642,
14,
3533,
63,
344,
14,
344,
503,
756,
12,
971,
490,
1595,
29,
3749,
14,
1287,
12,
1067,
29,
1100,
9,
398,
372,
14617,
1250,
14,
4876,
63,
9339,
1250,
63,
1345,
8,
1556,
12,
1747,
12,
299,
526,
1250,
63,
1580,
59,
9339,
1250,
63,
1580,
59,
16,
2365,
1067,
29,
1100,
9,
2286,
347,
849,
63,
362,
8,
277,
12,
2467,
12,
1747,
12,
1504,
12,
1067,
29,
403,
304,
267,
408,
267,
961,
805,
7545,
849,
1338,
2728,
408,
267,
522,
275,
1613,
8,
15213,
63,
9339,
1250,
18,
9339,
1250,
12,
291,
680,
885,
63,
362,
8,
1556,
12,
1747,
12,
1504,
12,
1067,
29,
1100,
9,
267,
2777,
63,
344,
275,
1067,
436,
1067,
14,
362,
360,
2682,
63,
344,
297,
756,
9,
503,
756,
267,
522,
14,
873,
3252,
1287,
356,
283,
7211,
297,
283,
602,
356,
900,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
22220,
267,
340,
2777,
63,
344,
26,
288,
14617,
1250,
275,
291,
14,
2293,
14,
362,
360,
15213,
14,
9339,
1250,
1959,
4570,
8,
1556,
12,
1747,
12,
2777,
63,
344,
12,
1067,
29,
1100,
9,
953,
7737,
63,
344,
275,
756,
288,
666,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
723,
14,
1238,
14,
576,
358,
288,
862,
26,
355,
522,
63,
344,
275,
666,
63,
1113,
423,
362,
63,
344,
8,
1556,
12,
1747,
12,
283,
15213,
297,
283,
3533,
63,
9339,
18,
358,
355,
7737,
63,
344,
275,
666,
63,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
522,
63,
344,
12,
1067,
29,
1100,
680,
470,
63,
344,
288,
871,
1722,
26,
355,
986,
953,
340,
283,
354,
7,
315,
1504,
26,
355,
522,
14,
873,
3252,
354,
356,
14617,
1250,
14,
354,
1552,
288,
340,
283,
751,
63,
344,
7,
315,
1504,
26,
355,
522,
14,
873,
3252,
751,
63,
344,
356,
14617,
1250,
14,
751,
63,
344,
436,
14617,
1250,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
zhaozengguang/opencog
|
opencog/python/spatiotemporal/temporal_events/composition/__init__.py
|
1
|
1286
|
from math import fabs, sqrt
__author__ = 'keyvan'
def unpack(relation, start_reference=0, length_reference=1):
before, same, after = relation
similarity = same / (1 - fabs(before - after))
solutions = []
lengths = length_reference / similarity**2, length_reference * similarity**2
for i in xrange(2):
length_solution = lengths[i]
starts = [
start_reference - (length_solution*before - 0.5*length_reference),
start_reference + length_reference - (length_reference*before + 0.5*length_solution)
]
start_solution = starts[i]
comparison_operand = 0.5 * (length_reference / length_solution)**((-1)**i)
if before <= comparison_operand:
start_solution = start_reference + length_reference - sqrt(2*before*length_solution*length_reference)
elif before > 1 - comparison_operand:
start_solution = start_reference - length_solution + sqrt(2*after*length_solution*length_reference)
if i == 0 or i == 1 and solutions[0] != (start_solution, start_solution + length_solution):
solution_a, solution_b = round(start_solution, 15), round(start_solution + length_solution, 15)
solutions.append((solution_a, solution_b))
return solutions
|
agpl-3.0
|
[
504,
3473,
492,
289,
2101,
12,
7452,
199,
199,
363,
2502,
363,
275,
283,
498,
20662,
7,
421,
199,
318,
7787,
8,
5690,
12,
1343,
63,
4443,
29,
16,
12,
2582,
63,
4443,
29,
17,
304,
272,
2544,
12,
2011,
12,
2410,
275,
5850,
272,
22838,
275,
2011,
1182,
334,
17,
446,
289,
2101,
8,
5182,
446,
2410,
430,
339,
24886,
275,
942,
339,
17464,
275,
2582,
63,
4443,
1182,
22838,
538,
18,
12,
2582,
63,
4443,
627,
22838,
538,
18,
272,
367,
284,
315,
4945,
8,
18,
304,
267,
2582,
63,
14458,
275,
17464,
59,
73,
61,
267,
9174,
275,
359,
288,
1343,
63,
4443,
446,
334,
1267,
63,
14458,
10,
5182,
446,
378,
14,
21,
10,
1267,
63,
4443,
395,
288,
1343,
63,
4443,
435,
2582,
63,
4443,
446,
334,
1267,
63,
4443,
10,
5182,
435,
378,
14,
21,
10,
1267,
63,
14458,
9,
267,
1622,
267,
1343,
63,
14458,
275,
9174,
59,
73,
61,
398,
9132,
63,
20315,
275,
378,
14,
21,
627,
334,
1267,
63,
4443,
1182,
2582,
63,
14458,
6422,
18138,
17,
6422,
73,
9,
267,
340,
2544,
2695,
9132,
63,
20315,
26,
288,
1343,
63,
14458,
275,
1343,
63,
4443,
435,
2582,
63,
4443,
446,
7452,
8,
18,
10,
5182,
10,
1267,
63,
14458,
10,
1267,
63,
4443,
9,
267,
916,
2544,
690,
413,
446,
9132,
63,
20315,
26,
288,
1343,
63,
14458,
275,
1343,
63,
4443,
446,
2582,
63,
14458,
435,
7452,
8,
18,
10,
4399,
10,
1267,
63,
14458,
10,
1267,
63,
4443,
9,
398,
340,
284,
508,
378,
503,
284,
508,
413,
436,
24886,
59,
16,
61,
1137,
334,
928,
63,
14458,
12,
1343,
63,
14458,
435,
2582,
63,
14458,
304,
288,
8744,
63,
65,
12,
8744,
63,
66,
275,
6168,
8,
928,
63,
14458,
12,
4114,
395,
6168,
8,
928,
63,
14458,
435,
2582,
63,
14458,
12,
4114,
9,
288,
24886,
14,
740,
1332,
14458,
63,
65,
12,
8744,
63,
66,
430,
339,
372,
24886,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
3473,
492,
289,
2101,
12,
7452,
199,
199,
363,
2502,
363,
275,
283,
498,
20662,
7,
421,
199,
318,
7787,
8,
5690,
12,
1343,
63,
4443,
29,
16,
12,
2582,
63,
4443,
29,
17,
304,
272,
2544,
12,
2011,
12,
2410,
275,
5850,
272,
22838,
275,
2011,
1182,
334,
17,
446,
289,
2101,
8,
5182,
446,
2410,
430,
339,
24886,
275,
942,
339,
17464,
275,
2582,
63,
4443,
1182,
22838,
538,
18,
12,
2582,
63,
4443,
627,
22838,
538,
18,
272,
367,
284,
315,
4945,
8,
18,
304,
267,
2582,
63,
14458,
275,
17464,
59,
73,
61,
267,
9174,
275,
359,
288,
1343,
63,
4443,
446,
334,
1267,
63,
14458,
10,
5182,
446,
378,
14,
21,
10,
1267,
63,
4443,
395,
288,
1343,
63,
4443,
435,
2582,
63,
4443,
446,
334,
1267,
63,
4443,
10,
5182,
435,
378,
14,
21,
10,
1267,
63,
14458,
9,
267,
1622,
267,
1343,
63,
14458,
275,
9174,
59,
73,
61,
398,
9132,
63,
20315,
275,
378,
14,
21,
627,
334,
1267,
63,
4443,
1182,
2582,
63,
14458,
6422,
18138,
17,
6422,
73,
9,
267,
340,
2544,
2695,
9132,
63,
20315,
26,
288,
1343,
63,
14458,
275,
1343,
63,
4443,
435,
2582,
63,
4443,
446,
7452,
8,
18,
10,
5182,
10,
1267,
63,
14458,
10,
1267,
63,
4443,
9,
267,
916,
2544,
690,
413,
446,
9132,
63,
20315,
26,
288,
1343,
63,
14458,
275,
1343,
63,
4443,
446,
2582,
63,
14458,
435,
7452,
8,
18,
10,
4399,
10,
1267,
63,
14458,
10,
1267,
63,
4443,
9,
398,
340,
284,
508,
378,
503,
284,
508,
413,
436,
24886,
59,
16,
61,
1137,
334,
928,
63,
14458,
12,
1343,
63,
14458,
435,
2582,
63,
14458,
304,
288,
8744,
63,
65,
12,
8744,
63,
66,
275,
6168,
8,
928,
63,
14458,
12,
4114,
395,
6168,
8,
928,
63,
14458,
435,
2582,
63,
14458,
12,
4114,
9,
288,
24886,
14,
740,
1332,
14458,
63,
65,
12,
8744,
63,
66,
430,
339,
372,
24886,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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 toscaparser.elements.property_definition import PropertyDef
from toscaparser.elements.statefulentitytype import StatefulEntityType
class CapabilityTypeDef(StatefulEntityType):
'''TOSCA built-in capabilities type.'''
TOSCA_TYPEURI_CAPABILITY_ROOT = 'tosca.capabilities.Root'
def __init__(self, name, ctype, ntype, custom_def=None):
self.name = name
if ctype is None:
return
super(CapabilityTypeDef, self).__init__(ctype, self.CAPABILITY_PREFIX,
custom_def)
self.nodetype = ntype
self.properties = None
self.custom_def = custom_def
if self.PROPERTIES in self.defs:
self.properties = self.defs[self.PROPERTIES]
self.parent_capabilities = self._get_parent_capabilities(custom_def)
def get_properties_def_objects(self):
'''Return a list of property definition objects.'''
properties = []
parent_properties = {}
if self.parent_capabilities:
for type, value in self.parent_capabilities.items():
parent_properties[type] = value.get('properties')
if self.properties:
for prop, schema in self.properties.items():
properties.append(PropertyDef(prop, None, schema))
if parent_properties:
for parent, props in parent_properties.items():
for prop, schema in props.items():
# add parent property if not overridden by children type
if not self.properties or \
prop not in self.properties.keys():
properties.append(PropertyDef(prop, None, schema))
return properties
def get_properties_def(self):
'''Return a dictionary of property definition name-object pairs.'''
return {prop.name: prop
for prop in self.get_properties_def_objects()}
def get_property_def_value(self, name):
'''Return the definition of a given property name.'''
props_def = self.get_properties_def()
if props_def and name in props_def:
return props_def[name].value
def _get_parent_capabilities(self, custom_def=None):
capabilities = {}
parent_cap = self.parent_type
if parent_cap:
parent_cap = parent_cap.type
while parent_cap != self.TOSCA_TYPEURI_CAPABILITY_ROOT:
if parent_cap in self.TOSCA_DEF.keys():
capabilities[parent_cap] = self.TOSCA_DEF[parent_cap]
elif custom_def and parent_cap in custom_def.keys():
capabilities[parent_cap] = custom_def[parent_cap]
parent_cap = capabilities[parent_cap]['derived_from']
return capabilities
@property
def parent_type(self):
'''Return a capability this capability is derived from.'''
if not hasattr(self, 'defs'):
return None
pnode = self.derived_from(self.defs)
if pnode:
return CapabilityTypeDef(self.name, pnode,
self.nodetype, self.custom_def)
|
apache-2.0
|
[
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
370,
551,
439,
285,
332,
14,
5527,
14,
1829,
63,
7463,
492,
16158,
6172,
199,
504,
370,
551,
439,
285,
332,
14,
5527,
14,
929,
70,
443,
78,
1701,
466,
492,
8511,
1893,
7302,
804,
421,
199,
533,
22516,
3616,
804,
6172,
8,
2223,
1893,
7302,
804,
304,
272,
1449,
2566,
51,
3263,
6137,
13,
262,
14918,
730,
10595,
272,
2296,
51,
3263,
63,
2711,
7639,
63,
8549,
2477,
63,
5441,
275,
283,
475,
7101,
14,
10732,
14,
6405,
7,
339,
347,
636,
826,
721,
277,
12,
536,
12,
16360,
12,
302,
466,
12,
3537,
63,
318,
29,
403,
304,
267,
291,
14,
354,
275,
536,
267,
340,
16360,
365,
488,
26,
288,
372,
267,
1613,
8,
24512,
804,
6172,
12,
291,
2843,
826,
721,
3667,
12,
291,
14,
8549,
2477,
63,
6351,
12,
6059,
3537,
63,
318,
9,
267,
291,
14,
9895,
275,
302,
466,
267,
291,
14,
3282,
275,
488,
267,
291,
14,
4229,
63,
318,
275,
3537,
63,
318,
267,
340,
291,
14,
18858,
29807,
315,
291,
14,
8710,
26,
288,
291,
14,
3282,
275,
291,
14,
8710,
59,
277,
14,
18858,
29807,
61,
267,
291,
14,
1708,
63,
10732,
275,
291,
423,
362,
63,
1708,
63,
10732,
8,
4229,
63,
318,
9,
339,
347,
664,
63,
3282,
63,
318,
63,
1462,
8,
277,
304,
267,
1449,
1767,
282,
769,
402,
3324,
5492,
2251,
10595,
267,
4382,
275,
942,
267,
1676,
63,
3282,
275,
1052,
267,
340,
291,
14,
1708,
63,
10732,
26,
288,
367,
730,
12,
574,
315,
291,
14,
1708,
63,
10732,
14,
1744,
837,
355,
1676,
63,
3282,
59,
466,
61,
275,
574,
14,
362,
360,
3282,
358,
267,
340,
291,
14,
3282,
26,
288,
367,
5931,
12,
4177,
315,
291,
14,
3282,
14,
1744,
837,
355,
4382,
14,
740,
8,
3697,
6172,
8,
4469,
12,
488,
12,
4177,
430,
267,
340,
1676,
63,
3282,
26,
288,
367,
1676,
12,
10792,
315,
1676,
63,
3282,
14,
1744,
837,
355,
367,
5931,
12,
4177,
315,
10792,
14,
1744,
837,
490,
327,
1050,
1676,
3324,
340,
440,
10087,
701,
4978,
730,
490,
340,
440,
291,
14,
3282,
503,
971,
1169,
5931,
440,
315,
291,
14,
3282,
14,
1612,
837,
717,
4382,
14,
740,
8,
3697,
6172,
8,
4469,
12,
488,
12,
4177,
430,
267,
372,
4382,
339,
347,
664,
63,
3282,
63,
318,
8,
277,
304,
267,
1449,
1767,
282,
2600,
402,
3324,
5492,
536,
13,
785,
6342,
10595,
267,
372,
469,
4469,
14,
354,
26,
5931,
355,
367,
5931,
315,
291,
14,
362,
63,
3282,
63,
318,
63,
1462,
12737,
339,
347,
664,
63,
1829,
63,
318,
63,
585,
8,
277,
12,
536,
304,
267,
1449,
1767,
314,
5492,
402,
282,
1627,
3324,
536,
10595,
267,
10792,
63,
318,
275,
291,
14,
362,
63,
3282,
63,
318,
342,
267,
340,
10792,
63,
318,
436,
536,
315,
10792,
63,
318,
26,
288,
372,
10792,
63,
318,
59,
354,
1055,
585,
339,
347,
485,
362,
63,
1708,
63,
10732,
8,
277,
12,
3537,
63,
318,
29,
403,
304,
267,
14918,
275,
1052,
267,
1676,
63,
2874,
275,
291,
14,
1708,
63,
466,
267,
340,
1676,
63,
2874,
26,
288,
1676,
63,
2874,
275,
1676,
63,
2874,
14,
466,
288,
1830,
1676,
63,
2874,
1137,
291,
14,
2566,
51,
3263,
63,
2711,
7639,
63,
8549,
2477,
63,
5441,
26,
355,
340,
1676,
63,
2874,
315,
291,
14,
2566,
51,
3263,
63,
5638,
14,
1612,
837,
490,
14918,
59,
1708,
63,
2874,
61,
275,
291,
14,
2566,
51,
3263,
63,
5638,
59,
1708,
63,
2874,
61,
355,
916,
3537,
63,
318,
436,
1676,
63,
2874,
315,
3537,
63,
318,
14,
1612,
837,
490,
14918,
59,
1708,
63,
2874,
61,
275,
3537,
63,
318,
59,
1708,
63,
2874,
61,
355,
1676,
63,
2874,
275,
14918,
59,
1708,
63,
2874,
2733,
19588,
63,
504,
418,
267,
372,
14918,
339,
768,
1829,
272,
347,
1676,
63,
466,
8,
277,
304,
267,
1449,
1767,
282,
19854,
642,
19854,
365,
7131,
687,
10595,
267,
340,
440,
2688,
8,
277,
12,
283,
8710,
735,
288,
372,
488,
267,
299,
932,
275,
291,
14,
19588,
63,
504,
8,
277,
14,
8710,
9,
267,
340,
299,
932,
26,
288,
372,
22516,
3616,
804,
6172,
8,
277,
14,
354,
12,
299,
932,
12,
3660,
291,
14,
9895,
12,
291,
14,
4229,
63,
318,
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
] |
[
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
370,
551,
439,
285,
332,
14,
5527,
14,
1829,
63,
7463,
492,
16158,
6172,
199,
504,
370,
551,
439,
285,
332,
14,
5527,
14,
929,
70,
443,
78,
1701,
466,
492,
8511,
1893,
7302,
804,
421,
199,
533,
22516,
3616,
804,
6172,
8,
2223,
1893,
7302,
804,
304,
272,
1449,
2566,
51,
3263,
6137,
13,
262,
14918,
730,
10595,
272,
2296,
51,
3263,
63,
2711,
7639,
63,
8549,
2477,
63,
5441,
275,
283,
475,
7101,
14,
10732,
14,
6405,
7,
339,
347,
636,
826,
721,
277,
12,
536,
12,
16360,
12,
302,
466,
12,
3537,
63,
318,
29,
403,
304,
267,
291,
14,
354,
275,
536,
267,
340,
16360,
365,
488,
26,
288,
372,
267,
1613,
8,
24512,
804,
6172,
12,
291,
2843,
826,
721,
3667,
12,
291,
14,
8549,
2477,
63,
6351,
12,
6059,
3537,
63,
318,
9,
267,
291,
14,
9895,
275,
302,
466,
267,
291,
14,
3282,
275,
488,
267,
291,
14,
4229,
63,
318,
275,
3537,
63,
318,
267,
340,
291,
14,
18858,
29807,
315,
291,
14,
8710,
26,
288,
291,
14,
3282,
275,
291,
14,
8710,
59,
277,
14,
18858,
29807,
61,
267,
291,
14,
1708,
63,
10732,
275,
291,
423,
362,
63,
1708,
63,
10732,
8,
4229,
63,
318,
9,
339,
347,
664,
63,
3282,
63,
318,
63,
1462,
8,
277,
304,
267,
1449,
1767,
282,
769,
402,
3324,
5492,
2251,
10595,
267,
4382,
275,
942,
267,
1676,
63,
3282,
275,
1052,
267,
340,
291,
14,
1708,
63,
10732,
26,
288,
367,
730,
12,
574,
315,
291,
14,
1708,
63,
10732,
14,
1744,
837,
355,
1676,
63,
3282,
59,
466,
61,
275,
574,
14,
362,
360,
3282,
358,
267,
340,
291,
14,
3282,
26,
288,
367,
5931,
12,
4177,
315,
291,
14,
3282,
14,
1744,
837,
355,
4382,
14,
740,
8,
3697,
6172,
8,
4469,
12,
488,
12,
4177,
430,
267,
340,
1676,
63,
3282,
26,
288,
367,
1676,
12,
10792,
315,
1676,
63,
3282,
14,
1744,
837,
355,
367,
5931,
12,
4177,
315,
10792,
14,
1744,
837,
490,
327,
1050,
1676,
3324,
340,
440,
10087,
701,
4978,
730,
490,
340,
440,
291,
14,
3282,
503,
971,
1169,
5931,
440,
315,
291,
14,
3282,
14,
1612,
837,
717,
4382,
14,
740,
8,
3697,
6172,
8,
4469,
12,
488,
12,
4177,
430,
267,
372,
4382,
339,
347,
664,
63,
3282,
63,
318,
8,
277,
304,
267,
1449,
1767,
282,
2600,
402,
3324,
5492,
536,
13,
785,
6342,
10595,
267,
372,
469,
4469,
14,
354,
26,
5931,
355,
367,
5931,
315,
291,
14,
362,
63,
3282,
63,
318,
63,
1462,
12737,
339,
347,
664,
63,
1829,
63,
318,
63,
585,
8,
277,
12,
536,
304,
267,
1449,
1767,
314,
5492,
402,
282,
1627,
3324,
536,
10595,
267,
10792,
63,
318,
275,
291,
14,
362,
63,
3282,
63,
318,
342,
267,
340,
10792,
63,
318,
436,
536,
315,
10792,
63,
318,
26,
288,
372,
10792,
63,
318,
59,
354,
1055,
585,
339,
347,
485,
362,
63,
1708,
63,
10732,
8,
277,
12,
3537,
63,
318,
29,
403,
304,
267,
14918,
275,
1052,
267,
1676,
63,
2874,
275,
291,
14,
1708,
63,
466,
267,
340,
1676,
63,
2874,
26,
288,
1676,
63,
2874,
275,
1676,
63,
2874,
14,
466,
288,
1830,
1676,
63,
2874,
1137,
291,
14,
2566,
51,
3263,
63,
2711,
7639,
63,
8549,
2477,
63,
5441,
26,
355,
340,
1676,
63,
2874,
315,
291,
14,
2566,
51,
3263,
63,
5638,
14,
1612,
837,
490,
14918,
59,
1708,
63,
2874,
61,
275,
291,
14,
2566,
51,
3263,
63,
5638,
59,
1708,
63,
2874,
61,
355,
916,
3537,
63,
318,
436,
1676,
63,
2874,
315,
3537,
63,
318,
14,
1612,
837,
490,
14918,
59,
1708,
63,
2874,
61,
275,
3537,
63,
318,
59,
1708,
63,
2874,
61,
355,
1676,
63,
2874,
275,
14918,
59,
1708,
63,
2874,
2733,
19588,
63,
504,
418,
267,
372,
14918,
339,
768,
1829,
272,
347,
1676,
63,
466,
8,
277,
304,
267,
1449,
1767,
282,
19854,
642,
19854,
365,
7131,
687,
10595,
267,
340,
440,
2688,
8,
277,
12,
283,
8710,
735,
288,
372,
488,
267,
299,
932,
275,
291,
14,
19588,
63,
504,
8,
277,
14,
8710,
9,
267,
340,
299,
932,
26,
288,
372,
22516,
3616,
804,
6172,
8,
277,
14,
354,
12,
299,
932,
12,
3660,
291,
14,
9895,
12,
291,
14,
4229,
63,
318,
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,
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