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
|
|---|---|---|---|---|---|---|---|---|
cryptoprojects/ultimateonlinecash
|
test/functional/test_framework/coverage.py
|
2
|
3383
|
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Utilities for doing coverage analysis on the RPC interface.
Provides a way to track which RPC commands are exercised during
testing.
"""
import os
REFERENCE_FILENAME = 'rpc_interface.txt'
class AuthServiceProxyWrapper():
"""
An object that wraps AuthServiceProxy to record specific RPC calls.
"""
def __init__(self, auth_service_proxy_instance, coverage_logfile=None):
"""
Kwargs:
auth_service_proxy_instance (AuthServiceProxy): the instance
being wrapped.
coverage_logfile (str): if specified, write each service_name
out to a file when called.
"""
self.auth_service_proxy_instance = auth_service_proxy_instance
self.coverage_logfile = coverage_logfile
def __getattr__(self, name):
return_val = getattr(self.auth_service_proxy_instance, name)
if not isinstance(return_val, type(self.auth_service_proxy_instance)):
# If proxy getattr returned an unwrapped value, do the same here.
return return_val
return AuthServiceProxyWrapper(return_val, self.coverage_logfile)
def __call__(self, *args, **kwargs):
"""
Delegates to AuthServiceProxy, then writes the particular RPC method
called to a file.
"""
return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
self._log_call()
return return_val
def _log_call(self):
rpc_method = self.auth_service_proxy_instance._service_name
if self.coverage_logfile:
with open(self.coverage_logfile, 'a+', encoding='utf8') as f:
f.write("%s\n" % rpc_method)
def __truediv__(self, relative_uri):
return AuthServiceProxyWrapper(self.auth_service_proxy_instance / relative_uri,
self.coverage_logfile)
def get_request(self, *args, **kwargs):
self._log_call()
return self.auth_service_proxy_instance.get_request(*args, **kwargs)
def get_filename(dirname, n_node):
"""
Get a filename unique to the test process ID and node.
This file will contain a list of RPC commands covered.
"""
pid = str(os.getpid())
return os.path.join(
dirname, "coverage.pid%s.node%s.txt" % (pid, str(n_node)))
def write_all_rpc_commands(dirname, node):
"""
Write out a list of all RPC functions available in `bitcoin-cli` for
coverage comparison. This will only happen once per coverage
directory.
Args:
dirname (str): temporary test dir
node (AuthServiceProxy): client
Returns:
bool. if the RPC interface file was written.
"""
filename = os.path.join(dirname, REFERENCE_FILENAME)
if os.path.isfile(filename):
return False
help_output = node.help().split('\n')
commands = set()
for line in help_output:
line = line.strip()
# Ignore blanks and headers
if line and not line.startswith('='):
commands.add("%s\n" % line.split()[0])
with open(filename, 'w', encoding='utf8') as f:
f.writelines(list(commands))
return True
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
6900,
13,
9261,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
22905,
367,
9689,
11745,
11284,
641,
314,
11785,
3217,
14,
199,
199,
17473,
282,
4340,
370,
4426,
1314,
11785,
3718,
787,
444,
281,
559,
939,
5309,
199,
4776,
14,
199,
624,
199,
199,
646,
747,
421,
199,
31177,
63,
15440,
275,
283,
4354,
63,
3266,
14,
2424,
7,
421,
199,
533,
3590,
3167,
4936,
4590,
837,
272,
408,
272,
1626,
909,
626,
14018,
3590,
3167,
4936,
370,
2777,
2488,
11785,
4882,
14,
339,
408,
272,
347,
636,
826,
721,
277,
12,
1790,
63,
1364,
63,
3280,
63,
842,
12,
11745,
63,
12804,
29,
403,
304,
267,
408,
267,
1804,
87,
589,
26,
288,
1790,
63,
1364,
63,
3280,
63,
842,
334,
2817,
3167,
4936,
304,
314,
1256,
355,
3769,
8072,
14,
288,
11745,
63,
12804,
334,
495,
304,
340,
2013,
12,
2218,
1924,
2435,
63,
354,
355,
734,
370,
282,
570,
1380,
2797,
14,
398,
408,
267,
291,
14,
1178,
63,
1364,
63,
3280,
63,
842,
275,
1790,
63,
1364,
63,
3280,
63,
842,
267,
291,
14,
10828,
63,
12804,
275,
11745,
63,
12804,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
63,
637,
275,
2519,
8,
277,
14,
1178,
63,
1364,
63,
3280,
63,
842,
12,
536,
9,
267,
340,
440,
1228,
8,
1107,
63,
637,
12,
730,
8,
277,
14,
1178,
63,
1364,
63,
3280,
63,
842,
2298,
288,
327,
982,
4566,
2519,
2138,
376,
625,
9130,
574,
12,
886,
314,
2011,
2348,
14,
288,
372,
372,
63,
637,
267,
372,
3590,
3167,
4936,
4590,
8,
1107,
63,
637,
12,
291,
14,
10828,
63,
12804,
9,
339,
347,
636,
1250,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
1487,
4170,
2335,
370,
3590,
3167,
4936,
12,
2066,
14511,
314,
6770,
11785,
1083,
267,
2797,
370,
282,
570,
14,
398,
408,
267,
372,
63,
637,
275,
291,
14,
1178,
63,
1364,
63,
3280,
63,
842,
855,
1250,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
793,
63,
1250,
342,
267,
372,
372,
63,
637,
339,
347,
485,
793,
63,
1250,
8,
277,
304,
267,
8985,
63,
765,
275,
291,
14,
1178,
63,
1364,
63,
3280,
63,
842,
423,
1364,
63,
354,
398,
340,
291,
14,
10828,
63,
12804,
26,
288,
543,
1551,
8,
277,
14,
10828,
63,
12804,
12,
283,
65,
7386,
2644,
534,
1624,
24,
358,
465,
289,
26,
355,
289,
14,
952,
3647,
83,
60,
78,
2,
450,
8985,
63,
765,
9,
339,
347,
636,
22062,
721,
277,
12,
3847,
63,
2302,
304,
267,
372,
3590,
3167,
4936,
4590,
8,
277,
14,
1178,
63,
1364,
63,
3280,
63,
842,
1182,
3847,
63,
2302,
12,
4318,
291,
14,
10828,
63,
12804,
9,
339,
347,
664,
63,
1069,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
423,
793,
63,
1250,
342,
267,
372,
291,
14,
1178,
63,
1364,
63,
3280,
63,
842,
14,
362,
63,
1069,
2031,
589,
12,
1011,
958,
9,
199,
199,
318,
664,
63,
1501,
8,
3475,
12,
302,
63,
932,
304,
272,
408,
272,
2372,
282,
1788,
3747,
370,
314,
511,
2112,
2870,
436,
1031,
14,
339,
961,
570,
911,
1395,
282,
769,
402,
11785,
3718,
24295,
14,
272,
408,
272,
4422,
275,
620,
8,
736,
14,
17829,
1012,
272,
372,
747,
14,
515,
14,
904,
8,
267,
9017,
12,
298,
10828,
14,
3150,
5,
83,
14,
932,
5,
83,
14,
2424,
2,
450,
334,
3150,
12,
620,
8,
78,
63,
932,
1724,
421,
199,
318,
2218,
63,
452,
63,
4354,
63,
4405,
8,
3475,
12,
1031,
304,
272,
408,
272,
6990,
734,
282,
769,
402,
1006,
11785,
3423,
2808,
315,
658,
22816,
13,
2764,
64,
367,
272,
11745,
9132,
14,
961,
911,
1454,
5992,
5403,
1126,
11745,
272,
2082,
14,
339,
3033,
26,
267,
9017,
334,
495,
304,
7937,
511,
2935,
267,
1031,
334,
2817,
3167,
4936,
304,
1890,
339,
1803,
26,
267,
2155,
14,
340,
314,
11785,
3217,
570,
1990,
5313,
14,
339,
408,
272,
1788,
275,
747,
14,
515,
14,
904,
8,
3475,
12,
26901,
6013,
63,
15440,
9,
339,
340,
747,
14,
515,
14,
6292,
8,
1501,
304,
267,
372,
756,
339,
1720,
63,
1199,
275,
1031,
14,
3437,
1252,
1294,
2258,
78,
358,
272,
3718,
275,
663,
342,
339,
367,
1004,
315,
1720,
63,
1199,
26,
267,
1004,
275,
1004,
14,
1913,
342,
398,
327,
14092,
4596,
83,
436,
2323,
267,
340,
1004,
436,
440,
1004,
14,
2460,
360,
534,
304,
288,
3718,
14,
525,
3647,
83,
60,
78,
2,
450,
1004,
14,
1294,
3430,
16,
566,
339,
543,
1551,
8,
1501,
12,
283,
87,
297,
2644,
534,
1624,
24,
358,
465,
289,
26,
267,
289,
14,
23277,
8,
513,
8,
4405,
430,
339,
372,
715,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
6900,
13,
9261,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
22905,
367,
9689,
11745,
11284,
641,
314,
11785,
3217,
14,
199,
199,
17473,
282,
4340,
370,
4426,
1314,
11785,
3718,
787,
444,
281,
559,
939,
5309,
199,
4776,
14,
199,
624,
199,
199,
646,
747,
421,
199,
31177,
63,
15440,
275,
283,
4354,
63,
3266,
14,
2424,
7,
421,
199,
533,
3590,
3167,
4936,
4590,
837,
272,
408,
272,
1626,
909,
626,
14018,
3590,
3167,
4936,
370,
2777,
2488,
11785,
4882,
14,
339,
408,
272,
347,
636,
826,
721,
277,
12,
1790,
63,
1364,
63,
3280,
63,
842,
12,
11745,
63,
12804,
29,
403,
304,
267,
408,
267,
1804,
87,
589,
26,
288,
1790,
63,
1364,
63,
3280,
63,
842,
334,
2817,
3167,
4936,
304,
314,
1256,
355,
3769,
8072,
14,
288,
11745,
63,
12804,
334,
495,
304,
340,
2013,
12,
2218,
1924,
2435,
63,
354,
355,
734,
370,
282,
570,
1380,
2797,
14,
398,
408,
267,
291,
14,
1178,
63,
1364,
63,
3280,
63,
842,
275,
1790,
63,
1364,
63,
3280,
63,
842,
267,
291,
14,
10828,
63,
12804,
275,
11745,
63,
12804,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
63,
637,
275,
2519,
8,
277,
14,
1178,
63,
1364,
63,
3280,
63,
842,
12,
536,
9,
267,
340,
440,
1228,
8,
1107,
63,
637,
12,
730,
8,
277,
14,
1178,
63,
1364,
63,
3280,
63,
842,
2298,
288,
327,
982,
4566,
2519,
2138,
376,
625,
9130,
574,
12,
886,
314,
2011,
2348,
14,
288,
372,
372,
63,
637,
267,
372,
3590,
3167,
4936,
4590,
8,
1107,
63,
637,
12,
291,
14,
10828,
63,
12804,
9,
339,
347,
636,
1250,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
1487,
4170,
2335,
370,
3590,
3167,
4936,
12,
2066,
14511,
314,
6770,
11785,
1083,
267,
2797,
370,
282,
570,
14,
398,
408,
267,
372,
63,
637,
275,
291,
14,
1178,
63,
1364,
63,
3280,
63,
842,
855,
1250,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
793,
63,
1250,
342,
267,
372,
372,
63,
637,
339,
347,
485,
793,
63,
1250,
8,
277,
304,
267,
8985,
63,
765,
275,
291,
14,
1178,
63,
1364,
63,
3280,
63,
842,
423,
1364,
63,
354,
398,
340,
291,
14,
10828,
63,
12804,
26,
288,
543,
1551,
8,
277,
14,
10828,
63,
12804,
12,
283,
65,
7386,
2644,
534,
1624,
24,
358,
465,
289,
26,
355,
289,
14,
952,
3647,
83,
60,
78,
2,
450,
8985,
63,
765,
9,
339,
347,
636,
22062,
721,
277,
12,
3847,
63,
2302,
304,
267,
372,
3590,
3167,
4936,
4590,
8,
277,
14,
1178,
63,
1364,
63,
3280,
63,
842,
1182,
3847,
63,
2302,
12,
4318,
291,
14,
10828,
63,
12804,
9,
339,
347,
664,
63,
1069,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
423,
793,
63,
1250,
342,
267,
372,
291,
14,
1178,
63,
1364,
63,
3280,
63,
842,
14,
362,
63,
1069,
2031,
589,
12,
1011,
958,
9,
199,
199,
318,
664,
63,
1501,
8,
3475,
12,
302,
63,
932,
304,
272,
408,
272,
2372,
282,
1788,
3747,
370,
314,
511,
2112,
2870,
436,
1031,
14,
339,
961,
570,
911,
1395,
282,
769,
402,
11785,
3718,
24295,
14,
272,
408,
272,
4422,
275,
620,
8,
736,
14,
17829,
1012,
272,
372,
747,
14,
515,
14,
904,
8,
267,
9017,
12,
298,
10828,
14,
3150,
5,
83,
14,
932,
5,
83,
14,
2424,
2,
450,
334,
3150,
12,
620,
8,
78,
63,
932,
1724,
421,
199,
318,
2218,
63,
452,
63,
4354,
63,
4405,
8,
3475,
12,
1031,
304,
272,
408,
272,
6990,
734,
282,
769,
402,
1006,
11785,
3423,
2808,
315,
658,
22816,
13,
2764,
64,
367,
272,
11745,
9132,
14,
961,
911,
1454,
5992,
5403,
1126,
11745,
272,
2082,
14,
339,
3033,
26,
267,
9017,
334,
495,
304,
7937,
511,
2935,
267,
1031,
334,
2817,
3167,
4936,
304,
1890,
339,
1803,
26,
267,
2155,
14,
340,
314,
11785,
3217,
570,
1990,
5313,
14,
339,
408,
272,
1788,
275,
747,
14,
515,
14,
904,
8,
3475,
12,
26901,
6013,
63,
15440,
9,
339,
340,
747,
14,
515,
14,
6292,
8,
1501,
304,
267,
372,
756,
339,
1720,
63,
1199,
275,
1031,
14,
3437,
1252,
1294,
2258,
78,
358,
272,
3718,
275,
663,
342,
339,
367,
1004,
315,
1720,
63,
1199,
26,
267,
1004,
275,
1004,
14,
1913,
342,
398,
327,
14092,
4596,
83,
436,
2323,
267,
340,
1004,
436,
440,
1004,
14,
2460,
360,
534,
304,
288,
3718,
14,
525,
3647,
83,
60,
78,
2,
450,
1004,
14,
1294,
3430,
16,
566,
339,
543,
1551,
8,
1501,
12,
283,
87,
297,
2644,
534,
1624,
24,
358,
465,
289,
26,
267,
289,
14,
23277,
8,
513,
8,
4405,
430,
339,
372,
715,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
savi-dev/quantum
|
quantum/plugins/ryu/db/models.py
|
3
|
1401
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Isaku Yamahata <yamahata at private email ne jp>
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from sqlalchemy import Column, Integer, String
from quantum.db.models import BASE
class OFPServer(BASE):
"""Openflow Server/API address"""
__tablename__ = 'ofp_server'
id = Column(Integer, primary_key=True, autoincrement=True)
address = Column(String(255)) # netloc <host ip address>:<port>
host_type = Column(String(255)) # server type
# Controller, REST_API
def __init__(self, address, host_type):
self.address = address
self.host_type = host_type
def __repr__(self):
return "<OFPServer(%s,%s,%s)>" % (self.id, self.address,
self.host_type)
|
apache-2.0
|
[
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
3,
1898,
6029,
6596,
1151,
85,
1488,
14541,
72,
419,
665,
11552,
391,
72,
419,
737,
5726,
3031,
1279,
28921,
30,
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,
504,
8335,
492,
4996,
12,
7225,
12,
2624,
199,
199,
504,
15381,
453,
14,
697,
14,
992,
492,
19721,
421,
199,
533,
16563,
3120,
8,
5825,
304,
272,
408,
4299,
1659,
7146,
15,
3735,
2287,
624,
272,
636,
10983,
363,
275,
283,
20943,
63,
1000,
7,
339,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
12,
32497,
29,
549,
9,
272,
2287,
275,
4996,
8,
1558,
8,
2299,
430,
755,
327,
10154,
665,
1102,
3384,
2287,
30,
16875,
719,
30,
272,
1591,
63,
466,
275,
4996,
8,
1558,
8,
2299,
430,
258,
327,
1654,
730,
3147,
327,
16282,
12,
14880,
63,
3735,
339,
347,
636,
826,
721,
277,
12,
2287,
12,
1591,
63,
466,
304,
267,
291,
14,
1562,
275,
2287,
267,
291,
14,
1102,
63,
466,
275,
1591,
63,
466,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
6733,
3120,
4042,
83,
8719,
83,
8719,
83,
9,
4335,
450,
334,
277,
14,
344,
12,
291,
14,
1562,
12,
5101,
291,
14,
1102,
63,
466,
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
] |
[
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
3,
1898,
6029,
6596,
1151,
85,
1488,
14541,
72,
419,
665,
11552,
391,
72,
419,
737,
5726,
3031,
1279,
28921,
30,
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,
504,
8335,
492,
4996,
12,
7225,
12,
2624,
199,
199,
504,
15381,
453,
14,
697,
14,
992,
492,
19721,
421,
199,
533,
16563,
3120,
8,
5825,
304,
272,
408,
4299,
1659,
7146,
15,
3735,
2287,
624,
272,
636,
10983,
363,
275,
283,
20943,
63,
1000,
7,
339,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
12,
32497,
29,
549,
9,
272,
2287,
275,
4996,
8,
1558,
8,
2299,
430,
755,
327,
10154,
665,
1102,
3384,
2287,
30,
16875,
719,
30,
272,
1591,
63,
466,
275,
4996,
8,
1558,
8,
2299,
430,
258,
327,
1654,
730,
3147,
327,
16282,
12,
14880,
63,
3735,
339,
347,
636,
826,
721,
277,
12,
2287,
12,
1591,
63,
466,
304,
267,
291,
14,
1562,
275,
2287,
267,
291,
14,
1102,
63,
466,
275,
1591,
63,
466,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
3886,
6733,
3120,
4042,
83,
8719,
83,
8719,
83,
9,
4335,
450,
334,
277,
14,
344,
12,
291,
14,
1562,
12,
5101,
291,
14,
1102,
63,
466,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
betoesquivel/fil2014
|
build/django/tests/csrf_tests/tests.py
|
55
|
15265
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import logging
from django.conf import settings
from django.core.context_processors import csrf
from django.http import HttpRequest, HttpResponse
from django.middleware.csrf import CsrfViewMiddleware, CSRF_KEY_LENGTH
from django.template import RequestContext, Template
from django.test import TestCase
from django.test.utils import override_settings
from django.views.decorators.csrf import csrf_exempt, requires_csrf_token, ensure_csrf_cookie
# Response/views used for CsrfResponseMiddleware and CsrfViewMiddleware tests
def post_form_response():
resp = HttpResponse(content="""
<html><body><h1>\u00a1Unicode!<form method="post"><input type="text" /></form></body></html>
""", mimetype="text/html")
return resp
def post_form_view(request):
"""A view that returns a POST form (without a token)"""
return post_form_response()
# Response/views used for template tag tests
def token_view(request):
"""A view that uses {% csrf_token %}"""
context = RequestContext(request, processors=[csrf])
template = Template("{% csrf_token %}")
return HttpResponse(template.render(context))
def non_token_view_using_request_processor(request):
"""
A view that doesn't use the token, but does use the csrf view processor.
"""
context = RequestContext(request, processors=[csrf])
template = Template("")
return HttpResponse(template.render(context))
class TestingHttpRequest(HttpRequest):
"""
A version of HttpRequest that allows us to change some things
more easily
"""
def is_secure(self):
return getattr(self, '_is_secure_override', False)
class CsrfViewMiddlewareTest(TestCase):
# The csrf token is potentially from an untrusted source, so could have
# characters that need dealing with.
_csrf_id_cookie = b"<1>\xc2\xa1"
_csrf_id = "1"
def _get_GET_no_csrf_cookie_request(self):
return TestingHttpRequest()
def _get_GET_csrf_cookie_request(self):
req = TestingHttpRequest()
req.COOKIES[settings.CSRF_COOKIE_NAME] = self._csrf_id_cookie
return req
def _get_POST_csrf_cookie_request(self):
req = self._get_GET_csrf_cookie_request()
req.method = "POST"
return req
def _get_POST_no_csrf_cookie_request(self):
req = self._get_GET_no_csrf_cookie_request()
req.method = "POST"
return req
def _get_POST_request_with_token(self):
req = self._get_POST_csrf_cookie_request()
req.POST['csrfmiddlewaretoken'] = self._csrf_id
return req
def _check_token_present(self, response, csrf_id=None):
self.assertContains(response, "name='csrfmiddlewaretoken' value='%s'" % (csrf_id or self._csrf_id))
def test_process_view_token_too_long(self):
"""
Check that if the token is longer than expected, it is ignored and
a new token is created.
"""
req = self._get_GET_no_csrf_cookie_request()
req.COOKIES[settings.CSRF_COOKIE_NAME] = 'x' * 10000000
CsrfViewMiddleware().process_view(req, token_view, (), {})
resp = token_view(req)
resp2 = CsrfViewMiddleware().process_response(req, resp)
csrf_cookie = resp2.cookies.get(settings.CSRF_COOKIE_NAME, False)
self.assertEqual(len(csrf_cookie.value), CSRF_KEY_LENGTH)
def test_process_response_get_token_used(self):
"""
When get_token is used, check that the cookie is created and headers
patched.
"""
req = self._get_GET_no_csrf_cookie_request()
# Put tests for CSRF_COOKIE_* settings here
with self.settings(CSRF_COOKIE_NAME='myname',
CSRF_COOKIE_DOMAIN='.example.com',
CSRF_COOKIE_PATH='/test/',
CSRF_COOKIE_SECURE=True,
CSRF_COOKIE_HTTPONLY=True):
# token_view calls get_token() indirectly
CsrfViewMiddleware().process_view(req, token_view, (), {})
resp = token_view(req)
resp2 = CsrfViewMiddleware().process_response(req, resp)
csrf_cookie = resp2.cookies.get('myname', False)
self.assertNotEqual(csrf_cookie, False)
self.assertEqual(csrf_cookie['domain'], '.example.com')
self.assertEqual(csrf_cookie['secure'], True)
self.assertEqual(csrf_cookie['httponly'], True)
self.assertEqual(csrf_cookie['path'], '/test/')
self.assertTrue('Cookie' in resp2.get('Vary',''))
def test_process_response_get_token_not_used(self):
"""
Check that if get_token() is not called, the view middleware does not
add a cookie.
"""
# This is important to make pages cacheable. Pages which do call
# get_token(), assuming they use the token, are not cacheable because
# the token is specific to the user
req = self._get_GET_no_csrf_cookie_request()
# non_token_view_using_request_processor does not call get_token(), but
# does use the csrf request processor. By using this, we are testing
# that the view processor is properly lazy and doesn't call get_token()
# until needed.
CsrfViewMiddleware().process_view(req, non_token_view_using_request_processor, (), {})
resp = non_token_view_using_request_processor(req)
resp2 = CsrfViewMiddleware().process_response(req, resp)
csrf_cookie = resp2.cookies.get(settings.CSRF_COOKIE_NAME, False)
self.assertEqual(csrf_cookie, False)
# Check the request processing
def test_process_request_no_csrf_cookie(self):
"""
Check that if no CSRF cookies is present, the middleware rejects the
incoming request. This will stop login CSRF.
"""
req = self._get_POST_no_csrf_cookie_request()
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(403, req2.status_code)
def test_process_request_csrf_cookie_no_token(self):
"""
Check that if a CSRF cookie is present but no token, the middleware
rejects the incoming request.
"""
req = self._get_POST_csrf_cookie_request()
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(403, req2.status_code)
def test_process_request_csrf_cookie_and_token(self):
"""
Check that if both a cookie and a token is present, the middleware lets it through.
"""
req = self._get_POST_request_with_token()
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(None, req2)
def test_process_request_csrf_cookie_no_token_exempt_view(self):
"""
Check that if a CSRF cookie is present and no token, but the csrf_exempt
decorator has been applied to the view, the middleware lets it through
"""
req = self._get_POST_csrf_cookie_request()
req2 = CsrfViewMiddleware().process_view(req, csrf_exempt(post_form_view), (), {})
self.assertEqual(None, req2)
def test_csrf_token_in_header(self):
"""
Check that we can pass in the token in a header instead of in the form
"""
req = self._get_POST_csrf_cookie_request()
req.META['HTTP_X_CSRFTOKEN'] = self._csrf_id
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(None, req2)
def test_put_and_delete_rejected(self):
"""
Tests that HTTP PUT and DELETE methods have protection
"""
req = TestingHttpRequest()
req.method = 'PUT'
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(403, req2.status_code)
req = TestingHttpRequest()
req.method = 'DELETE'
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(403, req2.status_code)
def test_put_and_delete_allowed(self):
"""
Tests that HTTP PUT and DELETE methods can get through with
X-CSRFToken and a cookie
"""
req = self._get_GET_csrf_cookie_request()
req.method = 'PUT'
req.META['HTTP_X_CSRFTOKEN'] = self._csrf_id
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(None, req2)
req = self._get_GET_csrf_cookie_request()
req.method = 'DELETE'
req.META['HTTP_X_CSRFTOKEN'] = self._csrf_id
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(None, req2)
# Tests for the template tag method
def test_token_node_no_csrf_cookie(self):
"""
Check that CsrfTokenNode works when no CSRF cookie is set
"""
req = self._get_GET_no_csrf_cookie_request()
resp = token_view(req)
self.assertEqual(resp.content, b'')
def test_token_node_empty_csrf_cookie(self):
"""
Check that we get a new token if the csrf_cookie is the empty string
"""
req = self._get_GET_no_csrf_cookie_request()
req.COOKIES[settings.CSRF_COOKIE_NAME] = b""
CsrfViewMiddleware().process_view(req, token_view, (), {})
resp = token_view(req)
self.assertNotEqual("", resp.content)
def test_token_node_with_csrf_cookie(self):
"""
Check that CsrfTokenNode works when a CSRF cookie is set
"""
req = self._get_GET_csrf_cookie_request()
CsrfViewMiddleware().process_view(req, token_view, (), {})
resp = token_view(req)
self._check_token_present(resp)
def test_get_token_for_exempt_view(self):
"""
Check that get_token still works for a view decorated with 'csrf_exempt'.
"""
req = self._get_GET_csrf_cookie_request()
CsrfViewMiddleware().process_view(req, csrf_exempt(token_view), (), {})
resp = token_view(req)
self._check_token_present(resp)
def test_get_token_for_requires_csrf_token_view(self):
"""
Check that get_token works for a view decorated solely with requires_csrf_token
"""
req = self._get_GET_csrf_cookie_request()
resp = requires_csrf_token(token_view)(req)
self._check_token_present(resp)
def test_token_node_with_new_csrf_cookie(self):
"""
Check that CsrfTokenNode works when a CSRF cookie is created by
the middleware (when one was not already present)
"""
req = self._get_GET_no_csrf_cookie_request()
CsrfViewMiddleware().process_view(req, token_view, (), {})
resp = token_view(req)
resp2 = CsrfViewMiddleware().process_response(req, resp)
csrf_cookie = resp2.cookies[settings.CSRF_COOKIE_NAME]
self._check_token_present(resp, csrf_id=csrf_cookie.value)
@override_settings(ALLOWED_HOSTS=['www.example.com'])
def test_https_bad_referer(self):
"""
Test that a POST HTTPS request with a bad referer is rejected
"""
req = self._get_POST_request_with_token()
req._is_secure_override = True
req.META['HTTP_HOST'] = 'www.example.com'
req.META['HTTP_REFERER'] = 'https://www.evil.org/somepage'
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertNotEqual(None, req2)
self.assertEqual(403, req2.status_code)
@override_settings(ALLOWED_HOSTS=['www.example.com'])
def test_https_malformed_referer(self):
"""
Test that a POST HTTPS request with a bad referer is rejected
"""
req = self._get_POST_request_with_token()
req._is_secure_override = True
req.META['HTTP_HOST'] = 'www.example.com'
req.META['HTTP_REFERER'] = 'http://http://www.example.com/'
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertNotEqual(None, req2)
self.assertEqual(403, req2.status_code)
@override_settings(ALLOWED_HOSTS=['www.example.com'])
def test_https_good_referer(self):
"""
Test that a POST HTTPS request with a good referer is accepted
"""
req = self._get_POST_request_with_token()
req._is_secure_override = True
req.META['HTTP_HOST'] = 'www.example.com'
req.META['HTTP_REFERER'] = 'https://www.example.com/somepage'
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(None, req2)
@override_settings(ALLOWED_HOSTS=['www.example.com'])
def test_https_good_referer_2(self):
"""
Test that a POST HTTPS request with a good referer is accepted
where the referer contains no trailing slash
"""
# See ticket #15617
req = self._get_POST_request_with_token()
req._is_secure_override = True
req.META['HTTP_HOST'] = 'www.example.com'
req.META['HTTP_REFERER'] = 'https://www.example.com'
req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
self.assertEqual(None, req2)
def test_ensures_csrf_cookie_no_middleware(self):
"""
Tests that ensures_csrf_cookie decorator fulfils its promise
with no middleware
"""
@ensure_csrf_cookie
def view(request):
# Doesn't insert a token or anything
return HttpResponse(content="")
req = self._get_GET_no_csrf_cookie_request()
resp = view(req)
self.assertTrue(resp.cookies.get(settings.CSRF_COOKIE_NAME, False))
self.assertTrue('Cookie' in resp.get('Vary',''))
def test_ensures_csrf_cookie_with_middleware(self):
"""
Tests that ensures_csrf_cookie decorator fulfils its promise
with the middleware enabled.
"""
@ensure_csrf_cookie
def view(request):
# Doesn't insert a token or anything
return HttpResponse(content="")
req = self._get_GET_no_csrf_cookie_request()
CsrfViewMiddleware().process_view(req, view, (), {})
resp = view(req)
resp2 = CsrfViewMiddleware().process_response(req, resp)
self.assertTrue(resp2.cookies.get(settings.CSRF_COOKIE_NAME, False))
self.assertTrue('Cookie' in resp2.get('Vary',''))
def test_ensures_csrf_cookie_no_logging(self):
"""
Tests that ensure_csrf_cookie doesn't log warnings. See #19436.
"""
@ensure_csrf_cookie
def view(request):
# Doesn't insert a token or anything
return HttpResponse(content="")
class TestHandler(logging.Handler):
def emit(self, record):
raise Exception("This shouldn't have happened!")
logger = logging.getLogger('django.request')
test_handler = TestHandler()
old_log_level = logger.level
try:
logger.addHandler(test_handler)
logger.setLevel(logging.WARNING)
req = self._get_GET_no_csrf_cookie_request()
resp = view(req)
finally:
logger.removeHandler(test_handler)
logger.setLevel(old_log_level)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
2050,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
1100,
63,
10547,
492,
19213,
199,
504,
1639,
14,
1014,
492,
20730,
12,
6183,
199,
504,
1639,
14,
5754,
14,
10088,
492,
22145,
25322,
12,
22468,
63,
3078,
63,
9127,
199,
504,
1639,
14,
1160,
492,
22538,
12,
5458,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
396,
14,
1208,
492,
4278,
63,
1751,
199,
504,
1639,
14,
4196,
14,
11582,
14,
10088,
492,
19213,
63,
25254,
12,
5074,
63,
10088,
63,
1418,
12,
4868,
63,
10088,
63,
5306,
421,
199,
3,
7232,
15,
4196,
1202,
367,
22145,
3941,
2364,
6608,
436,
22145,
25322,
2295,
199,
318,
2963,
63,
964,
63,
1310,
837,
272,
3085,
275,
6183,
8,
1317,
11916,
199,
28,
1360,
2535,
2030,
2535,
72,
17,
3072,
85,
383,
65,
17,
7087,
1,
28,
964,
1083,
628,
1932,
8186,
1210,
730,
628,
505,
2,
9109,
964,
2957,
2030,
2957,
1360,
30,
199,
7208,
12200,
628,
505,
15,
1360,
531,
272,
372,
3085,
199,
199,
318,
2963,
63,
964,
63,
1345,
8,
1069,
304,
272,
408,
33,
2455,
626,
2529,
282,
8761,
1824,
334,
7395,
282,
1526,
9471,
272,
372,
2963,
63,
964,
63,
1310,
342,
199,
199,
3,
7232,
15,
4196,
1202,
367,
1978,
1947,
2295,
199,
199,
318,
1526,
63,
1345,
8,
1069,
304,
272,
408,
33,
2455,
626,
4440,
7749,
19213,
63,
1418,
3674,
624,
272,
1067,
275,
22538,
8,
1069,
12,
21620,
1524,
10088,
566,
272,
1978,
275,
5458,
480,
3996,
19213,
63,
1418,
3674,
531,
272,
372,
6183,
8,
1160,
14,
3352,
8,
1100,
430,
199,
199,
318,
2222,
63,
1418,
63,
1345,
63,
4941,
63,
1069,
63,
6459,
8,
1069,
304,
272,
408,
272,
437,
2455,
626,
3181,
1133,
675,
314,
1526,
12,
1325,
1630,
675,
314,
19213,
2455,
12495,
14,
272,
408,
272,
1067,
275,
22538,
8,
1069,
12,
21620,
1524,
10088,
566,
272,
1978,
275,
5458,
10804,
272,
372,
6183,
8,
1160,
14,
3352,
8,
1100,
430,
199,
199,
533,
11940,
10441,
8,
10441,
304,
272,
408,
272,
437,
1015,
402,
20730,
626,
6127,
2739,
370,
1570,
2005,
7645,
272,
1655,
16174,
272,
408,
272,
347,
365,
63,
7817,
8,
277,
304,
267,
372,
2519,
8,
277,
12,
2513,
374,
63,
7817,
63,
4415,
297,
756,
9,
199,
199,
533,
22145,
25322,
774,
8,
1746,
304,
272,
327,
710,
19213,
1526,
365,
18994,
687,
376,
625,
17549,
1350,
12,
880,
4293,
1172,
272,
327,
4110,
626,
1929,
23654,
543,
14,
272,
485,
10088,
63,
344,
63,
5306,
275,
330,
17030,
17,
3072,
1812,
18,
60,
1800,
17,
2,
272,
485,
10088,
63,
344,
275,
298,
17,
2,
339,
347,
485,
362,
63,
2970,
63,
889,
63,
10088,
63,
5306,
63,
1069,
8,
277,
304,
267,
372,
11940,
10441,
342,
339,
347,
485,
362,
63,
2970,
63,
10088,
63,
5306,
63,
1069,
8,
277,
304,
267,
2648,
275,
11940,
10441,
342,
267,
2648,
14,
12189,
2563,
59,
1751,
14,
26405,
63,
13665,
63,
2339,
61,
275,
291,
423,
10088,
63,
344,
63,
5306,
267,
372,
2648,
339,
347,
485,
362,
63,
4030,
63,
10088,
63,
5306,
63,
1069,
8,
277,
304,
267,
2648,
275,
291,
423,
362,
63,
2970,
63,
10088,
63,
5306,
63,
1069,
342,
267,
2648,
14,
765,
275,
298,
4030,
2,
267,
372,
2648,
339,
347,
485,
362,
63,
4030,
63,
889,
63,
10088,
63,
5306,
63,
1069,
8,
277,
304,
267,
2648,
275,
291,
423,
362,
63,
2970,
63,
889,
63,
10088,
63,
5306,
63,
1069,
342,
267,
2648,
14,
765,
275,
298,
4030,
2,
267,
372,
2648,
339,
347,
485,
362,
63,
4030,
63,
1069,
63,
1045,
63,
1418,
8,
277,
304,
267,
2648,
275,
291,
423,
362,
63,
4030,
63,
10088,
63,
5306,
63,
1069,
342,
267,
2648,
14,
4030,
459,
10088,
5754,
1418,
418,
275,
291,
423,
10088,
63,
344,
267,
372,
2648,
339,
347,
485,
1074,
63,
1418,
63,
1881,
8,
277,
12,
1177,
12,
19213,
63,
344,
29,
403,
304,
267,
291,
14,
9535,
8,
1310,
12,
298,
354,
534,
10088,
5754,
1418,
7,
574,
9569,
83,
4065,
450,
334,
10088,
63,
344,
503,
291,
423,
10088,
63,
344,
430,
339,
347,
511,
63,
1412,
63,
1345,
63,
1418,
63,
7354,
63,
2809,
8,
277,
304,
267,
408,
267,
2670,
626,
340,
314,
1526,
365,
8088,
2419,
1420,
12,
652,
365,
5525,
436,
267,
282,
892,
1526,
365,
2737,
14,
267,
408,
267,
2648,
275,
291,
423,
362,
63,
2970,
63,
889,
63,
10088,
63,
5306,
63,
1069,
342,
267,
2648,
14,
12189,
2563,
59,
1751,
14,
26405,
63,
13665,
63,
2339,
61,
275,
283,
88,
7,
627,
413,
9084,
267,
22145,
25322,
1252,
1412,
63,
1345,
8,
2103,
12,
1526,
63,
1345,
12,
11969,
5009,
267,
3085,
275,
1526,
63,
1345,
8,
2103,
9,
267,
3085,
18,
275,
22145,
25322,
1252,
1412,
63,
1310,
8,
2103,
12,
3085,
9,
267,
19213,
63,
5306,
275,
3085,
18,
14,
7792,
14,
362,
8,
1751,
14,
26405,
63,
13665,
63,
2339,
12,
756,
9,
267,
291,
14,
629,
8,
552,
8,
10088,
63,
5306,
14,
585,
395,
22468,
63,
3078,
63,
9127,
9,
339,
347,
511,
63,
1412,
63,
1310,
63,
362,
63,
1418,
63,
2972,
8,
277,
304,
267,
408,
267,
3979,
664,
63,
1418,
365,
1202,
12,
1104,
626,
314,
5494,
365,
2737,
436,
2323,
267,
19483,
14,
267,
408,
267,
2648,
275,
291,
423,
362,
63,
2970,
63,
889,
63,
10088,
63,
5306,
63,
1069,
342,
398,
327,
16280,
2295,
367,
22468,
63,
13665,
15192,
2202,
2348,
267,
543,
291,
14,
1751,
8,
26405,
63,
13665,
63,
2339,
534,
1662,
354,
297,
2574,
22468,
63,
13665,
63,
7378,
15637,
2694,
14,
957,
297,
2574,
22468,
63,
13665,
63,
3243,
8805,
396,
3678,
2574,
22468,
63,
13665,
63,
20696,
29,
549,
12,
2574,
22468,
63,
13665,
63,
2856,
10452,
29,
549,
304,
288,
327,
1526,
63,
1345,
4882,
664,
63,
1418,
342,
19458,
590,
288,
22145,
25322,
1252,
1412,
63,
1345,
8,
2103,
12,
1526,
63,
1345,
12,
11969,
5009
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
2050,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
1100,
63,
10547,
492,
19213,
199,
504,
1639,
14,
1014,
492,
20730,
12,
6183,
199,
504,
1639,
14,
5754,
14,
10088,
492,
22145,
25322,
12,
22468,
63,
3078,
63,
9127,
199,
504,
1639,
14,
1160,
492,
22538,
12,
5458,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
396,
14,
1208,
492,
4278,
63,
1751,
199,
504,
1639,
14,
4196,
14,
11582,
14,
10088,
492,
19213,
63,
25254,
12,
5074,
63,
10088,
63,
1418,
12,
4868,
63,
10088,
63,
5306,
421,
199,
3,
7232,
15,
4196,
1202,
367,
22145,
3941,
2364,
6608,
436,
22145,
25322,
2295,
199,
318,
2963,
63,
964,
63,
1310,
837,
272,
3085,
275,
6183,
8,
1317,
11916,
199,
28,
1360,
2535,
2030,
2535,
72,
17,
3072,
85,
383,
65,
17,
7087,
1,
28,
964,
1083,
628,
1932,
8186,
1210,
730,
628,
505,
2,
9109,
964,
2957,
2030,
2957,
1360,
30,
199,
7208,
12200,
628,
505,
15,
1360,
531,
272,
372,
3085,
199,
199,
318,
2963,
63,
964,
63,
1345,
8,
1069,
304,
272,
408,
33,
2455,
626,
2529,
282,
8761,
1824,
334,
7395,
282,
1526,
9471,
272,
372,
2963,
63,
964,
63,
1310,
342,
199,
199,
3,
7232,
15,
4196,
1202,
367,
1978,
1947,
2295,
199,
199,
318,
1526,
63,
1345,
8,
1069,
304,
272,
408,
33,
2455,
626,
4440,
7749,
19213,
63,
1418,
3674,
624,
272,
1067,
275,
22538,
8,
1069,
12,
21620,
1524,
10088,
566,
272,
1978,
275,
5458,
480,
3996,
19213,
63,
1418,
3674,
531,
272,
372,
6183,
8,
1160,
14,
3352,
8,
1100,
430,
199,
199,
318,
2222,
63,
1418,
63,
1345,
63,
4941,
63,
1069,
63,
6459,
8,
1069,
304,
272,
408,
272,
437,
2455,
626,
3181,
1133,
675,
314,
1526,
12,
1325,
1630,
675,
314,
19213,
2455,
12495,
14,
272,
408,
272,
1067,
275,
22538,
8,
1069,
12,
21620,
1524,
10088,
566,
272,
1978,
275,
5458,
10804,
272,
372,
6183,
8,
1160,
14,
3352,
8,
1100,
430,
199,
199,
533,
11940,
10441,
8,
10441,
304,
272,
408,
272,
437,
1015,
402,
20730,
626,
6127,
2739,
370,
1570,
2005,
7645,
272,
1655,
16174,
272,
408,
272,
347,
365,
63,
7817,
8,
277,
304,
267,
372,
2519,
8,
277,
12,
2513,
374,
63,
7817,
63,
4415,
297,
756,
9,
199,
199,
533,
22145,
25322,
774,
8,
1746,
304,
272,
327,
710,
19213,
1526,
365,
18994,
687,
376,
625,
17549,
1350,
12,
880,
4293,
1172,
272,
327,
4110,
626,
1929,
23654,
543,
14,
272,
485,
10088,
63,
344,
63,
5306,
275,
330,
17030,
17,
3072,
1812,
18,
60,
1800,
17,
2,
272,
485,
10088,
63,
344,
275,
298,
17,
2,
339,
347,
485,
362,
63,
2970,
63,
889,
63,
10088,
63,
5306,
63,
1069,
8,
277,
304,
267,
372,
11940,
10441,
342,
339,
347,
485,
362,
63,
2970,
63,
10088,
63,
5306,
63,
1069,
8,
277,
304,
267,
2648,
275,
11940,
10441,
342,
267,
2648,
14,
12189,
2563,
59,
1751,
14,
26405,
63,
13665,
63,
2339,
61,
275,
291,
423,
10088,
63,
344,
63,
5306,
267,
372,
2648,
339,
347,
485,
362,
63,
4030,
63,
10088,
63,
5306,
63,
1069,
8,
277,
304,
267,
2648,
275,
291,
423,
362,
63,
2970,
63,
10088,
63,
5306,
63,
1069,
342,
267,
2648,
14,
765,
275,
298,
4030,
2,
267,
372,
2648,
339,
347,
485,
362,
63,
4030,
63,
889,
63,
10088,
63,
5306,
63,
1069,
8,
277,
304,
267,
2648,
275,
291,
423,
362,
63,
2970,
63,
889,
63,
10088,
63,
5306,
63,
1069,
342,
267,
2648,
14,
765,
275,
298,
4030,
2,
267,
372,
2648,
339,
347,
485,
362,
63,
4030,
63,
1069,
63,
1045,
63,
1418,
8,
277,
304,
267,
2648,
275,
291,
423,
362,
63,
4030,
63,
10088,
63,
5306,
63,
1069,
342,
267,
2648,
14,
4030,
459,
10088,
5754,
1418,
418,
275,
291,
423,
10088,
63,
344,
267,
372,
2648,
339,
347,
485,
1074,
63,
1418,
63,
1881,
8,
277,
12,
1177,
12,
19213,
63,
344,
29,
403,
304,
267,
291,
14,
9535,
8,
1310,
12,
298,
354,
534,
10088,
5754,
1418,
7,
574,
9569,
83,
4065,
450,
334,
10088,
63,
344,
503,
291,
423,
10088,
63,
344,
430,
339,
347,
511,
63,
1412,
63,
1345,
63,
1418,
63,
7354,
63,
2809,
8,
277,
304,
267,
408,
267,
2670,
626,
340,
314,
1526,
365,
8088,
2419,
1420,
12,
652,
365,
5525,
436,
267,
282,
892,
1526,
365,
2737,
14,
267,
408,
267,
2648,
275,
291,
423,
362,
63,
2970,
63,
889,
63,
10088,
63,
5306,
63,
1069,
342,
267,
2648,
14,
12189,
2563,
59,
1751,
14,
26405,
63,
13665,
63,
2339,
61,
275,
283,
88,
7,
627,
413,
9084,
267,
22145,
25322,
1252,
1412,
63,
1345,
8,
2103,
12,
1526,
63,
1345,
12,
11969,
5009,
267,
3085,
275,
1526,
63,
1345,
8,
2103,
9,
267,
3085,
18,
275,
22145,
25322,
1252,
1412,
63,
1310,
8,
2103,
12,
3085,
9,
267,
19213,
63,
5306,
275,
3085,
18,
14,
7792,
14,
362,
8,
1751,
14,
26405,
63,
13665,
63,
2339,
12,
756,
9,
267,
291,
14,
629,
8,
552,
8,
10088,
63,
5306,
14,
585,
395,
22468,
63,
3078,
63,
9127,
9,
339,
347,
511,
63,
1412,
63,
1310,
63,
362,
63,
1418,
63,
2972,
8,
277,
304,
267,
408,
267,
3979,
664,
63,
1418,
365,
1202,
12,
1104,
626,
314,
5494,
365,
2737,
436,
2323,
267,
19483,
14,
267,
408,
267,
2648,
275,
291,
423,
362,
63,
2970,
63,
889,
63,
10088,
63,
5306,
63,
1069,
342,
398,
327,
16280,
2295,
367,
22468,
63,
13665,
15192,
2202,
2348,
267,
543,
291,
14,
1751,
8,
26405,
63,
13665,
63,
2339,
534,
1662,
354,
297,
2574,
22468,
63,
13665,
63,
7378,
15637,
2694,
14,
957,
297,
2574,
22468,
63,
13665,
63,
3243,
8805,
396,
3678,
2574,
22468,
63,
13665,
63,
20696,
29,
549,
12,
2574,
22468,
63,
13665,
63,
2856,
10452,
29,
549,
304,
288,
327,
1526,
63,
1345,
4882,
664,
63,
1418,
342,
19458,
590,
288,
22145,
25322,
1252,
1412,
63,
1345,
8,
2103,
12,
1526,
63,
1345,
12,
11969,
5009,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jhawkesworth/ansible
|
test/units/modules/source_control/test_bitbucket_pipeline_key_pair.py
|
37
|
8552
|
from ansible.module_utils.source_control.bitbucket import BitbucketHelper
from ansible.modules.source_control.bitbucket import bitbucket_pipeline_key_pair
from units.compat import unittest
from units.compat.mock import patch
from units.modules.utils import AnsibleFailJson, AnsibleExitJson, ModuleTestCase, set_module_args
class TestBucketPipelineKeyPairModule(ModuleTestCase):
def setUp(self):
super(TestBucketPipelineKeyPairModule, self).setUp()
self.module = bitbucket_pipeline_key_pair
def test_missing_keys_with_present_state(self):
with self.assertRaises(AnsibleFailJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'state': 'present',
})
self.module.main()
self.assertEqual(exec_info.exception.args[0]['msg'], self.module.error_messages['required_keys'])
@patch.object(BitbucketHelper, 'fetch_access_token', return_value='token')
@patch.object(bitbucket_pipeline_key_pair, 'get_existing_ssh_key_pair', return_value=None)
def test_create_keys(self, *args):
with patch.object(self.module, 'update_ssh_key_pair') as update_ssh_key_pair_mock:
with self.assertRaises(AnsibleExitJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'public_key': 'public',
'private_key': 'PRIVATE',
'state': 'present',
})
self.module.main()
self.assertEqual(update_ssh_key_pair_mock.call_count, 1)
self.assertEqual(exec_info.exception.args[0]['changed'], True)
@patch.object(BitbucketHelper, 'fetch_access_token', return_value='token')
@patch.object(bitbucket_pipeline_key_pair, 'get_existing_ssh_key_pair', return_value=None)
def test_create_keys_check_mode(self, *args):
with patch.object(self.module, 'update_ssh_key_pair') as update_ssh_key_pair_mock:
with self.assertRaises(AnsibleExitJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'public_key': 'public',
'private_key': 'PRIVATE',
'state': 'present',
'_ansible_check_mode': True,
})
self.module.main()
self.assertEqual(update_ssh_key_pair_mock.call_count, 0)
self.assertEqual(exec_info.exception.args[0]['changed'], True)
@patch.object(BitbucketHelper, 'fetch_access_token', return_value='token')
@patch.object(bitbucket_pipeline_key_pair, 'get_existing_ssh_key_pair', return_value={
'public_key': 'unknown',
'type': 'pipeline_ssh_key_pair',
})
def test_update_keys(self, *args):
with patch.object(self.module, 'update_ssh_key_pair') as update_ssh_key_pair_mock:
with self.assertRaises(AnsibleExitJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'public_key': 'public',
'private_key': 'PRIVATE',
'state': 'present',
})
self.module.main()
self.assertEqual(update_ssh_key_pair_mock.call_count, 1)
self.assertEqual(exec_info.exception.args[0]['changed'], True)
@patch.object(BitbucketHelper, 'fetch_access_token', return_value='token')
@patch.object(bitbucket_pipeline_key_pair, 'get_existing_ssh_key_pair', return_value={
'public_key': 'public',
'type': 'pipeline_ssh_key_pair',
})
def test_dont_update_same_key(self, *args):
with patch.object(self.module, 'update_ssh_key_pair') as update_ssh_key_pair_mock:
with self.assertRaises(AnsibleExitJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'public_key': 'public',
'private_key': 'PRIVATE',
'state': 'present',
})
self.module.main()
self.assertEqual(update_ssh_key_pair_mock.call_count, 0)
self.assertEqual(exec_info.exception.args[0]['changed'], False)
@patch.object(BitbucketHelper, 'fetch_access_token', return_value='token')
@patch.object(bitbucket_pipeline_key_pair, 'get_existing_ssh_key_pair', return_value={
'public_key': 'unknown',
'type': 'pipeline_ssh_key_pair',
})
def test_update_keys_check_mode(self, *args):
with patch.object(self.module, 'update_ssh_key_pair') as update_ssh_key_pair_mock:
with self.assertRaises(AnsibleExitJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'public_key': 'public',
'private_key': 'PRIVATE',
'state': 'present',
'_ansible_check_mode': True,
})
self.module.main()
self.assertEqual(update_ssh_key_pair_mock.call_count, 0)
self.assertEqual(exec_info.exception.args[0]['changed'], True)
@patch.object(BitbucketHelper, 'fetch_access_token', return_value='token')
@patch.object(bitbucket_pipeline_key_pair, 'get_existing_ssh_key_pair', return_value={
'public_key': 'public',
'type': 'pipeline_ssh_key_pair',
})
def test_delete_keys(self, *args):
with patch.object(self.module, 'delete_ssh_key_pair') as delete_ssh_key_pair_mock:
with self.assertRaises(AnsibleExitJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'state': 'absent',
})
self.module.main()
self.assertEqual(delete_ssh_key_pair_mock.call_count, 1)
self.assertEqual(exec_info.exception.args[0]['changed'], True)
@patch.object(BitbucketHelper, 'fetch_access_token', return_value='token')
@patch.object(bitbucket_pipeline_key_pair, 'get_existing_ssh_key_pair', return_value=None)
def test_delete_absent_keys(self, *args):
with patch.object(self.module, 'delete_ssh_key_pair') as delete_ssh_key_pair_mock:
with self.assertRaises(AnsibleExitJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'state': 'absent',
})
self.module.main()
self.assertEqual(delete_ssh_key_pair_mock.call_count, 0)
self.assertEqual(exec_info.exception.args[0]['changed'], False)
@patch.object(BitbucketHelper, 'fetch_access_token', return_value='token')
@patch.object(bitbucket_pipeline_key_pair, 'get_existing_ssh_key_pair', return_value={
'public_key': 'public',
'type': 'pipeline_ssh_key_pair',
})
def test_delete_keys_check_mode(self, *args):
with patch.object(self.module, 'delete_ssh_key_pair') as delete_ssh_key_pair_mock:
with self.assertRaises(AnsibleExitJson) as exec_info:
set_module_args({
'client_id': 'ABC',
'client_secret': 'XXX',
'username': 'name',
'repository': 'repo',
'state': 'absent',
'_ansible_check_mode': True,
})
self.module.main()
self.assertEqual(delete_ssh_key_pair_mock.call_count, 0)
self.assertEqual(exec_info.exception.args[0]['changed'], True)
if __name__ == '__main__':
unittest.main()
|
gpl-3.0
|
[
504,
3242,
14,
578,
63,
1208,
14,
1365,
63,
2785,
14,
25668,
492,
10199,
4623,
4433,
199,
504,
3242,
14,
3112,
14,
1365,
63,
2785,
14,
25668,
492,
4546,
4623,
63,
7379,
63,
498,
63,
3852,
199,
504,
6204,
14,
5819,
492,
2882,
199,
504,
6204,
14,
5819,
14,
1805,
492,
3371,
199,
504,
6204,
14,
3112,
14,
1208,
492,
2622,
4874,
9653,
12,
2622,
6699,
9653,
12,
5673,
1746,
12,
663,
63,
578,
63,
589,
421,
199,
533,
1379,
12311,
17562,
1197,
12882,
2377,
8,
2377,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
12311,
17562,
1197,
12882,
2377,
12,
291,
680,
5996,
342,
267,
291,
14,
578,
275,
4546,
4623,
63,
7379,
63,
498,
63,
3852,
339,
347,
511,
63,
4752,
63,
1612,
63,
1045,
63,
1881,
63,
929,
8,
277,
304,
267,
543,
291,
14,
1855,
8,
10047,
4874,
9653,
9,
465,
2146,
63,
815,
26,
288,
663,
63,
578,
63,
589,
2561,
355,
283,
1258,
63,
344,
356,
283,
8390,
297,
355,
283,
1258,
63,
4731,
356,
283,
13933,
297,
355,
283,
2473,
356,
283,
354,
297,
355,
283,
8421,
356,
283,
3417,
297,
355,
283,
929,
356,
283,
1881,
297,
288,
3828,
288,
291,
14,
578,
14,
973,
342,
398,
291,
14,
629,
8,
1628,
63,
815,
14,
1971,
14,
589,
59,
16,
2733,
1328,
995,
291,
14,
578,
14,
705,
63,
3431,
459,
2427,
63,
1612,
1105,
339,
768,
2068,
14,
785,
8,
4734,
4623,
4433,
12,
283,
3535,
63,
2732,
63,
1418,
297,
372,
63,
585,
534,
1418,
358,
272,
768,
2068,
14,
785,
8,
25668,
63,
7379,
63,
498,
63,
3852,
12,
283,
362,
63,
5952,
63,
5510,
63,
498,
63,
3852,
297,
372,
63,
585,
29,
403,
9,
272,
347,
511,
63,
981,
63,
1612,
8,
277,
12,
627,
589,
304,
267,
543,
3371,
14,
785,
8,
277,
14,
578,
12,
283,
873,
63,
5510,
63,
498,
63,
3852,
358,
465,
1678,
63,
5510,
63,
498,
63,
3852,
63,
1805,
26,
288,
543,
291,
14,
1855,
8,
10047,
6699,
9653,
9,
465,
2146,
63,
815,
26,
355,
663,
63,
578,
63,
589,
2561,
490,
283,
1258,
63,
344,
356,
283,
8390,
297,
490,
283,
1258,
63,
4731,
356,
283,
13933,
297,
490,
283,
2473,
356,
283,
354,
297,
490,
283,
8421,
356,
283,
3417,
297,
490,
283,
3455,
63,
498,
356,
283,
3455,
297,
490,
283,
4239,
63,
498,
356,
283,
18748,
297,
490,
283,
929,
356,
283,
1881,
297,
355,
3828,
355,
291,
14,
578,
14,
973,
342,
953,
291,
14,
629,
8,
873,
63,
5510,
63,
498,
63,
3852,
63,
1805,
14,
1250,
63,
835,
12,
413,
9,
288,
291,
14,
629,
8,
1628,
63,
815,
14,
1971,
14,
589,
59,
16,
2733,
2489,
995,
715,
9,
339,
768,
2068,
14,
785,
8,
4734,
4623,
4433,
12,
283,
3535,
63,
2732,
63,
1418,
297,
372,
63,
585,
534,
1418,
358,
272,
768,
2068,
14,
785,
8,
25668,
63,
7379,
63,
498,
63,
3852,
12,
283,
362,
63,
5952,
63,
5510,
63,
498,
63,
3852,
297,
372,
63,
585,
29,
403,
9,
272,
347,
511,
63,
981,
63,
1612,
63,
1074,
63,
632,
8,
277,
12,
627,
589,
304,
267,
543,
3371,
14,
785,
8,
277,
14,
578,
12,
283,
873,
63,
5510,
63,
498,
63,
3852,
358,
465,
1678,
63,
5510,
63,
498,
63,
3852,
63,
1805,
26,
288,
543,
291,
14,
1855,
8,
10047,
6699,
9653,
9,
465,
2146,
63,
815,
26,
355,
663,
63,
578,
63,
589,
2561,
490,
283,
1258,
63,
344,
356,
283,
8390,
297,
490,
283,
1258,
63,
4731,
356,
283,
13933,
297,
490,
283,
2473,
356,
283,
354,
297,
490,
283,
8421,
356,
283,
3417,
297,
490,
283,
3455,
63,
498,
356,
283,
3455,
297,
490,
283,
4239,
63,
498,
356,
283,
18748,
297,
490,
283,
929,
356,
283,
1881,
297,
490,
2513,
4853,
63,
1074,
63,
632,
356,
715,
12,
355,
3828,
355,
291,
14,
578,
14,
973,
342,
953,
291,
14,
629,
8,
873,
63,
5510,
63,
498,
63,
3852,
63,
1805,
14,
1250,
63,
835,
12,
378,
9,
288,
291,
14,
629,
8,
1628,
63,
815,
14,
1971,
14,
589,
59,
16,
2733,
2489,
995,
715,
9,
339,
768,
2068,
14,
785,
8,
4734,
4623,
4433,
12,
283,
3535,
63,
2732,
63,
1418,
297,
372,
63,
585,
534,
1418,
358,
272,
768,
2068,
14,
785,
8,
25668,
63,
7379,
63,
498,
63,
3852,
12,
283,
362,
63,
5952,
63,
5510,
63,
498,
63,
3852,
297,
372,
63,
585,
3126,
267,
283,
3455,
63,
498,
356,
283,
5187,
297,
267,
283,
466,
356,
283,
7379,
63,
5510,
63,
498,
63,
3852,
297,
272,
3828,
272,
347,
511,
63,
873,
63,
1612,
8,
277,
12,
627,
589,
304,
267,
543,
3371,
14,
785,
8,
277,
14,
578,
12,
283,
873,
63,
5510,
63,
498,
63,
3852,
358,
465,
1678,
63,
5510,
63,
498,
63,
3852,
63,
1805,
26,
288,
543,
291,
14,
1855,
8,
10047,
6699,
9653,
9,
465,
2146,
63,
815,
26,
355,
663,
63,
578,
63,
589,
2561,
490,
283,
1258,
63,
344,
356,
283,
8390,
297,
490,
283,
1258,
63,
4731,
356,
283,
13933,
297,
490,
283,
2473,
356,
283,
354,
297,
490,
283,
8421,
356,
283,
3417,
297,
490,
283,
3455,
63,
498,
356,
283,
3455,
297,
490,
283,
4239,
63,
498,
356,
283,
18748,
297,
490,
283,
929,
356,
283,
1881,
297,
355,
3828,
355,
291,
14,
578,
14,
973,
342,
953,
291,
14,
629,
8,
873,
63,
5510,
63,
498,
63,
3852,
63,
1805,
14,
1250,
63,
835,
12,
413,
9,
288,
291,
14,
629,
8,
1628,
63,
815,
14,
1971,
14,
589,
59,
16,
2733,
2489,
995,
715,
9,
339,
768,
2068,
14,
785,
8,
4734,
4623,
4433,
12,
283,
3535,
63,
2732,
63,
1418,
297,
372,
63,
585,
534,
1418,
358,
272,
768,
2068,
14,
785,
8,
25668,
63,
7379,
63,
498,
63,
3852,
12,
283,
362,
63,
5952,
63,
5510,
63,
498,
63,
3852,
297,
372,
63,
585,
3126,
267,
283,
3455,
63,
498,
356,
283,
3455,
297,
267,
283,
466,
356,
283,
7379,
63,
5510,
63,
498,
63,
3852,
297,
272,
3828
] |
[
3242,
14,
578,
63,
1208,
14,
1365,
63,
2785,
14,
25668,
492,
10199,
4623,
4433,
199,
504,
3242,
14,
3112,
14,
1365,
63,
2785,
14,
25668,
492,
4546,
4623,
63,
7379,
63,
498,
63,
3852,
199,
504,
6204,
14,
5819,
492,
2882,
199,
504,
6204,
14,
5819,
14,
1805,
492,
3371,
199,
504,
6204,
14,
3112,
14,
1208,
492,
2622,
4874,
9653,
12,
2622,
6699,
9653,
12,
5673,
1746,
12,
663,
63,
578,
63,
589,
421,
199,
533,
1379,
12311,
17562,
1197,
12882,
2377,
8,
2377,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
12311,
17562,
1197,
12882,
2377,
12,
291,
680,
5996,
342,
267,
291,
14,
578,
275,
4546,
4623,
63,
7379,
63,
498,
63,
3852,
339,
347,
511,
63,
4752,
63,
1612,
63,
1045,
63,
1881,
63,
929,
8,
277,
304,
267,
543,
291,
14,
1855,
8,
10047,
4874,
9653,
9,
465,
2146,
63,
815,
26,
288,
663,
63,
578,
63,
589,
2561,
355,
283,
1258,
63,
344,
356,
283,
8390,
297,
355,
283,
1258,
63,
4731,
356,
283,
13933,
297,
355,
283,
2473,
356,
283,
354,
297,
355,
283,
8421,
356,
283,
3417,
297,
355,
283,
929,
356,
283,
1881,
297,
288,
3828,
288,
291,
14,
578,
14,
973,
342,
398,
291,
14,
629,
8,
1628,
63,
815,
14,
1971,
14,
589,
59,
16,
2733,
1328,
995,
291,
14,
578,
14,
705,
63,
3431,
459,
2427,
63,
1612,
1105,
339,
768,
2068,
14,
785,
8,
4734,
4623,
4433,
12,
283,
3535,
63,
2732,
63,
1418,
297,
372,
63,
585,
534,
1418,
358,
272,
768,
2068,
14,
785,
8,
25668,
63,
7379,
63,
498,
63,
3852,
12,
283,
362,
63,
5952,
63,
5510,
63,
498,
63,
3852,
297,
372,
63,
585,
29,
403,
9,
272,
347,
511,
63,
981,
63,
1612,
8,
277,
12,
627,
589,
304,
267,
543,
3371,
14,
785,
8,
277,
14,
578,
12,
283,
873,
63,
5510,
63,
498,
63,
3852,
358,
465,
1678,
63,
5510,
63,
498,
63,
3852,
63,
1805,
26,
288,
543,
291,
14,
1855,
8,
10047,
6699,
9653,
9,
465,
2146,
63,
815,
26,
355,
663,
63,
578,
63,
589,
2561,
490,
283,
1258,
63,
344,
356,
283,
8390,
297,
490,
283,
1258,
63,
4731,
356,
283,
13933,
297,
490,
283,
2473,
356,
283,
354,
297,
490,
283,
8421,
356,
283,
3417,
297,
490,
283,
3455,
63,
498,
356,
283,
3455,
297,
490,
283,
4239,
63,
498,
356,
283,
18748,
297,
490,
283,
929,
356,
283,
1881,
297,
355,
3828,
355,
291,
14,
578,
14,
973,
342,
953,
291,
14,
629,
8,
873,
63,
5510,
63,
498,
63,
3852,
63,
1805,
14,
1250,
63,
835,
12,
413,
9,
288,
291,
14,
629,
8,
1628,
63,
815,
14,
1971,
14,
589,
59,
16,
2733,
2489,
995,
715,
9,
339,
768,
2068,
14,
785,
8,
4734,
4623,
4433,
12,
283,
3535,
63,
2732,
63,
1418,
297,
372,
63,
585,
534,
1418,
358,
272,
768,
2068,
14,
785,
8,
25668,
63,
7379,
63,
498,
63,
3852,
12,
283,
362,
63,
5952,
63,
5510,
63,
498,
63,
3852,
297,
372,
63,
585,
29,
403,
9,
272,
347,
511,
63,
981,
63,
1612,
63,
1074,
63,
632,
8,
277,
12,
627,
589,
304,
267,
543,
3371,
14,
785,
8,
277,
14,
578,
12,
283,
873,
63,
5510,
63,
498,
63,
3852,
358,
465,
1678,
63,
5510,
63,
498,
63,
3852,
63,
1805,
26,
288,
543,
291,
14,
1855,
8,
10047,
6699,
9653,
9,
465,
2146,
63,
815,
26,
355,
663,
63,
578,
63,
589,
2561,
490,
283,
1258,
63,
344,
356,
283,
8390,
297,
490,
283,
1258,
63,
4731,
356,
283,
13933,
297,
490,
283,
2473,
356,
283,
354,
297,
490,
283,
8421,
356,
283,
3417,
297,
490,
283,
3455,
63,
498,
356,
283,
3455,
297,
490,
283,
4239,
63,
498,
356,
283,
18748,
297,
490,
283,
929,
356,
283,
1881,
297,
490,
2513,
4853,
63,
1074,
63,
632,
356,
715,
12,
355,
3828,
355,
291,
14,
578,
14,
973,
342,
953,
291,
14,
629,
8,
873,
63,
5510,
63,
498,
63,
3852,
63,
1805,
14,
1250,
63,
835,
12,
378,
9,
288,
291,
14,
629,
8,
1628,
63,
815,
14,
1971,
14,
589,
59,
16,
2733,
2489,
995,
715,
9,
339,
768,
2068,
14,
785,
8,
4734,
4623,
4433,
12,
283,
3535,
63,
2732,
63,
1418,
297,
372,
63,
585,
534,
1418,
358,
272,
768,
2068,
14,
785,
8,
25668,
63,
7379,
63,
498,
63,
3852,
12,
283,
362,
63,
5952,
63,
5510,
63,
498,
63,
3852,
297,
372,
63,
585,
3126,
267,
283,
3455,
63,
498,
356,
283,
5187,
297,
267,
283,
466,
356,
283,
7379,
63,
5510,
63,
498,
63,
3852,
297,
272,
3828,
272,
347,
511,
63,
873,
63,
1612,
8,
277,
12,
627,
589,
304,
267,
543,
3371,
14,
785,
8,
277,
14,
578,
12,
283,
873,
63,
5510,
63,
498,
63,
3852,
358,
465,
1678,
63,
5510,
63,
498,
63,
3852,
63,
1805,
26,
288,
543,
291,
14,
1855,
8,
10047,
6699,
9653,
9,
465,
2146,
63,
815,
26,
355,
663,
63,
578,
63,
589,
2561,
490,
283,
1258,
63,
344,
356,
283,
8390,
297,
490,
283,
1258,
63,
4731,
356,
283,
13933,
297,
490,
283,
2473,
356,
283,
354,
297,
490,
283,
8421,
356,
283,
3417,
297,
490,
283,
3455,
63,
498,
356,
283,
3455,
297,
490,
283,
4239,
63,
498,
356,
283,
18748,
297,
490,
283,
929,
356,
283,
1881,
297,
355,
3828,
355,
291,
14,
578,
14,
973,
342,
953,
291,
14,
629,
8,
873,
63,
5510,
63,
498,
63,
3852,
63,
1805,
14,
1250,
63,
835,
12,
413,
9,
288,
291,
14,
629,
8,
1628,
63,
815,
14,
1971,
14,
589,
59,
16,
2733,
2489,
995,
715,
9,
339,
768,
2068,
14,
785,
8,
4734,
4623,
4433,
12,
283,
3535,
63,
2732,
63,
1418,
297,
372,
63,
585,
534,
1418,
358,
272,
768,
2068,
14,
785,
8,
25668,
63,
7379,
63,
498,
63,
3852,
12,
283,
362,
63,
5952,
63,
5510,
63,
498,
63,
3852,
297,
372,
63,
585,
3126,
267,
283,
3455,
63,
498,
356,
283,
3455,
297,
267,
283,
466,
356,
283,
7379,
63,
5510,
63,
498,
63,
3852,
297,
272,
3828,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
afrolov1/nova
|
nova/tests/api/openstack/compute/contrib/test_baremetal_nodes.py
|
22
|
14672
|
# Copyright (c) 2013 NTT DOCOMO, INC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from webob import exc
from nova.api.openstack.compute.contrib import baremetal_nodes
from nova.api.openstack import extensions
from nova import context
from nova import exception
from nova import test
from nova.virt.baremetal import db
class FakeRequest(object):
def __init__(self, context):
self.environ = {"nova.context": context}
def fake_node(**updates):
node = {
'id': 1,
'service_host': "host",
'cpus': 8,
'memory_mb': 8192,
'local_gb': 128,
'pm_address': "10.1.2.3",
'pm_user': "pm_user",
'pm_password': "pm_pass",
'terminal_port': 8000,
'interfaces': [],
'instance_uuid': 'fake-instance-uuid',
}
if updates:
node.update(updates)
return node
def fake_node_ext_status(**updates):
node = fake_node(uuid='fake-uuid',
task_state='fake-task-state',
updated_at='fake-updated-at',
pxe_config_path='fake-pxe-config-path')
if updates:
node.update(updates)
return node
def fake_interface(**updates):
interface = {
'id': 1,
'address': '11:11:11:11:11:11',
'datapath_id': 2,
'port_no': 3,
}
if updates:
interface.update(updates)
return interface
class BareMetalNodesTest(test.NoDBTestCase):
def setUp(self):
super(BareMetalNodesTest, self).setUp()
self.ext_mgr = self.mox.CreateMock(extensions.ExtensionManager)
self.context = context.get_admin_context()
self.controller = baremetal_nodes.BareMetalNodeController(self.ext_mgr)
self.request = FakeRequest(self.context)
def _test_create(self, node, ext_status=False):
response = node.copy()
del response['pm_password']
response['instance_uuid'] = None
self.mox.StubOutWithMock(db, 'bm_node_create')
db.bm_node_create(self.context, node).AndReturn(response)
self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(ext_status)
self.mox.ReplayAll()
res_dict = self.controller.create(self.request, {'node': node})
self.assertEqual({'node': response}, res_dict)
def _test_show(self, node, ext_status=False):
interfaces = [fake_interface(id=1, address='11:11:11:11:11:11'),
fake_interface(id=2, address='22:22:22:22:22:22'),
]
node.update(interfaces=interfaces)
response = node.copy()
del response['pm_password']
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get(self.context, node['id']).AndReturn(node)
db.bm_interface_get_all_by_bm_node_id(self.context, node['id']).\
AndReturn(interfaces)
self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(ext_status)
self.mox.ReplayAll()
res_dict = self.controller.show(self.request, node['id'])
self.assertEqual({'node': response}, res_dict)
self.assertEqual(2, len(res_dict['node']['interfaces']))
def _test_show_no_interfaces(self, ext_status=False):
node_id = 1
node = {'id': node_id}
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get(self.context, node_id).AndReturn(node)
db.bm_interface_get_all_by_bm_node_id(self.context, node_id).\
AndRaise(exception.NodeNotFound(node_id=node_id))
self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(ext_status)
self.mox.ReplayAll()
res_dict = self.controller.show(self.request, node_id)
self.assertEqual(node_id, res_dict['node']['id'])
self.assertEqual(0, len(res_dict['node']['interfaces']))
def _test_index(self, ext_status=False):
nodes = [{'id': 1},
{'id': 2},
]
interfaces = [{'id': 1, 'address': '11:11:11:11:11:11'},
{'id': 2, 'address': '22:22:22:22:22:22'},
]
self.mox.StubOutWithMock(db, 'bm_node_get_all')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get_all(self.context).AndReturn(nodes)
db.bm_interface_get_all_by_bm_node_id(self.context, 1).\
AndRaise(exception.NodeNotFound(node_id=1))
for n in nodes:
self.ext_mgr.is_loaded('os-baremetal-ext-status').\
AndReturn(ext_status)
db.bm_interface_get_all_by_bm_node_id(self.context, 2).\
AndReturn(interfaces)
self.mox.ReplayAll()
res_dict = self.controller.index(self.request)
self.assertEqual(2, len(res_dict['nodes']))
self.assertEqual([], res_dict['nodes'][0]['interfaces'])
self.assertEqual(2, len(res_dict['nodes'][1]['interfaces']))
def test_create(self):
node = fake_node(id=100)
self._test_create(node)
def test_create_ext_status(self):
node = fake_node_ext_status(id=100)
self._test_create(node, ext_status=True)
def test_create_with_prov_mac_address(self):
node = {
'service_host': "host",
'cpus': 8,
'memory_mb': 8192,
'local_gb': 128,
'pm_address': "10.1.2.3",
'pm_user': "pm_user",
'pm_password': "pm_pass",
'terminal_port': 8000,
'interfaces': [],
}
intf = {
'address': '1a:B2:3C:4d:e5:6f',
'datapath_id': None,
'id': None,
'port_no': None,
}
request = node.copy()
request['prov_mac_address'] = intf['address']
db_node = node.copy()
db_node['id'] = 100
response = node.copy()
response.update(id=db_node['id'],
instance_uuid=None,
interfaces=[intf])
del response['pm_password']
self.mox.StubOutWithMock(db, 'bm_node_create')
self.mox.StubOutWithMock(db, 'bm_interface_create')
self.mox.StubOutWithMock(db, 'bm_interface_get')
db.bm_node_create(self.context, node).AndReturn(db_node)
self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(False)
db.bm_interface_create(self.context,
bm_node_id=db_node['id'],
address=intf['address'],
datapath_id=intf['datapath_id'],
port_no=intf['port_no']).AndReturn(1000)
db.bm_interface_get(self.context, 1000).AndReturn(intf)
self.mox.ReplayAll()
res_dict = self.controller.create(self.request, {'node': request})
self.assertEqual({'node': response}, res_dict)
def test_create_with_invalid_prov_mac_address(self):
node = {
'service_host': "host",
'cpus': 8,
'memory_mb': 8192,
'local_gb': 128,
'pm_address': "10.1.2.3",
'pm_user': "pm_user",
'pm_password': "pm_pass",
'terminal_port': 8000,
'prov_mac_address': 'INVALID!!',
}
self.assertRaises(exc.HTTPBadRequest,
self.controller.create,
self.request, {'node': node})
def test_delete(self):
self.mox.StubOutWithMock(db, 'bm_node_destroy')
db.bm_node_destroy(self.context, 1)
self.mox.ReplayAll()
self.controller.delete(self.request, 1)
def test_delete_node_not_found(self):
self.mox.StubOutWithMock(db, 'bm_node_destroy')
db.bm_node_destroy(self.context, 1).\
AndRaise(exception.NodeNotFound(node_id=1))
self.mox.ReplayAll()
self.assertRaises(
exc.HTTPNotFound,
self.controller.delete,
self.request,
1)
def test_index(self):
self._test_index()
def test_index_ext_status(self):
self._test_index(ext_status=True)
def test_show(self):
node = fake_node(id=1)
self._test_show(node)
def test_show_ext_status(self):
node = fake_node_ext_status(id=1)
self._test_show(node, ext_status=True)
def test_show_no_interfaces(self):
self._test_show_no_interfaces()
def test_show_no_interfaces_ext_status(self):
self._test_show_no_interfaces(ext_status=True)
def test_add_interface(self):
node_id = 1
address = '11:22:33:ab:cd:ef'
body = {'add_interface': {'address': address}}
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_create')
self.mox.StubOutWithMock(db, 'bm_interface_get')
db.bm_node_get(self.context, node_id)
db.bm_interface_create(self.context,
bm_node_id=node_id,
address=address,
datapath_id=None,
port_no=None).\
AndReturn(12345)
db.bm_interface_get(self.context, 12345).\
AndReturn({'id': 12345, 'address': address})
self.mox.ReplayAll()
res_dict = self.controller._add_interface(self.request, node_id, body)
self.assertEqual(12345, res_dict['interface']['id'])
self.assertEqual(address, res_dict['interface']['address'])
def test_add_interface_invalid_address(self):
node_id = 1
body = {'add_interface': {'address': ''}}
self.mox.StubOutWithMock(db, 'bm_node_get')
db.bm_node_get(self.context, node_id)
self.mox.ReplayAll()
self.assertRaises(exc.HTTPBadRequest,
self.controller._add_interface,
self.request,
node_id,
body)
def test_remove_interface(self):
node_id = 1
interfaces = [{'id': 1},
{'id': 2},
{'id': 3},
]
body = {'remove_interface': {'id': 2}}
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
self.mox.StubOutWithMock(db, 'bm_interface_destroy')
db.bm_node_get(self.context, node_id)
db.bm_interface_get_all_by_bm_node_id(self.context, node_id).\
AndReturn(interfaces)
db.bm_interface_destroy(self.context, 2)
self.mox.ReplayAll()
self.controller._remove_interface(self.request, node_id, body)
def test_remove_interface_by_address(self):
node_id = 1
interfaces = [{'id': 1, 'address': '11:11:11:11:11:11'},
{'id': 2, 'address': '22:22:22:22:22:22'},
{'id': 3, 'address': '33:33:33:33:33:33'},
]
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
self.mox.StubOutWithMock(db, 'bm_interface_destroy')
db.bm_node_get(self.context, node_id)
db.bm_interface_get_all_by_bm_node_id(self.context, node_id).\
AndReturn(interfaces)
db.bm_interface_destroy(self.context, 2)
self.mox.ReplayAll()
body = {'remove_interface': {'address': '22:22:22:22:22:22'}}
self.controller._remove_interface(self.request, node_id, body)
def test_remove_interface_no_id_no_address(self):
node_id = 1
self.mox.StubOutWithMock(db, 'bm_node_get')
db.bm_node_get(self.context, node_id)
self.mox.ReplayAll()
body = {'remove_interface': {}}
self.assertRaises(exc.HTTPBadRequest,
self.controller._remove_interface,
self.request,
node_id,
body)
def test_add_interface_node_not_found(self):
node_id = 1
self.mox.StubOutWithMock(db, 'bm_node_get')
db.bm_node_get(self.context, node_id).\
AndRaise(exception.NodeNotFound(node_id=node_id))
self.mox.ReplayAll()
body = {'add_interface': {'address': '11:11:11:11:11:11'}}
self.assertRaises(exc.HTTPNotFound,
self.controller._add_interface,
self.request,
node_id,
body)
def test_remove_interface_node_not_found(self):
node_id = 1
self.mox.StubOutWithMock(db, 'bm_node_get')
db.bm_node_get(self.context, node_id).\
AndRaise(exception.NodeNotFound(node_id=node_id))
self.mox.ReplayAll()
body = {'remove_interface': {'address': '11:11:11:11:11:11'}}
self.assertRaises(exc.HTTPNotFound,
self.controller._remove_interface,
self.request,
node_id,
body)
def test_is_valid_mac(self):
self.assertFalse(baremetal_nodes.is_valid_mac(None))
self.assertTrue(baremetal_nodes.is_valid_mac("52:54:00:cf:2d:31"))
self.assertTrue(baremetal_nodes.is_valid_mac(u"52:54:00:cf:2d:31"))
self.assertFalse(baremetal_nodes.is_valid_mac("127.0.0.1"))
self.assertFalse(baremetal_nodes.is_valid_mac("not:a:mac:address"))
self.assertFalse(baremetal_nodes.is_valid_mac("52-54-00-cf-2d-31"))
self.assertFalse(baremetal_nodes.is_valid_mac("5254.00cf.2d31"))
self.assertFalse(baremetal_nodes.is_valid_mac("52:54:0:cf:2d:31"))
self.assertFalse(baremetal_nodes.is_valid_mac("aa bb cc dd ee ff"))
self.assertTrue(baremetal_nodes.is_valid_mac("AA:BB:CC:DD:EE:FF"))
self.assertFalse(baremetal_nodes.is_valid_mac("AA BB CC DD EE FF"))
self.assertFalse(baremetal_nodes.is_valid_mac("AA-BB-CC-DD-EE-FF"))
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6171,
653,
1481,
3506,
1439,
2679,
12,
7839,
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,
504,
14568,
492,
3178,
199,
199,
504,
5913,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
492,
18753,
22420,
63,
2415,
199,
504,
5913,
14,
1246,
14,
8512,
492,
5478,
199,
504,
5913,
492,
1067,
199,
504,
5913,
492,
1919,
199,
504,
5913,
492,
511,
199,
504,
5913,
14,
4549,
14,
14890,
22420,
492,
1592,
421,
199,
533,
7777,
2017,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1067,
304,
267,
291,
14,
2314,
275,
2420,
6765,
14,
1100,
582,
1067,
93,
421,
199,
318,
4026,
63,
932,
3682,
7618,
304,
272,
1031,
275,
469,
267,
283,
344,
356,
413,
12,
267,
283,
1364,
63,
1102,
356,
298,
1102,
401,
267,
283,
8896,
356,
1695,
12,
267,
283,
4844,
63,
887,
356,
28828,
12,
267,
283,
1832,
63,
4908,
356,
7960,
12,
267,
283,
7073,
63,
1562,
356,
298,
709,
14,
17,
14,
18,
14,
19,
401,
267,
283,
7073,
63,
751,
356,
298,
7073,
63,
751,
401,
267,
283,
7073,
63,
2060,
356,
298,
7073,
63,
1529,
401,
267,
283,
12010,
63,
719,
356,
29855,
12,
267,
283,
7436,
356,
990,
267,
283,
842,
63,
2580,
356,
283,
3183,
13,
842,
13,
2580,
297,
272,
789,
272,
340,
7029,
26,
267,
1031,
14,
873,
8,
7618,
9,
272,
372,
1031,
421,
199,
318,
4026,
63,
932,
63,
832,
63,
1205,
3682,
7618,
304,
272,
1031,
275,
4026,
63,
932,
8,
2580,
534,
3183,
13,
2580,
297,
2151,
2120,
63,
929,
534,
3183,
13,
1765,
13,
929,
297,
2151,
4588,
63,
292,
534,
3183,
13,
5334,
13,
292,
297,
2151,
299,
1845,
63,
888,
63,
515,
534,
3183,
13,
80,
1845,
13,
888,
13,
515,
358,
272,
340,
7029,
26,
267,
1031,
14,
873,
8,
7618,
9,
272,
372,
1031,
421,
199,
318,
4026,
63,
3266,
3682,
7618,
304,
272,
3217,
275,
469,
267,
283,
344,
356,
413,
12,
267,
283,
1562,
356,
283,
845,
26,
845,
26,
845,
26,
845,
26,
845,
26,
845,
297,
267,
283,
25019,
63,
344,
356,
499,
12,
267,
283,
719,
63,
889,
356,
650,
12,
272,
789,
272,
340,
7029,
26,
267,
3217,
14,
873,
8,
7618,
9,
272,
372,
3217,
421,
199,
533,
699,
1530,
4015,
279,
6300,
774,
8,
396,
14,
32437,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
34,
1530,
4015,
279,
6300,
774,
12,
291,
680,
5996,
342,
398,
291,
14,
832,
63,
7755,
275,
291,
14,
6625,
14,
2499,
3346,
8,
5359,
14,
6382,
2988,
9,
267,
291,
14,
1100,
275,
1067,
14,
362,
63,
2113,
63,
1100,
342,
267,
291,
14,
5538,
275,
18753,
22420,
63,
2415,
14,
34,
1530,
4015,
279,
1716,
7506,
8,
277,
14,
832,
63,
7755,
9,
267,
291,
14,
1069,
275,
7777,
2017,
8,
277,
14,
1100,
9,
339,
347,
485,
396,
63,
981,
8,
277,
12,
1031,
12,
1599,
63,
1205,
29,
797,
304,
267,
1177,
275,
1031,
14,
1574,
342,
267,
2150,
1177,
459,
7073,
63,
2060,
418,
267,
1177,
459,
842,
63,
2580,
418,
275,
488,
267,
291,
14,
6625,
14,
12088,
8,
697,
12,
283,
12648,
63,
932,
63,
981,
358,
267,
1592,
14,
12648,
63,
932,
63,
981,
8,
277,
14,
1100,
12,
1031,
680,
8572,
8,
1310,
9,
267,
291,
14,
832,
63,
7755,
14,
374,
63,
4591,
360,
736,
13,
14890,
22420,
13,
832,
13,
1205,
1959,
8572,
8,
832,
63,
1205,
9,
267,
291,
14,
6625,
14,
12982,
342,
267,
522,
63,
807,
275,
291,
14,
5538,
14,
981,
8,
277,
14,
1069,
12,
791,
932,
356,
1031,
1552,
267,
291,
14,
629,
3252,
932,
356,
1177,
1386,
522,
63,
807,
9,
339,
347,
485,
396,
63,
2384,
8,
277,
12,
1031,
12,
1599,
63,
1205,
29,
797,
304,
267,
8386,
275,
359,
3183,
63,
3266,
8,
344,
29,
17,
12,
2287,
534,
845,
26,
845,
26,
845,
26,
845,
26,
845,
26,
845,
659,
1993,
4026,
63,
3266,
8,
344,
29,
18,
12,
2287,
534,
1081,
26,
1081,
26,
1081,
26,
1081,
26,
1081,
26,
1081,
659,
1993,
1622,
267,
1031,
14,
873,
8,
7436,
29,
7436,
9,
267,
1177,
275,
1031,
14,
1574,
342,
267,
2150,
1177,
459,
7073,
63,
2060,
418,
267,
291,
14,
6625,
14,
12088,
8,
697,
12,
283,
12648,
63,
932,
63,
362,
358,
267,
291,
14,
6625,
14,
12088,
8,
697,
12,
283,
12648,
63,
3266,
63,
362,
63,
452,
63,
991,
63,
12648,
63,
932,
63,
344,
358,
267,
1592,
14,
12648,
63,
932,
63,
362,
8,
277,
14,
1100,
12,
1031,
459,
344,
13227,
8572,
8,
932,
9,
267,
1592,
14,
12648,
63,
3266,
63,
362,
63,
452,
63,
991,
63,
12648,
63,
932,
63,
344,
8,
277,
14,
1100,
12,
1031,
459,
344,
418,
12013,
355,
6061,
1767,
8,
7436,
9,
267,
291,
14,
832,
63,
7755,
14,
374,
63,
4591,
360,
736,
13,
14890,
22420,
13,
832,
13,
1205,
1959,
8572,
8,
832,
63,
1205,
9,
267,
291,
14,
6625,
14,
12982,
342,
267,
522,
63,
807,
275,
291,
14,
5538,
14,
2384,
8,
277,
14,
1069,
12,
1031,
459,
344,
1105,
267,
291,
14,
629,
3252,
932,
356,
1177,
1386,
522,
63,
807,
9,
267,
291,
14,
629,
8,
18
] |
[
1898,
334,
67,
9,
6171,
653,
1481,
3506,
1439,
2679,
12,
7839,
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,
504,
14568,
492,
3178,
199,
199,
504,
5913,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
492,
18753,
22420,
63,
2415,
199,
504,
5913,
14,
1246,
14,
8512,
492,
5478,
199,
504,
5913,
492,
1067,
199,
504,
5913,
492,
1919,
199,
504,
5913,
492,
511,
199,
504,
5913,
14,
4549,
14,
14890,
22420,
492,
1592,
421,
199,
533,
7777,
2017,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1067,
304,
267,
291,
14,
2314,
275,
2420,
6765,
14,
1100,
582,
1067,
93,
421,
199,
318,
4026,
63,
932,
3682,
7618,
304,
272,
1031,
275,
469,
267,
283,
344,
356,
413,
12,
267,
283,
1364,
63,
1102,
356,
298,
1102,
401,
267,
283,
8896,
356,
1695,
12,
267,
283,
4844,
63,
887,
356,
28828,
12,
267,
283,
1832,
63,
4908,
356,
7960,
12,
267,
283,
7073,
63,
1562,
356,
298,
709,
14,
17,
14,
18,
14,
19,
401,
267,
283,
7073,
63,
751,
356,
298,
7073,
63,
751,
401,
267,
283,
7073,
63,
2060,
356,
298,
7073,
63,
1529,
401,
267,
283,
12010,
63,
719,
356,
29855,
12,
267,
283,
7436,
356,
990,
267,
283,
842,
63,
2580,
356,
283,
3183,
13,
842,
13,
2580,
297,
272,
789,
272,
340,
7029,
26,
267,
1031,
14,
873,
8,
7618,
9,
272,
372,
1031,
421,
199,
318,
4026,
63,
932,
63,
832,
63,
1205,
3682,
7618,
304,
272,
1031,
275,
4026,
63,
932,
8,
2580,
534,
3183,
13,
2580,
297,
2151,
2120,
63,
929,
534,
3183,
13,
1765,
13,
929,
297,
2151,
4588,
63,
292,
534,
3183,
13,
5334,
13,
292,
297,
2151,
299,
1845,
63,
888,
63,
515,
534,
3183,
13,
80,
1845,
13,
888,
13,
515,
358,
272,
340,
7029,
26,
267,
1031,
14,
873,
8,
7618,
9,
272,
372,
1031,
421,
199,
318,
4026,
63,
3266,
3682,
7618,
304,
272,
3217,
275,
469,
267,
283,
344,
356,
413,
12,
267,
283,
1562,
356,
283,
845,
26,
845,
26,
845,
26,
845,
26,
845,
26,
845,
297,
267,
283,
25019,
63,
344,
356,
499,
12,
267,
283,
719,
63,
889,
356,
650,
12,
272,
789,
272,
340,
7029,
26,
267,
3217,
14,
873,
8,
7618,
9,
272,
372,
3217,
421,
199,
533,
699,
1530,
4015,
279,
6300,
774,
8,
396,
14,
32437,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
34,
1530,
4015,
279,
6300,
774,
12,
291,
680,
5996,
342,
398,
291,
14,
832,
63,
7755,
275,
291,
14,
6625,
14,
2499,
3346,
8,
5359,
14,
6382,
2988,
9,
267,
291,
14,
1100,
275,
1067,
14,
362,
63,
2113,
63,
1100,
342,
267,
291,
14,
5538,
275,
18753,
22420,
63,
2415,
14,
34,
1530,
4015,
279,
1716,
7506,
8,
277,
14,
832,
63,
7755,
9,
267,
291,
14,
1069,
275,
7777,
2017,
8,
277,
14,
1100,
9,
339,
347,
485,
396,
63,
981,
8,
277,
12,
1031,
12,
1599,
63,
1205,
29,
797,
304,
267,
1177,
275,
1031,
14,
1574,
342,
267,
2150,
1177,
459,
7073,
63,
2060,
418,
267,
1177,
459,
842,
63,
2580,
418,
275,
488,
267,
291,
14,
6625,
14,
12088,
8,
697,
12,
283,
12648,
63,
932,
63,
981,
358,
267,
1592,
14,
12648,
63,
932,
63,
981,
8,
277,
14,
1100,
12,
1031,
680,
8572,
8,
1310,
9,
267,
291,
14,
832,
63,
7755,
14,
374,
63,
4591,
360,
736,
13,
14890,
22420,
13,
832,
13,
1205,
1959,
8572,
8,
832,
63,
1205,
9,
267,
291,
14,
6625,
14,
12982,
342,
267,
522,
63,
807,
275,
291,
14,
5538,
14,
981,
8,
277,
14,
1069,
12,
791,
932,
356,
1031,
1552,
267,
291,
14,
629,
3252,
932,
356,
1177,
1386,
522,
63,
807,
9,
339,
347,
485,
396,
63,
2384,
8,
277,
12,
1031,
12,
1599,
63,
1205,
29,
797,
304,
267,
8386,
275,
359,
3183,
63,
3266,
8,
344,
29,
17,
12,
2287,
534,
845,
26,
845,
26,
845,
26,
845,
26,
845,
26,
845,
659,
1993,
4026,
63,
3266,
8,
344,
29,
18,
12,
2287,
534,
1081,
26,
1081,
26,
1081,
26,
1081,
26,
1081,
26,
1081,
659,
1993,
1622,
267,
1031,
14,
873,
8,
7436,
29,
7436,
9,
267,
1177,
275,
1031,
14,
1574,
342,
267,
2150,
1177,
459,
7073,
63,
2060,
418,
267,
291,
14,
6625,
14,
12088,
8,
697,
12,
283,
12648,
63,
932,
63,
362,
358,
267,
291,
14,
6625,
14,
12088,
8,
697,
12,
283,
12648,
63,
3266,
63,
362,
63,
452,
63,
991,
63,
12648,
63,
932,
63,
344,
358,
267,
1592,
14,
12648,
63,
932,
63,
362,
8,
277,
14,
1100,
12,
1031,
459,
344,
13227,
8572,
8,
932,
9,
267,
1592,
14,
12648,
63,
3266,
63,
362,
63,
452,
63,
991,
63,
12648,
63,
932,
63,
344,
8,
277,
14,
1100,
12,
1031,
459,
344,
418,
12013,
355,
6061,
1767,
8,
7436,
9,
267,
291,
14,
832,
63,
7755,
14,
374,
63,
4591,
360,
736,
13,
14890,
22420,
13,
832,
13,
1205,
1959,
8572,
8,
832,
63,
1205,
9,
267,
291,
14,
6625,
14,
12982,
342,
267,
522,
63,
807,
275,
291,
14,
5538,
14,
2384,
8,
277,
14,
1069,
12,
1031,
459,
344,
1105,
267,
291,
14,
629,
3252,
932,
356,
1177,
1386,
522,
63,
807,
9,
267,
291,
14,
629,
8,
18,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
snakeleon/YouCompleteMe-x64
|
third_party/ycmd/third_party/jedi_deps/parso/parso/pgen2/generator.py
|
2
|
14570
|
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Modifications:
# Copyright David Halter and Contributors
# Modifications are dual-licensed: MIT and PSF.
"""
This module defines the data structures used to represent a grammar.
Specifying grammars in pgen is possible with this grammar::
grammar: (NEWLINE | rule)* ENDMARKER
rule: NAME ':' rhs NEWLINE
rhs: items ('|' items)*
items: item+
item: '[' rhs ']' | atom ['+' | '*']
atom: '(' rhs ')' | NAME | STRING
This grammar is self-referencing.
This parser generator (pgen2) was created by Guido Rossum and used for lib2to3.
Most of the code has been refactored to make it more Pythonic. Since this was a
"copy" of the CPython Parser parser "pgen", there was some work needed to make
it more readable. It should also be slightly faster than the original pgen2,
because we made some optimizations.
"""
from ast import literal_eval
from typing import TypeVar, Generic, Mapping, Sequence, Set, Union
from parso.pgen2.grammar_parser import GrammarParser, NFAState
_TokenTypeT = TypeVar("_TokenTypeT")
class Grammar(Generic[_TokenTypeT]):
"""
Once initialized, this class supplies the grammar tables for the
parsing engine implemented by parse.py. The parsing engine
accesses the instance variables directly.
The only important part in this parsers are dfas and transitions between
dfas.
"""
def __init__(self,
start_nonterminal: str,
rule_to_dfas: Mapping[str, Sequence['DFAState[_TokenTypeT]']],
reserved_syntax_strings: Mapping[str, 'ReservedString']):
self.nonterminal_to_dfas = rule_to_dfas
self.reserved_syntax_strings = reserved_syntax_strings
self.start_nonterminal = start_nonterminal
class DFAPlan:
"""
Plans are used for the parser to create stack nodes and do the proper
DFA state transitions.
"""
def __init__(self, next_dfa: 'DFAState', dfa_pushes: Sequence['DFAState'] = []):
self.next_dfa = next_dfa
self.dfa_pushes = dfa_pushes
def __repr__(self):
return '%s(%s, %s)' % (self.__class__.__name__, self.next_dfa, self.dfa_pushes)
class DFAState(Generic[_TokenTypeT]):
"""
The DFAState object is the core class for pretty much anything. DFAState
are the vertices of an ordered graph while arcs and transitions are the
edges.
Arcs are the initial edges, where most DFAStates are not connected and
transitions are then calculated to connect the DFA state machines that have
different nonterminals.
"""
def __init__(self, from_rule: str, nfa_set: Set[NFAState], final: NFAState):
assert isinstance(nfa_set, set)
assert isinstance(next(iter(nfa_set)), NFAState)
assert isinstance(final, NFAState)
self.from_rule = from_rule
self.nfa_set = nfa_set
# map from terminals/nonterminals to DFAState
self.arcs: Mapping[str, DFAState] = {}
# In an intermediary step we set these nonterminal arcs (which has the
# same structure as arcs). These don't contain terminals anymore.
self.nonterminal_arcs: Mapping[str, DFAState] = {}
# Transitions are basically the only thing that the parser is using
# with is_final. Everyting else is purely here to create a parser.
self.transitions: Mapping[Union[_TokenTypeT, ReservedString], DFAPlan] = {}
self.is_final = final in nfa_set
def add_arc(self, next_, label):
assert isinstance(label, str)
assert label not in self.arcs
assert isinstance(next_, DFAState)
self.arcs[label] = next_
def unifystate(self, old, new):
for label, next_ in self.arcs.items():
if next_ is old:
self.arcs[label] = new
def __eq__(self, other):
# Equality test -- ignore the nfa_set instance variable
assert isinstance(other, DFAState)
if self.is_final != other.is_final:
return False
# Can't just return self.arcs == other.arcs, because that
# would invoke this method recursively, with cycles...
if len(self.arcs) != len(other.arcs):
return False
for label, next_ in self.arcs.items():
if next_ is not other.arcs.get(label):
return False
return True
def __repr__(self):
return '<%s: %s is_final=%s>' % (
self.__class__.__name__, self.from_rule, self.is_final
)
class ReservedString:
"""
Most grammars will have certain keywords and operators that are mentioned
in the grammar as strings (e.g. "if") and not token types (e.g. NUMBER).
This class basically is the former.
"""
def __init__(self, value: str):
self.value = value
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, self.value)
def _simplify_dfas(dfas):
"""
This is not theoretically optimal, but works well enough.
Algorithm: repeatedly look for two states that have the same
set of arcs (same labels pointing to the same nodes) and
unify them, until things stop changing.
dfas is a list of DFAState instances
"""
changes = True
while changes:
changes = False
for i, state_i in enumerate(dfas):
for j in range(i + 1, len(dfas)):
state_j = dfas[j]
if state_i == state_j:
del dfas[j]
for state in dfas:
state.unifystate(state_j, state_i)
changes = True
break
def _make_dfas(start, finish):
"""
Uses the powerset construction algorithm to create DFA states from sets of
NFA states.
Also does state reduction if some states are not needed.
"""
# To turn an NFA into a DFA, we define the states of the DFA
# to correspond to *sets* of states of the NFA. Then do some
# state reduction.
assert isinstance(start, NFAState)
assert isinstance(finish, NFAState)
def addclosure(nfa_state, base_nfa_set):
assert isinstance(nfa_state, NFAState)
if nfa_state in base_nfa_set:
return
base_nfa_set.add(nfa_state)
for nfa_arc in nfa_state.arcs:
if nfa_arc.nonterminal_or_string is None:
addclosure(nfa_arc.next, base_nfa_set)
base_nfa_set = set()
addclosure(start, base_nfa_set)
states = [DFAState(start.from_rule, base_nfa_set, finish)]
for state in states: # NB states grows while we're iterating
arcs = {}
# Find state transitions and store them in arcs.
for nfa_state in state.nfa_set:
for nfa_arc in nfa_state.arcs:
if nfa_arc.nonterminal_or_string is not None:
nfa_set = arcs.setdefault(nfa_arc.nonterminal_or_string, set())
addclosure(nfa_arc.next, nfa_set)
# Now create the dfa's with no None's in arcs anymore. All Nones have
# been eliminated and state transitions (arcs) are properly defined, we
# just need to create the dfa's.
for nonterminal_or_string, nfa_set in arcs.items():
for nested_state in states:
if nested_state.nfa_set == nfa_set:
# The DFA state already exists for this rule.
break
else:
nested_state = DFAState(start.from_rule, nfa_set, finish)
states.append(nested_state)
state.add_arc(nested_state, nonterminal_or_string)
return states # List of DFAState instances; first one is start
def _dump_nfa(start, finish):
print("Dump of NFA for", start.from_rule)
todo = [start]
for i, state in enumerate(todo):
print(" State", i, state is finish and "(final)" or "")
for arc in state.arcs:
label, next_ = arc.nonterminal_or_string, arc.next
if next_ in todo:
j = todo.index(next_)
else:
j = len(todo)
todo.append(next_)
if label is None:
print(" -> %d" % j)
else:
print(" %s -> %d" % (label, j))
def _dump_dfas(dfas):
print("Dump of DFA for", dfas[0].from_rule)
for i, state in enumerate(dfas):
print(" State", i, state.is_final and "(final)" or "")
for nonterminal, next_ in state.arcs.items():
print(" %s -> %d" % (nonterminal, dfas.index(next_)))
def generate_grammar(bnf_grammar: str, token_namespace) -> Grammar:
"""
``bnf_text`` is a grammar in extended BNF (using * for repetition, + for
at-least-once repetition, [] for optional parts, | for alternatives and ()
for grouping).
It's not EBNF according to ISO/IEC 14977. It's a dialect Python uses in its
own parser.
"""
rule_to_dfas = {}
start_nonterminal = None
for nfa_a, nfa_z in GrammarParser(bnf_grammar).parse():
# _dump_nfa(nfa_a, nfa_z)
dfas = _make_dfas(nfa_a, nfa_z)
# _dump_dfas(dfas)
# oldlen = len(dfas)
_simplify_dfas(dfas)
# newlen = len(dfas)
rule_to_dfas[nfa_a.from_rule] = dfas
# print(nfa_a.from_rule, oldlen, newlen)
if start_nonterminal is None:
start_nonterminal = nfa_a.from_rule
reserved_strings: Mapping[str, ReservedString] = {}
for nonterminal, dfas in rule_to_dfas.items():
for dfa_state in dfas:
for terminal_or_nonterminal, next_dfa in dfa_state.arcs.items():
if terminal_or_nonterminal in rule_to_dfas:
dfa_state.nonterminal_arcs[terminal_or_nonterminal] = next_dfa
else:
transition = _make_transition(
token_namespace,
reserved_strings,
terminal_or_nonterminal
)
dfa_state.transitions[transition] = DFAPlan(next_dfa)
_calculate_tree_traversal(rule_to_dfas)
return Grammar(start_nonterminal, rule_to_dfas, reserved_strings) # type: ignore
def _make_transition(token_namespace, reserved_syntax_strings, label):
"""
Creates a reserved string ("if", "for", "*", ...) or returns the token type
(NUMBER, STRING, ...) for a given grammar terminal.
"""
if label[0].isalpha():
# A named token (e.g. NAME, NUMBER, STRING)
return getattr(token_namespace, label)
else:
# Either a keyword or an operator
assert label[0] in ('"', "'"), label
assert not label.startswith('"""') and not label.startswith("'''")
value = literal_eval(label)
try:
return reserved_syntax_strings[value]
except KeyError:
r = reserved_syntax_strings[value] = ReservedString(value)
return r
def _calculate_tree_traversal(nonterminal_to_dfas):
"""
By this point we know how dfas can move around within a stack node, but we
don't know how we can add a new stack node (nonterminal transitions).
"""
# Map from grammar rule (nonterminal) name to a set of tokens.
first_plans = {}
nonterminals = list(nonterminal_to_dfas.keys())
nonterminals.sort()
for nonterminal in nonterminals:
if nonterminal not in first_plans:
_calculate_first_plans(nonterminal_to_dfas, first_plans, nonterminal)
# Now that we have calculated the first terminals, we are sure that
# there is no left recursion.
for dfas in nonterminal_to_dfas.values():
for dfa_state in dfas:
transitions = dfa_state.transitions
for nonterminal, next_dfa in dfa_state.nonterminal_arcs.items():
for transition, pushes in first_plans[nonterminal].items():
if transition in transitions:
prev_plan = transitions[transition]
# Make sure these are sorted so that error messages are
# at least deterministic
choices = sorted([
(
prev_plan.dfa_pushes[0].from_rule
if prev_plan.dfa_pushes
else prev_plan.next_dfa.from_rule
),
(
pushes[0].from_rule
if pushes else next_dfa.from_rule
),
])
raise ValueError(
"Rule %s is ambiguous; given a %s token, we "
"can't determine if we should evaluate %s or %s."
% (
(
dfa_state.from_rule,
transition,
) + tuple(choices)
)
)
transitions[transition] = DFAPlan(next_dfa, pushes)
def _calculate_first_plans(nonterminal_to_dfas, first_plans, nonterminal):
"""
Calculates the first plan in the first_plans dictionary for every given
nonterminal. This is going to be used to know when to create stack nodes.
"""
dfas = nonterminal_to_dfas[nonterminal]
new_first_plans = {}
first_plans[nonterminal] = None # dummy to detect left recursion
# We only need to check the first dfa. All the following ones are not
# interesting to find first terminals.
state = dfas[0]
for transition, next_ in state.transitions.items():
# It's a string. We have finally found a possible first token.
new_first_plans[transition] = [next_.next_dfa]
for nonterminal2, next_ in state.nonterminal_arcs.items():
# It's a nonterminal and we have either a left recursion issue
# in the grammar or we have to recurse.
try:
first_plans2 = first_plans[nonterminal2]
except KeyError:
first_plans2 = _calculate_first_plans(nonterminal_to_dfas, first_plans, nonterminal2)
else:
if first_plans2 is None:
raise ValueError("left recursion for rule %r" % nonterminal)
for t, pushes in first_plans2.items():
new_first_plans[t] = [next_] + pushes
first_plans[nonterminal] = new_first_plans
return new_first_plans
|
gpl-3.0
|
[
3,
1898,
8353,
13,
9397,
6566,
279,
13863,
12,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
3909,
370,
29770,
1334,
282,
17636,
28629,
14,
199,
199,
3,
12972,
3477,
83,
26,
199,
3,
1898,
20232,
869,
11858,
436,
23212,
199,
3,
12972,
3477,
83,
787,
21164,
13,
1682,
68,
26,
10697,
436,
29770,
14,
199,
199,
624,
199,
2765,
859,
7890,
314,
666,
13955,
1202,
370,
2954,
282,
12528,
14,
199,
199,
17768,
316,
1999,
596,
4291,
315,
299,
2268,
365,
3962,
543,
642,
12528,
447,
339,
12528,
26,
334,
28758,
1204,
2332,
3342,
7729,
18997,
272,
2332,
26,
13637,
10871,
9085,
18689,
6174,
272,
9085,
26,
2974,
661,
5227,
2974,
3342,
272,
2974,
26,
1242,
11,
272,
1242,
26,
22640,
9085,
24840,
1204,
6222,
788,
4786,
1204,
6438,
418,
272,
6222,
26,
16746,
9085,
16107,
1204,
13637,
1204,
18661,
199,
199,
2765,
12528,
365,
291,
13,
264,
21532,
14,
199,
199,
2765,
1798,
4306,
334,
80,
2268,
18,
9,
1990,
2737,
701,
598,
1535,
79,
6848,
385,
453,
436,
1202,
367,
1973,
18,
475,
19,
14,
199,
24625,
402,
314,
1233,
965,
2757,
295,
7783,
2908,
370,
1852,
652,
1655,
2018,
530,
14,
9336,
642,
1990,
282,
199,
2,
1574,
2,
402,
314,
25654,
10191,
1798,
298,
80,
2268,
401,
2337,
1990,
2005,
1736,
4346,
370,
1852,
199,
390,
1655,
12701,
14,
2779,
1077,
2597,
506,
18023,
12930,
2419,
314,
3379,
299,
2268,
18,
12,
199,
20684,
781,
6326,
2005,
5323,
12270,
14,
199,
624,
199,
199,
504,
6073,
492,
8785,
63,
2579,
199,
504,
14090,
492,
2434,
5894,
12,
8307,
12,
12340,
12,
10975,
12,
2494,
12,
15961,
199,
199,
504,
623,
1152,
14,
80,
2268,
18,
14,
15239,
63,
2087,
492,
10268,
9992,
2842,
12,
653,
2078,
2223,
199,
199,
63,
3264,
804,
52,
275,
2434,
5894,
11008,
3264,
804,
52,
531,
421,
199,
533,
10268,
9992,
8,
9417,
13040,
3264,
804,
52,
4682,
272,
408,
272,
19468,
10038,
12,
642,
1021,
4973,
6528,
314,
12528,
6716,
367,
314,
272,
6057,
6869,
6366,
701,
2198,
14,
647,
14,
221,
710,
6057,
6869,
272,
1066,
5804,
314,
1256,
2860,
5370,
14,
339,
710,
1454,
11012,
1777,
315,
642,
21295,
787,
4051,
305,
436,
19077,
3382,
272,
4051,
305,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
326,
1343,
63,
2865,
12010,
26,
620,
12,
326,
2332,
63,
475,
63,
1587,
305,
26,
12340,
59,
495,
12,
10975,
459,
36,
2078,
2223,
13040,
3264,
804,
52,
61,
2157,
326,
4644,
63,
7093,
63,
5465,
26,
12340,
59,
495,
12,
283,
10285,
1558,
9090,
267,
291,
14,
2865,
12010,
63,
475,
63,
1587,
305,
275,
2332,
63,
475,
63,
1587,
305,
267,
291,
14,
10421,
63,
7093,
63,
5465,
275,
4644,
63,
7093,
63,
5465,
267,
291,
14,
928,
63,
2865,
12010,
275,
1343,
63,
2865,
12010,
421,
199,
533,
577,
38,
1282,
1502,
26,
272,
408,
272,
7497,
796,
787,
1202,
367,
314,
1798,
370,
1218,
3464,
3380,
436,
886,
314,
5576,
272,
577,
2078,
1174,
19077,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
2163,
63,
26520,
26,
283,
36,
2078,
2223,
297,
366,
667,
63,
5335,
397,
26,
10975,
459,
36,
2078,
2223,
418,
275,
12319,
267,
291,
14,
2184,
63,
26520,
275,
2163,
63,
26520,
267,
291,
14,
26520,
63,
5335,
397,
275,
366,
667,
63,
5335,
397,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
83,
12,
450,
83,
3171,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
14,
2184,
63,
26520,
12,
291,
14,
26520,
63,
5335,
397,
9,
421,
199,
533,
577,
2078,
2223,
8,
9417,
13040,
3264,
804,
52,
4682,
272,
408,
272,
710,
577,
2078,
2223,
909,
365,
314,
6170,
1021,
367,
7268,
8298,
7003,
14,
577,
2078,
2223,
272,
787,
314,
14971,
402,
376,
7741,
3343,
1830,
601,
1259,
436,
19077,
787,
314,
272,
8207,
14,
339,
437,
1195,
83,
787,
314,
2536,
8207,
12,
2382,
4750,
577,
2078,
18010,
787,
440,
8539,
436,
272,
19077,
787,
2066,
12950,
370,
4907,
314,
577,
2078,
1174,
20601,
626,
1172,
272,
3365,
2222,
24322,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
687,
63,
2200,
26,
620,
12,
302,
667,
63,
409,
26,
2494,
59,
46,
2078,
2223,
467,
4242,
26,
653,
2078,
2223,
304,
267,
702,
1228,
8,
78,
667,
63,
409,
12,
663,
9,
267,
702,
1228,
8,
2184,
8,
1661,
8,
78,
667,
63,
409,
1826,
653,
2078,
2223,
9,
267,
702,
1228,
8,
5094,
12,
653,
2078,
2223,
9,
267,
291,
14,
504,
63,
2200,
275,
687,
63,
2200,
267,
291,
14,
78,
667,
63,
409,
275,
302,
667,
63,
409,
267,
327,
2341,
687,
5537,
2551,
15,
2865,
24322,
370,
577,
2078,
2223,
267,
291,
14,
20672,
26,
12340,
59,
495,
12,
577,
2078,
2223,
61,
275,
1052,
267,
327,
1010,
376,
1640,
30747,
3650,
781,
663,
3520,
2222,
12010,
601,
1259,
334,
6777,
965,
314,
267,
327,
2011,
5523,
465,
601,
1259,
680,
5723,
2793,
1133,
1395,
5537,
2551,
20827,
14,
267,
291,
14,
2865,
12010,
63,
20672,
26,
12340,
59,
495,
12,
577,
2078,
2223,
61,
275,
1052,
398,
327,
19894,
6150,
787,
26014,
314,
1454,
8377,
626,
221,
314,
1798,
365,
1808,
267,
327,
543,
365,
63,
5094,
14,
18414,
1337,
587,
365,
15111,
590,
2348,
370,
1218,
282,
1798,
14,
267,
291,
14,
23062,
26,
12340,
59,
15540,
13040,
3264,
804,
52,
12,
5702,
1558,
467,
577,
38,
1282,
1502,
61,
275,
1052,
267,
291,
14,
374,
63,
5094,
275,
4242,
315,
302,
667,
63,
409,
339,
347,
1050,
63,
9912,
8,
277,
12,
2163,
3131,
1768,
304,
267,
702,
1228,
8,
1302,
12,
620,
9,
267,
702,
1768,
440,
315,
291,
14,
20672,
267,
702,
1228,
8,
2184,
3131,
577,
2078,
2223,
9,
267,
291,
14,
20672,
59,
1302,
61,
275,
2163,
63,
339,
347,
625,
2021,
929,
8,
277,
12,
2269,
12,
892,
304,
267,
367,
1768,
12,
2163,
63,
315,
291,
14,
20672,
14,
1744,
837,
288,
340,
2163,
63,
365,
2269,
26,
355,
291,
14,
20672,
59,
1302,
61,
275,
892,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267
] |
[
1898,
8353,
13,
9397,
6566,
279,
13863,
12,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
3909,
370,
29770,
1334,
282,
17636,
28629,
14,
199,
199,
3,
12972,
3477,
83,
26,
199,
3,
1898,
20232,
869,
11858,
436,
23212,
199,
3,
12972,
3477,
83,
787,
21164,
13,
1682,
68,
26,
10697,
436,
29770,
14,
199,
199,
624,
199,
2765,
859,
7890,
314,
666,
13955,
1202,
370,
2954,
282,
12528,
14,
199,
199,
17768,
316,
1999,
596,
4291,
315,
299,
2268,
365,
3962,
543,
642,
12528,
447,
339,
12528,
26,
334,
28758,
1204,
2332,
3342,
7729,
18997,
272,
2332,
26,
13637,
10871,
9085,
18689,
6174,
272,
9085,
26,
2974,
661,
5227,
2974,
3342,
272,
2974,
26,
1242,
11,
272,
1242,
26,
22640,
9085,
24840,
1204,
6222,
788,
4786,
1204,
6438,
418,
272,
6222,
26,
16746,
9085,
16107,
1204,
13637,
1204,
18661,
199,
199,
2765,
12528,
365,
291,
13,
264,
21532,
14,
199,
199,
2765,
1798,
4306,
334,
80,
2268,
18,
9,
1990,
2737,
701,
598,
1535,
79,
6848,
385,
453,
436,
1202,
367,
1973,
18,
475,
19,
14,
199,
24625,
402,
314,
1233,
965,
2757,
295,
7783,
2908,
370,
1852,
652,
1655,
2018,
530,
14,
9336,
642,
1990,
282,
199,
2,
1574,
2,
402,
314,
25654,
10191,
1798,
298,
80,
2268,
401,
2337,
1990,
2005,
1736,
4346,
370,
1852,
199,
390,
1655,
12701,
14,
2779,
1077,
2597,
506,
18023,
12930,
2419,
314,
3379,
299,
2268,
18,
12,
199,
20684,
781,
6326,
2005,
5323,
12270,
14,
199,
624,
199,
199,
504,
6073,
492,
8785,
63,
2579,
199,
504,
14090,
492,
2434,
5894,
12,
8307,
12,
12340,
12,
10975,
12,
2494,
12,
15961,
199,
199,
504,
623,
1152,
14,
80,
2268,
18,
14,
15239,
63,
2087,
492,
10268,
9992,
2842,
12,
653,
2078,
2223,
199,
199,
63,
3264,
804,
52,
275,
2434,
5894,
11008,
3264,
804,
52,
531,
421,
199,
533,
10268,
9992,
8,
9417,
13040,
3264,
804,
52,
4682,
272,
408,
272,
19468,
10038,
12,
642,
1021,
4973,
6528,
314,
12528,
6716,
367,
314,
272,
6057,
6869,
6366,
701,
2198,
14,
647,
14,
221,
710,
6057,
6869,
272,
1066,
5804,
314,
1256,
2860,
5370,
14,
339,
710,
1454,
11012,
1777,
315,
642,
21295,
787,
4051,
305,
436,
19077,
3382,
272,
4051,
305,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
326,
1343,
63,
2865,
12010,
26,
620,
12,
326,
2332,
63,
475,
63,
1587,
305,
26,
12340,
59,
495,
12,
10975,
459,
36,
2078,
2223,
13040,
3264,
804,
52,
61,
2157,
326,
4644,
63,
7093,
63,
5465,
26,
12340,
59,
495,
12,
283,
10285,
1558,
9090,
267,
291,
14,
2865,
12010,
63,
475,
63,
1587,
305,
275,
2332,
63,
475,
63,
1587,
305,
267,
291,
14,
10421,
63,
7093,
63,
5465,
275,
4644,
63,
7093,
63,
5465,
267,
291,
14,
928,
63,
2865,
12010,
275,
1343,
63,
2865,
12010,
421,
199,
533,
577,
38,
1282,
1502,
26,
272,
408,
272,
7497,
796,
787,
1202,
367,
314,
1798,
370,
1218,
3464,
3380,
436,
886,
314,
5576,
272,
577,
2078,
1174,
19077,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
2163,
63,
26520,
26,
283,
36,
2078,
2223,
297,
366,
667,
63,
5335,
397,
26,
10975,
459,
36,
2078,
2223,
418,
275,
12319,
267,
291,
14,
2184,
63,
26520,
275,
2163,
63,
26520,
267,
291,
14,
26520,
63,
5335,
397,
275,
366,
667,
63,
5335,
397,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
83,
12,
450,
83,
3171,
450,
334,
277,
855,
533,
4914,
354,
3108,
291,
14,
2184,
63,
26520,
12,
291,
14,
26520,
63,
5335,
397,
9,
421,
199,
533,
577,
2078,
2223,
8,
9417,
13040,
3264,
804,
52,
4682,
272,
408,
272,
710,
577,
2078,
2223,
909,
365,
314,
6170,
1021,
367,
7268,
8298,
7003,
14,
577,
2078,
2223,
272,
787,
314,
14971,
402,
376,
7741,
3343,
1830,
601,
1259,
436,
19077,
787,
314,
272,
8207,
14,
339,
437,
1195,
83,
787,
314,
2536,
8207,
12,
2382,
4750,
577,
2078,
18010,
787,
440,
8539,
436,
272,
19077,
787,
2066,
12950,
370,
4907,
314,
577,
2078,
1174,
20601,
626,
1172,
272,
3365,
2222,
24322,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
687,
63,
2200,
26,
620,
12,
302,
667,
63,
409,
26,
2494,
59,
46,
2078,
2223,
467,
4242,
26,
653,
2078,
2223,
304,
267,
702,
1228,
8,
78,
667,
63,
409,
12,
663,
9,
267,
702,
1228,
8,
2184,
8,
1661,
8,
78,
667,
63,
409,
1826,
653,
2078,
2223,
9,
267,
702,
1228,
8,
5094,
12,
653,
2078,
2223,
9,
267,
291,
14,
504,
63,
2200,
275,
687,
63,
2200,
267,
291,
14,
78,
667,
63,
409,
275,
302,
667,
63,
409,
267,
327,
2341,
687,
5537,
2551,
15,
2865,
24322,
370,
577,
2078,
2223,
267,
291,
14,
20672,
26,
12340,
59,
495,
12,
577,
2078,
2223,
61,
275,
1052,
267,
327,
1010,
376,
1640,
30747,
3650,
781,
663,
3520,
2222,
12010,
601,
1259,
334,
6777,
965,
314,
267,
327,
2011,
5523,
465,
601,
1259,
680,
5723,
2793,
1133,
1395,
5537,
2551,
20827,
14,
267,
291,
14,
2865,
12010,
63,
20672,
26,
12340,
59,
495,
12,
577,
2078,
2223,
61,
275,
1052,
398,
327,
19894,
6150,
787,
26014,
314,
1454,
8377,
626,
221,
314,
1798,
365,
1808,
267,
327,
543,
365,
63,
5094,
14,
18414,
1337,
587,
365,
15111,
590,
2348,
370,
1218,
282,
1798,
14,
267,
291,
14,
23062,
26,
12340,
59,
15540,
13040,
3264,
804,
52,
12,
5702,
1558,
467,
577,
38,
1282,
1502,
61,
275,
1052,
267,
291,
14,
374,
63,
5094,
275,
4242,
315,
302,
667,
63,
409,
339,
347,
1050,
63,
9912,
8,
277,
12,
2163,
3131,
1768,
304,
267,
702,
1228,
8,
1302,
12,
620,
9,
267,
702,
1768,
440,
315,
291,
14,
20672,
267,
702,
1228,
8,
2184,
3131,
577,
2078,
2223,
9,
267,
291,
14,
20672,
59,
1302,
61,
275,
2163,
63,
339,
347,
625,
2021,
929,
8,
277,
12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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
] |
jlongstaf/f5-openstack-lbaasv2-driver
|
f5lbaasdriver/v2/bigip/constants_v2.py
|
3
|
1072
|
# coding=utf-8
u"""Constants for F5® LBaaSv2 Driver."""
# coding=utf-8
# Copyright 2016 F5 Networks Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# F5EnvironmentDriver provider name
F5ENVDRIVER_PROVIDER_NAME = 'f5env'
# RPC channel names
TOPIC_PROCESS_ON_HOST_V2 = 'f5-lbaasv2-process-on-controller'
TOPIC_LOADBALANCER_AGENT_V2 = 'f5-lbaasv2-process-on-agent'
BASE_RPC_API_VERSION = '1.0'
RPC_API_NAMESPACE = None
# service builder constants
VIF_TYPE = 'f5'
NET_CACHE_SECONDS = 1800
# SUPPORTED PROVIDERNET TUNNEL NETWORK TYPES
TUNNEL_TYPES = ['vxlan', 'gre']
|
apache-2.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
85,
624,
22185,
367,
481,
21,
127,
107,
491,
34,
2158,
51,
86,
18,
19447,
1041,
199,
3,
2803,
29,
1624,
13,
24,
199,
3,
1898,
7800,
481,
21,
17138,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
3,
481,
21,
8263,
6158,
5022,
536,
199,
38,
21,
9984,
23401,
63,
30600,
63,
2339,
275,
283,
70,
21,
1813,
7,
199,
199,
3,
11785,
3623,
1561,
199,
23740,
63,
10494,
63,
615,
63,
5449,
63,
54,
18,
275,
283,
70,
21,
13,
76,
2470,
305,
86,
18,
13,
1412,
13,
265,
13,
5538,
7,
199,
23740,
63,
7405,
31232,
879,
35,
540,
63,
14565,
63,
54,
18,
275,
283,
70,
21,
13,
76,
2470,
305,
86,
18,
13,
1412,
13,
265,
13,
4054,
7,
199,
199,
5825,
63,
8171,
63,
3735,
63,
4612,
275,
283,
17,
14,
16,
7,
199,
8171,
63,
3735,
63,
13001,
275,
488,
199,
199,
3,
2435,
6545,
5262,
199,
27890,
63,
2711,
275,
283,
70,
21,
7,
199,
7278,
63,
8677,
63,
23319,
275,
6155,
383,
199,
199,
3,
32501,
6837,
540,
7278,
377,
1734,
11301,
18340,
8406,
32317,
199,
52,
1734,
11301,
63,
7893,
275,
788,
18843,
1502,
297,
283,
9157,
418,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2803,
29,
1624,
13,
24,
199,
85,
624,
22185,
367,
481,
21,
127,
107,
491,
34,
2158,
51,
86,
18,
19447,
1041,
199,
3,
2803,
29,
1624,
13,
24,
199,
3,
1898,
7800,
481,
21,
17138,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
3,
481,
21,
8263,
6158,
5022,
536,
199,
38,
21,
9984,
23401,
63,
30600,
63,
2339,
275,
283,
70,
21,
1813,
7,
199,
199,
3,
11785,
3623,
1561,
199,
23740,
63,
10494,
63,
615,
63,
5449,
63,
54,
18,
275,
283,
70,
21,
13,
76,
2470,
305,
86,
18,
13,
1412,
13,
265,
13,
5538,
7,
199,
23740,
63,
7405,
31232,
879,
35,
540,
63,
14565,
63,
54,
18,
275,
283,
70,
21,
13,
76,
2470,
305,
86,
18,
13,
1412,
13,
265,
13,
4054,
7,
199,
199,
5825,
63,
8171,
63,
3735,
63,
4612,
275,
283,
17,
14,
16,
7,
199,
8171,
63,
3735,
63,
13001,
275,
488,
199,
199,
3,
2435,
6545,
5262,
199,
27890,
63,
2711,
275,
283,
70,
21,
7,
199,
7278,
63,
8677,
63,
23319,
275,
6155,
383,
199,
199,
3,
32501,
6837,
540,
7278,
377,
1734,
11301,
18340,
8406,
32317,
199,
52,
1734,
11301,
63,
7893,
275,
788,
18843,
1502,
297,
283,
9157,
418,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
3dfxmadscientist/odoo_vi
|
setup/win32/OpenERPServerService.py
|
105
|
3328
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import win32serviceutil
import win32service
import win32api
import win32process
import servicemanager
import sys
import subprocess
import os
try:
import meta
except ImportError:
if hasattr(sys, 'frozen'):
raise
from setup import generate_files
generate_files()
import meta # noqa
class OpenERPServerService(win32serviceutil.ServiceFramework):
# required info
_svc_name_ = meta.nt_service_name
_svc_display_name_ = "%s %s" % (meta.description, meta.serie)
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
# a reference to the server's process
self.terpprocess = None
def SvcStop(self):
# Before we do anything, tell the SCM we are starting the stop process.
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
# stop the running OpenERP Server: say it's a normal exit
win32api.TerminateProcess(int(self.terpprocess._handle), 0)
servicemanager.LogInfoMsg("OpenERP Server stopped correctly")
def StartTERP(self):
# The server finds now its configuration automatically on Windows
# We start the ERP Server as an independent process, but we keep its handle
# The server's binary must be one directory above the service's binary (when py2exe'd the python libraries shouldn' mix)
service_dir = os.path.dirname(sys.argv[0])
server_dir = os.path.split(service_dir)[0]
server_path = os.path.join(server_dir, 'server', 'openerp-server.exe')
self.terpprocess = subprocess.Popen([server_path], cwd=server_dir, creationflags=win32process.CREATE_NO_WINDOW)
def SvcDoRun(self):
self.StartTERP()
servicemanager.LogInfoMsg("OpenERP Server up and running")
# exit with same exit code as OpenERP process
sys.exit(self.terpprocess.wait())
def option_handler(opts):
# configure the service to auto restart on failures...
subprocess.call(['sc', 'failure', meta.nt_service_name, 'reset=', '0', 'actions=', 'restart/0/restart/0/restart/0'])
if __name__ == '__main__':
# Do with the service whatever option is passed in the command line
win32serviceutil.HandleCommandLine(OpenERPServerService, customOptionHandler=option_handler)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
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,
646,
4747,
708,
1364,
1974,
199,
646,
4747,
708,
1364,
199,
646,
4747,
708,
1246,
199,
646,
4747,
708,
1412,
199,
646,
2435,
2609,
199,
199,
646,
984,
199,
646,
3873,
199,
646,
747,
199,
199,
893,
26,
272,
492,
3404,
199,
2590,
3545,
26,
272,
340,
2688,
8,
1274,
12,
283,
11202,
735,
267,
746,
272,
687,
3272,
492,
3550,
63,
1725,
272,
3550,
63,
1725,
342,
272,
492,
3404,
258,
327,
8151,
199,
199,
533,
7653,
3120,
3167,
8,
2676,
708,
1364,
1974,
14,
3167,
16442,
304,
272,
327,
1415,
2256,
272,
485,
10599,
63,
354,
63,
275,
3404,
14,
343,
63,
1364,
63,
354,
272,
485,
10599,
63,
2918,
63,
354,
63,
275,
2071,
83,
450,
83,
2,
450,
334,
2024,
14,
1802,
12,
3404,
14,
261,
11317,
9,
339,
347,
636,
826,
721,
277,
12,
1249,
304,
267,
4747,
708,
1364,
1974,
14,
3167,
16442,
855,
826,
721,
277,
12,
1249,
9,
267,
327,
282,
3659,
370,
314,
1654,
1159,
2112,
267,
291,
14,
351,
80,
1412,
275,
488,
339,
347,
428,
6737,
6293,
8,
277,
304,
267,
327,
21467,
781,
886,
7003,
12,
11480,
314,
428,
9249,
781,
787,
6617,
314,
3631,
2112,
14,
267,
291,
14,
7457,
3167,
3694,
8,
2676,
708,
1364,
14,
10486,
63,
11632,
63,
21243,
9,
267,
327,
3631,
314,
3879,
7653,
7146,
26,
14722,
652,
1159,
282,
3293,
4458,
267,
4747,
708,
1246,
14,
12154,
323,
3498,
8,
442,
8,
277,
14,
351,
80,
1412,
423,
2479,
395,
378,
9,
267,
2435,
2609,
14,
2445,
2354,
6173,
480,
25347,
7146,
15248,
6657,
531,
339,
347,
7707,
1157,
48,
8,
277,
304,
267,
327,
710,
1654,
17651,
3063,
2399,
2897,
5847,
641,
5417,
267,
327,
2136,
1343,
314,
221,
6758,
7146,
465,
376,
12717,
2112,
12,
1325,
781,
4215,
2399,
2429,
267,
327,
710,
1654,
1159,
3366,
1471,
506,
1373,
2082,
3432,
314,
2435,
1159,
3366,
334,
6526,
1134,
18,
5803,
5121,
314,
2366,
8363,
9296,
7,
13667,
9,
267,
2435,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
566,
267,
1654,
63,
694,
275,
747,
14,
515,
14,
1294,
8,
1364,
63,
694,
2788,
16,
61,
267,
1654,
63,
515,
275,
747,
14,
515,
14,
904,
8,
1000,
63,
694,
12,
283,
1000,
297,
283,
11267,
13,
1000,
14,
5803,
358,
267,
291,
14,
351,
80,
1412,
275,
3873,
14,
7942,
779,
1000,
63,
515,
467,
8288,
29,
1000,
63,
694,
12,
7143,
2469,
29,
2676,
708,
1412,
14,
8366,
63,
2826,
63,
15480,
9,
339,
347,
428,
6737,
2585,
2540,
8,
277,
304,
267,
291,
14,
3162,
1157,
48,
342,
267,
2435,
2609,
14,
2445,
2354,
6173,
480,
25347,
7146,
1536,
436,
3879,
531,
267,
327,
4458,
543,
2011,
4458,
1233,
465,
7653,
2112,
267,
984,
14,
2224,
8,
277,
14,
351,
80,
1412,
14,
2573,
1012,
421,
199,
318,
945,
63,
2232,
8,
3291,
304,
272,
327,
7908,
314,
2435,
370,
2599,
11004,
641,
9081,
1396,
272,
3873,
14,
1250,
2941,
551,
297,
283,
5328,
297,
3404,
14,
343,
63,
1364,
63,
354,
12,
283,
3958,
4009,
283,
16,
297,
283,
3723,
4009,
283,
10506,
15,
16,
15,
10506,
15,
16,
15,
10506,
15,
16,
1105,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
327,
4226,
543,
314,
2435,
15685,
945,
365,
3032,
315,
314,
1414,
1004,
272,
4747,
708,
1364,
1974,
14,
5940,
16926,
8,
25347,
3120,
3167,
12,
3537,
2602,
2461,
29,
1422,
63,
2232,
9,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
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,
646,
4747,
708,
1364,
1974,
199,
646,
4747,
708,
1364,
199,
646,
4747,
708,
1246,
199,
646,
4747,
708,
1412,
199,
646,
2435,
2609,
199,
199,
646,
984,
199,
646,
3873,
199,
646,
747,
199,
199,
893,
26,
272,
492,
3404,
199,
2590,
3545,
26,
272,
340,
2688,
8,
1274,
12,
283,
11202,
735,
267,
746,
272,
687,
3272,
492,
3550,
63,
1725,
272,
3550,
63,
1725,
342,
272,
492,
3404,
258,
327,
8151,
199,
199,
533,
7653,
3120,
3167,
8,
2676,
708,
1364,
1974,
14,
3167,
16442,
304,
272,
327,
1415,
2256,
272,
485,
10599,
63,
354,
63,
275,
3404,
14,
343,
63,
1364,
63,
354,
272,
485,
10599,
63,
2918,
63,
354,
63,
275,
2071,
83,
450,
83,
2,
450,
334,
2024,
14,
1802,
12,
3404,
14,
261,
11317,
9,
339,
347,
636,
826,
721,
277,
12,
1249,
304,
267,
4747,
708,
1364,
1974,
14,
3167,
16442,
855,
826,
721,
277,
12,
1249,
9,
267,
327,
282,
3659,
370,
314,
1654,
1159,
2112,
267,
291,
14,
351,
80,
1412,
275,
488,
339,
347,
428,
6737,
6293,
8,
277,
304,
267,
327,
21467,
781,
886,
7003,
12,
11480,
314,
428,
9249,
781,
787,
6617,
314,
3631,
2112,
14,
267,
291,
14,
7457,
3167,
3694,
8,
2676,
708,
1364,
14,
10486,
63,
11632,
63,
21243,
9,
267,
327,
3631,
314,
3879,
7653,
7146,
26,
14722,
652,
1159,
282,
3293,
4458,
267,
4747,
708,
1246,
14,
12154,
323,
3498,
8,
442,
8,
277,
14,
351,
80,
1412,
423,
2479,
395,
378,
9,
267,
2435,
2609,
14,
2445,
2354,
6173,
480,
25347,
7146,
15248,
6657,
531,
339,
347,
7707,
1157,
48,
8,
277,
304,
267,
327,
710,
1654,
17651,
3063,
2399,
2897,
5847,
641,
5417,
267,
327,
2136,
1343,
314,
221,
6758,
7146,
465,
376,
12717,
2112,
12,
1325,
781,
4215,
2399,
2429,
267,
327,
710,
1654,
1159,
3366,
1471,
506,
1373,
2082,
3432,
314,
2435,
1159,
3366,
334,
6526,
1134,
18,
5803,
5121,
314,
2366,
8363,
9296,
7,
13667,
9,
267,
2435,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
566,
267,
1654,
63,
694,
275,
747,
14,
515,
14,
1294,
8,
1364,
63,
694,
2788,
16,
61,
267,
1654,
63,
515,
275,
747,
14,
515,
14,
904,
8,
1000,
63,
694,
12,
283,
1000,
297,
283,
11267,
13,
1000,
14,
5803,
358,
267,
291,
14,
351,
80,
1412,
275,
3873,
14,
7942,
779,
1000,
63,
515,
467,
8288,
29,
1000,
63,
694,
12,
7143,
2469,
29,
2676,
708,
1412,
14,
8366,
63,
2826,
63,
15480,
9,
339,
347,
428,
6737,
2585,
2540,
8,
277,
304,
267,
291,
14,
3162,
1157,
48,
342,
267,
2435,
2609,
14,
2445,
2354,
6173,
480,
25347,
7146,
1536,
436,
3879,
531,
267,
327,
4458,
543,
2011,
4458,
1233,
465,
7653,
2112,
267,
984,
14,
2224,
8,
277,
14,
351,
80,
1412,
14,
2573,
1012,
421,
199,
318,
945,
63,
2232,
8,
3291,
304,
272,
327,
7908,
314,
2435,
370,
2599,
11004,
641,
9081,
1396,
272,
3873,
14,
1250,
2941,
551,
297,
283,
5328,
297,
3404,
14,
343,
63,
1364,
63,
354,
12,
283,
3958,
4009,
283,
16,
297,
283,
3723,
4009,
283,
10506,
15,
16,
15,
10506,
15,
16,
15,
10506,
15,
16,
1105,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
327,
4226,
543,
314,
2435,
15685,
945,
365,
3032,
315,
314,
1414,
1004,
272,
4747,
708,
1364,
1974,
14,
5940,
16926,
8,
25347,
3120,
3167,
12,
3537,
2602,
2461,
29,
1422,
63,
2232,
9,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
3dfxmadscientist/odoo_vi
|
addons/account_payment/report/payment_order.py
|
378
|
2974
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from openerp.osv import osv
from openerp.report import report_sxw
class payment_order(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context=None):
super(payment_order, self).__init__(cr, uid, name, context=context)
self.localcontext.update( {
'time': time,
'get_invoice_name': self._get_invoice_name,
'get_amount_total_in_currency': self._get_amount_total_in_currency,
'get_amount_total': self._get_amount_total,
'get_account_name': self._get_account_name,
})
def _get_invoice_name(self, invoice_id):
if invoice_id:
value_name = self.pool['account.invoice'].name_get(self.cr, self.uid, [invoice_id])
if value_name:
return value_name[0][1]
return False
def _get_amount_total_in_currency(self, payment):
total = 0.0
if payment.line_ids:
currency_cmp = payment.line_ids[0].currency.id
else:
return False
for line in payment.line_ids:
if currency_cmp == line.currency.id:
total += line.amount_currency
else:
return False
return total
def _get_amount_total(self, payment):
total = 0.0
if not payment.line_ids:
return False
for line in payment.line_ids:
total += line.amount
return total
def _get_account_name(self,bank_id):
if bank_id:
value_name = self.pool['res.partner.bank'].name_get(self.cr, self.uid, [bank_id])
if value_name:
return value_name[0][1]
return False
class report_paymentorder(osv.AbstractModel):
_name = 'report.account_payment.report_paymentorder'
_inherit = 'report.abstract_report'
_template = 'account_payment.report_paymentorder'
_wrapped_report_class = payment_order
# 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,
646,
900,
199,
504,
5166,
14,
4795,
492,
9506,
199,
504,
5166,
14,
3070,
492,
3622,
63,
20851,
421,
199,
533,
11628,
63,
1648,
8,
3070,
63,
20851,
14,
16300,
63,
1122,
304,
339,
347,
636,
826,
721,
277,
12,
2467,
12,
1747,
12,
536,
12,
1067,
29,
403,
304,
267,
1613,
8,
7948,
63,
1648,
12,
291,
2843,
826,
721,
1556,
12,
1747,
12,
536,
12,
1067,
29,
1100,
9,
267,
291,
14,
17886,
14,
873,
8,
469,
288,
283,
521,
356,
900,
12,
288,
283,
362,
63,
5404,
63,
354,
356,
291,
423,
362,
63,
5404,
63,
354,
12,
288,
283,
362,
63,
4606,
63,
2923,
63,
262,
63,
4968,
356,
291,
423,
362,
63,
4606,
63,
2923,
63,
262,
63,
4968,
12,
288,
283,
362,
63,
4606,
63,
2923,
356,
291,
423,
362,
63,
4606,
63,
2923,
12,
288,
283,
362,
63,
2048,
63,
354,
356,
291,
423,
362,
63,
2048,
63,
354,
12,
267,
3828,
339,
347,
485,
362,
63,
5404,
63,
354,
8,
277,
12,
8485,
63,
344,
304,
267,
340,
8485,
63,
344,
26,
288,
574,
63,
354,
275,
291,
14,
2293,
459,
2048,
14,
5404,
2278,
354,
63,
362,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
359,
5404,
63,
344,
566,
288,
340,
574,
63,
354,
26,
355,
372,
574,
63,
354,
59,
16,
1527,
17,
61,
267,
372,
756,
339,
347,
485,
362,
63,
4606,
63,
2923,
63,
262,
63,
4968,
8,
277,
12,
11628,
304,
267,
3141,
275,
378,
14,
16,
267,
340,
11628,
14,
604,
63,
1580,
26,
288,
9952,
63,
5730,
275,
11628,
14,
604,
63,
1580,
59,
16,
1055,
4968,
14,
344,
267,
587,
26,
288,
372,
756,
267,
367,
1004,
315,
11628,
14,
604,
63,
1580,
26,
288,
340,
9952,
63,
5730,
508,
1004,
14,
4968,
14,
344,
26,
355,
3141,
847,
1004,
14,
4606,
63,
4968,
288,
587,
26,
355,
372,
756,
267,
372,
3141,
339,
347,
485,
362,
63,
4606,
63,
2923,
8,
277,
12,
11628,
304,
267,
3141,
275,
378,
14,
16,
267,
340,
440,
11628,
14,
604,
63,
1580,
26,
288,
372,
756,
267,
367,
1004,
315,
11628,
14,
604,
63,
1580,
26,
288,
3141,
847,
1004,
14,
4606,
267,
372,
3141,
339,
347,
485,
362,
63,
2048,
63,
354,
8,
277,
12,
9860,
63,
344,
304,
267,
340,
16297,
63,
344,
26,
288,
574,
63,
354,
275,
291,
14,
2293,
459,
470,
14,
3899,
14,
9860,
2278,
354,
63,
362,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
359,
9860,
63,
344,
566,
288,
340,
574,
63,
354,
26,
355,
372,
574,
63,
354,
59,
16,
1527,
17,
61,
267,
372,
756,
421,
199,
533,
3622,
63,
7948,
1648,
8,
4795,
14,
8458,
1685,
304,
272,
485,
354,
275,
283,
3070,
14,
2048,
63,
7948,
14,
3070,
63,
7948,
1648,
7,
272,
485,
6486,
275,
283,
3070,
14,
6198,
63,
3070,
7,
272,
485,
1160,
275,
283,
2048,
63,
7948,
14,
3070,
63,
7948,
1648,
7,
272,
485,
9130,
63,
3070,
63,
533,
275,
11628,
63,
1648,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
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,
646,
900,
199,
504,
5166,
14,
4795,
492,
9506,
199,
504,
5166,
14,
3070,
492,
3622,
63,
20851,
421,
199,
533,
11628,
63,
1648,
8,
3070,
63,
20851,
14,
16300,
63,
1122,
304,
339,
347,
636,
826,
721,
277,
12,
2467,
12,
1747,
12,
536,
12,
1067,
29,
403,
304,
267,
1613,
8,
7948,
63,
1648,
12,
291,
2843,
826,
721,
1556,
12,
1747,
12,
536,
12,
1067,
29,
1100,
9,
267,
291,
14,
17886,
14,
873,
8,
469,
288,
283,
521,
356,
900,
12,
288,
283,
362,
63,
5404,
63,
354,
356,
291,
423,
362,
63,
5404,
63,
354,
12,
288,
283,
362,
63,
4606,
63,
2923,
63,
262,
63,
4968,
356,
291,
423,
362,
63,
4606,
63,
2923,
63,
262,
63,
4968,
12,
288,
283,
362,
63,
4606,
63,
2923,
356,
291,
423,
362,
63,
4606,
63,
2923,
12,
288,
283,
362,
63,
2048,
63,
354,
356,
291,
423,
362,
63,
2048,
63,
354,
12,
267,
3828,
339,
347,
485,
362,
63,
5404,
63,
354,
8,
277,
12,
8485,
63,
344,
304,
267,
340,
8485,
63,
344,
26,
288,
574,
63,
354,
275,
291,
14,
2293,
459,
2048,
14,
5404,
2278,
354,
63,
362,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
359,
5404,
63,
344,
566,
288,
340,
574,
63,
354,
26,
355,
372,
574,
63,
354,
59,
16,
1527,
17,
61,
267,
372,
756,
339,
347,
485,
362,
63,
4606,
63,
2923,
63,
262,
63,
4968,
8,
277,
12,
11628,
304,
267,
3141,
275,
378,
14,
16,
267,
340,
11628,
14,
604,
63,
1580,
26,
288,
9952,
63,
5730,
275,
11628,
14,
604,
63,
1580,
59,
16,
1055,
4968,
14,
344,
267,
587,
26,
288,
372,
756,
267,
367,
1004,
315,
11628,
14,
604,
63,
1580,
26,
288,
340,
9952,
63,
5730,
508,
1004,
14,
4968,
14,
344,
26,
355,
3141,
847,
1004,
14,
4606,
63,
4968,
288,
587,
26,
355,
372,
756,
267,
372,
3141,
339,
347,
485,
362,
63,
4606,
63,
2923,
8,
277,
12,
11628,
304,
267,
3141,
275,
378,
14,
16,
267,
340,
440,
11628,
14,
604,
63,
1580,
26,
288,
372,
756,
267,
367,
1004,
315,
11628,
14,
604,
63,
1580,
26,
288,
3141,
847,
1004,
14,
4606,
267,
372,
3141,
339,
347,
485,
362,
63,
2048,
63,
354,
8,
277,
12,
9860,
63,
344,
304,
267,
340,
16297,
63,
344,
26,
288,
574,
63,
354,
275,
291,
14,
2293,
459,
470,
14,
3899,
14,
9860,
2278,
354,
63,
362,
8,
277,
14,
1556,
12,
291,
14,
1535,
12,
359,
9860,
63,
344,
566,
288,
340,
574,
63,
354,
26,
355,
372,
574,
63,
354,
59,
16,
1527,
17,
61,
267,
372,
756,
421,
199,
533,
3622,
63,
7948,
1648,
8,
4795,
14,
8458,
1685,
304,
272,
485,
354,
275,
283,
3070,
14,
2048,
63,
7948,
14,
3070,
63,
7948,
1648,
7,
272,
485,
6486,
275,
283,
3070,
14,
6198,
63,
3070,
7,
272,
485,
1160,
275,
283,
2048,
63,
7948,
14,
3070,
63,
7948,
1648,
7,
272,
485,
9130,
63,
3070,
63,
533,
275,
11628,
63,
1648,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
CompassionCH/compassion-switzerland
|
mass_mailing_switzerland/migrations/10.0.2.0.1/pre-migration.py
|
3
|
1543
|
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2018 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
#
# The licence is in the file __manifest__.py
#
##############################################################################
def migrate(cr, version):
if not version:
return
cr.execute("""
SELECT id FROM utm_medium WHERE name = 'Mass mailing'
""")
mass_mailing_medium = cr.fetchone()[0]
cr.execute("""
SELECT c.campaign_id, %s, r.id
FROM recurring_contract r JOIN mail_mass_mailing_campaign c
ON r.mailing_campaign_id = c.id
WHERE r.mailing_campaign_id IS NOT NULL
""", [mass_mailing_medium])
results = cr.fetchall()
for row in results:
cr.execute("""
UPDATE recurring_contract
SET campaign_id = %s, medium_id = %s
WHERE id = %s
""", row)
cr.execute("""
ALTER TABLE account_invoice ADD COLUMN campaign_bkp INTEGER;
ALTER TABLE correspondence ADD COLUMN campaign_bkp INTEGER;
UPDATE account_invoice SET campaign_bkp = mailing_campaign_id;
UPDATE correspondence SET campaign_bkp = mailing_campaign_id;
""")
# Delete view which is making errors at migration
cr.execute("""
DELETE FROM ir_ui_view
WHERE model='recurring.contract' AND arch_db LIKE '%web_data%'
""")
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
1898,
334,
35,
9,
14894,
3599,
305,
438,
6624,
334,
1014,
921,
1544,
14,
863,
305,
438,
14,
335,
9,
199,
3,
259,
799,
274,
11571,
4978,
687,
1115,
422,
369,
315,
1603,
397,
527,
7,
536,
199,
3,
259,
768,
2502,
26,
662,
1237,
13086,
445,
10175,
665,
825,
10175,
32,
863,
305,
438,
14,
335,
30,
199,
3,
199,
3,
259,
710,
23854,
4894,
365,
315,
314,
570,
636,
6418,
4343,
647,
199,
3,
199,
4605,
421,
199,
318,
12810,
8,
1556,
12,
1015,
304,
272,
340,
440,
1015,
26,
267,
372,
339,
2467,
14,
2526,
4852,
267,
10468,
1305,
4442,
11430,
77,
63,
14345,
6038,
536,
275,
283,
27218,
30939,
7,
272,
7857,
272,
12250,
63,
22989,
63,
14345,
275,
2467,
14,
11591,
3430,
16,
61,
272,
2467,
14,
2526,
4852,
267,
10468,
286,
14,
17368,
63,
344,
12,
450,
83,
12,
519,
14,
344,
267,
4442,
5344,
5985,
63,
14624,
519,
10593,
6016,
63,
11535,
63,
22989,
63,
17368,
286,
267,
5258,
519,
14,
22989,
63,
17368,
63,
344,
275,
286,
14,
344,
267,
6038,
519,
14,
22989,
63,
17368,
63,
344,
2281,
2845,
5962,
272,
10327,
359,
11535,
63,
22989,
63,
14345,
566,
272,
2058,
275,
2467,
14,
10174,
342,
272,
367,
1962,
315,
2058,
26,
267,
2467,
14,
2526,
4852,
288,
17148,
5344,
5985,
63,
14624,
288,
11543,
22166,
63,
344,
275,
450,
83,
12,
21576,
63,
344,
275,
450,
83,
288,
6038,
1305,
275,
450,
83,
267,
10327,
1962,
9,
339,
2467,
14,
2526,
4852,
267,
12112,
1157,
9934,
2933,
63,
5404,
21380,
29955,
22166,
63,
18314,
80,
17086,
27,
267,
12112,
1157,
9934,
4327,
5606,
21380,
29955,
22166,
63,
18314,
80,
17086,
27,
267,
17148,
2933,
63,
5404,
11543,
22166,
63,
18314,
80,
275,
30939,
63,
17368,
63,
344,
27,
267,
17148,
4327,
5606,
11543,
22166,
63,
18314,
80,
275,
30939,
63,
17368,
63,
344,
27,
272,
7857,
339,
327,
8496,
2455,
1314,
365,
10663,
2552,
737,
8367,
272,
2467,
14,
2526,
4852,
267,
15137,
4442,
8190,
63,
1907,
63,
1345,
267,
6038,
1402,
534,
6794,
5985,
14,
14624,
7,
2401,
3819,
63,
697,
29369,
1543,
2520,
63,
576,
5,
7,
272,
7857,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
1898,
334,
35,
9,
14894,
3599,
305,
438,
6624,
334,
1014,
921,
1544,
14,
863,
305,
438,
14,
335,
9,
199,
3,
259,
799,
274,
11571,
4978,
687,
1115,
422,
369,
315,
1603,
397,
527,
7,
536,
199,
3,
259,
768,
2502,
26,
662,
1237,
13086,
445,
10175,
665,
825,
10175,
32,
863,
305,
438,
14,
335,
30,
199,
3,
199,
3,
259,
710,
23854,
4894,
365,
315,
314,
570,
636,
6418,
4343,
647,
199,
3,
199,
4605,
421,
199,
318,
12810,
8,
1556,
12,
1015,
304,
272,
340,
440,
1015,
26,
267,
372,
339,
2467,
14,
2526,
4852,
267,
10468,
1305,
4442,
11430,
77,
63,
14345,
6038,
536,
275,
283,
27218,
30939,
7,
272,
7857,
272,
12250,
63,
22989,
63,
14345,
275,
2467,
14,
11591,
3430,
16,
61,
272,
2467,
14,
2526,
4852,
267,
10468,
286,
14,
17368,
63,
344,
12,
450,
83,
12,
519,
14,
344,
267,
4442,
5344,
5985,
63,
14624,
519,
10593,
6016,
63,
11535,
63,
22989,
63,
17368,
286,
267,
5258,
519,
14,
22989,
63,
17368,
63,
344,
275,
286,
14,
344,
267,
6038,
519,
14,
22989,
63,
17368,
63,
344,
2281,
2845,
5962,
272,
10327,
359,
11535,
63,
22989,
63,
14345,
566,
272,
2058,
275,
2467,
14,
10174,
342,
272,
367,
1962,
315,
2058,
26,
267,
2467,
14,
2526,
4852,
288,
17148,
5344,
5985,
63,
14624,
288,
11543,
22166,
63,
344,
275,
450,
83,
12,
21576,
63,
344,
275,
450,
83,
288,
6038,
1305,
275,
450,
83,
267,
10327,
1962,
9,
339,
2467,
14,
2526,
4852,
267,
12112,
1157,
9934,
2933,
63,
5404,
21380,
29955,
22166,
63,
18314,
80,
17086,
27,
267,
12112,
1157,
9934,
4327,
5606,
21380,
29955,
22166,
63,
18314,
80,
17086,
27,
267,
17148,
2933,
63,
5404,
11543,
22166,
63,
18314,
80,
275,
30939,
63,
17368,
63,
344,
27,
267,
17148,
4327,
5606,
11543,
22166,
63,
18314,
80,
275,
30939,
63,
17368,
63,
344,
27,
272,
7857,
339,
327,
8496,
2455,
1314,
365,
10663,
2552,
737,
8367,
272,
2467,
14,
2526,
4852,
267,
15137,
4442,
8190,
63,
1907,
63,
1345,
267,
6038,
1402,
534,
6794,
5985,
14,
14624,
7,
2401,
3819,
63,
697,
29369,
1543,
2520,
63,
576,
5,
7,
272,
7857,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
iotaledger/iota.lib.py
|
iota/transaction/validator.py
|
1
|
9563
|
from typing import Generator, List, Optional, Type
from iota.crypto.kerl import Kerl
from iota.crypto.signing import validate_signature_fragments
from iota.transaction.base import Bundle, Transaction
__all__ = [
'BundleValidator',
]
# In very rare cases, the IOTA protocol may switch hash algorithms.
# When this happens, the IOTA Foundation will create a snapshot, so
# that all new objects on the Tangle use the new hash algorithm.
#
# However, the snapshot will still contain references to addresses
# created using the legacy hash algorithm, so the bundle validator has
# to be able to use that as a fallback when validation fails.
SUPPORTED_SPONGE = Kerl
LEGACY_SPONGE = None # Curl
class BundleValidator(object):
"""
Checks a bundle and its transactions for problems.
"""
def __init__(self, bundle: Bundle) -> None:
super(BundleValidator, self).__init__()
self.bundle = bundle
self._errors: Optional[List[str]] = []
self._validator = self._create_validator()
@property
def errors(self) -> List[str]:
"""
Returns all errors found with the bundle.
"""
try:
self._errors.extend(self._validator) # type: List[str]
except StopIteration:
pass
return self._errors
def is_valid(self) -> bool:
"""
Returns whether the bundle is valid.
"""
if not self._errors:
try:
# We only have to check for a single error to determine
# if the bundle is valid or not.
self._errors.append(next(self._validator))
except StopIteration:
pass
return not self._errors
def _create_validator(self) -> Generator[str, None, None]:
"""
Creates a generator that does all the work.
"""
# Group transactions by address to make it easier to iterate
# over inputs.
grouped_transactions = self.bundle.group_transactions()
# Define a few expected values.
bundle_hash = self.bundle.hash
last_index = len(self.bundle) - 1
# Track a few others as we go along.
balance = 0
# Check indices and balance first.
# Note that we use a counter to keep track of the current index,
# since at this point we can't trust that the transactions have
# correct ``current_index`` values.
counter = 0
for group in grouped_transactions:
for txn in group:
balance += txn.value
if txn.bundle_hash != bundle_hash:
yield 'Transaction {i} has invalid bundle hash.'.format(
i=counter,
)
if txn.current_index != counter:
yield (
'Transaction {i} has invalid current index value '
'(expected {i}, actual {actual}).'.format(
actual=txn.current_index,
i=counter,
)
)
if txn.last_index != last_index:
yield (
'Transaction {i} has invalid last index value '
'(expected {expected}, actual {actual}).'.format(
actual=txn.last_index,
expected=last_index,
i=counter,
)
)
counter += 1
# Bundle must be balanced (spends must match inputs).
if balance != 0:
yield (
'Bundle has invalid balance '
'(expected 0, actual {actual}).'.format(
actual=balance,
)
)
# Signature validation is only meaningful if the transactions
# are otherwise valid.
if not self._errors:
signature_validation_queue: List[List[Transaction]] = []
for group in grouped_transactions:
# Signature validation only applies to inputs.
if group[0].value >= 0:
continue
validate_group_signature = True
for j, txn in enumerate(group):
if (j > 0) and (txn.value != 0):
# Input is malformed; signature fragments after
# the first should have zero value.
yield (
'Transaction {i} has invalid value '
'(expected 0, actual {actual}).'.format(
actual=txn.value,
# If we get to this point, we know that
# the ``current_index`` value for each
# transaction can be trusted.
i=txn.current_index,
)
)
# We won't be able to validate the signature,
# but continue anyway, so that we can check that
# the other transactions in the group have the
# correct ``value``.
validate_group_signature = False
continue
# After collecting the signature fragment from each
# transaction in the group, queue them up to run through
# the validator.
#
# We have to perform signature validation separately so
# that we can try different algorithms (for
# backwards-compatibility).
#
# References:
#
# - https://github.com/iotaledger/kerl#kerl-integration-in-iota
if validate_group_signature:
signature_validation_queue.append(group)
# Once we've finished checking the attributes from each
# transaction in the bundle, go back and validate
# signatures.
if signature_validation_queue:
# ``yield from`` is an option here, but for
# compatibility with Python 2 clients, we will do it the
# old-fashioned way.
for error in self._get_bundle_signature_errors(
signature_validation_queue
):
yield error
def _get_bundle_signature_errors(
self,
groups: List[List[Transaction]]
) -> List[str]:
"""
Validates the signature fragments in the bundle.
:return:
List of error messages.
If empty, signature fragments are valid.
"""
# Start with the currently-supported hash algo.
current_pos = None
current_errors = []
for current_pos, group in enumerate(groups):
error = self._get_group_signature_error(group, SUPPORTED_SPONGE)
if error:
current_errors.append(error)
# Pause and retry with the legacy algo.
break
# If validation failed, then go back and try with the legacy
# algo (only applies if we are currently transitioning to a new
# algo).
if current_errors and LEGACY_SPONGE:
for group in groups:
if self._get_group_signature_error(group, LEGACY_SPONGE):
# Legacy algo doesn't work, either; no point in
# continuing.
break
else:
# If we get here, then we were able to validate the
# signature fragments successfully using the legacy
# algorithm.
return []
# If we get here, then validation also failed when using the
# legacy algorithm.
# At this point, we know that the bundle is invalid, but we will
# continue validating with the supported algorithm anyway, so
# that we can return an error message for every invalid input.
current_errors.extend(filter(None, (
self._get_group_signature_error(group, SUPPORTED_SPONGE)
for group in groups[current_pos + 1:]
)))
return current_errors
@staticmethod
def _get_group_signature_error(
group: List[Transaction],
sponge_type: Type
) -> Optional[str]:
"""
Validates the signature fragments for a group of transactions
using the specified sponge type.
Note: this method assumes that the transactions in the group
have already passed basic validation (see
:py:meth:`_create_validator`).
:return:
- ``None``: Indicates that the signature fragments are valid.
- ``str``: Error message indicating the fragments are invalid.
"""
validate_group_signature = validate_signature_fragments(
fragments=[txn.signature_message_fragment for txn in group],
hash_=group[0].bundle_hash,
public_key=group[0].address,
sponge_type=sponge_type,
)
if validate_group_signature:
return None
return (
'Transaction {i} has invalid signature '
'(using {fragments} fragments).'.format(
fragments=len(group),
i=group[0].current_index,
)
)
|
mit
|
[
504,
14090,
492,
15042,
12,
3820,
12,
4879,
12,
2434,
199,
199,
504,
284,
12041,
14,
10316,
14,
2570,
76,
492,
1804,
281,
76,
199,
504,
284,
12041,
14,
10316,
14,
23238,
492,
4107,
63,
5233,
63,
18047,
199,
504,
284,
12041,
14,
5945,
14,
1095,
492,
29311,
12,
18244,
199,
199,
363,
452,
363,
275,
359,
272,
283,
12320,
8640,
297,
199,
61,
199,
199,
3,
1010,
7437,
24063,
5560,
12,
314,
473,
32760,
4113,
1443,
6258,
2631,
18036,
14,
199,
3,
3979,
642,
10986,
12,
314,
473,
32760,
2752,
911,
1218,
282,
5740,
12,
880,
199,
3,
626,
1006,
892,
2251,
641,
314,
377,
4593,
675,
314,
892,
2631,
5563,
14,
199,
3,
199,
3,
9738,
12,
314,
5740,
911,
5139,
1395,
6941,
370,
7149,
199,
3,
2737,
1808,
314,
12139,
2631,
5563,
12,
880,
314,
8844,
11822,
965,
199,
3,
370,
506,
7688,
370,
675,
626,
465,
282,
9567,
1380,
6411,
6918,
14,
199,
15925,
63,
5763,
615,
4962,
275,
1804,
281,
76,
199,
25086,
22114,
63,
5763,
615,
4962,
275,
488,
221,
327,
445,
633,
421,
199,
533,
29311,
8640,
8,
785,
304,
272,
408,
272,
13813,
282,
8844,
436,
2399,
15809,
367,
8826,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
8844,
26,
29311,
9,
1035,
488,
26,
267,
1613,
8,
12320,
8640,
12,
291,
2843,
826,
4533,
398,
291,
14,
6469,
275,
8844,
398,
291,
423,
2550,
26,
4879,
59,
1296,
59,
495,
2677,
275,
942,
267,
291,
423,
11034,
275,
291,
423,
981,
63,
11034,
342,
339,
768,
1829,
272,
347,
2552,
8,
277,
9,
1035,
3820,
59,
495,
2189,
267,
408,
267,
1803,
1006,
2552,
1911,
543,
314,
8844,
14,
267,
408,
267,
862,
26,
288,
291,
423,
2550,
14,
2880,
8,
277,
423,
11034,
9,
221,
327,
730,
26,
3820,
59,
495,
61,
267,
871,
10852,
26,
288,
986,
398,
372,
291,
423,
2550,
339,
347,
365,
63,
1078,
8,
277,
9,
1035,
2155,
26,
267,
408,
267,
1803,
3775,
314,
8844,
365,
1686,
14,
267,
408,
267,
340,
440,
291,
423,
2550,
26,
288,
862,
26,
355,
327,
2136,
1454,
1172,
370,
1104,
367,
282,
2849,
1125,
370,
6705,
355,
327,
340,
314,
8844,
365,
1686,
503,
440,
14,
355,
291,
423,
2550,
14,
740,
8,
2184,
8,
277,
423,
11034,
430,
288,
871,
10852,
26,
355,
986,
398,
372,
440,
291,
423,
2550,
339,
347,
485,
981,
63,
11034,
8,
277,
9,
1035,
15042,
59,
495,
12,
488,
12,
488,
2189,
267,
408,
267,
10560,
282,
4306,
626,
1630,
1006,
314,
1736,
14,
267,
408,
267,
327,
5611,
15809,
701,
2287,
370,
1852,
652,
14905,
370,
13974,
267,
327,
1806,
4153,
14,
267,
16251,
63,
13754,
275,
291,
14,
6469,
14,
923,
63,
13754,
342,
398,
327,
13930,
282,
9284,
1420,
1338,
14,
267,
8844,
63,
2227,
275,
291,
14,
6469,
14,
2227,
267,
2061,
63,
1080,
275,
822,
8,
277,
14,
6469,
9,
446,
413,
398,
327,
17507,
282,
9284,
11789,
465,
781,
2621,
3180,
14,
267,
14094,
275,
378,
398,
327,
2670,
4918,
436,
14094,
1642,
14,
267,
327,
3390,
626,
781,
675,
282,
7055,
370,
4215,
4426,
402,
314,
1453,
1478,
12,
267,
327,
3967,
737,
642,
2376,
781,
883,
1133,
16822,
626,
314,
15809,
1172,
267,
327,
3211,
1124,
1818,
63,
1080,
1040,
1338,
14,
267,
7055,
275,
378,
267,
367,
1572,
315,
16251,
63,
13754,
26,
288,
367,
23883,
315,
1572,
26,
355,
14094,
847,
23883,
14,
585,
2234,
340,
23883,
14,
6469,
63,
2227,
1137,
8844,
63,
2227,
26,
490,
1995,
283,
10161,
469,
73,
93,
965,
3866,
8844,
2631,
17374,
908,
8,
717,
284,
29,
5337,
12,
490,
776,
2234,
340,
23883,
14,
1818,
63,
1080,
1137,
7055,
26,
490,
1995,
334,
717,
283,
10161,
469,
73,
93,
965,
3866,
1453,
1478,
574,
283,
717,
8189,
2062,
469,
73,
1386,
3503,
469,
6514,
21385,
1370,
908,
8,
1169,
3503,
29,
18174,
14,
1818,
63,
1080,
12,
1169,
284,
29,
5337,
12,
717,
776,
490,
776,
2234,
340,
23883,
14,
2019,
63,
1080,
1137,
2061,
63,
1080,
26,
490,
1995,
334,
717,
283,
10161,
469,
73,
93,
965,
3866,
2061,
1478,
574,
283,
717,
8189,
2062,
469,
2062,
1386,
3503,
469,
6514,
21385,
1370,
908,
8,
1169,
3503,
29,
18174,
14,
2019,
63,
1080,
12,
1169,
1420,
29,
2019,
63,
1080,
12,
1169,
284,
29,
5337,
12,
717,
776,
490,
776,
2234,
7055,
847,
413,
398,
327,
29311,
1471,
506,
14094,
68,
334,
681,
3198,
1471,
1336,
4153,
680,
267,
340,
14094,
1137,
378,
26,
288,
1995,
334,
355,
283,
12320,
965,
3866,
14094,
283,
355,
8189,
2062,
378,
12,
3503,
469,
6514,
21385,
1370,
908,
8,
490,
3503,
29,
7358,
12,
355,
776,
288,
776,
398,
327,
18603,
6411,
365,
1454,
26562,
340,
314,
15809,
267,
327,
787,
4257,
1686,
14,
267,
340,
440,
291,
423,
2550,
26,
288,
4955,
63,
6136,
63,
1825,
26,
3820,
59,
1296,
59,
10161,
2677,
275,
942,
953,
367,
1572,
315,
16251,
63,
13754,
26,
355,
327,
18603,
6411,
1454,
12966,
370,
4153,
14,
355,
340,
1572,
59,
16,
1055,
585,
2356,
378,
26,
490,
1980,
2234,
4107,
63,
923,
63,
5233,
275,
715,
355,
367,
1335,
12,
23883,
315,
3874,
8,
923,
304,
490,
340,
334,
74,
690,
378,
9,
436,
334,
18174,
14,
585,
1137,
378,
304,
717,
327,
6924,
365,
24159,
27,
4955,
21495,
2410,
717,
327,
314,
1642,
1077,
1172,
4697,
574,
14,
717,
1995,
334,
1169,
283,
10161,
469,
73,
93,
965,
3866,
574,
283,
1169,
8189,
2062,
378,
12,
3503,
469,
6514,
21385,
1370,
908,
8,
1816,
3503,
29,
18174,
14,
585,
12,
28134,
327,
982,
781,
664,
370,
642,
2376,
12,
781,
5715,
626,
1816,
327,
314,
1124,
1818,
63,
1080,
1040,
574,
367,
1924,
1816,
327,
6008,
883,
506,
19427,
14,
1816,
284,
29,
18174,
14,
1818,
63,
1080,
12,
1169,
776,
717,
776,
9453,
327,
2136,
7859,
1133,
506,
7688,
370,
4107,
314,
4955,
12,
717,
327,
1325,
1980,
15988,
12,
880,
626,
781,
883,
1104,
626,
717,
327,
314,
1163,
15809,
315,
314,
1572,
1172,
314,
717,
327,
3211,
1124,
585,
4345,
717,
4107,
63,
923,
63,
5233
] |
[
14090,
492,
15042,
12,
3820,
12,
4879,
12,
2434,
199,
199,
504,
284,
12041,
14,
10316,
14,
2570,
76,
492,
1804,
281,
76,
199,
504,
284,
12041,
14,
10316,
14,
23238,
492,
4107,
63,
5233,
63,
18047,
199,
504,
284,
12041,
14,
5945,
14,
1095,
492,
29311,
12,
18244,
199,
199,
363,
452,
363,
275,
359,
272,
283,
12320,
8640,
297,
199,
61,
199,
199,
3,
1010,
7437,
24063,
5560,
12,
314,
473,
32760,
4113,
1443,
6258,
2631,
18036,
14,
199,
3,
3979,
642,
10986,
12,
314,
473,
32760,
2752,
911,
1218,
282,
5740,
12,
880,
199,
3,
626,
1006,
892,
2251,
641,
314,
377,
4593,
675,
314,
892,
2631,
5563,
14,
199,
3,
199,
3,
9738,
12,
314,
5740,
911,
5139,
1395,
6941,
370,
7149,
199,
3,
2737,
1808,
314,
12139,
2631,
5563,
12,
880,
314,
8844,
11822,
965,
199,
3,
370,
506,
7688,
370,
675,
626,
465,
282,
9567,
1380,
6411,
6918,
14,
199,
15925,
63,
5763,
615,
4962,
275,
1804,
281,
76,
199,
25086,
22114,
63,
5763,
615,
4962,
275,
488,
221,
327,
445,
633,
421,
199,
533,
29311,
8640,
8,
785,
304,
272,
408,
272,
13813,
282,
8844,
436,
2399,
15809,
367,
8826,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
8844,
26,
29311,
9,
1035,
488,
26,
267,
1613,
8,
12320,
8640,
12,
291,
2843,
826,
4533,
398,
291,
14,
6469,
275,
8844,
398,
291,
423,
2550,
26,
4879,
59,
1296,
59,
495,
2677,
275,
942,
267,
291,
423,
11034,
275,
291,
423,
981,
63,
11034,
342,
339,
768,
1829,
272,
347,
2552,
8,
277,
9,
1035,
3820,
59,
495,
2189,
267,
408,
267,
1803,
1006,
2552,
1911,
543,
314,
8844,
14,
267,
408,
267,
862,
26,
288,
291,
423,
2550,
14,
2880,
8,
277,
423,
11034,
9,
221,
327,
730,
26,
3820,
59,
495,
61,
267,
871,
10852,
26,
288,
986,
398,
372,
291,
423,
2550,
339,
347,
365,
63,
1078,
8,
277,
9,
1035,
2155,
26,
267,
408,
267,
1803,
3775,
314,
8844,
365,
1686,
14,
267,
408,
267,
340,
440,
291,
423,
2550,
26,
288,
862,
26,
355,
327,
2136,
1454,
1172,
370,
1104,
367,
282,
2849,
1125,
370,
6705,
355,
327,
340,
314,
8844,
365,
1686,
503,
440,
14,
355,
291,
423,
2550,
14,
740,
8,
2184,
8,
277,
423,
11034,
430,
288,
871,
10852,
26,
355,
986,
398,
372,
440,
291,
423,
2550,
339,
347,
485,
981,
63,
11034,
8,
277,
9,
1035,
15042,
59,
495,
12,
488,
12,
488,
2189,
267,
408,
267,
10560,
282,
4306,
626,
1630,
1006,
314,
1736,
14,
267,
408,
267,
327,
5611,
15809,
701,
2287,
370,
1852,
652,
14905,
370,
13974,
267,
327,
1806,
4153,
14,
267,
16251,
63,
13754,
275,
291,
14,
6469,
14,
923,
63,
13754,
342,
398,
327,
13930,
282,
9284,
1420,
1338,
14,
267,
8844,
63,
2227,
275,
291,
14,
6469,
14,
2227,
267,
2061,
63,
1080,
275,
822,
8,
277,
14,
6469,
9,
446,
413,
398,
327,
17507,
282,
9284,
11789,
465,
781,
2621,
3180,
14,
267,
14094,
275,
378,
398,
327,
2670,
4918,
436,
14094,
1642,
14,
267,
327,
3390,
626,
781,
675,
282,
7055,
370,
4215,
4426,
402,
314,
1453,
1478,
12,
267,
327,
3967,
737,
642,
2376,
781,
883,
1133,
16822,
626,
314,
15809,
1172,
267,
327,
3211,
1124,
1818,
63,
1080,
1040,
1338,
14,
267,
7055,
275,
378,
267,
367,
1572,
315,
16251,
63,
13754,
26,
288,
367,
23883,
315,
1572,
26,
355,
14094,
847,
23883,
14,
585,
2234,
340,
23883,
14,
6469,
63,
2227,
1137,
8844,
63,
2227,
26,
490,
1995,
283,
10161,
469,
73,
93,
965,
3866,
8844,
2631,
17374,
908,
8,
717,
284,
29,
5337,
12,
490,
776,
2234,
340,
23883,
14,
1818,
63,
1080,
1137,
7055,
26,
490,
1995,
334,
717,
283,
10161,
469,
73,
93,
965,
3866,
1453,
1478,
574,
283,
717,
8189,
2062,
469,
73,
1386,
3503,
469,
6514,
21385,
1370,
908,
8,
1169,
3503,
29,
18174,
14,
1818,
63,
1080,
12,
1169,
284,
29,
5337,
12,
717,
776,
490,
776,
2234,
340,
23883,
14,
2019,
63,
1080,
1137,
2061,
63,
1080,
26,
490,
1995,
334,
717,
283,
10161,
469,
73,
93,
965,
3866,
2061,
1478,
574,
283,
717,
8189,
2062,
469,
2062,
1386,
3503,
469,
6514,
21385,
1370,
908,
8,
1169,
3503,
29,
18174,
14,
2019,
63,
1080,
12,
1169,
1420,
29,
2019,
63,
1080,
12,
1169,
284,
29,
5337,
12,
717,
776,
490,
776,
2234,
7055,
847,
413,
398,
327,
29311,
1471,
506,
14094,
68,
334,
681,
3198,
1471,
1336,
4153,
680,
267,
340,
14094,
1137,
378,
26,
288,
1995,
334,
355,
283,
12320,
965,
3866,
14094,
283,
355,
8189,
2062,
378,
12,
3503,
469,
6514,
21385,
1370,
908,
8,
490,
3503,
29,
7358,
12,
355,
776,
288,
776,
398,
327,
18603,
6411,
365,
1454,
26562,
340,
314,
15809,
267,
327,
787,
4257,
1686,
14,
267,
340,
440,
291,
423,
2550,
26,
288,
4955,
63,
6136,
63,
1825,
26,
3820,
59,
1296,
59,
10161,
2677,
275,
942,
953,
367,
1572,
315,
16251,
63,
13754,
26,
355,
327,
18603,
6411,
1454,
12966,
370,
4153,
14,
355,
340,
1572,
59,
16,
1055,
585,
2356,
378,
26,
490,
1980,
2234,
4107,
63,
923,
63,
5233,
275,
715,
355,
367,
1335,
12,
23883,
315,
3874,
8,
923,
304,
490,
340,
334,
74,
690,
378,
9,
436,
334,
18174,
14,
585,
1137,
378,
304,
717,
327,
6924,
365,
24159,
27,
4955,
21495,
2410,
717,
327,
314,
1642,
1077,
1172,
4697,
574,
14,
717,
1995,
334,
1169,
283,
10161,
469,
73,
93,
965,
3866,
574,
283,
1169,
8189,
2062,
378,
12,
3503,
469,
6514,
21385,
1370,
908,
8,
1816,
3503,
29,
18174,
14,
585,
12,
28134,
327,
982,
781,
664,
370,
642,
2376,
12,
781,
5715,
626,
1816,
327,
314,
1124,
1818,
63,
1080,
1040,
574,
367,
1924,
1816,
327,
6008,
883,
506,
19427,
14,
1816,
284,
29,
18174,
14,
1818,
63,
1080,
12,
1169,
776,
717,
776,
9453,
327,
2136,
7859,
1133,
506,
7688,
370,
4107,
314,
4955,
12,
717,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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
] |
mdanielwork/intellij-community
|
python/helpers/py3only/docutils/frontend.py
|
44
|
35209
|
# $Id: frontend.py 7584 2013-01-01 20:00:21Z milde $
# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.
"""
Command-line and common processing for Docutils front-end tools.
Exports the following classes:
* `OptionParser`: Standard Docutils command-line processing.
* `Option`: Customized version of `optparse.Option`; validation support.
* `Values`: Runtime settings; objects are simple structs
(``object.attribute``). Supports cumulative list settings (attributes).
* `ConfigParser`: Standard Docutils config file processing.
Also exports the following functions:
* Option callbacks: `store_multiple`, `read_config_file`.
* Setting validators: `validate_encoding`,
`validate_encoding_error_handler`,
`validate_encoding_and_error_handler`,
`validate_boolean`, `validate_ternary`, `validate_threshold`,
`validate_colon_separated_string_list`,
`validate_comma_separated_string_list`,
`validate_dependency_file`.
* `make_paths_absolute`.
* SettingSpec manipulation: `filter_settings_spec`.
"""
__docformat__ = 'reStructuredText'
import codecs
import optparse
import os
import os.path
import sys
import warnings
from optparse import SUPPRESS_HELP
import configparser as CP
import docutils
import docutils.nodes
import docutils.utils
from docutils.utils.error_reporting import locale_encoding, ErrorOutput, ErrorString
def store_multiple(option, opt, value, parser, *args, **kwargs):
"""
Store multiple values in `parser.values`. (Option callback.)
Store `None` for each attribute named in `args`, and store the value for
each key (attribute name) in `kwargs`.
"""
for attribute in args:
setattr(parser.values, attribute, None)
for key, value in list(kwargs.items()):
setattr(parser.values, key, value)
def read_config_file(option, opt, value, parser):
"""
Read a configuration file during option processing. (Option callback.)
"""
try:
new_settings = parser.get_config_file_settings(value)
except ValueError as error:
parser.error(error)
parser.values.update(new_settings, parser)
def validate_encoding(setting, value, option_parser,
config_parser=None, config_section=None):
try:
codecs.lookup(value)
except LookupError:
raise LookupError('setting "%s": unknown encoding: "%s"'
% (setting, value))
return value
def validate_encoding_error_handler(setting, value, option_parser,
config_parser=None, config_section=None):
try:
codecs.lookup_error(value)
except LookupError:
raise LookupError(
'unknown encoding error handler: "%s" (choices: '
'"strict", "ignore", "replace", "backslashreplace", '
'"xmlcharrefreplace", and possibly others; see documentation for '
'the Python ``codecs`` module)' % value)
return value
def validate_encoding_and_error_handler(
setting, value, option_parser, config_parser=None, config_section=None):
"""
Side-effect: if an error handler is included in the value, it is inserted
into the appropriate place as if it was a separate setting/option.
"""
if ':' in value:
encoding, handler = value.split(':')
validate_encoding_error_handler(
setting + '_error_handler', handler, option_parser,
config_parser, config_section)
if config_parser:
config_parser.set(config_section, setting + '_error_handler',
handler)
else:
setattr(option_parser.values, setting + '_error_handler', handler)
else:
encoding = value
validate_encoding(setting, encoding, option_parser,
config_parser, config_section)
return encoding
def validate_boolean(setting, value, option_parser,
config_parser=None, config_section=None):
"""Check/normalize boolean settings:
True: '1', 'on', 'yes', 'true'
False: '0', 'off', 'no','false', ''
"""
if isinstance(value, bool):
return value
try:
return option_parser.booleans[value.strip().lower()]
except KeyError:
raise LookupError('unknown boolean value: "%s"' % value)
def validate_ternary(setting, value, option_parser,
config_parser=None, config_section=None):
"""Check/normalize three-value settings:
True: '1', 'on', 'yes', 'true'
False: '0', 'off', 'no','false', ''
any other value: returned as-is.
"""
if isinstance(value, bool) or value is None:
return value
try:
return option_parser.booleans[value.strip().lower()]
except KeyError:
return value
def validate_nonnegative_int(setting, value, option_parser,
config_parser=None, config_section=None):
value = int(value)
if value < 0:
raise ValueError('negative value; must be positive or zero')
return value
def validate_threshold(setting, value, option_parser,
config_parser=None, config_section=None):
try:
return int(value)
except ValueError:
try:
return option_parser.thresholds[value.lower()]
except (KeyError, AttributeError):
raise LookupError('unknown threshold: %r.' % value)
def validate_colon_separated_string_list(
setting, value, option_parser, config_parser=None, config_section=None):
if not isinstance(value, list):
value = value.split(':')
else:
last = value.pop()
value.extend(last.split(':'))
return value
def validate_comma_separated_list(setting, value, option_parser,
config_parser=None, config_section=None):
"""Check/normalize list arguments (split at "," and strip whitespace).
"""
# `value` is already a ``list`` when given as command line option
# and "action" is "append" and ``unicode`` or ``str`` else.
if not isinstance(value, list):
value = [value]
# this function is called for every option added to `value`
# -> split the last item and append the result:
last = value.pop()
items = [i.strip(' \t\n') for i in last.split(',') if i.strip(' \t\n')]
value.extend(items)
return value
def validate_url_trailing_slash(
setting, value, option_parser, config_parser=None, config_section=None):
if not value:
return './'
elif value.endswith('/'):
return value
else:
return value + '/'
def validate_dependency_file(setting, value, option_parser,
config_parser=None, config_section=None):
try:
return docutils.utils.DependencyList(value)
except IOError:
return docutils.utils.DependencyList(None)
def validate_strip_class(setting, value, option_parser,
config_parser=None, config_section=None):
# value is a comma separated string list:
value = validate_comma_separated_list(setting, value, option_parser,
config_parser, config_section)
# validate list elements:
for cls in value:
normalized = docutils.nodes.make_id(cls)
if cls != normalized:
raise ValueError('invalid class value %r (perhaps %r?)'
% (cls, normalized))
return value
def make_paths_absolute(pathdict, keys, base_path=None):
"""
Interpret filesystem path settings relative to the `base_path` given.
Paths are values in `pathdict` whose keys are in `keys`. Get `keys` from
`OptionParser.relative_path_settings`.
"""
if base_path is None:
base_path = os.getcwd() # type(base_path) == unicode
# to allow combining non-ASCII cwd with unicode values in `pathdict`
for key in keys:
if key in pathdict:
value = pathdict[key]
if isinstance(value, list):
value = [make_one_path_absolute(base_path, path)
for path in value]
elif value:
value = make_one_path_absolute(base_path, value)
pathdict[key] = value
def make_one_path_absolute(base_path, path):
return os.path.abspath(os.path.join(base_path, path))
def filter_settings_spec(settings_spec, *exclude, **replace):
"""Return a copy of `settings_spec` excluding/replacing some settings.
`settings_spec` is a tuple of configuration settings with a structure
described for docutils.SettingsSpec.settings_spec.
Optional positional arguments are names of to-be-excluded settings.
Keyword arguments are option specification replacements.
(See the html4strict writer for an example.)
"""
settings = list(settings_spec)
# every third item is a sequence of option tuples
for i in range(2, len(settings), 3):
newopts = []
for opt_spec in settings[i]:
# opt_spec is ("<help>", [<option strings>], {<keyword args>})
opt_name = [opt_string[2:].replace('-', '_')
for opt_string in opt_spec[1]
if opt_string.startswith('--')
][0]
if opt_name in exclude:
continue
if opt_name in list(replace.keys()):
newopts.append(replace[opt_name])
else:
newopts.append(opt_spec)
settings[i] = tuple(newopts)
return tuple(settings)
class Values(optparse.Values):
"""
Updates list attributes by extension rather than by replacement.
Works in conjunction with the `OptionParser.lists` instance attribute.
"""
def __init__(self, *args, **kwargs):
optparse.Values.__init__(self, *args, **kwargs)
if (not hasattr(self, 'record_dependencies')
or self.record_dependencies is None):
# Set up dependency list, in case it is needed.
self.record_dependencies = docutils.utils.DependencyList()
def update(self, other_dict, option_parser):
if isinstance(other_dict, Values):
other_dict = other_dict.__dict__
other_dict = other_dict.copy()
for setting in list(option_parser.lists.keys()):
if (hasattr(self, setting) and setting in other_dict):
value = getattr(self, setting)
if value:
value += other_dict[setting]
del other_dict[setting]
self._update_loose(other_dict)
def copy(self):
"""Return a shallow copy of `self`."""
return self.__class__(defaults=self.__dict__)
class Option(optparse.Option):
ATTRS = optparse.Option.ATTRS + ['validator', 'overrides']
def process(self, opt, value, values, parser):
"""
Call the validator function on applicable settings and
evaluate the 'overrides' option.
Extends `optparse.Option.process`.
"""
result = optparse.Option.process(self, opt, value, values, parser)
setting = self.dest
if setting:
if self.validator:
value = getattr(values, setting)
try:
new_value = self.validator(setting, value, parser)
except Exception as error:
raise optparse.OptionValueError(
'Error in option "%s":\n %s'
% (opt, ErrorString(error)))
setattr(values, setting, new_value)
if self.overrides:
setattr(values, self.overrides, None)
return result
class OptionParser(optparse.OptionParser, docutils.SettingsSpec):
"""
Parser for command-line and library use. The `settings_spec`
specification here and in other Docutils components are merged to build
the set of command-line options and runtime settings for this process.
Common settings (defined below) and component-specific settings must not
conflict. Short options are reserved for common settings, and components
are restrict to using long options.
"""
standard_config_files = [
'/etc/docutils.conf', # system-wide
'./docutils.conf', # project-specific
'~/.docutils'] # user-specific
"""Docutils configuration files, using ConfigParser syntax. Filenames
will be tilde-expanded later. Later files override earlier ones."""
threshold_choices = 'info 1 warning 2 error 3 severe 4 none 5'.split()
"""Possible inputs for for --report and --halt threshold values."""
thresholds = {'info': 1, 'warning': 2, 'error': 3, 'severe': 4, 'none': 5}
"""Lookup table for --report and --halt threshold values."""
booleans={'1': True, 'on': True, 'yes': True, 'true': True,
'0': False, 'off': False, 'no': False, 'false': False, '': False}
"""Lookup table for boolean configuration file settings."""
default_error_encoding = getattr(sys.stderr, 'encoding',
None) or locale_encoding or 'ascii'
default_error_encoding_error_handler = 'backslashreplace'
settings_spec = (
'General Docutils Options',
None,
(('Specify the document title as metadata.',
['--title'], {}),
('Include a "Generated by Docutils" credit and link.',
['--generator', '-g'], {'action': 'store_true',
'validator': validate_boolean}),
('Do not include a generator credit.',
['--no-generator'], {'action': 'store_false', 'dest': 'generator'}),
('Include the date at the end of the document (UTC).',
['--date', '-d'], {'action': 'store_const', 'const': '%Y-%m-%d',
'dest': 'datestamp'}),
('Include the time & date (UTC).',
['--time', '-t'], {'action': 'store_const',
'const': '%Y-%m-%d %H:%M UTC',
'dest': 'datestamp'}),
('Do not include a datestamp of any kind.',
['--no-datestamp'], {'action': 'store_const', 'const': None,
'dest': 'datestamp'}),
('Include a "View document source" link.',
['--source-link', '-s'], {'action': 'store_true',
'validator': validate_boolean}),
('Use <URL> for a source link; implies --source-link.',
['--source-url'], {'metavar': '<URL>'}),
('Do not include a "View document source" link.',
['--no-source-link'],
{'action': 'callback', 'callback': store_multiple,
'callback_args': ('source_link', 'source_url')}),
('Link from section headers to TOC entries. (default)',
['--toc-entry-backlinks'],
{'dest': 'toc_backlinks', 'action': 'store_const', 'const': 'entry',
'default': 'entry'}),
('Link from section headers to the top of the TOC.',
['--toc-top-backlinks'],
{'dest': 'toc_backlinks', 'action': 'store_const', 'const': 'top'}),
('Disable backlinks to the table of contents.',
['--no-toc-backlinks'],
{'dest': 'toc_backlinks', 'action': 'store_false'}),
('Link from footnotes/citations to references. (default)',
['--footnote-backlinks'],
{'action': 'store_true', 'default': 1,
'validator': validate_boolean}),
('Disable backlinks from footnotes and citations.',
['--no-footnote-backlinks'],
{'dest': 'footnote_backlinks', 'action': 'store_false'}),
('Enable section numbering by Docutils. (default)',
['--section-numbering'],
{'action': 'store_true', 'dest': 'sectnum_xform',
'default': 1, 'validator': validate_boolean}),
('Disable section numbering by Docutils.',
['--no-section-numbering'],
{'action': 'store_false', 'dest': 'sectnum_xform'}),
('Remove comment elements from the document tree.',
['--strip-comments'],
{'action': 'store_true', 'validator': validate_boolean}),
('Leave comment elements in the document tree. (default)',
['--leave-comments'],
{'action': 'store_false', 'dest': 'strip_comments'}),
('Remove all elements with classes="<class>" from the document tree. '
'Warning: potentially dangerous; use with caution. '
'(Multiple-use option.)',
['--strip-elements-with-class'],
{'action': 'append', 'dest': 'strip_elements_with_classes',
'metavar': '<class>', 'validator': validate_strip_class}),
('Remove all classes="<class>" attributes from elements in the '
'document tree. Warning: potentially dangerous; use with caution. '
'(Multiple-use option.)',
['--strip-class'],
{'action': 'append', 'dest': 'strip_classes',
'metavar': '<class>', 'validator': validate_strip_class}),
('Report system messages at or higher than <level>: "info" or "1", '
'"warning"/"2" (default), "error"/"3", "severe"/"4", "none"/"5"',
['--report', '-r'], {'choices': threshold_choices, 'default': 2,
'dest': 'report_level', 'metavar': '<level>',
'validator': validate_threshold}),
('Report all system messages. (Same as "--report=1".)',
['--verbose', '-v'], {'action': 'store_const', 'const': 1,
'dest': 'report_level'}),
('Report no system messages. (Same as "--report=5".)',
['--quiet', '-q'], {'action': 'store_const', 'const': 5,
'dest': 'report_level'}),
('Halt execution at system messages at or above <level>. '
'Levels as in --report. Default: 4 (severe).',
['--halt'], {'choices': threshold_choices, 'dest': 'halt_level',
'default': 4, 'metavar': '<level>',
'validator': validate_threshold}),
('Halt at the slightest problem. Same as "--halt=info".',
['--strict'], {'action': 'store_const', 'const': 1,
'dest': 'halt_level'}),
('Enable a non-zero exit status for non-halting system messages at '
'or above <level>. Default: 5 (disabled).',
['--exit-status'], {'choices': threshold_choices,
'dest': 'exit_status_level',
'default': 5, 'metavar': '<level>',
'validator': validate_threshold}),
('Enable debug-level system messages and diagnostics.',
['--debug'], {'action': 'store_true', 'validator': validate_boolean}),
('Disable debug output. (default)',
['--no-debug'], {'action': 'store_false', 'dest': 'debug'}),
('Send the output of system messages to <file>.',
['--warnings'], {'dest': 'warning_stream', 'metavar': '<file>'}),
('Enable Python tracebacks when Docutils is halted.',
['--traceback'], {'action': 'store_true', 'default': None,
'validator': validate_boolean}),
('Disable Python tracebacks. (default)',
['--no-traceback'], {'dest': 'traceback', 'action': 'store_false'}),
('Specify the encoding and optionally the '
'error handler of input text. Default: <locale-dependent>:strict.',
['--input-encoding', '-i'],
{'metavar': '<name[:handler]>',
'validator': validate_encoding_and_error_handler}),
('Specify the error handler for undecodable characters. '
'Choices: "strict" (default), "ignore", and "replace".',
['--input-encoding-error-handler'],
{'default': 'strict', 'validator': validate_encoding_error_handler}),
('Specify the text encoding and optionally the error handler for '
'output. Default: UTF-8:strict.',
['--output-encoding', '-o'],
{'metavar': '<name[:handler]>', 'default': 'utf-8',
'validator': validate_encoding_and_error_handler}),
('Specify error handler for unencodable output characters; '
'"strict" (default), "ignore", "replace", '
'"xmlcharrefreplace", "backslashreplace".',
['--output-encoding-error-handler'],
{'default': 'strict', 'validator': validate_encoding_error_handler}),
('Specify text encoding and error handler for error output. '
'Default: %s:%s.'
% (default_error_encoding, default_error_encoding_error_handler),
['--error-encoding', '-e'],
{'metavar': '<name[:handler]>', 'default': default_error_encoding,
'validator': validate_encoding_and_error_handler}),
('Specify the error handler for unencodable characters in '
'error output. Default: %s.'
% default_error_encoding_error_handler,
['--error-encoding-error-handler'],
{'default': default_error_encoding_error_handler,
'validator': validate_encoding_error_handler}),
('Specify the language (as BCP 47 language tag). Default: en.',
['--language', '-l'], {'dest': 'language_code', 'default': 'en',
'metavar': '<name>'}),
('Write output file dependencies to <file>.',
['--record-dependencies'],
{'metavar': '<file>', 'validator': validate_dependency_file,
'default': None}), # default set in Values class
('Read configuration settings from <file>, if it exists.',
['--config'], {'metavar': '<file>', 'type': 'string',
'action': 'callback', 'callback': read_config_file}),
("Show this program's version number and exit.",
['--version', '-V'], {'action': 'version'}),
('Show this help message and exit.',
['--help', '-h'], {'action': 'help'}),
# Typically not useful for non-programmatical use:
(SUPPRESS_HELP, ['--id-prefix'], {'default': ''}),
(SUPPRESS_HELP, ['--auto-id-prefix'], {'default': 'id'}),
# Hidden options, for development use only:
(SUPPRESS_HELP, ['--dump-settings'], {'action': 'store_true'}),
(SUPPRESS_HELP, ['--dump-internals'], {'action': 'store_true'}),
(SUPPRESS_HELP, ['--dump-transforms'], {'action': 'store_true'}),
(SUPPRESS_HELP, ['--dump-pseudo-xml'], {'action': 'store_true'}),
(SUPPRESS_HELP, ['--expose-internal-attribute'],
{'action': 'append', 'dest': 'expose_internals',
'validator': validate_colon_separated_string_list}),
(SUPPRESS_HELP, ['--strict-visitor'], {'action': 'store_true'}),
))
"""Runtime settings and command-line options common to all Docutils front
ends. Setting specs specific to individual Docutils components are also
used (see `populate_from_components()`)."""
settings_defaults = {'_disable_config': None,
'_source': None,
'_destination': None,
'_config_files': None}
"""Defaults for settings that don't have command-line option equivalents."""
relative_path_settings = ('warning_stream',)
config_section = 'general'
version_template = ('%%prog (Docutils %s [%s], Python %s, on %s)'
% (docutils.__version__, docutils.__version_details__,
sys.version.split()[0], sys.platform))
"""Default version message."""
def __init__(self, components=(), defaults=None, read_config_files=None,
*args, **kwargs):
"""
`components` is a list of Docutils components each containing a
``.settings_spec`` attribute. `defaults` is a mapping of setting
default overrides.
"""
self.lists = {}
"""Set of list-type settings."""
self.config_files = []
"""List of paths of applied configuration files."""
optparse.OptionParser.__init__(
self, option_class=Option, add_help_option=None,
formatter=optparse.TitledHelpFormatter(width=78),
*args, **kwargs)
if not self.version:
self.version = self.version_template
# Make an instance copy (it will be modified):
self.relative_path_settings = list(self.relative_path_settings)
self.components = (self,) + tuple(components)
self.populate_from_components(self.components)
self.set_defaults_from_dict(defaults or {})
if read_config_files and not self.defaults['_disable_config']:
try:
config_settings = self.get_standard_config_settings()
except ValueError as error:
self.error(error)
self.set_defaults_from_dict(config_settings.__dict__)
def populate_from_components(self, components):
"""
For each component, first populate from the `SettingsSpec.settings_spec`
structure, then from the `SettingsSpec.settings_defaults` dictionary.
After all components have been processed, check for and populate from
each component's `SettingsSpec.settings_default_overrides` dictionary.
"""
for component in components:
if component is None:
continue
settings_spec = component.settings_spec
self.relative_path_settings.extend(
component.relative_path_settings)
for i in range(0, len(settings_spec), 3):
title, description, option_spec = settings_spec[i:i+3]
if title:
group = optparse.OptionGroup(self, title, description)
self.add_option_group(group)
else:
group = self # single options
for (help_text, option_strings, kwargs) in option_spec:
option = group.add_option(help=help_text, *option_strings,
**kwargs)
if kwargs.get('action') == 'append':
self.lists[option.dest] = 1
if component.settings_defaults:
self.defaults.update(component.settings_defaults)
for component in components:
if component and component.settings_default_overrides:
self.defaults.update(component.settings_default_overrides)
def get_standard_config_files(self):
"""Return list of config files, from environment or standard."""
try:
config_files = os.environ['DOCUTILSCONFIG'].split(os.pathsep)
except KeyError:
config_files = self.standard_config_files
# If 'HOME' is not set, expandvars() requires the 'pwd' module which is
# not available under certain environments, for example, within
# mod_python. The publisher ends up in here, and we need to publish
# from within mod_python. Therefore we need to avoid expanding when we
# are in those environments.
expand = os.path.expanduser
if 'HOME' not in os.environ:
try:
import pwd
except ImportError:
expand = lambda x: x
return [expand(f) for f in config_files if f.strip()]
def get_standard_config_settings(self):
settings = Values()
for filename in self.get_standard_config_files():
settings.update(self.get_config_file_settings(filename), self)
return settings
def get_config_file_settings(self, config_file):
"""Returns a dictionary containing appropriate config file settings."""
parser = ConfigParser()
parser.read(config_file, self)
self.config_files.extend(parser._files)
base_path = os.path.dirname(config_file)
applied = {}
settings = Values()
for component in self.components:
if not component:
continue
for section in (tuple(component.config_section_dependencies or ())
+ (component.config_section,)):
if section in applied:
continue
applied[section] = 1
settings.update(parser.get_section(section), self)
make_paths_absolute(
settings.__dict__, self.relative_path_settings, base_path)
return settings.__dict__
def check_values(self, values, args):
"""Store positional arguments as runtime settings."""
values._source, values._destination = self.check_args(args)
make_paths_absolute(values.__dict__, self.relative_path_settings)
values._config_files = self.config_files
return values
def check_args(self, args):
source = destination = None
if args:
source = args.pop(0)
if source == '-': # means stdin
source = None
if args:
destination = args.pop(0)
if destination == '-': # means stdout
destination = None
if args:
self.error('Maximum 2 arguments allowed.')
if source and source == destination:
self.error('Do not specify the same file for both source and '
'destination. It will clobber the source file.')
return source, destination
def set_defaults_from_dict(self, defaults):
self.defaults.update(defaults)
def get_default_values(self):
"""Needed to get custom `Values` instances."""
defaults = Values(self.defaults)
defaults._config_files = self.config_files
return defaults
def get_option_by_dest(self, dest):
"""
Get an option by its dest.
If you're supplying a dest which is shared by several options,
it is undefined which option of those is returned.
A KeyError is raised if there is no option with the supplied
dest.
"""
for group in self.option_groups + [self]:
for option in group.option_list:
if option.dest == dest:
return option
raise KeyError('No option with dest == %r.' % dest)
class ConfigParser(CP.RawConfigParser):
old_settings = {
'pep_stylesheet': ('pep_html writer', 'stylesheet'),
'pep_stylesheet_path': ('pep_html writer', 'stylesheet_path'),
'pep_template': ('pep_html writer', 'template')}
"""{old setting: (new section, new setting)} mapping, used by
`handle_old_config`, to convert settings from the old [options] section."""
old_warning = """
The "[option]" section is deprecated. Support for old-format configuration
files may be removed in a future Docutils release. Please revise your
configuration files. See <http://docutils.sf.net/docs/user/config.html>,
section "Old-Format Configuration Files".
"""
not_utf8_error = """\
Unable to read configuration file "%s": content not encoded as UTF-8.
Skipping "%s" configuration file.
"""
def __init__(self, *args, **kwargs):
CP.RawConfigParser.__init__(self, *args, **kwargs)
self._files = []
"""List of paths of configuration files read."""
self._stderr = ErrorOutput()
"""Wrapper around sys.stderr catching en-/decoding errors"""
def read(self, filenames, option_parser):
if type(filenames) in (str, str):
filenames = [filenames]
for filename in filenames:
try:
# Config files must be UTF-8-encoded:
fp = codecs.open(filename, 'r', 'utf-8')
except IOError:
continue
try:
if sys.version_info < (3,2):
CP.RawConfigParser.readfp(self, fp, filename)
else:
CP.RawConfigParser.read_file(self, fp, filename)
except UnicodeDecodeError:
self._stderr.write(self.not_utf8_error % (filename, filename))
fp.close()
continue
fp.close()
self._files.append(filename)
if self.has_section('options'):
self.handle_old_config(filename)
self.validate_settings(filename, option_parser)
def handle_old_config(self, filename):
warnings.warn_explicit(self.old_warning, ConfigDeprecationWarning,
filename, 0)
options = self.get_section('options')
if not self.has_section('general'):
self.add_section('general')
for key, value in list(options.items()):
if key in self.old_settings:
section, setting = self.old_settings[key]
if not self.has_section(section):
self.add_section(section)
else:
section = 'general'
setting = key
if not self.has_option(section, setting):
self.set(section, setting, value)
self.remove_section('options')
def validate_settings(self, filename, option_parser):
"""
Call the validator function and implement overrides on all applicable
settings.
"""
for section in self.sections():
for setting in self.options(section):
try:
option = option_parser.get_option_by_dest(setting)
except KeyError:
continue
if option.validator:
value = self.get(section, setting)
try:
new_value = option.validator(
setting, value, option_parser,
config_parser=self, config_section=section)
except Exception as error:
raise ValueError(
'Error in config file "%s", section "[%s]":\n'
' %s\n'
' %s = %s'
% (filename, section, ErrorString(error),
setting, value))
self.set(section, setting, new_value)
if option.overrides:
self.set(section, option.overrides, None)
def optionxform(self, optionstr):
"""
Transform '-' to '_' so the cmdline form of option names can be used.
"""
return optionstr.lower().replace('-', '_')
def get_section(self, section):
"""
Return a given section as a dictionary (empty if the section
doesn't exist).
"""
section_dict = {}
if self.has_section(section):
for option in self.options(section):
section_dict[option] = self.get(section, option)
return section_dict
class ConfigDeprecationWarning(DeprecationWarning):
"""Warning for deprecated configuration file features."""
|
apache-2.0
|
[
3,
2672,
1304,
26,
22523,
14,
647,
1520,
12248,
6171,
13,
614,
13,
614,
3388,
26,
383,
26,
2025,
58,
333,
24446,
2672,
199,
3,
6529,
26,
20232,
22311,
836,
665,
8302,
836,
32,
1548,
14,
1308,
30,
199,
3,
1898,
26,
961,
859,
965,
2757,
15090,
315,
314,
4575,
2881,
14,
199,
199,
624,
199,
3110,
13,
604,
436,
2863,
6661,
367,
5454,
1208,
13738,
13,
500,
7249,
14,
199,
199,
920,
5203,
314,
2569,
3992,
26,
199,
199,
10,
658,
14553,
8340,
9739,
5454,
1208,
1414,
13,
604,
6661,
14,
199,
10,
658,
2602,
8340,
8388,
1759,
1015,
402,
658,
2992,
1122,
14,
2602,
64,
27,
6411,
2291,
14,
199,
10,
658,
6550,
8340,
19103,
2202,
27,
2251,
787,
3486,
2702,
83,
523,
15693,
785,
14,
3215,
20008,
221,
32090,
25814,
769,
2202,
334,
2987,
680,
199,
10,
658,
15218,
8340,
9739,
5454,
1208,
1101,
570,
6661,
14,
199,
199,
31892,
22609,
314,
2569,
3423,
26,
199,
199,
10,
3207,
13484,
26,
658,
1617,
63,
6048,
3559,
658,
739,
63,
888,
63,
493,
2313,
199,
10,
13510,
14370,
26,
658,
3502,
63,
2991,
3559,
523,
658,
3502,
63,
2991,
63,
705,
63,
2232,
3559,
523,
658,
3502,
63,
2991,
63,
460,
63,
705,
63,
2232,
3559,
523,
658,
3502,
63,
4871,
3559,
658,
3502,
63,
1203,
695,
3559,
658,
3502,
63,
7227,
3559,
523,
658,
3502,
63,
12167,
63,
12794,
63,
875,
63,
513,
3559,
523,
658,
3502,
63,
13184,
63,
12794,
63,
875,
63,
513,
3559,
523,
658,
3502,
63,
8575,
63,
493,
2313,
199,
10,
658,
1875,
63,
3771,
63,
6116,
2313,
199,
10,
13510,
5307,
26212,
26,
658,
1541,
63,
1751,
63,
1650,
2313,
199,
624,
199,
199,
363,
21841,
363,
275,
283,
264,
27486,
1872,
7,
199,
199,
646,
6010,
199,
646,
8691,
199,
646,
747,
199,
646,
747,
14,
515,
199,
646,
984,
199,
646,
3598,
199,
504,
8691,
492,
7402,
5786,
63,
17930,
199,
199,
646,
21230,
465,
19701,
199,
199,
646,
18382,
199,
646,
18382,
14,
2415,
199,
646,
18382,
14,
1208,
199,
504,
18382,
14,
1208,
14,
705,
63,
28071,
492,
5867,
63,
2991,
12,
4520,
2959,
12,
4520,
1558,
421,
199,
318,
3877,
63,
6048,
8,
1422,
12,
2450,
12,
574,
12,
1798,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
13874,
3663,
1338,
315,
658,
2087,
14,
1459,
2313,
221,
334,
2602,
3233,
4959,
339,
13874,
658,
403,
64,
367,
1924,
2225,
4310,
315,
658,
589,
3559,
436,
3877,
314,
574,
367,
272,
1924,
790,
334,
3215,
536,
9,
315,
658,
958,
2313,
272,
408,
272,
367,
2225,
315,
1249,
26,
267,
5371,
8,
2087,
14,
1459,
12,
2225,
12,
488,
9,
272,
367,
790,
12,
574,
315,
769,
8,
958,
14,
1744,
5109,
267,
5371,
8,
2087,
14,
1459,
12,
790,
12,
574,
9,
199,
199,
318,
1586,
63,
888,
63,
493,
8,
1422,
12,
2450,
12,
574,
12,
1798,
304,
272,
408,
272,
5574,
282,
2897,
570,
5309,
945,
6661,
14,
221,
334,
2602,
3233,
4959,
272,
408,
272,
862,
26,
267,
892,
63,
1751,
275,
1798,
14,
362,
63,
888,
63,
493,
63,
1751,
8,
585,
9,
272,
871,
1722,
465,
1125,
26,
267,
1798,
14,
705,
8,
705,
9,
272,
1798,
14,
1459,
14,
873,
8,
1222,
63,
1751,
12,
1798,
9,
199,
199,
318,
4107,
63,
2991,
8,
6031,
12,
574,
12,
945,
63,
2087,
12,
1993,
1101,
63,
2087,
29,
403,
12,
1101,
63,
2792,
29,
403,
304,
272,
862,
26,
267,
6010,
14,
3892,
8,
585,
9,
272,
871,
19021,
26,
267,
746,
19021,
360,
6031,
2071,
83,
582,
5809,
2644,
26,
2071,
83,
4507,
2574,
450,
334,
6031,
12,
574,
430,
272,
372,
574,
199,
199,
318,
4107,
63,
2991,
63,
705,
63,
2232,
8,
6031,
12,
574,
12,
945,
63,
2087,
12,
2511,
1101,
63,
2087,
29,
403,
12,
1101,
63,
2792,
29,
403,
304,
272,
862,
26,
267,
6010,
14,
3892,
63,
705,
8,
585,
9,
272,
871,
19021,
26,
267,
746,
19021,
8,
288,
283,
5187,
2644,
1125,
3016,
26,
2071,
83,
2,
334,
4577,
26,
283,
288,
5522,
4768,
401,
298,
4247,
401,
298,
1814,
401,
298,
21509,
1814,
401,
283,
288,
5522,
1652,
24253,
1814,
401,
436,
12570,
11789,
27,
1937,
3794,
367,
283,
288,
283,
1589,
2018,
1124,
8933,
1040,
859,
3171,
450,
574,
9,
272,
372,
574,
199,
199,
318,
4107,
63,
2991,
63,
460,
63,
705,
63,
2232,
8,
272,
4260,
12,
574,
12,
945,
63,
2087,
12,
1101,
63,
2087,
29,
403,
12,
1101,
63,
2792,
29,
403,
304,
272,
408,
272,
428,
2655,
13,
5881,
26,
340,
376,
1125,
3016,
365,
5120,
315,
314,
574,
12,
652,
365,
11788,
272,
1901,
314,
5827,
4192,
465,
340,
652,
1990,
282,
7396,
4260,
15,
1422,
14,
272,
408,
272,
340,
10871,
315,
574,
26,
267,
2644,
12,
3016,
275,
574,
14,
1294,
11633,
267,
4107,
63,
2991,
63,
705,
63,
2232,
8,
288,
4260,
435,
2513,
705,
63,
2232,
297,
3016,
12,
945,
63,
2087,
12,
288,
1101,
63,
2087,
12,
1101,
63,
2792,
9,
267,
340,
1101,
63,
2087,
26,
288,
1101,
63,
2087,
14,
409,
8,
888,
63,
2792,
12,
4260,
435,
2513,
705,
63,
2232,
297,
2892,
3016,
9,
267,
587,
26,
288,
5371,
8,
1422,
63,
2087,
14,
1459,
12,
4260,
435,
2513,
705,
63,
2232,
297,
3016,
9,
272,
587,
26,
267,
2644,
275,
574,
272,
4107,
63,
2991,
8,
6031,
12,
2644,
12,
945,
63,
2087,
12,
1993,
1101,
63,
2087,
12,
1101,
63,
2792,
9,
272,
372,
2644,
199,
199,
318,
4107,
63,
4871,
8,
6031,
12,
574,
12,
945,
63,
2087,
12,
2151,
1101,
63,
2087,
29,
403,
12,
1101,
63,
2792,
29,
403,
304,
272,
408,
1799,
15,
7721,
5046,
2202,
26,
268,
715,
26,
221,
283,
17,
297,
283,
265,
297,
283,
5066,
297,
283,
2052,
7,
268,
756,
26,
283,
16,
297,
283,
1997,
297,
283,
889,
1673,
3910,
297,
2125,
272,
408,
272,
340,
1228,
8,
585,
12,
2155,
304,
267,
372,
574,
272,
862,
26,
267,
372,
945,
63,
2087,
14,
15056,
274,
796,
59,
585,
14,
1913,
1252,
2325,
5106
] |
[
2672,
1304,
26,
22523,
14,
647,
1520,
12248,
6171,
13,
614,
13,
614,
3388,
26,
383,
26,
2025,
58,
333,
24446,
2672,
199,
3,
6529,
26,
20232,
22311,
836,
665,
8302,
836,
32,
1548,
14,
1308,
30,
199,
3,
1898,
26,
961,
859,
965,
2757,
15090,
315,
314,
4575,
2881,
14,
199,
199,
624,
199,
3110,
13,
604,
436,
2863,
6661,
367,
5454,
1208,
13738,
13,
500,
7249,
14,
199,
199,
920,
5203,
314,
2569,
3992,
26,
199,
199,
10,
658,
14553,
8340,
9739,
5454,
1208,
1414,
13,
604,
6661,
14,
199,
10,
658,
2602,
8340,
8388,
1759,
1015,
402,
658,
2992,
1122,
14,
2602,
64,
27,
6411,
2291,
14,
199,
10,
658,
6550,
8340,
19103,
2202,
27,
2251,
787,
3486,
2702,
83,
523,
15693,
785,
14,
3215,
20008,
221,
32090,
25814,
769,
2202,
334,
2987,
680,
199,
10,
658,
15218,
8340,
9739,
5454,
1208,
1101,
570,
6661,
14,
199,
199,
31892,
22609,
314,
2569,
3423,
26,
199,
199,
10,
3207,
13484,
26,
658,
1617,
63,
6048,
3559,
658,
739,
63,
888,
63,
493,
2313,
199,
10,
13510,
14370,
26,
658,
3502,
63,
2991,
3559,
523,
658,
3502,
63,
2991,
63,
705,
63,
2232,
3559,
523,
658,
3502,
63,
2991,
63,
460,
63,
705,
63,
2232,
3559,
523,
658,
3502,
63,
4871,
3559,
658,
3502,
63,
1203,
695,
3559,
658,
3502,
63,
7227,
3559,
523,
658,
3502,
63,
12167,
63,
12794,
63,
875,
63,
513,
3559,
523,
658,
3502,
63,
13184,
63,
12794,
63,
875,
63,
513,
3559,
523,
658,
3502,
63,
8575,
63,
493,
2313,
199,
10,
658,
1875,
63,
3771,
63,
6116,
2313,
199,
10,
13510,
5307,
26212,
26,
658,
1541,
63,
1751,
63,
1650,
2313,
199,
624,
199,
199,
363,
21841,
363,
275,
283,
264,
27486,
1872,
7,
199,
199,
646,
6010,
199,
646,
8691,
199,
646,
747,
199,
646,
747,
14,
515,
199,
646,
984,
199,
646,
3598,
199,
504,
8691,
492,
7402,
5786,
63,
17930,
199,
199,
646,
21230,
465,
19701,
199,
199,
646,
18382,
199,
646,
18382,
14,
2415,
199,
646,
18382,
14,
1208,
199,
504,
18382,
14,
1208,
14,
705,
63,
28071,
492,
5867,
63,
2991,
12,
4520,
2959,
12,
4520,
1558,
421,
199,
318,
3877,
63,
6048,
8,
1422,
12,
2450,
12,
574,
12,
1798,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
13874,
3663,
1338,
315,
658,
2087,
14,
1459,
2313,
221,
334,
2602,
3233,
4959,
339,
13874,
658,
403,
64,
367,
1924,
2225,
4310,
315,
658,
589,
3559,
436,
3877,
314,
574,
367,
272,
1924,
790,
334,
3215,
536,
9,
315,
658,
958,
2313,
272,
408,
272,
367,
2225,
315,
1249,
26,
267,
5371,
8,
2087,
14,
1459,
12,
2225,
12,
488,
9,
272,
367,
790,
12,
574,
315,
769,
8,
958,
14,
1744,
5109,
267,
5371,
8,
2087,
14,
1459,
12,
790,
12,
574,
9,
199,
199,
318,
1586,
63,
888,
63,
493,
8,
1422,
12,
2450,
12,
574,
12,
1798,
304,
272,
408,
272,
5574,
282,
2897,
570,
5309,
945,
6661,
14,
221,
334,
2602,
3233,
4959,
272,
408,
272,
862,
26,
267,
892,
63,
1751,
275,
1798,
14,
362,
63,
888,
63,
493,
63,
1751,
8,
585,
9,
272,
871,
1722,
465,
1125,
26,
267,
1798,
14,
705,
8,
705,
9,
272,
1798,
14,
1459,
14,
873,
8,
1222,
63,
1751,
12,
1798,
9,
199,
199,
318,
4107,
63,
2991,
8,
6031,
12,
574,
12,
945,
63,
2087,
12,
1993,
1101,
63,
2087,
29,
403,
12,
1101,
63,
2792,
29,
403,
304,
272,
862,
26,
267,
6010,
14,
3892,
8,
585,
9,
272,
871,
19021,
26,
267,
746,
19021,
360,
6031,
2071,
83,
582,
5809,
2644,
26,
2071,
83,
4507,
2574,
450,
334,
6031,
12,
574,
430,
272,
372,
574,
199,
199,
318,
4107,
63,
2991,
63,
705,
63,
2232,
8,
6031,
12,
574,
12,
945,
63,
2087,
12,
2511,
1101,
63,
2087,
29,
403,
12,
1101,
63,
2792,
29,
403,
304,
272,
862,
26,
267,
6010,
14,
3892,
63,
705,
8,
585,
9,
272,
871,
19021,
26,
267,
746,
19021,
8,
288,
283,
5187,
2644,
1125,
3016,
26,
2071,
83,
2,
334,
4577,
26,
283,
288,
5522,
4768,
401,
298,
4247,
401,
298,
1814,
401,
298,
21509,
1814,
401,
283,
288,
5522,
1652,
24253,
1814,
401,
436,
12570,
11789,
27,
1937,
3794,
367,
283,
288,
283,
1589,
2018,
1124,
8933,
1040,
859,
3171,
450,
574,
9,
272,
372,
574,
199,
199,
318,
4107,
63,
2991,
63,
460,
63,
705,
63,
2232,
8,
272,
4260,
12,
574,
12,
945,
63,
2087,
12,
1101,
63,
2087,
29,
403,
12,
1101,
63,
2792,
29,
403,
304,
272,
408,
272,
428,
2655,
13,
5881,
26,
340,
376,
1125,
3016,
365,
5120,
315,
314,
574,
12,
652,
365,
11788,
272,
1901,
314,
5827,
4192,
465,
340,
652,
1990,
282,
7396,
4260,
15,
1422,
14,
272,
408,
272,
340,
10871,
315,
574,
26,
267,
2644,
12,
3016,
275,
574,
14,
1294,
11633,
267,
4107,
63,
2991,
63,
705,
63,
2232,
8,
288,
4260,
435,
2513,
705,
63,
2232,
297,
3016,
12,
945,
63,
2087,
12,
288,
1101,
63,
2087,
12,
1101,
63,
2792,
9,
267,
340,
1101,
63,
2087,
26,
288,
1101,
63,
2087,
14,
409,
8,
888,
63,
2792,
12,
4260,
435,
2513,
705,
63,
2232,
297,
2892,
3016,
9,
267,
587,
26,
288,
5371,
8,
1422,
63,
2087,
14,
1459,
12,
4260,
435,
2513,
705,
63,
2232,
297,
3016,
9,
272,
587,
26,
267,
2644,
275,
574,
272,
4107,
63,
2991,
8,
6031,
12,
2644,
12,
945,
63,
2087,
12,
1993,
1101,
63,
2087,
12,
1101,
63,
2792,
9,
272,
372,
2644,
199,
199,
318,
4107,
63,
4871,
8,
6031,
12,
574,
12,
945,
63,
2087,
12,
2151,
1101,
63,
2087,
29,
403,
12,
1101,
63,
2792,
29,
403,
304,
272,
408,
1799,
15,
7721,
5046,
2202,
26,
268,
715,
26,
221,
283,
17,
297,
283,
265,
297,
283,
5066,
297,
283,
2052,
7,
268,
756,
26,
283,
16,
297,
283,
1997,
297,
283,
889,
1673,
3910,
297,
2125,
272,
408,
272,
340,
1228,
8,
585,
12,
2155,
304,
267,
372,
574,
272,
862,
26,
267,
372,
945,
63,
2087,
14,
15056,
274,
796,
59,
585,
14,
1913,
1252,
2325,
5106,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tchernomax/ansible
|
lib/ansible/plugins/connection/__init__.py
|
14
|
15940
|
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
# (c) 2015 Toshio Kuratomi <tkuratomi@ansible.com>
# (c) 2017, Peter Sprygada <psprygad@redhat.com>
# (c) 2017 Ansible Project
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import fcntl
import gettext
import os
import shlex
from abc import abstractmethod, abstractproperty
from functools import wraps
from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_bytes, to_text
from ansible.plugins import AnsiblePlugin
from ansible.plugins.loader import shell_loader, connection_loader
from ansible.utils.path import unfrackpath
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
__all__ = ['ConnectionBase', 'ensure_connect']
BUFSIZE = 65536
def ensure_connect(func):
@wraps(func)
def wrapped(self, *args, **kwargs):
if not self._connected:
self._connect()
return func(self, *args, **kwargs)
return wrapped
class ConnectionBase(AnsiblePlugin):
'''
A base class for connections to contain common code.
'''
has_pipelining = False
has_native_async = False # eg, winrm
always_pipeline_modules = False # eg, winrm
become_methods = C.BECOME_METHODS
# When running over this connection type, prefer modules written in a certain language
# as discovered by the specified file extension. An empty string as the
# language means any language.
module_implementation_preferences = ('',)
allow_executable = True
# the following control whether or not the connection supports the
# persistent connection framework or not
supports_persistence = False
force_persistence = False
default_user = None
def __init__(self, play_context, new_stdin, shell=None, *args, **kwargs):
super(ConnectionBase, self).__init__()
# All these hasattrs allow subclasses to override these parameters
if not hasattr(self, '_play_context'):
self._play_context = play_context
if not hasattr(self, '_new_stdin'):
self._new_stdin = new_stdin
# Backwards compat: self._display isn't really needed, just import the global display and use that.
if not hasattr(self, '_display'):
self._display = display
if not hasattr(self, '_connected'):
self._connected = False
self.success_key = None
self.prompt = None
self._connected = False
self._socket_path = None
if shell is not None:
self._shell = shell
# load the shell plugin for this action/connection
if play_context.shell:
shell_type = play_context.shell
elif hasattr(self, '_shell_type'):
shell_type = getattr(self, '_shell_type')
else:
shell_type = 'sh'
shell_filename = os.path.basename(self._play_context.executable)
try:
shell = shell_loader.get(shell_filename)
except Exception:
shell = None
if shell is None:
for shell in shell_loader.all():
if shell_filename in shell.COMPATIBLE_SHELLS:
break
shell_type = shell.SHELL_FAMILY
self._shell = shell_loader.get(shell_type)
if not self._shell:
raise AnsibleError("Invalid shell type specified (%s), or the plugin for that shell type is missing." % shell_type)
@property
def connected(self):
'''Read-only property holding whether the connection to the remote host is active or closed.'''
return self._connected
@property
def socket_path(self):
'''Read-only property holding the connection socket path for this remote host'''
return self._socket_path
def _become_method_supported(self):
''' Checks if the current class supports this privilege escalation method '''
if self._play_context.become_method in self.become_methods:
return True
raise AnsibleError("Internal Error: this connection module does not support running commands via %s" % self._play_context.become_method)
@staticmethod
def _split_ssh_args(argstring):
"""
Takes a string like '-o Foo=1 -o Bar="foo bar"' and returns a
list ['-o', 'Foo=1', '-o', 'Bar=foo bar'] that can be added to
the argument list. The list will not contain any empty elements.
"""
try:
# Python 2.6.x shlex doesn't handle unicode type so we have to
# convert args to byte string for that case. More efficient to
# try without conversion first but python2.6 doesn't throw an
# exception, it merely mangles the output:
# >>> shlex.split(u't e')
# ['t\x00\x00\x00', '\x00\x00\x00e\x00\x00\x00']
return [to_text(x.strip()) for x in shlex.split(to_bytes(argstring)) if x.strip()]
except AttributeError:
# In Python3, shlex.split doesn't work on a byte string.
return [to_text(x.strip()) for x in shlex.split(argstring) if x.strip()]
@abstractproperty
def transport(self):
"""String used to identify this Connection class from other classes"""
pass
@abstractmethod
def _connect(self):
"""Connect to the host we've been initialized with"""
# Check if PE is supported
if self._play_context.become:
self._become_method_supported()
@ensure_connect
@abstractmethod
def exec_command(self, cmd, in_data=None, sudoable=True):
"""Run a command on the remote host.
:arg cmd: byte string containing the command
:kwarg in_data: If set, this data is passed to the command's stdin.
This is used to implement pipelining. Currently not all
connection plugins implement pipelining.
:kwarg sudoable: Tell the connection plugin if we're executing
a command via a privilege escalation mechanism. This may affect
how the connection plugin returns data. Note that not all
connections can handle privilege escalation.
:returns: a tuple of (return code, stdout, stderr) The return code is
an int while stdout and stderr are both byte strings.
When a command is executed, it goes through multiple commands to get
there. It looks approximately like this::
[LocalShell] ConnectionCommand [UsersLoginShell (*)] ANSIBLE_SHELL_EXECUTABLE [(BecomeCommand ANSIBLE_SHELL_EXECUTABLE)] Command
:LocalShell: Is optional. It is run locally to invoke the
``Connection Command``. In most instances, the
``ConnectionCommand`` can be invoked directly instead. The ssh
connection plugin which can have values that need expanding
locally specified via ssh_args is the sole known exception to
this. Shell metacharacters in the command itself should be
processed on the remote machine, not on the local machine so no
shell is needed on the local machine. (Example, ``/bin/sh``)
:ConnectionCommand: This is the command that connects us to the remote
machine to run the rest of the command. ``ansible_ssh_user``,
``ansible_ssh_host`` and so forth are fed to this piece of the
command to connect to the correct host (Examples ``ssh``,
``chroot``)
:UsersLoginShell: This shell may or may not be created depending on
the ConnectionCommand used by the connection plugin. This is the
shell that the ``ansible_ssh_user`` has configured as their login
shell. In traditional UNIX parlance, this is the last field of
a user's ``/etc/passwd`` entry We do not specifically try to run
the ``UsersLoginShell`` when we connect. Instead it is implicit
in the actions that the ``ConnectionCommand`` takes when it
connects to a remote machine. ``ansible_shell_type`` may be set
to inform ansible of differences in how the ``UsersLoginShell``
handles things like quoting if a shell has different semantics
than the Bourne shell.
:ANSIBLE_SHELL_EXECUTABLE: This is the shell set via the inventory var
``ansible_shell_executable`` or via
``constants.DEFAULT_EXECUTABLE`` if the inventory var is not set.
We explicitly invoke this shell so that we have predictable
quoting rules at this point. ``ANSIBLE_SHELL_EXECUTABLE`` is only
settable by the user because some sudo setups may only allow
invoking a specific shell. (For instance, ``/bin/bash`` may be
allowed but ``/bin/sh``, our default, may not). We invoke this
twice, once after the ``ConnectionCommand`` and once after the
``BecomeCommand``. After the ConnectionCommand, this is run by
the ``UsersLoginShell``. After the ``BecomeCommand`` we specify
that the ``ANSIBLE_SHELL_EXECUTABLE`` is being invoked directly.
:BecomeComand ANSIBLE_SHELL_EXECUTABLE: Is the command that performs
privilege escalation. Setting this up is performed by the action
plugin prior to running ``exec_command``. So we just get passed
:param:`cmd` which has the BecomeCommand already added.
(Examples: sudo, su) If we have a BecomeCommand then we will
invoke a ANSIBLE_SHELL_EXECUTABLE shell inside of it so that we
have a consistent view of quoting.
:Command: Is the command we're actually trying to run remotely.
(Examples: mkdir -p $HOME/.ansible, python $HOME/.ansible/tmp-script-file)
"""
pass
@ensure_connect
@abstractmethod
def put_file(self, in_path, out_path):
"""Transfer a file from local to remote"""
pass
@ensure_connect
@abstractmethod
def fetch_file(self, in_path, out_path):
"""Fetch a file from remote to local"""
pass
@abstractmethod
def close(self):
"""Terminate the connection"""
pass
def check_become_success(self, b_output):
b_success_key = to_bytes(self._play_context.success_key)
for b_line in b_output.splitlines(True):
if b_success_key == b_line.rstrip():
return True
return False
def check_password_prompt(self, b_output):
if self._play_context.prompt is None:
return False
elif isinstance(self._play_context.prompt, string_types):
b_prompt = to_bytes(self._play_context.prompt).strip()
b_lines = b_output.splitlines()
return any(l.strip().startswith(b_prompt) for l in b_lines)
else:
return self._play_context.prompt(b_output)
def check_incorrect_password(self, b_output):
b_incorrect_password = to_bytes(gettext.dgettext(self._play_context.become_method, C.BECOME_ERROR_STRINGS[self._play_context.become_method]))
return b_incorrect_password and b_incorrect_password in b_output
def check_missing_password(self, b_output):
b_missing_password = to_bytes(gettext.dgettext(self._play_context.become_method, C.BECOME_MISSING_STRINGS[self._play_context.become_method]))
return b_missing_password and b_missing_password in b_output
def connection_lock(self):
f = self._play_context.connection_lockfd
display.vvvv('CONNECTION: pid %d waiting for lock on %d' % (os.getpid(), f), host=self._play_context.remote_addr)
fcntl.lockf(f, fcntl.LOCK_EX)
display.vvvv('CONNECTION: pid %d acquired lock on %d' % (os.getpid(), f), host=self._play_context.remote_addr)
def connection_unlock(self):
f = self._play_context.connection_lockfd
fcntl.lockf(f, fcntl.LOCK_UN)
display.vvvv('CONNECTION: pid %d released lock on %d' % (os.getpid(), f), host=self._play_context.remote_addr)
def reset(self):
display.warning("Reset is not implemented for this connection")
class NetworkConnectionBase(ConnectionBase):
"""
A base class for network-style connections.
"""
force_persistence = True
# Do not use _remote_is_local in other connections
_remote_is_local = True
def __init__(self, play_context, new_stdin, *args, **kwargs):
super(NetworkConnectionBase, self).__init__(play_context, new_stdin, *args, **kwargs)
self._network_os = self._play_context.network_os
self._local = connection_loader.get('local', play_context, '/dev/null')
self._local.set_options()
self._sub_plugins = []
self._cached_variables = (None, None, None)
# reconstruct the socket_path and set instance values accordingly
self._ansible_playbook_pid = kwargs.get('ansible_playbook_pid')
self._update_connection_state()
def __getattr__(self, name):
try:
return self.__dict__[name]
except KeyError:
if not name.startswith('_'):
for plugin in self._sub_plugins:
method = getattr(plugin['obj'], name, None)
if method is not None:
return method
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
def exec_command(self, cmd, in_data=None, sudoable=True):
return self._local.exec_command(cmd, in_data, sudoable)
def put_file(self, in_path, out_path):
"""Transfer a file from local to remote"""
return self._local.put_file(in_path, out_path)
def fetch_file(self, in_path, out_path):
"""Fetch a file from remote to local"""
return self._local.fetch_file(in_path, out_path)
def reset(self):
'''
Reset the connection
'''
if self._socket_path:
display.vvvv('resetting persistent connection for socket_path %s' % self._socket_path, host=self._play_context.remote_addr)
self.close()
display.vvvv('reset call on connection instance', host=self._play_context.remote_addr)
def close(self):
if self._connected:
self._connected = False
def set_options(self, task_keys=None, var_options=None, direct=None):
super(NetworkConnectionBase, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
for plugin in self._sub_plugins:
if plugin['type'] != 'external':
try:
plugin['obj'].set_options(task_keys=task_keys, var_options=var_options, direct=direct)
except AttributeError:
pass
def _update_connection_state(self):
'''
Reconstruct the connection socket_path and check if it exists
If the socket path exists then the connection is active and set
both the _socket_path value to the path and the _connected value
to True. If the socket path doesn't exist, leave the socket path
value to None and the _connected value to False
'''
ssh = connection_loader.get('ssh', class_only=True)
control_path = ssh._create_control_path(
self._play_context.remote_addr, self._play_context.port,
self._play_context.remote_user, self._play_context.connection,
self._ansible_playbook_pid
)
tmp_path = unfrackpath(C.PERSISTENT_CONTROL_PATH_DIR)
socket_path = unfrackpath(control_path % dict(directory=tmp_path))
if os.path.exists(socket_path):
self._connected = True
self._socket_path = socket_path
|
gpl-3.0
|
[
3,
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
334,
67,
9,
6900,
4005,
609,
2308,
1804,
300,
4188,
73,
665,
2663,
300,
4188,
73,
32,
4853,
14,
957,
30,
199,
3,
334,
67,
9,
9708,
12,
22912,
8360,
651,
71,
10641,
665,
80,
681,
651,
71,
350,
32,
17164,
14,
957,
30,
199,
3,
334,
67,
9,
9708,
2622,
7290,
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,
12871,
199,
646,
9796,
199,
646,
747,
199,
646,
16701,
199,
504,
13022,
492,
9006,
765,
12,
9006,
1829,
199,
504,
9143,
492,
14018,
199,
199,
504,
3242,
492,
5262,
465,
445,
199,
504,
3242,
14,
2550,
492,
13358,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
1059,
63,
1313,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
2394,
12,
370,
63,
505,
199,
504,
3242,
14,
5265,
492,
2622,
5061,
199,
504,
3242,
14,
5265,
14,
3422,
492,
5218,
63,
3422,
12,
1950,
63,
3422,
199,
504,
3242,
14,
1208,
14,
515,
492,
625,
70,
8085,
515,
199,
199,
893,
26,
272,
687,
636,
973,
363,
492,
2929,
199,
2590,
3545,
26,
272,
687,
3242,
14,
1208,
14,
2918,
492,
12175,
272,
2929,
275,
12175,
342,
421,
199,
363,
452,
363,
275,
788,
3225,
1563,
297,
283,
7505,
63,
2242,
418,
199,
199,
21323,
4305,
275,
25980,
421,
199,
318,
4868,
63,
2242,
8,
1532,
304,
272,
768,
13582,
8,
1532,
9,
272,
347,
8072,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
440,
291,
423,
7113,
26,
288,
291,
423,
2242,
342,
267,
372,
2562,
8,
277,
12,
627,
589,
12,
1011,
958,
9,
272,
372,
8072,
421,
199,
533,
8113,
1563,
8,
10047,
5061,
304,
272,
1449,
272,
437,
1300,
1021,
367,
6947,
370,
1395,
2863,
1233,
14,
272,
1449,
339,
965,
63,
4990,
30176,
275,
756,
272,
965,
63,
6106,
63,
4146,
275,
756,
221,
327,
11837,
12,
4747,
5682,
272,
3544,
63,
7379,
63,
3112,
275,
756,
221,
327,
11837,
12,
4747,
5682,
272,
8649,
63,
2474,
275,
445,
14,
6773,
1439,
3635,
63,
18383,
272,
327,
3979,
3879,
1806,
642,
1950,
730,
12,
16602,
4621,
5313,
315,
282,
9842,
2637,
272,
327,
465,
24983,
701,
314,
2013,
570,
3329,
14,
221,
1626,
2701,
1059,
465,
314,
272,
327,
2637,
4910,
1263,
2637,
14,
272,
859,
63,
12236,
63,
18063,
275,
661,
9538,
272,
2040,
63,
5904,
275,
715,
339,
327,
314,
2569,
3304,
3775,
503,
440,
314,
1950,
5171,
314,
272,
327,
16149,
1950,
10059,
503,
440,
272,
5171,
63,
24854,
275,
756,
272,
3542,
63,
24854,
275,
756,
339,
849,
63,
751,
275,
488,
339,
347,
636,
826,
721,
277,
12,
5232,
63,
1100,
12,
892,
63,
6626,
12,
5218,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
398,
1613,
8,
3225,
1563,
12,
291,
2843,
826,
4533,
398,
327,
2900,
3520,
2688,
83,
2040,
9180,
370,
4278,
3520,
2633,
267,
340,
440,
2688,
8,
277,
12,
2513,
2802,
63,
1100,
735,
288,
291,
423,
2802,
63,
1100,
275,
5232,
63,
1100,
267,
340,
440,
2688,
8,
277,
12,
2513,
1222,
63,
6626,
735,
288,
291,
423,
1222,
63,
6626,
275,
892,
63,
6626,
267,
327,
10257,
4751,
8434,
26,
291,
423,
2918,
5712,
1133,
7710,
4346,
12,
2951,
492,
314,
2288,
2929,
436,
675,
626,
14,
267,
340,
440,
2688,
8,
277,
12,
2513,
2918,
735,
288,
291,
423,
2918,
275,
2929,
267,
340,
440,
2688,
8,
277,
12,
2513,
7113,
735,
288,
291,
423,
7113,
275,
756,
398,
291,
14,
3742,
63,
498,
275,
488,
267,
291,
14,
7650,
275,
488,
267,
291,
423,
7113,
275,
756,
267,
291,
423,
3450,
63,
515,
275,
488,
398,
340,
5218,
365,
440,
488,
26,
288,
291,
423,
5641,
275,
5218,
398,
327,
2248,
314,
5218,
3589,
367,
642,
1595,
15,
2105,
267,
340,
5232,
63,
1100,
14,
5641,
26,
288,
5218,
63,
466,
275,
5232,
63,
1100,
14,
5641,
267,
916,
2688,
8,
277,
12,
2513,
5641,
63,
466,
735,
288,
5218,
63,
466,
275,
2519,
8,
277,
12,
2513,
5641,
63,
466,
358,
267,
587,
26,
288,
5218,
63,
466,
275,
283,
609,
7,
288,
5218,
63,
1501,
275,
747,
14,
515,
14,
4846,
8,
277,
423,
2802,
63,
1100,
14,
5904,
9,
288,
862,
26,
355,
5218,
275,
5218,
63,
3422,
14,
362,
8,
5641,
63,
1501,
9,
288,
871,
2186,
26,
355,
5218,
275,
488,
288,
340,
5218,
365,
488,
26,
355,
367,
5218,
315,
5218,
63,
3422,
14,
452,
837,
490,
340,
5218,
63,
1501,
315,
5218,
14,
29720,
7187,
63,
29085,
51,
26,
717,
2059,
288,
5218,
63,
466,
275,
5218,
14,
29085,
63,
38,
1156,
1193,
57,
398,
291,
423,
5641,
275,
5218,
63,
3422,
14,
362,
8,
5641,
63,
466,
9,
267,
340,
440,
291,
423,
5641,
26,
288,
746,
13358,
480,
3364,
5218,
730,
2013,
4366,
83,
395,
503,
314,
3589,
367,
626,
5218,
730,
365,
4124,
2122,
450,
5218,
63,
466,
9,
339,
768,
1829,
272,
347,
8539,
8,
277,
304,
267,
1449,
3284,
13,
2118,
3324,
17573,
3775,
314,
1950,
370,
314,
3982,
1591,
365,
4702,
503,
6876,
10595,
267,
372,
291,
423,
7113,
339,
768,
1829,
272,
347,
2838,
63,
515,
8,
277,
304,
267,
1449,
3284,
13,
2118,
3324,
17573,
314,
1950,
2838,
931,
367,
642,
3982,
1591,
2344,
267,
372,
291,
423,
3450,
63,
515,
339,
347,
485,
13970,
63,
765,
63,
4946,
8,
277,
304,
267,
1449,
13813,
340,
314,
1453,
1021,
5171,
642,
1979,
17228,
325,
4732,
425,
1083,
1449,
398,
340,
291,
423,
2802,
63,
1100,
14,
13970,
63,
765,
315,
291,
14,
13970,
63,
2474,
26,
288,
372,
715,
398,
746,
13358,
480,
8405,
4520,
26,
642,
1950,
859,
1630,
440,
2291,
3879,
3718,
4799,
450,
83,
2,
450,
291,
423,
2802,
63,
1100,
14,
13970,
63,
765,
9,
339,
768,
4639,
272,
347,
485,
1294,
63,
5510,
63,
589,
8,
1273,
875,
304,
267,
408,
267,
17415,
282,
1059,
2839
] |
[
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
334,
67,
9,
6900,
4005,
609,
2308,
1804,
300,
4188,
73,
665,
2663,
300,
4188,
73,
32,
4853,
14,
957,
30,
199,
3,
334,
67,
9,
9708,
12,
22912,
8360,
651,
71,
10641,
665,
80,
681,
651,
71,
350,
32,
17164,
14,
957,
30,
199,
3,
334,
67,
9,
9708,
2622,
7290,
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,
12871,
199,
646,
9796,
199,
646,
747,
199,
646,
16701,
199,
504,
13022,
492,
9006,
765,
12,
9006,
1829,
199,
504,
9143,
492,
14018,
199,
199,
504,
3242,
492,
5262,
465,
445,
199,
504,
3242,
14,
2550,
492,
13358,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
1059,
63,
1313,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
2394,
12,
370,
63,
505,
199,
504,
3242,
14,
5265,
492,
2622,
5061,
199,
504,
3242,
14,
5265,
14,
3422,
492,
5218,
63,
3422,
12,
1950,
63,
3422,
199,
504,
3242,
14,
1208,
14,
515,
492,
625,
70,
8085,
515,
199,
199,
893,
26,
272,
687,
636,
973,
363,
492,
2929,
199,
2590,
3545,
26,
272,
687,
3242,
14,
1208,
14,
2918,
492,
12175,
272,
2929,
275,
12175,
342,
421,
199,
363,
452,
363,
275,
788,
3225,
1563,
297,
283,
7505,
63,
2242,
418,
199,
199,
21323,
4305,
275,
25980,
421,
199,
318,
4868,
63,
2242,
8,
1532,
304,
272,
768,
13582,
8,
1532,
9,
272,
347,
8072,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
440,
291,
423,
7113,
26,
288,
291,
423,
2242,
342,
267,
372,
2562,
8,
277,
12,
627,
589,
12,
1011,
958,
9,
272,
372,
8072,
421,
199,
533,
8113,
1563,
8,
10047,
5061,
304,
272,
1449,
272,
437,
1300,
1021,
367,
6947,
370,
1395,
2863,
1233,
14,
272,
1449,
339,
965,
63,
4990,
30176,
275,
756,
272,
965,
63,
6106,
63,
4146,
275,
756,
221,
327,
11837,
12,
4747,
5682,
272,
3544,
63,
7379,
63,
3112,
275,
756,
221,
327,
11837,
12,
4747,
5682,
272,
8649,
63,
2474,
275,
445,
14,
6773,
1439,
3635,
63,
18383,
272,
327,
3979,
3879,
1806,
642,
1950,
730,
12,
16602,
4621,
5313,
315,
282,
9842,
2637,
272,
327,
465,
24983,
701,
314,
2013,
570,
3329,
14,
221,
1626,
2701,
1059,
465,
314,
272,
327,
2637,
4910,
1263,
2637,
14,
272,
859,
63,
12236,
63,
18063,
275,
661,
9538,
272,
2040,
63,
5904,
275,
715,
339,
327,
314,
2569,
3304,
3775,
503,
440,
314,
1950,
5171,
314,
272,
327,
16149,
1950,
10059,
503,
440,
272,
5171,
63,
24854,
275,
756,
272,
3542,
63,
24854,
275,
756,
339,
849,
63,
751,
275,
488,
339,
347,
636,
826,
721,
277,
12,
5232,
63,
1100,
12,
892,
63,
6626,
12,
5218,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
398,
1613,
8,
3225,
1563,
12,
291,
2843,
826,
4533,
398,
327,
2900,
3520,
2688,
83,
2040,
9180,
370,
4278,
3520,
2633,
267,
340,
440,
2688,
8,
277,
12,
2513,
2802,
63,
1100,
735,
288,
291,
423,
2802,
63,
1100,
275,
5232,
63,
1100,
267,
340,
440,
2688,
8,
277,
12,
2513,
1222,
63,
6626,
735,
288,
291,
423,
1222,
63,
6626,
275,
892,
63,
6626,
267,
327,
10257,
4751,
8434,
26,
291,
423,
2918,
5712,
1133,
7710,
4346,
12,
2951,
492,
314,
2288,
2929,
436,
675,
626,
14,
267,
340,
440,
2688,
8,
277,
12,
2513,
2918,
735,
288,
291,
423,
2918,
275,
2929,
267,
340,
440,
2688,
8,
277,
12,
2513,
7113,
735,
288,
291,
423,
7113,
275,
756,
398,
291,
14,
3742,
63,
498,
275,
488,
267,
291,
14,
7650,
275,
488,
267,
291,
423,
7113,
275,
756,
267,
291,
423,
3450,
63,
515,
275,
488,
398,
340,
5218,
365,
440,
488,
26,
288,
291,
423,
5641,
275,
5218,
398,
327,
2248,
314,
5218,
3589,
367,
642,
1595,
15,
2105,
267,
340,
5232,
63,
1100,
14,
5641,
26,
288,
5218,
63,
466,
275,
5232,
63,
1100,
14,
5641,
267,
916,
2688,
8,
277,
12,
2513,
5641,
63,
466,
735,
288,
5218,
63,
466,
275,
2519,
8,
277,
12,
2513,
5641,
63,
466,
358,
267,
587,
26,
288,
5218,
63,
466,
275,
283,
609,
7,
288,
5218,
63,
1501,
275,
747,
14,
515,
14,
4846,
8,
277,
423,
2802,
63,
1100,
14,
5904,
9,
288,
862,
26,
355,
5218,
275,
5218,
63,
3422,
14,
362,
8,
5641,
63,
1501,
9,
288,
871,
2186,
26,
355,
5218,
275,
488,
288,
340,
5218,
365,
488,
26,
355,
367,
5218,
315,
5218,
63,
3422,
14,
452,
837,
490,
340,
5218,
63,
1501,
315,
5218,
14,
29720,
7187,
63,
29085,
51,
26,
717,
2059,
288,
5218,
63,
466,
275,
5218,
14,
29085,
63,
38,
1156,
1193,
57,
398,
291,
423,
5641,
275,
5218,
63,
3422,
14,
362,
8,
5641,
63,
466,
9,
267,
340,
440,
291,
423,
5641,
26,
288,
746,
13358,
480,
3364,
5218,
730,
2013,
4366,
83,
395,
503,
314,
3589,
367,
626,
5218,
730,
365,
4124,
2122,
450,
5218,
63,
466,
9,
339,
768,
1829,
272,
347,
8539,
8,
277,
304,
267,
1449,
3284,
13,
2118,
3324,
17573,
3775,
314,
1950,
370,
314,
3982,
1591,
365,
4702,
503,
6876,
10595,
267,
372,
291,
423,
7113,
339,
768,
1829,
272,
347,
2838,
63,
515,
8,
277,
304,
267,
1449,
3284,
13,
2118,
3324,
17573,
314,
1950,
2838,
931,
367,
642,
3982,
1591,
2344,
267,
372,
291,
423,
3450,
63,
515,
339,
347,
485,
13970,
63,
765,
63,
4946,
8,
277,
304,
267,
1449,
13813,
340,
314,
1453,
1021,
5171,
642,
1979,
17228,
325,
4732,
425,
1083,
1449,
398,
340,
291,
423,
2802,
63,
1100,
14,
13970,
63,
765,
315,
291,
14,
13970,
63,
2474,
26,
288,
372,
715,
398,
746,
13358,
480,
8405,
4520,
26,
642,
1950,
859,
1630,
440,
2291,
3879,
3718,
4799,
450,
83,
2,
450,
291,
423,
2802,
63,
1100,
14,
13970,
63,
765,
9,
339,
768,
4639,
272,
347,
485,
1294,
63,
5510,
63,
589,
8,
1273,
875,
304,
267,
408,
267,
17415,
282,
1059,
2839,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
rpdillon/wikid
|
wikid/web/test.py
|
118
|
1393
|
"""test utilities
(part of web.py)
"""
import unittest
import sys, os
import web
TestCase = unittest.TestCase
TestSuite = unittest.TestSuite
def load_modules(names):
return [__import__(name, None, None, "x") for name in names]
def module_suite(module, classnames=None):
"""Makes a suite from a module."""
if classnames:
return unittest.TestLoader().loadTestsFromNames(classnames, module)
elif hasattr(module, 'suite'):
return module.suite()
else:
return unittest.TestLoader().loadTestsFromModule(module)
def doctest_suite(module_names):
"""Makes a test suite from doctests."""
import doctest
suite = TestSuite()
for mod in load_modules(module_names):
suite.addTest(doctest.DocTestSuite(mod))
return suite
def suite(module_names):
"""Creates a suite from multiple modules."""
suite = TestSuite()
for mod in load_modules(module_names):
suite.addTest(module_suite(mod))
return suite
def runTests(suite):
runner = unittest.TextTestRunner()
return runner.run(suite)
def main(suite=None):
if not suite:
main_module = __import__('__main__')
# allow command line switches
args = [a for a in sys.argv[1:] if not a.startswith('-')]
suite = module_suite(main_module, args or None)
result = runTests(suite)
sys.exit(not result.wasSuccessful())
|
gpl-3.0
|
[
624,
396,
15841,
199,
8,
2064,
402,
3330,
14,
647,
9,
199,
624,
199,
646,
2882,
199,
646,
984,
12,
747,
199,
646,
3330,
199,
199,
1746,
275,
2882,
14,
1746,
199,
10591,
275,
2882,
14,
10591,
199,
199,
318,
2248,
63,
3112,
8,
1247,
304,
272,
372,
359,
363,
646,
721,
354,
12,
488,
12,
488,
12,
298,
88,
531,
367,
536,
315,
1561,
61,
199,
199,
318,
859,
63,
5768,
8,
578,
12,
1021,
1247,
29,
403,
304,
272,
408,
27142,
282,
5241,
687,
282,
859,
1041,
272,
340,
1021,
1247,
26,
267,
372,
2882,
14,
15824,
1252,
28730,
8,
533,
1247,
12,
859,
9,
272,
916,
2688,
8,
578,
12,
283,
5768,
735,
267,
372,
859,
14,
5768,
342,
272,
587,
26,
267,
372,
2882,
14,
15824,
1252,
12861,
2377,
8,
578,
9,
199,
199,
318,
8868,
63,
5768,
8,
578,
63,
1247,
304,
272,
408,
27142,
282,
511,
5241,
687,
26721,
1041,
272,
492,
8868,
272,
5241,
275,
20979,
342,
272,
367,
3413,
315,
2248,
63,
3112,
8,
578,
63,
1247,
304,
267,
5241,
14,
15714,
8,
11390,
14,
3768,
10591,
8,
1494,
430,
272,
372,
5241,
1362,
199,
318,
5241,
8,
578,
63,
1247,
304,
272,
408,
10607,
282,
5241,
687,
3663,
4621,
1041,
272,
5241,
275,
20979,
342,
272,
367,
3413,
315,
2248,
63,
3112,
8,
578,
63,
1247,
304,
267,
5241,
14,
15714,
8,
578,
63,
5768,
8,
1494,
430,
272,
372,
5241,
199,
199,
318,
1255,
2925,
8,
5768,
304,
272,
7876,
275,
2882,
14,
24285,
342,
272,
372,
7876,
14,
1065,
8,
5768,
9,
199,
199,
318,
2446,
8,
5768,
29,
403,
304,
272,
340,
440,
5241,
26,
267,
2446,
63,
578,
275,
636,
646,
363,
10714,
973,
13766,
267,
327,
2040,
1414,
1004,
24563,
267,
1249,
275,
359,
65,
367,
282,
315,
984,
14,
3020,
59,
17,
2938,
340,
440,
282,
14,
2460,
3654,
5440,
267,
5241,
275,
859,
63,
5768,
8,
973,
63,
578,
12,
1249,
503,
488,
9,
339,
754,
275,
1255,
2925,
8,
5768,
9,
272,
984,
14,
2224,
8,
1397,
754,
14,
10274,
20839,
1012,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
396,
15841,
199,
8,
2064,
402,
3330,
14,
647,
9,
199,
624,
199,
646,
2882,
199,
646,
984,
12,
747,
199,
646,
3330,
199,
199,
1746,
275,
2882,
14,
1746,
199,
10591,
275,
2882,
14,
10591,
199,
199,
318,
2248,
63,
3112,
8,
1247,
304,
272,
372,
359,
363,
646,
721,
354,
12,
488,
12,
488,
12,
298,
88,
531,
367,
536,
315,
1561,
61,
199,
199,
318,
859,
63,
5768,
8,
578,
12,
1021,
1247,
29,
403,
304,
272,
408,
27142,
282,
5241,
687,
282,
859,
1041,
272,
340,
1021,
1247,
26,
267,
372,
2882,
14,
15824,
1252,
28730,
8,
533,
1247,
12,
859,
9,
272,
916,
2688,
8,
578,
12,
283,
5768,
735,
267,
372,
859,
14,
5768,
342,
272,
587,
26,
267,
372,
2882,
14,
15824,
1252,
12861,
2377,
8,
578,
9,
199,
199,
318,
8868,
63,
5768,
8,
578,
63,
1247,
304,
272,
408,
27142,
282,
511,
5241,
687,
26721,
1041,
272,
492,
8868,
272,
5241,
275,
20979,
342,
272,
367,
3413,
315,
2248,
63,
3112,
8,
578,
63,
1247,
304,
267,
5241,
14,
15714,
8,
11390,
14,
3768,
10591,
8,
1494,
430,
272,
372,
5241,
1362,
199,
318,
5241,
8,
578,
63,
1247,
304,
272,
408,
10607,
282,
5241,
687,
3663,
4621,
1041,
272,
5241,
275,
20979,
342,
272,
367,
3413,
315,
2248,
63,
3112,
8,
578,
63,
1247,
304,
267,
5241,
14,
15714,
8,
578,
63,
5768,
8,
1494,
430,
272,
372,
5241,
199,
199,
318,
1255,
2925,
8,
5768,
304,
272,
7876,
275,
2882,
14,
24285,
342,
272,
372,
7876,
14,
1065,
8,
5768,
9,
199,
199,
318,
2446,
8,
5768,
29,
403,
304,
272,
340,
440,
5241,
26,
267,
2446,
63,
578,
275,
636,
646,
363,
10714,
973,
13766,
267,
327,
2040,
1414,
1004,
24563,
267,
1249,
275,
359,
65,
367,
282,
315,
984,
14,
3020,
59,
17,
2938,
340,
440,
282,
14,
2460,
3654,
5440,
267,
5241,
275,
859,
63,
5768,
8,
973,
63,
578,
12,
1249,
503,
488,
9,
339,
754,
275,
1255,
2925,
8,
5768,
9,
272,
984,
14,
2224,
8,
1397,
754,
14,
10274,
20839,
1012,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
mkaluza/external_chromium_org
|
chrome/common/extensions/docs/server2/persistent_object_store_test.py
|
117
|
1737
|
#!/usr/bin/env python
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from persistent_object_store import PersistentObjectStore
import unittest
class PersistentObjectStoreTest(unittest.TestCase):
'''Tests for PersistentObjectStore. These are all a bit contrived because
ultimately it comes down to our use of the appengine datastore API, and we
mock it out for tests anyway. Who knows whether it's correct.
'''
def testPersistence(self):
# First object store.
object_store = PersistentObjectStore('test')
object_store.Set('key', 'value')
self.assertEqual('value', object_store.Get('key').Get())
# Other object store should have it too.
another_object_store = PersistentObjectStore('test')
self.assertEqual('value', another_object_store.Get('key').Get())
# Setting in the other store should set in both.
mapping = {'key2': 'value2', 'key3': 'value3'}
another_object_store.SetMulti(mapping)
self.assertEqual(mapping, object_store.GetMulti(mapping.keys()).Get())
self.assertEqual(mapping,
another_object_store.GetMulti(mapping.keys()).Get())
# And delete.
object_store.DelMulti(mapping.keys())
self.assertEqual({}, object_store.GetMulti(mapping.keys()).Get())
self.assertEqual({}, another_object_store.GetMulti(mapping.keys()).Get())
def testNamespaceIsolation(self):
object_store = PersistentObjectStore('test')
another_object_store = PersistentObjectStore('another')
object_store.Set('key', 'value')
self.assertEqual(None, another_object_store.Get('key').Get())
if __name__ == '__main__':
unittest.main()
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
504,
16149,
63,
785,
63,
1617,
492,
3492,
6082,
1692,
5502,
199,
646,
2882,
199,
199,
533,
3492,
6082,
1692,
5502,
774,
8,
2796,
14,
1746,
304,
523,
1449,
2925,
367,
3492,
6082,
1692,
5502,
14,
5723,
787,
1006,
282,
4546,
406,
599,
1354,
2952,
523,
221,
1141,
77,
13824,
652,
12477,
3224,
370,
4154,
675,
402,
314,
1145,
3908,
12007,
3261,
12,
436,
781,
523,
1683,
652,
734,
367,
2295,
15988,
14,
644,
526,
19428,
3775,
652,
1159,
3211,
14,
523,
1449,
523,
347,
511,
2623,
15284,
8,
277,
304,
272,
327,
7758,
909,
3877,
14,
272,
909,
63,
1617,
275,
3492,
6082,
1692,
5502,
360,
396,
358,
272,
909,
63,
1617,
14,
1084,
360,
498,
297,
283,
585,
358,
272,
291,
14,
629,
360,
585,
297,
909,
63,
1617,
14,
1002,
360,
498,
1959,
1002,
1012,
272,
327,
5439,
909,
3877,
1077,
1172,
652,
4634,
14,
272,
4573,
63,
785,
63,
1617,
275,
3492,
6082,
1692,
5502,
360,
396,
358,
272,
291,
14,
629,
360,
585,
297,
4573,
63,
785,
63,
1617,
14,
1002,
360,
498,
1959,
1002,
1012,
272,
327,
13510,
315,
314,
1163,
3877,
1077,
663,
315,
3865,
14,
272,
4412,
275,
791,
498,
18,
356,
283,
585,
18,
297,
283,
498,
19,
356,
283,
585,
19,
936,
272,
4573,
63,
785,
63,
1617,
14,
1084,
3947,
8,
4745,
9,
272,
291,
14,
629,
8,
4745,
12,
909,
63,
1617,
14,
1002,
3947,
8,
4745,
14,
1612,
8801,
1002,
1012,
272,
291,
14,
629,
8,
4745,
12,
2151,
4573,
63,
785,
63,
1617,
14,
1002,
3947,
8,
4745,
14,
1612,
8801,
1002,
1012,
272,
327,
6061,
3145,
14,
272,
909,
63,
1617,
14,
6994,
3947,
8,
4745,
14,
1612,
1012,
272,
291,
14,
629,
16037,
909,
63,
1617,
14,
1002,
3947,
8,
4745,
14,
1612,
8801,
1002,
1012,
272,
291,
14,
629,
16037,
4573,
63,
785,
63,
1617,
14,
1002,
3947,
8,
4745,
14,
1612,
8801,
1002,
1012,
819,
347,
511,
8814,
1831,
10410,
8,
277,
304,
272,
909,
63,
1617,
275,
3492,
6082,
1692,
5502,
360,
396,
358,
272,
4573,
63,
785,
63,
1617,
275,
3492,
6082,
1692,
5502,
360,
13565,
358,
272,
909,
63,
1617,
14,
1084,
360,
498,
297,
283,
585,
358,
272,
291,
14,
629,
8,
403,
12,
4573,
63,
785,
63,
1617,
14,
1002,
360,
498,
1959,
1002,
1012,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
1898,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
504,
16149,
63,
785,
63,
1617,
492,
3492,
6082,
1692,
5502,
199,
646,
2882,
199,
199,
533,
3492,
6082,
1692,
5502,
774,
8,
2796,
14,
1746,
304,
523,
1449,
2925,
367,
3492,
6082,
1692,
5502,
14,
5723,
787,
1006,
282,
4546,
406,
599,
1354,
2952,
523,
221,
1141,
77,
13824,
652,
12477,
3224,
370,
4154,
675,
402,
314,
1145,
3908,
12007,
3261,
12,
436,
781,
523,
1683,
652,
734,
367,
2295,
15988,
14,
644,
526,
19428,
3775,
652,
1159,
3211,
14,
523,
1449,
523,
347,
511,
2623,
15284,
8,
277,
304,
272,
327,
7758,
909,
3877,
14,
272,
909,
63,
1617,
275,
3492,
6082,
1692,
5502,
360,
396,
358,
272,
909,
63,
1617,
14,
1084,
360,
498,
297,
283,
585,
358,
272,
291,
14,
629,
360,
585,
297,
909,
63,
1617,
14,
1002,
360,
498,
1959,
1002,
1012,
272,
327,
5439,
909,
3877,
1077,
1172,
652,
4634,
14,
272,
4573,
63,
785,
63,
1617,
275,
3492,
6082,
1692,
5502,
360,
396,
358,
272,
291,
14,
629,
360,
585,
297,
4573,
63,
785,
63,
1617,
14,
1002,
360,
498,
1959,
1002,
1012,
272,
327,
13510,
315,
314,
1163,
3877,
1077,
663,
315,
3865,
14,
272,
4412,
275,
791,
498,
18,
356,
283,
585,
18,
297,
283,
498,
19,
356,
283,
585,
19,
936,
272,
4573,
63,
785,
63,
1617,
14,
1084,
3947,
8,
4745,
9,
272,
291,
14,
629,
8,
4745,
12,
909,
63,
1617,
14,
1002,
3947,
8,
4745,
14,
1612,
8801,
1002,
1012,
272,
291,
14,
629,
8,
4745,
12,
2151,
4573,
63,
785,
63,
1617,
14,
1002,
3947,
8,
4745,
14,
1612,
8801,
1002,
1012,
272,
327,
6061,
3145,
14,
272,
909,
63,
1617,
14,
6994,
3947,
8,
4745,
14,
1612,
1012,
272,
291,
14,
629,
16037,
909,
63,
1617,
14,
1002,
3947,
8,
4745,
14,
1612,
8801,
1002,
1012,
272,
291,
14,
629,
16037,
4573,
63,
785,
63,
1617,
14,
1002,
3947,
8,
4745,
14,
1612,
8801,
1002,
1012,
819,
347,
511,
8814,
1831,
10410,
8,
277,
304,
272,
909,
63,
1617,
275,
3492,
6082,
1692,
5502,
360,
396,
358,
272,
4573,
63,
785,
63,
1617,
275,
3492,
6082,
1692,
5502,
360,
13565,
358,
272,
909,
63,
1617,
14,
1084,
360,
498,
297,
283,
585,
358,
272,
291,
14,
629,
8,
403,
12,
4573,
63,
785,
63,
1617,
14,
1002,
360,
498,
1959,
1002,
1012,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
swapnakrishnan2k/tp-qemu
|
qemu/tests/usb_storage.py
|
5
|
8978
|
import logging
import re
import uuid
import aexpect
from autotest.client.shared import error
from virttest import utils_test, utils_misc
@error.context_aware
def run(test, params, env):
"""
Test usb storage devices in the guest.
1) Create a image file by qemu-img
2) Boot up a guest add this image as a usb device
3) Check usb device information via monitor
4) Check usb information by executing guest command
5) Check usb serial option (optional)
6) Check usb removable option (optional)
7) Check usb min_io_size/opt_io_size option (optional)
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
@error.context_aware
def _verify_string(regex_str, string, expect_result, search_opt=0):
"""
Verify USB storage device in monitor
:param regex_str: Regex for checking command output
:param string: The string which will be checked
:param expect_result: The expected string
:param search_opt: Search option for re module.
"""
def _compare_str(act, exp, ignore_case):
def str_func_1(x):
return x
def str_func_2(x):
return x.lower()
str_func = str_func_1
if ignore_case:
str_func = str_func_2
if str_func(act) != str_func(exp):
return ("Expected: '%s', Actual: '%s'" %
(str_func(exp), str_func(act)))
return ""
ignore_case = False
if search_opt & re.I == re.I:
ignore_case = True
error.context("Finding matched sub-string with regex pattern '%s'" %
regex_str, logging.info)
m = re.findall(regex_str, string, search_opt)
if not m:
logging.debug(string)
raise error.TestError("Could not find matched sub-string")
error.context("Verify matched string is same as expected")
actual_result = m[0]
if "removable" in regex_str:
if actual_result in ["on", "yes", "true"]:
actual_result = "on"
if actual_result in ["off", "no", "false"]:
actual_result = "off"
fail_log = []
if isinstance(actual_result, tuple):
for i, v in enumerate(expect_result):
ret = _compare_str(actual_result[i], v, ignore_case)
if ret:
fail_log.append(ret)
else:
ret = _compare_str(actual_result, expect_result[0], ignore_case)
if ret:
fail_log.append(ret)
if fail_log:
logging.debug(string)
raise error.TestFail("Could not find expected string:\n %s" %
("\n".join(fail_log)))
def _do_io_test_guest(session):
utils_test.run_virt_sub_test(test, params, env, "format_disk")
@error.context_aware
def _restart_vm(options):
if vm.is_alive():
vm.destroy()
for option, value in options.iteritems():
params[option] = value
error.context("Restarting VM")
vm.create(params=params)
vm.verify_alive()
def _login():
return vm.wait_for_login(timeout=login_timeout)
def _get_usb_disk_name_in_guest(session):
def _get_output():
cmd = "ls -l /dev/disk/by-path/* | grep usb"
try:
return session.cmd(cmd).strip()
except aexpect.ShellCmdError:
return ""
output = utils_misc.wait_for(_get_output, login_timeout, step=5,
text="Wait for getting USB disk name")
devname = re.findall("sd\w", output)
if devname:
return devname[0]
return "sda"
@error.context_aware
def _check_serial_option(serial, regex_str, expect_str):
error.context("Set serial option to '%s'" % serial, logging.info)
_restart_vm({"blk_extra_params_stg": "serial=" + serial})
error.context("Check serial option in monitor", logging.info)
output = str(vm.monitor.info("qtree"))
_verify_string(regex_str, output, [expect_str], re.S)
error.context("Check serial option in guest", logging.info)
session = _login()
output = session.cmd("lsusb -v")
if serial not in ["EMPTY_STRING", "NO_EQUAL_STRING"]:
# Verify in guest when serial is set to empty/null is meaningless.
_verify_string(serial, output, [serial])
_do_io_test_guest(session)
session.close()
@error.context_aware
def _check_removable_option(removable, expect_str):
error.context("Set removable option to '%s'" % removable, logging.info)
_restart_vm({"removable_stg": removable})
error.context("Check removable option in monitor", logging.info)
output = str(vm.monitor.info("qtree"))
regex_str = 'usb-storage.*?removable = (.*?)\s'
_verify_string(regex_str, output, [removable], re.S)
error.context("Check removable option in guest", logging.info)
session = _login()
cmd = "dmesg | grep %s" % _get_usb_disk_name_in_guest(session)
output = session.cmd(cmd)
_verify_string(expect_str, output, [expect_str], re.I)
_do_io_test_guest(session)
session.close()
@error.context_aware
def _check_io_size_option(min_io_size="512", opt_io_size="0"):
error.context("Set min_io_size to %s, opt_io_size to %s" %
(min_io_size, opt_io_size), logging.info)
opt = {}
opt["min_io_size_stg"] = min_io_size
opt["opt_io_size_stg"] = opt_io_size
_restart_vm(opt)
error.context("Check min/opt io_size option in monitor", logging.info)
output = str(vm.monitor.info("qtree"))
regex_str = "usb-storage.*?min_io_size = (\d+).*?opt_io_size = (\d+)"
_verify_string(regex_str, output, [min_io_size, opt_io_size], re.S)
error.context("Check min/opt io_size option in guest", logging.info)
session = _login()
d = _get_usb_disk_name_in_guest(session)
cmd = ("cat /sys/block/%s/queue/{minimum,optimal}_io_size" % d)
output = session.cmd(cmd)
# Note: If set min_io_size = 0, guest min_io_size would be set to
# 512 by default.
if min_io_size != "0":
expected_min_size = min_io_size
else:
expected_min_size = "512"
_verify_string(
"(\d+)\n(\d+)", output, [expected_min_size, opt_io_size])
_do_io_test_guest(session)
session.close()
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
login_timeout = int(params.get("login_timeout", 360))
error.context("Check usb device information in monitor", logging.info)
output = str(vm.monitor.info("usb"))
if "Product QEMU USB MSD" not in output:
logging.debug(output)
raise error.TestFail("Could not find mass storage device")
error.context("Check usb device information in guest", logging.info)
session = _login()
output = session.cmd(params["chk_usb_info_cmd"])
# No bus specified, default using "usb.0" for "usb-storage"
for i in params["chk_usb_info_keyword"].split(","):
_verify_string(i, output, [i])
_do_io_test_guest(session)
session.close()
if params.get("check_serial_option") == "yes":
error.context("Check usb serial option", logging.info)
serial = str(uuid.uuid4())
regex_str = 'usb-storage.*?serial = "(.*?)"\s'
_check_serial_option(serial, regex_str, serial)
logging.info("Check this option with some illegal string")
logging.info("Set usb serial to a empty string")
# An empty string, ""
serial = "EMPTY_STRING"
regex_str = 'usb-storage.*?serial = (.*?)\s'
_check_serial_option(serial, regex_str, '""')
logging.info("Leave usb serial option blank")
serial = "NO_EQUAL_STRING"
regex_str = 'usb-storage.*?serial = (.*?)\s'
_check_serial_option(serial, regex_str, '"on"')
if params.get("check_removable_option") == "yes":
error.context("Check usb removable option", logging.info)
removable = "on"
expect_str = "Attached SCSI removable disk"
_check_removable_option(removable, expect_str)
removable = "off"
expect_str = "Attached SCSI disk"
_check_removable_option(removable, expect_str)
if params.get("check_io_size_option") == "yes":
error.context("Check usb min/opt io_size option", logging.info)
_check_io_size_option("0", "0")
# Guest can't recognize correct value which we set now,
# So comment these test temporary.
#_check_io_size_option("1024", "1024")
#_check_io_size_option("4096", "4096")
|
gpl-2.0
|
[
646,
2050,
199,
646,
295,
199,
646,
5377,
199,
199,
646,
282,
4921,
199,
199,
504,
2599,
396,
14,
1258,
14,
5555,
492,
1125,
199,
199,
504,
12043,
396,
492,
3778,
63,
396,
12,
3778,
63,
9923,
421,
199,
32,
705,
14,
1100,
63,
14600,
199,
318,
1255,
8,
396,
12,
1862,
12,
2589,
304,
272,
408,
272,
1379,
27923,
4887,
7256,
315,
314,
13980,
14,
339,
413,
9,
2790,
282,
1834,
570,
701,
1894,
14756,
13,
4060,
272,
499,
9,
27324,
1536,
282,
13980,
1050,
642,
1834,
465,
282,
27923,
2243,
272,
650,
9,
2670,
27923,
2243,
2556,
4799,
8372,
272,
841,
9,
2670,
27923,
2556,
701,
14043,
13980,
1414,
272,
959,
9,
2670,
27923,
3012,
945,
334,
4144,
9,
272,
1227,
9,
2670,
27923,
295,
14469,
461,
945,
334,
4144,
9,
272,
1520,
9,
2670,
27923,
1748,
63,
2308,
63,
890,
15,
2992,
63,
2308,
63,
890,
945,
334,
4144,
9,
339,
520,
635,
511,
26,
1413,
2769,
53,
511,
909,
272,
520,
635,
1862,
26,
11932,
543,
314,
511,
2633,
272,
520,
635,
2589,
26,
11932,
543,
511,
3734,
14,
272,
408,
272,
768,
705,
14,
1100,
63,
14600,
272,
347,
485,
4712,
63,
875,
8,
3821,
63,
495,
12,
1059,
12,
4282,
63,
1099,
12,
2754,
63,
2992,
29,
16,
304,
267,
408,
267,
7635,
28655,
4887,
2243,
315,
8372,
398,
520,
635,
5163,
63,
495,
26,
12939,
367,
7907,
1414,
1072,
267,
520,
635,
1059,
26,
710,
1059,
1314,
911,
506,
7923,
267,
520,
635,
4282,
63,
1099,
26,
710,
1420,
1059,
267,
520,
635,
2754,
63,
2992,
26,
8730,
945,
367,
295,
859,
14,
267,
408,
267,
347,
485,
5785,
63,
495,
8,
2442,
12,
1437,
12,
3686,
63,
2546,
304,
288,
347,
620,
63,
1532,
63,
17,
8,
88,
304,
355,
372,
671,
953,
347,
620,
63,
1532,
63,
18,
8,
88,
304,
355,
372,
671,
14,
2325,
342,
953,
620,
63,
1532,
275,
620,
63,
1532,
63,
17,
288,
340,
3686,
63,
2546,
26,
355,
620,
63,
1532,
275,
620,
63,
1532,
63,
18,
953,
340,
620,
63,
1532,
8,
2442,
9,
1137,
620,
63,
1532,
8,
1474,
304,
355,
372,
1689,
6964,
26,
1543,
83,
297,
18982,
1061,
26,
1543,
83,
4065,
450,
717,
334,
495,
63,
1532,
8,
1474,
395,
620,
63,
1532,
8,
2442,
1724,
288,
372,
3087,
398,
3686,
63,
2546,
275,
756,
267,
340,
2754,
63,
2992,
1253,
295,
14,
41,
508,
295,
14,
41,
26,
288,
3686,
63,
2546,
275,
715,
398,
1125,
14,
1100,
480,
6591,
316,
7838,
1007,
13,
875,
543,
5163,
3851,
1543,
83,
4065,
450,
1993,
5163,
63,
495,
12,
2050,
14,
815,
9,
267,
333,
275,
295,
14,
6452,
8,
3821,
63,
495,
12,
1059,
12,
2754,
63,
2992,
9,
267,
340,
440,
333,
26,
288,
2050,
14,
1757,
8,
875,
9,
288,
746,
1125,
14,
774,
547,
480,
6531,
440,
2342,
7838,
1007,
13,
875,
531,
398,
1125,
14,
1100,
480,
7496,
7838,
1059,
365,
2011,
465,
1420,
531,
267,
3503,
63,
1099,
275,
333,
59,
16,
61,
267,
340,
298,
264,
14469,
461,
2,
315,
5163,
63,
495,
26,
288,
340,
3503,
63,
1099,
315,
2097,
265,
401,
298,
5066,
401,
298,
2052,
6229,
355,
3503,
63,
1099,
275,
298,
265,
2,
288,
340,
3503,
63,
1099,
315,
2097,
1997,
401,
298,
889,
401,
298,
3910,
6229,
355,
3503,
63,
1099,
275,
298,
1997,
2,
398,
2449,
63,
793,
275,
942,
267,
340,
1228,
8,
6514,
63,
1099,
12,
2008,
304,
288,
367,
284,
12,
373,
315,
3874,
8,
4921,
63,
1099,
304,
355,
2203,
275,
485,
5785,
63,
495,
8,
6514,
63,
1099,
59,
73,
467,
373,
12,
3686,
63,
2546,
9,
355,
340,
2203,
26,
490,
2449,
63,
793,
14,
740,
8,
3292,
9,
267,
587,
26,
288,
2203,
275,
485,
5785,
63,
495,
8,
6514,
63,
1099,
12,
4282,
63,
1099,
59,
16,
467,
3686,
63,
2546,
9,
288,
340,
2203,
26,
355,
2449,
63,
793,
14,
740,
8,
3292,
9,
398,
340,
2449,
63,
793,
26,
288,
2050,
14,
1757,
8,
875,
9,
288,
746,
1125,
14,
774,
4874,
480,
6531,
440,
2342,
1420,
1059,
3427,
78,
450,
83,
2,
450,
639,
25381,
78,
1674,
904,
8,
1633,
63,
793,
1724,
339,
347,
485,
1117,
63,
2308,
63,
396,
63,
10409,
8,
1730,
304,
267,
3778,
63,
396,
14,
1065,
63,
4549,
63,
954,
63,
396,
8,
396,
12,
1862,
12,
2589,
12,
298,
908,
63,
4032,
531,
339,
768,
705,
14,
1100,
63,
14600,
272,
347,
485,
10506,
63,
2611,
8,
1419,
304,
267,
340,
4169,
14,
374,
63,
9631,
837,
288,
4169,
14,
7237,
342,
398,
367,
945,
12,
574,
315,
1511,
14,
4611,
837,
288,
1862,
59,
1422,
61,
275,
574,
267,
1125,
14,
1100,
480,
497,
15769,
7525,
531,
267,
4169,
14,
981,
8,
1162,
29,
1162,
9,
267,
4169,
14,
4712,
63,
9631,
342,
339,
347,
485,
2886,
837,
267,
372,
4169,
14,
2573,
63,
509,
63,
2886,
8,
2593,
29,
2886,
63,
2593,
9,
339,
347,
485,
362,
63,
17411,
63,
4032,
63,
354,
63,
262,
63,
10409,
8,
1730,
304,
267,
347,
485,
362,
63,
1199,
837,
288,
2088,
275,
298,
478,
446,
76,
1182,
2374,
15,
4032,
15,
991,
13,
515,
6331,
1204,
20595,
27923,
2,
288,
862,
26,
355,
372,
2351,
14,
1760,
8,
1760,
680,
1913,
342,
288,
871,
282,
4921,
14,
8529,
7874,
547,
26,
355,
372,
3087,
398,
1072,
275,
3778,
63,
9923,
14,
2573,
63,
509,
1547,
362,
63,
1199,
12,
4676,
63,
2593,
12,
3650,
29,
21,
12,
3660,
1318,
628,
7536,
367,
10232,
28655,
4543,
536,
531,
267,
4866,
354,
275,
295,
14,
6452,
480,
3893,
60,
87,
401,
1072,
9,
267,
340,
4866,
354,
26,
288,
372,
4866,
354,
59,
16,
61,
267,
372,
298,
19387,
2,
339,
768,
705,
14,
1100,
63,
14600,
272,
347,
485,
1074,
63,
2171,
63,
1422,
8,
2171,
12,
5163,
63,
495,
12,
4282,
63,
495,
304,
267,
1125,
14,
1100,
480,
1084,
3012,
945,
370,
1543,
83,
4065,
450,
3012,
12,
2050,
14,
815,
9,
267,
485,
10506,
63,
2611,
6333,
14023,
63,
2911,
63,
1162
] |
[
2050,
199,
646,
295,
199,
646,
5377,
199,
199,
646,
282,
4921,
199,
199,
504,
2599,
396,
14,
1258,
14,
5555,
492,
1125,
199,
199,
504,
12043,
396,
492,
3778,
63,
396,
12,
3778,
63,
9923,
421,
199,
32,
705,
14,
1100,
63,
14600,
199,
318,
1255,
8,
396,
12,
1862,
12,
2589,
304,
272,
408,
272,
1379,
27923,
4887,
7256,
315,
314,
13980,
14,
339,
413,
9,
2790,
282,
1834,
570,
701,
1894,
14756,
13,
4060,
272,
499,
9,
27324,
1536,
282,
13980,
1050,
642,
1834,
465,
282,
27923,
2243,
272,
650,
9,
2670,
27923,
2243,
2556,
4799,
8372,
272,
841,
9,
2670,
27923,
2556,
701,
14043,
13980,
1414,
272,
959,
9,
2670,
27923,
3012,
945,
334,
4144,
9,
272,
1227,
9,
2670,
27923,
295,
14469,
461,
945,
334,
4144,
9,
272,
1520,
9,
2670,
27923,
1748,
63,
2308,
63,
890,
15,
2992,
63,
2308,
63,
890,
945,
334,
4144,
9,
339,
520,
635,
511,
26,
1413,
2769,
53,
511,
909,
272,
520,
635,
1862,
26,
11932,
543,
314,
511,
2633,
272,
520,
635,
2589,
26,
11932,
543,
511,
3734,
14,
272,
408,
272,
768,
705,
14,
1100,
63,
14600,
272,
347,
485,
4712,
63,
875,
8,
3821,
63,
495,
12,
1059,
12,
4282,
63,
1099,
12,
2754,
63,
2992,
29,
16,
304,
267,
408,
267,
7635,
28655,
4887,
2243,
315,
8372,
398,
520,
635,
5163,
63,
495,
26,
12939,
367,
7907,
1414,
1072,
267,
520,
635,
1059,
26,
710,
1059,
1314,
911,
506,
7923,
267,
520,
635,
4282,
63,
1099,
26,
710,
1420,
1059,
267,
520,
635,
2754,
63,
2992,
26,
8730,
945,
367,
295,
859,
14,
267,
408,
267,
347,
485,
5785,
63,
495,
8,
2442,
12,
1437,
12,
3686,
63,
2546,
304,
288,
347,
620,
63,
1532,
63,
17,
8,
88,
304,
355,
372,
671,
953,
347,
620,
63,
1532,
63,
18,
8,
88,
304,
355,
372,
671,
14,
2325,
342,
953,
620,
63,
1532,
275,
620,
63,
1532,
63,
17,
288,
340,
3686,
63,
2546,
26,
355,
620,
63,
1532,
275,
620,
63,
1532,
63,
18,
953,
340,
620,
63,
1532,
8,
2442,
9,
1137,
620,
63,
1532,
8,
1474,
304,
355,
372,
1689,
6964,
26,
1543,
83,
297,
18982,
1061,
26,
1543,
83,
4065,
450,
717,
334,
495,
63,
1532,
8,
1474,
395,
620,
63,
1532,
8,
2442,
1724,
288,
372,
3087,
398,
3686,
63,
2546,
275,
756,
267,
340,
2754,
63,
2992,
1253,
295,
14,
41,
508,
295,
14,
41,
26,
288,
3686,
63,
2546,
275,
715,
398,
1125,
14,
1100,
480,
6591,
316,
7838,
1007,
13,
875,
543,
5163,
3851,
1543,
83,
4065,
450,
1993,
5163,
63,
495,
12,
2050,
14,
815,
9,
267,
333,
275,
295,
14,
6452,
8,
3821,
63,
495,
12,
1059,
12,
2754,
63,
2992,
9,
267,
340,
440,
333,
26,
288,
2050,
14,
1757,
8,
875,
9,
288,
746,
1125,
14,
774,
547,
480,
6531,
440,
2342,
7838,
1007,
13,
875,
531,
398,
1125,
14,
1100,
480,
7496,
7838,
1059,
365,
2011,
465,
1420,
531,
267,
3503,
63,
1099,
275,
333,
59,
16,
61,
267,
340,
298,
264,
14469,
461,
2,
315,
5163,
63,
495,
26,
288,
340,
3503,
63,
1099,
315,
2097,
265,
401,
298,
5066,
401,
298,
2052,
6229,
355,
3503,
63,
1099,
275,
298,
265,
2,
288,
340,
3503,
63,
1099,
315,
2097,
1997,
401,
298,
889,
401,
298,
3910,
6229,
355,
3503,
63,
1099,
275,
298,
1997,
2,
398,
2449,
63,
793,
275,
942,
267,
340,
1228,
8,
6514,
63,
1099,
12,
2008,
304,
288,
367,
284,
12,
373,
315,
3874,
8,
4921,
63,
1099,
304,
355,
2203,
275,
485,
5785,
63,
495,
8,
6514,
63,
1099,
59,
73,
467,
373,
12,
3686,
63,
2546,
9,
355,
340,
2203,
26,
490,
2449,
63,
793,
14,
740,
8,
3292,
9,
267,
587,
26,
288,
2203,
275,
485,
5785,
63,
495,
8,
6514,
63,
1099,
12,
4282,
63,
1099,
59,
16,
467,
3686,
63,
2546,
9,
288,
340,
2203,
26,
355,
2449,
63,
793,
14,
740,
8,
3292,
9,
398,
340,
2449,
63,
793,
26,
288,
2050,
14,
1757,
8,
875,
9,
288,
746,
1125,
14,
774,
4874,
480,
6531,
440,
2342,
1420,
1059,
3427,
78,
450,
83,
2,
450,
639,
25381,
78,
1674,
904,
8,
1633,
63,
793,
1724,
339,
347,
485,
1117,
63,
2308,
63,
396,
63,
10409,
8,
1730,
304,
267,
3778,
63,
396,
14,
1065,
63,
4549,
63,
954,
63,
396,
8,
396,
12,
1862,
12,
2589,
12,
298,
908,
63,
4032,
531,
339,
768,
705,
14,
1100,
63,
14600,
272,
347,
485,
10506,
63,
2611,
8,
1419,
304,
267,
340,
4169,
14,
374,
63,
9631,
837,
288,
4169,
14,
7237,
342,
398,
367,
945,
12,
574,
315,
1511,
14,
4611,
837,
288,
1862,
59,
1422,
61,
275,
574,
267,
1125,
14,
1100,
480,
497,
15769,
7525,
531,
267,
4169,
14,
981,
8,
1162,
29,
1162,
9,
267,
4169,
14,
4712,
63,
9631,
342,
339,
347,
485,
2886,
837,
267,
372,
4169,
14,
2573,
63,
509,
63,
2886,
8,
2593,
29,
2886,
63,
2593,
9,
339,
347,
485,
362,
63,
17411,
63,
4032,
63,
354,
63,
262,
63,
10409,
8,
1730,
304,
267,
347,
485,
362,
63,
1199,
837,
288,
2088,
275,
298,
478,
446,
76,
1182,
2374,
15,
4032,
15,
991,
13,
515,
6331,
1204,
20595,
27923,
2,
288,
862,
26,
355,
372,
2351,
14,
1760,
8,
1760,
680,
1913,
342,
288,
871,
282,
4921,
14,
8529,
7874,
547,
26,
355,
372,
3087,
398,
1072,
275,
3778,
63,
9923,
14,
2573,
63,
509,
1547,
362,
63,
1199,
12,
4676,
63,
2593,
12,
3650,
29,
21,
12,
3660,
1318,
628,
7536,
367,
10232,
28655,
4543,
536,
531,
267,
4866,
354,
275,
295,
14,
6452,
480,
3893,
60,
87,
401,
1072,
9,
267,
340,
4866,
354,
26,
288,
372,
4866,
354,
59,
16,
61,
267,
372,
298,
19387,
2,
339,
768,
705,
14,
1100,
63,
14600,
272,
347,
485,
1074,
63,
2171,
63,
1422,
8,
2171,
12,
5163,
63,
495,
12,
4282,
63,
495,
304,
267,
1125,
14,
1100,
480,
1084,
3012,
945,
370,
1543,
83,
4065,
450,
3012,
12,
2050,
14,
815,
9,
267,
485,
10506,
63,
2611,
6333,
14023,
63,
2911,
63,
1162,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jonnatas/codeschool
|
old/cs_activities/migrations/old/0011_auto_20160531_2054.py
|
2
|
2774
|
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-31 23:54
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('cs_activities', '0010_auto_20160531_1953'),
]
operations = [
migrations.AlterModelOptions(
name='filedownloadactivity',
options={'verbose_name': 'file download list', 'verbose_name_plural': 'file download activities'},
),
migrations.AlterModelOptions(
name='response',
options={'verbose_name': 'response', 'verbose_name_plural': 'responses'},
),
migrations.AlterModelOptions(
name='urlactivity',
options={'verbose_name': 'URL list', 'verbose_name_plural': 'url list activities'},
),
migrations.RemoveField(
model_name='activity',
name='allow_multiple_responses',
),
migrations.AddField(
model_name='activity',
name='owner_content_type',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='activities_as_owner', to='contenttypes.ContentType', verbose_name='owner model type'),
),
migrations.AddField(
model_name='activity',
name='owner_id',
field=models.PositiveIntegerField(blank=True, null=True, verbose_name="onwer model's id"),
),
migrations.AddField(
model_name='activity',
name='target_content_type',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='activities_as_target', to='contenttypes.ContentType', verbose_name='target model type'),
),
migrations.AddField(
model_name='activity',
name='target_id',
field=models.PositiveIntegerField(blank=True, null=True, verbose_name="target model's id"),
),
migrations.AddField(
model_name='urlitem',
name='alt',
field=models.CharField(blank=True, max_length=50),
),
migrations.AddField(
model_name='urlitem',
name='name',
field=models.CharField(blank=True, max_length=50),
),
migrations.AlterField(
model_name='activity',
name='icon_src',
field=models.CharField(blank=True, help_text='Optional icon name that can be used to personalize the activity. Material icons are available by using the "material:" namespace as in "material:menu".', max_length=50),
),
]
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
17065,
701,
5634,
413,
14,
25,
14,
22,
641,
7800,
13,
1717,
13,
2192,
6546,
26,
1477,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
697,
492,
6180,
12,
1709,
199,
646,
1639,
14,
697,
14,
992,
14,
14281,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
10778,
297,
283,
9425,
63,
2168,
63,
1317,
63,
466,
63,
354,
659,
267,
661,
1259,
63,
27442,
297,
283,
17657,
63,
2495,
63,
9261,
1717,
2192,
63,
1167,
2481,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
14364,
1685,
4558,
8,
288,
536,
534,
493,
4249,
8240,
297,
288,
1511,
3713,
3832,
63,
354,
356,
283,
493,
5235,
769,
297,
283,
3832,
63,
354,
63,
10019,
356,
283,
493,
5235,
30744,
2267,
267,
2318,
267,
6180,
14,
14364,
1685,
4558,
8,
288,
536,
534,
1310,
297,
288,
1511,
3713,
3832,
63,
354,
356,
283,
1310,
297,
283,
3832,
63,
354,
63,
10019,
356,
283,
10360,
2267,
267,
2318,
267,
6180,
14,
14364,
1685,
4558,
8,
288,
536,
534,
300,
416,
67,
4191,
297,
288,
1511,
3713,
3832,
63,
354,
356,
283,
2632,
769,
297,
283,
3832,
63,
354,
63,
10019,
356,
283,
633,
769,
30744,
2267,
267,
2318,
267,
6180,
14,
5587,
792,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
3306,
63,
6048,
63,
10360,
297,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
4597,
63,
1317,
63,
466,
297,
288,
901,
29,
992,
14,
3190,
8,
2500,
29,
549,
12,
2973,
29,
549,
12,
641,
63,
1807,
29,
1176,
14,
697,
14,
992,
14,
14281,
14,
10855,
12,
4048,
63,
354,
534,
27442,
63,
305,
63,
4597,
297,
370,
534,
10778,
14,
11282,
297,
3376,
63,
354,
534,
4597,
1402,
730,
659,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
4597,
63,
344,
297,
288,
901,
29,
992,
14,
8591,
8,
2500,
29,
549,
12,
2973,
29,
549,
12,
3376,
63,
354,
628,
265,
2135,
1402,
1159,
1305,
1288,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
1375,
63,
1317,
63,
466,
297,
288,
901,
29,
992,
14,
3190,
8,
2500,
29,
549,
12,
2973,
29,
549,
12,
641,
63,
1807,
29,
1176,
14,
697,
14,
992,
14,
14281,
14,
10855,
12,
4048,
63,
354,
534,
27442,
63,
305,
63,
1375,
297,
370,
534,
10778,
14,
11282,
297,
3376,
63,
354,
534,
1375,
1402,
730,
659,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
1375,
63,
344,
297,
288,
901,
29,
992,
14,
8591,
8,
2500,
29,
549,
12,
2973,
29,
549,
12,
3376,
63,
354,
628,
1375,
1402,
1159,
1305,
1288,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
300,
317,
563,
297,
288,
536,
534,
4478,
297,
288,
901,
29,
992,
14,
2183,
8,
2500,
29,
549,
12,
1390,
63,
1267,
29,
1400,
395,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
300,
317,
563,
297,
288,
536,
534,
354,
297,
288,
901,
29,
992,
14,
2183,
8,
2500,
29,
549,
12,
1390,
63,
1267,
29,
1400,
395,
267,
2318,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
4677,
63,
2164,
297,
288,
901,
29,
992,
14,
2183,
8,
2500,
29,
549,
12,
1720,
63,
505,
534,
7012,
7016,
536,
626,
883,
506,
1202,
370,
25994,
794,
314,
10679,
14,
26570,
7016,
83,
787,
2808,
701,
1808,
314,
298,
9820,
5424,
3231,
465,
315,
298,
9820,
26,
4470,
1674,
297,
1390,
63,
1267,
29,
1400,
395,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
17065,
701,
5634,
413,
14,
25,
14,
22,
641,
7800,
13,
1717,
13,
2192,
6546,
26,
1477,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
697,
492,
6180,
12,
1709,
199,
646,
1639,
14,
697,
14,
992,
14,
14281,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
10778,
297,
283,
9425,
63,
2168,
63,
1317,
63,
466,
63,
354,
659,
267,
661,
1259,
63,
27442,
297,
283,
17657,
63,
2495,
63,
9261,
1717,
2192,
63,
1167,
2481,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
14364,
1685,
4558,
8,
288,
536,
534,
493,
4249,
8240,
297,
288,
1511,
3713,
3832,
63,
354,
356,
283,
493,
5235,
769,
297,
283,
3832,
63,
354,
63,
10019,
356,
283,
493,
5235,
30744,
2267,
267,
2318,
267,
6180,
14,
14364,
1685,
4558,
8,
288,
536,
534,
1310,
297,
288,
1511,
3713,
3832,
63,
354,
356,
283,
1310,
297,
283,
3832,
63,
354,
63,
10019,
356,
283,
10360,
2267,
267,
2318,
267,
6180,
14,
14364,
1685,
4558,
8,
288,
536,
534,
300,
416,
67,
4191,
297,
288,
1511,
3713,
3832,
63,
354,
356,
283,
2632,
769,
297,
283,
3832,
63,
354,
63,
10019,
356,
283,
633,
769,
30744,
2267,
267,
2318,
267,
6180,
14,
5587,
792,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
3306,
63,
6048,
63,
10360,
297,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
4597,
63,
1317,
63,
466,
297,
288,
901,
29,
992,
14,
3190,
8,
2500,
29,
549,
12,
2973,
29,
549,
12,
641,
63,
1807,
29,
1176,
14,
697,
14,
992,
14,
14281,
14,
10855,
12,
4048,
63,
354,
534,
27442,
63,
305,
63,
4597,
297,
370,
534,
10778,
14,
11282,
297,
3376,
63,
354,
534,
4597,
1402,
730,
659,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
4597,
63,
344,
297,
288,
901,
29,
992,
14,
8591,
8,
2500,
29,
549,
12,
2973,
29,
549,
12,
3376,
63,
354,
628,
265,
2135,
1402,
1159,
1305,
1288,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
1375,
63,
1317,
63,
466,
297,
288,
901,
29,
992,
14,
3190,
8,
2500,
29,
549,
12,
2973,
29,
549,
12,
641,
63,
1807,
29,
1176,
14,
697,
14,
992,
14,
14281,
14,
10855,
12,
4048,
63,
354,
534,
27442,
63,
305,
63,
1375,
297,
370,
534,
10778,
14,
11282,
297,
3376,
63,
354,
534,
1375,
1402,
730,
659,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
1375,
63,
344,
297,
288,
901,
29,
992,
14,
8591,
8,
2500,
29,
549,
12,
2973,
29,
549,
12,
3376,
63,
354,
628,
1375,
1402,
1159,
1305,
1288,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
300,
317,
563,
297,
288,
536,
534,
4478,
297,
288,
901,
29,
992,
14,
2183,
8,
2500,
29,
549,
12,
1390,
63,
1267,
29,
1400,
395,
267,
2318,
267,
6180,
14,
18381,
8,
288,
1402,
63,
354,
534,
300,
317,
563,
297,
288,
536,
534,
354,
297,
288,
901,
29,
992,
14,
2183,
8,
2500,
29,
549,
12,
1390,
63,
1267,
29,
1400,
395,
267,
2318,
267,
6180,
14,
19275,
8,
288,
1402,
63,
354,
534,
8240,
297,
288,
536,
534,
4677,
63,
2164,
297,
288,
901,
29,
992,
14,
2183,
8,
2500,
29,
549,
12,
1720,
63,
505,
534,
7012,
7016,
536,
626,
883,
506,
1202,
370,
25994,
794,
314,
10679,
14,
26570,
7016,
83,
787,
2808,
701,
1808,
314,
298,
9820,
5424,
3231,
465,
315,
298,
9820,
26,
4470,
1674,
297,
1390,
63,
1267,
29,
1400,
395,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
rememerme/games-api
|
rememerme/games/rest/rounds/forms.py
|
2
|
8654
|
'''
This file holds all of the forms for the cleaning and validation of
the parameters being used for friend requests received.
Created on Dec 20, 2013
@author: Andrew Oberlin, Jake Gregg
'''
from django import forms
from rememerme.games.models import Game, Round, GameMember, Nomination
from rememerme.cards.models import PhraseCard, NominationCard
from rememerme.games.rest.exceptions import NoCurrentRound, RoundNotFound, \
GameNotFound, GameAlreadyStarted, AlreadyNominated, InvalidNominationCard, NotTheSelector
from rememerme.games.serializers import RoundSerializer, NominationSerializer
from uuid import UUID
from pycassa.cassandra.ttypes import NotFoundException as CassaNotFoundException
import datetime
import random
from rememerme.games.permissions import GamePermissions
from rest_framework.exceptions import PermissionDenied
'''
Gets all friend requests recieved and returns them to the user.
@return: A list of requests matching the query with the given offset/limit
'''
class StartGameForm(forms.Form):
game_id = forms.CharField(required=True)
deck_id = forms.CharField(required=True)
def clean(self):
try:
self.cleaned_data['game_id'] = str(UUID(self.cleaned_data['game_id']))
self.cleaned_data['deck_id'] = str(UUID(self.cleaned_data['deck_id']))
except ValueError:
raise GameNotFound()
return self.cleaned_data
'''
Submits the form and returns the friend requests received for the user.
'''
def submit(self, request):
try:
game = Game.getByID(self.cleaned_data['game_id'])
if game.current_round_id:
raise GameAlreadyStarted()
except CassaNotFoundException:
raise GameNotFound()
if not GamePermissions.has_object_permission(request, game):
raise PermissionDenied()
# select randomly from the game members
game_members = GameMember.filterByGame(game.game_id)
selector = random.choice(game_members)
now = datetime.datetime.now()
round = Round(selector_id=selector.user_id, phrase_card_id=PhraseCard.getRandom(self.cleaned_data['deck_id']).phrase_card_id,
game_id=game.game_id, date_created=now, last_modified=now)
round.save()
game.deck = self.cleaned_data['deck_id']
game.current_round_id = round.round_id
game.save()
return RoundSerializer(round).data
'''
Accepts a friend request for a user.
@return: Validation of accepting the request.
'''
class RoundForm(forms.Form):
game_id = forms.CharField(required=True)
def clean(self):
cleaned_data = super(RoundForm, self).clean()
try:
cleaned_data['game_id'] = str(UUID(cleaned_data['game_id']))
except ValueError:
raise GameNotFound()
return cleaned_data
def submit(self, request):
game_id = self.cleaned_data['game_id']
try:
game = Game.getByID(game_id)
except CassaNotFoundException:
raise GameNotFound()
if not GamePermissions.has_object_permission(request, game):
raise PermissionDenied()
try:
if not game.current_round_id:
raise NoCurrentRound()
round = Round.getByID(game.current_round_id)
except CassaNotFoundException:
raise NoCurrentRound()
return RoundSerializer(round).data
'''
Denies a friend request for the user.
@return: confirmation that the request was denied.
'''
class NominationsGetForm(forms.Form):
game_id = forms.CharField(required=True)
def clean(self):
try:
self.cleaned_data['game_id'] = str(UUID(self.cleaned_data['game_id']))
return self.cleaned_data
except ValueError:
raise GameNotFound()
'''
Submits the form to deny the friend request.
'''
def submit(self, request):
game = Game.getByID(self.cleaned_data['game_id'])
if not game.current_round_id:
raise NoCurrentRound()
if not GamePermissions.has_object_permission(request, game):
raise PermissionDenied()
nominations = Nomination.filterByRound(game.current_round_id)
return NominationSerializer(nominations, many=True).data
'''
Denies a friend request for the user.
@return: confirmation that the request was denied.
'''
class NominationsPostForm(forms.Form):
game_id = forms.CharField(required=True)
nomination_card_id = forms.CharField(required=True)
def clean(self):
try:
self.cleaned_data['game_id'] = str(UUID(self.cleaned_data['game_id']))
self.cleaned_data['nomination_card_id'] = str(UUID(self.cleaned_data['nomination_card_id']))
return self.cleaned_data
except ValueError:
raise GameNotFound()
'''
Submits the form to deny the friend request.
'''
def submit(self, request):
game = Game.getByID(self.cleaned_data['game_id'])
if not game.current_round_id:
raise NoCurrentRound()
if not GamePermissions.has_object_permission(request, game):
raise PermissionDenied()
nominations = Nomination.filterByRound(game.current_round_id)
users = set([str(n.nominator_id) for n in nominations])
if request.user.pk in users:
raise AlreadyNominated()
now = datetime.datetime.now()
try:
NominationCard.getByID(self.cleaned_data['nomination_card_id'])
except CassaNotFoundException:
raise InvalidNominationCard()
nomination = Nomination(round_id=game.current_round_id, nominator_id=request.user.pk,
nomination_card_id=self.cleaned_data['nomination_card_id'], date_created=now, last_modified=now)
nomination.save()
return NominationSerializer(nomination).data
'''
Denies a friend request for the user.
@return: confirmation that the request was denied.
'''
class SelectionForm(forms.Form):
game_id = forms.CharField(required=True)
selection_id = forms.CharField(required=True)
def clean(self):
try:
self.cleaned_data['game_id'] = str(UUID(self.cleaned_data['game_id']))
self.cleaned_data['selection_id'] = str(UUID(self.cleaned_data['selection_id']))
return self.cleaned_data
except ValueError:
raise GameNotFound()
'''
Submits the form to deny the friend request.
'''
def submit(self, request):
try:
game = Game.getByID(self.cleaned_data['game_id'])
except CassaNotFoundException:
raise GameNotFound()
if not GamePermissions.has_object_permission(request, game):
raise PermissionDenied()
if not game.current_round_id:
raise NoCurrentRound()
try:
round = Round.getByID(game.current_round_id)
except CassaNotFoundException:
raise RoundNotFound()
if request.user.pk != str(round.selector_id):
raise NotTheSelector()
try:
nomination = Nomination.getByID(self.cleaned_data['selection_id'])
except CassaNotFoundException:
raise InvalidNominationCard()
round.selection_id = self.cleaned_data['selection_id']
round.save()
game_members = GameMember.filterByGame(game.game_id)
# finds the game state that should be updated
member = None
for m in game_members:
if str(m.user_id) == str(nomination.nominator_id):
member = m
break
member.score += 10
member.save()
# creates a new round, saves it and the game
now = datetime.datetime.now()
selector = random.choice(game_members)
new_round = Round(selector_id=selector.user_id, phrase_card_id=PhraseCard.getRandom(game.deck).phrase_card_id,
game_id=game.game_id, date_created=now, last_modified=now)
new_round.save()
game.current_round_id = new_round.round_id
game.save()
return RoundSerializer(new_round).data
|
apache-2.0
|
[
2344,
272,
961,
570,
15164,
1006,
402,
314,
4513,
367,
314,
29579,
436,
6411,
402,
272,
314,
2633,
3769,
1202,
367,
32506,
4145,
3086,
14,
2286,
18208,
641,
13966,
3388,
12,
6171,
339,
768,
2502,
26,
6061,
5257,
593,
605,
472,
12,
1603,
1728,
29096,
71,
199,
2344,
199,
504,
1639,
492,
4513,
199,
504,
295,
278,
2626,
278,
14,
28129,
14,
992,
492,
25132,
12,
31312,
12,
25132,
7021,
12,
653,
676,
3155,
199,
504,
295,
278,
2626,
278,
14,
13761,
14,
992,
492,
11308,
8062,
13832,
12,
653,
676,
3155,
13832,
199,
504,
295,
278,
2626,
278,
14,
28129,
14,
3911,
14,
3924,
492,
3091,
5639,
18579,
12,
31312,
4667,
12,
971,
272,
25132,
4667,
12,
25132,
16760,
21031,
12,
21086,
46,
676,
23831,
12,
6378,
46,
676,
3155,
13832,
12,
2832,
1918,
11212,
199,
504,
295,
278,
2626,
278,
14,
28129,
14,
12844,
492,
31312,
7299,
12,
653,
676,
3155,
7299,
199,
504,
5377,
492,
11134,
199,
504,
28968,
405,
65,
14,
67,
22388,
14,
21776,
492,
21909,
1726,
465,
445,
405,
65,
22646,
199,
646,
2197,
199,
646,
2196,
199,
504,
295,
278,
2626,
278,
14,
28129,
14,
6060,
492,
25132,
17004,
199,
504,
4618,
63,
4857,
14,
3924,
492,
23724,
199,
199,
2344,
272,
14509,
1006,
32506,
4145,
295,
559,
27986,
436,
2529,
3062,
370,
314,
922,
14,
339,
768,
1107,
26,
437,
769,
402,
4145,
4877,
314,
1827,
543,
314,
1627,
3268,
15,
3097,
199,
2344,
260,
199,
533,
7707,
11454,
2821,
8,
3351,
14,
2821,
304,
272,
9219,
63,
344,
275,
4513,
14,
2183,
8,
2427,
29,
549,
9,
272,
477,
346,
63,
344,
275,
4513,
14,
2183,
8,
2427,
29,
549,
9,
2286,
347,
3633,
8,
277,
304,
267,
862,
26,
288,
291,
14,
8275,
63,
576,
459,
5097,
63,
344,
418,
275,
620,
8,
8757,
8,
277,
14,
8275,
63,
576,
459,
5097,
63,
344,
5156,
288,
291,
14,
8275,
63,
576,
459,
31919,
63,
344,
418,
275,
620,
8,
8757,
8,
277,
14,
8275,
63,
576,
459,
31919,
63,
344,
5156,
267,
871,
1722,
26,
288,
746,
25132,
4667,
342,
267,
372,
291,
14,
8275,
63,
576,
17635,
1449,
267,
28295,
83,
314,
1824,
436,
2529,
314,
32506,
4145,
3086,
367,
314,
922,
14,
272,
1449,
272,
347,
11482,
8,
277,
12,
1056,
304,
267,
862,
26,
288,
9219,
275,
25132,
14,
362,
2175,
998,
8,
277,
14,
8275,
63,
576,
459,
5097,
63,
344,
1105,
288,
340,
9219,
14,
1818,
63,
2363,
63,
344,
26,
355,
746,
25132,
16760,
21031,
342,
267,
871,
445,
405,
65,
22646,
26,
288,
746,
25132,
4667,
342,
2728,
340,
440,
25132,
17004,
14,
1989,
63,
785,
63,
5693,
8,
1069,
12,
9219,
304,
288,
746,
23724,
342,
2728,
327,
3504,
19311,
687,
314,
9219,
7556,
267,
9219,
63,
6334,
275,
25132,
7021,
14,
1541,
2175,
11454,
8,
5097,
14,
5097,
63,
344,
9,
267,
9759,
275,
2196,
14,
5095,
8,
5097,
63,
6334,
9,
2728,
3063,
275,
2197,
14,
2083,
14,
2131,
342,
2728,
6168,
275,
31312,
8,
6662,
63,
344,
29,
6662,
14,
751,
63,
344,
12,
21621,
63,
5841,
63,
344,
29,
5663,
8062,
13832,
14,
362,
3883,
8,
277,
14,
8275,
63,
576,
459,
31919,
63,
344,
13227,
10906,
63,
5841,
63,
344,
12,
288,
9219,
63,
344,
29,
5097,
14,
5097,
63,
344,
12,
1434,
63,
3966,
29,
2131,
12,
2061,
63,
5540,
29,
2131,
9,
2728,
6168,
14,
2117,
342,
2728,
9219,
14,
31919,
275,
291,
14,
8275,
63,
576,
459,
31919,
63,
344,
418,
267,
9219,
14,
1818,
63,
2363,
63,
344,
275,
6168,
14,
2363,
63,
344,
267,
9219,
14,
2117,
342,
398,
372,
31312,
7299,
8,
2363,
680,
576,
1362,
199,
2344,
272,
15506,
83,
282,
32506,
1056,
367,
282,
922,
14,
339,
768,
1107,
26,
19381,
402,
32163,
314,
1056,
14,
199,
2344,
199,
533,
31312,
2821,
8,
3351,
14,
2821,
304,
272,
9219,
63,
344,
275,
4513,
14,
2183,
8,
2427,
29,
549,
9,
2286,
347,
3633,
8,
277,
304,
267,
12364,
63,
576,
275,
1613,
8,
18579,
2821,
12,
291,
680,
3118,
342,
267,
862,
26,
288,
12364,
63,
576,
459,
5097,
63,
344,
418,
275,
620,
8,
8757,
8,
8275,
63,
576,
459,
5097,
63,
344,
5156,
267,
871,
1722,
26,
288,
746,
25132,
4667,
342,
267,
372,
12364,
63,
576,
2286,
347,
11482,
8,
277,
12,
1056,
304,
267,
9219,
63,
344,
275,
291,
14,
8275,
63,
576,
459,
5097,
63,
344,
418,
2728,
862,
26,
288,
9219,
275,
25132,
14,
362,
2175,
998,
8,
5097,
63,
344,
9,
267,
871,
445,
405,
65,
22646,
26,
288,
746,
25132,
4667,
342,
2728,
340,
440,
25132,
17004,
14,
1989,
63,
785,
63,
5693,
8,
1069,
12,
9219,
304,
288,
746,
23724,
342,
2728,
862,
26,
288,
340,
440,
9219,
14,
1818,
63,
2363,
63,
344,
26,
355,
746,
3091,
5639,
18579,
342,
288,
6168,
275,
31312,
14,
362,
2175,
998,
8,
5097,
14,
1818,
63,
2363,
63,
344,
9,
267,
871,
445,
405,
65,
22646,
26,
288,
746,
3091,
5639,
18579,
342,
2728,
372,
31312,
7299,
8,
2363,
680,
576,
27844,
199,
2344,
272,
25187,
1500,
282,
32506,
1056,
367,
314,
922,
14,
339,
768,
1107,
26,
18791,
626,
314,
1056,
1990,
23355,
14,
199,
2344,
199,
533,
653,
676,
9511,
1002,
2821,
8,
3351,
14,
2821,
304,
272,
9219,
63,
344,
275,
4513,
14,
2183,
8,
2427,
29,
549,
9,
2286,
347,
3633,
8,
277,
304,
267,
862,
26,
288,
291,
14,
8275,
63,
576,
459,
5097,
63,
344,
418,
275,
620,
8,
8757,
8,
277,
14,
8275,
63,
576,
459,
5097,
63,
344,
5156,
288,
372,
291,
14,
8275,
63,
576,
267,
871,
1722,
26,
288,
746,
25132,
4667,
342,
2286,
1449,
267,
28295,
83,
314,
1824,
370,
5376,
89,
314,
32506,
1056,
14,
272,
1449,
272,
347,
11482,
8,
277,
12,
1056,
304,
267,
9219,
275,
25132,
14,
362,
2175,
998,
8,
277,
14,
8275,
63,
576,
459,
5097,
63,
344,
1105,
267,
340,
440,
9219,
14,
1818,
63,
2363,
63,
344,
26,
288,
746,
3091,
5639,
18579,
342,
2728,
340,
440,
25132,
17004,
14,
1989,
63,
785,
63,
5693,
8,
1069
] |
[
272,
961,
570,
15164,
1006,
402,
314,
4513,
367,
314,
29579,
436,
6411,
402,
272,
314,
2633,
3769,
1202,
367,
32506,
4145,
3086,
14,
2286,
18208,
641,
13966,
3388,
12,
6171,
339,
768,
2502,
26,
6061,
5257,
593,
605,
472,
12,
1603,
1728,
29096,
71,
199,
2344,
199,
504,
1639,
492,
4513,
199,
504,
295,
278,
2626,
278,
14,
28129,
14,
992,
492,
25132,
12,
31312,
12,
25132,
7021,
12,
653,
676,
3155,
199,
504,
295,
278,
2626,
278,
14,
13761,
14,
992,
492,
11308,
8062,
13832,
12,
653,
676,
3155,
13832,
199,
504,
295,
278,
2626,
278,
14,
28129,
14,
3911,
14,
3924,
492,
3091,
5639,
18579,
12,
31312,
4667,
12,
971,
272,
25132,
4667,
12,
25132,
16760,
21031,
12,
21086,
46,
676,
23831,
12,
6378,
46,
676,
3155,
13832,
12,
2832,
1918,
11212,
199,
504,
295,
278,
2626,
278,
14,
28129,
14,
12844,
492,
31312,
7299,
12,
653,
676,
3155,
7299,
199,
504,
5377,
492,
11134,
199,
504,
28968,
405,
65,
14,
67,
22388,
14,
21776,
492,
21909,
1726,
465,
445,
405,
65,
22646,
199,
646,
2197,
199,
646,
2196,
199,
504,
295,
278,
2626,
278,
14,
28129,
14,
6060,
492,
25132,
17004,
199,
504,
4618,
63,
4857,
14,
3924,
492,
23724,
199,
199,
2344,
272,
14509,
1006,
32506,
4145,
295,
559,
27986,
436,
2529,
3062,
370,
314,
922,
14,
339,
768,
1107,
26,
437,
769,
402,
4145,
4877,
314,
1827,
543,
314,
1627,
3268,
15,
3097,
199,
2344,
260,
199,
533,
7707,
11454,
2821,
8,
3351,
14,
2821,
304,
272,
9219,
63,
344,
275,
4513,
14,
2183,
8,
2427,
29,
549,
9,
272,
477,
346,
63,
344,
275,
4513,
14,
2183,
8,
2427,
29,
549,
9,
2286,
347,
3633,
8,
277,
304,
267,
862,
26,
288,
291,
14,
8275,
63,
576,
459,
5097,
63,
344,
418,
275,
620,
8,
8757,
8,
277,
14,
8275,
63,
576,
459,
5097,
63,
344,
5156,
288,
291,
14,
8275,
63,
576,
459,
31919,
63,
344,
418,
275,
620,
8,
8757,
8,
277,
14,
8275,
63,
576,
459,
31919,
63,
344,
5156,
267,
871,
1722,
26,
288,
746,
25132,
4667,
342,
267,
372,
291,
14,
8275,
63,
576,
17635,
1449,
267,
28295,
83,
314,
1824,
436,
2529,
314,
32506,
4145,
3086,
367,
314,
922,
14,
272,
1449,
272,
347,
11482,
8,
277,
12,
1056,
304,
267,
862,
26,
288,
9219,
275,
25132,
14,
362,
2175,
998,
8,
277,
14,
8275,
63,
576,
459,
5097,
63,
344,
1105,
288,
340,
9219,
14,
1818,
63,
2363,
63,
344,
26,
355,
746,
25132,
16760,
21031,
342,
267,
871,
445,
405,
65,
22646,
26,
288,
746,
25132,
4667,
342,
2728,
340,
440,
25132,
17004,
14,
1989,
63,
785,
63,
5693,
8,
1069,
12,
9219,
304,
288,
746,
23724,
342,
2728,
327,
3504,
19311,
687,
314,
9219,
7556,
267,
9219,
63,
6334,
275,
25132,
7021,
14,
1541,
2175,
11454,
8,
5097,
14,
5097,
63,
344,
9,
267,
9759,
275,
2196,
14,
5095,
8,
5097,
63,
6334,
9,
2728,
3063,
275,
2197,
14,
2083,
14,
2131,
342,
2728,
6168,
275,
31312,
8,
6662,
63,
344,
29,
6662,
14,
751,
63,
344,
12,
21621,
63,
5841,
63,
344,
29,
5663,
8062,
13832,
14,
362,
3883,
8,
277,
14,
8275,
63,
576,
459,
31919,
63,
344,
13227,
10906,
63,
5841,
63,
344,
12,
288,
9219,
63,
344,
29,
5097,
14,
5097,
63,
344,
12,
1434,
63,
3966,
29,
2131,
12,
2061,
63,
5540,
29,
2131,
9,
2728,
6168,
14,
2117,
342,
2728,
9219,
14,
31919,
275,
291,
14,
8275,
63,
576,
459,
31919,
63,
344,
418,
267,
9219,
14,
1818,
63,
2363,
63,
344,
275,
6168,
14,
2363,
63,
344,
267,
9219,
14,
2117,
342,
398,
372,
31312,
7299,
8,
2363,
680,
576,
1362,
199,
2344,
272,
15506,
83,
282,
32506,
1056,
367,
282,
922,
14,
339,
768,
1107,
26,
19381,
402,
32163,
314,
1056,
14,
199,
2344,
199,
533,
31312,
2821,
8,
3351,
14,
2821,
304,
272,
9219,
63,
344,
275,
4513,
14,
2183,
8,
2427,
29,
549,
9,
2286,
347,
3633,
8,
277,
304,
267,
12364,
63,
576,
275,
1613,
8,
18579,
2821,
12,
291,
680,
3118,
342,
267,
862,
26,
288,
12364,
63,
576,
459,
5097,
63,
344,
418,
275,
620,
8,
8757,
8,
8275,
63,
576,
459,
5097,
63,
344,
5156,
267,
871,
1722,
26,
288,
746,
25132,
4667,
342,
267,
372,
12364,
63,
576,
2286,
347,
11482,
8,
277,
12,
1056,
304,
267,
9219,
63,
344,
275,
291,
14,
8275,
63,
576,
459,
5097,
63,
344,
418,
2728,
862,
26,
288,
9219,
275,
25132,
14,
362,
2175,
998,
8,
5097,
63,
344,
9,
267,
871,
445,
405,
65,
22646,
26,
288,
746,
25132,
4667,
342,
2728,
340,
440,
25132,
17004,
14,
1989,
63,
785,
63,
5693,
8,
1069,
12,
9219,
304,
288,
746,
23724,
342,
2728,
862,
26,
288,
340,
440,
9219,
14,
1818,
63,
2363,
63,
344,
26,
355,
746,
3091,
5639,
18579,
342,
288,
6168,
275,
31312,
14,
362,
2175,
998,
8,
5097,
14,
1818,
63,
2363,
63,
344,
9,
267,
871,
445,
405,
65,
22646,
26,
288,
746,
3091,
5639,
18579,
342,
2728,
372,
31312,
7299,
8,
2363,
680,
576,
27844,
199,
2344,
272,
25187,
1500,
282,
32506,
1056,
367,
314,
922,
14,
339,
768,
1107,
26,
18791,
626,
314,
1056,
1990,
23355,
14,
199,
2344,
199,
533,
653,
676,
9511,
1002,
2821,
8,
3351,
14,
2821,
304,
272,
9219,
63,
344,
275,
4513,
14,
2183,
8,
2427,
29,
549,
9,
2286,
347,
3633,
8,
277,
304,
267,
862,
26,
288,
291,
14,
8275,
63,
576,
459,
5097,
63,
344,
418,
275,
620,
8,
8757,
8,
277,
14,
8275,
63,
576,
459,
5097,
63,
344,
5156,
288,
372,
291,
14,
8275,
63,
576,
267,
871,
1722,
26,
288,
746,
25132,
4667,
342,
2286,
1449,
267,
28295,
83,
314,
1824,
370,
5376,
89,
314,
32506,
1056,
14,
272,
1449,
272,
347,
11482,
8,
277,
12,
1056,
304,
267,
9219,
275,
25132,
14,
362,
2175,
998,
8,
277,
14,
8275,
63,
576,
459,
5097,
63,
344,
1105,
267,
340,
440,
9219,
14,
1818,
63,
2363,
63,
344,
26,
288,
746,
3091,
5639,
18579,
342,
2728,
340,
440,
25132,
17004,
14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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
maxalbert/bokeh
|
scripts/version_update.py
|
42
|
1687
|
import os
import re
import sys
def check_input(new_ver):
""" Ensure that user input matches the format X.X.X """
pat = r'\d+.\d+.\d+'
if not re.match(pat, new_ver):
print("The new version must be in the format X.X.X (ex. '0.6.0')")
return True
def version_update(new_ver, file_array):
""" Replace existing version/release number in an array of files
with a user-supplied version number (new_ver)"""
pat = r"""(release|version)([\" ][:=] [\"\'])(\d+.\d+.\d+)([\"\'])"""
# List that will contain any files where the version number was successfully replaced
replaced = []
# Set as false until a match is found and replaced in the loop below
early_ver = False
for ver_file in file_array:
f = open(ver_file)
text = f.read()
matchObj = re.search(pat, text)
f.close()
if matchObj:
early_ver = matchObj.group(3)
f = open(ver_file, 'w')
text = re.sub(pat, r'\g<1>\g<2>%s\g<4>' % new_ver, text)
f.write(text)
replaced.append(ver_file)
else:
print("Unable to find version number matching expected format 'X.X.X' in %s" % ver_file)
if early_ver:
print("Version number changed from %s to %s in \n%s" % (early_ver, new_ver, replaced))
if __name__ == '__main__':
if not len(sys.argv) == 2:
print("Please provide a version number.")
sys.exit(1)
os.chdir('../')
files = ['bokehjs/src/coffee/main.coffee', 'bokehjs/package.json']
updated_version = sys.argv[1]
if check_input(updated_version):
sys.exit(1)
version_update(updated_version, files)
|
bsd-3-clause
|
[
646,
747,
199,
646,
295,
199,
646,
984,
421,
199,
318,
1104,
63,
1210,
8,
1222,
63,
422,
304,
272,
408,
7523,
626,
922,
1324,
4450,
314,
1475,
1323,
14,
56,
14,
56,
408,
339,
12713,
275,
519,
1154,
68,
11,
3134,
68,
11,
3134,
68,
4786,
272,
340,
440,
295,
14,
1431,
8,
10853,
12,
892,
63,
422,
304,
267,
870,
480,
1918,
892,
1015,
1471,
506,
315,
314,
1475,
1323,
14,
56,
14,
56,
334,
476,
14,
283,
16,
14,
22,
14,
16,
26530,
267,
372,
715,
421,
199,
318,
1015,
63,
873,
8,
1222,
63,
422,
12,
570,
63,
1144,
304,
272,
408,
14402,
3411,
1015,
15,
3221,
1329,
315,
376,
1625,
402,
1584,
267,
543,
282,
922,
13,
22525,
1015,
1329,
334,
1222,
63,
422,
9471,
339,
12713,
275,
519,
624,
8,
3221,
92,
1023,
31440,
4451,
1622,
1491,
29,
61,
359,
13356,
1105,
2961,
68,
11,
3134,
68,
11,
3134,
68,
8771,
779,
13356,
1105,
624,
339,
327,
3820,
626,
911,
1395,
1263,
1584,
2382,
314,
1015,
1329,
1990,
8792,
8717,
272,
8717,
275,
942,
339,
327,
2494,
465,
3055,
5133,
282,
1336,
365,
1911,
436,
8717,
315,
314,
4438,
5084,
272,
14670,
63,
422,
275,
756,
339,
367,
809,
63,
493,
315,
570,
63,
1144,
26,
267,
289,
275,
1551,
8,
422,
63,
493,
9,
267,
1318,
275,
289,
14,
739,
342,
267,
1336,
5665,
275,
295,
14,
1733,
8,
10853,
12,
1318,
9,
267,
289,
14,
1600,
342,
398,
340,
1336,
5665,
26,
288,
14670,
63,
422,
275,
1336,
5665,
14,
923,
8,
19,
9,
288,
289,
275,
1551,
8,
422,
63,
493,
12,
283,
87,
358,
288,
1318,
275,
295,
14,
954,
8,
10853,
12,
519,
1154,
71,
28,
17,
3072,
71,
28,
18,
6598,
83,
60,
71,
28,
20,
3524,
450,
892,
63,
422,
12,
1318,
9,
288,
289,
14,
952,
8,
505,
9,
288,
8717,
14,
740,
8,
422,
63,
493,
9,
267,
587,
26,
288,
870,
480,
6005,
370,
2342,
1015,
1329,
4877,
1420,
1475,
283,
56,
14,
56,
14,
56,
7,
315,
450,
83,
2,
450,
809,
63,
493,
9,
339,
340,
14670,
63,
422,
26,
267,
870,
480,
3353,
1329,
2896,
687,
450,
83,
370,
450,
83,
315,
971,
78,
5,
83,
2,
450,
334,
21423,
63,
422,
12,
892,
63,
422,
12,
8717,
430,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
340,
440,
822,
8,
1274,
14,
3020,
9,
508,
499,
26,
267,
870,
480,
8254,
5647,
282,
1015,
1329,
2685,
267,
984,
14,
2224,
8,
17,
9,
339,
747,
14,
8563,
24592,
358,
339,
1584,
275,
788,
656,
16610,
3596,
15,
2164,
15,
331,
24715,
15,
973,
14,
331,
24715,
297,
283,
656,
16610,
3596,
15,
2491,
14,
1001,
418,
272,
4588,
63,
1023,
275,
984,
14,
3020,
59,
17,
61,
339,
340,
1104,
63,
1210,
8,
5334,
63,
1023,
304,
267,
984,
14,
2224,
8,
17,
9,
339,
1015,
63,
873,
8,
5334,
63,
1023,
12,
1584,
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
] |
[
747,
199,
646,
295,
199,
646,
984,
421,
199,
318,
1104,
63,
1210,
8,
1222,
63,
422,
304,
272,
408,
7523,
626,
922,
1324,
4450,
314,
1475,
1323,
14,
56,
14,
56,
408,
339,
12713,
275,
519,
1154,
68,
11,
3134,
68,
11,
3134,
68,
4786,
272,
340,
440,
295,
14,
1431,
8,
10853,
12,
892,
63,
422,
304,
267,
870,
480,
1918,
892,
1015,
1471,
506,
315,
314,
1475,
1323,
14,
56,
14,
56,
334,
476,
14,
283,
16,
14,
22,
14,
16,
26530,
267,
372,
715,
421,
199,
318,
1015,
63,
873,
8,
1222,
63,
422,
12,
570,
63,
1144,
304,
272,
408,
14402,
3411,
1015,
15,
3221,
1329,
315,
376,
1625,
402,
1584,
267,
543,
282,
922,
13,
22525,
1015,
1329,
334,
1222,
63,
422,
9471,
339,
12713,
275,
519,
624,
8,
3221,
92,
1023,
31440,
4451,
1622,
1491,
29,
61,
359,
13356,
1105,
2961,
68,
11,
3134,
68,
11,
3134,
68,
8771,
779,
13356,
1105,
624,
339,
327,
3820,
626,
911,
1395,
1263,
1584,
2382,
314,
1015,
1329,
1990,
8792,
8717,
272,
8717,
275,
942,
339,
327,
2494,
465,
3055,
5133,
282,
1336,
365,
1911,
436,
8717,
315,
314,
4438,
5084,
272,
14670,
63,
422,
275,
756,
339,
367,
809,
63,
493,
315,
570,
63,
1144,
26,
267,
289,
275,
1551,
8,
422,
63,
493,
9,
267,
1318,
275,
289,
14,
739,
342,
267,
1336,
5665,
275,
295,
14,
1733,
8,
10853,
12,
1318,
9,
267,
289,
14,
1600,
342,
398,
340,
1336,
5665,
26,
288,
14670,
63,
422,
275,
1336,
5665,
14,
923,
8,
19,
9,
288,
289,
275,
1551,
8,
422,
63,
493,
12,
283,
87,
358,
288,
1318,
275,
295,
14,
954,
8,
10853,
12,
519,
1154,
71,
28,
17,
3072,
71,
28,
18,
6598,
83,
60,
71,
28,
20,
3524,
450,
892,
63,
422,
12,
1318,
9,
288,
289,
14,
952,
8,
505,
9,
288,
8717,
14,
740,
8,
422,
63,
493,
9,
267,
587,
26,
288,
870,
480,
6005,
370,
2342,
1015,
1329,
4877,
1420,
1475,
283,
56,
14,
56,
14,
56,
7,
315,
450,
83,
2,
450,
809,
63,
493,
9,
339,
340,
14670,
63,
422,
26,
267,
870,
480,
3353,
1329,
2896,
687,
450,
83,
370,
450,
83,
315,
971,
78,
5,
83,
2,
450,
334,
21423,
63,
422,
12,
892,
63,
422,
12,
8717,
430,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
340,
440,
822,
8,
1274,
14,
3020,
9,
508,
499,
26,
267,
870,
480,
8254,
5647,
282,
1015,
1329,
2685,
267,
984,
14,
2224,
8,
17,
9,
339,
747,
14,
8563,
24592,
358,
339,
1584,
275,
788,
656,
16610,
3596,
15,
2164,
15,
331,
24715,
15,
973,
14,
331,
24715,
297,
283,
656,
16610,
3596,
15,
2491,
14,
1001,
418,
272,
4588,
63,
1023,
275,
984,
14,
3020,
59,
17,
61,
339,
340,
1104,
63,
1210,
8,
5334,
63,
1023,
304,
267,
984,
14,
2224,
8,
17,
9,
339,
1015,
63,
873,
8,
5334,
63,
1023,
12,
1584,
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,
0
] |
[
1,
1,
1,
1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
django/contrib/auth/tokens.py
|
433
|
2803
|
from datetime import date
from django.conf import settings
from django.utils import six
from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils.http import base36_to_int, int_to_base36
class PasswordResetTokenGenerator(object):
"""
Strategy object used to generate and check tokens for the password
reset mechanism.
"""
key_salt = "django.contrib.auth.tokens.PasswordResetTokenGenerator"
def make_token(self, user):
"""
Returns a token that can be used once to do a password reset
for the given user.
"""
return self._make_token_with_timestamp(user, self._num_days(self._today()))
def check_token(self, user, token):
"""
Check that a password reset token is correct for a given user.
"""
# Parse the token
try:
ts_b36, hash = token.split("-")
except ValueError:
return False
try:
ts = base36_to_int(ts_b36)
except ValueError:
return False
# Check that the timestamp/uid has not been tampered with
if not constant_time_compare(self._make_token_with_timestamp(user, ts), token):
return False
# Check the timestamp is within limit
if (self._num_days(self._today()) - ts) > settings.PASSWORD_RESET_TIMEOUT_DAYS:
return False
return True
def _make_token_with_timestamp(self, user, timestamp):
# timestamp is number of days since 2001-1-1. Converted to
# base 36, this gives us a 3 digit string until about 2121
ts_b36 = int_to_base36(timestamp)
# By hashing on the internal state of the user and using state
# that is sure to change (the password salt will change as soon as
# the password is set, at least for current Django auth, and
# last_login will also change), we produce a hash that will be
# invalid as soon as it is used.
# We limit the hash to 20 chars to keep URL short
hash = salted_hmac(
self.key_salt,
self._make_hash_value(user, timestamp),
).hexdigest()[::2]
return "%s-%s" % (ts_b36, hash)
def _make_hash_value(self, user, timestamp):
# Ensure results are consistent across DB backends
login_timestamp = '' if user.last_login is None else user.last_login.replace(microsecond=0, tzinfo=None)
return (
six.text_type(user.pk) + user.password +
six.text_type(login_timestamp) + six.text_type(timestamp)
)
def _num_days(self, dt):
return (dt - date(2001, 1, 1)).days
def _today(self):
# Used for mocking in tests
return date.today()
default_token_generator = PasswordResetTokenGenerator()
|
bsd-3-clause
|
[
504,
2197,
492,
1434,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
10316,
492,
4413,
63,
521,
63,
5785,
12,
18641,
471,
63,
18537,
199,
504,
1639,
14,
1208,
14,
1014,
492,
1300,
1344,
63,
475,
63,
442,
12,
1109,
63,
475,
63,
1095,
1344,
421,
199,
533,
13635,
9637,
3264,
7599,
8,
785,
304,
272,
408,
272,
8303,
5374,
909,
1202,
370,
3550,
436,
1104,
4645,
367,
314,
2505,
272,
5305,
14729,
14,
272,
408,
272,
790,
63,
12597,
275,
298,
1176,
14,
2828,
14,
1178,
14,
4504,
14,
6139,
9637,
3264,
7599,
2,
339,
347,
1852,
63,
1418,
8,
277,
12,
922,
304,
267,
408,
267,
1803,
282,
1526,
626,
883,
506,
1202,
5403,
370,
886,
282,
2505,
5305,
267,
367,
314,
1627,
922,
14,
267,
408,
267,
372,
291,
423,
1875,
63,
1418,
63,
1045,
63,
3954,
8,
751,
12,
291,
423,
1507,
63,
4899,
8,
277,
423,
8136,
4059,
339,
347,
1104,
63,
1418,
8,
277,
12,
922,
12,
1526,
304,
267,
408,
267,
2670,
626,
282,
2505,
5305,
1526,
365,
3211,
367,
282,
1627,
922,
14,
267,
408,
267,
327,
6077,
314,
1526,
267,
862,
26,
288,
6714,
63,
66,
1344,
12,
2631,
275,
1526,
14,
1294,
6096,
531,
267,
871,
1722,
26,
288,
372,
756,
398,
862,
26,
288,
6714,
275,
1300,
1344,
63,
475,
63,
442,
8,
1086,
63,
66,
1344,
9,
267,
871,
1722,
26,
288,
372,
756,
398,
327,
2670,
626,
314,
4913,
15,
1535,
965,
440,
2757,
3052,
311,
16179,
543,
267,
340,
440,
4413,
63,
521,
63,
5785,
8,
277,
423,
1875,
63,
1418,
63,
1045,
63,
3954,
8,
751,
12,
6714,
395,
1526,
304,
288,
372,
756,
398,
327,
2670,
314,
4913,
365,
4453,
2304,
267,
340,
334,
277,
423,
1507,
63,
4899,
8,
277,
423,
8136,
1012,
446,
6714,
9,
690,
2202,
14,
9032,
63,
18066,
63,
8899,
63,
25683,
26,
288,
372,
756,
398,
372,
715,
339,
347,
485,
1875,
63,
1418,
63,
1045,
63,
3954,
8,
277,
12,
922,
12,
4913,
304,
267,
327,
4913,
365,
1329,
402,
7609,
3967,
12521,
13,
17,
13,
17,
14,
221,
11801,
471,
370,
267,
327,
1300,
8780,
12,
642,
10557,
2739,
282,
650,
10964,
1059,
5133,
3595,
499,
10753,
267,
6714,
63,
66,
1344,
275,
1109,
63,
475,
63,
1095,
1344,
8,
3954,
9,
398,
327,
4885,
25223,
641,
314,
5007,
1174,
402,
314,
922,
436,
1808,
1174,
267,
327,
626,
365,
3238,
370,
1570,
334,
1589,
2505,
10105,
911,
1570,
465,
18930,
465,
267,
327,
314,
2505,
365,
663,
12,
737,
5210,
367,
1453,
5634,
1790,
12,
436,
267,
327,
2061,
63,
2886,
911,
2597,
1570,
395,
781,
7389,
282,
2631,
626,
911,
506,
267,
327,
3866,
465,
18930,
465,
652,
365,
1202,
14,
267,
327,
2136,
2304,
314,
2631,
370,
3388,
8365,
370,
4215,
2851,
3974,
398,
2631,
275,
18641,
471,
63,
18537,
8,
288,
291,
14,
498,
63,
12597,
12,
288,
291,
423,
1875,
63,
2227,
63,
585,
8,
751,
12,
4913,
395,
267,
7092,
11453,
3430,
447,
18,
61,
267,
372,
2071,
83,
3295,
83,
2,
450,
334,
1086,
63,
66,
1344,
12,
2631,
9,
339,
347,
485,
1875,
63,
2227,
63,
585,
8,
277,
12,
922,
12,
4913,
304,
267,
327,
7523,
2058,
787,
12137,
9371,
6249,
14745,
267,
4676,
63,
3954,
275,
2125,
340,
922,
14,
2019,
63,
2886,
365,
488,
587,
922,
14,
2019,
63,
2886,
14,
1814,
8,
16627,
29,
16,
12,
10313,
29,
403,
9,
267,
372,
334,
288,
3816,
14,
505,
63,
466,
8,
751,
14,
2051,
9,
435,
922,
14,
2060,
435,
288,
3816,
14,
505,
63,
466,
8,
2886,
63,
3954,
9,
435,
3816,
14,
505,
63,
466,
8,
3954,
9,
267,
776,
339,
347,
485,
1507,
63,
4899,
8,
277,
12,
4487,
304,
267,
372,
334,
3583,
446,
1434,
8,
8339,
12,
413,
12,
413,
4992,
4899,
339,
347,
485,
8136,
8,
277,
304,
267,
327,
8051,
367,
1683,
316,
315,
2295,
267,
372,
1434,
14,
8136,
342,
199,
199,
885,
63,
1418,
63,
4679,
275,
13635,
9637,
3264,
7599,
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
] |
[
2197,
492,
1434,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
10316,
492,
4413,
63,
521,
63,
5785,
12,
18641,
471,
63,
18537,
199,
504,
1639,
14,
1208,
14,
1014,
492,
1300,
1344,
63,
475,
63,
442,
12,
1109,
63,
475,
63,
1095,
1344,
421,
199,
533,
13635,
9637,
3264,
7599,
8,
785,
304,
272,
408,
272,
8303,
5374,
909,
1202,
370,
3550,
436,
1104,
4645,
367,
314,
2505,
272,
5305,
14729,
14,
272,
408,
272,
790,
63,
12597,
275,
298,
1176,
14,
2828,
14,
1178,
14,
4504,
14,
6139,
9637,
3264,
7599,
2,
339,
347,
1852,
63,
1418,
8,
277,
12,
922,
304,
267,
408,
267,
1803,
282,
1526,
626,
883,
506,
1202,
5403,
370,
886,
282,
2505,
5305,
267,
367,
314,
1627,
922,
14,
267,
408,
267,
372,
291,
423,
1875,
63,
1418,
63,
1045,
63,
3954,
8,
751,
12,
291,
423,
1507,
63,
4899,
8,
277,
423,
8136,
4059,
339,
347,
1104,
63,
1418,
8,
277,
12,
922,
12,
1526,
304,
267,
408,
267,
2670,
626,
282,
2505,
5305,
1526,
365,
3211,
367,
282,
1627,
922,
14,
267,
408,
267,
327,
6077,
314,
1526,
267,
862,
26,
288,
6714,
63,
66,
1344,
12,
2631,
275,
1526,
14,
1294,
6096,
531,
267,
871,
1722,
26,
288,
372,
756,
398,
862,
26,
288,
6714,
275,
1300,
1344,
63,
475,
63,
442,
8,
1086,
63,
66,
1344,
9,
267,
871,
1722,
26,
288,
372,
756,
398,
327,
2670,
626,
314,
4913,
15,
1535,
965,
440,
2757,
3052,
311,
16179,
543,
267,
340,
440,
4413,
63,
521,
63,
5785,
8,
277,
423,
1875,
63,
1418,
63,
1045,
63,
3954,
8,
751,
12,
6714,
395,
1526,
304,
288,
372,
756,
398,
327,
2670,
314,
4913,
365,
4453,
2304,
267,
340,
334,
277,
423,
1507,
63,
4899,
8,
277,
423,
8136,
1012,
446,
6714,
9,
690,
2202,
14,
9032,
63,
18066,
63,
8899,
63,
25683,
26,
288,
372,
756,
398,
372,
715,
339,
347,
485,
1875,
63,
1418,
63,
1045,
63,
3954,
8,
277,
12,
922,
12,
4913,
304,
267,
327,
4913,
365,
1329,
402,
7609,
3967,
12521,
13,
17,
13,
17,
14,
221,
11801,
471,
370,
267,
327,
1300,
8780,
12,
642,
10557,
2739,
282,
650,
10964,
1059,
5133,
3595,
499,
10753,
267,
6714,
63,
66,
1344,
275,
1109,
63,
475,
63,
1095,
1344,
8,
3954,
9,
398,
327,
4885,
25223,
641,
314,
5007,
1174,
402,
314,
922,
436,
1808,
1174,
267,
327,
626,
365,
3238,
370,
1570,
334,
1589,
2505,
10105,
911,
1570,
465,
18930,
465,
267,
327,
314,
2505,
365,
663,
12,
737,
5210,
367,
1453,
5634,
1790,
12,
436,
267,
327,
2061,
63,
2886,
911,
2597,
1570,
395,
781,
7389,
282,
2631,
626,
911,
506,
267,
327,
3866,
465,
18930,
465,
652,
365,
1202,
14,
267,
327,
2136,
2304,
314,
2631,
370,
3388,
8365,
370,
4215,
2851,
3974,
398,
2631,
275,
18641,
471,
63,
18537,
8,
288,
291,
14,
498,
63,
12597,
12,
288,
291,
423,
1875,
63,
2227,
63,
585,
8,
751,
12,
4913,
395,
267,
7092,
11453,
3430,
447,
18,
61,
267,
372,
2071,
83,
3295,
83,
2,
450,
334,
1086,
63,
66,
1344,
12,
2631,
9,
339,
347,
485,
1875,
63,
2227,
63,
585,
8,
277,
12,
922,
12,
4913,
304,
267,
327,
7523,
2058,
787,
12137,
9371,
6249,
14745,
267,
4676,
63,
3954,
275,
2125,
340,
922,
14,
2019,
63,
2886,
365,
488,
587,
922,
14,
2019,
63,
2886,
14,
1814,
8,
16627,
29,
16,
12,
10313,
29,
403,
9,
267,
372,
334,
288,
3816,
14,
505,
63,
466,
8,
751,
14,
2051,
9,
435,
922,
14,
2060,
435,
288,
3816,
14,
505,
63,
466,
8,
2886,
63,
3954,
9,
435,
3816,
14,
505,
63,
466,
8,
3954,
9,
267,
776,
339,
347,
485,
1507,
63,
4899,
8,
277,
12,
4487,
304,
267,
372,
334,
3583,
446,
1434,
8,
8339,
12,
413,
12,
413,
4992,
4899,
339,
347,
485,
8136,
8,
277,
304,
267,
327,
8051,
367,
1683,
316,
315,
2295,
267,
372,
1434,
14,
8136,
342,
199,
199,
885,
63,
1418,
63,
4679,
275,
13635,
9637,
3264,
7599,
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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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
netortik/yandex-tank
|
yandextank/plugins/Pandora/tests/test_pandora_plugin.py
|
2
|
1056
|
import pytest
from mock import MagicMock
from yandextank.plugins.Pandora import Plugin
@pytest.mark.parametrize('cfg, expected', [
(
{'pools': [
{
'ammo': {'uri-headers': '[User-Agent: Wget/1.13.4 (linux-gnu)] [Host: foo.ru] [Accept-Encoding: gzip,deflate,sdch]',
'type': 'uri',
'file': 'https://raw.githubusercontent.com/yandex/yandex-tank/develop/README.md'
}
}]},
{'pools': [
{
'ammo': {'uri-headers': '[User-Agent: Wget/1.13.4 (linux-gnu)] [Host: foo.ru] [Accept-Encoding: gzip,deflate,sdch]',
'type': 'uri',
'file': 'some local file'}
}]}
)
])
def test_patch_config(cfg, expected):
plugin = Plugin(MagicMock(), None, 'pandora')
# '/tmp/9b73d966bcbf27467d4c4190cfe58c2a.downloaded_resource'
filename = plugin.patch_config(cfg)['pools'][0]['ammo']['file']
assert filename.endswith('.downloaded_resource')
|
lgpl-2.1
|
[
646,
4613,
199,
504,
1683,
492,
10079,
199,
199,
504,
612,
290,
271,
400,
3580,
14,
5265,
14,
48,
460,
11131,
492,
11349,
421,
199,
32,
4462,
14,
1657,
14,
10396,
360,
4128,
12,
1420,
297,
359,
272,
334,
267,
791,
12406,
356,
359,
288,
469,
355,
283,
455,
573,
356,
791,
2302,
13,
2139,
356,
6730,
1899,
13,
7788,
26,
644,
362,
15,
17,
14,
969,
14,
20,
334,
5135,
13,
3689,
1874,
359,
4965,
26,
3925,
14,
6558,
61,
359,
8422,
13,
7630,
26,
11756,
12,
20902,
12,
3893,
335,
4300,
586,
283,
466,
356,
283,
2302,
297,
586,
283,
493,
356,
283,
2859,
921,
1773,
14,
5031,
751,
1317,
14,
957,
15,
89,
290,
731,
15,
89,
290,
731,
13,
84,
3580,
15,
32176,
15,
18195,
14,
1064,
7,
586,
789,
288,
789,
13888,
267,
791,
12406,
356,
359,
288,
469,
355,
283,
455,
573,
356,
791,
2302,
13,
2139,
356,
6730,
1899,
13,
7788,
26,
644,
362,
15,
17,
14,
969,
14,
20,
334,
5135,
13,
3689,
1874,
359,
4965,
26,
3925,
14,
6558,
61,
359,
8422,
13,
7630,
26,
11756,
12,
20902,
12,
3893,
335,
4300,
586,
283,
466,
356,
283,
2302,
297,
586,
283,
493,
356,
283,
3972,
2257,
570,
936,
288,
789,
9420,
272,
776,
199,
566,
199,
318,
511,
63,
2068,
63,
888,
8,
4128,
12,
1420,
304,
272,
3589,
275,
11349,
8,
11988,
1062,
488,
12,
283,
80,
460,
11131,
358,
272,
327,
1994,
2791,
15,
25,
66,
2898,
68,
30689,
66,
2894,
70,
9014,
1822,
68,
20,
67,
20,
12205,
67,
771,
2010,
67,
18,
65,
14,
19385,
63,
1927,
7,
272,
1788,
275,
3589,
14,
2068,
63,
888,
8,
4128,
11820,
12406,
3488,
16,
2733,
455,
573,
2545,
493,
418,
272,
702,
1788,
14,
4130,
5175,
19385,
63,
1927,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4613,
199,
504,
1683,
492,
10079,
199,
199,
504,
612,
290,
271,
400,
3580,
14,
5265,
14,
48,
460,
11131,
492,
11349,
421,
199,
32,
4462,
14,
1657,
14,
10396,
360,
4128,
12,
1420,
297,
359,
272,
334,
267,
791,
12406,
356,
359,
288,
469,
355,
283,
455,
573,
356,
791,
2302,
13,
2139,
356,
6730,
1899,
13,
7788,
26,
644,
362,
15,
17,
14,
969,
14,
20,
334,
5135,
13,
3689,
1874,
359,
4965,
26,
3925,
14,
6558,
61,
359,
8422,
13,
7630,
26,
11756,
12,
20902,
12,
3893,
335,
4300,
586,
283,
466,
356,
283,
2302,
297,
586,
283,
493,
356,
283,
2859,
921,
1773,
14,
5031,
751,
1317,
14,
957,
15,
89,
290,
731,
15,
89,
290,
731,
13,
84,
3580,
15,
32176,
15,
18195,
14,
1064,
7,
586,
789,
288,
789,
13888,
267,
791,
12406,
356,
359,
288,
469,
355,
283,
455,
573,
356,
791,
2302,
13,
2139,
356,
6730,
1899,
13,
7788,
26,
644,
362,
15,
17,
14,
969,
14,
20,
334,
5135,
13,
3689,
1874,
359,
4965,
26,
3925,
14,
6558,
61,
359,
8422,
13,
7630,
26,
11756,
12,
20902,
12,
3893,
335,
4300,
586,
283,
466,
356,
283,
2302,
297,
586,
283,
493,
356,
283,
3972,
2257,
570,
936,
288,
789,
9420,
272,
776,
199,
566,
199,
318,
511,
63,
2068,
63,
888,
8,
4128,
12,
1420,
304,
272,
3589,
275,
11349,
8,
11988,
1062,
488,
12,
283,
80,
460,
11131,
358,
272,
327,
1994,
2791,
15,
25,
66,
2898,
68,
30689,
66,
2894,
70,
9014,
1822,
68,
20,
67,
20,
12205,
67,
771,
2010,
67,
18,
65,
14,
19385,
63,
1927,
7,
272,
1788,
275,
3589,
14,
2068,
63,
888,
8,
4128,
11820,
12406,
3488,
16,
2733,
455,
573,
2545,
493,
418,
272,
702,
1788,
14,
4130,
5175,
19385,
63,
1927,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
alobbs/ansible
|
v1/ansible/module_utils/gce.py
|
305
|
4179
|
# This code is part of Ansible, but is an independent component.
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete work.
#
# Copyright (c), Franck Cuny <franck.cuny@gmail.com>, 2014
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
import pprint
USER_AGENT_PRODUCT="Ansible-gce"
USER_AGENT_VERSION="v1"
def gce_connect(module, provider=None):
"""Return a Google Cloud Engine connection."""
service_account_email = module.params.get('service_account_email', None)
pem_file = module.params.get('pem_file', None)
project_id = module.params.get('project_id', None)
# If any of the values are not given as parameters, check the appropriate
# environment variables.
if not service_account_email:
service_account_email = os.environ.get('GCE_EMAIL', None)
if not project_id:
project_id = os.environ.get('GCE_PROJECT', None)
if not pem_file:
pem_file = os.environ.get('GCE_PEM_FILE_PATH', None)
# If we still don't have one or more of our credentials, attempt to
# get the remaining values from the libcloud secrets file.
if service_account_email is None or pem_file is None:
try:
import secrets
except ImportError:
secrets = None
if hasattr(secrets, 'GCE_PARAMS'):
if not service_account_email:
service_account_email = secrets.GCE_PARAMS[0]
if not pem_file:
pem_file = secrets.GCE_PARAMS[1]
keyword_params = getattr(secrets, 'GCE_KEYWORD_PARAMS', {})
if not project_id:
project_id = keyword_params.get('project', None)
# If we *still* don't have the credentials we need, then it's time to
# just fail out.
if service_account_email is None or pem_file is None or project_id is None:
module.fail_json(msg='Missing GCE connection parameters in libcloud '
'secrets file.')
return None
# Allow for passing in libcloud Google DNS (e.g, Provider.GOOGLE)
if provider is None:
provider = Provider.GCE
try:
gce = get_driver(provider)(service_account_email, pem_file,
datacenter=module.params.get('zone', None),
project=project_id)
gce.connection.user_agent_append("%s/%s" % (
USER_AGENT_PRODUCT, USER_AGENT_VERSION))
except (RuntimeError, ValueError), e:
module.fail_json(msg=str(e), changed=False)
except Exception, e:
module.fail_json(msg=unexpected_error_msg(e), changed=False)
return gce
def unexpected_error_msg(error):
"""Create an error string based on passed in error."""
return 'Unexpected response: ' + pprint.pformat(vars(error))
|
gpl-3.0
|
[
3,
961,
1233,
365,
1777,
402,
2622,
12,
1325,
365,
376,
12717,
3931,
14,
199,
3,
961,
6770,
570,
17440,
12,
436,
642,
570,
17440,
1454,
12,
365,
6289,
18233,
14,
199,
3,
18167,
1265,
2218,
1808,
642,
17440,
12,
1314,
365,
12169,
18774,
701,
2622,
199,
3,
5139,
13511,
370,
314,
4132,
402,
314,
859,
12,
436,
1443,
5090,
3932,
5705,
4190,
199,
3,
370,
314,
4890,
1736,
14,
199,
3,
199,
3,
1898,
334,
67,
395,
481,
1312,
346,
445,
324,
89,
665,
70,
1312,
346,
14,
67,
324,
89,
32,
6799,
14,
957,
6244,
6927,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
7100,
12,
199,
3,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
199,
3,
259,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
420,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
259,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
420,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
420,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
2401,
199,
3,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
5292,
199,
3,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
9315,
9706,
14,
199,
3,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
199,
3,
9716,
12,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
199,
3,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
199,
3,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
199,
646,
10933,
199,
199,
3791,
63,
14565,
63,
14853,
628,
10047,
13,
22833,
2,
199,
3791,
63,
14565,
63,
4612,
628,
86,
17,
2,
199,
199,
318,
21319,
63,
2242,
8,
578,
12,
5022,
29,
403,
304,
272,
408,
1767,
282,
4475,
8142,
12580,
1950,
1041,
272,
2435,
63,
2048,
63,
2123,
275,
859,
14,
1162,
14,
362,
360,
1364,
63,
2048,
63,
2123,
297,
488,
9,
272,
4837,
77,
63,
493,
275,
859,
14,
1162,
14,
362,
360,
13102,
63,
493,
297,
488,
9,
272,
2199,
63,
344,
275,
859,
14,
1162,
14,
362,
360,
1715,
63,
344,
297,
488,
9,
339,
327,
982,
1263,
402,
314,
1338,
787,
440,
1627,
465,
2633,
12,
1104,
314,
5827,
272,
327,
3734,
2860,
14,
272,
340,
440,
2435,
63,
2048,
63,
2123,
26,
267,
2435,
63,
2048,
63,
2123,
275,
747,
14,
2314,
14,
362,
360,
39,
2089,
63,
10089,
297,
488,
9,
272,
340,
440,
2199,
63,
344,
26,
267,
2199,
63,
344,
275,
747,
14,
2314,
14,
362,
360,
39,
2089,
63,
10797,
297,
488,
9,
272,
340,
440,
4837,
77,
63,
493,
26,
267,
4837,
77,
63,
493,
275,
747,
14,
2314,
14,
362,
360,
39,
2089,
63,
24160,
63,
3817,
63,
3243,
297,
488,
9,
339,
327,
982,
781,
5139,
2793,
1133,
1172,
1373,
503,
1655,
402,
4154,
6235,
12,
7427,
370,
272,
327,
664,
314,
7971,
1338,
687,
314,
17069,
25563,
570,
14,
272,
340,
2435,
63,
2048,
63,
2123,
365,
488,
503,
4837,
77,
63,
493,
365,
488,
26,
267,
862,
26,
288,
492,
25563,
267,
871,
3545,
26,
288,
25563,
275,
488,
398,
340,
2688,
8,
16153,
12,
283,
39,
2089,
63,
17978,
735,
288,
340,
440,
2435,
63,
2048,
63,
2123,
26,
355,
2435,
63,
2048,
63,
2123,
275,
25563,
14,
39,
2089,
63,
17978,
59,
16,
61,
288,
340,
440,
4837,
77,
63,
493,
26,
355,
4837,
77,
63,
493,
275,
25563,
14,
39,
2089,
63,
17978,
59,
17,
61,
267,
4252,
63,
1162,
275,
2519,
8,
16153,
12,
283,
39,
2089,
63,
17714,
63,
17978,
297,
5009,
267,
340,
440,
2199,
63,
344,
26,
288,
2199,
63,
344,
275,
4252,
63,
1162,
14,
362,
360,
1715,
297,
488,
9,
339,
327,
982,
781,
627,
32310,
10,
2793,
1133,
1172,
314,
6235,
781,
1929,
12,
2066,
652,
1159,
900,
370,
272,
327,
2951,
2449,
734,
14,
272,
340,
2435,
63,
2048,
63,
2123,
365,
488,
503,
4837,
77,
63,
493,
365,
488,
503,
2199,
63,
344,
365,
488,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
7718,
31556,
1950,
2633,
315,
17069,
283,
2490,
283,
16153,
570,
2659,
267,
372,
488,
339,
327,
9812,
367,
9476,
315,
17069,
4475,
10237,
334,
69,
14,
71,
12,
18489,
14,
24243,
9,
272,
340,
5022,
365,
488,
26,
267,
5022,
275,
18489,
14,
39,
2089,
339,
862,
26,
267,
21319,
275,
664,
63,
3090,
8,
3780,
5130,
1364,
63,
2048,
63,
2123,
12,
4837,
77,
63,
493,
12,
355,
16606,
29,
578,
14,
1162,
14,
362,
360,
2619,
297,
488,
395,
355,
2199,
29,
1715,
63,
344,
9,
267,
21319,
14,
2105,
14,
751,
63,
4054,
63,
740,
3647,
83,
3149,
83,
2,
450,
334,
288,
13044,
63,
14565,
63,
14853,
12,
13044,
63,
14565,
63,
4612,
430,
272,
871,
334,
13281,
12,
1722,
395,
325,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
495,
8,
69,
395,
2896,
29,
797,
9,
272,
871,
2186,
12,
325,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
8953,
63,
705,
63,
1328,
8,
69,
395,
2896,
29,
797,
9,
339,
372,
21319,
199,
199,
318,
10537,
63,
705,
63,
1328,
8,
705,
304,
272,
408,
2499,
376,
1125,
1059,
4079,
641,
3032,
315,
1125,
1041,
272,
372,
283,
8708,
1177,
26,
283,
435,
10933,
14,
24225,
8,
2936,
8,
705,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
961,
1233,
365,
1777,
402,
2622,
12,
1325,
365,
376,
12717,
3931,
14,
199,
3,
961,
6770,
570,
17440,
12,
436,
642,
570,
17440,
1454,
12,
365,
6289,
18233,
14,
199,
3,
18167,
1265,
2218,
1808,
642,
17440,
12,
1314,
365,
12169,
18774,
701,
2622,
199,
3,
5139,
13511,
370,
314,
4132,
402,
314,
859,
12,
436,
1443,
5090,
3932,
5705,
4190,
199,
3,
370,
314,
4890,
1736,
14,
199,
3,
199,
3,
1898,
334,
67,
395,
481,
1312,
346,
445,
324,
89,
665,
70,
1312,
346,
14,
67,
324,
89,
32,
6799,
14,
957,
6244,
6927,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
7100,
12,
199,
3,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
199,
3,
259,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
420,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
259,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
420,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
420,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
2401,
199,
3,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
5292,
199,
3,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
9315,
9706,
14,
199,
3,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
199,
3,
9716,
12,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
199,
3,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
199,
3,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
199,
646,
10933,
199,
199,
3791,
63,
14565,
63,
14853,
628,
10047,
13,
22833,
2,
199,
3791,
63,
14565,
63,
4612,
628,
86,
17,
2,
199,
199,
318,
21319,
63,
2242,
8,
578,
12,
5022,
29,
403,
304,
272,
408,
1767,
282,
4475,
8142,
12580,
1950,
1041,
272,
2435,
63,
2048,
63,
2123,
275,
859,
14,
1162,
14,
362,
360,
1364,
63,
2048,
63,
2123,
297,
488,
9,
272,
4837,
77,
63,
493,
275,
859,
14,
1162,
14,
362,
360,
13102,
63,
493,
297,
488,
9,
272,
2199,
63,
344,
275,
859,
14,
1162,
14,
362,
360,
1715,
63,
344,
297,
488,
9,
339,
327,
982,
1263,
402,
314,
1338,
787,
440,
1627,
465,
2633,
12,
1104,
314,
5827,
272,
327,
3734,
2860,
14,
272,
340,
440,
2435,
63,
2048,
63,
2123,
26,
267,
2435,
63,
2048,
63,
2123,
275,
747,
14,
2314,
14,
362,
360,
39,
2089,
63,
10089,
297,
488,
9,
272,
340,
440,
2199,
63,
344,
26,
267,
2199,
63,
344,
275,
747,
14,
2314,
14,
362,
360,
39,
2089,
63,
10797,
297,
488,
9,
272,
340,
440,
4837,
77,
63,
493,
26,
267,
4837,
77,
63,
493,
275,
747,
14,
2314,
14,
362,
360,
39,
2089,
63,
24160,
63,
3817,
63,
3243,
297,
488,
9,
339,
327,
982,
781,
5139,
2793,
1133,
1172,
1373,
503,
1655,
402,
4154,
6235,
12,
7427,
370,
272,
327,
664,
314,
7971,
1338,
687,
314,
17069,
25563,
570,
14,
272,
340,
2435,
63,
2048,
63,
2123,
365,
488,
503,
4837,
77,
63,
493,
365,
488,
26,
267,
862,
26,
288,
492,
25563,
267,
871,
3545,
26,
288,
25563,
275,
488,
398,
340,
2688,
8,
16153,
12,
283,
39,
2089,
63,
17978,
735,
288,
340,
440,
2435,
63,
2048,
63,
2123,
26,
355,
2435,
63,
2048,
63,
2123,
275,
25563,
14,
39,
2089,
63,
17978,
59,
16,
61,
288,
340,
440,
4837,
77,
63,
493,
26,
355,
4837,
77,
63,
493,
275,
25563,
14,
39,
2089,
63,
17978,
59,
17,
61,
267,
4252,
63,
1162,
275,
2519,
8,
16153,
12,
283,
39,
2089,
63,
17714,
63,
17978,
297,
5009,
267,
340,
440,
2199,
63,
344,
26,
288,
2199,
63,
344,
275,
4252,
63,
1162,
14,
362,
360,
1715,
297,
488,
9,
339,
327,
982,
781,
627,
32310,
10,
2793,
1133,
1172,
314,
6235,
781,
1929,
12,
2066,
652,
1159,
900,
370,
272,
327,
2951,
2449,
734,
14,
272,
340,
2435,
63,
2048,
63,
2123,
365,
488,
503,
4837,
77,
63,
493,
365,
488,
503,
2199,
63,
344,
365,
488,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
7718,
31556,
1950,
2633,
315,
17069,
283,
2490,
283,
16153,
570,
2659,
267,
372,
488,
339,
327,
9812,
367,
9476,
315,
17069,
4475,
10237,
334,
69,
14,
71,
12,
18489,
14,
24243,
9,
272,
340,
5022,
365,
488,
26,
267,
5022,
275,
18489,
14,
39,
2089,
339,
862,
26,
267,
21319,
275,
664,
63,
3090,
8,
3780,
5130,
1364,
63,
2048,
63,
2123,
12,
4837,
77,
63,
493,
12,
355,
16606,
29,
578,
14,
1162,
14,
362,
360,
2619,
297,
488,
395,
355,
2199,
29,
1715,
63,
344,
9,
267,
21319,
14,
2105,
14,
751,
63,
4054,
63,
740,
3647,
83,
3149,
83,
2,
450,
334,
288,
13044,
63,
14565,
63,
14853,
12,
13044,
63,
14565,
63,
4612,
430,
272,
871,
334,
13281,
12,
1722,
395,
325,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
495,
8,
69,
395,
2896,
29,
797,
9,
272,
871,
2186,
12,
325,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
8953,
63,
705,
63,
1328,
8,
69,
395,
2896,
29,
797,
9,
339,
372,
21319,
199,
199,
318,
10537,
63,
705,
63,
1328,
8,
705,
304,
272,
408,
2499,
376,
1125,
1059,
4079,
641,
3032,
315,
1125,
1041,
272,
372,
283,
8708,
1177,
26,
283,
435,
10933,
14,
24225,
8,
2936,
8,
705,
430,
199,
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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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
nilbody/h2o-3
|
h2o-py/tests/testdir_golden/pyunit_svd_1_golden.py
|
1
|
2402
|
from __future__ import print_function
from builtins import zip
import sys
sys.path.insert(1,"../../")
import h2o
from tests import pyunit_utils
def svd_1_golden():
print("Importing USArrests.csv data...")
arrestsH2O = h2o.upload_file(pyunit_utils.locate("smalldata/pca_test/USArrests.csv"))
print("Compare with SVD")
fitH2O = h2o.svd(x=arrestsH2O[0:4], nv=4, transform="NONE", max_iterations=2000)
print("Compare singular values (D)")
h2o_d = fitH2O._model_json['output']['d']
r_d = [1419.06139509772, 194.825846110138, 45.6613376308754, 18.0695566224677]
print("R Singular Values: {0}".format(r_d))
print("H2O Singular Values: {0}".format(h2o_d))
for r, h in zip(r_d, h2o_d): assert abs(r - h) < 1e-6, "H2O got {0}, but R got {1}".format(h, r)
print("Compare right singular vectors (V)")
h2o_v = h2o.as_list(h2o.get_frame(fitH2O._model_json['output']['v_key']['name']), use_pandas=False)
h2o_v.pop(0)
r_v = [[-0.04239181, 0.01616262, -0.06588426, 0.99679535],
[-0.94395706, 0.32068580, 0.06655170, -0.04094568],
[-0.30842767, -0.93845891, 0.15496743, 0.01234261],
[-0.10963744, -0.12725666, -0.98347101, -0.06760284]]
print("R Right Singular Vectors: {0}".format(r_v))
print("H2O Right Singular Vectors: {0}".format(h2o_v))
for rl, hl in zip(r_v, h2o_v):
for r, h in zip(rl, hl): assert abs(abs(r) - abs(float(h))) < 1e-5, "H2O got {0}, but R got {1}".format(h, r)
print("Compare left singular vectors (U)")
h2o_u = h2o.as_list(h2o.get_frame(fitH2O._model_json['output']['u_key']['name']), use_pandas=False)
h2o_u.pop(0)
r_u = [[-0.1716251, 0.096325710, 0.06515480, 0.15369551],
[-0.1891166, 0.173452566, -0.42665785, -0.17801438],
[-0.2155930, 0.078998111, 0.02063740, -0.28070784],
[-0.1390244, 0.059889811, 0.01392269, 0.01610418],
[-0.2067788, -0.009812026, -0.17633244, -0.21867425],
[-0.1558794, -0.064555293, -0.28288280, -0.11797419]]
print("R Left Singular Vectors: {0}".format(r_u))
print("H2O Left Singular Vectors: {0}".format(h2o_u))
for rl, hl in zip(r_u, h2o_u):
for r, h in zip(rl, hl): assert abs(abs(r) - abs(float(h))) < 1e-5, "H2O got {0}, but R got {1}".format(h, r)
if __name__ == "__main__":
pyunit_utils.standalone_test(svd_1_golden)
else:
svd_1_golden()
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
12963,
492,
3482,
199,
646,
984,
199,
1274,
14,
515,
14,
3176,
8,
17,
4589,
9707,
531,
199,
646,
394,
18,
79,
199,
504,
2295,
492,
1134,
3248,
63,
1208,
28154,
199,
318,
26937,
63,
17,
63,
19440,
837,
2378,
870,
480,
6295,
316,
19635,
1596,
3911,
83,
14,
4737,
666,
12594,
272,
601,
3911,
83,
40,
18,
47,
275,
394,
18,
79,
14,
5064,
63,
493,
8,
647,
3248,
63,
1208,
14,
6280,
480,
7241,
576,
15,
19247,
63,
396,
15,
1668,
1596,
3911,
83,
14,
4737,
2237,
339,
870,
480,
16051,
543,
14056,
36,
531,
272,
5542,
40,
18,
47,
275,
394,
18,
79,
14,
18675,
8,
88,
29,
285,
3911,
83,
40,
18,
47,
59,
16,
26,
20,
467,
26510,
29,
20,
12,
5793,
628,
9185,
401,
1390,
63,
13570,
29,
8269,
9,
339,
870,
480,
16051,
15823,
1338,
334,
36,
6320,
272,
394,
18,
79,
63,
68,
275,
5542,
40,
18,
47,
423,
1238,
63,
1001,
459,
1199,
2545,
68,
418,
272,
519,
63,
68,
275,
359,
1079,
1167,
14,
1690,
7491,
6576,
19518,
12,
413,
2635,
14,
29208,
16134,
24827,
1703,
12,
10416,
14,
1272,
969,
11452,
1216,
1555,
1477,
12,
6155,
14,
18264,
1229,
1272,
1081,
2466,
1138,
61,
272,
870,
480,
50,
428,
14257,
13468,
26,
469,
16,
5469,
908,
8,
82,
63,
68,
430,
272,
870,
480,
40,
18,
47,
428,
14257,
13468,
26,
469,
16,
5469,
908,
8,
72,
18,
79,
63,
68,
430,
272,
367,
519,
12,
394,
315,
3482,
8,
82,
63,
68,
12,
394,
18,
79,
63,
68,
304,
702,
2853,
8,
82,
446,
394,
9,
665,
413,
69,
13,
22,
12,
298,
40,
18,
47,
4788,
469,
16,
1386,
1325,
820,
4788,
469,
17,
5469,
908,
8,
72,
12,
519,
9,
339,
870,
480,
16051,
2451,
15823,
11102,
334,
54,
6320,
272,
394,
18,
79,
63,
86,
275,
394,
18,
79,
14,
305,
63,
513,
8,
72,
18,
79,
14,
362,
63,
1943,
8,
3269,
40,
18,
47,
423,
1238,
63,
1001,
459,
1199,
2545,
86,
63,
498,
2545,
354,
3815,
675,
63,
15718,
29,
797,
9,
272,
394,
18,
79,
63,
86,
14,
1935,
8,
16,
9,
272,
519,
63,
86,
275,
27291,
16,
14,
966,
9803,
12851,
12,
378,
14,
10882,
975,
14820,
12,
446,
16,
14,
21254,
16303,
1479,
12,
378,
14,
1020,
1822,
2720,
1276,
467,
1779,
5243,
16,
14,
2635,
1355,
1641,
1690,
12,
378,
14,
708,
1690,
2426,
1257,
12,
378,
14,
14045,
1229,
11010,
12,
446,
16,
14,
966,
1643,
11419,
24,
467,
1779,
5243,
16,
14,
1216,
1349,
1465,
1822,
12,
446,
16,
14,
3129,
16963,
15601,
12,
378,
14,
1046,
1887,
10393,
19,
12,
378,
14,
9461,
15128,
467,
1779,
5243,
16,
14,
709,
2534,
9880,
20,
12,
446,
16,
14,
4195,
821,
11829,
12,
446,
16,
14,
2905,
1082,
3172,
614,
12,
446,
16,
14,
1690,
2114,
996,
1349,
2677,
272,
870,
480,
50,
20854,
428,
14257,
812,
9177,
26,
469,
16,
5469,
908,
8,
82,
63,
86,
430,
272,
870,
480,
40,
18,
47,
20854,
428,
14257,
812,
9177,
26,
469,
16,
5469,
908,
8,
72,
18,
79,
63,
86,
430,
272,
367,
25717,
12,
27768,
315,
3482,
8,
82,
63,
86,
12,
394,
18,
79,
63,
86,
304,
267,
367,
519,
12,
394,
315,
3482,
8,
4308,
12,
27768,
304,
702,
2853,
8,
2101,
8,
82,
9,
446,
2853,
8,
1609,
8,
72,
1724,
665,
413,
69,
13,
21,
12,
298,
40,
18,
47,
4788,
469,
16,
1386,
1325,
820,
4788,
469,
17,
5469,
908,
8,
72,
12,
519,
9,
339,
870,
480,
16051,
3602,
15823,
11102,
334,
53,
6320,
272,
394,
18,
79,
63,
85,
275,
394,
18,
79,
14,
305,
63,
513,
8,
72,
18,
79,
14,
362,
63,
1943,
8,
3269,
40,
18,
47,
423,
1238,
63,
1001,
459,
1199,
2545,
85,
63,
498,
2545,
354,
3815,
675,
63,
15718,
29,
797,
9,
272,
394,
18,
79,
63,
85,
14,
1935,
8,
16,
9,
272,
519,
63,
85,
275,
27291,
16,
14,
1196,
975,
12140,
12,
378,
14,
9211,
708,
1641,
709,
12,
378,
14,
21254,
10478,
1257,
12,
378,
14,
1046,
11939,
23327,
467,
1779,
5243,
16,
14,
11370,
845,
1272,
12,
378,
14,
1196,
9908,
28317,
12,
446,
16,
14,
2260,
1272,
1641,
2426,
12,
446,
16,
14,
11175,
10752,
1703,
467,
1779,
5243,
16,
14,
7842,
1427,
1216,
12,
378,
14,
19226,
13830,
6673,
12,
378,
14,
996,
1690,
9880,
16,
12,
446,
16,
14,
18,
11369,
1780,
1349,
467,
1779,
5243,
16,
14,
7491,
996,
1602,
12,
378,
14,
27479,
1299,
2905,
845,
12,
378,
14,
614,
1355,
1081,
1876,
12,
378,
14,
10882,
6785,
1085,
467,
1779,
5243,
16,
14,
11089,
1138,
1299,
12,
446,
16,
14,
383,
2905,
713,
14842,
12,
446,
16,
14,
1196,
2766,
708,
1602,
12,
446,
16,
14,
9252,
10393,
821,
467,
1779,
5243,
16,
14,
11520,
1555,
2635,
12,
446,
16,
14,
17010,
15722,
16417,
12,
446,
16,
14,
1651,
10740,
18520,
12,
446,
16,
14,
845,
1965,
1342,
1167,
2677,
272,
870,
480,
50,
29350,
428,
14257,
812,
9177,
26,
469,
16,
5469,
908,
8,
82,
63,
85,
430,
272,
870,
480,
40,
18,
47,
29350,
428,
14257,
812,
9177,
26,
469,
16,
5469,
908,
8,
72,
18,
79,
63,
85,
430,
272,
367,
25717,
12,
27768,
315,
3482,
8,
82,
63,
85,
12,
394,
18,
79,
63,
85,
304,
267,
367,
519,
12,
394,
315,
3482,
8,
4308,
12,
27768,
304,
702,
2853,
8,
2101,
8,
82,
9,
446,
2853,
8,
1609,
8,
72,
1724,
665,
413,
69,
13,
21,
12,
298,
40,
18,
47,
4788,
469,
16,
1386,
1325,
820,
4788,
469,
17,
5469,
908,
8,
72,
12,
519,
9,
4388,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
1134,
3248,
63,
1208,
14,
20323,
63,
396,
8,
18675,
63,
17,
63,
19440,
9,
199,
2836,
26,
272,
26937,
63,
17,
63,
19440,
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
] |
[
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
12963,
492,
3482,
199,
646,
984,
199,
1274,
14,
515,
14,
3176,
8,
17,
4589,
9707,
531,
199,
646,
394,
18,
79,
199,
504,
2295,
492,
1134,
3248,
63,
1208,
28154,
199,
318,
26937,
63,
17,
63,
19440,
837,
2378,
870,
480,
6295,
316,
19635,
1596,
3911,
83,
14,
4737,
666,
12594,
272,
601,
3911,
83,
40,
18,
47,
275,
394,
18,
79,
14,
5064,
63,
493,
8,
647,
3248,
63,
1208,
14,
6280,
480,
7241,
576,
15,
19247,
63,
396,
15,
1668,
1596,
3911,
83,
14,
4737,
2237,
339,
870,
480,
16051,
543,
14056,
36,
531,
272,
5542,
40,
18,
47,
275,
394,
18,
79,
14,
18675,
8,
88,
29,
285,
3911,
83,
40,
18,
47,
59,
16,
26,
20,
467,
26510,
29,
20,
12,
5793,
628,
9185,
401,
1390,
63,
13570,
29,
8269,
9,
339,
870,
480,
16051,
15823,
1338,
334,
36,
6320,
272,
394,
18,
79,
63,
68,
275,
5542,
40,
18,
47,
423,
1238,
63,
1001,
459,
1199,
2545,
68,
418,
272,
519,
63,
68,
275,
359,
1079,
1167,
14,
1690,
7491,
6576,
19518,
12,
413,
2635,
14,
29208,
16134,
24827,
1703,
12,
10416,
14,
1272,
969,
11452,
1216,
1555,
1477,
12,
6155,
14,
18264,
1229,
1272,
1081,
2466,
1138,
61,
272,
870,
480,
50,
428,
14257,
13468,
26,
469,
16,
5469,
908,
8,
82,
63,
68,
430,
272,
870,
480,
40,
18,
47,
428,
14257,
13468,
26,
469,
16,
5469,
908,
8,
72,
18,
79,
63,
68,
430,
272,
367,
519,
12,
394,
315,
3482,
8,
82,
63,
68,
12,
394,
18,
79,
63,
68,
304,
702,
2853,
8,
82,
446,
394,
9,
665,
413,
69,
13,
22,
12,
298,
40,
18,
47,
4788,
469,
16,
1386,
1325,
820,
4788,
469,
17,
5469,
908,
8,
72,
12,
519,
9,
339,
870,
480,
16051,
2451,
15823,
11102,
334,
54,
6320,
272,
394,
18,
79,
63,
86,
275,
394,
18,
79,
14,
305,
63,
513,
8,
72,
18,
79,
14,
362,
63,
1943,
8,
3269,
40,
18,
47,
423,
1238,
63,
1001,
459,
1199,
2545,
86,
63,
498,
2545,
354,
3815,
675,
63,
15718,
29,
797,
9,
272,
394,
18,
79,
63,
86,
14,
1935,
8,
16,
9,
272,
519,
63,
86,
275,
27291,
16,
14,
966,
9803,
12851,
12,
378,
14,
10882,
975,
14820,
12,
446,
16,
14,
21254,
16303,
1479,
12,
378,
14,
1020,
1822,
2720,
1276,
467,
1779,
5243,
16,
14,
2635,
1355,
1641,
1690,
12,
378,
14,
708,
1690,
2426,
1257,
12,
378,
14,
14045,
1229,
11010,
12,
446,
16,
14,
966,
1643,
11419,
24,
467,
1779,
5243,
16,
14,
1216,
1349,
1465,
1822,
12,
446,
16,
14,
3129,
16963,
15601,
12,
378,
14,
1046,
1887,
10393,
19,
12,
378,
14,
9461,
15128,
467,
1779,
5243,
16,
14,
709,
2534,
9880,
20,
12,
446,
16,
14,
4195,
821,
11829,
12,
446,
16,
14,
2905,
1082,
3172,
614,
12,
446,
16,
14,
1690,
2114,
996,
1349,
2677,
272,
870,
480,
50,
20854,
428,
14257,
812,
9177,
26,
469,
16,
5469,
908,
8,
82,
63,
86,
430,
272,
870,
480,
40,
18,
47,
20854,
428,
14257,
812,
9177,
26,
469,
16,
5469,
908,
8,
72,
18,
79,
63,
86,
430,
272,
367,
25717,
12,
27768,
315,
3482,
8,
82,
63,
86,
12,
394,
18,
79,
63,
86,
304,
267,
367,
519,
12,
394,
315,
3482,
8,
4308,
12,
27768,
304,
702,
2853,
8,
2101,
8,
82,
9,
446,
2853,
8,
1609,
8,
72,
1724,
665,
413,
69,
13,
21,
12,
298,
40,
18,
47,
4788,
469,
16,
1386,
1325,
820,
4788,
469,
17,
5469,
908,
8,
72,
12,
519,
9,
339,
870,
480,
16051,
3602,
15823,
11102,
334,
53,
6320,
272,
394,
18,
79,
63,
85,
275,
394,
18,
79,
14,
305,
63,
513,
8,
72,
18,
79,
14,
362,
63,
1943,
8,
3269,
40,
18,
47,
423,
1238,
63,
1001,
459,
1199,
2545,
85,
63,
498,
2545,
354,
3815,
675,
63,
15718,
29,
797,
9,
272,
394,
18,
79,
63,
85,
14,
1935,
8,
16,
9,
272,
519,
63,
85,
275,
27291,
16,
14,
1196,
975,
12140,
12,
378,
14,
9211,
708,
1641,
709,
12,
378,
14,
21254,
10478,
1257,
12,
378,
14,
1046,
11939,
23327,
467,
1779,
5243,
16,
14,
11370,
845,
1272,
12,
378,
14,
1196,
9908,
28317,
12,
446,
16,
14,
2260,
1272,
1641,
2426,
12,
446,
16,
14,
11175,
10752,
1703,
467,
1779,
5243,
16,
14,
7842,
1427,
1216,
12,
378,
14,
19226,
13830,
6673,
12,
378,
14,
996,
1690,
9880,
16,
12,
446,
16,
14,
18,
11369,
1780,
1349,
467,
1779,
5243,
16,
14,
7491,
996,
1602,
12,
378,
14,
27479,
1299,
2905,
845,
12,
378,
14,
614,
1355,
1081,
1876,
12,
378,
14,
10882,
6785,
1085,
467,
1779,
5243,
16,
14,
11089,
1138,
1299,
12,
446,
16,
14,
383,
2905,
713,
14842,
12,
446,
16,
14,
1196,
2766,
708,
1602,
12,
446,
16,
14,
9252,
10393,
821,
467,
1779,
5243,
16,
14,
11520,
1555,
2635,
12,
446,
16,
14,
17010,
15722,
16417,
12,
446,
16,
14,
1651,
10740,
18520,
12,
446,
16,
14,
845,
1965,
1342,
1167,
2677,
272,
870,
480,
50,
29350,
428,
14257,
812,
9177,
26,
469,
16,
5469,
908,
8,
82,
63,
85,
430,
272,
870,
480,
40,
18,
47,
29350,
428,
14257,
812,
9177,
26,
469,
16,
5469,
908,
8,
72,
18,
79,
63,
85,
430,
272,
367,
25717,
12,
27768,
315,
3482,
8,
82,
63,
85,
12,
394,
18,
79,
63,
85,
304,
267,
367,
519,
12,
394,
315,
3482,
8,
4308,
12,
27768,
304,
702,
2853,
8,
2101,
8,
82,
9,
446,
2853,
8,
1609,
8,
72,
1724,
665,
413,
69,
13,
21,
12,
298,
40,
18,
47,
4788,
469,
16,
1386,
1325,
820,
4788,
469,
17,
5469,
908,
8,
72,
12,
519,
9,
4388,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
1134,
3248,
63,
1208,
14,
20323,
63,
396,
8,
18675,
63,
17,
63,
19440,
9,
199,
2836,
26,
272,
26937,
63,
17,
63,
19440,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
sophacles/invoke
|
tests/runner.py
|
1
|
8258
|
import sys
import os
from spec import eq_, skip, Spec, raises, ok_, trap
from invoke.runner import Runner, run
from invoke.exceptions import Failure
from _utils import support, reset_cwd
def _run(returns=None, **kwargs):
"""
Create a Runner w/ retval reflecting ``returns`` & call ``run(**kwargs)``.
"""
# Set up return value tuple for Runner.run
returns = returns or {}
returns.setdefault('exited', 0)
value = map(
lambda x: returns.get(x, None),
('stdout', 'stderr', 'exited', 'exception'),
)
class MockRunner(Runner):
def run(self, command, warn, hide):
return value
# Ensure top level run() uses that runner, provide dummy command.
kwargs['runner'] = MockRunner
return run("whatever", **kwargs)
class Run(Spec):
"run()"
def setup(self):
os.chdir(support)
self.both = "echo foo && ./err bar"
self.out = "echo foo"
self.err = "./err bar"
self.sub = "inv -c pty_output hide_%s"
def teardown(self):
reset_cwd()
class return_value:
def return_code_in_result(self):
"""
Result has .return_code (and .exited) containing exit code int
"""
r = run(self.out, hide='both')
eq_(r.return_code, 0)
eq_(r.exited, 0)
def nonzero_return_code_for_failures(self):
result = run("false", warn=True)
eq_(result.exited, 1)
result = run("goobypls", warn=True, hide='both')
eq_(result.exited, 127)
def stdout_attribute_contains_stdout(self):
eq_(run(self.out, hide='both').stdout, 'foo\n')
def stderr_attribute_contains_stderr(self):
eq_(run(self.err, hide='both').stderr, 'bar\n')
def ok_attr_indicates_success(self):
eq_(_run().ok, True)
eq_(_run(returns={'exited': 1}, warn=True).ok, False)
def failed_attr_indicates_failure(self):
eq_(_run().failed, False)
eq_(_run(returns={'exited': 1}, warn=True).failed, True)
def has_exception_attr(self):
eq_(_run().exception, None)
class failure_handling:
@raises(Failure)
def fast_failures(self):
run("false")
def run_acts_as_success_boolean(self):
ok_(not run("false", warn=True))
ok_(run("true"))
def non_one_return_codes_still_act_as_False(self):
ok_(not run("goobypls", warn=True, hide='both'))
def warn_kwarg_allows_continuing_past_failures(self):
eq_(run("false", warn=True).exited, 1)
def Failure_repr_includes_stderr(self):
try:
run("./err ohnoz && exit 1", hide='both')
assert false # Ensure failure to Failure fails
except Failure as f:
r = repr(f)
assert 'ohnoz' in r, "Sentinel 'ohnoz' not found in %r" % r
class output_controls:
@trap
def _hide_both(self, val):
run(self.both, hide=val)
eq_(sys.stdall.getvalue(), "")
def hide_both_hides_everything(self):
self._hide_both('both')
def hide_True_hides_everything(self):
self._hide_both(True)
@trap
def hide_out_only_hides_stdout(self):
run(self.both, hide='out')
eq_(sys.stdout.getvalue().strip(), "")
eq_(sys.stderr.getvalue().strip(), "bar")
@trap
def hide_err_only_hides_stderr(self):
run(self.both, hide='err')
eq_(sys.stdout.getvalue().strip(), "foo")
eq_(sys.stderr.getvalue().strip(), "")
@trap
def hide_accepts_stderr_alias_for_err(self):
run(self.both, hide='stderr')
eq_(sys.stdout.getvalue().strip(), "foo")
eq_(sys.stderr.getvalue().strip(), "")
@trap
def hide_accepts_stdout_alias_for_out(self):
run(self.both, hide='stdout')
eq_(sys.stdout.getvalue().strip(), "")
eq_(sys.stderr.getvalue().strip(), "bar")
def hide_both_hides_both_under_pty(self):
r = run(self.sub % 'both', hide='both')
eq_(r.stdout, "")
eq_(r.stderr, "")
def hide_out_hides_both_under_pty(self):
r = run(self.sub % 'out', hide='both')
eq_(r.stdout, "")
eq_(r.stderr, "")
def hide_err_has_no_effect_under_pty(self):
r = run(self.sub % 'err', hide='both')
eq_(r.stdout, "foo\r\nbar\r\n")
eq_(r.stderr, "")
@trap
def _no_hiding(self, val):
r = run(self.both, hide=val)
eq_(sys.stdout.getvalue().strip(), "foo")
eq_(sys.stderr.getvalue().strip(), "bar")
def hide_None_hides_nothing(self):
self._no_hiding(None)
def hide_False_hides_nothing(self):
self._no_hiding(False)
@raises(ValueError)
def hide_unknown_vals_raises_ValueError(self):
run("command", hide="what")
def hide_unknown_vals_mention_value_given_in_error(self):
value = "penguinmints"
try:
run("command", hide=value)
except ValueError as e:
msg = "Error from run(hide=xxx) did not tell user what the bad value was!"
msg += "\nException msg: %s" % e
ok_(value in str(e), msg)
else:
assert False, "run() did not raise ValueError for bad hide= value"
def hide_does_not_affect_capturing(self):
eq_(run(self.out, hide='both').stdout, 'foo\n')
class pseudo_terminals:
def return_value_indicates_whether_pty_was_used(self):
eq_(run("true").pty, False)
eq_(run("true", pty=True).pty, True)
def pty_defaults_to_off(self):
eq_(run("true").pty, False)
def complex_nesting_doesnt_break(self):
# GH issue 191
substr = " hello\t\t\nworld with spaces"
cmd = """ eval 'echo "{0}" ' """.format(substr)
# TODO: consider just mocking os.execv here (and in the other
# tests) though that feels like too much of a tautology / testing
# pexpect
expected = ' hello\t\t\r\nworld with spaces\r\n'
eq_(run(cmd, pty=True, hide='both').stdout, expected)
class command_echo:
@trap
def does_not_echo_commands_run_by_default(self):
run("echo hi")
eq_(sys.stdout.getvalue().strip(), "hi")
@trap
def when_echo_True_commands_echoed_in_bold(self):
run("echo hi", echo=True)
expected = "\033[1;37mecho hi\033[0m\nhi"
eq_(sys.stdout.getvalue().strip(), expected)
#
# Random edge/corner case junk
#
def non_stupid_OSErrors_get_captured(self):
# Somehow trigger an OSError saying "Input/output error" within
# pexpect.spawn().interact() & assert it is in result.exception
skip()
def KeyboardInterrupt_on_stdin_doesnt_flake(self):
# E.g. inv test => Ctrl-C halfway => shouldn't get buffer API errors
skip()
class funky_characters_in_stdout:
def basic_nonstandard_characters(self):
# Crummy "doesn't explode with decode errors" test
run("cat tree.out", hide='both')
def nonprinting_bytes(self):
# Seriously non-printing characters (i.e. non UTF8) also don't asplode
# load('funky').derp()
run("echo '\xff'", hide='both')
def nonprinting_bytes_pty(self):
# PTY use adds another utf-8 decode spot which can also fail.
run("echo '\xff'", pty=True, hide='both')
class Local_(Spec):
def setup(self):
os.chdir(support)
self.both = "echo foo && ./err bar"
def teardown(self):
reset_cwd()
def stdout_contains_both_streams_under_pty(self):
r = run(self.both, hide='both', pty=True)
eq_(r.stdout, 'foo\r\nbar\r\n')
def stderr_is_empty_under_pty(self):
r = run(self.both, hide='both', pty=True)
eq_(r.stderr, '')
|
bsd-2-clause
|
[
646,
984,
199,
646,
747,
199,
199,
504,
3158,
492,
3850,
3131,
3372,
12,
31511,
12,
6534,
12,
4112,
3131,
22514,
199,
199,
504,
12677,
14,
5933,
492,
3378,
1372,
12,
1255,
199,
504,
12677,
14,
3924,
492,
20367,
199,
199,
504,
485,
1208,
492,
2291,
12,
5305,
63,
6525,
421,
199,
318,
485,
1065,
8,
5808,
29,
403,
12,
1011,
958,
304,
272,
408,
272,
2790,
282,
3378,
1372,
336,
15,
9151,
16806,
316,
1124,
5808,
1040,
1253,
1240,
1124,
1065,
3682,
958,
20642,
272,
408,
272,
327,
2494,
1536,
372,
574,
2008,
367,
3378,
1372,
14,
1065,
272,
2529,
275,
2529,
503,
1052,
272,
2529,
14,
5486,
360,
32290,
297,
378,
9,
272,
574,
275,
2341,
8,
267,
2400,
671,
26,
2529,
14,
362,
8,
88,
12,
488,
395,
267,
661,
2703,
297,
283,
3083,
297,
283,
32290,
297,
283,
1971,
659,
272,
776,
272,
1021,
4420,
7446,
8,
7446,
304,
267,
347,
1255,
8,
277,
12,
1414,
12,
7987,
12,
13714,
304,
288,
372,
574,
272,
327,
7523,
2746,
2166,
1255,
342,
4440,
626,
7876,
12,
5647,
7283,
1414,
14,
272,
2074,
459,
5933,
418,
275,
4420,
7446,
272,
372,
1255,
480,
26517,
401,
1011,
958,
9,
421,
199,
533,
3378,
8,
5307,
304,
272,
298,
1065,
16493,
339,
347,
3272,
8,
277,
304,
267,
747,
14,
8563,
8,
4058,
9,
267,
291,
14,
10727,
275,
298,
7878,
3925,
10883,
16605,
1508,
4681,
2,
267,
291,
14,
548,
275,
298,
7878,
3925,
2,
267,
291,
14,
1508,
275,
26069,
1508,
4681,
2,
267,
291,
14,
954,
275,
298,
5350,
446,
67,
31237,
63,
1199,
13714,
4970,
83,
2,
339,
347,
17558,
8,
277,
304,
267,
5305,
63,
6525,
342,
339,
1021,
372,
63,
585,
26,
267,
347,
372,
63,
600,
63,
262,
63,
1099,
8,
277,
304,
288,
408,
288,
10695,
965,
1275,
1107,
63,
600,
334,
460,
1275,
32290,
9,
3035,
4458,
1233,
1109,
288,
408,
288,
519,
275,
1255,
8,
277,
14,
548,
12,
13714,
534,
10727,
358,
288,
3850,
2531,
82,
14,
1107,
63,
600,
12,
378,
9,
288,
3850,
2531,
82,
14,
32290,
12,
378,
9,
398,
347,
23338,
63,
1107,
63,
600,
63,
509,
63,
9968,
8,
277,
304,
288,
754,
275,
1255,
480,
3910,
401,
7987,
29,
549,
9,
288,
3850,
2531,
1099,
14,
32290,
12,
413,
9,
288,
754,
275,
1255,
480,
29546,
991,
80,
478,
401,
7987,
29,
549,
12,
13714,
534,
10727,
358,
288,
3850,
2531,
1099,
14,
32290,
12,
12792,
9,
398,
347,
3839,
63,
3215,
63,
6134,
63,
2703,
8,
277,
304,
288,
3850,
2531,
1065,
8,
277,
14,
548,
12,
13714,
534,
10727,
1959,
2703,
12,
283,
1421,
60,
78,
358,
398,
347,
4635,
63,
3215,
63,
6134,
63,
3083,
8,
277,
304,
288,
3850,
2531,
1065,
8,
277,
14,
1508,
12,
13714,
534,
10727,
1959,
3083,
12,
283,
1700,
60,
78,
358,
398,
347,
4112,
63,
962,
63,
3558,
1411,
83,
63,
3742,
8,
277,
304,
288,
3850,
63,
1547,
1065,
1252,
745,
12,
715,
9,
288,
3850,
63,
1547,
1065,
8,
5808,
3713,
32290,
356,
413,
1386,
7987,
29,
549,
680,
745,
12,
756,
9,
398,
347,
3405,
63,
962,
63,
3558,
1411,
83,
63,
5328,
8,
277,
304,
288,
3850,
63,
1547,
1065,
1252,
4892,
12,
756,
9,
288,
3850,
63,
1547,
1065,
8,
5808,
3713,
32290,
356,
413,
1386,
7987,
29,
549,
680,
4892,
12,
715,
9,
398,
347,
965,
63,
1971,
63,
962,
8,
277,
304,
288,
3850,
63,
1547,
1065,
1252,
1971,
12,
488,
9,
2378,
1021,
5988,
63,
22273,
26,
267,
768,
3536,
8,
6782,
9,
267,
347,
7377,
63,
9968,
8,
277,
304,
288,
1255,
480,
3910,
531,
398,
347,
1255,
63,
22282,
63,
305,
63,
3742,
63,
4871,
8,
277,
304,
288,
4112,
2531,
1397,
1255,
480,
3910,
401,
7987,
29,
549,
430,
288,
4112,
2531,
1065,
480,
2052,
2237,
398,
347,
2222,
63,
368,
63,
1107,
63,
6021,
63,
32310,
63,
2442,
63,
305,
63,
797,
8,
277,
304,
288,
4112,
2531,
1397,
1255,
480,
29546,
991,
80,
478,
401,
7987,
29,
549,
12,
13714,
534,
10727,
1333,
398,
347,
7987,
63,
12745,
63,
24077,
63,
12875,
23221,
63,
18597,
63,
9968,
8,
277,
304,
288,
3850,
2531,
1065,
480,
3910,
401,
7987,
29,
549,
680,
32290,
12,
413,
9,
398,
347,
20367,
63,
2722,
63,
9441,
63,
3083,
8,
277,
304,
288,
862,
26,
355,
1255,
28615,
1508,
312,
72,
889,
90,
10883,
4458,
413,
401,
13714,
534,
10727,
358,
355,
702,
3055,
327,
7523,
5988,
370,
20367,
6918,
288,
871,
20367,
465,
289,
26,
355,
519,
275,
4700,
8,
70,
9,
355,
702,
283,
19194,
889,
90,
7,
315,
519,
12,
298,
17367,
8395,
283,
19194,
889,
90,
7,
440,
1911,
315,
450,
82,
2,
450,
519,
339,
1021,
1072,
63,
13658,
26,
267,
768,
19510,
267,
347,
485,
8191,
63,
10727,
8,
277,
12,
1139,
304,
288,
1255,
8,
277,
14,
10727,
12,
13714,
29,
637,
9,
288,
3850,
2531,
1274,
14,
1516,
452,
14,
7150,
1062,
6899,
398,
347,
13714,
63,
10727,
63,
8191,
83,
63,
14287,
2127,
8,
277,
304,
288,
291,
423,
8191,
63,
10727,
360,
10727,
358,
398,
347,
13714,
63,
549,
63,
8191,
83,
63,
14287,
2127,
8,
277,
304,
288,
291,
423,
8191,
63,
10727,
8,
549,
9,
398,
768,
19510,
267,
347,
13714,
63,
548,
63,
2118,
63,
8191,
83,
63,
2703,
8,
277,
304,
288,
1255,
8,
277,
14,
10727,
12,
13714,
534,
548,
358,
288,
3850,
2531,
1274,
14,
2703,
14,
7150,
1252,
1913,
1062,
6899,
288,
3850,
2531,
1274,
14,
3083,
14,
7150,
1252,
1913,
1062,
298,
1700,
531,
398,
768,
19510,
267,
347,
13714,
63,
1508,
63,
2118,
63,
8191,
83,
63,
3083,
8,
277,
304,
288,
1255,
8,
277,
14,
10727,
12,
13714,
534,
1508,
358,
288,
3850,
2531,
1274,
14,
2703,
14,
7150,
1252,
1913,
1062,
298,
1421,
531,
288,
3850,
2531,
1274,
14,
3083,
14,
7150,
1252,
1913,
1062,
6899,
398,
768,
19510,
267,
347,
13714,
63,
27692,
63,
3083,
63,
3620,
63,
509,
63,
1508,
8,
277,
304,
288,
1255,
8,
277,
14,
10727,
12,
13714,
534,
3083,
358,
288,
3850
] |
[
984,
199,
646,
747,
199,
199,
504,
3158,
492,
3850,
3131,
3372,
12,
31511,
12,
6534,
12,
4112,
3131,
22514,
199,
199,
504,
12677,
14,
5933,
492,
3378,
1372,
12,
1255,
199,
504,
12677,
14,
3924,
492,
20367,
199,
199,
504,
485,
1208,
492,
2291,
12,
5305,
63,
6525,
421,
199,
318,
485,
1065,
8,
5808,
29,
403,
12,
1011,
958,
304,
272,
408,
272,
2790,
282,
3378,
1372,
336,
15,
9151,
16806,
316,
1124,
5808,
1040,
1253,
1240,
1124,
1065,
3682,
958,
20642,
272,
408,
272,
327,
2494,
1536,
372,
574,
2008,
367,
3378,
1372,
14,
1065,
272,
2529,
275,
2529,
503,
1052,
272,
2529,
14,
5486,
360,
32290,
297,
378,
9,
272,
574,
275,
2341,
8,
267,
2400,
671,
26,
2529,
14,
362,
8,
88,
12,
488,
395,
267,
661,
2703,
297,
283,
3083,
297,
283,
32290,
297,
283,
1971,
659,
272,
776,
272,
1021,
4420,
7446,
8,
7446,
304,
267,
347,
1255,
8,
277,
12,
1414,
12,
7987,
12,
13714,
304,
288,
372,
574,
272,
327,
7523,
2746,
2166,
1255,
342,
4440,
626,
7876,
12,
5647,
7283,
1414,
14,
272,
2074,
459,
5933,
418,
275,
4420,
7446,
272,
372,
1255,
480,
26517,
401,
1011,
958,
9,
421,
199,
533,
3378,
8,
5307,
304,
272,
298,
1065,
16493,
339,
347,
3272,
8,
277,
304,
267,
747,
14,
8563,
8,
4058,
9,
267,
291,
14,
10727,
275,
298,
7878,
3925,
10883,
16605,
1508,
4681,
2,
267,
291,
14,
548,
275,
298,
7878,
3925,
2,
267,
291,
14,
1508,
275,
26069,
1508,
4681,
2,
267,
291,
14,
954,
275,
298,
5350,
446,
67,
31237,
63,
1199,
13714,
4970,
83,
2,
339,
347,
17558,
8,
277,
304,
267,
5305,
63,
6525,
342,
339,
1021,
372,
63,
585,
26,
267,
347,
372,
63,
600,
63,
262,
63,
1099,
8,
277,
304,
288,
408,
288,
10695,
965,
1275,
1107,
63,
600,
334,
460,
1275,
32290,
9,
3035,
4458,
1233,
1109,
288,
408,
288,
519,
275,
1255,
8,
277,
14,
548,
12,
13714,
534,
10727,
358,
288,
3850,
2531,
82,
14,
1107,
63,
600,
12,
378,
9,
288,
3850,
2531,
82,
14,
32290,
12,
378,
9,
398,
347,
23338,
63,
1107,
63,
600,
63,
509,
63,
9968,
8,
277,
304,
288,
754,
275,
1255,
480,
3910,
401,
7987,
29,
549,
9,
288,
3850,
2531,
1099,
14,
32290,
12,
413,
9,
288,
754,
275,
1255,
480,
29546,
991,
80,
478,
401,
7987,
29,
549,
12,
13714,
534,
10727,
358,
288,
3850,
2531,
1099,
14,
32290,
12,
12792,
9,
398,
347,
3839,
63,
3215,
63,
6134,
63,
2703,
8,
277,
304,
288,
3850,
2531,
1065,
8,
277,
14,
548,
12,
13714,
534,
10727,
1959,
2703,
12,
283,
1421,
60,
78,
358,
398,
347,
4635,
63,
3215,
63,
6134,
63,
3083,
8,
277,
304,
288,
3850,
2531,
1065,
8,
277,
14,
1508,
12,
13714,
534,
10727,
1959,
3083,
12,
283,
1700,
60,
78,
358,
398,
347,
4112,
63,
962,
63,
3558,
1411,
83,
63,
3742,
8,
277,
304,
288,
3850,
63,
1547,
1065,
1252,
745,
12,
715,
9,
288,
3850,
63,
1547,
1065,
8,
5808,
3713,
32290,
356,
413,
1386,
7987,
29,
549,
680,
745,
12,
756,
9,
398,
347,
3405,
63,
962,
63,
3558,
1411,
83,
63,
5328,
8,
277,
304,
288,
3850,
63,
1547,
1065,
1252,
4892,
12,
756,
9,
288,
3850,
63,
1547,
1065,
8,
5808,
3713,
32290,
356,
413,
1386,
7987,
29,
549,
680,
4892,
12,
715,
9,
398,
347,
965,
63,
1971,
63,
962,
8,
277,
304,
288,
3850,
63,
1547,
1065,
1252,
1971,
12,
488,
9,
2378,
1021,
5988,
63,
22273,
26,
267,
768,
3536,
8,
6782,
9,
267,
347,
7377,
63,
9968,
8,
277,
304,
288,
1255,
480,
3910,
531,
398,
347,
1255,
63,
22282,
63,
305,
63,
3742,
63,
4871,
8,
277,
304,
288,
4112,
2531,
1397,
1255,
480,
3910,
401,
7987,
29,
549,
430,
288,
4112,
2531,
1065,
480,
2052,
2237,
398,
347,
2222,
63,
368,
63,
1107,
63,
6021,
63,
32310,
63,
2442,
63,
305,
63,
797,
8,
277,
304,
288,
4112,
2531,
1397,
1255,
480,
29546,
991,
80,
478,
401,
7987,
29,
549,
12,
13714,
534,
10727,
1333,
398,
347,
7987,
63,
12745,
63,
24077,
63,
12875,
23221,
63,
18597,
63,
9968,
8,
277,
304,
288,
3850,
2531,
1065,
480,
3910,
401,
7987,
29,
549,
680,
32290,
12,
413,
9,
398,
347,
20367,
63,
2722,
63,
9441,
63,
3083,
8,
277,
304,
288,
862,
26,
355,
1255,
28615,
1508,
312,
72,
889,
90,
10883,
4458,
413,
401,
13714,
534,
10727,
358,
355,
702,
3055,
327,
7523,
5988,
370,
20367,
6918,
288,
871,
20367,
465,
289,
26,
355,
519,
275,
4700,
8,
70,
9,
355,
702,
283,
19194,
889,
90,
7,
315,
519,
12,
298,
17367,
8395,
283,
19194,
889,
90,
7,
440,
1911,
315,
450,
82,
2,
450,
519,
339,
1021,
1072,
63,
13658,
26,
267,
768,
19510,
267,
347,
485,
8191,
63,
10727,
8,
277,
12,
1139,
304,
288,
1255,
8,
277,
14,
10727,
12,
13714,
29,
637,
9,
288,
3850,
2531,
1274,
14,
1516,
452,
14,
7150,
1062,
6899,
398,
347,
13714,
63,
10727,
63,
8191,
83,
63,
14287,
2127,
8,
277,
304,
288,
291,
423,
8191,
63,
10727,
360,
10727,
358,
398,
347,
13714,
63,
549,
63,
8191,
83,
63,
14287,
2127,
8,
277,
304,
288,
291,
423,
8191,
63,
10727,
8,
549,
9,
398,
768,
19510,
267,
347,
13714,
63,
548,
63,
2118,
63,
8191,
83,
63,
2703,
8,
277,
304,
288,
1255,
8,
277,
14,
10727,
12,
13714,
534,
548,
358,
288,
3850,
2531,
1274,
14,
2703,
14,
7150,
1252,
1913,
1062,
6899,
288,
3850,
2531,
1274,
14,
3083,
14,
7150,
1252,
1913,
1062,
298,
1700,
531,
398,
768,
19510,
267,
347,
13714,
63,
1508,
63,
2118,
63,
8191,
83,
63,
3083,
8,
277,
304,
288,
1255,
8,
277,
14,
10727,
12,
13714,
534,
1508,
358,
288,
3850,
2531,
1274,
14,
2703,
14,
7150,
1252,
1913,
1062,
298,
1421,
531,
288,
3850,
2531,
1274,
14,
3083,
14,
7150,
1252,
1913,
1062,
6899,
398,
768,
19510,
267,
347,
13714,
63,
27692,
63,
3083,
63,
3620,
63,
509,
63,
1508,
8,
277,
304,
288,
1255,
8,
277,
14,
10727,
12,
13714,
534,
3083,
358,
288,
3850,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ArtsiomCh/tensorflow
|
tensorflow/contrib/receptive_field/python/util/graph_compute_order.py
|
25
|
2454
|
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Library to compute order of computations in a graph.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
class GraphDefHelper(object):
"""Helper class to collect node names and definitions.
Example:
b = GraphDefHelper(graph_def)
# Prints node that produces given output.
print b.output_of['conv/foo/bar']
"""
def __init__(self, gd):
self.output_of = {}
for each in gd.node:
self.output_of[each.name] = each
# pylint: disable=invalid-name
_NodeEntry = collections.namedtuple('NodeEntry', field_names=['order', 'node'])
def _get_computed_nodes(g, output, seen):
"""Traverses the graph in topological order.
Args:
g: GraphDefHelper object.
output: current node.
seen: map of nodes we've already traversed.
Returns:
order in topological sort for 'output'.
"""
if output in seen:
return seen[output].order
node_def = g.output_of.get(output, None)
if node_def is None:
seen[output] = _NodeEntry(0, None)
return 0
r = 0
for each in node_def.input:
# Parses name of input node.
if each.startswith('^'):
each = each[1:]
each = each.split(':')[0]
# Recursively computes ordering.
new_v = _get_computed_nodes(g, each, seen)
r = max(r, new_v + 1)
seen[output] = _NodeEntry(r, node_def)
return seen[output].order
def get_compute_order(graph_def):
"""Computes order of computation for a given graph.
Args:
graph_def: GraphDef object.
Returns:
map: name -> {order, node}
"""
helper = GraphDefHelper(graph_def)
seen = collections.defaultdict(_NodeEntry)
for each in graph_def.node:
_get_computed_nodes(helper, each.name, seen)
return seen
|
apache-2.0
|
[
3,
1898,
9708,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
7424,
370,
4526,
1865,
402,
28319,
1298,
315,
282,
3343,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
5055,
421,
199,
533,
11513,
6172,
4433,
8,
785,
304,
523,
408,
4433,
1021,
370,
8775,
1031,
1561,
436,
10269,
14,
819,
5679,
26,
272,
330,
275,
11513,
6172,
4433,
8,
2180,
63,
318,
9,
272,
327,
9101,
83,
1031,
626,
16904,
1627,
1072,
14,
272,
870,
330,
14,
1199,
63,
1618,
459,
5598,
15,
1421,
15,
1700,
418,
523,
408,
819,
347,
636,
826,
721,
277,
12,
24714,
304,
272,
291,
14,
1199,
63,
1618,
275,
1052,
272,
367,
1924,
315,
24714,
14,
932,
26,
489,
291,
14,
1199,
63,
1618,
59,
10885,
14,
354,
61,
275,
1924,
421,
199,
3,
4287,
26,
3507,
29,
3197,
13,
354,
199,
63,
1716,
3900,
275,
5055,
14,
18921,
360,
1716,
3900,
297,
901,
63,
1247,
2968,
1648,
297,
283,
932,
1105,
421,
199,
318,
485,
362,
63,
14378,
63,
2415,
8,
71,
12,
1072,
12,
6775,
304,
523,
408,
2437,
422,
874,
314,
3343,
315,
11111,
7954,
1865,
14,
819,
3033,
26,
272,
486,
26,
11513,
6172,
4433,
909,
14,
272,
1072,
26,
1453,
1031,
14,
272,
6775,
26,
2341,
402,
3380,
781,
9064,
2575,
1468,
7460,
14,
523,
1803,
26,
272,
1865,
315,
11111,
7954,
4069,
367,
283,
1199,
1370,
523,
408,
523,
340,
1072,
315,
6775,
26,
272,
372,
6775,
59,
1199,
1055,
1648,
523,
1031,
63,
318,
275,
486,
14,
1199,
63,
1618,
14,
362,
8,
1199,
12,
488,
9,
523,
340,
1031,
63,
318,
365,
488,
26,
272,
6775,
59,
1199,
61,
275,
485,
1716,
3900,
8,
16,
12,
488,
9,
272,
372,
378,
819,
519,
275,
378,
523,
367,
1924,
315,
1031,
63,
318,
14,
1210,
26,
272,
327,
29968,
536,
402,
1324,
1031,
14,
272,
340,
1924,
14,
2460,
9097,
735,
489,
1924,
275,
1924,
59,
17,
2938,
272,
1924,
275,
1924,
14,
1294,
24050,
16,
61,
272,
327,
18306,
9840,
21445,
7794,
14,
272,
892,
63,
86,
275,
485,
362,
63,
14378,
63,
2415,
8,
71,
12,
1924,
12,
6775,
9,
272,
519,
275,
1390,
8,
82,
12,
892,
63,
86,
435,
413,
9,
819,
6775,
59,
1199,
61,
275,
485,
1716,
3900,
8,
82,
12,
1031,
63,
318,
9,
819,
372,
6775,
59,
1199,
1055,
1648,
421,
199,
318,
664,
63,
3357,
63,
1648,
8,
2180,
63,
318,
304,
523,
408,
22594,
1865,
402,
14009,
367,
282,
1627,
3343,
14,
819,
3033,
26,
272,
3343,
63,
318,
26,
11513,
6172,
909,
14,
523,
1803,
26,
272,
2341,
26,
536,
1035,
469,
1648,
12,
1031,
93,
523,
408,
523,
5922,
275,
11513,
6172,
4433,
8,
2180,
63,
318,
9,
523,
6775,
275,
5055,
14,
21501,
1547,
1716,
3900,
9,
523,
367,
1924,
315,
3343,
63,
318,
14,
932,
26,
272,
485,
362,
63,
14378,
63,
2415,
8,
3676,
12,
1924,
14,
354,
12,
6775,
9,
523,
372,
6775,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
9708,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
7424,
370,
4526,
1865,
402,
28319,
1298,
315,
282,
3343,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
5055,
421,
199,
533,
11513,
6172,
4433,
8,
785,
304,
523,
408,
4433,
1021,
370,
8775,
1031,
1561,
436,
10269,
14,
819,
5679,
26,
272,
330,
275,
11513,
6172,
4433,
8,
2180,
63,
318,
9,
272,
327,
9101,
83,
1031,
626,
16904,
1627,
1072,
14,
272,
870,
330,
14,
1199,
63,
1618,
459,
5598,
15,
1421,
15,
1700,
418,
523,
408,
819,
347,
636,
826,
721,
277,
12,
24714,
304,
272,
291,
14,
1199,
63,
1618,
275,
1052,
272,
367,
1924,
315,
24714,
14,
932,
26,
489,
291,
14,
1199,
63,
1618,
59,
10885,
14,
354,
61,
275,
1924,
421,
199,
3,
4287,
26,
3507,
29,
3197,
13,
354,
199,
63,
1716,
3900,
275,
5055,
14,
18921,
360,
1716,
3900,
297,
901,
63,
1247,
2968,
1648,
297,
283,
932,
1105,
421,
199,
318,
485,
362,
63,
14378,
63,
2415,
8,
71,
12,
1072,
12,
6775,
304,
523,
408,
2437,
422,
874,
314,
3343,
315,
11111,
7954,
1865,
14,
819,
3033,
26,
272,
486,
26,
11513,
6172,
4433,
909,
14,
272,
1072,
26,
1453,
1031,
14,
272,
6775,
26,
2341,
402,
3380,
781,
9064,
2575,
1468,
7460,
14,
523,
1803,
26,
272,
1865,
315,
11111,
7954,
4069,
367,
283,
1199,
1370,
523,
408,
523,
340,
1072,
315,
6775,
26,
272,
372,
6775,
59,
1199,
1055,
1648,
523,
1031,
63,
318,
275,
486,
14,
1199,
63,
1618,
14,
362,
8,
1199,
12,
488,
9,
523,
340,
1031,
63,
318,
365,
488,
26,
272,
6775,
59,
1199,
61,
275,
485,
1716,
3900,
8,
16,
12,
488,
9,
272,
372,
378,
819,
519,
275,
378,
523,
367,
1924,
315,
1031,
63,
318,
14,
1210,
26,
272,
327,
29968,
536,
402,
1324,
1031,
14,
272,
340,
1924,
14,
2460,
9097,
735,
489,
1924,
275,
1924,
59,
17,
2938,
272,
1924,
275,
1924,
14,
1294,
24050,
16,
61,
272,
327,
18306,
9840,
21445,
7794,
14,
272,
892,
63,
86,
275,
485,
362,
63,
14378,
63,
2415,
8,
71,
12,
1924,
12,
6775,
9,
272,
519,
275,
1390,
8,
82,
12,
892,
63,
86,
435,
413,
9,
819,
6775,
59,
1199,
61,
275,
485,
1716,
3900,
8,
82,
12,
1031,
63,
318,
9,
819,
372,
6775,
59,
1199,
1055,
1648,
421,
199,
318,
664,
63,
3357,
63,
1648,
8,
2180,
63,
318,
304,
523,
408,
22594,
1865,
402,
14009,
367,
282,
1627,
3343,
14,
819,
3033,
26,
272,
3343,
63,
318,
26,
11513,
6172,
909,
14,
523,
1803,
26,
272,
2341,
26,
536,
1035,
469,
1648,
12,
1031,
93,
523,
408,
523,
5922,
275,
11513,
6172,
4433,
8,
2180,
63,
318,
9,
523,
6775,
275,
5055,
14,
21501,
1547,
1716,
3900,
9,
523,
367,
1924,
315,
3343,
63,
318,
14,
932,
26,
272,
485,
362,
63,
14378,
63,
2415,
8,
3676,
12,
1924,
14,
354,
12,
6775,
9,
523,
372,
6775,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
Hybrid-Cloud/conveyor
|
conveyor/conveyorheat/common/service_utils.py
|
15
|
2011
|
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_utils import timeutils
SERVICE_KEYS = (
SERVICE_ID,
SERVICE_HOST,
SERVICE_HOSTNAME,
SERVICE_BINARY,
SERVICE_TOPIC,
SERVICE_ENGINE_ID,
SERVICE_REPORT_INTERVAL,
SERVICE_CREATED_AT,
SERVICE_UPDATED_AT,
SERVICE_DELETED_AT,
SERVICE_STATUS
) = (
'id',
'host',
'hostname',
'binary',
'topic',
'engine_id',
'report_interval',
'created_at',
'updated_at',
'deleted_at',
'status'
)
def format_service(service):
if service is None:
return
status = 'down'
if service.updated_at is not None:
if ((timeutils.utcnow() - service.updated_at).total_seconds()
<= service.report_interval):
status = 'up'
else:
if ((timeutils.utcnow() - service.created_at).total_seconds()
<= service.report_interval):
status = 'up'
result = {
SERVICE_ID: service.id,
SERVICE_BINARY: service.binary,
SERVICE_ENGINE_ID: service.engine_id,
SERVICE_HOST: service.host,
SERVICE_HOSTNAME: service.hostname,
SERVICE_TOPIC: service.topic,
SERVICE_REPORT_INTERVAL: service.report_interval,
SERVICE_CREATED_AT: service.created_at,
SERVICE_UPDATED_AT: service.updated_at,
SERVICE_DELETED_AT: service.deleted_at,
SERVICE_STATUS: status
}
return result
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6927,
27849,
13,
29471,
15290,
15878,
12,
491,
14,
48,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
11258,
63,
1208,
492,
23011,
199,
199,
10486,
63,
17434,
275,
334,
272,
16655,
63,
998,
12,
272,
16655,
63,
5449,
12,
272,
16655,
63,
22647,
12,
272,
16655,
63,
13246,
12,
272,
16655,
63,
23740,
12,
272,
16655,
63,
15956,
63,
998,
12,
272,
16655,
63,
17356,
63,
17359,
12,
272,
16655,
63,
26561,
63,
619,
12,
272,
16655,
63,
23612,
1149,
63,
619,
12,
272,
16655,
63,
27408,
63,
619,
12,
272,
16655,
63,
6305,
199,
9,
275,
334,
272,
283,
344,
297,
272,
283,
1102,
297,
272,
283,
4269,
297,
272,
283,
3008,
297,
272,
283,
5746,
297,
272,
283,
3908,
63,
344,
297,
272,
283,
3070,
63,
4284,
297,
272,
283,
3966,
63,
292,
297,
272,
283,
5334,
63,
292,
297,
272,
283,
6062,
63,
292,
297,
272,
283,
1205,
7,
199,
9,
421,
199,
318,
1475,
63,
1364,
8,
1364,
304,
272,
340,
2435,
365,
488,
26,
267,
372,
339,
2004,
275,
283,
2110,
7,
272,
340,
2435,
14,
5334,
63,
292,
365,
440,
488,
26,
267,
340,
3666,
521,
1208,
14,
10779,
342,
446,
2435,
14,
5334,
63,
292,
680,
2923,
63,
4515,
342,
355,
2695,
2435,
14,
3070,
63,
4284,
304,
288,
2004,
275,
283,
384,
7,
272,
587,
26,
267,
340,
3666,
521,
1208,
14,
10779,
342,
446,
2435,
14,
3966,
63,
292,
680,
2923,
63,
4515,
342,
355,
2695,
2435,
14,
3070,
63,
4284,
304,
288,
2004,
275,
283,
384,
7,
339,
754,
275,
469,
267,
16655,
63,
998,
26,
2435,
14,
344,
12,
267,
16655,
63,
13246,
26,
2435,
14,
3008,
12,
267,
16655,
63,
15956,
63,
998,
26,
2435,
14,
3908,
63,
344,
12,
267,
16655,
63,
5449,
26,
2435,
14,
1102,
12,
267,
16655,
63,
22647,
26,
2435,
14,
4269,
12,
267,
16655,
63,
23740,
26,
2435,
14,
5746,
12,
267,
16655,
63,
17356,
63,
17359,
26,
2435,
14,
3070,
63,
4284,
12,
267,
16655,
63,
26561,
63,
619,
26,
2435,
14,
3966,
63,
292,
12,
267,
16655,
63,
23612,
1149,
63,
619,
26,
2435,
14,
5334,
63,
292,
12,
267,
16655,
63,
27408,
63,
619,
26,
2435,
14,
6062,
63,
292,
12,
267,
16655,
63,
6305,
26,
2004,
272,
789,
272,
372,
754,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6927,
27849,
13,
29471,
15290,
15878,
12,
491,
14,
48,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
11258,
63,
1208,
492,
23011,
199,
199,
10486,
63,
17434,
275,
334,
272,
16655,
63,
998,
12,
272,
16655,
63,
5449,
12,
272,
16655,
63,
22647,
12,
272,
16655,
63,
13246,
12,
272,
16655,
63,
23740,
12,
272,
16655,
63,
15956,
63,
998,
12,
272,
16655,
63,
17356,
63,
17359,
12,
272,
16655,
63,
26561,
63,
619,
12,
272,
16655,
63,
23612,
1149,
63,
619,
12,
272,
16655,
63,
27408,
63,
619,
12,
272,
16655,
63,
6305,
199,
9,
275,
334,
272,
283,
344,
297,
272,
283,
1102,
297,
272,
283,
4269,
297,
272,
283,
3008,
297,
272,
283,
5746,
297,
272,
283,
3908,
63,
344,
297,
272,
283,
3070,
63,
4284,
297,
272,
283,
3966,
63,
292,
297,
272,
283,
5334,
63,
292,
297,
272,
283,
6062,
63,
292,
297,
272,
283,
1205,
7,
199,
9,
421,
199,
318,
1475,
63,
1364,
8,
1364,
304,
272,
340,
2435,
365,
488,
26,
267,
372,
339,
2004,
275,
283,
2110,
7,
272,
340,
2435,
14,
5334,
63,
292,
365,
440,
488,
26,
267,
340,
3666,
521,
1208,
14,
10779,
342,
446,
2435,
14,
5334,
63,
292,
680,
2923,
63,
4515,
342,
355,
2695,
2435,
14,
3070,
63,
4284,
304,
288,
2004,
275,
283,
384,
7,
272,
587,
26,
267,
340,
3666,
521,
1208,
14,
10779,
342,
446,
2435,
14,
3966,
63,
292,
680,
2923,
63,
4515,
342,
355,
2695,
2435,
14,
3070,
63,
4284,
304,
288,
2004,
275,
283,
384,
7,
339,
754,
275,
469,
267,
16655,
63,
998,
26,
2435,
14,
344,
12,
267,
16655,
63,
13246,
26,
2435,
14,
3008,
12,
267,
16655,
63,
15956,
63,
998,
26,
2435,
14,
3908,
63,
344,
12,
267,
16655,
63,
5449,
26,
2435,
14,
1102,
12,
267,
16655,
63,
22647,
26,
2435,
14,
4269,
12,
267,
16655,
63,
23740,
26,
2435,
14,
5746,
12,
267,
16655,
63,
17356,
63,
17359,
26,
2435,
14,
3070,
63,
4284,
12,
267,
16655,
63,
26561,
63,
619,
26,
2435,
14,
3966,
63,
292,
12,
267,
16655,
63,
23612,
1149,
63,
619,
26,
2435,
14,
5334,
63,
292,
12,
267,
16655,
63,
27408,
63,
619,
26,
2435,
14,
6062,
63,
292,
12,
267,
16655,
63,
6305,
26,
2004,
272,
789,
272,
372,
754,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
hpe-storage/python-lefthandclient
|
hpelefthandclient/http.py
|
2
|
13485
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# (c) Copyright 2013-2015 Hewlett Packard Enterprise Development LP
# 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.
"""
HPELeftHand HTTP Client
.. module: http
:Author: Walter A. Boring IV
:Description: This is the HTTP Client that is used to make the actual calls.
It includes the authentication that knows the cookie name for LH.
"""
import logging
import requests
import time
try:
import json
except ImportError:
import simplejson as json
from hpelefthandclient import exceptions
class HTTPJSONRESTClient(object):
"""
An HTTP REST Client that sends and recieves JSON data as the body of the
HTTP request.
:param api_url: The url to the LH OS REST service
ie. https://<hostname or IP>:<port>/lhos
:type api_url: str
:param secure: Validate SSL cert? Default will not validate
:type secure: bool
:param http_log_debug: Turns on http log debugging. Default will not log
:type http_log_debug: bool
:param suppress_ssl_warnings: Suppresses log warning messages if True.
Default will not suppress warnings.
:type suppress_ssl_warnings: bool
"""
USER_AGENT = 'python-hpelefthandclient'
SESSION_COOKIE_NAME = 'Authorization'
#API_VERSION = 'X-API-Version'
#CHRP_VERSION = 'X_HPE-CHRP-Client-Version'
http_log_debug = False
_logger = logging.getLogger(__name__)
def __init__(self, api_url, secure=False, http_log_debug=False,
suppress_ssl_warnings=False, timeout=None):
if suppress_ssl_warnings:
requests.packages.urllib3.disable_warnings()
self.session_key = None
#should be http://<Server:Port>/lhos
self.set_url(api_url)
self.set_debug_flag(http_log_debug)
self.times = [] # [("item", starttime, endtime), ...]
self.secure = secure
self.timeout = timeout
def set_url(self, api_url):
#should be http://<Server:Port>/lhos
self.api_url = api_url.rstrip('/')
def set_debug_flag(self, flag):
"""
This turns on/off http request/response debugging output to console
:param flag: Set to True to enable debugging output
:type flag: bool
"""
if not HTTPJSONRESTClient.http_log_debug and flag:
ch = logging.StreamHandler()
HTTPJSONRESTClient._logger.setLevel(logging.DEBUG)
HTTPJSONRESTClient._logger.addHandler(ch)
HTTPJSONRESTClient.http_log_debug = True
def authenticate(self, user, password, optional=None):
"""
This tries to create an authenticated session with the LH OS server
:param user: The username
:type user: str
:param password: The password
:type password: str
"""
#this prevens re-auth attempt if auth fails
self.auth_try = 1
self.session_key = None
info = {'user': user, 'password': password}
self._auth_optional = None
if optional:
self._auth_optional = optional
info.update(optional)
resp, body = self.post('/credentials', body=info)
if body and 'authToken' in body:
self.session_key = body['authToken']
self.auth_try = 0
self.user = user
self.password = password
return resp
def _reauth(self):
self.authenticate(self.user, self.password, self._auth_optional)
def unauthenticate(self):
"""
This clears the authenticated session with the LH server. It logs out.
"""
#delete the session on the LH
self.delete('/credentials/%s' % self.session_key)
self.session_key = None
def get_timings(self):
"""
Ths gives an array of the request timings since last reset_timings call
"""
return self.times
def reset_timings(self):
"""
This resets the request/response timings array
"""
self.times = []
def _http_log_req(self, args, kwargs):
if not self.http_log_debug:
return
string_parts = ['curl -i']
for element in args:
if element in ('GET', 'POST'):
string_parts.append(' -X %s' % element)
else:
string_parts.append(' %s' % element)
for element in kwargs['headers']:
header = ' -H "%s: %s"' % (element, kwargs['headers'][element])
string_parts.append(header)
HTTPJSONRESTClient._logger.debug("\nREQ: %s\n" % "".join(string_parts))
if 'body' in kwargs:
HTTPJSONRESTClient._logger.debug("REQ BODY: %s\n"
% (kwargs['body']))
def _http_log_resp(self, resp, body):
if not self.http_log_debug:
return
HTTPJSONRESTClient._logger.debug("RESP:%s\n",
str(resp).replace('\',', '\'\n'))
HTTPJSONRESTClient._logger.debug("RESP BODY:%s\n", body)
def request(self, *args, **kwargs):
"""
This makes an HTTP Request to the LH server. You should use get, post,
delete instead.
"""
if self.session_key and self.auth_try != 1:
kwargs.setdefault('headers',
{})[self.SESSION_COOKIE_NAME] = self.session_key
kwargs.setdefault('headers', kwargs.get('headers', {}))
kwargs['headers']['User-Agent'] = self.USER_AGENT
kwargs['headers']['Accept'] = 'application/json'
if 'body' in kwargs:
kwargs['headers']['Content-Type'] = 'application/json'
kwargs['body'] = json.dumps(kwargs['body'])
payload = kwargs['body']
else:
payload = None
# args[0] contains the URL, args[1] contains the HTTP verb/method
http_url = args[0]
http_method = args[1]
self._http_log_req(args, kwargs)
try:
if self.timeout:
r = requests.request(http_method, http_url, data=payload,
headers=kwargs['headers'],
verify=self.secure,
timeout=self.timeout)
else:
r = requests.request(http_method, http_url, data=payload,
headers=kwargs['headers'],
verify=self.secure)
except requests.exceptions.SSLError as err:
HTTPJSONRESTClient._logger.error("SSL certificate verification"
" failed: (%s). You must have a"
" valid SSL certificate or"
" disable SSL verification.", err)
raise exceptions.SSLCertFailed("SSL Certificate Verification"
" Failed")
except requests.exceptions.RequestException as err:
raise exceptions.RequestException("Request Exception: %s" % err)
except requests.exceptions.ConnectionError as err:
raise exceptions.ConnectionError("Connection Error: %s" % err)
except requests.exceptions.HTTPError as err:
raise exceptions.HTTPError("HTTP Error: %s" % err)
except requests.exceptions.URLRequired as err:
raise exceptions.URLRequired("URL Required: %s" % err)
except requests.exceptions.TooManyRedirects as err:
raise exceptions.TooManyRedirects("Too Many Redirects: %s" % err)
except requests.exceptions.Timeout as err:
raise exceptions.Timeout("Timeout: %s" % err)
resp = r.headers
body = r.text
if isinstance(body, bytes):
body = body.decode('utf-8')
# resp['status'], status['content-location'], and resp.status need to
# be manually set as Python Requests doesnt provide them automatically
resp['status'] = str(r.status_code)
resp.status = r.status_code
if 'location' not in resp:
resp['content-location'] = r.url
r.close()
self._http_log_resp(resp, body)
# Try and conver the body response to an object
# This assumes the body of the reply is JSON
if body:
try:
body = json.loads(body)
except ValueError:
#pprint.pprint("failed to decode json\n")
pass
else:
body = None
if resp.status >= 400:
if body and 'message' in body:
body['desc'] = body['message']
raise exceptions.from_response(resp, body)
return resp, body
def _time_request(self, url, method, **kwargs):
start_time = time.time()
resp, body = self.request(url, method, **kwargs)
self.times.append(("%s %s" % (method, url),
start_time, time.time()))
return resp, body
def _do_reauth(self, url, method, ex, **kwargs):
print("_do_reauth called")
try:
if self.auth_try != 1:
self._reauth()
resp, body = self._time_request(self.api_url + url,
method, **kwargs)
return resp, body
else:
raise ex
except exceptions.HTTPUnauthorized:
raise ex
def _cs_request(self, url, method, **kwargs):
# Perform the request once. If we get a 401 back then it
# might be because the auth token expired, so try to
# re-authenticate and try again. If it still fails, bail.
try:
resp, body = self._time_request(self.api_url + url, method,
**kwargs)
return resp, body
except exceptions.HTTPUnauthorized as ex:
resp, body = self._do_reauth(url, method, ex, **kwargs)
return resp, body
except exceptions.HTTPForbidden as ex:
resp, body = self._do_reauth(url, method, ex, **kwargs)
return resp, body
def get(self, url, **kwargs):
"""
Make an HTTP GET request to the server.
.. code-block:: python
#example call
try {
headers, body = http.get('/volumes')
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
:param url: The relative url from the LH api_url
:type url: str
:returns: headers - dict of HTTP Response headers
:returns: body - the body of the response. If the body was JSON,
it will be an object
"""
return self._cs_request(url, 'GET', **kwargs)
def post(self, url, **kwargs):
"""
Make an HTTP POST request to the server.
.. code-block:: python
#example call
try {
info = {'name': 'new volume name', 'sizeMiB': 300}
headers, body = http.post('/volumes', body=info)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
:param url: The relative url from the LH api_url
:type url: str
:returns: headers - dict of HTTP Response headers
:returns: body - the body of the response. If the body was JSON,
it will be an object
"""
return self._cs_request(url, 'POST', **kwargs)
def put(self, url, **kwargs):
"""
Make an HTTP PUT request to the server.
.. code-block:: python
#example call
try {
info = {'name': 'something'}
headers, body = http.put('/volumes', body=info)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
:param url: The relative url from the LH api_url
:type url: str
:returns: headers - dict of HTTP Response headers
:returns: body - the body of the response. If the body was JSON,
it will be an object
"""
return self._cs_request(url, 'PUT', **kwargs)
def delete(self, url, **kwargs):
"""
Make an HTTP DELETE request to the server.
.. code-block:: python
#example call
try {
headers, body = http.delete('/volumes/%s' % name)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
:param url: The relative url from the LH api_url
:type url: str
:returns: headers - dict of HTTP Response headers
:returns: body - the body of the response. If the body was JSON,
it will be an object
"""
return self._cs_request(url, 'DELETE', **kwargs)
|
apache-2.0
|
[
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
3,
199,
3,
334,
67,
9,
1898,
6171,
13,
7806,
27849,
9954,
1005,
29949,
15290,
21738,
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,
40,
1510,
8185,
13220,
3101,
6810,
199,
199,
703,
859,
26,
1455,
199,
199,
26,
5949,
26,
644,
11858,
437,
14,
699,
6854,
27892,
199,
26,
5831,
26,
961,
365,
314,
3101,
6810,
626,
365,
1202,
370,
1852,
314,
3503,
4882,
14,
199,
2779,
6952,
314,
6299,
626,
19428,
314,
5494,
536,
367,
491,
40,
14,
199,
199,
624,
199,
199,
646,
2050,
199,
646,
4145,
199,
646,
900,
199,
199,
893,
26,
272,
492,
2022,
199,
2590,
3545,
26,
272,
492,
13804,
465,
2022,
199,
199,
504,
394,
321,
21491,
273,
460,
1258,
492,
4967,
421,
199,
533,
3101,
6243,
15740,
3041,
8,
785,
304,
272,
408,
272,
1626,
3101,
14880,
6810,
626,
16178,
436,
295,
559,
69,
2310,
4840,
666,
465,
314,
2396,
402,
314,
272,
3101,
1056,
14,
339,
520,
635,
2986,
63,
633,
26,
710,
1166,
370,
314,
491,
40,
4403,
14880,
2435,
490,
13446,
14,
4178,
921,
28,
4269,
503,
3531,
30,
16875,
719,
12202,
76,
526,
83,
272,
520,
466,
2986,
63,
633,
26,
620,
272,
520,
635,
11153,
26,
12134,
7799,
6250,
31,
3758,
911,
440,
4107,
272,
520,
466,
11153,
26,
2155,
272,
520,
635,
1455,
63,
793,
63,
1757,
26,
16147,
83,
641,
1455,
943,
10201,
14,
3758,
911,
440,
943,
272,
520,
466,
1455,
63,
793,
63,
1757,
26,
2155,
272,
520,
635,
15678,
63,
4266,
63,
5451,
26,
29083,
4357,
943,
5721,
3788,
340,
715,
14,
3303,
3758,
911,
440,
15678,
3598,
14,
272,
520,
466,
15678,
63,
4266,
63,
5451,
26,
2155,
339,
408,
339,
13044,
63,
14565,
275,
283,
1548,
13,
72,
321,
21491,
273,
460,
1258,
7,
272,
428,
9577,
63,
13665,
63,
2339,
275,
283,
11626,
7,
272,
327,
3735,
63,
4612,
275,
283,
56,
13,
3735,
13,
3353,
7,
272,
327,
1244,
18612,
63,
4612,
275,
283,
56,
63,
40,
1510,
13,
1244,
18612,
13,
3041,
13,
3353,
7,
272,
1455,
63,
793,
63,
1757,
275,
756,
272,
485,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
339,
347,
636,
826,
721,
277,
12,
2986,
63,
633,
12,
11153,
29,
797,
12,
1455,
63,
793,
63,
1757,
29,
797,
12,
326,
15678,
63,
4266,
63,
5451,
29,
797,
12,
2653,
29,
403,
304,
267,
340,
15678,
63,
4266,
63,
5451,
26,
288,
4145,
14,
5154,
14,
4078,
19,
14,
5993,
63,
5451,
342,
267,
291,
14,
1730,
63,
498,
275,
488,
398,
327,
5626,
506,
1455,
921,
28,
3120,
26,
4313,
12202,
76,
526,
83,
267,
291,
14,
409,
63,
633,
8,
1246,
63,
633,
9,
267,
291,
14,
409,
63,
1757,
63,
4173,
8,
1014,
63,
793,
63,
1757,
9,
398,
291,
14,
4508,
275,
942,
221,
327,
10003,
1053,
401,
1343,
521,
12,
1284,
521,
395,
21214,
267,
291,
14,
7817,
275,
11153,
267,
291,
14,
2593,
275,
2653,
339,
347,
663,
63,
633,
8,
277,
12,
2986,
63,
633,
304,
267,
327,
5626,
506,
1455,
921,
28,
3120,
26,
4313,
12202,
76,
526,
83,
267,
291,
14,
1246,
63,
633,
275,
2986,
63,
633,
14,
6735,
7825,
339,
347,
663,
63,
1757,
63,
4173,
8,
277,
12,
3305,
304,
267,
408,
267,
961,
25449,
641,
15,
1997,
1455,
1056,
15,
1310,
10201,
1072,
370,
8559,
398,
520,
635,
3305,
26,
2494,
370,
715,
370,
4756,
10201,
1072,
267,
520,
466,
3305,
26,
2155,
398,
408,
267,
340,
440,
3101,
6243,
15740,
3041,
14,
1014,
63,
793,
63,
1757,
436,
3305,
26,
288,
682,
275,
2050,
14,
22482,
342,
288,
3101,
6243,
15740,
3041,
423,
2921,
14,
13548,
8,
4806,
14,
5287,
9,
288,
3101,
6243,
15740,
3041,
423,
2921,
14,
18826,
8,
335,
9,
288,
3101,
6243,
15740,
3041,
14,
1014,
63,
793,
63,
1757,
275,
715,
339,
347,
12895,
8,
277,
12,
922,
12,
2505,
12,
2716,
29,
403,
304,
267,
408,
267,
961,
11275,
370,
1218,
376,
15082,
2351,
543,
314,
491,
40,
4403,
1654,
398,
520,
635,
922,
26,
710,
3434,
267,
520,
466,
922,
26,
620,
267,
520,
635,
2505,
26,
710,
2505,
267,
520,
466,
2505,
26,
620,
398,
408,
267,
327,
3749,
876,
1856,
83,
295,
13,
1178,
7427,
340,
1790,
6918,
267,
291,
14,
1178,
63,
893,
275,
413,
267,
291,
14,
1730,
63,
498,
275,
488,
398,
2256,
275,
791,
751,
356,
922,
12,
283,
2060,
356,
2505,
93,
267,
291,
423,
1178,
63,
4144,
275,
488,
398,
340,
2716,
26,
288,
291,
423,
1178,
63,
4144,
275,
2716,
288,
2256,
14,
873,
8,
4144,
9,
398,
3085,
12,
2396,
275,
291,
14,
1932,
2336,
6942,
297,
2396,
29,
815,
9,
267,
340,
2396,
436,
283,
1178,
3264,
7,
315,
2396,
26,
288,
291,
14,
1730,
63,
498,
275,
2396,
459,
1178,
3264,
418,
267,
291,
14,
1178,
63,
893,
275,
378,
267,
291,
14,
751,
275,
922,
267,
291,
14,
2060,
275,
2505,
267,
372,
3085,
339,
347,
485,
264,
1178,
8,
277,
304,
267,
291,
14,
13975,
8,
277,
14,
751,
12,
291,
14,
2060,
12,
291,
423,
1178,
63,
4144,
9,
339,
347,
625,
13975,
8,
277,
304,
267,
408,
267,
961,
5436,
83,
314,
15082
] |
[
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
3,
199,
3,
334,
67,
9,
1898,
6171,
13,
7806,
27849,
9954,
1005,
29949,
15290,
21738,
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,
40,
1510,
8185,
13220,
3101,
6810,
199,
199,
703,
859,
26,
1455,
199,
199,
26,
5949,
26,
644,
11858,
437,
14,
699,
6854,
27892,
199,
26,
5831,
26,
961,
365,
314,
3101,
6810,
626,
365,
1202,
370,
1852,
314,
3503,
4882,
14,
199,
2779,
6952,
314,
6299,
626,
19428,
314,
5494,
536,
367,
491,
40,
14,
199,
199,
624,
199,
199,
646,
2050,
199,
646,
4145,
199,
646,
900,
199,
199,
893,
26,
272,
492,
2022,
199,
2590,
3545,
26,
272,
492,
13804,
465,
2022,
199,
199,
504,
394,
321,
21491,
273,
460,
1258,
492,
4967,
421,
199,
533,
3101,
6243,
15740,
3041,
8,
785,
304,
272,
408,
272,
1626,
3101,
14880,
6810,
626,
16178,
436,
295,
559,
69,
2310,
4840,
666,
465,
314,
2396,
402,
314,
272,
3101,
1056,
14,
339,
520,
635,
2986,
63,
633,
26,
710,
1166,
370,
314,
491,
40,
4403,
14880,
2435,
490,
13446,
14,
4178,
921,
28,
4269,
503,
3531,
30,
16875,
719,
12202,
76,
526,
83,
272,
520,
466,
2986,
63,
633,
26,
620,
272,
520,
635,
11153,
26,
12134,
7799,
6250,
31,
3758,
911,
440,
4107,
272,
520,
466,
11153,
26,
2155,
272,
520,
635,
1455,
63,
793,
63,
1757,
26,
16147,
83,
641,
1455,
943,
10201,
14,
3758,
911,
440,
943,
272,
520,
466,
1455,
63,
793,
63,
1757,
26,
2155,
272,
520,
635,
15678,
63,
4266,
63,
5451,
26,
29083,
4357,
943,
5721,
3788,
340,
715,
14,
3303,
3758,
911,
440,
15678,
3598,
14,
272,
520,
466,
15678,
63,
4266,
63,
5451,
26,
2155,
339,
408,
339,
13044,
63,
14565,
275,
283,
1548,
13,
72,
321,
21491,
273,
460,
1258,
7,
272,
428,
9577,
63,
13665,
63,
2339,
275,
283,
11626,
7,
272,
327,
3735,
63,
4612,
275,
283,
56,
13,
3735,
13,
3353,
7,
272,
327,
1244,
18612,
63,
4612,
275,
283,
56,
63,
40,
1510,
13,
1244,
18612,
13,
3041,
13,
3353,
7,
272,
1455,
63,
793,
63,
1757,
275,
756,
272,
485,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
339,
347,
636,
826,
721,
277,
12,
2986,
63,
633,
12,
11153,
29,
797,
12,
1455,
63,
793,
63,
1757,
29,
797,
12,
326,
15678,
63,
4266,
63,
5451,
29,
797,
12,
2653,
29,
403,
304,
267,
340,
15678,
63,
4266,
63,
5451,
26,
288,
4145,
14,
5154,
14,
4078,
19,
14,
5993,
63,
5451,
342,
267,
291,
14,
1730,
63,
498,
275,
488,
398,
327,
5626,
506,
1455,
921,
28,
3120,
26,
4313,
12202,
76,
526,
83,
267,
291,
14,
409,
63,
633,
8,
1246,
63,
633,
9,
267,
291,
14,
409,
63,
1757,
63,
4173,
8,
1014,
63,
793,
63,
1757,
9,
398,
291,
14,
4508,
275,
942,
221,
327,
10003,
1053,
401,
1343,
521,
12,
1284,
521,
395,
21214,
267,
291,
14,
7817,
275,
11153,
267,
291,
14,
2593,
275,
2653,
339,
347,
663,
63,
633,
8,
277,
12,
2986,
63,
633,
304,
267,
327,
5626,
506,
1455,
921,
28,
3120,
26,
4313,
12202,
76,
526,
83,
267,
291,
14,
1246,
63,
633,
275,
2986,
63,
633,
14,
6735,
7825,
339,
347,
663,
63,
1757,
63,
4173,
8,
277,
12,
3305,
304,
267,
408,
267,
961,
25449,
641,
15,
1997,
1455,
1056,
15,
1310,
10201,
1072,
370,
8559,
398,
520,
635,
3305,
26,
2494,
370,
715,
370,
4756,
10201,
1072,
267,
520,
466,
3305,
26,
2155,
398,
408,
267,
340,
440,
3101,
6243,
15740,
3041,
14,
1014,
63,
793,
63,
1757,
436,
3305,
26,
288,
682,
275,
2050,
14,
22482,
342,
288,
3101,
6243,
15740,
3041,
423,
2921,
14,
13548,
8,
4806,
14,
5287,
9,
288,
3101,
6243,
15740,
3041,
423,
2921,
14,
18826,
8,
335,
9,
288,
3101,
6243,
15740,
3041,
14,
1014,
63,
793,
63,
1757,
275,
715,
339,
347,
12895,
8,
277,
12,
922,
12,
2505,
12,
2716,
29,
403,
304,
267,
408,
267,
961,
11275,
370,
1218,
376,
15082,
2351,
543,
314,
491,
40,
4403,
1654,
398,
520,
635,
922,
26,
710,
3434,
267,
520,
466,
922,
26,
620,
267,
520,
635,
2505,
26,
710,
2505,
267,
520,
466,
2505,
26,
620,
398,
408,
267,
327,
3749,
876,
1856,
83,
295,
13,
1178,
7427,
340,
1790,
6918,
267,
291,
14,
1178,
63,
893,
275,
413,
267,
291,
14,
1730,
63,
498,
275,
488,
398,
2256,
275,
791,
751,
356,
922,
12,
283,
2060,
356,
2505,
93,
267,
291,
423,
1178,
63,
4144,
275,
488,
398,
340,
2716,
26,
288,
291,
423,
1178,
63,
4144,
275,
2716,
288,
2256,
14,
873,
8,
4144,
9,
398,
3085,
12,
2396,
275,
291,
14,
1932,
2336,
6942,
297,
2396,
29,
815,
9,
267,
340,
2396,
436,
283,
1178,
3264,
7,
315,
2396,
26,
288,
291,
14,
1730,
63,
498,
275,
2396,
459,
1178,
3264,
418,
267,
291,
14,
1178,
63,
893,
275,
378,
267,
291,
14,
751,
275,
922,
267,
291,
14,
2060,
275,
2505,
267,
372,
3085,
339,
347,
485,
264,
1178,
8,
277,
304,
267,
291,
14,
13975,
8,
277,
14,
751,
12,
291,
14,
2060,
12,
291,
423,
1178,
63,
4144,
9,
339,
347,
625,
13975,
8,
277,
304,
267,
408,
267,
961,
5436,
83,
314,
15082,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sergiocorato/odoomrp-wip
|
mrp_bom_component_change/models/mrp_bom_change.py
|
7
|
3325
|
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from openerp import models, fields, api, exceptions, _
from datetime import datetime as dt
class MrpBomChange(models.Model):
_name = 'mrp.bom.change'
_description = 'Mrp BoM Component Change'
@api.one
@api.depends('old_component')
def _calc_boms(self):
self.boms = [(6, 0, [])]
if self.old_component:
for bom in self.env['mrp.bom'].search([]):
bom_lines = bom.bom_line_ids.filtered(
lambda x: x.product_id.id == self.old_component.id)
if bom_lines:
self.boms = [(4, bom.id)]
name = fields.Char('Name', required=True)
new_component = fields.Many2one('product.product', 'New Component',
required=True)
old_component = fields.Many2one('product.product', 'Old Component',
required=True)
create_new_version = fields.Boolean(
string="Create new BoM version", help='Check this field if you want to'
' create a new version of the BOM before modifying the component')
boms = fields.Many2many(
comodel_name='mrp.bom',
relation='rel_mrp_bom_change', column1='bom_change_id',
column2='bom_id', string='BoMs', copy=False, store=True, readonly=True,
compute='_calc_boms')
date = fields.Date('Change Date', readonly=True)
user = fields.Many2one('res.users', 'Changed By', readonly=True)
reason = fields.Char('Reason')
@api.multi
def do_component_change(self):
self.ensure_one()
if not self.old_component or not self.new_component:
raise exceptions.Warning(_("Not Components selected!"))
if not self.boms:
raise exceptions.Warning(_("There isn't any BoM for selected "
"component"))
for bom in self.boms:
bom_lines = bom.bom_line_ids.filtered(
lambda x: x.product_id.id == self.old_component.id)
if self.create_new_version:
new_bom = bom._copy_bom()
bom.button_historical()
new_bom.button_activate()
self.boms = [(3, bom.id)]
self.boms = [(4, new_bom.id)]
bom_lines = new_bom.bom_line_ids.filtered(
lambda x: x.product_id.id == self.old_component.id)
values = {'product_id': self.new_component.id}
# add product_tmpl_id in case of mrp_product_variants are installed
if hasattr(bom_lines, 'product_tmpl_id'):
values['product_tmpl_id'] = (
self.new_component.product_tmpl_id.id)
bom_lines.write(values)
self.write({'date': dt.now(), 'user': self.env.uid})
return {'name': _('Bill of Material'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'mrp.bom',
'type': 'ir.actions.act_window',
'domain': [('id', 'in', self.boms.mapped('id'))]
}
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
2104,
4248,
436,
4190,
949,
7724,
12,
1937,
636,
11267,
4343,
647,
570,
315,
1738,
2082,
199,
4605,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
12,
4967,
12,
485,
199,
504,
2197,
492,
2197,
465,
4487,
421,
199,
533,
603,
4599,
34,
676,
4001,
8,
992,
14,
1685,
304,
272,
485,
354,
275,
283,
17058,
14,
16302,
14,
1461,
7,
272,
485,
1802,
275,
283,
45,
4599,
5088,
45,
12727,
7743,
7,
339,
768,
1246,
14,
368,
272,
768,
1246,
14,
8912,
360,
1753,
63,
3173,
358,
272,
347,
485,
8104,
63,
656,
706,
8,
277,
304,
267,
291,
14,
656,
706,
275,
3842,
22,
12,
378,
12,
3073,
61,
267,
340,
291,
14,
1753,
63,
3173,
26,
288,
367,
17190,
315,
291,
14,
1813,
459,
17058,
14,
16302,
2278,
1733,
779,
4682,
355,
17190,
63,
1278,
275,
17190,
14,
16302,
63,
604,
63,
1580,
14,
11142,
8,
490,
2400,
671,
26,
671,
14,
2558,
63,
344,
14,
344,
508,
291,
14,
1753,
63,
3173,
14,
344,
9,
355,
340,
17190,
63,
1278,
26,
490,
291,
14,
656,
706,
275,
3842,
20,
12,
17190,
14,
344,
1874,
339,
536,
275,
1504,
14,
1610,
360,
985,
297,
1415,
29,
549,
9,
272,
892,
63,
3173,
275,
1504,
14,
4089,
18,
368,
360,
2558,
14,
2558,
297,
283,
4665,
12727,
297,
2511,
1415,
29,
549,
9,
272,
2269,
63,
3173,
275,
1504,
14,
4089,
18,
368,
360,
2558,
14,
2558,
297,
283,
16411,
12727,
297,
2511,
1415,
29,
549,
9,
272,
1218,
63,
1222,
63,
1023,
275,
1504,
14,
4082,
8,
267,
1059,
628,
2499,
892,
5088,
45,
1015,
401,
1720,
534,
1799,
642,
901,
340,
1265,
2934,
370,
7,
267,
283,
1218,
282,
892,
1015,
402,
314,
17720,
2544,
24662,
314,
3931,
358,
272,
17190,
83,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
17058,
14,
16302,
297,
267,
5850,
534,
3369,
63,
17058,
63,
16302,
63,
1461,
297,
2763,
17,
534,
16302,
63,
1461,
63,
344,
297,
267,
2763,
18,
534,
16302,
63,
344,
297,
1059,
534,
2208,
13586,
297,
1331,
29,
797,
12,
3877,
29,
549,
12,
6863,
29,
549,
12,
267,
4526,
17574,
8104,
63,
656,
706,
358,
272,
1434,
275,
1504,
14,
2506,
360,
4001,
6148,
297,
6863,
29,
549,
9,
272,
922,
275,
1504,
14,
4089,
18,
368,
360,
470,
14,
3707,
297,
283,
6970,
4885,
297,
6863,
29,
549,
9,
272,
4499,
275,
1504,
14,
1610,
360,
16148,
358,
339,
768,
1246,
14,
3029,
272,
347,
886,
63,
3173,
63,
1461,
8,
277,
304,
267,
291,
14,
7505,
63,
368,
342,
267,
340,
440,
291,
14,
1753,
63,
3173,
503,
440,
291,
14,
1222,
63,
3173,
26,
288,
746,
4967,
14,
3849,
6115,
1763,
17823,
4895,
1,
2237,
267,
340,
440,
291,
14,
656,
706,
26,
288,
746,
4967,
14,
3849,
6115,
10924,
5712,
1133,
1263,
5088,
45,
367,
4895,
298,
4318,
298,
3173,
2237,
267,
367,
17190,
315,
291,
14,
656,
706,
26,
288,
17190,
63,
1278,
275,
17190,
14,
16302,
63,
604,
63,
1580,
14,
11142,
8,
355,
2400,
671,
26,
671,
14,
2558,
63,
344,
14,
344,
508,
291,
14,
1753,
63,
3173,
14,
344,
9,
288,
340,
291,
14,
981,
63,
1222,
63,
1023,
26,
355,
892,
63,
16302,
275,
17190,
423,
1574,
63,
16302,
342,
355,
17190,
14,
3887,
63,
11141,
10611,
342,
355,
892,
63,
16302,
14,
3887,
63,
8222,
342,
355,
291,
14,
656,
706,
275,
3842,
19,
12,
17190,
14,
344,
1874,
355,
291,
14,
656,
706,
275,
3842,
20,
12,
892,
63,
16302,
14,
344,
1874,
355,
17190,
63,
1278,
275,
892,
63,
16302,
14,
16302,
63,
604,
63,
1580,
14,
11142,
8,
490,
2400,
671,
26,
671,
14,
2558,
63,
344,
14,
344,
508,
291,
14,
1753,
63,
3173,
14,
344,
9,
288,
1338,
275,
791,
2558,
63,
344,
356,
291,
14,
1222,
63,
3173,
14,
344,
93,
288,
327,
1050,
3336,
63,
11510,
63,
344,
315,
1930,
402,
333,
4599,
63,
2558,
63,
15680,
787,
4903,
288,
340,
2688,
8,
16302,
63,
1278,
12,
283,
2558,
63,
11510,
63,
344,
735,
355,
1338,
459,
2558,
63,
11510,
63,
344,
418,
275,
334,
490,
291,
14,
1222,
63,
3173,
14,
2558,
63,
11510,
63,
344,
14,
344,
9,
288,
17190,
63,
1278,
14,
952,
8,
1459,
9,
267,
291,
14,
952,
3252,
602,
356,
4487,
14,
2131,
1062,
283,
751,
356,
291,
14,
1813,
14,
1535,
1552,
267,
372,
791,
354,
356,
4018,
34,
778,
402,
26570,
659,
355,
283,
1345,
63,
466,
356,
283,
964,
297,
355,
283,
1345,
63,
632,
356,
283,
2350,
12,
964,
297,
355,
283,
470,
63,
1238,
356,
283,
17058,
14,
16302,
297,
355,
283,
466,
356,
283,
723,
14,
3723,
14,
2442,
63,
3806,
297,
355,
283,
2261,
356,
4274,
344,
297,
283,
262,
297,
291,
14,
656,
706,
14,
11663,
360,
344,
27738,
355,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
2104,
4248,
436,
4190,
949,
7724,
12,
1937,
636,
11267,
4343,
647,
570,
315,
1738,
2082,
199,
4605,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
12,
4967,
12,
485,
199,
504,
2197,
492,
2197,
465,
4487,
421,
199,
533,
603,
4599,
34,
676,
4001,
8,
992,
14,
1685,
304,
272,
485,
354,
275,
283,
17058,
14,
16302,
14,
1461,
7,
272,
485,
1802,
275,
283,
45,
4599,
5088,
45,
12727,
7743,
7,
339,
768,
1246,
14,
368,
272,
768,
1246,
14,
8912,
360,
1753,
63,
3173,
358,
272,
347,
485,
8104,
63,
656,
706,
8,
277,
304,
267,
291,
14,
656,
706,
275,
3842,
22,
12,
378,
12,
3073,
61,
267,
340,
291,
14,
1753,
63,
3173,
26,
288,
367,
17190,
315,
291,
14,
1813,
459,
17058,
14,
16302,
2278,
1733,
779,
4682,
355,
17190,
63,
1278,
275,
17190,
14,
16302,
63,
604,
63,
1580,
14,
11142,
8,
490,
2400,
671,
26,
671,
14,
2558,
63,
344,
14,
344,
508,
291,
14,
1753,
63,
3173,
14,
344,
9,
355,
340,
17190,
63,
1278,
26,
490,
291,
14,
656,
706,
275,
3842,
20,
12,
17190,
14,
344,
1874,
339,
536,
275,
1504,
14,
1610,
360,
985,
297,
1415,
29,
549,
9,
272,
892,
63,
3173,
275,
1504,
14,
4089,
18,
368,
360,
2558,
14,
2558,
297,
283,
4665,
12727,
297,
2511,
1415,
29,
549,
9,
272,
2269,
63,
3173,
275,
1504,
14,
4089,
18,
368,
360,
2558,
14,
2558,
297,
283,
16411,
12727,
297,
2511,
1415,
29,
549,
9,
272,
1218,
63,
1222,
63,
1023,
275,
1504,
14,
4082,
8,
267,
1059,
628,
2499,
892,
5088,
45,
1015,
401,
1720,
534,
1799,
642,
901,
340,
1265,
2934,
370,
7,
267,
283,
1218,
282,
892,
1015,
402,
314,
17720,
2544,
24662,
314,
3931,
358,
272,
17190,
83,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
17058,
14,
16302,
297,
267,
5850,
534,
3369,
63,
17058,
63,
16302,
63,
1461,
297,
2763,
17,
534,
16302,
63,
1461,
63,
344,
297,
267,
2763,
18,
534,
16302,
63,
344,
297,
1059,
534,
2208,
13586,
297,
1331,
29,
797,
12,
3877,
29,
549,
12,
6863,
29,
549,
12,
267,
4526,
17574,
8104,
63,
656,
706,
358,
272,
1434,
275,
1504,
14,
2506,
360,
4001,
6148,
297,
6863,
29,
549,
9,
272,
922,
275,
1504,
14,
4089,
18,
368,
360,
470,
14,
3707,
297,
283,
6970,
4885,
297,
6863,
29,
549,
9,
272,
4499,
275,
1504,
14,
1610,
360,
16148,
358,
339,
768,
1246,
14,
3029,
272,
347,
886,
63,
3173,
63,
1461,
8,
277,
304,
267,
291,
14,
7505,
63,
368,
342,
267,
340,
440,
291,
14,
1753,
63,
3173,
503,
440,
291,
14,
1222,
63,
3173,
26,
288,
746,
4967,
14,
3849,
6115,
1763,
17823,
4895,
1,
2237,
267,
340,
440,
291,
14,
656,
706,
26,
288,
746,
4967,
14,
3849,
6115,
10924,
5712,
1133,
1263,
5088,
45,
367,
4895,
298,
4318,
298,
3173,
2237,
267,
367,
17190,
315,
291,
14,
656,
706,
26,
288,
17190,
63,
1278,
275,
17190,
14,
16302,
63,
604,
63,
1580,
14,
11142,
8,
355,
2400,
671,
26,
671,
14,
2558,
63,
344,
14,
344,
508,
291,
14,
1753,
63,
3173,
14,
344,
9,
288,
340,
291,
14,
981,
63,
1222,
63,
1023,
26,
355,
892,
63,
16302,
275,
17190,
423,
1574,
63,
16302,
342,
355,
17190,
14,
3887,
63,
11141,
10611,
342,
355,
892,
63,
16302,
14,
3887,
63,
8222,
342,
355,
291,
14,
656,
706,
275,
3842,
19,
12,
17190,
14,
344,
1874,
355,
291,
14,
656,
706,
275,
3842,
20,
12,
892,
63,
16302,
14,
344,
1874,
355,
17190,
63,
1278,
275,
892,
63,
16302,
14,
16302,
63,
604,
63,
1580,
14,
11142,
8,
490,
2400,
671,
26,
671,
14,
2558,
63,
344,
14,
344,
508,
291,
14,
1753,
63,
3173,
14,
344,
9,
288,
1338,
275,
791,
2558,
63,
344,
356,
291,
14,
1222,
63,
3173,
14,
344,
93,
288,
327,
1050,
3336,
63,
11510,
63,
344,
315,
1930,
402,
333,
4599,
63,
2558,
63,
15680,
787,
4903,
288,
340,
2688,
8,
16302,
63,
1278,
12,
283,
2558,
63,
11510,
63,
344,
735,
355,
1338,
459,
2558,
63,
11510,
63,
344,
418,
275,
334,
490,
291,
14,
1222,
63,
3173,
14,
2558,
63,
11510,
63,
344,
14,
344,
9,
288,
17190,
63,
1278,
14,
952,
8,
1459,
9,
267,
291,
14,
952,
3252,
602,
356,
4487,
14,
2131,
1062,
283,
751,
356,
291,
14,
1813,
14,
1535,
1552,
267,
372,
791,
354,
356,
4018,
34,
778,
402,
26570,
659,
355,
283,
1345,
63,
466,
356,
283,
964,
297,
355,
283,
1345,
63,
632,
356,
283,
2350,
12,
964,
297,
355,
283,
470,
63,
1238,
356,
283,
17058,
14,
16302,
297,
355,
283,
466,
356,
283,
723,
14,
3723,
14,
2442,
63,
3806,
297,
355,
283,
2261,
356,
4274,
344,
297,
283,
262,
297,
291,
14,
656,
706,
14,
11663,
360,
344,
27738,
355,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
coreymcdermott/artbot
|
artbot_scraper/spiders/arthouse_spider.py
|
1
|
2106
|
# -*- coding: utf-8 -*-
import re
from scrapy import Spider, Request
from dateutil import parser
from artbot_scraper.items import EventItem
from pytz import timezone
class ArthouseSpider(Spider):
name = 'Arthouse Gallery'
allowed_domains = ['www.arthousegallery.com.au']
start_urls = ['http://www.arthousegallery.com.au/exhibitions/']
def parse(self, response):
for href in response.xpath('//div[contains(@id, "index")]//li//a/@href'):
url = response.urljoin(href.extract())
yield Request(url, callback=self.parse_exhibition)
def parse_exhibition(self, response):
item = EventItem()
item['url'] = response.url
item['venue'] = self.name
item['title'] = response.xpath('//div[contains(@id, "headerTitle")]//text()').extract_first().strip() \
+ ' - ' \
+ response.xpath('//div[contains(@id, "headerSubTitle")]//em/text()').extract_first().strip()
item['description'] = ''.join(response.xpath('//div[contains(@id, "exhibition")]//hr/following-sibling::p//text()').extract()).strip()
item['image'] = response.urljoin(response.xpath('//img//@src').extract_first())
season = ''.join(response.xpath('//div[contains(@id, "headerSubTitle")]//text()[not(ancestor::em)]').extract()).strip()
match = re.match(u'(?P<start>^[\d\w\s]+)[\s\-\–]*(?P<end>[\d\w\s]+$)', season)
if (match):
tz = timezone('Australia/Sydney')
start = tz.localize(parser.parse(match.group('start'), fuzzy = True))
end = tz.localize(parser.parse(match.group('end'), fuzzy = True))
if (re.match(u'^\d+$', match.group('start'))):
start = start.replace(month=end.month, year=end.year)
if (re.match(u'^\d+\s+\w+$', match.group('start'))):
start = start.replace(year=end.year)
item['start'] = start
item['end'] = end
yield item
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
295,
199,
504,
18918,
5185,
492,
428,
12508,
12,
4784,
199,
504,
22208,
3777,
492,
1798,
199,
504,
24701,
3018,
63,
12865,
529,
14,
1744,
492,
6763,
2081,
199,
504,
15444,
463,
492,
7137,
421,
199,
533,
1952,
273,
7130,
25157,
8,
25157,
304,
272,
536,
3322,
275,
283,
1596,
273,
7130,
598,
17787,
7,
272,
4370,
63,
9756,
275,
788,
1544,
14,
19677,
7130,
25372,
14,
957,
14,
3844,
418,
272,
1343,
63,
3603,
420,
275,
788,
1014,
921,
1544,
14,
19677,
7130,
25372,
14,
957,
14,
3844,
15,
476,
20215,
73,
852,
15,
418,
339,
347,
2198,
8,
277,
12,
1177,
304,
267,
367,
4369,
315,
1177,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
1080,
11323,
501,
317,
501,
65,
15,
32,
6399,
735,
288,
1166,
275,
1177,
14,
17755,
8,
6399,
14,
5005,
1012,
953,
1995,
4784,
8,
633,
12,
3233,
29,
277,
14,
1122,
63,
476,
20215,
15415,
9,
339,
347,
2198,
63,
476,
20215,
15415,
8,
277,
12,
1177,
304,
267,
1242,
4483,
275,
6763,
2081,
342,
267,
1242,
459,
633,
418,
260,
275,
1177,
14,
633,
267,
1242,
459,
24728,
418,
755,
275,
291,
14,
354,
267,
1242,
459,
1213,
418,
755,
275,
1177,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
1291,
6888,
11323,
501,
505,
342,
1959,
5005,
63,
2246,
1252,
1913,
342,
971,
1169,
435,
283,
446,
283,
971,
1169,
435,
1177,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
1291,
2610,
6888,
11323,
501,
5633,
15,
505,
342,
1959,
5005,
63,
2246,
1252,
1913,
342,
267,
1242,
459,
1802,
418,
275,
6522,
904,
8,
1310,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
476,
20215,
15415,
11323,
501,
6271,
15,
21589,
13,
17285,
447,
80,
501,
505,
342,
1959,
5005,
8801,
1913,
342,
267,
1242,
459,
1569,
418,
755,
275,
1177,
14,
17755,
8,
1310,
14,
8006,
15079,
4060,
501,
32,
2164,
1959,
5005,
63,
2246,
1012,
398,
14718,
275,
6522,
904,
8,
1310,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
1291,
2610,
6888,
11323,
501,
505,
3430,
1397,
8,
20745,
447,
5633,
1874,
1959,
5005,
8801,
1913,
342,
267,
1336,
221,
275,
295,
14,
1431,
8,
85,
10120,
48,
28,
928,
30,
62,
7023,
68,
60,
87,
60,
83,
2807,
2788,
60,
83,
60,
2696,
8477,
242,
3672,
2229,
48,
28,
500,
24693,
68,
60,
87,
60,
83,
2807,
4,
3196,
14718,
9,
398,
340,
334,
1431,
304,
288,
5823,
259,
275,
7137,
360,
29459,
15,
4323,
68,
23263,
358,
288,
1343,
275,
5823,
14,
21279,
8,
2087,
14,
1122,
8,
1431,
14,
923,
360,
928,
659,
24101,
275,
715,
430,
288,
1284,
257,
275,
5823,
14,
21279,
8,
2087,
14,
1122,
8,
1431,
14,
923,
360,
500,
659,
24101,
275,
715,
430,
953,
340,
334,
264,
14,
1431,
8,
85,
15542,
68,
11,
4268,
1336,
14,
923,
360,
928,
1333,
304,
355,
1343,
275,
1343,
14,
1814,
8,
4482,
29,
500,
14,
4482,
12,
5361,
29,
500,
14,
3403,
9,
953,
340,
334,
264,
14,
1431,
8,
85,
15542,
68,
7896,
83,
7896,
87,
11,
4268,
1336,
14,
923,
360,
928,
1333,
304,
355,
1343,
275,
1343,
14,
1814,
8,
3403,
29,
500,
14,
3403,
9,
953,
1242,
459,
928,
418,
275,
1343,
288,
1242,
459,
500,
418,
257,
275,
1284,
398,
1995,
1242,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
295,
199,
504,
18918,
5185,
492,
428,
12508,
12,
4784,
199,
504,
22208,
3777,
492,
1798,
199,
504,
24701,
3018,
63,
12865,
529,
14,
1744,
492,
6763,
2081,
199,
504,
15444,
463,
492,
7137,
421,
199,
533,
1952,
273,
7130,
25157,
8,
25157,
304,
272,
536,
3322,
275,
283,
1596,
273,
7130,
598,
17787,
7,
272,
4370,
63,
9756,
275,
788,
1544,
14,
19677,
7130,
25372,
14,
957,
14,
3844,
418,
272,
1343,
63,
3603,
420,
275,
788,
1014,
921,
1544,
14,
19677,
7130,
25372,
14,
957,
14,
3844,
15,
476,
20215,
73,
852,
15,
418,
339,
347,
2198,
8,
277,
12,
1177,
304,
267,
367,
4369,
315,
1177,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
1080,
11323,
501,
317,
501,
65,
15,
32,
6399,
735,
288,
1166,
275,
1177,
14,
17755,
8,
6399,
14,
5005,
1012,
953,
1995,
4784,
8,
633,
12,
3233,
29,
277,
14,
1122,
63,
476,
20215,
15415,
9,
339,
347,
2198,
63,
476,
20215,
15415,
8,
277,
12,
1177,
304,
267,
1242,
4483,
275,
6763,
2081,
342,
267,
1242,
459,
633,
418,
260,
275,
1177,
14,
633,
267,
1242,
459,
24728,
418,
755,
275,
291,
14,
354,
267,
1242,
459,
1213,
418,
755,
275,
1177,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
1291,
6888,
11323,
501,
505,
342,
1959,
5005,
63,
2246,
1252,
1913,
342,
971,
1169,
435,
283,
446,
283,
971,
1169,
435,
1177,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
1291,
2610,
6888,
11323,
501,
5633,
15,
505,
342,
1959,
5005,
63,
2246,
1252,
1913,
342,
267,
1242,
459,
1802,
418,
275,
6522,
904,
8,
1310,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
476,
20215,
15415,
11323,
501,
6271,
15,
21589,
13,
17285,
447,
80,
501,
505,
342,
1959,
5005,
8801,
1913,
342,
267,
1242,
459,
1569,
418,
755,
275,
1177,
14,
17755,
8,
1310,
14,
8006,
15079,
4060,
501,
32,
2164,
1959,
5005,
63,
2246,
1012,
398,
14718,
275,
6522,
904,
8,
1310,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
344,
12,
298,
1291,
2610,
6888,
11323,
501,
505,
3430,
1397,
8,
20745,
447,
5633,
1874,
1959,
5005,
8801,
1913,
342,
267,
1336,
221,
275,
295,
14,
1431,
8,
85,
10120,
48,
28,
928,
30,
62,
7023,
68,
60,
87,
60,
83,
2807,
2788,
60,
83,
60,
2696,
8477,
242,
3672,
2229,
48,
28,
500,
24693,
68,
60,
87,
60,
83,
2807,
4,
3196,
14718,
9,
398,
340,
334,
1431,
304,
288,
5823,
259,
275,
7137,
360,
29459,
15,
4323,
68,
23263,
358,
288,
1343,
275,
5823,
14,
21279,
8,
2087,
14,
1122,
8,
1431,
14,
923,
360,
928,
659,
24101,
275,
715,
430,
288,
1284,
257,
275,
5823,
14,
21279,
8,
2087,
14,
1122,
8,
1431,
14,
923,
360,
500,
659,
24101,
275,
715,
430,
953,
340,
334,
264,
14,
1431,
8,
85,
15542,
68,
11,
4268,
1336,
14,
923,
360,
928,
1333,
304,
355,
1343,
275,
1343,
14,
1814,
8,
4482,
29,
500,
14,
4482,
12,
5361,
29,
500,
14,
3403,
9,
953,
340,
334,
264,
14,
1431,
8,
85,
15542,
68,
7896,
83,
7896,
87,
11,
4268,
1336,
14,
923,
360,
928,
1333,
304,
355,
1343,
275,
1343,
14,
1814,
8,
3403,
29,
500,
14,
3403,
9,
953,
1242,
459,
928,
418,
275,
1343,
288,
1242,
459,
500,
418,
257,
275,
1284,
398,
1995,
1242,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
mmb90/dftintegrate
|
dftintegrate/fourier/readdata.py
|
1
|
5536
|
"""
Classes::
ReadData -- A collection of functions to collect extracted VASP/QE data
into a json file.
"""
import json
from copy import deepcopy
from ast import literal_eval
from collections import defaultdict
class ReadData(object):
"""
A collection of functions to collect extracted VASP/QE data
into a json file.
Variables::
name -- A string containing the name to the extracted data.
kmax -- A number that determines how many terms can be used
in the fourier representation based on the density of the
sample points.
kgrid -- A list of lists. Each inner list is a triplet that
represents a k-point. The outer list is the collection of
the triplets or k-points and therefore represents the k-kgrid.
Note these are the irreducible k-points.
weights -- A list of floats. Since kgrid represents the
irreducible wedge, each k-point has a weight that
represents in a way how degenerate it is. These
are in the same order as their corresponding k-points
in kgrid.
eigenvals -- A dictionary. At each k-point there is an
eigenvalue (energy) for each band that was calculated. The
keys are the band numbers and the values are a list of
energies for that band at each k-point.
symops -- A triple nested list. The outer list is a collection
of matrices that represent the symmetry operators for the
system calculated. The inner double nested lists are
representations of the matrices.
trans -- A list of lists. Each symmetry operator has a
translation vector associated with it. We aren't sure
what they are for but we have them so we can implement
them if we figure it out.
Functions::
_read_lines -- Read a file yielding one line at a time. Generator.
read_kpts_eigenvals -- Read kpts_eigenvals.dat in as a list of
k-points and a dictionary.
read_symops_trans -- Read symops_trans.dat in as two lists.
read_kmax -- Read kmax from kmax.dat in. For example one might run
a calulation with a grid of 4 4 4, in this case k is 4. This
is needed in the Fourier basis fit to ensure the highest
frequency term doesn't exceed the Nyquist frequency. This means
that the highest frequency can't exeed k/2, so if k is 4
then the highest frequency can't exeed 2. Since we are in 3D we
have to consider sqrt(x^2+x^2+x^2) < k/2, thus
x = kmax = ceil(k/(2sqrt(3)).
serialize -- Serialize the data to a json file.
"""
def __init__(self, name_of_data_directory):
"""
Arguments::
name_of_data_directory -- A string containing the name to
the VASP data.
"""
self.name = name_of_data_directory
self.read_kpts_eigenvals()
self.read_symops_trans()
self.read_kmax()
self.serialize()
def _read_lines(self, path_to_file):
"""
Read file, yield line by line.
Arguments::
path_to_file -- String containing the path to the file.
"""
with open(path_to_file) as inf:
for line in inf:
yield [literal_eval(x) for x in line.strip().split()]
def read_kpts_eigenvals(self):
"""
Read in kpts_eigenvals.dat with _read_lines. Stores the k-pionts
in kgrid, the weights in weights, and the band energy
(eigenvalues) in eigenvals. See this class's (ReadData)
docstring for more details on kgrid, weights, and eigenvals.
"""
name = self.name
kgrid = []
weights = []
eigenvals = defaultdict(list)
for line in self._read_lines(name + '/kpts_eigenvals.dat'):
if len(line) == 4:
kgrid.append(line[:3])
weights.append(line[-1])
elif len(line) == 2:
eigenvals[line[0]].append(line[1])
self.kgrid = kgrid
self.weights = weights
self.eigenvals = eigenvals
def read_symops_trans(self):
"""
Read in symops_trans.dat with _read_lines. Stores the symmetry
operators in symops and the translations in trans. See this
class's (ReadData) docstring for more details on symops and trans.
"""
name = self.name
symops = []
symop = []
trans = []
lines = self._read_lines(name + '/symops_trans.dat')
for line in lines:
symop.append(line)
symop.append(next(lines))
symop.append(next(lines))
next(lines)
tran = next(lines)
next(lines)
symops.append(deepcopy(symop))
trans.append(tran)
symop.clear()
self.symops = symops
self.trans = trans
def read_kmax(self):
"""
Read in kmax.dat using _read_lines. Only the first line will be
read. It will be assigned to self.kmax.
"""
name = self.name
lines = self._read_lines(name + '/kmax.dat')
self.kmax = next(lines)[0]
def serialize(self):
data_dict = {'kmax': self.kmax, 'kgrid': self.kgrid,
'weights': self.weights, 'eigenvals': self.eigenvals,
'symops': self.symops, 'trans': self.trans}
with open(self.name + '/data.json', mode='w',
encoding='utf-8') as outf:
json.dump(data_dict, outf, indent=2)
|
mit
|
[
624,
199,
15711,
447,
523,
5574,
1451,
1553,
437,
3245,
402,
3423,
370,
8775,
12509,
812,
1179,
48,
15,
31668,
666,
272,
1901,
282,
2022,
570,
14,
199,
624,
199,
199,
646,
2022,
199,
504,
1331,
492,
14800,
199,
504,
6073,
492,
8785,
63,
2579,
199,
504,
5055,
492,
10018,
421,
199,
533,
5574,
1451,
8,
785,
304,
272,
408,
272,
437,
3245,
402,
3423,
370,
8775,
12509,
812,
1179,
48,
15,
31668,
666,
272,
1901,
282,
2022,
570,
14,
339,
17198,
447,
489,
536,
1553,
437,
1059,
3035,
314,
536,
370,
314,
12509,
666,
14,
2541,
1022,
988,
1553,
437,
1329,
626,
16756,
4212,
5002,
2895,
883,
506,
1202,
267,
315,
314,
11648,
4446,
6025,
4079,
641,
314,
13650,
402,
314,
267,
2690,
4501,
14,
2541,
1022,
3825,
1553,
437,
769,
402,
5548,
14,
7048,
6506,
769,
365,
282,
18038,
2723,
626,
267,
8469,
282,
1022,
13,
1403,
14,
710,
6890,
769,
365,
314,
3245,
402,
267,
314,
19671,
1086,
503,
1022,
13,
3438,
436,
16119,
8469,
314,
1022,
13,
75,
3825,
14,
267,
3390,
3520,
787,
314,
8190,
19493,
559,
830,
1022,
13,
3438,
14,
2541,
4931,
1553,
437,
769,
402,
15657,
14,
9336,
1022,
3825,
8469,
314,
267,
8190,
19493,
559,
830,
336,
5173,
12,
1924,
1022,
13,
1403,
965,
282,
5401,
626,
267,
8469,
315,
282,
4340,
4212,
477,
4208,
652,
365,
14,
5723,
267,
787,
315,
314,
2011,
1865,
465,
3932,
5226,
1022,
13,
3438,
267,
315,
1022,
3825,
14,
2541,
11471,
3643,
1553,
437,
2600,
14,
2854,
1924,
1022,
13,
1403,
2337,
365,
376,
267,
11471,
585,
334,
8443,
9,
367,
1924,
10981,
626,
1990,
12950,
14,
710,
267,
2883,
787,
314,
10981,
5579,
436,
314,
1338,
787,
282,
769,
402,
267,
655,
19719,
1500,
367,
626,
10981,
737,
1924,
1022,
13,
1403,
14,
2541,
4678,
1483,
1553,
437,
19671,
6032,
769,
14,
710,
6890,
769,
365,
282,
3245,
267,
402,
12627,
626,
2954,
314,
30246,
10211,
367,
314,
267,
2656,
12950,
14,
710,
6506,
4270,
6032,
5548,
787,
267,
30580,
402,
314,
12627,
14,
2541,
1752,
1553,
437,
769,
402,
5548,
14,
7048,
30246,
4182,
965,
282,
267,
7761,
5477,
4568,
543,
652,
14,
2136,
10621,
1133,
3238,
267,
4052,
2985,
787,
367,
1325,
781,
1172,
3062,
880,
781,
883,
5669,
267,
3062,
340,
781,
9658,
652,
734,
14,
339,
17471,
447,
489,
485,
739,
63,
1278,
1553,
5574,
282,
570,
32035,
1373,
1004,
737,
282,
900,
14,
15042,
14,
2541,
1586,
63,
75,
8382,
63,
19545,
3643,
1553,
5574,
1022,
8382,
63,
19545,
3643,
14,
4616,
315,
465,
282,
769,
402,
288,
1022,
13,
3438,
436,
282,
2600,
14,
2541,
1586,
63,
3840,
1483,
63,
1515,
1553,
5574,
4678,
1483,
63,
1515,
14,
4616,
315,
465,
2877,
5548,
14,
2541,
1586,
63,
75,
988,
1553,
5574,
1022,
988,
687,
1022,
988,
14,
4616,
315,
14,
2104,
2893,
1373,
5594,
1255,
267,
282,
3213,
5332,
543,
282,
6068,
402,
841,
841,
841,
12,
315,
642,
1930,
1022,
365,
841,
14,
961,
267,
365,
4346,
315,
314,
23843,
4446,
5597,
5542,
370,
4868,
314,
15356,
267,
9857,
6707,
3181,
1133,
24068,
314,
653,
89,
392,
631,
9857,
14,
961,
4910,
267,
626,
314,
15356,
9857,
883,
1133,
14778,
379,
1022,
15,
18,
12,
880,
340,
1022,
365,
841,
267,
2066,
314,
15356,
9857,
883,
1133,
14778,
379,
499,
14,
9336,
781,
787,
315,
650,
36,
781,
267,
1172,
370,
11201,
7452,
8,
88,
62,
18,
11,
88,
62,
18,
11,
88,
62,
18,
9,
665,
1022,
15,
18,
12,
12850,
267,
671,
275,
1022,
988,
275,
30449,
8,
75,
7985,
18,
5079,
8,
19,
4992,
2541,
8437,
1553,
11973,
794,
314,
666,
370,
282,
2022,
570,
14,
339,
408,
339,
347,
636,
826,
721,
277,
12,
536,
63,
1618,
63,
576,
63,
3619,
304,
267,
408,
267,
7628,
447,
881,
536,
63,
1618,
63,
576,
63,
3619,
1553,
437,
1059,
3035,
314,
536,
370,
288,
314,
812,
1179,
48,
666,
14,
267,
408,
267,
291,
14,
354,
275,
536,
63,
1618,
63,
576,
63,
3619,
267,
291,
14,
739,
63,
75,
8382,
63,
19545,
3643,
342,
267,
291,
14,
739,
63,
3840,
1483,
63,
1515,
342,
267,
291,
14,
739,
63,
75,
988,
342,
267,
291,
14,
3549,
342,
339,
347,
485,
739,
63,
1278,
8,
277,
12,
931,
63,
475,
63,
493,
304,
267,
408,
267,
5574,
570,
12,
1995,
1004,
701,
1004,
14,
398,
7628,
447,
881,
931,
63,
475,
63,
493,
1553,
2624,
3035,
314,
931,
370,
314,
570,
14,
267,
408,
267,
543,
1551,
8,
515,
63,
475,
63,
493,
9,
465,
10739,
26,
288,
367,
1004,
315,
10739,
26,
355,
1995,
359,
8939,
63,
2579,
8,
88,
9,
367,
671,
315,
1004,
14,
1913,
1252,
1294,
5106,
339,
347,
1586,
63,
75,
8382,
63,
19545,
3643,
8,
277,
304,
267,
408,
267,
5574,
315,
1022,
8382,
63,
19545,
3643,
14,
4616,
543,
485,
739,
63,
1278,
14,
31299,
314,
1022,
13,
1038,
13366,
267,
315,
1022,
3825,
12,
314,
4931,
315,
4931,
12,
436,
314,
10981,
12304,
267,
334,
19545,
1459,
9,
315,
11471,
3643,
14,
1666,
642,
1021,
1159,
334,
3284,
1451,
9,
267,
9214,
367,
1655,
2436,
641,
1022,
3825,
12,
4931,
12,
436,
11471,
3643,
14,
267,
408,
267,
536,
275,
291,
14,
354,
267,
1022,
3825,
275,
942,
267,
4931,
275,
942,
267,
11471,
3643,
275,
10018,
8,
513,
9,
267,
367,
1004,
315,
291,
423,
739,
63,
1278,
8,
354,
435,
1994,
75,
8382,
63,
19545,
3643,
14,
4616,
735,
288,
340,
822,
8,
604,
9,
508,
841,
26,
355,
1022,
3825,
14,
740,
8,
604,
1491,
19,
566,
355,
4931,
14,
740,
8,
604,
1988,
17,
566,
288,
916,
822,
8,
604,
9,
508,
499,
26,
355,
11471,
3643,
59,
604,
59,
16,
20230,
740,
8,
604,
59,
17,
566,
267,
291,
14,
75,
3825,
275,
1022,
3825,
267,
291,
14,
4916,
275,
4931,
267,
291,
14,
19545,
3643,
275,
11471,
3643,
339,
347,
1586,
63,
3840,
1483,
63,
1515,
8,
277,
304,
267,
408,
267,
5574,
315,
4678,
1483,
63,
1515,
14,
4616,
543,
485,
739,
63,
1278,
14,
31299,
314,
30246,
267,
10211,
315,
4678
] |
[
199,
15711,
447,
523,
5574,
1451,
1553,
437,
3245,
402,
3423,
370,
8775,
12509,
812,
1179,
48,
15,
31668,
666,
272,
1901,
282,
2022,
570,
14,
199,
624,
199,
199,
646,
2022,
199,
504,
1331,
492,
14800,
199,
504,
6073,
492,
8785,
63,
2579,
199,
504,
5055,
492,
10018,
421,
199,
533,
5574,
1451,
8,
785,
304,
272,
408,
272,
437,
3245,
402,
3423,
370,
8775,
12509,
812,
1179,
48,
15,
31668,
666,
272,
1901,
282,
2022,
570,
14,
339,
17198,
447,
489,
536,
1553,
437,
1059,
3035,
314,
536,
370,
314,
12509,
666,
14,
2541,
1022,
988,
1553,
437,
1329,
626,
16756,
4212,
5002,
2895,
883,
506,
1202,
267,
315,
314,
11648,
4446,
6025,
4079,
641,
314,
13650,
402,
314,
267,
2690,
4501,
14,
2541,
1022,
3825,
1553,
437,
769,
402,
5548,
14,
7048,
6506,
769,
365,
282,
18038,
2723,
626,
267,
8469,
282,
1022,
13,
1403,
14,
710,
6890,
769,
365,
314,
3245,
402,
267,
314,
19671,
1086,
503,
1022,
13,
3438,
436,
16119,
8469,
314,
1022,
13,
75,
3825,
14,
267,
3390,
3520,
787,
314,
8190,
19493,
559,
830,
1022,
13,
3438,
14,
2541,
4931,
1553,
437,
769,
402,
15657,
14,
9336,
1022,
3825,
8469,
314,
267,
8190,
19493,
559,
830,
336,
5173,
12,
1924,
1022,
13,
1403,
965,
282,
5401,
626,
267,
8469,
315,
282,
4340,
4212,
477,
4208,
652,
365,
14,
5723,
267,
787,
315,
314,
2011,
1865,
465,
3932,
5226,
1022,
13,
3438,
267,
315,
1022,
3825,
14,
2541,
11471,
3643,
1553,
437,
2600,
14,
2854,
1924,
1022,
13,
1403,
2337,
365,
376,
267,
11471,
585,
334,
8443,
9,
367,
1924,
10981,
626,
1990,
12950,
14,
710,
267,
2883,
787,
314,
10981,
5579,
436,
314,
1338,
787,
282,
769,
402,
267,
655,
19719,
1500,
367,
626,
10981,
737,
1924,
1022,
13,
1403,
14,
2541,
4678,
1483,
1553,
437,
19671,
6032,
769,
14,
710,
6890,
769,
365,
282,
3245,
267,
402,
12627,
626,
2954,
314,
30246,
10211,
367,
314,
267,
2656,
12950,
14,
710,
6506,
4270,
6032,
5548,
787,
267,
30580,
402,
314,
12627,
14,
2541,
1752,
1553,
437,
769,
402,
5548,
14,
7048,
30246,
4182,
965,
282,
267,
7761,
5477,
4568,
543,
652,
14,
2136,
10621,
1133,
3238,
267,
4052,
2985,
787,
367,
1325,
781,
1172,
3062,
880,
781,
883,
5669,
267,
3062,
340,
781,
9658,
652,
734,
14,
339,
17471,
447,
489,
485,
739,
63,
1278,
1553,
5574,
282,
570,
32035,
1373,
1004,
737,
282,
900,
14,
15042,
14,
2541,
1586,
63,
75,
8382,
63,
19545,
3643,
1553,
5574,
1022,
8382,
63,
19545,
3643,
14,
4616,
315,
465,
282,
769,
402,
288,
1022,
13,
3438,
436,
282,
2600,
14,
2541,
1586,
63,
3840,
1483,
63,
1515,
1553,
5574,
4678,
1483,
63,
1515,
14,
4616,
315,
465,
2877,
5548,
14,
2541,
1586,
63,
75,
988,
1553,
5574,
1022,
988,
687,
1022,
988,
14,
4616,
315,
14,
2104,
2893,
1373,
5594,
1255,
267,
282,
3213,
5332,
543,
282,
6068,
402,
841,
841,
841,
12,
315,
642,
1930,
1022,
365,
841,
14,
961,
267,
365,
4346,
315,
314,
23843,
4446,
5597,
5542,
370,
4868,
314,
15356,
267,
9857,
6707,
3181,
1133,
24068,
314,
653,
89,
392,
631,
9857,
14,
961,
4910,
267,
626,
314,
15356,
9857,
883,
1133,
14778,
379,
1022,
15,
18,
12,
880,
340,
1022,
365,
841,
267,
2066,
314,
15356,
9857,
883,
1133,
14778,
379,
499,
14,
9336,
781,
787,
315,
650,
36,
781,
267,
1172,
370,
11201,
7452,
8,
88,
62,
18,
11,
88,
62,
18,
11,
88,
62,
18,
9,
665,
1022,
15,
18,
12,
12850,
267,
671,
275,
1022,
988,
275,
30449,
8,
75,
7985,
18,
5079,
8,
19,
4992,
2541,
8437,
1553,
11973,
794,
314,
666,
370,
282,
2022,
570,
14,
339,
408,
339,
347,
636,
826,
721,
277,
12,
536,
63,
1618,
63,
576,
63,
3619,
304,
267,
408,
267,
7628,
447,
881,
536,
63,
1618,
63,
576,
63,
3619,
1553,
437,
1059,
3035,
314,
536,
370,
288,
314,
812,
1179,
48,
666,
14,
267,
408,
267,
291,
14,
354,
275,
536,
63,
1618,
63,
576,
63,
3619,
267,
291,
14,
739,
63,
75,
8382,
63,
19545,
3643,
342,
267,
291,
14,
739,
63,
3840,
1483,
63,
1515,
342,
267,
291,
14,
739,
63,
75,
988,
342,
267,
291,
14,
3549,
342,
339,
347,
485,
739,
63,
1278,
8,
277,
12,
931,
63,
475,
63,
493,
304,
267,
408,
267,
5574,
570,
12,
1995,
1004,
701,
1004,
14,
398,
7628,
447,
881,
931,
63,
475,
63,
493,
1553,
2624,
3035,
314,
931,
370,
314,
570,
14,
267,
408,
267,
543,
1551,
8,
515,
63,
475,
63,
493,
9,
465,
10739,
26,
288,
367,
1004,
315,
10739,
26,
355,
1995,
359,
8939,
63,
2579,
8,
88,
9,
367,
671,
315,
1004,
14,
1913,
1252,
1294,
5106,
339,
347,
1586,
63,
75,
8382,
63,
19545,
3643,
8,
277,
304,
267,
408,
267,
5574,
315,
1022,
8382,
63,
19545,
3643,
14,
4616,
543,
485,
739,
63,
1278,
14,
31299,
314,
1022,
13,
1038,
13366,
267,
315,
1022,
3825,
12,
314,
4931,
315,
4931,
12,
436,
314,
10981,
12304,
267,
334,
19545,
1459,
9,
315,
11471,
3643,
14,
1666,
642,
1021,
1159,
334,
3284,
1451,
9,
267,
9214,
367,
1655,
2436,
641,
1022,
3825,
12,
4931,
12,
436,
11471,
3643,
14,
267,
408,
267,
536,
275,
291,
14,
354,
267,
1022,
3825,
275,
942,
267,
4931,
275,
942,
267,
11471,
3643,
275,
10018,
8,
513,
9,
267,
367,
1004,
315,
291,
423,
739,
63,
1278,
8,
354,
435,
1994,
75,
8382,
63,
19545,
3643,
14,
4616,
735,
288,
340,
822,
8,
604,
9,
508,
841,
26,
355,
1022,
3825,
14,
740,
8,
604,
1491,
19,
566,
355,
4931,
14,
740,
8,
604,
1988,
17,
566,
288,
916,
822,
8,
604,
9,
508,
499,
26,
355,
11471,
3643,
59,
604,
59,
16,
20230,
740,
8,
604,
59,
17,
566,
267,
291,
14,
75,
3825,
275,
1022,
3825,
267,
291,
14,
4916,
275,
4931,
267,
291,
14,
19545,
3643,
275,
11471,
3643,
339,
347,
1586,
63,
3840,
1483,
63,
1515,
8,
277,
304,
267,
408,
267,
5574,
315,
4678,
1483,
63,
1515,
14,
4616,
543,
485,
739,
63,
1278,
14,
31299,
314,
30246,
267,
10211,
315,
4678,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
aularon/meld
|
meld/ui/vcdialogs.py
|
4
|
5155
|
# Copyright (C) 2002-2006 Stephen Kennedy <stevek@gnome.org>
# Copyright (C) 2010-2013 Kai Willadsen <kai.willadsen@gmail.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, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os
import textwrap
from gi.repository import Gio
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Pango
from meld.conf import _
from meld.misc import commonprefix
from meld.settings import meldsettings, settings
from meld.ui.gnomeglade import Component
# FIXME: Duplication from vcview
def _commonprefix(files):
if len(files) != 1:
workdir = commonprefix(files)
else:
workdir = os.path.dirname(files[0]) or "."
return workdir
class CommitDialog(GObject.GObject, Component):
__gtype_name__ = "CommitDialog"
break_commit_message = GObject.property(type=bool, default=False)
def __init__(self, parent):
GObject.GObject.__init__(self)
Component.__init__(self, "vcview.ui", "commitdialog")
self.parent = parent
self.widget.set_transient_for(parent.widget.get_toplevel())
selected = parent._get_selected_files()
try:
to_commit = parent.vc.get_files_to_commit(selected)
topdir = parent.vc.root
if to_commit:
to_commit = ["\t" + s for s in to_commit]
else:
to_commit = ["\t" + _("No files will be committed")]
except NotImplementedError:
topdir = _commonprefix(selected)
to_commit = ["\t" + s[len(topdir) + 1:] for s in selected]
self.changedfiles.set_text("(in %s)\n%s" %
(topdir, "\n".join(to_commit)))
self.textview.modify_font(meldsettings.font)
commit_prefill = self.parent.vc.get_commit_message_prefill()
if commit_prefill:
buf = self.textview.get_buffer()
buf.set_text(commit_prefill)
buf.place_cursor(buf.get_start_iter())
# Try and make the textview wide enough for a standard 80-character
# commit message.
context = self.textview.get_pango_context()
metrics = context.get_metrics(meldsettings.font,
context.get_language())
char_width = metrics.get_approximate_char_width() / Pango.SCALE
self.scrolledwindow1.set_size_request(80 * char_width, -1)
settings.bind('vc-show-commit-margin', self.textview,
'show-right-margin', Gio.SettingsBindFlags.DEFAULT)
settings.bind('vc-commit-margin', self.textview,
'right-margin-position', Gio.SettingsBindFlags.DEFAULT)
settings.bind('vc-break-commit-message', self,
'break-commit-message', Gio.SettingsBindFlags.DEFAULT)
self.widget.show_all()
def run(self):
self.previousentry.set_active(-1)
self.textview.grab_focus()
response = self.widget.run()
if response == Gtk.ResponseType.OK:
show_margin = self.textview.get_show_right_margin()
margin = self.textview.get_right_margin_position()
buf = self.textview.get_buffer()
msg = buf.get_text(*buf.get_bounds(), include_hidden_chars=False)
# This is a dependent option because of the margin column
if show_margin and self.props.break_commit_message:
paragraphs = msg.split("\n\n")
msg = "\n\n".join(textwrap.fill(p, margin) for p in paragraphs)
self.parent._command_on_selected(
self.parent.vc.commit_command(msg))
if msg.strip():
self.previousentry.prepend_history(msg)
self.widget.destroy()
def on_previousentry_activate(self, gentry):
idx = gentry.get_active()
if idx != -1:
model = gentry.get_model()
buf = self.textview.get_buffer()
buf.set_text(model[idx][1])
class PushDialog(Component):
def __init__(self, parent):
Component.__init__(self, "vcview.ui", "pushdialog")
self.parent = parent
self.widget.set_transient_for(parent.widget.get_toplevel())
self.widget.show_all()
def run(self):
# TODO: Ask the VC for a more informative label for what will happen.
# In git, this is probably the parsed output of push --dry-run.
response = self.widget.run()
if response == Gtk.ResponseType.OK:
self.parent.vc.push(self.parent._command)
self.widget.destroy()
|
gpl-2.0
|
[
3,
1898,
334,
35,
9,
14790,
13,
7968,
17854,
17579,
1804,
287,
7439,
89,
665,
1597,
432,
75,
32,
784,
1377,
14,
1308,
30,
199,
3,
1898,
334,
35,
9,
7129,
13,
6965,
1804,
5789,
12823,
350,
2464,
665,
75,
5789,
14,
14117,
350,
2464,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
199,
3,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
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,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
747,
199,
646,
13390,
199,
199,
504,
18895,
14,
8421,
492,
598,
2308,
199,
504,
18895,
14,
8421,
492,
31264,
199,
504,
18895,
14,
8421,
492,
11424,
199,
504,
18895,
14,
8421,
492,
510,
17771,
199,
199,
504,
562,
1447,
14,
2190,
492,
485,
199,
504,
562,
1447,
14,
9923,
492,
2863,
1861,
199,
504,
562,
1447,
14,
1751,
492,
562,
1447,
1751,
12,
2202,
199,
504,
562,
1447,
14,
1907,
14,
784,
1377,
31589,
492,
12727,
421,
199,
3,
7600,
26,
577,
384,
1863,
687,
16548,
1345,
199,
318,
485,
2330,
1861,
8,
1725,
304,
272,
340,
822,
8,
1725,
9,
1137,
413,
26,
267,
1736,
694,
275,
2863,
1861,
8,
1725,
9,
272,
587,
26,
267,
1736,
694,
275,
747,
14,
515,
14,
3475,
8,
1725,
59,
16,
566,
503,
14530,
272,
372,
1736,
694,
421,
199,
533,
21447,
5619,
8,
39,
1692,
14,
39,
1692,
12,
12727,
304,
339,
636,
71,
466,
63,
354,
363,
275,
298,
11421,
5619,
2,
339,
2059,
63,
3543,
63,
1188,
275,
31264,
14,
1829,
8,
466,
29,
2245,
12,
849,
29,
797,
9,
339,
347,
636,
826,
721,
277,
12,
1676,
304,
267,
31264,
14,
39,
1692,
855,
826,
721,
277,
9,
267,
12727,
855,
826,
721,
277,
12,
298,
6737,
1345,
14,
1907,
401,
298,
3543,
7196,
531,
267,
291,
14,
1708,
275,
1676,
267,
291,
14,
3440,
14,
409,
63,
23387,
63,
509,
8,
1708,
14,
3440,
14,
362,
63,
13517,
1012,
267,
4895,
275,
1676,
423,
362,
63,
5511,
63,
1725,
342,
398,
862,
26,
288,
370,
63,
3543,
275,
1676,
14,
6737,
14,
362,
63,
1725,
63,
475,
63,
3543,
8,
5511,
9,
288,
2746,
694,
275,
1676,
14,
6737,
14,
1231,
288,
340,
370,
63,
3543,
26,
355,
370,
63,
3543,
275,
2097,
60,
84,
2,
435,
308,
367,
308,
315,
370,
63,
3543,
61,
288,
587,
26,
355,
370,
63,
3543,
275,
2097,
60,
84,
2,
435,
3824,
1944,
1584,
911,
506,
27659,
11323,
267,
871,
4279,
26,
288,
2746,
694,
275,
485,
2330,
1861,
8,
5511,
9,
288,
370,
63,
3543,
275,
2097,
60,
84,
2,
435,
308,
59,
552,
8,
2119,
694,
9,
435,
413,
2938,
367,
308,
315,
4895,
61,
267,
291,
14,
2489,
1725,
14,
409,
63,
505,
18353,
262,
450,
83,
2862,
78,
5,
83,
2,
450,
3521,
334,
2119,
694,
12,
1867,
78,
1674,
904,
8,
475,
63,
3543,
1724,
398,
291,
14,
505,
1345,
14,
8951,
63,
4246,
8,
278,
1447,
1751,
14,
4246,
9,
267,
5532,
63,
657,
4498,
275,
291,
14,
1708,
14,
6737,
14,
362,
63,
3543,
63,
1188,
63,
657,
4498,
342,
267,
340,
5532,
63,
657,
4498,
26,
288,
4123,
275,
291,
14,
505,
1345,
14,
362,
63,
2738,
342,
288,
4123,
14,
409,
63,
505,
8,
3543,
63,
657,
4498,
9,
288,
4123,
14,
2778,
63,
3937,
8,
1436,
14,
362,
63,
928,
63,
1661,
1012,
398,
327,
7649,
436,
1852,
314,
1318,
1345,
20239,
8321,
367,
282,
4465,
5939,
13,
10856,
267,
327,
5532,
1245,
14,
267,
1067,
275,
291,
14,
505,
1345,
14,
362,
63,
80,
17771,
63,
1100,
342,
267,
7186,
275,
1067,
14,
362,
63,
6759,
8,
278,
1447,
1751,
14,
4246,
12,
4228,
1067,
14,
362,
63,
3671,
1012,
267,
1495,
63,
2063,
275,
7186,
14,
362,
63,
16815,
6897,
63,
1560,
63,
2063,
342,
1182,
510,
17771,
14,
24333,
267,
291,
14,
551,
10504,
3806,
17,
14,
409,
63,
890,
63,
1069,
8,
1257,
627,
1495,
63,
2063,
12,
446,
17,
9,
398,
2202,
14,
3409,
360,
6737,
13,
2384,
13,
3543,
13,
9650,
297,
291,
14,
505,
1345,
12,
1993,
283,
2384,
13,
1019,
13,
9650,
297,
598,
2308,
14,
5268,
8198,
6381,
14,
3472,
9,
267,
2202,
14,
3409,
360,
6737,
13,
3543,
13,
9650,
297,
291,
14,
505,
1345,
12,
1993,
283,
1019,
13,
9650,
13,
3124,
297,
598,
2308,
14,
5268,
8198,
6381,
14,
3472,
9,
267,
2202,
14,
3409,
360,
6737,
13,
4785,
13,
3543,
13,
1188,
297,
291,
12,
1993,
283,
4785,
13,
3543,
13,
1188,
297,
598,
2308,
14,
5268,
8198,
6381,
14,
3472,
9,
267,
291,
14,
3440,
14,
2384,
63,
452,
342,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
657,
433,
810,
3870,
14,
409,
63,
2682,
2801,
17,
9,
267,
291,
14,
505,
1345,
14,
22090,
63,
12283,
342,
267,
1177,
275,
291,
14,
3440,
14,
1065,
342,
267,
340,
1177,
508,
11424,
14,
2364,
804,
14,
3593,
26,
288,
2498,
63,
9650,
275,
291,
14,
505,
1345,
14,
362,
63,
2384,
63,
1019,
63,
9650,
342,
288,
11042,
275,
291,
14,
505,
1345,
14,
362,
63,
1019,
63,
9650,
63,
3124,
342,
288,
4123,
275,
291,
14,
505,
1345,
14,
362,
63,
2738,
342,
288,
1499,
275,
4123,
14,
362,
63,
505,
2031,
1436,
14,
362,
63,
9632,
1062,
2387,
63,
5642,
63
] |
[
1898,
334,
35,
9,
14790,
13,
7968,
17854,
17579,
1804,
287,
7439,
89,
665,
1597,
432,
75,
32,
784,
1377,
14,
1308,
30,
199,
3,
1898,
334,
35,
9,
7129,
13,
6965,
1804,
5789,
12823,
350,
2464,
665,
75,
5789,
14,
14117,
350,
2464,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
199,
3,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
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,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
747,
199,
646,
13390,
199,
199,
504,
18895,
14,
8421,
492,
598,
2308,
199,
504,
18895,
14,
8421,
492,
31264,
199,
504,
18895,
14,
8421,
492,
11424,
199,
504,
18895,
14,
8421,
492,
510,
17771,
199,
199,
504,
562,
1447,
14,
2190,
492,
485,
199,
504,
562,
1447,
14,
9923,
492,
2863,
1861,
199,
504,
562,
1447,
14,
1751,
492,
562,
1447,
1751,
12,
2202,
199,
504,
562,
1447,
14,
1907,
14,
784,
1377,
31589,
492,
12727,
421,
199,
3,
7600,
26,
577,
384,
1863,
687,
16548,
1345,
199,
318,
485,
2330,
1861,
8,
1725,
304,
272,
340,
822,
8,
1725,
9,
1137,
413,
26,
267,
1736,
694,
275,
2863,
1861,
8,
1725,
9,
272,
587,
26,
267,
1736,
694,
275,
747,
14,
515,
14,
3475,
8,
1725,
59,
16,
566,
503,
14530,
272,
372,
1736,
694,
421,
199,
533,
21447,
5619,
8,
39,
1692,
14,
39,
1692,
12,
12727,
304,
339,
636,
71,
466,
63,
354,
363,
275,
298,
11421,
5619,
2,
339,
2059,
63,
3543,
63,
1188,
275,
31264,
14,
1829,
8,
466,
29,
2245,
12,
849,
29,
797,
9,
339,
347,
636,
826,
721,
277,
12,
1676,
304,
267,
31264,
14,
39,
1692,
855,
826,
721,
277,
9,
267,
12727,
855,
826,
721,
277,
12,
298,
6737,
1345,
14,
1907,
401,
298,
3543,
7196,
531,
267,
291,
14,
1708,
275,
1676,
267,
291,
14,
3440,
14,
409,
63,
23387,
63,
509,
8,
1708,
14,
3440,
14,
362,
63,
13517,
1012,
267,
4895,
275,
1676,
423,
362,
63,
5511,
63,
1725,
342,
398,
862,
26,
288,
370,
63,
3543,
275,
1676,
14,
6737,
14,
362,
63,
1725,
63,
475,
63,
3543,
8,
5511,
9,
288,
2746,
694,
275,
1676,
14,
6737,
14,
1231,
288,
340,
370,
63,
3543,
26,
355,
370,
63,
3543,
275,
2097,
60,
84,
2,
435,
308,
367,
308,
315,
370,
63,
3543,
61,
288,
587,
26,
355,
370,
63,
3543,
275,
2097,
60,
84,
2,
435,
3824,
1944,
1584,
911,
506,
27659,
11323,
267,
871,
4279,
26,
288,
2746,
694,
275,
485,
2330,
1861,
8,
5511,
9,
288,
370,
63,
3543,
275,
2097,
60,
84,
2,
435,
308,
59,
552,
8,
2119,
694,
9,
435,
413,
2938,
367,
308,
315,
4895,
61,
267,
291,
14,
2489,
1725,
14,
409,
63,
505,
18353,
262,
450,
83,
2862,
78,
5,
83,
2,
450,
3521,
334,
2119,
694,
12,
1867,
78,
1674,
904,
8,
475,
63,
3543,
1724,
398,
291,
14,
505,
1345,
14,
8951,
63,
4246,
8,
278,
1447,
1751,
14,
4246,
9,
267,
5532,
63,
657,
4498,
275,
291,
14,
1708,
14,
6737,
14,
362,
63,
3543,
63,
1188,
63,
657,
4498,
342,
267,
340,
5532,
63,
657,
4498,
26,
288,
4123,
275,
291,
14,
505,
1345,
14,
362,
63,
2738,
342,
288,
4123,
14,
409,
63,
505,
8,
3543,
63,
657,
4498,
9,
288,
4123,
14,
2778,
63,
3937,
8,
1436,
14,
362,
63,
928,
63,
1661,
1012,
398,
327,
7649,
436,
1852,
314,
1318,
1345,
20239,
8321,
367,
282,
4465,
5939,
13,
10856,
267,
327,
5532,
1245,
14,
267,
1067,
275,
291,
14,
505,
1345,
14,
362,
63,
80,
17771,
63,
1100,
342,
267,
7186,
275,
1067,
14,
362,
63,
6759,
8,
278,
1447,
1751,
14,
4246,
12,
4228,
1067,
14,
362,
63,
3671,
1012,
267,
1495,
63,
2063,
275,
7186,
14,
362,
63,
16815,
6897,
63,
1560,
63,
2063,
342,
1182,
510,
17771,
14,
24333,
267,
291,
14,
551,
10504,
3806,
17,
14,
409,
63,
890,
63,
1069,
8,
1257,
627,
1495,
63,
2063,
12,
446,
17,
9,
398,
2202,
14,
3409,
360,
6737,
13,
2384,
13,
3543,
13,
9650,
297,
291,
14,
505,
1345,
12,
1993,
283,
2384,
13,
1019,
13,
9650,
297,
598,
2308,
14,
5268,
8198,
6381,
14,
3472,
9,
267,
2202,
14,
3409,
360,
6737,
13,
3543,
13,
9650,
297,
291,
14,
505,
1345,
12,
1993,
283,
1019,
13,
9650,
13,
3124,
297,
598,
2308,
14,
5268,
8198,
6381,
14,
3472,
9,
267,
2202,
14,
3409,
360,
6737,
13,
4785,
13,
3543,
13,
1188,
297,
291,
12,
1993,
283,
4785,
13,
3543,
13,
1188,
297,
598,
2308,
14,
5268,
8198,
6381,
14,
3472,
9,
267,
291,
14,
3440,
14,
2384,
63,
452,
342,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
657,
433,
810,
3870,
14,
409,
63,
2682,
2801,
17,
9,
267,
291,
14,
505,
1345,
14,
22090,
63,
12283,
342,
267,
1177,
275,
291,
14,
3440,
14,
1065,
342,
267,
340,
1177,
508,
11424,
14,
2364,
804,
14,
3593,
26,
288,
2498,
63,
9650,
275,
291,
14,
505,
1345,
14,
362,
63,
2384,
63,
1019,
63,
9650,
342,
288,
11042,
275,
291,
14,
505,
1345,
14,
362,
63,
1019,
63,
9650,
63,
3124,
342,
288,
4123,
275,
291,
14,
505,
1345,
14,
362,
63,
2738,
342,
288,
1499,
275,
4123,
14,
362,
63,
505,
2031,
1436,
14,
362,
63,
9632,
1062,
2387,
63,
5642,
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,
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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
] |
kongseokhwan/kulcloud-iitp-neutron
|
neutron/db/migration/models/frozen.py
|
26
|
72356
|
# Copyright (c) 2014 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.
"""
The module provides all database models.
Its purpose is to create comparable metadata with current database schema.
Based on this comparison database can be healed with healing migration.
Current HEAD commit is 59da928e945ec58836d34fd561d30a8a446e2728
"""
import sqlalchemy as sa
from sqlalchemy.ext import declarative
from sqlalchemy.ext.orderinglist import ordering_list
from sqlalchemy import orm
from sqlalchemy import schema
from neutron.db import model_base
from neutron.openstack.common import uuidutils
# Dictionary of all tables that was renamed:
# {new_table_name: old_table_name}
renamed_tables = {
'subnetroutes': 'routes',
'cisco_credentials': 'credentials',
'cisco_nexusport_bindings': 'nexusport_bindings',
'cisco_qos_policies': 'qoss',
'tz_network_bindings': 'nvp_network_bindings',
'multi_provider_networks': 'nvp_multi_provider_networks',
'net_partitions': 'nuage_net_partitions',
'net_partition_router_mapping': 'nuage_net_partition_router_mapping',
'router_zone_mapping': 'nuage_router_zone_mapping',
'subnet_l2dom_mapping': 'nuage_subnet_l2dom_mapping',
'port_mapping': 'nuage_port_mapping',
'routerroutes_mapping': 'nuage_routerroutes_mapping',
}
#neutron/plugins/ml2/drivers/mech_arista/db.py
UUID_LEN = 36
STR_LEN = 255
#neutron/plugins/cisco/common/cisco_constants.py
CISCO_CONSTANTS_NETWORK_TYPE_VLAN = 'vlan'
CISCO_CONSTANTS_NETWORK_TYPE_OVERLAY = 'overlay'
CISCO_CONSTANTS_NETWORK_TYPE_TRUNK = 'trunk'
CISCO_CONSTANTS_NETWORK_TYPE_MULTI_SEGMENT = 'multi-segment'
CISCO_CONSTANTS_NETWORK = 'network'
CISCO_CONSTANTS_POLICY = 'policy'
CISCO_CONSTANTS_TENANT_ID_NOT_SET = 'TENANT_ID_NOT_SET'
#neutron/plugins/ml2/models.py
BINDING_PROFILE_LEN = 4095
#neutron/extensions/portbindings.py
VNIC_NORMAL = 'normal'
#neutron/common/constants.py
IPV6_SLAAC = 'slaac'
DHCPV6_STATEFUL = 'dhcpv6-stateful'
DHCPV6_STATELESS = 'dhcpv6-stateless'
BASEV2 = declarative.declarative_base(cls=model_base.NeutronBaseV2)
#neutron/db/models_v2.py
class HasTenant(object):
tenant_id = sa.Column(sa.String(255))
#neutron/db/models_v2.py
class HasId(object):
id = sa.Column(sa.String(36),
primary_key=True,
default=uuidutils.generate_uuid)
#neutron/db/models_v2.py
class HasStatusDescription(object):
status = sa.Column(sa.String(16), nullable=False)
status_description = sa.Column(sa.String(255))
#neutron/db/models_v2.py
class IPAvailabilityRange(BASEV2):
allocation_pool_id = sa.Column(sa.String(36),
sa.ForeignKey('ipallocationpools.id',
ondelete="CASCADE"),
nullable=False,
primary_key=True)
first_ip = sa.Column(sa.String(64), nullable=False, primary_key=True)
last_ip = sa.Column(sa.String(64), nullable=False, primary_key=True)
#neutron/db/models_v2.py
class IPAllocationPool(BASEV2, HasId):
subnet_id = sa.Column(sa.String(36), sa.ForeignKey('subnets.id',
ondelete="CASCADE"),
nullable=True)
first_ip = sa.Column(sa.String(64), nullable=False)
last_ip = sa.Column(sa.String(64), nullable=False)
available_ranges = orm.relationship(IPAvailabilityRange,
backref='ipallocationpool',
lazy="joined",
cascade='all, delete-orphan')
#neutron/db/models_v2.py
class IPAllocation(BASEV2):
port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id',
ondelete="CASCADE"),
nullable=True)
ip_address = sa.Column(sa.String(64), nullable=False, primary_key=True)
subnet_id = sa.Column(sa.String(36), sa.ForeignKey('subnets.id',
ondelete="CASCADE"),
nullable=False, primary_key=True)
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id",
ondelete="CASCADE"),
nullable=False, primary_key=True)
#neutron/db/models_v2.py
class Route(object):
destination = sa.Column(sa.String(64), nullable=False, primary_key=True)
nexthop = sa.Column(sa.String(64), nullable=False, primary_key=True)
#neutron/db/models_v2.py
class SubnetRoute(BASEV2, Route):
subnet_id = sa.Column(sa.String(36),
sa.ForeignKey('subnets.id',
ondelete="CASCADE"),
primary_key=True)
#neutron/db/models_v2.py
class Port(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"),
nullable=False)
fixed_ips = orm.relationship(IPAllocation, backref='ports', lazy='joined')
mac_address = sa.Column(sa.String(32), nullable=False)
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
status = sa.Column(sa.String(16), nullable=False)
device_id = sa.Column(sa.String(255), nullable=False)
device_owner = sa.Column(sa.String(255), nullable=False)
#neutron/db/models_v2.py
class DNSNameServer(BASEV2):
address = sa.Column(sa.String(128), nullable=False, primary_key=True)
subnet_id = sa.Column(sa.String(36),
sa.ForeignKey('subnets.id',
ondelete="CASCADE"),
primary_key=True)
#neutron/db/models_v2.py
class Subnet(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
network_id = sa.Column(sa.String(36), sa.ForeignKey('networks.id'))
ip_version = sa.Column(sa.Integer, nullable=False)
cidr = sa.Column(sa.String(64), nullable=False)
gateway_ip = sa.Column(sa.String(64))
allocation_pools = orm.relationship(IPAllocationPool,
backref='subnet',
lazy="joined",
cascade='delete')
enable_dhcp = sa.Column(sa.Boolean())
dns_nameservers = orm.relationship(DNSNameServer,
backref='subnet',
cascade='all, delete, delete-orphan')
routes = orm.relationship(SubnetRoute,
backref='subnet',
cascade='all, delete, delete-orphan')
shared = sa.Column(sa.Boolean)
ipv6_ra_mode = sa.Column(sa.Enum(IPV6_SLAAC,
DHCPV6_STATEFUL,
DHCPV6_STATELESS,
name='ipv6_ra_modes'), nullable=True)
ipv6_address_mode = sa.Column(sa.Enum(IPV6_SLAAC,
DHCPV6_STATEFUL,
DHCPV6_STATELESS,
name='ipv6_address_modes'),
nullable=True)
#neutron/db/models_v2.py
class Network(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
ports = orm.relationship(Port, backref='networks')
subnets = orm.relationship(Subnet, backref='networks',
lazy="joined")
status = sa.Column(sa.String(16))
admin_state_up = sa.Column(sa.Boolean)
shared = sa.Column(sa.Boolean)
#neutron/db/agents_db.py
class Agent(BASEV2, HasId):
__table_args__ = (
sa.UniqueConstraint('agent_type', 'host',
name='uniq_agents0agent_type0host'),
)
agent_type = sa.Column(sa.String(255), nullable=False)
binary = sa.Column(sa.String(255), nullable=False)
topic = sa.Column(sa.String(255), nullable=False)
host = sa.Column(sa.String(255), nullable=False)
admin_state_up = sa.Column(sa.Boolean, default=True,
server_default=sa.sql.true(), nullable=False)
created_at = sa.Column(sa.DateTime, nullable=False)
started_at = sa.Column(sa.DateTime, nullable=False)
heartbeat_timestamp = sa.Column(sa.DateTime, nullable=False)
description = sa.Column(sa.String(255))
configurations = sa.Column(sa.String(4095), nullable=False)
#neutron/db/agentschedulers_db.py
class NetworkDhcpAgentBinding(BASEV2):
network_id = sa.Column(sa.String(36),
sa.ForeignKey("networks.id", ondelete='CASCADE'),
primary_key=True)
dhcp_agent = orm.relation(Agent)
dhcp_agent_id = sa.Column(sa.String(36),
sa.ForeignKey("agents.id",
ondelete='CASCADE'),
primary_key=True)
#neutron/db/allowedaddresspairs_db.py
class AllowedAddressPair(BASEV2):
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
mac_address = sa.Column(sa.String(32), nullable=False, primary_key=True)
ip_address = sa.Column(sa.String(64), nullable=False, primary_key=True)
port = orm.relationship(
Port,
backref=orm.backref("allowed_address_pairs",
lazy="joined", cascade="delete"))
#neutron/db/external_net_db.py
class ExternalNetwork(BASEV2):
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
network = orm.relationship(
Network,
backref=orm.backref("external", lazy='joined',
uselist=False, cascade='delete'))
#neutron/db/extradhcpopt_db.py
class ExtraDhcpOpt(BASEV2, HasId):
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
nullable=False)
opt_name = sa.Column(sa.String(64), nullable=False)
opt_value = sa.Column(sa.String(255), nullable=False)
__table_args__ = (sa.UniqueConstraint('port_id',
'opt_name',
name='uidx_portid_optname'),
BASEV2.__table_args__,)
ports = orm.relationship(
Port,
backref=orm.backref("dhcp_opts", lazy='joined', cascade='delete'))
#neutron/db/l3_db.py
class Router(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
status = sa.Column(sa.String(16))
admin_state_up = sa.Column(sa.Boolean)
gw_port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
gw_port = orm.relationship(Port, lazy='joined')
enable_snat = sa.Column(sa.Boolean, default=True,
server_default=sa.sql.true(), nullable=False)
#neutron/db/l3_db.py
class FloatingIP(BASEV2, HasId, HasTenant):
floating_ip_address = sa.Column(sa.String(64), nullable=False)
floating_network_id = sa.Column(sa.String(36), nullable=False)
floating_port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'),
nullable=False)
fixed_port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
fixed_ip_address = sa.Column(sa.String(64))
router_id = sa.Column(sa.String(36), sa.ForeignKey('routers.id'))
last_known_router_id = sa.Column(sa.String(36))
status = sa.Column(sa.String(16))
#neutron/db/extraroute_db.py
class RouterRoute(BASEV2, Route):
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id',
ondelete="CASCADE"),
primary_key=True)
router = orm.relationship(Router,
backref=orm.backref("route_list",
lazy='joined',
cascade='delete'))
#neutron/db/servicetype_db.py
class ProviderResourceAssociation(BASEV2):
provider_name = sa.Column(sa.String(255),
nullable=False, primary_key=True)
resource_id = sa.Column(sa.String(36), nullable=False, primary_key=True,
unique=True)
#neutron/db/firewall/firewall_db.py
class FirewallRule(BASEV2, HasId, HasTenant):
__tablename__ = 'firewall_rules'
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(1024))
firewall_policy_id = sa.Column(sa.String(36),
sa.ForeignKey('firewall_policies.id'),
nullable=True)
shared = sa.Column(sa.Boolean)
protocol = sa.Column(sa.String(40))
ip_version = sa.Column(sa.Integer, nullable=False)
source_ip_address = sa.Column(sa.String(46))
destination_ip_address = sa.Column(sa.String(46))
source_port_range_min = sa.Column(sa.Integer)
source_port_range_max = sa.Column(sa.Integer)
destination_port_range_min = sa.Column(sa.Integer)
destination_port_range_max = sa.Column(sa.Integer)
action = sa.Column(sa.Enum('allow', 'deny', name='firewallrules_action'))
enabled = sa.Column(sa.Boolean)
position = sa.Column(sa.Integer)
#neutron/db/firewall/firewall_db.py
class Firewall(BASEV2, HasId, HasTenant):
__tablename__ = 'firewalls'
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(1024))
shared = sa.Column(sa.Boolean)
admin_state_up = sa.Column(sa.Boolean)
status = sa.Column(sa.String(16))
firewall_policy_id = sa.Column(sa.String(36),
sa.ForeignKey('firewall_policies.id'),
nullable=True)
#neutron/db/firewall/firewall_db.py
class FirewallPolicy(BASEV2, HasId, HasTenant):
__tablename__ = 'firewall_policies'
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(1024))
shared = sa.Column(sa.Boolean)
firewall_rules = orm.relationship(
FirewallRule,
backref=orm.backref('firewall_policies', cascade='all, delete'),
order_by='FirewallRule.position',
collection_class=ordering_list('position', count_from=1))
audited = sa.Column(sa.Boolean)
firewalls = orm.relationship(Firewall, backref='firewall_policies')
#neutron/db/l3_agentschedulers_db.py
class RouterL3AgentBinding(BASEV2, HasId):
router_id = sa.Column(sa.String(36),
sa.ForeignKey("routers.id", ondelete='CASCADE'))
l3_agent = orm.relation(Agent)
l3_agent_id = sa.Column(sa.String(36),
sa.ForeignKey("agents.id",
ondelete='CASCADE'))
#neutron/db/loadbalancer/loadbalancer_db.py
class SessionPersistence(BASEV2):
vip_id = sa.Column(sa.String(36),
sa.ForeignKey("vips.id"),
primary_key=True)
type = sa.Column(sa.Enum("SOURCE_IP",
"HTTP_COOKIE",
"APP_COOKIE",
name="sesssionpersistences_type"),
nullable=False)
cookie_name = sa.Column(sa.String(1024))
#neutron/db/loadbalancer/loadbalancer_db.py
class PoolStatistics(BASEV2):
pool_id = sa.Column(sa.String(36), sa.ForeignKey("pools.id"),
primary_key=True)
bytes_in = sa.Column(sa.BigInteger, nullable=False)
bytes_out = sa.Column(sa.BigInteger, nullable=False)
active_connections = sa.Column(sa.BigInteger, nullable=False)
total_connections = sa.Column(sa.BigInteger, nullable=False)
#neutron/db/loadbalancer/loadbalancer_db.py
class Vip(BASEV2, HasId, HasTenant, HasStatusDescription):
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(255))
port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
protocol_port = sa.Column(sa.Integer, nullable=False)
protocol = sa.Column(sa.Enum("HTTP", "HTTPS", "TCP", name="lb_protocols"),
nullable=False)
pool_id = sa.Column(sa.String(36), nullable=False, unique=True)
session_persistence = orm.relationship(SessionPersistence,
uselist=False,
backref="vips",
cascade="all, delete-orphan")
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
connection_limit = sa.Column(sa.Integer)
port = orm.relationship(Port)
#neutron/db/loadbalancer/loadbalancer_db.py
class Member(BASEV2, HasId, HasTenant, HasStatusDescription):
__table_args__ = (
sa.schema.UniqueConstraint('pool_id', 'address', 'protocol_port',
name='uniq_member0pool_id0address0port'),
)
pool_id = sa.Column(sa.String(36), sa.ForeignKey("pools.id"),
nullable=False)
address = sa.Column(sa.String(64), nullable=False)
protocol_port = sa.Column(sa.Integer, nullable=False)
weight = sa.Column(sa.Integer, nullable=False)
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
#neutron/db/loadbalancer/loadbalancer_db.py
class Pool(BASEV2, HasId, HasTenant, HasStatusDescription):
vip_id = sa.Column(sa.String(36), sa.ForeignKey("vips.id"))
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(255))
subnet_id = sa.Column(sa.String(36), nullable=False)
protocol = sa.Column(sa.Enum("HTTP", "HTTPS", "TCP", name="lb_protocols"),
nullable=False)
lb_method = sa.Column(sa.Enum("ROUND_ROBIN",
"LEAST_CONNECTIONS",
"SOURCE_IP",
name="pools_lb_method"),
nullable=False)
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
stats = orm.relationship(PoolStatistics,
uselist=False,
backref="pools",
cascade="all, delete-orphan")
members = orm.relationship(Member, backref="pools",
cascade="all, delete-orphan")
monitors = orm.relationship("PoolMonitorAssociation", backref="pools",
cascade="all, delete-orphan")
vip = orm.relationship(Vip, backref='pool')
provider = orm.relationship(
ProviderResourceAssociation,
uselist=False,
lazy="joined",
primaryjoin="Pool.id==ProviderResourceAssociation.resource_id",
foreign_keys=[ProviderResourceAssociation.resource_id]
)
#neutron/db/loadbalancer/loadbalancer_db.py
class HealthMonitor(BASEV2, HasId, HasTenant):
type = sa.Column(sa.Enum("PING", "TCP", "HTTP", "HTTPS",
name="healthmontiors_type"),
nullable=False)
delay = sa.Column(sa.Integer, nullable=False)
timeout = sa.Column(sa.Integer, nullable=False)
max_retries = sa.Column(sa.Integer, nullable=False)
http_method = sa.Column(sa.String(16))
url_path = sa.Column(sa.String(255))
expected_codes = sa.Column(sa.String(64))
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
pools = orm.relationship(
"PoolMonitorAssociation", backref="healthmonitor",
cascade="all", lazy="joined"
)
#neutron/db/loadbalancer/loadbalancer_db.py
class PoolMonitorAssociation(BASEV2, HasStatusDescription):
pool_id = sa.Column(sa.String(36),
sa.ForeignKey("pools.id"),
primary_key=True)
monitor_id = sa.Column(sa.String(36),
sa.ForeignKey("healthmonitors.id"),
primary_key=True)
#neutron/db/metering/metering_db.py
class MeteringLabelRule(BASEV2, HasId):
direction = sa.Column(sa.Enum('ingress', 'egress',
name='meteringlabels_direction'))
remote_ip_prefix = sa.Column(sa.String(64))
metering_label_id = sa.Column(sa.String(36),
sa.ForeignKey("meteringlabels.id",
ondelete="CASCADE"),
nullable=False)
excluded = sa.Column(sa.Boolean, default=False,
server_default=sa.sql.false())
#neutron/db/metering/metering_db.py
class MeteringLabel(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(1024))
rules = orm.relationship(MeteringLabelRule, backref="label",
cascade="delete", lazy="joined")
routers = orm.relationship(
Router,
primaryjoin="MeteringLabel.tenant_id==Router.tenant_id",
foreign_keys='MeteringLabel.tenant_id',
uselist=True)
#neutron/db/portbindings_db.py
class PortBindingPort(BASEV2):
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
host = sa.Column(sa.String(255), nullable=False)
port = orm.relationship(
Port,
backref=orm.backref("portbinding",
lazy='joined', uselist=False,
cascade='delete'))
#neutron/db/portsecurity_db.py
class PortSecurityBinding(BASEV2):
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
port_security_enabled = sa.Column(sa.Boolean(), nullable=False)
port = orm.relationship(
Port,
backref=orm.backref("port_security", uselist=False,
cascade='delete', lazy='joined'))
#neutron/db/portsecurity_db.py
class NetworkSecurityBinding(BASEV2):
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
port_security_enabled = sa.Column(sa.Boolean(), nullable=False)
network = orm.relationship(
Network,
backref=orm.backref("port_security", uselist=False,
cascade='delete', lazy='joined'))
#neutron/db/quota_db.py
class Quota(BASEV2, HasId):
tenant_id = sa.Column(sa.String(255), index=True)
resource = sa.Column(sa.String(255))
limit = sa.Column(sa.Integer)
#neutron/db/routedserviceinsertion_db.py
class ServiceRouterBinding(BASEV2):
resource_id = sa.Column(sa.String(36),
primary_key=True)
resource_type = sa.Column(sa.String(36),
primary_key=True)
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id'),
nullable=False)
#neutron/db/routerservicetype_db.py
class RouterServiceTypeBinding(BASEV2):
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id', ondelete="CASCADE"),
primary_key=True)
service_type_id = sa.Column(sa.String(36),
nullable=False)
#neutron/db/securitygroups_db.py
class SecurityGroup(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(255))
#neutron/db/securitygroups_db.py
class SecurityGroupPortBinding(BASEV2):
port_id = sa.Column(sa.String(36),
sa.ForeignKey("ports.id",
ondelete='CASCADE'),
primary_key=True)
security_group_id = sa.Column(sa.String(36),
sa.ForeignKey("securitygroups.id"),
primary_key=True)
# Add a relationship to the Port model in order to instruct SQLAlchemy to
# eagerly load security group bindings
ports = orm.relationship(
Port,
backref=orm.backref("security_groups",
lazy='joined', cascade='delete'))
#neutron/db/securitygroups_db.py
class SecurityGroupRule(BASEV2, HasId,
HasTenant):
security_group_id = sa.Column(sa.String(36),
sa.ForeignKey("securitygroups.id",
ondelete="CASCADE"),
nullable=False)
remote_group_id = sa.Column(sa.String(36),
sa.ForeignKey("securitygroups.id",
ondelete="CASCADE"),
nullable=True)
direction = sa.Column(sa.Enum('ingress', 'egress',
name='securitygrouprules_direction'))
ethertype = sa.Column(sa.String(40))
protocol = sa.Column(sa.String(40))
port_range_min = sa.Column(sa.Integer)
port_range_max = sa.Column(sa.Integer)
remote_ip_prefix = sa.Column(sa.String(255))
security_group = orm.relationship(
SecurityGroup,
backref=orm.backref('rules', cascade='all,delete'),
primaryjoin="SecurityGroup.id==SecurityGroupRule.security_group_id")
source_group = orm.relationship(
SecurityGroup,
backref=orm.backref('source_rules', cascade='all,delete'),
primaryjoin="SecurityGroup.id==SecurityGroupRule.remote_group_id")
#neutron/db/vpn/vpn_db.py
class IPsecPeerCidr(BASEV2):
cidr = sa.Column(sa.String(32), nullable=False, primary_key=True)
ipsec_site_connection_id = sa.Column(
sa.String(36),
sa.ForeignKey('ipsec_site_connections.id',
ondelete="CASCADE"),
primary_key=True)
#neutron/db/vpn/vpn_db.py
class IPsecPolicy(BASEV2, HasId, HasTenant):
__tablename__ = 'ipsecpolicies'
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(255))
transform_protocol = sa.Column(sa.Enum("esp", "ah", "ah-esp",
name="ipsec_transform_protocols"),
nullable=False)
auth_algorithm = sa.Column(sa.Enum("sha1",
name="vpn_auth_algorithms"),
nullable=False)
encryption_algorithm = sa.Column(sa.Enum("3des", "aes-128",
"aes-256", "aes-192",
name="vpn_encrypt_algorithms"),
nullable=False)
encapsulation_mode = sa.Column(sa.Enum("tunnel", "transport",
name="ipsec_encapsulations"),
nullable=False)
lifetime_units = sa.Column(sa.Enum("seconds", "kilobytes",
name="vpn_lifetime_units"),
nullable=False)
lifetime_value = sa.Column(sa.Integer, nullable=False)
pfs = sa.Column(sa.Enum("group2", "group5", "group14",
name="vpn_pfs"), nullable=False)
#neutron/db/vpn/vpn_db.py
class IKEPolicy(BASEV2, HasId, HasTenant):
__tablename__ = 'ikepolicies'
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(255))
auth_algorithm = sa.Column(sa.Enum("sha1",
name="vpn_auth_algorithms"),
nullable=False)
encryption_algorithm = sa.Column(sa.Enum("3des", "aes-128",
"aes-256", "aes-192",
name="vpn_encrypt_algorithms"),
nullable=False)
phase1_negotiation_mode = sa.Column(sa.Enum("main",
name="ike_phase1_mode"),
nullable=False)
lifetime_units = sa.Column(sa.Enum("seconds", "kilobytes",
name="vpn_lifetime_units"),
nullable=False)
lifetime_value = sa.Column(sa.Integer, nullable=False)
ike_version = sa.Column(sa.Enum("v1", "v2", name="ike_versions"),
nullable=False)
pfs = sa.Column(sa.Enum("group2", "group5", "group14",
name="vpn_pfs"), nullable=False)
#neutron/db/vpn/vpn_db.py
class IPsecSiteConnection(BASEV2,
HasId, HasTenant):
__tablename__ = 'ipsec_site_connections'
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(255))
peer_address = sa.Column(sa.String(255), nullable=False)
peer_id = sa.Column(sa.String(255), nullable=False)
route_mode = sa.Column(sa.String(8), nullable=False)
mtu = sa.Column(sa.Integer, nullable=False)
initiator = sa.Column(sa.Enum("bi-directional", "response-only",
name="vpn_initiators"), nullable=False)
auth_mode = sa.Column(sa.String(16), nullable=False)
psk = sa.Column(sa.String(255), nullable=False)
dpd_action = sa.Column(sa.Enum("hold", "clear",
"restart", "disabled",
"restart-by-peer", name="vpn_dpd_actions"),
nullable=False)
dpd_interval = sa.Column(sa.Integer, nullable=False)
dpd_timeout = sa.Column(sa.Integer, nullable=False)
status = sa.Column(sa.String(16), nullable=False)
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
vpnservice_id = sa.Column(sa.String(36),
sa.ForeignKey('vpnservices.id'),
nullable=False)
ipsecpolicy_id = sa.Column(sa.String(36),
sa.ForeignKey('ipsecpolicies.id'),
nullable=False)
ikepolicy_id = sa.Column(sa.String(36),
sa.ForeignKey('ikepolicies.id'),
nullable=False)
ipsecpolicy = orm.relationship(
IPsecPolicy, backref='ipsec_site_connection')
ikepolicy = orm.relationship(IKEPolicy, backref='ipsec_site_connection')
peer_cidrs = orm.relationship(IPsecPeerCidr,
backref='ipsec_site_connection',
lazy='joined',
cascade='all, delete, delete-orphan')
#neutron/db/vpn/vpn_db.py
class VPNService(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
description = sa.Column(sa.String(255))
status = sa.Column(sa.String(16), nullable=False)
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
subnet_id = sa.Column(sa.String(36), sa.ForeignKey('subnets.id'),
nullable=False)
router_id = sa.Column(sa.String(36), sa.ForeignKey('routers.id'),
nullable=False)
subnet = orm.relationship(Subnet)
router = orm.relationship(Router)
ipsec_site_connections = orm.relationship(
IPsecSiteConnection,
backref='vpnservice',
cascade="all, delete-orphan")
#neutron/plugins/bigswitch/db/consistency_db.py
class ConsistencyHash(BASEV2):
__tablename__ = 'consistencyhashes'
hash_id = sa.Column(sa.String(255),
primary_key=True)
hash = sa.Column(sa.String(255), nullable=False)
#neutron/plugins/bigswitch/routerrule_db.py
class RouterRule(BASEV2):
id = sa.Column(sa.Integer, primary_key=True)
source = sa.Column(sa.String(64), nullable=False)
destination = sa.Column(sa.String(64), nullable=False)
nexthops = orm.relationship('NextHop', cascade='all,delete')
action = sa.Column(sa.String(10), nullable=False)
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id',
ondelete="CASCADE"))
#neutron/plugins/bigswitch/routerrule_db.py
class NextHop(BASEV2):
rule_id = sa.Column(sa.Integer,
sa.ForeignKey('routerrules.id',
ondelete="CASCADE"),
primary_key=True)
nexthop = sa.Column(sa.String(64), nullable=False, primary_key=True)
#neutron/plugins/brocade/db/models.py
class BrocadeNetwork(BASEV2, HasId):
vlan = sa.Column(sa.String(10))
#neutron/plugins/brocade/db/models.py
class BrocadePort(BASEV2):
port_id = sa.Column(sa.String(36), primary_key=True, default="",
server_default='')
network_id = sa.Column(sa.String(36),
sa.ForeignKey("brocadenetworks.id"),
nullable=False)
admin_state_up = sa.Column(sa.Boolean, nullable=False)
physical_interface = sa.Column(sa.String(36))
vlan_id = sa.Column(sa.String(36))
tenant_id = sa.Column(sa.String(36))
#neutron/plugins/cisco/db/n1kv_models_v2.py
class N1kvVlanAllocation(BASEV2):
__tablename__ = 'cisco_n1kv_vlan_allocations'
physical_network = sa.Column(sa.String(64),
nullable=False,
primary_key=True)
vlan_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False, default=False,
server_default=sa.sql.false())
network_profile_id = sa.Column(sa.String(36),
sa.ForeignKey('cisco_network_profiles.id',
ondelete="CASCADE"),
nullable=False)
#neutron/plugins/cisco/db/n1kv_models_v2.py
class N1kvVxlanAllocation(BASEV2):
__tablename__ = 'cisco_n1kv_vxlan_allocations'
vxlan_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False, default=False,
server_default=sa.sql.false())
network_profile_id = sa.Column(sa.String(36),
sa.ForeignKey('cisco_network_profiles.id',
ondelete="CASCADE"),
nullable=False)
#neutron/plugins/cisco/db/n1kv_models_v2.py
class N1kvPortBinding(BASEV2):
__tablename__ = 'cisco_n1kv_port_bindings'
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
profile_id = sa.Column(sa.String(36),
sa.ForeignKey('cisco_policy_profiles.id'))
#neutron/plugins/cisco/db/n1kv_models_v2.py
class N1kvNetworkBinding(BASEV2):
__tablename__ = 'cisco_n1kv_network_bindings'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
network_type = sa.Column(sa.String(32), nullable=False)
physical_network = sa.Column(sa.String(64))
segmentation_id = sa.Column(sa.Integer)
multicast_ip = sa.Column(sa.String(32))
profile_id = sa.Column(sa.String(36),
sa.ForeignKey('cisco_network_profiles.id'))
#neutron/plugins/cisco/db/n1kv_models_v2.py
class N1kVmNetwork(BASEV2):
__tablename__ = 'cisco_n1kv_vmnetworks'
name = sa.Column(sa.String(80), primary_key=True)
profile_id = sa.Column(sa.String(36),
sa.ForeignKey('cisco_policy_profiles.id'))
network_id = sa.Column(sa.String(36))
port_count = sa.Column(sa.Integer)
#neutron/plugins/cisco/db/n1kv_models_v2.py
class NetworkProfile(BASEV2, HasId):
__tablename__ = 'cisco_network_profiles'
name = sa.Column(sa.String(255))
segment_type = sa.Column(
sa.Enum(CISCO_CONSTANTS_NETWORK_TYPE_VLAN,
CISCO_CONSTANTS_NETWORK_TYPE_OVERLAY,
CISCO_CONSTANTS_NETWORK_TYPE_TRUNK,
CISCO_CONSTANTS_NETWORK_TYPE_MULTI_SEGMENT,
name='segment_type'),
nullable=False)
sub_type = sa.Column(sa.String(255))
segment_range = sa.Column(sa.String(255))
multicast_ip_index = sa.Column(sa.Integer, default=0,
server_default='0')
multicast_ip_range = sa.Column(sa.String(255))
physical_network = sa.Column(sa.String(255))
#neutron/plugins/cisco/db/n1kv_models_v2.py
class PolicyProfile(BASEV2):
__tablename__ = 'cisco_policy_profiles'
id = sa.Column(sa.String(36), primary_key=True)
name = sa.Column(sa.String(255))
#neutron/plugins/cisco/db/n1kv_models_v2.py
class ProfileBinding(BASEV2):
__tablename__ = 'cisco_n1kv_profile_bindings'
profile_type = sa.Column(sa.Enum(CISCO_CONSTANTS_NETWORK,
CISCO_CONSTANTS_POLICY,
name='profile_type'))
tenant_id = sa.Column(sa.String(36),
primary_key=True,
default=CISCO_CONSTANTS_TENANT_ID_NOT_SET,
server_default=CISCO_CONSTANTS_TENANT_ID_NOT_SET)
profile_id = sa.Column(sa.String(36), primary_key=True)
#neutron/plugins/cisco/db/n1kv_models_v2.py
class N1kvTrunkSegmentBinding(BASEV2):
__tablename__ = 'cisco_n1kv_trunk_segments'
trunk_segment_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id',
ondelete="CASCADE"),
primary_key=True)
segment_id = sa.Column(sa.String(36), nullable=False, primary_key=True)
dot1qtag = sa.Column(sa.String(36), nullable=False, primary_key=True)
#neutron/plugins/cisco/db/n1kv_models_v2.py
class N1kvMultiSegmentNetworkBinding(BASEV2):
__tablename__ = 'cisco_n1kv_multi_segments'
multi_segment_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id',
ondelete="CASCADE"),
primary_key=True)
segment1_id = sa.Column(sa.String(36), nullable=False, primary_key=True)
segment2_id = sa.Column(sa.String(36), nullable=False, primary_key=True)
encap_profile_name = sa.Column(sa.String(36))
#neutron/plugins/cisco/db/network_models_v2.py
class QoS(BASEV2):
__tablename__ = 'cisco_qos_policies'
qos_id = sa.Column(sa.String(255))
tenant_id = sa.Column(sa.String(255), primary_key=True)
qos_name = sa.Column(sa.String(255), primary_key=True)
qos_desc = sa.Column(sa.String(255))
#neutron/plugins/cisco/db/network_models_v2.py
class Credential(BASEV2):
__tablename__ = 'cisco_credentials'
credential_id = sa.Column(sa.String(255))
credential_name = sa.Column(sa.String(255), primary_key=True)
user_name = sa.Column(sa.String(255))
password = sa.Column(sa.String(255))
type = sa.Column(sa.String(255))
#neutron/plugins/cisco/db/network_models_v2.py
class ProviderNetwork(BASEV2):
__tablename__ = 'cisco_provider_networks'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
network_type = sa.Column(sa.String(255), nullable=False)
segmentation_id = sa.Column(sa.Integer, nullable=False)
#neutron/plugins/cisco/db/nexus_models_v2.py
#class was renamed from NexusPortBinding to CiscoNexusPortBinding
class CiscoNexusPortBinding(BASEV2):
__tablename__ = "cisco_nexusport_bindings"
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
port_id = sa.Column(sa.String(255))
vlan_id = sa.Column(sa.Integer, nullable=False)
switch_ip = sa.Column(sa.String(255), nullable=False)
instance_id = sa.Column(sa.String(255), nullable=False)
#neutron/plugins/hyperv/model.py
#class was renamed from VlanAllocation to HyperVVlanAllocation
class HyperVVlanAllocation(BASEV2):
__tablename__ = 'hyperv_vlan_allocations'
physical_network = sa.Column(sa.String(64),
nullable=False,
primary_key=True)
vlan_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False)
#neutron/plugins/hyperv/model.py
#class was renamed from NetworkBinding to HyperVNetworkBinding
class HyperVNetworkBinding(BASEV2):
__tablename__ = 'hyperv_network_bindings'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
network_type = sa.Column(sa.String(32), nullable=False)
physical_network = sa.Column(sa.String(64))
segmentation_id = sa.Column(sa.Integer)
#neutron/plugins/linuxbridge/db/l2network_models_v2.py
class NetworkState(BASEV2):
__tablename__ = 'network_states'
physical_network = sa.Column(sa.String(64), nullable=False,
primary_key=True)
vlan_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False)
#neutron/plugins/linuxbridge/db/l2network_models_v2.py
class NetworkBinding(BASEV2):
__tablename__ = 'network_bindings'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
physical_network = sa.Column(sa.String(64))
vlan_id = sa.Column(sa.Integer, nullable=False)
#neutron/plugins/metaplugin/meta_models_v2.py
class NetworkFlavor(BASEV2):
flavor = sa.Column(sa.String(255))
network_id = sa.Column(sa.String(36), sa.ForeignKey('networks.id',
ondelete="CASCADE"),
primary_key=True)
#neutron/plugins/metaplugin/meta_models_v2.py
class RouterFlavor(BASEV2):
flavor = sa.Column(sa.String(255))
router_id = sa.Column(sa.String(36), sa.ForeignKey('routers.id',
ondelete="CASCADE"),
primary_key=True)
#neutron/plugins/ml2/drivers/brocade/db/models.py
class ML2_BrocadeNetwork(BASEV2, HasId,
HasTenant):
vlan = sa.Column(sa.String(10))
segment_id = sa.Column(sa.String(36))
network_type = sa.Column(sa.String(10))
#neutron/plugins/ml2/drivers/brocade/db/models.py
class ML2_BrocadePort(BASEV2, HasId,
HasTenant):
network_id = sa.Column(sa.String(36),
sa.ForeignKey("ml2_brocadenetworks.id"),
nullable=False)
admin_state_up = sa.Column(sa.Boolean, nullable=False)
physical_interface = sa.Column(sa.String(36))
vlan_id = sa.Column(sa.String(36))
#neutron/plugins/ml2/drivers/cisco/apic/apic_model.py
class NetworkEPG(BASEV2):
__tablename__ = 'cisco_ml2_apic_epgs'
network_id = sa.Column(sa.String(255), nullable=False, primary_key=True)
epg_id = sa.Column(sa.String(64), nullable=False)
segmentation_id = sa.Column(sa.String(64), nullable=False)
provider = sa.Column(sa.Boolean, default=False,
server_default=sa.sql.false(), nullable=False)
#neutron/plugins/ml2/drivers/cisco/apic/apic_model.py
class PortProfile(BASEV2):
__tablename__ = 'cisco_ml2_apic_port_profiles'
node_id = sa.Column(sa.String(255), nullable=False, primary_key=True)
profile_id = sa.Column(sa.String(64), nullable=False)
hpselc_id = sa.Column(sa.String(64), nullable=False)
module = sa.Column(sa.String(10), nullable=False)
from_port = sa.Column(sa.Integer(), nullable=False)
to_port = sa.Column(sa.Integer(), nullable=False)
#neutron/plugins/ml2/drivers/cisco/apic/apic_model.py
class TenantContract(BASEV2, HasTenant):
__tablename__ = 'cisco_ml2_apic_contracts'
__table_args__ = (sa.PrimaryKeyConstraint('tenant_id'),)
contract_id = sa.Column(sa.String(64), nullable=False)
filter_id = sa.Column(sa.String(64), nullable=False)
#neutron/plugins/ml2/drivers/cisco/nexus/nexus_models_v2.py
#class was renamed from NexusPortBinding to CiscoMl2NexusPortBinding
class CiscoMl2NexusPortBinding(BASEV2):
__tablename__ = "cisco_ml2_nexusport_bindings"
binding_id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
port_id = sa.Column(sa.String(255))
vlan_id = sa.Column(sa.Integer, nullable=False)
switch_ip = sa.Column(sa.String(255))
instance_id = sa.Column(sa.String(255))
#neutron/plugins/ml2/drivers/mech_arista/db.py
class AristaProvisionedNets(BASEV2, HasId,
HasTenant):
__tablename__ = 'arista_provisioned_nets'
network_id = sa.Column(sa.String(UUID_LEN))
segmentation_id = sa.Column(sa.Integer)
#neutron/plugins/ml2/drivers/mech_arista/db.py
class AristaProvisionedVms(BASEV2, HasId,
HasTenant):
__tablename__ = 'arista_provisioned_vms'
vm_id = sa.Column(sa.String(STR_LEN))
host_id = sa.Column(sa.String(STR_LEN))
port_id = sa.Column(sa.String(UUID_LEN))
network_id = sa.Column(sa.String(UUID_LEN))
#neutron/plugins/ml2/drivers/mech_arista/db.py
class AristaProvisionedTenants(BASEV2, HasId,
HasTenant):
__tablename__ = 'arista_provisioned_tenants'
#neutron/plugins/ml2/drivers/type_flat.py
class FlatAllocation(BASEV2):
__tablename__ = 'ml2_flat_allocations'
physical_network = sa.Column(sa.String(64), nullable=False,
primary_key=True)
#neutron/plugins/ml2/drivers/type_gre.py
class GreAllocation(BASEV2):
__tablename__ = 'ml2_gre_allocations'
gre_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False, default=False,
server_default=sa.sql.false())
#neutron/plugins/ml2/drivers/type_gre.py
class GreEndpoints(BASEV2):
__tablename__ = 'ml2_gre_endpoints'
ip_address = sa.Column(sa.String(64), primary_key=True)
#neutron/plugins/ml2/drivers/type_vlan.py
#class was renamed from VlanAllocation to Ml2VlanAllocation
class Ml2VlanAllocation(BASEV2):
__tablename__ = 'ml2_vlan_allocations'
physical_network = sa.Column(sa.String(64), nullable=False,
primary_key=True)
vlan_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False)
#neutron/plugins/ml2/drivers/type_vxlan.py
class VxlanAllocation(BASEV2):
__tablename__ = 'ml2_vxlan_allocations'
vxlan_vni = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False, default=False,
server_default=sa.sql.false())
#neutron/plugins/ml2/drivers/type_vxlan.py
class VxlanEndpoints(BASEV2):
__tablename__ = 'ml2_vxlan_endpoints'
ip_address = sa.Column(sa.String(64), primary_key=True)
udp_port = sa.Column(sa.Integer, primary_key=True, nullable=False,
autoincrement=False)
#neutron/plugins/ml2/models.py
class NetworkSegment(BASEV2, HasId):
__tablename__ = 'ml2_network_segments'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
nullable=False)
network_type = sa.Column(sa.String(32), nullable=False)
physical_network = sa.Column(sa.String(64))
segmentation_id = sa.Column(sa.Integer)
#neutron/plugins/ml2/models.py
class PortBinding(BASEV2):
__tablename__ = 'ml2_port_bindings'
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
host = sa.Column(sa.String(255), nullable=False, default='',
server_default='')
vnic_type = sa.Column(sa.String(64), nullable=False,
default=VNIC_NORMAL, server_default=VNIC_NORMAL)
profile = sa.Column(sa.String(BINDING_PROFILE_LEN), nullable=False,
default='', server_default='')
vif_type = sa.Column(sa.String(64), nullable=False)
vif_details = sa.Column(sa.String(4095), nullable=False, default='',
server_default='')
driver = sa.Column(sa.String(64))
segment = sa.Column(sa.String(36),
sa.ForeignKey('ml2_network_segments.id',
ondelete="SET NULL"))
port = orm.relationship(
Port,
backref=orm.backref("port_binding",
lazy='joined', uselist=False,
cascade='delete'))
#neutron/plugins/mlnx/db/mlnx_models_v2.py
class SegmentationIdAllocation(BASEV2):
__tablename__ = 'segmentation_id_allocation'
physical_network = sa.Column(sa.String(64), nullable=False,
primary_key=True)
segmentation_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False, default=False,
server_default=sa.sql.false())
#neutron/plugins/mlnx/db/mlnx_models_v2.py
#class was renamed from NetworkBinding to MlnxNetworkBinding
class MlnxNetworkBinding(BASEV2):
__tablename__ = 'mlnx_network_bindings'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
network_type = sa.Column(sa.String(32), nullable=False)
physical_network = sa.Column(sa.String(64))
segmentation_id = sa.Column(sa.Integer, nullable=False)
#neutron/plugins/mlnx/db/mlnx_models_v2.py
class PortProfileBinding(BASEV2):
__tablename__ = 'port_profile'
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
vnic_type = sa.Column(sa.String(32), nullable=False)
#neutron/plugins/nec/db/models.py
class OFCId(object):
ofc_id = sa.Column(sa.String(255), unique=True, nullable=False)
#neutron/plugins/nec/db/models.py
class NeutronId(object):
neutron_id = sa.Column(sa.String(36), primary_key=True)
#neutron/plugins/nec/db/models.py
class OFCTenantMapping(BASEV2, NeutronId, OFCId):
"""Represents a Tenant on OpenFlow Network/Controller."""
#neutron/plugins/nec/db/models.py
class OFCNetworkMapping(BASEV2, NeutronId, OFCId):
"""Represents a Network on OpenFlow Network/Controller."""
#neutron/plugins/nec/db/models.py
class OFCPortMapping(BASEV2, NeutronId, OFCId):
"""Represents a Port on OpenFlow Network/Controller."""
#neutron/plugins/nec/db/models.py
class OFCRouterMapping(BASEV2, NeutronId, OFCId):
"""Represents a router on OpenFlow Network/Controller."""
#neutron/plugins/nec/db/models.py
class OFCFilterMapping(BASEV2, NeutronId, OFCId):
"""Represents a Filter on OpenFlow Network/Controller."""
#neutron/plugins/nec/db/models.py
class PortInfo(BASEV2):
id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
datapath_id = sa.Column(sa.String(36), nullable=False)
port_no = sa.Column(sa.Integer, nullable=False)
vlan_id = sa.Column(sa.Integer, nullable=False)
mac = sa.Column(sa.String(32), nullable=False)
port = orm.relationship(
Port,
backref=orm.backref("portinfo",
lazy='joined', uselist=False,
cascade='delete'))
#neutron/plugins/nec/db/packetfilter.py
class PacketFilter(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
nullable=False)
priority = sa.Column(sa.Integer, nullable=False)
action = sa.Column(sa.String(16), nullable=False)
in_port = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
nullable=True)
src_mac = sa.Column(sa.String(32), nullable=False)
dst_mac = sa.Column(sa.String(32), nullable=False)
eth_type = sa.Column(sa.Integer, nullable=False)
src_cidr = sa.Column(sa.String(64), nullable=False)
dst_cidr = sa.Column(sa.String(64), nullable=False)
protocol = sa.Column(sa.String(16), nullable=False)
src_port = sa.Column(sa.Integer, nullable=False)
dst_port = sa.Column(sa.Integer, nullable=False)
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
status = sa.Column(sa.String(16), nullable=False)
network = orm.relationship(
Network,
backref=orm.backref('packetfilters', lazy='joined', cascade='delete'),
uselist=False)
in_port_ref = orm.relationship(
Port,
backref=orm.backref('packetfilters', lazy='joined', cascade='delete'),
primaryjoin="Port.id==PacketFilter.in_port",
uselist=False)
#neutron/plugins/nec/db/router.py
class RouterProvider(BASEV2):
provider = sa.Column(sa.String(255))
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id', ondelete="CASCADE"),
primary_key=True)
router = orm.relationship(Router, uselist=False,
backref=orm.backref('provider', uselist=False,
lazy='joined',
cascade='delete'))
#neutron/plugins/nuage/nuage_models.py
class NetPartition(BASEV2, HasId):
__tablename__ = 'nuage_net_partitions'
name = sa.Column(sa.String(64))
l3dom_tmplt_id = sa.Column(sa.String(36))
l2dom_tmplt_id = sa.Column(sa.String(36))
#neutron/plugins/nuage/nuage_models.py
class NetPartitionRouter(BASEV2):
__tablename__ = "nuage_net_partition_router_mapping"
net_partition_id = sa.Column(sa.String(36),
sa.ForeignKey('nuage_net_partitions.id',
ondelete="CASCADE"),
primary_key=True)
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id', ondelete="CASCADE"),
primary_key=True)
nuage_router_id = sa.Column(sa.String(36))
#neutron/plugins/nuage/nuage_models.py
class RouterZone(BASEV2):
__tablename__ = "nuage_router_zone_mapping"
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id', ondelete="CASCADE"),
primary_key=True)
nuage_zone_id = sa.Column(sa.String(36))
nuage_user_id = sa.Column(sa.String(36))
nuage_group_id = sa.Column(sa.String(36))
#neutron/plugins/nuage/nuage_models.py
class SubnetL2Domain(BASEV2):
__tablename__ = 'nuage_subnet_l2dom_mapping'
subnet_id = sa.Column(sa.String(36),
sa.ForeignKey('subnets.id', ondelete="CASCADE"),
primary_key=True)
net_partition_id = sa.Column(sa.String(36),
sa.ForeignKey('nuage_net_partitions.id',
ondelete="CASCADE"))
nuage_subnet_id = sa.Column(sa.String(36))
nuage_l2dom_tmplt_id = sa.Column(sa.String(36))
nuage_user_id = sa.Column(sa.String(36))
nuage_group_id = sa.Column(sa.String(36))
#neutron/plugins/nuage/nuage_models.py
class PortVPortMapping(BASEV2):
__tablename__ = 'nuage_port_mapping'
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
nuage_vport_id = sa.Column(sa.String(36))
nuage_vif_id = sa.Column(sa.String(36))
static_ip = sa.Column(sa.Boolean())
#neutron/plugins/nuage/nuage_models.py
class RouterRoutesMapping(BASEV2, Route):
__tablename__ = 'nuage_routerroutes_mapping'
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id',
ondelete="CASCADE"),
primary_key=True,
nullable=False)
nuage_route_id = sa.Column(sa.String(36))
#neutron/plugins/nuage/nuage_models.py
class FloatingIPPoolMapping(BASEV2):
__tablename__ = "nuage_floatingip_pool_mapping"
fip_pool_id = sa.Column(sa.String(36), primary_key=True)
net_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"))
router_id = sa.Column(sa.String(36))
#neutron/plugins/nuage/nuage_models.py
class FloatingIPMapping(BASEV2):
__tablename__ = 'nuage_floatingip_mapping'
fip_id = sa.Column(sa.String(36),
sa.ForeignKey('floatingips.id',
ondelete="CASCADE"),
primary_key=True)
router_id = sa.Column(sa.String(36))
nuage_fip_id = sa.Column(sa.String(36))
#neutron/plugins/openvswitch/ovs_models_v2.py
#class was renamed from VlanAllocation to OvsVlanAllocation
class OvsVlanAllocation(BASEV2):
__tablename__ = 'ovs_vlan_allocations'
physical_network = sa.Column(sa.String(64),
nullable=False,
primary_key=True)
vlan_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False)
#neutron/plugins/openvswitch/ovs_models_v2.py
class TunnelAllocation(BASEV2):
__tablename__ = 'ovs_tunnel_allocations'
tunnel_id = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False)
#neutron/plugins/openvswitch/ovs_models_v2.py
#class was renamed from NetworkBinding to OvsNetworkBinding
class OvsNetworkBinding(BASEV2):
__tablename__ = 'ovs_network_bindings'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
# 'gre', 'vlan', 'flat', 'local'
network_type = sa.Column(sa.String(32), nullable=False)
physical_network = sa.Column(sa.String(64))
segmentation_id = sa.Column(sa.Integer) # tunnel_id or vlan_id
network = orm.relationship(
Network,
backref=orm.backref("binding", lazy='joined',
uselist=False, cascade='delete'))
#neutron/plugins/openvswitch/ovs_models_v2.py
class TunnelEndpoint(BASEV2):
__tablename__ = 'ovs_tunnel_endpoints'
__table_args__ = (
schema.UniqueConstraint('id', name='uniq_ovs_tunnel_endpoints0id'),
BASEV2.__table_args__,
)
ip_address = sa.Column(sa.String(64), primary_key=True)
id = sa.Column(sa.Integer, nullable=False)
#neutron/plugins/ryu/db/models_v2.py
class TunnelKeyLast(BASEV2):
last_key = sa.Column(sa.Integer, primary_key=True)
#neutron/plugins/ryu/db/models_v2.py
class TunnelKey(BASEV2):
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"),
nullable=False)
tunnel_key = sa.Column(sa.Integer, primary_key=True,
nullable=False, autoincrement=False)
#neutron/plugins/vmware/dbexts/lsn_db.py
class LsnPort(BASEV2):
__tablename__ = 'lsn_port'
lsn_port_id = sa.Column(sa.String(36), primary_key=True)
lsn_id = sa.Column(sa.String(36), sa.ForeignKey('lsn.lsn_id',
ondelete="CASCADE"),
nullable=False)
sub_id = sa.Column(sa.String(36), nullable=False, unique=True)
mac_addr = sa.Column(sa.String(32), nullable=False, unique=True)
#neutron/plugins/vmware/dbexts/lsn_db.py
class Lsn(BASEV2):
__tablename__ = 'lsn'
lsn_id = sa.Column(sa.String(36), primary_key=True)
net_id = sa.Column(sa.String(36), nullable=False)
#neutron/plugins/vmware/dbexts/maclearning.py
class MacLearningState(BASEV2):
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
mac_learning_enabled = sa.Column(sa.Boolean(), nullable=False)
port = orm.relationship(
Port,
backref=orm.backref("mac_learning_state", lazy='joined',
uselist=False, cascade='delete'))
#neutron/plugins/vmware/dbexts/models.py
class TzNetworkBinding(BASEV2):
__tablename__ = 'tz_network_bindings'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
binding_type = sa.Column(sa.Enum('flat', 'vlan', 'stt', 'gre', 'l3_ext',
name='tz_network_bindings_binding_type'),
nullable=False, primary_key=True)
phy_uuid = sa.Column(sa.String(36), primary_key=True, nullable=True)
vlan_id = sa.Column(sa.Integer, primary_key=True, nullable=True,
autoincrement=False)
#neutron/plugins/vmware/dbexts/models.py
class NeutronNsxNetworkMapping(BASEV2):
__tablename__ = 'neutron_nsx_network_mappings'
neutron_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete='CASCADE'),
primary_key=True)
nsx_id = sa.Column(sa.String(36), primary_key=True)
#neutron/plugins/vmware/dbexts/models.py
class NeutronNsxSecurityGroupMapping(BASEV2):
__tablename__ = 'neutron_nsx_security_group_mappings'
neutron_id = sa.Column(sa.String(36),
sa.ForeignKey('securitygroups.id',
ondelete="CASCADE"),
primary_key=True)
nsx_id = sa.Column(sa.String(36), primary_key=True)
#neutron/plugins/vmware/dbexts/models.py
class NeutronNsxPortMapping(BASEV2):
__tablename__ = 'neutron_nsx_port_mappings'
neutron_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
nsx_switch_id = sa.Column(sa.String(36))
nsx_port_id = sa.Column(sa.String(36), nullable=False)
#neutron/plugins/vmware/dbexts/models.py
class NeutronNsxRouterMapping(BASEV2):
__tablename__ = 'neutron_nsx_router_mappings'
neutron_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id', ondelete='CASCADE'),
primary_key=True)
nsx_id = sa.Column(sa.String(36))
#neutron/plugins/vmware/dbexts/models.py
class MultiProviderNetworks(BASEV2):
__tablename__ = 'multi_provider_networks'
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
#neutron/plugins/vmware/dbexts/models.py
class NSXRouterExtAttributes(BASEV2):
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id', ondelete="CASCADE"),
primary_key=True)
distributed = sa.Column(sa.Boolean, default=False,
server_default=sa.sql.false(), nullable=False)
service_router = sa.Column(sa.Boolean, default=False,
server_default=sa.sql.false(), nullable=False)
router = orm.relationship(
Router,
backref=orm.backref("nsx_attributes", lazy='joined',
uselist=False, cascade='delete'))
#neutron/plugins/vmware/dbexts/networkgw_db.py
class NetworkConnection(BASEV2, HasTenant):
network_gateway_id = sa.Column(sa.String(36),
sa.ForeignKey('networkgateways.id',
ondelete='CASCADE'))
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete='CASCADE'))
segmentation_type = sa.Column(
sa.Enum('flat', 'vlan',
name='networkconnections_segmentation_type'))
segmentation_id = sa.Column(sa.Integer)
__table_args__ = (sa.UniqueConstraint(network_gateway_id,
segmentation_type,
segmentation_id),)
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete='CASCADE'),
primary_key=True)
#neutron/plugins/vmware/dbexts/networkgw_db.py
class NetworkGatewayDeviceReference(BASEV2):
id = sa.Column(sa.String(36), primary_key=True)
network_gateway_id = sa.Column(sa.String(36),
sa.ForeignKey('networkgateways.id',
ondelete='CASCADE'),
primary_key=True)
interface_name = sa.Column(sa.String(64), primary_key=True)
#neutron/plugins/vmware/dbexts/networkgw_db.py
class NetworkGatewayDevice(BASEV2, HasId,
HasTenant):
nsx_id = sa.Column(sa.String(36))
# Optional name for the gateway device
name = sa.Column(sa.String(255))
# Transport connector type. Not using enum as range of
# connector types might vary with backend version
connector_type = sa.Column(sa.String(10))
# Transport connector IP Address
connector_ip = sa.Column(sa.String(64))
# operational status
status = sa.Column(sa.String(16))
#neutron/plugins/vmware/dbexts/networkgw_db.py
class NetworkGateway(BASEV2, HasId,
HasTenant):
name = sa.Column(sa.String(255))
# Tenant id is nullable for this resource
tenant_id = sa.Column(sa.String(36))
default = sa.Column(sa.Boolean())
devices = orm.relationship(NetworkGatewayDeviceReference,
backref='networkgateways',
cascade='all,delete')
network_connections = orm.relationship(NetworkConnection, lazy='joined')
#neutron/plugins/vmware/dbexts/qos_db.py
class QoSQueue(BASEV2, HasId, HasTenant):
name = sa.Column(sa.String(255))
default = sa.Column(sa.Boolean, default=False,
server_default=sa.sql.false())
min = sa.Column(sa.Integer, nullable=False)
max = sa.Column(sa.Integer, nullable=True)
qos_marking = sa.Column(sa.Enum('untrusted', 'trusted',
name='qosqueues_qos_marking'))
dscp = sa.Column(sa.Integer)
#neutron/plugins/vmware/dbexts/qos_db.py
class PortQueueMapping(BASEV2):
port_id = sa.Column(sa.String(36),
sa.ForeignKey("ports.id", ondelete="CASCADE"),
primary_key=True)
queue_id = sa.Column(sa.String(36), sa.ForeignKey("qosqueues.id"),
primary_key=True)
# Add a relationship to the Port model adding a backref which will
# allow SQLAlchemy for eagerly load the queue binding
port = orm.relationship(
Port,
backref=orm.backref("qos_queue", uselist=False,
cascade='delete', lazy='joined'))
#neutron/plugins/vmware/dbexts/qos_db.py
class NetworkQueueMapping(BASEV2):
network_id = sa.Column(sa.String(36),
sa.ForeignKey("networks.id", ondelete="CASCADE"),
primary_key=True)
queue_id = sa.Column(sa.String(36), sa.ForeignKey("qosqueues.id",
ondelete="CASCADE"))
# Add a relationship to the Network model adding a backref which will
# allow SQLAlcremy for eagerly load the queue binding
network = orm.relationship(
Network,
backref=orm.backref("qos_queue", uselist=False,
cascade='delete', lazy='joined'))
#neutron/plugins/vmware/dbexts/vcns_models.py
class VcnsRouterBinding(BASEV2, HasStatusDescription):
__tablename__ = 'vcns_router_bindings'
# no sa.ForeignKey to routers.id because for now, a router can be removed
# from routers when delete_router is executed, but the binding is only
# removed after the Edge is deleted
router_id = sa.Column(sa.String(36),
primary_key=True)
edge_id = sa.Column(sa.String(16),
nullable=True)
lswitch_id = sa.Column(sa.String(36),
nullable=False)
#neutron/plugins/vmware/dbexts/vcns_models.py
class VcnsEdgeFirewallRuleBinding(BASEV2):
__tablename__ = 'vcns_firewall_rule_bindings'
rule_id = sa.Column(sa.String(36),
sa.ForeignKey("firewall_rules.id"),
primary_key=True)
edge_id = sa.Column(sa.String(36), primary_key=True)
rule_vseid = sa.Column(sa.String(36))
#neutron/plugins/vmware/dbexts/vcns_models.py
class VcnsEdgePoolBinding(BASEV2):
__tablename__ = 'vcns_edge_pool_bindings'
pool_id = sa.Column(sa.String(36),
sa.ForeignKey("pools.id", ondelete="CASCADE"),
primary_key=True)
edge_id = sa.Column(sa.String(36), primary_key=True)
pool_vseid = sa.Column(sa.String(36))
#neutron/plugins/vmware/dbexts/vcns_models.py
class VcnsEdgeVipBinding(BASEV2):
__tablename__ = 'vcns_edge_vip_bindings'
vip_id = sa.Column(sa.String(36),
sa.ForeignKey("vips.id", ondelete="CASCADE"),
primary_key=True)
edge_id = sa.Column(sa.String(36))
vip_vseid = sa.Column(sa.String(36))
app_profileid = sa.Column(sa.String(36))
#neutron/plugins/vmware/dbexts/vcns_models.py
class VcnsEdgeMonitorBinding(BASEV2):
__tablename__ = 'vcns_edge_monitor_bindings'
monitor_id = sa.Column(sa.String(36),
sa.ForeignKey("healthmonitors.id",
ondelete="CASCADE"),
primary_key=True)
edge_id = sa.Column(sa.String(36), primary_key=True)
monitor_vseid = sa.Column(sa.String(36))
#neutron/services/loadbalancer/agent_scheduler.py
class PoolLoadbalancerAgentBinding(BASEV2):
pool_id = sa.Column(sa.String(36),
sa.ForeignKey("pools.id", ondelete='CASCADE'),
primary_key=True)
agent = orm.relation(Agent)
agent_id = sa.Column(sa.String(36), sa.ForeignKey("agents.id",
ondelete='CASCADE'),
nullable=False)
#neutron/services/loadbalancer/drivers/embrane/models.py
class PoolPort(BASEV2):
__tablename__ = 'embrane_pool_port'
pool_id = sa.Column(sa.String(36), sa.ForeignKey('pools.id'),
primary_key=True)
port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'),
nullable=False)
#neutron/services/vpn/service_drivers/cisco_csr_db.py
class IdentifierMap(BASEV2, HasTenant):
__tablename__ = 'cisco_csr_identifier_map'
ipsec_site_conn_id = sa.Column(sa.String(64),
sa.ForeignKey('ipsec_site_connections.id',
ondelete="CASCADE"),
primary_key=True)
csr_tunnel_id = sa.Column(sa.Integer, nullable=False)
csr_ike_policy_id = sa.Column(sa.Integer, nullable=False)
csr_ipsec_policy_id = sa.Column(sa.Integer, nullable=False)
def get_metadata():
return BASEV2.metadata
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6927,
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,
1918,
859,
6571,
1006,
3050,
1709,
14,
199,
199,
11881,
12016,
365,
370,
1218,
1013,
19816,
3341,
543,
1453,
3050,
4177,
14,
199,
20409,
641,
642,
9132,
3050,
883,
506,
946,
65,
1146,
543,
946,
29515,
8367,
14,
199,
199,
5639,
13053,
5532,
365,
8155,
983,
25,
1651,
69,
25,
2322,
825,
29043,
1344,
68,
1082,
2592,
17538,
68,
1216,
65,
24,
65,
19792,
69,
1465,
1651,
199,
624,
421,
199,
646,
8335,
465,
2937,
199,
504,
8335,
14,
832,
492,
30191,
199,
504,
8335,
14,
832,
14,
7128,
513,
492,
7794,
63,
513,
199,
504,
8335,
492,
9813,
199,
504,
8335,
492,
4177,
199,
199,
504,
8224,
14,
697,
492,
1402,
63,
1095,
199,
504,
8224,
14,
8512,
14,
2330,
492,
5377,
1208,
421,
199,
3,
11932,
402,
1006,
6716,
626,
1990,
17864,
26,
199,
3,
469,
1222,
63,
1224,
63,
354,
26,
2269,
63,
1224,
63,
354,
93,
199,
29401,
63,
5987,
275,
469,
272,
283,
5327,
13243,
356,
283,
13243,
297,
272,
283,
19597,
63,
6942,
356,
283,
6942,
297,
272,
283,
19597,
63,
21787,
719,
63,
10880,
356,
283,
21787,
719,
63,
10880,
297,
272,
283,
19597,
63,
12282,
63,
11767,
356,
283,
81,
26890,
297,
272,
283,
3903,
63,
1200,
63,
10880,
356,
283,
78,
11702,
63,
1200,
63,
10880,
297,
272,
283,
3029,
63,
3780,
63,
7642,
356,
283,
78,
11702,
63,
3029,
63,
3780,
63,
7642,
297,
272,
283,
846,
63,
12553,
356,
283,
78,
1718,
63,
846,
63,
12553,
297,
272,
283,
846,
63,
5312,
63,
4995,
63,
4745,
356,
283,
78,
1718,
63,
846,
63,
5312,
63,
4995,
63,
4745,
297,
272,
283,
4995,
63,
2619,
63,
4745,
356,
283,
78,
1718,
63,
4995,
63,
2619,
63,
4745,
297,
272,
283,
5327,
63,
76,
18,
4556,
63,
4745,
356,
283,
78,
1718,
63,
5327,
63,
76,
18,
4556,
63,
4745,
297,
272,
283,
719,
63,
4745,
356,
283,
78,
1718,
63,
719,
63,
4745,
297,
272,
283,
4995,
13243,
63,
4745,
356,
283,
78,
1718,
63,
4995,
13243,
63,
4745,
297,
199,
93,
199,
199,
3,
10271,
15,
5265,
15,
757,
18,
15,
13337,
15,
278,
335,
63,
285,
631,
65,
15,
697,
14,
647,
199,
8757,
63,
5304,
275,
8780,
199,
3027,
63,
5304,
275,
5450,
199,
199,
3,
10271,
15,
5265,
15,
19597,
15,
2330,
15,
19597,
63,
5559,
14,
647,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
63,
2711,
63,
22716,
275,
283,
7175,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
63,
2711,
63,
14336,
16897,
275,
283,
18534,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
63,
2711,
63,
1766,
8019,
275,
283,
13409,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
63,
2711,
63,
21389,
63,
27001,
275,
283,
3029,
13,
9255,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
275,
283,
1200,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
15976,
275,
283,
3185,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
52,
31718,
63,
998,
63,
4609,
63,
3597,
275,
283,
52,
31718,
63,
998,
63,
4609,
63,
3597,
7,
199,
199,
3,
10271,
15,
5265,
15,
757,
18,
15,
992,
14,
647,
199,
28347,
63,
16632,
63,
5304,
275,
841,
19113,
199,
199,
3,
10271,
15,
5359,
15,
719,
10880,
14,
647,
199,
54,
30374,
63,
10765,
275,
283,
3302,
7,
199,
199,
3,
10271,
15,
2330,
15,
5559,
14,
647,
199,
11253,
22,
63,
4929,
20768,
275,
283,
83,
416,
645,
7,
199,
29977,
54,
22,
63,
6689,
38,
1293,
275,
283,
7821,
67,
1381,
22,
13,
929,
1893,
7,
199,
29977,
54,
22,
63,
6689,
30928,
275,
283,
7821,
67,
1381,
22,
13,
929,
2003,
7,
421,
199,
5825,
54,
18,
275,
30191,
14,
12164,
1905,
63,
1095,
8,
1886,
29,
1238,
63,
1095,
14,
20915,
1563,
54,
18,
9,
421,
199,
3,
10271,
15,
697,
15,
992,
63,
86,
18,
14,
647,
199,
533,
13481,
27807,
8,
785,
304,
272,
8261,
63,
344,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
2299,
430,
421,
199,
3,
10271,
15,
697,
15,
992,
63,
86,
18,
14,
647,
199,
533,
13481,
1304,
8,
785,
304,
272,
1305,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
1344,
395,
673,
5062,
63,
498,
29,
549,
12,
673,
849,
29,
2580,
1208,
14,
4208,
63,
2580,
9,
421,
199,
3,
10271,
15,
697,
15,
992,
63,
86,
18,
14,
647,
199,
533,
13481,
3694,
5831,
8,
785,
304,
272,
2004,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
975,
395,
7854,
29,
797,
9,
272,
2004,
63,
1802,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
2299,
430,
421,
199,
3,
10271,
15,
697,
15,
992,
63,
86,
18,
14,
647,
199,
533,
3531,
26462,
4709,
8,
5825,
54,
18,
304,
272,
18723,
63,
2293,
63,
344,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
1344,
395,
3521,
2937,
14,
3190,
360,
711,
14940,
12406,
14,
344,
297,
1740,
16549,
628,
10855,
1288,
3521,
7854,
29,
797,
12,
3521,
5062,
63,
498,
29,
549,
9,
272,
1642,
63,
711,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
772,
395,
7854,
29,
797
] |
[
1898,
334,
67,
9,
6927,
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,
1918,
859,
6571,
1006,
3050,
1709,
14,
199,
199,
11881,
12016,
365,
370,
1218,
1013,
19816,
3341,
543,
1453,
3050,
4177,
14,
199,
20409,
641,
642,
9132,
3050,
883,
506,
946,
65,
1146,
543,
946,
29515,
8367,
14,
199,
199,
5639,
13053,
5532,
365,
8155,
983,
25,
1651,
69,
25,
2322,
825,
29043,
1344,
68,
1082,
2592,
17538,
68,
1216,
65,
24,
65,
19792,
69,
1465,
1651,
199,
624,
421,
199,
646,
8335,
465,
2937,
199,
504,
8335,
14,
832,
492,
30191,
199,
504,
8335,
14,
832,
14,
7128,
513,
492,
7794,
63,
513,
199,
504,
8335,
492,
9813,
199,
504,
8335,
492,
4177,
199,
199,
504,
8224,
14,
697,
492,
1402,
63,
1095,
199,
504,
8224,
14,
8512,
14,
2330,
492,
5377,
1208,
421,
199,
3,
11932,
402,
1006,
6716,
626,
1990,
17864,
26,
199,
3,
469,
1222,
63,
1224,
63,
354,
26,
2269,
63,
1224,
63,
354,
93,
199,
29401,
63,
5987,
275,
469,
272,
283,
5327,
13243,
356,
283,
13243,
297,
272,
283,
19597,
63,
6942,
356,
283,
6942,
297,
272,
283,
19597,
63,
21787,
719,
63,
10880,
356,
283,
21787,
719,
63,
10880,
297,
272,
283,
19597,
63,
12282,
63,
11767,
356,
283,
81,
26890,
297,
272,
283,
3903,
63,
1200,
63,
10880,
356,
283,
78,
11702,
63,
1200,
63,
10880,
297,
272,
283,
3029,
63,
3780,
63,
7642,
356,
283,
78,
11702,
63,
3029,
63,
3780,
63,
7642,
297,
272,
283,
846,
63,
12553,
356,
283,
78,
1718,
63,
846,
63,
12553,
297,
272,
283,
846,
63,
5312,
63,
4995,
63,
4745,
356,
283,
78,
1718,
63,
846,
63,
5312,
63,
4995,
63,
4745,
297,
272,
283,
4995,
63,
2619,
63,
4745,
356,
283,
78,
1718,
63,
4995,
63,
2619,
63,
4745,
297,
272,
283,
5327,
63,
76,
18,
4556,
63,
4745,
356,
283,
78,
1718,
63,
5327,
63,
76,
18,
4556,
63,
4745,
297,
272,
283,
719,
63,
4745,
356,
283,
78,
1718,
63,
719,
63,
4745,
297,
272,
283,
4995,
13243,
63,
4745,
356,
283,
78,
1718,
63,
4995,
13243,
63,
4745,
297,
199,
93,
199,
199,
3,
10271,
15,
5265,
15,
757,
18,
15,
13337,
15,
278,
335,
63,
285,
631,
65,
15,
697,
14,
647,
199,
8757,
63,
5304,
275,
8780,
199,
3027,
63,
5304,
275,
5450,
199,
199,
3,
10271,
15,
5265,
15,
19597,
15,
2330,
15,
19597,
63,
5559,
14,
647,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
63,
2711,
63,
22716,
275,
283,
7175,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
63,
2711,
63,
14336,
16897,
275,
283,
18534,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
63,
2711,
63,
1766,
8019,
275,
283,
13409,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
63,
2711,
63,
21389,
63,
27001,
275,
283,
3029,
13,
9255,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
14560,
275,
283,
1200,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
15976,
275,
283,
3185,
7,
199,
35,
1311,
1439,
63,
25825,
51,
63,
52,
31718,
63,
998,
63,
4609,
63,
3597,
275,
283,
52,
31718,
63,
998,
63,
4609,
63,
3597,
7,
199,
199,
3,
10271,
15,
5265,
15,
757,
18,
15,
992,
14,
647,
199,
28347,
63,
16632,
63,
5304,
275,
841,
19113,
199,
199,
3,
10271,
15,
5359,
15,
719,
10880,
14,
647,
199,
54,
30374,
63,
10765,
275,
283,
3302,
7,
199,
199,
3,
10271,
15,
2330,
15,
5559,
14,
647,
199,
11253,
22,
63,
4929,
20768,
275,
283,
83,
416,
645,
7,
199,
29977,
54,
22,
63,
6689,
38,
1293,
275,
283,
7821,
67,
1381,
22,
13,
929,
1893,
7,
199,
29977,
54,
22,
63,
6689,
30928,
275,
283,
7821,
67,
1381,
22,
13,
929,
2003,
7,
421,
199,
5825,
54,
18,
275,
30191,
14,
12164,
1905,
63,
1095,
8,
1886,
29,
1238,
63,
1095,
14,
20915,
1563,
54,
18,
9,
421,
199,
3,
10271,
15,
697,
15,
992,
63,
86,
18,
14,
647,
199,
533,
13481,
27807,
8,
785,
304,
272,
8261,
63,
344,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
2299,
430,
421,
199,
3,
10271,
15,
697,
15,
992,
63,
86,
18,
14,
647,
199,
533,
13481,
1304,
8,
785,
304,
272,
1305,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
1344,
395,
673,
5062,
63,
498,
29,
549,
12,
673,
849,
29,
2580,
1208,
14,
4208,
63,
2580,
9,
421,
199,
3,
10271,
15,
697,
15,
992,
63,
86,
18,
14,
647,
199,
533,
13481,
3694,
5831,
8,
785,
304,
272,
2004,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
975,
395,
7854,
29,
797,
9,
272,
2004,
63,
1802,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
2299,
430,
421,
199,
3,
10271,
15,
697,
15,
992,
63,
86,
18,
14,
647,
199,
533,
3531,
26462,
4709,
8,
5825,
54,
18,
304,
272,
18723,
63,
2293,
63,
344,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
1344,
395,
3521,
2937,
14,
3190,
360,
711,
14940,
12406,
14,
344,
297,
1740,
16549,
628,
10855,
1288,
3521,
7854,
29,
797,
12,
3521,
5062,
63,
498,
29,
549,
9,
272,
1642,
63,
711,
275,
2937,
14,
4547,
8,
2231,
14,
1558,
8,
772,
395,
7854,
29,
797,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
rossgoodwin/drgonzo
|
en/parser/nltk_lite/tag/brill.py
|
9
|
47684
|
# Natural Language Toolkit: Brill Tagger
#
# Copyright (C) 2001-2006 University of Pennsylvania
# Authors: Christopher Maloof <cjmaloof@gradient.cis.upenn.edu>
# Edward Loper <edloper@gradient.cis.upenn.edu>
# Steven Bird <sb@csse.unimelb.edu.au>
# URL: <http://nltk.sf.net>
# For license information, see LICENSE.TXT
"""
Brill's transformational rule-based tagger.
"""
from en.parser.nltk_lite.tag import TagI
import bisect # for binary search through a subset of indices
import os # for finding WSJ files
import random # for shuffling WSJ files
import sys # for getting command-line arguments
######################################################################
## The Brill Tagger
######################################################################
class Brill(TagI):
"""
Brill's transformational rule-based tagger. Brill taggers use an
X{initial tagger} (such as L{tag.Default}) to assign an intial
tag sequence to a text; and then apply an ordered list of
transformational rules to correct the tags of individual tokens.
These transformation rules are specified by the L{BrillRuleI}
interface.
Brill taggers can be created directly, from an initial tagger and
a list of transformational rules; but more often, Brill taggers
are created by learning rules from a training corpus, using either
L{BrillTrainer} or L{FastBrillTrainer}.
"""
def __init__(self, initial_tagger, rules):
"""
@param initial_tagger: The initial tagger
@type initial_tagger: L{TagI}
@param rules: An ordered list of transformation rules that
should be used to correct the initial tagging.
@type rules: C{list} of L{BrillRuleI}
"""
self._initial_tagger = initial_tagger
self._rules = rules
def rules(self):
return self._rules[:]
def tag (self, tokens):
# Inherit documentation from TagI
# Run the initial tagger.
tagged_tokens = list(self._initial_tagger.tag(tokens))
# Create a dictionary that maps each tag to a list of the
# indices of tokens that have that tag.
tag_to_positions = {}
for i, (token, tag) in enumerate(tagged_tokens):
if tag not in tag_to_positions:
tag_to_positions[tag] = set([i])
else:
tag_to_positions[tag].add(i)
# Apply each rule, in order. Only try to apply rules at
# positions that have the desired original tag.
for rule in self._rules:
# Find the positions where it might apply
positions = tag_to_positions.get(rule.original_tag(), [])
# Apply the rule at those positions.
changed = rule.apply_at(tagged_tokens, positions)
# Update tag_to_positions with the positions of tags that
# were modified.
for i in changed:
tag_to_positions[rule.original_tag()].remove(i)
if rule.replacement_tag() not in tag_to_positions:
tag_to_positions[rule.replacement_tag()] = set([i])
else:
tag_to_positions[rule.replacement_tag()].add(i)
for t in tagged_tokens:
yield t
######################################################################
## Brill Rules
######################################################################
class BrillRuleI(object):
"""
An interface for tag transformations on a tagged corpus, as
performed by brill taggers. Each transformation finds all tokens
in the corpus that are tagged with a specific X{original tag} and
satisfy a specific X{condition}, and replaces their tags with a
X{replacement tag}. For any given transformation, the original
tag, replacement tag, and condition are fixed. Conditions may
depend on the token under consideration, as well as any other
tokens in the corpus.
Brill rules must be comparable and hashable.
"""
def apply_to(self, tokens):
"""
Apply this rule everywhere it applies in the corpus. I.e.,
for each token in the corpus that is tagged with this rule's
original tag, and that satisfies this rule's condition, set
its tag to be this rule's replacement tag.
@param tokens: The tagged corpus
@type tokens: C{list} of C{tuple}
@return: The indices of tokens whose tags were changed by this
rule.
@rtype: C{list} of C{int}
"""
return self.apply_at(tokens, range(len(tokens)))
def apply_at(self, tokens, positions):
"""
Apply this rule at every position in C{positions} where it
applies to the corpus. I.e., for each position M{p} in
C{positions}, if C{tokens[M{p}]} is tagged with this rule's
original tag, and satisfies this rule's condition, then set
its tag to be this rule's replacement tag.
@param tokens: The tagged corpus
@type tokens: list of Token
@type positions: C{list} of C{int}
@param positions: The positions where the transformation is to
be tried.
@return: The indices of tokens whose tags were changed by this
rule.
@rtype: C{int}
"""
assert False, "BrillRuleI is an abstract interface"
def applies(self, tokens, index):
"""
@return: True if the rule would change the tag of
C{tokens[index]}, False otherwise
@rtype: Boolean
@param tokens: A tagged corpus
@type tokens: list of Token
@param index: The index to check
@type index: int
"""
assert False, "BrillRuleI is an abstract interface"
def original_tag(self):
"""
@return: The tag which this C{BrillRuleI} may cause to be
replaced.
@rtype: any
"""
assert False, "BrillRuleI is an abstract interface"
def replacement_tag(self):
"""
@return: the tag with which this C{BrillRuleI} may replace
another tag.
@rtype: any
"""
assert False, "BrillRuleI is an abstract interface"
# Rules must be comparable and hashable for the algorithm to work
def __eq__(self):
assert False, "Brill rules must be comparable"
def __hash__(self):
assert False, "Brill rules must be hashable"
class ProximateTokensRule(BrillRuleI):
"""
An abstract base class for brill rules whose condition checks for
the presence of tokens with given properties at given ranges of
positions, relative to the token.
Each subclass of proximate tokens brill rule defines a method
M{extract_property}, which extracts a specific property from the
the token, such as its text or tag. Each instance is
parameterized by a set of tuples, specifying ranges of positions
and property values to check for in those ranges:
- (M{start}, M{end}, M{value})
The brill rule is then applicable to the M{n}th token iff:
- The M{n}th token is tagged with the rule's original tag; and
- For each (M{start}, M{end}, M{value}) triple:
- The property value of at least one token between
M{n+start} and M{n+end} (inclusive) is M{value}.
For example, a proximate token brill template with M{start=end=-1}
generates rules that check just the property of the preceding
token. Note that multiple properties may be included in a single
rule; the rule applies if they all hold.
"""
def __init__(self, original_tag, replacement_tag, *conditions):
"""
Construct a new brill rule that changes a token's tag from
C{original_tag} to C{replacement_tag} if all of the properties
specified in C{conditions} hold.
@type conditions: C{tuple} of C{(int, int, *)}
@param conditions: A list of 3-tuples C{(start, end, value)},
each of which specifies that the property of at least one
token between M{n}+C{start} and M{n}+C{end} (inclusive) is
C{value}.
@raise ValueError: If C{start}>C{end} for any condition.
"""
assert self.__class__ != ProximateTokensRule, \
"ProximateTokensRule is an abstract base class"
self._original = original_tag
self._replacement = replacement_tag
self._conditions = conditions
for (s,e,v) in conditions:
if s>e:
raise ValueError('Condition %s has an invalid range' %
((s,e,v),))
def extract_property(token): # [staticmethod]
"""
Returns some property characterizing this token, such as its
base lexical item or its tag.
Each implentation of this method should correspond to an
implementation of the method with the same name in a subclass
of L{ProximateTokensTemplate}.
@param token: The token
@type token: Token
@return: The property
@rtype: any
"""
assert False, "ProximateTokensRule is an abstract interface"
extract_property = staticmethod(extract_property)
def apply_at(self, tokens, positions):
# Inherit docs from BrillRuleI
# Find all locations where the rule is applicable
change = []
for i in positions:
if self.applies(tokens, i):
change.append(i)
# Make the changes. Note: this must be done in a separate
# step from finding applicable locations, since we don't want
# the rule to interact with itself.
for i in change:
(token, tag) = tokens[i]
tokens[i] = (token, self._replacement)
return change
def applies(self, tokens, index):
# Inherit docs from BrillRuleI
# Does the given token have this rule's "original tag"?
if tokens[index][1] != self._original:
return False
# Check to make sure that every condition holds.
for (start, end, val) in self._conditions:
# Find the (absolute) start and end indices.
s = max(0, index+start)
e = min(index+end+1, len(tokens))
# Look for *any* token that satisfies the condition.
for i in range(s, e):
if self.extract_property(tokens[i]) == val:
break
else:
# No token satisfied the condition; return false.
return False
# Every condition checked out, so the rule is applicable.
return True
def original_tag(self):
# Inherit docs from BrillRuleI
return self._original
def replacement_tag(self):
# Inherit docs from BrillRuleI
return self._replacement
def __eq__(self, other):
return (other != None and
other.__class__ == self.__class__ and
self._original == other._original and
self._replacement == other._replacement and
self._conditions == other._conditions)
def __hash__(self):
# Needs to include extract_property in order to distinguish subclasses
# A nicer way would be welcome.
return hash( (self._original, self._replacement, self._conditions,
self.extract_property.func_code) )
def __repr__(self):
conditions = ' and '.join(['%s in %d...%d' % (v,s,e)
for (s,e,v) in self._conditions])
return '<%s: %s->%s if %s>' % (self.__class__.__name__,
self._original, self._replacement,
conditions)
def __str__(self):
replacement = '%s -> %s' % (self._original,
self._replacement)
if len(self._conditions) == 0:
conditions = ''
else:
conditions = ' if '+ ', and '.join([self._condition_to_str(c)
for c in self._conditions])
return replacement+conditions
def _condition_to_str(self, condition):
"""
Return a string representation of the given condition.
This helper method is used by L{__str__}.
"""
(start, end, value) = condition
return ('the %s of %s is %r' %
(self.PROPERTY_NAME, self._range_to_str(start, end), value))
def _range_to_str(self, start, end):
"""
Return a string representation for the given range. This
helper method is used by L{__str__}.
"""
if start == end == 0:
return 'this word'
if start == end == -1:
return 'the preceding word'
elif start == end == 1:
return 'the following word'
elif start == end and start < 0:
return 'word i-%d' % -start
elif start == end and start > 0:
return 'word i+%d' % start
else:
if start >= 0: start = '+%d' % start
if end >= 0: end = '+%d' % end
return 'words i%s...i%s' % (start, end)
class ProximateTagsRule(ProximateTokensRule):
"""
A rule which examines the tags of nearby tokens.
@see: superclass L{ProximateTokensRule} for details.
@see: L{ProximateTagsTemplate}, which generates these rules.
"""
PROPERTY_NAME = 'tag' # for printing.
def extract_property(token): # [staticmethod]
"""@return: The given token's tag."""
return token[1]
extract_property = staticmethod(extract_property)
class ProximateWordsRule(ProximateTokensRule):
"""
A rule which examines the base types of nearby tokens.
@see: L{ProximateTokensRule} for details.
@see: L{ProximateWordsTemplate}, which generates these rules.
"""
PROPERTY_NAME = 'text' # for printing.
def extract_property(token): # [staticmethod]
"""@return: The given token's text."""
return token[0]
extract_property = staticmethod(extract_property)
######################################################################
## Brill Templates
######################################################################
class BrillTemplateI(object):
"""
An interface for generating lists of transformational rules that
apply at given corpus positions. C{BrillTemplateI} is used by
C{Brill} training algorithms to generate candidate rules.
"""
def __init__(self):
raise AssertionError, "BrillTemplateI is an abstract interface"
def applicable_rules(self, tokens, i, correctTag):
"""
Return a list of the transformational rules that would correct
the C{i}th subtoken's tag in the given token. In particular,
return a list of zero or more rules that would change
C{tagged_tokens[i][1]} to C{correctTag}, if applied
to C{token}.
If the C{i}th subtoken already has the correct tag (i.e., if
C{tagged_tokens[i][1]} == C{correctTag}), then
C{applicable_rules} should return the empty list.
@param token: The tagged tokens being tagged.
@type token: C{list} of C{tuple}
@param i: The index of the token whose tag should be corrected.
@type i: C{int}
@param correctTag: The correct tag for the C{i}th token.
@type correctTag: (any)
@rtype: C{list} of L{BrillRuleI}
"""
raise AssertionError, "BrillTemplateI is an abstract interface"
def get_neighborhood(self, token, index):
"""
Returns the set of indices C{i} such that
C{applicable_rules(token, index, ...)} depends on the value of
the C{i}th subtoken of C{token}.
This method is used by the \"fast\" Brill tagger trainer.
@param token: The tokens being tagged.
@type token: C{list} of C{tuple}
@param index: The index whose neighborhood should be returned.
@type index: C{int}
@rtype: C{Set}
"""
raise AssertionError, "BrillTemplateI is an abstract interface"
class ProximateTokensTemplate(BrillTemplateI):
"""
An brill templates that generates a list of
L{ProximateTokensRule}s that apply at a given corpus
position. In particular, each C{ProximateTokensTemplate} is
parameterized by a proximate token brill rule class and a list of
boundaries, and generates all rules that:
- use the given brill rule class
- use the given list of boundaries as the C{start} and C{end}
points for their conditions
- are applicable to the given token.
"""
def __init__(self, rule_class, *boundaries):
"""
Construct a template for generating proximate token brill
rules.
@type rule_class: C{class}
@param rule_class: The proximate token brill rule class that
should be used to generate new rules. This class must be a
subclass of L{ProximateTokensRule}.
@type boundaries: C{tuple} of C{(int, int)}
@param boundaries: A list of tuples C{(start, end)}, each of
which specifies a range for which a condition should be
created by each rule.
@raise ValueError: If C{start}>C{end} for any boundary.
"""
self._rule_class = rule_class
self._boundaries = boundaries
for (s,e) in boundaries:
if s>e:
raise ValueError('Boundary %s has an invalid range' %
((s,e),))
def applicable_rules(self, tokens, index, correct_tag):
if tokens[index][1] == correct_tag:
return []
# For each of this template's boundaries, Find the conditions
# that are applicable for the given token.
applicable_conditions = \
[self._applicable_conditions(tokens, index, start, end)
for (start, end) in self._boundaries]
# Find all combinations of these applicable conditions. E.g.,
# if applicable_conditions=[[A,B], [C,D]], then this will
# generate [[A,C], [A,D], [B,C], [B,D]].
condition_combos = [[]]
for conditions in applicable_conditions:
condition_combos = [old_conditions+[new_condition]
for old_conditions in condition_combos
for new_condition in conditions]
# Translate the condition sets into rules.
return [self._rule_class(tokens[index][1], correct_tag, *conds)
for conds in condition_combos]
def _applicable_conditions(self, tokens, index, start, end):
"""
@return: A set of all conditions for proximate token rules
that are applicable to C{tokens[index]}, given boundaries of
C{(start, end)}. I.e., return a list of all tuples C{(start,
end, M{value})}, such the property value of at least one token
between M{index+start} and M{index+end} (inclusive) is
M{value}.
"""
conditions = set()
s = max(0, index+start)
e = min(index+end+1, len(tokens))
for i in range(s, e):
value = self._rule_class.extract_property(tokens[i])
conditions.add( (start, end, value) )
return conditions
def get_neighborhood(self, tokens, index):
# inherit docs from BrillTemplateI
neighborhood = set([index])
for (start, end) in self._boundaries:
s = max(0, index+start)
e = min(index+end+1, len(tokens))
for i in range(s, e):
neighborhood.add(i)
return neighborhood
class SymmetricProximateTokensTemplate(BrillTemplateI):
"""
Simulates two L{ProximateTokensTemplate}s which are symmetric
across the location of the token. For rules of the form \"If the
M{n}th token is tagged C{A}, and any tag preceding B{or} following
the M{n}th token by a distance between M{x} and M{y} is C{B}, and
... , then change the tag of the nth token from C{A} to C{C}.\"
One C{ProximateTokensTemplate} is formed by passing in the
same arguments given to this class's constructor: tuples
representing intervals in which a tag may be found. The other
C{ProximateTokensTemplate} is constructed with the negative
of all the arguments in reversed order. For example, a
C{SymmetricProximateTokensTemplate} using the pair (-2,-1) and the
constructor C{ProximateTagsTemplate} generates the same rules as a
C{ProximateTagsTemplate} using (-2,-1) plus a second
C{ProximateTagsTemplate} using (1,2).
This is useful because we typically don't want templates to
specify only \"following\" or only \"preceding\"; we'd like our
rules to be able to look in either direction.
"""
def __init__(self, rule_class, *boundaries):
"""
Construct a template for generating proximate token brill
rules.
@type rule_class: C{class}
@param rule_class: The proximate token brill rule class that
should be used to generate new rules. This class must be a
subclass of L{ProximateTokensRule}.
@type boundaries: C{tuple} of C{(int, int)}
@param boundaries: A list of tuples C{(start, end)}, each of
which specifies a range for which a condition should be
created by each rule.
@raise ValueError: If C{start}>C{end} for any boundary.
"""
self._ptt1 = ProximateTokensTemplate(rule_class, *boundaries)
reversed = [(-e,-s) for (s,e) in boundaries]
self._ptt2 = ProximateTokensTemplate(rule_class, *reversed)
# Generates lists of a subtype of ProximateTokensRule.
def applicable_rules(self, tokens, index, correctTag):
"""
See L{BrillTemplateI} for full specifications.
@rtype: list of ProximateTokensRule
"""
return (self._ptt1.applicable_rules(tokens, index, correctTag) +
self._ptt2.applicable_rules(tokens, index, correctTag))
def get_neighborhood(self, tokens, index):
# inherit docs from BrillTemplateI
n1 = self._ptt1.get_neighborhood(tokens, index)
n2 = self._ptt2.get_neighborhood(tokens, index)
return n1.union(n2)
######################################################################
## Brill Tagger Trainer
######################################################################
class BrillTrainer(object):
"""
A trainer for brill taggers.
"""
def __init__(self, initial_tagger, templates, trace=0):
self._initial_tagger = initial_tagger
self._templates = templates
self._trace = trace
#////////////////////////////////////////////////////////////
# Training
#////////////////////////////////////////////////////////////
def train(self, train_tokens, max_rules=200, min_score=2):
"""
Trains the Brill tagger on the corpus C{train_token},
producing at most C{max_rules} transformations, each of which
reduces the net number of errors in the corpus by at least
C{min_score}.
@type train_tokens: C{list} of L{tuple}
@param train_tokens: The corpus of tagged tokens
@type max_rules: C{int}
@param max_rules: The maximum number of transformations to be created
@type min_score: C{int}
@param min_score: The minimum acceptable net error reduction
that each transformation must produce in the corpus.
"""
if self._trace > 0: print ("Training Brill tagger on %d tokens..." %
len(train_tokens))
# Create a new copy of the training token, and run the initial
# tagger on this. We will progressively update this test
# token to look more like the training token.
test_tokens = list(self._initial_tagger.tag(t[0] for t in train_tokens))
if self._trace > 2: self._trace_header()
# Look for useful rules.
rules = []
try:
while len(rules) < max_rules:
old_tags = [t[1] for t in test_tokens]
(rule, score, fixscore) = self._best_rule(test_tokens,
train_tokens)
if rule is None or score < min_score:
if self._trace > 1:
print 'Insufficient improvement; stopping'
break
else:
# Add the rule to our list of rules.
rules.append(rule)
# Use the rules to update the test token.
k = rule.apply_to(test_tokens)
# Display trace output.
if self._trace > 1:
self._trace_rule(rule, score, fixscore, len(k))
# The user can also cancel training manually:
except KeyboardInterrupt: pass
# Create and return a tagger from the rules we found.
return Brill(self._initial_tagger, rules)
#////////////////////////////////////////////////////////////
# Finding the best rule
#////////////////////////////////////////////////////////////
# Finds the rule that makes the biggest net improvement in the corpus.
# Returns a (rule, score) pair.
def _best_rule(self, test_tokens, train_tokens):
# Create a dictionary mapping from each tag to a list of the
# indices that have that tag in both test_tokens and
# train_tokens (i.e., where it is correctly tagged).
correct_indices = {}
for i in range(len(test_tokens)):
if test_tokens[i][1] == train_tokens[i][1]:
tag = test_tokens[i][1]
correct_indices.setdefault(tag, []).append(i)
# Find all the rules that correct at least one token's tag,
# and the number of tags that each rule corrects (in
# descending order of number of tags corrected).
rules = self._find_rules(test_tokens, train_tokens)
# Keep track of the current best rule, and its score.
best_rule, best_score, best_fixscore = None, 0, 0
# Consider each rule, in descending order of fixscore (the
# number of tags that the rule corrects, not including the
# number that it breaks).
for (rule, fixscore) in rules:
# The actual score must be <= fixscore; so if best_score
# is bigger than fixscore, then we already have the best
# rule.
if best_score >= fixscore:
return best_rule, best_score, best_fixscore
# Calculate the actual score, by decrementing fixscore
# once for each tag that the rule changes to an incorrect
# value.
score = fixscore
if correct_indices.has_key(rule.original_tag()):
for i in correct_indices[rule.original_tag()]:
if rule.applies(test_tokens, i):
score -= 1
# If the score goes below best_score, then we know
# that this isn't the best rule; so move on:
if score <= best_score: break
#print '%5d %5d %s' % (fixscore, score, rule)
# If the actual score is better than the best score, then
# update best_score and best_rule.
if score > best_score:
best_rule, best_score, best_fixscore = rule, score, fixscore
# Return the best rule, and its score.
return best_rule, best_score, best_fixscore
def _find_rules(self, test_tokens, train_tokens):
"""
Find all rules that correct at least one token's tag in
C{test_tokens}.
@return: A list of tuples C{(rule, fixscore)}, where C{rule}
is a brill rule and C{fixscore} is the number of tokens
whose tag the rule corrects. Note that C{fixscore} does
I{not} include the number of tokens whose tags are changed
to incorrect values.
"""
# Create a list of all indices that are incorrectly tagged.
error_indices = [i for i in range(len(test_tokens))
if (test_tokens[i][1] !=
train_tokens[i][1])]
# Create a dictionary mapping from rules to their positive-only
# scores.
rule_score_dict = {}
for i in range(len(test_tokens)):
rules = self._find_rules_at(test_tokens, train_tokens, i)
for rule in rules:
rule_score_dict[rule] = rule_score_dict.get(rule,0) + 1
# Convert the dictionary into a list of (rule, score) tuples,
# sorted in descending order of score.
rule_score_items = rule_score_dict.items()
temp = [(-score, rule) for (rule, score) in rule_score_items]
temp.sort()
return [(rule, -negscore) for (negscore, rule) in temp]
def _find_rules_at(self, test_tokens, train_tokens, i):
"""
@rtype: C{Set}
@return: the set of all rules (based on the templates) that
correct token C{i}'s tag in C{test_tokens}.
"""
applicable_rules = set()
if test_tokens[i][1] != train_tokens[i][1]:
correct_tag = train_tokens[i][1]
for template in self._templates:
new_rules = template.applicable_rules(test_tokens, i,
correct_tag)
applicable_rules.update(new_rules)
return applicable_rules
#////////////////////////////////////////////////////////////
# Tracing
#////////////////////////////////////////////////////////////
def _trace_header(self):
print """
B |
S F r O | Score = Fixed - Broken
c i o t | R Fixed = num tags changed incorrect -> correct
o x k h | u Broken = num tags changed correct -> incorrect
r e e e | l Other = num tags changed incorrect -> incorrect
e d n r | e
------------------+-------------------------------------------------------
""".rstrip()
def _trace_rule(self, rule, score, fixscore, numchanges):
if self._trace > 2:
print ('%4d%4d%4d%4d ' % (score, fixscore, fixscore-score,
numchanges-fixscore*2+score)), '|',
print rule
######################################################################
## Fast Brill Tagger Trainer
######################################################################
class FastBrillTrainer(object):
"""
A faster trainer for brill taggers.
"""
def __init__(self, initial_tagger, templates, trace=0):
self._initial_tagger = initial_tagger
self._templates = templates
self._trace = trace
#////////////////////////////////////////////////////////////
# Training
#////////////////////////////////////////////////////////////
def train(self, train_tokens, max_rules=200, min_score=2):
# If TESTING is true, extra computation is done to determine whether
# each "best" rule actually reduces net error by the score it received.
TESTING = False
# Basic idea: Keep track of the rules that apply at each position.
# And keep track of the positions to which each rule applies.
# The set of somewhere-useful rules that apply at each position
rulesByPosition = []
for i in range(len(train_tokens)):
rulesByPosition.append(set())
# Mapping somewhere-useful rules to the positions where they apply.
# Then maps each position to the score change the rule generates there.
# (always -1, 0, or 1)
positionsByRule = {}
# Map scores to sets of rules known to achieve *at most* that score.
rulesByScore = {0:{}}
# Conversely, map somewhere-useful rules to their minimal scores.
ruleScores = {}
tagIndices = {} # Lists of indices, mapped to by their tags
# Maps rules to the first index in the corpus where it may not be known
# whether the rule applies. (Rules can't be chosen for inclusion
# unless this value = len(corpus). But most rules are bad, and
# we won't need to check the whole corpus to know that.)
# Some indices past this may actually have been checked; it just isn't
# guaranteed.
firstUnknownIndex = {}
# Make entries in the rule-mapping dictionaries.
# Should be called before _updateRuleApplies.
def _initRule (rule):
positionsByRule[rule] = {}
rulesByScore[0][rule] = None
ruleScores[rule] = 0
firstUnknownIndex[rule] = 0
# Takes a somewhere-useful rule which applies at index i;
# Updates all rule data to reflect that the rule so applies.
def _updateRuleApplies (rule, i):
# If the rule is already known to apply here, ignore.
# (This only happens if the position's tag hasn't changed.)
if positionsByRule[rule].has_key(i):
return
if rule.replacement_tag() == train_tokens[i][1]:
positionsByRule[rule][i] = 1
elif rule.original_tag() == train_tokens[i][1]:
positionsByRule[rule][i] = -1
else: # was wrong, remains wrong
positionsByRule[rule][i] = 0
# Update rules in the other dictionaries
del rulesByScore[ruleScores[rule]][rule]
ruleScores[rule] += positionsByRule[rule][i]
if not rulesByScore.has_key(ruleScores[rule]):
rulesByScore[ruleScores[rule]] = {}
rulesByScore[ruleScores[rule]][rule] = None
rulesByPosition[i].add(rule)
# Takes a rule which no longer applies at index i;
# Updates all rule data to reflect that the rule doesn't apply.
def _updateRuleNotApplies (rule, i):
del rulesByScore[ruleScores[rule]][rule]
ruleScores[rule] -= positionsByRule[rule][i]
if not rulesByScore.has_key(ruleScores[rule]):
rulesByScore[ruleScores[rule]] = {}
rulesByScore[ruleScores[rule]][rule] = None
del positionsByRule[rule][i]
rulesByPosition[i].remove(rule)
# Optional addition: if the rule now applies nowhere, delete
# all its dictionary entries.
tagged_tokens = list(self._initial_tagger.tag(t[0] for t in train_tokens))
# First sort the corpus by tag, and also note where the errors are.
errorIndices = [] # only used in initialization
for i in range(len(tagged_tokens)):
tag = tagged_tokens[i][1]
if tag != train_tokens[i][1]:
errorIndices.append(i)
if not tagIndices.has_key(tag):
tagIndices[tag] = []
tagIndices[tag].append(i)
print "Finding useful rules..."
# Collect all rules that fix any errors, with their positive scores.
for i in errorIndices:
for template in self._templates:
# Find the templated rules that could fix the error.
for rule in template.applicable_rules(tagged_tokens, i,
train_tokens[i][1]):
if not positionsByRule.has_key(rule):
_initRule(rule)
_updateRuleApplies(rule, i)
print "Done initializing %i useful rules." %len(positionsByRule)
if TESTING:
after = -1 # bug-check only
# Each iteration through the loop tries a new maxScore.
maxScore = max(rulesByScore.keys())
rules = []
while len(rules) < max_rules and maxScore >= min_score:
# Find the next best rule. This is done by repeatedly taking a rule with
# the highest score and stepping through the corpus to see where it
# applies. When it makes an error (decreasing its score) it's bumped
# down, and we try a new rule with the highest score.
# When we find a rule which has the highest score AND which has been
# tested against the entire corpus, we can conclude that it's the next
# best rule.
bestRule = None
bestRules = rulesByScore[maxScore].keys()
for rule in bestRules:
# Find the first relevant index at or following the first
# unknown index. (Only check indices with the right tag.)
ti = bisect.bisect_left(tagIndices[rule.original_tag()],
firstUnknownIndex[rule])
for nextIndex in tagIndices[rule.original_tag()][ti:]:
if rule.applies(tagged_tokens, nextIndex):
_updateRuleApplies(rule, nextIndex)
if ruleScores[rule] < maxScore:
firstUnknownIndex[rule] = nextIndex+1
break # the _update demoted the rule
# If we checked all remaining indices and found no more errors:
if ruleScores[rule] == maxScore:
firstUnknownIndex[rule] = len(tagged_tokens) # i.e., we checked them all
print "%i) %s (score: %i)" %(len(rules)+1, rule, maxScore)
bestRule = rule
break
if bestRule == None: # all rules dropped below maxScore
del rulesByScore[maxScore]
maxScore = max(rulesByScore.keys())
continue # with next-best rules
# bug-check only
if TESTING:
before = len(_errorPositions(tagged_tokens, train_tokens))
print "There are %i errors before applying this rule." %before
assert after == -1 or before == after, \
"after=%i but before=%i" %(after,before)
print "Applying best rule at %i locations..." \
%len(positionsByRule[bestRule].keys())
# If we reach this point, we've found a new best rule.
# Apply the rule at the relevant sites.
# (apply_at is a little inefficient here, since we know the rule applies
# and don't actually need to test it again.)
rules.append(bestRule)
bestRule.apply_at(tagged_tokens, positionsByRule[bestRule].keys())
# Update the tag index accordingly.
for i in positionsByRule[bestRule].keys(): # where it applied
# Update positions of tags
# First, find and delete the index for i from the old tag.
oldIndex = bisect.bisect_left(tagIndices[bestRule.original_tag()], i)
del tagIndices[bestRule.original_tag()][oldIndex]
# Then, insert i into the index list of the new tag.
if not tagIndices.has_key(bestRule.replacement_tag()):
tagIndices[bestRule.replacement_tag()] = []
newIndex = bisect.bisect_left(tagIndices[bestRule.replacement_tag()], i)
tagIndices[bestRule.replacement_tag()].insert(newIndex, i)
# This part is tricky.
# We need to know which sites might now require new rules -- that
# is, which sites are close enough to the changed site so that
# a template might now generate different rules for it.
# Only the templates can know this.
#
# If a template now generates a different set of rules, we have
# to update our indices to reflect that.
print "Updating neighborhoods of changed sites.\n"
# First, collect all the indices that might get new rules.
neighbors = set()
for i in positionsByRule[bestRule].keys(): # sites changed
for template in self._templates:
neighbors.update(template.get_neighborhood(tagged_tokens, i))
# Then collect the new set of rules for each such index.
c = d = e = 0
for i in neighbors:
siteRules = set()
for template in self._templates:
# Get a set of the rules that the template now generates
siteRules.update(set(template.applicable_rules(
tagged_tokens, i, train_tokens[i][1])))
# Update rules no longer generated here by any template
for obsolete in rulesByPosition[i] - siteRules:
c += 1
_updateRuleNotApplies(obsolete, i)
# Update rules only now generated by this template
for newRule in siteRules - rulesByPosition[i]:
d += 1
if not positionsByRule.has_key(newRule):
e += 1
_initRule(newRule) # make a new rule w/score=0
_updateRuleApplies(newRule, i) # increment score, etc.
if TESTING:
after = before - maxScore
print "%i obsolete rule applications, %i new ones, " %(c,d)+ \
"using %i previously-unseen rules." %e
maxScore = max(rulesByScore.keys()) # may have gone up
if self._trace > 0: print ("Training Brill tagger on %d tokens..." %
len(train_tokens))
# Maintain a list of the rules that apply at each position.
rules_by_position = [{} for tok in train_tokens]
# Create and return a tagger from the rules we found.
return Brill(self._initial_tagger, rules)
######################################################################
## Testing
######################################################################
def _errorPositions (train_tokens, tokens):
return [i for i in range(len(tokens))
if tokens[i][1] !=
train_tokens[i][1] ]
# returns a list of errors in string format
def errorList (train_tokens, tokens, radius=2):
"""
Returns a list of human-readable strings indicating the errors in the
given tagging of the corpus.
@param train_tokens: The correct tagging of the corpus
@type train_tokens: C{list} of C{tuple}
@param tokens: The tagged corpus
@type tokens: C{list} of C{tuple}
@param radius: How many tokens on either side of a wrongly-tagged token
to include in the error string. For example, if C{radius}=2, each error
string will show the incorrect token plus two tokens on either side.
@type radius: int
"""
errors = []
indices = _errorPositions(train_tokens, tokens)
tokenLen = len(tokens)
for i in indices:
ei = tokens[i][1].rjust(3) + " -> " \
+ train_tokens[i][1].rjust(3) + ": "
for j in range( max(i-radius, 0), min(i+radius+1, tokenLen) ):
if tokens[j][0] == tokens[j][1]:
s = tokens[j][0] # don't print punctuation tags
else:
s = tokens[j][0] + "/" + tokens[j][1]
if j == i:
ei += "**"+s+"** "
else:
ei += s + " "
errors.append(ei)
return errors
#####################################################################################
# Demonstration
#####################################################################################
def demo(num_sents=100, max_rules=200, min_score=2, error_output = "errors.out",
rule_output="rules.out", randomize=False, train=.8, trace=3):
"""
Brill Tagger Demonstration
@param num_sents: how many sentences of training and testing data to use
@type num_sents: L{int}
@param max_rules: maximum number of rule instances to create
@type max_rules: L{int}
@param min_score: the minimum score for a rule in order for it to be considered
@type min_score: L{int}
@param error_output: the file where errors will be saved
@type error_output: L{string}
@param rule_output: the file where rules will be saved
@type rule_output: L{string}
@param randomize: whether the training data should be a random subset of the corpus
@type randomize: L{boolean}
@param train: the fraction of the the corpus to be used for training (1=all)
@type train: L{float}
@param trace: the level of diagnostic tracing output to produce (0-3)
@type train: L{int}
"""
from en.parser.nltk_lite.corpora import treebank
from en.parser.nltk_lite import tag
from en.parser.nltk_lite.tag import brill
NN_CD_tagger = tag.Regexp([(r'^-?[0-9]+(.[0-9]+)?$', 'CD'), (r'.*', 'NN')])
# train is the proportion of data used in training; the rest is reserved
# for testing.
print "Loading tagged data..."
sents = list(treebank.tagged())
if randomize:
random.seed(len(sents))
random.shuffle(sents)
tagged_data = [t for s in sents[:num_sents] for t in s]
cutoff = int(len(tagged_data)*train)
training_data = tagged_data[:cutoff]
gold_data = tagged_data[cutoff:]
testing_data = [t[0] for t in gold_data]
# Unigram tagger
print "Training unigram tagger:",
u = tag.Unigram(backoff=NN_CD_tagger)
# NB training and testing are required to use a list-of-lists structure,
# so we wrap the flattened corpus data with the extra list structure.
u.train([training_data])
print("[accuracy: %f]" % tag.accuracy(u, [gold_data]))
# Brill tagger
templates = [
brill.SymmetricProximateTokensTemplate(brill.ProximateTagsRule, (1,1)),
brill.SymmetricProximateTokensTemplate(brill.ProximateTagsRule, (2,2)),
brill.SymmetricProximateTokensTemplate(brill.ProximateTagsRule, (1,2)),
brill.SymmetricProximateTokensTemplate(brill.ProximateTagsRule, (1,3)),
brill.SymmetricProximateTokensTemplate(brill.ProximateWordsRule, (1,1)),
brill.SymmetricProximateTokensTemplate(brill.ProximateWordsRule, (2,2)),
brill.SymmetricProximateTokensTemplate(brill.ProximateWordsRule, (1,2)),
brill.SymmetricProximateTokensTemplate(brill.ProximateWordsRule, (1,3)),
brill.ProximateTokensTemplate(brill.ProximateTagsRule, (-1, -1), (1,1)),
brill.ProximateTokensTemplate(brill.ProximateWordsRule, (-1, -1), (1,1)),
]
#trainer = brill.FastBrillTrainer(u, templates, trace)
trainer = brill.BrillTrainer(u, templates, trace)
b = trainer.train(training_data, max_rules, min_score)
print
print("Brill accuracy: %f" % tag.accuracy(b, [gold_data]))
print("\nRules: ")
printRules = file(rule_output, 'w')
for rule in b.rules():
print(str(rule))
printRules.write(str(rule)+"\n\n")
testing_data = list(b.tag(testing_data))
el = errorList(gold_data, testing_data)
errorFile = file(error_output, 'w')
for e in el:
errorFile.write(e+"\n\n")
errorFile.close()
print "Done; rules and errors saved to %s and %s." % (rule_output, error_output)
if __name__ == '__main__':
demo()
|
mit
|
[
3,
653,
292,
4889,
8466,
15650,
6065,
26,
699,
322,
914,
8053,
836,
199,
3,
199,
3,
1898,
334,
35,
9,
12521,
13,
7968,
15904,
402,
510,
287,
21320,
6371,
290,
4674,
199,
3,
6642,
26,
2799,
322,
2379,
2523,
29936,
1534,
70,
665,
24862,
2174,
1534,
70,
32,
7490,
14,
67,
374,
14,
384,
287,
78,
14,
8654,
30,
199,
3,
3515,
17379,
3079,
491,
2262,
665,
379,
320,
529,
32,
7490,
14,
67,
374,
14,
384,
287,
78,
14,
8654,
30,
199,
3,
3515,
17854,
1856,
699,
5428,
665,
9264,
32,
1259,
261,
14,
324,
1036,
6374,
14,
8654,
14,
3844,
30,
199,
3,
2851,
26,
665,
1014,
921,
7530,
2663,
14,
7646,
14,
846,
30,
199,
3,
2104,
4190,
2556,
12,
1937,
5113,
14,
17715,
199,
199,
624,
199,
34,
322,
914,
1159,
13315,
279,
2332,
13,
6788,
1947,
836,
14,
199,
624,
199,
199,
504,
655,
14,
2087,
14,
7530,
2663,
63,
5333,
14,
1450,
492,
8053,
41,
199,
199,
646,
19063,
263,
327,
367,
3366,
2754,
4012,
282,
10026,
402,
4918,
199,
646,
747,
3322,
327,
367,
17196,
644,
51,
42,
1584,
199,
646,
2196,
263,
327,
367,
28126,
2983,
644,
51,
42,
1584,
199,
646,
984,
3698,
327,
367,
10232,
1414,
13,
604,
2368,
199,
199,
18022,
199,
309,
710,
699,
322,
914,
8053,
836,
199,
18022,
199,
199,
533,
699,
322,
914,
8,
1931,
41,
304,
272,
408,
272,
699,
322,
914,
1159,
13315,
279,
2332,
13,
6788,
1947,
836,
14,
221,
699,
322,
914,
1947,
31988,
675,
376,
272,
1323,
91,
2747,
1947,
836,
93,
334,
10180,
465,
491,
91,
1450,
14,
2698,
1552,
370,
5090,
376,
315,
1009,
272,
1947,
3414,
370,
282,
1318,
27,
436,
2066,
4838,
376,
7741,
769,
402,
272,
13315,
279,
4713,
370,
3211,
314,
3762,
402,
8212,
4645,
14,
272,
5723,
13315,
4713,
787,
2013,
701,
314,
491,
91,
34,
322,
914,
5065,
41,
93,
272,
3217,
14,
339,
699,
322,
914,
1947,
31988,
883,
506,
2737,
5370,
12,
687,
376,
2536,
1947,
836,
436,
272,
282,
769,
402,
13315,
279,
4713,
27,
1325,
1655,
14115,
12,
699,
322,
914,
1947,
31988,
272,
787,
2737,
701,
9328,
4713,
687,
282,
6093,
16831,
12,
1808,
1902,
272,
491,
91,
34,
322,
914,
2437,
16187,
93,
503,
491,
91,
16976,
34,
322,
914,
2437,
16187,
5565,
272,
408,
272,
347,
636,
826,
721,
277,
12,
2536,
63,
1450,
836,
12,
4713,
304,
267,
408,
267,
768,
635,
2536,
63,
1450,
836,
26,
710,
2536,
1947,
836,
267,
768,
466,
2536,
63,
1450,
836,
26,
491,
91,
1931,
41,
93,
267,
768,
635,
4713,
26,
1626,
7741,
769,
402,
13315,
4713,
626,
288,
1077,
506,
1202,
370,
3211,
314,
2536,
1947,
1540,
14,
267,
768,
466,
4713,
26,
445,
91,
513,
93,
402,
491,
91,
34,
322,
914,
5065,
41,
93,
267,
408,
267,
291,
423,
2747,
63,
1450,
836,
275,
2536,
63,
1450,
836,
267,
291,
423,
4423,
275,
4713,
339,
347,
4713,
8,
277,
304,
267,
372,
291,
423,
4423,
5873,
339,
347,
1947,
334,
277,
12,
4645,
304,
267,
327,
27502,
3794,
687,
8053,
41,
2728,
327,
3378,
314,
2536,
1947,
836,
14,
267,
20018,
63,
4504,
275,
769,
8,
277,
423,
2747,
63,
1450,
836,
14,
1450,
8,
4504,
430,
398,
327,
2790,
282,
2600,
626,
9033,
1924,
1947,
370,
282,
769,
402,
314,
267,
327,
4918,
402,
4645,
626,
1172,
626,
1947,
14,
267,
1947,
63,
475,
63,
12658,
275,
1052,
267,
367,
284,
12,
334,
1418,
12,
1947,
9,
315,
3874,
8,
15679,
63,
4504,
304,
288,
340,
1947,
440,
315,
1947,
63,
475,
63,
12658,
26,
355,
1947,
63,
475,
63,
12658,
59,
1450,
61,
275,
663,
779,
73,
566,
288,
587,
26,
355,
1947,
63,
475,
63,
12658,
59,
1450,
1055,
525,
8,
73,
9,
398,
327,
14618,
1924,
2332,
12,
315,
1865,
14,
221,
5972,
862,
370,
4838,
4713,
737,
267,
327,
12266,
626,
1172,
314,
6387,
3379,
1947,
14,
267,
367,
2332,
315,
291,
423,
4423,
26,
288,
327,
6668,
314,
12266,
2382,
652,
5594,
4838,
288,
12266,
275,
1947,
63,
475,
63,
12658,
14,
362,
8,
2200,
14,
5043,
63,
1450,
1062,
3073,
288,
327,
14618,
314,
2332,
737,
5204,
12266,
14,
288,
2896,
275,
2332,
14,
4998,
63,
292,
8,
15679,
63,
4504,
12,
12266,
9,
288,
327,
6162,
1947,
63,
475,
63,
12658,
543,
314,
12266,
402,
3762,
626,
288,
327,
4898,
6042,
14,
288,
367,
284,
315,
2896,
26,
355,
1947,
63,
475,
63,
12658,
59,
2200,
14,
5043,
63,
1450,
342,
1055,
2168,
8,
73,
9,
355,
340,
2332,
14,
15895,
63,
1450,
342,
440,
315,
1947,
63,
475,
63,
12658,
26,
490,
1947,
63,
475,
63,
12658,
59,
2200,
14,
15895,
63,
1450,
5106,
275,
663,
779,
73,
566,
355,
587,
26,
490,
1947,
63,
475,
63,
12658,
59,
2200,
14,
15895,
63,
1450,
342,
1055,
525,
8,
73,
9,
267,
367,
307,
315,
20018,
63,
4504,
26,
288,
1995,
307,
199,
199,
18022,
199,
309,
699,
322,
914,
24259,
199,
18022,
199,
199,
533,
699,
322,
914,
5065,
41,
8,
785,
304,
272,
408,
272,
1626,
3217,
367,
1947,
25947,
641,
282,
20018,
16831,
12,
465,
272,
10585,
701,
20611,
914,
1947,
31988,
14,
221,
7048,
13315,
17651,
1006,
4645,
272,
315,
314,
16831,
626,
787,
20018,
543,
282,
2488,
1323,
91,
5043,
1947,
93,
436,
272,
23082,
282,
2488,
1323,
91,
5394,
1386,
436,
19058,
3932,
3762,
543,
282,
272,
1323,
91,
15895,
1947,
5565,
221,
2104,
1263,
1627,
13315,
12,
314,
3379,
272,
1947,
12,
8343,
1947,
12,
436,
5558,
787,
6317,
14,
221,
1448,
3138,
1443,
272,
11687,
641,
314,
1526,
1334,
8219,
1754,
12,
465,
5521,
465,
1263,
1163,
272,
4645,
315,
314,
16831,
14,
339,
699,
322,
914,
4713,
1471,
506,
1013,
19816,
436,
21197,
14,
272,
408,
14821,
347,
4838,
63,
475,
8,
277,
12,
4645,
304,
267,
408,
267,
14618,
642,
2332,
4036,
4509,
652,
12966,
315,
314,
16831,
14,
221,
473,
14,
69,
2020,
267,
367,
1924,
1526,
315,
314,
16831,
626,
365,
20018,
543,
642,
2332,
1159,
267,
3379,
1947,
12,
436,
626,
13529,
5604,
642,
2332
] |
[
653,
292,
4889,
8466,
15650,
6065,
26,
699,
322,
914,
8053,
836,
199,
3,
199,
3,
1898,
334,
35,
9,
12521,
13,
7968,
15904,
402,
510,
287,
21320,
6371,
290,
4674,
199,
3,
6642,
26,
2799,
322,
2379,
2523,
29936,
1534,
70,
665,
24862,
2174,
1534,
70,
32,
7490,
14,
67,
374,
14,
384,
287,
78,
14,
8654,
30,
199,
3,
3515,
17379,
3079,
491,
2262,
665,
379,
320,
529,
32,
7490,
14,
67,
374,
14,
384,
287,
78,
14,
8654,
30,
199,
3,
3515,
17854,
1856,
699,
5428,
665,
9264,
32,
1259,
261,
14,
324,
1036,
6374,
14,
8654,
14,
3844,
30,
199,
3,
2851,
26,
665,
1014,
921,
7530,
2663,
14,
7646,
14,
846,
30,
199,
3,
2104,
4190,
2556,
12,
1937,
5113,
14,
17715,
199,
199,
624,
199,
34,
322,
914,
1159,
13315,
279,
2332,
13,
6788,
1947,
836,
14,
199,
624,
199,
199,
504,
655,
14,
2087,
14,
7530,
2663,
63,
5333,
14,
1450,
492,
8053,
41,
199,
199,
646,
19063,
263,
327,
367,
3366,
2754,
4012,
282,
10026,
402,
4918,
199,
646,
747,
3322,
327,
367,
17196,
644,
51,
42,
1584,
199,
646,
2196,
263,
327,
367,
28126,
2983,
644,
51,
42,
1584,
199,
646,
984,
3698,
327,
367,
10232,
1414,
13,
604,
2368,
199,
199,
18022,
199,
309,
710,
699,
322,
914,
8053,
836,
199,
18022,
199,
199,
533,
699,
322,
914,
8,
1931,
41,
304,
272,
408,
272,
699,
322,
914,
1159,
13315,
279,
2332,
13,
6788,
1947,
836,
14,
221,
699,
322,
914,
1947,
31988,
675,
376,
272,
1323,
91,
2747,
1947,
836,
93,
334,
10180,
465,
491,
91,
1450,
14,
2698,
1552,
370,
5090,
376,
315,
1009,
272,
1947,
3414,
370,
282,
1318,
27,
436,
2066,
4838,
376,
7741,
769,
402,
272,
13315,
279,
4713,
370,
3211,
314,
3762,
402,
8212,
4645,
14,
272,
5723,
13315,
4713,
787,
2013,
701,
314,
491,
91,
34,
322,
914,
5065,
41,
93,
272,
3217,
14,
339,
699,
322,
914,
1947,
31988,
883,
506,
2737,
5370,
12,
687,
376,
2536,
1947,
836,
436,
272,
282,
769,
402,
13315,
279,
4713,
27,
1325,
1655,
14115,
12,
699,
322,
914,
1947,
31988,
272,
787,
2737,
701,
9328,
4713,
687,
282,
6093,
16831,
12,
1808,
1902,
272,
491,
91,
34,
322,
914,
2437,
16187,
93,
503,
491,
91,
16976,
34,
322,
914,
2437,
16187,
5565,
272,
408,
272,
347,
636,
826,
721,
277,
12,
2536,
63,
1450,
836,
12,
4713,
304,
267,
408,
267,
768,
635,
2536,
63,
1450,
836,
26,
710,
2536,
1947,
836,
267,
768,
466,
2536,
63,
1450,
836,
26,
491,
91,
1931,
41,
93,
267,
768,
635,
4713,
26,
1626,
7741,
769,
402,
13315,
4713,
626,
288,
1077,
506,
1202,
370,
3211,
314,
2536,
1947,
1540,
14,
267,
768,
466,
4713,
26,
445,
91,
513,
93,
402,
491,
91,
34,
322,
914,
5065,
41,
93,
267,
408,
267,
291,
423,
2747,
63,
1450,
836,
275,
2536,
63,
1450,
836,
267,
291,
423,
4423,
275,
4713,
339,
347,
4713,
8,
277,
304,
267,
372,
291,
423,
4423,
5873,
339,
347,
1947,
334,
277,
12,
4645,
304,
267,
327,
27502,
3794,
687,
8053,
41,
2728,
327,
3378,
314,
2536,
1947,
836,
14,
267,
20018,
63,
4504,
275,
769,
8,
277,
423,
2747,
63,
1450,
836,
14,
1450,
8,
4504,
430,
398,
327,
2790,
282,
2600,
626,
9033,
1924,
1947,
370,
282,
769,
402,
314,
267,
327,
4918,
402,
4645,
626,
1172,
626,
1947,
14,
267,
1947,
63,
475,
63,
12658,
275,
1052,
267,
367,
284,
12,
334,
1418,
12,
1947,
9,
315,
3874,
8,
15679,
63,
4504,
304,
288,
340,
1947,
440,
315,
1947,
63,
475,
63,
12658,
26,
355,
1947,
63,
475,
63,
12658,
59,
1450,
61,
275,
663,
779,
73,
566,
288,
587,
26,
355,
1947,
63,
475,
63,
12658,
59,
1450,
1055,
525,
8,
73,
9,
398,
327,
14618,
1924,
2332,
12,
315,
1865,
14,
221,
5972,
862,
370,
4838,
4713,
737,
267,
327,
12266,
626,
1172,
314,
6387,
3379,
1947,
14,
267,
367,
2332,
315,
291,
423,
4423,
26,
288,
327,
6668,
314,
12266,
2382,
652,
5594,
4838,
288,
12266,
275,
1947,
63,
475,
63,
12658,
14,
362,
8,
2200,
14,
5043,
63,
1450,
1062,
3073,
288,
327,
14618,
314,
2332,
737,
5204,
12266,
14,
288,
2896,
275,
2332,
14,
4998,
63,
292,
8,
15679,
63,
4504,
12,
12266,
9,
288,
327,
6162,
1947,
63,
475,
63,
12658,
543,
314,
12266,
402,
3762,
626,
288,
327,
4898,
6042,
14,
288,
367,
284,
315,
2896,
26,
355,
1947,
63,
475,
63,
12658,
59,
2200,
14,
5043,
63,
1450,
342,
1055,
2168,
8,
73,
9,
355,
340,
2332,
14,
15895,
63,
1450,
342,
440,
315,
1947,
63,
475,
63,
12658,
26,
490,
1947,
63,
475,
63,
12658,
59,
2200,
14,
15895,
63,
1450,
5106,
275,
663,
779,
73,
566,
355,
587,
26,
490,
1947,
63,
475,
63,
12658,
59,
2200,
14,
15895,
63,
1450,
342,
1055,
525,
8,
73,
9,
267,
367,
307,
315,
20018,
63,
4504,
26,
288,
1995,
307,
199,
199,
18022,
199,
309,
699,
322,
914,
24259,
199,
18022,
199,
199,
533,
699,
322,
914,
5065,
41,
8,
785,
304,
272,
408,
272,
1626,
3217,
367,
1947,
25947,
641,
282,
20018,
16831,
12,
465,
272,
10585,
701,
20611,
914,
1947,
31988,
14,
221,
7048,
13315,
17651,
1006,
4645,
272,
315,
314,
16831,
626,
787,
20018,
543,
282,
2488,
1323,
91,
5043,
1947,
93,
436,
272,
23082,
282,
2488,
1323,
91,
5394,
1386,
436,
19058,
3932,
3762,
543,
282,
272,
1323,
91,
15895,
1947,
5565,
221,
2104,
1263,
1627,
13315,
12,
314,
3379,
272,
1947,
12,
8343,
1947,
12,
436,
5558,
787,
6317,
14,
221,
1448,
3138,
1443,
272,
11687,
641,
314,
1526,
1334,
8219,
1754,
12,
465,
5521,
465,
1263,
1163,
272,
4645,
315,
314,
16831,
14,
339,
699,
322,
914,
4713,
1471,
506,
1013,
19816,
436,
21197,
14,
272,
408,
14821,
347,
4838,
63,
475,
8,
277,
12,
4645,
304,
267,
408,
267,
14618,
642,
2332,
4036,
4509,
652,
12966,
315,
314,
16831,
14,
221,
473,
14,
69,
2020,
267,
367,
1924,
1526,
315,
314,
16831,
626,
365,
20018,
543,
642,
2332,
1159,
267,
3379,
1947,
12,
436,
626,
13529,
5604,
642,
2332,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
komarudin02/Public
|
node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py
|
1558
|
4945
|
# Copyright (c) 2011 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.
import re
import os
def XmlToString(content, encoding='utf-8', pretty=False):
""" Writes the XML content to disk, touching the file only if it has changed.
Visual Studio files have a lot of pre-defined structures. This function makes
it easy to represent these structures as Python data structures, instead of
having to create a lot of function calls.
Each XML element of the content is represented as a list composed of:
1. The name of the element, a string,
2. The attributes of the element, a dictionary (optional), and
3+. The content of the element, if any. Strings are simple text nodes and
lists are child elements.
Example 1:
<test/>
becomes
['test']
Example 2:
<myelement a='value1' b='value2'>
<childtype>This is</childtype>
<childtype>it!</childtype>
</myelement>
becomes
['myelement', {'a':'value1', 'b':'value2'},
['childtype', 'This is'],
['childtype', 'it!'],
]
Args:
content: The structured content to be converted.
encoding: The encoding to report on the first XML line.
pretty: True if we want pretty printing with indents and new lines.
Returns:
The XML content as a string.
"""
# We create a huge list of all the elements of the file.
xml_parts = ['<?xml version="1.0" encoding="%s"?>' % encoding]
if pretty:
xml_parts.append('\n')
_ConstructContentList(xml_parts, content, pretty)
# Convert it to a string
return ''.join(xml_parts)
def _ConstructContentList(xml_parts, specification, pretty, level=0):
""" Appends the XML parts corresponding to the specification.
Args:
xml_parts: A list of XML parts to be appended to.
specification: The specification of the element. See EasyXml docs.
pretty: True if we want pretty printing with indents and new lines.
level: Indentation level.
"""
# The first item in a specification is the name of the element.
if pretty:
indentation = ' ' * level
new_line = '\n'
else:
indentation = ''
new_line = ''
name = specification[0]
if not isinstance(name, str):
raise Exception('The first item of an EasyXml specification should be '
'a string. Specification was ' + str(specification))
xml_parts.append(indentation + '<' + name)
# Optionally in second position is a dictionary of the attributes.
rest = specification[1:]
if rest and isinstance(rest[0], dict):
for at, val in sorted(rest[0].iteritems()):
xml_parts.append(' %s="%s"' % (at, _XmlEscape(val, attr=True)))
rest = rest[1:]
if rest:
xml_parts.append('>')
all_strings = reduce(lambda x, y: x and isinstance(y, str), rest, True)
multi_line = not all_strings
if multi_line and new_line:
xml_parts.append(new_line)
for child_spec in rest:
# If it's a string, append a text node.
# Otherwise recurse over that child definition
if isinstance(child_spec, str):
xml_parts.append(_XmlEscape(child_spec))
else:
_ConstructContentList(xml_parts, child_spec, pretty, level + 1)
if multi_line and indentation:
xml_parts.append(indentation)
xml_parts.append('</%s>%s' % (name, new_line))
else:
xml_parts.append('/>%s' % new_line)
def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False,
win32=False):
""" Writes the XML content to disk, touching the file only if it has changed.
Args:
content: The structured content to be written.
path: Location of the file.
encoding: The encoding to report on the first line of the XML file.
pretty: True if we want pretty printing with indents and new lines.
"""
xml_string = XmlToString(content, encoding, pretty)
if win32 and os.linesep != '\r\n':
xml_string = xml_string.replace('\n', '\r\n')
try:
xml_string = xml_string.encode(encoding)
except Exception:
xml_string = unicode(xml_string, 'latin-1').encode(encoding)
# Get the old content
try:
f = open(path, 'r')
existing = f.read()
f.close()
except:
existing = None
# It has changed, write it
if existing != xml_string:
f = open(path, 'w')
f.write(xml_string)
f.close()
_xml_escape_map = {
'"': '"',
"'": ''',
'<': '<',
'>': '>',
'&': '&',
'\n': '
',
'\r': '
',
}
_xml_escape_re = re.compile(
"(%s)" % "|".join(map(re.escape, _xml_escape_map.keys())))
def _XmlEscape(value, attr=False):
""" Escape a string for inclusion in XML."""
def replace(match):
m = match.string[match.start() : match.end()]
# don't replace single quotes in attrs
if attr and m == "'":
return m
return _xml_escape_map[m]
return _xml_escape_re.sub(replace, value)
|
mit
|
[
3,
1898,
334,
67,
9,
7760,
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,
646,
295,
199,
646,
747,
421,
199,
318,
24881,
7756,
8,
1317,
12,
2644,
534,
1624,
13,
24,
297,
7268,
29,
797,
304,
523,
408,
30753,
314,
4692,
1564,
370,
4543,
12,
12943,
316,
314,
570,
1454,
340,
652,
965,
2896,
14,
819,
14702,
13225,
1584,
1172,
282,
13918,
402,
876,
13,
4037,
13955,
14,
221,
961,
805,
7704,
523,
652,
8837,
370,
2954,
3520,
13955,
465,
2018,
666,
13955,
12,
3140,
402,
523,
9445,
370,
1218,
282,
13918,
402,
805,
4882,
14,
819,
7048,
4692,
1819,
402,
314,
1564,
365,
11159,
465,
282,
769,
26356,
402,
26,
523,
413,
14,
710,
536,
402,
314,
1819,
12,
282,
1059,
12,
523,
499,
14,
710,
3004,
402,
314,
1819,
12,
282,
2600,
334,
4144,
395,
436,
523,
650,
26240,
710,
1564,
402,
314,
1819,
12,
340,
1263,
14,
221,
24361,
787,
3486,
1318,
3380,
436,
489,
5548,
787,
1982,
4008,
14,
819,
5679,
413,
26,
489,
665,
396,
3133,
523,
15410,
489,
788,
396,
418,
819,
5679,
499,
26,
489,
665,
1662,
2108,
282,
534,
585,
17,
7,
330,
534,
585,
18,
8423,
268,
665,
1739,
466,
30,
2765,
365,
1108,
1739,
466,
30,
268,
665,
1739,
466,
30,
390,
28718,
1739,
466,
30,
489,
3068,
1662,
2108,
30,
819,
15410,
489,
788,
1662,
2108,
297,
791,
65,
5242,
585,
17,
297,
283,
66,
5242,
585,
18,
2267,
268,
788,
1739,
466,
297,
283,
2765,
365,
995,
268,
788,
1739,
466,
297,
283,
390,
1,
995,
489,
1622,
819,
3033,
26,
272,
1564,
26,
221,
710,
21781,
1564,
370,
506,
6702,
14,
272,
2644,
26,
710,
2644,
370,
3622,
641,
314,
1642,
4692,
1004,
14,
272,
7268,
26,
715,
340,
781,
2934,
7268,
16116,
543,
31140,
436,
892,
2385,
14,
819,
1803,
26,
272,
710,
4692,
1564,
465,
282,
1059,
14,
523,
408,
523,
327,
2136,
1218,
282,
27791,
769,
402,
1006,
314,
4008,
402,
314,
570,
14,
523,
2748,
63,
4181,
275,
12329,
31,
1652,
1015,
628,
17,
14,
16,
2,
2644,
5961,
83,
14863,
3524,
450,
2644,
61,
523,
340,
7268,
26,
272,
2748,
63,
4181,
14,
740,
2258,
78,
358,
523,
485,
11493,
2714,
1296,
8,
1652,
63,
4181,
12,
1564,
12,
7268,
9,
819,
327,
7905,
652,
370,
282,
1059,
523,
372,
6522,
904,
8,
1652,
63,
4181,
9,
421,
199,
318,
485,
11493,
2714,
1296,
8,
1652,
63,
4181,
12,
8929,
12,
7268,
12,
2166,
29,
16,
304,
523,
408,
4693,
3198,
314,
4692,
4184,
5226,
370,
314,
8929,
14,
819,
3033,
26,
272,
2748,
63,
4181,
26,
437,
769,
402,
4692,
4184,
370,
506,
11544,
370,
14,
272,
8929,
26,
221,
710,
8929,
402,
314,
1819,
14,
221,
1666,
18951,
8672,
9149,
14,
272,
7268,
26,
715,
340,
781,
2934,
7268,
16116,
543,
31140,
436,
892,
2385,
14,
272,
2166,
26,
1010,
1326,
425,
2166,
14,
523,
408,
523,
327,
710,
1642,
1242,
315,
282,
8929,
365,
314,
536,
402,
314,
1819,
14,
523,
340,
7268,
26,
272,
14311,
275,
283,
221,
283,
627,
2166,
272,
892,
63,
604,
275,
1557,
78,
7,
523,
587,
26,
272,
14311,
275,
2125,
272,
892,
63,
604,
275,
2125,
523,
536,
275,
8929,
59,
16,
61,
523,
340,
440,
1228,
8,
354,
12,
620,
304,
272,
746,
2186,
360,
1918,
1642,
1242,
402,
376,
18951,
8672,
8929,
1077,
506,
283,
490,
283,
65,
1059,
14,
221,
5367,
3477,
1990,
283,
435,
620,
8,
22271,
430,
523,
2748,
63,
4181,
14,
740,
8,
25152,
435,
24958,
435,
536,
9,
819,
327,
22383,
315,
3499,
3421,
365,
282,
2600,
402,
314,
3004,
14,
523,
4618,
275,
8929,
59,
17,
2938,
523,
340,
4618,
436,
1228,
8,
3911,
59,
16,
467,
1211,
304,
272,
367,
737,
12,
1139,
315,
3355,
8,
3911,
59,
16,
1055,
4611,
5109,
489,
2748,
63,
4181,
14,
740,
360,
450,
83,
5961,
83,
4507,
450,
334,
292,
12,
485,
8672,
10260,
8,
637,
12,
1921,
29,
549,
1724,
272,
4618,
275,
4618,
59,
17,
2938,
523,
340,
4618,
26,
272,
2748,
63,
4181,
14,
740,
28781,
272,
1006,
63,
5465,
275,
7114,
8,
2734,
671,
12,
612,
26,
671,
436,
1228,
8,
89,
12,
620,
395,
4618,
12,
715,
9,
272,
3510,
63,
604,
275,
440,
1006,
63,
5465,
272,
340,
3510,
63,
604,
436,
892,
63,
604,
26,
489,
2748,
63,
4181,
14,
740,
8,
1222,
63,
604,
9,
272,
367,
1982,
63,
1650,
315,
4618,
26,
489,
327,
982,
652,
1159,
282,
1059,
12,
5666,
282,
1318,
1031,
14,
489,
327,
6630,
18011,
1806,
626,
1982,
5492,
489,
340,
1228,
8,
1739,
63,
1650,
12,
620,
304,
2126,
2748,
63,
4181,
14,
740,
1547,
8672,
10260,
8,
1739,
63,
1650,
430,
489,
587,
26,
267,
485,
11493,
2714,
1296,
8,
1652,
63,
4181,
12,
1982,
63,
1650,
12,
7268,
12,
2166,
435,
413,
9,
272,
340,
3510,
63,
604,
436,
14311,
26,
489,
2748,
63,
4181,
14,
740,
8,
25152,
9,
272,
2748,
63,
4181,
14,
740,
26576,
83,
6598,
83,
7,
450,
334,
354,
12,
892,
63,
604,
430,
523,
587,
26,
272,
2748,
63,
4181,
14,
740,
2336,
6598,
83,
7,
450,
892,
63,
604,
9,
421,
199,
318,
6990,
8672,
3917,
6970,
8,
1317,
12,
931,
12,
2644,
534,
1624,
13,
24,
297,
7268,
29,
797,
12,
1993,
4747,
708,
29,
797,
304,
523,
408,
30753,
314,
4692,
1564,
370,
4543,
12,
12943,
316,
314,
570,
1454,
340,
652,
965,
2896,
14,
819,
3033,
26,
272,
1564,
26,
221,
710,
21781,
1564,
370,
506,
5313,
14,
272,
931,
26,
12625,
402,
314,
570,
14,
272,
2644,
26,
710,
2644,
370,
3622,
641,
314,
1642,
1004,
402,
314,
4692,
570,
14,
272,
7268,
26,
715,
340,
781,
2934,
7268,
16116,
543,
31140,
436,
892,
2385,
14,
523,
408,
523,
2748,
63,
875,
275,
24881,
7756,
8,
1317,
12,
2644,
12,
7268,
9,
523,
340,
4747,
708,
436,
747,
14,
19254,
1137,
1557,
82,
60,
78
] |
[
1898,
334,
67,
9,
7760,
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,
646,
295,
199,
646,
747,
421,
199,
318,
24881,
7756,
8,
1317,
12,
2644,
534,
1624,
13,
24,
297,
7268,
29,
797,
304,
523,
408,
30753,
314,
4692,
1564,
370,
4543,
12,
12943,
316,
314,
570,
1454,
340,
652,
965,
2896,
14,
819,
14702,
13225,
1584,
1172,
282,
13918,
402,
876,
13,
4037,
13955,
14,
221,
961,
805,
7704,
523,
652,
8837,
370,
2954,
3520,
13955,
465,
2018,
666,
13955,
12,
3140,
402,
523,
9445,
370,
1218,
282,
13918,
402,
805,
4882,
14,
819,
7048,
4692,
1819,
402,
314,
1564,
365,
11159,
465,
282,
769,
26356,
402,
26,
523,
413,
14,
710,
536,
402,
314,
1819,
12,
282,
1059,
12,
523,
499,
14,
710,
3004,
402,
314,
1819,
12,
282,
2600,
334,
4144,
395,
436,
523,
650,
26240,
710,
1564,
402,
314,
1819,
12,
340,
1263,
14,
221,
24361,
787,
3486,
1318,
3380,
436,
489,
5548,
787,
1982,
4008,
14,
819,
5679,
413,
26,
489,
665,
396,
3133,
523,
15410,
489,
788,
396,
418,
819,
5679,
499,
26,
489,
665,
1662,
2108,
282,
534,
585,
17,
7,
330,
534,
585,
18,
8423,
268,
665,
1739,
466,
30,
2765,
365,
1108,
1739,
466,
30,
268,
665,
1739,
466,
30,
390,
28718,
1739,
466,
30,
489,
3068,
1662,
2108,
30,
819,
15410,
489,
788,
1662,
2108,
297,
791,
65,
5242,
585,
17,
297,
283,
66,
5242,
585,
18,
2267,
268,
788,
1739,
466,
297,
283,
2765,
365,
995,
268,
788,
1739,
466,
297,
283,
390,
1,
995,
489,
1622,
819,
3033,
26,
272,
1564,
26,
221,
710,
21781,
1564,
370,
506,
6702,
14,
272,
2644,
26,
710,
2644,
370,
3622,
641,
314,
1642,
4692,
1004,
14,
272,
7268,
26,
715,
340,
781,
2934,
7268,
16116,
543,
31140,
436,
892,
2385,
14,
819,
1803,
26,
272,
710,
4692,
1564,
465,
282,
1059,
14,
523,
408,
523,
327,
2136,
1218,
282,
27791,
769,
402,
1006,
314,
4008,
402,
314,
570,
14,
523,
2748,
63,
4181,
275,
12329,
31,
1652,
1015,
628,
17,
14,
16,
2,
2644,
5961,
83,
14863,
3524,
450,
2644,
61,
523,
340,
7268,
26,
272,
2748,
63,
4181,
14,
740,
2258,
78,
358,
523,
485,
11493,
2714,
1296,
8,
1652,
63,
4181,
12,
1564,
12,
7268,
9,
819,
327,
7905,
652,
370,
282,
1059,
523,
372,
6522,
904,
8,
1652,
63,
4181,
9,
421,
199,
318,
485,
11493,
2714,
1296,
8,
1652,
63,
4181,
12,
8929,
12,
7268,
12,
2166,
29,
16,
304,
523,
408,
4693,
3198,
314,
4692,
4184,
5226,
370,
314,
8929,
14,
819,
3033,
26,
272,
2748,
63,
4181,
26,
437,
769,
402,
4692,
4184,
370,
506,
11544,
370,
14,
272,
8929,
26,
221,
710,
8929,
402,
314,
1819,
14,
221,
1666,
18951,
8672,
9149,
14,
272,
7268,
26,
715,
340,
781,
2934,
7268,
16116,
543,
31140,
436,
892,
2385,
14,
272,
2166,
26,
1010,
1326,
425,
2166,
14,
523,
408,
523,
327,
710,
1642,
1242,
315,
282,
8929,
365,
314,
536,
402,
314,
1819,
14,
523,
340,
7268,
26,
272,
14311,
275,
283,
221,
283,
627,
2166,
272,
892,
63,
604,
275,
1557,
78,
7,
523,
587,
26,
272,
14311,
275,
2125,
272,
892,
63,
604,
275,
2125,
523,
536,
275,
8929,
59,
16,
61,
523,
340,
440,
1228,
8,
354,
12,
620,
304,
272,
746,
2186,
360,
1918,
1642,
1242,
402,
376,
18951,
8672,
8929,
1077,
506,
283,
490,
283,
65,
1059,
14,
221,
5367,
3477,
1990,
283,
435,
620,
8,
22271,
430,
523,
2748,
63,
4181,
14,
740,
8,
25152,
435,
24958,
435,
536,
9,
819,
327,
22383,
315,
3499,
3421,
365,
282,
2600,
402,
314,
3004,
14,
523,
4618,
275,
8929,
59,
17,
2938,
523,
340,
4618,
436,
1228,
8,
3911,
59,
16,
467,
1211,
304,
272,
367,
737,
12,
1139,
315,
3355,
8,
3911,
59,
16,
1055,
4611,
5109,
489,
2748,
63,
4181,
14,
740,
360,
450,
83,
5961,
83,
4507,
450,
334,
292,
12,
485,
8672,
10260,
8,
637,
12,
1921,
29,
549,
1724,
272,
4618,
275,
4618,
59,
17,
2938,
523,
340,
4618,
26,
272,
2748,
63,
4181,
14,
740,
28781,
272,
1006,
63,
5465,
275,
7114,
8,
2734,
671,
12,
612,
26,
671,
436,
1228,
8,
89,
12,
620,
395,
4618,
12,
715,
9,
272,
3510,
63,
604,
275,
440,
1006,
63,
5465,
272,
340,
3510,
63,
604,
436,
892,
63,
604,
26,
489,
2748,
63,
4181,
14,
740,
8,
1222,
63,
604,
9,
272,
367,
1982,
63,
1650,
315,
4618,
26,
489,
327,
982,
652,
1159,
282,
1059,
12,
5666,
282,
1318,
1031,
14,
489,
327,
6630,
18011,
1806,
626,
1982,
5492,
489,
340,
1228,
8,
1739,
63,
1650,
12,
620,
304,
2126,
2748,
63,
4181,
14,
740,
1547,
8672,
10260,
8,
1739,
63,
1650,
430,
489,
587,
26,
267,
485,
11493,
2714,
1296,
8,
1652,
63,
4181,
12,
1982,
63,
1650,
12,
7268,
12,
2166,
435,
413,
9,
272,
340,
3510,
63,
604,
436,
14311,
26,
489,
2748,
63,
4181,
14,
740,
8,
25152,
9,
272,
2748,
63,
4181,
14,
740,
26576,
83,
6598,
83,
7,
450,
334,
354,
12,
892,
63,
604,
430,
523,
587,
26,
272,
2748,
63,
4181,
14,
740,
2336,
6598,
83,
7,
450,
892,
63,
604,
9,
421,
199,
318,
6990,
8672,
3917,
6970,
8,
1317,
12,
931,
12,
2644,
534,
1624,
13,
24,
297,
7268,
29,
797,
12,
1993,
4747,
708,
29,
797,
304,
523,
408,
30753,
314,
4692,
1564,
370,
4543,
12,
12943,
316,
314,
570,
1454,
340,
652,
965,
2896,
14,
819,
3033,
26,
272,
1564,
26,
221,
710,
21781,
1564,
370,
506,
5313,
14,
272,
931,
26,
12625,
402,
314,
570,
14,
272,
2644,
26,
710,
2644,
370,
3622,
641,
314,
1642,
1004,
402,
314,
4692,
570,
14,
272,
7268,
26,
715,
340,
781,
2934,
7268,
16116,
543,
31140,
436,
892,
2385,
14,
523,
408,
523,
2748,
63,
875,
275,
24881,
7756,
8,
1317,
12,
2644,
12,
7268,
9,
523,
340,
4747,
708,
436,
747,
14,
19254,
1137,
1557,
82,
60,
78,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
nkmk/python-snippets
|
notebook/pypdf2_metadata_remove.py
|
1
|
4178
|
import PyPDF2
src_pdf = PyPDF2.PdfFileReader('data/src/pdf/sample1.pdf')
dst_pdf = PyPDF2.PdfFileWriter()
dst_pdf.cloneReaderDocumentRoot(src_pdf)
with open('data/temp/sample1_no_meta.pdf', 'wb') as f:
dst_pdf.write(f)
print(PyPDF2.PdfFileReader('data/temp/sample1_no_meta.pdf').documentInfo)
# {'/Producer': 'PyPDF2'}
dst_pdf.addMetadata({'/Producer': ''})
with open('data/temp/sample1_no_meta.pdf', 'wb') as f:
dst_pdf.write(f)
print(PyPDF2.PdfFileReader('data/temp/sample1_no_meta.pdf').documentInfo)
# {'/Producer': ''}
def remove_all_metadata(src_path, dst_path, producer=''):
src_pdf = PyPDF2.PdfFileReader(src_path)
dst_pdf = PyPDF2.PdfFileWriter()
dst_pdf.cloneReaderDocumentRoot(src_pdf)
dst_pdf.addMetadata({'/Producer': producer})
with open(dst_path, 'wb') as f:
dst_pdf.write(f)
remove_all_metadata('data/src/pdf/sample1.pdf', 'data/temp/sample1_no_meta.pdf')
print(PyPDF2.PdfFileReader('data/temp/sample1_no_meta.pdf').documentInfo)
# {'/Producer': ''}
src_pdf = PyPDF2.PdfFileReader('data/src/pdf/sample1.pdf')
dst_pdf = PyPDF2.PdfFileWriter()
d = {key: src_pdf.documentInfo[key] for key in src_pdf.documentInfo.keys()}
print(d)
# {'/Title': 'sample1', '/Producer': 'macOS バージョン10.14.2(ビルド18C54) Quartz PDFContext', '/Creator': 'Keynote', '/CreationDate': "D:20190114072947Z00'00'", '/ModDate': "D:20190114072947Z00'00'"}
d.pop('/Creator')
d.pop('/Producer')
print(d)
# {'/Title': 'sample1', '/CreationDate': "D:20190114072947Z00'00'", '/ModDate': "D:20190114072947Z00'00'"}
dst_pdf.addMetadata(d)
with open('data/temp/sample1_remove_meta.pdf', 'wb') as f:
dst_pdf.write(f)
print(PyPDF2.PdfFileReader('data/temp/sample1_remove_meta.pdf').documentInfo)
# {'/Producer': 'PyPDF2', '/Title': 'sample1', '/CreationDate': "D:20190114072947Z00'00'", '/ModDate': "D:20190114072947Z00'00'"}
def remove_metadata(src_path, dst_path, *args, producer=''):
src_pdf = PyPDF2.PdfFileReader(src_path)
dst_pdf = PyPDF2.PdfFileWriter()
dst_pdf.cloneReaderDocumentRoot(src_pdf)
d = {key: src_pdf.documentInfo[key] for key in src_pdf.documentInfo.keys()
if key not in args}
d.setdefault('/Producer', producer)
dst_pdf.addMetadata(d)
with open(dst_path, 'wb') as f:
dst_pdf.write(f)
remove_metadata('data/src/pdf/sample1.pdf', 'data/temp/sample1_no_meta.pdf',
'/Creator', '/ModDate', '/CreationDate')
print(PyPDF2.PdfFileReader('data/temp/sample1_no_meta.pdf').documentInfo)
# {'/Producer': 'macOS バージョン10.14.2(ビルド18C54) Quartz PDFContext', '/Title': 'sample1'}
remove_metadata('data/src/pdf/sample1.pdf', 'data/temp/sample1_no_meta.pdf',
'/Creator', '/ModDate', '/CreationDate', '/Producer')
print(PyPDF2.PdfFileReader('data/temp/sample1_no_meta.pdf').documentInfo)
# {'/Producer': '', '/Title': 'sample1'}
remove_metadata('data/src/pdf/sample1.pdf', 'data/temp/sample1_no_meta.pdf',
'/Creator', '/ModDate', '/CreationDate', '/Producer', producer='XXX')
print(PyPDF2.PdfFileReader('data/temp/sample1_no_meta.pdf').documentInfo)
# {'/Producer': 'XXX', '/Title': 'sample1'}
def select_metadata(src_path, dst_path, *args, producer=''):
src_pdf = PyPDF2.PdfFileReader(src_path)
dst_pdf = PyPDF2.PdfFileWriter()
dst_pdf.cloneReaderDocumentRoot(src_pdf)
d = {key: src_pdf.documentInfo[key] for key in src_pdf.documentInfo.keys()
if key in args}
d.setdefault('/Producer', producer)
dst_pdf.addMetadata(d)
with open(dst_path, 'wb') as f:
dst_pdf.write(f)
select_metadata('data/src/pdf/sample1.pdf', 'data/temp/sample1_no_meta.pdf',
'/Title', '/ModDate')
print(PyPDF2.PdfFileReader('data/temp/sample1_no_meta.pdf').documentInfo)
# {'/Producer': '', '/Title': 'sample1', '/ModDate': "D:20190114072947Z00'00'"}
select_metadata('data/src/pdf/sample1.pdf', 'data/temp/sample1_no_meta.pdf',
'/Title', '/Producer')
print(PyPDF2.PdfFileReader('data/temp/sample1_no_meta.pdf').documentInfo)
# {'/Producer': 'macOS バージョン10.14.2(ビルド18C54) Quartz PDFContext', '/Title': 'sample1'}
|
mit
|
[
646,
1611,
7638,
18,
199,
199,
2164,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
358,
199,
5119,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
28199,
342,
199,
199,
5119,
63,
5607,
14,
6311,
5929,
5564,
6405,
8,
2164,
63,
5607,
9,
199,
199,
1045,
1551,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
297,
283,
6603,
358,
465,
289,
26,
272,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
283,
2713,
7638,
18,
936,
199,
199,
5119,
63,
5607,
14,
525,
5142,
3252,
15,
15532,
356,
283,
3071,
199,
199,
1045,
1551,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
297,
283,
6603,
358,
465,
289,
26,
272,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
28174,
199,
199,
318,
2813,
63,
452,
63,
2343,
8,
2164,
63,
515,
12,
5042,
63,
515,
12,
17339,
9280,
272,
2928,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
1173,
5929,
8,
2164,
63,
515,
9,
272,
5042,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
28199,
342,
272,
5042,
63,
5607,
14,
6311,
5929,
5564,
6405,
8,
2164,
63,
5607,
9,
272,
5042,
63,
5607,
14,
525,
5142,
3252,
15,
15532,
356,
17339,
1552,
272,
543,
1551,
8,
5119,
63,
515,
12,
283,
6603,
358,
465,
289,
26,
267,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
2168,
63,
452,
63,
2343,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
297,
283,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
358,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
28174,
199,
199,
2164,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
358,
199,
5119,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
28199,
342,
199,
199,
68,
275,
469,
498,
26,
2928,
63,
5607,
14,
3554,
2354,
59,
498,
61,
367,
790,
315,
2928,
63,
5607,
14,
3554,
2354,
14,
1612,
12737,
199,
199,
1361,
8,
68,
9,
199,
3,
791,
15,
6888,
356,
283,
3271,
17,
297,
1994,
15532,
356,
283,
3088,
3100,
221,
5692,
239,
17670,
5573,
117,
5692,
101,
23488,
709,
14,
1079,
14,
18,
8454,
231,
5692,
242,
29910,
5692,
232,
1085,
35,
1477,
8454,
232,
5843,
28124,
15537,
2998,
297,
1994,
17523,
356,
283,
1197,
4610,
297,
1994,
13921,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
4662,
1994,
9871,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
7,
3570,
199,
199,
68,
14,
1935,
2336,
17523,
358,
199,
68,
14,
1935,
2336,
15532,
358,
199,
199,
1361,
8,
68,
9,
199,
3,
791,
15,
6888,
356,
283,
3271,
17,
297,
1994,
13921,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
4662,
1994,
9871,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
7,
3570,
199,
199,
5119,
63,
5607,
14,
525,
5142,
8,
68,
9,
199,
199,
1045,
1551,
360,
576,
15,
808,
15,
3271,
17,
63,
2168,
63,
2024,
14,
5607,
297,
283,
6603,
358,
465,
289,
26,
272,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
2168,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
283,
2713,
7638,
18,
297,
1994,
6888,
356,
283,
3271,
17,
297,
1994,
13921,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
4662,
1994,
9871,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
7,
3570,
199,
199,
318,
2813,
63,
2343,
8,
2164,
63,
515,
12,
5042,
63,
515,
12,
627,
589,
12,
17339,
9280,
272,
2928,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
1173,
5929,
8,
2164,
63,
515,
9,
272,
5042,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
28199,
342,
272,
5042,
63,
5607,
14,
6311,
5929,
5564,
6405,
8,
2164,
63,
5607,
9,
2286,
366,
275,
469,
498,
26,
2928,
63,
5607,
14,
3554,
2354,
59,
498,
61,
367,
790,
315,
2928,
63,
5607,
14,
3554,
2354,
14,
1612,
342,
268,
340,
790,
440,
315,
1249,
93,
2286,
366,
14,
5486,
2336,
15532,
297,
17339,
9,
2286,
5042,
63,
5607,
14,
525,
5142,
8,
68,
9,
272,
543,
1551,
8,
5119,
63,
515,
12,
283,
6603,
358,
465,
289,
26,
267,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
2168,
63,
2343,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
297,
283,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
297,
355,
1994,
17523,
297,
1994,
9871,
2506,
297,
1994,
13921,
2506,
358,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
283,
3088,
3100,
221,
5692,
239,
17670,
5573,
117,
5692,
101,
23488,
709,
14,
1079,
14,
18,
8454,
231,
5692,
242,
29910,
5692,
232,
1085,
35,
1477,
8454,
232,
5843,
28124,
15537,
2998,
297,
1994,
6888,
356,
283,
3271,
17,
936,
199,
199,
2168,
63,
2343,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
297,
283,
576,
15,
808,
15,
3271
] |
[
1611,
7638,
18,
199,
199,
2164,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
358,
199,
5119,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
28199,
342,
199,
199,
5119,
63,
5607,
14,
6311,
5929,
5564,
6405,
8,
2164,
63,
5607,
9,
199,
199,
1045,
1551,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
297,
283,
6603,
358,
465,
289,
26,
272,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
283,
2713,
7638,
18,
936,
199,
199,
5119,
63,
5607,
14,
525,
5142,
3252,
15,
15532,
356,
283,
3071,
199,
199,
1045,
1551,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
297,
283,
6603,
358,
465,
289,
26,
272,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
28174,
199,
199,
318,
2813,
63,
452,
63,
2343,
8,
2164,
63,
515,
12,
5042,
63,
515,
12,
17339,
9280,
272,
2928,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
1173,
5929,
8,
2164,
63,
515,
9,
272,
5042,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
28199,
342,
272,
5042,
63,
5607,
14,
6311,
5929,
5564,
6405,
8,
2164,
63,
5607,
9,
272,
5042,
63,
5607,
14,
525,
5142,
3252,
15,
15532,
356,
17339,
1552,
272,
543,
1551,
8,
5119,
63,
515,
12,
283,
6603,
358,
465,
289,
26,
267,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
2168,
63,
452,
63,
2343,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
297,
283,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
358,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
28174,
199,
199,
2164,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
358,
199,
5119,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
28199,
342,
199,
199,
68,
275,
469,
498,
26,
2928,
63,
5607,
14,
3554,
2354,
59,
498,
61,
367,
790,
315,
2928,
63,
5607,
14,
3554,
2354,
14,
1612,
12737,
199,
199,
1361,
8,
68,
9,
199,
3,
791,
15,
6888,
356,
283,
3271,
17,
297,
1994,
15532,
356,
283,
3088,
3100,
221,
5692,
239,
17670,
5573,
117,
5692,
101,
23488,
709,
14,
1079,
14,
18,
8454,
231,
5692,
242,
29910,
5692,
232,
1085,
35,
1477,
8454,
232,
5843,
28124,
15537,
2998,
297,
1994,
17523,
356,
283,
1197,
4610,
297,
1994,
13921,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
4662,
1994,
9871,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
7,
3570,
199,
199,
68,
14,
1935,
2336,
17523,
358,
199,
68,
14,
1935,
2336,
15532,
358,
199,
199,
1361,
8,
68,
9,
199,
3,
791,
15,
6888,
356,
283,
3271,
17,
297,
1994,
13921,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
4662,
1994,
9871,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
7,
3570,
199,
199,
5119,
63,
5607,
14,
525,
5142,
8,
68,
9,
199,
199,
1045,
1551,
360,
576,
15,
808,
15,
3271,
17,
63,
2168,
63,
2024,
14,
5607,
297,
283,
6603,
358,
465,
289,
26,
272,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
2168,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
283,
2713,
7638,
18,
297,
1994,
6888,
356,
283,
3271,
17,
297,
1994,
13921,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
4662,
1994,
9871,
2506,
356,
298,
36,
26,
14982,
614,
1079,
1780,
1398,
2417,
58,
383,
7,
383,
7,
3570,
199,
199,
318,
2813,
63,
2343,
8,
2164,
63,
515,
12,
5042,
63,
515,
12,
627,
589,
12,
17339,
9280,
272,
2928,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
1173,
5929,
8,
2164,
63,
515,
9,
272,
5042,
63,
5607,
275,
1611,
7638,
18,
14,
48,
1587,
28199,
342,
272,
5042,
63,
5607,
14,
6311,
5929,
5564,
6405,
8,
2164,
63,
5607,
9,
2286,
366,
275,
469,
498,
26,
2928,
63,
5607,
14,
3554,
2354,
59,
498,
61,
367,
790,
315,
2928,
63,
5607,
14,
3554,
2354,
14,
1612,
342,
268,
340,
790,
440,
315,
1249,
93,
2286,
366,
14,
5486,
2336,
15532,
297,
17339,
9,
2286,
5042,
63,
5607,
14,
525,
5142,
8,
68,
9,
272,
543,
1551,
8,
5119,
63,
515,
12,
283,
6603,
358,
465,
289,
26,
267,
5042,
63,
5607,
14,
952,
8,
70,
9,
199,
199,
2168,
63,
2343,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
297,
283,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
297,
355,
1994,
17523,
297,
1994,
9871,
2506,
297,
1994,
13921,
2506,
358,
199,
1361,
8,
2713,
7638,
18,
14,
48,
1587,
1173,
5929,
360,
576,
15,
808,
15,
3271,
17,
63,
889,
63,
2024,
14,
5607,
1959,
3554,
2354,
9,
199,
3,
791,
15,
15532,
356,
283,
3088,
3100,
221,
5692,
239,
17670,
5573,
117,
5692,
101,
23488,
709,
14,
1079,
14,
18,
8454,
231,
5692,
242,
29910,
5692,
232,
1085,
35,
1477,
8454,
232,
5843,
28124,
15537,
2998,
297,
1994,
6888,
356,
283,
3271,
17,
936,
199,
199,
2168,
63,
2343,
360,
576,
15,
2164,
15,
5607,
15,
3271,
17,
14,
5607,
297,
283,
576,
15,
808,
15,
3271,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
KaranToor/MA450
|
google-cloud-sdk/.install/.backup/lib/googlecloudsdk/command_lib/ml/predict_utilities.py
|
3
|
3913
|
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utilities for reading instances for prediction."""
import json
from googlecloudsdk.core import exceptions as core_exceptions
from googlecloudsdk.core import resources
from googlecloudsdk.core.util import files
class InvalidInstancesFileError(core_exceptions.Error):
"""Indicates that the input file was invalid in some way."""
pass
def ReadInstances(input_file, data_format, limit=None):
"""Reads the instances from input file.
Args:
input_file: An open file-like object for the input file.
data_format: str, data format of the input file, 'json' or 'text'.
limit: int, the maximum number of instances allowed in the file
Returns:
A list of instances.
Raises:
InvalidInstancesFileError: If the input file is invalid (invalid format or
contains too many/zero instances).
"""
instances = []
for line_num, line in enumerate(input_file):
line_content = line.rstrip('\n')
if not line_content:
raise InvalidInstancesFileError('Empty line is not allowed in the '
'instances file.')
if limit and line_num >= limit:
raise InvalidInstancesFileError(
'Online prediction can process no more than ' + str(limit) +
' instances per file. Please use batch prediction instead.')
if data_format == 'json':
try:
instances.append(json.loads(line_content))
except ValueError:
raise InvalidInstancesFileError(
'Input instances are not in JSON format. '
'See "gcloud beta ml predict --help" for details.')
elif data_format == 'text':
instances.append(line_content)
if not instances:
raise InvalidInstancesFileError('No valid instance was found.')
return instances
def ReadInstancesFromArgs(json_instances, text_instances, limit=None):
"""Reads the instances from the given file path ('-' for stdin).
Exactly one of json_instances, text_instances must be given.
Args:
json_instances: str or None, a path to a file ('-' for stdin) containing
instances in JSON format.
text_instances: str or None, a path to a file ('-' for stdin) containing
instances in text format.
limit: int, the maximum number of instances allowed in the file
Returns:
A list of instances.
Raises:
InvalidInstancesFileError: If the input file is invalid (invalid format or
contains too many/zero instances), or an improper combination of input
files was given.
"""
if (json_instances and text_instances or
not (json_instances or text_instances)):
raise InvalidInstancesFileError(
'Exactly one of --json-instances and --text-instances must be '
'specified.')
if json_instances:
data_format = 'json'
input_file = json_instances
elif text_instances:
data_format = 'text'
input_file = text_instances
with files.Open(input_file) as f:
return ReadInstances(f, data_format, limit=limit)
def ParseModelOrVersionRef(model_id, version_id):
if version_id:
return resources.REGISTRY.Parse(version_id,
collection='ml.projects.models.versions',
params={'modelsId': model_id})
else:
return resources.REGISTRY.Parse(model_id, collection='ml.projects.models')
|
apache-2.0
|
[
3,
1898,
7800,
4475,
3277,
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,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
624,
22905,
367,
7664,
4454,
367,
12044,
1041,
199,
199,
646,
2022,
199,
199,
504,
6233,
29691,
6341,
14,
1018,
492,
4967,
465,
6170,
63,
3924,
199,
504,
6233,
29691,
6341,
14,
1018,
492,
5944,
199,
504,
6233,
29691,
6341,
14,
1018,
14,
1974,
492,
1584,
421,
199,
533,
6378,
18194,
25212,
8,
1018,
63,
3924,
14,
547,
304,
523,
408,
607,
16292,
626,
314,
1324,
570,
1990,
3866,
315,
2005,
4340,
1041,
523,
986,
421,
199,
318,
5574,
18194,
8,
1210,
63,
493,
12,
666,
63,
908,
12,
2304,
29,
403,
304,
523,
408,
23614,
314,
4454,
687,
1324,
570,
14,
819,
3033,
26,
272,
1324,
63,
493,
26,
1626,
1551,
570,
13,
2930,
909,
367,
314,
1324,
570,
14,
272,
666,
63,
908,
26,
620,
12,
666,
1475,
402,
314,
1324,
570,
12,
283,
1001,
7,
503,
283,
505,
1370,
272,
2304,
26,
1109,
12,
314,
5696,
1329,
402,
4454,
4370,
315,
314,
570,
819,
1803,
26,
272,
437,
769,
402,
4454,
14,
819,
6218,
26,
272,
6378,
18194,
25212,
26,
982,
314,
1324,
570,
365,
3866,
334,
3197,
1475,
503,
267,
3509,
4634,
5002,
15,
4262,
4454,
680,
523,
408,
523,
4454,
275,
942,
819,
367,
1004,
63,
1507,
12,
1004,
315,
3874,
8,
1210,
63,
493,
304,
272,
1004,
63,
1317,
275,
1004,
14,
6735,
2258,
78,
358,
272,
340,
440,
1004,
63,
1317,
26,
489,
746,
6378,
18194,
25212,
360,
4699,
1004,
365,
440,
4370,
315,
314,
283,
4228,
283,
5990,
570,
2659,
272,
340,
2304,
436,
1004,
63,
1507,
2356,
2304,
26,
489,
746,
6378,
18194,
25212,
8,
881,
283,
28587,
12044,
883,
2112,
949,
1655,
2419,
283,
435,
620,
8,
3097,
9,
435,
881,
283,
4454,
1126,
570,
14,
7754,
675,
3522,
12044,
3140,
2659,
272,
340,
666,
63,
908,
508,
283,
1001,
356,
489,
862,
26,
267,
4454,
14,
740,
8,
1001,
14,
3640,
8,
604,
63,
1317,
430,
489,
871,
1722,
26,
267,
746,
6378,
18194,
25212,
8,
288,
283,
3205,
4454,
787,
440,
315,
4840,
1475,
14,
283,
288,
283,
9295,
298,
71,
4091,
8201,
19184,
12610,
1553,
3437,
2,
367,
2436,
2659,
272,
916,
666,
63,
908,
508,
283,
505,
356,
489,
4454,
14,
740,
8,
604,
63,
1317,
9,
819,
340,
440,
4454,
26,
272,
746,
6378,
18194,
25212,
360,
1944,
1686,
1256,
1990,
1911,
2659,
819,
372,
4454,
421,
199,
318,
5574,
18194,
2532,
6213,
8,
1001,
63,
5990,
12,
1318,
63,
5990,
12,
2304,
29,
403,
304,
523,
408,
23614,
314,
4454,
687,
314,
1627,
570,
931,
12291,
7,
367,
9009,
680,
819,
1316,
2442,
590,
1373,
402,
2022,
63,
5990,
12,
1318,
63,
5990,
1471,
506,
1627,
14,
819,
3033,
26,
272,
2022,
63,
5990,
26,
620,
503,
488,
12,
282,
931,
370,
282,
570,
12291,
7,
367,
9009,
9,
3035,
267,
4454,
315,
4840,
1475,
14,
272,
1318,
63,
5990,
26,
620,
503,
488,
12,
282,
931,
370,
282,
570,
12291,
7,
367,
9009,
9,
3035,
267,
4454,
315,
1318,
1475,
14,
272,
2304,
26,
1109,
12,
314,
5696,
1329,
402,
4454,
4370,
315,
314,
570,
819,
1803,
26,
272,
437,
769,
402,
4454,
14,
819,
6218,
26,
272,
6378,
18194,
25212,
26,
982,
314,
1324,
570,
365,
3866,
334,
3197,
1475,
503,
267,
3509,
4634,
5002,
15,
4262,
4454,
395,
503,
376,
1742,
9198,
14665,
402,
1324,
267,
1584,
1990,
1627,
14,
523,
408,
523,
340,
334,
1001,
63,
5990,
436,
1318,
63,
5990,
503,
489,
440,
334,
1001,
63,
5990,
503,
1318,
63,
5990,
2298,
272,
746,
6378,
18194,
25212,
8,
267,
283,
29751,
590,
1373,
402,
1553,
1001,
13,
5990,
436,
1553,
505,
13,
5990,
1471,
506,
283,
267,
283,
10085,
2659,
819,
340,
2022,
63,
5990,
26,
272,
666,
63,
908,
275,
283,
1001,
7,
272,
1324,
63,
493,
275,
2022,
63,
5990,
523,
916,
1318,
63,
5990,
26,
272,
666,
63,
908,
275,
283,
505,
7,
272,
1324,
63,
493,
275,
1318,
63,
5990,
819,
543,
1584,
14,
4299,
8,
1210,
63,
493,
9,
465,
289,
26,
272,
372,
5574,
18194,
8,
70,
12,
666,
63,
908,
12,
2304,
29,
3097,
9,
421,
199,
318,
6077,
1685,
2844,
3353,
2891,
8,
1238,
63,
344,
12,
1015,
63,
344,
304,
523,
340,
1015,
63,
344,
26,
272,
372,
5944,
14,
25304,
57,
14,
4003,
8,
1023,
63,
344,
12,
2511,
3245,
534,
757,
14,
6776,
14,
992,
14,
6234,
297,
2511,
1862,
3713,
992,
1304,
356,
1402,
63,
344,
1552,
523,
587,
26,
272,
372,
5944,
14,
25304,
57,
14,
4003,
8,
1238,
63,
344,
12,
3245,
534,
757,
14,
6776,
14,
992,
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
] |
[
1898,
7800,
4475,
3277,
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,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
624,
22905,
367,
7664,
4454,
367,
12044,
1041,
199,
199,
646,
2022,
199,
199,
504,
6233,
29691,
6341,
14,
1018,
492,
4967,
465,
6170,
63,
3924,
199,
504,
6233,
29691,
6341,
14,
1018,
492,
5944,
199,
504,
6233,
29691,
6341,
14,
1018,
14,
1974,
492,
1584,
421,
199,
533,
6378,
18194,
25212,
8,
1018,
63,
3924,
14,
547,
304,
523,
408,
607,
16292,
626,
314,
1324,
570,
1990,
3866,
315,
2005,
4340,
1041,
523,
986,
421,
199,
318,
5574,
18194,
8,
1210,
63,
493,
12,
666,
63,
908,
12,
2304,
29,
403,
304,
523,
408,
23614,
314,
4454,
687,
1324,
570,
14,
819,
3033,
26,
272,
1324,
63,
493,
26,
1626,
1551,
570,
13,
2930,
909,
367,
314,
1324,
570,
14,
272,
666,
63,
908,
26,
620,
12,
666,
1475,
402,
314,
1324,
570,
12,
283,
1001,
7,
503,
283,
505,
1370,
272,
2304,
26,
1109,
12,
314,
5696,
1329,
402,
4454,
4370,
315,
314,
570,
819,
1803,
26,
272,
437,
769,
402,
4454,
14,
819,
6218,
26,
272,
6378,
18194,
25212,
26,
982,
314,
1324,
570,
365,
3866,
334,
3197,
1475,
503,
267,
3509,
4634,
5002,
15,
4262,
4454,
680,
523,
408,
523,
4454,
275,
942,
819,
367,
1004,
63,
1507,
12,
1004,
315,
3874,
8,
1210,
63,
493,
304,
272,
1004,
63,
1317,
275,
1004,
14,
6735,
2258,
78,
358,
272,
340,
440,
1004,
63,
1317,
26,
489,
746,
6378,
18194,
25212,
360,
4699,
1004,
365,
440,
4370,
315,
314,
283,
4228,
283,
5990,
570,
2659,
272,
340,
2304,
436,
1004,
63,
1507,
2356,
2304,
26,
489,
746,
6378,
18194,
25212,
8,
881,
283,
28587,
12044,
883,
2112,
949,
1655,
2419,
283,
435,
620,
8,
3097,
9,
435,
881,
283,
4454,
1126,
570,
14,
7754,
675,
3522,
12044,
3140,
2659,
272,
340,
666,
63,
908,
508,
283,
1001,
356,
489,
862,
26,
267,
4454,
14,
740,
8,
1001,
14,
3640,
8,
604,
63,
1317,
430,
489,
871,
1722,
26,
267,
746,
6378,
18194,
25212,
8,
288,
283,
3205,
4454,
787,
440,
315,
4840,
1475,
14,
283,
288,
283,
9295,
298,
71,
4091,
8201,
19184,
12610,
1553,
3437,
2,
367,
2436,
2659,
272,
916,
666,
63,
908,
508,
283,
505,
356,
489,
4454,
14,
740,
8,
604,
63,
1317,
9,
819,
340,
440,
4454,
26,
272,
746,
6378,
18194,
25212,
360,
1944,
1686,
1256,
1990,
1911,
2659,
819,
372,
4454,
421,
199,
318,
5574,
18194,
2532,
6213,
8,
1001,
63,
5990,
12,
1318,
63,
5990,
12,
2304,
29,
403,
304,
523,
408,
23614,
314,
4454,
687,
314,
1627,
570,
931,
12291,
7,
367,
9009,
680,
819,
1316,
2442,
590,
1373,
402,
2022,
63,
5990,
12,
1318,
63,
5990,
1471,
506,
1627,
14,
819,
3033,
26,
272,
2022,
63,
5990,
26,
620,
503,
488,
12,
282,
931,
370,
282,
570,
12291,
7,
367,
9009,
9,
3035,
267,
4454,
315,
4840,
1475,
14,
272,
1318,
63,
5990,
26,
620,
503,
488,
12,
282,
931,
370,
282,
570,
12291,
7,
367,
9009,
9,
3035,
267,
4454,
315,
1318,
1475,
14,
272,
2304,
26,
1109,
12,
314,
5696,
1329,
402,
4454,
4370,
315,
314,
570,
819,
1803,
26,
272,
437,
769,
402,
4454,
14,
819,
6218,
26,
272,
6378,
18194,
25212,
26,
982,
314,
1324,
570,
365,
3866,
334,
3197,
1475,
503,
267,
3509,
4634,
5002,
15,
4262,
4454,
395,
503,
376,
1742,
9198,
14665,
402,
1324,
267,
1584,
1990,
1627,
14,
523,
408,
523,
340,
334,
1001,
63,
5990,
436,
1318,
63,
5990,
503,
489,
440,
334,
1001,
63,
5990,
503,
1318,
63,
5990,
2298,
272,
746,
6378,
18194,
25212,
8,
267,
283,
29751,
590,
1373,
402,
1553,
1001,
13,
5990,
436,
1553,
505,
13,
5990,
1471,
506,
283,
267,
283,
10085,
2659,
819,
340,
2022,
63,
5990,
26,
272,
666,
63,
908,
275,
283,
1001,
7,
272,
1324,
63,
493,
275,
2022,
63,
5990,
523,
916,
1318,
63,
5990,
26,
272,
666,
63,
908,
275,
283,
505,
7,
272,
1324,
63,
493,
275,
1318,
63,
5990,
819,
543,
1584,
14,
4299,
8,
1210,
63,
493,
9,
465,
289,
26,
272,
372,
5574,
18194,
8,
70,
12,
666,
63,
908,
12,
2304,
29,
3097,
9,
421,
199,
318,
6077,
1685,
2844,
3353,
2891,
8,
1238,
63,
344,
12,
1015,
63,
344,
304,
523,
340,
1015,
63,
344,
26,
272,
372,
5944,
14,
25304,
57,
14,
4003,
8,
1023,
63,
344,
12,
2511,
3245,
534,
757,
14,
6776,
14,
992,
14,
6234,
297,
2511,
1862,
3713,
992,
1304,
356,
1402,
63,
344,
1552,
523,
587,
26,
272,
372,
5944,
14,
25304,
57,
14,
4003,
8,
1238,
63,
344,
12,
3245,
534,
757,
14,
6776,
14,
992,
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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mozilla/stoneridge
|
python/src/Lib/lib2to3/fixes/fix_has_key.py
|
326
|
3227
|
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for has_key().
Calls to .has_key() methods are expressed in terms of the 'in'
operator:
d.has_key(k) -> k in d
CAVEATS:
1) While the primary target of this fixer is dict.has_key(), the
fixer will change any has_key() method call, regardless of its
class.
2) Cases like this will not be converted:
m = d.has_key
if m(k):
...
Only *calls* to has_key() are converted. While it is possible to
convert the above to something like
m = d.__contains__
if m(k):
...
this is currently not done.
"""
# Local imports
from .. import pytree
from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Name, parenthesize
class FixHasKey(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
anchor=power<
before=any+
trailer< '.' 'has_key' >
trailer<
'('
( not(arglist | argument<any '=' any>) arg=any
| arglist<(not argument<any '=' any>) arg=any ','>
)
')'
>
after=any*
>
|
negation=not_test<
'not'
anchor=power<
before=any+
trailer< '.' 'has_key' >
trailer<
'('
( not(arglist | argument<any '=' any>) arg=any
| arglist<(not argument<any '=' any>) arg=any ','>
)
')'
>
>
>
"""
def transform(self, node, results):
assert results
syms = self.syms
if (node.parent.type == syms.not_test and
self.pattern.match(node.parent)):
# Don't transform a node matching the first alternative of the
# pattern when its parent matches the second alternative
return None
negation = results.get("negation")
anchor = results["anchor"]
prefix = node.prefix
before = [n.clone() for n in results["before"]]
arg = results["arg"].clone()
after = results.get("after")
if after:
after = [n.clone() for n in after]
if arg.type in (syms.comparison, syms.not_test, syms.and_test,
syms.or_test, syms.test, syms.lambdef, syms.argument):
arg = parenthesize(arg)
if len(before) == 1:
before = before[0]
else:
before = pytree.Node(syms.power, before)
before.prefix = u" "
n_op = Name(u"in", prefix=u" ")
if negation:
n_not = Name(u"not", prefix=u" ")
n_op = pytree.Node(syms.comp_op, (n_not, n_op))
new = pytree.Node(syms.comparison, (arg, n_op, before))
if after:
new = parenthesize(new)
new = pytree.Node(syms.power, (new,) + tuple(after))
if node.parent.type in (syms.comparison, syms.expr, syms.xor_expr,
syms.and_expr, syms.shift_expr,
syms.arith_expr, syms.term,
syms.factor, syms.power):
new = parenthesize(new)
new.prefix = prefix
return new
|
mpl-2.0
|
[
3,
1898,
8315,
4475,
12,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
3909,
370,
29770,
1334,
282,
17636,
28629,
14,
199,
199,
624,
11985,
281,
367,
965,
63,
498,
1252,
199,
199,
18287,
370,
1275,
1989,
63,
498,
342,
3102,
787,
19147,
315,
2895,
402,
314,
283,
262,
7,
199,
3856,
26,
339,
366,
14,
1989,
63,
498,
8,
75,
9,
1035,
1022,
315,
366,
199,
199,
3263,
2524,
619,
51,
26,
199,
17,
9,
22117,
314,
5062,
1347,
402,
642,
24739,
365,
1211,
14,
1989,
63,
498,
1062,
314,
2043,
24739,
911,
1570,
1263,
965,
63,
498,
342,
1083,
1240,
12,
15270,
402,
2399,
2043,
1021,
14,
199,
199,
18,
9,
445,
3274,
2839,
642,
911,
440,
506,
6702,
26,
339,
333,
275,
366,
14,
1989,
63,
498,
272,
340,
333,
8,
75,
304,
267,
2263,
8410,
5972,
627,
5352,
10,
370,
965,
63,
498,
342,
787,
6702,
14,
22117,
652,
365,
3962,
370,
2043,
3957,
314,
3432,
370,
6020,
2839,
339,
333,
275,
366,
855,
6134,
363,
272,
340,
333,
8,
75,
304,
267,
2263,
8410,
642,
365,
5544,
440,
4224,
14,
199,
624,
199,
199,
3,
10111,
8925,
199,
504,
2508,
492,
23353,
199,
504,
2508,
80,
2268,
18,
492,
1526,
199,
504,
2508,
492,
24739,
63,
1095,
199,
504,
2508,
25973,
63,
1974,
492,
2812,
12,
13566,
1589,
890,
421,
199,
533,
14811,
6362,
1197,
8,
25973,
63,
1095,
14,
1563,
11985,
304,
272,
699,
45,
63,
6490,
275,
715,
339,
31467,
7689,
275,
408,
272,
12514,
29,
5652,
28,
267,
2544,
29,
1629,
11,
267,
17357,
28,
7815,
283,
1989,
63,
498,
7,
690,
267,
17357,
28,
288,
16746,
288,
334,
440,
8,
26995,
1204,
1423,
28,
1629,
14051,
1263,
18956,
1680,
29,
1629,
288,
1204,
24660,
28,
8,
1397,
1423,
28,
1629,
14051,
1263,
18956,
1680,
29,
1629,
1656,
8423,
288,
776,
288,
16107,
267,
690,
267,
2410,
29,
1629,
10,
272,
690,
272,
1204,
272,
1279,
5360,
29,
1397,
63,
396,
28,
267,
283,
1397,
7,
267,
12514,
29,
5652,
28,
288,
2544,
29,
1629,
11,
288,
17357,
28,
7815,
283,
1989,
63,
498,
7,
690,
288,
17357,
28,
355,
16746,
355,
334,
440,
8,
26995,
1204,
1423,
28,
1629,
14051,
1263,
18956,
1680,
29,
1629,
355,
1204,
24660,
28,
8,
1397,
1423,
28,
1629,
14051,
1263,
18956,
1680,
29,
1629,
1656,
8423,
355,
776,
355,
16107,
288,
690,
267,
690,
272,
690,
272,
408,
339,
347,
5793,
8,
277,
12,
1031,
12,
2058,
304,
267,
702,
2058,
267,
25308,
275,
291,
14,
13807,
267,
340,
334,
932,
14,
1708,
14,
466,
508,
25308,
14,
1397,
63,
396,
436,
288,
291,
14,
3401,
14,
1431,
8,
932,
14,
1708,
2298,
288,
327,
7529,
1133,
5793,
282,
1031,
4877,
314,
1642,
13943,
402,
314,
288,
327,
3851,
1380,
2399,
1676,
4450,
314,
3499,
13943,
288,
372,
488,
267,
1279,
5360,
275,
2058,
14,
362,
480,
685,
5360,
531,
267,
12514,
275,
2058,
905,
11498,
937,
267,
2403,
275,
1031,
14,
1861,
267,
2544,
275,
359,
78,
14,
6311,
342,
367,
302,
315,
2058,
905,
5182,
15261,
267,
1680,
275,
2058,
905,
1273,
4140,
6311,
342,
267,
2410,
275,
2058,
14,
362,
480,
4399,
531,
267,
340,
2410,
26,
288,
2410,
275,
359,
78,
14,
6311,
342,
367,
302,
315,
2410,
61,
267,
340,
1680,
14,
466,
315,
334,
13807,
14,
8547,
12,
25308,
14,
1397,
63,
396,
12,
25308,
14,
460,
63,
396,
12,
717,
25308,
14,
269,
63,
396,
12,
25308,
14,
396,
12,
25308,
14,
416,
887,
318,
12,
25308,
14,
2094,
304,
288,
1680,
275,
13566,
1589,
890,
8,
1273,
9,
267,
340,
822,
8,
5182,
9,
508,
413,
26,
288,
2544,
275,
2544,
59,
16,
61,
267,
587,
26,
288,
2544,
275,
23353,
14,
1716,
8,
13807,
14,
5652,
12,
2544,
9,
267,
2544,
14,
1861,
275,
399,
2,
298,
267,
302,
63,
411,
275,
2812,
8,
85,
2,
262,
401,
2403,
29,
85,
2,
6099,
267,
340,
1279,
5360,
26,
288,
302,
63,
1397,
275,
2812,
8,
85,
2,
1397,
401,
2403,
29,
85,
2,
6099,
288,
302,
63,
411,
275,
23353,
14,
1716,
8,
13807,
14,
863,
63,
411,
12,
334,
78,
63,
1397,
12,
302,
63,
411,
430,
267,
892,
275,
23353,
14,
1716,
8,
13807,
14,
8547,
12,
334,
1273,
12,
302,
63,
411,
12,
2544,
430,
267,
340,
2410,
26,
288,
892,
275,
13566,
1589,
890,
8,
1222,
9,
288,
892,
275,
23353,
14,
1716,
8,
13807,
14,
5652,
12,
334,
1222,
4258,
435,
2008,
8,
4399,
430,
267,
340,
1031,
14,
1708,
14,
466,
315,
334,
13807,
14,
8547,
12,
25308,
14,
3684,
12,
25308,
14,
15721,
63,
3684,
12,
1816,
25308,
14,
460,
63,
3684,
12,
25308,
14,
4723,
63,
3684,
12,
1816,
25308,
14,
18327,
63,
3684,
12,
25308,
14,
5125,
12,
1816,
25308,
14,
4778,
12,
25308,
14,
5652,
304,
288,
892,
275,
13566,
1589,
890,
8,
1222,
9,
267,
892,
14,
1861,
275,
2403,
267,
372,
892,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
8315,
4475,
12,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
3909,
370,
29770,
1334,
282,
17636,
28629,
14,
199,
199,
624,
11985,
281,
367,
965,
63,
498,
1252,
199,
199,
18287,
370,
1275,
1989,
63,
498,
342,
3102,
787,
19147,
315,
2895,
402,
314,
283,
262,
7,
199,
3856,
26,
339,
366,
14,
1989,
63,
498,
8,
75,
9,
1035,
1022,
315,
366,
199,
199,
3263,
2524,
619,
51,
26,
199,
17,
9,
22117,
314,
5062,
1347,
402,
642,
24739,
365,
1211,
14,
1989,
63,
498,
1062,
314,
2043,
24739,
911,
1570,
1263,
965,
63,
498,
342,
1083,
1240,
12,
15270,
402,
2399,
2043,
1021,
14,
199,
199,
18,
9,
445,
3274,
2839,
642,
911,
440,
506,
6702,
26,
339,
333,
275,
366,
14,
1989,
63,
498,
272,
340,
333,
8,
75,
304,
267,
2263,
8410,
5972,
627,
5352,
10,
370,
965,
63,
498,
342,
787,
6702,
14,
22117,
652,
365,
3962,
370,
2043,
3957,
314,
3432,
370,
6020,
2839,
339,
333,
275,
366,
855,
6134,
363,
272,
340,
333,
8,
75,
304,
267,
2263,
8410,
642,
365,
5544,
440,
4224,
14,
199,
624,
199,
199,
3,
10111,
8925,
199,
504,
2508,
492,
23353,
199,
504,
2508,
80,
2268,
18,
492,
1526,
199,
504,
2508,
492,
24739,
63,
1095,
199,
504,
2508,
25973,
63,
1974,
492,
2812,
12,
13566,
1589,
890,
421,
199,
533,
14811,
6362,
1197,
8,
25973,
63,
1095,
14,
1563,
11985,
304,
272,
699,
45,
63,
6490,
275,
715,
339,
31467,
7689,
275,
408,
272,
12514,
29,
5652,
28,
267,
2544,
29,
1629,
11,
267,
17357,
28,
7815,
283,
1989,
63,
498,
7,
690,
267,
17357,
28,
288,
16746,
288,
334,
440,
8,
26995,
1204,
1423,
28,
1629,
14051,
1263,
18956,
1680,
29,
1629,
288,
1204,
24660,
28,
8,
1397,
1423,
28,
1629,
14051,
1263,
18956,
1680,
29,
1629,
1656,
8423,
288,
776,
288,
16107,
267,
690,
267,
2410,
29,
1629,
10,
272,
690,
272,
1204,
272,
1279,
5360,
29,
1397,
63,
396,
28,
267,
283,
1397,
7,
267,
12514,
29,
5652,
28,
288,
2544,
29,
1629,
11,
288,
17357,
28,
7815,
283,
1989,
63,
498,
7,
690,
288,
17357,
28,
355,
16746,
355,
334,
440,
8,
26995,
1204,
1423,
28,
1629,
14051,
1263,
18956,
1680,
29,
1629,
355,
1204,
24660,
28,
8,
1397,
1423,
28,
1629,
14051,
1263,
18956,
1680,
29,
1629,
1656,
8423,
355,
776,
355,
16107,
288,
690,
267,
690,
272,
690,
272,
408,
339,
347,
5793,
8,
277,
12,
1031,
12,
2058,
304,
267,
702,
2058,
267,
25308,
275,
291,
14,
13807,
267,
340,
334,
932,
14,
1708,
14,
466,
508,
25308,
14,
1397,
63,
396,
436,
288,
291,
14,
3401,
14,
1431,
8,
932,
14,
1708,
2298,
288,
327,
7529,
1133,
5793,
282,
1031,
4877,
314,
1642,
13943,
402,
314,
288,
327,
3851,
1380,
2399,
1676,
4450,
314,
3499,
13943,
288,
372,
488,
267,
1279,
5360,
275,
2058,
14,
362,
480,
685,
5360,
531,
267,
12514,
275,
2058,
905,
11498,
937,
267,
2403,
275,
1031,
14,
1861,
267,
2544,
275,
359,
78,
14,
6311,
342,
367,
302,
315,
2058,
905,
5182,
15261,
267,
1680,
275,
2058,
905,
1273,
4140,
6311,
342,
267,
2410,
275,
2058,
14,
362,
480,
4399,
531,
267,
340,
2410,
26,
288,
2410,
275,
359,
78,
14,
6311,
342,
367,
302,
315,
2410,
61,
267,
340,
1680,
14,
466,
315,
334,
13807,
14,
8547,
12,
25308,
14,
1397,
63,
396,
12,
25308,
14,
460,
63,
396,
12,
717,
25308,
14,
269,
63,
396,
12,
25308,
14,
396,
12,
25308,
14,
416,
887,
318,
12,
25308,
14,
2094,
304,
288,
1680,
275,
13566,
1589,
890,
8,
1273,
9,
267,
340,
822,
8,
5182,
9,
508,
413,
26,
288,
2544,
275,
2544,
59,
16,
61,
267,
587,
26,
288,
2544,
275,
23353,
14,
1716,
8,
13807,
14,
5652,
12,
2544,
9,
267,
2544,
14,
1861,
275,
399,
2,
298,
267,
302,
63,
411,
275,
2812,
8,
85,
2,
262,
401,
2403,
29,
85,
2,
6099,
267,
340,
1279,
5360,
26,
288,
302,
63,
1397,
275,
2812,
8,
85,
2,
1397,
401,
2403,
29,
85,
2,
6099,
288,
302,
63,
411,
275,
23353,
14,
1716,
8,
13807,
14,
863,
63,
411,
12,
334,
78,
63,
1397,
12,
302,
63,
411,
430,
267,
892,
275,
23353,
14,
1716,
8,
13807,
14,
8547,
12,
334,
1273,
12,
302,
63,
411,
12,
2544,
430,
267,
340,
2410,
26,
288,
892,
275,
13566,
1589,
890,
8,
1222,
9,
288,
892,
275,
23353,
14,
1716,
8,
13807,
14,
5652,
12,
334,
1222,
4258,
435,
2008,
8,
4399,
430,
267,
340,
1031,
14,
1708,
14,
466,
315,
334,
13807,
14,
8547,
12,
25308,
14,
3684,
12,
25308,
14,
15721,
63,
3684,
12,
1816,
25308,
14,
460,
63,
3684,
12,
25308,
14,
4723,
63,
3684,
12,
1816,
25308,
14,
18327,
63,
3684,
12,
25308,
14,
5125,
12,
1816,
25308,
14,
4778,
12,
25308,
14,
5652,
304,
288,
892,
275,
13566,
1589,
890,
8,
1222,
9,
267,
892,
14,
1861,
275,
2403,
267,
372,
892,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
endlessm/chromium-browser
|
third_party/catapult/telemetry/telemetry/internal/actions/scroll_unittest.py
|
1
|
11759
|
# Copyright 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry import decorators
from telemetry.internal.actions import page_action
from telemetry.internal.actions import scroll
from telemetry.internal.actions import utils
from telemetry.testing import tab_test_case
class ScrollActionTest(tab_test_case.TabTestCase):
def _MakePageVerticallyScrollable(self):
# Make page taller than window so it's scrollable vertically.
self._tab.ExecuteJavaScript(
'document.body.style.height ='
'(3 * __GestureCommon_GetWindowHeight() + 1) + "px";')
def _MakePageHorizontallyScrollable(self):
# Make page wider than window so it's scrollable horizontally.
self._tab.ExecuteJavaScript(
'document.body.style.width ='
'(3 * __GestureCommon_GetWindowWidth() + 1) + "px";')
def setUp(self):
tab_test_case.TabTestCase.setUp(self)
self.Navigate('blank.html')
utils.InjectJavaScript(self._tab, 'gesture_common.js')
def _RunScrollDistanceTest(self, distance, speed, source, maxError):
# TODO(bokan): Distance tests will fail on versions of Chrome that haven't
# been fixed. The fixes landed at the same time as the
# setBrowserControlsShown method was added so only run the test if that's
# available. Once that rolls into ref builds we can remove this check.
distanceFixedInChrome = self._tab.EvaluateJavaScript(
"'setBrowserControlsShown' in chrome.gpuBenchmarking")
if not distanceFixedInChrome:
return
# Hide the URL bar so we can measure scrolled distance without worrying
# about the URL bar consuming delta.
self._tab.ExecuteJavaScript(
'chrome.gpuBenchmarking.setBrowserControlsShown(false);')
# Make the document tall enough to accomodate the requested distance but
# also leave enough space so we can tell if the scroll overshoots the
# target.
screenHeight = self._tab.EvaluateJavaScript('window.visualViewport.height')
documentHeight = (screenHeight + distance) * 2
self._tab.ExecuteJavaScript(
'document.body.style.height = "' + str(documentHeight) + 'px";')
self.assertEquals(
self._tab.EvaluateJavaScript('document.scrollingElement.scrollTop'), 0)
# Allow for some visual viewport offset. For example, if the test doesn't
# want any visual viewport offset due to animation handoff error between
# the two viewports.
start_offset = self._tab.EvaluateJavaScript('window.visualViewport.pageTop')
i = scroll.ScrollAction(
distance=distance,
direction="down",
speed_in_pixels_per_second=speed,
synthetic_gesture_source=source)
i.WillRunAction(self._tab)
i.RunAction(self._tab)
actual = self._tab.EvaluateJavaScript(
'window.visualViewport.pageTop') - start_offset
# TODO(bokan): setBrowserControlsShown isn't quite enough. Chrome will hide
# the browser controls but then they animate in after a timeout. We'll need
# to add a way to lock them to hidden. Until then, just increase the
# allowed error.
urlBarError = 150
self.assertAlmostEqual(distance, actual, delta=maxError + urlBarError)
@decorators.Disabled('chromeos', 'linux') # crbug.com/1006789
def testScrollDistanceFastTouch(self):
# Just pass the test on platforms that don't support touch (i.e. Mac)
if not page_action.IsGestureSourceTypeSupported(self._tab, 'touch'):
return
# Scrolling distance for touch will have some error from the excess delta
# of the event that crosses the slop threshold but isn't applied, also
# scroll resampling can increase the error amount..
self._RunScrollDistanceTest(
500000, 200000, page_action.GESTURE_SOURCE_TOUCH, 200)
@decorators.Disabled('android') # crbug.com/934649
def testScrollDistanceFastWheel(self):
# Wheel scrolling will have a much greater error than touch. There's 2
# reasons: 1) synthetic wheel gesture accumulate the sent deltas and use
# that to determine how much delta to send at each event dispatch time.
# This assumes that the entire sent delta is applied which is wrong due to
# physical pixel snapping which accumulates over the gesture.
# 2) We can only send delta as ticks of the wheel. If the total delta is
# not a multiple of the tick size, we'll "lose" the remainder.
self._RunScrollDistanceTest(
500000, 200000, page_action.GESTURE_SOURCE_MOUSE, 15000)
def testScrollDistanceSlowTouch(self):
# Just pass the test on platforms that don't support touch (i.e. Mac)
if not page_action.IsGestureSourceTypeSupported(self._tab, 'touch'):
return
# Scrolling slowly produces larger error since each event will have a
# smaller delta. Thus error from snapping in each event will be a larger
# share of the total delta.
self._RunScrollDistanceTest(
1000, 300, page_action.GESTURE_SOURCE_TOUCH, 10)
@decorators.Disabled('android') # crbug.com/934649
def testScrollDistanceSlowWheel(self):
self._RunScrollDistanceTest(
1000, 300, page_action.GESTURE_SOURCE_MOUSE, 200)
@decorators.Disabled('android', 'mac') # crbug.com/934649
@decorators.Disabled('chromeos', 'linux') # crbug.com/805523
@decorators.Disabled('win-reference') # crbug.com/805523
def testWheelScrollDistanceWhileZoomed(self):
# TODO(bokan): This API was added recently so only run the test once it's
# available. Remove this check once it rolls into stable builds.
chromeSupportsSetPageScaleFactor = self._tab.EvaluateJavaScript(
"'setPageScaleFactor' in chrome.gpuBenchmarking")
if not chromeSupportsSetPageScaleFactor:
return
self._tab.EvaluateJavaScript('chrome.gpuBenchmarking.setPageScaleFactor(2)')
# Wheel scrolling can cause animated scrolls. This is a problem here since
# Chrome currently doesn't hand off the animation between the visual and
# layout viewports. To account for this, scroll the visual viewport to it's
# maximum extent so that the entire scroll goes to the layout viewport.
screenHeight = self._tab.EvaluateJavaScript('window.visualViewport.height')
i = scroll.ScrollAction(
distance=screenHeight*2,
direction="down",
speed_in_pixels_per_second=5000,
synthetic_gesture_source=page_action.GESTURE_SOURCE_MOUSE)
i.WillRunAction(self._tab)
i.RunAction(self._tab)
# Ensure the layout viewport isn't scrolled but the visual is.
self.assertGreater(
self._tab.EvaluateJavaScript('window.visualViewport.offsetTop'),
screenHeight / 2 - 1)
self.assertEqual(self._tab.EvaluateJavaScript('window.scrollY'), 0)
self._RunScrollDistanceTest(
2000, 2000, page_action.GESTURE_SOURCE_MOUSE, 60)
def testTouchScrollDistanceWhileZoomed(self):
# Just pass the test on platforms that don't support touch (i.e. Mac)
if not page_action.IsGestureSourceTypeSupported(self._tab, 'touch'):
return
# TODO(bokan): This API was added recently so only run the test once it's
# available. Remove this check once it rolls into stable builds.
chromeSupportsSetPageScaleFactor = self._tab.EvaluateJavaScript(
"'setPageScaleFactor' in chrome.gpuBenchmarking")
if not chromeSupportsSetPageScaleFactor:
return
self._tab.EvaluateJavaScript('chrome.gpuBenchmarking.setPageScaleFactor(2)')
self._RunScrollDistanceTest(
2000, 2000, page_action.GESTURE_SOURCE_TOUCH, 20)
def testScrollAction(self):
self._MakePageVerticallyScrollable()
self.assertEquals(
self._tab.EvaluateJavaScript('document.scrollingElement.scrollTop'), 0)
i = scroll.ScrollAction()
i.WillRunAction(self._tab)
self._tab.ExecuteJavaScript("""
window.__scrollAction.beginMeasuringHook = function() {
window.__didBeginMeasuring = true;
};
window.__scrollAction.endMeasuringHook = function() {
window.__didEndMeasuring = true;
};""")
i.RunAction(self._tab)
self.assertTrue(self._tab.EvaluateJavaScript('window.__didBeginMeasuring'))
self.assertTrue(self._tab.EvaluateJavaScript('window.__didEndMeasuring'))
scroll_position = self._tab.EvaluateJavaScript(
'document.scrollingElement.scrollTop')
self.assertTrue(
scroll_position != 0, msg='scroll_position=%d;' % (scroll_position))
# https://github.com/catapult-project/catapult/issues/3099
@decorators.Disabled('android')
@decorators.Disabled('chromeos') # crbug.com/984016
def testDiagonalScrollAction(self):
self._MakePageVerticallyScrollable()
self.assertEquals(
self._tab.EvaluateJavaScript('document.scrollingElement.scrollTop'), 0)
self._MakePageHorizontallyScrollable()
self.assertEquals(
self._tab.EvaluateJavaScript('document.scrollingElement.scrollLeft'), 0)
i = scroll.ScrollAction(direction='downright')
i.WillRunAction(self._tab)
i.RunAction(self._tab)
viewport_top = self._tab.EvaluateJavaScript(
'document.scrollingElement.scrollTop')
self.assertTrue(viewport_top != 0, msg='viewport_top=%d;' % viewport_top)
viewport_left = self._tab.EvaluateJavaScript(
'document.scrollingElement.scrollLeft')
self.assertTrue(viewport_left != 0, msg='viewport_left=%d;' % viewport_left)
def testBoundingClientRect(self):
# Verify that the rect returned by getBoundingVisibleRect() in scroll.js is
# completely contained within the viewport. Scroll events dispatched by the
# scrolling API use the center of this rect as their location, and this
# location needs to be within the viewport bounds to correctly decide
# between main-thread and impl-thread scroll. If the scrollable area were
# not clipped to the viewport bounds, then the instance used here (the
# scrollable area being more than twice as tall as the viewport) would
# result in a scroll location outside of the viewport bounds.
self._MakePageVerticallyScrollable()
self.assertEquals(
self._tab.EvaluateJavaScript('document.scrollingElement.scrollTop'), 0)
self._MakePageHorizontallyScrollable()
self.assertEquals(
self._tab.EvaluateJavaScript('document.scrollingElement.scrollLeft'), 0)
self._tab.ExecuteJavaScript("""
window.scrollTo(__GestureCommon_GetWindowWidth(),
__GestureCommon_GetWindowHeight());""")
rect_top = int(
self._tab.EvaluateJavaScript(
'__GestureCommon_GetBoundingVisibleRect(document.body).top'))
rect_height = int(
self._tab.EvaluateJavaScript(
'__GestureCommon_GetBoundingVisibleRect(document.body).height'))
rect_bottom = rect_top + rect_height
rect_left = int(
self._tab.EvaluateJavaScript(
'__GestureCommon_GetBoundingVisibleRect(document.body).left'))
rect_width = int(
self._tab.EvaluateJavaScript(
'__GestureCommon_GetBoundingVisibleRect(document.body).width'))
rect_right = rect_left + rect_width
viewport_height = int(
self._tab.EvaluateJavaScript('__GestureCommon_GetWindowHeight()'))
viewport_width = int(
self._tab.EvaluateJavaScript('__GestureCommon_GetWindowWidth()'))
self.assertTrue(rect_top >= 0, msg='%s >= %s' % (rect_top, 0))
self.assertTrue(rect_left >= 0, msg='%s >= %s' % (rect_left, 0))
self.assertTrue(
rect_bottom <= viewport_height,
msg='%s + %s <= %s' % (rect_top, rect_height, viewport_height))
self.assertTrue(
rect_right <= viewport_width,
msg='%s + %s <= %s' % (rect_left, rect_width, viewport_width))
|
bsd-3-clause
|
[
3,
1898,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
504,
17298,
492,
20419,
199,
504,
17298,
14,
4672,
14,
3723,
492,
2034,
63,
1287,
199,
504,
17298,
14,
4672,
14,
3723,
492,
13704,
199,
504,
17298,
14,
4672,
14,
3723,
492,
3778,
199,
504,
17298,
14,
4776,
492,
5174,
63,
396,
63,
2546,
421,
199,
533,
13916,
2827,
3310,
774,
8,
2902,
63,
396,
63,
2546,
14,
7690,
1746,
304,
819,
347,
485,
5483,
3276,
3673,
17269,
13127,
461,
8,
277,
304,
272,
327,
4155,
2034,
307,
9230,
2419,
4353,
880,
652,
1159,
13704,
461,
809,
17269,
14,
272,
291,
423,
2902,
14,
12049,
21986,
8,
267,
283,
3554,
14,
2030,
14,
2487,
14,
3333,
275,
7,
267,
8189,
19,
627,
636,
39,
597,
608,
7844,
63,
1002,
4301,
8436,
342,
435,
413,
9,
435,
298,
5326,
2,
10784,
819,
347,
485,
5483,
3276,
40,
7366,
1183,
13127,
461,
8,
277,
304,
272,
327,
4155,
2034,
26038,
424,
2419,
4353,
880,
652,
1159,
13704,
461,
394,
7366,
1183,
14,
272,
291,
423,
2902,
14,
12049,
21986,
8,
267,
283,
3554,
14,
2030,
14,
2487,
14,
2063,
275,
7,
267,
8189,
19,
627,
636,
39,
597,
608,
7844,
63,
1002,
4301,
6216,
342,
435,
413,
9,
435,
298,
5326,
2,
10784,
819,
347,
3613,
8,
277,
304,
272,
5174,
63,
396,
63,
2546,
14,
7690,
1746,
14,
5996,
8,
277,
9,
272,
291,
14,
31914,
360,
2500,
14,
1360,
358,
272,
3778,
14,
607,
963,
21986,
8,
277,
423,
2902,
12,
283,
3199,
608,
63,
2330,
14,
3596,
358,
819,
347,
485,
2540,
13127,
10076,
774,
8,
277,
12,
6033,
12,
8112,
12,
1350,
12,
1390,
547,
304,
272,
327,
3254,
8,
656,
29305,
304,
21892,
2295,
911,
2449,
641,
5459,
402,
16776,
626,
19051,
1133,
272,
327,
2757,
6317,
14,
221,
710,
25079,
634,
7028,
737,
314,
2011,
900,
465,
314,
272,
327,
663,
11930,
25457,
6824,
78,
1083,
1990,
3483,
880,
1454,
1255,
314,
511,
340,
626,
1159,
272,
327,
2808,
14,
19468,
626,
20182,
478,
1901,
2984,
14723,
781,
883,
2813,
642,
1104,
14,
272,
6033,
9515,
607,
18083,
275,
291,
423,
2902,
14,
25002,
21986,
8,
267,
3546,
409,
11930,
25457,
6824,
78,
7,
315,
18221,
14,
6477,
18644,
316,
531,
272,
340,
440,
6033,
9515,
607,
18083,
26,
489,
372,
339,
327,
869,
2655,
314,
2851,
4681,
880,
781,
883,
9775,
4061,
10504,
6033,
1928,
30944,
316,
272,
327,
3595,
314,
2851,
4681,
406,
26745,
5762,
14,
272,
291,
423,
2902,
14,
12049,
21986,
8,
267,
283,
9887,
14,
6477,
18644,
316,
14,
409,
11930,
25457,
6824,
78,
8,
3910,
2736,
358,
339,
327,
4155,
314,
2213,
307,
452,
8321,
370,
1066,
957,
364,
323,
314,
5839,
6033,
1325,
272,
327,
2597,
10137,
8321,
4601,
880,
781,
883,
11480,
340,
314,
13704,
1806,
13927,
16673,
314,
272,
327,
1347,
14,
272,
6426,
8436,
275,
291,
423,
2902,
14,
25002,
21986,
360,
3806,
14,
16948,
2768,
719,
14,
3333,
358,
272,
2213,
8436,
275,
334,
5410,
8436,
435,
6033,
9,
627,
499,
339,
291,
423,
2902,
14,
12049,
21986,
8,
267,
283,
3554,
14,
2030,
14,
2487,
14,
3333,
275,
3546,
435,
620,
8,
3554,
8436,
9,
435,
283,
5326,
2,
10784,
272,
291,
14,
2947,
8,
267,
291,
423,
2902,
14,
25002,
21986,
360,
3554,
14,
6755,
316,
2162,
14,
6755,
6105,
659,
378,
9,
339,
327,
9812,
367,
2005,
13104,
2455,
719,
3268,
14,
2104,
2893,
12,
340,
314,
511,
3181,
1133,
272,
327,
2934,
1263,
13104,
2455,
719,
3268,
7037,
370,
24154,
4926,
1997,
1125,
3382,
272,
327,
314,
2877,
2455,
5203,
14,
272,
1343,
63,
2743,
275,
291,
423,
2902,
14,
25002,
21986,
360,
3806,
14,
16948,
2768,
719,
14,
1606,
6105,
358,
339,
284,
275,
13704,
14,
13127,
3310,
8,
267,
6033,
29,
5590,
12,
267,
7581,
628,
2110,
401,
267,
8112,
63,
262,
63,
15727,
63,
529,
63,
4375,
29,
7625,
12,
267,
9560,
21231,
63,
3199,
608,
63,
1365,
29,
1365,
9,
272,
284,
14,
20326,
2540,
3310,
8,
277,
423,
2902,
9,
272,
284,
14,
2540,
3310,
8,
277,
423,
2902,
9,
339,
3503,
275,
291,
423,
2902,
14,
25002,
21986,
8,
267,
283,
3806,
14,
16948,
2768,
719,
14,
1606,
6105,
358,
446,
1343,
63,
2743,
339,
327,
3254,
8,
656,
29305,
304,
663,
11930,
25457,
6824,
78,
5712,
1133,
18794,
8321,
14,
16776,
911,
13714,
272,
327,
314,
7042,
13467,
1325,
2066,
2985,
376,
6897,
315,
2410,
282,
2653,
14,
2136,
7171,
1929,
272,
327,
370,
1050,
282,
4340,
370,
4650,
3062,
370,
8752,
14,
1910,
2270,
2066,
12,
2951,
19781,
314,
272,
327,
4370,
1125,
14,
272,
1166,
5281,
547,
275,
14711,
339,
291,
14,
7904,
8,
5590,
12,
3503,
12,
5762,
29,
988,
547,
435,
1166,
5281,
547,
9,
819,
768,
11582,
14,
15049,
360,
9887,
736,
297,
283,
5135,
358,
221,
327,
2467,
1266,
14,
957,
15,
1960,
1822,
1407,
523,
347,
511,
13127,
10076,
16976,
52,
13087,
8,
277,
304,
272,
327,
13870,
986,
314,
511,
641,
10677,
626,
2793,
1133,
2291,
12943,
334,
73,
14,
69,
14,
10444,
9,
272,
340,
440,
2034,
63,
1287,
14,
1831,
39,
597,
608,
2980,
804,
10682,
8,
277,
423,
2902,
12,
283,
12376,
735,
489,
372,
339,
327,
13916,
31562,
6033,
367,
12943,
911,
1172,
2005,
1125,
687,
314,
444,
670,
5762,
272,
327,
402,
314,
1566,
626,
25532,
874,
314,
308,
18630,
8765,
1325,
5712,
1133,
6781,
12,
2597,
272,
327,
13704,
522,
23144,
883,
19781,
314,
1125,
5982,
703,
272,
291,
423,
2540,
13127,
10076,
774,
8,
267,
959,
5345,
12,
499,
5345,
12,
2034,
63,
1287,
14,
39,
1719,
3942,
63,
10187,
63,
2566,
53,
1244,
12,
1926,
9,
819,
768,
11582,
14,
15049,
360,
6238,
358,
221,
327,
2467,
1266,
14,
957,
15,
30391,
11228,
523,
347,
511,
13127,
10076,
16976,
25663,
8,
277,
304,
272,
327,
26161,
13704,
316,
911,
1172,
282,
8298,
8932,
1125,
2419,
12943,
14,
6006,
1159,
499,
272,
327,
14872
] |
[
1898,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
504,
17298,
492,
20419,
199,
504,
17298,
14,
4672,
14,
3723,
492,
2034,
63,
1287,
199,
504,
17298,
14,
4672,
14,
3723,
492,
13704,
199,
504,
17298,
14,
4672,
14,
3723,
492,
3778,
199,
504,
17298,
14,
4776,
492,
5174,
63,
396,
63,
2546,
421,
199,
533,
13916,
2827,
3310,
774,
8,
2902,
63,
396,
63,
2546,
14,
7690,
1746,
304,
819,
347,
485,
5483,
3276,
3673,
17269,
13127,
461,
8,
277,
304,
272,
327,
4155,
2034,
307,
9230,
2419,
4353,
880,
652,
1159,
13704,
461,
809,
17269,
14,
272,
291,
423,
2902,
14,
12049,
21986,
8,
267,
283,
3554,
14,
2030,
14,
2487,
14,
3333,
275,
7,
267,
8189,
19,
627,
636,
39,
597,
608,
7844,
63,
1002,
4301,
8436,
342,
435,
413,
9,
435,
298,
5326,
2,
10784,
819,
347,
485,
5483,
3276,
40,
7366,
1183,
13127,
461,
8,
277,
304,
272,
327,
4155,
2034,
26038,
424,
2419,
4353,
880,
652,
1159,
13704,
461,
394,
7366,
1183,
14,
272,
291,
423,
2902,
14,
12049,
21986,
8,
267,
283,
3554,
14,
2030,
14,
2487,
14,
2063,
275,
7,
267,
8189,
19,
627,
636,
39,
597,
608,
7844,
63,
1002,
4301,
6216,
342,
435,
413,
9,
435,
298,
5326,
2,
10784,
819,
347,
3613,
8,
277,
304,
272,
5174,
63,
396,
63,
2546,
14,
7690,
1746,
14,
5996,
8,
277,
9,
272,
291,
14,
31914,
360,
2500,
14,
1360,
358,
272,
3778,
14,
607,
963,
21986,
8,
277,
423,
2902,
12,
283,
3199,
608,
63,
2330,
14,
3596,
358,
819,
347,
485,
2540,
13127,
10076,
774,
8,
277,
12,
6033,
12,
8112,
12,
1350,
12,
1390,
547,
304,
272,
327,
3254,
8,
656,
29305,
304,
21892,
2295,
911,
2449,
641,
5459,
402,
16776,
626,
19051,
1133,
272,
327,
2757,
6317,
14,
221,
710,
25079,
634,
7028,
737,
314,
2011,
900,
465,
314,
272,
327,
663,
11930,
25457,
6824,
78,
1083,
1990,
3483,
880,
1454,
1255,
314,
511,
340,
626,
1159,
272,
327,
2808,
14,
19468,
626,
20182,
478,
1901,
2984,
14723,
781,
883,
2813,
642,
1104,
14,
272,
6033,
9515,
607,
18083,
275,
291,
423,
2902,
14,
25002,
21986,
8,
267,
3546,
409,
11930,
25457,
6824,
78,
7,
315,
18221,
14,
6477,
18644,
316,
531,
272,
340,
440,
6033,
9515,
607,
18083,
26,
489,
372,
339,
327,
869,
2655,
314,
2851,
4681,
880,
781,
883,
9775,
4061,
10504,
6033,
1928,
30944,
316,
272,
327,
3595,
314,
2851,
4681,
406,
26745,
5762,
14,
272,
291,
423,
2902,
14,
12049,
21986,
8,
267,
283,
9887,
14,
6477,
18644,
316,
14,
409,
11930,
25457,
6824,
78,
8,
3910,
2736,
358,
339,
327,
4155,
314,
2213,
307,
452,
8321,
370,
1066,
957,
364,
323,
314,
5839,
6033,
1325,
272,
327,
2597,
10137,
8321,
4601,
880,
781,
883,
11480,
340,
314,
13704,
1806,
13927,
16673,
314,
272,
327,
1347,
14,
272,
6426,
8436,
275,
291,
423,
2902,
14,
25002,
21986,
360,
3806,
14,
16948,
2768,
719,
14,
3333,
358,
272,
2213,
8436,
275,
334,
5410,
8436,
435,
6033,
9,
627,
499,
339,
291,
423,
2902,
14,
12049,
21986,
8,
267,
283,
3554,
14,
2030,
14,
2487,
14,
3333,
275,
3546,
435,
620,
8,
3554,
8436,
9,
435,
283,
5326,
2,
10784,
272,
291,
14,
2947,
8,
267,
291,
423,
2902,
14,
25002,
21986,
360,
3554,
14,
6755,
316,
2162,
14,
6755,
6105,
659,
378,
9,
339,
327,
9812,
367,
2005,
13104,
2455,
719,
3268,
14,
2104,
2893,
12,
340,
314,
511,
3181,
1133,
272,
327,
2934,
1263,
13104,
2455,
719,
3268,
7037,
370,
24154,
4926,
1997,
1125,
3382,
272,
327,
314,
2877,
2455,
5203,
14,
272,
1343,
63,
2743,
275,
291,
423,
2902,
14,
25002,
21986,
360,
3806,
14,
16948,
2768,
719,
14,
1606,
6105,
358,
339,
284,
275,
13704,
14,
13127,
3310,
8,
267,
6033,
29,
5590,
12,
267,
7581,
628,
2110,
401,
267,
8112,
63,
262,
63,
15727,
63,
529,
63,
4375,
29,
7625,
12,
267,
9560,
21231,
63,
3199,
608,
63,
1365,
29,
1365,
9,
272,
284,
14,
20326,
2540,
3310,
8,
277,
423,
2902,
9,
272,
284,
14,
2540,
3310,
8,
277,
423,
2902,
9,
339,
3503,
275,
291,
423,
2902,
14,
25002,
21986,
8,
267,
283,
3806,
14,
16948,
2768,
719,
14,
1606,
6105,
358,
446,
1343,
63,
2743,
339,
327,
3254,
8,
656,
29305,
304,
663,
11930,
25457,
6824,
78,
5712,
1133,
18794,
8321,
14,
16776,
911,
13714,
272,
327,
314,
7042,
13467,
1325,
2066,
2985,
376,
6897,
315,
2410,
282,
2653,
14,
2136,
7171,
1929,
272,
327,
370,
1050,
282,
4340,
370,
4650,
3062,
370,
8752,
14,
1910,
2270,
2066,
12,
2951,
19781,
314,
272,
327,
4370,
1125,
14,
272,
1166,
5281,
547,
275,
14711,
339,
291,
14,
7904,
8,
5590,
12,
3503,
12,
5762,
29,
988,
547,
435,
1166,
5281,
547,
9,
819,
768,
11582,
14,
15049,
360,
9887,
736,
297,
283,
5135,
358,
221,
327,
2467,
1266,
14,
957,
15,
1960,
1822,
1407,
523,
347,
511,
13127,
10076,
16976,
52,
13087,
8,
277,
304,
272,
327,
13870,
986,
314,
511,
641,
10677,
626,
2793,
1133,
2291,
12943,
334,
73,
14,
69,
14,
10444,
9,
272,
340,
440,
2034,
63,
1287,
14,
1831,
39,
597,
608,
2980,
804,
10682,
8,
277,
423,
2902,
12,
283,
12376,
735,
489,
372,
339,
327,
13916,
31562,
6033,
367,
12943,
911,
1172,
2005,
1125,
687,
314,
444,
670,
5762,
272,
327,
402,
314,
1566,
626,
25532,
874,
314,
308,
18630,
8765,
1325,
5712,
1133,
6781,
12,
2597,
272,
327,
13704,
522,
23144,
883,
19781,
314,
1125,
5982,
703,
272,
291,
423,
2540,
13127,
10076,
774,
8,
267,
959,
5345,
12,
499,
5345,
12,
2034,
63,
1287,
14,
39,
1719,
3942,
63,
10187,
63,
2566,
53,
1244,
12,
1926,
9,
819,
768,
11582,
14,
15049,
360,
6238,
358,
221,
327,
2467,
1266,
14,
957,
15,
30391,
11228,
523,
347,
511,
13127,
10076,
16976,
25663,
8,
277,
304,
272,
327,
26161,
13704,
316,
911,
1172,
282,
8298,
8932,
1125,
2419,
12943,
14,
6006,
1159,
499,
272,
327,
14872,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
googleapis/googleapis-gen
|
google/ads/googleads/v8/googleads-py/google/ads/googleads/v8/services/services/payments_account_service/client.py
|
1
|
18740
|
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# 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 collections import OrderedDict
from distutils import util
import os
import re
from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
import pkg_resources
from google.api_core import client_options as client_options_lib # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport import mtls # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore
from google.ads.googleads.v8.resources.types import payments_account
from google.ads.googleads.v8.services.types import payments_account_service
from .transports.base import PaymentsAccountServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import PaymentsAccountServiceGrpcTransport
class PaymentsAccountServiceClientMeta(type):
"""Metaclass for the PaymentsAccountService client.
This provides class-level methods for building and retrieving
support objects (e.g. transport) without polluting the client instance
objects.
"""
_transport_registry = OrderedDict() # type: Dict[str, Type[PaymentsAccountServiceTransport]]
_transport_registry['grpc'] = PaymentsAccountServiceGrpcTransport
def get_transport_class(cls,
label: str = None,
) -> Type[PaymentsAccountServiceTransport]:
"""Return an appropriate transport class.
Args:
label: The name of the desired transport. If none is
provided, then the first transport in the registry is used.
Returns:
The transport class to use.
"""
# If a specific transport is requested, return that one.
if label:
return cls._transport_registry[label]
# No transport is requested; return the default (that is, the first one
# in the dictionary).
return next(iter(cls._transport_registry.values()))
class PaymentsAccountServiceClient(metaclass=PaymentsAccountServiceClientMeta):
"""Service to provide payments accounts that can be used to set
up consolidated billing.
"""
@staticmethod
def _get_default_mtls_endpoint(api_endpoint):
"""Convert api endpoint to mTLS endpoint.
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
api_endpoint (Optional[str]): the api endpoint to convert.
Returns:
str: converted mTLS api endpoint.
"""
if not api_endpoint:
return api_endpoint
mtls_endpoint_re = re.compile(
r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
)
m = mtls_endpoint_re.match(api_endpoint)
name, mtls, sandbox, googledomain = m.groups()
if mtls or not googledomain:
return api_endpoint
if sandbox:
return api_endpoint.replace(
"sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
)
return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
DEFAULT_ENDPOINT = 'googleads.googleapis.com'
DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
DEFAULT_ENDPOINT
)
@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
"""Creates an instance of this client using the provided credentials info.
Args:
info (dict): The service account private key info.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.
Returns:
PaymentsAccountServiceClient: The constructed client.
"""
credentials = service_account.Credentials.from_service_account_info(info)
kwargs["credentials"] = credentials
return cls(*args, **kwargs)
@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.
Returns:
PaymentsAccountServiceClient: The constructed client.
"""
credentials = service_account.Credentials.from_service_account_file(
filename)
kwargs['credentials'] = credentials
return cls(*args, **kwargs)
from_service_account_json = from_service_account_file
@property
def transport(self) -> PaymentsAccountServiceTransport:
"""Return the transport used by the client instance.
Returns:
PaymentsAccountServiceTransport: The transport used by the client instance.
"""
return self._transport
@staticmethod
def customer_path(customer_id: str,) -> str:
"""Return a fully-qualified customer string."""
return "customers/{customer_id}".format(customer_id=customer_id, )
@staticmethod
def parse_customer_path(path: str) -> Dict[str,str]:
"""Parse a customer path into its component segments."""
m = re.match(r"^customers/(?P<customer_id>.+?)$", path)
return m.groupdict() if m else {}
@staticmethod
def payments_account_path(customer_id: str,payments_account_id: str,) -> str:
"""Return a fully-qualified payments_account string."""
return "customers/{customer_id}/paymentsAccounts/{payments_account_id}".format(customer_id=customer_id, payments_account_id=payments_account_id, )
@staticmethod
def parse_payments_account_path(path: str) -> Dict[str,str]:
"""Parse a payments_account path into its component segments."""
m = re.match(r"^customers/(?P<customer_id>.+?)/paymentsAccounts/(?P<payments_account_id>.+?)$", path)
return m.groupdict() if m else {}
@staticmethod
def common_billing_account_path(billing_account: str, ) -> str:
"""Return a fully-qualified billing_account string."""
return "billingAccounts/{billing_account}".format(billing_account=billing_account, )
@staticmethod
def parse_common_billing_account_path(path: str) -> Dict[str,str]:
"""Parse a billing_account path into its component segments."""
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
return m.groupdict() if m else {}
@staticmethod
def common_folder_path(folder: str, ) -> str:
"""Return a fully-qualified folder string."""
return "folders/{folder}".format(folder=folder, )
@staticmethod
def parse_common_folder_path(path: str) -> Dict[str,str]:
"""Parse a folder path into its component segments."""
m = re.match(r"^folders/(?P<folder>.+?)$", path)
return m.groupdict() if m else {}
@staticmethod
def common_organization_path(organization: str, ) -> str:
"""Return a fully-qualified organization string."""
return "organizations/{organization}".format(organization=organization, )
@staticmethod
def parse_common_organization_path(path: str) -> Dict[str,str]:
"""Parse a organization path into its component segments."""
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
return m.groupdict() if m else {}
@staticmethod
def common_project_path(project: str, ) -> str:
"""Return a fully-qualified project string."""
return "projects/{project}".format(project=project, )
@staticmethod
def parse_common_project_path(path: str) -> Dict[str,str]:
"""Parse a project path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)$", path)
return m.groupdict() if m else {}
@staticmethod
def common_location_path(project: str, location: str, ) -> str:
"""Return a fully-qualified location string."""
return "projects/{project}/locations/{location}".format(project=project, location=location, )
@staticmethod
def parse_common_location_path(path: str) -> Dict[str,str]:
"""Parse a location path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
return m.groupdict() if m else {}
def __init__(self, *,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, PaymentsAccountServiceTransport, None] = None,
client_options: Optional[client_options_lib.ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiate the payments account service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
transport (Union[str, ~.PaymentsAccountServiceTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
client_options (google.api_core.client_options.ClientOptions): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
environment variable can also be used to override the endpoint:
"always" (always use the default mTLS endpoint), "never" (always
use the default regular endpoint) and "auto" (auto switch to the
default mTLS endpoint if client certificate is present, this is
the default value). However, the ``api_endpoint`` property takes
precedence if provided.
(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
is "true", then the ``client_cert_source`` property can be used
to provide client certificate for mutual TLS transport. If
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
The client info used to send a user-agent string along with
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
creation failed for any reason.
"""
if isinstance(client_options, dict):
client_options = client_options_lib.from_dict(client_options)
if client_options is None:
client_options = client_options_lib.ClientOptions()
# Create SSL credentials for mutual TLS if needed.
use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")))
ssl_credentials = None
is_mtls = False
if use_client_cert:
if client_options.client_cert_source:
import grpc # type: ignore
cert, key = client_options.client_cert_source()
ssl_credentials = grpc.ssl_channel_credentials(
certificate_chain=cert, private_key=key
)
is_mtls = True
else:
creds = SslCredentials()
is_mtls = creds.is_mtls
ssl_credentials = creds.ssl_credentials if is_mtls else None
# Figure out which api endpoint to use.
if client_options.api_endpoint is not None:
api_endpoint = client_options.api_endpoint
else:
use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
if use_mtls_env == "never":
api_endpoint = self.DEFAULT_ENDPOINT
elif use_mtls_env == "always":
api_endpoint = self.DEFAULT_MTLS_ENDPOINT
elif use_mtls_env == "auto":
api_endpoint = self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
else:
raise MutualTLSChannelError(
"Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
)
# Save or instantiate the transport.
# Ordinarily, we provide the transport, but allowing a custom transport
# instance provides an extensibility point for unusual situations.
if isinstance(transport, PaymentsAccountServiceTransport):
# transport is a PaymentsAccountServiceTransport instance.
if credentials:
raise ValueError('When providing a transport instance, '
'provide its credentials directly.')
self._transport = transport
elif isinstance(transport, str):
Transport = type(self).get_transport_class(transport)
self._transport = Transport(
credentials=credentials, host=self.DEFAULT_ENDPOINT
)
else:
self._transport = PaymentsAccountServiceGrpcTransport(
credentials=credentials,
host=api_endpoint,
ssl_channel_credentials=ssl_credentials,
client_info=client_info,
)
def list_payments_accounts(self,
request: payments_account_service.ListPaymentsAccountsRequest = None,
*,
customer_id: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> payments_account_service.ListPaymentsAccountsResponse:
r"""Returns all payments accounts associated with all managers
between the login customer ID and specified serving customer in
the hierarchy, inclusive.
List of thrown errors: `AuthenticationError <>`__
`AuthorizationError <>`__ `HeaderError <>`__
`InternalError <>`__ `PaymentsAccountError <>`__
`QuotaError <>`__ `RequestError <>`__
Args:
request (:class:`google.ads.googleads.v8.services.types.ListPaymentsAccountsRequest`):
The request object. Request message for fetching all
accessible payments accounts.
customer_id (:class:`str`):
Required. The ID of the customer to
apply the PaymentsAccount list operation
to.
This corresponds to the ``customer_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.ads.googleads.v8.services.types.ListPaymentsAccountsResponse:
Response message for
[PaymentsAccountService.ListPaymentsAccounts][google.ads.googleads.v8.services.PaymentsAccountService.ListPaymentsAccounts].
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([customer_id]):
raise ValueError('If the `request` argument is set, then none of '
'the individual field arguments should be set.')
# Minor optimization to avoid making a copy if the user passes
# in a payments_account_service.ListPaymentsAccountsRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, payments_account_service.ListPaymentsAccountsRequest):
request = payments_account_service.ListPaymentsAccountsRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if customer_id is not None:
request.customer_id = customer_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.list_payments_accounts]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((
('customer_id', request.customer_id),
)),
)
# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
__all__ = (
'PaymentsAccountServiceClient',
)
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
25455,
4475,
20376,
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,
199,
504,
5055,
492,
8773,
199,
504,
7065,
492,
4884,
199,
646,
747,
199,
646,
295,
199,
504,
14090,
492,
16975,
12,
7448,
12,
4879,
12,
10975,
12,
11634,
12,
2434,
12,
15961,
199,
646,
5496,
63,
4435,
199,
199,
504,
6233,
14,
1246,
63,
1018,
492,
1890,
63,
1419,
465,
1890,
63,
1419,
63,
773,
221,
327,
730,
26,
3686,
199,
504,
6233,
14,
1246,
63,
1018,
492,
4967,
465,
6170,
63,
3924,
260,
327,
730,
26,
3686,
199,
504,
6233,
14,
1246,
63,
1018,
492,
16301,
530,
63,
86,
17,
19242,
327,
730,
26,
3686,
199,
504,
6233,
14,
1246,
63,
1018,
492,
7269,
465,
10086,
10473,
327,
730,
26,
3686,
199,
504,
6233,
14,
1178,
492,
6235,
465,
16072,
63,
6942,
3777,
327,
730,
26,
3686,
199,
504,
6233,
14,
1178,
14,
5545,
492,
333,
9945,
14960,
327,
730,
26,
3686,
199,
504,
6233,
14,
1178,
14,
5545,
14,
15391,
492,
428,
2482,
13428,
3777,
327,
730,
26,
3686,
199,
504,
6233,
14,
1178,
14,
3924,
492,
26550,
1061,
10224,
5358,
547,
3515,
327,
730,
26,
3686,
199,
504,
6233,
14,
6126,
18,
492,
2435,
63,
2048,
12793,
327,
730,
26,
3686,
199,
199,
504,
6233,
14,
9402,
14,
29882,
14,
86,
24,
14,
4435,
14,
1313,
492,
8633,
1470,
63,
2048,
199,
504,
6233,
14,
9402,
14,
29882,
14,
86,
24,
14,
5950,
14,
1313,
492,
8633,
1470,
63,
2048,
63,
1364,
199,
504,
1275,
5545,
83,
14,
1095,
492,
15911,
1470,
6009,
3167,
7836,
12,
6186,
63,
9901,
63,
4531,
199,
504,
1275,
5545,
83,
14,
15391,
492,
15911,
1470,
6009,
3167,
39,
4354,
7836,
421,
199,
533,
15911,
1470,
6009,
3167,
3041,
3396,
8,
466,
304,
272,
408,
29387,
367,
314,
15911,
1470,
6009,
3167,
1890,
14,
339,
961,
6571,
1021,
13,
1896,
3102,
367,
10015,
436,
23812,
272,
2291,
2251,
334,
69,
14,
71,
14,
7773,
9,
1928,
11271,
4655,
314,
1890,
1256,
272,
2251,
14,
272,
408,
272,
485,
5545,
63,
5189,
275,
8773,
342,
221,
327,
730,
26,
7448,
59,
495,
12,
2434,
59,
10517,
1470,
6009,
3167,
7836,
2677,
272,
485,
5545,
63,
5189,
459,
15391,
418,
275,
15911,
1470,
6009,
3167,
39,
4354,
7836,
339,
347,
664,
63,
5545,
63,
533,
8,
1886,
12,
288,
1768,
26,
620,
275,
488,
12,
288,
776,
1035,
2434,
59,
10517,
1470,
6009,
3167,
7836,
2189,
267,
408,
1767,
376,
5827,
7773,
1021,
14,
398,
3033,
26,
288,
1768,
26,
710,
536,
402,
314,
6387,
7773,
14,
982,
7179,
365,
355,
2741,
12,
2066,
314,
1642,
7773,
315,
314,
7086,
365,
1202,
14,
398,
1803,
26,
288,
710,
7773,
1021,
370,
675,
14,
267,
408,
267,
327,
982,
282,
2488,
7773,
365,
5839,
12,
372,
626,
1373,
14,
267,
340,
1768,
26,
288,
372,
843,
423,
5545,
63,
5189,
59,
1302,
61,
398,
327,
3091,
7773,
365,
5839,
27,
372,
314,
849,
334,
9099,
365,
12,
314,
1642,
1373,
267,
327,
315,
314,
2600,
680,
267,
372,
2163,
8,
1661,
8,
1886,
423,
5545,
63,
5189,
14,
1459,
4059,
421,
199,
533,
15911,
1470,
6009,
3167,
3041,
8,
6577,
29,
10517,
1470,
6009,
3167,
3041,
3396,
304,
272,
408,
3167,
370,
5647,
8633,
1470,
12639,
626,
883,
506,
1202,
370,
663,
272,
1536,
406,
28335,
19074,
32663,
14,
272,
408,
339,
768,
4639,
272,
347,
485,
362,
63,
885,
63,
2037,
478,
63,
6520,
8,
1246,
63,
6520,
304,
267,
408,
7306,
2986,
6037,
370,
333,
10224,
6037,
14,
267,
7905,
298,
4856,
16647,
14,
17533,
14,
957,
2,
436,
298,
4856,
17533,
14,
957,
2,
370,
267,
298,
4856,
2037,
478,
14,
16647,
14,
17533,
14,
957,
2,
436,
298,
4856,
2037,
478,
14,
17533,
14,
957,
2,
17342,
14,
267,
3033,
26,
288,
2986,
63,
6520,
334,
7012,
59,
495,
4682,
314,
2986,
6037,
370,
3957,
14,
267,
1803,
26,
288,
620,
26,
6702,
333,
10224,
2986,
6037,
14,
267,
408,
267,
340,
440,
2986,
63,
6520,
26,
288,
372,
2986,
63,
6520,
398,
333,
9945,
63,
6520,
63,
264,
275,
295,
14,
2014,
8,
288,
519,
24726,
48,
28,
354,
13489,
14,
11896,
2229,
48,
28,
2037,
478,
3072,
14,
2037,
478,
5547,
2229,
48,
28,
16647,
3072,
14,
16647,
5547,
2229,
48,
28,
3098,
2261,
3072,
14,
17533,
4537,
957,
5547,
2,
267,
776,
398,
333,
275,
333,
9945,
63,
6520,
63,
264,
14,
1431,
8,
1246,
63,
6520,
9,
267,
536,
12,
333,
9945,
12,
19699,
12,
6233,
2261,
275,
333,
14,
2634,
342,
267,
340,
333,
9945,
503,
440,
6233,
2261,
26,
288,
372,
2986,
63,
6520,
398,
340,
19699,
26,
288,
372,
2986,
63,
6520,
14,
1814,
8,
355,
298,
16647,
14,
17533,
14,
957,
401,
298,
2037,
478,
14,
16647,
14,
17533,
14,
957,
2,
288,
776,
398,
372,
2986,
63,
6520,
14,
1814,
9520,
17533,
14,
957,
401,
3680,
2037,
478,
14,
17533,
14,
957,
531,
339,
6186,
63,
21054,
275,
283,
29882,
14,
17533,
14,
957,
7,
272,
6186,
63,
5747,
5296,
63,
21054,
275,
485,
362,
63,
885,
63,
2037,
478,
63,
6520,
855,
1532,
721,
221,
327,
730,
26,
3686,
267,
6186,
63,
21054,
272,
776,
339,
768,
3744,
272,
347,
687,
63,
1364,
63,
2048,
63,
815,
8,
1886,
12,
2256,
26,
1211,
12,
627,
589,
12
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
25455,
4475,
20376,
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,
199,
504,
5055,
492,
8773,
199,
504,
7065,
492,
4884,
199,
646,
747,
199,
646,
295,
199,
504,
14090,
492,
16975,
12,
7448,
12,
4879,
12,
10975,
12,
11634,
12,
2434,
12,
15961,
199,
646,
5496,
63,
4435,
199,
199,
504,
6233,
14,
1246,
63,
1018,
492,
1890,
63,
1419,
465,
1890,
63,
1419,
63,
773,
221,
327,
730,
26,
3686,
199,
504,
6233,
14,
1246,
63,
1018,
492,
4967,
465,
6170,
63,
3924,
260,
327,
730,
26,
3686,
199,
504,
6233,
14,
1246,
63,
1018,
492,
16301,
530,
63,
86,
17,
19242,
327,
730,
26,
3686,
199,
504,
6233,
14,
1246,
63,
1018,
492,
7269,
465,
10086,
10473,
327,
730,
26,
3686,
199,
504,
6233,
14,
1178,
492,
6235,
465,
16072,
63,
6942,
3777,
327,
730,
26,
3686,
199,
504,
6233,
14,
1178,
14,
5545,
492,
333,
9945,
14960,
327,
730,
26,
3686,
199,
504,
6233,
14,
1178,
14,
5545,
14,
15391,
492,
428,
2482,
13428,
3777,
327,
730,
26,
3686,
199,
504,
6233,
14,
1178,
14,
3924,
492,
26550,
1061,
10224,
5358,
547,
3515,
327,
730,
26,
3686,
199,
504,
6233,
14,
6126,
18,
492,
2435,
63,
2048,
12793,
327,
730,
26,
3686,
199,
199,
504,
6233,
14,
9402,
14,
29882,
14,
86,
24,
14,
4435,
14,
1313,
492,
8633,
1470,
63,
2048,
199,
504,
6233,
14,
9402,
14,
29882,
14,
86,
24,
14,
5950,
14,
1313,
492,
8633,
1470,
63,
2048,
63,
1364,
199,
504,
1275,
5545,
83,
14,
1095,
492,
15911,
1470,
6009,
3167,
7836,
12,
6186,
63,
9901,
63,
4531,
199,
504,
1275,
5545,
83,
14,
15391,
492,
15911,
1470,
6009,
3167,
39,
4354,
7836,
421,
199,
533,
15911,
1470,
6009,
3167,
3041,
3396,
8,
466,
304,
272,
408,
29387,
367,
314,
15911,
1470,
6009,
3167,
1890,
14,
339,
961,
6571,
1021,
13,
1896,
3102,
367,
10015,
436,
23812,
272,
2291,
2251,
334,
69,
14,
71,
14,
7773,
9,
1928,
11271,
4655,
314,
1890,
1256,
272,
2251,
14,
272,
408,
272,
485,
5545,
63,
5189,
275,
8773,
342,
221,
327,
730,
26,
7448,
59,
495,
12,
2434,
59,
10517,
1470,
6009,
3167,
7836,
2677,
272,
485,
5545,
63,
5189,
459,
15391,
418,
275,
15911,
1470,
6009,
3167,
39,
4354,
7836,
339,
347,
664,
63,
5545,
63,
533,
8,
1886,
12,
288,
1768,
26,
620,
275,
488,
12,
288,
776,
1035,
2434,
59,
10517,
1470,
6009,
3167,
7836,
2189,
267,
408,
1767,
376,
5827,
7773,
1021,
14,
398,
3033,
26,
288,
1768,
26,
710,
536,
402,
314,
6387,
7773,
14,
982,
7179,
365,
355,
2741,
12,
2066,
314,
1642,
7773,
315,
314,
7086,
365,
1202,
14,
398,
1803,
26,
288,
710,
7773,
1021,
370,
675,
14,
267,
408,
267,
327,
982,
282,
2488,
7773,
365,
5839,
12,
372,
626,
1373,
14,
267,
340,
1768,
26,
288,
372,
843,
423,
5545,
63,
5189,
59,
1302,
61,
398,
327,
3091,
7773,
365,
5839,
27,
372,
314,
849,
334,
9099,
365,
12,
314,
1642,
1373,
267,
327,
315,
314,
2600,
680,
267,
372,
2163,
8,
1661,
8,
1886,
423,
5545,
63,
5189,
14,
1459,
4059,
421,
199,
533,
15911,
1470,
6009,
3167,
3041,
8,
6577,
29,
10517,
1470,
6009,
3167,
3041,
3396,
304,
272,
408,
3167,
370,
5647,
8633,
1470,
12639,
626,
883,
506,
1202,
370,
663,
272,
1536,
406,
28335,
19074,
32663,
14,
272,
408,
339,
768,
4639,
272,
347,
485,
362,
63,
885,
63,
2037,
478,
63,
6520,
8,
1246,
63,
6520,
304,
267,
408,
7306,
2986,
6037,
370,
333,
10224,
6037,
14,
267,
7905,
298,
4856,
16647,
14,
17533,
14,
957,
2,
436,
298,
4856,
17533,
14,
957,
2,
370,
267,
298,
4856,
2037,
478,
14,
16647,
14,
17533,
14,
957,
2,
436,
298,
4856,
2037,
478,
14,
17533,
14,
957,
2,
17342,
14,
267,
3033,
26,
288,
2986,
63,
6520,
334,
7012,
59,
495,
4682,
314,
2986,
6037,
370,
3957,
14,
267,
1803,
26,
288,
620,
26,
6702,
333,
10224,
2986,
6037,
14,
267,
408,
267,
340,
440,
2986,
63,
6520,
26,
288,
372,
2986,
63,
6520,
398,
333,
9945,
63,
6520,
63,
264,
275,
295,
14,
2014,
8,
288,
519,
24726,
48,
28,
354,
13489,
14,
11896,
2229,
48,
28,
2037,
478,
3072,
14,
2037,
478,
5547,
2229,
48,
28,
16647,
3072,
14,
16647,
5547,
2229,
48,
28,
3098,
2261,
3072,
14,
17533,
4537,
957,
5547,
2,
267,
776,
398,
333,
275,
333,
9945,
63,
6520,
63,
264,
14,
1431,
8,
1246,
63,
6520,
9,
267,
536,
12,
333,
9945,
12,
19699,
12,
6233,
2261,
275,
333,
14,
2634,
342,
267,
340,
333,
9945,
503,
440,
6233,
2261,
26,
288,
372,
2986,
63,
6520,
398,
340,
19699,
26,
288,
372,
2986,
63,
6520,
14,
1814,
8,
355,
298,
16647,
14,
17533,
14,
957,
401,
298,
2037,
478,
14,
16647,
14,
17533,
14,
957,
2,
288,
776,
398,
372,
2986,
63,
6520,
14,
1814,
9520,
17533,
14,
957,
401,
3680,
2037,
478,
14,
17533,
14,
957,
531,
339,
6186,
63,
21054,
275,
283,
29882,
14,
17533,
14,
957,
7,
272,
6186,
63,
5747,
5296,
63,
21054,
275,
485,
362,
63,
885,
63,
2037,
478,
63,
6520,
855,
1532,
721,
221,
327,
730,
26,
3686,
267,
6186,
63,
21054,
272,
776,
339,
768,
3744,
272,
347,
687,
63,
1364,
63,
2048,
63,
815,
8,
1886,
12,
2256,
26,
1211,
12,
627,
589,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
feureau/Small-Scripts
|
Blender/Blender config/2.91/scripts/addons/bricker_v2-2-1/lib/property_groups/created_model_properties.py
|
1
|
35831
|
# Copyright (C) 2020 Christopher Gearhart
# chris@bblanimation.com
# http://bblanimation.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 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/>.
# System imports
# NONE!
# Blender imports
import bpy
from bpy.props import *
# Module imports
from .boolean_properties import *
from ...functions.property_callbacks import *
# Create custom property group
class CreatedModelProperties(bpy.types.PropertyGroup):
# CMLIST ITEM SETTINGS
name = StringProperty(update=uniquify_name)
id = IntProperty()
idx = IntProperty()
# NAME OF SOURCE
source_obj = PointerProperty(
type=bpy.types.Object,
poll=lambda self, object: object.type == "MESH",
name="Source Object",
description="Name of the source object to Brickify",
update=set_default_obj_if_empty,
)
# TRANSFORMATION SETTINGS
model_loc = StringProperty(default="-1,-1,-1")
model_rot = StringProperty(default="-1,-1,-1")
model_scale = StringProperty(default="-1,-1,-1")
transform_scale = FloatProperty(
name="Scale",
description="Scale of the brick model",
update=update_model_scale,
step=1,
default=1.0,
)
apply_to_source_object = BoolProperty(
name="Apply to source",
description="Apply transformations to source object when Brick Model is deleted",
default=True,
)
parent_obj = PointerProperty(
type=bpy.types.Object,
name="Parent Object",
description="Name of the parent object used for model transformations",
)
expose_parent = BoolProperty(
name="Show Manipulator",
description="Expose the parent object for this brick model for viewport manipulation",
update=update_parent_exposure,
default=False,
)
# ANIMATION SETTINGS
use_animation = BoolProperty(
name="Use Animation",
description="Create Brick Model for each frame, from start to stop frame (WARNING: Calculation takes time, and may result in large blend file)",
default=False,
)
start_frame = IntProperty(
name="Start",
description="First frame of the brick animation",
update=dirty_anim,
min=0, max=500000,
default=1,
)
stop_frame = IntProperty(
name="End",
description="Final frame of the brick animation",
update=dirty_anim,
min=0, max=500000,
default=10,
)
step_frame = IntProperty(
name="Step",
description="Number of frames to skip forward when generating the brick animation",
update=dirty_anim,
min=0, max=500000,
default=1,
)
# BASIC MODEL SETTINGS
brick_height = FloatProperty(
name="Brick Height",
description="Height of the bricks in the final Brick Model (in meters, excluding the stud)",
update=dirty_matrix,
subtype="DISTANCE",
step=1,
precision=3,
min = 0.000001,
soft_min=0.001, soft_max=10,
default=0.1,
)
gap = FloatProperty(
name="Gap Between Bricks",
description="Distance between bricks (relative to brick height)",
update=dirty_matrix,
subtype="PERCENTAGE",
step=1,
precision=1,
min=0.0, max=100.0,
default=0.5,
)
split_model = BoolProperty(
name="Split Model",
description="Split model into separate objects (slower)",
update=dirty_model,
default=False,
)
random_loc = FloatProperty(
name="Random Location",
description="Max random location applied to each brick",
update=dirty_model,
step=1,
precision=3,
min=0, soft_max=1,
default=0.01,
)
random_rot = FloatProperty(
name="Random Rotation",
description="Max random rotation applied to each brick",
update=dirty_model,
step=1,
precision=3,
min=0, soft_max=1,
default=0.025,
)
shell_thickness = IntProperty(
name="Shell Thickness",
description="Thickness of the outer shell of bricks",
update=dirty_build,
min=1, max=50,
default=1,
)
# MERGE SETTINGS
merge_type = EnumProperty(
name="Merge Type",
description="Type of algorithm used for merging bricks together",
items=[
# ("NONE", "None (fast)", "Bricks are not merged"),
("GREEDY", "Greedy", "Creates fewest amount of bricks possible"),
("RANDOM", "Random", "Merges randomly for realistic build"),
],
update=dirty_build,
default="RANDOM",
)
legal_bricks_only = BoolProperty(
name="Legal Bricks Only",
description="Construct model using only legal brick sizes",
update=dirty_build,
default=True,
)
merge_seed = IntProperty(
name="Seed",
description="Random seed for brick merging calculations",
update=dirty_build,
min=0,
default=1000,
)
align_bricks = BoolProperty(
name="Align Bricks Horizontally",
description="Keep bricks aligned horizontally, and fill the gaps with plates",
update=dirty_build,
default=True,
)
offset_brick_layers = IntProperty(
name="Offset Brick Layers",
description="Offset the layers that will be merged into bricks if possible",
update=dirty_build,
step=1,
min=0, max=2,
default=0,
)
# SMOKE SETTINGS
smoke_density = FloatProperty(
name="Smoke Density",
description="Density of brickified smoke (threshold for smoke: 1 - d)",
update=dirty_matrix,
min=0, max=1,
default=0.9,
)
smoke_quality = FloatProperty(
name="Smoke Quality",
description="Amount of data to analyze for density and color of brickified smoke",
update=dirty_matrix,
min=1, soft_max=100,
default=1,
)
smoke_brightness = FloatProperty(
name="Smoke Brightness",
description="Add brightness to smoke colors read from smoke data",
update=dirty_matrix,
soft_min=0, soft_max=100,
default=1,
)
smoke_saturation = FloatProperty(
name="Smoke Saturation",
description="Change saturation level of smoke colors read from smoke data",
update=dirty_matrix,
min=0, soft_max=100,
default=1,
)
flame_color = FloatVectorProperty(
name="Hex Value",
subtype="COLOR",
update=dirty_matrix,
default=[1.0, 0.63, 0.2],
)
flame_intensity = FloatProperty(
name="Flame Intensity",
description="Intensity of the flames",
update=dirty_matrix,
min=1, soft_max=50,
default=4,
)
# BRICK TYPE SETTINGS
brick_type = EnumProperty(
name="Brick Type",
description="Type of brick used to build the model",
items=get_brick_type_items,
update=update_brick_type,
# default="BRICKS",
)
max_width = IntProperty(
name="Max Width",
description="Maximum brick width in studs",
update=dirty_build,
step=1,
min=1, soft_max=100,
default=8,
)
max_depth = IntProperty(
name="Max Depth",
description="Maximum brick depth in studs",
update=dirty_build,
step=1,
min=1, soft_max=100,
default=24,
)
custom_object1 = PointerProperty(
type=bpy.types.Object,
poll=lambda self, object: object.type == "MESH" and object != self.source_obj and not object.name.startswith("Bricker_{}".format(self.source_obj.name)),
name="Custom Object 1",
description="Custom object to use as brick type",
)
custom_mesh1 = PointerProperty(
type=bpy.types.Mesh,
name="Custom Mesh 1",
description="Cached mesh from Custom Object 1 with materials applied/transform removed",
)
custom_object2 = PointerProperty(
type=bpy.types.Object,
poll=lambda self, object: object.type == "MESH" and object != self.source_obj and not object.name.startswith("Bricker_{}".format(self.source_obj.name)),
name="Custom Object 2",
description="Custom object to use as brick type",
)
custom_mesh2 = PointerProperty(
type=bpy.types.Mesh,
name="Custom Mesh 2",
description="Cached mesh from Custom Object 2 with materials applied/transform removed",
)
custom_object3 = PointerProperty(
type=bpy.types.Object,
poll=lambda self, object: object.type == "MESH" and object != self.source_obj and not object.name.startswith("Bricker_{}".format(self.source_obj.name)),
name="Custom Object 3",
description="Custom object to use as brick type",
)
custom_mesh3 = PointerProperty(
type=bpy.types.Mesh,
name="Custom Mesh 3",
description="Cached mesh from Custom Object 3 with materials applied/transform removed",
)
dist_offset = FloatVectorProperty(
name="Offset Distance",
description="Offset distance between custom bricks (1.0 = side-by-side)",
update=dirty_matrix,
step=1,
precision=3,
subtype="TRANSLATION",
min=0.001, soft_max=1.0,
default=(1, 1, 1),
)
# BOOLEAN SETTINGS
booleans = CollectionProperty(type=BooleanProperties)
boolean_index = IntProperty(default=-1)
# MATERIAL & COLOR SETTINGS
material_type = EnumProperty(
name="Material Type",
description="Choose what materials will be applied to model",
items=[
("NONE", "None", "No material applied to bricks"),
("CUSTOM", "Single Material", "Choose one material to apply to all generated bricks"),
("RANDOM", "Random", "Apply a random material from Brick materials to each generated brick"),
("SOURCE", "Use Source Materials", "Apply material based on closest intersecting face"),
],
update=dirty_build,
default="SOURCE",
)
custom_mat = PointerProperty(
type=bpy.types.Material,
name="Custom Material",
description="Material to apply to all bricks",
)
internal_mat = PointerProperty(
type=bpy.types.Material,
name="Internal Material",
description="Material to apply to bricks inside material shell",
update=dirty_material,
)
mat_shell_depth = IntProperty(
name="Shell Material Depth",
description="Depth to which the outer materials should be applied (1 = Only exposed bricks)",
step=1,
min=1, max=50,
update=dirty_matrix,
default=1,
)
merge_internals = EnumProperty(
name="Merge Shell with Internals",
description="Merge bricks on shell with internal bricks",
items=[
("NEITHER", "Neither", "Don't merge shell bricks with internals in either direction"),
("HORIZONTAL", "Horizontal", "Merge shell bricks with internals horizontally, but not vertically"),
("VERTICAL", "Vertical", "Merge shell bricks with internals vertically, but not horizontally"),
("BOTH", "Horizontal & Vertical", "Merge shell bricks with internals in both directions"),
],
update=dirty_build,
default="BOTH",
)
random_mat_seed = IntProperty(
name="Seed",
description="Random seed for material assignment",
min=0,
update=dirty_material,
default=1000,
)
use_uv_map = BoolProperty(
name="Use UV Map",
description="Transfer colors from UV map (if disabled or no UV map found, brick color will be based on RGB of first shader node)",
update=dirty_build,
default=True,
)
uv_image = PointerProperty(
type=bpy.types.Image,
name="UV Image",
description="UV Image to use for UV Map color transfer (defaults to active UV if left blank)",
update=dirty_build,
)
color_snap = EnumProperty(
name="Color Mapping",
description="Method for mapping source material(s)/texture(s) to new materials",
items=[
("NONE", "None", "Use source material(s)"),
("RGB", "RGB", "Map RGB values to new materials (similar materials will merge into one material based on threshold)"),
("ABS", "ABS", "Map RGB values to nearest ABS Plastic Materials")
],
update=dirty_build,
default="RGB",
)
color_depth = IntProperty(
name="Color Depth",
description="Number of colors to use in representing the UV texture (2^depth colors are created)",
min=1, max=10,
update=dirty_build,
default=4,
)
blur_radius = IntProperty(
name="Blur Radius",
description="Distance over which to blur the image before sampling",
min=0, max=10,
update=dirty_build,
default=0, # 1
)
color_snap_specular = FloatProperty(
name="Specular",
description="Specular value for the created materials",
subtype="FACTOR",
precision=3,
min=0.0, soft_max=1.0,
update=dirty_material,
default=0.5,
)
color_snap_roughness = FloatProperty(
name="Roughness",
description="Roughness value for the created materials",
subtype="FACTOR",
precision=3,
min=0.0, soft_max=1.0,
update=dirty_material,
default=0.5,
)
color_snap_sss = FloatProperty(
name="Subsurface Scattering",
description="Subsurface scattering value for the created materials",
subtype="FACTOR",
precision=3,
min=0.0, soft_max=1.0,
update=dirty_material,
default=0.0,
)
color_snap_sss_saturation = FloatProperty(
name="SSS Saturation",
description="Saturation of the subsurface scattering for the created materials (relative to base color value)",
subtype="FACTOR",
precision=3,
min=0.0, soft_max=1.0,
update=dirty_material,
default=1.0,
)
color_snap_ior = FloatProperty(
name="IOR",
description="IOR value for the created materials",
precision=3,
min=0.0, soft_max=1000.0,
update=dirty_material,
default=1.45,
)
color_snap_transmission = FloatProperty(
name="Transmission",
description="Transmission value for the created materials",
subtype="FACTOR",
precision=3,
min=0.0, soft_max=1.0,
update=dirty_material,
default=0.0,
)
color_snap_displacement = FloatProperty(
name="Displacement",
description="Displacement value for the created materials (overrides ABS Plastic displacement value)",
subtype="FACTOR",
precision=3,
min=0.0, soft_max=1.0,
update=dirty_material,
default=0.04,
)
use_abs_template = BoolProperty(
name="Use ABS Template",
description="Use the default ABS Plastic Material node tree to build the RGB materials",
update=dirty_material,
default=True,
)
include_transparency = BoolProperty(
name="Include Transparency",
description="Include alpha value of original material color",
update=dirty_build,
default=True,
)
transparent_weight = FloatProperty(
name="Transparency Weight",
description="How much the original material's alpha value affects the chosen ABS Plastic Material",
precision=1,
min=0, soft_max=2,
update=dirty_material,
default=1,
)
target_material = PointerProperty(
name="Target Material",
type=bpy.types.Material,
description="Add material to materials list",
update=add_material_to_list,
)
target_material_message = StringProperty(
description="Message from target material chosen (warning or success)",
default="",
)
target_material_time = StringProperty( # stored as string because float cuts off digits
description="'str(time.time())' from when the material message was created",
default="0",
)
# BRICK DETAIL SETTINGS
stud_detail = EnumProperty(
name="Stud Detailing",
description="Choose where to draw brick studs",
items=[
("NONE", "None", "Don't include brick studs/logos on bricks"),
("EXPOSED", "Exposed Bricks", "Include brick studs/logos only on bricks with the top exposed"),
("ALL", "All Bricks", "Include brick studs/logos only on bricks with the top exposed"),
],
update=dirty_bricks,
default="EXPOSED",
)
logo_type = EnumProperty(
name="Logo Type",
description="Choose logo type to draw on brick studs",
items=get_logo_types,
update=dirty_bricks,
# default="NONE",
)
logo_resolution = IntProperty(
name="Resolution",
description="Resolution of the brick logo",
update=dirty_bricks,
min=1, soft_max=10,
default=2,
)
logo_decimate = FloatProperty(
name="Decimate",
description="Decimate the brick logo (lower number for higher resolution)",
update=dirty_bricks,
precision=0,
min=0, max=10,
default=7.25,
)
logo_object = PointerProperty(
type=bpy.types.Object,
poll=lambda self, object: object.type == "MESH" and object != self.source_obj and not object.name.startswith("Bricker_{}".format(self.source_obj.name)),
name="Logo Object",
description="Select a custom logo object to use on top of each stud",
update=dirty_bricks,
)
logo_scale = FloatProperty(
name="Logo Scale",
description="Logo scale relative to stud scale",
subtype="PERCENTAGE",
step=1,
update=dirty_bricks,
precision=1,
min=0.0001, soft_max=100.0,
default=78.0,
)
logo_inset = FloatProperty(
name="Logo Inset",
description="How far to inset logo to stud",
subtype="PERCENTAGE",
step=1,
update=dirty_bricks,
precision=1,
soft_min=0.0, soft_max=100.0,
default=50.0,
)
hidden_underside_detail = EnumProperty(
name="Underside Detailing of Obstructed Bricks",
description="Level of detail on underside of bricks with obstructed undersides",
items=[
("FLAT", "Flat", "Draw single face on brick underside", 0),
("LOW", "Low Detail", "Hollow out brick underside and draw tube supports", 1),
("HIGH", "High Detail", "Draw underside of bricks at full detail (support beams, ticks, inset tubes)", 3),
],
update=dirty_bricks,
default="FLAT",
)
exposed_underside_detail = EnumProperty(
name="Underside Detailing of Exposed Bricks",
description="Level of detail on underside of bricks with exposed undersides",
items=[
("FLAT", "Flat", "Draw single face on brick underside", 0),
("LOW", "Low Detail", "Hollow out brick underside and draw tube supports", 1),
("HIGH", "High Detail", "Draw underside of bricks at full detail (support beams, ticks, inset tubes)", 3),
],
update=dirty_bricks,
default="FLAT",
)
circle_verts = IntProperty(
name="Vertices",
description="Number of vertices in each circle in brick mesh",
update=update_circle_verts,
min=4, soft_max=64,
default=16,
)
# BEVEL SETTINGS
bevel_added = BoolProperty(
name="Bevel Bricks",
description="Bevel brick edges and corners for added realism",
default=False,
)
bevel_show_render = BoolProperty(
name="Render",
description="Use modifier during render",
update=update_bevel_render,
default=True,
)
bevel_show_viewport = BoolProperty(
name="Realtime",
description="Display modifier in viewport",
update=update_bevel_viewport,
default=True,
)
bevel_show_edit_mode = BoolProperty(
name="Edit Mode",
description="Display modifier in Edit mode",
update=update_bevel_edit_mode,
default=True,
)
bevel_width = FloatProperty(
name="Bevel Width",
description="Bevel amount (relative to Brick Height)",
subtype="DISTANCE",
step=1,
min=0.0, soft_max=10,
update=update_bevel,
default=0.01,
)
bevel_segments = IntProperty(
name="Bevel Resolution",
description="Number of segments for round edges/verts",
step=1,
min=1, max=100,
update=update_bevel,
default=1,
)
bevel_profile = FloatProperty(
name="Bevel Profile",
description="The profile shape (0.5 = round)",
subtype="FACTOR",
step=1,
min=0.0, max=1.0,
update=update_bevel,
default=0.7,
)
# INTERNAL SUPPORTS SETTINGS
internal_supports = EnumProperty(
name="Internal Supports",
description="Choose what type of brick support structure to use inside your model",
items=[
("NONE", "None", "No internal supports"),
("COLUMNS", "Columns", "Use columns inside model"),
("LATTICE", "Lattice", "Use latice inside model"),
],
update=dirty_internal,
default="NONE",
)
lattice_step = IntProperty(
name="Step",
description="Distance between cross-beams",
update=dirty_internal,
step=1,
min=2, soft_max=100,
default=4,
)
lattice_height = IntProperty(
name="Height",
description="Height of the cross-beams",
update=dirty_internal,
step=1,
min=1, soft_max=100,
default=1,
)
alternate_xy = BoolProperty(
name="Alternate X and Y",
description="Alternate back-and-forth and side-to-side beams",
update=dirty_internal,
default=True,
)
col_thickness = IntProperty(
name="Thickness",
description="Thickness of the columns",
update=dirty_internal,
min=1, soft_max=100,
default=2,
)
col_step = IntProperty(
name="Step",
description="Distance between columns",
update=dirty_internal,
step=1,
min=1, soft_max=100,
default=2,
)
# ADVANCED SETTINGS
insideness_ray_cast_dir = EnumProperty(
name="Insideness Ray Cast Direction",
description="Ray cast method for calculation of insideness",
items=[
("HIGH_EFFICIENCY", "High Efficiency", "Reuses single intersection ray cast for insideness calculation"),
("X", "X", "Cast rays along X axis for insideness calculations"),
("Y", "Y", "Cast rays along Y axis for insideness calculations"),
("Z", "Z", "Cast rays along Z axis for insideness calculations"),
("XYZ", "XYZ (Best Result)", "Cast rays in all axis directions for insideness calculation (slowest; uses result consistent for at least 2 of the 3 rays)"),
],
update=dirty_matrix,
default="HIGH_EFFICIENCY",
)
brick_shell = EnumProperty(
name="Brick Shell",
description="Choose whether the outer shell of bricks will be inside or outside the source mesh",
items=[
("INSIDE", "Inside Mesh", "Draw brick shell inside source mesh (recommended)"),
("OUTSIDE", "Outside Mesh", "Draw brick shell outside source mesh"),
("CONSISTENT", "Consistent", "Draw brick shell on a consistent side of the source mesh topology (may fix noisy model if source mesh is not water-tight)"),
],
update=update_brick_shell,
default="INSIDE",
)
calculation_axes = EnumProperty(
name="Expanded Axes",
description="The brick shell will be drawn on the outside in these directions",
items=[
("XYZ", "XYZ", "XYZ"),
("XY", "XY", "XY"),
("YZ", "YZ", "YZ"),
("XZ", "XZ", "XZ"),
("X", "X", "X"),
("Y", "Y", "Y"),
("Z", "Z", "Z"),
],
update=dirty_matrix,
default="XY",
)
use_normals = BoolProperty(
name="Use Normals",
description="Use normals to calculate insideness of bricks (may improve the result if normals on source mesh are oriented correctly)",
update=dirty_matrix,
default=False,
)
grid_offset = FloatVectorProperty(
name="Grid Offset",
description="Offset the brick grid along the volume of the source mesh (factor of brick dimensions)",
subtype="XYZ",
min=-1, max=1,
update=dirty_matrix,
default=(0, 0, 0),
)
use_absolute_grid = BoolProperty(
name="Absolute Grid Coords",
description="Place bricks on a fixed grid that is consistent between all models",
update=dirty_matrix,
default=False,
)
use_absolute_grid_anim = BoolProperty(
name="Absolute Grid Coords",
description="Place bricks on a fixed grid that is consistent between all models",
update=dirty_matrix,
default=True,
)
calc_internals = BoolProperty(
name="Calculate Internals",
description="Calculate values for bricks inside shell (disable for faster calculation at the loss of the 'Shell Thickness' and 'Supports' features)",
update=dirty_matrix,
default=True,
)
use_local_orient = BoolProperty(
name="Use Local Orient",
description="Generate bricks based on local orientation of source object",
default=False,
)
instance_method = EnumProperty(
name="Instance Method",
description="Method to use for instancing equivalent meshes to save on memory and render times",
items=[
("NONE", "None", "No object instancing"),
("LINK_DATA", "Link Data", "Link mesh data for like objects when 'Split Model' is enabled"),
("POINT_CLOUD", "Point Cloud (experimental)", "Instance a single mesh over a point cloud (this method does not support multiple materials or brick merging)"),
],
update=dirty_build,
default="LINK_DATA",
)
# Deep Cache of bricksdict
bfm_cache = StringProperty(default="")
# Blender State for Undo Stack
blender_undo_state = IntProperty(default=0)
# Back-End UI Properties
active_key = IntVectorProperty(subtype="XYZ", default=(-1,-1,-1))
# Internal Model Properties
model_created = BoolProperty(default=False)
brickifying_in_background = BoolProperty(default=False)
job_progress = IntProperty(
name="",
description="",
subtype="PERCENTAGE",
default=0,
soft_min=0,
soft_max=100,
)
linked_from_external = BoolProperty(default=False)
num_animated_frames = IntProperty(default=0)
completed_frames = StringProperty(default="")
frames_to_animate = IntProperty(default=1)
stop_background_process = BoolProperty(default=False)
animated = BoolProperty(default=False)
armature = BoolProperty(default=False)
zstep = IntProperty(default=3)
parent_obj = PointerProperty(type=bpy.types.Object)
collection = PointerProperty(type=bpy.types.Collection if b280() else bpy.types.Group)
mat_obj_abs = PointerProperty(type=bpy.types.Object)
mat_obj_random = PointerProperty(type=bpy.types.Object)
rgba_vals = StringProperty(default="789c8b8e0500011500b9") # result of `compress_str(json.dumps({}))`
customized = BoolProperty(default=True)
brick_sizes_used = StringProperty(default="") # list of brick_sizes used separated by | (e.g. '5,4,3|7,4,5|8,6,5')
brick_types_used = StringProperty(default="") # list of brick_types used separated by | (e.g. 'PLATE|BRICK|STUD')
model_created_on_frame = IntProperty(default=-1)
is_smoke = BoolProperty(default=False)
has_custom_obj1 = BoolProperty(default=False)
has_custom_obj2 = BoolProperty(default=False)
has_custom_obj3 = BoolProperty(default=False)
# model stats
num_bricks_in_model = IntProperty(default=0)
num_materials_in_model = IntProperty(default=0)
model_weight = IntProperty(default=0)
real_world_dimensions = FloatVectorProperty(
name="Real World Dimensions",
description="",
subtype="XYZ",
unit="LENGTH",
precision=6,
default=(0, 0, 0),
)
# Properties for checking of model needs updating
anim_is_dirty = BoolProperty(default=True)
material_is_dirty = BoolProperty(default=True)
model_is_dirty = BoolProperty(default=True)
build_is_dirty = BoolProperty(default=False)
bricks_are_dirty = BoolProperty(default=True)
matrix_is_dirty = BoolProperty(default=True)
matrix_lost = BoolProperty(default=False)
internal_is_dirty = BoolProperty(default=True)
last_logo_type = StringProperty(default="NONE")
last_split_model = BoolProperty(default=False)
last_start_frame = IntProperty(
name="Last Start",
description="Current start frame of brickified animation",
default=-1,
)
last_stop_frame = IntProperty(
name="Last End",
description="Current end frame of brickified animation",
default=-1,
)
last_step_frame = IntProperty(
name="Last Step",
description="Current number of frames to skip forward when generating brickified animation",
default=-1,
)
last_source_mid = StringProperty(default="-1,-1,-1")
last_material_type = StringProperty(default="SOURCE")
last_use_abs_template = BoolProperty(default=False)
last_shell_thickness = IntProperty(default=1)
last_internal_supports = StringProperty(default="NONE")
last_brick_type = StringProperty(default="BRICKS")
last_instance_method = StringProperty(default="LINK_DATA")
last_matrix_settings = StringProperty(default="")
last_legal_bricks_only = BoolProperty(default=False)
last_mat_shell_depth = IntProperty(default=1)
last_bevel_width = FloatProperty()
last_bevel_segments = IntProperty()
last_bevel_profile = IntProperty()
last_is_smoke = BoolProperty()
# Bricker Version of Model
version = StringProperty(default="1.0.4")
### BACKWARDS COMPATIBILITY
# v1.0
maxBrickScale1 = IntProperty()
maxBrickScale2 = IntProperty()
# v1.3
distOffsetX = FloatProperty()
distOffsetY = FloatProperty()
distOffsetZ = FloatProperty()
# v1.4
logoDetail = StringProperty("NONE")
# v1.5
source_name = StringProperty()
parent_name = StringProperty()
# v1.6
modelLoc = StringProperty(default="-1,-1,-1")
modelRot = StringProperty(default="-1,-1,-1")
modelScale = StringProperty(default="-1,-1,-1")
transformScale = FloatProperty(default=1)
applyToSourceObject = BoolProperty(default=True)
exposeParent = BoolProperty(default=False)
useAnimation = BoolProperty(default=False)
startFrame = IntProperty(default=1)
stopFrame = IntProperty(default=10)
maxWorkers = IntProperty(default=5)
backProcTimeout = FloatProperty(default=0)
brickHeight = FloatProperty(default=0.1)
mergeSeed = IntProperty(default=1000)
connectThresh = IntProperty(default=1)
smokeDensity = FloatProperty(default=0.9)
smokeQuality = FloatProperty(default=1)
smokeBrightness = FloatProperty(default=1)
smokeSaturation = FloatProperty(default=1)
flameColor = FloatVectorProperty(default=[1.0, 0.63, 0.2])
flameIntensity = FloatProperty(default=4)
splitModel = BoolProperty(default=False)
randomLoc = FloatProperty(default=0.01)
randomRot = FloatProperty(default=0.025)
brickShell = StringProperty(default="INSIDE")
calculationAxes = StringProperty(default="XY")
shellThickness = IntProperty(default=1)
brickType = StringProperty(default="BRICKS")
alignBricks = BoolProperty(default=True)
offsetBrickLayers = IntProperty(default=0)
maxWidth = IntProperty(default=2)
maxDepth = IntProperty(default=10)
mergeType = StringProperty(default="RANDOM")
legalBricksOnly = BoolProperty(default=True)
customObject1 = PointerProperty(type=bpy.types.Object)
customObject2 = PointerProperty(type=bpy.types.Object)
customObject3 = PointerProperty(type=bpy.types.Object)
distOffset = FloatVectorProperty(default=(1, 1, 1))
paintbrushMat = PointerProperty(type=bpy.types.Material)
materialType = StringProperty(default="NONE")
customMat = PointerProperty(type=bpy.types.Material)
internalMat = PointerProperty(type=bpy.types.Material)
matShellDepth = IntProperty(default=1)
mergeInternals = StringProperty(default="BOTH")
randomMatSeed = IntProperty(default=1000)
useUVMap = BoolProperty(default=True)
uvImage = PointerProperty(type=bpy.types.Image)
colorSnap = StringProperty(default="RGB")
colorSnapAmount = FloatProperty(default=0.001)
color_snap_amount = FloatProperty(default=0.001)
colorSnapSpecular = FloatProperty(0.5)
colorSnapRoughness = FloatProperty(0.5)
colorSnapIOR = FloatProperty(1.45)
colorSnapTransmission = FloatProperty(0.0)
includeTransparency = BoolProperty(default=True)
transparentWeight = FloatProperty(default=1)
targetMaterial = StringProperty(default="")
studDetail = StringProperty(default="EXPOSED")
logoType = StringProperty(default="NONE")
logoResolution = IntProperty(default=2)
logoDecimate = FloatProperty(default=7.25)
logoScale = FloatProperty(default=78.0)
logoInset = FloatProperty(default=50.0)
hiddenUndersideDetail = StringProperty(default="FLAT")
exposedUndersideDetail = StringProperty(default="FLAT")
circleVerts = IntProperty(default=16)
bevelAdded = BoolProperty(default=False)
bevelShowRender = BoolProperty(default=True)
bevelShowViewport = BoolProperty(default=True)
bevelShowEditmode = BoolProperty(default=True)
bevelWidth = FloatProperty(default=0.01)
bevelSegments = IntProperty(default=1)
bevelProfile = FloatProperty(default=0.7)
internalSupports = StringProperty(default="NONE")
latticeStep = IntProperty(default=4)
latticeHeight = IntProperty(default=1)
alternateXY = BoolProperty(default=1)
colThickness = IntProperty(default=2)
colStep = IntProperty(default=2)
insidenessRayCastDir = StringProperty(default="HIGH_EFFICIENCY")
useNormals = BoolProperty(default=False)
verifyExposure = BoolProperty(default=False)
calcInternals = BoolProperty(default=True)
useLocalOrient = BoolProperty(default=False)
instanceBricks = BoolProperty(default=True)
BFMCache = StringProperty(default="")
modelCreated = BoolProperty(default=False)
numAnimatedFrames = IntProperty(default=0)
framesToAnimate = IntProperty(default=0)
modelCreatedOnFrame = IntProperty(default=-1)
|
gpl-3.0
|
[
3,
1898,
334,
35,
9,
25455,
2799,
322,
2379,
2523,
598,
2210,
72,
580,
199,
3,
682,
5719,
32,
2501,
1502,
8182,
14,
957,
199,
3,
1455,
921,
2501,
1502,
8182,
14,
957,
15,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
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,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
6187,
8925,
199,
3,
653,
4817,
1,
199,
199,
3,
699,
24912,
8925,
199,
646,
20575,
199,
504,
20575,
14,
6750,
492,
627,
199,
199,
3,
5673,
8925,
199,
504,
1275,
4871,
63,
3282,
492,
627,
199,
504,
2263,
5777,
14,
1829,
63,
11948,
492,
627,
421,
199,
3,
2790,
3537,
3324,
1572,
199,
533,
18208,
1685,
8516,
8,
66,
647,
14,
1313,
14,
3697,
2448,
304,
272,
327,
445,
1698,
6225,
473,
22057,
11543,
52,
3881,
272,
536,
275,
2624,
3697,
8,
873,
29,
5411,
392,
2021,
63,
354,
9,
272,
1305,
275,
9805,
3697,
342,
272,
4280,
275,
9805,
3697,
342,
339,
327,
13637,
1634,
25470,
272,
1350,
63,
1113,
275,
28833,
3697,
8,
267,
730,
29,
66,
647,
14,
1313,
14,
1692,
12,
267,
11271,
29,
2734,
291,
12,
909,
26,
909,
14,
466,
508,
298,
22076,
40,
401,
267,
536,
628,
2980,
6935,
401,
267,
1369,
628,
985,
402,
314,
1350,
909,
370,
699,
27091,
2021,
401,
267,
1678,
29,
409,
63,
885,
63,
1113,
63,
692,
63,
1667,
12,
272,
776,
339,
327,
9074,
5622,
18623,
11543,
52,
3881,
272,
1402,
63,
2102,
275,
2624,
3697,
8,
885,
27295,
17,
3057,
17,
3057,
17,
531,
272,
1402,
63,
4571,
275,
2624,
3697,
8,
885,
27295,
17,
3057,
17,
3057,
17,
531,
272,
1402,
63,
3467,
275,
2624,
3697,
8,
885,
27295,
17,
3057,
17,
3057,
17,
531,
272,
5793,
63,
3467,
275,
11140,
3697,
8,
267,
536,
628,
9944,
401,
267,
1369,
628,
9944,
402,
314,
20611,
346,
1402,
401,
267,
1678,
29,
873,
63,
1238,
63,
3467,
12,
267,
3650,
29,
17,
12,
267,
849,
29,
17,
14,
16,
12,
272,
776,
272,
4838,
63,
475,
63,
1365,
63,
785,
275,
19287,
3697,
8,
267,
536,
628,
16581,
370,
1350,
401,
267,
1369,
628,
16581,
25947,
370,
1350,
909,
1380,
699,
27091,
5822,
365,
5463,
401,
267,
849,
29,
549,
12,
272,
776,
272,
1676,
63,
1113,
275,
28833,
3697,
8,
267,
730,
29,
66,
647,
14,
1313,
14,
1692,
12,
267,
536,
628,
6652,
6935,
401,
267,
1369,
628,
985,
402,
314,
1676,
909,
1202,
367,
1402,
25947,
401,
272,
776,
272,
23705,
63,
1708,
275,
19287,
3697,
8,
267,
536,
628,
6824,
4688,
711,
6109,
401,
267,
1369,
628,
920,
4070,
314,
1676,
909,
367,
642,
20611,
346,
1402,
367,
2455,
719,
26212,
401,
267,
1678,
29,
873,
63,
1708,
63,
28480,
12,
267,
849,
29,
797,
12,
272,
776,
339,
327,
1261,
1469,
2594,
11543,
52,
3881,
272,
675,
63,
22228,
275,
19287,
3697,
8,
267,
536,
628,
6119,
1626,
8182,
401,
267,
1369,
628,
2499,
699,
27091,
5822,
367,
1924,
2787,
12,
687,
1343,
370,
3631,
2787,
334,
9171,
26,
19821,
425,
6181,
900,
12,
436,
1443,
754,
315,
7031,
330,
12944,
570,
4186,
267,
849,
29,
797,
12,
272,
776,
272,
1343,
63,
1943,
275,
9805,
3697,
8,
267,
536,
628,
3162,
401,
267,
1369,
628,
7147,
2787,
402,
314,
20611,
346,
24154,
401,
267,
1678,
29,
8799,
63,
22019,
12,
267,
1748,
29,
16,
12,
1390,
29,
21,
5345,
12,
267,
849,
29,
17,
12,
272,
776,
272,
3631,
63,
1943,
275,
9805,
3697,
8,
267,
536,
628,
3005,
401,
267,
1369,
628,
12776,
2787,
402,
314,
20611,
346,
24154,
401,
267,
1678,
29,
8799,
63,
22019,
12,
267,
1748,
29,
16,
12,
1390,
29,
21,
5345,
12,
267,
849,
29,
709,
12,
272,
776,
272,
3650,
63,
1943,
275,
9805,
3697,
8,
267,
536,
628,
7801,
401,
267,
1369,
628,
3259,
402,
11223,
370,
3372,
7568,
1380,
12999,
314,
20611,
346,
24154,
401,
267,
1678,
29,
8799,
63,
22019,
12,
267,
1748,
29,
16,
12,
1390,
29,
21,
5345,
12,
267,
849,
29,
17,
12,
272,
776,
339,
327,
4147,
948,
10362,
4424,
11543,
52,
3881,
272,
20611,
346,
63,
3333,
275,
11140,
3697,
8,
267,
536,
628,
34,
27091,
5311,
1070,
401,
267,
1369,
628,
8436,
402,
314,
20611,
5618,
315,
314,
4242,
699,
27091,
5822,
334,
262,
24808,
12,
28529,
314,
410,
1181,
4186,
267,
1678,
29,
8799,
63,
3642,
12,
267,
15686,
628,
22375,
401,
267,
3650,
29,
17,
12,
267,
7151,
29,
19,
12,
267,
1748,
275,
378,
14,
19983,
12,
267,
11620,
63,
827,
29,
16,
14,
4587,
12,
11620,
63,
988,
29,
709,
12,
267,
849,
29,
16,
14,
17,
12,
272,
776,
272,
16301,
275,
11140,
3697,
8,
267,
536,
628,
39,
439,
31535,
3109,
699,
322,
5618,
401,
267,
1369,
628,
10076,
3382,
20611,
5618,
334,
6188,
370,
20611,
346,
4569,
4186,
267,
1678,
29,
8799,
63,
3642,
12,
267,
15686,
628,
4227,
17349,
2962,
401,
267,
3650,
29,
17,
12,
267,
7151,
29,
17,
12,
267,
1748,
29,
16,
14,
16,
12,
1390,
29,
1960,
14,
16,
12,
267,
849,
29,
16,
14,
21,
12,
272,
776,
272,
3715,
63,
1238,
275,
19287,
3697,
8,
267,
536,
628,
8862,
5822,
401,
267,
1369,
628,
8862,
1402,
1901,
7396,
2251,
334,
83,
2325,
4186,
267,
1678,
29,
8799,
63,
1238,
12,
267,
849,
29,
797
] |
[
1898,
334,
35,
9,
25455,
2799,
322,
2379,
2523,
598,
2210,
72,
580,
199,
3,
682,
5719,
32,
2501,
1502,
8182,
14,
957,
199,
3,
1455,
921,
2501,
1502,
8182,
14,
957,
15,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
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,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
6187,
8925,
199,
3,
653,
4817,
1,
199,
199,
3,
699,
24912,
8925,
199,
646,
20575,
199,
504,
20575,
14,
6750,
492,
627,
199,
199,
3,
5673,
8925,
199,
504,
1275,
4871,
63,
3282,
492,
627,
199,
504,
2263,
5777,
14,
1829,
63,
11948,
492,
627,
421,
199,
3,
2790,
3537,
3324,
1572,
199,
533,
18208,
1685,
8516,
8,
66,
647,
14,
1313,
14,
3697,
2448,
304,
272,
327,
445,
1698,
6225,
473,
22057,
11543,
52,
3881,
272,
536,
275,
2624,
3697,
8,
873,
29,
5411,
392,
2021,
63,
354,
9,
272,
1305,
275,
9805,
3697,
342,
272,
4280,
275,
9805,
3697,
342,
339,
327,
13637,
1634,
25470,
272,
1350,
63,
1113,
275,
28833,
3697,
8,
267,
730,
29,
66,
647,
14,
1313,
14,
1692,
12,
267,
11271,
29,
2734,
291,
12,
909,
26,
909,
14,
466,
508,
298,
22076,
40,
401,
267,
536,
628,
2980,
6935,
401,
267,
1369,
628,
985,
402,
314,
1350,
909,
370,
699,
27091,
2021,
401,
267,
1678,
29,
409,
63,
885,
63,
1113,
63,
692,
63,
1667,
12,
272,
776,
339,
327,
9074,
5622,
18623,
11543,
52,
3881,
272,
1402,
63,
2102,
275,
2624,
3697,
8,
885,
27295,
17,
3057,
17,
3057,
17,
531,
272,
1402,
63,
4571,
275,
2624,
3697,
8,
885,
27295,
17,
3057,
17,
3057,
17,
531,
272,
1402,
63,
3467,
275,
2624,
3697,
8,
885,
27295,
17,
3057,
17,
3057,
17,
531,
272,
5793,
63,
3467,
275,
11140,
3697,
8,
267,
536,
628,
9944,
401,
267,
1369,
628,
9944,
402,
314,
20611,
346,
1402,
401,
267,
1678,
29,
873,
63,
1238,
63,
3467,
12,
267,
3650,
29,
17,
12,
267,
849,
29,
17,
14,
16,
12,
272,
776,
272,
4838,
63,
475,
63,
1365,
63,
785,
275,
19287,
3697,
8,
267,
536,
628,
16581,
370,
1350,
401,
267,
1369,
628,
16581,
25947,
370,
1350,
909,
1380,
699,
27091,
5822,
365,
5463,
401,
267,
849,
29,
549,
12,
272,
776,
272,
1676,
63,
1113,
275,
28833,
3697,
8,
267,
730,
29,
66,
647,
14,
1313,
14,
1692,
12,
267,
536,
628,
6652,
6935,
401,
267,
1369,
628,
985,
402,
314,
1676,
909,
1202,
367,
1402,
25947,
401,
272,
776,
272,
23705,
63,
1708,
275,
19287,
3697,
8,
267,
536,
628,
6824,
4688,
711,
6109,
401,
267,
1369,
628,
920,
4070,
314,
1676,
909,
367,
642,
20611,
346,
1402,
367,
2455,
719,
26212,
401,
267,
1678,
29,
873,
63,
1708,
63,
28480,
12,
267,
849,
29,
797,
12,
272,
776,
339,
327,
1261,
1469,
2594,
11543,
52,
3881,
272,
675,
63,
22228,
275,
19287,
3697,
8,
267,
536,
628,
6119,
1626,
8182,
401,
267,
1369,
628,
2499,
699,
27091,
5822,
367,
1924,
2787,
12,
687,
1343,
370,
3631,
2787,
334,
9171,
26,
19821,
425,
6181,
900,
12,
436,
1443,
754,
315,
7031,
330,
12944,
570,
4186,
267,
849,
29,
797,
12,
272,
776,
272,
1343,
63,
1943,
275,
9805,
3697,
8,
267,
536,
628,
3162,
401,
267,
1369,
628,
7147,
2787,
402,
314,
20611,
346,
24154,
401,
267,
1678,
29,
8799,
63,
22019,
12,
267,
1748,
29,
16,
12,
1390,
29,
21,
5345,
12,
267,
849,
29,
17,
12,
272,
776,
272,
3631,
63,
1943,
275,
9805,
3697,
8,
267,
536,
628,
3005,
401,
267,
1369,
628,
12776,
2787,
402,
314,
20611,
346,
24154,
401,
267,
1678,
29,
8799,
63,
22019,
12,
267,
1748,
29,
16,
12,
1390,
29,
21,
5345,
12,
267,
849,
29,
709,
12,
272,
776,
272,
3650,
63,
1943,
275,
9805,
3697,
8,
267,
536,
628,
7801,
401,
267,
1369,
628,
3259,
402,
11223,
370,
3372,
7568,
1380,
12999,
314,
20611,
346,
24154,
401,
267,
1678,
29,
8799,
63,
22019,
12,
267,
1748,
29,
16,
12,
1390,
29,
21,
5345,
12,
267,
849,
29,
17,
12,
272,
776,
339,
327,
4147,
948,
10362,
4424,
11543,
52,
3881,
272,
20611,
346,
63,
3333,
275,
11140,
3697,
8,
267,
536,
628,
34,
27091,
5311,
1070,
401,
267,
1369,
628,
8436,
402,
314,
20611,
5618,
315,
314,
4242,
699,
27091,
5822,
334,
262,
24808,
12,
28529,
314,
410,
1181,
4186,
267,
1678,
29,
8799,
63,
3642,
12,
267,
15686,
628,
22375,
401,
267,
3650,
29,
17,
12,
267,
7151,
29,
19,
12,
267,
1748,
275,
378,
14,
19983,
12,
267,
11620,
63,
827,
29,
16,
14,
4587,
12,
11620,
63,
988,
29,
709,
12,
267,
849,
29,
16,
14,
17,
12,
272,
776,
272,
16301,
275,
11140,
3697,
8,
267,
536,
628,
39,
439,
31535,
3109,
699,
322,
5618,
401,
267,
1369,
628,
10076,
3382,
20611,
5618,
334,
6188,
370,
20611,
346,
4569,
4186,
267,
1678,
29,
8799,
63,
3642,
12,
267,
15686,
628,
4227,
17349,
2962,
401,
267,
3650,
29,
17,
12,
267,
7151,
29,
17,
12,
267,
1748,
29,
16,
14,
16,
12,
1390,
29,
1960,
14,
16,
12,
267,
849,
29,
16,
14,
21,
12,
272,
776,
272,
3715,
63,
1238,
275,
19287,
3697,
8,
267,
536,
628,
8862,
5822,
401,
267,
1369,
628,
8862,
1402,
1901,
7396,
2251,
334,
83,
2325,
4186,
267,
1678,
29,
8799,
63,
1238,
12,
267,
849,
29,
797,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
xclxxl414/rqalpha
|
rqalpha/__main__.py
|
1
|
14210
|
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import errno
import sys
import os
import shutil
import six
import click
from importlib import import_module
from rqalpha.utils.click_helper import Date
from rqalpha.utils.config import parse_config, dump_config
CONTEXT_SETTINGS = {
'default_map': {
'run': {
}
}
}
@click.group(context_settings=CONTEXT_SETTINGS)
@click.option('-v', '--verbose', count=True)
@click.help_option('-h', '--help')
@click.pass_context
def cli(ctx, verbose):
ctx.obj["VERBOSE"] = verbose
def inject_mod_commands():
from rqalpha.utils.config import get_mod_conf
from rqalpha.mod import SYSTEM_MOD_LIST
from rqalpha.utils.package_helper import import_mod
mod_config = get_mod_conf()
for mod_name, config in six.iteritems(mod_config['mod']):
if 'lib' in config:
lib_name = config["lib"]
else:
lib_name = "rqalpha_mod_{}".format(mod_name)
if not config['enabled']:
continue
try:
if mod_name in SYSTEM_MOD_LIST:
# inject system mod
import_mod("rqalpha.mod." + lib_name)
else:
# inject third part mod
import_mod(lib_name)
except Exception as e:
pass
def entry_point():
inject_mod_commands()
cli(obj={})
@cli.command()
@click.option('-d', '--data-bundle-path', default=os.path.expanduser('~/.rqalpha'), type=click.Path(file_okay=False))
@click.option('--locale', 'locale', type=click.STRING, default="zh_Hans_CN")
def update_bundle(data_bundle_path, locale):
"""
Sync Data Bundle
"""
from rqalpha import main
main.update_bundle(data_bundle_path, locale)
@cli.command()
@click.help_option('-h', '--help')
# -- Base Configuration
@click.option('-d', '--data-bundle-path', 'base__data_bundle_path', type=click.Path(exists=True))
@click.option('-f', '--strategy-file', 'base__strategy_file', type=click.Path(exists=True))
@click.option('-s', '--start-date', 'base__start_date', type=Date())
@click.option('-e', '--end-date', 'base__end_date', type=Date())
@click.option('-bm', '--benchmark', 'base__benchmark', type=click.STRING, default=None)
@click.option('-mm', '--margin-multiplier', 'base__margin_multiplier', type=click.FLOAT)
@click.option('-a', '--account', 'base__accounts', nargs=2, multiple=True, help="set account type with starting cash")
@click.option('--position', 'base__init_positions', type=click.STRING, help="set init position")
@click.option('-fq', '--frequency', 'base__frequency', type=click.Choice(['1d', '1m', 'tick']))
@click.option('-rt', '--run-type', 'base__run_type', type=click.Choice(['b', 'p', 'r']), default="b")
@click.option('-rp', '--round-price', 'base__round_price', is_flag=True)
@click.option('-mk', '--market', 'base__market', type=click.Choice(['cn', 'hk']), default=None)
@click.option('--resume', 'base__resume_mode', is_flag=True)
@click.option('--source-code', 'base__source_code')
# -- Extra Configuration
@click.option('-l', '--log-level', 'extra__log_level', type=click.Choice(['verbose', 'debug', 'info', 'error', 'none']))
@click.option('--disable-user-system-log', 'extra__user_system_log_disabled', is_flag=True, help='disable user system log stdout')
@click.option('--disable-user-log', 'extra__user_log_disabled', is_flag=True, help='disable user log stdout')
@click.option('--logger', 'extra__logger', nargs=2, multiple=True, help='config logger, e.g. --logger system_log debug')
@click.option('--locale', 'extra__locale', type=click.Choice(['cn', 'en']), default="cn")
@click.option('--extra-vars', 'extra__context_vars', type=click.STRING, help="override context vars")
@click.option("--enable-profiler", "extra__enable_profiler", is_flag=True, help="add line profiler to profile your strategy")
@click.option('--config', 'config_path', type=click.STRING, help="config file path")
# -- Mod Configuration
@click.option('-mc', '--mod-config', 'mod_configs', nargs=2, multiple=True, type=click.STRING, help="mod extra config")
def run(**kwargs):
"""
Start to run a strategy
"""
config_path = kwargs.get('config_path', None)
if config_path is not None:
config_path = os.path.abspath(config_path)
kwargs.pop('config_path')
if not kwargs.get('base__securities', None):
kwargs.pop('base__securities', None)
from rqalpha import main
source_code = kwargs.get("base__source_code")
cfg = parse_config(kwargs, config_path=config_path, click_type=True, source_code=source_code)
source_code = cfg.base.source_code
results = main.run(cfg, source_code=source_code)
# store results into ipython when running in ipython
from rqalpha.utils import is_run_from_ipython
if results is not None and is_run_from_ipython():
import IPython
from rqalpha.utils import RqAttrDict
ipy = IPython.get_ipython()
report = results.get("sys_analyser", {})
ipy.user_global_ns["results"] = results
ipy.user_global_ns["report"] = RqAttrDict(report)
if results is None:
sys.exit(1)
@cli.command()
@click.option('-d', '--directory', default="./", type=click.Path(), required=True)
def examples(directory):
"""
Generate example strategies to target folder
"""
source_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "examples")
try:
shutil.copytree(source_dir, os.path.join(directory, "examples"))
except OSError as e:
if e.errno == errno.EEXIST:
six.print_("Folder examples is exists.")
@cli.command()
@click.option('-v', '--verbose', is_flag=True)
def version(**kwargs):
"""
Output Version Info
"""
from rqalpha import version_info
six.print_("Current Version: ", version_info)
@cli.command()
@click.option('-d', '--directory', default="./", type=click.Path(), required=True)
def generate_config(directory):
"""
Generate default config file
"""
default_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.yml")
target_config_path = os.path.abspath(os.path.join(directory, 'config.yml'))
shutil.copy(default_config, target_config_path)
six.print_("Config file has been generated in", target_config_path)
# For Mod Cli
@cli.command(context_settings=dict(
ignore_unknown_options=True,
))
@click.help_option('-h', '--help')
@click.argument('cmd', nargs=1, type=click.Choice(['list', 'enable', 'disable', 'install', 'uninstall']))
@click.argument('params', nargs=-1)
def mod(cmd, params):
"""
Mod management command
rqalpha mod list \n
rqalpha mod install xxx \n
rqalpha mod uninstall xxx \n
rqalpha mod enable xxx \n
rqalpha mod disable xxx \n
"""
def list(params):
"""
List all mod configuration
"""
from tabulate import tabulate
from rqalpha.utils.config import get_mod_conf
mod_config = get_mod_conf()
table = []
for mod_name, mod in six.iteritems(mod_config['mod']):
table.append([
mod_name,
("enabled" if mod['enabled'] else "disabled")
])
headers = [
"name",
"status"
]
six.print_(tabulate(table, headers=headers, tablefmt="psql"))
six.print_("You can use `rqalpha mod list/install/uninstall/enable/disable` to manage your mods")
def install(params):
"""
Install third-party Mod
"""
try:
from pip._internal import main as pip_main
from pip._internal.commands.install import InstallCommand
except ImportError:
from pip import main as pip_main
from pip.commands.install import InstallCommand
params = [param for param in params]
options, mod_list = InstallCommand().parse_args(params)
mod_list = [mod_name for mod_name in mod_list if mod_name != "."]
params = ["install"] + params
for mod_name in mod_list:
mod_name_index = params.index(mod_name)
if mod_name.startswith("rqalpha_mod_sys_"):
six.print_('System Mod can not be installed or uninstalled')
return
if "rqalpha_mod_" in mod_name:
lib_name = mod_name
else:
lib_name = "rqalpha_mod_" + mod_name
params[mod_name_index] = lib_name
# Install Mod
installed_result = pip_main(params)
# Export config
from rqalpha.utils.config import load_yaml, user_mod_conf_path
user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}}
if installed_result == 0:
# 如果为0,则说明安装成功
if len(mod_list) == 0:
"""
主要是方便 `pip install -e .` 这种方式 本地调试 Mod 使用,需要满足以下条件:
1. `rqalpha mod install -e .` 命令是在对应 自定义 Mod 的根目录下
2. 该 Mod 必须包含 `setup.py` 文件(否则也不能正常的 `pip install -e .` 来安装)
3. 该 Mod 包名必须按照 RQAlpha 的规范来命名,具体规则如下
* 必须以 `rqalpha-mod-` 来开头,比如 `rqalpha-mod-xxx-yyy`
* 对应import的库名必须要 `rqalpha_mod_` 来开头,并且需要和包名后半部分一致,但是 `-` 需要替换为 `_`, 比如 `rqalpha_mod_xxx_yyy`
"""
mod_name = _detect_package_name_from_dir(params)
mod_name = mod_name.replace("-", "_").replace("rqalpha_mod_", "")
mod_list.append(mod_name)
for mod_name in mod_list:
if "rqalpha_mod_" in mod_name:
mod_name = mod_name.replace("rqalpha_mod_", "")
if "==" in mod_name:
mod_name = mod_name.split('==')[0]
user_conf['mod'][mod_name] = {}
user_conf['mod'][mod_name]['enabled'] = False
dump_config(user_mod_conf_path(), user_conf)
return installed_result
def uninstall(params):
"""
Uninstall third-party Mod
"""
try:
from pip._internal import main as pip_main
from pip._internal.commands.uninstall import UninstallCommand
except ImportError:
# be compatible with pip < 10.0
from pip import main as pip_main
from pip.commands.uninstall import UninstallCommand
params = [param for param in params]
options, mod_list = UninstallCommand().parse_args(params)
params = ["uninstall"] + params
for mod_name in mod_list:
mod_name_index = params.index(mod_name)
if mod_name.startswith("rqalpha_mod_sys_"):
six.print_('System Mod can not be installed or uninstalled')
return
if "rqalpha_mod_" in mod_name:
lib_name = mod_name
else:
lib_name = "rqalpha_mod_" + mod_name
params[mod_name_index] = lib_name
# Uninstall Mod
uninstalled_result = pip_main(params)
# Remove Mod Config
from rqalpha.utils.config import user_mod_conf_path, load_yaml
user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}}
for mod_name in mod_list:
if "rqalpha_mod_" in mod_name:
mod_name = mod_name.replace("rqalpha_mod_", "")
del user_conf['mod'][mod_name]
dump_config(user_mod_conf_path(), user_conf)
return uninstalled_result
def enable(params):
"""
enable mod
"""
mod_name = params[0]
if "rqalpha_mod_" in mod_name:
mod_name = mod_name.replace("rqalpha_mod_", "")
# check whether is installed
module_name = "rqalpha_mod_" + mod_name
if module_name.startswith("rqalpha_mod_sys_"):
module_name = "rqalpha.mod." + module_name
try:
import_module(module_name)
except ImportError:
installed_result = install([module_name])
if installed_result != 0:
return
from rqalpha.utils.config import user_mod_conf_path, load_yaml
user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}}
try:
user_conf['mod'][mod_name]['enabled'] = True
except KeyError:
user_conf['mod'][mod_name] = {'enabled': True}
dump_config(user_mod_conf_path(), user_conf)
def disable(params):
"""
disable mod
"""
mod_name = params[0]
if "rqalpha_mod_" in mod_name:
mod_name = mod_name.replace("rqalpha_mod_", "")
from rqalpha.utils.config import user_mod_conf_path, load_yaml
user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}}
try:
user_conf['mod'][mod_name]['enabled'] = False
except KeyError:
user_conf['mod'][mod_name] = {'enabled': False}
dump_config(user_mod_conf_path(), user_conf)
locals()[cmd](params)
def _detect_package_name_from_dir(params):
setup_path = os.path.join(os.path.abspath(params[-1]), 'setup.py')
if not os.path.exists(setup_path):
return None
return os.path.split(os.path.dirname(setup_path))[1]
if __name__ == '__main__':
entry_point()
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
9708,
820,
1885,
13603,
12,
3277,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
646,
7554,
199,
646,
984,
199,
646,
747,
199,
646,
5145,
199,
646,
3816,
199,
646,
8968,
199,
504,
14802,
492,
492,
63,
578,
199,
199,
504,
24659,
4468,
14,
1208,
14,
4891,
63,
3676,
492,
6148,
199,
504,
24659,
4468,
14,
1208,
14,
888,
492,
2198,
63,
888,
12,
5461,
63,
888,
199,
199,
9059,
63,
13931,
275,
469,
272,
283,
885,
63,
1130,
356,
469,
267,
283,
1065,
356,
469,
267,
789,
272,
789,
199,
93,
421,
199,
32,
4891,
14,
923,
8,
1100,
63,
1751,
29,
9059,
63,
13931,
9,
199,
32,
4891,
14,
1422,
3654,
86,
297,
2850,
3832,
297,
2338,
29,
549,
9,
199,
32,
4891,
14,
3437,
63,
1422,
3654,
72,
297,
2850,
3437,
358,
199,
32,
4891,
14,
1529,
63,
1100,
199,
318,
5053,
8,
3799,
12,
3376,
304,
272,
4027,
14,
1113,
905,
16075,
937,
275,
3376,
421,
199,
318,
16182,
63,
1494,
63,
4405,
837,
272,
687,
24659,
4468,
14,
1208,
14,
888,
492,
664,
63,
1494,
63,
2190,
272,
687,
24659,
4468,
14,
1494,
492,
20859,
63,
8816,
63,
4924,
272,
687,
24659,
4468,
14,
1208,
14,
2491,
63,
3676,
492,
492,
63,
1494,
272,
3413,
63,
888,
275,
664,
63,
1494,
63,
2190,
342,
339,
367,
3413,
63,
354,
12,
1101,
315,
3816,
14,
4611,
8,
1494,
63,
888,
459,
1494,
9090,
267,
340,
283,
773,
7,
315,
1101,
26,
288,
1973,
63,
354,
275,
1101,
905,
773,
937,
267,
587,
26,
288,
1973,
63,
354,
275,
298,
5098,
4468,
63,
1494,
63,
13536,
908,
8,
1494,
63,
354,
9,
267,
340,
440,
1101,
459,
3827,
2565,
288,
1980,
267,
862,
26,
288,
340,
3413,
63,
354,
315,
20859,
63,
8816,
63,
4924,
26,
355,
327,
16182,
2656,
3413,
355,
492,
63,
1494,
480,
5098,
4468,
14,
1494,
2122,
435,
1973,
63,
354,
9,
288,
587,
26,
355,
327,
16182,
10919,
1777,
3413,
355,
492,
63,
1494,
8,
773,
63,
354,
9,
267,
871,
2186,
465,
325,
26,
288,
986,
421,
199,
318,
2397,
63,
1403,
837,
272,
16182,
63,
1494,
63,
4405,
342,
339,
5053,
8,
1113,
21146,
421,
199,
32,
2764,
14,
1531,
342,
199,
32,
4891,
14,
1422,
3654,
68,
297,
2850,
576,
13,
6469,
13,
515,
297,
849,
29,
736,
14,
515,
14,
12131,
21114,
8083,
5098,
4468,
659,
730,
29,
4891,
14,
2042,
8,
493,
63,
745,
1187,
29,
797,
430,
199,
32,
4891,
14,
1422,
4517,
5508,
297,
283,
5508,
297,
730,
29,
4891,
14,
5353,
12,
849,
628,
3951,
63,
40,
796,
63,
12874,
531,
199,
318,
1678,
63,
6469,
8,
576,
63,
6469,
63,
515,
12,
5867,
304,
272,
408,
272,
22407,
3918,
29311,
272,
408,
272,
687,
24659,
4468,
492,
2446,
272,
2446,
14,
873,
63,
6469,
8,
576,
63,
6469,
63,
515,
12,
5867,
9,
421,
199,
32,
2764,
14,
1531,
342,
199,
32,
4891,
14,
3437,
63,
1422,
3654,
72,
297,
2850,
3437,
358,
199,
3,
1553,
3523,
11595,
199,
32,
4891,
14,
1422,
3654,
68,
297,
2850,
576,
13,
6469,
13,
515,
297,
283,
1095,
363,
576,
63,
6469,
63,
515,
297,
730,
29,
4891,
14,
2042,
8,
2444,
29,
549,
430,
199,
32,
4891,
14,
1422,
3654,
70,
297,
2850,
8590,
13,
493,
297,
283,
1095,
363,
8590,
63,
493,
297,
730,
29,
4891,
14,
2042,
8,
2444,
29,
549,
430,
199,
32,
4891,
14,
1422,
3654,
83,
297,
2850,
928,
13,
602,
297,
283,
1095,
363,
928,
63,
602,
297,
730,
29,
2506,
1012,
199,
32,
4891,
14,
1422,
3654,
69,
297,
2850,
500,
13,
602,
297,
283,
1095,
363,
500,
63,
602,
297,
730,
29,
2506,
1012,
199,
32,
4891,
14,
1422,
3654,
12648,
297,
2850,
11861,
297,
283,
1095,
363,
11861,
297,
730,
29,
4891,
14,
5353,
12,
849,
29,
403,
9,
199,
32,
4891,
14,
1422,
3654,
596,
297,
2850,
9650,
13,
15812,
297,
283,
1095,
363,
9650,
63,
15812,
297,
730,
29,
4891,
14,
11783,
9,
199,
32,
4891,
14,
1422,
3654,
65,
297,
2850,
2048,
297,
283,
1095,
363,
8370,
297,
9237,
29,
18,
12,
3663,
29,
549,
12,
1720,
628,
409,
2933,
730,
543,
6617,
286,
1119,
531,
199,
32,
4891,
14,
1422,
4517,
3124,
297,
283,
1095,
363,
826,
63,
12658,
297,
730,
29,
4891,
14,
5353,
12,
1720,
628,
409,
4205,
3421,
531,
199,
32,
4891,
14,
1422,
3654,
11878,
297,
2850,
11132,
297,
283,
1095,
363,
11132,
297,
730,
29,
4891,
14,
9054,
2941,
17,
68,
297,
283,
17,
77,
297,
283,
8284,
5156,
199,
32,
4891,
14,
1422,
3654,
2591,
297,
2850,
1065,
13,
466,
297,
283,
1095,
363,
1065,
63,
466,
297,
730,
29,
4891,
14,
9054,
2941,
66,
297,
283,
80,
297,
283,
82,
3815,
849,
628,
66,
531,
199,
32,
4891,
14,
1422,
3654,
4599,
297,
2850,
2363,
13,
4777,
297,
283,
1095,
363,
2363,
63,
4777,
297,
365,
63,
4173,
29,
549,
9,
199,
32,
4891,
14,
1422,
3654,
3880,
297,
2850,
22270,
297,
283,
1095,
363,
22270,
297,
730,
29,
4891,
14,
9054,
2941,
6413,
297,
283,
21557,
3815,
849,
29,
403,
9,
199,
32,
4891,
14,
1422,
4517,
9964,
297,
283,
1095,
363,
9964,
63,
632,
297,
365,
63,
4173,
29,
549,
9,
199,
32,
4891,
14,
1422,
4517,
1365,
13
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
9708,
820,
1885,
13603,
12,
3277,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
646,
7554,
199,
646,
984,
199,
646,
747,
199,
646,
5145,
199,
646,
3816,
199,
646,
8968,
199,
504,
14802,
492,
492,
63,
578,
199,
199,
504,
24659,
4468,
14,
1208,
14,
4891,
63,
3676,
492,
6148,
199,
504,
24659,
4468,
14,
1208,
14,
888,
492,
2198,
63,
888,
12,
5461,
63,
888,
199,
199,
9059,
63,
13931,
275,
469,
272,
283,
885,
63,
1130,
356,
469,
267,
283,
1065,
356,
469,
267,
789,
272,
789,
199,
93,
421,
199,
32,
4891,
14,
923,
8,
1100,
63,
1751,
29,
9059,
63,
13931,
9,
199,
32,
4891,
14,
1422,
3654,
86,
297,
2850,
3832,
297,
2338,
29,
549,
9,
199,
32,
4891,
14,
3437,
63,
1422,
3654,
72,
297,
2850,
3437,
358,
199,
32,
4891,
14,
1529,
63,
1100,
199,
318,
5053,
8,
3799,
12,
3376,
304,
272,
4027,
14,
1113,
905,
16075,
937,
275,
3376,
421,
199,
318,
16182,
63,
1494,
63,
4405,
837,
272,
687,
24659,
4468,
14,
1208,
14,
888,
492,
664,
63,
1494,
63,
2190,
272,
687,
24659,
4468,
14,
1494,
492,
20859,
63,
8816,
63,
4924,
272,
687,
24659,
4468,
14,
1208,
14,
2491,
63,
3676,
492,
492,
63,
1494,
272,
3413,
63,
888,
275,
664,
63,
1494,
63,
2190,
342,
339,
367,
3413,
63,
354,
12,
1101,
315,
3816,
14,
4611,
8,
1494,
63,
888,
459,
1494,
9090,
267,
340,
283,
773,
7,
315,
1101,
26,
288,
1973,
63,
354,
275,
1101,
905,
773,
937,
267,
587,
26,
288,
1973,
63,
354,
275,
298,
5098,
4468,
63,
1494,
63,
13536,
908,
8,
1494,
63,
354,
9,
267,
340,
440,
1101,
459,
3827,
2565,
288,
1980,
267,
862,
26,
288,
340,
3413,
63,
354,
315,
20859,
63,
8816,
63,
4924,
26,
355,
327,
16182,
2656,
3413,
355,
492,
63,
1494,
480,
5098,
4468,
14,
1494,
2122,
435,
1973,
63,
354,
9,
288,
587,
26,
355,
327,
16182,
10919,
1777,
3413,
355,
492,
63,
1494,
8,
773,
63,
354,
9,
267,
871,
2186,
465,
325,
26,
288,
986,
421,
199,
318,
2397,
63,
1403,
837,
272,
16182,
63,
1494,
63,
4405,
342,
339,
5053,
8,
1113,
21146,
421,
199,
32,
2764,
14,
1531,
342,
199,
32,
4891,
14,
1422,
3654,
68,
297,
2850,
576,
13,
6469,
13,
515,
297,
849,
29,
736,
14,
515,
14,
12131,
21114,
8083,
5098,
4468,
659,
730,
29,
4891,
14,
2042,
8,
493,
63,
745,
1187,
29,
797,
430,
199,
32,
4891,
14,
1422,
4517,
5508,
297,
283,
5508,
297,
730,
29,
4891,
14,
5353,
12,
849,
628,
3951,
63,
40,
796,
63,
12874,
531,
199,
318,
1678,
63,
6469,
8,
576,
63,
6469,
63,
515,
12,
5867,
304,
272,
408,
272,
22407,
3918,
29311,
272,
408,
272,
687,
24659,
4468,
492,
2446,
272,
2446,
14,
873,
63,
6469,
8,
576,
63,
6469,
63,
515,
12,
5867,
9,
421,
199,
32,
2764,
14,
1531,
342,
199,
32,
4891,
14,
3437,
63,
1422,
3654,
72,
297,
2850,
3437,
358,
199,
3,
1553,
3523,
11595,
199,
32,
4891,
14,
1422,
3654,
68,
297,
2850,
576,
13,
6469,
13,
515,
297,
283,
1095,
363,
576,
63,
6469,
63,
515,
297,
730,
29,
4891,
14,
2042,
8,
2444,
29,
549,
430,
199,
32,
4891,
14,
1422,
3654,
70,
297,
2850,
8590,
13,
493,
297,
283,
1095,
363,
8590,
63,
493,
297,
730,
29,
4891,
14,
2042,
8,
2444,
29,
549,
430,
199,
32,
4891,
14,
1422,
3654,
83,
297,
2850,
928,
13,
602,
297,
283,
1095,
363,
928,
63,
602,
297,
730,
29,
2506,
1012,
199,
32,
4891,
14,
1422,
3654,
69,
297,
2850,
500,
13,
602,
297,
283,
1095,
363,
500,
63,
602,
297,
730,
29,
2506,
1012,
199,
32,
4891,
14,
1422,
3654,
12648,
297,
2850,
11861,
297,
283,
1095,
363,
11861,
297,
730,
29,
4891,
14,
5353,
12,
849,
29,
403,
9,
199,
32,
4891,
14,
1422,
3654,
596,
297,
2850,
9650,
13,
15812,
297,
283,
1095,
363,
9650,
63,
15812,
297,
730,
29,
4891,
14,
11783,
9,
199,
32,
4891,
14,
1422,
3654,
65,
297,
2850,
2048,
297,
283,
1095,
363,
8370,
297,
9237,
29,
18,
12,
3663,
29,
549,
12,
1720,
628,
409,
2933,
730,
543,
6617,
286,
1119,
531,
199,
32,
4891,
14,
1422,
4517,
3124,
297,
283,
1095,
363,
826,
63,
12658,
297,
730,
29,
4891,
14,
5353,
12,
1720,
628,
409,
4205,
3421,
531,
199,
32,
4891,
14,
1422,
3654,
11878,
297,
2850,
11132,
297,
283,
1095,
363,
11132,
297,
730,
29,
4891,
14,
9054,
2941,
17,
68,
297,
283,
17,
77,
297,
283,
8284,
5156,
199,
32,
4891,
14,
1422,
3654,
2591,
297,
2850,
1065,
13,
466,
297,
283,
1095,
363,
1065,
63,
466,
297,
730,
29,
4891,
14,
9054,
2941,
66,
297,
283,
80,
297,
283,
82,
3815,
849,
628,
66,
531,
199,
32,
4891,
14,
1422,
3654,
4599,
297,
2850,
2363,
13,
4777,
297,
283,
1095,
363,
2363,
63,
4777,
297,
365,
63,
4173,
29,
549,
9,
199,
32,
4891,
14,
1422,
3654,
3880,
297,
2850,
22270,
297,
283,
1095,
363,
22270,
297,
730,
29,
4891,
14,
9054,
2941,
6413,
297,
283,
21557,
3815,
849,
29,
403,
9,
199,
32,
4891,
14,
1422,
4517,
9964,
297,
283,
1095,
363,
9964,
63,
632,
297,
365,
63,
4173,
29,
549,
9,
199,
32,
4891,
14,
1422,
4517,
1365,
13,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
MalloyPower/parsing-python
|
front-end/testsuite-python-lib/Python-2.4.3/Lib/encodings/__init__.py
|
14
|
4817
|
""" Standard "encodings" Package
Standard Python encoding modules are stored in this package
directory.
Codec modules must have names corresponding to normalized encoding
names as defined in the normalize_encoding() function below, e.g.
'utf-8' must be implemented by the module 'utf_8.py'.
Each codec module must export the following interface:
* getregentry() -> (encoder, decoder, stream_reader, stream_writer)
The getregentry() API must return callable objects which adhere to
the Python Codec Interface Standard.
In addition, a module may optionally also define the following
APIs which are then used by the package's codec search function:
* getaliases() -> sequence of encoding name strings to use as aliases
Alias names returned by getaliases() must be normalized encoding
names as defined by normalize_encoding().
Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""#"
import codecs, exceptions, types, aliases
_cache = {}
_unknown = '--unknown--'
_import_tail = ['*']
_norm_encoding_map = (' . '
'0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ '
' abcdefghijklmnopqrstuvwxyz '
' '
' '
' ')
_aliases = aliases.aliases
class CodecRegistryError(exceptions.LookupError,
exceptions.SystemError):
pass
def normalize_encoding(encoding):
""" Normalize an encoding name.
Normalization works as follows: all non-alphanumeric
characters except the dot used for Python package names are
collapsed and replaced with a single underscore, e.g. ' -;#'
becomes '_'. Leading and trailing underscores are removed.
Note that encoding names should be ASCII only; if they do use
non-ASCII characters, these must be Latin-1 compatible.
"""
# Make sure we have an 8-bit string, because .translate() works
# differently for Unicode strings.
if type(encoding) is types.UnicodeType:
# Note that .encode('latin-1') does *not* use the codec
# registry, so this call doesn't recurse. (See unicodeobject.c
# PyUnicode_AsEncodedString() for details)
encoding = encoding.encode('latin-1')
return '_'.join(encoding.translate(_norm_encoding_map).split())
def search_function(encoding):
# Cache lookup
entry = _cache.get(encoding, _unknown)
if entry is not _unknown:
return entry
# Import the module:
#
# First try to find an alias for the normalized encoding
# name and lookup the module using the aliased name, then try to
# lookup the module using the standard import scheme, i.e. first
# try in the encodings package, then at top-level.
#
norm_encoding = normalize_encoding(encoding)
aliased_encoding = _aliases.get(norm_encoding) or \
_aliases.get(norm_encoding.replace('.', '_'))
if aliased_encoding is not None:
modnames = [aliased_encoding,
norm_encoding]
else:
modnames = [norm_encoding]
for modname in modnames:
if not modname:
continue
try:
mod = __import__(modname,
globals(), locals(), _import_tail)
except ImportError:
pass
else:
break
else:
mod = None
try:
getregentry = mod.getregentry
except AttributeError:
# Not a codec module
mod = None
if mod is None:
# Cache misses
_cache[encoding] = None
return None
# Now ask the module for the registry entry
entry = tuple(getregentry())
if len(entry) != 4:
raise CodecRegistryError,\
'module "%s" (%s) failed to register' % \
(mod.__name__, mod.__file__)
for obj in entry:
if not callable(obj):
raise CodecRegistryError,\
'incompatible codecs in module "%s" (%s)' % \
(mod.__name__, mod.__file__)
# Cache the codec registry entry
_cache[encoding] = entry
# Register its aliases (without overwriting previously registered
# aliases)
try:
codecaliases = mod.getaliases()
except AttributeError:
pass
else:
for alias in codecaliases:
if not _aliases.has_key(alias):
_aliases[alias] = modname
# Return the registry entry
return entry
# Register the search_function in the Python codec registry
codecs.register(search_function)
|
mit
|
[
624,
9739,
298,
21138,
2,
15665,
339,
9739,
2018,
2644,
4621,
787,
5489,
315,
642,
2559,
272,
2082,
14,
339,
13732,
4621,
1471,
1172,
1561,
5226,
370,
9657,
2644,
272,
1561,
465,
3247,
315,
314,
7666,
63,
2991,
342,
805,
5084,
12,
325,
14,
71,
14,
272,
283,
1624,
13,
24,
7,
1471,
506,
6366,
701,
314,
859,
283,
1624,
63,
24,
14,
647,
1370,
339,
7048,
9076,
859,
1471,
4843,
314,
2569,
3217,
26,
339,
627,
26116,
342,
1035,
334,
9347,
12,
10334,
12,
2547,
63,
5503,
12,
2547,
63,
5491,
9,
272,
710,
26116,
342,
3261,
1471,
372,
4550,
2251,
1314,
1503,
1681,
370,
272,
314,
2018,
13732,
14816,
9739,
14,
339,
1010,
10234,
12,
282,
859,
1443,
14190,
2597,
5627,
314,
2569,
272,
15913,
1314,
787,
2066,
1202,
701,
314,
2559,
1159,
9076,
2754,
805,
26,
339,
627,
664,
8602,
342,
1035,
3414,
402,
2644,
536,
3326,
370,
675,
465,
5481,
339,
24777,
1561,
2138,
701,
664,
8602,
342,
1471,
506,
9657,
2644,
272,
1561,
465,
3247,
701,
7666,
63,
2991,
1252,
199,
199,
32329,
701,
603,
9912,
13,
3325,
264,
7005,
32649,
334,
2174,
32,
274,
32649,
14,
957,
680,
199,
199,
8,
67,
9,
1898,
445,
46,
6129,
12,
2900,
5924,
5702,
14,
4825,
3408,
14,
199,
199,
624,
23662,
199,
199,
646,
6010,
12,
4967,
12,
2943,
12,
5481,
199,
199,
63,
1637,
275,
1052,
199,
63,
5187,
275,
2850,
5187,
306,
7,
199,
63,
646,
63,
1521,
275,
788,
10,
418,
199,
63,
4791,
63,
2991,
63,
1130,
275,
661,
2476,
4519,
1275,
283,
1993,
283,
11371,
755,
17281,
5638,
39,
11183,
26490,
26018,
258,
283,
1993,
283,
13022,
318,
3561,
7879,
20701,
21832,
9326,
283,
1993,
283,
2476,
4483,
283,
1993,
283,
2476,
4483,
283,
1993,
283,
4483,
5320,
199,
63,
8602,
275,
5481,
14,
8602,
199,
199,
533,
13732,
10899,
547,
8,
3924,
14,
32060,
12,
586,
4967,
14,
3989,
547,
304,
272,
986,
199,
199,
318,
7666,
63,
2991,
8,
2991,
304,
339,
408,
21017,
376,
2644,
536,
14,
398,
11514,
2072,
5419,
465,
11924,
26,
1006,
2222,
13,
31119,
267,
4110,
871,
314,
6308,
1202,
367,
2018,
2559,
1561,
787,
267,
31219,
436,
8717,
543,
282,
2849,
18888,
12,
325,
14,
71,
14,
283,
221,
446,
27,
19367,
267,
15410,
2513,
1370,
7005,
5384,
436,
8520,
23998,
787,
4829,
14,
398,
3390,
626,
2644,
1561,
1077,
506,
10485,
1454,
27,
340,
2985,
886,
675,
267,
2222,
13,
12292,
4110,
12,
3520,
1471,
506,
23864,
13,
17,
9025,
14,
339,
408,
272,
327,
4155,
3238,
781,
1172,
376,
1695,
13,
2075,
1059,
12,
2952,
1275,
5275,
342,
5419,
272,
327,
23142,
367,
6140,
3326,
14,
272,
340,
730,
8,
2991,
9,
365,
2943,
14,
7087,
804,
26,
267,
327,
3390,
626,
1275,
2143,
360,
10378,
13,
17,
358,
1630,
627,
1397,
10,
675,
314,
9076,
267,
327,
7086,
12,
880,
642,
1240,
3181,
1133,
18011,
14,
334,
9295,
2649,
785,
14,
67,
267,
327,
1611,
7087,
63,
2822,
32149,
1558,
342,
367,
2436,
9,
267,
2644,
275,
2644,
14,
2143,
360,
10378,
13,
17,
358,
272,
372,
2513,
1370,
904,
8,
2991,
14,
5275,
1547,
4791,
63,
2991,
63,
1130,
680,
1294,
1012,
199,
199,
318,
2754,
63,
1593,
8,
2991,
304,
339,
327,
11977,
4237,
272,
2397,
275,
485,
1637,
14,
362,
8,
2991,
12,
485,
5187,
9,
272,
340,
2397,
365,
440,
485,
5187,
26,
267,
372,
2397,
339,
327,
3161,
314,
859,
26,
272,
327,
272,
327,
7758,
862,
370,
2342,
376,
5162,
367,
314,
9657,
2644,
272,
327,
536,
436,
4237,
314,
859,
1808,
314,
26642,
536,
12,
2066,
862,
370,
272,
327,
4237,
314,
859,
1808,
314,
4465,
492,
5687,
12,
284,
14,
69,
14,
1642,
272,
327,
862,
315,
314,
14134,
2559,
12,
2066,
737,
2746,
13,
1896,
14,
272,
327,
272,
6316,
63,
2991,
275,
7666,
63,
2991,
8,
2991,
9,
272,
26642,
63,
2991,
275,
485,
8602,
14,
362,
8,
4791,
63,
2991,
9,
503,
971,
2432,
485,
8602,
14,
362,
8,
4791,
63,
2991,
14,
1814,
14078,
2513,
1333,
272,
340,
26642,
63,
2991,
365,
440,
488,
26,
267,
3413,
1247,
275,
359,
26930,
63,
2991,
12,
490,
6316,
63,
2991,
61,
272,
587,
26,
267,
3413,
1247,
275,
359,
4791,
63,
2991,
61,
272,
367,
13526,
315,
3413,
1247,
26,
267,
340,
440,
13526,
26,
288,
1980,
267,
862,
26,
288,
3413,
275,
636,
646,
721,
14789,
12,
2490,
7992,
1062,
9480,
1062,
485,
646,
63,
1521,
9,
267,
871,
3545,
26,
288,
986,
267,
587,
26,
288,
2059,
272,
587,
26,
267,
3413,
275,
488,
339,
862,
26,
267,
26116,
275,
3413,
14,
362,
1135,
2373,
272,
871,
4281,
26,
267,
327,
2832,
282,
9076,
859,
267,
3413,
275,
488,
339,
340,
3413,
365,
488,
26,
267,
327,
11977,
3201,
874,
267,
485,
1637,
59,
2991,
61,
275,
488,
267,
372,
488,
339,
327,
7356,
7198,
314,
859,
367,
314,
7086,
2397,
272,
2397,
275,
2008,
8,
362,
1135,
2373,
1012,
272,
340,
822,
8,
2373,
9,
1137,
841,
26,
267,
746,
13732,
10899,
547,
4202,
1598,
283,
578,
2071,
83,
2,
4366,
83,
9,
3405,
370,
2274,
7,
450,
971,
1598,
334,
1494,
855,
354,
3108,
3413,
855,
493,
3368,
272,
367,
1559,
315,
2397,
26,
267,
340,
440,
4550,
8,
1113,
304,
288,
746,
13732,
10899,
547,
4202,
2116,
283,
31787,
6010,
315,
859,
2071,
83,
2,
4366,
83,
3171,
450,
971,
2116,
334,
1494,
855,
354,
3108,
3413,
855,
493,
3368,
339,
327,
11977,
314,
9076,
7086,
2397,
272,
485,
1637,
59,
2991,
61,
275,
2397,
339,
327,
11828,
2399,
5481,
334,
7395,
32592,
10889,
7264,
272,
327,
5481,
9,
272,
862,
26,
267,
1233,
915,
3994,
275,
3413,
14,
362,
8602,
342,
272,
871,
4281,
26,
267,
986,
272,
587,
26,
267,
367,
5162,
315,
1233,
915,
3994,
26,
288,
340,
440,
485,
8602,
14,
1989,
63,
498,
8,
3620,
304,
355,
485,
8602,
59,
3620,
61,
275,
13526,
339,
327,
1432,
314,
7086,
2397,
272,
372,
2397,
199,
199,
3,
11828,
314,
2754,
63,
1593,
315,
314,
2018,
9076,
7086,
199,
8933,
14,
2683,
8,
1733,
63,
1593
] |
[
9739,
298,
21138,
2,
15665,
339,
9739,
2018,
2644,
4621,
787,
5489,
315,
642,
2559,
272,
2082,
14,
339,
13732,
4621,
1471,
1172,
1561,
5226,
370,
9657,
2644,
272,
1561,
465,
3247,
315,
314,
7666,
63,
2991,
342,
805,
5084,
12,
325,
14,
71,
14,
272,
283,
1624,
13,
24,
7,
1471,
506,
6366,
701,
314,
859,
283,
1624,
63,
24,
14,
647,
1370,
339,
7048,
9076,
859,
1471,
4843,
314,
2569,
3217,
26,
339,
627,
26116,
342,
1035,
334,
9347,
12,
10334,
12,
2547,
63,
5503,
12,
2547,
63,
5491,
9,
272,
710,
26116,
342,
3261,
1471,
372,
4550,
2251,
1314,
1503,
1681,
370,
272,
314,
2018,
13732,
14816,
9739,
14,
339,
1010,
10234,
12,
282,
859,
1443,
14190,
2597,
5627,
314,
2569,
272,
15913,
1314,
787,
2066,
1202,
701,
314,
2559,
1159,
9076,
2754,
805,
26,
339,
627,
664,
8602,
342,
1035,
3414,
402,
2644,
536,
3326,
370,
675,
465,
5481,
339,
24777,
1561,
2138,
701,
664,
8602,
342,
1471,
506,
9657,
2644,
272,
1561,
465,
3247,
701,
7666,
63,
2991,
1252,
199,
199,
32329,
701,
603,
9912,
13,
3325,
264,
7005,
32649,
334,
2174,
32,
274,
32649,
14,
957,
680,
199,
199,
8,
67,
9,
1898,
445,
46,
6129,
12,
2900,
5924,
5702,
14,
4825,
3408,
14,
199,
199,
624,
23662,
199,
199,
646,
6010,
12,
4967,
12,
2943,
12,
5481,
199,
199,
63,
1637,
275,
1052,
199,
63,
5187,
275,
2850,
5187,
306,
7,
199,
63,
646,
63,
1521,
275,
788,
10,
418,
199,
63,
4791,
63,
2991,
63,
1130,
275,
661,
2476,
4519,
1275,
283,
1993,
283,
11371,
755,
17281,
5638,
39,
11183,
26490,
26018,
258,
283,
1993,
283,
13022,
318,
3561,
7879,
20701,
21832,
9326,
283,
1993,
283,
2476,
4483,
283,
1993,
283,
2476,
4483,
283,
1993,
283,
4483,
5320,
199,
63,
8602,
275,
5481,
14,
8602,
199,
199,
533,
13732,
10899,
547,
8,
3924,
14,
32060,
12,
586,
4967,
14,
3989,
547,
304,
272,
986,
199,
199,
318,
7666,
63,
2991,
8,
2991,
304,
339,
408,
21017,
376,
2644,
536,
14,
398,
11514,
2072,
5419,
465,
11924,
26,
1006,
2222,
13,
31119,
267,
4110,
871,
314,
6308,
1202,
367,
2018,
2559,
1561,
787,
267,
31219,
436,
8717,
543,
282,
2849,
18888,
12,
325,
14,
71,
14,
283,
221,
446,
27,
19367,
267,
15410,
2513,
1370,
7005,
5384,
436,
8520,
23998,
787,
4829,
14,
398,
3390,
626,
2644,
1561,
1077,
506,
10485,
1454,
27,
340,
2985,
886,
675,
267,
2222,
13,
12292,
4110,
12,
3520,
1471,
506,
23864,
13,
17,
9025,
14,
339,
408,
272,
327,
4155,
3238,
781,
1172,
376,
1695,
13,
2075,
1059,
12,
2952,
1275,
5275,
342,
5419,
272,
327,
23142,
367,
6140,
3326,
14,
272,
340,
730,
8,
2991,
9,
365,
2943,
14,
7087,
804,
26,
267,
327,
3390,
626,
1275,
2143,
360,
10378,
13,
17,
358,
1630,
627,
1397,
10,
675,
314,
9076,
267,
327,
7086,
12,
880,
642,
1240,
3181,
1133,
18011,
14,
334,
9295,
2649,
785,
14,
67,
267,
327,
1611,
7087,
63,
2822,
32149,
1558,
342,
367,
2436,
9,
267,
2644,
275,
2644,
14,
2143,
360,
10378,
13,
17,
358,
272,
372,
2513,
1370,
904,
8,
2991,
14,
5275,
1547,
4791,
63,
2991,
63,
1130,
680,
1294,
1012,
199,
199,
318,
2754,
63,
1593,
8,
2991,
304,
339,
327,
11977,
4237,
272,
2397,
275,
485,
1637,
14,
362,
8,
2991,
12,
485,
5187,
9,
272,
340,
2397,
365,
440,
485,
5187,
26,
267,
372,
2397,
339,
327,
3161,
314,
859,
26,
272,
327,
272,
327,
7758,
862,
370,
2342,
376,
5162,
367,
314,
9657,
2644,
272,
327,
536,
436,
4237,
314,
859,
1808,
314,
26642,
536,
12,
2066,
862,
370,
272,
327,
4237,
314,
859,
1808,
314,
4465,
492,
5687,
12,
284,
14,
69,
14,
1642,
272,
327,
862,
315,
314,
14134,
2559,
12,
2066,
737,
2746,
13,
1896,
14,
272,
327,
272,
6316,
63,
2991,
275,
7666,
63,
2991,
8,
2991,
9,
272,
26642,
63,
2991,
275,
485,
8602,
14,
362,
8,
4791,
63,
2991,
9,
503,
971,
2432,
485,
8602,
14,
362,
8,
4791,
63,
2991,
14,
1814,
14078,
2513,
1333,
272,
340,
26642,
63,
2991,
365,
440,
488,
26,
267,
3413,
1247,
275,
359,
26930,
63,
2991,
12,
490,
6316,
63,
2991,
61,
272,
587,
26,
267,
3413,
1247,
275,
359,
4791,
63,
2991,
61,
272,
367,
13526,
315,
3413,
1247,
26,
267,
340,
440,
13526,
26,
288,
1980,
267,
862,
26,
288,
3413,
275,
636,
646,
721,
14789,
12,
2490,
7992,
1062,
9480,
1062,
485,
646,
63,
1521,
9,
267,
871,
3545,
26,
288,
986,
267,
587,
26,
288,
2059,
272,
587,
26,
267,
3413,
275,
488,
339,
862,
26,
267,
26116,
275,
3413,
14,
362,
1135,
2373,
272,
871,
4281,
26,
267,
327,
2832,
282,
9076,
859,
267,
3413,
275,
488,
339,
340,
3413,
365,
488,
26,
267,
327,
11977,
3201,
874,
267,
485,
1637,
59,
2991,
61,
275,
488,
267,
372,
488,
339,
327,
7356,
7198,
314,
859,
367,
314,
7086,
2397,
272,
2397,
275,
2008,
8,
362,
1135,
2373,
1012,
272,
340,
822,
8,
2373,
9,
1137,
841,
26,
267,
746,
13732,
10899,
547,
4202,
1598,
283,
578,
2071,
83,
2,
4366,
83,
9,
3405,
370,
2274,
7,
450,
971,
1598,
334,
1494,
855,
354,
3108,
3413,
855,
493,
3368,
272,
367,
1559,
315,
2397,
26,
267,
340,
440,
4550,
8,
1113,
304,
288,
746,
13732,
10899,
547,
4202,
2116,
283,
31787,
6010,
315,
859,
2071,
83,
2,
4366,
83,
3171,
450,
971,
2116,
334,
1494,
855,
354,
3108,
3413,
855,
493,
3368,
339,
327,
11977,
314,
9076,
7086,
2397,
272,
485,
1637,
59,
2991,
61,
275,
2397,
339,
327,
11828,
2399,
5481,
334,
7395,
32592,
10889,
7264,
272,
327,
5481,
9,
272,
862,
26,
267,
1233,
915,
3994,
275,
3413,
14,
362,
8602,
342,
272,
871,
4281,
26,
267,
986,
272,
587,
26,
267,
367,
5162,
315,
1233,
915,
3994,
26,
288,
340,
440,
485,
8602,
14,
1989,
63,
498,
8,
3620,
304,
355,
485,
8602,
59,
3620,
61,
275,
13526,
339,
327,
1432,
314,
7086,
2397,
272,
372,
2397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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
] |
edx-solutions/edx-platform
|
openedx/core/djangoapps/oauth_dispatch/tests/mixins.py
|
4
|
3663
|
"""
OAuth Dispatch test mixins
"""
import jwt
from django.conf import settings
from jwkest.jwk import KEYS
from jwkest.jws import JWS
from jwt.exceptions import ExpiredSignatureError
from student.models import UserProfile, anonymous_id_for_user
class AccessTokenMixin(object):
""" Mixin for tests dealing with OAuth 2 access tokens. """
def assert_valid_jwt_access_token(self, access_token, user, scopes=None, should_be_expired=False, filters=None,
should_be_asymmetric_key=False, should_be_restricted=None, aud=None, secret=None):
"""
Verify the specified JWT access token is valid, and belongs to the specified user.
Returns:
dict: Decoded JWT payload
"""
scopes = scopes or []
audience = aud or settings.JWT_AUTH['JWT_AUDIENCE']
secret_key = secret or settings.JWT_AUTH['JWT_SECRET_KEY']
issuer = settings.JWT_AUTH['JWT_ISSUER']
def _decode_jwt(verify_expiration):
"""
Helper method to decode a JWT with the ability to
verify the expiration of said token
"""
keys = KEYS()
if should_be_asymmetric_key:
keys.load_jwks(settings.JWT_AUTH['JWT_PUBLIC_SIGNING_JWK_SET'])
else:
keys.add({'key': secret_key, 'kty': 'oct'})
_ = JWS().verify_compact(access_token.encode('utf-8'), keys)
return jwt.decode(
access_token,
secret_key,
algorithms=[settings.JWT_AUTH['JWT_ALGORITHM']],
audience=audience,
issuer=issuer,
verify_expiration=verify_expiration,
options={'verify_signature': False},
)
# Note that if we expect the claims to have expired
# then we ask the JWT library not to verify expiration
# as that would throw a ExpiredSignatureError and
# halt other verifications steps. We'll do a manual
# expiry verification later on
payload = _decode_jwt(verify_expiration=not should_be_expired)
expected = {
'aud': audience,
'iss': issuer,
'preferred_username': user.username,
'scopes': scopes,
'version': settings.JWT_AUTH['JWT_SUPPORTED_VERSION'],
'sub': anonymous_id_for_user(user, None),
'email_verified': user.is_active,
}
if 'user_id' in scopes:
expected['user_id'] = user.id
if 'email' in scopes:
expected['email'] = user.email
if 'profile' in scopes:
try:
name = UserProfile.objects.get(user=user).name
except UserProfile.DoesNotExist:
name = None
expected.update({
'name': name,
'administrator': user.is_staff,
'family_name': user.last_name,
'given_name': user.first_name,
})
if filters:
expected['filters'] = filters
if should_be_restricted is not None:
expected['is_restricted'] = should_be_restricted
self.assertDictContainsSubset(expected, payload)
# Since we suppressed checking of expiry
# in the claim in the above check, because we want
# to fully examine the claims outside of the expiry,
# now we should assert that the claim is indeed
# expired
if should_be_expired:
with self.assertRaises(ExpiredSignatureError):
_decode_jwt(verify_expiration=True)
return payload
|
agpl-3.0
|
[
624,
199,
12906,
28626,
511,
13667,
3617,
199,
624,
421,
199,
646,
1335,
9115,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1335,
87,
415,
270,
14,
74,
14947,
492,
9301,
51,
199,
504,
1335,
87,
415,
270,
14,
74,
3569,
492,
1603,
5035,
199,
504,
1335,
9115,
14,
3924,
492,
1316,
1038,
581,
10014,
547,
199,
199,
504,
6474,
14,
992,
492,
19037,
12,
16535,
63,
344,
63,
509,
63,
751,
421,
199,
533,
11003,
3264,
4256,
8,
785,
304,
272,
408,
28438,
367,
2295,
23654,
543,
11715,
499,
2879,
4645,
14,
408,
339,
347,
702,
63,
1078,
63,
30033,
63,
2732,
63,
1418,
8,
277,
12,
2879,
63,
1418,
12,
922,
12,
14570,
29,
403,
12,
1077,
63,
1235,
63,
16340,
29,
797,
12,
4766,
29,
403,
12,
4228,
1077,
63,
1235,
63,
5660,
77,
5165,
63,
498,
29,
797,
12,
1077,
63,
1235,
63,
17973,
29,
403,
12,
282,
1181,
29,
403,
12,
7565,
29,
403,
304,
267,
408,
267,
7635,
314,
2013,
1603,
21283,
2879,
1526,
365,
1686,
12,
436,
15006,
370,
314,
2013,
922,
14,
267,
1803,
26,
288,
1211,
26,
1487,
15282,
1603,
21283,
4886,
267,
408,
267,
14570,
275,
14570,
503,
942,
267,
10576,
328,
4894,
275,
282,
1181,
503,
2202,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
9331,
1914,
6013,
418,
267,
7565,
63,
498,
275,
7565,
503,
2202,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
12961,
63,
3078,
418,
267,
365,
20166,
275,
2202,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
1311,
6195,
540,
418,
398,
347,
485,
2708,
63,
30033,
8,
4712,
63,
15469,
304,
288,
408,
288,
11642,
1083,
370,
4849,
282,
1603,
21283,
543,
314,
21255,
370,
288,
4911,
314,
15399,
402,
25097,
1526,
288,
408,
288,
2883,
275,
9301,
51,
342,
288,
340,
1077,
63,
1235,
63,
5660,
77,
5165,
63,
498,
26,
355,
2883,
14,
912,
63,
30561,
6080,
8,
1751,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
19476,
63,
9396,
1206,
63,
42,
31005,
63,
3597,
1105,
288,
587,
26,
355,
2883,
14,
525,
3252,
498,
356,
7565,
63,
498,
12,
283,
75,
369,
356,
283,
15560,
3071,
953,
485,
275,
1603,
5035,
1252,
4712,
63,
23046,
8,
2732,
63,
1418,
14,
2143,
360,
1624,
13,
24,
659,
2883,
9,
953,
372,
1335,
9115,
14,
2708,
8,
355,
2879,
63,
1418,
12,
355,
7565,
63,
498,
12,
355,
18036,
1524,
1751,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
26613,
726,
1571,
45,
2157,
355,
10576,
328,
4894,
29,
23577,
4894,
12,
355,
365,
20166,
29,
26484,
12,
355,
4911,
63,
15469,
29,
4712,
63,
15469,
12,
355,
1511,
3713,
4712,
63,
5233,
356,
756,
1386,
288,
776,
398,
327,
3390,
626,
340,
781,
4282,
314,
6108,
11171,
370,
1172,
14721,
267,
327,
2066,
781,
7198,
314,
1603,
21283,
3555,
440,
370,
4911,
15399,
267,
327,
465,
626,
3955,
7978,
282,
1316,
1038,
581,
10014,
547,
436,
267,
327,
394,
4478,
1163,
14786,
83,
7124,
14,
2136,
7171,
886,
282,
8722,
267,
327,
23402,
14786,
2945,
641,
267,
4886,
275,
485,
2708,
63,
30033,
8,
4712,
63,
15469,
29,
1397,
1077,
63,
1235,
63,
16340,
9,
398,
1420,
275,
469,
288,
283,
32024,
356,
10576,
328,
4894,
12,
288,
283,
19857,
356,
365,
20166,
12,
288,
283,
17477,
63,
2473,
356,
922,
14,
2473,
12,
288,
283,
14129,
356,
14570,
12,
288,
283,
1023,
356,
2202,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
15925,
63,
4612,
995,
288,
283,
954,
356,
16535,
63,
344,
63,
509,
63,
751,
8,
751,
12,
488,
395,
288,
283,
2123,
63,
12949,
356,
922,
14,
374,
63,
2682,
12,
267,
789,
398,
340,
283,
751,
63,
344,
7,
315,
14570,
26,
288,
1420,
459,
751,
63,
344,
418,
275,
922,
14,
344,
398,
340,
283,
2123,
7,
315,
14570,
26,
288,
1420,
459,
2123,
418,
275,
922,
14,
2123,
398,
340,
283,
2913,
7,
315,
14570,
26,
288,
862,
26,
355,
536,
275,
19037,
14,
1462,
14,
362,
8,
751,
29,
751,
680,
354,
288,
871,
19037,
14,
7400,
26,
355,
536,
275,
488,
953,
1420,
14,
873,
2561,
355,
283,
354,
356,
536,
12,
355,
283,
2113,
14710,
356,
922,
14,
374,
63,
7018,
12,
355,
283,
6606,
63,
354,
356,
922,
14,
2019,
63,
354,
12,
355,
283,
11809,
63,
354,
356,
922,
14,
2246,
63,
354,
12,
288,
3828,
398,
340,
4766,
26,
288,
1420,
459,
4273,
418,
275,
4766,
398,
340,
1077,
63,
1235,
63,
17973,
365,
440,
488,
26,
288,
1420,
459,
374,
63,
17973,
418,
275,
1077,
63,
1235,
63,
17973,
398,
291,
14,
16443,
6906,
20113,
8,
2062,
12,
4886,
9,
398,
327,
9336,
781,
30581,
7907,
402,
23402,
267,
327,
315,
314,
22498,
315,
314,
3432,
1104,
12,
2952,
781,
2934,
267,
327,
370,
9999,
31758,
314,
6108,
11171,
9682,
402,
314,
23402,
12,
267,
327,
3063,
781,
1077,
702,
626,
314,
22498,
365,
31043,
379,
267,
327,
14721,
267,
340,
1077,
63,
1235,
63,
16340,
26,
288,
543,
291,
14,
1855,
8,
20898,
10014,
547,
304,
355,
485,
2708,
63,
30033,
8,
4712,
63,
15469,
29,
549,
9,
398,
372,
4886,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
12906,
28626,
511,
13667,
3617,
199,
624,
421,
199,
646,
1335,
9115,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1335,
87,
415,
270,
14,
74,
14947,
492,
9301,
51,
199,
504,
1335,
87,
415,
270,
14,
74,
3569,
492,
1603,
5035,
199,
504,
1335,
9115,
14,
3924,
492,
1316,
1038,
581,
10014,
547,
199,
199,
504,
6474,
14,
992,
492,
19037,
12,
16535,
63,
344,
63,
509,
63,
751,
421,
199,
533,
11003,
3264,
4256,
8,
785,
304,
272,
408,
28438,
367,
2295,
23654,
543,
11715,
499,
2879,
4645,
14,
408,
339,
347,
702,
63,
1078,
63,
30033,
63,
2732,
63,
1418,
8,
277,
12,
2879,
63,
1418,
12,
922,
12,
14570,
29,
403,
12,
1077,
63,
1235,
63,
16340,
29,
797,
12,
4766,
29,
403,
12,
4228,
1077,
63,
1235,
63,
5660,
77,
5165,
63,
498,
29,
797,
12,
1077,
63,
1235,
63,
17973,
29,
403,
12,
282,
1181,
29,
403,
12,
7565,
29,
403,
304,
267,
408,
267,
7635,
314,
2013,
1603,
21283,
2879,
1526,
365,
1686,
12,
436,
15006,
370,
314,
2013,
922,
14,
267,
1803,
26,
288,
1211,
26,
1487,
15282,
1603,
21283,
4886,
267,
408,
267,
14570,
275,
14570,
503,
942,
267,
10576,
328,
4894,
275,
282,
1181,
503,
2202,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
9331,
1914,
6013,
418,
267,
7565,
63,
498,
275,
7565,
503,
2202,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
12961,
63,
3078,
418,
267,
365,
20166,
275,
2202,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
1311,
6195,
540,
418,
398,
347,
485,
2708,
63,
30033,
8,
4712,
63,
15469,
304,
288,
408,
288,
11642,
1083,
370,
4849,
282,
1603,
21283,
543,
314,
21255,
370,
288,
4911,
314,
15399,
402,
25097,
1526,
288,
408,
288,
2883,
275,
9301,
51,
342,
288,
340,
1077,
63,
1235,
63,
5660,
77,
5165,
63,
498,
26,
355,
2883,
14,
912,
63,
30561,
6080,
8,
1751,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
19476,
63,
9396,
1206,
63,
42,
31005,
63,
3597,
1105,
288,
587,
26,
355,
2883,
14,
525,
3252,
498,
356,
7565,
63,
498,
12,
283,
75,
369,
356,
283,
15560,
3071,
953,
485,
275,
1603,
5035,
1252,
4712,
63,
23046,
8,
2732,
63,
1418,
14,
2143,
360,
1624,
13,
24,
659,
2883,
9,
953,
372,
1335,
9115,
14,
2708,
8,
355,
2879,
63,
1418,
12,
355,
7565,
63,
498,
12,
355,
18036,
1524,
1751,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
26613,
726,
1571,
45,
2157,
355,
10576,
328,
4894,
29,
23577,
4894,
12,
355,
365,
20166,
29,
26484,
12,
355,
4911,
63,
15469,
29,
4712,
63,
15469,
12,
355,
1511,
3713,
4712,
63,
5233,
356,
756,
1386,
288,
776,
398,
327,
3390,
626,
340,
781,
4282,
314,
6108,
11171,
370,
1172,
14721,
267,
327,
2066,
781,
7198,
314,
1603,
21283,
3555,
440,
370,
4911,
15399,
267,
327,
465,
626,
3955,
7978,
282,
1316,
1038,
581,
10014,
547,
436,
267,
327,
394,
4478,
1163,
14786,
83,
7124,
14,
2136,
7171,
886,
282,
8722,
267,
327,
23402,
14786,
2945,
641,
267,
4886,
275,
485,
2708,
63,
30033,
8,
4712,
63,
15469,
29,
1397,
1077,
63,
1235,
63,
16340,
9,
398,
1420,
275,
469,
288,
283,
32024,
356,
10576,
328,
4894,
12,
288,
283,
19857,
356,
365,
20166,
12,
288,
283,
17477,
63,
2473,
356,
922,
14,
2473,
12,
288,
283,
14129,
356,
14570,
12,
288,
283,
1023,
356,
2202,
14,
42,
21283,
63,
5580,
459,
42,
21283,
63,
15925,
63,
4612,
995,
288,
283,
954,
356,
16535,
63,
344,
63,
509,
63,
751,
8,
751,
12,
488,
395,
288,
283,
2123,
63,
12949,
356,
922,
14,
374,
63,
2682,
12,
267,
789,
398,
340,
283,
751,
63,
344,
7,
315,
14570,
26,
288,
1420,
459,
751,
63,
344,
418,
275,
922,
14,
344,
398,
340,
283,
2123,
7,
315,
14570,
26,
288,
1420,
459,
2123,
418,
275,
922,
14,
2123,
398,
340,
283,
2913,
7,
315,
14570,
26,
288,
862,
26,
355,
536,
275,
19037,
14,
1462,
14,
362,
8,
751,
29,
751,
680,
354,
288,
871,
19037,
14,
7400,
26,
355,
536,
275,
488,
953,
1420,
14,
873,
2561,
355,
283,
354,
356,
536,
12,
355,
283,
2113,
14710,
356,
922,
14,
374,
63,
7018,
12,
355,
283,
6606,
63,
354,
356,
922,
14,
2019,
63,
354,
12,
355,
283,
11809,
63,
354,
356,
922,
14,
2246,
63,
354,
12,
288,
3828,
398,
340,
4766,
26,
288,
1420,
459,
4273,
418,
275,
4766,
398,
340,
1077,
63,
1235,
63,
17973,
365,
440,
488,
26,
288,
1420,
459,
374,
63,
17973,
418,
275,
1077,
63,
1235,
63,
17973,
398,
291,
14,
16443,
6906,
20113,
8,
2062,
12,
4886,
9,
398,
327,
9336,
781,
30581,
7907,
402,
23402,
267,
327,
315,
314,
22498,
315,
314,
3432,
1104,
12,
2952,
781,
2934,
267,
327,
370,
9999,
31758,
314,
6108,
11171,
9682,
402,
314,
23402,
12,
267,
327,
3063,
781,
1077,
702,
626,
314,
22498,
365,
31043,
379,
267,
327,
14721,
267,
340,
1077,
63,
1235,
63,
16340,
26,
288,
543,
291,
14,
1855,
8,
20898,
10014,
547,
304,
355,
485,
2708,
63,
30033,
8,
4712,
63,
15469,
29,
549,
9,
398,
372,
4886,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
makinacorpus/odoo
|
addons/website_membership/models/product.py
|
338
|
1264
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import osv, fields
class product_template(osv.Model):
_inherit = 'product.template'
_columns = {
'website_published': fields.boolean('Available in the website', copy=False),
}
_defaults = {
'website_published': False,
}
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
6171,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
199,
533,
3336,
63,
1160,
8,
4795,
14,
1685,
304,
272,
485,
6486,
275,
283,
2558,
14,
1160,
7,
339,
485,
3406,
275,
469,
267,
283,
7360,
63,
8987,
356,
1504,
14,
4871,
360,
11464,
315,
314,
10691,
297,
1331,
29,
797,
395,
272,
789,
272,
485,
4322,
275,
469,
267,
283,
7360,
63,
8987,
356,
756,
12,
272,
789,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
6171,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
199,
533,
3336,
63,
1160,
8,
4795,
14,
1685,
304,
272,
485,
6486,
275,
283,
2558,
14,
1160,
7,
339,
485,
3406,
275,
469,
267,
283,
7360,
63,
8987,
356,
1504,
14,
4871,
360,
11464,
315,
314,
10691,
297,
1331,
29,
797,
395,
272,
789,
272,
485,
4322,
275,
469,
267,
283,
7360,
63,
8987,
356,
756,
12,
272,
789,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
samedder/azure-cli
|
src/command_modules/azure-cli-billing/setup.py
|
2
|
1983
|
#!/usr/bin/env python
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
from codecs import open
from setuptools import setup
try:
from azure_bdist_wheel import cmdclass
except ImportError:
from distutils import log as logger
logger.warn("Wheel is not available, disabling bdist_wheel hook")
cmdclass = {}
VERSION = "0.1.4+dev"
# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'License :: OSI Approved :: MIT License',
]
DEPENDENCIES = [
'azure-mgmt-billing==0.1.0',
'azure-cli-core'
]
with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
with open('HISTORY.rst', 'r', encoding='utf-8') as f:
HISTORY = f.read()
setup(
name='azure-cli-billing',
version=VERSION,
description='Microsoft Azure Command-Line Tools Billing Command Module',
long_description=README + '\n\n' + HISTORY,
license='MIT',
author='Microsoft Corporation',
author_email='azpycli@microsoft.com',
url='https://github.com/Azure/azure-cli',
classifiers=CLASSIFIERS,
packages=[
'azure',
'azure.cli',
'azure.cli.command_modules',
'azure.cli.command_modules.billing',
],
install_requires=DEPENDENCIES,
cmdclass=cmdclass,
)
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
5620,
777,
4559,
199,
3,
1898,
334,
67,
9,
15332,
11098,
14,
2900,
4481,
4644,
14,
199,
3,
3909,
1334,
314,
10697,
844,
14,
1666,
844,
14,
2424,
315,
314,
2199,
1738,
367,
4190,
2556,
14,
199,
3,
5620,
777,
4559,
421,
199,
504,
6010,
492,
1551,
199,
504,
9116,
492,
3272,
199,
893,
26,
272,
687,
13601,
63,
17403,
63,
11798,
492,
2088,
533,
199,
2590,
3545,
26,
272,
687,
7065,
492,
943,
465,
2512,
272,
2512,
14,
4050,
480,
25663,
365,
440,
2808,
12,
30723,
26308,
63,
11798,
5759,
531,
272,
2088,
533,
275,
1052,
421,
199,
4612,
275,
298,
16,
14,
17,
14,
20,
11,
2374,
2,
199,
3,
710,
2615,
769,
402,
19137,
365,
2808,
737,
199,
3,
4178,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
25790,
19,
33,
1287,
29,
513,
63,
27628,
199,
31163,
1976,
3960,
275,
359,
272,
283,
23753,
9795,
3800,
841,
446,
29521,
297,
272,
283,
23910,
23975,
3800,
23493,
297,
272,
283,
23910,
23975,
3800,
6187,
9516,
3075,
2750,
297,
272,
283,
11411,
8466,
3800,
2018,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
499,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
23,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
650,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
20,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
21,
297,
272,
283,
3761,
3800,
25718,
26330,
3800,
10697,
844,
297,
199,
61,
199,
199,
25743,
9415,
2563,
275,
359,
272,
283,
9078,
13,
9752,
13,
19929,
389,
16,
14,
17,
14,
16,
297,
272,
283,
9078,
13,
2764,
13,
1018,
7,
199,
61,
199,
199,
1045,
1551,
360,
18195,
14,
8332,
297,
283,
82,
297,
2644,
534,
1624,
13,
24,
358,
465,
289,
26,
272,
27781,
275,
289,
14,
739,
342,
199,
1045,
1551,
360,
30895,
14,
8332,
297,
283,
82,
297,
2644,
534,
1624,
13,
24,
358,
465,
289,
26,
272,
869,
6225,
5347,
275,
289,
14,
739,
342,
199,
199,
2758,
8,
272,
536,
534,
9078,
13,
2764,
13,
19929,
297,
272,
1015,
29,
4612,
12,
272,
1369,
534,
12940,
15474,
5817,
13,
3049,
23228,
699,
12687,
5817,
5673,
297,
272,
1846,
63,
1802,
29,
18195,
435,
1557,
78,
60,
78,
7,
435,
869,
6225,
5347,
12,
272,
4190,
534,
13965,
297,
272,
4132,
534,
12940,
11098,
297,
272,
4132,
63,
2123,
534,
4651,
647,
2764,
32,
17040,
14,
957,
297,
272,
1166,
534,
2859,
921,
5031,
14,
957,
15,
22386,
15,
9078,
13,
2764,
297,
272,
19137,
29,
31163,
1976,
3960,
12,
272,
6117,
1524,
267,
283,
9078,
297,
267,
283,
9078,
14,
2764,
297,
267,
283,
9078,
14,
2764,
14,
1531,
63,
3112,
297,
267,
283,
9078,
14,
2764,
14,
1531,
63,
3112,
14,
19929,
297,
272,
2156,
272,
3907,
63,
6537,
29,
25743,
9415,
2563,
12,
272,
2088,
533,
29,
1760,
533,
12,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
5620,
777,
4559,
199,
3,
1898,
334,
67,
9,
15332,
11098,
14,
2900,
4481,
4644,
14,
199,
3,
3909,
1334,
314,
10697,
844,
14,
1666,
844,
14,
2424,
315,
314,
2199,
1738,
367,
4190,
2556,
14,
199,
3,
5620,
777,
4559,
421,
199,
504,
6010,
492,
1551,
199,
504,
9116,
492,
3272,
199,
893,
26,
272,
687,
13601,
63,
17403,
63,
11798,
492,
2088,
533,
199,
2590,
3545,
26,
272,
687,
7065,
492,
943,
465,
2512,
272,
2512,
14,
4050,
480,
25663,
365,
440,
2808,
12,
30723,
26308,
63,
11798,
5759,
531,
272,
2088,
533,
275,
1052,
421,
199,
4612,
275,
298,
16,
14,
17,
14,
20,
11,
2374,
2,
199,
3,
710,
2615,
769,
402,
19137,
365,
2808,
737,
199,
3,
4178,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
25790,
19,
33,
1287,
29,
513,
63,
27628,
199,
31163,
1976,
3960,
275,
359,
272,
283,
23753,
9795,
3800,
841,
446,
29521,
297,
272,
283,
23910,
23975,
3800,
23493,
297,
272,
283,
23910,
23975,
3800,
6187,
9516,
3075,
2750,
297,
272,
283,
11411,
8466,
3800,
2018,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
499,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
23,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
650,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
20,
297,
272,
283,
11411,
8466,
3800,
2018,
3800,
650,
14,
21,
297,
272,
283,
3761,
3800,
25718,
26330,
3800,
10697,
844,
297,
199,
61,
199,
199,
25743,
9415,
2563,
275,
359,
272,
283,
9078,
13,
9752,
13,
19929,
389,
16,
14,
17,
14,
16,
297,
272,
283,
9078,
13,
2764,
13,
1018,
7,
199,
61,
199,
199,
1045,
1551,
360,
18195,
14,
8332,
297,
283,
82,
297,
2644,
534,
1624,
13,
24,
358,
465,
289,
26,
272,
27781,
275,
289,
14,
739,
342,
199,
1045,
1551,
360,
30895,
14,
8332,
297,
283,
82,
297,
2644,
534,
1624,
13,
24,
358,
465,
289,
26,
272,
869,
6225,
5347,
275,
289,
14,
739,
342,
199,
199,
2758,
8,
272,
536,
534,
9078,
13,
2764,
13,
19929,
297,
272,
1015,
29,
4612,
12,
272,
1369,
534,
12940,
15474,
5817,
13,
3049,
23228,
699,
12687,
5817,
5673,
297,
272,
1846,
63,
1802,
29,
18195,
435,
1557,
78,
60,
78,
7,
435,
869,
6225,
5347,
12,
272,
4190,
534,
13965,
297,
272,
4132,
534,
12940,
11098,
297,
272,
4132,
63,
2123,
534,
4651,
647,
2764,
32,
17040,
14,
957,
297,
272,
1166,
534,
2859,
921,
5031,
14,
957,
15,
22386,
15,
9078,
13,
2764,
297,
272,
19137,
29,
31163,
1976,
3960,
12,
272,
6117,
1524,
267,
283,
9078,
297,
267,
283,
9078,
14,
2764,
297,
267,
283,
9078,
14,
2764,
14,
1531,
63,
3112,
297,
267,
283,
9078,
14,
2764,
14,
1531,
63,
3112,
14,
19929,
297,
272,
2156,
272,
3907,
63,
6537,
29,
25743,
9415,
2563,
12,
272,
2088,
533,
29,
1760,
533,
12,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
NoelMacwan/SXDNickiCM11-OLD
|
scripts/gcc-wrapper.py
|
364
|
3936
|
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of The Linux Foundation nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Invoke gcc, looking for warnings, and causing a failure if there are
# non-whitelisted warnings.
import errno
import re
import os
import sys
import subprocess
# Note that gcc uses unicode, which may depend on the locale. TODO:
# force LANG to be set to en_US.UTF-8 to get consistent warnings.
allowed_warnings = set([
"alignment.c:327",
"mmu.c:602",
"return_address.c:62",
"swab.h:49",
"SemaLambda.cpp:946",
"CGObjCGNU.cpp:1414",
"BugReporter.h:146",
"RegionStore.cpp:1904",
"SymbolManager.cpp:484",
"RewriteObjCFoundationAPI.cpp:737",
"RewriteObjCFoundationAPI.cpp:696",
"CommentParser.cpp:394",
"CommentParser.cpp:391",
"CommentParser.cpp:356",
"LegalizeDAG.cpp:3646",
"IRBuilder.h:844",
"DataLayout.cpp:193",
"transport.c:653",
"xt_socket.c:307",
"xt_socket.c:161",
"inet_hashtables.h:356",
"xc4000.c:1049",
"xc4000.c:1063",
])
# Capture the name of the object file, can find it.
ofile = None
warning_re = re.compile(r'''(.*/|)([^/]+\.[a-z]+:\d+):(\d+:)? warning:''')
def interpret_warning(line):
"""Decode the message from gcc. The messages we care about have a filename, and a warning"""
line = line.rstrip('\n')
m = warning_re.match(line)
if m and m.group(2) not in allowed_warnings:
print "error, forbidden warning:", m.group(2)
# If there is a warning, remove any object if it exists.
if ofile:
try:
os.remove(ofile)
except OSError:
pass
sys.exit(1)
def run_gcc():
args = sys.argv[1:]
# Look for -o
try:
i = args.index('-o')
global ofile
ofile = args[i+1]
except (ValueError, IndexError):
pass
compiler = sys.argv[0]
try:
proc = subprocess.Popen(args, stderr=subprocess.PIPE)
for line in proc.stderr:
print line,
interpret_warning(line)
result = proc.wait()
except OSError as e:
result = e.errno
if result == errno.ENOENT:
print args[0] + ':',e.strerror
print 'Is your PATH set correctly?'
else:
print ' '.join(args), str(e)
return result
if __name__ == '__main__':
status = run_gcc()
sys.exit(status)
|
gpl-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
334,
67,
9,
7760,
13,
7409,
12,
710,
10130,
2752,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
755,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
710,
10130,
2752,
6590,
199,
3,
755,
314,
1561,
402,
2399,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
199,
3,
755,
7585,
7131,
687,
642,
2032,
1928,
2488,
6791,
5313,
199,
3,
755,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
5292,
2990,
1634,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
11214,
13,
12799,
9315,
9706,
14,
221,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
199,
3,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
199,
3,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
199,
3,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
199,
3,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
199,
3,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
199,
3,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
3,
31049,
19443,
12,
10023,
367,
3598,
12,
436,
25498,
282,
5988,
340,
2337,
787,
199,
3,
2222,
13,
7510,
15023,
3598,
14,
199,
199,
646,
7554,
199,
646,
295,
199,
646,
747,
199,
646,
984,
199,
646,
3873,
199,
199,
3,
3390,
626,
19443,
4440,
2649,
12,
1314,
1443,
11687,
641,
314,
5867,
14,
221,
3254,
26,
199,
3,
3542,
25029,
370,
506,
663,
370,
655,
63,
1668,
14,
6610,
13,
24,
370,
664,
12137,
3598,
14,
199,
199,
6541,
63,
5451,
275,
663,
779,
272,
298,
13699,
14,
67,
26,
11754,
401,
272,
298,
596,
85,
14,
67,
26,
28384,
401,
272,
298,
1107,
63,
1562,
14,
67,
26,
2789,
401,
199,
198,
2,
3519,
371,
14,
72,
26,
1887,
401,
2043,
298,
1513,
391,
21350,
14,
5910,
26,
30626,
401,
2043,
298,
4064,
5665,
4064,
1440,
14,
5910,
26,
1079,
1079,
401,
2043,
298,
17545,
15891,
14,
72,
26,
11432,
401,
2043,
298,
10708,
5502,
14,
5910,
26,
1167,
966,
401,
2043,
298,
8169,
2988,
14,
5910,
26,
29618,
401,
2043,
298,
497,
952,
5665,
35,
30216,
3735,
14,
5910,
26,
29045,
401,
2043,
298,
497,
952,
5665,
35,
30216,
3735,
14,
5910,
26,
15154,
401,
2043,
298,
7488,
2842,
14,
5910,
26,
13549,
401,
2043,
298,
7488,
2842,
14,
5910,
26,
16959,
401,
2043,
298,
7488,
2842,
14,
5910,
26,
13251,
401,
2043,
298,
13257,
279,
794,
28211,
14,
5910,
26,
19,
11387,
401,
2043,
298,
3927,
6437,
14,
72,
26,
16042,
401,
2043,
298,
1451,
4798,
14,
5910,
26,
13015,
401,
2043,
298,
5545,
14,
67,
26,
25401,
401,
2043,
298,
400,
63,
3450,
14,
67,
26,
11516,
401,
2043,
298,
400,
63,
3450,
14,
67,
26,
12285,
401,
2043,
298,
10811,
63,
1989,
517,
5921,
14,
72,
26,
13251,
401,
2043,
298,
1812,
23641,
14,
67,
26,
709,
1887,
401,
2043,
298,
1812,
23641,
14,
67,
26,
709,
2766,
401,
198,
199,
4794,
199,
199,
3,
29828,
314,
536,
402,
314,
909,
570,
12,
883,
2342,
652,
14,
199,
79,
493,
275,
488,
199,
199,
3764,
63,
264,
275,
295,
14,
2014,
8,
82,
2344,
19276,
15,
92,
9,
7059,
15251,
27658,
65,
13,
90,
2807,
3427,
68,
11,
304,
2961,
68,
11,
26,
5547,
5721,
26,
12310,
199,
318,
15579,
63,
3764,
8,
604,
304,
272,
408,
9400,
314,
1245,
687,
19443,
14,
221,
710,
3788,
781,
10296,
3595,
1172,
282,
1788,
12,
436,
282,
5721,
624,
272,
1004,
275,
1004,
14,
6735,
2258,
78,
358,
272,
333,
275,
5721,
63,
264,
14,
1431,
8,
604,
9,
272,
340,
333,
436,
333,
14,
923,
8,
18,
9,
440,
315,
4370,
63,
5451,
26,
267,
870,
298,
705,
12,
24786,
5721,
6783,
333,
14,
923,
8,
18,
9,
398,
327,
982,
2337,
365,
282,
5721,
12,
2813,
1263,
909,
340,
652,
3495,
14,
267,
340,
312,
493,
26,
288,
862,
26,
355,
747,
14,
2168,
8,
79,
493,
9,
288,
871,
6440,
26,
355,
986,
267,
984,
14,
2224,
8,
17,
9,
199,
199,
318,
1255,
63,
13112,
837,
272,
1249,
275,
984,
14,
3020,
59,
17,
2938,
272,
327,
12077,
367,
446,
79,
272,
862,
26,
267,
284,
275,
1249,
14,
1080,
3654,
79,
358,
267,
2288,
312,
493,
267,
312,
493,
275,
1249,
59,
73,
11,
17,
61,
272,
871,
334,
3393,
12,
7888,
304,
267,
986,
339,
6365,
275,
984,
14,
3020,
59,
16,
61,
339,
862,
26,
267,
6499,
275,
3873,
14,
7942,
8,
589,
12,
4635,
29,
5781,
14,
6089,
9,
267,
367,
1004,
315,
6499,
14,
3083,
26,
288,
870,
1004,
12,
288,
15579,
63,
3764,
8,
604,
9,
398,
754,
275,
6499,
14,
2573,
342,
272,
871,
6440,
465,
325,
26,
267,
754,
275,
325,
14,
7931,
267,
340,
754,
508,
7554,
14,
20465,
26,
288,
870,
1249,
59,
16,
61,
435,
25475,
69,
14,
20395,
288,
870,
283,
1831,
2195,
15097,
663,
6657,
14069,
267,
587,
26,
288,
870,
283,
1987,
904,
8,
589,
395,
620,
8,
69,
9,
339,
372,
754,
199,
199,
692,
636,
354,
363
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
334,
67,
9,
7760,
13,
7409,
12,
710,
10130,
2752,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
755,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
710,
10130,
2752,
6590,
199,
3,
755,
314,
1561,
402,
2399,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
199,
3,
755,
7585,
7131,
687,
642,
2032,
1928,
2488,
6791,
5313,
199,
3,
755,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
5292,
2990,
1634,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
11214,
13,
12799,
9315,
9706,
14,
221,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
199,
3,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
199,
3,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
199,
3,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
199,
3,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
199,
3,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
199,
3,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
3,
31049,
19443,
12,
10023,
367,
3598,
12,
436,
25498,
282,
5988,
340,
2337,
787,
199,
3,
2222,
13,
7510,
15023,
3598,
14,
199,
199,
646,
7554,
199,
646,
295,
199,
646,
747,
199,
646,
984,
199,
646,
3873,
199,
199,
3,
3390,
626,
19443,
4440,
2649,
12,
1314,
1443,
11687,
641,
314,
5867,
14,
221,
3254,
26,
199,
3,
3542,
25029,
370,
506,
663,
370,
655,
63,
1668,
14,
6610,
13,
24,
370,
664,
12137,
3598,
14,
199,
199,
6541,
63,
5451,
275,
663,
779,
272,
298,
13699,
14,
67,
26,
11754,
401,
272,
298,
596,
85,
14,
67,
26,
28384,
401,
272,
298,
1107,
63,
1562,
14,
67,
26,
2789,
401,
199,
198,
2,
3519,
371,
14,
72,
26,
1887,
401,
2043,
298,
1513,
391,
21350,
14,
5910,
26,
30626,
401,
2043,
298,
4064,
5665,
4064,
1440,
14,
5910,
26,
1079,
1079,
401,
2043,
298,
17545,
15891,
14,
72,
26,
11432,
401,
2043,
298,
10708,
5502,
14,
5910,
26,
1167,
966,
401,
2043,
298,
8169,
2988,
14,
5910,
26,
29618,
401,
2043,
298,
497,
952,
5665,
35,
30216,
3735,
14,
5910,
26,
29045,
401,
2043,
298,
497,
952,
5665,
35,
30216,
3735,
14,
5910,
26,
15154,
401,
2043,
298,
7488,
2842,
14,
5910,
26,
13549,
401,
2043,
298,
7488,
2842,
14,
5910,
26,
16959,
401,
2043,
298,
7488,
2842,
14,
5910,
26,
13251,
401,
2043,
298,
13257,
279,
794,
28211,
14,
5910,
26,
19,
11387,
401,
2043,
298,
3927,
6437,
14,
72,
26,
16042,
401,
2043,
298,
1451,
4798,
14,
5910,
26,
13015,
401,
2043,
298,
5545,
14,
67,
26,
25401,
401,
2043,
298,
400,
63,
3450,
14,
67,
26,
11516,
401,
2043,
298,
400,
63,
3450,
14,
67,
26,
12285,
401,
2043,
298,
10811,
63,
1989,
517,
5921,
14,
72,
26,
13251,
401,
2043,
298,
1812,
23641,
14,
67,
26,
709,
1887,
401,
2043,
298,
1812,
23641,
14,
67,
26,
709,
2766,
401,
198,
199,
4794,
199,
199,
3,
29828,
314,
536,
402,
314,
909,
570,
12,
883,
2342,
652,
14,
199,
79,
493,
275,
488,
199,
199,
3764,
63,
264,
275,
295,
14,
2014,
8,
82,
2344,
19276,
15,
92,
9,
7059,
15251,
27658,
65,
13,
90,
2807,
3427,
68,
11,
304,
2961,
68,
11,
26,
5547,
5721,
26,
12310,
199,
318,
15579,
63,
3764,
8,
604,
304,
272,
408,
9400,
314,
1245,
687,
19443,
14,
221,
710,
3788,
781,
10296,
3595,
1172,
282,
1788,
12,
436,
282,
5721,
624,
272,
1004,
275,
1004,
14,
6735,
2258,
78,
358,
272,
333,
275,
5721,
63,
264,
14,
1431,
8,
604,
9,
272,
340,
333,
436,
333,
14,
923,
8,
18,
9,
440,
315,
4370,
63,
5451,
26,
267,
870,
298,
705,
12,
24786,
5721,
6783,
333,
14,
923,
8,
18,
9,
398,
327,
982,
2337,
365,
282,
5721,
12,
2813,
1263,
909,
340,
652,
3495,
14,
267,
340,
312,
493,
26,
288,
862,
26,
355,
747,
14,
2168,
8,
79,
493,
9,
288,
871,
6440,
26,
355,
986,
267,
984,
14,
2224,
8,
17,
9,
199,
199,
318,
1255,
63,
13112,
837,
272,
1249,
275,
984,
14,
3020,
59,
17,
2938,
272,
327,
12077,
367,
446,
79,
272,
862,
26,
267,
284,
275,
1249,
14,
1080,
3654,
79,
358,
267,
2288,
312,
493,
267,
312,
493,
275,
1249,
59,
73,
11,
17,
61,
272,
871,
334,
3393,
12,
7888,
304,
267,
986,
339,
6365,
275,
984,
14,
3020,
59,
16,
61,
339,
862,
26,
267,
6499,
275,
3873,
14,
7942,
8,
589,
12,
4635,
29,
5781,
14,
6089,
9,
267,
367,
1004,
315,
6499,
14,
3083,
26,
288,
870,
1004,
12,
288,
15579,
63,
3764,
8,
604,
9,
398,
754,
275,
6499,
14,
2573,
342,
272,
871,
6440,
465,
325,
26,
267,
754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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
] |
PaulStoffregen/Arduino-1.6.0-Teensyduino
|
arduino-core/src/processing/app/i18n/python/requests/packages/charade/sbcharsetprober.py
|
2927
|
4793
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
# Shy Shalom - original C code
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
import sys
from . import constants
from .charsetprober import CharSetProber
from .compat import wrap_ord
SAMPLE_SIZE = 64
SB_ENOUGH_REL_THRESHOLD = 1024
POSITIVE_SHORTCUT_THRESHOLD = 0.95
NEGATIVE_SHORTCUT_THRESHOLD = 0.05
SYMBOL_CAT_ORDER = 250
NUMBER_OF_SEQ_CAT = 4
POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 1
#NEGATIVE_CAT = 0
class SingleByteCharSetProber(CharSetProber):
def __init__(self, model, reversed=False, nameProber=None):
CharSetProber.__init__(self)
self._mModel = model
# TRUE if we need to reverse every pair in the model lookup
self._mReversed = reversed
# Optional auxiliary prober for name decision
self._mNameProber = nameProber
self.reset()
def reset(self):
CharSetProber.reset(self)
# char order of last character
self._mLastOrder = 255
self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT
self._mTotalSeqs = 0
self._mTotalChar = 0
# characters that fall in our sampling range
self._mFreqChar = 0
def get_charset_name(self):
if self._mNameProber:
return self._mNameProber.get_charset_name()
else:
return self._mModel['charsetName']
def feed(self, aBuf):
if not self._mModel['keepEnglishLetter']:
aBuf = self.filter_without_english_letters(aBuf)
aLen = len(aBuf)
if not aLen:
return self.get_state()
for c in aBuf:
order = self._mModel['charToOrderMap'][wrap_ord(c)]
if order < SYMBOL_CAT_ORDER:
self._mTotalChar += 1
if order < SAMPLE_SIZE:
self._mFreqChar += 1
if self._mLastOrder < SAMPLE_SIZE:
self._mTotalSeqs += 1
if not self._mReversed:
i = (self._mLastOrder * SAMPLE_SIZE) + order
model = self._mModel['precedenceMatrix'][i]
else: # reverse the order of the letters in the lookup
i = (order * SAMPLE_SIZE) + self._mLastOrder
model = self._mModel['precedenceMatrix'][i]
self._mSeqCounters[model] += 1
self._mLastOrder = order
if self.get_state() == constants.eDetecting:
if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD:
cf = self.get_confidence()
if cf > POSITIVE_SHORTCUT_THRESHOLD:
if constants._debug:
sys.stderr.write('%s confidence = %s, we have a'
'winner\n' %
(self._mModel['charsetName'], cf))
self._mState = constants.eFoundIt
elif cf < NEGATIVE_SHORTCUT_THRESHOLD:
if constants._debug:
sys.stderr.write('%s confidence = %s, below negative'
'shortcut threshhold %s\n' %
(self._mModel['charsetName'], cf,
NEGATIVE_SHORTCUT_THRESHOLD))
self._mState = constants.eNotMe
return self.get_state()
def get_confidence(self):
r = 0.01
if self._mTotalSeqs > 0:
r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs
/ self._mModel['mTypicalPositiveRatio'])
r = r * self._mFreqChar / self._mTotalChar
if r >= 1.0:
r = 0.99
return r
|
lgpl-2.1
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
29347,
5960,
17842,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
12521,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
257,
428,
3577,
5244,
279,
676,
446,
3379,
445,
1233,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
646,
984,
199,
504,
1275,
492,
5262,
199,
504,
1275,
6043,
19903,
492,
31727,
199,
504,
1275,
5819,
492,
4816,
63,
2181,
199,
199,
15827,
63,
4305,
275,
5049,
199,
12463,
63,
15577,
10134,
40,
63,
13604,
63,
19307,
275,
6619,
199,
27998,
5399,
63,
13003,
24678,
63,
19307,
275,
378,
14,
2720,
199,
46,
23651,
63,
13003,
24678,
63,
19307,
275,
378,
14,
1717,
199,
10527,
63,
11206,
63,
12125,
275,
16074,
199,
9190,
63,
3359,
63,
28674,
63,
11206,
275,
841,
199,
27998,
5399,
63,
11206,
275,
18122,
63,
3359,
63,
28674,
63,
11206,
446,
413,
199,
3,
46,
23651,
63,
11206,
275,
378,
421,
199,
533,
13050,
21312,
8,
15159,
304,
272,
347,
636,
826,
721,
277,
12,
1402,
12,
10822,
29,
797,
12,
536,
8029,
29,
403,
304,
267,
31727,
855,
826,
721,
277,
9,
267,
291,
423,
77,
1685,
275,
1402,
267,
327,
9074,
4187,
340,
781,
1929,
370,
3837,
4036,
4092,
315,
314,
1402,
4237,
267,
291,
423,
77,
497,
7460,
275,
10822,
267,
327,
4879,
31407,
16118,
367,
536,
14692,
267,
291,
423,
77,
985,
8029,
275,
536,
8029,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
31727,
14,
3958,
8,
277,
9,
267,
327,
1495,
1865,
402,
2061,
4528,
267,
291,
423,
27329,
4738,
275,
5450,
267,
291,
423,
77,
11205,
24532,
878,
275,
359,
16,
61,
627,
18122,
63,
3359,
63,
28674,
63,
11206,
267,
291,
423,
77,
7316,
1513,
6177,
275,
378,
267,
291,
423,
77,
7316,
1610,
275,
378,
267,
327,
4110,
626,
11264,
315,
4154,
15877,
1425,
267,
291,
423,
77,
13875,
1610,
275,
378,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
340,
291,
423,
77,
985,
8029,
26,
288,
372,
291,
423,
77,
985,
8029,
14,
362,
63,
6043,
63,
354,
342,
267,
587,
26,
288,
372,
291,
423,
77,
1685,
459,
6043,
985,
418,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
340,
440,
291,
423,
77,
1685,
459,
3250,
19410,
23496,
2565,
288,
17407,
275,
291,
14,
1541,
63,
7395,
63,
17872,
63,
16415,
8,
22353,
9,
267,
282,
3166,
275,
822,
8,
22353,
9,
267,
340,
440,
282,
3166,
26,
288,
372,
291,
14,
362,
63,
929,
342,
267,
367,
286,
315,
17407,
26,
288,
1865,
275,
291,
423,
77,
1685,
459,
1560,
1378,
19409,
3488,
3823,
63,
2181,
8,
67,
1874,
288,
340,
1865,
665,
10046,
9903,
63,
11206,
63,
12125,
26,
355,
291,
423,
77,
7316,
1610,
847,
413,
288,
340,
1865,
665,
428,
10818,
63,
4305,
26,
355,
291,
423,
77,
13875,
1610,
847,
413,
355,
340,
291,
423,
27329,
4738,
665,
428,
10818,
63,
4305,
26,
490,
291,
423,
77,
7316,
1513,
6177,
847,
413,
490,
340,
440,
291,
423,
77,
497,
7460,
26,
717,
284,
275,
334,
277,
423,
27329,
4738,
627,
428,
10818,
63,
4305,
9,
435,
1865,
717,
1402,
275,
291,
423,
77,
1685,
459,
19571,
6443,
3488,
73,
61,
490,
587,
26,
221,
327,
3837,
314,
1865,
402,
314,
14435,
315,
314,
4237,
717,
284,
275,
334,
1648,
627,
428,
10818,
63,
4305,
9,
435,
291,
423,
27329,
4738,
717,
1402,
275,
291,
423,
77,
1685,
459,
19571,
6443,
3488,
73,
61,
490,
291,
423,
77,
11205,
24532,
878,
59,
1238,
61,
847,
413,
288,
291,
423,
27329,
4738,
275,
1865,
398,
340,
291,
14,
362,
63,
929,
342,
508,
5262,
14,
69,
20064,
316,
26,
288,
340,
291,
423,
77,
7316,
1513,
6177,
690,
26811,
63,
15577,
10134,
40,
63,
13604,
63,
19307,
26,
355,
3980,
275,
291,
14,
362,
63,
13969,
342,
355,
340,
3980,
690,
510,
3100,
649,
5399,
63,
13003,
24678,
63,
19307,
26,
490,
340,
5262,
423,
1757,
26,
717,
984,
14,
3083,
14,
952,
3508,
83,
15197,
275,
450,
83,
12,
781,
1172,
282,
7,
1460,
283,
2676,
1372,
60,
78,
7,
450,
1460,
334,
277,
423,
77,
1685,
459,
6043,
985,
995,
3980,
430,
490,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
355,
916,
3980,
665,
29837,
63,
13003,
24678,
63,
19307,
26,
490,
340,
5262,
423,
1757,
26,
717,
984,
14,
3083,
14,
952,
3508,
83,
15197,
275,
450,
83,
12,
5084,
6946,
7,
1460,
283,
24231,
16126,
12239,
450,
83,
60,
78,
7,
450,
1460,
334,
277,
423,
77,
1685,
459,
6043,
985,
995,
3980,
12,
5101,
29837,
63,
13003,
24678,
63,
19307,
430,
490,
291,
423,
31984,
275,
5262,
14,
69,
1763,
1352,
398,
372,
291,
14,
362,
63,
929,
342,
339,
347,
664,
63,
13969,
8,
277,
304,
267,
519,
275
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
29347,
5960,
17842,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
12521,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
257,
428,
3577,
5244,
279,
676,
446,
3379,
445,
1233,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
646,
984,
199,
504,
1275,
492,
5262,
199,
504,
1275,
6043,
19903,
492,
31727,
199,
504,
1275,
5819,
492,
4816,
63,
2181,
199,
199,
15827,
63,
4305,
275,
5049,
199,
12463,
63,
15577,
10134,
40,
63,
13604,
63,
19307,
275,
6619,
199,
27998,
5399,
63,
13003,
24678,
63,
19307,
275,
378,
14,
2720,
199,
46,
23651,
63,
13003,
24678,
63,
19307,
275,
378,
14,
1717,
199,
10527,
63,
11206,
63,
12125,
275,
16074,
199,
9190,
63,
3359,
63,
28674,
63,
11206,
275,
841,
199,
27998,
5399,
63,
11206,
275,
18122,
63,
3359,
63,
28674,
63,
11206,
446,
413,
199,
3,
46,
23651,
63,
11206,
275,
378,
421,
199,
533,
13050,
21312,
8,
15159,
304,
272,
347,
636,
826,
721,
277,
12,
1402,
12,
10822,
29,
797,
12,
536,
8029,
29,
403,
304,
267,
31727,
855,
826,
721,
277,
9,
267,
291,
423,
77,
1685,
275,
1402,
267,
327,
9074,
4187,
340,
781,
1929,
370,
3837,
4036,
4092,
315,
314,
1402,
4237,
267,
291,
423,
77,
497,
7460,
275,
10822,
267,
327,
4879,
31407,
16118,
367,
536,
14692,
267,
291,
423,
77,
985,
8029,
275,
536,
8029,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
31727,
14,
3958,
8,
277,
9,
267,
327,
1495,
1865,
402,
2061,
4528,
267,
291,
423,
27329,
4738,
275,
5450,
267,
291,
423,
77,
11205,
24532,
878,
275,
359,
16,
61,
627,
18122,
63,
3359,
63,
28674,
63,
11206,
267,
291,
423,
77,
7316,
1513,
6177,
275,
378,
267,
291,
423,
77,
7316,
1610,
275,
378,
267,
327,
4110,
626,
11264,
315,
4154,
15877,
1425,
267,
291,
423,
77,
13875,
1610,
275,
378,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
340,
291,
423,
77,
985,
8029,
26,
288,
372,
291,
423,
77,
985,
8029,
14,
362,
63,
6043,
63,
354,
342,
267,
587,
26,
288,
372,
291,
423,
77,
1685,
459,
6043,
985,
418,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
340,
440,
291,
423,
77,
1685,
459,
3250,
19410,
23496,
2565,
288,
17407,
275,
291,
14,
1541,
63,
7395,
63,
17872,
63,
16415,
8,
22353,
9,
267,
282,
3166,
275,
822,
8,
22353,
9,
267,
340,
440,
282,
3166,
26,
288,
372,
291,
14,
362,
63,
929,
342,
267,
367,
286,
315,
17407,
26,
288,
1865,
275,
291,
423,
77,
1685,
459,
1560,
1378,
19409,
3488,
3823,
63,
2181,
8,
67,
1874,
288,
340,
1865,
665,
10046,
9903,
63,
11206,
63,
12125,
26,
355,
291,
423,
77,
7316,
1610,
847,
413,
288,
340,
1865,
665,
428,
10818,
63,
4305,
26,
355,
291,
423,
77,
13875,
1610,
847,
413,
355,
340,
291,
423,
27329,
4738,
665,
428,
10818,
63,
4305,
26,
490,
291,
423,
77,
7316,
1513,
6177,
847,
413,
490,
340,
440,
291,
423,
77,
497,
7460,
26,
717,
284,
275,
334,
277,
423,
27329,
4738,
627,
428,
10818,
63,
4305,
9,
435,
1865,
717,
1402,
275,
291,
423,
77,
1685,
459,
19571,
6443,
3488,
73,
61,
490,
587,
26,
221,
327,
3837,
314,
1865,
402,
314,
14435,
315,
314,
4237,
717,
284,
275,
334,
1648,
627,
428,
10818,
63,
4305,
9,
435,
291,
423,
27329,
4738,
717,
1402,
275,
291,
423,
77,
1685,
459,
19571,
6443,
3488,
73,
61,
490,
291,
423,
77,
11205,
24532,
878,
59,
1238,
61,
847,
413,
288,
291,
423,
27329,
4738,
275,
1865,
398,
340,
291,
14,
362,
63,
929,
342,
508,
5262,
14,
69,
20064,
316,
26,
288,
340,
291,
423,
77,
7316,
1513,
6177,
690,
26811,
63,
15577,
10134,
40,
63,
13604,
63,
19307,
26,
355,
3980,
275,
291,
14,
362,
63,
13969,
342,
355,
340,
3980,
690,
510,
3100,
649,
5399,
63,
13003,
24678,
63,
19307,
26,
490,
340,
5262,
423,
1757,
26,
717,
984,
14,
3083,
14,
952,
3508,
83,
15197,
275,
450,
83,
12,
781,
1172,
282,
7,
1460,
283,
2676,
1372,
60,
78,
7,
450,
1460,
334,
277,
423,
77,
1685,
459,
6043,
985,
995,
3980,
430,
490,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
355,
916,
3980,
665,
29837,
63,
13003,
24678,
63,
19307,
26,
490,
340,
5262,
423,
1757,
26,
717,
984,
14,
3083,
14,
952,
3508,
83,
15197,
275,
450,
83,
12,
5084,
6946,
7,
1460,
283,
24231,
16126,
12239,
450,
83,
60,
78,
7,
450,
1460,
334,
277,
423,
77,
1685,
459,
6043,
985,
995,
3980,
12,
5101,
29837,
63,
13003,
24678,
63,
19307,
430,
490,
291,
423,
31984,
275,
5262,
14,
69,
1763,
1352,
398,
372,
291,
14,
362,
63,
929,
342,
339,
347,
664,
63,
13969,
8,
277,
304,
267,
519,
275,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
xfournet/intellij-community
|
python/lib/Lib/site-packages/django/contrib/gis/geometry/test_data.py
|
364
|
2994
|
"""
This module has the mock object definitions used to hold reference geometry
for the GEOS and GDAL tests.
"""
import gzip
import os
from django.contrib import gis
from django.utils import simplejson
# This global used to store reference geometry data.
GEOMETRIES = None
# Path where reference test data is located.
TEST_DATA = os.path.join(os.path.dirname(gis.__file__), 'tests', 'data')
def tuplize(seq):
"Turn all nested sequences to tuples in given sequence."
if isinstance(seq, (list, tuple)):
return tuple([tuplize(i) for i in seq])
return seq
def strconvert(d):
"Converts all keys in dictionary to str type."
return dict([(str(k), v) for k, v in d.iteritems()])
def get_ds_file(name, ext):
return os.path.join(TEST_DATA,
name,
name + '.%s' % ext
)
class TestObj(object):
"""
Base testing object, turns keyword args into attributes.
"""
def __init__(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
class TestDS(TestObj):
"""
Object for testing GDAL data sources.
"""
def __init__(self, name, **kwargs):
# Shapefile is default extension, unless specified otherwise.
ext = kwargs.pop('ext', 'shp')
self.ds = get_ds_file(name, ext)
super(TestDS, self).__init__(**kwargs)
class TestGeom(TestObj):
"""
Testing object used for wrapping reference geometry data
in GEOS/GDAL tests.
"""
def __init__(self, **kwargs):
# Converting lists to tuples of certain keyword args
# so coordinate test cases will match (JSON has no
# concept of tuple).
coords = kwargs.pop('coords', None)
if coords:
self.coords = tuplize(coords)
centroid = kwargs.pop('centroid', None)
if centroid:
self.centroid = tuple(centroid)
ext_ring_cs = kwargs.pop('ext_ring_cs', None)
if ext_ring_cs:
ext_ring_cs = tuplize(ext_ring_cs)
self.ext_ring_cs = ext_ring_cs
super(TestGeom, self).__init__(**kwargs)
class TestGeomSet(object):
"""
Each attribute of this object is a list of `TestGeom` instances.
"""
def __init__(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, [TestGeom(**strconvert(kw)) for kw in value])
class TestDataMixin(object):
"""
Mixin used for GEOS/GDAL test cases that defines a `geometries`
property, which returns and/or loads the reference geometry data.
"""
@property
def geometries(self):
global GEOMETRIES
if GEOMETRIES is None:
# Load up the test geometry data from fixture into global.
gzf = gzip.GzipFile(os.path.join(TEST_DATA, 'geometries.json.gz'))
geometries = simplejson.loads(gzf.read())
GEOMETRIES = TestGeomSet(**strconvert(geometries))
return GEOMETRIES
|
apache-2.0
|
[
624,
199,
2765,
859,
965,
314,
1683,
909,
10269,
1202,
370,
10266,
3659,
3400,
199,
509,
314,
11920,
436,
15801,
2295,
14,
199,
624,
199,
646,
11756,
199,
646,
747,
199,
199,
504,
1639,
14,
2828,
492,
486,
374,
199,
504,
1639,
14,
1208,
492,
13804,
421,
199,
3,
961,
2288,
1202,
370,
3877,
3659,
3400,
666,
14,
199,
18120,
3940,
23359,
275,
488,
199,
199,
3,
6912,
2382,
3659,
511,
666,
365,
16180,
14,
199,
2864,
63,
3998,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
5668,
855,
493,
10139,
283,
2219,
297,
283,
576,
358,
421,
199,
318,
16477,
13559,
8,
3610,
304,
272,
298,
16838,
1006,
6032,
8013,
370,
6346,
315,
1627,
3414,
2122,
272,
340,
1228,
8,
3610,
12,
334,
513,
12,
2008,
2298,
267,
372,
2008,
779,
17034,
13559,
8,
73,
9,
367,
284,
315,
5412,
566,
272,
372,
5412,
421,
199,
318,
620,
3916,
8,
68,
304,
272,
298,
17729,
1006,
2883,
315,
2600,
370,
620,
730,
2122,
272,
372,
1211,
7694,
495,
8,
75,
395,
373,
9,
367,
1022,
12,
373,
315,
366,
14,
4611,
9383,
421,
199,
318,
664,
63,
795,
63,
493,
8,
354,
12,
1599,
304,
272,
372,
747,
14,
515,
14,
904,
8,
2864,
63,
3998,
12,
717,
536,
12,
717,
536,
435,
1987,
5,
83,
7,
450,
1599,
717,
776,
421,
199,
533,
1379,
5665,
8,
785,
304,
272,
408,
272,
3523,
5343,
909,
12,
25449,
4252,
1249,
1901,
3004,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
367,
790,
12,
574,
315,
2074,
14,
1744,
837,
288,
5371,
8,
277,
12,
790,
12,
574,
9,
421,
199,
533,
1379,
3177,
8,
774,
5665,
304,
272,
408,
272,
6935,
367,
5343,
15801,
666,
5274,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
536,
12,
1011,
958,
304,
267,
327,
16528,
493,
365,
849,
3329,
12,
7444,
2013,
4257,
14,
267,
1599,
275,
2074,
14,
1935,
360,
832,
297,
283,
17299,
358,
267,
291,
14,
795,
275,
664,
63,
795,
63,
493,
8,
354,
12,
1599,
9,
267,
1613,
8,
774,
3177,
12,
291,
2843,
826,
14155,
958,
9,
421,
199,
533,
1379,
13427,
8,
774,
5665,
304,
272,
408,
272,
11940,
909,
1202,
367,
19696,
3659,
3400,
666,
272,
315,
11920,
15,
17835,
2295,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
327,
23258,
5548,
370,
6346,
402,
9842,
4252,
1249,
267,
327,
880,
10021,
511,
5560,
911,
1336,
334,
6243,
965,
949,
267,
327,
19834,
402,
2008,
680,
267,
13259,
275,
2074,
14,
1935,
360,
8032,
297,
488,
9,
267,
340,
13259,
26,
288,
291,
14,
8032,
275,
16477,
13559,
8,
8032,
9,
398,
27587,
275,
2074,
14,
1935,
360,
22098,
297,
488,
9,
267,
340,
27587,
26,
288,
291,
14,
22098,
275,
2008,
8,
22098,
9,
398,
1599,
63,
5985,
63,
1259,
275,
2074,
14,
1935,
360,
832,
63,
5985,
63,
1259,
297,
488,
9,
267,
340,
1599,
63,
5985,
63,
1259,
26,
288,
1599,
63,
5985,
63,
1259,
275,
16477,
13559,
8,
832,
63,
5985,
63,
1259,
9,
267,
291,
14,
832,
63,
5985,
63,
1259,
275,
1599,
63,
5985,
63,
1259,
398,
1613,
8,
774,
13427,
12,
291,
2843,
826,
14155,
958,
9,
421,
199,
533,
1379,
13427,
1084,
8,
785,
304,
272,
408,
272,
7048,
2225,
402,
642,
909,
365,
282,
769,
402,
658,
774,
13427,
64,
4454,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
367,
790,
12,
574,
315,
2074,
14,
1744,
837,
288,
5371,
8,
277,
12,
790,
12,
359,
774,
13427,
3682,
495,
3916,
8,
829,
430,
367,
4775,
315,
574,
566,
421,
199,
533,
1379,
1451,
4256,
8,
785,
304,
272,
408,
272,
28438,
1202,
367,
11920,
15,
17835,
511,
5560,
626,
7890,
282,
658,
21626,
64,
272,
3324,
12,
1314,
2529,
436,
15,
269,
14404,
314,
3659,
3400,
666,
14,
272,
408,
272,
768,
1829,
272,
347,
24883,
8,
277,
304,
267,
2288,
21390,
3940,
23359,
267,
340,
21390,
3940,
23359,
365,
488,
26,
288,
327,
7190,
1536,
314,
511,
3400,
666,
687,
10949,
1901,
2288,
14,
288,
486,
20127,
275,
11756,
14,
29827,
8,
736,
14,
515,
14,
904,
8,
2864,
63,
3998,
12,
283,
21626,
14,
1001,
14,
6838,
1333,
288,
24883,
275,
13804,
14,
3640,
8,
6838,
70,
14,
739,
1012,
288,
21390,
3940,
23359,
275,
1379,
13427,
1084,
3682,
495,
3916,
8,
21626,
430,
267,
372,
21390,
3940,
23359,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
2765,
859,
965,
314,
1683,
909,
10269,
1202,
370,
10266,
3659,
3400,
199,
509,
314,
11920,
436,
15801,
2295,
14,
199,
624,
199,
646,
11756,
199,
646,
747,
199,
199,
504,
1639,
14,
2828,
492,
486,
374,
199,
504,
1639,
14,
1208,
492,
13804,
421,
199,
3,
961,
2288,
1202,
370,
3877,
3659,
3400,
666,
14,
199,
18120,
3940,
23359,
275,
488,
199,
199,
3,
6912,
2382,
3659,
511,
666,
365,
16180,
14,
199,
2864,
63,
3998,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
5668,
855,
493,
10139,
283,
2219,
297,
283,
576,
358,
421,
199,
318,
16477,
13559,
8,
3610,
304,
272,
298,
16838,
1006,
6032,
8013,
370,
6346,
315,
1627,
3414,
2122,
272,
340,
1228,
8,
3610,
12,
334,
513,
12,
2008,
2298,
267,
372,
2008,
779,
17034,
13559,
8,
73,
9,
367,
284,
315,
5412,
566,
272,
372,
5412,
421,
199,
318,
620,
3916,
8,
68,
304,
272,
298,
17729,
1006,
2883,
315,
2600,
370,
620,
730,
2122,
272,
372,
1211,
7694,
495,
8,
75,
395,
373,
9,
367,
1022,
12,
373,
315,
366,
14,
4611,
9383,
421,
199,
318,
664,
63,
795,
63,
493,
8,
354,
12,
1599,
304,
272,
372,
747,
14,
515,
14,
904,
8,
2864,
63,
3998,
12,
717,
536,
12,
717,
536,
435,
1987,
5,
83,
7,
450,
1599,
717,
776,
421,
199,
533,
1379,
5665,
8,
785,
304,
272,
408,
272,
3523,
5343,
909,
12,
25449,
4252,
1249,
1901,
3004,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
367,
790,
12,
574,
315,
2074,
14,
1744,
837,
288,
5371,
8,
277,
12,
790,
12,
574,
9,
421,
199,
533,
1379,
3177,
8,
774,
5665,
304,
272,
408,
272,
6935,
367,
5343,
15801,
666,
5274,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
536,
12,
1011,
958,
304,
267,
327,
16528,
493,
365,
849,
3329,
12,
7444,
2013,
4257,
14,
267,
1599,
275,
2074,
14,
1935,
360,
832,
297,
283,
17299,
358,
267,
291,
14,
795,
275,
664,
63,
795,
63,
493,
8,
354,
12,
1599,
9,
267,
1613,
8,
774,
3177,
12,
291,
2843,
826,
14155,
958,
9,
421,
199,
533,
1379,
13427,
8,
774,
5665,
304,
272,
408,
272,
11940,
909,
1202,
367,
19696,
3659,
3400,
666,
272,
315,
11920,
15,
17835,
2295,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
327,
23258,
5548,
370,
6346,
402,
9842,
4252,
1249,
267,
327,
880,
10021,
511,
5560,
911,
1336,
334,
6243,
965,
949,
267,
327,
19834,
402,
2008,
680,
267,
13259,
275,
2074,
14,
1935,
360,
8032,
297,
488,
9,
267,
340,
13259,
26,
288,
291,
14,
8032,
275,
16477,
13559,
8,
8032,
9,
398,
27587,
275,
2074,
14,
1935,
360,
22098,
297,
488,
9,
267,
340,
27587,
26,
288,
291,
14,
22098,
275,
2008,
8,
22098,
9,
398,
1599,
63,
5985,
63,
1259,
275,
2074,
14,
1935,
360,
832,
63,
5985,
63,
1259,
297,
488,
9,
267,
340,
1599,
63,
5985,
63,
1259,
26,
288,
1599,
63,
5985,
63,
1259,
275,
16477,
13559,
8,
832,
63,
5985,
63,
1259,
9,
267,
291,
14,
832,
63,
5985,
63,
1259,
275,
1599,
63,
5985,
63,
1259,
398,
1613,
8,
774,
13427,
12,
291,
2843,
826,
14155,
958,
9,
421,
199,
533,
1379,
13427,
1084,
8,
785,
304,
272,
408,
272,
7048,
2225,
402,
642,
909,
365,
282,
769,
402,
658,
774,
13427,
64,
4454,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
367,
790,
12,
574,
315,
2074,
14,
1744,
837,
288,
5371,
8,
277,
12,
790,
12,
359,
774,
13427,
3682,
495,
3916,
8,
829,
430,
367,
4775,
315,
574,
566,
421,
199,
533,
1379,
1451,
4256,
8,
785,
304,
272,
408,
272,
28438,
1202,
367,
11920,
15,
17835,
511,
5560,
626,
7890,
282,
658,
21626,
64,
272,
3324,
12,
1314,
2529,
436,
15,
269,
14404,
314,
3659,
3400,
666,
14,
272,
408,
272,
768,
1829,
272,
347,
24883,
8,
277,
304,
267,
2288,
21390,
3940,
23359,
267,
340,
21390,
3940,
23359,
365,
488,
26,
288,
327,
7190,
1536,
314,
511,
3400,
666,
687,
10949,
1901,
2288,
14,
288,
486,
20127,
275,
11756,
14,
29827,
8,
736,
14,
515,
14,
904,
8,
2864,
63,
3998,
12,
283,
21626,
14,
1001,
14,
6838,
1333,
288,
24883,
275,
13804,
14,
3640,
8,
6838,
70,
14,
739,
1012,
288,
21390,
3940,
23359,
275,
1379,
13427,
1084,
3682,
495,
3916,
8,
21626,
430,
267,
372,
21390,
3940,
23359,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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from opencog.type_constructors import *
# Choose atoms which are connected to specific atom.
def get_incoming_nodes(a, target):
ret = []
xget_target_link = a.xget_atoms_by_target_atom(types.Link, target)
for link in xget_target_link:
xget_target_link_node = a.xget_outgoing(link.h)
for node in xget_target_link_node:
if node.h != target.h:
ret.append(node)
return ret
def get_weighted_tv(atoms):
"""
Make new TruthValue by evaluate weighted average of exist
link's TruthValue.
This is implement code of this idea written by Ben Goertzel:
https://groups.google.com/forum/#!topic/opencog/fa5c4yE8YdU
:param list(EqualLinkKey) atoms: List of EqualLinkKey which are
expected to make weighted average TruthValue from theirs.
:rtype TruthValue: New truth value.
"""
if len(atoms) < 2:
raise UserWarning(
"Weighted TruthValue can't be evaluated with small size."
)
mean_sum = 0
weighted_strength_sum = 0
confidence_sum = 0
link_count = 0
for atom in atoms:
weighted_strength_sum += (atom.tv.confidence * atom.tv.mean)
confidence_sum += atom.tv.confidence
link_count += 1
try:
new_strength = weighted_strength_sum / confidence_sum
except ZeroDivisionError:
# This is arithmetic mean, maybe given atoms doesn't have TruthValue.
for atom in atoms:
mean_sum += atom.tv.mean
new_strength = mean_sum / link_count
# TODO: Currently, confidence value for new blended node is just
# average of old value.
# 충돌값 보정을 단순 평균이 아닌 적절한 이유를 가진 값으로 바꿔야 한다.
new_confidence = confidence_sum / link_count
return TruthValue(new_strength, new_confidence)
|
agpl-3.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
363,
2502,
363,
275,
283,
36,
951,
4649,
1804,
1017,
7,
199,
199,
504,
1551,
23147,
14,
466,
63,
1880,
83,
492,
627,
421,
199,
3,
29826,
14503,
1314,
787,
8539,
370,
2488,
6222,
14,
199,
318,
664,
63,
15994,
63,
2415,
8,
65,
12,
1347,
304,
272,
2203,
275,
942,
339,
671,
362,
63,
1375,
63,
1073,
275,
282,
14,
88,
362,
63,
11521,
63,
991,
63,
1375,
63,
4188,
8,
1313,
14,
3834,
12,
1347,
9,
339,
367,
2142,
315,
671,
362,
63,
1375,
63,
1073,
26,
267,
671,
362,
63,
1375,
63,
1073,
63,
932,
275,
282,
14,
88,
362,
63,
19388,
8,
1073,
14,
72,
9,
267,
367,
1031,
315,
671,
362,
63,
1375,
63,
1073,
63,
932,
26,
288,
340,
1031,
14,
72,
1137,
1347,
14,
72,
26,
355,
2203,
14,
740,
8,
932,
9,
339,
372,
2203,
421,
199,
318,
664,
63,
13522,
63,
6993,
8,
11521,
304,
272,
408,
272,
4155,
892,
28814,
762,
1110,
701,
9352,
14609,
8095,
402,
2187,
272,
2142,
1159,
28814,
762,
1110,
14,
339,
961,
365,
5669,
1233,
402,
642,
16819,
5313,
701,
26844,
3971,
281,
3903,
352,
26,
272,
4178,
921,
2634,
14,
3098,
14,
957,
15,
10044,
15,
3168,
5746,
15,
1490,
23147,
15,
667,
21,
67,
20,
89,
37,
24,
57,
68,
53,
339,
520,
635,
769,
8,
591,
3834,
1197,
9,
14503,
26,
3820,
402,
221,
591,
3834,
1197,
1314,
787,
272,
1420,
370,
1852,
14609,
8095,
28814,
762,
1110,
687,
3932,
83,
14,
272,
520,
4500,
28814,
762,
1110,
26,
7053,
16865,
574,
14,
272,
408,
272,
340,
822,
8,
11521,
9,
665,
499,
26,
267,
746,
2876,
3849,
8,
288,
298,
6004,
8364,
28814,
762,
1110,
883,
1133,
506,
13006,
543,
7425,
1568,
2122,
267,
776,
339,
4615,
63,
1838,
275,
378,
339,
14609,
63,
21049,
63,
1838,
275,
378,
272,
15197,
63,
1838,
275,
378,
272,
2142,
63,
835,
275,
378,
339,
367,
6222,
315,
14503,
26,
267,
14609,
63,
21049,
63,
1838,
847,
334,
4188,
14,
6993,
14,
13969,
627,
6222,
14,
6993,
14,
3670,
9,
267,
15197,
63,
1838,
847,
6222,
14,
6993,
14,
13969,
267,
2142,
63,
835,
847,
413,
339,
862,
26,
267,
892,
63,
21049,
275,
14609,
63,
21049,
63,
1838,
1182,
15197,
63,
1838,
272,
871,
25838,
26,
267,
327,
961,
365,
24166,
4615,
12,
11703,
1627,
14503,
3181,
1133,
1172,
28814,
762,
1110,
14,
267,
367,
6222,
315,
14503,
26,
288,
4615,
63,
1838,
847,
6222,
14,
6993,
14,
3670,
267,
892,
63,
21049,
275,
4615,
63,
1838,
1182,
2142,
63,
835,
339,
327,
3254,
26,
13550,
12,
15197,
574,
367,
892,
330,
552,
770,
1031,
365,
2951,
272,
327,
8095,
402,
2269,
574,
14,
272,
327,
10148,
115,
103,
168,
238,
235,
22247,
241,
16002,
112,
113,
28648,
244,
16439,
227,
16002,
234,
102,
169,
231,
251,
26521,
238,
232,
167,
116,
255,
31888,
10148,
244,
227,
21048,
235,
10148,
8774,
28648,
231,
17272,
251,
10148,
252,
113,
169,
251,
255,
168,
99,
121,
221,
28733,
32704,
227,
221,
22247,
241,
169,
251,
121,
29985,
251,
16002,
109,
243,
167,
124,
243,
169,
244,
121,
221,
17272,
251,
31503,
14,
272,
892,
63,
13969,
275,
15197,
63,
1838,
1182,
2142,
63,
835,
272,
372,
28814,
762,
1110,
8,
1222,
63,
21049,
12,
892,
63,
13969,
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
] |
[
2803,
29,
1624,
13,
24,
199,
363,
2502,
363,
275,
283,
36,
951,
4649,
1804,
1017,
7,
199,
199,
504,
1551,
23147,
14,
466,
63,
1880,
83,
492,
627,
421,
199,
3,
29826,
14503,
1314,
787,
8539,
370,
2488,
6222,
14,
199,
318,
664,
63,
15994,
63,
2415,
8,
65,
12,
1347,
304,
272,
2203,
275,
942,
339,
671,
362,
63,
1375,
63,
1073,
275,
282,
14,
88,
362,
63,
11521,
63,
991,
63,
1375,
63,
4188,
8,
1313,
14,
3834,
12,
1347,
9,
339,
367,
2142,
315,
671,
362,
63,
1375,
63,
1073,
26,
267,
671,
362,
63,
1375,
63,
1073,
63,
932,
275,
282,
14,
88,
362,
63,
19388,
8,
1073,
14,
72,
9,
267,
367,
1031,
315,
671,
362,
63,
1375,
63,
1073,
63,
932,
26,
288,
340,
1031,
14,
72,
1137,
1347,
14,
72,
26,
355,
2203,
14,
740,
8,
932,
9,
339,
372,
2203,
421,
199,
318,
664,
63,
13522,
63,
6993,
8,
11521,
304,
272,
408,
272,
4155,
892,
28814,
762,
1110,
701,
9352,
14609,
8095,
402,
2187,
272,
2142,
1159,
28814,
762,
1110,
14,
339,
961,
365,
5669,
1233,
402,
642,
16819,
5313,
701,
26844,
3971,
281,
3903,
352,
26,
272,
4178,
921,
2634,
14,
3098,
14,
957,
15,
10044,
15,
3168,
5746,
15,
1490,
23147,
15,
667,
21,
67,
20,
89,
37,
24,
57,
68,
53,
339,
520,
635,
769,
8,
591,
3834,
1197,
9,
14503,
26,
3820,
402,
221,
591,
3834,
1197,
1314,
787,
272,
1420,
370,
1852,
14609,
8095,
28814,
762,
1110,
687,
3932,
83,
14,
272,
520,
4500,
28814,
762,
1110,
26,
7053,
16865,
574,
14,
272,
408,
272,
340,
822,
8,
11521,
9,
665,
499,
26,
267,
746,
2876,
3849,
8,
288,
298,
6004,
8364,
28814,
762,
1110,
883,
1133,
506,
13006,
543,
7425,
1568,
2122,
267,
776,
339,
4615,
63,
1838,
275,
378,
339,
14609,
63,
21049,
63,
1838,
275,
378,
272,
15197,
63,
1838,
275,
378,
272,
2142,
63,
835,
275,
378,
339,
367,
6222,
315,
14503,
26,
267,
14609,
63,
21049,
63,
1838,
847,
334,
4188,
14,
6993,
14,
13969,
627,
6222,
14,
6993,
14,
3670,
9,
267,
15197,
63,
1838,
847,
6222,
14,
6993,
14,
13969,
267,
2142,
63,
835,
847,
413,
339,
862,
26,
267,
892,
63,
21049,
275,
14609,
63,
21049,
63,
1838,
1182,
15197,
63,
1838,
272,
871,
25838,
26,
267,
327,
961,
365,
24166,
4615,
12,
11703,
1627,
14503,
3181,
1133,
1172,
28814,
762,
1110,
14,
267,
367,
6222,
315,
14503,
26,
288,
4615,
63,
1838,
847,
6222,
14,
6993,
14,
3670,
267,
892,
63,
21049,
275,
4615,
63,
1838,
1182,
2142,
63,
835,
339,
327,
3254,
26,
13550,
12,
15197,
574,
367,
892,
330,
552,
770,
1031,
365,
2951,
272,
327,
8095,
402,
2269,
574,
14,
272,
327,
10148,
115,
103,
168,
238,
235,
22247,
241,
16002,
112,
113,
28648,
244,
16439,
227,
16002,
234,
102,
169,
231,
251,
26521,
238,
232,
167,
116,
255,
31888,
10148,
244,
227,
21048,
235,
10148,
8774,
28648,
231,
17272,
251,
10148,
252,
113,
169,
251,
255,
168,
99,
121,
221,
28733,
32704,
227,
221,
22247,
241,
169,
251,
121,
29985,
251,
16002,
109,
243,
167,
124,
243,
169,
244,
121,
221,
17272,
251,
31503,
14,
272,
892,
63,
13969,
275,
15197,
63,
1838,
1182,
2142,
63,
835,
272,
372,
28814,
762,
1110,
8,
1222,
63,
21049,
12,
892,
63,
13969,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,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/pygletplot/plot.py
|
84
|
13256
|
from __future__ import print_function, division
from sympy import Integer
from sympy.core.compatibility import is_sequence
from threading import RLock
# it is sufficient to import "pyglet" here once
try:
from pyglet.gl import *
except ImportError:
raise ImportError("pyglet is required for plotting.\n "
"visit http://www.pyglet.org/")
from plot_object import PlotObject
from plot_axes import PlotAxes
from plot_window import PlotWindow
from plot_mode import PlotMode
from time import sleep
from os import getcwd, listdir
from util import parse_option_string
from sympy.geometry.entity import GeometryEntity
from sympy.utilities.decorator import doctest_depends_on
@doctest_depends_on(modules=('pyglet',))
class PygletPlot(object):
"""
Plot Examples
=============
See examples/advaned/pyglet_plotting.py for many more examples.
>>> from sympy.plotting.pygletplot import PygletPlot as Plot
>>> from sympy.abc import x, y, z
>>> Plot(x*y**3-y*x**3)
[0]: -x**3*y + x*y**3, 'mode=cartesian'
>>> p = Plot()
>>> p[1] = x*y
>>> p[1].color = z, (0.4,0.4,0.9), (0.9,0.4,0.4)
>>> p = Plot()
>>> p[1] = x**2+y**2
>>> p[2] = -x**2-y**2
Variable Intervals
==================
The basic format is [var, min, max, steps], but the
syntax is flexible and arguments left out are taken
from the defaults for the current coordinate mode:
>>> Plot(x**2) # implies [x,-5,5,100]
[0]: x**2, 'mode=cartesian'
>>> Plot(x**2, [], []) # [x,-1,1,40], [y,-1,1,40]
[0]: x**2, 'mode=cartesian'
>>> Plot(x**2-y**2, [100], [100]) # [x,-1,1,100], [y,-1,1,100]
[0]: x**2 - y**2, 'mode=cartesian'
>>> Plot(x**2, [x,-13,13,100])
[0]: x**2, 'mode=cartesian'
>>> Plot(x**2, [-13,13]) # [x,-13,13,100]
[0]: x**2, 'mode=cartesian'
>>> Plot(x**2, [x,-13,13]) # [x,-13,13,10]
[0]: x**2, 'mode=cartesian'
>>> Plot(1*x, [], [x], mode='cylindrical')
... # [unbound_theta,0,2*Pi,40], [x,-1,1,20]
[0]: x, 'mode=cartesian'
Coordinate Modes
================
Plot supports several curvilinear coordinate modes, and
they independent for each plotted function. You can specify
a coordinate mode explicitly with the 'mode' named argument,
but it can be automatically determined for Cartesian or
parametric plots, and therefore must only be specified for
polar, cylindrical, and spherical modes.
Specifically, Plot(function arguments) and Plot[n] =
(function arguments) will interpret your arguments as a
Cartesian plot if you provide one function and a parametric
plot if you provide two or three functions. Similarly, the
arguments will be interpreted as a curve if one variable is
used, and a surface if two are used.
Supported mode names by number of variables:
1: parametric, cartesian, polar
2: parametric, cartesian, cylindrical = polar, spherical
>>> Plot(1, mode='spherical') # doctest: +SKIP
Calculator-like Interface
=========================
>>> p = Plot(visible=False)
>>> f = x**2
>>> p[1] = f
>>> p[2] = f.diff(x)
>>> p[3] = f.diff(x).diff(x) # doctest: +SKIP
>>> p # doctest: +SKIP
[1]: x**2, 'mode=cartesian'
[2]: 2*x, 'mode=cartesian'
[3]: 2, 'mode=cartesian'
>>> p.show()
>>> p.clear()
>>> p
<blank plot>
>>> p[1] = x**2+y**2
>>> p[1].style = 'solid'
>>> p[2] = -x**2-y**2
>>> p[2].style = 'wireframe'
>>> p[1].color = z, (0.4,0.4,0.9), (0.9,0.4,0.4)
>>> p[1].style = 'both'
>>> p[2].style = 'both'
>>> p.close()
Plot Window Keyboard Controls
=============================
Screen Rotation:
X,Y axis Arrow Keys, A,S,D,W, Numpad 4,6,8,2
Z axis Q,E, Numpad 7,9
Model Rotation:
Z axis Z,C, Numpad 1,3
Zoom: R,F, PgUp,PgDn, Numpad +,-
Reset Camera: X, Numpad 5
Camera Presets:
XY F1
XZ F2
YZ F3
Perspective F4
Sensitivity Modifier: SHIFT
Axes Toggle:
Visible F5
Colors F6
Close Window: ESCAPE
=============================
"""
@doctest_depends_on(modules=('pyglet',))
def __init__(self, *fargs, **win_args):
"""
Positional Arguments
====================
Any given positional arguments are used to
initialize a plot function at index 1. In
other words...
>>> from sympy.plotting.pygletplot import PygletPlot as Plot
>>> from sympy.core import Symbol
>>> from sympy.abc import x
>>> p = Plot(x**2, visible=False)
...is equivalent to...
>>> p = Plot(visible=False)
>>> p[1] = x**2
Note that in earlier versions of the plotting
module, you were able to specify multiple
functions in the initializer. This functionality
has been dropped in favor of better automatic
plot plot_mode detection.
Named Arguments
===============
axes
An option string of the form
"key1=value1; key2 = value2" which
can use the following options:
style = ordinate
none OR frame OR box OR ordinate
stride = 0.25
val OR (val_x, val_y, val_z)
overlay = True (draw on top of plot)
True OR False
colored = False (False uses Black,
True uses colors
R,G,B = X,Y,Z)
True OR False
label_axes = False (display axis names
at endpoints)
True OR False
visible = True (show immediately
True OR False
The following named arguments are passed as
arguments to window initialization:
antialiasing = True
True OR False
ortho = False
True OR False
invert_mouse_zoom = False
True OR False
"""
self._win_args = win_args
self._window = None
self._render_lock = RLock()
self._functions = {}
self._pobjects = []
self._screenshot = ScreenShot(self)
axe_options = parse_option_string(win_args.pop('axes', ''))
self.axes = PlotAxes(**axe_options)
self._pobjects.append(self.axes)
self[0] = fargs
if win_args.get('visible', True):
self.show()
## Window Interfaces
def show(self):
"""
Creates and displays a plot window, or activates it
(gives it focus) if it has already been created.
"""
if self._window and not self._window.has_exit:
self._window.activate()
else:
self._win_args['visible'] = True
self.axes.reset_resources()
if hasattr(self, '_doctest_depends_on'):
self._win_args['runfromdoctester'] = True
self._window = PlotWindow(self, **self._win_args)
def close(self):
"""
Closes the plot window.
"""
if self._window:
self._window.close()
def saveimage(self, outfile=None, format='', size=(600, 500)):
"""
Saves a screen capture of the plot window to an
image file.
If outfile is given, it can either be a path
or a file object. Otherwise a png image will
be saved to the current working directory.
If the format is omitted, it is determined from
the filename extension.
"""
self._screenshot.save(outfile, format, size)
## Function List Interfaces
def clear(self):
"""
Clears the function list of this plot.
"""
self._render_lock.acquire()
self._functions = {}
self.adjust_all_bounds()
self._render_lock.release()
def __getitem__(self, i):
"""
Returns the function at position i in the
function list.
"""
return self._functions[i]
def __setitem__(self, i, args):
"""
Parses and adds a PlotMode to the function
list.
"""
if not (isinstance(i, (int, Integer)) and i >= 0):
raise ValueError("Function index must "
"be an integer >= 0.")
if isinstance(args, PlotObject):
f = args
else:
if (not is_sequence(args)) or isinstance(args, GeometryEntity):
args = [args]
if len(args) == 0:
return # no arguments given
kwargs = dict(bounds_callback=self.adjust_all_bounds)
f = PlotMode(*args, **kwargs)
if f:
self._render_lock.acquire()
self._functions[i] = f
self._render_lock.release()
else:
raise ValueError("Failed to parse '%s'."
% ', '.join(str(a) for a in args))
def __delitem__(self, i):
"""
Removes the function in the function list at
position i.
"""
self._render_lock.acquire()
del self._functions[i]
self.adjust_all_bounds()
self._render_lock.release()
def firstavailableindex(self):
"""
Returns the first unused index in the function list.
"""
i = 0
self._render_lock.acquire()
while i in self._functions:
i += 1
self._render_lock.release()
return i
def append(self, *args):
"""
Parses and adds a PlotMode to the function
list at the first available index.
"""
self.__setitem__(self.firstavailableindex(), args)
def __len__(self):
"""
Returns the number of functions in the function list.
"""
return len(self._functions)
def __iter__(self):
"""
Allows iteration of the function list.
"""
return self._functions.itervalues()
def __repr__(self):
return str(self)
def __str__(self):
"""
Returns a string containing a new-line separated
list of the functions in the function list.
"""
s = ""
if len(self._functions) == 0:
s += "<blank plot>"
else:
self._render_lock.acquire()
s += "\n".join(["%s[%i]: %s" % ("", i, str(self._functions[i]))
for i in self._functions])
self._render_lock.release()
return s
def adjust_all_bounds(self):
self._render_lock.acquire()
self.axes.reset_bounding_box()
for f in self._functions:
self.axes.adjust_bounds(self._functions[f].bounds)
self._render_lock.release()
def wait_for_calculations(self):
sleep(0)
self._render_lock.acquire()
for f in self._functions:
a = self._functions[f]._get_calculating_verts
b = self._functions[f]._get_calculating_cverts
while a() or b():
sleep(0)
self._render_lock.release()
class ScreenShot:
def __init__(self, plot):
self._plot = plot
self.screenshot_requested = False
self.outfile = None
self.format = ''
self.invisibleMode = False
self.flag = 0
def __nonzero__(self):
if self.screenshot_requested:
return 1
return 0
__bool__ = __nonzero__
def _execute_saving(self):
if self.flag < 3:
self.flag += 1
return
size_x, size_y = self._plot._window.get_size()
size = size_x*size_y*4*sizeof(c_ubyte)
image = create_string_buffer(size)
glReadPixels(0, 0, size_x, size_y, GL_RGBA, GL_UNSIGNED_BYTE, image)
from PIL import Image
im = Image.frombuffer('RGBA', (size_x, size_y),
image.raw, 'raw', 'RGBA', 0, 1)
im.transpose(Image.FLIP_TOP_BOTTOM).save(self.outfile, self.format)
self.flag = 0
self.screenshot_requested = False
if self.invisibleMode:
self._plot._window.close()
def save(self, outfile=None, format='', size=(600, 500)):
self.outfile = outfile
self.format = format
self.size = size
self.screenshot_requested = True
if not self._plot._window or self._plot._window.has_exit:
self._plot._win_args['visible'] = False
self._plot._win_args['width'] = size[0]
self._plot._win_args['height'] = size[1]
self._plot.axes.reset_resources()
self._plot._window = PlotWindow(self._plot, **self._plot._win_args)
self.invisibleMode = True
if self.outfile is None:
self.outfile = self._create_unique_path()
print(self.outfile)
def _create_unique_path(self):
cwd = getcwd()
l = listdir(cwd)
path = ''
i = 0
while True:
if not 'plot_%s.png' % i in l:
path = cwd + '/plot_%s.png' % i
break
i += 1
return path
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
870,
63,
1593,
12,
4629,
199,
199,
504,
5840,
492,
7225,
199,
504,
5840,
14,
1018,
14,
15390,
492,
365,
63,
4041,
199,
199,
504,
5796,
492,
820,
6432,
199,
199,
3,
652,
365,
19258,
370,
492,
298,
647,
18678,
2,
2348,
5403,
199,
893,
26,
272,
687,
23409,
14,
3528,
492,
627,
199,
2590,
3545,
26,
272,
746,
3545,
480,
647,
18678,
365,
1415,
367,
25174,
3134,
78,
298,
1993,
298,
5427,
1455,
921,
1544,
14,
647,
18678,
14,
1308,
13589,
199,
199,
504,
5137,
63,
785,
492,
14794,
1692,
199,
504,
5137,
63,
6402,
492,
14794,
20386,
199,
504,
5137,
63,
3806,
492,
14794,
4301,
199,
504,
5137,
63,
632,
492,
14794,
1385,
199,
199,
504,
900,
492,
9435,
199,
504,
747,
492,
664,
6525,
12,
27483,
199,
504,
4884,
492,
2198,
63,
1422,
63,
875,
199,
199,
504,
5840,
14,
7660,
14,
4502,
492,
10579,
7302,
199,
199,
504,
5840,
14,
16355,
14,
11547,
492,
8868,
63,
8912,
63,
265,
199,
199,
32,
11390,
63,
8912,
63,
265,
8,
3112,
7782,
647,
18678,
16829,
199,
533,
1611,
18678,
10711,
8,
785,
304,
272,
408,
272,
14794,
6058,
272,
275,
5769,
339,
1666,
7251,
15,
350,
20662,
379,
15,
647,
18678,
63,
2798,
1337,
14,
647,
367,
5002,
1655,
7251,
14,
2378,
1306,
687,
5840,
14,
2798,
1337,
14,
647,
3845,
683,
1653,
492,
1611,
18678,
10711,
465,
14794,
272,
1306,
687,
5840,
14,
3175,
492,
671,
12,
612,
12,
1315,
339,
1306,
14794,
8,
88,
10,
89,
538,
19,
13,
89,
10,
88,
538,
19,
9,
272,
359,
16,
2189,
446,
88,
538,
19,
10,
89,
435,
671,
10,
89,
538,
19,
12,
283,
632,
29,
7007,
19157,
7,
339,
1306,
299,
275,
14794,
342,
272,
1306,
299,
59,
17,
61,
275,
671,
10,
89,
272,
1306,
299,
59,
17,
1055,
2326,
275,
1315,
12,
334,
16,
14,
20,
12,
16,
14,
20,
12,
16,
14,
25,
395,
334,
16,
14,
25,
12,
16,
14,
20,
12,
16,
14,
20,
9,
339,
1306,
299,
275,
14794,
342,
272,
1306,
299,
59,
17,
61,
275,
221,
671,
538,
18,
11,
89,
538,
18,
272,
1306,
299,
59,
18,
61,
275,
446,
88,
538,
18,
13,
89,
538,
18,
2378,
4905,
6551,
3643,
272,
16248,
29,
339,
710,
5678,
1475,
365,
359,
1391,
12,
1748,
12,
1390,
12,
7124,
467,
1325,
314,
272,
6302,
365,
26841,
436,
2368,
3602,
734,
787,
9394,
272,
687,
314,
4243,
367,
314,
1453,
10021,
818,
26,
339,
1306,
14794,
8,
88,
538,
18,
9,
327,
22660,
359,
88,
3057,
21,
12,
21,
12,
1960,
61,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
12,
990,
3073,
327,
359,
88,
3057,
17,
12,
17,
12,
2167,
467,
359,
89,
3057,
17,
12,
17,
12,
2167,
61,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
13,
89,
538,
18,
12,
359,
1960,
467,
359,
1960,
566,
327,
359,
88,
3057,
17,
12,
17,
12,
1960,
467,
359,
89,
3057,
17,
12,
17,
12,
1960,
61,
272,
359,
16,
2189,
671,
538,
18,
446,
612,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
12,
359,
88,
3057,
969,
12,
969,
12,
1960,
566,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
12,
5243,
969,
12,
969,
566,
327,
359,
88,
3057,
969,
12,
969,
12,
1960,
61,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
12,
359,
88,
3057,
969,
12,
969,
566,
327,
359,
88,
3057,
969,
12,
969,
12,
709,
61,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
17,
10,
88,
12,
990,
359,
88,
467,
818,
534,
1480,
24491,
8825,
358,
272,
2263,
327,
359,
18124,
63,
9337,
12,
16,
12,
18,
10,
10542,
12,
2167,
467,
359,
88,
3057,
17,
12,
17,
12,
1165,
61,
272,
359,
16,
2189,
671,
12,
283,
632,
29,
7007,
19157,
7,
2378,
25334,
323,
4900,
83,
272,
275,
16964,
339,
14794,
5171,
9978,
1094,
29792,
1132,
285,
10021,
12404,
12,
436,
272,
2985,
12717,
367,
1924,
5137,
471,
805,
14,
2047,
883,
4165,
272,
282,
10021,
818,
7662,
543,
314,
283,
632,
7,
4310,
1423,
12,
272,
1325,
652,
883,
506,
5847,
12037,
367,
14243,
19157,
503,
272,
18117,
13929,
19695,
12,
436,
16119,
1471,
1454,
506,
2013,
367,
272,
29167,
12,
6325,
24491,
8825,
12,
436,
308,
27058,
12404,
14,
339,
30836,
12,
14794,
8,
1593,
2368,
9,
436,
14794,
59,
78,
61,
275,
272,
334,
1593,
2368,
9,
911,
15579,
2195,
2368,
465,
282,
272,
14243,
19157,
5137,
340,
1265,
5647,
1373,
805,
436,
282,
18117,
13929,
272,
5137,
340,
1265,
5647,
2877,
503,
7795,
3423,
14,
20046,
590,
12,
314,
272,
2368,
911,
506,
11922,
465,
282,
15318,
340,
1373,
1750,
365,
272,
1202,
12,
436,
282,
13195,
340,
2877,
787,
1202,
14,
339,
26167,
818,
1561,
701,
1329,
402,
2860,
26,
339,
413,
26,
18117,
13929,
12,
9590,
19157,
12,
29167,
272,
499,
26,
18117,
13929,
12,
9590,
19157,
12,
6325,
24491,
8825,
275,
29167,
12,
308,
27058,
339,
1306,
14794,
8,
17,
12,
818,
534,
23286,
2652,
358,
327,
8868,
26,
435,
13525,
2378,
19821,
707,
13,
2930,
14816,
272,
16248,
763,
339,
1306,
299,
275,
14794,
8,
6604,
29,
797,
9,
272,
1306,
289,
275,
671,
538,
18,
272,
1306,
299,
59,
17,
61,
275,
289,
272,
1306,
299,
59,
18,
61,
275,
289,
14,
3028,
8,
88,
9,
272,
1306,
299,
59,
19,
61,
275,
289,
14,
3028,
8,
88,
680,
3028,
8,
88,
9,
327,
8868,
26,
435,
13525,
272,
1306,
299,
327,
8868,
26,
435,
13525,
272,
359,
17,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
359,
18,
2189,
499,
10,
88,
12,
283,
632,
29,
7007,
19157,
7,
272
] |
[
636,
2443,
363,
492,
870,
63,
1593,
12,
4629,
199,
199,
504,
5840,
492,
7225,
199,
504,
5840,
14,
1018,
14,
15390,
492,
365,
63,
4041,
199,
199,
504,
5796,
492,
820,
6432,
199,
199,
3,
652,
365,
19258,
370,
492,
298,
647,
18678,
2,
2348,
5403,
199,
893,
26,
272,
687,
23409,
14,
3528,
492,
627,
199,
2590,
3545,
26,
272,
746,
3545,
480,
647,
18678,
365,
1415,
367,
25174,
3134,
78,
298,
1993,
298,
5427,
1455,
921,
1544,
14,
647,
18678,
14,
1308,
13589,
199,
199,
504,
5137,
63,
785,
492,
14794,
1692,
199,
504,
5137,
63,
6402,
492,
14794,
20386,
199,
504,
5137,
63,
3806,
492,
14794,
4301,
199,
504,
5137,
63,
632,
492,
14794,
1385,
199,
199,
504,
900,
492,
9435,
199,
504,
747,
492,
664,
6525,
12,
27483,
199,
504,
4884,
492,
2198,
63,
1422,
63,
875,
199,
199,
504,
5840,
14,
7660,
14,
4502,
492,
10579,
7302,
199,
199,
504,
5840,
14,
16355,
14,
11547,
492,
8868,
63,
8912,
63,
265,
199,
199,
32,
11390,
63,
8912,
63,
265,
8,
3112,
7782,
647,
18678,
16829,
199,
533,
1611,
18678,
10711,
8,
785,
304,
272,
408,
272,
14794,
6058,
272,
275,
5769,
339,
1666,
7251,
15,
350,
20662,
379,
15,
647,
18678,
63,
2798,
1337,
14,
647,
367,
5002,
1655,
7251,
14,
2378,
1306,
687,
5840,
14,
2798,
1337,
14,
647,
3845,
683,
1653,
492,
1611,
18678,
10711,
465,
14794,
272,
1306,
687,
5840,
14,
3175,
492,
671,
12,
612,
12,
1315,
339,
1306,
14794,
8,
88,
10,
89,
538,
19,
13,
89,
10,
88,
538,
19,
9,
272,
359,
16,
2189,
446,
88,
538,
19,
10,
89,
435,
671,
10,
89,
538,
19,
12,
283,
632,
29,
7007,
19157,
7,
339,
1306,
299,
275,
14794,
342,
272,
1306,
299,
59,
17,
61,
275,
671,
10,
89,
272,
1306,
299,
59,
17,
1055,
2326,
275,
1315,
12,
334,
16,
14,
20,
12,
16,
14,
20,
12,
16,
14,
25,
395,
334,
16,
14,
25,
12,
16,
14,
20,
12,
16,
14,
20,
9,
339,
1306,
299,
275,
14794,
342,
272,
1306,
299,
59,
17,
61,
275,
221,
671,
538,
18,
11,
89,
538,
18,
272,
1306,
299,
59,
18,
61,
275,
446,
88,
538,
18,
13,
89,
538,
18,
2378,
4905,
6551,
3643,
272,
16248,
29,
339,
710,
5678,
1475,
365,
359,
1391,
12,
1748,
12,
1390,
12,
7124,
467,
1325,
314,
272,
6302,
365,
26841,
436,
2368,
3602,
734,
787,
9394,
272,
687,
314,
4243,
367,
314,
1453,
10021,
818,
26,
339,
1306,
14794,
8,
88,
538,
18,
9,
327,
22660,
359,
88,
3057,
21,
12,
21,
12,
1960,
61,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
12,
990,
3073,
327,
359,
88,
3057,
17,
12,
17,
12,
2167,
467,
359,
89,
3057,
17,
12,
17,
12,
2167,
61,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
13,
89,
538,
18,
12,
359,
1960,
467,
359,
1960,
566,
327,
359,
88,
3057,
17,
12,
17,
12,
1960,
467,
359,
89,
3057,
17,
12,
17,
12,
1960,
61,
272,
359,
16,
2189,
671,
538,
18,
446,
612,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
12,
359,
88,
3057,
969,
12,
969,
12,
1960,
566,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
12,
5243,
969,
12,
969,
566,
327,
359,
88,
3057,
969,
12,
969,
12,
1960,
61,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
88,
538,
18,
12,
359,
88,
3057,
969,
12,
969,
566,
327,
359,
88,
3057,
969,
12,
969,
12,
709,
61,
272,
359,
16,
2189,
671,
538,
18,
12,
283,
632,
29,
7007,
19157,
7,
272,
1306,
14794,
8,
17,
10,
88,
12,
990,
359,
88,
467,
818,
534,
1480,
24491,
8825,
358,
272,
2263,
327,
359,
18124,
63,
9337,
12,
16,
12,
18,
10,
10542,
12,
2167,
467,
359,
88,
3057,
17,
12,
17,
12,
1165,
61,
272,
359,
16,
2189,
671,
12,
283,
632,
29,
7007,
19157,
7,
2378,
25334,
323,
4900,
83,
272,
275,
16964,
339,
14794,
5171,
9978,
1094,
29792,
1132,
285,
10021,
12404,
12,
436,
272,
2985,
12717,
367,
1924,
5137,
471,
805,
14,
2047,
883,
4165,
272,
282,
10021,
818,
7662,
543,
314,
283,
632,
7,
4310,
1423,
12,
272,
1325,
652,
883,
506,
5847,
12037,
367,
14243,
19157,
503,
272,
18117,
13929,
19695,
12,
436,
16119,
1471,
1454,
506,
2013,
367,
272,
29167,
12,
6325,
24491,
8825,
12,
436,
308,
27058,
12404,
14,
339,
30836,
12,
14794,
8,
1593,
2368,
9,
436,
14794,
59,
78,
61,
275,
272,
334,
1593,
2368,
9,
911,
15579,
2195,
2368,
465,
282,
272,
14243,
19157,
5137,
340,
1265,
5647,
1373,
805,
436,
282,
18117,
13929,
272,
5137,
340,
1265,
5647,
2877,
503,
7795,
3423,
14,
20046,
590,
12,
314,
272,
2368,
911,
506,
11922,
465,
282,
15318,
340,
1373,
1750,
365,
272,
1202,
12,
436,
282,
13195,
340,
2877,
787,
1202,
14,
339,
26167,
818,
1561,
701,
1329,
402,
2860,
26,
339,
413,
26,
18117,
13929,
12,
9590,
19157,
12,
29167,
272,
499,
26,
18117,
13929,
12,
9590,
19157,
12,
6325,
24491,
8825,
275,
29167,
12,
308,
27058,
339,
1306,
14794,
8,
17,
12,
818,
534,
23286,
2652,
358,
327,
8868,
26,
435,
13525,
2378,
19821,
707,
13,
2930,
14816,
272,
16248,
763,
339,
1306,
299,
275,
14794,
8,
6604,
29,
797,
9,
272,
1306,
289,
275,
671,
538,
18,
272,
1306,
299,
59,
17,
61,
275,
289,
272,
1306,
299,
59,
18,
61,
275,
289,
14,
3028,
8,
88,
9,
272,
1306,
299,
59,
19,
61,
275,
289,
14,
3028,
8,
88,
680,
3028,
8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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
scorpionis/docklet
|
client/venv/lib/python3.5/site-packages/pip/vcs/__init__.py
|
170
|
12349
|
"""Handles all VCS (version control) support"""
from __future__ import absolute_import
import errno
import logging
import os
import shutil
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip.exceptions import BadCommand
from pip.utils import (display_path, backup_dir, call_subprocess,
rmtree, ask_path_exists)
__all__ = ['vcs', 'get_src_requirement']
logger = logging.getLogger(__name__)
class VcsSupport(object):
_registry = {}
schemes = ['ssh', 'git', 'hg', 'bzr', 'sftp', 'svn']
def __init__(self):
# Register more schemes with urlparse for various version control
# systems
urllib_parse.uses_netloc.extend(self.schemes)
# Python >= 2.7.4, 3.3 doesn't have uses_fragment
if getattr(urllib_parse, 'uses_fragment', None):
urllib_parse.uses_fragment.extend(self.schemes)
super(VcsSupport, self).__init__()
def __iter__(self):
return self._registry.__iter__()
@property
def backends(self):
return list(self._registry.values())
@property
def dirnames(self):
return [backend.dirname for backend in self.backends]
@property
def all_schemes(self):
schemes = []
for backend in self.backends:
schemes.extend(backend.schemes)
return schemes
def register(self, cls):
if not hasattr(cls, 'name'):
logger.warning('Cannot register VCS %s', cls.__name__)
return
if cls.name not in self._registry:
self._registry[cls.name] = cls
logger.debug('Registered VCS backend: %s', cls.name)
def unregister(self, cls=None, name=None):
if name in self._registry:
del self._registry[name]
elif cls in self._registry.values():
del self._registry[cls.name]
else:
logger.warning('Cannot unregister because no class or name given')
def get_backend_name(self, location):
"""
Return the name of the version control backend if found at given
location, e.g. vcs.get_backend_name('/path/to/vcs/checkout')
"""
for vc_type in self._registry.values():
if vc_type.controls_location(location):
logger.debug('Determine that %s uses VCS: %s',
location, vc_type.name)
return vc_type.name
return None
def get_backend(self, name):
name = name.lower()
if name in self._registry:
return self._registry[name]
def get_backend_from_location(self, location):
vc_type = self.get_backend_name(location)
if vc_type:
return self.get_backend(vc_type)
return None
vcs = VcsSupport()
class VersionControl(object):
name = ''
dirname = ''
# List of supported schemes for this Version Control
schemes = ()
def __init__(self, url=None, *args, **kwargs):
self.url = url
super(VersionControl, self).__init__(*args, **kwargs)
def _is_local_repository(self, repo):
"""
posix absolute paths start with os.path.sep,
win32 ones ones start with drive (like c:\\folder)
"""
drive, tail = os.path.splitdrive(repo)
return repo.startswith(os.path.sep) or drive
# See issue #1083 for why this method was introduced:
# https://github.com/pypa/pip/issues/1083
def translate_egg_surname(self, surname):
# For example, Django has branches of the form "stable/1.7.x".
return surname.replace('/', '_')
def export(self, location):
"""
Export the repository at the url to the destination location
i.e. only download the files, without vcs informations
"""
raise NotImplementedError
def get_url_rev(self):
"""
Returns the correct repository URL and revision by parsing the given
repository URL
"""
error_message = (
"Sorry, '%s' is a malformed VCS url. "
"The format is <vcs>+<protocol>://<url>, "
"e.g. svn+http://myrepo/svn/MyApp#egg=MyApp"
)
assert '+' in self.url, error_message % self.url
url = self.url.split('+', 1)[1]
scheme, netloc, path, query, frag = urllib_parse.urlsplit(url)
rev = None
if '@' in path:
path, rev = path.rsplit('@', 1)
url = urllib_parse.urlunsplit((scheme, netloc, path, query, ''))
return url, rev
def get_info(self, location):
"""
Returns (url, revision), where both are strings
"""
assert not location.rstrip('/').endswith(self.dirname), \
'Bad directory: %s' % location
return self.get_url(location), self.get_revision(location)
def normalize_url(self, url):
"""
Normalize a URL for comparison by unquoting it and removing any
trailing slash.
"""
return urllib_parse.unquote(url).rstrip('/')
def compare_urls(self, url1, url2):
"""
Compare two repo URLs for identity, ignoring incidental differences.
"""
return (self.normalize_url(url1) == self.normalize_url(url2))
def obtain(self, dest):
"""
Called when installing or updating an editable package, takes the
source path of the checkout.
"""
raise NotImplementedError
def switch(self, dest, url, rev_options):
"""
Switch the repo at ``dest`` to point to ``URL``.
"""
raise NotImplementedError
def update(self, dest, rev_options):
"""
Update an already-existing repo to the given ``rev_options``.
"""
raise NotImplementedError
def check_version(self, dest, rev_options):
"""
Return True if the version is identical to what exists and
doesn't need to be updated.
"""
raise NotImplementedError
def check_destination(self, dest, url, rev_options, rev_display):
"""
Prepare a location to receive a checkout/clone.
Return True if the location is ready for (and requires) a
checkout/clone, False otherwise.
"""
checkout = True
prompt = False
if os.path.exists(dest):
checkout = False
if os.path.exists(os.path.join(dest, self.dirname)):
existing_url = self.get_url(dest)
if self.compare_urls(existing_url, url):
logger.debug(
'%s in %s exists, and has correct URL (%s)',
self.repo_name.title(),
display_path(dest),
url,
)
if not self.check_version(dest, rev_options):
logger.info(
'Updating %s %s%s',
display_path(dest),
self.repo_name,
rev_display,
)
self.update(dest, rev_options)
else:
logger.info(
'Skipping because already up-to-date.')
else:
logger.warning(
'%s %s in %s exists with URL %s',
self.name,
self.repo_name,
display_path(dest),
existing_url,
)
prompt = ('(s)witch, (i)gnore, (w)ipe, (b)ackup ',
('s', 'i', 'w', 'b'))
else:
logger.warning(
'Directory %s already exists, and is not a %s %s.',
dest,
self.name,
self.repo_name,
)
prompt = ('(i)gnore, (w)ipe, (b)ackup ', ('i', 'w', 'b'))
if prompt:
logger.warning(
'The plan is to install the %s repository %s',
self.name,
url,
)
response = ask_path_exists('What to do? %s' % prompt[0],
prompt[1])
if response == 's':
logger.info(
'Switching %s %s to %s%s',
self.repo_name,
display_path(dest),
url,
rev_display,
)
self.switch(dest, url, rev_options)
elif response == 'i':
# do nothing
pass
elif response == 'w':
logger.warning('Deleting %s', display_path(dest))
rmtree(dest)
checkout = True
elif response == 'b':
dest_dir = backup_dir(dest)
logger.warning(
'Backing up %s to %s', display_path(dest), dest_dir,
)
shutil.move(dest, dest_dir)
checkout = True
return checkout
def unpack(self, location):
"""
Clean up current location and download the url repository
(and vcs infos) into location
"""
if os.path.exists(location):
rmtree(location)
self.obtain(location)
def get_src_requirement(self, dist, location):
"""
Return a string representing the requirement needed to
redownload the files currently present in location, something
like:
{repository_url}@{revision}#egg={project_name}-{version_identifier}
"""
raise NotImplementedError
def get_url(self, location):
"""
Return the url used at location
Used in get_info or check_destination
"""
raise NotImplementedError
def get_revision(self, location):
"""
Return the current revision of the files at location
Used in get_info
"""
raise NotImplementedError
def run_command(self, cmd, show_stdout=True, cwd=None,
on_returncode='raise',
command_level=logging.DEBUG, command_desc=None,
extra_environ=None, spinner=None):
"""
Run a VCS subcommand
This is simply a wrapper around call_subprocess that adds the VCS
command name, and checks that the VCS is available
"""
cmd = [self.name] + cmd
try:
return call_subprocess(cmd, show_stdout, cwd,
on_returncode, command_level,
command_desc, extra_environ,
spinner)
except OSError as e:
# errno.ENOENT = no such file or directory
# In other words, the VCS executable isn't available
if e.errno == errno.ENOENT:
raise BadCommand('Cannot find command %r' % self.name)
else:
raise # re-raise exception if a different error occurred
@classmethod
def controls_location(cls, location):
"""
Check if a location is controlled by the vcs.
It is meant to be overridden to implement smarter detection
mechanisms for specific vcs.
"""
logger.debug('Checking in %s for %s (%s)...',
location, cls.dirname, cls.name)
path = os.path.join(location, cls.dirname)
return os.path.exists(path)
def get_src_requirement(dist, location):
version_control = vcs.get_backend_from_location(location)
if version_control:
try:
return version_control().get_src_requirement(dist,
location)
except BadCommand:
logger.warning(
'cannot determine version of editable source in %s '
'(%s command not found in path)',
location,
version_control.name,
)
return dist.as_requirement()
logger.warning(
'cannot determine version of editable source in %s (is not SVN '
'checkout, Git clone, Mercurial clone or Bazaar branch)',
location,
)
return dist.as_requirement()
|
bsd-3-clause
|
[
624,
23555,
1006,
23563,
334,
1023,
3304,
9,
2291,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
7554,
199,
646,
2050,
199,
646,
747,
199,
646,
5145,
199,
199,
504,
7305,
423,
9884,
14,
4174,
14,
4912,
14,
4078,
492,
2198,
465,
4011,
63,
1122,
199,
199,
504,
7305,
14,
3924,
492,
8857,
3110,
199,
504,
7305,
14,
1208,
492,
334,
2918,
63,
515,
12,
6902,
63,
694,
12,
1240,
63,
5781,
12,
2432,
20978,
12,
7198,
63,
515,
63,
2444,
9,
421,
199,
363,
452,
363,
275,
788,
15525,
297,
283,
362,
63,
2164,
63,
12434,
418,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
812,
1259,
11532,
8,
785,
304,
272,
485,
5189,
275,
1052,
272,
21149,
275,
788,
5510,
297,
283,
3187,
297,
283,
9208,
297,
283,
10582,
82,
297,
283,
25032,
297,
283,
6836,
418,
339,
347,
636,
826,
721,
277,
304,
267,
327,
11828,
1655,
21149,
543,
7097,
367,
7750,
1015,
3304,
267,
327,
10460,
267,
4011,
63,
1122,
14,
5589,
63,
12652,
14,
2880,
8,
277,
14,
26818,
9,
267,
327,
2018,
2356,
499,
14,
23,
14,
20,
12,
650,
14,
19,
3181,
1133,
1172,
4440,
63,
7677,
267,
340,
2519,
8,
4078,
63,
1122,
12,
283,
5589,
63,
7677,
297,
488,
304,
288,
4011,
63,
1122,
14,
5589,
63,
7677,
14,
2880,
8,
277,
14,
26818,
9,
267,
1613,
8,
54,
1259,
11532,
12,
291,
2843,
826,
4533,
339,
347,
636,
1661,
721,
277,
304,
267,
372,
291,
423,
5189,
855,
1661,
4533,
339,
768,
1829,
272,
347,
14745,
8,
277,
304,
267,
372,
769,
8,
277,
423,
5189,
14,
1459,
1012,
339,
768,
1829,
272,
347,
22310,
8,
277,
304,
267,
372,
359,
4620,
14,
3475,
367,
4865,
315,
291,
14,
7765,
61,
339,
768,
1829,
272,
347,
1006,
63,
26818,
8,
277,
304,
267,
21149,
275,
942,
267,
367,
4865,
315,
291,
14,
7765,
26,
288,
21149,
14,
2880,
8,
4620,
14,
26818,
9,
267,
372,
21149,
339,
347,
2274,
8,
277,
12,
843,
304,
267,
340,
440,
2688,
8,
1886,
12,
283,
354,
735,
288,
2512,
14,
3764,
360,
6612,
2274,
23563,
450,
83,
297,
843,
855,
354,
3368,
288,
372,
267,
340,
843,
14,
354,
440,
315,
291,
423,
5189,
26,
288,
291,
423,
5189,
59,
1886,
14,
354,
61,
275,
843,
288,
2512,
14,
1757,
360,
20341,
23563,
4865,
26,
450,
83,
297,
843,
14,
354,
9,
339,
347,
24369,
8,
277,
12,
843,
29,
403,
12,
536,
29,
403,
304,
267,
340,
536,
315,
291,
423,
5189,
26,
288,
2150,
291,
423,
5189,
59,
354,
61,
267,
916,
843,
315,
291,
423,
5189,
14,
1459,
837,
288,
2150,
291,
423,
5189,
59,
1886,
14,
354,
61,
267,
587,
26,
288,
2512,
14,
3764,
360,
6612,
24369,
2952,
949,
1021,
503,
536,
1627,
358,
339,
347,
664,
63,
4620,
63,
354,
8,
277,
12,
2909,
304,
267,
408,
267,
1432,
314,
536,
402,
314,
1015,
3304,
4865,
340,
1911,
737,
1627,
267,
2909,
12,
325,
14,
71,
14,
19827,
14,
362,
63,
4620,
63,
354,
2336,
515,
15,
475,
15,
15525,
15,
12891,
358,
267,
408,
267,
367,
16548,
63,
466,
315,
291,
423,
5189,
14,
1459,
837,
288,
340,
16548,
63,
466,
14,
13658,
63,
1985,
8,
1985,
304,
355,
2512,
14,
1757,
360,
21767,
626,
450,
83,
4440,
23563,
26,
450,
83,
297,
2490,
2909,
12,
16548,
63,
466,
14,
354,
9,
355,
372,
16548,
63,
466,
14,
354,
267,
372,
488,
339,
347,
664,
63,
4620,
8,
277,
12,
536,
304,
267,
536,
275,
536,
14,
2325,
342,
267,
340,
536,
315,
291,
423,
5189,
26,
288,
372,
291,
423,
5189,
59,
354,
61,
339,
347,
664,
63,
4620,
63,
504,
63,
1985,
8,
277,
12,
2909,
304,
267,
16548,
63,
466,
275,
291,
14,
362,
63,
4620,
63,
354,
8,
1985,
9,
267,
340,
16548,
63,
466,
26,
288,
372,
291,
14,
362,
63,
4620,
8,
6737,
63,
466,
9,
267,
372,
488,
421,
199,
15525,
275,
812,
1259,
11532,
342,
421,
199,
533,
3394,
3717,
8,
785,
304,
272,
536,
275,
2125,
272,
9017,
275,
2125,
272,
327,
3820,
402,
3748,
21149,
367,
642,
3394,
8612,
272,
21149,
275,
6248,
339,
347,
636,
826,
721,
277,
12,
1166,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
14,
633,
275,
1166,
267,
1613,
8,
3353,
3717,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
485,
374,
63,
1832,
63,
8421,
8,
277,
12,
3831,
304,
267,
408,
1779,
10694,
3679,
3792,
1343,
543,
747,
14,
515,
14,
4127,
12,
1779,
4747,
708,
7869,
7869,
1343,
543,
12912,
334,
2930,
286,
18589,
3741,
9,
267,
408,
267,
12912,
12,
9483,
275,
747,
14,
515,
14,
1294,
9541,
8,
3417,
9,
267,
372,
3831,
14,
2460,
8,
736,
14,
515,
14,
4127,
9,
503,
12912,
339,
327,
1666,
4976,
327,
709,
2658,
367,
10842,
642,
1083,
1990,
21399,
26,
272,
327,
4178,
921,
5031,
14,
957,
15,
647,
387,
15,
9983,
15,
10115,
15,
709,
2658,
272,
347,
9028,
63,
5799,
63,
30959,
8,
277,
12,
308,
21121,
304,
267,
327,
2104,
2893,
12,
5634,
965,
17347,
402,
314,
1824,
298,
11989,
15,
17,
14,
23,
14,
88,
1674,
267,
372,
308,
21121,
14,
1814,
10998,
18962,
339,
347,
4843,
8,
277,
12,
2909,
304,
267,
408,
267,
20220,
314,
7611,
737,
314,
1166,
370,
314,
5724,
2909,
267,
284,
14,
69,
14,
1454,
5235,
314,
1584,
12,
1928,
19827,
315,
17308,
267,
408,
267,
746,
4279,
339,
347,
664,
63,
633,
63,
4964,
8,
277,
304,
267,
408,
267,
1803,
314,
3211,
7611,
2851,
436,
6974,
701,
6057,
314,
1627,
267,
7611,
2851,
267,
408,
267,
1125,
63,
1188,
275,
334,
288,
298,
27143,
12,
1543,
83,
7,
365,
282,
24159,
23563,
1166,
14,
298,
288,
298,
1918,
1475,
365,
665,
15525,
30,
11,
28,
3922,
30,
921,
28,
633,
6244,
298,
288,
298,
69,
14,
71,
14,
11327,
11,
1014,
921,
1662,
3417,
15,
6836,
15,
5713,
2640,
3,
5799,
29,
5713,
2640,
2,
267,
776,
267,
702,
20246,
315,
291
] |
[
23555,
1006,
23563,
334,
1023,
3304,
9,
2291,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
7554,
199,
646,
2050,
199,
646,
747,
199,
646,
5145,
199,
199,
504,
7305,
423,
9884,
14,
4174,
14,
4912,
14,
4078,
492,
2198,
465,
4011,
63,
1122,
199,
199,
504,
7305,
14,
3924,
492,
8857,
3110,
199,
504,
7305,
14,
1208,
492,
334,
2918,
63,
515,
12,
6902,
63,
694,
12,
1240,
63,
5781,
12,
2432,
20978,
12,
7198,
63,
515,
63,
2444,
9,
421,
199,
363,
452,
363,
275,
788,
15525,
297,
283,
362,
63,
2164,
63,
12434,
418,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
812,
1259,
11532,
8,
785,
304,
272,
485,
5189,
275,
1052,
272,
21149,
275,
788,
5510,
297,
283,
3187,
297,
283,
9208,
297,
283,
10582,
82,
297,
283,
25032,
297,
283,
6836,
418,
339,
347,
636,
826,
721,
277,
304,
267,
327,
11828,
1655,
21149,
543,
7097,
367,
7750,
1015,
3304,
267,
327,
10460,
267,
4011,
63,
1122,
14,
5589,
63,
12652,
14,
2880,
8,
277,
14,
26818,
9,
267,
327,
2018,
2356,
499,
14,
23,
14,
20,
12,
650,
14,
19,
3181,
1133,
1172,
4440,
63,
7677,
267,
340,
2519,
8,
4078,
63,
1122,
12,
283,
5589,
63,
7677,
297,
488,
304,
288,
4011,
63,
1122,
14,
5589,
63,
7677,
14,
2880,
8,
277,
14,
26818,
9,
267,
1613,
8,
54,
1259,
11532,
12,
291,
2843,
826,
4533,
339,
347,
636,
1661,
721,
277,
304,
267,
372,
291,
423,
5189,
855,
1661,
4533,
339,
768,
1829,
272,
347,
14745,
8,
277,
304,
267,
372,
769,
8,
277,
423,
5189,
14,
1459,
1012,
339,
768,
1829,
272,
347,
22310,
8,
277,
304,
267,
372,
359,
4620,
14,
3475,
367,
4865,
315,
291,
14,
7765,
61,
339,
768,
1829,
272,
347,
1006,
63,
26818,
8,
277,
304,
267,
21149,
275,
942,
267,
367,
4865,
315,
291,
14,
7765,
26,
288,
21149,
14,
2880,
8,
4620,
14,
26818,
9,
267,
372,
21149,
339,
347,
2274,
8,
277,
12,
843,
304,
267,
340,
440,
2688,
8,
1886,
12,
283,
354,
735,
288,
2512,
14,
3764,
360,
6612,
2274,
23563,
450,
83,
297,
843,
855,
354,
3368,
288,
372,
267,
340,
843,
14,
354,
440,
315,
291,
423,
5189,
26,
288,
291,
423,
5189,
59,
1886,
14,
354,
61,
275,
843,
288,
2512,
14,
1757,
360,
20341,
23563,
4865,
26,
450,
83,
297,
843,
14,
354,
9,
339,
347,
24369,
8,
277,
12,
843,
29,
403,
12,
536,
29,
403,
304,
267,
340,
536,
315,
291,
423,
5189,
26,
288,
2150,
291,
423,
5189,
59,
354,
61,
267,
916,
843,
315,
291,
423,
5189,
14,
1459,
837,
288,
2150,
291,
423,
5189,
59,
1886,
14,
354,
61,
267,
587,
26,
288,
2512,
14,
3764,
360,
6612,
24369,
2952,
949,
1021,
503,
536,
1627,
358,
339,
347,
664,
63,
4620,
63,
354,
8,
277,
12,
2909,
304,
267,
408,
267,
1432,
314,
536,
402,
314,
1015,
3304,
4865,
340,
1911,
737,
1627,
267,
2909,
12,
325,
14,
71,
14,
19827,
14,
362,
63,
4620,
63,
354,
2336,
515,
15,
475,
15,
15525,
15,
12891,
358,
267,
408,
267,
367,
16548,
63,
466,
315,
291,
423,
5189,
14,
1459,
837,
288,
340,
16548,
63,
466,
14,
13658,
63,
1985,
8,
1985,
304,
355,
2512,
14,
1757,
360,
21767,
626,
450,
83,
4440,
23563,
26,
450,
83,
297,
2490,
2909,
12,
16548,
63,
466,
14,
354,
9,
355,
372,
16548,
63,
466,
14,
354,
267,
372,
488,
339,
347,
664,
63,
4620,
8,
277,
12,
536,
304,
267,
536,
275,
536,
14,
2325,
342,
267,
340,
536,
315,
291,
423,
5189,
26,
288,
372,
291,
423,
5189,
59,
354,
61,
339,
347,
664,
63,
4620,
63,
504,
63,
1985,
8,
277,
12,
2909,
304,
267,
16548,
63,
466,
275,
291,
14,
362,
63,
4620,
63,
354,
8,
1985,
9,
267,
340,
16548,
63,
466,
26,
288,
372,
291,
14,
362,
63,
4620,
8,
6737,
63,
466,
9,
267,
372,
488,
421,
199,
15525,
275,
812,
1259,
11532,
342,
421,
199,
533,
3394,
3717,
8,
785,
304,
272,
536,
275,
2125,
272,
9017,
275,
2125,
272,
327,
3820,
402,
3748,
21149,
367,
642,
3394,
8612,
272,
21149,
275,
6248,
339,
347,
636,
826,
721,
277,
12,
1166,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
14,
633,
275,
1166,
267,
1613,
8,
3353,
3717,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
485,
374,
63,
1832,
63,
8421,
8,
277,
12,
3831,
304,
267,
408,
1779,
10694,
3679,
3792,
1343,
543,
747,
14,
515,
14,
4127,
12,
1779,
4747,
708,
7869,
7869,
1343,
543,
12912,
334,
2930,
286,
18589,
3741,
9,
267,
408,
267,
12912,
12,
9483,
275,
747,
14,
515,
14,
1294,
9541,
8,
3417,
9,
267,
372,
3831,
14,
2460,
8,
736,
14,
515,
14,
4127,
9,
503,
12912,
339,
327,
1666,
4976,
327,
709,
2658,
367,
10842,
642,
1083,
1990,
21399,
26,
272,
327,
4178,
921,
5031,
14,
957,
15,
647,
387,
15,
9983,
15,
10115,
15,
709,
2658,
272,
347,
9028,
63,
5799,
63,
30959,
8,
277,
12,
308,
21121,
304,
267,
327,
2104,
2893,
12,
5634,
965,
17347,
402,
314,
1824,
298,
11989,
15,
17,
14,
23,
14,
88,
1674,
267,
372,
308,
21121,
14,
1814,
10998,
18962,
339,
347,
4843,
8,
277,
12,
2909,
304,
267,
408,
267,
20220,
314,
7611,
737,
314,
1166,
370,
314,
5724,
2909,
267,
284,
14,
69,
14,
1454,
5235,
314,
1584,
12,
1928,
19827,
315,
17308,
267,
408,
267,
746,
4279,
339,
347,
664,
63,
633,
63,
4964,
8,
277,
304,
267,
408,
267,
1803,
314,
3211,
7611,
2851,
436,
6974,
701,
6057,
314,
1627,
267,
7611,
2851,
267,
408,
267,
1125,
63,
1188,
275,
334,
288,
298,
27143,
12,
1543,
83,
7,
365,
282,
24159,
23563,
1166,
14,
298,
288,
298,
1918,
1475,
365,
665,
15525,
30,
11,
28,
3922,
30,
921,
28,
633,
6244,
298,
288,
298,
69,
14,
71,
14,
11327,
11,
1014,
921,
1662,
3417,
15,
6836,
15,
5713,
2640,
3,
5799,
29,
5713,
2640,
2,
267,
776,
267,
702,
20246,
315,
291,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
elysium001/zamboni
|
sites/s3dev/settings_base.py
|
1
|
5495
|
"""private_base will be populated from puppet and placed in this directory"""
import logging
import os
import dj_database_url
from mkt.settings import (CACHE_PREFIX, ES_INDEXES,
KNOWN_PROXIES, LOGGING, HOSTNAME)
from .. import splitstrip
import private_base as private
ALLOWED_HOSTS = ['.allizom.org', '.mozflare.net']
ENGAGE_ROBOTS = False
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = private.EMAIL_HOST
DEBUG = False
TEMPLATE_DEBUG = DEBUG
DEBUG_PROPAGATE_EXCEPTIONS = False
SESSION_COOKIE_SECURE = True
ADMINS = ()
DATABASES = {}
DATABASES['default'] = dj_database_url.parse(private.DATABASES_DEFAULT_URL)
DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
DATABASES['default']['OPTIONS'] = {'init_command': 'SET storage_engine=InnoDB'}
DATABASES['default']['ATOMIC_REQUESTS'] = True
DATABASES['default']['CONN_MAX_AGE'] = 5 * 60 # 5m for persistent connections.
DATABASES['slave'] = dj_database_url.parse(private.DATABASES_SLAVE_URL)
DATABASES['slave']['ENGINE'] = 'django.db.backends.mysql'
DATABASES['slave']['OPTIONS'] = {'init_command': 'SET storage_engine=InnoDB'}
DATABASES['slave']['sa_pool_key'] = 'slave'
DATABASES['slave']['ATOMIC_REQUESTS'] = True
DATABASES['slave']['CONN_MAX_AGE'] = 5 * 60 # 5m for persistent connections.
SERVICES_DATABASE = dj_database_url.parse(private.SERVICES_DATABASE_URL)
SLAVE_DATABASES = ['slave']
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': splitstrip(private.CACHES_DEFAULT_LOCATION),
'TIMEOUT': 500,
'KEY_PREFIX': CACHE_PREFIX,
}
}
SECRET_KEY = private.SECRET_KEY
LOG_LEVEL = logging.DEBUG
# Celery
BROKER_URL = private.BROKER_URL
CELERY_ALWAYS_EAGER = False
CELERY_IGNORE_RESULT = True
CELERY_DISABLE_RATE_LIMITS = True
CELERYD_PREFETCH_MULTIPLIER = 1
NETAPP_STORAGE = private.NETAPP_STORAGE_ROOT + '/shared_storage'
GUARDED_ADDONS_PATH = private.NETAPP_STORAGE_ROOT + '/guarded-addons'
UPLOADS_PATH = NETAPP_STORAGE + '/uploads'
ADDON_ICONS_PATH = UPLOADS_PATH + '/addon_icons'
WEBSITE_ICONS_PATH = UPLOADS_PATH + '/website_icons'
FEATURED_APP_BG_PATH = UPLOADS_PATH + '/featured_app_background'
FEED_COLLECTION_BG_PATH = UPLOADS_PATH + '/feed_collection_background'
FEED_SHELF_BG_PATH = UPLOADS_PATH + '/feed_shelf_background'
IMAGEASSETS_PATH = UPLOADS_PATH + '/imageassets'
REVIEWER_ATTACHMENTS_PATH = UPLOADS_PATH + '/reviewer_attachment'
PREVIEWS_PATH = UPLOADS_PATH + '/previews'
WEBAPP_PROMO_IMG_PATH = UPLOADS_PATH + '/webapp_promo_imgs'
WEBSITE_PROMO_IMG_PATH = UPLOADS_PATH + '/website_promo_imgs'
SIGNED_APPS_PATH = NETAPP_STORAGE + '/signed_apps'
SIGNED_APPS_REVIEWER_PATH = NETAPP_STORAGE + '/signed_apps_reviewer'
PREVIEW_THUMBNAIL_PATH = PREVIEWS_PATH + '/thumbs/%s/%d.png'
PREVIEW_FULL_PATH = PREVIEWS_PATH + '/full/%s/%d.%s'
EXTENSIONS_PATH = NETAPP_STORAGE + '/extensions'
SIGNED_EXTENSIONS_PATH = NETAPP_STORAGE + '/signed-extensions'
LOGGING['loggers'].update({
'amqp': {'level': logging.WARNING},
'raven': {'level': logging.WARNING},
'requests': {'level': logging.WARNING},
'z.addons': {'level': logging.DEBUG},
'z.elasticsearch': {'level': logging.DEBUG},
'z.pool': {'level': logging.ERROR},
'z.task': {'level': logging.DEBUG},
'z.users': {'level': logging.DEBUG},
})
TMP_PATH = os.path.join(NETAPP_STORAGE, 'tmp')
ADDONS_PATH = private.NETAPP_STORAGE_ROOT + '/files'
SPIDERMONKEY = '/usr/bin/tracemonkey'
csp = 'csp.middleware.CSPMiddleware'
RESPONSYS_ID = private.RESPONSYS_ID
CRONJOB_LOCK_PREFIX = 'mkt-s3dev'
ES_DEFAULT_NUM_REPLICAS = 2
ES_HOSTS = splitstrip(private.ES_HOSTS)
ES_URLS = ['http://%s' % h for h in ES_HOSTS]
ES_INDEXES = dict((k, '%s_s3dev' % v) for k, v in ES_INDEXES.items())
STATSD_HOST = private.STATSD_HOST
STATSD_PORT = private.STATSD_PORT
STATSD_PREFIX = private.STATSD_PREFIX
CEF_PRODUCT = STATSD_PREFIX
ES_TIMEOUT = 60
EXPOSE_VALIDATOR_TRACEBACKS = False
KNOWN_PROXIES += ['10.2.83.105',
'10.2.83.106',
'10.2.83.107',
'10.8.83.200',
'10.8.83.201',
'10.8.83.202',
'10.8.83.203',
'10.8.83.204',
'10.8.83.210',
'10.8.83.211',
'10.8.83.212',
'10.8.83.213',
'10.8.83.214',
'10.8.83.215',
'10.8.83.251',
'10.8.83.252',
'10.8.83.253',
]
NEW_FEATURES = True
CLEANCSS_BIN = 'cleancss'
LESS_BIN = 'lessc'
STYLUS_BIN = 'stylus'
UGLIFY_BIN = 'uglifyjs'
CELERYD_TASK_SOFT_TIME_LIMIT = 540
VALIDATOR_TIMEOUT = 180
LESS_PREPROCESS = True
XSENDFILE = True
ALLOW_SELF_REVIEWS = True
GOOGLE_ANALYTICS_CREDENTIALS = private.GOOGLE_ANALYTICS_CREDENTIALS
GOOGLE_API_CREDENTIALS = private.GOOGLE_API_CREDENTIALS
MONOLITH_SERVER = 'https://monolith-dev.allizom.org'
GEOIP_URL = 'https://geo-dev-marketplace.allizom.org'
AWS_ACCESS_KEY_ID = private.AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY = private.AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME = private.AWS_STORAGE_BUCKET_NAME
RAISE_ON_SIGNAL_ERROR = True
API_THROTTLE = False
NEWRELIC_ENABLED_LIST = ['dev1.addons.phx1.mozilla.com',
'dev2.addons.phx1.mozilla.com']
NEWRELIC_ENABLE = HOSTNAME in NEWRELIC_ENABLED_LIST
AES_KEYS = private.AES_KEYS
TASK_USER_ID = 4757633
SERVE_TMP_PATH = False
|
bsd-3-clause
|
[
624,
4239,
63,
1095,
911,
506,
16460,
687,
299,
17934,
436,
15090,
315,
642,
2082,
624,
199,
199,
646,
2050,
199,
646,
747,
199,
199,
646,
366,
74,
63,
4659,
63,
633,
199,
199,
504,
21825,
14,
1751,
492,
334,
8677,
63,
6351,
12,
10427,
63,
10215,
654,
12,
2079,
1804,
9165,
63,
2514,
56,
2563,
12,
3412,
22790,
12,
25741,
2339,
9,
199,
199,
504,
2508,
492,
3715,
1913,
199,
646,
5726,
63,
1095,
465,
5726,
199,
199,
17350,
63,
23775,
275,
18953,
279,
19030,
676,
14,
1308,
297,
1987,
23120,
14163,
264,
14,
846,
418,
199,
199,
742,
39,
2962,
63,
1092,
11372,
51,
275,
756,
199,
199,
10089,
63,
18145,
275,
283,
1176,
14,
1018,
14,
1198,
14,
7765,
14,
15592,
14,
7035,
8447,
7,
199,
10089,
63,
5449,
275,
5726,
14,
10089,
63,
5449,
199,
199,
5287,
275,
756,
199,
7433,
63,
5287,
275,
10990,
199,
5287,
63,
19926,
1254,
1951,
63,
25054,
275,
756,
199,
12763,
63,
13665,
63,
20696,
275,
715,
199,
199,
14288,
51,
275,
6248,
199,
199,
27260,
275,
1052,
199,
27260,
459,
885,
418,
275,
366,
74,
63,
4659,
63,
633,
14,
1122,
8,
4239,
14,
27260,
63,
3472,
63,
2632,
9,
199,
27260,
459,
885,
2545,
15956,
418,
275,
283,
1176,
14,
697,
14,
7765,
14,
8644,
7,
199,
27260,
459,
885,
2545,
8808,
418,
275,
791,
826,
63,
1531,
356,
283,
3597,
4887,
63,
3908,
29,
607,
889,
2846,
936,
199,
27260,
459,
885,
2545,
22479,
948,
63,
6780,
51,
418,
275,
715,
199,
27260,
459,
885,
2545,
17489,
63,
4283,
63,
2962,
418,
275,
959,
627,
5212,
221,
327,
959,
77,
367,
16149,
6947,
14,
199,
199,
27260,
459,
12384,
418,
275,
366,
74,
63,
4659,
63,
633,
14,
1122,
8,
4239,
14,
27260,
63,
4929,
26907,
63,
2632,
9,
199,
27260,
459,
12384,
2545,
15956,
418,
275,
283,
1176,
14,
697,
14,
7765,
14,
8644,
7,
199,
27260,
459,
12384,
2545,
8808,
418,
275,
791,
826,
63,
1531,
356,
283,
3597,
4887,
63,
3908,
29,
607,
889,
2846,
936,
199,
27260,
459,
12384,
2545,
2231,
63,
2293,
63,
498,
418,
275,
283,
12384,
7,
199,
27260,
459,
12384,
2545,
22479,
948,
63,
6780,
51,
418,
275,
715,
199,
27260,
459,
12384,
2545,
17489,
63,
4283,
63,
2962,
418,
275,
959,
627,
5212,
221,
327,
959,
77,
367,
16149,
6947,
14,
199,
199,
3279,
8670,
63,
17873,
275,
366,
74,
63,
4659,
63,
633,
14,
1122,
8,
4239,
14,
3279,
8670,
63,
17873,
63,
2632,
9,
199,
199,
4929,
26907,
63,
27260,
275,
788,
12384,
418,
199,
199,
3263,
1244,
654,
275,
469,
272,
283,
885,
356,
469,
267,
283,
18145,
356,
283,
1176,
14,
1018,
14,
1637,
14,
7765,
14,
32567,
14,
14169,
5245,
4437,
297,
267,
283,
16575,
356,
3715,
1913,
8,
4239,
14,
3263,
1244,
654,
63,
3472,
63,
16575,
395,
267,
283,
8899,
356,
6891,
12,
267,
283,
3078,
63,
6351,
356,
7240,
4576,
63,
6351,
12,
272,
789,
199,
93,
199,
199,
12961,
63,
3078,
275,
5726,
14,
12961,
63,
3078,
199,
199,
4947,
63,
11817,
275,
2050,
14,
5287,
199,
199,
3,
445,
19028,
199,
21111,
19972,
63,
2632,
275,
5726,
14,
21111,
19972,
63,
2632,
199,
199,
30922,
63,
32509,
63,
37,
1254,
540,
275,
756,
199,
30922,
63,
11209,
63,
9517,
275,
715,
199,
30922,
63,
13052,
63,
16553,
63,
13387,
51,
275,
715,
199,
30922,
36,
63,
4225,
32097,
63,
21894,
2673,
540,
275,
413,
199,
199,
7278,
7121,
63,
17467,
275,
5726,
14,
7278,
7121,
63,
17467,
63,
5441,
435,
1994,
5555,
63,
3494,
7,
199,
17188,
689,
8280,
63,
9732,
23300,
63,
3243,
275,
5726,
14,
7278,
7121,
63,
17467,
63,
5441,
435,
1994,
6051,
12910,
13,
10788,
7,
199,
16418,
51,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
21725,
7,
199,
9732,
615,
63,
15903,
51,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
9291,
63,
16471,
7,
199,
13166,
7917,
63,
15903,
51,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
7360,
63,
16471,
7,
199,
22884,
36,
63,
7121,
63,
18998,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
30779,
63,
571,
63,
7451,
7,
199,
18068,
63,
29374,
63,
18998,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
3871,
63,
3627,
63,
7451,
7,
199,
18068,
63,
20255,
15965,
63,
18998,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
3871,
63,
19195,
276,
63,
7451,
7,
199,
9438,
1179,
3597,
51,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
1569,
12186,
7,
199,
907,
12058,
540,
63,
23890,
1244,
20967,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
23492,
63,
8905,
7,
199,
28422,
4332,
5035,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
657,
4196,
7,
199,
13166,
7121,
63,
2514,
2679,
63,
26246,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
22632,
63,
12741,
79,
63,
1017,
458,
7,
199,
13166,
7917,
63,
2514,
2679,
63,
26246,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
7360,
63,
12741,
79,
63,
1017,
458,
7,
199,
24184,
63,
14219,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
1737,
63,
5181,
7,
199,
24184,
63,
14219,
63,
907,
12058,
540,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
1737,
63,
5181,
63,
23492,
7,
199,
4225,
12058,
63,
2080,
2639,
18273,
6593,
63,
3243,
275,
19924,
54,
4332,
5035,
63,
3243,
435,
1994,
273,
23135,
3149,
83,
3149,
68,
14,
4524,
7,
199,
4225,
12058,
63,
14742,
63,
3243,
275,
19924,
54,
4332,
5035,
63,
3243,
435,
1994,
2861,
3149,
83,
3149,
68,
4111,
83,
7,
199,
18451,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
5359,
7,
199,
24184,
63,
18451,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
1737,
13,
5359,
7,
199,
199,
27896,
459,
22771,
2278,
873,
2561,
272,
283,
455,
15202,
356,
791,
1896,
356,
2050,
14,
9171,
1386,
272,
283,
345,
1856,
356,
791,
1896,
356,
2050,
14,
9171,
1386,
272,
283,
6615,
356,
791,
1896,
356,
2050,
14,
9171,
1386,
272,
283,
90,
14,
10788
] |
[
4239,
63,
1095,
911,
506,
16460,
687,
299,
17934,
436,
15090,
315,
642,
2082,
624,
199,
199,
646,
2050,
199,
646,
747,
199,
199,
646,
366,
74,
63,
4659,
63,
633,
199,
199,
504,
21825,
14,
1751,
492,
334,
8677,
63,
6351,
12,
10427,
63,
10215,
654,
12,
2079,
1804,
9165,
63,
2514,
56,
2563,
12,
3412,
22790,
12,
25741,
2339,
9,
199,
199,
504,
2508,
492,
3715,
1913,
199,
646,
5726,
63,
1095,
465,
5726,
199,
199,
17350,
63,
23775,
275,
18953,
279,
19030,
676,
14,
1308,
297,
1987,
23120,
14163,
264,
14,
846,
418,
199,
199,
742,
39,
2962,
63,
1092,
11372,
51,
275,
756,
199,
199,
10089,
63,
18145,
275,
283,
1176,
14,
1018,
14,
1198,
14,
7765,
14,
15592,
14,
7035,
8447,
7,
199,
10089,
63,
5449,
275,
5726,
14,
10089,
63,
5449,
199,
199,
5287,
275,
756,
199,
7433,
63,
5287,
275,
10990,
199,
5287,
63,
19926,
1254,
1951,
63,
25054,
275,
756,
199,
12763,
63,
13665,
63,
20696,
275,
715,
199,
199,
14288,
51,
275,
6248,
199,
199,
27260,
275,
1052,
199,
27260,
459,
885,
418,
275,
366,
74,
63,
4659,
63,
633,
14,
1122,
8,
4239,
14,
27260,
63,
3472,
63,
2632,
9,
199,
27260,
459,
885,
2545,
15956,
418,
275,
283,
1176,
14,
697,
14,
7765,
14,
8644,
7,
199,
27260,
459,
885,
2545,
8808,
418,
275,
791,
826,
63,
1531,
356,
283,
3597,
4887,
63,
3908,
29,
607,
889,
2846,
936,
199,
27260,
459,
885,
2545,
22479,
948,
63,
6780,
51,
418,
275,
715,
199,
27260,
459,
885,
2545,
17489,
63,
4283,
63,
2962,
418,
275,
959,
627,
5212,
221,
327,
959,
77,
367,
16149,
6947,
14,
199,
199,
27260,
459,
12384,
418,
275,
366,
74,
63,
4659,
63,
633,
14,
1122,
8,
4239,
14,
27260,
63,
4929,
26907,
63,
2632,
9,
199,
27260,
459,
12384,
2545,
15956,
418,
275,
283,
1176,
14,
697,
14,
7765,
14,
8644,
7,
199,
27260,
459,
12384,
2545,
8808,
418,
275,
791,
826,
63,
1531,
356,
283,
3597,
4887,
63,
3908,
29,
607,
889,
2846,
936,
199,
27260,
459,
12384,
2545,
2231,
63,
2293,
63,
498,
418,
275,
283,
12384,
7,
199,
27260,
459,
12384,
2545,
22479,
948,
63,
6780,
51,
418,
275,
715,
199,
27260,
459,
12384,
2545,
17489,
63,
4283,
63,
2962,
418,
275,
959,
627,
5212,
221,
327,
959,
77,
367,
16149,
6947,
14,
199,
199,
3279,
8670,
63,
17873,
275,
366,
74,
63,
4659,
63,
633,
14,
1122,
8,
4239,
14,
3279,
8670,
63,
17873,
63,
2632,
9,
199,
199,
4929,
26907,
63,
27260,
275,
788,
12384,
418,
199,
199,
3263,
1244,
654,
275,
469,
272,
283,
885,
356,
469,
267,
283,
18145,
356,
283,
1176,
14,
1018,
14,
1637,
14,
7765,
14,
32567,
14,
14169,
5245,
4437,
297,
267,
283,
16575,
356,
3715,
1913,
8,
4239,
14,
3263,
1244,
654,
63,
3472,
63,
16575,
395,
267,
283,
8899,
356,
6891,
12,
267,
283,
3078,
63,
6351,
356,
7240,
4576,
63,
6351,
12,
272,
789,
199,
93,
199,
199,
12961,
63,
3078,
275,
5726,
14,
12961,
63,
3078,
199,
199,
4947,
63,
11817,
275,
2050,
14,
5287,
199,
199,
3,
445,
19028,
199,
21111,
19972,
63,
2632,
275,
5726,
14,
21111,
19972,
63,
2632,
199,
199,
30922,
63,
32509,
63,
37,
1254,
540,
275,
756,
199,
30922,
63,
11209,
63,
9517,
275,
715,
199,
30922,
63,
13052,
63,
16553,
63,
13387,
51,
275,
715,
199,
30922,
36,
63,
4225,
32097,
63,
21894,
2673,
540,
275,
413,
199,
199,
7278,
7121,
63,
17467,
275,
5726,
14,
7278,
7121,
63,
17467,
63,
5441,
435,
1994,
5555,
63,
3494,
7,
199,
17188,
689,
8280,
63,
9732,
23300,
63,
3243,
275,
5726,
14,
7278,
7121,
63,
17467,
63,
5441,
435,
1994,
6051,
12910,
13,
10788,
7,
199,
16418,
51,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
21725,
7,
199,
9732,
615,
63,
15903,
51,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
9291,
63,
16471,
7,
199,
13166,
7917,
63,
15903,
51,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
7360,
63,
16471,
7,
199,
22884,
36,
63,
7121,
63,
18998,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
30779,
63,
571,
63,
7451,
7,
199,
18068,
63,
29374,
63,
18998,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
3871,
63,
3627,
63,
7451,
7,
199,
18068,
63,
20255,
15965,
63,
18998,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
3871,
63,
19195,
276,
63,
7451,
7,
199,
9438,
1179,
3597,
51,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
1569,
12186,
7,
199,
907,
12058,
540,
63,
23890,
1244,
20967,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
23492,
63,
8905,
7,
199,
28422,
4332,
5035,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
657,
4196,
7,
199,
13166,
7121,
63,
2514,
2679,
63,
26246,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
22632,
63,
12741,
79,
63,
1017,
458,
7,
199,
13166,
7917,
63,
2514,
2679,
63,
26246,
63,
3243,
275,
7215,
7405,
51,
63,
3243,
435,
1994,
7360,
63,
12741,
79,
63,
1017,
458,
7,
199,
24184,
63,
14219,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
1737,
63,
5181,
7,
199,
24184,
63,
14219,
63,
907,
12058,
540,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
1737,
63,
5181,
63,
23492,
7,
199,
4225,
12058,
63,
2080,
2639,
18273,
6593,
63,
3243,
275,
19924,
54,
4332,
5035,
63,
3243,
435,
1994,
273,
23135,
3149,
83,
3149,
68,
14,
4524,
7,
199,
4225,
12058,
63,
14742,
63,
3243,
275,
19924,
54,
4332,
5035,
63,
3243,
435,
1994,
2861,
3149,
83,
3149,
68,
4111,
83,
7,
199,
18451,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
5359,
7,
199,
24184,
63,
18451,
63,
3243,
275,
18340,
7121,
63,
17467,
435,
1994,
1737,
13,
5359,
7,
199,
199,
27896,
459,
22771,
2278,
873,
2561,
272,
283,
455,
15202,
356,
791,
1896,
356,
2050,
14,
9171,
1386,
272,
283,
345,
1856,
356,
791,
1896,
356,
2050,
14,
9171,
1386,
272,
283,
6615,
356,
791,
1896,
356,
2050,
14,
9171,
1386,
272,
283,
90,
14,
10788,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
dagwieers/ansible
|
lib/ansible/modules/remote_management/oneview/oneview_ethernet_network_facts.py
|
125
|
4863
|
#!/usr/bin/python
# Copyright (c) 2016-2017 Hewlett Packard Enterprise Development LP
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: oneview_ethernet_network_facts
short_description: Retrieve the facts about one or more of the OneView Ethernet Networks
description:
- Retrieve the facts about one or more of the Ethernet Networks from OneView.
version_added: "2.4"
requirements:
- hpOneView >= 2.0.1
author:
- Felipe Bulsoni (@fgbulsoni)
- Thiago Miotto (@tmiotto)
- Adriane Cardozo (@adriane-cardozo)
options:
name:
description:
- Ethernet Network name.
options:
description:
- "List with options to gather additional facts about an Ethernet Network and related resources.
Options allowed: C(associatedProfiles) and C(associatedUplinkGroups)."
extends_documentation_fragment:
- oneview
- oneview.factsparams
'''
EXAMPLES = '''
- name: Gather facts about all Ethernet Networks
oneview_ethernet_network_facts:
config: /etc/oneview/oneview_config.json
delegate_to: localhost
- debug: var=ethernet_networks
- name: Gather paginated and filtered facts about Ethernet Networks
oneview_ethernet_network_facts:
config: /etc/oneview/oneview_config.json
params:
start: 1
count: 3
sort: 'name:descending'
filter: 'purpose=General'
delegate_to: localhost
- debug: var=ethernet_networks
- name: Gather facts about an Ethernet Network by name
oneview_ethernet_network_facts:
config: /etc/oneview/oneview_config.json
name: Ethernet network name
delegate_to: localhost
- debug: var=ethernet_networks
- name: Gather facts about an Ethernet Network by name with options
oneview_ethernet_network_facts:
config: /etc/oneview/oneview_config.json
name: eth1
options:
- associatedProfiles
- associatedUplinkGroups
delegate_to: localhost
- debug: var=enet_associated_profiles
- debug: var=enet_associated_uplink_groups
'''
RETURN = '''
ethernet_networks:
description: Has all the OneView facts about the Ethernet Networks.
returned: Always, but can be null.
type: dict
enet_associated_profiles:
description: Has all the OneView facts about the profiles which are using the Ethernet network.
returned: When requested, but can be null.
type: dict
enet_associated_uplink_groups:
description: Has all the OneView facts about the uplink sets which are using the Ethernet network.
returned: When requested, but can be null.
type: dict
'''
from ansible.module_utils.oneview import OneViewModuleBase
class EthernetNetworkFactsModule(OneViewModuleBase):
argument_spec = dict(
name=dict(type='str'),
options=dict(type='list'),
params=dict(type='dict')
)
def __init__(self):
super(EthernetNetworkFactsModule, self).__init__(additional_arg_spec=self.argument_spec)
self.resource_client = self.oneview_client.ethernet_networks
def execute_module(self):
ansible_facts = {}
if self.module.params['name']:
ethernet_networks = self.resource_client.get_by('name', self.module.params['name'])
if self.module.params.get('options') and ethernet_networks:
ansible_facts = self.__gather_optional_facts(ethernet_networks[0])
else:
ethernet_networks = self.resource_client.get_all(**self.facts_params)
ansible_facts['ethernet_networks'] = ethernet_networks
return dict(changed=False, ansible_facts=ansible_facts)
def __gather_optional_facts(self, ethernet_network):
ansible_facts = {}
if self.options.get('associatedProfiles'):
ansible_facts['enet_associated_profiles'] = self.__get_associated_profiles(ethernet_network)
if self.options.get('associatedUplinkGroups'):
ansible_facts['enet_associated_uplink_groups'] = self.__get_associated_uplink_groups(ethernet_network)
return ansible_facts
def __get_associated_profiles(self, ethernet_network):
associated_profiles = self.resource_client.get_associated_profiles(ethernet_network['uri'])
return [self.oneview_client.server_profiles.get(x) for x in associated_profiles]
def __get_associated_uplink_groups(self, ethernet_network):
uplink_groups = self.resource_client.get_associated_uplink_groups(ethernet_network['uri'])
return [self.oneview_client.uplink_sets.get(x) for x in uplink_groups]
def main():
EthernetNetworkFactsModule().run()
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1898,
334,
67,
9,
7800,
13,
10680,
27849,
9954,
1005,
29949,
15290,
21738,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
199,
3612,
63,
1802,
26,
13939,
314,
9036,
3595,
1373,
503,
1655,
402,
314,
7309,
2768,
26125,
17138,
199,
1802,
26,
272,
446,
13939,
314,
9036,
3595,
1373,
503,
1655,
402,
314,
26125,
17138,
687,
7309,
2768,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
20,
2,
199,
7538,
26,
272,
446,
20962,
4395,
2768,
2356,
499,
14,
16,
14,
17,
199,
2502,
26,
272,
446,
7949,
317,
321,
699,
348,
834,
73,
8593,
70,
4908,
348,
834,
73,
9,
272,
446,
3868,
73,
14315,
603,
73,
357,
475,
8593,
84,
2664,
357,
475,
9,
272,
446,
4431,
322,
5865,
445,
1005,
79,
18070,
8593,
350,
322,
5865,
13,
5841,
79,
18070,
9,
199,
1419,
26,
272,
536,
26,
489,
1369,
26,
267,
446,
26125,
7220,
536,
14,
272,
1511,
26,
489,
1369,
26,
267,
446,
298,
1296,
543,
1511,
370,
13082,
4722,
9036,
3595,
376,
26125,
7220,
436,
4048,
5944,
14,
881,
8394,
4370,
26,
445,
8,
22288,
30208,
9,
436,
445,
8,
22288,
29523,
10177,
17617,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
1373,
1345,
272,
446,
1373,
1345,
14,
5047,
1162,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
19634,
9036,
3595,
1006,
26125,
17138,
523,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
26,
272,
1101,
26,
1182,
6839,
15,
368,
1345,
15,
368,
1345,
63,
888,
14,
1001,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
3105,
26,
2729,
29,
20354,
63,
7642,
199,
199,
13,
536,
26,
19634,
9881,
23831,
436,
9806,
9036,
3595,
26125,
17138,
523,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
26,
272,
1101,
26,
1182,
6839,
15,
368,
1345,
15,
368,
1345,
63,
888,
14,
1001,
272,
1862,
26,
489,
1343,
26,
413,
489,
2338,
26,
650,
489,
4069,
26,
283,
354,
26,
3257,
3219,
7,
489,
2457,
26,
283,
22615,
29,
14109,
7,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
3105,
26,
2729,
29,
20354,
63,
7642,
199,
199,
13,
536,
26,
19634,
9036,
3595,
376,
26125,
7220,
701,
536,
523,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
26,
272,
1101,
26,
1182,
6839,
15,
368,
1345,
15,
368,
1345,
63,
888,
14,
1001,
272,
536,
26,
26125,
2784,
536,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
3105,
26,
2729,
29,
20354,
63,
7642,
199,
199,
13,
536,
26,
19634,
9036,
3595,
376,
26125,
7220,
701,
536,
543,
1511,
523,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
26,
272,
1101,
26,
1182,
6839,
15,
368,
1345,
15,
368,
1345,
63,
888,
14,
1001,
272,
536,
26,
16227,
17,
272,
1511,
26,
489,
446,
4568,
30208,
489,
446,
4568,
29523,
10177,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
3105,
26,
2729,
29,
287,
386,
63,
22288,
63,
11225,
199,
13,
3105,
26,
2729,
29,
287,
386,
63,
22288,
63,
28816,
63,
2634,
199,
2344,
199,
199,
9677,
275,
1449,
199,
20354,
63,
7642,
26,
272,
1369,
26,
13481,
1006,
314,
7309,
2768,
9036,
3595,
314,
26125,
17138,
14,
272,
2138,
26,
16763,
12,
1325,
883,
506,
2973,
14,
272,
730,
26,
1211,
199,
199,
287,
386,
63,
22288,
63,
11225,
26,
272,
1369,
26,
13481,
1006,
314,
7309,
2768,
9036,
3595,
314,
17390,
1314,
787,
1808,
314,
26125,
2784,
14,
272,
2138,
26,
3979,
5839,
12,
1325,
883,
506,
2973,
14,
272,
730,
26,
1211,
199,
199,
287,
386,
63,
22288,
63,
28816,
63,
2634,
26,
272,
1369,
26,
13481,
1006,
314,
7309,
2768,
9036,
3595,
314,
1536,
1073,
5951,
1314,
787,
1808,
314,
26125,
2784,
14,
272,
2138,
26,
3979,
5839,
12,
1325,
883,
506,
2973,
14,
272,
730,
26,
1211,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
368,
1345,
492,
7309,
2768,
2377,
1563,
421,
199,
533,
26125,
4491,
25821,
2377,
8,
4395,
2768,
2377,
1563,
304,
272,
1423,
63,
1650,
275,
1211,
8,
267,
536,
29,
807,
8,
466,
534,
495,
659,
267,
1511,
29,
807,
8,
466,
534,
513,
659,
267,
1862,
29,
807,
8,
466,
534,
807,
358,
272,
776,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
22056,
4491,
25821,
2377,
12,
291,
2843,
826,
721,
8460,
63,
1273,
63,
1650,
29,
277,
14,
2094,
63,
1650,
9,
398,
291,
14,
1927,
63,
1258,
275,
291,
14,
368,
1345,
63,
1258,
14,
20354,
63,
7642,
339,
347,
5341,
63,
578,
8,
277,
304,
267,
3242,
63,
5047,
275,
1052,
267,
340,
291,
14,
578,
14,
1162,
459,
354,
2565,
288,
21944,
63,
7642,
275,
291,
14,
1927,
63,
1258,
14,
362,
63,
991,
360,
354,
297,
291,
14,
578,
14,
1162,
459,
354,
1105,
953,
340,
291,
14,
578,
14,
1162,
14,
362,
360,
1419,
358,
436,
21944,
63,
7642,
26,
355,
3242,
63,
5047,
275,
291,
855,
13737,
63,
4144,
63,
5047,
8,
20354,
63,
7642,
59,
16,
566,
267,
587,
26,
288,
21944,
63,
7642,
275,
291,
14,
1927,
63,
1258,
14,
362,
63,
452,
3682,
277,
14,
5047,
63,
1162,
9,
398,
3242,
63,
5047,
459,
20354,
63,
7642,
418,
275,
21944,
63,
7642,
398,
372,
1211,
8,
2489,
29,
797,
12,
3242,
63,
5047,
29,
4853,
63,
5047,
9,
339,
347,
636,
13737,
63,
4144,
63,
5047,
8,
277,
12,
21944,
63,
1200,
304,
398,
3242,
63,
5047,
275,
1052,
398,
340,
291,
14,
1419,
14,
362,
360,
22288,
30208,
735,
288,
3242,
63
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1898,
334,
67,
9,
7800,
13,
10680,
27849,
9954,
1005,
29949,
15290,
21738,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
199,
3612,
63,
1802,
26,
13939,
314,
9036,
3595,
1373,
503,
1655,
402,
314,
7309,
2768,
26125,
17138,
199,
1802,
26,
272,
446,
13939,
314,
9036,
3595,
1373,
503,
1655,
402,
314,
26125,
17138,
687,
7309,
2768,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
20,
2,
199,
7538,
26,
272,
446,
20962,
4395,
2768,
2356,
499,
14,
16,
14,
17,
199,
2502,
26,
272,
446,
7949,
317,
321,
699,
348,
834,
73,
8593,
70,
4908,
348,
834,
73,
9,
272,
446,
3868,
73,
14315,
603,
73,
357,
475,
8593,
84,
2664,
357,
475,
9,
272,
446,
4431,
322,
5865,
445,
1005,
79,
18070,
8593,
350,
322,
5865,
13,
5841,
79,
18070,
9,
199,
1419,
26,
272,
536,
26,
489,
1369,
26,
267,
446,
26125,
7220,
536,
14,
272,
1511,
26,
489,
1369,
26,
267,
446,
298,
1296,
543,
1511,
370,
13082,
4722,
9036,
3595,
376,
26125,
7220,
436,
4048,
5944,
14,
881,
8394,
4370,
26,
445,
8,
22288,
30208,
9,
436,
445,
8,
22288,
29523,
10177,
17617,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
1373,
1345,
272,
446,
1373,
1345,
14,
5047,
1162,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
19634,
9036,
3595,
1006,
26125,
17138,
523,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
26,
272,
1101,
26,
1182,
6839,
15,
368,
1345,
15,
368,
1345,
63,
888,
14,
1001,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
3105,
26,
2729,
29,
20354,
63,
7642,
199,
199,
13,
536,
26,
19634,
9881,
23831,
436,
9806,
9036,
3595,
26125,
17138,
523,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
26,
272,
1101,
26,
1182,
6839,
15,
368,
1345,
15,
368,
1345,
63,
888,
14,
1001,
272,
1862,
26,
489,
1343,
26,
413,
489,
2338,
26,
650,
489,
4069,
26,
283,
354,
26,
3257,
3219,
7,
489,
2457,
26,
283,
22615,
29,
14109,
7,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
3105,
26,
2729,
29,
20354,
63,
7642,
199,
199,
13,
536,
26,
19634,
9036,
3595,
376,
26125,
7220,
701,
536,
523,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
26,
272,
1101,
26,
1182,
6839,
15,
368,
1345,
15,
368,
1345,
63,
888,
14,
1001,
272,
536,
26,
26125,
2784,
536,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
3105,
26,
2729,
29,
20354,
63,
7642,
199,
199,
13,
536,
26,
19634,
9036,
3595,
376,
26125,
7220,
701,
536,
543,
1511,
523,
1373,
1345,
63,
20354,
63,
1200,
63,
5047,
26,
272,
1101,
26,
1182,
6839,
15,
368,
1345,
15,
368,
1345,
63,
888,
14,
1001,
272,
536,
26,
16227,
17,
272,
1511,
26,
489,
446,
4568,
30208,
489,
446,
4568,
29523,
10177,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
3105,
26,
2729,
29,
287,
386,
63,
22288,
63,
11225,
199,
13,
3105,
26,
2729,
29,
287,
386,
63,
22288,
63,
28816,
63,
2634,
199,
2344,
199,
199,
9677,
275,
1449,
199,
20354,
63,
7642,
26,
272,
1369,
26,
13481,
1006,
314,
7309,
2768,
9036,
3595,
314,
26125,
17138,
14,
272,
2138,
26,
16763,
12,
1325,
883,
506,
2973,
14,
272,
730,
26,
1211,
199,
199,
287,
386,
63,
22288,
63,
11225,
26,
272,
1369,
26,
13481,
1006,
314,
7309,
2768,
9036,
3595,
314,
17390,
1314,
787,
1808,
314,
26125,
2784,
14,
272,
2138,
26,
3979,
5839,
12,
1325,
883,
506,
2973,
14,
272,
730,
26,
1211,
199,
199,
287,
386,
63,
22288,
63,
28816,
63,
2634,
26,
272,
1369,
26,
13481,
1006,
314,
7309,
2768,
9036,
3595,
314,
1536,
1073,
5951,
1314,
787,
1808,
314,
26125,
2784,
14,
272,
2138,
26,
3979,
5839,
12,
1325,
883,
506,
2973,
14,
272,
730,
26,
1211,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
368,
1345,
492,
7309,
2768,
2377,
1563,
421,
199,
533,
26125,
4491,
25821,
2377,
8,
4395,
2768,
2377,
1563,
304,
272,
1423,
63,
1650,
275,
1211,
8,
267,
536,
29,
807,
8,
466,
534,
495,
659,
267,
1511,
29,
807,
8,
466,
534,
513,
659,
267,
1862,
29,
807,
8,
466,
534,
807,
358,
272,
776,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
22056,
4491,
25821,
2377,
12,
291,
2843,
826,
721,
8460,
63,
1273,
63,
1650,
29,
277,
14,
2094,
63,
1650,
9,
398,
291,
14,
1927,
63,
1258,
275,
291,
14,
368,
1345,
63,
1258,
14,
20354,
63,
7642,
339,
347,
5341,
63,
578,
8,
277,
304,
267,
3242,
63,
5047,
275,
1052,
267,
340,
291,
14,
578,
14,
1162,
459,
354,
2565,
288,
21944,
63,
7642,
275,
291,
14,
1927,
63,
1258,
14,
362,
63,
991,
360,
354,
297,
291,
14,
578,
14,
1162,
459,
354,
1105,
953,
340,
291,
14,
578,
14,
1162,
14,
362,
360,
1419,
358,
436,
21944,
63,
7642,
26,
355,
3242,
63,
5047,
275,
291,
855,
13737,
63,
4144,
63,
5047,
8,
20354,
63,
7642,
59,
16,
566,
267,
587,
26,
288,
21944,
63,
7642,
275,
291,
14,
1927,
63,
1258,
14,
362,
63,
452,
3682,
277,
14,
5047,
63,
1162,
9,
398,
3242,
63,
5047,
459,
20354,
63,
7642,
418,
275,
21944,
63,
7642,
398,
372,
1211,
8,
2489,
29,
797,
12,
3242,
63,
5047,
29,
4853,
63,
5047,
9,
339,
347,
636,
13737,
63,
4144,
63,
5047,
8,
277,
12,
21944,
63,
1200,
304,
398,
3242,
63,
5047,
275,
1052,
398,
340,
291,
14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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
flyfei/python-for-android
|
python3-alpha/python3-src/Lib/test/test_pkgimport.py
|
57
|
2757
|
import os
import sys
import shutil
import string
import random
import tempfile
import unittest
from imp import cache_from_source
from test.support import run_unittest
class TestImport(unittest.TestCase):
def __init__(self, *args, **kw):
self.package_name = 'PACKAGE_'
while self.package_name in sys.modules:
self.package_name += random.choose(string.ascii_letters)
self.module_name = self.package_name + '.foo'
unittest.TestCase.__init__(self, *args, **kw)
def remove_modules(self):
for module_name in (self.package_name, self.module_name):
if module_name in sys.modules:
del sys.modules[module_name]
def setUp(self):
self.test_dir = tempfile.mkdtemp()
sys.path.append(self.test_dir)
self.package_dir = os.path.join(self.test_dir,
self.package_name)
os.mkdir(self.package_dir)
open(os.path.join(self.package_dir, '__init__.py'), 'w').close()
self.module_path = os.path.join(self.package_dir, 'foo.py')
def tearDown(self):
shutil.rmtree(self.test_dir)
self.assertNotEqual(sys.path.count(self.test_dir), 0)
sys.path.remove(self.test_dir)
self.remove_modules()
def rewrite_file(self, contents):
compiled_path = cache_from_source(self.module_path)
if os.path.exists(compiled_path):
os.remove(compiled_path)
with open(self.module_path, 'w') as f:
f.write(contents)
def test_package_import__semantics(self):
# Generate a couple of broken modules to try importing.
# ...try loading the module when there's a SyntaxError
self.rewrite_file('for')
try: __import__(self.module_name)
except SyntaxError: pass
else: raise RuntimeError('Failed to induce SyntaxError') # self.fail()?
self.assertNotIn(self.module_name, sys.modules)
self.assertFalse(hasattr(sys.modules[self.package_name], 'foo'))
# ...make up a variable name that isn't bound in __builtins__
var = 'a'
while var in dir(__builtins__):
var += random.choose(string.ascii_letters)
# ...make a module that just contains that
self.rewrite_file(var)
try: __import__(self.module_name)
except NameError: pass
else: raise RuntimeError('Failed to induce NameError.')
# ...now change the module so that the NameError doesn't
# happen
self.rewrite_file('%s = 1' % var)
module = __import__(self.module_name).foo
self.assertEqual(getattr(module, var), 1)
def test_main():
run_unittest(TestImport)
if __name__ == "__main__":
test_main()
|
apache-2.0
|
[
646,
747,
199,
646,
984,
199,
646,
5145,
199,
646,
1059,
199,
646,
2196,
199,
646,
5549,
199,
646,
2882,
199,
199,
504,
1742,
492,
2581,
63,
504,
63,
1365,
199,
504,
511,
14,
4058,
492,
1255,
63,
2796,
199,
199,
533,
1379,
6295,
8,
2796,
14,
1746,
304,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
291,
14,
2491,
63,
354,
275,
283,
19265,
8650,
267,
1830,
291,
14,
2491,
63,
354,
315,
984,
14,
3112,
26,
288,
291,
14,
2491,
63,
354,
847,
2196,
14,
16143,
8,
875,
14,
4371,
63,
16415,
9,
267,
291,
14,
578,
63,
354,
275,
291,
14,
2491,
63,
354,
435,
1987,
1421,
7,
267,
2882,
14,
1746,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
9,
339,
347,
2813,
63,
3112,
8,
277,
304,
267,
367,
859,
63,
354,
315,
334,
277,
14,
2491,
63,
354,
12,
291,
14,
578,
63,
354,
304,
288,
340,
859,
63,
354,
315,
984,
14,
3112,
26,
355,
2150,
984,
14,
3112,
59,
578,
63,
354,
61,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
396,
63,
694,
275,
5549,
14,
11983,
342,
267,
984,
14,
515,
14,
740,
8,
277,
14,
396,
63,
694,
9,
267,
291,
14,
2491,
63,
694,
275,
747,
14,
515,
14,
904,
8,
277,
14,
396,
63,
694,
12,
3147,
291,
14,
2491,
63,
354,
9,
267,
747,
14,
8215,
8,
277,
14,
2491,
63,
694,
9,
267,
1551,
8,
736,
14,
515,
14,
904,
8,
277,
14,
2491,
63,
694,
12,
2560,
826,
4343,
647,
659,
283,
87,
1959,
1600,
342,
267,
291,
14,
578,
63,
515,
275,
747,
14,
515,
14,
904,
8,
277,
14,
2491,
63,
694,
12,
283,
1421,
14,
647,
358,
339,
347,
6766,
8,
277,
304,
267,
5145,
14,
9242,
8,
277,
14,
396,
63,
694,
9,
267,
291,
14,
7418,
8,
1274,
14,
515,
14,
835,
8,
277,
14,
396,
63,
694,
395,
378,
9,
267,
984,
14,
515,
14,
2168,
8,
277,
14,
396,
63,
694,
9,
267,
291,
14,
2168,
63,
3112,
342,
339,
347,
19913,
63,
493,
8,
277,
12,
4072,
304,
267,
10311,
63,
515,
275,
2581,
63,
504,
63,
1365,
8,
277,
14,
578,
63,
515,
9,
267,
340,
747,
14,
515,
14,
2444,
8,
8427,
63,
515,
304,
288,
747,
14,
2168,
8,
8427,
63,
515,
9,
267,
543,
1551,
8,
277,
14,
578,
63,
515,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
952,
8,
4407,
9,
339,
347,
511,
63,
2491,
63,
646,
363,
261,
1237,
7769,
8,
277,
304,
398,
327,
7958,
282,
17535,
402,
10529,
4621,
370,
862,
16306,
14,
398,
327,
2263,
893,
8697,
314,
859,
1380,
2337,
1159,
282,
12053,
267,
291,
14,
14366,
63,
493,
360,
509,
358,
267,
862,
26,
636,
646,
721,
277,
14,
578,
63,
354,
9,
267,
871,
12053,
26,
986,
267,
587,
26,
746,
6064,
360,
4276,
370,
315,
3402,
12053,
358,
327,
291,
14,
1633,
342,
31,
267,
291,
14,
8795,
8,
277,
14,
578,
63,
354,
12,
984,
14,
3112,
9,
267,
291,
14,
3334,
8,
11161,
8,
1274,
14,
3112,
59,
277,
14,
2491,
63,
354,
467,
283,
1421,
1333,
398,
327,
2263,
1875,
1536,
282,
1750,
536,
626,
5712,
1133,
3914,
315,
636,
10372,
363,
267,
2729,
275,
283,
65,
7,
267,
1830,
2729,
315,
2935,
3460,
10372,
18580,
288,
2729,
847,
2196,
14,
16143,
8,
875,
14,
4371,
63,
16415,
9,
398,
327,
2263,
1875,
282,
859,
626,
2951,
3509,
626,
267,
291,
14,
14366,
63,
493,
8,
1391,
9,
398,
862,
26,
636,
646,
721,
277,
14,
578,
63,
354,
9,
267,
871,
12746,
26,
986,
267,
587,
26,
746,
6064,
360,
4276,
370,
315,
3402,
12746,
2659,
398,
327,
2263,
2131,
221,
1570,
221,
314,
859,
221,
880,
221,
626,
221,
314,
12746,
221,
3181,
1133,
267,
327,
5992,
267,
291,
14,
14366,
63,
493,
3508,
83,
275,
413,
7,
450,
2729,
9,
267,
859,
275,
636,
646,
721,
277,
14,
578,
63,
354,
680,
1421,
267,
291,
14,
629,
8,
5675,
8,
578,
12,
2729,
395,
413,
9,
421,
199,
318,
511,
63,
973,
837,
272,
1255,
63,
2796,
8,
774,
6295,
9,
421,
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
] |
[
747,
199,
646,
984,
199,
646,
5145,
199,
646,
1059,
199,
646,
2196,
199,
646,
5549,
199,
646,
2882,
199,
199,
504,
1742,
492,
2581,
63,
504,
63,
1365,
199,
504,
511,
14,
4058,
492,
1255,
63,
2796,
199,
199,
533,
1379,
6295,
8,
2796,
14,
1746,
304,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
291,
14,
2491,
63,
354,
275,
283,
19265,
8650,
267,
1830,
291,
14,
2491,
63,
354,
315,
984,
14,
3112,
26,
288,
291,
14,
2491,
63,
354,
847,
2196,
14,
16143,
8,
875,
14,
4371,
63,
16415,
9,
267,
291,
14,
578,
63,
354,
275,
291,
14,
2491,
63,
354,
435,
1987,
1421,
7,
267,
2882,
14,
1746,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
9,
339,
347,
2813,
63,
3112,
8,
277,
304,
267,
367,
859,
63,
354,
315,
334,
277,
14,
2491,
63,
354,
12,
291,
14,
578,
63,
354,
304,
288,
340,
859,
63,
354,
315,
984,
14,
3112,
26,
355,
2150,
984,
14,
3112,
59,
578,
63,
354,
61,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
396,
63,
694,
275,
5549,
14,
11983,
342,
267,
984,
14,
515,
14,
740,
8,
277,
14,
396,
63,
694,
9,
267,
291,
14,
2491,
63,
694,
275,
747,
14,
515,
14,
904,
8,
277,
14,
396,
63,
694,
12,
3147,
291,
14,
2491,
63,
354,
9,
267,
747,
14,
8215,
8,
277,
14,
2491,
63,
694,
9,
267,
1551,
8,
736,
14,
515,
14,
904,
8,
277,
14,
2491,
63,
694,
12,
2560,
826,
4343,
647,
659,
283,
87,
1959,
1600,
342,
267,
291,
14,
578,
63,
515,
275,
747,
14,
515,
14,
904,
8,
277,
14,
2491,
63,
694,
12,
283,
1421,
14,
647,
358,
339,
347,
6766,
8,
277,
304,
267,
5145,
14,
9242,
8,
277,
14,
396,
63,
694,
9,
267,
291,
14,
7418,
8,
1274,
14,
515,
14,
835,
8,
277,
14,
396,
63,
694,
395,
378,
9,
267,
984,
14,
515,
14,
2168,
8,
277,
14,
396,
63,
694,
9,
267,
291,
14,
2168,
63,
3112,
342,
339,
347,
19913,
63,
493,
8,
277,
12,
4072,
304,
267,
10311,
63,
515,
275,
2581,
63,
504,
63,
1365,
8,
277,
14,
578,
63,
515,
9,
267,
340,
747,
14,
515,
14,
2444,
8,
8427,
63,
515,
304,
288,
747,
14,
2168,
8,
8427,
63,
515,
9,
267,
543,
1551,
8,
277,
14,
578,
63,
515,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
952,
8,
4407,
9,
339,
347,
511,
63,
2491,
63,
646,
363,
261,
1237,
7769,
8,
277,
304,
398,
327,
7958,
282,
17535,
402,
10529,
4621,
370,
862,
16306,
14,
398,
327,
2263,
893,
8697,
314,
859,
1380,
2337,
1159,
282,
12053,
267,
291,
14,
14366,
63,
493,
360,
509,
358,
267,
862,
26,
636,
646,
721,
277,
14,
578,
63,
354,
9,
267,
871,
12053,
26,
986,
267,
587,
26,
746,
6064,
360,
4276,
370,
315,
3402,
12053,
358,
327,
291,
14,
1633,
342,
31,
267,
291,
14,
8795,
8,
277,
14,
578,
63,
354,
12,
984,
14,
3112,
9,
267,
291,
14,
3334,
8,
11161,
8,
1274,
14,
3112,
59,
277,
14,
2491,
63,
354,
467,
283,
1421,
1333,
398,
327,
2263,
1875,
1536,
282,
1750,
536,
626,
5712,
1133,
3914,
315,
636,
10372,
363,
267,
2729,
275,
283,
65,
7,
267,
1830,
2729,
315,
2935,
3460,
10372,
18580,
288,
2729,
847,
2196,
14,
16143,
8,
875,
14,
4371,
63,
16415,
9,
398,
327,
2263,
1875,
282,
859,
626,
2951,
3509,
626,
267,
291,
14,
14366,
63,
493,
8,
1391,
9,
398,
862,
26,
636,
646,
721,
277,
14,
578,
63,
354,
9,
267,
871,
12746,
26,
986,
267,
587,
26,
746,
6064,
360,
4276,
370,
315,
3402,
12746,
2659,
398,
327,
2263,
2131,
221,
1570,
221,
314,
859,
221,
880,
221,
626,
221,
314,
12746,
221,
3181,
1133,
267,
327,
5992,
267,
291,
14,
14366,
63,
493,
3508,
83,
275,
413,
7,
450,
2729,
9,
267,
859,
275,
636,
646,
721,
277,
14,
578,
63,
354,
680,
1421,
267,
291,
14,
629,
8,
5675,
8,
578,
12,
2729,
395,
413,
9,
421,
199,
318,
511,
63,
973,
837,
272,
1255,
63,
2796,
8,
774,
6295,
9,
421,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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undation licenses this file to you under the Apache 2.0 License.
# See the LICENSE file in the project root for more information.
'''
This tests what CPythons test_sha.py does not hit.
'''
import _sha512
import unittest
from iptest import is_cli, run_test
class _Sha512Test(unittest.TestCase):
def test_sanity(self):
self.assertTrue("__doc__" in dir(_sha512))
if is_cli:
self.assertEqual(_sha512.__doc__, "SHA512 hash algorithm")
self.assertTrue("__name__" in dir(_sha512))
self.assertTrue("sha384" in dir (_sha512))
self.assertTrue("sha512" in dir(_sha512))
self.assertEqual(len(dir(_sha512)), 5, "there should be 5 attributes in the _sha512 module")
def test_sha512_sanity(self):
x = _sha512.sha512()
self.assertEqual(x.block_size, 128)
self.assertEqual(x.digest(),
"\xcf\x83\xe15~\xef\xb8\xbd\xf1T(P\xd6m\x80\x07\xd6 \xe4\x05\x0bW\x15\xdc\x83\xf4\xa9!\xd3l\xe9\xceG\xd0\xd1<]\x85\xf2\xb0\xff\x83\x18\xd2\x87~\xec/c\xb91\xbdGAz\x81\xa582z\xf9'\xda>")
self.assertEqual(x.digest_size, 64)
self.assertEqual(x.digest_size, x.digestsize)
self.assertEqual(x.hexdigest(),
'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e')
self.assertEqual(x.name, "SHA512")
x.update("abc")
self.assertEqual(x.hexdigest(),
'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f')
x_copy = x.copy()
self.assertTrue(x!=x_copy)
self.assertEqual(x.hexdigest(), x_copy.hexdigest())
def test_sha384_sanity(self):
x = _sha512.sha384()
self.assertEqual(x.block_size, 128)
self.assertEqual(x.digest(),
"8\xb0`\xa7Q\xac\x968L\xd92~\xb1\xb1\xe3j!\xfd\xb7\x11\x14\xbe\x07CL\x0c\xc7\xbfc\xf6\xe1\xda'N\xde\xbf\xe7oe\xfb\xd5\x1a\xd2\xf1H\x98\xb9[")
self.assertEqual(x.digest_size, 48)
self.assertEqual(x.digest_size, x.digestsize)
self.assertEqual(x.hexdigest(),
'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b')
self.assertEqual(x.name, "SHA384")
x.update("abc")
self.assertEqual(x.hexdigest(),
'cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7')
x_copy = x.copy()
self.assertTrue(x!=x_copy)
self.assertEqual(x.hexdigest(), x_copy.hexdigest())
run_test(__name__)
|
apache-2.0
|
[
3,
3909,
370,
314,
1275,
7278,
2752,
1334,
1373,
503,
1655,
14024,
14,
199,
3,
710,
1275,
7278,
2752,
12378,
642,
570,
370,
1265,
1334,
314,
3668,
499,
14,
16,
844,
14,
199,
3,
1666,
314,
5113,
570,
315,
314,
2199,
1738,
367,
1655,
2556,
14,
199,
199,
2344,
199,
2765,
2295,
4052,
25654,
83,
511,
63,
4835,
14,
647,
1630,
440,
9793,
14,
199,
2344,
199,
199,
646,
485,
4835,
7736,
199,
646,
2882,
199,
199,
504,
3384,
396,
492,
365,
63,
2764,
12,
1255,
63,
396,
199,
199,
533,
485,
23527,
7736,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
21614,
8,
277,
304,
267,
291,
14,
1815,
16232,
1301,
16526,
315,
2935,
1547,
4835,
7736,
430,
267,
340,
365,
63,
2764,
26,
288,
291,
14,
629,
1547,
4835,
7736,
855,
1301,
3108,
298,
8461,
7736,
2631,
5563,
531,
267,
291,
14,
1815,
16232,
354,
16526,
315,
2935,
1547,
4835,
7736,
430,
267,
291,
14,
1815,
480,
4835,
8188,
2,
315,
2935,
6110,
4835,
7736,
430,
267,
291,
14,
1815,
480,
4835,
7736,
2,
315,
2935,
1547,
4835,
7736,
430,
267,
291,
14,
629,
8,
552,
8,
694,
1547,
4835,
7736,
1826,
959,
12,
298,
16990,
1077,
506,
959,
3004,
315,
314,
485,
4835,
7736,
859,
531,
339,
347,
511,
63,
4835,
7736,
63,
21614,
8,
277,
304,
267,
671,
275,
485,
4835,
7736,
14,
4835,
7736,
342,
267,
291,
14,
629,
8,
88,
14,
1457,
63,
890,
12,
7960,
9,
267,
291,
14,
629,
8,
88,
14,
5671,
1062,
355,
1867,
10493,
60,
88,
2658,
60,
1845,
1046,
94,
60,
9532,
60,
1774,
24,
60,
9826,
60,
1949,
17,
52,
8,
48,
60,
2207,
22,
77,
60,
88,
1257,
60,
88,
1780,
60,
2207,
22,
971,
1845,
20,
60,
88,
1717,
60,
88,
16,
66,
55,
60,
88,
1046,
60,
10550,
60,
88,
2658,
60,
1949,
20,
60,
1800,
25,
12525,
2207,
19,
76,
60,
1845,
25,
60,
10489,
39,
60,
2207,
16,
60,
2207,
17,
28,
7272,
88,
2426,
60,
1949,
18,
60,
1774,
16,
60,
3581,
60,
88,
2658,
60,
88,
1085,
60,
2207,
18,
60,
88,
1555,
94,
60,
9542,
15,
67,
60,
1774,
3328,
60,
9826,
9741,
90,
60,
88,
2835,
60,
1800,
17760,
90,
60,
1949,
25,
1154,
11078,
9579,
267,
291,
14,
629,
8,
88,
14,
5671,
63,
890,
12,
5049,
9,
267,
291,
14,
629,
8,
88,
14,
5671,
63,
890,
12,
671,
14,
5671,
890,
9,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
355,
283,
2177,
2658,
69,
969,
1641,
1024,
4675,
24,
66,
1587,
10478,
1651,
1400,
68,
1272,
68,
6718,
23,
68,
22085,
69,
2167,
1400,
66,
1641,
1046,
3833,
2658,
70,
20,
65,
25,
2025,
68,
1344,
301,
25,
301,
2417,
68,
16,
68,
969,
67,
21,
68,
2426,
70,
18,
66,
16,
556,
2658,
1085,
68,
1651,
1138,
69,
825,
18,
70,
2766,
66,
25,
2192,
3691,
13818,
1196,
65,
2835,
65,
32747,
11754,
2756,
31981,
983,
19,
69,
358,
267,
291,
14,
629,
8,
88,
14,
354,
12,
298,
8461,
7736,
531,
267,
671,
14,
873,
480,
3175,
531,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
355,
283,
617,
2756,
1276,
65,
1167,
1344,
1196,
371,
5470,
25292,
11991,
3624,
6686,
969,
6094,
69,
22,
667,
20,
69,
1407,
65,
2576,
4489,
1165,
65,
25,
21706,
772,
66,
1229,
68,
1355,
65,
18,
5756,
16544,
65,
9014,
3003,
17,
65,
32283,
2470,
19,
67,
1789,
65,
19,
11195,
32737,
12383,
68,
1602,
1789,
14637,
301,
1257,
69,
18,
65,
25,
645,
2635,
667,
1477,
696,
1887,
70,
358,
398,
671,
63,
1574,
275,
671,
14,
1574,
342,
267,
291,
14,
1815,
8,
88,
1111,
88,
63,
1574,
9,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
671,
63,
1574,
14,
11453,
1012,
339,
347,
511,
63,
4835,
8188,
63,
21614,
8,
277,
304,
267,
671,
275,
485,
4835,
7736,
14,
4835,
8188,
342,
267,
291,
14,
629,
8,
88,
14,
1457,
63,
890,
12,
7960,
9,
267,
291,
14,
629,
8,
88,
14,
5671,
1062,
355,
298,
24,
60,
1774,
16,
25502,
1800,
23,
49,
60,
10104,
60,
88,
25,
2333,
44,
60,
2207,
2942,
94,
60,
1774,
17,
60,
1774,
17,
60,
1845,
19,
74,
12525,
11208,
60,
1774,
23,
60,
88,
845,
60,
88,
1079,
60,
9957,
60,
88,
1780,
1981,
60,
88,
16,
67,
60,
1812,
23,
60,
1774,
3003,
60,
1949,
22,
60,
1845,
17,
60,
11078,
7,
46,
60,
10745,
60,
9566,
60,
1845,
23,
13361,
60,
10272,
60,
2207,
21,
60,
88,
17,
65,
60,
2207,
18,
60,
1949,
17,
40,
60,
88,
2905,
60,
1774,
25,
59,
531,
267,
291,
14,
629,
8,
88,
14,
5671,
63,
890,
12,
9615,
9,
267,
291,
14,
629,
8,
88,
14,
5671,
63,
890,
12,
671,
14,
5671,
890,
9,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
355,
283,
1703,
66,
18857,
65,
24595,
645,
2534,
8188,
2866,
25,
11754,
2871,
17,
66,
17,
69,
1344,
65,
2025,
29636,
32748,
1079,
1235,
24888,
1082,
67,
16,
2055,
23,
4361,
2766,
70,
22,
69,
17,
983,
9014,
69,
16762,
771,
2114,
70,
2182,
17108,
2869,
350,
18,
70,
1079,
13176,
66,
2720,
66,
358,
267,
291,
14,
629,
8,
88,
14,
354,
12,
298,
8461,
8188,
531,
267,
671,
14,
873,
480,
3175,
531,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
355,
283,
2894,
383,
22566,
70,
2322,
65,
1276,
69,
24,
2501,
21,
65,
1644,
68,
30688,
645,
2182,
8255,
12900,
67,
708,
371,
16,
6133,
975,
2192,
65,
24,
66,
30783,
65,
2824,
556,
21,
6123,
1257,
1184,
20281,
2470,
17,
69,
23,
2055,
8276,
24,
28363,
696,
7582,
67,
29208,
65,
23,
358,
398,
671,
63,
1574,
275,
671,
14,
1574,
342,
267,
291,
14,
1815,
8,
88,
1111,
88,
63,
1574,
9,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
671,
63,
1574,
14,
11453,
1012,
199,
199,
1065,
63,
396,
3460,
354,
3368,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
3909,
370,
314,
1275,
7278,
2752,
1334,
1373,
503,
1655,
14024,
14,
199,
3,
710,
1275,
7278,
2752,
12378,
642,
570,
370,
1265,
1334,
314,
3668,
499,
14,
16,
844,
14,
199,
3,
1666,
314,
5113,
570,
315,
314,
2199,
1738,
367,
1655,
2556,
14,
199,
199,
2344,
199,
2765,
2295,
4052,
25654,
83,
511,
63,
4835,
14,
647,
1630,
440,
9793,
14,
199,
2344,
199,
199,
646,
485,
4835,
7736,
199,
646,
2882,
199,
199,
504,
3384,
396,
492,
365,
63,
2764,
12,
1255,
63,
396,
199,
199,
533,
485,
23527,
7736,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
21614,
8,
277,
304,
267,
291,
14,
1815,
16232,
1301,
16526,
315,
2935,
1547,
4835,
7736,
430,
267,
340,
365,
63,
2764,
26,
288,
291,
14,
629,
1547,
4835,
7736,
855,
1301,
3108,
298,
8461,
7736,
2631,
5563,
531,
267,
291,
14,
1815,
16232,
354,
16526,
315,
2935,
1547,
4835,
7736,
430,
267,
291,
14,
1815,
480,
4835,
8188,
2,
315,
2935,
6110,
4835,
7736,
430,
267,
291,
14,
1815,
480,
4835,
7736,
2,
315,
2935,
1547,
4835,
7736,
430,
267,
291,
14,
629,
8,
552,
8,
694,
1547,
4835,
7736,
1826,
959,
12,
298,
16990,
1077,
506,
959,
3004,
315,
314,
485,
4835,
7736,
859,
531,
339,
347,
511,
63,
4835,
7736,
63,
21614,
8,
277,
304,
267,
671,
275,
485,
4835,
7736,
14,
4835,
7736,
342,
267,
291,
14,
629,
8,
88,
14,
1457,
63,
890,
12,
7960,
9,
267,
291,
14,
629,
8,
88,
14,
5671,
1062,
355,
1867,
10493,
60,
88,
2658,
60,
1845,
1046,
94,
60,
9532,
60,
1774,
24,
60,
9826,
60,
1949,
17,
52,
8,
48,
60,
2207,
22,
77,
60,
88,
1257,
60,
88,
1780,
60,
2207,
22,
971,
1845,
20,
60,
88,
1717,
60,
88,
16,
66,
55,
60,
88,
1046,
60,
10550,
60,
88,
2658,
60,
1949,
20,
60,
1800,
25,
12525,
2207,
19,
76,
60,
1845,
25,
60,
10489,
39,
60,
2207,
16,
60,
2207,
17,
28,
7272,
88,
2426,
60,
1949,
18,
60,
1774,
16,
60,
3581,
60,
88,
2658,
60,
88,
1085,
60,
2207,
18,
60,
88,
1555,
94,
60,
9542,
15,
67,
60,
1774,
3328,
60,
9826,
9741,
90,
60,
88,
2835,
60,
1800,
17760,
90,
60,
1949,
25,
1154,
11078,
9579,
267,
291,
14,
629,
8,
88,
14,
5671,
63,
890,
12,
5049,
9,
267,
291,
14,
629,
8,
88,
14,
5671,
63,
890,
12,
671,
14,
5671,
890,
9,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
355,
283,
2177,
2658,
69,
969,
1641,
1024,
4675,
24,
66,
1587,
10478,
1651,
1400,
68,
1272,
68,
6718,
23,
68,
22085,
69,
2167,
1400,
66,
1641,
1046,
3833,
2658,
70,
20,
65,
25,
2025,
68,
1344,
301,
25,
301,
2417,
68,
16,
68,
969,
67,
21,
68,
2426,
70,
18,
66,
16,
556,
2658,
1085,
68,
1651,
1138,
69,
825,
18,
70,
2766,
66,
25,
2192,
3691,
13818,
1196,
65,
2835,
65,
32747,
11754,
2756,
31981,
983,
19,
69,
358,
267,
291,
14,
629,
8,
88,
14,
354,
12,
298,
8461,
7736,
531,
267,
671,
14,
873,
480,
3175,
531,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
355,
283,
617,
2756,
1276,
65,
1167,
1344,
1196,
371,
5470,
25292,
11991,
3624,
6686,
969,
6094,
69,
22,
667,
20,
69,
1407,
65,
2576,
4489,
1165,
65,
25,
21706,
772,
66,
1229,
68,
1355,
65,
18,
5756,
16544,
65,
9014,
3003,
17,
65,
32283,
2470,
19,
67,
1789,
65,
19,
11195,
32737,
12383,
68,
1602,
1789,
14637,
301,
1257,
69,
18,
65,
25,
645,
2635,
667,
1477,
696,
1887,
70,
358,
398,
671,
63,
1574,
275,
671,
14,
1574,
342,
267,
291,
14,
1815,
8,
88,
1111,
88,
63,
1574,
9,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
671,
63,
1574,
14,
11453,
1012,
339,
347,
511,
63,
4835,
8188,
63,
21614,
8,
277,
304,
267,
671,
275,
485,
4835,
7736,
14,
4835,
8188,
342,
267,
291,
14,
629,
8,
88,
14,
1457,
63,
890,
12,
7960,
9,
267,
291,
14,
629,
8,
88,
14,
5671,
1062,
355,
298,
24,
60,
1774,
16,
25502,
1800,
23,
49,
60,
10104,
60,
88,
25,
2333,
44,
60,
2207,
2942,
94,
60,
1774,
17,
60,
1774,
17,
60,
1845,
19,
74,
12525,
11208,
60,
1774,
23,
60,
88,
845,
60,
88,
1079,
60,
9957,
60,
88,
1780,
1981,
60,
88,
16,
67,
60,
1812,
23,
60,
1774,
3003,
60,
1949,
22,
60,
1845,
17,
60,
11078,
7,
46,
60,
10745,
60,
9566,
60,
1845,
23,
13361,
60,
10272,
60,
2207,
21,
60,
88,
17,
65,
60,
2207,
18,
60,
1949,
17,
40,
60,
88,
2905,
60,
1774,
25,
59,
531,
267,
291,
14,
629,
8,
88,
14,
5671,
63,
890,
12,
9615,
9,
267,
291,
14,
629,
8,
88,
14,
5671,
63,
890,
12,
671,
14,
5671,
890,
9,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
355,
283,
1703,
66,
18857,
65,
24595,
645,
2534,
8188,
2866,
25,
11754,
2871,
17,
66,
17,
69,
1344,
65,
2025,
29636,
32748,
1079,
1235,
24888,
1082,
67,
16,
2055,
23,
4361,
2766,
70,
22,
69,
17,
983,
9014,
69,
16762,
771,
2114,
70,
2182,
17108,
2869,
350,
18,
70,
1079,
13176,
66,
2720,
66,
358,
267,
291,
14,
629,
8,
88,
14,
354,
12,
298,
8461,
8188,
531,
267,
671,
14,
873,
480,
3175,
531,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
355,
283,
2894,
383,
22566,
70,
2322,
65,
1276,
69,
24,
2501,
21,
65,
1644,
68,
30688,
645,
2182,
8255,
12900,
67,
708,
371,
16,
6133,
975,
2192,
65,
24,
66,
30783,
65,
2824,
556,
21,
6123,
1257,
1184,
20281,
2470,
17,
69,
23,
2055,
8276,
24,
28363,
696,
7582,
67,
29208,
65,
23,
358,
398,
671,
63,
1574,
275,
671,
14,
1574,
342,
267,
291,
14,
1815,
8,
88,
1111,
88,
63,
1574,
9,
267,
291,
14,
629,
8,
88,
14,
11453,
1062,
671,
63,
1574,
14,
11453,
1012,
199,
199,
1065,
63,
396,
3460,
354,
3368,
199,
32768,
32768,
32768,
32768,
32768,
32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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
] |
bbuchalter/python_koans
|
python2/koans/about_modules.py
|
1
|
2488
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is very different to AboutModules in Ruby Koans
# Our AboutMultipleInheritance class is a little more comparable
#
from runner.koan import *
from another_local_module import *
from local_module_with_all_defined import *
class AboutModules(Koan):
def test_importing_other_python_scripts_as_modules(self):
import local_module # local_module.py
duck = local_module.Duck()
self.assertEqual("Daffy", duck.name)
def test_importing_attributes_from_classes_using_from_keyword(self):
from local_module import Duck
duck = Duck() # no module qualifier needed this time
self.assertEqual("Daffy", duck.name)
def test_we_can_import_multiple_items_at_once(self):
import jims, joes
jims_dog = jims.Dog()
joes_dog = joes.Dog()
self.assertEqual("jims dog", jims_dog.identify())
self.assertEqual("joes dog", joes_dog.identify())
def test_importing_all_module_attributes_at_once(self):
"""
importing all attributes at once is done like so:
from another_local_module import *
The import wildcard cannot be used from within classes or functions.
"""
goose = Goose()
hamster = Hamster()
self.assertEqual("Mr Stabby", goose.name)
self.assertEqual("Phil", hamster.name)
def test_modules_hide_attributes_prefixed_by_underscores(self):
try:
private_squirrel = _SecretSquirrel()
except NameError as ex:
self.assertMatch("not defined", ex[0])
def test_private_attributes_are_still_accessible_in_modules(self):
from local_module import Duck # local_module.py
duck = Duck()
self.assertEqual("password", duck._password)
# module level attribute hiding doesn't affect class attributes
# (unless the class itself is hidden).
def test_a_modules_XallX_statement_limits_what_wildcards_will_match(self):
"""Examine results of from local_module_with_all_defined import *"""
# 'Goat' is on the __all__ list
goat = Goat()
self.assertEqual("George", goat.name)
# How about velociraptors?
lizard = _Velociraptor()
self.assertEqual("Cuddles", lizard.name)
# SecretDuck? Never heard of her!
try:
duck = SecretDuck()
except NameError as ex:
self.assertMatch("not defined", ex[0])
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
199,
3,
961,
365,
7437,
3365,
370,
25225,
17981,
315,
820,
10972,
1804,
79,
796,
199,
3,
25119,
25225,
8433,
23542,
554,
1021,
365,
282,
12050,
1655,
1013,
19816,
199,
3,
199,
199,
504,
7876,
14,
7697,
290,
492,
627,
199,
199,
504,
4573,
63,
1832,
63,
578,
492,
627,
199,
504,
2257,
63,
578,
63,
1045,
63,
452,
63,
4037,
492,
627,
421,
199,
533,
25225,
17981,
8,
31305,
290,
304,
272,
347,
511,
63,
646,
316,
63,
1848,
63,
1548,
63,
6429,
63,
305,
63,
3112,
8,
277,
304,
267,
492,
2257,
63,
578,
221,
327,
2257,
63,
578,
14,
647,
398,
366,
10112,
275,
2257,
63,
578,
14,
36,
10112,
342,
267,
291,
14,
629,
480,
36,
9181,
89,
401,
366,
10112,
14,
354,
9,
339,
347,
511,
63,
646,
316,
63,
2987,
63,
504,
63,
2888,
63,
4941,
63,
504,
63,
6691,
8,
277,
304,
267,
687,
2257,
63,
578,
492,
577,
10112,
398,
366,
10112,
275,
577,
10112,
342,
221,
327,
949,
859,
6420,
9893,
4346,
642,
900,
267,
291,
14,
629,
480,
36,
9181,
89,
401,
366,
10112,
14,
354,
9,
339,
347,
511,
63,
1129,
63,
2425,
63,
646,
63,
6048,
63,
1744,
63,
292,
63,
5089,
8,
277,
304,
267,
492,
1335,
11171,
12,
5225,
397,
398,
1335,
11171,
63,
13889,
275,
1335,
11171,
14,
36,
974,
342,
267,
5225,
397,
63,
13889,
275,
5225,
397,
14,
36,
974,
342,
267,
291,
14,
629,
480,
8047,
706,
23454,
401,
1335,
11171,
63,
13889,
14,
22232,
1012,
267,
291,
14,
629,
480,
743,
397,
23454,
401,
5225,
397,
63,
13889,
14,
22232,
1012,
339,
347,
511,
63,
646,
316,
63,
452,
63,
578,
63,
2987,
63,
292,
63,
5089,
8,
277,
304,
267,
408,
267,
16306,
1006,
3004,
737,
5403,
365,
4224,
2839,
880,
26,
288,
687,
4573,
63,
1832,
63,
578,
492,
627,
267,
710,
492,
16792,
3913,
506,
1202,
687,
4453,
3992,
503,
3423,
14,
267,
408,
398,
486,
10518,
275,
598,
10518,
342,
267,
24868,
11652,
275,
869,
455,
11652,
342,
398,
291,
14,
629,
480,
45,
82,
1933,
371,
991,
401,
486,
10518,
14,
354,
9,
267,
291,
14,
629,
480,
5663,
382,
401,
24868,
11652,
14,
354,
9,
339,
347,
511,
63,
3112,
63,
8191,
63,
2987,
63,
27833,
63,
991,
63,
7138,
7107,
8,
277,
304,
267,
862,
26,
288,
5726,
63,
8471,
723,
3369,
275,
485,
13790,
51,
392,
723,
3369,
342,
267,
871,
12746,
465,
444,
26,
288,
291,
14,
479,
4486,
480,
1397,
3247,
401,
444,
59,
16,
566,
339,
347,
511,
63,
4239,
63,
2987,
63,
1530,
63,
32310,
63,
24669,
63,
262,
63,
3112,
8,
277,
304,
267,
687,
2257,
63,
578,
492,
577,
10112,
221,
327,
2257,
63,
578,
14,
647,
398,
366,
10112,
275,
577,
10112,
342,
267,
291,
14,
629,
480,
2060,
401,
366,
10112,
423,
2060,
9,
267,
327,
859,
2166,
2225,
27276,
316,
3181,
1133,
12787,
1021,
3004,
267,
327,
334,
18447,
314,
1021,
6337,
365,
8752,
680,
339,
347,
511,
63,
65,
63,
3112,
63,
56,
452,
56,
63,
6242,
63,
9368,
63,
10058,
63,
29500,
63,
14117,
63,
1431,
8,
277,
304,
267,
408,
920,
455,
1132,
2058,
402,
687,
2257,
63,
578,
63,
1045,
63,
452,
63,
4037,
492,
627,
624,
398,
327,
283,
7250,
292,
7,
365,
641,
314,
636,
452,
363,
769,
267,
2621,
292,
275,
3971,
292,
342,
267,
291,
14,
629,
480,
4240,
24591,
401,
2621,
292,
14,
354,
9,
398,
327,
7494,
3595,
11199,
320,
559,
345,
541,
1384,
31,
267,
1212,
90,
1005,
275,
485,
15169,
320,
559,
345,
541,
269,
342,
267,
291,
14,
629,
480,
35,
8615,
2978,
401,
1212,
90,
1005,
14,
354,
9,
398,
327,
23580,
36,
10112,
31,
5612,
422,
946,
1005,
402,
14737,
1,
267,
862,
26,
288,
366,
10112,
275,
23580,
36,
10112,
342,
267,
871,
12746,
465,
444,
26,
288,
291,
14,
479,
4486,
480,
1397,
3247,
401,
444,
59,
16,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
199,
3,
961,
365,
7437,
3365,
370,
25225,
17981,
315,
820,
10972,
1804,
79,
796,
199,
3,
25119,
25225,
8433,
23542,
554,
1021,
365,
282,
12050,
1655,
1013,
19816,
199,
3,
199,
199,
504,
7876,
14,
7697,
290,
492,
627,
199,
199,
504,
4573,
63,
1832,
63,
578,
492,
627,
199,
504,
2257,
63,
578,
63,
1045,
63,
452,
63,
4037,
492,
627,
421,
199,
533,
25225,
17981,
8,
31305,
290,
304,
272,
347,
511,
63,
646,
316,
63,
1848,
63,
1548,
63,
6429,
63,
305,
63,
3112,
8,
277,
304,
267,
492,
2257,
63,
578,
221,
327,
2257,
63,
578,
14,
647,
398,
366,
10112,
275,
2257,
63,
578,
14,
36,
10112,
342,
267,
291,
14,
629,
480,
36,
9181,
89,
401,
366,
10112,
14,
354,
9,
339,
347,
511,
63,
646,
316,
63,
2987,
63,
504,
63,
2888,
63,
4941,
63,
504,
63,
6691,
8,
277,
304,
267,
687,
2257,
63,
578,
492,
577,
10112,
398,
366,
10112,
275,
577,
10112,
342,
221,
327,
949,
859,
6420,
9893,
4346,
642,
900,
267,
291,
14,
629,
480,
36,
9181,
89,
401,
366,
10112,
14,
354,
9,
339,
347,
511,
63,
1129,
63,
2425,
63,
646,
63,
6048,
63,
1744,
63,
292,
63,
5089,
8,
277,
304,
267,
492,
1335,
11171,
12,
5225,
397,
398,
1335,
11171,
63,
13889,
275,
1335,
11171,
14,
36,
974,
342,
267,
5225,
397,
63,
13889,
275,
5225,
397,
14,
36,
974,
342,
267,
291,
14,
629,
480,
8047,
706,
23454,
401,
1335,
11171,
63,
13889,
14,
22232,
1012,
267,
291,
14,
629,
480,
743,
397,
23454,
401,
5225,
397,
63,
13889,
14,
22232,
1012,
339,
347,
511,
63,
646,
316,
63,
452,
63,
578,
63,
2987,
63,
292,
63,
5089,
8,
277,
304,
267,
408,
267,
16306,
1006,
3004,
737,
5403,
365,
4224,
2839,
880,
26,
288,
687,
4573,
63,
1832,
63,
578,
492,
627,
267,
710,
492,
16792,
3913,
506,
1202,
687,
4453,
3992,
503,
3423,
14,
267,
408,
398,
486,
10518,
275,
598,
10518,
342,
267,
24868,
11652,
275,
869,
455,
11652,
342,
398,
291,
14,
629,
480,
45,
82,
1933,
371,
991,
401,
486,
10518,
14,
354,
9,
267,
291,
14,
629,
480,
5663,
382,
401,
24868,
11652,
14,
354,
9,
339,
347,
511,
63,
3112,
63,
8191,
63,
2987,
63,
27833,
63,
991,
63,
7138,
7107,
8,
277,
304,
267,
862,
26,
288,
5726,
63,
8471,
723,
3369,
275,
485,
13790,
51,
392,
723,
3369,
342,
267,
871,
12746,
465,
444,
26,
288,
291,
14,
479,
4486,
480,
1397,
3247,
401,
444,
59,
16,
566,
339,
347,
511,
63,
4239,
63,
2987,
63,
1530,
63,
32310,
63,
24669,
63,
262,
63,
3112,
8,
277,
304,
267,
687,
2257,
63,
578,
492,
577,
10112,
221,
327,
2257,
63,
578,
14,
647,
398,
366,
10112,
275,
577,
10112,
342,
267,
291,
14,
629,
480,
2060,
401,
366,
10112,
423,
2060,
9,
267,
327,
859,
2166,
2225,
27276,
316,
3181,
1133,
12787,
1021,
3004,
267,
327,
334,
18447,
314,
1021,
6337,
365,
8752,
680,
339,
347,
511,
63,
65,
63,
3112,
63,
56,
452,
56,
63,
6242,
63,
9368,
63,
10058,
63,
29500,
63,
14117,
63,
1431,
8,
277,
304,
267,
408,
920,
455,
1132,
2058,
402,
687,
2257,
63,
578,
63,
1045,
63,
452,
63,
4037,
492,
627,
624,
398,
327,
283,
7250,
292,
7,
365,
641,
314,
636,
452,
363,
769,
267,
2621,
292,
275,
3971,
292,
342,
267,
291,
14,
629,
480,
4240,
24591,
401,
2621,
292,
14,
354,
9,
398,
327,
7494,
3595,
11199,
320,
559,
345,
541,
1384,
31,
267,
1212,
90,
1005,
275,
485,
15169,
320,
559,
345,
541,
269,
342,
267,
291,
14,
629,
480,
35,
8615,
2978,
401,
1212,
90,
1005,
14,
354,
9,
398,
327,
23580,
36,
10112,
31,
5612,
422,
946,
1005,
402,
14737,
1,
267,
862,
26,
288,
366,
10112,
275,
23580,
36,
10112,
342,
267,
871,
12746,
465,
444,
26,
288,
291,
14,
479,
4486,
480,
1397,
3247,
401,
444,
59,
16,
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,
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
0,
0,
0,
0,
0,
0
] |
DepthDeluxe/ansible
|
lib/ansible/plugins/action/add_host.py
|
27
|
3142
|
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
# Copyright 2012, Seth Vidal <skvidal@fedoraproject.org>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.errors import AnsibleError
from ansible.module_utils.six import string_types
from ansible.plugins.action import ActionBase
from ansible.parsing.utils.addresses import parse_address
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
class ActionModule(ActionBase):
''' Create inventory hosts and groups in the memory inventory'''
# We need to be able to modify the inventory
BYPASS_HOST_LOOP = True
TRANSFERS_FILES = False
def run(self, tmp=None, task_vars=None):
self._supports_check_mode = True
result = super(ActionModule, self).run(tmp, task_vars)
# Parse out any hostname:port patterns
new_name = self._task.args.get('name', self._task.args.get('hostname', None))
display.vv("creating host via 'add_host': hostname=%s" % new_name)
try:
name, port = parse_address(new_name, allow_ranges=False)
except:
# not a parsable hostname, but might still be usable
name = new_name
port = None
if port:
self._task.args['ansible_ssh_port'] = port
groups = self._task.args.get('groupname', self._task.args.get('groups', self._task.args.get('group', '')))
# add it to the group if that was specified
new_groups = []
if groups:
if isinstance(groups, list):
group_list = groups
elif isinstance(groups, string_types):
group_list = groups.split(",")
else:
raise AnsibleError("Groups must be specified as a list.", obj=self._task)
for group_name in group_list:
if group_name not in new_groups:
new_groups.append(group_name.strip())
# Add any variables to the new_host
host_vars = dict()
special_args = frozenset(('name', 'hostname', 'groupname', 'groups'))
for k in self._task.args.keys():
if k not in special_args:
host_vars[k] = self._task.args[k]
result['changed'] = True
result['add_host'] = dict(host_name=name, groups=new_groups, host_vars=host_vars)
return result
|
gpl-3.0
|
[
3,
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
1898,
6029,
12,
3240,
273,
812,
344,
279,
665,
1339,
5017,
279,
32,
15800,
269,
30204,
963,
14,
1308,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
2550,
492,
13358,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
1059,
63,
1313,
199,
504,
3242,
14,
5265,
14,
1287,
492,
10033,
1563,
199,
504,
3242,
14,
11059,
14,
1208,
14,
7423,
492,
2198,
63,
1562,
199,
199,
893,
26,
272,
687,
636,
973,
363,
492,
2929,
199,
2590,
3545,
26,
272,
687,
3242,
14,
1208,
14,
2918,
492,
12175,
272,
2929,
275,
12175,
342,
421,
199,
533,
10033,
2377,
8,
3310,
1563,
304,
272,
1449,
2790,
8200,
7057,
436,
4652,
315,
314,
4402,
8200,
2344,
339,
327,
2136,
1929,
370,
506,
7688,
370,
2811,
314,
8200,
272,
6515,
6909,
63,
5449,
63,
26573,
275,
715,
272,
9074,
5622,
38,
3960,
63,
9472,
275,
756,
339,
347,
1255,
8,
277,
12,
3529,
29,
403,
12,
2120,
63,
2936,
29,
403,
304,
398,
291,
423,
9823,
63,
1074,
63,
632,
275,
715,
398,
754,
275,
1613,
8,
3310,
2377,
12,
291,
680,
1065,
8,
2791,
12,
2120,
63,
2936,
9,
398,
327,
6077,
734,
1263,
6246,
26,
719,
7970,
267,
892,
63,
354,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
354,
297,
291,
423,
1765,
14,
589,
14,
362,
360,
4269,
297,
488,
430,
267,
2929,
14,
8958,
480,
20358,
1591,
4799,
283,
525,
63,
1102,
356,
6246,
2458,
83,
2,
450,
892,
63,
354,
9,
398,
862,
26,
288,
536,
12,
1844,
275,
2198,
63,
1562,
8,
1222,
63,
354,
12,
2040,
63,
8404,
29,
797,
9,
267,
871,
26,
288,
327,
440,
282,
30903,
461,
6246,
12,
1325,
5594,
5139,
506,
18025,
288,
536,
275,
892,
63,
354,
288,
1844,
275,
488,
398,
340,
1844,
26,
288,
291,
423,
1765,
14,
589,
459,
4853,
63,
5510,
63,
719,
418,
275,
1844,
398,
4652,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
923,
354,
297,
291,
423,
1765,
14,
589,
14,
362,
360,
2634,
297,
291,
423,
1765,
14,
589,
14,
362,
360,
923,
297,
4074,
430,
267,
327,
1050,
652,
370,
314,
1572,
340,
626,
1990,
2013,
267,
892,
63,
2634,
275,
942,
267,
340,
4652,
26,
288,
340,
1228,
8,
2634,
12,
769,
304,
355,
1572,
63,
513,
275,
4652,
288,
916,
1228,
8,
2634,
12,
1059,
63,
1313,
304,
355,
1572,
63,
513,
275,
4652,
14,
1294,
20324,
288,
587,
26,
355,
746,
13358,
480,
10177,
1471,
506,
2013,
465,
282,
769,
4765,
1559,
29,
277,
423,
1765,
9,
953,
367,
1572,
63,
354,
315,
1572,
63,
513,
26,
355,
340,
1572,
63,
354,
440,
315,
892,
63,
2634,
26,
490,
892,
63,
2634,
14,
740,
8,
923,
63,
354,
14,
1913,
1012,
398,
327,
2654,
1263,
2860,
370,
314,
892,
63,
1102,
267,
1591,
63,
2936,
275,
1211,
342,
267,
4539,
63,
589,
275,
9522,
4725,
354,
297,
283,
4269,
297,
283,
923,
354,
297,
283,
2634,
1333,
267,
367,
1022,
315,
291,
423,
1765,
14,
589,
14,
1612,
837,
288,
340,
1022,
440,
315,
4539,
63,
589,
26,
355,
1591,
63,
2936,
59,
75,
61,
275,
291,
423,
1765,
14,
589,
59,
75,
61,
398,
754,
459,
2489,
418,
275,
715,
267,
754,
459,
525,
63,
1102,
418,
275,
1211,
8,
1102,
63,
354,
29,
354,
12,
4652,
29,
1222,
63,
2634,
12,
1591,
63,
2936,
29,
1102,
63,
2936,
9,
267,
372,
754,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
1898,
6029,
12,
3240,
273,
812,
344,
279,
665,
1339,
5017,
279,
32,
15800,
269,
30204,
963,
14,
1308,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
2550,
492,
13358,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
1059,
63,
1313,
199,
504,
3242,
14,
5265,
14,
1287,
492,
10033,
1563,
199,
504,
3242,
14,
11059,
14,
1208,
14,
7423,
492,
2198,
63,
1562,
199,
199,
893,
26,
272,
687,
636,
973,
363,
492,
2929,
199,
2590,
3545,
26,
272,
687,
3242,
14,
1208,
14,
2918,
492,
12175,
272,
2929,
275,
12175,
342,
421,
199,
533,
10033,
2377,
8,
3310,
1563,
304,
272,
1449,
2790,
8200,
7057,
436,
4652,
315,
314,
4402,
8200,
2344,
339,
327,
2136,
1929,
370,
506,
7688,
370,
2811,
314,
8200,
272,
6515,
6909,
63,
5449,
63,
26573,
275,
715,
272,
9074,
5622,
38,
3960,
63,
9472,
275,
756,
339,
347,
1255,
8,
277,
12,
3529,
29,
403,
12,
2120,
63,
2936,
29,
403,
304,
398,
291,
423,
9823,
63,
1074,
63,
632,
275,
715,
398,
754,
275,
1613,
8,
3310,
2377,
12,
291,
680,
1065,
8,
2791,
12,
2120,
63,
2936,
9,
398,
327,
6077,
734,
1263,
6246,
26,
719,
7970,
267,
892,
63,
354,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
354,
297,
291,
423,
1765,
14,
589,
14,
362,
360,
4269,
297,
488,
430,
267,
2929,
14,
8958,
480,
20358,
1591,
4799,
283,
525,
63,
1102,
356,
6246,
2458,
83,
2,
450,
892,
63,
354,
9,
398,
862,
26,
288,
536,
12,
1844,
275,
2198,
63,
1562,
8,
1222,
63,
354,
12,
2040,
63,
8404,
29,
797,
9,
267,
871,
26,
288,
327,
440,
282,
30903,
461,
6246,
12,
1325,
5594,
5139,
506,
18025,
288,
536,
275,
892,
63,
354,
288,
1844,
275,
488,
398,
340,
1844,
26,
288,
291,
423,
1765,
14,
589,
459,
4853,
63,
5510,
63,
719,
418,
275,
1844,
398,
4652,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
923,
354,
297,
291,
423,
1765,
14,
589,
14,
362,
360,
2634,
297,
291,
423,
1765,
14,
589,
14,
362,
360,
923,
297,
4074,
430,
267,
327,
1050,
652,
370,
314,
1572,
340,
626,
1990,
2013,
267,
892,
63,
2634,
275,
942,
267,
340,
4652,
26,
288,
340,
1228,
8,
2634,
12,
769,
304,
355,
1572,
63,
513,
275,
4652,
288,
916,
1228,
8,
2634,
12,
1059,
63,
1313,
304,
355,
1572,
63,
513,
275,
4652,
14,
1294,
20324,
288,
587,
26,
355,
746,
13358,
480,
10177,
1471,
506,
2013,
465,
282,
769,
4765,
1559,
29,
277,
423,
1765,
9,
953,
367,
1572,
63,
354,
315,
1572,
63,
513,
26,
355,
340,
1572,
63,
354,
440,
315,
892,
63,
2634,
26,
490,
892,
63,
2634,
14,
740,
8,
923,
63,
354,
14,
1913,
1012,
398,
327,
2654,
1263,
2860,
370,
314,
892,
63,
1102,
267,
1591,
63,
2936,
275,
1211,
342,
267,
4539,
63,
589,
275,
9522,
4725,
354,
297,
283,
4269,
297,
283,
923,
354,
297,
283,
2634,
1333,
267,
367,
1022,
315,
291,
423,
1765,
14,
589,
14,
1612,
837,
288,
340,
1022,
440,
315,
4539,
63,
589,
26,
355,
1591,
63,
2936,
59,
75,
61,
275,
291,
423,
1765,
14,
589,
59,
75,
61,
398,
754,
459,
2489,
418,
275,
715,
267,
754,
459,
525,
63,
1102,
418,
275,
1211,
8,
1102,
63,
354,
29,
354,
12,
4652,
29,
1222,
63,
2634,
12,
1591,
63,
2936,
29,
1102,
63,
2936,
9,
267,
372,
754,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
omnirom/android_external_chromium-org
|
tools/telemetry/telemetry/timeline/inspector_importer.py
|
33
|
2907
|
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
'''Imports event data obtained from the inspector's timeline.'''
import telemetry.timeline.slice as tracing_slice
import telemetry.timeline.thread as timeline_thread
from telemetry.timeline import importer
from telemetry.timeline import inspector_timeline_data
class InspectorTimelineImporter(importer.TimelineImporter):
def __init__(self, model, timeline_data):
super(InspectorTimelineImporter, self).__init__(model, timeline_data)
@staticmethod
def CanImport(timeline_data):
''' Checks if timeline_data is from the inspector timeline. We assume
that if the first event is a valid inspector event, we can import the
entire list.
'''
if not isinstance(timeline_data,
inspector_timeline_data.InspectorTimelineData):
return False
event_data = timeline_data.EventData()
if isinstance(event_data, list) and len(event_data):
event_datum = event_data[0]
return 'startTime' in event_datum and 'type' in event_datum
return False
def ImportEvents(self):
render_process = self._model.GetOrCreateProcess(0)
for raw_event in self._timeline_data.EventData():
thread = render_process.GetOrCreateThread(raw_event.get('thread', 0))
InspectorTimelineImporter.AddRawEventToThreadRecursive(thread, raw_event)
def FinalizeImport(self):
pass
@staticmethod
def AddRawEventToThreadRecursive(thread, raw_inspector_event):
pending_slice = None
if ('startTime' in raw_inspector_event and
'type' in raw_inspector_event):
args = {}
for x in raw_inspector_event:
if x in ('startTime', 'endTime', 'children'):
continue
args[x] = raw_inspector_event[x]
if len(args) == 0:
args = None
start_time = raw_inspector_event['startTime']
end_time = raw_inspector_event.get('endTime', start_time)
pending_slice = tracing_slice.Slice(
thread, 'inspector',
raw_inspector_event['type'],
start_time,
thread_timestamp=None,
args=args)
for child in raw_inspector_event.get('children', []):
InspectorTimelineImporter.AddRawEventToThreadRecursive(
thread, child)
if pending_slice:
pending_slice.duration = end_time - pending_slice.start
thread.PushSlice(pending_slice)
@staticmethod
def RawEventToTimelineEvent(raw_inspector_event):
"""Converts raw_inspector_event to TimelineEvent."""
thread = timeline_thread.Thread(None, 0)
InspectorTimelineImporter.AddRawEventToThreadRecursive(
thread, raw_inspector_event)
thread.FinalizeImport()
assert len(thread.toplevel_slices) <= 1
if len(thread.toplevel_slices) == 0:
return None
return thread.toplevel_slices[0]
|
bsd-3-clause
|
[
3,
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
2344,
32447,
1566,
666,
15884,
687,
314,
5261,
15152,
1159,
20780,
10595,
199,
199,
646,
17298,
14,
19369,
14,
5224,
465,
23465,
63,
5224,
199,
646,
17298,
14,
19369,
14,
2671,
465,
20780,
63,
2671,
199,
504,
17298,
14,
19369,
492,
13479,
199,
504,
17298,
14,
19369,
492,
5261,
15152,
63,
19369,
63,
576,
421,
199,
533,
12062,
15152,
27097,
18484,
8,
12138,
14,
27097,
18484,
304,
523,
347,
636,
826,
721,
277,
12,
1402,
12,
20780,
63,
576,
304,
272,
1613,
8,
13962,
15152,
27097,
18484,
12,
291,
2843,
826,
721,
1238,
12,
20780,
63,
576,
9,
819,
768,
4639,
523,
347,
6855,
6295,
8,
19369,
63,
576,
304,
272,
1449,
13813,
340,
20780,
63,
576,
365,
687,
314,
5261,
15152,
20780,
14,
2136,
5534,
272,
626,
340,
314,
1642,
1566,
365,
282,
1686,
5261,
15152,
1566,
12,
781,
883,
492,
314,
272,
8039,
769,
14,
272,
1449,
272,
340,
440,
1228,
8,
19369,
63,
576,
12,
1993,
5261,
15152,
63,
19369,
63,
576,
14,
13962,
15152,
27097,
1451,
304,
489,
372,
756,
339,
1566,
63,
576,
275,
20780,
63,
576,
14,
2390,
1451,
342,
339,
340,
1228,
8,
1430,
63,
576,
12,
769,
9,
436,
822,
8,
1430,
63,
576,
304,
489,
1566,
63,
18945,
275,
1566,
63,
576,
59,
16,
61,
489,
372,
283,
28276,
7,
315,
1566,
63,
18945,
436,
283,
466,
7,
315,
1566,
63,
18945,
272,
372,
756,
819,
347,
3161,
11770,
8,
277,
304,
272,
3795,
63,
1412,
275,
291,
423,
1238,
14,
1002,
2844,
2499,
3498,
8,
16,
9,
272,
367,
3066,
63,
1430,
315,
291,
423,
19369,
63,
576,
14,
2390,
1451,
837,
489,
2462,
275,
3795,
63,
1412,
14,
1002,
2844,
2499,
4436,
8,
1773,
63,
1430,
14,
362,
360,
2671,
297,
378,
430,
489,
12062,
15152,
27097,
18484,
14,
1123,
7963,
2390,
1378,
4436,
25122,
8,
2671,
12,
3066,
63,
1430,
9,
819,
347,
21789,
794,
6295,
8,
277,
304,
272,
986,
819,
768,
4639,
523,
347,
2654,
7963,
2390,
1378,
4436,
25122,
8,
2671,
12,
3066,
63,
26047,
63,
1430,
304,
272,
9413,
63,
5224,
275,
488,
272,
340,
661,
28276,
7,
315,
3066,
63,
26047,
63,
1430,
436,
267,
283,
466,
7,
315,
3066,
63,
26047,
63,
1430,
304,
489,
1249,
275,
1052,
489,
367,
671,
315,
3066,
63,
26047,
63,
1430,
26,
267,
340,
671,
315,
661,
28276,
297,
283,
500,
1366,
297,
283,
3223,
735,
881,
1980,
267,
1249,
59,
88,
61,
275,
3066,
63,
26047,
63,
1430,
59,
88,
61,
489,
340,
822,
8,
589,
9,
508,
378,
26,
267,
1249,
275,
488,
489,
1343,
63,
521,
275,
3066,
63,
26047,
63,
1430,
459,
28276,
418,
489,
1284,
63,
521,
275,
3066,
63,
26047,
63,
1430,
14,
362,
360,
500,
1366,
297,
1343,
63,
521,
9,
2541,
9413,
63,
5224,
275,
23465,
63,
5224,
14,
14034,
8,
267,
2462,
12,
283,
26047,
297,
267,
3066,
63,
26047,
63,
1430,
459,
466,
995,
267,
1343,
63,
521,
12,
267,
2462,
63,
3954,
29,
403,
12,
267,
1249,
29,
589,
9,
339,
367,
1982,
315,
3066,
63,
26047,
63,
1430,
14,
362,
360,
3223,
297,
12319,
489,
12062,
15152,
27097,
18484,
14,
1123,
7963,
2390,
1378,
4436,
25122,
8,
881,
2462,
12,
1982,
9,
339,
340,
9413,
63,
5224,
26,
489,
9413,
63,
5224,
14,
5553,
275,
1284,
63,
521,
446,
9413,
63,
5224,
14,
928,
489,
2462,
14,
10731,
14034,
8,
6455,
63,
5224,
9,
819,
768,
4639,
523,
347,
13480,
2390,
1378,
27097,
2390,
8,
1773,
63,
26047,
63,
1430,
304,
272,
408,
17729,
3066,
63,
26047,
63,
1430,
370,
4703,
604,
2390,
1041,
272,
2462,
275,
20780,
63,
2671,
14,
4436,
8,
403,
12,
378,
9,
272,
12062,
15152,
27097,
18484,
14,
1123,
7963,
2390,
1378,
4436,
25122,
8,
267,
2462,
12,
3066,
63,
26047,
63,
1430,
9,
272,
2462,
14,
12776,
794,
6295,
342,
272,
702,
822,
8,
2671,
14,
13517,
63,
14865,
9,
2695,
413,
272,
340,
822,
8,
2671,
14,
13517,
63,
14865,
9,
508,
378,
26,
489,
372,
488,
272,
372,
2462,
14,
13517,
63,
14865,
59,
16,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
2344,
32447,
1566,
666,
15884,
687,
314,
5261,
15152,
1159,
20780,
10595,
199,
199,
646,
17298,
14,
19369,
14,
5224,
465,
23465,
63,
5224,
199,
646,
17298,
14,
19369,
14,
2671,
465,
20780,
63,
2671,
199,
504,
17298,
14,
19369,
492,
13479,
199,
504,
17298,
14,
19369,
492,
5261,
15152,
63,
19369,
63,
576,
421,
199,
533,
12062,
15152,
27097,
18484,
8,
12138,
14,
27097,
18484,
304,
523,
347,
636,
826,
721,
277,
12,
1402,
12,
20780,
63,
576,
304,
272,
1613,
8,
13962,
15152,
27097,
18484,
12,
291,
2843,
826,
721,
1238,
12,
20780,
63,
576,
9,
819,
768,
4639,
523,
347,
6855,
6295,
8,
19369,
63,
576,
304,
272,
1449,
13813,
340,
20780,
63,
576,
365,
687,
314,
5261,
15152,
20780,
14,
2136,
5534,
272,
626,
340,
314,
1642,
1566,
365,
282,
1686,
5261,
15152,
1566,
12,
781,
883,
492,
314,
272,
8039,
769,
14,
272,
1449,
272,
340,
440,
1228,
8,
19369,
63,
576,
12,
1993,
5261,
15152,
63,
19369,
63,
576,
14,
13962,
15152,
27097,
1451,
304,
489,
372,
756,
339,
1566,
63,
576,
275,
20780,
63,
576,
14,
2390,
1451,
342,
339,
340,
1228,
8,
1430,
63,
576,
12,
769,
9,
436,
822,
8,
1430,
63,
576,
304,
489,
1566,
63,
18945,
275,
1566,
63,
576,
59,
16,
61,
489,
372,
283,
28276,
7,
315,
1566,
63,
18945,
436,
283,
466,
7,
315,
1566,
63,
18945,
272,
372,
756,
819,
347,
3161,
11770,
8,
277,
304,
272,
3795,
63,
1412,
275,
291,
423,
1238,
14,
1002,
2844,
2499,
3498,
8,
16,
9,
272,
367,
3066,
63,
1430,
315,
291,
423,
19369,
63,
576,
14,
2390,
1451,
837,
489,
2462,
275,
3795,
63,
1412,
14,
1002,
2844,
2499,
4436,
8,
1773,
63,
1430,
14,
362,
360,
2671,
297,
378,
430,
489,
12062,
15152,
27097,
18484,
14,
1123,
7963,
2390,
1378,
4436,
25122,
8,
2671,
12,
3066,
63,
1430,
9,
819,
347,
21789,
794,
6295,
8,
277,
304,
272,
986,
819,
768,
4639,
523,
347,
2654,
7963,
2390,
1378,
4436,
25122,
8,
2671,
12,
3066,
63,
26047,
63,
1430,
304,
272,
9413,
63,
5224,
275,
488,
272,
340,
661,
28276,
7,
315,
3066,
63,
26047,
63,
1430,
436,
267,
283,
466,
7,
315,
3066,
63,
26047,
63,
1430,
304,
489,
1249,
275,
1052,
489,
367,
671,
315,
3066,
63,
26047,
63,
1430,
26,
267,
340,
671,
315,
661,
28276,
297,
283,
500,
1366,
297,
283,
3223,
735,
881,
1980,
267,
1249,
59,
88,
61,
275,
3066,
63,
26047,
63,
1430,
59,
88,
61,
489,
340,
822,
8,
589,
9,
508,
378,
26,
267,
1249,
275,
488,
489,
1343,
63,
521,
275,
3066,
63,
26047,
63,
1430,
459,
28276,
418,
489,
1284,
63,
521,
275,
3066,
63,
26047,
63,
1430,
14,
362,
360,
500,
1366,
297,
1343,
63,
521,
9,
2541,
9413,
63,
5224,
275,
23465,
63,
5224,
14,
14034,
8,
267,
2462,
12,
283,
26047,
297,
267,
3066,
63,
26047,
63,
1430,
459,
466,
995,
267,
1343,
63,
521,
12,
267,
2462,
63,
3954,
29,
403,
12,
267,
1249,
29,
589,
9,
339,
367,
1982,
315,
3066,
63,
26047,
63,
1430,
14,
362,
360,
3223,
297,
12319,
489,
12062,
15152,
27097,
18484,
14,
1123,
7963,
2390,
1378,
4436,
25122,
8,
881,
2462,
12,
1982,
9,
339,
340,
9413,
63,
5224,
26,
489,
9413,
63,
5224,
14,
5553,
275,
1284,
63,
521,
446,
9413,
63,
5224,
14,
928,
489,
2462,
14,
10731,
14034,
8,
6455,
63,
5224,
9,
819,
768,
4639,
523,
347,
13480,
2390,
1378,
27097,
2390,
8,
1773,
63,
26047,
63,
1430,
304,
272,
408,
17729,
3066,
63,
26047,
63,
1430,
370,
4703,
604,
2390,
1041,
272,
2462,
275,
20780,
63,
2671,
14,
4436,
8,
403,
12,
378,
9,
272,
12062,
15152,
27097,
18484,
14,
1123,
7963,
2390,
1378,
4436,
25122,
8,
267,
2462,
12,
3066,
63,
26047,
63,
1430,
9,
272,
2462,
14,
12776,
794,
6295,
342,
272,
702,
822,
8,
2671,
14,
13517,
63,
14865,
9,
2695,
413,
272,
340,
822,
8,
2671,
14,
13517,
63,
14865,
9,
508,
378,
26,
489,
372,
488,
272,
372,
2462,
14,
13517,
63,
14865,
59,
16,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
HunanTV/redis-ctl
|
test/http.py
|
1
|
10950
|
import json
import redistrib.command as comm
import base
from models.base import db
from models.proxy import Proxy
from models.cluster import Cluster
import models.task
class HttpRequest(base.TestCase):
def test_http(self):
with self.app.test_client() as client:
self.assertEqual({'nodes': [], 'proxies': []},
self.app.polling_targets())
r = client.post('/redis/add', data={
'host': '127.0.0.1',
'port': '7100',
})
self.assertReqStatus(200, r)
self.assertEqual({
'nodes': [{
'host': '127.0.0.1',
'port': 7100,
'suppress_alert': 1,
}],
'proxies': [],
}, self.app.polling_targets())
r = client.post('/cluster/add', data={
'descr': 'the-quick-brown-fox',
})
self.assertReqStatus(200, r)
cluster_id = r.data
r = client.post('/task/launch', data=json.dumps({
'cluster': cluster_id,
'nodes': [{
'host': '127.0.0.1',
'port': 7100,
}],
}))
self.assertReqStatus(200, r)
self.exec_all_tasks()
self.assertRaises(ValueError, comm.quit_cluster, '127.0.0.1', 7100)
comm.shutdown_cluster('127.0.0.1', 7100)
def test_cluster(self):
with self.app.test_client() as client:
comm.start_cluster('127.0.0.1', 7100)
r = client.get('/cluster/autodiscover?host=127.0.0.1&port=7100')
self.assertReqStatus(200, r)
result = json.loads(r.data)
self.assertTrue(result['cluster_discovered'])
nodes = result['nodes']
self.assertEqual(1, len(nodes))
self.assertEqual({
'host': '127.0.0.1',
'port': 7100,
'role': 'master',
'known': False,
}, nodes[0])
r = client.post('/redis/add', data={
'host': '127.0.0.1',
'port': '7100',
})
self.assertReqStatus(200, r)
r = client.post('/cluster/autojoin', data={
'host': '127.0.0.1',
'port': '7100',
})
self.assertReqStatus(200, r)
cluster_id = r.data
r = client.post('/cluster/set_info', data={
'cluster_id': cluster_id,
'descr': '.',
})
self.assertReqStatus(200, r)
r = client.post('/cluster/register_proxy', data={
'cluster_id': cluster_id,
'host': '127.0.0.1',
'port': '8889',
})
self.assertReqStatus(200, r)
r = list(db.session.query(Proxy).all())
self.assertEqual(1, len(r))
self.assertEqual('127.0.0.1', r[0].host)
self.assertEqual(8889, r[0].port)
self.assertEqual(1, r[0].suppress_alert)
self.assertEqual(int(cluster_id), r[0].cluster_id)
r = list(db.session.query(Cluster).all())
self.assertEqual(1, len(r))
self.assertEqual('.', r[0].description)
r = client.post('/cluster/set_info', data={
'cluster_id': cluster_id,
'descr': 'xyzw',
})
self.assertReqStatus(200, r)
r = list(db.session.query(Cluster).all())
self.assertEqual(1, len(r))
self.assertEqual('xyzw', r[0].description)
comm.shutdown_cluster('127.0.0.1', 7100)
def test_cluster_with_multiple_nodes(self):
with self.app.test_client() as client:
r = client.post('/redis/add', data={
'host': '127.0.0.1',
'port': '7100',
})
self.assertReqStatus(200, r)
r = client.post('/redis/add', data={
'host': '127.0.0.1',
'port': '7101',
})
self.assertReqStatus(200, r)
r = client.post('/cluster/add', data={
'descr': 'the-quick-brown-fox',
})
self.assertReqStatus(200, r)
cluster_id = r.data
r = client.post('/task/launch', data=json.dumps({
'cluster': cluster_id,
'nodes': [{
'host': '127.0.0.1',
'port': 7100,
}],
}))
self.assertReqStatus(200, r)
self.exec_all_tasks()
r = client.post('/task/join', data=json.dumps({
'cluster_id': cluster_id,
'nodes': [{
'host': '127.0.0.1',
'port': 7101,
}],
}))
self.assertReqStatus(200, r)
nodes, node_7100 = comm.list_nodes('127.0.0.1', 7100)
self.assertEqual(1, len(nodes))
tasks = list(models.task.undone_tasks())
self.assertEqual(1, len(tasks))
self.exec_all_tasks()
nodes, node_7100 = comm.list_nodes('127.0.0.1', 7100)
self.assertEqual(2, len(nodes))
self.assertEqual(16384, len(node_7100.assigned_slots))
r = client.post('/task/migrate_slots', data={
'src_host': '127.0.0.1',
'src_port': 7100,
'dst_host': '127.0.0.1',
'dst_port': 7101,
'slots': '8192,8193,8194,8195',
})
self.assertReqStatus(200, r)
nodes, node_7100 = comm.list_nodes('127.0.0.1', 7100)
self.assertEqual(2, len(nodes))
self.assertEqual(16384, len(node_7100.assigned_slots))
tasks = list(models.task.undone_tasks())
self.assertEqual(1, len(tasks))
self.exec_all_tasks()
nodes, node_7100 = comm.list_nodes('127.0.0.1', 7100)
self.assertEqual(2, len(nodes))
self.assertEqual(16380, len(node_7100.assigned_slots))
r = client.post('/task/quit', data=json.dumps({
'host': '127.0.0.1',
'port': 7101,
'migratings': [{
'host': '127.0.0.1',
'port': 7100,
'slots': [8192, 8193, 8194, 8195],
}],
}))
self.assertReqStatus(200, r)
nodes, node_7100 = comm.list_nodes('127.0.0.1', 7100)
self.assertEqual(2, len(nodes))
tasks = list(models.task.undone_tasks())
self.assertEqual(1, len(tasks))
self.exec_all_tasks()
nodes, node_7100 = comm.list_nodes('127.0.0.1', 7100)
self.assertEqual(1, len(nodes))
comm.shutdown_cluster('127.0.0.1', 7100)
def test_set_alarm(self):
with self.app.test_client() as client:
r = client.post('/redis/add', data={
'host': '127.0.0.1',
'port': '7100',
})
self.assertEqual(200, r.status_code)
r = client.post('/redis/add', data={
'host': '127.0.0.1',
'port': '7101',
})
self.assertEqual(200, r.status_code)
r = client.post('/set_alarm/redis', data={
'host': '127.0.0.1',
'port': '7100',
'suppress': '0',
})
self.assertEqual(200, r.status_code)
r = client.post('/cluster/autojoin', data={
'host': '127.0.0.1',
'port': '7100',
})
self.assertEqual(200, r.status_code)
cluster_id = r.data
r = client.post('/cluster/set_info', data={
'cluster_id': cluster_id,
'descr': '.',
})
self.assertEqual(200, r.status_code)
r = client.post('/cluster/register_proxy', data={
'cluster_id': cluster_id,
'host': '127.0.0.1',
'port': '8889',
})
self.assertEqual(200, r.status_code)
self.app.write_polling_targets()
with open(self.app.polling_file, 'r') as fin:
polls = json.loads(fin.read())
self.assertEqual(2, len(polls['nodes']))
poll_nodes = sorted(polls['nodes'],
key=lambda n: '%s:%d' % (n['host'], n['port']))
n = poll_nodes[0]
self.assertEqual('127.0.0.1', n['host'])
self.assertEqual(7100, n['port'])
self.assertEqual(0, n['suppress_alert'])
n = poll_nodes[1]
self.assertEqual('127.0.0.1', n['host'])
self.assertEqual(7101, n['port'])
self.assertEqual(1, n['suppress_alert'])
self.assertEqual(1, len(polls['proxies']))
poll_proxies = sorted(
polls['proxies'],
key=lambda n: '%s:%d' % (n['host'], n['port']))
n = poll_proxies[0]
self.assertEqual('127.0.0.1', n['host'])
self.assertEqual(8889, n['port'])
self.assertEqual(1, n['suppress_alert'])
r = client.post('/set_alarm/redis', data={
'host': '127.0.0.1',
'port': '7101',
'suppress': '0',
})
self.assertEqual(200, r.status_code)
r = client.post('/set_alarm/redis', data={
'host': '127.0.0.1',
'port': '7102',
'suppress': '0',
})
self.assertEqual(400, r.status_code)
self.assertEqual({'reason': 'no such node'}, json.loads(r.data))
self.app.write_polling_targets()
with open(self.app.polling_file, 'r') as fin:
polls = json.loads(fin.read())
self.assertEqual(2, len(polls['nodes']))
poll_nodes = sorted(polls['nodes'],
key=lambda n: '%s:%d' % (n['host'], n['port']))
n = poll_nodes[0]
self.assertEqual('127.0.0.1', n['host'])
self.assertEqual(7100, n['port'])
self.assertEqual(0, n['suppress_alert'])
n = poll_nodes[1]
self.assertEqual('127.0.0.1', n['host'])
self.assertEqual(7101, n['port'])
self.assertEqual(0, n['suppress_alert'])
self.assertEqual(1, len(polls['proxies']))
poll_proxies = sorted(
polls['proxies'],
key=lambda n: '%s:%d' % (n['host'], n['port']))
n = poll_proxies[0]
self.assertEqual('127.0.0.1', n['host'])
self.assertEqual(8889, n['port'])
self.assertEqual(1, n['suppress_alert'])
|
mit
|
[
646,
2022,
199,
646,
295,
20231,
14,
1531,
465,
1923,
199,
199,
646,
1300,
199,
504,
1709,
14,
1095,
492,
1592,
199,
504,
1709,
14,
3280,
492,
12373,
199,
504,
1709,
14,
4201,
492,
16454,
199,
646,
1709,
14,
1765,
421,
199,
533,
20730,
8,
1095,
14,
1746,
304,
272,
347,
511,
63,
1014,
8,
277,
304,
267,
543,
291,
14,
571,
14,
396,
63,
1258,
342,
465,
1890,
26,
288,
291,
14,
629,
3252,
2415,
356,
990,
283,
17128,
356,
28657,
2490,
291,
14,
571,
14,
17154,
63,
4684,
1012,
288,
519,
275,
1890,
14,
1932,
2336,
15369,
15,
525,
297,
666,
3126,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
23,
1960,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
291,
14,
629,
2561,
355,
283,
2415,
356,
8910,
490,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
490,
283,
719,
356,
1520,
1960,
12,
490,
283,
17381,
63,
9241,
356,
413,
12,
355,
19971,
355,
283,
17128,
356,
990,
288,
1660,
291,
14,
571,
14,
17154,
63,
4684,
1012,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
525,
297,
666,
3126,
355,
283,
12113,
356,
283,
1589,
13,
13239,
13,
27133,
13,
9849,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
4350,
63,
344,
275,
519,
14,
576,
953,
519,
275,
1890,
14,
1932,
2336,
1765,
15,
9850,
297,
666,
29,
1001,
14,
4180,
2561,
355,
283,
4201,
356,
4350,
63,
344,
12,
355,
283,
2415,
356,
8910,
490,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
490,
283,
719,
356,
1520,
1960,
12,
355,
19971,
288,
23451,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
291,
14,
1628,
63,
452,
63,
5054,
342,
953,
291,
14,
1855,
8,
3393,
12,
1923,
14,
10589,
63,
4201,
12,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
1520,
1960,
9,
288,
1923,
14,
8831,
63,
4201,
360,
4195,
14,
16,
14,
16,
14,
17,
297,
1520,
1960,
9,
339,
347,
511,
63,
4201,
8,
277,
304,
267,
543,
291,
14,
571,
14,
396,
63,
1258,
342,
465,
1890,
26,
288,
1923,
14,
928,
63,
4201,
360,
4195,
14,
16,
14,
16,
14,
17,
297,
1520,
1960,
9,
288,
519,
275,
1890,
14,
362,
2336,
4201,
15,
2495,
18861,
31,
1102,
29,
4195,
14,
16,
14,
16,
14,
17,
6,
719,
29,
23,
1960,
358,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
754,
275,
2022,
14,
3640,
8,
82,
14,
576,
9,
288,
291,
14,
1815,
8,
1099,
459,
4201,
63,
2297,
13560,
1105,
288,
3380,
275,
754,
459,
2415,
418,
288,
291,
14,
629,
8,
17,
12,
822,
8,
2415,
430,
288,
291,
14,
629,
2561,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
1520,
1960,
12,
355,
283,
3756,
356,
283,
4133,
297,
355,
283,
3159,
356,
756,
12,
288,
1660,
3380,
59,
16,
566,
953,
519,
275,
1890,
14,
1932,
2336,
15369,
15,
525,
297,
666,
3126,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
23,
1960,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
2495,
904,
297,
666,
3126,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
23,
1960,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
4350,
63,
344,
275,
519,
14,
576,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
409,
63,
815,
297,
666,
3126,
355,
283,
4201,
63,
344,
356,
4350,
63,
344,
12,
355,
283,
12113,
356,
22608,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
2683,
63,
3280,
297,
666,
3126,
355,
283,
4201,
63,
344,
356,
4350,
63,
344,
12,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
1299,
1407,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
953,
519,
275,
769,
8,
697,
14,
1730,
14,
1131,
8,
4936,
680,
452,
1012,
288,
291,
14,
629,
8,
17,
12,
822,
8,
82,
430,
288,
291,
14,
629,
360,
4195,
14,
16,
14,
16,
14,
17,
297,
519,
59,
16,
1055,
1102,
9,
288,
291,
14,
629,
8,
1299,
1407,
12,
519,
59,
16,
1055,
719,
9,
288,
291,
14,
629,
8,
17,
12,
519,
59,
16,
1055,
17381,
63,
9241,
9,
288,
291,
14,
629,
8,
442,
8,
4201,
63,
344,
395,
519,
59,
16,
1055,
4201,
63,
344,
9,
953,
519,
275,
769,
8,
697,
14,
1730,
14,
1131,
8,
9581,
680,
452,
1012,
288,
291,
14,
629,
8,
17,
12,
822,
8,
82,
430,
288,
291,
14,
629,
14078,
519,
59,
16,
1055,
1802,
9,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
409,
63,
815,
297,
666,
3126,
355,
283,
4201,
63,
344,
356,
4350,
63,
344,
12,
355,
283,
12113,
356,
283,
8568,
87,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
953,
519,
275,
769,
8,
697,
14,
1730,
14,
1131,
8,
9581,
680,
452,
1012,
288,
291,
14,
629,
8,
17,
12,
822,
8,
82,
430,
288,
291,
14,
629,
360,
8568,
87,
297,
519,
59,
16,
1055,
1802,
9,
953,
1923,
14,
8831,
63,
4201,
360,
4195,
14,
16,
14,
16,
14,
17,
297,
1520,
1960,
9,
339,
347,
511,
63,
4201,
63,
1045,
63,
6048,
63,
2415,
8,
277,
304,
267,
543,
291,
14,
571,
14,
396,
63,
1258,
342,
465,
1890,
26,
288,
519,
275,
1890,
14,
1932,
2336,
15369,
15,
525,
297,
666,
3126,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
23,
1960,
297,
288,
3828,
288,
291,
14
] |
[
2022,
199,
646,
295,
20231,
14,
1531,
465,
1923,
199,
199,
646,
1300,
199,
504,
1709,
14,
1095,
492,
1592,
199,
504,
1709,
14,
3280,
492,
12373,
199,
504,
1709,
14,
4201,
492,
16454,
199,
646,
1709,
14,
1765,
421,
199,
533,
20730,
8,
1095,
14,
1746,
304,
272,
347,
511,
63,
1014,
8,
277,
304,
267,
543,
291,
14,
571,
14,
396,
63,
1258,
342,
465,
1890,
26,
288,
291,
14,
629,
3252,
2415,
356,
990,
283,
17128,
356,
28657,
2490,
291,
14,
571,
14,
17154,
63,
4684,
1012,
288,
519,
275,
1890,
14,
1932,
2336,
15369,
15,
525,
297,
666,
3126,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
23,
1960,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
291,
14,
629,
2561,
355,
283,
2415,
356,
8910,
490,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
490,
283,
719,
356,
1520,
1960,
12,
490,
283,
17381,
63,
9241,
356,
413,
12,
355,
19971,
355,
283,
17128,
356,
990,
288,
1660,
291,
14,
571,
14,
17154,
63,
4684,
1012,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
525,
297,
666,
3126,
355,
283,
12113,
356,
283,
1589,
13,
13239,
13,
27133,
13,
9849,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
4350,
63,
344,
275,
519,
14,
576,
953,
519,
275,
1890,
14,
1932,
2336,
1765,
15,
9850,
297,
666,
29,
1001,
14,
4180,
2561,
355,
283,
4201,
356,
4350,
63,
344,
12,
355,
283,
2415,
356,
8910,
490,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
490,
283,
719,
356,
1520,
1960,
12,
355,
19971,
288,
23451,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
291,
14,
1628,
63,
452,
63,
5054,
342,
953,
291,
14,
1855,
8,
3393,
12,
1923,
14,
10589,
63,
4201,
12,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
1520,
1960,
9,
288,
1923,
14,
8831,
63,
4201,
360,
4195,
14,
16,
14,
16,
14,
17,
297,
1520,
1960,
9,
339,
347,
511,
63,
4201,
8,
277,
304,
267,
543,
291,
14,
571,
14,
396,
63,
1258,
342,
465,
1890,
26,
288,
1923,
14,
928,
63,
4201,
360,
4195,
14,
16,
14,
16,
14,
17,
297,
1520,
1960,
9,
288,
519,
275,
1890,
14,
362,
2336,
4201,
15,
2495,
18861,
31,
1102,
29,
4195,
14,
16,
14,
16,
14,
17,
6,
719,
29,
23,
1960,
358,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
754,
275,
2022,
14,
3640,
8,
82,
14,
576,
9,
288,
291,
14,
1815,
8,
1099,
459,
4201,
63,
2297,
13560,
1105,
288,
3380,
275,
754,
459,
2415,
418,
288,
291,
14,
629,
8,
17,
12,
822,
8,
2415,
430,
288,
291,
14,
629,
2561,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
1520,
1960,
12,
355,
283,
3756,
356,
283,
4133,
297,
355,
283,
3159,
356,
756,
12,
288,
1660,
3380,
59,
16,
566,
953,
519,
275,
1890,
14,
1932,
2336,
15369,
15,
525,
297,
666,
3126,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
23,
1960,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
2495,
904,
297,
666,
3126,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
23,
1960,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
288,
4350,
63,
344,
275,
519,
14,
576,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
409,
63,
815,
297,
666,
3126,
355,
283,
4201,
63,
344,
356,
4350,
63,
344,
12,
355,
283,
12113,
356,
22608,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
2683,
63,
3280,
297,
666,
3126,
355,
283,
4201,
63,
344,
356,
4350,
63,
344,
12,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
1299,
1407,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
953,
519,
275,
769,
8,
697,
14,
1730,
14,
1131,
8,
4936,
680,
452,
1012,
288,
291,
14,
629,
8,
17,
12,
822,
8,
82,
430,
288,
291,
14,
629,
360,
4195,
14,
16,
14,
16,
14,
17,
297,
519,
59,
16,
1055,
1102,
9,
288,
291,
14,
629,
8,
1299,
1407,
12,
519,
59,
16,
1055,
719,
9,
288,
291,
14,
629,
8,
17,
12,
519,
59,
16,
1055,
17381,
63,
9241,
9,
288,
291,
14,
629,
8,
442,
8,
4201,
63,
344,
395,
519,
59,
16,
1055,
4201,
63,
344,
9,
953,
519,
275,
769,
8,
697,
14,
1730,
14,
1131,
8,
9581,
680,
452,
1012,
288,
291,
14,
629,
8,
17,
12,
822,
8,
82,
430,
288,
291,
14,
629,
14078,
519,
59,
16,
1055,
1802,
9,
953,
519,
275,
1890,
14,
1932,
2336,
4201,
15,
409,
63,
815,
297,
666,
3126,
355,
283,
4201,
63,
344,
356,
4350,
63,
344,
12,
355,
283,
12113,
356,
283,
8568,
87,
297,
288,
3828,
288,
291,
14,
479,
11981,
3694,
8,
1840,
12,
519,
9,
953,
519,
275,
769,
8,
697,
14,
1730,
14,
1131,
8,
9581,
680,
452,
1012,
288,
291,
14,
629,
8,
17,
12,
822,
8,
82,
430,
288,
291,
14,
629,
360,
8568,
87,
297,
519,
59,
16,
1055,
1802,
9,
953,
1923,
14,
8831,
63,
4201,
360,
4195,
14,
16,
14,
16,
14,
17,
297,
1520,
1960,
9,
339,
347,
511,
63,
4201,
63,
1045,
63,
6048,
63,
2415,
8,
277,
304,
267,
543,
291,
14,
571,
14,
396,
63,
1258,
342,
465,
1890,
26,
288,
519,
275,
1890,
14,
1932,
2336,
15369,
15,
525,
297,
666,
3126,
355,
283,
1102,
356,
283,
4195,
14,
16,
14,
16,
14,
17,
297,
355,
283,
719,
356,
283,
23,
1960,
297,
288,
3828,
288,
291,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
tima/ansible
|
lib/ansible/modules/cloud/vmware/vmware_host_ntp.py
|
11
|
7785
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {
'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'
}
DOCUMENTATION = r'''
---
module: vmware_host_ntp
short_description: Manage NTP configurations about an ESXi host
description:
- This module can be used to manage NTP configuration information about an ESXi host.
- User can specify an ESXi hostname or Cluster name. In case of cluster name, all ESXi hosts are updated.
version_added: '2.5'
author:
- Abhijeet Kasurde (@akasurde)
notes:
- Tested on vSphere 6.5
requirements:
- python >= 2.6
- PyVmomi
options:
cluster_name:
description:
- Name of the cluster.
- NTP settings are applied to every ESXi host system in the given cluster.
- If C(esxi_hostname) is not given, this parameter is required.
esxi_hostname:
description:
- ESXi hostname.
- NTP settings are applied to this ESXi host system.
- If C(cluster_name) is not given, this parameter is required.
ntp_servers:
description:
- "IP or FQDN of NTP server/s."
- This accepts a list of NTP servers. For multiple servers, please look at the examples.
required: True
state:
description:
- "present: Add NTP server/s, if it specified server/s are absent else do nothing."
- "absent: Remove NTP server/s, if specified server/s are present else do nothing."
default: present
choices: [ present, absent ]
extends_documentation_fragment: vmware.documentation
'''
EXAMPLES = r'''
- name: Set NTP setting for all ESXi Host in given Cluster
vmware_host_ntp:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
cluster_name: cluster_name
state: present
ntp_servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- name: Set NTP setting for an ESXi Host
vmware_host_ntp:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
esxi_hostname: '{{ esxi_hostname }}'
state: present
ntp_servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- name: Remove NTP setting for an ESXi Host
vmware_host_ntp:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
esxi_hostname: '{{ esxi_hostname }}'
state: absent
ntp_servers:
- bad.server.ntp.org
'''
RETURN = r'''#
'''
try:
from pyVmomi import vim, vmodl
except ImportError:
pass
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.vmware import vmware_argument_spec, PyVmomi
from ansible.module_utils._text import to_native
class VmwareNtpConfigManager(PyVmomi):
def __init__(self, module):
super(VmwareNtpConfigManager, self).__init__(module)
cluster_name = self.params.get('cluster_name', None)
esxi_host_name = self.params.get('esxi_hostname', None)
self.ntp_servers = self.params.get('ntp_servers', list())
self.hosts = []
if cluster_name:
cluster_obj = self.find_cluster_by_name(cluster_name=cluster_name)
if cluster_obj:
self.hosts = [host for host in cluster_obj.host]
else:
module.fail_json(changed=False, msg="Cluster '%s' not found" % cluster_name)
elif esxi_host_name:
esxi_host_obj = self.find_hostsystem_by_name(host_name=esxi_host_name)
if esxi_host_obj:
self.hosts = [esxi_host_obj]
else:
module.fail_json(changed=False, msg="ESXi '%s' not found" % esxi_host_name)
self.results = {}
self.desired_state = module.params['state']
def update_ntp_servers(self, host, ntp_servers, operation='add'):
changed = False
host_date_time_manager = host.configManager.dateTimeSystem
if host_date_time_manager:
available_ntp_servers = host_date_time_manager.dateTimeInfo.ntpConfig.server
if operation == 'add':
available_ntp_servers = available_ntp_servers + ntp_servers
elif operation == 'delete':
for server in ntp_servers:
if server in available_ntp_servers:
available_ntp_servers.remove(server)
ntp_config_spec = vim.host.NtpConfig()
ntp_config_spec.server = available_ntp_servers
date_config_spec = vim.host.DateTimeConfig()
date_config_spec.ntpConfig = ntp_config_spec
try:
host_date_time_manager.UpdateDateTimeConfig(date_config_spec)
self.results[host.name]['after_change_ntp_servers'] = host_date_time_manager.dateTimeInfo.ntpConfig.server
changed = True
except vim.fault.HostConfigFault as e:
self.results[host.name]['error'] = to_native(e.msg)
except Exception as e:
self.results[host.name]['error'] = to_native(e)
return changed
def check_host_state(self):
change_list = []
changed = False
for host in self.hosts:
ntp_servers_to_change = self.check_ntp_servers(host=host)
self.results[host.name].update(dict(
ntp_servers_to_change=ntp_servers_to_change,
desired_state=self.desired_state,
)
)
if not ntp_servers_to_change:
change_list.append(False)
self.results[host.name]['current_state'] = self.desired_state
elif ntp_servers_to_change:
if self.desired_state == 'present':
changed = self.update_ntp_servers(host=host, ntp_servers=ntp_servers_to_change)
change_list.append(changed)
elif self.desired_state == 'absent':
changed = self.update_ntp_servers(host=host, ntp_servers=ntp_servers_to_change, operation='delete')
change_list.append(changed)
self.results[host.name]['current_state'] = self.desired_state
if any(change_list):
changed = True
self.module.exit_json(changed=changed, results=self.results)
def check_ntp_servers(self, host):
update_ntp_list = []
host_datetime_system = host.configManager.dateTimeSystem
if host_datetime_system:
ntp_servers = host_datetime_system.dateTimeInfo.ntpConfig.server
self.results[host.name] = dict(available_ntp_servers=ntp_servers)
for ntp_server in self.ntp_servers:
if self.desired_state == 'present' and ntp_server not in ntp_servers:
update_ntp_list.append(ntp_server)
if self.desired_state == 'absent' and ntp_server in ntp_servers:
update_ntp_list.append(ntp_server)
return update_ntp_list
def main():
argument_spec = vmware_argument_spec()
argument_spec.update(
cluster_name=dict(type='str', required=False),
esxi_hostname=dict(type='str', required=False),
ntp_servers=dict(type='list', required=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
)
module = AnsibleModule(
argument_spec=argument_spec,
required_one_of=[
['cluster_name', 'esxi_hostname'],
]
)
vmware_host_ntp_config = VmwareNtpConfigManager(module)
vmware_host_ntp_config.check_host_state()
if __name__ == "__main__":
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
8351,
5812,
6532,
386,
1804,
305,
300,
271,
665,
1151,
305,
300,
271,
32,
17164,
14,
957,
30,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
469,
272,
283,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
272,
283,
1205,
356,
788,
7780,
995,
272,
283,
4946,
63,
991,
356,
283,
9387,
7,
199,
93,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
19365,
63,
1102,
63,
15893,
199,
3612,
63,
1802,
26,
14944,
653,
6495,
13422,
3595,
376,
10427,
14828,
1591,
199,
1802,
26,
199,
13,
961,
859,
883,
506,
1202,
370,
9635,
653,
6495,
2897,
2556,
3595,
376,
10427,
14828,
1591,
14,
199,
13,
2876,
883,
4165,
376,
10427,
14828,
6246,
503,
16454,
536,
14,
1010,
1930,
402,
4350,
536,
12,
1006,
10427,
14828,
7057,
787,
4588,
14,
199,
1023,
63,
3270,
26,
283,
18,
14,
21,
7,
199,
2502,
26,
199,
13,
8351,
5812,
6532,
386,
1804,
305,
300,
271,
8593,
1151,
305,
300,
271,
9,
199,
5983,
26,
199,
13,
30568,
641,
373,
22385,
1227,
14,
21,
199,
7538,
26,
199,
13,
2366,
2356,
499,
14,
22,
199,
13,
1611,
54,
28603,
199,
1419,
26,
523,
4350,
63,
354,
26,
272,
1369,
26,
272,
446,
2812,
402,
314,
4350,
14,
272,
446,
653,
6495,
2202,
787,
6781,
370,
4036,
10427,
14828,
1591,
2656,
315,
314,
1627,
4350,
14,
272,
446,
982,
445,
8,
397,
6865,
63,
4269,
9,
365,
440,
1627,
12,
642,
2725,
365,
1415,
14,
523,
9455,
6865,
63,
4269,
26,
272,
1369,
26,
272,
446,
10427,
14828,
6246,
14,
272,
446,
653,
6495,
2202,
787,
6781,
370,
642,
10427,
14828,
1591,
2656,
14,
272,
446,
982,
445,
8,
4201,
63,
354,
9,
365,
440,
1627,
12,
642,
2725,
365,
1415,
14,
523,
28581,
63,
5871,
26,
272,
1369,
26,
272,
446,
298,
1772,
503,
481,
49,
10872,
402,
653,
6495,
1654,
15,
83,
2122,
272,
446,
961,
11479,
282,
769,
402,
653,
6495,
8037,
14,
2104,
3663,
8037,
12,
8749,
3648,
737,
314,
7251,
14,
272,
1415,
26,
715,
523,
1174,
26,
272,
1369,
26,
272,
446,
298,
1881,
26,
2654,
653,
6495,
1654,
15,
83,
12,
340,
652,
2013,
1654,
15,
83,
787,
9552,
587,
886,
6548,
2122,
272,
446,
298,
5575,
26,
5852,
653,
6495,
1654,
15,
83,
12,
340,
2013,
1654,
15,
83,
787,
3451,
587,
886,
6548,
2122,
272,
849,
26,
3451,
272,
3415,
26,
359,
3451,
12,
9552,
1622,
199,
11036,
63,
9970,
63,
7677,
26,
19365,
14,
9970,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
2494,
653,
6495,
4260,
367,
1006,
10427,
14828,
10891,
315,
1627,
16454,
523,
19365,
63,
1102,
63,
15893,
26,
272,
6246,
26,
11400,
27127,
63,
4269,
16339,
272,
3434,
26,
11400,
27127,
63,
2473,
16339,
272,
2505,
26,
11400,
27127,
63,
2060,
16339,
272,
4350,
63,
354,
26,
4350,
63,
354,
272,
1174,
26,
3451,
272,
28581,
63,
5871,
26,
267,
446,
378,
14,
2293,
14,
15893,
14,
1308,
267,
446,
413,
14,
2293,
14,
15893,
14,
1308,
199,
199,
13,
536,
26,
2494,
653,
6495,
4260,
367,
376,
10427,
14828,
10891,
523,
19365,
63,
1102,
63,
15893,
26,
272,
6246,
26,
11400,
27127,
63,
4269,
16339,
272,
3434,
26,
11400,
27127,
63,
2473,
16339,
272,
2505,
26,
11400,
27127,
63,
2060,
16339,
272,
9455,
6865,
63,
4269,
26,
11400,
9455,
6865,
63,
4269,
16339,
272,
1174,
26,
3451,
272,
28581,
63,
5871,
26,
267,
446,
378,
14,
2293,
14,
15893,
14,
1308,
267,
446,
413,
14,
2293,
14,
15893,
14,
1308,
199,
199,
13,
536,
26,
5852,
653,
6495,
4260,
367,
376,
10427,
14828,
10891,
523,
19365,
63,
1102,
63,
15893,
26,
272,
6246,
26,
11400,
27127,
63,
4269,
16339,
272,
3434,
26,
11400,
27127,
63,
2473,
16339,
272,
2505,
26,
11400,
27127,
63,
2060,
16339,
272,
9455,
6865,
63,
4269,
26,
11400,
9455,
6865,
63,
4269,
16339,
272,
1174,
26,
9552,
272,
28581,
63,
5871,
26,
267,
446,
4875,
14,
1000,
14,
15893,
14,
1308,
199,
2344,
199,
199,
9677,
275,
519,
2344,
3,
199,
2344,
199,
199,
893,
26,
272,
687,
1134,
54,
28603,
492,
6695,
12,
373,
1494,
76,
199,
2590,
3545,
26,
272,
986,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
18970,
492,
19365,
63,
2094,
63,
1650,
12,
1611,
54,
28603,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
6106,
421,
199,
533,
812,
77,
1068,
46,
683,
2028,
2988,
8,
2713,
54,
28603,
304,
272,
347,
636,
826,
721,
277,
12,
859,
304,
267,
1613,
8,
17402,
1068,
46,
683,
2028,
2988,
12,
291,
2843,
826,
721,
578,
9,
267,
4350,
63,
354,
275,
291,
14,
1162,
14,
362,
360,
4201,
63,
354,
297,
488,
9,
267,
9455,
6865,
63,
1102,
63,
354,
275,
291,
14,
1162,
14,
362,
360,
397,
6865,
63,
4269,
297,
488,
9,
267,
291,
14,
15893,
63,
5871,
275,
291,
14,
1162,
14,
362,
360,
15893,
63,
5871,
297,
769,
1012,
267,
291,
14,
5146,
275,
942,
267,
340,
4350,
63,
354,
26,
288,
4350,
63,
1113,
275,
291,
14,
1623,
63,
4201,
63,
991,
63,
354,
8,
4201,
63,
354,
29,
4201,
63,
354,
9,
288,
340,
4350,
63,
1113,
26,
355,
291,
14,
5146,
275,
359,
1102,
367,
1591,
315,
4350,
63,
1113,
14,
1102,
61,
288,
587,
26,
355,
859,
14,
1633,
63,
1001,
8,
2489,
29,
797,
12,
1499,
628,
9581,
1543,
83,
7,
440,
1911,
2,
450,
4350,
63,
354,
9,
267,
916,
9455,
6865,
63,
1102,
63,
354,
26,
288,
9455,
6865,
63,
1102,
63,
1113,
275,
291,
14,
1623,
63,
1102,
2253,
63,
991
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
8351,
5812,
6532,
386,
1804,
305,
300,
271,
665,
1151,
305,
300,
271,
32,
17164,
14,
957,
30,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
469,
272,
283,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
272,
283,
1205,
356,
788,
7780,
995,
272,
283,
4946,
63,
991,
356,
283,
9387,
7,
199,
93,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
19365,
63,
1102,
63,
15893,
199,
3612,
63,
1802,
26,
14944,
653,
6495,
13422,
3595,
376,
10427,
14828,
1591,
199,
1802,
26,
199,
13,
961,
859,
883,
506,
1202,
370,
9635,
653,
6495,
2897,
2556,
3595,
376,
10427,
14828,
1591,
14,
199,
13,
2876,
883,
4165,
376,
10427,
14828,
6246,
503,
16454,
536,
14,
1010,
1930,
402,
4350,
536,
12,
1006,
10427,
14828,
7057,
787,
4588,
14,
199,
1023,
63,
3270,
26,
283,
18,
14,
21,
7,
199,
2502,
26,
199,
13,
8351,
5812,
6532,
386,
1804,
305,
300,
271,
8593,
1151,
305,
300,
271,
9,
199,
5983,
26,
199,
13,
30568,
641,
373,
22385,
1227,
14,
21,
199,
7538,
26,
199,
13,
2366,
2356,
499,
14,
22,
199,
13,
1611,
54,
28603,
199,
1419,
26,
523,
4350,
63,
354,
26,
272,
1369,
26,
272,
446,
2812,
402,
314,
4350,
14,
272,
446,
653,
6495,
2202,
787,
6781,
370,
4036,
10427,
14828,
1591,
2656,
315,
314,
1627,
4350,
14,
272,
446,
982,
445,
8,
397,
6865,
63,
4269,
9,
365,
440,
1627,
12,
642,
2725,
365,
1415,
14,
523,
9455,
6865,
63,
4269,
26,
272,
1369,
26,
272,
446,
10427,
14828,
6246,
14,
272,
446,
653,
6495,
2202,
787,
6781,
370,
642,
10427,
14828,
1591,
2656,
14,
272,
446,
982,
445,
8,
4201,
63,
354,
9,
365,
440,
1627,
12,
642,
2725,
365,
1415,
14,
523,
28581,
63,
5871,
26,
272,
1369,
26,
272,
446,
298,
1772,
503,
481,
49,
10872,
402,
653,
6495,
1654,
15,
83,
2122,
272,
446,
961,
11479,
282,
769,
402,
653,
6495,
8037,
14,
2104,
3663,
8037,
12,
8749,
3648,
737,
314,
7251,
14,
272,
1415,
26,
715,
523,
1174,
26,
272,
1369,
26,
272,
446,
298,
1881,
26,
2654,
653,
6495,
1654,
15,
83,
12,
340,
652,
2013,
1654,
15,
83,
787,
9552,
587,
886,
6548,
2122,
272,
446,
298,
5575,
26,
5852,
653,
6495,
1654,
15,
83,
12,
340,
2013,
1654,
15,
83,
787,
3451,
587,
886,
6548,
2122,
272,
849,
26,
3451,
272,
3415,
26,
359,
3451,
12,
9552,
1622,
199,
11036,
63,
9970,
63,
7677,
26,
19365,
14,
9970,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
2494,
653,
6495,
4260,
367,
1006,
10427,
14828,
10891,
315,
1627,
16454,
523,
19365,
63,
1102,
63,
15893,
26,
272,
6246,
26,
11400,
27127,
63,
4269,
16339,
272,
3434,
26,
11400,
27127,
63,
2473,
16339,
272,
2505,
26,
11400,
27127,
63,
2060,
16339,
272,
4350,
63,
354,
26,
4350,
63,
354,
272,
1174,
26,
3451,
272,
28581,
63,
5871,
26,
267,
446,
378,
14,
2293,
14,
15893,
14,
1308,
267,
446,
413,
14,
2293,
14,
15893,
14,
1308,
199,
199,
13,
536,
26,
2494,
653,
6495,
4260,
367,
376,
10427,
14828,
10891,
523,
19365,
63,
1102,
63,
15893,
26,
272,
6246,
26,
11400,
27127,
63,
4269,
16339,
272,
3434,
26,
11400,
27127,
63,
2473,
16339,
272,
2505,
26,
11400,
27127,
63,
2060,
16339,
272,
9455,
6865,
63,
4269,
26,
11400,
9455,
6865,
63,
4269,
16339,
272,
1174,
26,
3451,
272,
28581,
63,
5871,
26,
267,
446,
378,
14,
2293,
14,
15893,
14,
1308,
267,
446,
413,
14,
2293,
14,
15893,
14,
1308,
199,
199,
13,
536,
26,
5852,
653,
6495,
4260,
367,
376,
10427,
14828,
10891,
523,
19365,
63,
1102,
63,
15893,
26,
272,
6246,
26,
11400,
27127,
63,
4269,
16339,
272,
3434,
26,
11400,
27127,
63,
2473,
16339,
272,
2505,
26,
11400,
27127,
63,
2060,
16339,
272,
9455,
6865,
63,
4269,
26,
11400,
9455,
6865,
63,
4269,
16339,
272,
1174,
26,
9552,
272,
28581,
63,
5871,
26,
267,
446,
4875,
14,
1000,
14,
15893,
14,
1308,
199,
2344,
199,
199,
9677,
275,
519,
2344,
3,
199,
2344,
199,
199,
893,
26,
272,
687,
1134,
54,
28603,
492,
6695,
12,
373,
1494,
76,
199,
2590,
3545,
26,
272,
986,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
18970,
492,
19365,
63,
2094,
63,
1650,
12,
1611,
54,
28603,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
6106,
421,
199,
533,
812,
77,
1068,
46,
683,
2028,
2988,
8,
2713,
54,
28603,
304,
272,
347,
636,
826,
721,
277,
12,
859,
304,
267,
1613,
8,
17402,
1068,
46,
683,
2028,
2988,
12,
291,
2843,
826,
721,
578,
9,
267,
4350,
63,
354,
275,
291,
14,
1162,
14,
362,
360,
4201,
63,
354,
297,
488,
9,
267,
9455,
6865,
63,
1102,
63,
354,
275,
291,
14,
1162,
14,
362,
360,
397,
6865,
63,
4269,
297,
488,
9,
267,
291,
14,
15893,
63,
5871,
275,
291,
14,
1162,
14,
362,
360,
15893,
63,
5871,
297,
769,
1012,
267,
291,
14,
5146,
275,
942,
267,
340,
4350,
63,
354,
26,
288,
4350,
63,
1113,
275,
291,
14,
1623,
63,
4201,
63,
991,
63,
354,
8,
4201,
63,
354,
29,
4201,
63,
354,
9,
288,
340,
4350,
63,
1113,
26,
355,
291,
14,
5146,
275,
359,
1102,
367,
1591,
315,
4350,
63,
1113,
14,
1102,
61,
288,
587,
26,
355,
859,
14,
1633,
63,
1001,
8,
2489,
29,
797,
12,
1499,
628,
9581,
1543,
83,
7,
440,
1911,
2,
450,
4350,
63,
354,
9,
267,
916,
9455,
6865,
63,
1102,
63,
354,
26,
288,
9455,
6865,
63,
1102,
63,
1113,
275,
291,
14,
1623,
63,
1102,
2253,
63,
991,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ptoraskar/django
|
tests/migrate_signals/tests.py
|
324
|
3585
|
from django.apps import apps
from django.core import management
from django.db.models import signals
from django.test import TestCase, override_settings
from django.utils import six
APP_CONFIG = apps.get_app_config('migrate_signals')
PRE_MIGRATE_ARGS = ['app_config', 'verbosity', 'interactive', 'using']
MIGRATE_DATABASE = 'default'
MIGRATE_VERBOSITY = 1
MIGRATE_INTERACTIVE = False
class PreMigrateReceiver(object):
def __init__(self):
self.call_counter = 0
self.call_args = None
def __call__(self, signal, sender, **kwargs):
self.call_counter = self.call_counter + 1
self.call_args = kwargs
class OneTimeReceiver(object):
"""
Special receiver for handle the fact that test runner calls migrate for
several databases and several times for some of them.
"""
def __init__(self):
self.call_counter = 0
self.call_args = None
def __call__(self, signal, sender, **kwargs):
# Although test runner calls migrate for several databases,
# testing for only one of them is quite sufficient.
if kwargs['using'] == MIGRATE_DATABASE:
self.call_counter = self.call_counter + 1
self.call_args = kwargs
# we need to test only one call of migrate
signals.pre_migrate.disconnect(pre_migrate_receiver, sender=APP_CONFIG)
# We connect receiver here and not in unit test code because we need to
# connect receiver before test runner creates database. That is, sequence of
# actions would be:
#
# 1. Test runner imports this module.
# 2. We connect receiver.
# 3. Test runner calls migrate for create default database.
# 4. Test runner execute our unit test code.
pre_migrate_receiver = OneTimeReceiver()
signals.pre_migrate.connect(pre_migrate_receiver, sender=APP_CONFIG)
class MigrateSignalTests(TestCase):
available_apps = ['migrate_signals']
def test_pre_migrate_call_time(self):
self.assertEqual(pre_migrate_receiver.call_counter, 1)
def test_pre_migrate_args(self):
r = PreMigrateReceiver()
signals.pre_migrate.connect(r, sender=APP_CONFIG)
management.call_command('migrate', database=MIGRATE_DATABASE,
verbosity=MIGRATE_VERBOSITY, interactive=MIGRATE_INTERACTIVE,
stdout=six.StringIO())
args = r.call_args
self.assertEqual(r.call_counter, 1)
self.assertEqual(set(args), set(PRE_MIGRATE_ARGS))
self.assertEqual(args['app_config'], APP_CONFIG)
self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
self.assertEqual(args['using'], 'default')
@override_settings(MIGRATION_MODULES={'migrate_signals': 'migrate_signals.custom_migrations'})
def test_pre_migrate_migrations_only(self):
"""
If all apps have migrations, pre_migrate should be sent.
"""
r = PreMigrateReceiver()
signals.pre_migrate.connect(r, sender=APP_CONFIG)
stdout = six.StringIO()
management.call_command('migrate', database=MIGRATE_DATABASE,
verbosity=MIGRATE_VERBOSITY, interactive=MIGRATE_INTERACTIVE,
stdout=stdout)
args = r.call_args
self.assertEqual(r.call_counter, 1)
self.assertEqual(set(args), set(PRE_MIGRATE_ARGS))
self.assertEqual(args['app_config'], APP_CONFIG)
self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
self.assertEqual(args['using'], 'default')
|
bsd-3-clause
|
[
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
1018,
492,
10041,
199,
504,
1639,
14,
697,
14,
992,
492,
10166,
199,
504,
1639,
14,
396,
492,
7640,
12,
4278,
63,
1751,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
7121,
63,
5569,
275,
8686,
14,
362,
63,
571,
63,
888,
360,
8462,
63,
10458,
358,
199,
4225,
63,
22487,
16553,
63,
13990,
275,
788,
571,
63,
888,
297,
283,
9833,
297,
283,
13543,
297,
283,
4941,
418,
199,
22487,
16553,
63,
17873,
275,
283,
885,
7,
199,
22487,
16553,
63,
2111,
34,
3100,
1922,
275,
413,
199,
22487,
16553,
63,
3843,
10401,
275,
756,
421,
199,
533,
5543,
26641,
21800,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
1250,
63,
5337,
275,
378,
267,
291,
14,
1250,
63,
589,
275,
488,
339,
347,
636,
1250,
721,
277,
12,
4673,
12,
8904,
12,
1011,
958,
304,
267,
291,
14,
1250,
63,
5337,
275,
291,
14,
1250,
63,
5337,
435,
413,
267,
291,
14,
1250,
63,
589,
275,
2074,
421,
199,
533,
7309,
1366,
21800,
8,
785,
304,
272,
408,
272,
12568,
13035,
367,
2429,
314,
10572,
626,
511,
7876,
4882,
12810,
367,
272,
9978,
16219,
436,
9978,
5431,
367,
2005,
402,
3062,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
1250,
63,
5337,
275,
378,
267,
291,
14,
1250,
63,
589,
275,
488,
339,
347,
636,
1250,
721,
277,
12,
4673,
12,
8904,
12,
1011,
958,
304,
267,
327,
4580,
15401,
511,
7876,
4882,
12810,
367,
9978,
16219,
12,
267,
327,
5343,
367,
1454,
1373,
402,
3062,
365,
18794,
19258,
14,
267,
340,
2074,
459,
4941,
418,
508,
603,
1277,
16553,
63,
17873,
26,
288,
291,
14,
1250,
63,
5337,
275,
291,
14,
1250,
63,
5337,
435,
413,
288,
291,
14,
1250,
63,
589,
275,
2074,
288,
327,
781,
1929,
370,
511,
1454,
1373,
1240,
402,
12810,
288,
10166,
14,
657,
63,
8462,
14,
10673,
8,
657,
63,
8462,
63,
10244,
12,
8904,
29,
7121,
63,
5569,
9,
421,
199,
3,
2136,
4907,
13035,
2348,
436,
440,
315,
4137,
511,
1233,
2952,
781,
1929,
370,
199,
3,
4907,
13035,
2544,
511,
7876,
8491,
3050,
14,
221,
10314,
365,
12,
3414,
402,
199,
3,
5445,
3955,
506,
26,
199,
3,
199,
3,
257,
413,
14,
1379,
7876,
8925,
642,
859,
14,
199,
3,
257,
499,
14,
2136,
4907,
13035,
14,
199,
3,
257,
650,
14,
1379,
7876,
4882,
12810,
367,
1218,
849,
3050,
14,
199,
3,
257,
841,
14,
1379,
7876,
5341,
4154,
4137,
511,
1233,
14,
199,
657,
63,
8462,
63,
10244,
275,
7309,
1366,
21800,
342,
199,
10458,
14,
657,
63,
8462,
14,
2242,
8,
657,
63,
8462,
63,
10244,
12,
8904,
29,
7121,
63,
5569,
9,
421,
199,
533,
28195,
1866,
11274,
2925,
8,
1746,
304,
339,
2808,
63,
5181,
275,
788,
8462,
63,
10458,
418,
339,
347,
511,
63,
657,
63,
8462,
63,
1250,
63,
521,
8,
277,
304,
267,
291,
14,
629,
8,
657,
63,
8462,
63,
10244,
14,
1250,
63,
5337,
12,
413,
9,
339,
347,
511,
63,
657,
63,
8462,
63,
589,
8,
277,
304,
267,
519,
275,
5543,
26641,
21800,
342,
267,
10166,
14,
657,
63,
8462,
14,
2242,
8,
82,
12,
8904,
29,
7121,
63,
5569,
9,
267,
10041,
14,
1250,
63,
1531,
360,
8462,
297,
3050,
29,
22487,
16553,
63,
17873,
12,
288,
8661,
29,
22487,
16553,
63,
2111,
34,
3100,
1922,
12,
12777,
29,
22487,
16553,
63,
3843,
10401,
12,
288,
3839,
29,
4174,
14,
6424,
1012,
398,
1249,
275,
519,
14,
1250,
63,
589,
267,
291,
14,
629,
8,
82,
14,
1250,
63,
5337,
12,
413,
9,
267,
291,
14,
629,
8,
409,
8,
589,
395,
663,
8,
4225,
63,
22487,
16553,
63,
13990,
430,
267,
291,
14,
629,
8,
589,
459,
571,
63,
888,
995,
19525,
63,
5569,
9,
267,
291,
14,
629,
8,
589,
459,
9833,
995,
603,
1277,
16553,
63,
2111,
34,
3100,
1922,
9,
267,
291,
14,
629,
8,
589,
459,
13543,
995,
603,
1277,
16553,
63,
3843,
10401,
9,
267,
291,
14,
629,
8,
589,
459,
4941,
995,
283,
885,
358,
339,
768,
4415,
63,
1751,
8,
22487,
23743,
63,
21194,
3713,
8462,
63,
10458,
356,
283,
8462,
63,
10458,
14,
4229,
63,
7685,
3071,
272,
347,
511,
63,
657,
63,
8462,
63,
7685,
63,
2118,
8,
277,
304,
267,
408,
267,
982,
1006,
8686,
1172,
6180,
12,
876,
63,
8462,
1077,
506,
4847,
14,
267,
408,
267,
519,
275,
5543,
26641,
21800,
342,
267,
10166,
14,
657,
63,
8462,
14,
2242,
8,
82,
12,
8904,
29,
7121,
63,
5569,
9,
267,
3839,
275,
3816,
14,
6424,
342,
267,
10041,
14,
1250,
63,
1531,
360,
8462,
297,
3050,
29,
22487,
16553,
63,
17873,
12,
288,
8661,
29,
22487,
16553,
63,
2111,
34,
3100,
1922,
12,
12777,
29,
22487,
16553,
63,
3843,
10401,
12,
288,
3839,
29,
2703,
9,
267,
1249,
275,
519,
14,
1250,
63,
589,
267,
291,
14,
629,
8,
82,
14,
1250,
63,
5337,
12,
413,
9,
267,
291,
14,
629,
8,
409,
8,
589,
395,
663,
8,
4225,
63,
22487,
16553,
63,
13990,
430,
267,
291,
14,
629,
8,
589,
459,
571,
63,
888,
995,
19525,
63,
5569,
9,
267,
291,
14,
629,
8,
589,
459,
9833,
995,
603,
1277,
16553,
63,
2111,
34,
3100,
1922,
9,
267,
291,
14,
629,
8,
589,
459,
13543,
995,
603,
1277,
16553,
63,
3843,
10401,
9,
267,
291,
14,
629,
8,
589,
459,
4941,
995,
283,
885,
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
] |
[
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
1018,
492,
10041,
199,
504,
1639,
14,
697,
14,
992,
492,
10166,
199,
504,
1639,
14,
396,
492,
7640,
12,
4278,
63,
1751,
199,
504,
1639,
14,
1208,
492,
3816,
199,
199,
7121,
63,
5569,
275,
8686,
14,
362,
63,
571,
63,
888,
360,
8462,
63,
10458,
358,
199,
4225,
63,
22487,
16553,
63,
13990,
275,
788,
571,
63,
888,
297,
283,
9833,
297,
283,
13543,
297,
283,
4941,
418,
199,
22487,
16553,
63,
17873,
275,
283,
885,
7,
199,
22487,
16553,
63,
2111,
34,
3100,
1922,
275,
413,
199,
22487,
16553,
63,
3843,
10401,
275,
756,
421,
199,
533,
5543,
26641,
21800,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
1250,
63,
5337,
275,
378,
267,
291,
14,
1250,
63,
589,
275,
488,
339,
347,
636,
1250,
721,
277,
12,
4673,
12,
8904,
12,
1011,
958,
304,
267,
291,
14,
1250,
63,
5337,
275,
291,
14,
1250,
63,
5337,
435,
413,
267,
291,
14,
1250,
63,
589,
275,
2074,
421,
199,
533,
7309,
1366,
21800,
8,
785,
304,
272,
408,
272,
12568,
13035,
367,
2429,
314,
10572,
626,
511,
7876,
4882,
12810,
367,
272,
9978,
16219,
436,
9978,
5431,
367,
2005,
402,
3062,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
1250,
63,
5337,
275,
378,
267,
291,
14,
1250,
63,
589,
275,
488,
339,
347,
636,
1250,
721,
277,
12,
4673,
12,
8904,
12,
1011,
958,
304,
267,
327,
4580,
15401,
511,
7876,
4882,
12810,
367,
9978,
16219,
12,
267,
327,
5343,
367,
1454,
1373,
402,
3062,
365,
18794,
19258,
14,
267,
340,
2074,
459,
4941,
418,
508,
603,
1277,
16553,
63,
17873,
26,
288,
291,
14,
1250,
63,
5337,
275,
291,
14,
1250,
63,
5337,
435,
413,
288,
291,
14,
1250,
63,
589,
275,
2074,
288,
327,
781,
1929,
370,
511,
1454,
1373,
1240,
402,
12810,
288,
10166,
14,
657,
63,
8462,
14,
10673,
8,
657,
63,
8462,
63,
10244,
12,
8904,
29,
7121,
63,
5569,
9,
421,
199,
3,
2136,
4907,
13035,
2348,
436,
440,
315,
4137,
511,
1233,
2952,
781,
1929,
370,
199,
3,
4907,
13035,
2544,
511,
7876,
8491,
3050,
14,
221,
10314,
365,
12,
3414,
402,
199,
3,
5445,
3955,
506,
26,
199,
3,
199,
3,
257,
413,
14,
1379,
7876,
8925,
642,
859,
14,
199,
3,
257,
499,
14,
2136,
4907,
13035,
14,
199,
3,
257,
650,
14,
1379,
7876,
4882,
12810,
367,
1218,
849,
3050,
14,
199,
3,
257,
841,
14,
1379,
7876,
5341,
4154,
4137,
511,
1233,
14,
199,
657,
63,
8462,
63,
10244,
275,
7309,
1366,
21800,
342,
199,
10458,
14,
657,
63,
8462,
14,
2242,
8,
657,
63,
8462,
63,
10244,
12,
8904,
29,
7121,
63,
5569,
9,
421,
199,
533,
28195,
1866,
11274,
2925,
8,
1746,
304,
339,
2808,
63,
5181,
275,
788,
8462,
63,
10458,
418,
339,
347,
511,
63,
657,
63,
8462,
63,
1250,
63,
521,
8,
277,
304,
267,
291,
14,
629,
8,
657,
63,
8462,
63,
10244,
14,
1250,
63,
5337,
12,
413,
9,
339,
347,
511,
63,
657,
63,
8462,
63,
589,
8,
277,
304,
267,
519,
275,
5543,
26641,
21800,
342,
267,
10166,
14,
657,
63,
8462,
14,
2242,
8,
82,
12,
8904,
29,
7121,
63,
5569,
9,
267,
10041,
14,
1250,
63,
1531,
360,
8462,
297,
3050,
29,
22487,
16553,
63,
17873,
12,
288,
8661,
29,
22487,
16553,
63,
2111,
34,
3100,
1922,
12,
12777,
29,
22487,
16553,
63,
3843,
10401,
12,
288,
3839,
29,
4174,
14,
6424,
1012,
398,
1249,
275,
519,
14,
1250,
63,
589,
267,
291,
14,
629,
8,
82,
14,
1250,
63,
5337,
12,
413,
9,
267,
291,
14,
629,
8,
409,
8,
589,
395,
663,
8,
4225,
63,
22487,
16553,
63,
13990,
430,
267,
291,
14,
629,
8,
589,
459,
571,
63,
888,
995,
19525,
63,
5569,
9,
267,
291,
14,
629,
8,
589,
459,
9833,
995,
603,
1277,
16553,
63,
2111,
34,
3100,
1922,
9,
267,
291,
14,
629,
8,
589,
459,
13543,
995,
603,
1277,
16553,
63,
3843,
10401,
9,
267,
291,
14,
629,
8,
589,
459,
4941,
995,
283,
885,
358,
339,
768,
4415,
63,
1751,
8,
22487,
23743,
63,
21194,
3713,
8462,
63,
10458,
356,
283,
8462,
63,
10458,
14,
4229,
63,
7685,
3071,
272,
347,
511,
63,
657,
63,
8462,
63,
7685,
63,
2118,
8,
277,
304,
267,
408,
267,
982,
1006,
8686,
1172,
6180,
12,
876,
63,
8462,
1077,
506,
4847,
14,
267,
408,
267,
519,
275,
5543,
26641,
21800,
342,
267,
10166,
14,
657,
63,
8462,
14,
2242,
8,
82,
12,
8904,
29,
7121,
63,
5569,
9,
267,
3839,
275,
3816,
14,
6424,
342,
267,
10041,
14,
1250,
63,
1531,
360,
8462,
297,
3050,
29,
22487,
16553,
63,
17873,
12,
288,
8661,
29,
22487,
16553,
63,
2111,
34,
3100,
1922,
12,
12777,
29,
22487,
16553,
63,
3843,
10401,
12,
288,
3839,
29,
2703,
9,
267,
1249,
275,
519,
14,
1250,
63,
589,
267,
291,
14,
629,
8,
82,
14,
1250,
63,
5337,
12,
413,
9,
267,
291,
14,
629,
8,
409,
8,
589,
395,
663,
8,
4225,
63,
22487,
16553,
63,
13990,
430,
267,
291,
14,
629,
8,
589,
459,
571,
63,
888,
995,
19525,
63,
5569,
9,
267,
291,
14,
629,
8,
589,
459,
9833,
995,
603,
1277,
16553,
63,
2111,
34,
3100,
1922,
9,
267,
291,
14,
629,
8,
589,
459,
13543,
995,
603,
1277,
16553,
63,
3843,
10401,
9,
267,
291,
14,
629,
8,
589,
459,
4941,
995,
283,
885,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
sv-dev1/odoo
|
addons/auth_oauth/res_users.py
|
121
|
5240
|
import logging
import werkzeug.urls
import urlparse
import urllib2
import simplejson
import openerp
from openerp.addons.auth_signup.res_users import SignupError
from openerp.osv import osv, fields
from openerp import SUPERUSER_ID
_logger = logging.getLogger(__name__)
class res_users(osv.Model):
_inherit = 'res.users'
_columns = {
'oauth_provider_id': fields.many2one('auth.oauth.provider', 'OAuth Provider'),
'oauth_uid': fields.char('OAuth User ID', help="Oauth Provider user_id", copy=False),
'oauth_access_token': fields.char('OAuth Access Token', readonly=True, copy=False),
}
_sql_constraints = [
('uniq_users_oauth_provider_oauth_uid', 'unique(oauth_provider_id, oauth_uid)', 'OAuth UID must be unique per provider'),
]
def _auth_oauth_rpc(self, cr, uid, endpoint, access_token, context=None):
params = werkzeug.url_encode({'access_token': access_token})
if urlparse.urlparse(endpoint)[4]:
url = endpoint + '&' + params
else:
url = endpoint + '?' + params
f = urllib2.urlopen(url)
response = f.read()
return simplejson.loads(response)
def _auth_oauth_validate(self, cr, uid, provider, access_token, context=None):
""" return the validation data corresponding to the access token """
p = self.pool.get('auth.oauth.provider').browse(cr, uid, provider, context=context)
validation = self._auth_oauth_rpc(cr, uid, p.validation_endpoint, access_token)
if validation.get("error"):
raise Exception(validation['error'])
if p.data_endpoint:
data = self._auth_oauth_rpc(cr, uid, p.data_endpoint, access_token)
validation.update(data)
return validation
def _generate_signup_values(self, cr, uid, provider, validation, params, context=None):
oauth_uid = validation['user_id']
email = validation.get('email', 'provider_%s_user_%s' % (provider, oauth_uid))
name = validation.get('name', email)
return {
'name': name,
'login': email,
'email': email,
'oauth_provider_id': provider,
'oauth_uid': oauth_uid,
'oauth_access_token': params['access_token'],
'active': True,
}
def _auth_oauth_signin(self, cr, uid, provider, validation, params, context=None):
""" retrieve and sign in the user corresponding to provider and validated access token
:param provider: oauth provider id (int)
:param validation: result of validation of access token (dict)
:param params: oauth parameters (dict)
:return: user login (str)
:raise: openerp.exceptions.AccessDenied if signin failed
This method can be overridden to add alternative signin methods.
"""
try:
oauth_uid = validation['user_id']
user_ids = self.search(cr, uid, [("oauth_uid", "=", oauth_uid), ('oauth_provider_id', '=', provider)])
if not user_ids:
raise openerp.exceptions.AccessDenied()
assert len(user_ids) == 1
user = self.browse(cr, uid, user_ids[0], context=context)
user.write({'oauth_access_token': params['access_token']})
return user.login
except openerp.exceptions.AccessDenied, access_denied_exception:
if context and context.get('no_user_creation'):
return None
state = simplejson.loads(params['state'])
token = state.get('t')
values = self._generate_signup_values(cr, uid, provider, validation, params, context=context)
try:
_, login, _ = self.signup(cr, uid, values, token, context=context)
return login
except SignupError:
raise access_denied_exception
def auth_oauth(self, cr, uid, provider, params, context=None):
# Advice by Google (to avoid Confused Deputy Problem)
# if validation.audience != OUR_CLIENT_ID:
# abort()
# else:
# continue with the process
access_token = params.get('access_token')
validation = self._auth_oauth_validate(cr, uid, provider, access_token)
# required check
if not validation.get('user_id'):
# Workaround: facebook does not send 'user_id' in Open Graph Api
if validation.get('id'):
validation['user_id'] = validation['id']
else:
raise openerp.exceptions.AccessDenied()
# retrieve and sign in user
login = self._auth_oauth_signin(cr, uid, provider, validation, params, context=context)
if not login:
raise openerp.exceptions.AccessDenied()
# return user credentials
return (cr.dbname, login, access_token)
def check_credentials(self, cr, uid, password):
try:
return super(res_users, self).check_credentials(cr, uid, password)
except openerp.exceptions.AccessDenied:
res = self.search(cr, SUPERUSER_ID, [('id', '=', uid), ('oauth_access_token', '=', password)])
if not res:
raise
#
|
agpl-3.0
|
[
646,
2050,
199,
199,
646,
10380,
14,
3603,
199,
646,
7097,
199,
646,
4011,
18,
199,
646,
13804,
199,
199,
646,
5166,
199,
504,
5166,
14,
10788,
14,
1178,
63,
19799,
14,
470,
63,
3707,
492,
6632,
384,
547,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
492,
12824,
63,
998,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
533,
522,
63,
3707,
8,
4795,
14,
1685,
304,
272,
485,
6486,
275,
283,
470,
14,
3707,
7,
339,
485,
3406,
275,
469,
267,
283,
6126,
63,
3780,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
1178,
14,
6126,
14,
3780,
297,
283,
12906,
18489,
659,
267,
283,
6126,
63,
1535,
356,
1504,
14,
1560,
360,
12906,
2876,
2870,
297,
1720,
628,
47,
1178,
18489,
922,
63,
344,
401,
1331,
29,
797,
395,
267,
283,
6126,
63,
2732,
63,
1418,
356,
1504,
14,
1560,
360,
12906,
11003,
8767,
297,
6863,
29,
549,
12,
1331,
29,
797,
395,
272,
789,
339,
485,
3009,
63,
9882,
275,
359,
267,
661,
22484,
63,
3707,
63,
6126,
63,
3780,
63,
6126,
63,
1535,
297,
283,
3235,
8,
6126,
63,
3780,
63,
344,
12,
9725,
63,
1535,
3196,
283,
12906,
20746,
1471,
506,
3747,
1126,
5022,
659,
272,
1622,
339,
347,
485,
1178,
63,
6126,
63,
4354,
8,
277,
12,
2467,
12,
1747,
12,
6037,
12,
2879,
63,
1418,
12,
1067,
29,
403,
304,
267,
1862,
275,
10380,
14,
633,
63,
2143,
3252,
2732,
63,
1418,
356,
2879,
63,
1418,
1552,
267,
340,
7097,
14,
10290,
8,
6520,
2788,
20,
2189,
288,
1166,
275,
6037,
435,
29285,
435,
1862,
267,
587,
26,
288,
1166,
275,
6037,
435,
15539,
435,
1862,
267,
289,
275,
4011,
18,
14,
10890,
8,
633,
9,
267,
1177,
275,
289,
14,
739,
342,
267,
372,
13804,
14,
3640,
8,
1310,
9,
339,
347,
485,
1178,
63,
6126,
63,
3502,
8,
277,
12,
2467,
12,
1747,
12,
5022,
12,
2879,
63,
1418,
12,
1067,
29,
403,
304,
267,
408,
372,
314,
6411,
666,
5226,
370,
314,
2879,
1526,
408,
267,
299,
275,
291,
14,
2293,
14,
362,
360,
1178,
14,
6126,
14,
3780,
1959,
4570,
8,
1556,
12,
1747,
12,
5022,
12,
1067,
29,
1100,
9,
267,
6411,
275,
291,
423,
1178,
63,
6126,
63,
4354,
8,
1556,
12,
1747,
12,
299,
14,
6136,
63,
6520,
12,
2879,
63,
1418,
9,
267,
340,
6411,
14,
362,
480,
705,
2349,
288,
746,
2186,
8,
6136,
459,
705,
1105,
267,
340,
299,
14,
576,
63,
6520,
26,
288,
666,
275,
291,
423,
1178,
63,
6126,
63,
4354,
8,
1556,
12,
1747,
12,
299,
14,
576,
63,
6520,
12,
2879,
63,
1418,
9,
288,
6411,
14,
873,
8,
576,
9,
267,
372,
6411,
339,
347,
485,
4208,
63,
19799,
63,
1459,
8,
277,
12,
2467,
12,
1747,
12,
5022,
12,
6411,
12,
1862,
12,
1067,
29,
403,
304,
267,
9725,
63,
1535,
275,
6411,
459,
751,
63,
344,
418,
267,
3031,
275,
6411,
14,
362,
360,
2123,
297,
283,
3780,
4970,
83,
63,
751,
4970,
83,
7,
450,
334,
3780,
12,
9725,
63,
1535,
430,
267,
536,
275,
6411,
14,
362,
360,
354,
297,
3031,
9,
267,
372,
469,
288,
283,
354,
356,
536,
12,
288,
283,
2886,
356,
3031,
12,
288,
283,
2123,
356,
3031,
12,
288,
283,
6126,
63,
3780,
63,
344,
356,
5022,
12,
288,
283,
6126,
63,
1535,
356,
9725,
63,
1535,
12,
288,
283,
6126,
63,
2732,
63,
1418,
356,
1862,
459,
2732,
63,
1418,
995,
288,
283,
2682,
356,
715,
12,
267,
789,
339,
347,
485,
1178,
63,
6126,
63,
1037,
262,
8,
277,
12,
2467,
12,
1747,
12,
5022,
12,
6411,
12,
1862,
12,
1067,
29,
403,
304,
267,
408,
8044,
436,
2070,
315,
314,
922,
5226,
370,
5022,
436,
16468,
2879,
1526,
288,
520,
635,
5022,
26,
9725,
5022,
1305,
334,
442,
9,
288,
520,
635,
6411,
26,
754,
402,
6411,
402,
2879,
1526,
334,
807,
9,
288,
520,
635,
1862,
26,
9725,
2633,
334,
807,
9,
288,
520,
1107,
26,
922,
4676,
334,
495,
9,
288,
520,
3730,
26,
5166,
14,
3924,
14,
3946,
15729,
340,
2070,
262,
3405,
953,
961,
1083,
883,
506,
10087,
370,
1050,
13943,
2070,
262,
3102,
14,
267,
408,
267,
862,
26,
288,
9725,
63,
1535,
275,
6411,
459,
751,
63,
344,
418,
288,
922,
63,
1580,
275,
291,
14,
1733,
8,
1556,
12,
1747,
12,
10003,
6126,
63,
1535,
401,
298,
11107,
9725,
63,
1535,
395,
661,
6126,
63,
3780,
63,
344,
297,
6291,
5022,
3948,
288,
340,
440,
922,
63,
1580,
26,
355,
746,
5166,
14,
3924,
14,
3946,
15729,
342,
288,
702,
822,
8,
751,
63,
1580,
9,
508,
413,
288,
922,
275,
291,
14,
4570,
8,
1556,
12,
1747,
12,
922,
63,
1580,
59,
16,
467,
1067,
29,
1100,
9,
288,
922,
14,
952,
3252,
6126,
63,
2732,
63,
1418,
356,
1862,
459,
2732,
63,
1418,
13678,
288,
372,
922,
14,
2886,
267,
871,
5166,
14,
3924,
14,
3946,
15729,
12,
2879,
63,
28180,
63,
1971,
26,
288,
340,
1067,
436,
1067,
14,
362,
360,
889,
63,
751,
63,
8782,
735,
355,
372,
488,
288,
1174,
275,
13804,
14,
3640,
8,
1162,
459,
929,
1105,
288,
1526,
275,
1174,
14,
362,
360,
84,
358,
288,
1338,
275,
291,
423,
4208,
63,
19799,
63,
1459,
8,
1556,
12,
1747,
12,
5022,
12,
6411,
12,
1862,
12,
1067,
29,
1100,
9,
288,
862,
26,
355,
5501,
4676,
12,
485,
275,
291,
14,
19799,
8,
1556,
12,
1747,
12,
1338,
12,
1526,
12,
1067,
29,
1100,
9,
355,
372,
4676,
288,
871,
6632,
384,
547,
26,
355,
746,
2879,
63,
28180,
63,
1971,
339,
347,
1790,
63,
6126,
8,
277,
12,
2467,
12,
1747,
12,
5022,
12,
1862,
12,
1067,
29,
403,
304,
267,
327,
4431,
722,
701,
4475,
334,
475,
5126,
1448,
30032,
1487,
524,
89,
20980,
9,
267,
327,
340,
6411,
14,
23577,
4894,
1137,
593,
1230,
63,
9901,
63,
998,
26,
267,
327,
257,
12004,
342,
267,
327,
587,
26,
267,
327,
257,
1980,
543,
314,
2112,
267,
2879,
63,
1418,
275,
1862,
14,
362,
360,
2732,
63,
1418,
358,
267,
6411
] |
[
2050,
199,
199,
646,
10380,
14,
3603,
199,
646,
7097,
199,
646,
4011,
18,
199,
646,
13804,
199,
199,
646,
5166,
199,
504,
5166,
14,
10788,
14,
1178,
63,
19799,
14,
470,
63,
3707,
492,
6632,
384,
547,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
492,
12824,
63,
998,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
533,
522,
63,
3707,
8,
4795,
14,
1685,
304,
272,
485,
6486,
275,
283,
470,
14,
3707,
7,
339,
485,
3406,
275,
469,
267,
283,
6126,
63,
3780,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
1178,
14,
6126,
14,
3780,
297,
283,
12906,
18489,
659,
267,
283,
6126,
63,
1535,
356,
1504,
14,
1560,
360,
12906,
2876,
2870,
297,
1720,
628,
47,
1178,
18489,
922,
63,
344,
401,
1331,
29,
797,
395,
267,
283,
6126,
63,
2732,
63,
1418,
356,
1504,
14,
1560,
360,
12906,
11003,
8767,
297,
6863,
29,
549,
12,
1331,
29,
797,
395,
272,
789,
339,
485,
3009,
63,
9882,
275,
359,
267,
661,
22484,
63,
3707,
63,
6126,
63,
3780,
63,
6126,
63,
1535,
297,
283,
3235,
8,
6126,
63,
3780,
63,
344,
12,
9725,
63,
1535,
3196,
283,
12906,
20746,
1471,
506,
3747,
1126,
5022,
659,
272,
1622,
339,
347,
485,
1178,
63,
6126,
63,
4354,
8,
277,
12,
2467,
12,
1747,
12,
6037,
12,
2879,
63,
1418,
12,
1067,
29,
403,
304,
267,
1862,
275,
10380,
14,
633,
63,
2143,
3252,
2732,
63,
1418,
356,
2879,
63,
1418,
1552,
267,
340,
7097,
14,
10290,
8,
6520,
2788,
20,
2189,
288,
1166,
275,
6037,
435,
29285,
435,
1862,
267,
587,
26,
288,
1166,
275,
6037,
435,
15539,
435,
1862,
267,
289,
275,
4011,
18,
14,
10890,
8,
633,
9,
267,
1177,
275,
289,
14,
739,
342,
267,
372,
13804,
14,
3640,
8,
1310,
9,
339,
347,
485,
1178,
63,
6126,
63,
3502,
8,
277,
12,
2467,
12,
1747,
12,
5022,
12,
2879,
63,
1418,
12,
1067,
29,
403,
304,
267,
408,
372,
314,
6411,
666,
5226,
370,
314,
2879,
1526,
408,
267,
299,
275,
291,
14,
2293,
14,
362,
360,
1178,
14,
6126,
14,
3780,
1959,
4570,
8,
1556,
12,
1747,
12,
5022,
12,
1067,
29,
1100,
9,
267,
6411,
275,
291,
423,
1178,
63,
6126,
63,
4354,
8,
1556,
12,
1747,
12,
299,
14,
6136,
63,
6520,
12,
2879,
63,
1418,
9,
267,
340,
6411,
14,
362,
480,
705,
2349,
288,
746,
2186,
8,
6136,
459,
705,
1105,
267,
340,
299,
14,
576,
63,
6520,
26,
288,
666,
275,
291,
423,
1178,
63,
6126,
63,
4354,
8,
1556,
12,
1747,
12,
299,
14,
576,
63,
6520,
12,
2879,
63,
1418,
9,
288,
6411,
14,
873,
8,
576,
9,
267,
372,
6411,
339,
347,
485,
4208,
63,
19799,
63,
1459,
8,
277,
12,
2467,
12,
1747,
12,
5022,
12,
6411,
12,
1862,
12,
1067,
29,
403,
304,
267,
9725,
63,
1535,
275,
6411,
459,
751,
63,
344,
418,
267,
3031,
275,
6411,
14,
362,
360,
2123,
297,
283,
3780,
4970,
83,
63,
751,
4970,
83,
7,
450,
334,
3780,
12,
9725,
63,
1535,
430,
267,
536,
275,
6411,
14,
362,
360,
354,
297,
3031,
9,
267,
372,
469,
288,
283,
354,
356,
536,
12,
288,
283,
2886,
356,
3031,
12,
288,
283,
2123,
356,
3031,
12,
288,
283,
6126,
63,
3780,
63,
344,
356,
5022,
12,
288,
283,
6126,
63,
1535,
356,
9725,
63,
1535,
12,
288,
283,
6126,
63,
2732,
63,
1418,
356,
1862,
459,
2732,
63,
1418,
995,
288,
283,
2682,
356,
715,
12,
267,
789,
339,
347,
485,
1178,
63,
6126,
63,
1037,
262,
8,
277,
12,
2467,
12,
1747,
12,
5022,
12,
6411,
12,
1862,
12,
1067,
29,
403,
304,
267,
408,
8044,
436,
2070,
315,
314,
922,
5226,
370,
5022,
436,
16468,
2879,
1526,
288,
520,
635,
5022,
26,
9725,
5022,
1305,
334,
442,
9,
288,
520,
635,
6411,
26,
754,
402,
6411,
402,
2879,
1526,
334,
807,
9,
288,
520,
635,
1862,
26,
9725,
2633,
334,
807,
9,
288,
520,
1107,
26,
922,
4676,
334,
495,
9,
288,
520,
3730,
26,
5166,
14,
3924,
14,
3946,
15729,
340,
2070,
262,
3405,
953,
961,
1083,
883,
506,
10087,
370,
1050,
13943,
2070,
262,
3102,
14,
267,
408,
267,
862,
26,
288,
9725,
63,
1535,
275,
6411,
459,
751,
63,
344,
418,
288,
922,
63,
1580,
275,
291,
14,
1733,
8,
1556,
12,
1747,
12,
10003,
6126,
63,
1535,
401,
298,
11107,
9725,
63,
1535,
395,
661,
6126,
63,
3780,
63,
344,
297,
6291,
5022,
3948,
288,
340,
440,
922,
63,
1580,
26,
355,
746,
5166,
14,
3924,
14,
3946,
15729,
342,
288,
702,
822,
8,
751,
63,
1580,
9,
508,
413,
288,
922,
275,
291,
14,
4570,
8,
1556,
12,
1747,
12,
922,
63,
1580,
59,
16,
467,
1067,
29,
1100,
9,
288,
922,
14,
952,
3252,
6126,
63,
2732,
63,
1418,
356,
1862,
459,
2732,
63,
1418,
13678,
288,
372,
922,
14,
2886,
267,
871,
5166,
14,
3924,
14,
3946,
15729,
12,
2879,
63,
28180,
63,
1971,
26,
288,
340,
1067,
436,
1067,
14,
362,
360,
889,
63,
751,
63,
8782,
735,
355,
372,
488,
288,
1174,
275,
13804,
14,
3640,
8,
1162,
459,
929,
1105,
288,
1526,
275,
1174,
14,
362,
360,
84,
358,
288,
1338,
275,
291,
423,
4208,
63,
19799,
63,
1459,
8,
1556,
12,
1747,
12,
5022,
12,
6411,
12,
1862,
12,
1067,
29,
1100,
9,
288,
862,
26,
355,
5501,
4676,
12,
485,
275,
291,
14,
19799,
8,
1556,
12,
1747,
12,
1338,
12,
1526,
12,
1067,
29,
1100,
9,
355,
372,
4676,
288,
871,
6632,
384,
547,
26,
355,
746,
2879,
63,
28180,
63,
1971,
339,
347,
1790,
63,
6126,
8,
277,
12,
2467,
12,
1747,
12,
5022,
12,
1862,
12,
1067,
29,
403,
304,
267,
327,
4431,
722,
701,
4475,
334,
475,
5126,
1448,
30032,
1487,
524,
89,
20980,
9,
267,
327,
340,
6411,
14,
23577,
4894,
1137,
593,
1230,
63,
9901,
63,
998,
26,
267,
327,
257,
12004,
342,
267,
327,
587,
26,
267,
327,
257,
1980,
543,
314,
2112,
267,
2879,
63,
1418,
275,
1862,
14,
362,
360,
2732,
63,
1418,
358,
267,
6411,
0
] |
[
1,
1,
1,
1,
1,
1,
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chmail_attach_from_folder/model/fetchmail_server_folder.py
|
16
|
4394
|
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013 Therp BV (<http://therp.nl>)
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
from openerp import api, models, fields
from .. import match_algorithm
class fetchmail_server_folder(models.Model):
_name = 'fetchmail.server.folder'
_rec_name = 'path'
def _get_match_algorithms(self):
def get_all_subclasses(cls):
return (cls.__subclasses__() +
[subsub
for sub in cls.__subclasses__()
for subsub in get_all_subclasses(sub)])
return dict([(cls.__name__, cls)
for cls in get_all_subclasses(
match_algorithm.base.base)])
def _get_match_algorithms_sel(self):
algorithms = []
for cls in self._get_match_algorithms().itervalues():
algorithms.append((cls.__name__, cls.name))
algorithms.sort()
return algorithms
sequence = fields.Integer('Sequence')
path = fields.Char(
'Path',
help="The path to your mail folder. Typically would be something like "
"'INBOX.myfolder'", required=True)
model_id = fields.Many2one(
'ir.model', 'Model', required=True,
help='The model to attach emails to')
model_field = fields.Char(
'Field (model)',
help='The field in your model that contains the field to match '
'against.\n'
'Examples:\n'
"'email' if your model is res.partner, or "
"'partner_id.email' if you're matching sale orders")
model_order = fields.Char(
'Order (model)',
help='Field(s) to order by, this mostly useful in conjunction '
"with 'Use 1st match'")
match_algorithm = fields.Selection(
_get_match_algorithms_sel,
'Match algorithm', required=True,
help='The algorithm used to determine which object an email matches.')
mail_field = fields.Char(
'Field (email)',
help='The field in the email used for matching. Typically '
"this is 'to' or 'from'")
server_id = fields.Many2one('fetchmail.server', 'Server')
delete_matching = fields.Boolean(
'Delete matches',
help='Delete matched emails from server')
flag_nonmatching = fields.Boolean(
'Flag nonmatching',
help="Flag emails in the server that don't match any object in Odoo")
match_first = fields.Boolean(
'Use 1st match',
help='If there are multiple matches, use the first one. If '
'not checked, multiple matches count as no match at all')
domain = fields.Char(
'Domain',
help='Fill in a search filter to narrow down objects to match')
msg_state = fields.Selection(
[
('sent', 'Sent'),
('received', 'Received'),
],
'Message state',
help='The state messages fetched from this folder should be '
'assigned in Odoo')
_defaults = {
'flag_nonmatching': True,
'msg_state': 'received',
}
@api.multi
def get_algorithm(self):
return self._get_match_algorithms()[self.match_algorithm]()
@api.multi
def button_attach_mail_manually(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'fetchmail.attach.mail.manually',
'target': 'new',
'context': dict(self.env.context, default_folder_id=self.id),
'view_type': 'form',
'view_mode': 'form',
}
|
agpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
961,
859,
4248,
334,
35,
9,
6171,
377,
2523,
80,
699,
54,
8642,
1014,
921,
728,
80,
14,
7530,
18956,
199,
3,
259,
2900,
5924,
5702,
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,
3949,
199,
504,
5166,
492,
2986,
12,
1709,
12,
1504,
199,
504,
2508,
492,
1336,
63,
8833,
421,
199,
533,
5267,
1198,
63,
1000,
63,
3741,
8,
992,
14,
1685,
304,
272,
485,
354,
275,
283,
3535,
1198,
14,
1000,
14,
3741,
7,
272,
485,
2761,
63,
354,
275,
283,
515,
7,
339,
347,
485,
362,
63,
1431,
63,
24365,
8,
277,
304,
267,
347,
664,
63,
452,
63,
19094,
8,
1886,
304,
288,
372,
334,
1886,
855,
19094,
4533,
435,
490,
359,
954,
954,
2151,
367,
1007,
315,
843,
855,
19094,
4533,
2151,
367,
1007,
954,
315,
664,
63,
452,
63,
19094,
8,
954,
3948,
267,
372,
1211,
7694,
1886,
855,
354,
3108,
843,
9,
2151,
367,
843,
315,
664,
63,
452,
63,
19094,
8,
586,
1336,
63,
8833,
14,
1095,
14,
1095,
3948,
339,
347,
485,
362,
63,
1431,
63,
24365,
63,
5891,
8,
277,
304,
267,
18036,
275,
942,
267,
367,
843,
315,
291,
423,
362,
63,
1431,
63,
24365,
1252,
13012,
837,
288,
18036,
14,
740,
1332,
1886,
855,
354,
3108,
843,
14,
354,
430,
267,
18036,
14,
3191,
342,
267,
372,
18036,
339,
3414,
275,
1504,
14,
2674,
360,
5826,
358,
272,
931,
275,
1504,
14,
1610,
8,
267,
283,
2042,
297,
267,
1720,
628,
1918,
931,
370,
2195,
6016,
4922,
14,
26914,
3955,
506,
6020,
2839,
298,
267,
3546,
568,
15694,
14,
1662,
3741,
4662,
1415,
29,
549,
9,
272,
1402,
63,
344,
275,
1504,
14,
4089,
18,
368,
8,
267,
283,
723,
14,
1238,
297,
283,
1685,
297,
1415,
29,
549,
12,
267,
1720,
534,
1918,
1402,
370,
6554,
14931,
370,
358,
272,
1402,
63,
698,
275,
1504,
14,
1610,
8,
267,
283,
792,
334,
1238,
3196,
267,
1720,
534,
1918,
901,
315,
2195,
1402,
626,
3509,
314,
901,
370,
1336,
283,
267,
283,
17777,
3134,
78,
7,
267,
283,
22787,
3427,
78,
7,
267,
3546,
2123,
7,
340,
2195,
1402,
365,
522,
14,
3899,
12,
503,
298,
267,
3546,
3899,
63,
344,
14,
2123,
7,
340,
1265,
3984,
4877,
13590,
15460,
531,
272,
1402,
63,
1648,
275,
1504,
14,
1610,
8,
267,
283,
4738,
334,
1238,
3196,
267,
1720,
534,
792,
8,
83,
9,
370,
1865,
701,
12,
642,
19762,
2997,
315,
22888,
283,
267,
298,
1045,
283,
6119,
413,
270,
1336,
9859,
272,
1336,
63,
8833,
275,
1504,
14,
7713,
8,
267,
485,
362,
63,
1431,
63,
24365,
63,
5891,
12,
267,
283,
4486,
5563,
297,
1415,
29,
549,
12,
267,
1720,
534,
1918,
5563,
1202,
370,
6705,
1314,
909,
376,
3031,
4450,
2659,
272,
6016,
63,
698,
275,
1504,
14,
1610,
8,
267,
283,
792,
334,
2123,
3196,
267,
1720,
534,
1918,
901,
315,
314,
3031,
1202,
367,
4877,
14,
26914,
283,
267,
298,
3749,
365,
283,
475,
7,
503,
283,
504,
9859,
272,
1654,
63,
344,
275,
1504,
14,
4089,
18,
368,
360,
3535,
1198,
14,
1000,
297,
283,
3120,
358,
272,
3145,
63,
9467,
275,
1504,
14,
4082,
8,
267,
283,
5392,
4450,
297,
267,
1720,
534,
5392,
7838,
14931,
687,
1654,
358,
272,
3305,
63,
2865,
9467,
275,
1504,
14,
4082,
8,
267,
283,
5318,
2222,
9467,
297,
267,
1720,
628,
5318,
14931,
315,
314,
1654,
626,
2793,
1133,
1336,
1263,
909,
315,
28935,
531,
272,
1336,
63,
2246,
275,
1504,
14,
4082,
8,
267,
283,
6119,
413,
270,
1336,
297,
267,
1720,
534,
3917,
2337,
787,
3663,
4450,
12,
675,
314,
1642,
1373,
14,
982,
283,
267,
283,
1397,
7923,
12,
3663,
4450,
2338,
465,
949,
1336,
737,
1006,
358,
272,
2881,
275,
1504,
14,
1610,
8,
267,
283,
7705,
297,
267,
1720,
534,
12914,
315,
282,
2754,
2457,
370,
31530,
3224,
2251,
370,
1336,
358,
272,
1499,
63,
929,
275,
1504,
14,
7713,
8,
267,
359,
288,
661,
1150,
297,
283,
17367,
659,
288,
661,
9226,
297,
283,
9392,
659,
267,
2156,
267,
283,
2209,
1174,
297,
267,
1720,
534,
1918,
1174,
3788,
19251,
687,
642,
4922,
1077,
506,
283,
267,
283,
12941,
315,
28935,
358,
339,
485,
4322,
275,
469,
267,
283,
4173,
63,
2865,
9467,
356,
715,
12,
267,
283,
1328,
63,
929,
356,
283,
9226,
297,
272,
789,
339,
768,
1246,
14,
3029,
272,
347,
664,
63,
8833,
8,
277,
304,
267,
372,
291,
423,
362,
63,
1431,
63,
24365,
3430,
277,
14,
1431,
63,
8833,
32702,
339,
768,
1246,
14,
3029,
272,
347,
5528,
63,
5040,
63,
1198,
63,
1237,
3163,
8,
277,
304,
267,
372,
469,
288,
283,
466,
356,
283,
723,
14,
3723,
14,
2442,
63,
3806,
297,
288,
283,
470,
63,
1238,
356,
283,
3535,
1198,
14,
5040,
14,
1198,
14,
1237,
3163,
297,
288,
283,
1375,
356,
283,
1222,
297,
288,
283,
1100,
356,
1211,
8,
277,
14,
1813,
14,
1100,
12,
849,
63,
3741,
63,
344,
29,
277,
14,
344,
395,
288,
283,
1345,
63,
466,
356,
283,
964,
297,
288,
283,
1345
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
961,
859,
4248,
334,
35,
9,
6171,
377,
2523,
80,
699,
54,
8642,
1014,
921,
728,
80,
14,
7530,
18956,
199,
3,
259,
2900,
5924,
5702,
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,
3949,
199,
504,
5166,
492,
2986,
12,
1709,
12,
1504,
199,
504,
2508,
492,
1336,
63,
8833,
421,
199,
533,
5267,
1198,
63,
1000,
63,
3741,
8,
992,
14,
1685,
304,
272,
485,
354,
275,
283,
3535,
1198,
14,
1000,
14,
3741,
7,
272,
485,
2761,
63,
354,
275,
283,
515,
7,
339,
347,
485,
362,
63,
1431,
63,
24365,
8,
277,
304,
267,
347,
664,
63,
452,
63,
19094,
8,
1886,
304,
288,
372,
334,
1886,
855,
19094,
4533,
435,
490,
359,
954,
954,
2151,
367,
1007,
315,
843,
855,
19094,
4533,
2151,
367,
1007,
954,
315,
664,
63,
452,
63,
19094,
8,
954,
3948,
267,
372,
1211,
7694,
1886,
855,
354,
3108,
843,
9,
2151,
367,
843,
315,
664,
63,
452,
63,
19094,
8,
586,
1336,
63,
8833,
14,
1095,
14,
1095,
3948,
339,
347,
485,
362,
63,
1431,
63,
24365,
63,
5891,
8,
277,
304,
267,
18036,
275,
942,
267,
367,
843,
315,
291,
423,
362,
63,
1431,
63,
24365,
1252,
13012,
837,
288,
18036,
14,
740,
1332,
1886,
855,
354,
3108,
843,
14,
354,
430,
267,
18036,
14,
3191,
342,
267,
372,
18036,
339,
3414,
275,
1504,
14,
2674,
360,
5826,
358,
272,
931,
275,
1504,
14,
1610,
8,
267,
283,
2042,
297,
267,
1720,
628,
1918,
931,
370,
2195,
6016,
4922,
14,
26914,
3955,
506,
6020,
2839,
298,
267,
3546,
568,
15694,
14,
1662,
3741,
4662,
1415,
29,
549,
9,
272,
1402,
63,
344,
275,
1504,
14,
4089,
18,
368,
8,
267,
283,
723,
14,
1238,
297,
283,
1685,
297,
1415,
29,
549,
12,
267,
1720,
534,
1918,
1402,
370,
6554,
14931,
370,
358,
272,
1402,
63,
698,
275,
1504,
14,
1610,
8,
267,
283,
792,
334,
1238,
3196,
267,
1720,
534,
1918,
901,
315,
2195,
1402,
626,
3509,
314,
901,
370,
1336,
283,
267,
283,
17777,
3134,
78,
7,
267,
283,
22787,
3427,
78,
7,
267,
3546,
2123,
7,
340,
2195,
1402,
365,
522,
14,
3899,
12,
503,
298,
267,
3546,
3899,
63,
344,
14,
2123,
7,
340,
1265,
3984,
4877,
13590,
15460,
531,
272,
1402,
63,
1648,
275,
1504,
14,
1610,
8,
267,
283,
4738,
334,
1238,
3196,
267,
1720,
534,
792,
8,
83,
9,
370,
1865,
701,
12,
642,
19762,
2997,
315,
22888,
283,
267,
298,
1045,
283,
6119,
413,
270,
1336,
9859,
272,
1336,
63,
8833,
275,
1504,
14,
7713,
8,
267,
485,
362,
63,
1431,
63,
24365,
63,
5891,
12,
267,
283,
4486,
5563,
297,
1415,
29,
549,
12,
267,
1720,
534,
1918,
5563,
1202,
370,
6705,
1314,
909,
376,
3031,
4450,
2659,
272,
6016,
63,
698,
275,
1504,
14,
1610,
8,
267,
283,
792,
334,
2123,
3196,
267,
1720,
534,
1918,
901,
315,
314,
3031,
1202,
367,
4877,
14,
26914,
283,
267,
298,
3749,
365,
283,
475,
7,
503,
283,
504,
9859,
272,
1654,
63,
344,
275,
1504,
14,
4089,
18,
368,
360,
3535,
1198,
14,
1000,
297,
283,
3120,
358,
272,
3145,
63,
9467,
275,
1504,
14,
4082,
8,
267,
283,
5392,
4450,
297,
267,
1720,
534,
5392,
7838,
14931,
687,
1654,
358,
272,
3305,
63,
2865,
9467,
275,
1504,
14,
4082,
8,
267,
283,
5318,
2222,
9467,
297,
267,
1720,
628,
5318,
14931,
315,
314,
1654,
626,
2793,
1133,
1336,
1263,
909,
315,
28935,
531,
272,
1336,
63,
2246,
275,
1504,
14,
4082,
8,
267,
283,
6119,
413,
270,
1336,
297,
267,
1720,
534,
3917,
2337,
787,
3663,
4450,
12,
675,
314,
1642,
1373,
14,
982,
283,
267,
283,
1397,
7923,
12,
3663,
4450,
2338,
465,
949,
1336,
737,
1006,
358,
272,
2881,
275,
1504,
14,
1610,
8,
267,
283,
7705,
297,
267,
1720,
534,
12914,
315,
282,
2754,
2457,
370,
31530,
3224,
2251,
370,
1336,
358,
272,
1499,
63,
929,
275,
1504,
14,
7713,
8,
267,
359,
288,
661,
1150,
297,
283,
17367,
659,
288,
661,
9226,
297,
283,
9392,
659,
267,
2156,
267,
283,
2209,
1174,
297,
267,
1720,
534,
1918,
1174,
3788,
19251,
687,
642,
4922,
1077,
506,
283,
267,
283,
12941,
315,
28935,
358,
339,
485,
4322,
275,
469,
267,
283,
4173,
63,
2865,
9467,
356,
715,
12,
267,
283,
1328,
63,
929,
356,
283,
9226,
297,
272,
789,
339,
768,
1246,
14,
3029,
272,
347,
664,
63,
8833,
8,
277,
304,
267,
372,
291,
423,
362,
63,
1431,
63,
24365,
3430,
277,
14,
1431,
63,
8833,
32702,
339,
768,
1246,
14,
3029,
272,
347,
5528,
63,
5040,
63,
1198,
63,
1237,
3163,
8,
277,
304,
267,
372,
469,
288,
283,
466,
356,
283,
723,
14,
3723,
14,
2442,
63,
3806,
297,
288,
283,
470,
63,
1238,
356,
283,
3535,
1198,
14,
5040,
14,
1198,
14,
1237,
3163,
297,
288,
283,
1375,
356,
283,
1222,
297,
288,
283,
1100,
356,
1211,
8,
277,
14,
1813,
14,
1100,
12,
849,
63,
3741,
63,
344,
29,
277,
14,
344,
395,
288,
283,
1345,
63,
466,
356,
283,
964,
297,
288,
283,
1345,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
PaddlePaddle/Paddle
|
python/paddle/fluid/tests/unittests/test_conditional_block.py
|
2
|
3123
|
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import numpy as np
import unittest
import paddle.fluid as fluid
import paddle.fluid.layers as layers
import paddle.fluid.core as core
from paddle.fluid.executor import Executor
from paddle.fluid.backward import append_backward
from paddle.fluid.layers.control_flow import ConditionalBlock
class ConditionalBlockTest(unittest.TestCase):
def test_forward(self):
main_program = fluid.Program()
startup_program = fluid.Program()
with fluid.program_guard(main_program, startup_program):
data = layers.data(name='X', shape=[1], dtype='float32')
data.stop_gradient = False
cond = ConditionalBlock(inputs=[data])
out = layers.create_tensor(dtype='float32')
with cond.block():
hidden = layers.fc(input=data, size=10)
layers.assign(hidden, out)
cpu = core.CPUPlace()
exe = Executor(cpu)
exe.run(startup_program)
x = np.random.random(size=(10, 1)).astype('float32')
outs = exe.run(main_program, feed={'X': x}, fetch_list=[out])[0]
print(outs)
loss = layers.mean(out)
append_backward(loss=loss)
outs = exe.run(
main_program,
feed={'X': x},
fetch_list=[main_program.block(0).var(data.name + "@GRAD")])[0]
print(outs)
class TestConditionalBlockOpInferShape(unittest.TestCase):
def test_infer_shape(self):
main_program = fluid.Program()
startup_program = fluid.Program()
with fluid.program_guard(main_program, startup_program):
global_block = main_program.global_block()
sub_block = main_program._create_block()
main_program._rollback()
step_scope = global_block.create_var(
type=core.VarDesc.VarType.STEP_SCOPES)
cond_var = layers.fill_constant(
shape=[1], dtype='bool', value=False)
op = global_block.append_op(
type='conditional_block',
inputs={
'Cond': [cond_var],
'Input': [],
},
outputs={'Out': [],
'Scope': [step_scope]},
attrs={'sub_block': sub_block,
'is_scalar_condition': True})
op.desc.infer_shape(global_block.desc)
if __name__ == '__main__':
unittest.main()
|
apache-2.0
|
[
3,
257,
1898,
334,
67,
9,
14894,
510,
20101,
48,
20101,
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,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
2680,
465,
980,
199,
646,
2882,
199,
646,
28525,
14,
31515,
465,
25462,
199,
646,
28525,
14,
31515,
14,
4359,
465,
9393,
199,
646,
28525,
14,
31515,
14,
1018,
465,
6170,
199,
504,
28525,
14,
31515,
14,
13471,
492,
9434,
4139,
199,
504,
28525,
14,
31515,
14,
15457,
492,
5666,
63,
15457,
199,
504,
28525,
14,
31515,
14,
4359,
14,
2785,
63,
1659,
492,
24191,
3142,
421,
199,
533,
24191,
3142,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
6688,
8,
277,
304,
267,
2446,
63,
6815,
275,
25462,
14,
9184,
342,
267,
14210,
63,
6815,
275,
25462,
14,
9184,
342,
267,
543,
25462,
14,
6815,
63,
15606,
8,
973,
63,
6815,
12,
14210,
63,
6815,
304,
288,
666,
275,
9393,
14,
576,
8,
354,
534,
56,
297,
2215,
1524,
17,
467,
2152,
534,
1609,
708,
358,
288,
666,
14,
2379,
63,
7490,
275,
756,
288,
9288,
275,
24191,
3142,
8,
3711,
1524,
576,
566,
288,
734,
275,
9393,
14,
981,
63,
3128,
8,
2271,
534,
1609,
708,
358,
288,
543,
9288,
14,
1457,
837,
355,
8752,
275,
9393,
14,
3003,
8,
1210,
29,
576,
12,
1568,
29,
709,
9,
355,
9393,
14,
5038,
8,
5642,
12,
734,
9,
953,
5033,
275,
6170,
14,
2890,
2160,
1071,
342,
288,
14778,
275,
9434,
4139,
8,
3541,
9,
288,
14778,
14,
1065,
8,
16480,
63,
6815,
9,
953,
671,
275,
980,
14,
2355,
14,
2355,
8,
890,
2687,
709,
12,
413,
4992,
6041,
360,
1609,
708,
358,
953,
31557,
275,
14778,
14,
1065,
8,
973,
63,
6815,
12,
4733,
3713,
56,
356,
671,
1386,
5267,
63,
513,
1524,
548,
11057,
16,
61,
288,
870,
8,
16816,
9,
288,
5621,
275,
9393,
14,
3670,
8,
548,
9,
288,
5666,
63,
15457,
8,
4358,
29,
4358,
9,
288,
31557,
275,
14778,
14,
1065,
8,
355,
2446,
63,
6815,
12,
355,
4733,
3713,
56,
356,
671,
1386,
355,
5267,
63,
513,
1524,
973,
63,
6815,
14,
1457,
8,
16,
680,
1391,
8,
576,
14,
354,
435,
9244,
3975,
1554,
531,
11057,
16,
61,
288,
870,
8,
16816,
9,
421,
199,
533,
1379,
21321,
3142,
4619,
607,
2412,
7238,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
14578,
63,
1392,
8,
277,
304,
267,
2446,
63,
6815,
275,
25462,
14,
9184,
342,
267,
14210,
63,
6815,
275,
25462,
14,
9184,
342,
267,
543,
25462,
14,
6815,
63,
15606,
8,
973,
63,
6815,
12,
14210,
63,
6815,
304,
288,
2288,
63,
1457,
275,
2446,
63,
6815,
14,
2966,
63,
1457,
342,
288,
1007,
63,
1457,
275,
2446,
63,
6815,
423,
981,
63,
1457,
342,
288,
2446,
63,
6815,
423,
10437,
342,
288,
3650,
63,
2645,
275,
2288,
63,
1457,
14,
981,
63,
1391,
8,
355,
730,
29,
1018,
14,
5894,
9921,
14,
5894,
804,
14,
17988,
63,
15901,
48,
654,
9,
288,
9288,
63,
1391,
275,
9393,
14,
4498,
63,
4083,
8,
355,
2215,
1524,
17,
467,
2152,
534,
2245,
297,
574,
29,
797,
9,
953,
1687,
275,
2288,
63,
1457,
14,
740,
63,
411,
8,
355,
730,
534,
14353,
63,
1457,
297,
355,
4153,
3126,
490,
283,
23735,
356,
359,
2067,
63,
1391,
467,
490,
283,
3205,
356,
990,
355,
1660,
355,
4704,
3713,
2204,
356,
990,
586,
283,
7812,
356,
359,
2926,
63,
2645,
13888,
355,
3290,
3713,
954,
63,
1457,
356,
1007,
63,
1457,
12,
2432,
283,
374,
63,
7033,
63,
5394,
356,
715,
1552,
288,
1687,
14,
3257,
14,
14578,
63,
1392,
8,
2966,
63,
1457,
14,
3257,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
257,
1898,
334,
67,
9,
14894,
510,
20101,
48,
20101,
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,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
2680,
465,
980,
199,
646,
2882,
199,
646,
28525,
14,
31515,
465,
25462,
199,
646,
28525,
14,
31515,
14,
4359,
465,
9393,
199,
646,
28525,
14,
31515,
14,
1018,
465,
6170,
199,
504,
28525,
14,
31515,
14,
13471,
492,
9434,
4139,
199,
504,
28525,
14,
31515,
14,
15457,
492,
5666,
63,
15457,
199,
504,
28525,
14,
31515,
14,
4359,
14,
2785,
63,
1659,
492,
24191,
3142,
421,
199,
533,
24191,
3142,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
6688,
8,
277,
304,
267,
2446,
63,
6815,
275,
25462,
14,
9184,
342,
267,
14210,
63,
6815,
275,
25462,
14,
9184,
342,
267,
543,
25462,
14,
6815,
63,
15606,
8,
973,
63,
6815,
12,
14210,
63,
6815,
304,
288,
666,
275,
9393,
14,
576,
8,
354,
534,
56,
297,
2215,
1524,
17,
467,
2152,
534,
1609,
708,
358,
288,
666,
14,
2379,
63,
7490,
275,
756,
288,
9288,
275,
24191,
3142,
8,
3711,
1524,
576,
566,
288,
734,
275,
9393,
14,
981,
63,
3128,
8,
2271,
534,
1609,
708,
358,
288,
543,
9288,
14,
1457,
837,
355,
8752,
275,
9393,
14,
3003,
8,
1210,
29,
576,
12,
1568,
29,
709,
9,
355,
9393,
14,
5038,
8,
5642,
12,
734,
9,
953,
5033,
275,
6170,
14,
2890,
2160,
1071,
342,
288,
14778,
275,
9434,
4139,
8,
3541,
9,
288,
14778,
14,
1065,
8,
16480,
63,
6815,
9,
953,
671,
275,
980,
14,
2355,
14,
2355,
8,
890,
2687,
709,
12,
413,
4992,
6041,
360,
1609,
708,
358,
953,
31557,
275,
14778,
14,
1065,
8,
973,
63,
6815,
12,
4733,
3713,
56,
356,
671,
1386,
5267,
63,
513,
1524,
548,
11057,
16,
61,
288,
870,
8,
16816,
9,
288,
5621,
275,
9393,
14,
3670,
8,
548,
9,
288,
5666,
63,
15457,
8,
4358,
29,
4358,
9,
288,
31557,
275,
14778,
14,
1065,
8,
355,
2446,
63,
6815,
12,
355,
4733,
3713,
56,
356,
671,
1386,
355,
5267,
63,
513,
1524,
973,
63,
6815,
14,
1457,
8,
16,
680,
1391,
8,
576,
14,
354,
435,
9244,
3975,
1554,
531,
11057,
16,
61,
288,
870,
8,
16816,
9,
421,
199,
533,
1379,
21321,
3142,
4619,
607,
2412,
7238,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
14578,
63,
1392,
8,
277,
304,
267,
2446,
63,
6815,
275,
25462,
14,
9184,
342,
267,
14210,
63,
6815,
275,
25462,
14,
9184,
342,
267,
543,
25462,
14,
6815,
63,
15606,
8,
973,
63,
6815,
12,
14210,
63,
6815,
304,
288,
2288,
63,
1457,
275,
2446,
63,
6815,
14,
2966,
63,
1457,
342,
288,
1007,
63,
1457,
275,
2446,
63,
6815,
423,
981,
63,
1457,
342,
288,
2446,
63,
6815,
423,
10437,
342,
288,
3650,
63,
2645,
275,
2288,
63,
1457,
14,
981,
63,
1391,
8,
355,
730,
29,
1018,
14,
5894,
9921,
14,
5894,
804,
14,
17988,
63,
15901,
48,
654,
9,
288,
9288,
63,
1391,
275,
9393,
14,
4498,
63,
4083,
8,
355,
2215,
1524,
17,
467,
2152,
534,
2245,
297,
574,
29,
797,
9,
953,
1687,
275,
2288,
63,
1457,
14,
740,
63,
411,
8,
355,
730,
534,
14353,
63,
1457,
297,
355,
4153,
3126,
490,
283,
23735,
356,
359,
2067,
63,
1391,
467,
490,
283,
3205,
356,
990,
355,
1660,
355,
4704,
3713,
2204,
356,
990,
586,
283,
7812,
356,
359,
2926,
63,
2645,
13888,
355,
3290,
3713,
954,
63,
1457,
356,
1007,
63,
1457,
12,
2432,
283,
374,
63,
7033,
63,
5394,
356,
715,
1552,
288,
1687,
14,
3257,
14,
14578,
63,
1392,
8,
2966,
63,
1457,
14,
3257,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
riga/luigi
|
luigi/server.py
|
4
|
13958
|
# -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# 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.
#
"""
Simple REST server that takes commands in a JSON payload
Interface to the :py:class:`~luigi.scheduler.Scheduler` class.
See :doc:`/central_scheduler` for more info.
"""
#
# Description: Added codes for visualization of how long each task takes
# running-time until it reaches the next status (failed or done)
# At "{base_url}/tasklist", all completed(failed or done) tasks are shown.
# At "{base_url}/tasklist", a user can select one specific task to see
# how its running-time has changed over time.
# At "{base_url}/tasklist/{task_name}", it visualizes a multi-bar graph
# that represents the changes of the running-time for a selected task
# up to the next status (failed or done).
# This visualization let us know how the running-time of the specific task
# has changed over time.
#
# Copyright 2015 Naver Corp.
# Author Yeseul Park (yeseul.park@navercorp.com)
#
import atexit
import datetime
import json
import logging
import os
import signal
import sys
import time
import pkg_resources
import tornado.httpserver
import tornado.ioloop
import tornado.netutil
import tornado.web
from luigi import Config, parameter
from luigi.scheduler import Scheduler, RPC_METHODS
logger = logging.getLogger("luigi.server")
class cors(Config):
enabled = parameter.BoolParameter(
default=False,
description='Enables CORS support.')
allowed_origins = parameter.ListParameter(
default=[],
description='A list of allowed origins. Used only if `allow_any_origin` is false.')
allow_any_origin = parameter.BoolParameter(
default=False,
description='Accepts requests from any origin.')
allow_null_origin = parameter.BoolParameter(
default=False,
description='Allows the request to set `null` value of the `Origin` header.')
max_age = parameter.IntParameter(
default=86400,
description='Content of `Access-Control-Max-Age`.')
allowed_methods = parameter.Parameter(
default='GET, OPTIONS',
description='Content of `Access-Control-Allow-Methods`.')
allowed_headers = parameter.Parameter(
default='Accept, Content-Type, Origin',
description='Content of `Access-Control-Allow-Headers`.')
exposed_headers = parameter.Parameter(
default='',
description='Content of `Access-Control-Expose-Headers`.')
allow_credentials = parameter.BoolParameter(
default=False,
description='Indicates that the actual request can include user credentials.')
def __init__(self, *args, **kwargs):
super(cors, self).__init__(*args, **kwargs)
self.allowed_origins = set(i for i in self.allowed_origins if i not in ['*', 'null'])
class RPCHandler(tornado.web.RequestHandler):
"""
Handle remote scheduling calls using rpc.RemoteSchedulerResponder.
"""
def __init__(self, *args, **kwargs):
super(RPCHandler, self).__init__(*args, **kwargs)
self._cors_config = cors()
def initialize(self, scheduler):
self._scheduler = scheduler
def options(self, *args):
if self._cors_config.enabled:
self._handle_cors_preflight()
self.set_status(204)
self.finish()
def get(self, method):
if method not in RPC_METHODS:
self.send_error(404)
return
payload = self.get_argument('data', default="{}")
arguments = json.loads(payload)
if hasattr(self._scheduler, method):
result = getattr(self._scheduler, method)(**arguments)
if self._cors_config.enabled:
self._handle_cors()
self.write({"response": result}) # wrap all json response in a dictionary
else:
self.send_error(404)
post = get
def _handle_cors_preflight(self):
origin = self.request.headers.get('Origin')
if not origin:
return
if origin == 'null':
if self._cors_config.allow_null_origin:
self.set_header('Access-Control-Allow-Origin', 'null')
self._set_other_cors_headers()
else:
if self._cors_config.allow_any_origin:
self.set_header('Access-Control-Allow-Origin', '*')
self._set_other_cors_headers()
elif origin in self._cors_config.allowed_origins:
self.set_header('Access-Control-Allow-Origin', origin)
self._set_other_cors_headers()
def _handle_cors(self):
origin = self.request.headers.get('Origin')
if not origin:
return
if origin == 'null':
if self._cors_config.allow_null_origin:
self.set_header('Access-Control-Allow-Origin', 'null')
else:
if self._cors_config.allow_any_origin:
self.set_header('Access-Control-Allow-Origin', '*')
elif origin in self._cors_config.allowed_origins:
self.set_header('Access-Control-Allow-Origin', origin)
self.set_header('Vary', 'Origin')
def _set_other_cors_headers(self):
self.set_header('Access-Control-Max-Age', str(self._cors_config.max_age))
self.set_header('Access-Control-Allow-Methods', self._cors_config.allowed_methods)
self.set_header('Access-Control-Allow-Headers', self._cors_config.allowed_headers)
if self._cors_config.allow_credentials:
self.set_header('Access-Control-Allow-Credentials', 'true')
if self._cors_config.exposed_headers:
self.set_header('Access-Control-Expose-Headers', self._cors_config.exposed_headers)
class BaseTaskHistoryHandler(tornado.web.RequestHandler):
def initialize(self, scheduler):
self._scheduler = scheduler
def get_template_path(self):
return pkg_resources.resource_filename(__name__, 'templates')
class AllRunHandler(BaseTaskHistoryHandler):
def get(self):
all_tasks = self._scheduler.task_history.find_all_runs()
tasknames = [task.name for task in all_tasks]
# show all tasks with their name list to be selected
# why all tasks? the duration of the event history of a selected task
# can be more than 24 hours.
self.render("menu.html", tasknames=tasknames)
class SelectedRunHandler(BaseTaskHistoryHandler):
def get(self, name):
statusResults = {}
taskResults = []
# get all tasks that has been updated
all_tasks = self._scheduler.task_history.find_all_runs()
# get events history for all tasks
all_tasks_event_history = self._scheduler.task_history.find_all_events()
# build the dictionary tasks with index: id, value: task_name
tasks = {task.id: str(task.name) for task in all_tasks}
for task in all_tasks_event_history:
# if the name of user-selected task is in tasks, get its task_id
if tasks.get(task.task_id) == str(name):
status = str(task.event_name)
if status not in statusResults:
statusResults[status] = []
# append the id, task_id, ts, y with 0, next_process with null
# for the status(running/failed/done) of the selected task
statusResults[status].append(({
'id': str(task.id), 'task_id': str(task.task_id),
'x': from_utc(str(task.ts)), 'y': 0, 'next_process': ''}))
# append the id, task_name, task_id, status, datetime, timestamp
# for the selected task
taskResults.append({
'id': str(task.id), 'taskName': str(name), 'task_id': str(task.task_id),
'status': str(task.event_name), 'datetime': str(task.ts),
'timestamp': from_utc(str(task.ts))})
statusResults = json.dumps(statusResults)
taskResults = json.dumps(taskResults)
statusResults = tornado.escape.xhtml_unescape(str(statusResults))
taskResults = tornado.escape.xhtml_unescape(str(taskResults))
self.render('history.html', name=name, statusResults=statusResults, taskResults=taskResults)
def from_utc(utcTime, fmt=None):
"""convert UTC time string to time.struct_time: change datetime.datetime to time, return time.struct_time type"""
if fmt is None:
try_formats = ["%Y-%m-%d %H:%M:%S.%f", "%Y-%m-%d %H:%M:%S"]
else:
try_formats = [fmt]
for fmt in try_formats:
try:
time_struct = datetime.datetime.strptime(utcTime, fmt)
except ValueError:
pass
else:
date = int(time.mktime(time_struct.timetuple()))
return date
else:
raise ValueError("No UTC format matches {}".format(utcTime))
class RecentRunHandler(BaseTaskHistoryHandler):
def get(self):
tasks = self._scheduler.task_history.find_latest_runs()
self.render("recent.html", tasks=tasks)
class ByNameHandler(BaseTaskHistoryHandler):
def get(self, name):
tasks = self._scheduler.task_history.find_all_by_name(name)
self.render("recent.html", tasks=tasks)
class ByIdHandler(BaseTaskHistoryHandler):
def get(self, id):
task = self._scheduler.task_history.find_task_by_id(id)
self.render("show.html", task=task)
class ByParamsHandler(BaseTaskHistoryHandler):
def get(self, name):
payload = self.get_argument('data', default="{}")
arguments = json.loads(payload)
tasks = self._scheduler.task_history.find_all_by_parameters(name, session=None, **arguments)
self.render("recent.html", tasks=tasks)
class RootPathHandler(BaseTaskHistoryHandler):
def get(self):
# we omit the leading slash in case the visualizer is behind a different
# path (as in a reverse proxy setup)
#
# For example, if luigi is behind my.app.com/my/luigi/, we want / to
# redirect relative (so it goes to my.app.com/my/luigi/static/visualizer/index.html)
# instead of absolute (which would be my.app.com/static/visualizer/index.html)
self.redirect("static/visualiser/index.html")
def head(self):
"""HEAD endpoint for health checking the scheduler"""
self.set_status(204)
self.finish()
class MetricsHandler(tornado.web.RequestHandler):
def initialize(self, scheduler):
self._scheduler = scheduler
def get(self):
metrics_collector = self._scheduler._state._metrics_collector
metrics = metrics_collector.generate_latest()
if metrics:
metrics_collector.configure_http_handler(self)
self.write(metrics)
def app(scheduler):
settings = {"static_path": os.path.join(os.path.dirname(__file__), "static"),
"unescape": tornado.escape.xhtml_unescape,
"compress_response": True,
}
handlers = [
(r'/api/(.*)', RPCHandler, {"scheduler": scheduler}),
(r'/', RootPathHandler, {'scheduler': scheduler}),
(r'/tasklist', AllRunHandler, {'scheduler': scheduler}),
(r'/tasklist/(.*?)', SelectedRunHandler, {'scheduler': scheduler}),
(r'/history', RecentRunHandler, {'scheduler': scheduler}),
(r'/history/by_name/(.*?)', ByNameHandler, {'scheduler': scheduler}),
(r'/history/by_id/(.*?)', ByIdHandler, {'scheduler': scheduler}),
(r'/history/by_params/(.*?)', ByParamsHandler, {'scheduler': scheduler}),
(r'/metrics', MetricsHandler, {'scheduler': scheduler})
]
api_app = tornado.web.Application(handlers, **settings)
return api_app
def _init_api(scheduler, api_port=None, address=None, unix_socket=None):
api_app = app(scheduler)
if unix_socket is not None:
api_sockets = [tornado.netutil.bind_unix_socket(unix_socket)]
else:
api_sockets = tornado.netutil.bind_sockets(api_port, address=address)
server = tornado.httpserver.HTTPServer(api_app)
server.add_sockets(api_sockets)
# Return the bound socket names. Useful for connecting client in test scenarios.
return [s.getsockname() for s in api_sockets]
def run(api_port=8082, address=None, unix_socket=None, scheduler=None):
"""
Runs one instance of the API server.
"""
if scheduler is None:
scheduler = Scheduler()
# load scheduler state
scheduler.load()
_init_api(
scheduler=scheduler,
api_port=api_port,
address=address,
unix_socket=unix_socket,
)
# prune work DAG every 60 seconds
pruner = tornado.ioloop.PeriodicCallback(scheduler.prune, 60000)
pruner.start()
def shutdown_handler(signum, frame):
exit_handler()
sys.exit(0)
@atexit.register
def exit_handler():
logger.info("Scheduler instance shutting down")
scheduler.dump()
stop()
signal.signal(signal.SIGINT, shutdown_handler)
signal.signal(signal.SIGTERM, shutdown_handler)
if os.name == 'nt':
signal.signal(signal.SIGBREAK, shutdown_handler)
else:
signal.signal(signal.SIGQUIT, shutdown_handler)
logger.info("Scheduler starting up")
tornado.ioloop.IOLoop.instance().start()
def stop():
tornado.ioloop.IOLoop.instance().stop()
if __name__ == "__main__":
run()
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
6029,
13,
7806,
428,
555,
3338,
14840,
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,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
624,
199,
3184,
14880,
1654,
626,
6181,
3718,
315,
282,
4840,
4886,
199,
4267,
370,
314,
520,
647,
26,
533,
6054,
26795,
14,
8874,
14,
11251,
64,
1021,
14,
199,
9295,
520,
1301,
1705,
15,
16067,
63,
8874,
64,
367,
1655,
2256,
14,
199,
624,
199,
3,
199,
3,
11994,
26,
16230,
9479,
367,
13104,
2072,
402,
4212,
1846,
1924,
2120,
6181,
199,
3,
3879,
13,
521,
5133,
652,
12276,
397,
314,
2163,
2004,
334,
4892,
503,
4224,
9,
199,
3,
2854,
5310,
1095,
63,
633,
5995,
1765,
513,
401,
1006,
9709,
8,
4892,
503,
4224,
9,
6527,
787,
9164,
14,
199,
3,
2854,
5310,
1095,
63,
633,
5995,
1765,
513,
401,
282,
922,
883,
3504,
1373,
2488,
2120,
370,
1937,
199,
3,
4212,
2399,
3879,
13,
521,
965,
2896,
1806,
900,
14,
199,
3,
2854,
5310,
1095,
63,
633,
5995,
1765,
513,
5321,
1765,
63,
354,
10750,
652,
13104,
6491,
282,
3510,
13,
1700,
3343,
199,
3,
626,
8469,
314,
4493,
402,
314,
3879,
13,
521,
367,
282,
4895,
2120,
199,
3,
1536,
370,
314,
2163,
2004,
334,
4892,
503,
4224,
680,
199,
3,
961,
13104,
2072,
4691,
2739,
5715,
4212,
314,
3879,
13,
521,
402,
314,
2488,
2120,
199,
3,
965,
2896,
1806,
900,
14,
199,
3,
199,
3,
1898,
6900,
11290,
422,
22304,
14,
199,
3,
6529,
1488,
31209,
348,
510,
1096,
334,
8048,
261,
348,
14,
5149,
32,
3540,
422,
989,
80,
14,
957,
9,
199,
3,
199,
199,
646,
19840,
199,
646,
2197,
199,
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
646,
4673,
199,
646,
984,
199,
646,
900,
199,
199,
646,
5496,
63,
4435,
199,
646,
12148,
14,
1014,
1000,
199,
646,
12148,
14,
27212,
199,
646,
12148,
14,
846,
1974,
199,
646,
12148,
14,
2520,
199,
199,
504,
19485,
492,
4094,
12,
2725,
199,
504,
19485,
14,
8874,
492,
32051,
12,
11785,
63,
18383,
199,
199,
2921,
275,
2050,
14,
5572,
480,
26795,
14,
1000,
531,
421,
199,
533,
286,
1384,
8,
2028,
304,
272,
5223,
275,
2725,
14,
10349,
4720,
8,
267,
849,
29,
797,
12,
267,
1369,
534,
1327,
5921,
445,
4149,
2291,
2659,
272,
4370,
63,
2981,
3617,
275,
2725,
14,
1296,
4720,
8,
267,
849,
6034,
267,
1369,
534,
33,
769,
402,
4370,
2306,
3617,
14,
8051,
1454,
340,
658,
3306,
63,
1629,
63,
6493,
64,
365,
3055,
2659,
272,
2040,
63,
1629,
63,
6493,
275,
2725,
14,
10349,
4720,
8,
267,
849,
29,
797,
12,
267,
1369,
534,
8422,
83,
4145,
687,
1263,
6330,
2659,
272,
2040,
63,
2307,
63,
6493,
275,
2725,
14,
10349,
4720,
8,
267,
849,
29,
797,
12,
267,
1369,
534,
19780,
314,
1056,
370,
663,
658,
2307,
64,
574,
402,
314,
658,
12834,
64,
1406,
2659,
272,
1390,
63,
474,
275,
2725,
14,
3241,
4720,
8,
267,
849,
29,
24,
20543,
12,
267,
1369,
534,
2714,
402,
658,
3946,
13,
3717,
13,
4261,
13,
20480,
2313,
358,
272,
4370,
63,
2474,
275,
2725,
14,
4720,
8,
267,
849,
534,
2970,
12,
23860,
297,
267,
1369,
534,
2714,
402,
658,
3946,
13,
3717,
13,
7852,
13,
10385,
2313,
358,
272,
4370,
63,
2139,
275,
2725,
14,
4720,
8,
267,
849,
534,
8422,
12,
6646,
13,
804,
12,
31534,
297,
267,
1369,
534,
2714,
402,
658,
3946,
13,
3717,
13,
7852,
13,
9883,
2313,
358,
272,
19282,
63,
2139,
275,
2725,
14,
4720,
8,
267,
849,
4581,
267,
1369,
534,
2714,
402,
658,
3946,
13,
3717,
13,
920,
4070,
13,
9883,
2313,
358,
272,
2040,
63,
6942,
275,
2725,
14,
10349,
4720,
8,
267,
849,
29,
797,
12,
267,
1369,
534,
607,
16292,
626,
314,
3503,
1056,
883,
2387,
922,
6235,
2659,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
30967,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
14,
6541,
63,
2981,
3617,
275,
663,
8,
73,
367,
284,
315,
291,
14,
6541,
63,
2981,
3617,
340,
284,
440,
315,
788,
7693,
283,
2307,
1105,
421,
199,
533,
820,
48,
1244,
1221,
8,
18443,
14,
2520,
14,
11149,
304,
272,
408,
272,
8690,
3982,
23800,
4882,
1808,
8985,
14,
6713,
11251,
1322,
23621,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
18612,
1244,
1221,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
30967,
63,
888,
275,
286,
1384,
342,
339,
347,
8265,
8,
277,
12,
11899,
304,
267,
291,
423,
8874,
275,
11899,
339,
347,
1511,
8,
277,
12,
627,
589,
304,
267,
340,
291,
423,
30967,
63,
888,
14,
3827,
26,
288,
291,
423,
2479,
63,
30967,
63,
13829,
4040,
342,
398,
291,
14,
409,
63,
1205,
8,
6686,
9,
267,
291,
14,
8192,
342,
339,
347,
664,
8,
277,
12,
1083,
304,
267,
340,
1083,
440,
315,
11785,
63,
18383,
26,
288,
291,
14,
2254,
63,
705,
8,
5188,
9,
288,
372,
267,
4886,
275,
291,
14,
362,
63,
2094,
360,
576,
297,
849,
32053,
531,
267,
2368,
275,
2022,
14,
3640,
8,
4749,
9,
398,
340,
2688,
8,
277,
423,
8874,
12,
1083,
304,
288,
754,
275,
2519,
8,
277,
423,
8874,
12,
1083,
9,
3682,
4958,
9,
953,
340,
291,
423
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
6029,
13,
7806,
428,
555,
3338,
14840,
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,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
624,
199,
3184,
14880,
1654,
626,
6181,
3718,
315,
282,
4840,
4886,
199,
4267,
370,
314,
520,
647,
26,
533,
6054,
26795,
14,
8874,
14,
11251,
64,
1021,
14,
199,
9295,
520,
1301,
1705,
15,
16067,
63,
8874,
64,
367,
1655,
2256,
14,
199,
624,
199,
3,
199,
3,
11994,
26,
16230,
9479,
367,
13104,
2072,
402,
4212,
1846,
1924,
2120,
6181,
199,
3,
3879,
13,
521,
5133,
652,
12276,
397,
314,
2163,
2004,
334,
4892,
503,
4224,
9,
199,
3,
2854,
5310,
1095,
63,
633,
5995,
1765,
513,
401,
1006,
9709,
8,
4892,
503,
4224,
9,
6527,
787,
9164,
14,
199,
3,
2854,
5310,
1095,
63,
633,
5995,
1765,
513,
401,
282,
922,
883,
3504,
1373,
2488,
2120,
370,
1937,
199,
3,
4212,
2399,
3879,
13,
521,
965,
2896,
1806,
900,
14,
199,
3,
2854,
5310,
1095,
63,
633,
5995,
1765,
513,
5321,
1765,
63,
354,
10750,
652,
13104,
6491,
282,
3510,
13,
1700,
3343,
199,
3,
626,
8469,
314,
4493,
402,
314,
3879,
13,
521,
367,
282,
4895,
2120,
199,
3,
1536,
370,
314,
2163,
2004,
334,
4892,
503,
4224,
680,
199,
3,
961,
13104,
2072,
4691,
2739,
5715,
4212,
314,
3879,
13,
521,
402,
314,
2488,
2120,
199,
3,
965,
2896,
1806,
900,
14,
199,
3,
199,
3,
1898,
6900,
11290,
422,
22304,
14,
199,
3,
6529,
1488,
31209,
348,
510,
1096,
334,
8048,
261,
348,
14,
5149,
32,
3540,
422,
989,
80,
14,
957,
9,
199,
3,
199,
199,
646,
19840,
199,
646,
2197,
199,
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
646,
4673,
199,
646,
984,
199,
646,
900,
199,
199,
646,
5496,
63,
4435,
199,
646,
12148,
14,
1014,
1000,
199,
646,
12148,
14,
27212,
199,
646,
12148,
14,
846,
1974,
199,
646,
12148,
14,
2520,
199,
199,
504,
19485,
492,
4094,
12,
2725,
199,
504,
19485,
14,
8874,
492,
32051,
12,
11785,
63,
18383,
199,
199,
2921,
275,
2050,
14,
5572,
480,
26795,
14,
1000,
531,
421,
199,
533,
286,
1384,
8,
2028,
304,
272,
5223,
275,
2725,
14,
10349,
4720,
8,
267,
849,
29,
797,
12,
267,
1369,
534,
1327,
5921,
445,
4149,
2291,
2659,
272,
4370,
63,
2981,
3617,
275,
2725,
14,
1296,
4720,
8,
267,
849,
6034,
267,
1369,
534,
33,
769,
402,
4370,
2306,
3617,
14,
8051,
1454,
340,
658,
3306,
63,
1629,
63,
6493,
64,
365,
3055,
2659,
272,
2040,
63,
1629,
63,
6493,
275,
2725,
14,
10349,
4720,
8,
267,
849,
29,
797,
12,
267,
1369,
534,
8422,
83,
4145,
687,
1263,
6330,
2659,
272,
2040,
63,
2307,
63,
6493,
275,
2725,
14,
10349,
4720,
8,
267,
849,
29,
797,
12,
267,
1369,
534,
19780,
314,
1056,
370,
663,
658,
2307,
64,
574,
402,
314,
658,
12834,
64,
1406,
2659,
272,
1390,
63,
474,
275,
2725,
14,
3241,
4720,
8,
267,
849,
29,
24,
20543,
12,
267,
1369,
534,
2714,
402,
658,
3946,
13,
3717,
13,
4261,
13,
20480,
2313,
358,
272,
4370,
63,
2474,
275,
2725,
14,
4720,
8,
267,
849,
534,
2970,
12,
23860,
297,
267,
1369,
534,
2714,
402,
658,
3946,
13,
3717,
13,
7852,
13,
10385,
2313,
358,
272,
4370,
63,
2139,
275,
2725,
14,
4720,
8,
267,
849,
534,
8422,
12,
6646,
13,
804,
12,
31534,
297,
267,
1369,
534,
2714,
402,
658,
3946,
13,
3717,
13,
7852,
13,
9883,
2313,
358,
272,
19282,
63,
2139,
275,
2725,
14,
4720,
8,
267,
849,
4581,
267,
1369,
534,
2714,
402,
658,
3946,
13,
3717,
13,
920,
4070,
13,
9883,
2313,
358,
272,
2040,
63,
6942,
275,
2725,
14,
10349,
4720,
8,
267,
849,
29,
797,
12,
267,
1369,
534,
607,
16292,
626,
314,
3503,
1056,
883,
2387,
922,
6235,
2659,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
30967,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
14,
6541,
63,
2981,
3617,
275,
663,
8,
73,
367,
284,
315,
291,
14,
6541,
63,
2981,
3617,
340,
284,
440,
315,
788,
7693,
283,
2307,
1105,
421,
199,
533,
820,
48,
1244,
1221,
8,
18443,
14,
2520,
14,
11149,
304,
272,
408,
272,
8690,
3982,
23800,
4882,
1808,
8985,
14,
6713,
11251,
1322,
23621,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
18612,
1244,
1221,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
30967,
63,
888,
275,
286,
1384,
342,
339,
347,
8265,
8,
277,
12,
11899,
304,
267,
291,
423,
8874,
275,
11899,
339,
347,
1511,
8,
277,
12,
627,
589,
304,
267,
340,
291,
423,
30967,
63,
888,
14,
3827,
26,
288,
291,
423,
2479,
63,
30967,
63,
13829,
4040,
342,
398,
291,
14,
409,
63,
1205,
8,
6686,
9,
267,
291,
14,
8192,
342,
339,
347,
664,
8,
277,
12,
1083,
304,
267,
340,
1083,
440,
315,
11785,
63,
18383,
26,
288,
291,
14,
2254,
63,
705,
8,
5188,
9,
288,
372,
267,
4886,
275,
291,
14,
362,
63,
2094,
360,
576,
297,
849,
32053,
531,
267,
2368,
275,
2022,
14,
3640,
8,
4749,
9,
398,
340,
2688,
8,
277,
423,
8874,
12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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
] |
genenetwork/genenetwork2
|
wqflask/tests/unit/wqflask/correlation/test_correlation_functions.py
|
3
|
1026
|
import unittest
from unittest import mock
from wqflask.correlation.correlation_functions import get_trait_symbol_and_tissue_values
from wqflask.correlation.correlation_functions import cal_zero_order_corr_for_tiss
class TestCorrelationFunctions(unittest.TestCase):
@mock.patch("wqflask.correlation.correlation_functions.MrnaAssayTissueData")
def test_get_trait_symbol_and_tissue_values(self, mock_class):
"""test for getting trait symbol and tissue_values"""
mock_class_instance = mock_class.return_value
mock_class_instance.gene_symbols = ["k1", "k2", "k3"]
mock_class_instance.get_symbol_values_pairs.return_value = {
"k1": ["v1", "v2", "v3"], "k2": ["v2", "v3"], "k3": ["k3"]}
results = get_trait_symbol_and_tissue_values(
symbol_list=["k1", "k2", "k3"])
mock_class.assert_called_with(gene_symbols=['k1', 'k2', 'k3'])
self.assertEqual({"k1": ["v1", "v2", "v3"], "k2": [
"v2", "v3"], "k3": ["k3"]}, results)
|
agpl-3.0
|
[
646,
2882,
199,
504,
2882,
492,
1683,
199,
504,
336,
81,
15720,
14,
26487,
14,
26487,
63,
5777,
492,
664,
63,
22687,
63,
5155,
63,
460,
63,
280,
9423,
63,
1459,
199,
504,
336,
81,
15720,
14,
26487,
14,
26487,
63,
5777,
492,
3213,
63,
4262,
63,
1648,
63,
16742,
63,
509,
63,
280,
385,
421,
199,
533,
1379,
8380,
5690,
13967,
8,
2796,
14,
1746,
304,
339,
768,
1805,
14,
2068,
480,
87,
81,
15720,
14,
26487,
14,
26487,
63,
5777,
14,
45,
82,
3540,
9824,
1187,
52,
5237,
1451,
531,
272,
347,
511,
63,
362,
63,
22687,
63,
5155,
63,
460,
63,
280,
9423,
63,
1459,
8,
277,
12,
1683,
63,
533,
304,
267,
408,
396,
367,
10232,
30576,
5272,
436,
3367,
9423,
63,
1459,
624,
267,
1683,
63,
533,
63,
842,
275,
1683,
63,
533,
14,
1107,
63,
585,
267,
1683,
63,
533,
63,
842,
14,
10654,
63,
7450,
275,
2097,
75,
17,
401,
298,
75,
18,
401,
298,
75,
19,
937,
267,
1683,
63,
533,
63,
842,
14,
362,
63,
5155,
63,
1459,
63,
7322,
14,
1107,
63,
585,
275,
469,
288,
298,
75,
17,
582,
2097,
86,
17,
401,
298,
86,
18,
401,
298,
86,
19,
2255,
298,
75,
18,
582,
2097,
86,
18,
401,
298,
86,
19,
2255,
298,
75,
19,
582,
2097,
75,
19,
27635,
267,
2058,
275,
664,
63,
22687,
63,
5155,
63,
460,
63,
280,
9423,
63,
1459,
8,
288,
5272,
63,
513,
6270,
75,
17,
401,
298,
75,
18,
401,
298,
75,
19,
3135,
267,
1683,
63,
533,
14,
479,
63,
3527,
63,
1045,
8,
10654,
63,
7450,
2968,
75,
17,
297,
283,
75,
18,
297,
283,
75,
19,
1105,
267,
291,
14,
629,
6333,
75,
17,
582,
2097,
86,
17,
401,
298,
86,
18,
401,
298,
86,
19,
2255,
298,
75,
18,
582,
359,
586,
298,
86,
18,
401,
298,
86,
19,
2255,
298,
75,
19,
582,
2097,
75,
19,
19057,
2058,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
199,
504,
2882,
492,
1683,
199,
504,
336,
81,
15720,
14,
26487,
14,
26487,
63,
5777,
492,
664,
63,
22687,
63,
5155,
63,
460,
63,
280,
9423,
63,
1459,
199,
504,
336,
81,
15720,
14,
26487,
14,
26487,
63,
5777,
492,
3213,
63,
4262,
63,
1648,
63,
16742,
63,
509,
63,
280,
385,
421,
199,
533,
1379,
8380,
5690,
13967,
8,
2796,
14,
1746,
304,
339,
768,
1805,
14,
2068,
480,
87,
81,
15720,
14,
26487,
14,
26487,
63,
5777,
14,
45,
82,
3540,
9824,
1187,
52,
5237,
1451,
531,
272,
347,
511,
63,
362,
63,
22687,
63,
5155,
63,
460,
63,
280,
9423,
63,
1459,
8,
277,
12,
1683,
63,
533,
304,
267,
408,
396,
367,
10232,
30576,
5272,
436,
3367,
9423,
63,
1459,
624,
267,
1683,
63,
533,
63,
842,
275,
1683,
63,
533,
14,
1107,
63,
585,
267,
1683,
63,
533,
63,
842,
14,
10654,
63,
7450,
275,
2097,
75,
17,
401,
298,
75,
18,
401,
298,
75,
19,
937,
267,
1683,
63,
533,
63,
842,
14,
362,
63,
5155,
63,
1459,
63,
7322,
14,
1107,
63,
585,
275,
469,
288,
298,
75,
17,
582,
2097,
86,
17,
401,
298,
86,
18,
401,
298,
86,
19,
2255,
298,
75,
18,
582,
2097,
86,
18,
401,
298,
86,
19,
2255,
298,
75,
19,
582,
2097,
75,
19,
27635,
267,
2058,
275,
664,
63,
22687,
63,
5155,
63,
460,
63,
280,
9423,
63,
1459,
8,
288,
5272,
63,
513,
6270,
75,
17,
401,
298,
75,
18,
401,
298,
75,
19,
3135,
267,
1683,
63,
533,
14,
479,
63,
3527,
63,
1045,
8,
10654,
63,
7450,
2968,
75,
17,
297,
283,
75,
18,
297,
283,
75,
19,
1105,
267,
291,
14,
629,
6333,
75,
17,
582,
2097,
86,
17,
401,
298,
86,
18,
401,
298,
86,
19,
2255,
298,
75,
18,
582,
359,
586,
298,
86,
18,
401,
298,
86,
19,
2255,
298,
75,
19,
582,
2097,
75,
19,
19057,
2058,
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,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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
] |
Zelgadis87/Sick-Beard
|
lib/requests/packages/chardet2/escprober.py
|
52
|
3094
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
from . import constants
import sys
from .escsm import HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel, ISO2022KRSMModel
from .charsetprober import CharSetProber
from .codingstatemachine import CodingStateMachine
class EscCharSetProber(CharSetProber):
def __init__(self):
CharSetProber.__init__(self)
self._mCodingSM = [ \
CodingStateMachine(HZSMModel),
CodingStateMachine(ISO2022CNSMModel),
CodingStateMachine(ISO2022JPSMModel),
CodingStateMachine(ISO2022KRSMModel)
]
self.reset()
def reset(self):
CharSetProber.reset(self)
for codingSM in self._mCodingSM:
if not codingSM: continue
codingSM.active = True
codingSM.reset()
self._mActiveSM = len(self._mCodingSM)
self._mDetectedCharset = None
def get_charset_name(self):
return self._mDetectedCharset
def get_confidence(self):
if self._mDetectedCharset:
return 0.99
else:
return 0.00
def feed(self, aBuf):
for c in aBuf:
# PY3K: aBuf is a byte array, so c is an int, not a byte
for codingSM in self._mCodingSM:
if not codingSM: continue
if not codingSM.active: continue
codingState = codingSM.next_state(c)
if codingState == constants.eError:
codingSM.active = False
self._mActiveSM -= 1
if self._mActiveSM <= 0:
self._mState = constants.eNotMe
return self.get_state()
elif codingState == constants.eItsMe:
self._mState = constants.eFoundIt
self._mDetectedCharset = codingSM.get_coding_state_machine()
return self.get_state()
return self.get_state()
|
gpl-3.0
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
1303,
6956,
14,
1308,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
492,
5262,
199,
646,
984,
199,
504,
1275,
397,
1259,
77,
492,
869,
58,
25335,
12,
9055,
13859,
35,
2709,
45,
1685,
12,
9055,
13859,
15819,
25335,
12,
9055,
13859,
23063,
25335,
199,
504,
1275,
6043,
19903,
492,
31727,
199,
504,
1275,
1523,
929,
6744,
492,
30539,
199,
199,
533,
662,
551,
15159,
8,
15159,
304,
272,
347,
636,
826,
721,
277,
304,
267,
31727,
855,
826,
721,
277,
9,
267,
291,
423,
29633,
275,
359,
971,
288,
30539,
8,
25955,
25335,
395,
288,
30539,
8,
7336,
13859,
35,
2709,
45,
1685,
395,
288,
30539,
8,
7336,
13859,
15819,
25335,
395,
288,
30539,
8,
7336,
13859,
23063,
25335,
9,
288,
1622,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
31727,
14,
3958,
8,
277,
9,
267,
367,
2803,
4029,
315,
291,
423,
29633,
26,
288,
340,
440,
2803,
4029,
26,
1980,
288,
2803,
4029,
14,
2682,
275,
715,
288,
2803,
4029,
14,
3958,
342,
267,
291,
423,
77,
7472,
4029,
275,
822,
8,
277,
423,
29633,
9,
267,
291,
423,
77,
872,
4530,
28200,
275,
488,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
372,
291,
423,
77,
872,
4530,
28200,
339,
347,
664,
63,
13969,
8,
277,
304,
267,
340,
291,
423,
77,
872,
4530,
28200,
26,
288,
372,
378,
14,
1020,
267,
587,
26,
288,
372,
378,
14,
383,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
367,
286,
315,
17407,
26,
288,
327,
7843,
19,
43,
26,
17407,
365,
282,
3696,
1625,
12,
880,
286,
365,
376,
1109,
12,
440,
282,
3696,
288,
367,
2803,
4029,
315,
291,
423,
29633,
26,
355,
340,
440,
2803,
4029,
26,
1980,
355,
340,
440,
2803,
4029,
14,
2682,
26,
1980,
355,
2803,
2223,
275,
2803,
4029,
14,
2184,
63,
929,
8,
67,
9,
355,
340,
2803,
2223,
508,
5262,
14,
6259,
26,
490,
2803,
4029,
14,
2682,
275,
756,
490,
291,
423,
77,
7472,
4029,
4862,
413,
490,
340,
291,
423,
77,
7472,
4029,
2695,
378,
26,
717,
291,
423,
31984,
275,
5262,
14,
69,
1763,
1352,
717,
372,
291,
14,
362,
63,
929,
342,
355,
916,
2803,
2223,
508,
5262,
14,
13241,
26,
490,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
490,
291,
423,
77,
872,
4530,
28200,
275,
2803,
4029,
14,
362,
63,
1523,
63,
929,
63,
6744,
342,
490,
372,
291,
14,
362,
63,
929,
342,
21695,
372,
291,
14,
362,
63,
929,
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
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
1303,
6956,
14,
1308,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
492,
5262,
199,
646,
984,
199,
504,
1275,
397,
1259,
77,
492,
869,
58,
25335,
12,
9055,
13859,
35,
2709,
45,
1685,
12,
9055,
13859,
15819,
25335,
12,
9055,
13859,
23063,
25335,
199,
504,
1275,
6043,
19903,
492,
31727,
199,
504,
1275,
1523,
929,
6744,
492,
30539,
199,
199,
533,
662,
551,
15159,
8,
15159,
304,
272,
347,
636,
826,
721,
277,
304,
267,
31727,
855,
826,
721,
277,
9,
267,
291,
423,
29633,
275,
359,
971,
288,
30539,
8,
25955,
25335,
395,
288,
30539,
8,
7336,
13859,
35,
2709,
45,
1685,
395,
288,
30539,
8,
7336,
13859,
15819,
25335,
395,
288,
30539,
8,
7336,
13859,
23063,
25335,
9,
288,
1622,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
31727,
14,
3958,
8,
277,
9,
267,
367,
2803,
4029,
315,
291,
423,
29633,
26,
288,
340,
440,
2803,
4029,
26,
1980,
288,
2803,
4029,
14,
2682,
275,
715,
288,
2803,
4029,
14,
3958,
342,
267,
291,
423,
77,
7472,
4029,
275,
822,
8,
277,
423,
29633,
9,
267,
291,
423,
77,
872,
4530,
28200,
275,
488,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
372,
291,
423,
77,
872,
4530,
28200,
339,
347,
664,
63,
13969,
8,
277,
304,
267,
340,
291,
423,
77,
872,
4530,
28200,
26,
288,
372,
378,
14,
1020,
267,
587,
26,
288,
372,
378,
14,
383,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
367,
286,
315,
17407,
26,
288,
327,
7843,
19,
43,
26,
17407,
365,
282,
3696,
1625,
12,
880,
286,
365,
376,
1109,
12,
440,
282,
3696,
288,
367,
2803,
4029,
315,
291,
423,
29633,
26,
355,
340,
440,
2803,
4029,
26,
1980,
355,
340,
440,
2803,
4029,
14,
2682,
26,
1980,
355,
2803,
2223,
275,
2803,
4029,
14,
2184,
63,
929,
8,
67,
9,
355,
340,
2803,
2223,
508,
5262,
14,
6259,
26,
490,
2803,
4029,
14,
2682,
275,
756,
490,
291,
423,
77,
7472,
4029,
4862,
413,
490,
340,
291,
423,
77,
7472,
4029,
2695,
378,
26,
717,
291,
423,
31984,
275,
5262,
14,
69,
1763,
1352,
717,
372,
291,
14,
362,
63,
929,
342,
355,
916,
2803,
2223,
508,
5262,
14,
13241,
26,
490,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
490,
291,
423,
77,
872,
4530,
28200,
275,
2803,
4029,
14,
362,
63,
1523,
63,
929,
63,
6744,
342,
490,
372,
291,
14,
362,
63,
929,
342,
21695,
372,
291,
14,
362,
63,
929,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
hkariti/ansible
|
test/integration/targets/vault/password-script.py
|
64
|
1024
|
#!/usr/bin/env python
#
# 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-vault is a script that encrypts/decrypts YAML files. See
# http://docs.ansible.com/playbooks_vault.html for more details.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import sys
PASSWORD = 'test-vault-password'
def main(args):
print(PASSWORD)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[:]))
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
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,
3,
3242,
13,
10077,
365,
282,
2884,
626,
14645,
83,
15,
15682,
83,
18916,
1584,
14,
1666,
199,
3,
1455,
921,
4757,
14,
4853,
14,
957,
15,
2802,
8858,
63,
10077,
14,
1360,
367,
1655,
2436,
14,
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,
984,
199,
199,
9032,
275,
283,
396,
13,
10077,
13,
2060,
7,
421,
199,
318,
2446,
8,
589,
304,
272,
870,
8,
9032,
9,
272,
372,
378,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
984,
14,
2224,
8,
973,
8,
1274,
14,
3020,
1491,
2459,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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,
3,
3242,
13,
10077,
365,
282,
2884,
626,
14645,
83,
15,
15682,
83,
18916,
1584,
14,
1666,
199,
3,
1455,
921,
4757,
14,
4853,
14,
957,
15,
2802,
8858,
63,
10077,
14,
1360,
367,
1655,
2436,
14,
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,
984,
199,
199,
9032,
275,
283,
396,
13,
10077,
13,
2060,
7,
421,
199,
318,
2446,
8,
589,
304,
272,
870,
8,
9032,
9,
272,
372,
378,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
984,
14,
2224,
8,
973,
8,
1274,
14,
3020,
1491,
2459,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0
] |
MrKepzie/google-test
|
scripts/fuse_gtest_files.py
|
2577
|
8813
|
#!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""fuse_gtest_files.py v0.2.0
Fuses Google Test source code into a .h file and a .cc file.
SYNOPSIS
fuse_gtest_files.py [GTEST_ROOT_DIR] OUTPUT_DIR
Scans GTEST_ROOT_DIR for Google Test source code, and generates
two files: OUTPUT_DIR/gtest/gtest.h and OUTPUT_DIR/gtest/gtest-all.cc.
Then you can build your tests by adding OUTPUT_DIR to the include
search path and linking with OUTPUT_DIR/gtest/gtest-all.cc. These
two files contain everything you need to use Google Test. Hence
you can "install" Google Test by copying them to wherever you want.
GTEST_ROOT_DIR can be omitted and defaults to the parent
directory of the directory holding this script.
EXAMPLES
./fuse_gtest_files.py fused_gtest
./fuse_gtest_files.py path/to/unpacked/gtest fused_gtest
This tool is experimental. In particular, it assumes that there is no
conditional inclusion of Google Test headers. Please report any
problems to googletestframework@googlegroups.com. You can read
http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide for
more information.
"""
__author__ = 'wan@google.com (Zhanyong Wan)'
import os
import re
import sets
import sys
# We assume that this file is in the scripts/ directory in the Google
# Test root directory.
DEFAULT_GTEST_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')
# Regex for matching '#include "gtest/..."'.
INCLUDE_GTEST_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(gtest/.+)"')
# Regex for matching '#include "src/..."'.
INCLUDE_SRC_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(src/.+)"')
# Where to find the source seed files.
GTEST_H_SEED = 'include/gtest/gtest.h'
GTEST_SPI_H_SEED = 'include/gtest/gtest-spi.h'
GTEST_ALL_CC_SEED = 'src/gtest-all.cc'
# Where to put the generated files.
GTEST_H_OUTPUT = 'gtest/gtest.h'
GTEST_ALL_CC_OUTPUT = 'gtest/gtest-all.cc'
def VerifyFileExists(directory, relative_path):
"""Verifies that the given file exists; aborts on failure.
relative_path is the file path relative to the given directory.
"""
if not os.path.isfile(os.path.join(directory, relative_path)):
print 'ERROR: Cannot find %s in directory %s.' % (relative_path,
directory)
print ('Please either specify a valid project root directory '
'or omit it on the command line.')
sys.exit(1)
def ValidateGTestRootDir(gtest_root):
"""Makes sure gtest_root points to a valid gtest root directory.
The function aborts the program on failure.
"""
VerifyFileExists(gtest_root, GTEST_H_SEED)
VerifyFileExists(gtest_root, GTEST_ALL_CC_SEED)
def VerifyOutputFile(output_dir, relative_path):
"""Verifies that the given output file path is valid.
relative_path is relative to the output_dir directory.
"""
# Makes sure the output file either doesn't exist or can be overwritten.
output_file = os.path.join(output_dir, relative_path)
if os.path.exists(output_file):
# TODO(wan@google.com): The following user-interaction doesn't
# work with automated processes. We should provide a way for the
# Makefile to force overwriting the files.
print ('%s already exists in directory %s - overwrite it? (y/N) ' %
(relative_path, output_dir))
answer = sys.stdin.readline().strip()
if answer not in ['y', 'Y']:
print 'ABORTED.'
sys.exit(1)
# Makes sure the directory holding the output file exists; creates
# it and all its ancestors if necessary.
parent_directory = os.path.dirname(output_file)
if not os.path.isdir(parent_directory):
os.makedirs(parent_directory)
def ValidateOutputDir(output_dir):
"""Makes sure output_dir points to a valid output directory.
The function aborts the program on failure.
"""
VerifyOutputFile(output_dir, GTEST_H_OUTPUT)
VerifyOutputFile(output_dir, GTEST_ALL_CC_OUTPUT)
def FuseGTestH(gtest_root, output_dir):
"""Scans folder gtest_root to generate gtest/gtest.h in output_dir."""
output_file = file(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
processed_files = sets.Set() # Holds all gtest headers we've processed.
def ProcessFile(gtest_header_path):
"""Processes the given gtest header file."""
# We don't process the same header twice.
if gtest_header_path in processed_files:
return
processed_files.add(gtest_header_path)
# Reads each line in the given gtest header.
for line in file(os.path.join(gtest_root, gtest_header_path), 'r'):
m = INCLUDE_GTEST_FILE_REGEX.match(line)
if m:
# It's '#include "gtest/..."' - let's process it recursively.
ProcessFile('include/' + m.group(1))
else:
# Otherwise we copy the line unchanged to the output file.
output_file.write(line)
ProcessFile(GTEST_H_SEED)
output_file.close()
def FuseGTestAllCcToFile(gtest_root, output_file):
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_file."""
processed_files = sets.Set()
def ProcessFile(gtest_source_file):
"""Processes the given gtest source file."""
# We don't process the same #included file twice.
if gtest_source_file in processed_files:
return
processed_files.add(gtest_source_file)
# Reads each line in the given gtest source file.
for line in file(os.path.join(gtest_root, gtest_source_file), 'r'):
m = INCLUDE_GTEST_FILE_REGEX.match(line)
if m:
if 'include/' + m.group(1) == GTEST_SPI_H_SEED:
# It's '#include "gtest/gtest-spi.h"'. This file is not
# #included by "gtest/gtest.h", so we need to process it.
ProcessFile(GTEST_SPI_H_SEED)
else:
# It's '#include "gtest/foo.h"' where foo is not gtest-spi.
# We treat it as '#include "gtest/gtest.h"', as all other
# gtest headers are being fused into gtest.h and cannot be
# #included directly.
# There is no need to #include "gtest/gtest.h" more than once.
if not GTEST_H_SEED in processed_files:
processed_files.add(GTEST_H_SEED)
output_file.write('#include "%s"\n' % (GTEST_H_OUTPUT,))
else:
m = INCLUDE_SRC_FILE_REGEX.match(line)
if m:
# It's '#include "src/foo"' - let's process it recursively.
ProcessFile(m.group(1))
else:
output_file.write(line)
ProcessFile(GTEST_ALL_CC_SEED)
def FuseGTestAllCc(gtest_root, output_dir):
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir."""
output_file = file(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
FuseGTestAllCcToFile(gtest_root, output_file)
output_file.close()
def FuseGTest(gtest_root, output_dir):
"""Fuses gtest.h and gtest-all.cc."""
ValidateGTestRootDir(gtest_root)
ValidateOutputDir(output_dir)
FuseGTestH(gtest_root, output_dir)
FuseGTestAllCc(gtest_root, output_dir)
def main():
argc = len(sys.argv)
if argc == 2:
# fuse_gtest_files.py OUTPUT_DIR
FuseGTest(DEFAULT_GTEST_ROOT_DIR, sys.argv[1])
elif argc == 3:
# fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR
FuseGTest(sys.argv[1], sys.argv[2])
else:
print __doc__
sys.exit(1)
if __name__ == '__main__':
main()
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
70,
1180,
63,
8385,
63,
1725,
14,
647,
373,
16,
14,
18,
14,
16,
199,
38,
5589,
4475,
1379,
1350,
1233,
1901,
282,
1275,
72,
570,
436,
282,
1275,
2055,
570,
14,
199,
199,
31802,
21665,
1311,
2126,
289,
1180,
63,
8385,
63,
1725,
14,
647,
359,
16151,
63,
5441,
63,
3022,
61,
18746,
63,
3022,
10817,
13916,
796,
18652,
63,
5441,
63,
3022,
367,
4475,
1379,
1350,
1233,
12,
436,
12821,
2126,
2877,
1584,
26,
18746,
63,
3022,
15,
8385,
15,
8385,
14,
72,
436,
18746,
63,
3022,
15,
8385,
15,
8385,
13,
452,
14,
2055,
14,
2126,
9442,
1265,
883,
1900,
2195,
2295,
701,
7791,
18746,
63,
3022,
370,
314,
2387,
2126,
2754,
931,
436,
25833,
543,
18746,
63,
3022,
15,
8385,
15,
8385,
13,
452,
14,
2055,
14,
221,
5723,
2126,
2877,
1584,
1395,
8137,
1265,
1929,
370,
675,
4475,
1379,
14,
221,
869,
4894,
2126,
1265,
883,
298,
3174,
2,
4475,
1379,
701,
16743,
3062,
370,
2382,
422,
1265,
2934,
14,
10817,
18652,
63,
5441,
63,
3022,
883,
506,
11684,
436,
4243,
370,
314,
1676,
2126,
2082,
402,
314,
2082,
17573,
642,
2884,
14,
199,
199,
8918,
2126,
16605,
70,
1180,
63,
8385,
63,
1725,
14,
647,
28580,
63,
8385,
2126,
16605,
70,
1180,
63,
8385,
63,
1725,
14,
647,
931,
15,
475,
15,
24497,
15,
8385,
28580,
63,
8385,
199,
199,
2765,
4744,
365,
22820,
14,
221,
1010,
6770,
12,
652,
15194,
626,
2337,
365,
949,
199,
14353,
20396,
402,
4475,
1379,
2323,
14,
221,
7754,
3622,
1263,
199,
22959,
370,
31141,
4857,
32,
3098,
2634,
14,
957,
14,
221,
2047,
883,
1586,
199,
1014,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
3098,
396,
15,
6797,
15,
13266,
774,
23613,
4324,
271,
367,
199,
6878,
2556,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
20444,
32,
3098,
14,
957,
334,
12674,
1629,
951,
644,
290,
3171,
199,
199,
646,
747,
199,
646,
295,
199,
646,
5951,
199,
646,
984,
199,
199,
3,
2136,
5534,
626,
642,
570,
365,
315,
314,
10554,
15,
2082,
315,
314,
4475,
199,
3,
1379,
1738,
2082,
14,
199,
3472,
63,
16151,
63,
5441,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
11541,
358,
199,
199,
3,
12939,
367,
4877,
3943,
2613,
298,
8385,
15,
11500,
1370,
199,
18171,
63,
16151,
63,
3817,
63,
10710,
275,
295,
14,
2014,
8,
82,
15542,
83,
10,
20262,
83,
10,
2613,
60,
83,
12469,
8,
8385,
15,
6977,
2924,
358,
199,
199,
3,
12939,
367,
4877,
3943,
2613,
298,
2164,
15,
11500,
1370,
199,
18171,
63,
12447,
63,
3817,
63,
10710,
275,
295,
14,
2014,
8,
82,
15542,
83,
10,
20262,
83,
10,
2613,
60,
83,
12469,
8,
2164,
15,
6977,
2924,
358,
199,
199,
3,
17685,
370,
2342,
314,
1350,
6347,
1584,
14,
199,
16151,
63,
40,
63,
25508,
275,
283,
2613,
15,
8385,
15,
8385,
14,
72,
7,
199,
16151,
63,
20495,
63,
40,
63,
25508,
275,
283,
2613,
15,
8385,
15,
8385,
13,
8721,
14,
72,
7,
199,
16151,
63,
1761,
63,
2571,
63,
25508,
275,
283,
2164,
15,
8385,
13,
452,
14,
2055,
7,
199,
199,
3,
17685,
370,
5324,
314,
4046,
1584,
14,
199,
16151,
63,
40,
63,
8414,
275,
283,
8385,
15,
8385,
14,
72,
7,
199,
16151,
63,
1761,
63,
2571,
63,
8414,
275,
283,
8385,
15,
8385,
13,
452,
14,
2055,
7,
421,
199,
318,
7635,
1173,
7965,
8,
3619,
12,
3847,
63,
515,
304,
523,
408,
21168,
626,
314,
1627,
570,
3495,
27,
12004,
83,
641,
5988,
14,
819,
3847,
63,
515,
365,
314,
570,
931,
3847,
370,
314,
1627,
2082,
14,
523,
408,
819,
340,
440,
747,
14,
515,
14,
6292,
8,
736,
14,
515,
14,
904,
8,
3619,
12,
3847,
63,
515,
2298,
272,
870,
283,
3170,
26,
18435,
2342,
450,
83,
315,
2082,
450,
83,
3530,
450,
334,
6188,
63,
515,
12,
10028,
2082,
9,
272,
870,
661,
8254,
1902,
4165,
282,
1686,
2199,
1738,
2082,
283,
1779,
283,
269,
19413,
652,
641,
314,
1414,
1004,
2659,
272,
984,
14,
2224,
8,
17,
9,
421,
199,
318,
12134,
39,
774
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
70,
1180,
63,
8385,
63,
1725,
14,
647,
373,
16,
14,
18,
14,
16,
199,
38,
5589,
4475,
1379,
1350,
1233,
1901,
282,
1275,
72,
570,
436,
282,
1275,
2055,
570,
14,
199,
199,
31802,
21665,
1311,
2126,
289,
1180,
63,
8385,
63,
1725,
14,
647,
359,
16151,
63,
5441,
63,
3022,
61,
18746,
63,
3022,
10817,
13916,
796,
18652,
63,
5441,
63,
3022,
367,
4475,
1379,
1350,
1233,
12,
436,
12821,
2126,
2877,
1584,
26,
18746,
63,
3022,
15,
8385,
15,
8385,
14,
72,
436,
18746,
63,
3022,
15,
8385,
15,
8385,
13,
452,
14,
2055,
14,
2126,
9442,
1265,
883,
1900,
2195,
2295,
701,
7791,
18746,
63,
3022,
370,
314,
2387,
2126,
2754,
931,
436,
25833,
543,
18746,
63,
3022,
15,
8385,
15,
8385,
13,
452,
14,
2055,
14,
221,
5723,
2126,
2877,
1584,
1395,
8137,
1265,
1929,
370,
675,
4475,
1379,
14,
221,
869,
4894,
2126,
1265,
883,
298,
3174,
2,
4475,
1379,
701,
16743,
3062,
370,
2382,
422,
1265,
2934,
14,
10817,
18652,
63,
5441,
63,
3022,
883,
506,
11684,
436,
4243,
370,
314,
1676,
2126,
2082,
402,
314,
2082,
17573,
642,
2884,
14,
199,
199,
8918,
2126,
16605,
70,
1180,
63,
8385,
63,
1725,
14,
647,
28580,
63,
8385,
2126,
16605,
70,
1180,
63,
8385,
63,
1725,
14,
647,
931,
15,
475,
15,
24497,
15,
8385,
28580,
63,
8385,
199,
199,
2765,
4744,
365,
22820,
14,
221,
1010,
6770,
12,
652,
15194,
626,
2337,
365,
949,
199,
14353,
20396,
402,
4475,
1379,
2323,
14,
221,
7754,
3622,
1263,
199,
22959,
370,
31141,
4857,
32,
3098,
2634,
14,
957,
14,
221,
2047,
883,
1586,
199,
1014,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
3098,
396,
15,
6797,
15,
13266,
774,
23613,
4324,
271,
367,
199,
6878,
2556,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
20444,
32,
3098,
14,
957,
334,
12674,
1629,
951,
644,
290,
3171,
199,
199,
646,
747,
199,
646,
295,
199,
646,
5951,
199,
646,
984,
199,
199,
3,
2136,
5534,
626,
642,
570,
365,
315,
314,
10554,
15,
2082,
315,
314,
4475,
199,
3,
1379,
1738,
2082,
14,
199,
3472,
63,
16151,
63,
5441,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
11541,
358,
199,
199,
3,
12939,
367,
4877,
3943,
2613,
298,
8385,
15,
11500,
1370,
199,
18171,
63,
16151,
63,
3817,
63,
10710,
275,
295,
14,
2014,
8,
82,
15542,
83,
10,
20262,
83,
10,
2613,
60,
83,
12469,
8,
8385,
15,
6977,
2924,
358,
199,
199,
3,
12939,
367,
4877,
3943,
2613,
298,
2164,
15,
11500,
1370,
199,
18171,
63,
12447,
63,
3817,
63,
10710,
275,
295,
14,
2014,
8,
82,
15542,
83,
10,
20262,
83,
10,
2613,
60,
83,
12469,
8,
2164,
15,
6977,
2924,
358,
199,
199,
3,
17685,
370,
2342,
314,
1350,
6347,
1584,
14,
199,
16151,
63,
40,
63,
25508,
275,
283,
2613,
15,
8385,
15,
8385,
14,
72,
7,
199,
16151,
63,
20495,
63,
40,
63,
25508,
275,
283,
2613,
15,
8385,
15,
8385,
13,
8721,
14,
72,
7,
199,
16151,
63,
1761,
63,
2571,
63,
25508,
275,
283,
2164,
15,
8385,
13,
452,
14,
2055,
7,
199,
199,
3,
17685,
370,
5324,
314,
4046,
1584,
14,
199,
16151,
63,
40,
63,
8414,
275,
283,
8385,
15,
8385,
14,
72,
7,
199,
16151,
63,
1761,
63,
2571,
63,
8414,
275,
283,
8385,
15,
8385,
13,
452,
14,
2055,
7,
421,
199,
318,
7635,
1173,
7965,
8,
3619,
12,
3847,
63,
515,
304,
523,
408,
21168,
626,
314,
1627,
570,
3495,
27,
12004,
83,
641,
5988,
14,
819,
3847,
63,
515,
365,
314,
570,
931,
3847,
370,
314,
1627,
2082,
14,
523,
408,
819,
340,
440,
747,
14,
515,
14,
6292,
8,
736,
14,
515,
14,
904,
8,
3619,
12,
3847,
63,
515,
2298,
272,
870,
283,
3170,
26,
18435,
2342,
450,
83,
315,
2082,
450,
83,
3530,
450,
334,
6188,
63,
515,
12,
10028,
2082,
9,
272,
870,
661,
8254,
1902,
4165,
282,
1686,
2199,
1738,
2082,
283,
1779,
283,
269,
19413,
652,
641,
314,
1414,
1004,
2659,
272,
984,
14,
2224,
8,
17,
9,
421,
199,
318,
12134,
39,
774,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
zhukaixy/kbengine
|
kbe/src/lib/python/Lib/turtledemo/forest.py
|
85
|
2950
|
#!/usr/bin/env python3
""" turtlegraphics-example-suite:
tdemo_forest.py
Displays a 'forest' of 3 breadth-first-trees
similar to the one in tree.
For further remarks see tree.py
This example is a 'breadth-first'-rewrite of
a Logo program written by Erich Neuwirth. See
http://homepage.univie.ac.at/erich.neuwirth/
"""
from turtle import Turtle, colormode, tracer, mainloop
from random import randrange
from time import clock
def symRandom(n):
return randrange(-n,n+1)
def randomize( branchlist, angledist, sizedist ):
return [ (angle+symRandom(angledist),
sizefactor*1.01**symRandom(sizedist))
for angle, sizefactor in branchlist ]
def randomfd( t, distance, parts, angledist ):
for i in range(parts):
t.left(symRandom(angledist))
t.forward( (1.0 * distance)/parts )
def tree(tlist, size, level, widthfactor, branchlists, angledist=10, sizedist=5):
# benutzt Liste von turtles und Liste von Zweiglisten,
# fuer jede turtle eine!
if level > 0:
lst = []
brs = []
for t, branchlist in list(zip(tlist,branchlists)):
t.pensize( size * widthfactor )
t.pencolor( 255 - (180 - 11 * level + symRandom(15)),
180 - 11 * level + symRandom(15),
0 )
t.pendown()
randomfd(t, size, level, angledist )
yield 1
for angle, sizefactor in branchlist:
t.left(angle)
lst.append(t.clone())
brs.append(randomize(branchlist, angledist, sizedist))
t.right(angle)
for x in tree(lst, size*sizefactor, level-1, widthfactor, brs,
angledist, sizedist):
yield None
def start(t,x,y):
colormode(255)
t.reset()
t.speed(0)
t.hideturtle()
t.left(90)
t.penup()
t.setpos(x,y)
t.pendown()
def doit1(level, pen):
pen.hideturtle()
start(pen, 20, -208)
t = tree( [pen], 80, level, 0.1, [[ (45,0.69), (0,0.65), (-45,0.71) ]] )
return t
def doit2(level, pen):
pen.hideturtle()
start(pen, -135, -130)
t = tree( [pen], 120, level, 0.1, [[ (45,0.69), (-45,0.71) ]] )
return t
def doit3(level, pen):
pen.hideturtle()
start(pen, 190, -90)
t = tree( [pen], 100, level, 0.1, [[ (45,0.7), (0,0.72), (-45,0.65) ]] )
return t
# Hier 3 Baumgeneratoren:
def main():
p = Turtle()
p.ht()
tracer(75,0)
u = doit1(6, Turtle(undobuffersize=1))
s = doit2(7, Turtle(undobuffersize=1))
t = doit3(5, Turtle(undobuffersize=1))
a = clock()
while True:
done = 0
for b in u,s,t:
try:
b.__next__()
except:
done += 1
if done == 3:
break
tracer(1,10)
b = clock()
return "runtime: %.2f sec." % (b-a)
if __name__ == '__main__':
main()
mainloop()
|
lgpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
624,
258,
11946,
15707,
13,
2694,
13,
5768,
26,
10798,
307,
8768,
63,
25736,
14,
647,
199,
199,
2825,
20591,
282,
283,
25736,
7,
402,
650,
330,
739,
273,
13,
2246,
13,
14635,
199,
23079,
370,
314,
1373,
315,
3123,
14,
199,
1858,
9848,
295,
10375,
1937,
3123,
14,
647,
199,
199,
2765,
2893,
365,
282,
283,
66,
739,
273,
13,
2246,
12418,
14366,
402,
199,
65,
5297,
79,
2240,
5313,
701,
662,
10399,
5612,
29638,
8244,
14,
1666,
199,
1014,
921,
25539,
14,
5411,
6620,
14,
645,
14,
292,
15,
281,
1158,
14,
685,
29638,
8244,
15,
199,
624,
199,
504,
11946,
492,
20294,
12,
3164,
632,
12,
29140,
12,
2446,
3813,
199,
504,
2196,
492,
10261,
1842,
199,
504,
900,
492,
12516,
199,
199,
318,
4678,
3883,
8,
78,
304,
272,
372,
10261,
1842,
2801,
78,
12,
78,
11,
17,
9,
199,
199,
318,
2196,
794,
8,
5246,
513,
12,
9324,
2686,
12,
1568,
2686,
3461,
272,
372,
359,
334,
4593,
11,
3840,
3883,
8,
4593,
2686,
395,
1598,
1568,
4778,
10,
17,
14,
614,
538,
3840,
3883,
8,
890,
2686,
430,
2151,
367,
9324,
12,
1568,
4778,
315,
5246,
513,
1622,
199,
199,
318,
2196,
2592,
8,
307,
12,
6033,
12,
4184,
12,
9324,
2686,
3461,
272,
367,
284,
315,
1425,
8,
4181,
304,
267,
307,
14,
3039,
8,
3840,
3883,
8,
4593,
2686,
430,
267,
307,
14,
6688,
8,
334,
17,
14,
16,
627,
6033,
2447,
4181,
776,
199,
199,
318,
3123,
8,
84,
513,
12,
1568,
12,
2166,
12,
3462,
4778,
12,
5246,
6717,
12,
9324,
2686,
29,
709,
12,
1568,
2686,
29,
21,
304,
272,
327,
330,
287,
337,
90,
84,
491,
29729,
373,
265,
11946,
83,
625,
68,
491,
29729,
373,
265,
3107,
1129,
528,
5859,
12,
272,
327,
289,
14262,
1335,
69,
271,
11946,
325,
1132,
1,
272,
340,
2166,
690,
378,
26,
267,
9877,
275,
942,
267,
330,
2393,
275,
942,
267,
367,
307,
12,
5246,
513,
315,
769,
8,
3065,
8,
84,
513,
12,
4694,
6717,
2298,
288,
307,
14,
897,
890,
8,
1568,
627,
3462,
4778,
776,
288,
307,
14,
897,
2326,
8,
5450,
446,
334,
7663,
446,
4119,
627,
2166,
435,
4678,
3883,
8,
1046,
1826,
717,
13576,
446,
4119,
627,
2166,
435,
4678,
3883,
8,
1046,
395,
717,
378,
776,
288,
307,
14,
6643,
944,
342,
288,
2196,
2592,
8,
84,
12,
1568,
12,
2166,
12,
9324,
2686,
776,
288,
1995,
413,
288,
367,
9324,
12,
1568,
4778,
315,
5246,
513,
26,
355,
307,
14,
3039,
8,
4593,
9,
355,
9877,
14,
740,
8,
84,
14,
6311,
1012,
355,
330,
2393,
14,
740,
8,
28610,
8,
4694,
513,
12,
9324,
2686,
12,
1568,
2686,
430,
355,
307,
14,
1019,
8,
4593,
9,
267,
367,
671,
315,
3123,
8,
6916,
12,
1568,
10,
890,
4778,
12,
2166,
13,
17,
12,
3462,
4778,
12,
330,
2393,
12,
1993,
9324,
2686,
12,
1568,
2686,
304,
288,
1995,
488,
421,
199,
318,
1343,
8,
84,
12,
88,
12,
89,
304,
272,
3164,
632,
8,
2299,
9,
272,
307,
14,
3958,
342,
272,
307,
14,
7625,
8,
16,
9,
272,
307,
14,
8191,
25027,
342,
272,
307,
14,
3039,
8,
2710,
9,
272,
307,
14,
897,
384,
342,
272,
307,
14,
409,
1712,
8,
88,
12,
89,
9,
272,
307,
14,
6643,
944,
342,
199,
199,
318,
886,
390,
17,
8,
1896,
12,
12374,
304,
272,
12374,
14,
8191,
25027,
342,
272,
1343,
8,
897,
12,
3388,
12,
446,
10630,
9,
272,
307,
275,
3123,
8,
359,
897,
467,
5939,
12,
2166,
12,
378,
14,
17,
12,
3474,
334,
2322,
12,
16,
14,
1876,
395,
334,
16,
12,
16,
14,
2182,
395,
5868,
2322,
12,
16,
14,
3172,
9,
1622,
61,
776,
272,
372,
307,
199,
199,
318,
886,
390,
18,
8,
1896,
12,
12374,
304,
272,
12374,
14,
8191,
25027,
342,
272,
1343,
8,
897,
12,
446,
8312,
12,
446,
9056,
9,
272,
307,
275,
3123,
8,
359,
897,
467,
13960,
12,
2166,
12,
378,
14,
17,
12,
3474,
334,
2322,
12,
16,
14,
1876,
395,
5868,
2322,
12,
16,
14,
3172,
9,
1622,
61,
776,
272,
372,
307,
199,
199,
318,
886,
390,
19,
8,
1896,
12,
12374,
304,
272,
12374,
14,
8191,
25027,
342,
272,
1343,
8,
897,
12,
29682,
12,
446,
2710,
9,
272,
307,
275,
3123,
8,
359,
897,
467,
2948,
12,
2166,
12,
378,
14,
17,
12,
3474,
334,
2322,
12,
16,
14,
23,
395,
334,
16,
12,
16,
14,
2819,
395,
5868,
2322,
12,
16,
14,
2182,
9,
1622,
61,
776,
272,
372,
307,
199,
199,
3,
869,
4446,
650,
699,
65,
453,
2038,
292,
720,
78,
26,
199,
318,
2446,
837,
272,
299,
275,
20294,
342,
272,
299,
14,
517,
342,
272,
29140,
8,
2194,
12,
16,
9,
272,
399,
275,
886,
390,
17,
8,
22,
12,
20294,
8,
11833,
2738,
890,
29,
17,
430,
272,
308,
275,
886,
390,
18,
8,
23,
12,
20294,
8,
11833,
2738,
890,
29,
17,
430,
272,
307,
275,
886,
390,
19,
8,
21,
12,
20294,
8,
11833,
2738,
890,
29,
17,
430,
272,
282,
275,
12516,
342,
272,
1830,
715,
26,
267,
4224,
275,
378,
267,
367,
330,
315,
399,
12,
83,
12,
84,
26,
288,
862,
26,
355,
330,
855,
2184,
4533,
288,
871,
26,
355,
4224,
847,
413,
267,
340,
4224,
508,
650,
26,
288,
2059,
339,
29140,
8,
17,
12,
709,
9,
272,
330,
275,
12516,
342,
272,
372,
298,
7726,
26,
10536,
18,
70,
6513,
2122,
450,
334,
66,
13,
65,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
272,
2446,
3813,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
624,
258,
11946,
15707,
13,
2694,
13,
5768,
26,
10798,
307,
8768,
63,
25736,
14,
647,
199,
199,
2825,
20591,
282,
283,
25736,
7,
402,
650,
330,
739,
273,
13,
2246,
13,
14635,
199,
23079,
370,
314,
1373,
315,
3123,
14,
199,
1858,
9848,
295,
10375,
1937,
3123,
14,
647,
199,
199,
2765,
2893,
365,
282,
283,
66,
739,
273,
13,
2246,
12418,
14366,
402,
199,
65,
5297,
79,
2240,
5313,
701,
662,
10399,
5612,
29638,
8244,
14,
1666,
199,
1014,
921,
25539,
14,
5411,
6620,
14,
645,
14,
292,
15,
281,
1158,
14,
685,
29638,
8244,
15,
199,
624,
199,
504,
11946,
492,
20294,
12,
3164,
632,
12,
29140,
12,
2446,
3813,
199,
504,
2196,
492,
10261,
1842,
199,
504,
900,
492,
12516,
199,
199,
318,
4678,
3883,
8,
78,
304,
272,
372,
10261,
1842,
2801,
78,
12,
78,
11,
17,
9,
199,
199,
318,
2196,
794,
8,
5246,
513,
12,
9324,
2686,
12,
1568,
2686,
3461,
272,
372,
359,
334,
4593,
11,
3840,
3883,
8,
4593,
2686,
395,
1598,
1568,
4778,
10,
17,
14,
614,
538,
3840,
3883,
8,
890,
2686,
430,
2151,
367,
9324,
12,
1568,
4778,
315,
5246,
513,
1622,
199,
199,
318,
2196,
2592,
8,
307,
12,
6033,
12,
4184,
12,
9324,
2686,
3461,
272,
367,
284,
315,
1425,
8,
4181,
304,
267,
307,
14,
3039,
8,
3840,
3883,
8,
4593,
2686,
430,
267,
307,
14,
6688,
8,
334,
17,
14,
16,
627,
6033,
2447,
4181,
776,
199,
199,
318,
3123,
8,
84,
513,
12,
1568,
12,
2166,
12,
3462,
4778,
12,
5246,
6717,
12,
9324,
2686,
29,
709,
12,
1568,
2686,
29,
21,
304,
272,
327,
330,
287,
337,
90,
84,
491,
29729,
373,
265,
11946,
83,
625,
68,
491,
29729,
373,
265,
3107,
1129,
528,
5859,
12,
272,
327,
289,
14262,
1335,
69,
271,
11946,
325,
1132,
1,
272,
340,
2166,
690,
378,
26,
267,
9877,
275,
942,
267,
330,
2393,
275,
942,
267,
367,
307,
12,
5246,
513,
315,
769,
8,
3065,
8,
84,
513,
12,
4694,
6717,
2298,
288,
307,
14,
897,
890,
8,
1568,
627,
3462,
4778,
776,
288,
307,
14,
897,
2326,
8,
5450,
446,
334,
7663,
446,
4119,
627,
2166,
435,
4678,
3883,
8,
1046,
1826,
717,
13576,
446,
4119,
627,
2166,
435,
4678,
3883,
8,
1046,
395,
717,
378,
776,
288,
307,
14,
6643,
944,
342,
288,
2196,
2592,
8,
84,
12,
1568,
12,
2166,
12,
9324,
2686,
776,
288,
1995,
413,
288,
367,
9324,
12,
1568,
4778,
315,
5246,
513,
26,
355,
307,
14,
3039,
8,
4593,
9,
355,
9877,
14,
740,
8,
84,
14,
6311,
1012,
355,
330,
2393,
14,
740,
8,
28610,
8,
4694,
513,
12,
9324,
2686,
12,
1568,
2686,
430,
355,
307,
14,
1019,
8,
4593,
9,
267,
367,
671,
315,
3123,
8,
6916,
12,
1568,
10,
890,
4778,
12,
2166,
13,
17,
12,
3462,
4778,
12,
330,
2393,
12,
1993,
9324,
2686,
12,
1568,
2686,
304,
288,
1995,
488,
421,
199,
318,
1343,
8,
84,
12,
88,
12,
89,
304,
272,
3164,
632,
8,
2299,
9,
272,
307,
14,
3958,
342,
272,
307,
14,
7625,
8,
16,
9,
272,
307,
14,
8191,
25027,
342,
272,
307,
14,
3039,
8,
2710,
9,
272,
307,
14,
897,
384,
342,
272,
307,
14,
409,
1712,
8,
88,
12,
89,
9,
272,
307,
14,
6643,
944,
342,
199,
199,
318,
886,
390,
17,
8,
1896,
12,
12374,
304,
272,
12374,
14,
8191,
25027,
342,
272,
1343,
8,
897,
12,
3388,
12,
446,
10630,
9,
272,
307,
275,
3123,
8,
359,
897,
467,
5939,
12,
2166,
12,
378,
14,
17,
12,
3474,
334,
2322,
12,
16,
14,
1876,
395,
334,
16,
12,
16,
14,
2182,
395,
5868,
2322,
12,
16,
14,
3172,
9,
1622,
61,
776,
272,
372,
307,
199,
199,
318,
886,
390,
18,
8,
1896,
12,
12374,
304,
272,
12374,
14,
8191,
25027,
342,
272,
1343,
8,
897,
12,
446,
8312,
12,
446,
9056,
9,
272,
307,
275,
3123,
8,
359,
897,
467,
13960,
12,
2166,
12,
378,
14,
17,
12,
3474,
334,
2322,
12,
16,
14,
1876,
395,
5868,
2322,
12,
16,
14,
3172,
9,
1622,
61,
776,
272,
372,
307,
199,
199,
318,
886,
390,
19,
8,
1896,
12,
12374,
304,
272,
12374,
14,
8191,
25027,
342,
272,
1343,
8,
897,
12,
29682,
12,
446,
2710,
9,
272,
307,
275,
3123,
8,
359,
897,
467,
2948,
12,
2166,
12,
378,
14,
17,
12,
3474,
334,
2322,
12,
16,
14,
23,
395,
334,
16,
12,
16,
14,
2819,
395,
5868,
2322,
12,
16,
14,
2182,
9,
1622,
61,
776,
272,
372,
307,
199,
199,
3,
869,
4446,
650,
699,
65,
453,
2038,
292,
720,
78,
26,
199,
318,
2446,
837,
272,
299,
275,
20294,
342,
272,
299,
14,
517,
342,
272,
29140,
8,
2194,
12,
16,
9,
272,
399,
275,
886,
390,
17,
8,
22,
12,
20294,
8,
11833,
2738,
890,
29,
17,
430,
272,
308,
275,
886,
390,
18,
8,
23,
12,
20294,
8,
11833,
2738,
890,
29,
17,
430,
272,
307,
275,
886,
390,
19,
8,
21,
12,
20294,
8,
11833,
2738,
890,
29,
17,
430,
272,
282,
275,
12516,
342,
272,
1830,
715,
26,
267,
4224,
275,
378,
267,
367,
330,
315,
399,
12,
83,
12,
84,
26,
288,
862,
26,
355,
330,
855,
2184,
4533,
288,
871,
26,
355,
4224,
847,
413,
267,
340,
4224,
508,
650,
26,
288,
2059,
339,
29140,
8,
17,
12,
709,
9,
272,
330,
275,
12516,
342,
272,
372,
298,
7726,
26,
10536,
18,
70,
6513,
2122,
450,
334,
66,
13,
65,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
272,
2446,
3813,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
agateau/yokadi
|
yokadi/tests/yokadioptionparsertestcase.py
|
2
|
1160
|
# -*- coding: UTF-8 -*-
"""
Yokadi parser test cases
@author: Aurélien Gâteau <mail@agateau.com>
@license: GPL v3 or later
"""
import unittest
from yokadi.core.yokadioptionparser import YokadiOptionParser
from yokadi.core.yokadiexception import YokadiException
class YokadiOptionParserTestCase(unittest.TestCase):
def testQuote(self):
parser = YokadiOptionParser()
parser.add_argument("cmd", nargs='*')
src = "There's a quote here"
args = parser.parse_args(src)
# Recreate the line
line = " ".join(args.cmd)
self.assertEqual(line, src)
def testDash(self):
parser = YokadiOptionParser()
parser.add_argument("cmd", nargs="*")
srcs = ["foo-bar", "foo - bar"]
for src in srcs:
args = parser.parse_args(src)
# Recreate the line
line = " ".join(args.cmd)
self.assertEqual(line, src)
def testUknownOption(self):
def parseUnknownOption():
parser.parse_args("blabla -b")
parser = YokadiOptionParser()
self.assertRaises(YokadiException, parseUnknownOption)
# vi: ts=4 sw=4 et
|
gpl-3.0
|
[
3,
1882,
2803,
26,
9094,
13,
24,
1882,
199,
624,
199,
57,
745,
65,
328,
1798,
511,
5560,
199,
32,
2502,
26,
437,
300,
5741,
317,
287,
598,
128,
96,
266,
3844,
665,
1198,
32,
643,
323,
3844,
14,
957,
30,
199,
32,
1682,
26,
14629,
373,
19,
503,
2945,
199,
624,
199,
199,
646,
2882,
199,
199,
504,
612,
745,
65,
328,
14,
1018,
14,
89,
745,
65,
328,
1422,
2087,
492,
1488,
745,
65,
328,
14553,
199,
504,
612,
745,
65,
328,
14,
1018,
14,
89,
745,
65,
328,
1971,
492,
1488,
745,
65,
328,
1726,
421,
199,
533,
1488,
745,
65,
328,
14553,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
12838,
8,
277,
304,
267,
1798,
275,
1488,
745,
65,
328,
14553,
342,
267,
1798,
14,
525,
63,
2094,
480,
1760,
401,
9237,
534,
13418,
267,
2928,
275,
298,
10924,
1159,
282,
6313,
2348,
2,
267,
1249,
275,
1798,
14,
1122,
63,
589,
8,
2164,
9,
267,
327,
799,
981,
314,
1004,
267,
1004,
275,
298,
3680,
904,
8,
589,
14,
1760,
9,
267,
291,
14,
629,
8,
604,
12,
2928,
9,
339,
347,
511,
16659,
8,
277,
304,
267,
1798,
275,
1488,
745,
65,
328,
14553,
342,
267,
1798,
14,
525,
63,
2094,
480,
1760,
401,
9237,
32103,
531,
267,
2928,
83,
275,
2097,
1421,
13,
1700,
401,
298,
1421,
446,
4681,
937,
267,
367,
2928,
315,
2928,
83,
26,
288,
1249,
275,
1798,
14,
1122,
63,
589,
8,
2164,
9,
288,
327,
799,
981,
314,
1004,
288,
1004,
275,
298,
3680,
904,
8,
589,
14,
1760,
9,
288,
291,
14,
629,
8,
604,
12,
2928,
9,
339,
347,
511,
53,
3159,
2602,
8,
277,
304,
267,
347,
2198,
5912,
2602,
837,
288,
1798,
14,
1122,
63,
589,
480,
3345,
371,
416,
446,
66,
531,
267,
1798,
275,
1488,
745,
65,
328,
14553,
342,
267,
291,
14,
1855,
8,
57,
745,
65,
328,
1726,
12,
2198,
5912,
2602,
9,
199,
199,
3,
1321,
26,
6714,
29,
20,
5584,
29,
20,
10844,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
9094,
13,
24,
1882,
199,
624,
199,
57,
745,
65,
328,
1798,
511,
5560,
199,
32,
2502,
26,
437,
300,
5741,
317,
287,
598,
128,
96,
266,
3844,
665,
1198,
32,
643,
323,
3844,
14,
957,
30,
199,
32,
1682,
26,
14629,
373,
19,
503,
2945,
199,
624,
199,
199,
646,
2882,
199,
199,
504,
612,
745,
65,
328,
14,
1018,
14,
89,
745,
65,
328,
1422,
2087,
492,
1488,
745,
65,
328,
14553,
199,
504,
612,
745,
65,
328,
14,
1018,
14,
89,
745,
65,
328,
1971,
492,
1488,
745,
65,
328,
1726,
421,
199,
533,
1488,
745,
65,
328,
14553,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
12838,
8,
277,
304,
267,
1798,
275,
1488,
745,
65,
328,
14553,
342,
267,
1798,
14,
525,
63,
2094,
480,
1760,
401,
9237,
534,
13418,
267,
2928,
275,
298,
10924,
1159,
282,
6313,
2348,
2,
267,
1249,
275,
1798,
14,
1122,
63,
589,
8,
2164,
9,
267,
327,
799,
981,
314,
1004,
267,
1004,
275,
298,
3680,
904,
8,
589,
14,
1760,
9,
267,
291,
14,
629,
8,
604,
12,
2928,
9,
339,
347,
511,
16659,
8,
277,
304,
267,
1798,
275,
1488,
745,
65,
328,
14553,
342,
267,
1798,
14,
525,
63,
2094,
480,
1760,
401,
9237,
32103,
531,
267,
2928,
83,
275,
2097,
1421,
13,
1700,
401,
298,
1421,
446,
4681,
937,
267,
367,
2928,
315,
2928,
83,
26,
288,
1249,
275,
1798,
14,
1122,
63,
589,
8,
2164,
9,
288,
327,
799,
981,
314,
1004,
288,
1004,
275,
298,
3680,
904,
8,
589,
14,
1760,
9,
288,
291,
14,
629,
8,
604,
12,
2928,
9,
339,
347,
511,
53,
3159,
2602,
8,
277,
304,
267,
347,
2198,
5912,
2602,
837,
288,
1798,
14,
1122,
63,
589,
480,
3345,
371,
416,
446,
66,
531,
267,
1798,
275,
1488,
745,
65,
328,
14553,
342,
267,
291,
14,
1855,
8,
57,
745,
65,
328,
1726,
12,
2198,
5912,
2602,
9,
199,
199,
3,
1321,
26,
6714,
29,
20,
5584,
29,
20,
10844,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
Maspear/odoo
|
addons/hr_payroll/wizard/__init__.py
|
442
|
1159
|
#-*- coding:utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# d$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import hr_payroll_payslips_by_employees
import hr_payroll_contribution_register_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
13,
1837,
2803,
26,
1624,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
2900,
5924,
5702,
199,
3,
259,
366,
4,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
3267,
701,
199,
3,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
16140,
63,
5989,
2827,
63,
387,
588,
317,
1190,
63,
991,
63,
24561,
199,
646,
16140,
63,
5989,
2827,
63,
388,
15980,
63,
2683,
63,
3070,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
13,
1837,
2803,
26,
1624,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
2900,
5924,
5702,
199,
3,
259,
366,
4,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
3267,
701,
199,
3,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
16140,
63,
5989,
2827,
63,
387,
588,
317,
1190,
63,
991,
63,
24561,
199,
646,
16140,
63,
5989,
2827,
63,
388,
15980,
63,
2683,
63,
3070,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
dermoth/gramps
|
docs/update_doc.py
|
10
|
3491
|
#! /usr/bin/env python3
#
# update_po - a gramps tool to update translations
#
# Copyright (C) 2006-2006 Kees Bakker
# Copyright (C) 2006 Brian Matherly
# Copyright (C) 2008 Stephen George
# Copyright (C) 2012
#
# 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.
"""
update_doc.py for Gramps API(s) documentation.
Examples:
python update_doc.py -t
Tests if 'sphinx' and 'python' are well configured.
"""
from __future__ import print_function
import os
import sys
from argparse import ArgumentParser
# You can set these variables from the command line.
SPHINXBUILD = 'sphinx-build'
if sys.platform == 'win32':
pythonCmd = os.path.join(sys.prefix, 'bin', 'python.exe')
sphinxCmd = os.path.join(sys.prefix, 'bin', 'sphinx-build.exe')
elif sys.platform in ['linux', 'linux2', 'darwin', 'cygwin']:
pythonCmd = os.path.join(sys.prefix, 'bin', 'python')
sphinxCmd = SPHINXBUILD
else:
print ("Update Docs ERROR: unknown system, don't know sphinx, ... commands")
sys.exit(0)
def tests():
"""
Testing installed programs.
We made tests (-t flag) by displaying versions of tools if properly
installed. Cannot run all commands without 'sphinx' and 'python'.
"""
try:
print("\n=================='python'=============================\n")
os.system('''%(program)s -V''' % {'program': pythonCmd})
except:
print ('Please, install python')
try:
print("\n=================='sphinx-build'=============================\n")
os.system('''%(program)s''' % {'program': sphinxCmd})
except:
print ('Please, install sphinx')
def main():
"""
The utility for handling documentation stuff.
What is need by Gramps, nothing more.
"""
parser = ArgumentParser(
description='This program aims to handle manual'
' and translated version.',
)
parser.add_argument("-t", "--test",
action="store_true", dest="test", default=True,
help="test if 'python' and 'sphinx' are properly installed")
parser.add_argument("-b", "--build",
action="store_true", dest="build", default=True,
help="build documentation")
args = parser.parse_args()
if args.test:
tests()
if args.build:
build()
def build():
"""
Build documentation.
"""
# testing stage
os.system('''%(program)s -b html . _build/html''' % {'program': sphinxCmd})
#os.system('''%(program)s -b changes . _build/changes''' % {'program': sphinxCmd})
#os.system('''%(program)s -b linkcheck . _build/linkcheck''' % {'program': sphinxCmd})
#os.system('''%(program)s -b devhelp . _build/devhelp''' % {'program': sphinxCmd})
if __name__ == "__main__":
main()
|
gpl-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
199,
3,
1678,
63,
555,
446,
282,
1999,
13408,
4744,
370,
1678,
15547,
199,
3,
199,
3,
1898,
334,
35,
9,
8315,
13,
7968,
221,
25645,
397,
699,
1151,
2570,
199,
3,
1898,
334,
35,
9,
8315,
755,
699,
18429,
603,
7404,
590,
199,
3,
1898,
334,
35,
9,
9079,
755,
17854,
17579,
5346,
24591,
199,
3,
1898,
334,
35,
9,
6029,
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,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
14,
199,
199,
624,
199,
873,
63,
1301,
14,
647,
367,
10268,
13408,
3261,
8,
83,
9,
3794,
14,
199,
199,
22787,
26,
2043,
2366,
1678,
63,
1301,
14,
647,
446,
84,
2541,
6496,
340,
283,
8008,
7,
436,
283,
1548,
7,
787,
5521,
7526,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
747,
199,
646,
984,
199,
504,
7534,
492,
27615,
199,
199,
3,
2047,
883,
663,
3520,
2860,
687,
314,
1414,
1004,
14,
199,
5763,
40,
568,
56,
8248,
257,
275,
283,
8008,
13,
1506,
7,
199,
199,
692,
984,
14,
3246,
508,
283,
2676,
708,
356,
272,
2366,
7874,
275,
747,
14,
515,
14,
904,
8,
1274,
14,
1861,
12,
283,
1393,
297,
283,
1548,
14,
5803,
358,
272,
15882,
7874,
275,
747,
14,
515,
14,
904,
8,
1274,
14,
1861,
12,
283,
1393,
297,
283,
8008,
13,
1506,
14,
5803,
358,
199,
4164,
984,
14,
3246,
315,
788,
5135,
297,
283,
5135,
18,
297,
283,
13245,
297,
283,
16680,
2565,
272,
2366,
7874,
275,
747,
14,
515,
14,
904,
8,
1274,
14,
1861,
12,
283,
1393,
297,
283,
1548,
358,
272,
15882,
7874,
275,
6988,
40,
568,
56,
8248,
199,
2836,
26,
272,
870,
1689,
4152,
5454,
83,
12539,
26,
5809,
2656,
12,
2793,
1133,
5715,
15882,
12,
2263,
3718,
531,
272,
984,
14,
2224,
8,
16,
9,
199,
199,
318,
2295,
837,
272,
408,
272,
11940,
4903,
18572,
14,
272,
2136,
6326,
2295,
5868,
84,
3305,
9,
701,
20589,
5459,
402,
7249,
340,
7684,
272,
4903,
14,
18435,
1255,
1006,
3718,
1928,
283,
8008,
7,
436,
283,
1548,
1370,
272,
408,
272,
862,
26,
267,
870,
4582,
78,
1280,
6803,
1548,
7,
1280,
9152,
60,
78,
531,
267,
747,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
54,
2344,
450,
791,
6815,
356,
2366,
7874,
1552,
272,
871,
26,
267,
870,
661,
8254,
12,
3907,
2366,
358,
339,
862,
26,
267,
870,
4582,
78,
1280,
6803,
8008,
13,
1506,
7,
1280,
9152,
60,
78,
531,
267,
747,
14,
2253,
10505,
2840,
6815,
9,
83,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
272,
871,
26,
267,
870,
661,
8254,
12,
3907,
15882,
358,
199,
199,
318,
2446,
837,
272,
408,
272,
710,
11420,
367,
7252,
3794,
8292,
14,
272,
14791,
365,
1929,
701,
10268,
13408,
12,
6548,
1655,
14,
272,
408,
339,
1798,
275,
27615,
8,
586,
1369,
534,
2765,
2240,
282,
11171,
370,
2429,
8722,
7,
4228,
283,
436,
14598,
1015,
3130,
586,
776,
339,
1798,
14,
525,
63,
2094,
6096,
84,
401,
4320,
396,
401,
288,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
396,
401,
221,
849,
29,
549,
12,
288,
1720,
628,
396,
340,
283,
1548,
7,
436,
283,
8008,
7,
787,
7684,
4903,
531,
339,
1798,
14,
525,
63,
2094,
6096,
66,
401,
4320,
1506,
401,
288,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
1506,
401,
221,
849,
29,
549,
12,
288,
1720,
628,
1506,
3794,
531,
339,
1249,
275,
1798,
14,
1122,
63,
589,
342,
339,
340,
1249,
14,
396,
26,
267,
2295,
342,
339,
340,
1249,
14,
1506,
26,
267,
1900,
342,
199,
199,
318,
1900,
837,
272,
408,
272,
6516,
3794,
14,
272,
408,
339,
327,
5343,
9546,
339,
747,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
66,
3517,
1275,
485,
1506,
15,
1360,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
272,
327,
736,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
66,
4493,
1275,
485,
1506,
15,
6627,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
272,
327,
736,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
66,
2142,
1074,
1275,
485,
1506,
15,
1073,
1074,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
272,
327,
736,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
66,
4866,
3437,
1275,
485,
1506,
15,
2374,
3437,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
199,
3,
1678,
63,
555,
446,
282,
1999,
13408,
4744,
370,
1678,
15547,
199,
3,
199,
3,
1898,
334,
35,
9,
8315,
13,
7968,
221,
25645,
397,
699,
1151,
2570,
199,
3,
1898,
334,
35,
9,
8315,
755,
699,
18429,
603,
7404,
590,
199,
3,
1898,
334,
35,
9,
9079,
755,
17854,
17579,
5346,
24591,
199,
3,
1898,
334,
35,
9,
6029,
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,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
14,
199,
199,
624,
199,
873,
63,
1301,
14,
647,
367,
10268,
13408,
3261,
8,
83,
9,
3794,
14,
199,
199,
22787,
26,
2043,
2366,
1678,
63,
1301,
14,
647,
446,
84,
2541,
6496,
340,
283,
8008,
7,
436,
283,
1548,
7,
787,
5521,
7526,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
747,
199,
646,
984,
199,
504,
7534,
492,
27615,
199,
199,
3,
2047,
883,
663,
3520,
2860,
687,
314,
1414,
1004,
14,
199,
5763,
40,
568,
56,
8248,
257,
275,
283,
8008,
13,
1506,
7,
199,
199,
692,
984,
14,
3246,
508,
283,
2676,
708,
356,
272,
2366,
7874,
275,
747,
14,
515,
14,
904,
8,
1274,
14,
1861,
12,
283,
1393,
297,
283,
1548,
14,
5803,
358,
272,
15882,
7874,
275,
747,
14,
515,
14,
904,
8,
1274,
14,
1861,
12,
283,
1393,
297,
283,
8008,
13,
1506,
14,
5803,
358,
199,
4164,
984,
14,
3246,
315,
788,
5135,
297,
283,
5135,
18,
297,
283,
13245,
297,
283,
16680,
2565,
272,
2366,
7874,
275,
747,
14,
515,
14,
904,
8,
1274,
14,
1861,
12,
283,
1393,
297,
283,
1548,
358,
272,
15882,
7874,
275,
6988,
40,
568,
56,
8248,
199,
2836,
26,
272,
870,
1689,
4152,
5454,
83,
12539,
26,
5809,
2656,
12,
2793,
1133,
5715,
15882,
12,
2263,
3718,
531,
272,
984,
14,
2224,
8,
16,
9,
199,
199,
318,
2295,
837,
272,
408,
272,
11940,
4903,
18572,
14,
272,
2136,
6326,
2295,
5868,
84,
3305,
9,
701,
20589,
5459,
402,
7249,
340,
7684,
272,
4903,
14,
18435,
1255,
1006,
3718,
1928,
283,
8008,
7,
436,
283,
1548,
1370,
272,
408,
272,
862,
26,
267,
870,
4582,
78,
1280,
6803,
1548,
7,
1280,
9152,
60,
78,
531,
267,
747,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
54,
2344,
450,
791,
6815,
356,
2366,
7874,
1552,
272,
871,
26,
267,
870,
661,
8254,
12,
3907,
2366,
358,
339,
862,
26,
267,
870,
4582,
78,
1280,
6803,
8008,
13,
1506,
7,
1280,
9152,
60,
78,
531,
267,
747,
14,
2253,
10505,
2840,
6815,
9,
83,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
272,
871,
26,
267,
870,
661,
8254,
12,
3907,
15882,
358,
199,
199,
318,
2446,
837,
272,
408,
272,
710,
11420,
367,
7252,
3794,
8292,
14,
272,
14791,
365,
1929,
701,
10268,
13408,
12,
6548,
1655,
14,
272,
408,
339,
1798,
275,
27615,
8,
586,
1369,
534,
2765,
2240,
282,
11171,
370,
2429,
8722,
7,
4228,
283,
436,
14598,
1015,
3130,
586,
776,
339,
1798,
14,
525,
63,
2094,
6096,
84,
401,
4320,
396,
401,
288,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
396,
401,
221,
849,
29,
549,
12,
288,
1720,
628,
396,
340,
283,
1548,
7,
436,
283,
8008,
7,
787,
7684,
4903,
531,
339,
1798,
14,
525,
63,
2094,
6096,
66,
401,
4320,
1506,
401,
288,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
1506,
401,
221,
849,
29,
549,
12,
288,
1720,
628,
1506,
3794,
531,
339,
1249,
275,
1798,
14,
1122,
63,
589,
342,
339,
340,
1249,
14,
396,
26,
267,
2295,
342,
339,
340,
1249,
14,
1506,
26,
267,
1900,
342,
199,
199,
318,
1900,
837,
272,
408,
272,
6516,
3794,
14,
272,
408,
339,
327,
5343,
9546,
339,
747,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
66,
3517,
1275,
485,
1506,
15,
1360,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
272,
327,
736,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
66,
4493,
1275,
485,
1506,
15,
6627,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
272,
327,
736,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
66,
2142,
1074,
1275,
485,
1506,
15,
1073,
1074,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
272,
327,
736,
14,
2253,
10505,
2840,
6815,
9,
83,
446,
66,
4866,
3437,
1275,
485,
1506,
15,
2374,
3437,
2344,
450,
791,
6815,
356,
15882,
7874,
1552,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
gotchazipc/webida-server
|
src/ext/cordova-weinre/weinre.build/scripts/build-target-scripts.py
|
7
|
5339
|
#!/usr/bin/env python
# ---
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ---
import os
import re
import sys
import json
import optparse
#--------------------------------------------------------------------
def main():
#----------------------------------------------------------------
if len(sys.argv) < 3:
error("expecting parameters srcDir outputDir")
srcDirName = sys.argv[1]
oDirName = sys.argv[2]
if not os.path.exists(srcDirName): error("source directory not found: '" + srcDirName + "'")
if not os.path.isdir(srcDirName): error("source directory not a directory: '" + srcDirName + "'")
if not os.path.exists(oDirName): error("output directory not found: '" + oDirName + "'")
if not os.path.isdir(oDirName): error("output directory not a directory: '" + oDirName + "'")
#----------------------------------------------------------------
scripts = []
scriptNames = {}
scriptSrc = {}
scriptMin = {}
includedFiles = []
includedFiles.append("modjewel.js")
entries = os.listdir(os.path.join(srcDirName, "weinre/common"))
for entry in entries:
includedFiles.append("weinre/common/%s" % entry)
entries = os.listdir(os.path.join(srcDirName, "weinre/target"))
for entry in entries:
includedFiles.append("weinre/target/%s" % entry)
includedFiles.append("interfaces/all-json-idls-min.js")
for includedFile in includedFiles:
baseScriptFile = includedFile
scriptFile = os.path.join(srcDirName, baseScriptFile)
if not os.path.exists(scriptFile):
error("script file not found: '" + scriptFile + "'")
scripts.append(scriptFile)
scriptNames[scriptFile] = baseScriptFile
with open(scriptFile, "r") as iFile:
scriptSrc[scriptFile] = iFile.read()
scriptMin[scriptFile] = min(scriptSrc[scriptFile])
# log("read: %s" % scriptFile)
#----------------------------------------------------------------
oFileName = os.path.join(oDirName, "target-script.js")
writeMergedFile(oFileName, scripts, scriptNames, scriptSrc, True)
#----------------------------------------------------------------
oFileName = os.path.join(oDirName, "target-script-min.js")
writeMergedFile(oFileName, scripts, scriptNames, scriptMin, False)
#--------------------------------------------------------------------
def writeMergedFile(oFileName, scripts, scriptNames, srcs, useEval):
lines = []
licenseFile = os.path.join(os.path.dirname(__file__), "..", "LICENSE-header.js")
with open(licenseFile, "r") as iFile:
lines.append(iFile.read())
lines.append(";(function(){")
for script in scripts:
src = srcs[script]
srcName = scriptNames[script]
if not useEval:
lines.append("// %s" % srcName)
lines.append(src)
lines.append(";")
else:
src = "%s\n//@ sourceURL=%s" % (src, srcName)
lines.append(";eval(%s)" % json.dumps(src))
if srcName == "modjewel.js":
lines.append("modjewel.require('modjewel').warnOnRecursiveRequire(true);")
if not useEval:
lines.append("")
lines.append("// modjewel.require('weinre/common/Weinre').showNotImplemented();")
lines.append("modjewel.require('weinre/target/Target').main()")
lines.append("})();")
targetScript = "\n".join(lines)
with open(oFileName, "w") as oFile:
oFile.write(targetScript)
log("generated: %s" % oFileName)
#--------------------------------------------------------------------
def min(script):
patternCommentC = re.compile(r"/\*.*?\*/", re.MULTILINE + re.DOTALL)
patternCommentCPP = re.compile(r"(?<!\\)//.*?$", re.MULTILINE)
patternIndent = re.compile(r"^\s*", re.MULTILINE)
patternBlankLine = re.compile(r"^\s*\n", re.MULTILINE)
script = patternCommentC.sub( "", script)
script = patternCommentCPP.sub( "", script)
script = patternIndent.sub( "", script)
script = patternBlankLine.sub( "", script)
return script
#--------------------------------------------------------------------
def log(message):
message = "%s: %s" % (PROGRAM_NAME, message)
print >>sys.stderr, message
#--------------------------------------------------------------------
def error(message):
log(message)
sys.exit(-1)
#--------------------------------------------------------------------
PROGRAM_NAME = os.path.basename(sys.argv[0])
main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
10894,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
199,
3,
2032,
1854,
1334,
314,
844,
365,
1854,
641,
376,
199,
3,
298,
1179,
2281,
2,
4207,
12,
2428,
2990,
1549,
4217,
1634,
1821,
199,
3,
3826,
12,
1902,
4056,
503,
2478,
14,
221,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
3,
10894,
199,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
646,
2022,
199,
646,
8691,
199,
199,
7656,
375,
199,
318,
2446,
837,
339,
14309,
272,
340,
822,
8,
1274,
14,
3020,
9,
665,
650,
26,
267,
1125,
480,
4921,
316,
2633,
2928,
3567,
1072,
3567,
531,
339,
2928,
3567,
985,
221,
275,
984,
14,
3020,
59,
17,
61,
272,
312,
3567,
985,
259,
275,
984,
14,
3020,
59,
18,
61,
339,
340,
440,
747,
14,
515,
14,
2444,
8,
2164,
3567,
985,
304,
221,
1125,
480,
1365,
2082,
440,
1911,
26,
5522,
435,
2928,
3567,
985,
435,
3546,
531,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
2164,
3567,
985,
304,
257,
1125,
480,
1365,
2082,
440,
282,
2082,
26,
5522,
435,
2928,
3567,
985,
435,
3546,
531,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
79,
3567,
985,
304,
259,
1125,
480,
1199,
2082,
440,
1911,
26,
5522,
435,
312,
3567,
985,
435,
3546,
531,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
79,
3567,
985,
304,
258,
1125,
480,
1199,
2082,
440,
282,
2082,
26,
5522,
435,
312,
3567,
985,
435,
3546,
531,
339,
14309,
272,
10554,
258,
275,
942,
272,
2884,
5866,
275,
1052,
272,
2884,
21261,
257,
275,
1052,
272,
2884,
4649,
257,
275,
1052,
339,
5120,
5535,
275,
942,
272,
5120,
5535,
14,
740,
480,
1494,
74,
546,
352,
14,
3596,
531,
339,
4811,
275,
747,
14,
7374,
8,
736,
14,
515,
14,
904,
8,
2164,
3567,
985,
12,
298,
1129,
262,
264,
15,
2330,
2237,
272,
367,
2397,
315,
4811,
26,
267,
5120,
5535,
14,
740,
480,
1129,
262,
264,
15,
2330,
3149,
83,
2,
450,
2397,
9,
339,
4811,
275,
747,
14,
7374,
8,
736,
14,
515,
14,
904,
8,
2164,
3567,
985,
12,
298,
1129,
262,
264,
15,
1375,
2237,
272,
367,
2397,
315,
4811,
26,
267,
5120,
5535,
14,
740,
480,
1129,
262,
264,
15,
1375,
3149,
83,
2,
450,
2397,
9,
339,
5120,
5535,
14,
740,
480,
7436,
15,
452,
13,
1001,
13,
344,
478,
13,
827,
14,
3596,
531,
339,
367,
5120,
1173,
315,
5120,
5535,
26,
267,
1300,
5229,
1173,
275,
5120,
1173,
267,
2884,
1173,
275,
747,
14,
515,
14,
904,
8,
2164,
3567,
985,
12,
1300,
5229,
1173,
9,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
1579,
1173,
304,
288,
1125,
480,
1579,
570,
440,
1911,
26,
5522,
435,
2884,
1173,
435,
3546,
531,
398,
10554,
14,
740,
8,
1579,
1173,
9,
267,
2884,
5866,
59,
1579,
1173,
61,
275,
1300,
5229,
1173,
398,
543,
1551,
8,
1579,
1173,
12,
298,
82,
531,
465,
284,
1173,
26,
288,
2884,
21261,
59,
1579,
1173,
61,
275,
284,
1173,
14,
739,
342,
398,
2884,
4649,
59,
1579,
1173,
61,
275,
1748,
8,
1579,
21261,
59,
1579,
1173,
566,
398,
327,
943,
480,
739,
26,
450,
83,
2,
450,
2884,
1173,
9,
339,
14309,
272,
312,
7733,
275,
747,
14,
515,
14,
904,
8,
79,
3567,
985,
12,
298,
1375,
13,
1579,
14,
3596,
531,
272,
2218,
16797,
3046,
1173,
8,
79,
7733,
12,
10554,
12,
2884,
5866,
12,
2884,
21261,
12,
715,
9,
339,
14309,
272,
312,
7733,
275,
747,
14,
515,
14,
904,
8,
79,
3567,
985,
12,
298,
1375,
13,
1579,
13,
827,
14,
3596,
531,
272,
2218,
16797,
3046,
1173,
8,
79,
7733,
12,
10554,
12,
2884,
5866,
12,
2884,
4649,
12,
756,
9,
199,
199,
7656,
375,
199,
318,
2218,
16797,
3046,
1173,
8,
79,
7733,
12,
10554,
12,
2884,
5866,
12,
2928,
83,
12,
675,
10006,
304,
272,
2385,
275,
942,
2286,
4190,
1173,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
21777,
401,
298,
3961,
13,
1291,
14,
3596,
531,
2286,
543,
1551,
8,
1682,
1173,
12,
298,
82,
531,
465,
284,
1173,
26,
267,
2385,
14,
740,
8,
73,
1173,
14,
739,
1012,
15567,
2385,
14,
740,
480,
27,
8,
1593,
29466,
531,
339,
367,
2884,
315,
10554,
26,
398,
2928,
258,
275,
2928,
83,
59,
1579,
61,
267,
2928,
985,
275,
2884,
5866,
59,
1579,
61,
267,
340,
440,
675,
10006,
26,
288,
2385,
14,
740,
21816,
450,
83,
2,
450,
2928,
985,
9,
288,
2385,
14,
740,
8,
2164,
9,
288,
2385,
14,
740,
480,
15027,
267,
587,
26,
288,
2928,
275,
2071,
83,
60,
78,
501,
32,
1350,
2632,
2458,
83,
2,
450,
334,
2164,
12,
2928,
985,
9,
288,
2385,
14,
740,
480,
27,
2579,
4042,
83,
2924,
450,
2022,
14,
4180,
8,
2164,
430,
398,
340,
2928,
985,
508,
298,
1494,
74,
546,
352,
14,
3596,
582,
288,
2385,
14,
740,
480,
1494,
74,
546,
352,
14,
4365,
360,
1494,
74,
546,
352,
1959,
4050,
3314,
25122,
13902,
8,
2052,
2736,
531,
288,
340,
440,
675,
10006,
26,
355,
2385,
14,
740,
10804,
339,
2385,
14,
740,
21816,
3413,
74,
546,
352,
14,
4365,
360,
1129,
262,
264,
15,
2330,
15,
6004,
262,
264,
1959,
2384,
14278,
7303,
531,
272,
2385
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
10894,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
199,
3,
2032,
1854,
1334,
314,
844,
365,
1854,
641,
376,
199,
3,
298,
1179,
2281,
2,
4207,
12,
2428,
2990,
1549,
4217,
1634,
1821,
199,
3,
3826,
12,
1902,
4056,
503,
2478,
14,
221,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
3,
10894,
199,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
646,
2022,
199,
646,
8691,
199,
199,
7656,
375,
199,
318,
2446,
837,
339,
14309,
272,
340,
822,
8,
1274,
14,
3020,
9,
665,
650,
26,
267,
1125,
480,
4921,
316,
2633,
2928,
3567,
1072,
3567,
531,
339,
2928,
3567,
985,
221,
275,
984,
14,
3020,
59,
17,
61,
272,
312,
3567,
985,
259,
275,
984,
14,
3020,
59,
18,
61,
339,
340,
440,
747,
14,
515,
14,
2444,
8,
2164,
3567,
985,
304,
221,
1125,
480,
1365,
2082,
440,
1911,
26,
5522,
435,
2928,
3567,
985,
435,
3546,
531,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
2164,
3567,
985,
304,
257,
1125,
480,
1365,
2082,
440,
282,
2082,
26,
5522,
435,
2928,
3567,
985,
435,
3546,
531,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
79,
3567,
985,
304,
259,
1125,
480,
1199,
2082,
440,
1911,
26,
5522,
435,
312,
3567,
985,
435,
3546,
531,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
79,
3567,
985,
304,
258,
1125,
480,
1199,
2082,
440,
282,
2082,
26,
5522,
435,
312,
3567,
985,
435,
3546,
531,
339,
14309,
272,
10554,
258,
275,
942,
272,
2884,
5866,
275,
1052,
272,
2884,
21261,
257,
275,
1052,
272,
2884,
4649,
257,
275,
1052,
339,
5120,
5535,
275,
942,
272,
5120,
5535,
14,
740,
480,
1494,
74,
546,
352,
14,
3596,
531,
339,
4811,
275,
747,
14,
7374,
8,
736,
14,
515,
14,
904,
8,
2164,
3567,
985,
12,
298,
1129,
262,
264,
15,
2330,
2237,
272,
367,
2397,
315,
4811,
26,
267,
5120,
5535,
14,
740,
480,
1129,
262,
264,
15,
2330,
3149,
83,
2,
450,
2397,
9,
339,
4811,
275,
747,
14,
7374,
8,
736,
14,
515,
14,
904,
8,
2164,
3567,
985,
12,
298,
1129,
262,
264,
15,
1375,
2237,
272,
367,
2397,
315,
4811,
26,
267,
5120,
5535,
14,
740,
480,
1129,
262,
264,
15,
1375,
3149,
83,
2,
450,
2397,
9,
339,
5120,
5535,
14,
740,
480,
7436,
15,
452,
13,
1001,
13,
344,
478,
13,
827,
14,
3596,
531,
339,
367,
5120,
1173,
315,
5120,
5535,
26,
267,
1300,
5229,
1173,
275,
5120,
1173,
267,
2884,
1173,
275,
747,
14,
515,
14,
904,
8,
2164,
3567,
985,
12,
1300,
5229,
1173,
9,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
1579,
1173,
304,
288,
1125,
480,
1579,
570,
440,
1911,
26,
5522,
435,
2884,
1173,
435,
3546,
531,
398,
10554,
14,
740,
8,
1579,
1173,
9,
267,
2884,
5866,
59,
1579,
1173,
61,
275,
1300,
5229,
1173,
398,
543,
1551,
8,
1579,
1173,
12,
298,
82,
531,
465,
284,
1173,
26,
288,
2884,
21261,
59,
1579,
1173,
61,
275,
284,
1173,
14,
739,
342,
398,
2884,
4649,
59,
1579,
1173,
61,
275,
1748,
8,
1579,
21261,
59,
1579,
1173,
566,
398,
327,
943,
480,
739,
26,
450,
83,
2,
450,
2884,
1173,
9,
339,
14309,
272,
312,
7733,
275,
747,
14,
515,
14,
904,
8,
79,
3567,
985,
12,
298,
1375,
13,
1579,
14,
3596,
531,
272,
2218,
16797,
3046,
1173,
8,
79,
7733,
12,
10554,
12,
2884,
5866,
12,
2884,
21261,
12,
715,
9,
339,
14309,
272,
312,
7733,
275,
747,
14,
515,
14,
904,
8,
79,
3567,
985,
12,
298,
1375,
13,
1579,
13,
827,
14,
3596,
531,
272,
2218,
16797,
3046,
1173,
8,
79,
7733,
12,
10554,
12,
2884,
5866,
12,
2884,
4649,
12,
756,
9,
199,
199,
7656,
375,
199,
318,
2218,
16797,
3046,
1173,
8,
79,
7733,
12,
10554,
12,
2884,
5866,
12,
2928,
83,
12,
675,
10006,
304,
272,
2385,
275,
942,
2286,
4190,
1173,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
21777,
401,
298,
3961,
13,
1291,
14,
3596,
531,
2286,
543,
1551,
8,
1682,
1173,
12,
298,
82,
531,
465,
284,
1173,
26,
267,
2385,
14,
740,
8,
73,
1173,
14,
739,
1012,
15567,
2385,
14,
740,
480,
27,
8,
1593,
29466,
531,
339,
367,
2884,
315,
10554,
26,
398,
2928,
258,
275,
2928,
83,
59,
1579,
61,
267,
2928,
985,
275,
2884,
5866,
59,
1579,
61,
267,
340,
440,
675,
10006,
26,
288,
2385,
14,
740,
21816,
450,
83,
2,
450,
2928,
985,
9,
288,
2385,
14,
740,
8,
2164,
9,
288,
2385,
14,
740,
480,
15027,
267,
587,
26,
288,
2928,
275,
2071,
83,
60,
78,
501,
32,
1350,
2632,
2458,
83,
2,
450,
334,
2164,
12,
2928,
985,
9,
288,
2385,
14,
740,
480,
27,
2579,
4042,
83,
2924,
450,
2022,
14,
4180,
8,
2164,
430,
398,
340,
2928,
985,
508,
298,
1494,
74,
546,
352,
14,
3596,
582,
288,
2385,
14,
740,
480,
1494,
74,
546,
352,
14,
4365,
360,
1494,
74,
546,
352,
1959,
4050,
3314,
25122,
13902,
8,
2052,
2736,
531,
288,
340,
440,
675,
10006,
26,
355,
2385,
14,
740,
10804,
339,
2385,
14,
740,
21816,
3413,
74,
546,
352,
14,
4365,
360,
1129,
262,
264,
15,
2330,
15,
6004,
262,
264,
1959,
2384,
14278,
7303,
531,
272,
2385,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
lablup/backend.ai-manager
|
src/ai/backend/manager/models/alembic/versions/26d0c387e764_create_vfolder_invitations_table.py
|
2
|
1284
|
"""create vfolder_invitations table
Revision ID: 26d0c387e764
Revises: f8a71c3bffa2
Create Date: 2018-07-04 14:57:46.517587
"""
from alembic import op
import sqlalchemy as sa
from ai.backend.manager.models.base import GUID
# revision identifiers, used by Alembic.
revision = '26d0c387e764'
down_revision = 'f8a71c3bffa2'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
'vfolder_invitations',
sa.Column('id', GUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
sa.Column('permission', sa.String(length=2), nullable=True),
sa.Column('invitee', sa.String(length=256), nullable=False),
sa.Column('vfolder', GUID(), nullable=False),
sa.ForeignKeyConstraint(['vfolder'], ['vfolders.id'],
name=op.f('fk_vfolder_invitations_vfolder_vfolders'),
onupdate='CASCADE', ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('pk_vfolder_invitations'))
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('vfolder_invitations')
# ### end Alembic commands ###
|
lgpl-3.0
|
[
624,
981,
373,
3741,
63,
5350,
390,
1298,
1817,
199,
199,
12714,
2870,
26,
7875,
68,
16,
67,
12399,
69,
29871,
199,
497,
433,
874,
26,
289,
24,
65,
3172,
67,
19,
66,
556,
65,
18,
199,
2499,
6148,
26,
14894,
13,
1780,
13,
966,
4329,
26,
1641,
26,
2466,
14,
21,
10848,
1555,
199,
199,
624,
199,
504,
30960,
20596,
492,
1687,
199,
646,
8335,
465,
2937,
199,
504,
15933,
14,
4620,
14,
2609,
14,
992,
14,
1095,
492,
21645,
421,
199,
3,
6974,
14154,
12,
1202,
701,
6832,
20596,
14,
199,
5792,
275,
283,
1479,
68,
16,
67,
12399,
69,
29871,
7,
199,
2110,
63,
5792,
275,
283,
70,
24,
65,
3172,
67,
19,
66,
556,
65,
18,
7,
199,
4694,
63,
3512,
275,
488,
199,
8912,
63,
265,
275,
488,
421,
199,
318,
10754,
837,
272,
327,
6754,
3718,
2599,
4046,
701,
6832,
20596,
446,
8749,
11311,
1,
6754,
272,
1687,
14,
981,
63,
1224,
8,
267,
283,
86,
3741,
63,
5350,
390,
1298,
297,
267,
2937,
14,
4547,
360,
344,
297,
21645,
1062,
1654,
63,
885,
29,
2231,
14,
505,
360,
2580,
63,
4208,
63,
86,
20,
21898,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
5693,
297,
2937,
14,
1558,
8,
1267,
29,
18,
395,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
19061,
69,
297,
2937,
14,
1558,
8,
1267,
29,
3912,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
86,
3741,
297,
21645,
1062,
7854,
29,
797,
395,
267,
2937,
14,
3190,
8463,
2941,
86,
3741,
995,
788,
86,
15171,
14,
344,
995,
1816,
536,
29,
411,
14,
70,
360,
9010,
63,
86,
3741,
63,
5350,
390,
1298,
63,
86,
3741,
63,
86,
15171,
659,
1816,
641,
873,
534,
10855,
297,
16549,
534,
10855,
659,
267,
2937,
14,
29457,
8463,
360,
344,
297,
536,
29,
411,
14,
70,
360,
2051,
63,
86,
3741,
63,
5350,
390,
1298,
1333,
272,
776,
272,
327,
6754,
1284,
6832,
20596,
3718,
6754,
421,
199,
318,
32498,
837,
272,
327,
6754,
3718,
2599,
4046,
701,
6832,
20596,
446,
8749,
11311,
1,
6754,
272,
1687,
14,
4824,
63,
1224,
360,
86,
3741,
63,
5350,
390,
1298,
358,
272,
327,
6754,
1284,
6832,
20596,
3718,
6754,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
981,
373,
3741,
63,
5350,
390,
1298,
1817,
199,
199,
12714,
2870,
26,
7875,
68,
16,
67,
12399,
69,
29871,
199,
497,
433,
874,
26,
289,
24,
65,
3172,
67,
19,
66,
556,
65,
18,
199,
2499,
6148,
26,
14894,
13,
1780,
13,
966,
4329,
26,
1641,
26,
2466,
14,
21,
10848,
1555,
199,
199,
624,
199,
504,
30960,
20596,
492,
1687,
199,
646,
8335,
465,
2937,
199,
504,
15933,
14,
4620,
14,
2609,
14,
992,
14,
1095,
492,
21645,
421,
199,
3,
6974,
14154,
12,
1202,
701,
6832,
20596,
14,
199,
5792,
275,
283,
1479,
68,
16,
67,
12399,
69,
29871,
7,
199,
2110,
63,
5792,
275,
283,
70,
24,
65,
3172,
67,
19,
66,
556,
65,
18,
7,
199,
4694,
63,
3512,
275,
488,
199,
8912,
63,
265,
275,
488,
421,
199,
318,
10754,
837,
272,
327,
6754,
3718,
2599,
4046,
701,
6832,
20596,
446,
8749,
11311,
1,
6754,
272,
1687,
14,
981,
63,
1224,
8,
267,
283,
86,
3741,
63,
5350,
390,
1298,
297,
267,
2937,
14,
4547,
360,
344,
297,
21645,
1062,
1654,
63,
885,
29,
2231,
14,
505,
360,
2580,
63,
4208,
63,
86,
20,
21898,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
5693,
297,
2937,
14,
1558,
8,
1267,
29,
18,
395,
7854,
29,
549,
395,
267,
2937,
14,
4547,
360,
19061,
69,
297,
2937,
14,
1558,
8,
1267,
29,
3912,
395,
7854,
29,
797,
395,
267,
2937,
14,
4547,
360,
86,
3741,
297,
21645,
1062,
7854,
29,
797,
395,
267,
2937,
14,
3190,
8463,
2941,
86,
3741,
995,
788,
86,
15171,
14,
344,
995,
1816,
536,
29,
411,
14,
70,
360,
9010,
63,
86,
3741,
63,
5350,
390,
1298,
63,
86,
3741,
63,
86,
15171,
659,
1816,
641,
873,
534,
10855,
297,
16549,
534,
10855,
659,
267,
2937,
14,
29457,
8463,
360,
344,
297,
536,
29,
411,
14,
70,
360,
2051,
63,
86,
3741,
63,
5350,
390,
1298,
1333,
272,
776,
272,
327,
6754,
1284,
6832,
20596,
3718,
6754,
421,
199,
318,
32498,
837,
272,
327,
6754,
3718,
2599,
4046,
701,
6832,
20596,
446,
8749,
11311,
1,
6754,
272,
1687,
14,
4824,
63,
1224,
360,
86,
3741,
63,
5350,
390,
1298,
358,
272,
327,
6754,
1284,
6832,
20596,
3718,
6754,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
dagargo/phatty
|
phatty/editor.py
|
1
|
32769
|
# -*- coding: utf-8 -*-
#
# Copyright 2017 David García Goñi
#
# This file is part of Phatty.
#
# Phatty 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.
#
# Phatty 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 Phatty. If not, see <http://www.gnu.org/licenses/>.
"""Phatty user interface"""
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject
from gi.repository import GLib
from threading import Thread, Lock
import logging
import pkg_resources
from phatty import connector
from phatty.connector import ConnectorError
from phatty import preset
from phatty import utils
import sys
import getopt
import mido
GLib.threads_init()
CONN_MSG = 'Connected (firmware version {:s})'
ERROR_IN_BANK_TRANSFER = 'Error in bank transfer {:s}'
ERROR_WHILE_SAVING_DATA = 'Error while saving data to {:s}'
ERROR_WHILE_READING_DATA = 'Error while reading data from {:s}'
glade_file = pkg_resources.resource_filename(__name__, 'resources/gui.glade')
init_preset_file = pkg_resources.resource_filename(
__name__, 'resources/init_preset.syx')
version = pkg_resources.get_distribution(utils.APP_NAME).version
def print_help():
print('Usage: {:s} [-v]'.format(utils.APP_NAME))
log_level = logging.ERROR
try:
opts, args = getopt.getopt(sys.argv[1:], "hv")
except getopt.GetoptError:
print_help()
sys.exit(1)
for opt, arg in opts:
if opt == '-h':
print_help()
sys.exit()
elif opt == '-v':
log_level = logging.DEBUG
logging.basicConfig(level=log_level)
logger = logging.getLogger(__name__)
utils.create_config()
builder = Gtk.Builder()
builder.add_from_file(glade_file)
class TransferDialog(object):
def __init__(self, parent):
self.dialog = builder.get_object('transfer_dialog')
self.label = builder.get_object('transfer_label')
self.progressbar = builder.get_object('progressbar')
self.button = builder.get_object('transfer_cancel')
self.dialog.set_transient_for(parent)
self.dialog.connect('delete-event', lambda widget,
event: self.cancel() or True)
self.button.connect('clicked', lambda widget: self.cancel())
def show(self, title):
self.dialog.set_title(title)
self.running = True
self.progressbar.set_fraction(0)
self.dialog.show()
def show_fraction(self, title):
self.button.show()
self.show(title)
def show_pulse(self, title):
self.label.set_text('')
self.button.hide()
self.pulsating = True
self.show(title)
def cancel(self):
self.running = False
self.pulsating = False
def hide(self):
self.dialog.hide()
def set_status(self, msg, fraction):
self.label.set_text(msg)
self.progressbar.set_fraction(fraction)
def pulse_progressbar(self):
self.progressbar.pulse()
if self.running:
return self.pulsating
else:
return False
class SettingsDialog(object):
def __init__(self, phatty):
self.phatty = phatty
self.dialog = builder.get_object('settings_dialog')
self.accept = builder.get_object('settings_accept_button')
self.cancel = builder.get_object('settings_cancel_button')
self.bulk_switch = builder.get_object('bulk_switch')
self.auto_switch = builder.get_object('auto_switch')
self.dialog.set_transient_for(phatty.main_window)
self.dialog.connect('delete-event', lambda widget,
event: widget.hide() or True)
self.cancel.connect('clicked', lambda widget: self.dialog.hide())
self.accept.connect('clicked', lambda widget: self.save())
def show(self):
self.bulk_switch.set_active(self.phatty.config[utils.BULK_ON])
self.auto_switch.set_active(self.phatty.config[utils.DOWNLOAD_AUTO])
self.dialog.show()
def save(self):
self.phatty.config[utils.BULK_ON] = self.bulk_switch.get_active()
self.phatty.config[utils.DOWNLOAD_AUTO] = self.auto_switch.get_active()
self.dialog.hide()
class Editor(object):
"""Phatty user interface"""
def __init__(self):
self.connector = connector.Connector()
self.main_window = None
self.sysex_presets = []
self.config = utils.read_config()
self.transferring = Lock()
def load_devices(self, select):
self.device_liststore.clear()
i = 0
found = -1
for port in connector.get_ports():
logger.debug('Adding port {:s}...'.format(port))
self.device_liststore.append([port])
if self.config[utils.DEVICE] == port and select:
logger.debug('Port {:s} is active'.format(port))
found = i
i += 1
self.device_combo.set_active(found)
if select and self.device_combo.get_active() == -1:
self.ui_reconnect()
def set_ui_config(self):
self.configuring = True
self.load_devices(True)
self.lfo_midi_sync.set_state(self.config[utils.LFO_MIDI_SYNC])
self.configuring = False
def save_config(self):
logger.debug('Configuration: {:s}'.format(str(self.config)))
utils.write_config(self.config)
def init_ui(self):
self.main_window = builder.get_object('main_window')
self.main_window.connect(
'delete-event', lambda widget, event: self.quit())
self.main_window.set_position(Gtk.WindowPosition.CENTER)
self.main_container = builder.get_object('main_container')
self.about_dialog = builder.get_object('about_dialog')
self.about_dialog.set_version(version)
self.device_combo = builder.get_object('device_combo')
self.device_combo.connect('changed', lambda widget: self.set_device())
self.device_liststore = builder.get_object('device_liststore')
self.refresh_button = builder.get_object('refresh_button')
self.refresh_button.connect(
'clicked', lambda widget: self.load_devices(False))
# These are global parameters and hence are neither is stored in
# presets nor its value can be recalled
self.lfo_midi_sync = builder.get_object('lfo_midi_sync')
self.lfo_midi_sync.connect('state-set', lambda widget, state: self.set_lfo_midi_sync(state))
self.download_button = builder.get_object('download_button')
self.download_button.connect(
'clicked', lambda widget: self.download_presets())
self.upload_button = builder.get_object('upload_button')
self.upload_button.connect(
'clicked', lambda widget: self.upload_presets())
self.upload_button.set_sensitive(False)
self.about_button = builder.get_object('about_button')
self.about_button.connect('clicked', lambda widget: self.show_about())
self.preferences_button = builder.get_object('preferences_button')
self.preferences_button.connect(
'clicked', lambda widget: self.settings_dialog.show())
self.open_button = builder.get_object('open_button')
self.open_button.connect(
'clicked', lambda widget: self.open_bank_from_file())
self.save_button = builder.get_object('save_button')
self.save_button.connect(
'clicked', lambda widget: self.save_bank_to_file())
self.statusbar = builder.get_object('statusbar')
self.context_id = self.statusbar.get_context_id(utils.APP_NAME)
self.preset_list = builder.get_object('preset_list')
self.presets = builder.get_object('preset_liststore')
self.preset_selection = builder.get_object('preset_selection')
self.presets.connect('row-deleted', self.row_deleted)
self.preset_selection.connect('changed', self.selection_changed)
self.preset_name_renderer = builder.get_object(
'preset_name_renderer')
self.preset_name_renderer.connect('edited', self.set_preset_name)
self.transfer_dialog = TransferDialog(self.main_window)
self.settings_dialog = SettingsDialog(self)
# Filter and envelopes
self.filter_poles = builder.get_object('filter_poles')
self.filter_poles.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_filter_poles,
int(self.filter_poles.get_value() - 1)))
self.vel_to_filter = builder.get_object('vel_to_filter')
self.vel_to_filter.connect('value-changed', lambda widget: self.call_connector(
self.connector.set_panel_vel_to_filter,
int(self.vel_to_filter.get_value() + 8)))
self.vel_to_amp = builder.get_object('vel_to_amp')
self.vel_to_amp.connect('value-changed', lambda widget: self.call_connector(
self.connector.set_panel_vel_to_amp,
int(self.vel_to_amp.get_value())))
self.release = builder.get_object('release')
self.release.connect('state-set', lambda widget, state: self.call_connector(
self.connector.set_panel_release,
1 if state else 0))
# Keyboard and controls
self.scale = builder.get_object('scale')
self.scale.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_scale,
self.scale.get_active()))
self.pw_up_amount = builder.get_object('pw_up_amount')
self.pw_up_amount.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_pw_up_amount,
self.pw_up_amount.get_active()))
self.pw_down_amount = builder.get_object('pw_down_amount')
self.pw_down_amount.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_pw_down_amount,
self.pw_down_amount.get_active()))
self.legato = builder.get_object('legato')
self.legato.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_legato,
self.legato.get_active()))
self.keyboard_priority = builder.get_object('keyboard_priority')
self.keyboard_priority.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_keyboard_priority,
self.keyboard_priority.get_active()))
self.glide_on_legato = builder.get_object('glide_on_legato')
self.glide_on_legato.connect('state-set', lambda widget, state: self.call_connector(
self.connector.set_panel_glide_on_legato,
1 if state else 0))
# Modulation parameters
self.mod_source_5 = builder.get_object('mod_source_5')
self.mod_source_5.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_mod_source_5,
self.mod_source_5.get_active()))
self.mod_source_6 = builder.get_object('mod_source_6')
self.mod_source_6.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_mod_source_6,
self.mod_source_6.get_active()))
self.mod_dest_2 = builder.get_object('mod_dest_2')
self.mod_dest_2.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_mod_dest_2,
self.mod_dest_2.get_active()))
self.lfo_key_retrigger = builder.get_object('lfo_key_retrigger')
self.lfo_key_retrigger.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_lfo_key_retrigger,
self.lfo_key_retrigger.get_active()))
# Arpeggiator
self.arp_pattern = builder.get_object('arp_pattern')
self.arp_pattern.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_arp_pattern,
self.arp_pattern.get_active()))
self.arp_mode = builder.get_object('arp_mode')
self.arp_mode.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_arp_mode,
self.arp_mode.get_active()))
self.arp_octaves = builder.get_object('arp_octaves')
self.arp_octaves.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_arp_octaves,
int(self.arp_octaves.get_value() + 3)))
self.arp_gate = builder.get_object('arp_gate')
self.arp_gate.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_arp_gate,
self.arp_gate.get_active()))
self.arp_clock_source = builder.get_object('arp_clock_source')
self.arp_clock_source.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_arp_clock_source,
self.arp_clock_source.get_active()))
self.arp_clock_division = builder.get_object('arp_clock_division')
self.arp_clock_division.connect('changed', lambda widget: self.call_connector(
self.connector.set_panel_arp_clock_division,
self.arp_clock_division.get_active()))
# Preset buttons
self.download_panel = builder.get_object('download_panel')
self.download_panel.connect(
'clicked', lambda widget: self.get_panel())
self.download_preset = builder.get_object('download_preset')
self.download_preset.connect(
'clicked', lambda widget: self.get_preset())
self.upload_preset = builder.get_object('upload_preset')
self.upload_preset.connect('clicked', lambda widget: self.set_preset())
self.save_preset = builder.get_object('save_preset')
self.save_preset.connect(
'clicked', lambda widget: self.save_current_preset())
self.open_preset = builder.get_object('open_preset')
self.open_preset.connect(
'clicked', lambda widget: self.open_into_current_preset())
self.reset_preset = builder.get_object('reset_preset')
self.reset_preset.connect(
'clicked', lambda widget: self.reset_current_preset())
self.filter_syx = Gtk.FileFilter()
self.filter_syx.set_name('MIDI sysex')
self.filter_syx.add_pattern('*.' + preset.FILE_EXTENSION)
self.filter_syx.add_pattern('*.' + preset.FILE_EXTENSION_EX)
self.filter_any = Gtk.FileFilter()
self.filter_any.set_name('Any files')
self.filter_any.add_pattern('*')
self.main_window.present()
def get_panel(self):
model, iter = self.preset_selection.get_selected()
active_preset = model[iter][0]
try:
panel = self.connector.get_panel_as_preset(active_preset)
self.sysex_presets[active_preset] = panel
self.presets[active_preset][1] = preset.get_name(panel)
self.set_preset_attributes(active_preset)
except ConnectorError as e:
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
def get_preset(self):
model, iter = self.preset_selection.get_selected()
active_preset = model[iter][0]
try:
p = self.connector.get_preset(active_preset)
self.sysex_presets[active_preset] = p
self.presets[active_preset][1] = preset.get_name(p)
self.set_preset_attributes(active_preset)
except ConnectorError as e:
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
def set_preset(self):
model, iter = self.preset_selection.get_selected()
active_preset = model[iter][0]
try:
self.connector.tx_message(self.sysex_presets[active_preset])
except ConnectorError as e:
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
def save_current_preset(self):
model, iter = self.preset_selection.get_selected()
active_preset = model[iter][0]
def_filename = model[iter][1].strip() + '.syx'
dialog = Gtk.FileChooserDialog('Save as', self.main_window,
Gtk.FileChooserAction.SAVE,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
Gtk.FileChooser.set_do_overwrite_confirmation(dialog, True)
dialog.add_filter(self.filter_syx)
dialog.add_filter(self.filter_any)
dialog.set_current_name(def_filename)
response = dialog.run()
filename = dialog.get_filename()
dialog.destroy()
if response == Gtk.ResponseType.OK:
try:
data = self.sysex_presets[active_preset]
self.connector.write_data_to_file(filename, data)
except IOError as e:
msg = ERROR_WHILE_SAVING_DATA.format(filename)
desc = str(e)
GLib.idle_add(self.show_error_dialog, msg, desc)
def open_into_current_preset(self):
dialog = Gtk.FileChooserDialog('Open', self.main_window,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
dialog.add_filter(self.filter_syx)
dialog.add_filter(self.filter_any)
response = dialog.run()
filename = dialog.get_filename()
dialog.destroy()
if response == Gtk.ResponseType.OK:
self.override_preset(filename)
def override_preset(self, filename):
logger.debug('Overriding selected preset with file {:s}'.format(filename))
try:
data = self.connector.read_data_from_file(filename)
model, iter = self.preset_selection.get_selected()
active_preset = model[iter][0]
preset.set_number(data, active_preset)
self.sysex_presets[active_preset] = data
model[iter][1] = preset.get_name(data)
self.set_preset_attributes(active_preset)
self.connector.tx_message(data)
except (IOError, ConnectorError) as e:
msg = ERROR_WHILE_READING_DATA.format(filename)
desc = str(e)
GLib.idle_add(self.show_error_dialog, msg, desc)
def reset_current_preset(self):
self.override_preset(init_preset_file)
def set_preset_attributes(self, id):
active_preset = self.sysex_presets[id]
# Filter and amp
filter_poles = preset.get_filter_poles(active_preset)
self.filter_poles.set_value(filter_poles + 1)
vel_to_filter = preset.get_vel_to_filter(active_preset) - 8
self.vel_to_filter.set_value(vel_to_filter)
vel_to_amp = preset.get_vel_to_amp(active_preset)
self.vel_to_amp.set_value(vel_to_amp)
release = preset.get_release(active_preset)
self.release.set_active(True if release == 1 else False)
# Keyboard and controls
scale = preset.get_scale(active_preset)
self.scale.set_active(scale)
pw_up_amount = preset.get_pw_up_amount(active_preset)
self.pw_up_amount.set_active(pw_up_amount)
pw_down_amount = preset.get_pw_down_amount(active_preset)
self.pw_down_amount.set_active(pw_down_amount)
legato = preset.get_legato(active_preset)
self.legato.set_active(legato)
keyboard_priority = preset.get_keyboard_priority(active_preset)
self.keyboard_priority.set_active(keyboard_priority)
glide_on_legato = preset.get_glide_on_legato(active_preset)
self.glide_on_legato.set_active(
True if glide_on_legato == 1 else False)
# Modulation
mod_source_5 = preset.get_mod_source_5(active_preset)
self.mod_source_5.set_active(mod_source_5)
mod_source_6 = preset.get_mod_source_6(active_preset)
self.mod_source_6.set_active(mod_source_6)
mod_dest_2 = preset.get_mod_dest_2(active_preset)
self.mod_dest_2.set_active(mod_dest_2)
lfo_key_retrigger = preset.get_lfo_key_retrigger(active_preset)
self.lfo_key_retrigger.set_active(lfo_key_retrigger)
# Arpeggiator
arp_pattern = preset.get_arp_pattern(active_preset)
self.arp_pattern.set_active(arp_pattern)
arp_mode = preset.get_arp_mode(active_preset)
self.arp_mode.set_active(arp_mode)
arp_octaves = preset.get_arp_octaves(active_preset)
self.arp_octaves.set_value(arp_octaves - 3)
arp_gate = preset.get_arp_gate(active_preset)
self.arp_gate.set_active(arp_gate)
arp_clock_source = preset.get_arp_clock_source(active_preset)
self.arp_clock_source.set_active(arp_clock_source)
arp_clock_division = preset.get_arp_clock_division(active_preset)
self.arp_clock_division.set_active(arp_clock_division)
def selection_changed(self, selection):
model, iter = selection.get_selected()
if iter:
id = model[iter][0]
logger.debug('Preset {:d} selected'.format(id))
try:
self.connector.set_preset(id)
self.set_preset_attributes(id)
except ConnectorError as e:
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
def row_deleted(self, tree_model, path):
if not self.transferring.locked():
logger.debug('Reordering...')
new_sysex_presets = []
for i in range(connector.MAX_PRESETS):
sysex_preset = self.sysex_presets[self.presets[i][0]]
preset.set_number(sysex_preset, i)
new_sysex_presets.append(sysex_preset)
self.presets[i][0] = i
self.sysex_presets = new_sysex_presets
def set_preset_name(self, widget, row, name):
logger.debug('Changing preset name...')
active_preset = int(row)
normalized_name = preset.normalize_name(name)
self.presets[active_preset][1] = normalized_name
preset.set_name(self.sysex_presets[active_preset], normalized_name)
try:
self.connector.set_panel_name(normalized_name)
except ConnectorError as e:
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
def connect(self):
device = self.config[utils.DEVICE]
self.connector.connect(device, self.connect_callback)
if self.connector.connected():
conn_msg = CONN_MSG.format(self.connector.sw_version)
self.set_status_msg(conn_msg)
else:
self.set_status_msg('Not connected')
def ui_reconnect(self):
self.connect()
self.set_ui()
def set_ui(self):
if self.connector.connected():
if self.config[utils.DOWNLOAD_AUTO]:
self.download_presets()
self.set_sensitivities()
def set_sensitivities(self):
for c in [self.open_button, self.save_button, self.download_button, self.lfo_midi_sync]:
c.set_sensitive(self.connector.connected())
for c in [self.main_container, self.upload_button, self.download_panel, self.download_preset, self.upload_preset, self.save_preset, self.open_preset, self.reset_preset]:
c.set_sensitive(self.connector.connected()
and len(self.sysex_presets) > 0)
def download_presets(self):
logger.debug('Starting download thread...')
self.preset_selection.unselect_all()
self.transfer_dialog.show_fraction('Downloading presets')
self.transferring.acquire()
self.presets.clear()
self.sysex_presets.clear()
self.thread = Thread(target=self.do_download)
self.thread.start()
def do_download(self):
try:
for i in range(connector.MAX_PRESETS):
if not self.transfer_dialog.running:
logger.debug('Cancelling download...')
break
msg = 'Downloading preset {:d}...'.format(i)
logger.debug(msg)
fraction = (i + 1) / connector.MAX_PRESETS
GLib.idle_add(self.transfer_dialog.set_status, msg, fraction)
p = self.connector.get_preset(i)
preset_name = preset.get_name(p)
GLib.idle_add(self.add_preset, i, preset_name)
self.sysex_presets.append(p)
except ConnectorError as e:
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
GLib.idle_add(self.end_download)
def add_preset(self, number, name):
self.presets.append([number, name])
def end_download(self):
if not self.transfer_dialog.running:
self.presets.clear()
self.sysex_presets.clear()
self.thread.join()
logger.debug('Thread finished')
self.upload_button.set_sensitive(len(self.sysex_presets) > 0)
self.transferring.release()
self.transfer_dialog.hide()
self.preset_list.set_cursor(0)
self.set_sensitivities()
def upload_presets(self):
logger.debug('Starting upload thread...')
self.transfer_dialog.show_fraction("Uploading presets")
self.transferring.acquire()
self.thread = Thread(target=self.do_upload)
self.thread.start()
def do_upload(self):
try:
for i in range(connector.MAX_PRESETS):
if not self.transfer_dialog.running:
logger.debug('Cancelling upload...')
break
msg = 'Uploading preset {:d}...'.format(i)
logger.debug(msg)
fraction = (i + 1) / connector.MAX_PRESETS
GLib.idle_add(self.transfer_dialog.set_status, msg, fraction)
self.connector.tx_message(self.sysex_presets[i])
except ConnectorError as e:
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
GLib.idle_add(self.end_upload)
def end_upload(self):
self.thread.join()
logger.debug('Thread finished')
self.transferring.release()
self.transfer_dialog.hide()
def set_status_msg(self, msg):
logger.info(msg)
if self.main_window:
self.statusbar.pop(self.context_id)
self.statusbar.push(self.context_id, msg)
def open_bank_from_file(self):
dialog = Gtk.FileChooserDialog('Open', self.main_window,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
dialog.add_filter(self.filter_syx)
dialog.add_filter(self.filter_any)
response = dialog.run()
filename = dialog.get_filename()
dialog.destroy()
if response == Gtk.ResponseType.OK:
self.transfer_dialog.show_pulse('Sending bank')
GLib.timeout_add(50, self.transfer_dialog.pulse_progressbar)
self.thread = Thread(
target=self.set_bank_from_file, args=(filename,))
self.thread.start()
def set_bank_from_file(self, filename):
try:
self.connector.set_bank_from_file(filename)
self.cancel_and_hide_transfer()
GLib.idle_add(self.download_presets)
except (ValueError) as e:
self.cancel_and_hide_transfer()
msg = ERROR_IN_BANK_TRANSFER.format(filename)
desc = str(e)
GLib.idle_add(self.show_error_dialog, msg, desc)
except ConnectorError as e:
self.cancel_and_hide_transfer()
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
def save_bank_to_file(self):
type = 'bulk' if self.config[utils.BULK_ON] else 'bank'
title = 'Receiving {:s}'.format(type)
self.transfer_dialog.show_pulse(title)
GLib.timeout_add(50, self.transfer_dialog.pulse_progressbar)
self.thread = Thread(target=self.get_bank_and_save)
self.thread.start()
def get_bank_and_save(self):
try:
if self.config[utils.BULK_ON]:
data = self.connector.get_bulk()
def_filename = 'bulk.' + preset.FILE_EXTENSION
else:
data = self.connector.get_bank()
def_filename = 'bank.' + preset.FILE_EXTENSION
self.cancel_and_hide_transfer()
GLib.idle_add(self.ask_filename_and_save, def_filename, data)
except ConnectorError as e:
self.cancel_and_hide_transfer()
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
def ask_filename_and_save(self, def_filename, data):
dialog = Gtk.FileChooserDialog('Save as', self.main_window,
Gtk.FileChooserAction.SAVE,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
Gtk.FileChooser.set_do_overwrite_confirmation(dialog, True)
dialog.add_filter(self.filter_syx)
dialog.add_filter(self.filter_any)
dialog.set_current_name(def_filename)
response = dialog.run()
filename = dialog.get_filename()
dialog.destroy()
if response == Gtk.ResponseType.OK:
try:
self.connector.write_data_to_file(filename, data)
except IOError as e:
msg = ERROR_WHILE_SAVING_DATA.format(filename)
desc = str(e)
GLib.idle_add(self.show_error_dialog, msg, desc)
def cancel_and_hide_transfer(self):
self.transfer_dialog.cancel()
GLib.idle_add(self.transfer_dialog.hide)
GLib.idle_add(self.thread.join)
def show_error_dialog(self, msg, desc):
dialog = Gtk.MessageDialog(self.main_window,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.OK,
message_format=msg)
dialog.connect(
'response', lambda widget, response: widget.destroy())
dialog.format_secondary_text(desc)
logger.error(desc)
dialog.run()
dialog.destroy()
def call_connector(self, method, *args):
logger.debug('Calling connector {:s}...'.format(str(method)))
try:
method(*args)
except ConnectorError as e:
GLib.idle_add(self.show_error_dialog, str(e), None)
self.ui_reconnect()
def show_about(self):
self.about_dialog.run()
self.about_dialog.hide()
def set_device(self):
active = self.device_combo.get_active()
if active > -1:
device = self.device_liststore[active][0]
else:
device = ''
self.config[utils.DEVICE] = device
self.ui_reconnect()
def connect_callback(self, message):
self.call_connector(self.connector.set_lfo_midi_sync, 1 if self.config[utils.LFO_MIDI_SYNC] else 0)
if message.type == 'program_change':
program = message.program
logger.debug('Preset {:d} selected'.format(program))
if program >= 0 and program < connector.MAX_PRESETS and self.presets:
self.preset_selection.disconnect_by_func(
self.selection_changed)
self.preset_list.set_cursor(program)
self.preset_selection.connect(
'changed', self.selection_changed)
def set_lfo_midi_sync(self, state):
self.config[utils.LFO_MIDI_SYNC] = state
if not self.configuring:
self.call_connector(self.connector.set_lfo_midi_sync, 1 if state else 0)
def quit(self):
logger.debug('Quitting...')
self.connector.disconnect()
self.main_window.hide()
Gtk.main_quit()
def main(self):
self.init_ui()
self.set_ui_config()
Gtk.main()
self.save_config()
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
9708,
20232,
598,
9912,
13676,
65,
3971,
22692,
73,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
510,
8554,
369,
14,
199,
3,
199,
3,
510,
8554,
369,
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,
510,
8554,
369,
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,
510,
8554,
369,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
5663,
16623,
922,
3217,
624,
199,
199,
646,
18895,
199,
6153,
14,
4365,
63,
1023,
360,
18891,
297,
283,
19,
14,
16,
358,
199,
504,
18895,
14,
8421,
492,
11424,
12,
31264,
199,
504,
18895,
14,
8421,
492,
3563,
1892,
199,
504,
5796,
492,
11086,
12,
15536,
199,
646,
2050,
199,
646,
5496,
63,
4435,
199,
504,
3945,
16623,
492,
13252,
199,
504,
3945,
16623,
14,
11815,
492,
13482,
2406,
547,
199,
504,
3945,
16623,
492,
876,
409,
199,
504,
3945,
16623,
492,
3778,
199,
646,
984,
199,
646,
12733,
199,
646,
10887,
79,
199,
199,
2226,
1892,
14,
6962,
63,
826,
342,
199,
199,
17489,
63,
9740,
275,
283,
16382,
334,
26374,
1015,
19850,
83,
29668,
199,
3170,
63,
568,
63,
34,
15874,
63,
12191,
15849,
275,
283,
547,
315,
16297,
9307,
19850,
83,
6834,
199,
3170,
63,
9792,
8453,
63,
4251,
54,
1206,
63,
3998,
275,
283,
547,
1830,
13369,
666,
370,
19850,
83,
6834,
199,
3170,
63,
9792,
8453,
63,
5670,
1206,
63,
3998,
275,
283,
547,
1830,
7664,
666,
687,
19850,
83,
6834,
199,
199,
31589,
63,
493,
275,
5496,
63,
4435,
14,
1927,
63,
1501,
3460,
354,
3108,
283,
4435,
15,
5885,
14,
31589,
358,
199,
826,
63,
25701,
63,
493,
275,
5496,
63,
4435,
14,
1927,
63,
1501,
8,
272,
636,
354,
3108,
283,
4435,
15,
826,
63,
25701,
14,
1786,
88,
358,
199,
1023,
275,
5496,
63,
4435,
14,
362,
63,
4972,
8,
1208,
14,
7121,
63,
2339,
680,
1023,
421,
199,
318,
870,
63,
3437,
837,
272,
870,
360,
7692,
26,
19850,
83,
93,
5243,
86,
61,
1370,
908,
8,
1208,
14,
7121,
63,
2339,
430,
199,
199,
793,
63,
1896,
275,
2050,
14,
3170,
199,
893,
26,
272,
3999,
12,
1249,
275,
12733,
14,
18907,
8,
1274,
14,
3020,
59,
17,
8429,
298,
22926,
531,
199,
2590,
12733,
14,
1002,
29368,
26,
272,
870,
63,
3437,
342,
272,
984,
14,
2224,
8,
17,
9,
199,
509,
2450,
12,
1680,
315,
3999,
26,
272,
340,
2450,
508,
2475,
72,
356,
267,
870,
63,
3437,
342,
267,
984,
14,
2224,
342,
272,
916,
2450,
508,
2475,
86,
356,
267,
943,
63,
1896,
275,
2050,
14,
5287,
199,
199,
4806,
14,
19602,
8,
1896,
29,
793,
63,
1896,
9,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
1208,
14,
981,
63,
888,
342,
199,
199,
5649,
275,
11424,
14,
6437,
342,
199,
5649,
14,
525,
63,
504,
63,
493,
8,
31589,
63,
493,
9,
421,
199,
533,
27507,
5619,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1676,
304,
267,
291,
14,
7196,
275,
6545,
14,
362,
63,
785,
360,
9609,
63,
7196,
358,
267,
291,
14,
1302,
275,
6545,
14,
362,
63,
785,
360,
9609,
63,
1302,
358,
267,
291,
14,
5734,
1700,
275,
6545,
14,
362,
63,
785,
360,
5734,
1700,
358,
267,
291,
14,
3887,
275,
6545,
14,
362,
63,
785,
360,
9609,
63,
6406,
358,
267,
291,
14,
7196,
14,
409,
63,
23387,
63,
509,
8,
1708,
9,
267,
291,
14,
7196,
14,
2242,
360,
1807,
13,
1430,
297,
2400,
3938,
12,
1169,
1566,
26,
291,
14,
6406,
342,
503,
715,
9,
267,
291,
14,
3887,
14,
2242,
360,
11276,
297,
2400,
3938,
26,
291,
14,
6406,
1012,
339,
347,
2498,
8,
277,
12,
2538,
304,
267,
291,
14,
7196,
14,
409,
63,
1213,
8,
1213,
9,
267,
291,
14,
5720,
275,
715,
267,
291,
14,
5734,
1700,
14,
409,
63,
13054,
8,
16,
9,
267,
291,
14,
7196,
14,
2384,
342,
339,
347,
2498,
63,
13054,
8,
277,
12,
2538,
304,
267,
291,
14,
3887,
14,
2384,
342,
267,
291,
14,
2384,
8,
1213,
9,
339,
347,
2498,
63,
19538,
8,
277,
12,
2538,
304,
267,
291,
14,
1302,
14,
409,
63,
505,
8355,
267,
291,
14,
3887,
14,
8191,
342,
267,
291,
14,
80,
348,
83,
1958,
275,
715,
267,
291,
14,
2384,
8,
1213,
9,
339,
347,
9311,
8,
277,
304,
267,
291,
14,
5720,
275,
756,
267,
291,
14,
80,
348,
83,
1958,
275,
756,
339,
347,
13714,
8,
277,
304,
267,
291,
14,
7196,
14,
8191,
342,
339,
347,
663,
63,
1205,
8,
277,
12,
1499,
12,
12347,
304,
267,
291,
14,
1302,
14,
409,
63,
505,
8,
1328,
9,
267,
291,
14,
5734,
1700,
14,
409,
63,
13054,
8,
13054,
9,
339,
347,
27949,
63,
5734,
1700,
8,
277,
304,
267,
291,
14,
5734,
1700,
14,
19538,
342,
267,
340,
291,
14,
5720,
26,
288,
372,
291,
14,
80,
348,
83,
1958,
267,
587,
26,
288,
372,
756,
421,
199,
533,
13303,
5619,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
3945,
16623,
304,
267,
291,
14,
838,
16623,
275,
3945,
16623,
267,
291,
14,
7196,
275,
6545,
14,
362,
63,
785,
360,
1751,
63,
7196,
358,
267,
291,
14,
5694,
275,
6545,
14,
362,
63,
785,
360,
1751,
63,
5694,
63,
3887,
358,
267,
291,
14,
6406,
275,
6545,
14,
362,
63,
785,
360,
1751,
63,
6406,
63,
3887
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
9708,
20232,
598,
9912,
13676,
65,
3971,
22692,
73,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
510,
8554,
369,
14,
199,
3,
199,
3,
510,
8554,
369,
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,
510,
8554,
369,
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,
510,
8554,
369,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
5663,
16623,
922,
3217,
624,
199,
199,
646,
18895,
199,
6153,
14,
4365,
63,
1023,
360,
18891,
297,
283,
19,
14,
16,
358,
199,
504,
18895,
14,
8421,
492,
11424,
12,
31264,
199,
504,
18895,
14,
8421,
492,
3563,
1892,
199,
504,
5796,
492,
11086,
12,
15536,
199,
646,
2050,
199,
646,
5496,
63,
4435,
199,
504,
3945,
16623,
492,
13252,
199,
504,
3945,
16623,
14,
11815,
492,
13482,
2406,
547,
199,
504,
3945,
16623,
492,
876,
409,
199,
504,
3945,
16623,
492,
3778,
199,
646,
984,
199,
646,
12733,
199,
646,
10887,
79,
199,
199,
2226,
1892,
14,
6962,
63,
826,
342,
199,
199,
17489,
63,
9740,
275,
283,
16382,
334,
26374,
1015,
19850,
83,
29668,
199,
3170,
63,
568,
63,
34,
15874,
63,
12191,
15849,
275,
283,
547,
315,
16297,
9307,
19850,
83,
6834,
199,
3170,
63,
9792,
8453,
63,
4251,
54,
1206,
63,
3998,
275,
283,
547,
1830,
13369,
666,
370,
19850,
83,
6834,
199,
3170,
63,
9792,
8453,
63,
5670,
1206,
63,
3998,
275,
283,
547,
1830,
7664,
666,
687,
19850,
83,
6834,
199,
199,
31589,
63,
493,
275,
5496,
63,
4435,
14,
1927,
63,
1501,
3460,
354,
3108,
283,
4435,
15,
5885,
14,
31589,
358,
199,
826,
63,
25701,
63,
493,
275,
5496,
63,
4435,
14,
1927,
63,
1501,
8,
272,
636,
354,
3108,
283,
4435,
15,
826,
63,
25701,
14,
1786,
88,
358,
199,
1023,
275,
5496,
63,
4435,
14,
362,
63,
4972,
8,
1208,
14,
7121,
63,
2339,
680,
1023,
421,
199,
318,
870,
63,
3437,
837,
272,
870,
360,
7692,
26,
19850,
83,
93,
5243,
86,
61,
1370,
908,
8,
1208,
14,
7121,
63,
2339,
430,
199,
199,
793,
63,
1896,
275,
2050,
14,
3170,
199,
893,
26,
272,
3999,
12,
1249,
275,
12733,
14,
18907,
8,
1274,
14,
3020,
59,
17,
8429,
298,
22926,
531,
199,
2590,
12733,
14,
1002,
29368,
26,
272,
870,
63,
3437,
342,
272,
984,
14,
2224,
8,
17,
9,
199,
509,
2450,
12,
1680,
315,
3999,
26,
272,
340,
2450,
508,
2475,
72,
356,
267,
870,
63,
3437,
342,
267,
984,
14,
2224,
342,
272,
916,
2450,
508,
2475,
86,
356,
267,
943,
63,
1896,
275,
2050,
14,
5287,
199,
199,
4806,
14,
19602,
8,
1896,
29,
793,
63,
1896,
9,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
1208,
14,
981,
63,
888,
342,
199,
199,
5649,
275,
11424,
14,
6437,
342,
199,
5649,
14,
525,
63,
504,
63,
493,
8,
31589,
63,
493,
9,
421,
199,
533,
27507,
5619,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1676,
304,
267,
291,
14,
7196,
275,
6545,
14,
362,
63,
785,
360,
9609,
63,
7196,
358,
267,
291,
14,
1302,
275,
6545,
14,
362,
63,
785,
360,
9609,
63,
1302,
358,
267,
291,
14,
5734,
1700,
275,
6545,
14,
362,
63,
785,
360,
5734,
1700,
358,
267,
291,
14,
3887,
275,
6545,
14,
362,
63,
785,
360,
9609,
63,
6406,
358,
267,
291,
14,
7196,
14,
409,
63,
23387,
63,
509,
8,
1708,
9,
267,
291,
14,
7196,
14,
2242,
360,
1807,
13,
1430,
297,
2400,
3938,
12,
1169,
1566,
26,
291,
14,
6406,
342,
503,
715,
9,
267,
291,
14,
3887,
14,
2242,
360,
11276,
297,
2400,
3938,
26,
291,
14,
6406,
1012,
339,
347,
2498,
8,
277,
12,
2538,
304,
267,
291,
14,
7196,
14,
409,
63,
1213,
8,
1213,
9,
267,
291,
14,
5720,
275,
715,
267,
291,
14,
5734,
1700,
14,
409,
63,
13054,
8,
16,
9,
267,
291,
14,
7196,
14,
2384,
342,
339,
347,
2498,
63,
13054,
8,
277,
12,
2538,
304,
267,
291,
14,
3887,
14,
2384,
342,
267,
291,
14,
2384,
8,
1213,
9,
339,
347,
2498,
63,
19538,
8,
277,
12,
2538,
304,
267,
291,
14,
1302,
14,
409,
63,
505,
8355,
267,
291,
14,
3887,
14,
8191,
342,
267,
291,
14,
80,
348,
83,
1958,
275,
715,
267,
291,
14,
2384,
8,
1213,
9,
339,
347,
9311,
8,
277,
304,
267,
291,
14,
5720,
275,
756,
267,
291,
14,
80,
348,
83,
1958,
275,
756,
339,
347,
13714,
8,
277,
304,
267,
291,
14,
7196,
14,
8191,
342,
339,
347,
663,
63,
1205,
8,
277,
12,
1499,
12,
12347,
304,
267,
291,
14,
1302,
14,
409,
63,
505,
8,
1328,
9,
267,
291,
14,
5734,
1700,
14,
409,
63,
13054,
8,
13054,
9,
339,
347,
27949,
63,
5734,
1700,
8,
277,
304,
267,
291,
14,
5734,
1700,
14,
19538,
342,
267,
340,
291,
14,
5720,
26,
288,
372,
291,
14,
80,
348,
83,
1958,
267,
587,
26,
288,
372,
756,
421,
199,
533,
13303,
5619,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
3945,
16623,
304,
267,
291,
14,
838,
16623,
275,
3945,
16623,
267,
291,
14,
7196,
275,
6545,
14,
362,
63,
785,
360,
1751,
63,
7196,
358,
267,
291,
14,
5694,
275,
6545,
14,
362,
63,
785,
360,
1751,
63,
5694,
63,
3887,
358,
267,
291,
14,
6406,
275,
6545,
14,
362,
63,
785,
360,
1751,
63,
6406,
63,
3887,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
lekum/ansible
|
lib/ansible/galaxy/api.py
|
82
|
5143
|
#!/usr/bin/env python
########################################################################
#
# (C) 2013, James Cammarata <jcammarata@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
import json
from urllib2 import urlopen, quote as urlquote
from urlparse import urlparse
from ansible.errors import AnsibleError
class GalaxyAPI(object):
''' This class is meant to be used as a API client for an Ansible Galaxy server '''
SUPPORTED_VERSIONS = ['v1']
def __init__(self, galaxy, api_server):
self.galaxy = galaxy
try:
urlparse(api_server, scheme='https')
except:
raise AnsibleError("Invalid server API url passed: %s" % api_server)
server_version = self.get_server_api_version('%s/api/' % (api_server))
if not server_version:
raise AnsibleError("Could not retrieve server API version: %s" % api_server)
if server_version in self.SUPPORTED_VERSIONS:
self.baseurl = '%s/api/%s' % (api_server, server_version)
self.version = server_version # for future use
self.galaxy.display.vvvvv("Base API: %s" % self.baseurl)
else:
raise AnsibleError("Unsupported Galaxy server API version: %s" % server_version)
def get_server_api_version(self, api_server):
"""
Fetches the Galaxy API current version to ensure
the API server is up and reachable.
"""
#TODO: fix galaxy server which returns current_version path (/api/v1) vs actual version (v1)
# also should set baseurl using supported_versions which has path
return 'v1'
try:
data = json.load(urlopen(api_server))
return data.get("current_version", 'v1')
except Exception as e:
# TODO: report error
return None
def lookup_role_by_name(self, role_name, notify=True):
"""
Find a role by name
"""
role_name = urlquote(role_name)
try:
parts = role_name.split(".")
user_name = ".".join(parts[0:-1])
role_name = parts[-1]
if notify:
self.galaxy.display.display("- downloading role '%s', owned by %s" % (role_name, user_name))
except:
raise AnsibleError("- invalid role name (%s). Specify role as format: username.rolename" % role_name)
url = '%s/roles/?owner__username=%s&name=%s' % (self.baseurl, user_name, role_name)
self.galaxy.display.vvvv("- %s" % (url))
try:
data = json.load(urlopen(url))
if len(data["results"]) != 0:
return data["results"][0]
except:
# TODO: report on connection/availability errors
pass
return None
def fetch_role_related(self, related, role_id):
"""
Fetch the list of related items for the given role.
The url comes from the 'related' field of the role.
"""
try:
url = '%s/roles/%d/%s/?page_size=50' % (self.baseurl, int(role_id), related)
data = json.load(urlopen(url))
results = data['results']
done = (data.get('next', None) == None)
while not done:
url = '%s%s' % (self.baseurl, data['next'])
self.galaxy.display.display(url)
data = json.load(urlopen(url))
results += data['results']
done = (data.get('next', None) == None)
return results
except:
return None
def get_list(self, what):
"""
Fetch the list of items specified.
"""
try:
url = '%s/%s/?page_size' % (self.baseurl, what)
data = json.load(urlopen(url))
if "results" in data:
results = data['results']
else:
results = data
done = True
if "next" in data:
done = (data.get('next', None) == None)
while not done:
url = '%s%s' % (self.baseurl, data['next'])
self.galaxy.display.display(url)
data = json.load(urlopen(url))
results += data['results']
done = (data.get('next', None) == None)
return results
except Exception as error:
raise AnsibleError("Failed to download the %s list: %s" % (what, str(error)))
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3949,
199,
3,
199,
3,
334,
35,
9,
6171,
12,
1603,
14015,
445,
455,
4584,
419,
665,
74,
15176,
4584,
419,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
3949,
199,
646,
2022,
199,
504,
4011,
18,
492,
18279,
12,
6313,
465,
1166,
3513,
199,
504,
7097,
492,
7097,
199,
199,
504,
3242,
14,
2550,
492,
13358,
199,
199,
533,
598,
15914,
3735,
8,
785,
304,
272,
1449,
961,
1021,
365,
18329,
370,
506,
1202,
465,
282,
3261,
1890,
367,
376,
2622,
598,
15914,
1654,
1449,
339,
32501,
63,
26358,
275,
788,
86,
17,
418,
339,
347,
636,
826,
721,
277,
12,
486,
15914,
12,
2986,
63,
1000,
304,
398,
291,
14,
24806,
275,
486,
15914,
398,
862,
26,
288,
7097,
8,
1246,
63,
1000,
12,
5687,
534,
2859,
358,
267,
871,
26,
288,
746,
13358,
480,
3364,
1654,
3261,
1166,
3032,
26,
450,
83,
2,
450,
2986,
63,
1000,
9,
398,
1654,
63,
1023,
275,
291,
14,
362,
63,
1000,
63,
1246,
63,
1023,
3508,
83,
15,
1246,
4805,
450,
334,
1246,
63,
1000,
430,
267,
340,
440,
1654,
63,
1023,
26,
288,
746,
13358,
480,
6531,
440,
8044,
1654,
3261,
1015,
26,
450,
83,
2,
450,
2986,
63,
1000,
9,
398,
340,
1654,
63,
1023,
315,
291,
14,
15925,
63,
26358,
26,
288,
291,
14,
28937,
275,
1543,
83,
15,
1246,
3149,
83,
7,
450,
334,
1246,
63,
1000,
12,
1654,
63,
1023,
9,
288,
291,
14,
1023,
275,
1654,
63,
1023,
327,
367,
6466,
675,
288,
291,
14,
24806,
14,
2918,
14,
8958,
24622,
480,
1563,
3261,
26,
450,
83,
2,
450,
291,
14,
28937,
9,
267,
587,
26,
288,
746,
13358,
480,
12647,
598,
15914,
1654,
3261,
1015,
26,
450,
83,
2,
450,
1654,
63,
1023,
9,
339,
347,
664,
63,
1000,
63,
1246,
63,
1023,
8,
277,
12,
2986,
63,
1000,
304,
267,
408,
267,
16347,
397,
314,
598,
15914,
3261,
1453,
1015,
370,
4868,
267,
314,
3261,
1654,
365,
1536,
436,
29542,
14,
267,
408,
267,
327,
11768,
26,
5325,
486,
15914,
1654,
1314,
2529,
1453,
63,
1023,
931,
334,
15,
1246,
15,
86,
17,
9,
8118,
3503,
1015,
334,
86,
17,
9,
267,
327,
2597,
1077,
663,
1300,
633,
1808,
3748,
63,
6234,
1314,
965,
931,
267,
372,
283,
86,
17,
7,
398,
862,
26,
288,
666,
275,
2022,
14,
912,
8,
10890,
8,
1246,
63,
1000,
430,
288,
372,
666,
14,
362,
480,
1818,
63,
1023,
401,
283,
86,
17,
358,
267,
871,
2186,
465,
325,
26,
288,
327,
3254,
26,
3622,
1125,
288,
372,
488,
339,
347,
4237,
63,
3756,
63,
991,
63,
354,
8,
277,
12,
4719,
63,
354,
12,
11705,
29,
549,
304,
267,
408,
267,
6668,
282,
4719,
701,
536,
267,
408,
267,
4719,
63,
354,
275,
1166,
3513,
8,
3756,
63,
354,
9,
398,
862,
26,
288,
4184,
275,
4719,
63,
354,
14,
1294,
15857,
288,
922,
63,
354,
275,
32443,
904,
8,
4181,
59,
16,
6809,
17,
566,
288,
4719,
63,
354,
275,
4184,
1988,
17,
61,
288,
340,
11705,
26,
355,
291,
14,
24806,
14,
2918,
14,
2918,
6096,
25937,
4719,
1543,
83,
297,
23191,
701,
450,
83,
2,
450,
334,
3756,
63,
354,
12,
922,
63,
354,
430,
267,
871,
26,
288,
746,
13358,
6096,
3866,
4719,
536,
4366,
83,
680,
13327,
4719,
465,
1475,
26,
3434,
14,
3756,
354,
2,
450,
4719,
63,
354,
9,
398,
1166,
275,
1543,
83,
15,
8050,
10197,
4597,
363,
2473,
2458,
83,
6,
354,
2458,
83,
7,
450,
334,
277,
14,
28937,
12,
922,
63,
354,
12,
4719,
63,
354,
9,
267,
291,
14,
24806,
14,
2918,
14,
30448,
6096,
450,
83,
2,
450,
334,
633,
430,
267,
862,
26,
288,
666,
275,
2022,
14,
912,
8,
10890,
8,
633,
430,
288,
340,
822,
8,
576,
905,
2604,
3135,
1137,
378,
26,
355,
372,
666,
905,
2604,
9210,
16,
61,
267,
871,
26,
288,
327,
3254,
26,
3622,
641,
1950,
15,
11856,
2552,
288,
986,
398,
372,
488,
339,
347,
5267,
63,
3756,
63,
2407,
8,
277,
12,
4048,
12,
4719,
63,
344,
304,
267,
408,
267,
16347,
314,
769,
402,
4048,
2974,
367,
314,
1627,
4719,
14,
267,
710,
1166,
12477,
687,
314,
283,
2407,
7,
901,
402,
314,
4719,
14,
267,
408,
398,
862,
26,
288,
1166,
275,
1543,
83,
15,
8050,
3149,
68,
3149,
83,
10197,
1606,
63,
890,
29,
1400,
7,
450,
334,
277,
14,
28937,
12,
1109,
8,
3756,
63,
344,
395,
4048,
9,
288,
666,
275,
2022,
14,
912,
8,
10890,
8,
633,
430,
288,
2058,
275,
666,
459,
2604,
418,
288,
4224,
275,
334,
576,
14,
362,
360,
2184,
297,
488,
9,
508,
488,
9,
288,
1830,
440,
4224,
26,
355,
1166,
275,
1543,
83,
5,
83,
7,
450,
334,
277,
14,
28937,
12,
666,
459,
2184,
1105,
355,
291,
14,
24806,
14,
2918,
14,
2918,
8,
633,
9,
355,
666,
275,
2022,
14,
912,
8,
10890,
8,
633,
430,
355,
2058,
847,
666,
459,
2604,
418,
355,
4224,
275,
334,
576,
14,
362,
360,
2184,
297,
488,
9,
508,
488,
9,
288,
372,
2058,
267,
871,
26,
288,
372,
488,
339,
347,
664,
63,
513,
8
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3949,
199,
3,
199,
3,
334,
35,
9,
6171,
12,
1603,
14015,
445,
455,
4584,
419,
665,
74,
15176,
4584,
419,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
3949,
199,
646,
2022,
199,
504,
4011,
18,
492,
18279,
12,
6313,
465,
1166,
3513,
199,
504,
7097,
492,
7097,
199,
199,
504,
3242,
14,
2550,
492,
13358,
199,
199,
533,
598,
15914,
3735,
8,
785,
304,
272,
1449,
961,
1021,
365,
18329,
370,
506,
1202,
465,
282,
3261,
1890,
367,
376,
2622,
598,
15914,
1654,
1449,
339,
32501,
63,
26358,
275,
788,
86,
17,
418,
339,
347,
636,
826,
721,
277,
12,
486,
15914,
12,
2986,
63,
1000,
304,
398,
291,
14,
24806,
275,
486,
15914,
398,
862,
26,
288,
7097,
8,
1246,
63,
1000,
12,
5687,
534,
2859,
358,
267,
871,
26,
288,
746,
13358,
480,
3364,
1654,
3261,
1166,
3032,
26,
450,
83,
2,
450,
2986,
63,
1000,
9,
398,
1654,
63,
1023,
275,
291,
14,
362,
63,
1000,
63,
1246,
63,
1023,
3508,
83,
15,
1246,
4805,
450,
334,
1246,
63,
1000,
430,
267,
340,
440,
1654,
63,
1023,
26,
288,
746,
13358,
480,
6531,
440,
8044,
1654,
3261,
1015,
26,
450,
83,
2,
450,
2986,
63,
1000,
9,
398,
340,
1654,
63,
1023,
315,
291,
14,
15925,
63,
26358,
26,
288,
291,
14,
28937,
275,
1543,
83,
15,
1246,
3149,
83,
7,
450,
334,
1246,
63,
1000,
12,
1654,
63,
1023,
9,
288,
291,
14,
1023,
275,
1654,
63,
1023,
327,
367,
6466,
675,
288,
291,
14,
24806,
14,
2918,
14,
8958,
24622,
480,
1563,
3261,
26,
450,
83,
2,
450,
291,
14,
28937,
9,
267,
587,
26,
288,
746,
13358,
480,
12647,
598,
15914,
1654,
3261,
1015,
26,
450,
83,
2,
450,
1654,
63,
1023,
9,
339,
347,
664,
63,
1000,
63,
1246,
63,
1023,
8,
277,
12,
2986,
63,
1000,
304,
267,
408,
267,
16347,
397,
314,
598,
15914,
3261,
1453,
1015,
370,
4868,
267,
314,
3261,
1654,
365,
1536,
436,
29542,
14,
267,
408,
267,
327,
11768,
26,
5325,
486,
15914,
1654,
1314,
2529,
1453,
63,
1023,
931,
334,
15,
1246,
15,
86,
17,
9,
8118,
3503,
1015,
334,
86,
17,
9,
267,
327,
2597,
1077,
663,
1300,
633,
1808,
3748,
63,
6234,
1314,
965,
931,
267,
372,
283,
86,
17,
7,
398,
862,
26,
288,
666,
275,
2022,
14,
912,
8,
10890,
8,
1246,
63,
1000,
430,
288,
372,
666,
14,
362,
480,
1818,
63,
1023,
401,
283,
86,
17,
358,
267,
871,
2186,
465,
325,
26,
288,
327,
3254,
26,
3622,
1125,
288,
372,
488,
339,
347,
4237,
63,
3756,
63,
991,
63,
354,
8,
277,
12,
4719,
63,
354,
12,
11705,
29,
549,
304,
267,
408,
267,
6668,
282,
4719,
701,
536,
267,
408,
267,
4719,
63,
354,
275,
1166,
3513,
8,
3756,
63,
354,
9,
398,
862,
26,
288,
4184,
275,
4719,
63,
354,
14,
1294,
15857,
288,
922,
63,
354,
275,
32443,
904,
8,
4181,
59,
16,
6809,
17,
566,
288,
4719,
63,
354,
275,
4184,
1988,
17,
61,
288,
340,
11705,
26,
355,
291,
14,
24806,
14,
2918,
14,
2918,
6096,
25937,
4719,
1543,
83,
297,
23191,
701,
450,
83,
2,
450,
334,
3756,
63,
354,
12,
922,
63,
354,
430,
267,
871,
26,
288,
746,
13358,
6096,
3866,
4719,
536,
4366,
83,
680,
13327,
4719,
465,
1475,
26,
3434,
14,
3756,
354,
2,
450,
4719,
63,
354,
9,
398,
1166,
275,
1543,
83,
15,
8050,
10197,
4597,
363,
2473,
2458,
83,
6,
354,
2458,
83,
7,
450,
334,
277,
14,
28937,
12,
922,
63,
354,
12,
4719,
63,
354,
9,
267,
291,
14,
24806,
14,
2918,
14,
30448,
6096,
450,
83,
2,
450,
334,
633,
430,
267,
862,
26,
288,
666,
275,
2022,
14,
912,
8,
10890,
8,
633,
430,
288,
340,
822,
8,
576,
905,
2604,
3135,
1137,
378,
26,
355,
372,
666,
905,
2604,
9210,
16,
61,
267,
871,
26,
288,
327,
3254,
26,
3622,
641,
1950,
15,
11856,
2552,
288,
986,
398,
372,
488,
339,
347,
5267,
63,
3756,
63,
2407,
8,
277,
12,
4048,
12,
4719,
63,
344,
304,
267,
408,
267,
16347,
314,
769,
402,
4048,
2974,
367,
314,
1627,
4719,
14,
267,
710,
1166,
12477,
687,
314,
283,
2407,
7,
901,
402,
314,
4719,
14,
267,
408,
398,
862,
26,
288,
1166,
275,
1543,
83,
15,
8050,
3149,
68,
3149,
83,
10197,
1606,
63,
890,
29,
1400,
7,
450,
334,
277,
14,
28937,
12,
1109,
8,
3756,
63,
344,
395,
4048,
9,
288,
666,
275,
2022,
14,
912,
8,
10890,
8,
633,
430,
288,
2058,
275,
666,
459,
2604,
418,
288,
4224,
275,
334,
576,
14,
362,
360,
2184,
297,
488,
9,
508,
488,
9,
288,
1830,
440,
4224,
26,
355,
1166,
275,
1543,
83,
5,
83,
7,
450,
334,
277,
14,
28937,
12,
666,
459,
2184,
1105,
355,
291,
14,
24806,
14,
2918,
14,
2918,
8,
633,
9,
355,
666,
275,
2022,
14,
912,
8,
10890,
8,
633,
430,
355,
2058,
847,
666,
459,
2604,
418,
355,
4224,
275,
334,
576,
14,
362,
360,
2184,
297,
488,
9,
508,
488,
9,
288,
372,
2058,
267,
871,
26,
288,
372,
488,
339,
347,
664,
63,
513,
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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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
gunan/tensorflow
|
tensorflow/compiler/mlir/tensorflow/tests/tf_saved_model/exported_python_args.py
|
18
|
1478
|
# Copyright 2019 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.
# ==============================================================================
# RUN: (! %p/exported_python_args 2>&1) | FileCheck %s
# pylint: disable=missing-docstring,line-too-long,dangerous-default-value
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow.compat.v2 as tf
from tensorflow.compiler.mlir.tensorflow.tests.tf_saved_model import common
class TestModule(tf.Module):
@tf.function(input_signature=[tf.TensorSpec([], tf.float32)])
def some_function(self, x):
return self.callee(x)
# CHECK: While importing SavedModel function 'callee': in input signature:
# CHECK-SAME: Unhandled structured value kind {{.*}} at index path: <value>.1.foo
@tf.function
def callee(self, x, n={'foo': 42}):
return x
if __name__ == '__main__':
common.do_test(TestModule)
|
apache-2.0
|
[
3,
1898,
20312,
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,
199,
3,
21277,
26,
19452,
450,
80,
15,
23028,
63,
1548,
63,
589,
499,
18181,
17,
9,
1204,
3814,
1799,
450,
83,
199,
199,
3,
4287,
26,
3507,
29,
4752,
13,
12485,
12,
604,
13,
7354,
13,
2809,
12,
31444,
13,
885,
13,
585,
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,
3228,
14,
5819,
14,
86,
18,
465,
2833,
199,
504,
3228,
14,
5772,
14,
77,
317,
82,
14,
16008,
14,
2219,
14,
3249,
63,
8420,
63,
1238,
492,
2863,
421,
199,
533,
1379,
2377,
8,
3249,
14,
2377,
304,
819,
768,
3249,
14,
1593,
8,
1210,
63,
5233,
1524,
3249,
14,
3861,
5307,
8798,
2833,
14,
1609,
708,
3948,
523,
347,
2005,
63,
1593,
8,
277,
12,
671,
304,
272,
372,
291,
14,
915,
18387,
8,
88,
9,
819,
327,
17654,
26,
22117,
16306,
29026,
1685,
805,
283,
915,
18387,
356,
315,
1324,
4955,
26,
523,
327,
17654,
13,
19935,
26,
1910,
11217,
21781,
574,
4928,
8448,
2795,
4863,
737,
1478,
931,
26,
665,
585,
10827,
17,
14,
1421,
523,
768,
3249,
14,
1593,
523,
347,
3213,
18387,
8,
277,
12,
671,
12,
302,
3713,
1421,
356,
5685,
22558,
272,
372,
671,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2863,
14,
1117,
63,
396,
8,
774,
2377,
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
] |
[
1898,
20312,
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,
199,
3,
21277,
26,
19452,
450,
80,
15,
23028,
63,
1548,
63,
589,
499,
18181,
17,
9,
1204,
3814,
1799,
450,
83,
199,
199,
3,
4287,
26,
3507,
29,
4752,
13,
12485,
12,
604,
13,
7354,
13,
2809,
12,
31444,
13,
885,
13,
585,
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,
3228,
14,
5819,
14,
86,
18,
465,
2833,
199,
504,
3228,
14,
5772,
14,
77,
317,
82,
14,
16008,
14,
2219,
14,
3249,
63,
8420,
63,
1238,
492,
2863,
421,
199,
533,
1379,
2377,
8,
3249,
14,
2377,
304,
819,
768,
3249,
14,
1593,
8,
1210,
63,
5233,
1524,
3249,
14,
3861,
5307,
8798,
2833,
14,
1609,
708,
3948,
523,
347,
2005,
63,
1593,
8,
277,
12,
671,
304,
272,
372,
291,
14,
915,
18387,
8,
88,
9,
819,
327,
17654,
26,
22117,
16306,
29026,
1685,
805,
283,
915,
18387,
356,
315,
1324,
4955,
26,
523,
327,
17654,
13,
19935,
26,
1910,
11217,
21781,
574,
4928,
8448,
2795,
4863,
737,
1478,
931,
26,
665,
585,
10827,
17,
14,
1421,
523,
768,
3249,
14,
1593,
523,
347,
3213,
18387,
8,
277,
12,
671,
12,
302,
3713,
1421,
356,
5685,
22558,
272,
372,
671,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2863,
14,
1117,
63,
396,
8,
774,
2377,
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,
32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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
rackerlabs/qonos
|
qonos/openstack/common/rpc/dispatcher.py
|
1
|
5310
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Code for rpc message dispatching.
Messages that come in have a version number associated with them. RPC API
version numbers are in the form:
Major.Minor
For a given message with version X.Y, the receiver must be marked as able to
handle messages of version A.B, where:
A = X
B >= Y
The Major version number would be incremented for an almost completely new API.
The Minor version number would be incremented for backwards compatible changes
to an existing API. A backwards compatible change could be something like
adding a new method, adding an argument to an existing method (but not
requiring it), or changing the type for an existing argument (but still
handling the old type as well).
The conversion over to a versioned API must be done on both the client side and
server side of the API at the same time. However, as the code stands today,
there can be both versioned and unversioned APIs implemented in the same code
base.
EXAMPLES
========
Nova was the first project to use versioned rpc APIs. Consider the compute rpc
API as an example. The client side is in nova/compute/rpcapi.py and the server
side is in nova/compute/manager.py.
Example 1) Adding a new method.
-------------------------------
Adding a new method is a backwards compatible change. It should be added to
nova/compute/manager.py, and RPC_API_VERSION should be bumped from X.Y to
X.Y+1. On the client side, the new method in nova/compute/rpcapi.py should
have a specific version specified to indicate the minimum API version that must
be implemented for the method to be supported. For example::
def get_host_uptime(self, ctxt, host):
topic = _compute_topic(self.topic, ctxt, host, None)
return self.call(ctxt, self.make_msg('get_host_uptime'), topic,
version='1.1')
In this case, version '1.1' is the first version that supported the
get_host_uptime() method.
Example 2) Adding a new parameter.
----------------------------------
Adding a new parameter to an rpc method can be made backwards compatible. The
RPC_API_VERSION on the server side (nova/compute/manager.py) should be bumped.
The implementation of the method must not expect the parameter to be present.::
def some_remote_method(self, arg1, arg2, newarg=None):
# The code needs to deal with newarg=None for cases
# where an older client sends a message without it.
pass
On the client side, the same changes should be made as in example 1. The
minimum version that supports the new parameter should be specified.
"""
from qonos.openstack.common.rpc import common as rpc_common
class RpcDispatcher(object):
"""Dispatch rpc messages according to the requested API version.
This class can be used as the top level 'manager' for a service. It
contains a list of underlying managers that have an API_VERSION attribute.
"""
def __init__(self, callbacks):
"""Initialize the rpc dispatcher.
:param callbacks: List of proxy objects that are an instance
of a class with rpc methods exposed. Each proxy
object should have an RPC_API_VERSION attribute.
"""
self.callbacks = callbacks
super(RpcDispatcher, self).__init__()
def dispatch(self, ctxt, version, method, **kwargs):
"""Dispatch a message based on a requested version.
:param ctxt: The request context
:param version: The requested API version from the incoming message
:param method: The method requested to be called by the incoming
message.
:param kwargs: A dict of keyword arguments to be passed to the method.
:returns: Whatever is returned by the underlying method that gets
called.
"""
if not version:
version = '1.0'
had_compatible = False
for proxyobj in self.callbacks:
if hasattr(proxyobj, 'RPC_API_VERSION'):
rpc_api_version = proxyobj.RPC_API_VERSION
else:
rpc_api_version = '1.0'
is_compatible = rpc_common.version_is_compatible(rpc_api_version,
version)
had_compatible = had_compatible or is_compatible
if not hasattr(proxyobj, method):
continue
if is_compatible:
return getattr(proxyobj, method)(ctxt, **kwargs)
if had_compatible:
raise AttributeError("No such RPC function '%s'" % method)
else:
raise rpc_common.UnsupportedRpcVersion(version=version)
|
apache-2.0
|
[
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
3,
1898,
6029,
9572,
13002,
12,
3277,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
624,
199,
3034,
367,
8985,
1245,
7634,
316,
14,
199,
199,
14508,
626,
11492,
315,
1172,
282,
1015,
1329,
4568,
543,
3062,
14,
221,
11785,
3261,
199,
1023,
5579,
787,
315,
314,
1824,
26,
339,
16593,
5857,
14,
23094,
199,
199,
1858,
282,
1627,
1245,
543,
1015,
1323,
14,
57,
12,
314,
13035,
1471,
506,
11584,
465,
7688,
370,
199,
2479,
3788,
402,
1015,
437,
14,
34,
12,
2382,
26,
339,
437,
275,
1323,
339,
699,
2356,
1488,
199,
199,
1918,
16593,
5857,
1015,
1329,
3955,
506,
10035,
2509,
367,
376,
18871,
14793,
892,
3261,
14,
199,
1918,
10195,
269,
1015,
1329,
3955,
506,
10035,
2509,
367,
8552,
9025,
4493,
199,
475,
376,
3411,
3261,
14,
221,
437,
8552,
9025,
1570,
4293,
506,
6020,
2839,
199,
4095,
282,
892,
1083,
12,
7791,
376,
1423,
370,
376,
3411,
1083,
334,
7911,
440,
199,
264,
23729,
652,
395,
503,
13729,
314,
730,
367,
376,
3411,
1423,
334,
7911,
5139,
199,
22273,
314,
2269,
730,
465,
5521,
680,
199,
199,
1918,
8603,
1806,
370,
282,
31792,
3261,
1471,
506,
4224,
641,
3865,
314,
1890,
5366,
436,
199,
1000,
5366,
402,
314,
3261,
737,
314,
2011,
900,
14,
221,
9738,
12,
465,
314,
1233,
410,
5915,
11168,
12,
199,
16990,
883,
506,
3865,
31792,
436,
625,
24155,
15913,
6366,
315,
314,
2011,
1233,
199,
1095,
14,
199,
199,
8918,
199,
763,
199,
199,
19884,
1990,
314,
1642,
2199,
370,
675,
31792,
8985,
15913,
14,
221,
24413,
314,
4526,
8985,
199,
3735,
465,
376,
2893,
14,
221,
710,
1890,
5366,
365,
315,
5913,
15,
3357,
15,
20776,
14,
647,
436,
314,
1654,
199,
2441,
365,
315,
5913,
15,
3357,
15,
2609,
14,
647,
14,
421,
199,
9846,
413,
9,
12934,
282,
892,
1083,
14,
199,
777,
18964,
199,
199,
20897,
282,
892,
1083,
365,
282,
8552,
9025,
1570,
14,
221,
2779,
1077,
506,
3483,
370,
199,
6765,
15,
3357,
15,
2609,
14,
647,
12,
436,
11785,
63,
3735,
63,
4612,
1077,
506,
28108,
379,
687,
1323,
14,
57,
370,
199,
56,
14,
57,
11,
17,
14,
221,
4068,
314,
1890,
5366,
12,
314,
892,
1083,
315,
5913,
15,
3357,
15,
20776,
14,
647,
1077,
199,
7804,
282,
2488,
1015,
2013,
370,
6623,
314,
7481,
3261,
1015,
626,
1471,
199,
1235,
6366,
367,
314,
1083,
370,
506,
3748,
14,
221,
2104,
2893,
447,
339,
347,
664,
63,
1102,
63,
24853,
8,
277,
12,
11216,
12,
1591,
304,
267,
7482,
275,
485,
3357,
63,
5746,
8,
277,
14,
5746,
12,
11216,
12,
1591,
12,
488,
9,
267,
372,
291,
14,
1250,
8,
6725,
12,
291,
14,
1875,
63,
1328,
360,
362,
63,
1102,
63,
24853,
659,
7482,
12,
355,
1015,
534,
17,
14,
17,
358,
199,
199,
607,
642,
1930,
12,
1015,
283,
17,
14,
17,
7,
365,
314,
1642,
1015,
626,
3748,
314,
199,
362,
63,
1102,
63,
24853,
342,
1083,
14,
421,
199,
9846,
499,
9,
12934,
282,
892,
2725,
14,
199,
1444,
306,
199,
199,
20897,
282,
892,
2725,
370,
376,
8985,
1083,
883,
506,
6326,
8552,
9025,
14,
221,
710,
199,
8171,
63,
3735,
63,
4612,
641,
314,
1654,
5366,
334,
6765,
15,
3357,
15,
2609,
14,
647,
9,
1077,
506,
28108,
379,
14,
199,
1918,
4514,
402,
314,
1083,
1471,
440,
4282,
314,
2725,
370,
506,
3451,
28383,
339,
347,
2005,
63,
3846,
63,
765,
8,
277,
12,
1680,
17,
12,
1680,
18,
12,
892,
1273,
29,
403,
304,
267,
327,
710,
1233,
4839,
370,
7962,
543,
892,
1273,
29,
403,
367,
5560,
267,
327,
2382,
376,
12731,
1890,
16178,
282,
1245,
1928,
652,
14,
267,
986,
199,
199,
3314,
314,
1890,
5366,
12,
314,
2011,
4493,
1077,
506,
6326,
465,
315,
2893,
413,
14,
221,
710,
199,
10700,
1015,
626,
5171,
314,
892,
2725,
1077,
506,
2013,
14,
199,
624,
199,
199,
504,
1894,
265,
736,
14,
8512,
14,
2330,
14,
4354,
492,
2863,
465,
8985,
63,
2330,
421,
199,
533,
820,
2352,
15461,
8,
785,
304,
272,
408,
20628,
8985,
3788,
7182,
370,
314,
5839,
3261,
1015,
14,
339,
961,
1021,
883,
506,
1202,
465,
314,
2746,
2166,
283,
2609,
7,
367,
282,
2435,
14,
221,
2779,
272,
3509,
282,
769,
402,
8793,
19680,
626,
1172,
376,
3261,
63,
4612,
2225,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
13484,
304,
267,
408,
9345,
314,
8985,
17475,
14,
398,
520,
635,
13484,
26,
3820,
402,
4566,
2251,
626,
787,
376,
1256,
2079,
402,
282,
1021,
543,
8985,
3102,
19282,
14,
221,
7048,
4566,
2079,
909,
1077,
1172,
376,
11785,
63,
3735,
63,
4612,
2225,
14,
267,
408,
267,
291,
14,
11948,
275,
13484,
267,
1613,
8,
15569,
15461,
12,
291,
2843,
826,
4533,
339,
347,
7634,
8,
277,
12,
11216,
12,
1015,
12,
1083,
12,
1011,
958,
304,
267,
408,
20628,
282,
1245,
4079,
641,
282,
5839,
1015,
14,
398,
520,
635,
11216,
26,
710,
1056,
1067,
267,
520,
635,
1015,
26,
710,
5839,
3261,
1015,
687,
314,
12467,
1245,
267,
520,
635,
1083,
26,
710,
1083,
5839,
370,
506,
2797,
701,
314,
12467,
2432,
1245,
14,
267,
520,
635,
2074,
26,
437,
1211,
402,
4252,
2368,
370,
506,
3032,
370,
314,
1083,
14,
398,
520,
5808,
26,
2816
] |
[
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
3,
1898,
6029,
9572,
13002,
12,
3277,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
624,
199,
3034,
367,
8985,
1245,
7634,
316,
14,
199,
199,
14508,
626,
11492,
315,
1172,
282,
1015,
1329,
4568,
543,
3062,
14,
221,
11785,
3261,
199,
1023,
5579,
787,
315,
314,
1824,
26,
339,
16593,
5857,
14,
23094,
199,
199,
1858,
282,
1627,
1245,
543,
1015,
1323,
14,
57,
12,
314,
13035,
1471,
506,
11584,
465,
7688,
370,
199,
2479,
3788,
402,
1015,
437,
14,
34,
12,
2382,
26,
339,
437,
275,
1323,
339,
699,
2356,
1488,
199,
199,
1918,
16593,
5857,
1015,
1329,
3955,
506,
10035,
2509,
367,
376,
18871,
14793,
892,
3261,
14,
199,
1918,
10195,
269,
1015,
1329,
3955,
506,
10035,
2509,
367,
8552,
9025,
4493,
199,
475,
376,
3411,
3261,
14,
221,
437,
8552,
9025,
1570,
4293,
506,
6020,
2839,
199,
4095,
282,
892,
1083,
12,
7791,
376,
1423,
370,
376,
3411,
1083,
334,
7911,
440,
199,
264,
23729,
652,
395,
503,
13729,
314,
730,
367,
376,
3411,
1423,
334,
7911,
5139,
199,
22273,
314,
2269,
730,
465,
5521,
680,
199,
199,
1918,
8603,
1806,
370,
282,
31792,
3261,
1471,
506,
4224,
641,
3865,
314,
1890,
5366,
436,
199,
1000,
5366,
402,
314,
3261,
737,
314,
2011,
900,
14,
221,
9738,
12,
465,
314,
1233,
410,
5915,
11168,
12,
199,
16990,
883,
506,
3865,
31792,
436,
625,
24155,
15913,
6366,
315,
314,
2011,
1233,
199,
1095,
14,
199,
199,
8918,
199,
763,
199,
199,
19884,
1990,
314,
1642,
2199,
370,
675,
31792,
8985,
15913,
14,
221,
24413,
314,
4526,
8985,
199,
3735,
465,
376,
2893,
14,
221,
710,
1890,
5366,
365,
315,
5913,
15,
3357,
15,
20776,
14,
647,
436,
314,
1654,
199,
2441,
365,
315,
5913,
15,
3357,
15,
2609,
14,
647,
14,
421,
199,
9846,
413,
9,
12934,
282,
892,
1083,
14,
199,
777,
18964,
199,
199,
20897,
282,
892,
1083,
365,
282,
8552,
9025,
1570,
14,
221,
2779,
1077,
506,
3483,
370,
199,
6765,
15,
3357,
15,
2609,
14,
647,
12,
436,
11785,
63,
3735,
63,
4612,
1077,
506,
28108,
379,
687,
1323,
14,
57,
370,
199,
56,
14,
57,
11,
17,
14,
221,
4068,
314,
1890,
5366,
12,
314,
892,
1083,
315,
5913,
15,
3357,
15,
20776,
14,
647,
1077,
199,
7804,
282,
2488,
1015,
2013,
370,
6623,
314,
7481,
3261,
1015,
626,
1471,
199,
1235,
6366,
367,
314,
1083,
370,
506,
3748,
14,
221,
2104,
2893,
447,
339,
347,
664,
63,
1102,
63,
24853,
8,
277,
12,
11216,
12,
1591,
304,
267,
7482,
275,
485,
3357,
63,
5746,
8,
277,
14,
5746,
12,
11216,
12,
1591,
12,
488,
9,
267,
372,
291,
14,
1250,
8,
6725,
12,
291,
14,
1875,
63,
1328,
360,
362,
63,
1102,
63,
24853,
659,
7482,
12,
355,
1015,
534,
17,
14,
17,
358,
199,
199,
607,
642,
1930,
12,
1015,
283,
17,
14,
17,
7,
365,
314,
1642,
1015,
626,
3748,
314,
199,
362,
63,
1102,
63,
24853,
342,
1083,
14,
421,
199,
9846,
499,
9,
12934,
282,
892,
2725,
14,
199,
1444,
306,
199,
199,
20897,
282,
892,
2725,
370,
376,
8985,
1083,
883,
506,
6326,
8552,
9025,
14,
221,
710,
199,
8171,
63,
3735,
63,
4612,
641,
314,
1654,
5366,
334,
6765,
15,
3357,
15,
2609,
14,
647,
9,
1077,
506,
28108,
379,
14,
199,
1918,
4514,
402,
314,
1083,
1471,
440,
4282,
314,
2725,
370,
506,
3451,
28383,
339,
347,
2005,
63,
3846,
63,
765,
8,
277,
12,
1680,
17,
12,
1680,
18,
12,
892,
1273,
29,
403,
304,
267,
327,
710,
1233,
4839,
370,
7962,
543,
892,
1273,
29,
403,
367,
5560,
267,
327,
2382,
376,
12731,
1890,
16178,
282,
1245,
1928,
652,
14,
267,
986,
199,
199,
3314,
314,
1890,
5366,
12,
314,
2011,
4493,
1077,
506,
6326,
465,
315,
2893,
413,
14,
221,
710,
199,
10700,
1015,
626,
5171,
314,
892,
2725,
1077,
506,
2013,
14,
199,
624,
199,
199,
504,
1894,
265,
736,
14,
8512,
14,
2330,
14,
4354,
492,
2863,
465,
8985,
63,
2330,
421,
199,
533,
820,
2352,
15461,
8,
785,
304,
272,
408,
20628,
8985,
3788,
7182,
370,
314,
5839,
3261,
1015,
14,
339,
961,
1021,
883,
506,
1202,
465,
314,
2746,
2166,
283,
2609,
7,
367,
282,
2435,
14,
221,
2779,
272,
3509,
282,
769,
402,
8793,
19680,
626,
1172,
376,
3261,
63,
4612,
2225,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
13484,
304,
267,
408,
9345,
314,
8985,
17475,
14,
398,
520,
635,
13484,
26,
3820,
402,
4566,
2251,
626,
787,
376,
1256,
2079,
402,
282,
1021,
543,
8985,
3102,
19282,
14,
221,
7048,
4566,
2079,
909,
1077,
1172,
376,
11785,
63,
3735,
63,
4612,
2225,
14,
267,
408,
267,
291,
14,
11948,
275,
13484,
267,
1613,
8,
15569,
15461,
12,
291,
2843,
826,
4533,
339,
347,
7634,
8,
277,
12,
11216,
12,
1015,
12,
1083,
12,
1011,
958,
304,
267,
408,
20628,
282,
1245,
4079,
641,
282,
5839,
1015,
14,
398,
520,
635,
11216,
26,
710,
1056,
1067,
267,
520,
635,
1015,
26,
710,
5839,
3261,
1015,
687,
314,
12467,
1245,
267,
520,
635,
1083,
26,
710,
1083,
5839,
370,
506,
2797,
701,
314,
12467,
2432,
1245,
14,
267,
520,
635,
2074,
26,
437,
1211,
402,
4252,
2368,
370,
506,
3032,
370,
314,
1083,
14,
398,
520,
5808,
26,
2816,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Balaji2198/coala
|
tests/bearlib/aspects/CollectionsTest.py
|
10
|
1481
|
import pytest
from coalib.bearlib.aspects import aspectTypeError
from coalib.bearlib.aspects.collections import aspectlist
from coalib.bearlib.aspects.meta import isaspect
from coalib.bearlib.aspects.Metadata import Metadata
class aspectlistTest:
def test__init__(self):
with pytest.raises(aspectTypeError) as exc:
aspectlist(['String'])
exc.match("'String' is not an aspectclass or "
'an instance of an aspectclass')
def test__contains__(self):
list_of_aspect = aspectlist(
[Metadata.CommitMessage.Shortlog, Metadata.CommitMessage.Body])
assert Metadata.CommitMessage.Shortlog in list_of_aspect
assert Metadata.CommitMessage.Shortlog.ColonExistence in list_of_aspect
assert Metadata.CommitMessage.Body in list_of_aspect
assert Metadata not in list_of_aspect
assert Metadata.CommitMessage.Emptiness not in list_of_aspect
with pytest.raises(aspectTypeError) as exc:
'Metadata.CommitMessage.Shortlog' in list_of_aspect
assert not isaspect('Metadata.CommitMessage.Shortlog')
exc.match("'Metadata.CommitMessage.Shortlog' is not an "
'aspectclass or an instance of an aspectclass')
with pytest.raises(aspectTypeError) as exc:
str in list_of_aspect
assert not isaspect(str)
exc.match("<class 'str'> is not an "
'aspectclass or an instance of an aspectclass')
|
agpl-3.0
|
[
646,
4613,
199,
199,
504,
512,
25530,
14,
31796,
773,
14,
18658,
83,
492,
17435,
4333,
199,
504,
512,
25530,
14,
31796,
773,
14,
18658,
83,
14,
7882,
492,
17435,
513,
199,
504,
512,
25530,
14,
31796,
773,
14,
18658,
83,
14,
2024,
492,
365,
18658,
199,
504,
512,
25530,
14,
31796,
773,
14,
18658,
83,
14,
5142,
492,
16160,
421,
199,
533,
17435,
513,
774,
26,
339,
347,
511,
363,
826,
721,
277,
304,
267,
543,
4613,
14,
3536,
8,
18658,
4333,
9,
465,
3178,
26,
288,
17435,
513,
2941,
1558,
1105,
267,
3178,
14,
1431,
15587,
1558,
7,
365,
440,
376,
17435,
533,
503,
298,
2116,
283,
290,
1256,
402,
376,
17435,
533,
358,
339,
347,
511,
363,
6134,
721,
277,
304,
267,
769,
63,
1618,
63,
18658,
275,
17435,
513,
8,
288,
359,
5142,
14,
11421,
2209,
14,
10039,
793,
12,
16160,
14,
11421,
2209,
14,
8173,
566,
267,
702,
16160,
14,
11421,
2209,
14,
10039,
793,
315,
769,
63,
1618,
63,
18658,
267,
702,
16160,
14,
11421,
2209,
14,
10039,
793,
14,
2001,
265,
920,
18586,
315,
769,
63,
1618,
63,
18658,
267,
702,
16160,
14,
11421,
2209,
14,
8173,
315,
769,
63,
1618,
63,
18658,
267,
702,
16160,
440,
315,
769,
63,
1618,
63,
18658,
267,
702,
16160,
14,
11421,
2209,
14,
37,
4787,
9585,
440,
315,
769,
63,
1618,
63,
18658,
398,
543,
4613,
14,
3536,
8,
18658,
4333,
9,
465,
3178,
26,
288,
283,
5142,
14,
11421,
2209,
14,
10039,
793,
7,
315,
769,
63,
1618,
63,
18658,
267,
702,
440,
365,
18658,
360,
5142,
14,
11421,
2209,
14,
10039,
793,
358,
267,
3178,
14,
1431,
15587,
5142,
14,
11421,
2209,
14,
10039,
793,
7,
365,
440,
376,
298,
2116,
283,
18658,
533,
503,
376,
1256,
402,
376,
17435,
533,
358,
267,
543,
4613,
14,
3536,
8,
18658,
4333,
9,
465,
3178,
26,
288,
620,
315,
769,
63,
1618,
63,
18658,
267,
702,
440,
365,
18658,
8,
495,
9,
267,
3178,
14,
1431,
6757,
533,
283,
495,
8423,
365,
440,
376,
298,
2116,
283,
18658,
533,
503,
376,
1256,
402,
376,
17435,
533,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4613,
199,
199,
504,
512,
25530,
14,
31796,
773,
14,
18658,
83,
492,
17435,
4333,
199,
504,
512,
25530,
14,
31796,
773,
14,
18658,
83,
14,
7882,
492,
17435,
513,
199,
504,
512,
25530,
14,
31796,
773,
14,
18658,
83,
14,
2024,
492,
365,
18658,
199,
504,
512,
25530,
14,
31796,
773,
14,
18658,
83,
14,
5142,
492,
16160,
421,
199,
533,
17435,
513,
774,
26,
339,
347,
511,
363,
826,
721,
277,
304,
267,
543,
4613,
14,
3536,
8,
18658,
4333,
9,
465,
3178,
26,
288,
17435,
513,
2941,
1558,
1105,
267,
3178,
14,
1431,
15587,
1558,
7,
365,
440,
376,
17435,
533,
503,
298,
2116,
283,
290,
1256,
402,
376,
17435,
533,
358,
339,
347,
511,
363,
6134,
721,
277,
304,
267,
769,
63,
1618,
63,
18658,
275,
17435,
513,
8,
288,
359,
5142,
14,
11421,
2209,
14,
10039,
793,
12,
16160,
14,
11421,
2209,
14,
8173,
566,
267,
702,
16160,
14,
11421,
2209,
14,
10039,
793,
315,
769,
63,
1618,
63,
18658,
267,
702,
16160,
14,
11421,
2209,
14,
10039,
793,
14,
2001,
265,
920,
18586,
315,
769,
63,
1618,
63,
18658,
267,
702,
16160,
14,
11421,
2209,
14,
8173,
315,
769,
63,
1618,
63,
18658,
267,
702,
16160,
440,
315,
769,
63,
1618,
63,
18658,
267,
702,
16160,
14,
11421,
2209,
14,
37,
4787,
9585,
440,
315,
769,
63,
1618,
63,
18658,
398,
543,
4613,
14,
3536,
8,
18658,
4333,
9,
465,
3178,
26,
288,
283,
5142,
14,
11421,
2209,
14,
10039,
793,
7,
315,
769,
63,
1618,
63,
18658,
267,
702,
440,
365,
18658,
360,
5142,
14,
11421,
2209,
14,
10039,
793,
358,
267,
3178,
14,
1431,
15587,
5142,
14,
11421,
2209,
14,
10039,
793,
7,
365,
440,
376,
298,
2116,
283,
18658,
533,
503,
376,
1256,
402,
376,
17435,
533,
358,
267,
543,
4613,
14,
3536,
8,
18658,
4333,
9,
465,
3178,
26,
288,
620,
315,
769,
63,
1618,
63,
18658,
267,
702,
440,
365,
18658,
8,
495,
9,
267,
3178,
14,
1431,
6757,
533,
283,
495,
8423,
365,
440,
376,
298,
2116,
283,
18658,
533,
503,
376,
1256,
402,
376,
17435,
533,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
vincentrosso/xhtml2pdf
|
ez_setup.py
|
61
|
9429
|
#!python
"""Bootstrap setuptools installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from ez_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download
mirror, or use an alternate download directory, you can do so by supplying
the appropriate options to ``use_setuptools()``.
This file can also be run as a script to install or upgrade setuptools.
"""
import sys
DEFAULT_VERSION = "0.6c9"
DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
md5_data = {
'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
}
import sys, os
try: from hashlib import md5
except ImportError: from md5 import md5
def _validate_md5(egg_name, data):
if egg_name in md5_data:
digest = md5(data).hexdigest()
if digest != md5_data[egg_name]:
print >>sys.stderr, (
"md5 validation of %s failed! (Possible download problem?)"
% egg_name
)
sys.exit(2)
return data
def use_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
download_delay=15
):
"""Automatically find/download setuptools and make it available on sys.path
`version` should be a valid setuptools version number that is available
as an egg for download under the `download_base` URL (which should end with
a '/'). `to_dir` is the directory where setuptools will be downloaded, if
it is not already available. If `download_delay` is specified, it should
be the number of seconds that will be paused before initiating a download,
should one be required. If an older version of setuptools is installed,
this routine will print a message to ``sys.stderr`` and raise SystemExit in
an attempt to abort the calling script.
"""
was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
def do_download():
egg = download_setuptools(version, download_base, to_dir, download_delay)
sys.path.insert(0, egg)
import setuptools; setuptools.bootstrap_install_from = egg
try:
import pkg_resources
except ImportError:
return do_download()
try:
pkg_resources.require("setuptools>="+version); return
except pkg_resources.VersionConflict, e:
if was_imported:
print >>sys.stderr, (
"The required version of setuptools (>=%s) is not available, and\n"
"can't be installed while this script is running. Please install\n"
" a more recent version first, using 'easy_install -U setuptools'."
"\n\n(Currently using %r)"
) % (version, e.args[0])
sys.exit(2)
else:
del pkg_resources, sys.modules['pkg_resources'] # reload ok
return do_download()
except pkg_resources.DistributionNotFound:
return do_download()
def download_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
delay = 15
):
"""Download setuptools from a specified location and return its filename
`version` should be a valid setuptools version number that is available
as an egg for download under the `download_base` URL (which should end
with a '/'). `to_dir` is the directory where the egg will be downloaded.
`delay` is the number of seconds to pause before an actual download attempt.
"""
import urllib2, shutil
egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
url = download_base + egg_name
saveto = os.path.join(to_dir, egg_name)
src = dst = None
if not os.path.exists(saveto): # Avoid repeated downloads
try:
from distutils import log
if delay:
log.warn("""
---------------------------------------------------------------------------
This script requires setuptools version %s to run (even to display
help). I will attempt to download it for you (from
%s), but
you may need to enable firewall access for this script first.
I will start the download in %d seconds.
(Note: if this machine does not have network access, please obtain the file
%s
and place it in this directory before rerunning this script.)
---------------------------------------------------------------------------""",
version, download_base, delay, url
); from time import sleep; sleep(delay)
log.warn("Downloading %s", url)
src = urllib2.urlopen(url)
# Read/write all in one block, so we don't create a corrupt file
# if the download is interrupted.
data = _validate_md5(egg_name, src.read())
dst = open(saveto,"wb"); dst.write(data)
finally:
if src: src.close()
if dst: dst.close()
return os.path.realpath(saveto)
def main(argv, version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
try:
import setuptools
except ImportError:
egg = None
try:
egg = download_setuptools(version, delay=0)
sys.path.insert(0,egg)
from setuptools.command.easy_install import main
return main(list(argv)+[egg]) # we're done here
finally:
if egg and os.path.exists(egg):
os.unlink(egg)
else:
if setuptools.__version__ == '0.0.1':
print >>sys.stderr, (
"You have an obsolete version of setuptools installed. Please\n"
"remove it from your system entirely before rerunning this script."
)
sys.exit(2)
req = "setuptools>="+version
import pkg_resources
try:
pkg_resources.require(req)
except pkg_resources.VersionConflict:
try:
from setuptools.command.easy_install import main
except ImportError:
from easy_install import main
main(list(argv)+[download_setuptools(delay=0)])
sys.exit(0) # try to force an exit
else:
if argv:
from setuptools.command.easy_install import main
main(argv)
else:
print "Setuptools version",version,"or greater has been installed."
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
def update_md5(filenames):
"""Update our built-in md5 registry"""
import re
for name in filenames:
base = os.path.basename(name)
f = open(name,'rb')
md5_data[base] = md5(f.read()).hexdigest()
f.close()
data = [" %r: %r,\n" % it for it in md5_data.items()]
data.sort()
repl = "".join(data)
import inspect
srcfile = inspect.getsourcefile(sys.modules[__name__])
f = open(srcfile, 'rb'); src = f.read(); f.close()
match = re.search("\nmd5_data = {\n([^}]+)}", src)
if not match:
print >>sys.stderr, "Internal error!"
sys.exit(2)
src = src[:match.start(1)] + repl + src[match.end(1):]
f = open(srcfile,'w')
f.write(src)
f.close()
if __name__=='__main__':
if len(sys.argv)>2 and sys.argv[1]=='--md5update':
update_md5(sys.argv[2:])
else:
main(sys.argv[1:])
|
apache-2.0
|
[
3168,
1548,
199,
624,
17989,
7868,
9116,
12096,
199,
199,
3917,
1265,
2934,
370,
675,
9116,
315,
2195,
2559,
1159,
3272,
14,
647,
12,
2951,
2387,
642,
199,
493,
315,
314,
2011,
2082,
543,
652,
12,
436,
1050,
642,
370,
314,
2746,
402,
2195,
3272,
14,
647,
447,
339,
687,
325,
90,
63,
2758,
492,
675,
63,
13623,
272,
675,
63,
13623,
342,
199,
199,
3917,
1265,
2934,
370,
4409,
282,
2488,
1015,
402,
9116,
12,
663,
282,
5235,
199,
12324,
12,
503,
675,
376,
18034,
5235,
2082,
12,
1265,
883,
886,
880,
701,
4973,
6670,
199,
1589,
5827,
1511,
370,
1124,
1180,
63,
13623,
28566,
199,
199,
2765,
570,
883,
2597,
506,
1255,
465,
282,
2884,
370,
3907,
503,
10754,
9116,
14,
199,
624,
199,
646,
984,
199,
3472,
63,
4612,
275,
298,
16,
14,
22,
67,
25,
2,
199,
3472,
63,
2632,
258,
275,
298,
1014,
921,
17343,
14,
1548,
14,
1308,
15,
5154,
3149,
83,
15,
83,
15,
13623,
6687,
450,
984,
14,
1023,
1491,
19,
61,
199,
199,
1064,
21,
63,
576,
275,
469,
272,
283,
13623,
13,
16,
14,
22,
66,
17,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
1299,
1081,
27956,
23166,
7991,
68,
15186,
66,
14140,
66,
23,
70,
821,
67,
22,
69,
22,
696,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
17,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
66,
1965,
65,
24,
65,
13353,
69,
2322,
996,
70,
2501,
2426,
1024,
19,
70,
10860,
1196,
1276,
2894,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
18,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
1367,
13539,
1427,
68,
24,
65,
22,
68,
24,
3003,
1602,
19235,
65,
25,
68,
1780,
12900,
68,
1020,
66,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
18,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
20,
14140,
65,
24,
68,
10143,
68,
18,
1235,
19528,
667,
708,
65,
22,
69,
2528,
69,
20,
70,
2564,
65,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
19,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
2501,
2192,
67,
16,
3003,
2898,
1020,
65,
22,
13155,
1020,
2194,
28806,
25,
70,
21,
65,
1690,
1085,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
19,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
1703,
65,
24,
67,
22,
66,
19,
68,
22,
30441,
1081,
11717,
70,
10699,
70,
23,
983,
15014,
12668,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
20,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
2789,
12618,
65,
1194,
379,
20,
69,
17,
26816,
1138,
771,
10005,
2158,
20,
69,
22,
70,
23,
69,
21,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
20,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
20,
2894,
18,
65,
10233,
68,
12048,
31811,
31311,
18,
68,
1196,
70,
8845,
66,
19,
66,
17,
67,
20,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
17,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
66,
19,
70,
18,
66,
1229,
1355,
68,
2182,
2894,
23,
70,
1342,
350,
1965,
4195,
70,
17,
65,
25,
2036,
67,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
17,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
66,
2322,
3074,
65,
14045,
23,
68,
18,
68,
18,
2026,
1079,
383,
3129,
772,
70,
18,
65,
20,
66,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
18,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
70,
29851,
4361,
22,
2158,
18,
66,
23,
68,
16,
70,
19,
2470,
16,
66,
2824,
70,
10630,
1196,
67,
1465,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
18,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
26666,
5756,
69,
825,
1276,
70,
2417,
69,
24,
4489,
975,
2866,
22,
65,
7507,
66,
2819,
1138,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
19,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
70,
12851,
667,
6889,
68,
771,
2426,
65,
11990,
67,
25,
2866,
22,
70,
17,
68,
23,
66,
2277,
667,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
19,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
69,
16,
379,
1342,
24255,
67,
13830,
4361,
66,
2898,
4361,
14187,
65,
1400,
69,
23,
66,
3172,
69,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
19,
13,
647,
18,
14,
21,
14,
5799,
356,
283,
371,
2829,
975,
70,
617,
30270,
15722,
1079,
19211,
67,
23,
67,
22,
3691,
30924,
2182,
69,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
20,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
66,
16,
66,
25,
11780,
645,
371,
708,
16348,
4361,
645,
23,
70,
1602,
67,
21,
68,
1965,
3172,
70,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
20,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
18,
65,
17,
70,
2534,
1367,
68,
20,
70,
4361,
19,
67,
2576,
4361,
30626,
67,
16,
65,
7214,
69,
22,
69,
18,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
20,
13,
647,
18,
14,
21,
14,
5799,
356,
283,
24,
70,
21,
65,
19730,
69,
708,
24035,
25,
67,
2819,
66,
2177,
20,
66,
1229,
1479,
70,
1651,
2756,
67,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
21,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
1024,
25,
2592,
11782,
2182,
983,
966,
70,
18,
70,
19,
69,
22,
66,
1276,
2114,
69,
25,
68,
24,
10806,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
21,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
6504,
18,
24642,
17,
67,
9570,
614,
1024,
1349,
1196,
2976,
70,
21,
26333,
24,
2158,
772,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
21,
13,
647,
18,
14,
21,
14,
5799,
356,
283,
65,
24,
68,
19,
70,
32392,
2635,
30031,
65,
1555,
1079,
1587,
379,
1401,
21976,
68,
19,
68,
21,
68,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
22,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
1276,
10253,
66,
2277,
7524,
65,
1272,
1299,
2417,
10638,
66,
1876,
68,
15419
] |
[
1548,
199,
624,
17989,
7868,
9116,
12096,
199,
199,
3917,
1265,
2934,
370,
675,
9116,
315,
2195,
2559,
1159,
3272,
14,
647,
12,
2951,
2387,
642,
199,
493,
315,
314,
2011,
2082,
543,
652,
12,
436,
1050,
642,
370,
314,
2746,
402,
2195,
3272,
14,
647,
447,
339,
687,
325,
90,
63,
2758,
492,
675,
63,
13623,
272,
675,
63,
13623,
342,
199,
199,
3917,
1265,
2934,
370,
4409,
282,
2488,
1015,
402,
9116,
12,
663,
282,
5235,
199,
12324,
12,
503,
675,
376,
18034,
5235,
2082,
12,
1265,
883,
886,
880,
701,
4973,
6670,
199,
1589,
5827,
1511,
370,
1124,
1180,
63,
13623,
28566,
199,
199,
2765,
570,
883,
2597,
506,
1255,
465,
282,
2884,
370,
3907,
503,
10754,
9116,
14,
199,
624,
199,
646,
984,
199,
3472,
63,
4612,
275,
298,
16,
14,
22,
67,
25,
2,
199,
3472,
63,
2632,
258,
275,
298,
1014,
921,
17343,
14,
1548,
14,
1308,
15,
5154,
3149,
83,
15,
83,
15,
13623,
6687,
450,
984,
14,
1023,
1491,
19,
61,
199,
199,
1064,
21,
63,
576,
275,
469,
272,
283,
13623,
13,
16,
14,
22,
66,
17,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
1299,
1081,
27956,
23166,
7991,
68,
15186,
66,
14140,
66,
23,
70,
821,
67,
22,
69,
22,
696,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
17,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
66,
1965,
65,
24,
65,
13353,
69,
2322,
996,
70,
2501,
2426,
1024,
19,
70,
10860,
1196,
1276,
2894,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
18,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
1367,
13539,
1427,
68,
24,
65,
22,
68,
24,
3003,
1602,
19235,
65,
25,
68,
1780,
12900,
68,
1020,
66,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
18,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
20,
14140,
65,
24,
68,
10143,
68,
18,
1235,
19528,
667,
708,
65,
22,
69,
2528,
69,
20,
70,
2564,
65,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
19,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
2501,
2192,
67,
16,
3003,
2898,
1020,
65,
22,
13155,
1020,
2194,
28806,
25,
70,
21,
65,
1690,
1085,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
19,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
1703,
65,
24,
67,
22,
66,
19,
68,
22,
30441,
1081,
11717,
70,
10699,
70,
23,
983,
15014,
12668,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
20,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
2789,
12618,
65,
1194,
379,
20,
69,
17,
26816,
1138,
771,
10005,
2158,
20,
69,
22,
70,
23,
69,
21,
297,
272,
283,
13623,
13,
16,
14,
22,
66,
20,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
20,
2894,
18,
65,
10233,
68,
12048,
31811,
31311,
18,
68,
1196,
70,
8845,
66,
19,
66,
17,
67,
20,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
17,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
66,
19,
70,
18,
66,
1229,
1355,
68,
2182,
2894,
23,
70,
1342,
350,
1965,
4195,
70,
17,
65,
25,
2036,
67,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
17,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
66,
2322,
3074,
65,
14045,
23,
68,
18,
68,
18,
2026,
1079,
383,
3129,
772,
70,
18,
65,
20,
66,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
18,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
70,
29851,
4361,
22,
2158,
18,
66,
23,
68,
16,
70,
19,
2470,
16,
66,
2824,
70,
10630,
1196,
67,
1465,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
18,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
26666,
5756,
69,
825,
1276,
70,
2417,
69,
24,
4489,
975,
2866,
22,
65,
7507,
66,
2819,
1138,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
19,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
70,
12851,
667,
6889,
68,
771,
2426,
65,
11990,
67,
25,
2866,
22,
70,
17,
68,
23,
66,
2277,
667,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
19,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
69,
16,
379,
1342,
24255,
67,
13830,
4361,
66,
2898,
4361,
14187,
65,
1400,
69,
23,
66,
3172,
69,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
19,
13,
647,
18,
14,
21,
14,
5799,
356,
283,
371,
2829,
975,
70,
617,
30270,
15722,
1079,
19211,
67,
23,
67,
22,
3691,
30924,
2182,
69,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
20,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
66,
16,
66,
25,
11780,
645,
371,
708,
16348,
4361,
645,
23,
70,
1602,
67,
21,
68,
1965,
3172,
70,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
20,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
18,
65,
17,
70,
2534,
1367,
68,
20,
70,
4361,
19,
67,
2576,
4361,
30626,
67,
16,
65,
7214,
69,
22,
69,
18,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
20,
13,
647,
18,
14,
21,
14,
5799,
356,
283,
24,
70,
21,
65,
19730,
69,
708,
24035,
25,
67,
2819,
66,
2177,
20,
66,
1229,
1479,
70,
1651,
2756,
67,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
21,
13,
647,
18,
14,
19,
14,
5799,
356,
283,
1024,
25,
2592,
11782,
2182,
983,
966,
70,
18,
70,
19,
69,
22,
66,
1276,
2114,
69,
25,
68,
24,
10806,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
21,
13,
647,
18,
14,
20,
14,
5799,
356,
283,
6504,
18,
24642,
17,
67,
9570,
614,
1024,
1349,
1196,
2976,
70,
21,
26333,
24,
2158,
772,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
21,
13,
647,
18,
14,
21,
14,
5799,
356,
283,
65,
24,
68,
19,
70,
32392,
2635,
30031,
65,
1555,
1079,
1587,
379,
1401,
21976,
68,
19,
68,
21,
68,
297,
272,
283,
13623,
13,
16,
14,
22,
67,
22,
13,
647,
18,
14,
19,
14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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Panos-Bletsos/spark-cost-model-optimizer
|
python/pyspark/statcounter.py
|
130
|
5115
|
#
# 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.
#
# This file is ported from spark/util/StatCounter.scala
import copy
import math
try:
from numpy import maximum, minimum, sqrt
except ImportError:
maximum = max
minimum = min
sqrt = math.sqrt
class StatCounter(object):
def __init__(self, values=None):
if values is None:
values = list()
self.n = 0 # Running count of our values
self.mu = 0.0 # Running mean of our values
self.m2 = 0.0 # Running variance numerator (sum of (x - mean)^2)
self.maxValue = float("-inf")
self.minValue = float("inf")
for v in values:
self.merge(v)
# Add a value into this StatCounter, updating the internal statistics.
def merge(self, value):
delta = value - self.mu
self.n += 1
self.mu += delta / self.n
self.m2 += delta * (value - self.mu)
self.maxValue = maximum(self.maxValue, value)
self.minValue = minimum(self.minValue, value)
return self
# Merge another StatCounter into this one, adding up the internal statistics.
def mergeStats(self, other):
if not isinstance(other, StatCounter):
raise Exception("Can only merge Statcounters!")
if other is self: # reference equality holds
self.merge(copy.deepcopy(other)) # Avoid overwriting fields in a weird order
else:
if self.n == 0:
self.mu = other.mu
self.m2 = other.m2
self.n = other.n
self.maxValue = other.maxValue
self.minValue = other.minValue
elif other.n != 0:
delta = other.mu - self.mu
if other.n * 10 < self.n:
self.mu = self.mu + (delta * other.n) / (self.n + other.n)
elif self.n * 10 < other.n:
self.mu = other.mu - (delta * self.n) / (self.n + other.n)
else:
self.mu = (self.mu * self.n + other.mu * other.n) / (self.n + other.n)
self.maxValue = maximum(self.maxValue, other.maxValue)
self.minValue = minimum(self.minValue, other.minValue)
self.m2 += other.m2 + (delta * delta * self.n * other.n) / (self.n + other.n)
self.n += other.n
return self
# Clone this StatCounter
def copy(self):
return copy.deepcopy(self)
def count(self):
return int(self.n)
def mean(self):
return self.mu
def sum(self):
return self.n * self.mu
def min(self):
return self.minValue
def max(self):
return self.maxValue
# Return the variance of the values.
def variance(self):
if self.n == 0:
return float('nan')
else:
return self.m2 / self.n
#
# Return the sample variance, which corrects for bias in estimating the variance by dividing
# by N-1 instead of N.
#
def sampleVariance(self):
if self.n <= 1:
return float('nan')
else:
return self.m2 / (self.n - 1)
# Return the standard deviation of the values.
def stdev(self):
return sqrt(self.variance())
#
# Return the sample standard deviation of the values, which corrects for bias in estimating the
# variance by dividing by N-1 instead of N.
#
def sampleStdev(self):
return sqrt(self.sampleVariance())
def asDict(self, sample=False):
"""Returns the :class:`StatCounter` members as a ``dict``.
>>> sc.parallelize([1., 2., 3., 4.]).stats().asDict()
{'count': 4L,
'max': 4.0,
'mean': 2.5,
'min': 1.0,
'stdev': 1.2909944487358056,
'sum': 10.0,
'variance': 1.6666666666666667}
"""
return {
'count': self.count(),
'mean': self.mean(),
'sum': self.sum(),
'min': self.min(),
'max': self.max(),
'stdev': self.stdev() if sample else self.sampleStdev(),
'variance': self.variance() if sample else self.sampleVariance()
}
def __repr__(self):
return ("(count: %s, mean: %s, stdev: %s, max: %s, min: %s)" %
(self.count(), self.mean(), self.stdev(), self.max(), self.min()))
|
apache-2.0
|
[
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
3,
961,
570,
365,
299,
1376,
687,
15442,
15,
1974,
15,
11232,
11348,
14,
28708,
199,
199,
646,
1331,
199,
646,
3473,
199,
199,
893,
26,
272,
687,
2680,
492,
5696,
12,
7481,
12,
7452,
199,
2590,
3545,
26,
272,
5696,
275,
1390,
272,
7481,
275,
1748,
272,
7452,
275,
3473,
14,
5079,
421,
199,
533,
27673,
11348,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1338,
29,
403,
304,
267,
340,
1338,
365,
488,
26,
288,
1338,
275,
769,
342,
267,
291,
14,
78,
275,
378,
259,
327,
26848,
2338,
402,
4154,
1338,
267,
291,
14,
6553,
275,
378,
14,
16,
221,
327,
26848,
4615,
402,
4154,
1338,
267,
291,
14,
77,
18,
275,
378,
14,
16,
221,
327,
26848,
11773,
27640,
334,
1838,
402,
334,
88,
446,
4615,
18979,
18,
9,
267,
291,
14,
988,
1110,
275,
2069,
6096,
4904,
531,
267,
291,
14,
827,
1110,
275,
2069,
480,
4904,
531,
398,
367,
373,
315,
1338,
26,
288,
291,
14,
5628,
8,
86,
9,
339,
327,
2654,
282,
574,
1901,
642,
27673,
11348,
12,
12928,
314,
5007,
11076,
14,
272,
347,
5389,
8,
277,
12,
574,
304,
267,
5762,
275,
574,
446,
291,
14,
6553,
267,
291,
14,
78,
847,
413,
267,
291,
14,
6553,
847,
5762,
1182,
291,
14,
78,
267,
291,
14,
77,
18,
847,
5762,
627,
334,
585,
446,
291,
14,
6553,
9,
267,
291,
14,
988,
1110,
275,
5696,
8,
277,
14,
988,
1110,
12,
574,
9,
267,
291,
14,
827,
1110,
275,
7481,
8,
277,
14,
827,
1110,
12,
574,
9,
398,
372,
291,
339,
327,
14076,
4573,
27673,
11348,
1901,
642,
1373,
12,
7791,
1536,
314,
5007,
11076,
14,
272,
347,
5389,
8257,
8,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
27673,
11348,
304,
288,
746,
2186,
480,
6049,
1454,
5389,
27673,
16558,
9124,
398,
340,
1163,
365,
291,
26,
221,
327,
3659,
16612,
15164,
288,
291,
14,
5628,
8,
1574,
14,
8293,
8,
1848,
430,
221,
327,
19503,
32592,
1504,
315,
282,
22965,
1865,
267,
587,
26,
288,
340,
291,
14,
78,
508,
378,
26,
355,
291,
14,
6553,
275,
1163,
14,
6553,
355,
291,
14,
77,
18,
275,
1163,
14,
77,
18,
355,
291,
14,
78,
275,
1163,
14,
78,
355,
291,
14,
988,
1110,
275,
1163,
14,
988,
1110,
355,
291,
14,
827,
1110,
275,
1163,
14,
827,
1110,
953,
916,
1163,
14,
78,
1137,
378,
26,
355,
5762,
275,
1163,
14,
6553,
446,
291,
14,
6553,
355,
340,
1163,
14,
78,
627,
1616,
665,
291,
14,
78,
26,
490,
291,
14,
6553,
275,
291,
14,
6553,
435,
334,
3136,
627,
1163,
14,
78,
9,
1182,
334,
277,
14,
78,
435,
1163,
14,
78,
9,
355,
916,
291,
14,
78,
627,
1616,
665,
1163,
14,
78,
26,
490,
291,
14,
6553,
275,
1163,
14,
6553,
446,
334,
3136,
627,
291,
14,
78,
9,
1182,
334,
277,
14,
78,
435,
1163,
14,
78,
9,
355,
587,
26,
490,
291,
14,
6553,
275,
334,
277,
14,
6553,
627,
291,
14,
78,
435,
1163,
14,
6553,
627,
1163,
14,
78,
9,
1182,
334,
277,
14,
78,
435,
1163,
14,
78,
9,
2234,
291,
14,
988,
1110,
275,
5696,
8,
277,
14,
988,
1110,
12,
1163,
14,
988,
1110,
9,
355,
291,
14,
827,
1110,
275,
7481,
8,
277,
14,
827,
1110,
12,
1163,
14,
827,
1110,
9,
2234,
291,
14,
77,
18,
847,
1163,
14,
77,
18,
435,
334,
3136,
627,
5762,
627,
291,
14,
78,
627,
1163,
14,
78,
9,
1182,
334,
277,
14,
78,
435,
1163,
14,
78,
9,
355,
291,
14,
78,
847,
1163,
14,
78,
267,
372,
291,
339,
327,
8465,
368,
642,
27673,
11348,
272,
347,
1331,
8,
277,
304,
267,
372,
1331,
14,
8293,
8,
277,
9,
339,
347,
2338,
8,
277,
304,
267,
372,
1109,
8,
277,
14,
78,
9,
339,
347,
4615,
8,
277,
304,
267,
372,
291,
14,
6553,
339,
347,
3089,
8,
277,
304,
267,
372,
291,
14,
78,
627,
291,
14,
6553,
339,
347,
1748,
8,
277,
304,
267,
372,
291,
14,
827,
1110,
339,
347,
1390,
8,
277,
304,
267,
372,
291,
14,
988,
1110,
339,
327,
1432,
314,
11773,
402,
314,
1338,
14,
272,
347,
11773,
8,
277,
304,
267,
340,
291,
14,
78,
508,
378,
26,
288,
372,
2069,
360,
4304,
358,
267,
587,
26,
288,
372,
291,
14,
77,
18,
1182,
291,
14,
78,
339,
327,
272,
327,
1432,
314,
2690,
11773,
12,
1314,
3211,
83,
367,
10671,
315,
4347,
3969,
316,
314,
11773,
701,
487,
11604,
272,
327,
701,
653,
13,
17,
3140,
402,
653,
14,
272,
327,
272,
347,
2690,
31805,
8,
277,
304,
267,
340,
291,
14,
78,
2695,
413,
26,
288,
372,
2069,
360,
4304,
358,
267,
587,
26,
288,
372,
291,
14,
77,
18,
1182,
334,
277,
14,
78,
446,
413,
9,
339,
327,
1432,
314,
4465,
18458,
402,
314,
1338,
14,
272,
347,
410,
2374,
8,
277,
304,
267,
372,
7452,
8,
277,
14,
6221,
1012,
339,
327,
272,
327,
1432,
314,
2690,
4465,
18458,
402,
314,
1338,
12
] |
[
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
3,
961,
570,
365,
299,
1376,
687,
15442,
15,
1974,
15,
11232,
11348,
14,
28708,
199,
199,
646,
1331,
199,
646,
3473,
199,
199,
893,
26,
272,
687,
2680,
492,
5696,
12,
7481,
12,
7452,
199,
2590,
3545,
26,
272,
5696,
275,
1390,
272,
7481,
275,
1748,
272,
7452,
275,
3473,
14,
5079,
421,
199,
533,
27673,
11348,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1338,
29,
403,
304,
267,
340,
1338,
365,
488,
26,
288,
1338,
275,
769,
342,
267,
291,
14,
78,
275,
378,
259,
327,
26848,
2338,
402,
4154,
1338,
267,
291,
14,
6553,
275,
378,
14,
16,
221,
327,
26848,
4615,
402,
4154,
1338,
267,
291,
14,
77,
18,
275,
378,
14,
16,
221,
327,
26848,
11773,
27640,
334,
1838,
402,
334,
88,
446,
4615,
18979,
18,
9,
267,
291,
14,
988,
1110,
275,
2069,
6096,
4904,
531,
267,
291,
14,
827,
1110,
275,
2069,
480,
4904,
531,
398,
367,
373,
315,
1338,
26,
288,
291,
14,
5628,
8,
86,
9,
339,
327,
2654,
282,
574,
1901,
642,
27673,
11348,
12,
12928,
314,
5007,
11076,
14,
272,
347,
5389,
8,
277,
12,
574,
304,
267,
5762,
275,
574,
446,
291,
14,
6553,
267,
291,
14,
78,
847,
413,
267,
291,
14,
6553,
847,
5762,
1182,
291,
14,
78,
267,
291,
14,
77,
18,
847,
5762,
627,
334,
585,
446,
291,
14,
6553,
9,
267,
291,
14,
988,
1110,
275,
5696,
8,
277,
14,
988,
1110,
12,
574,
9,
267,
291,
14,
827,
1110,
275,
7481,
8,
277,
14,
827,
1110,
12,
574,
9,
398,
372,
291,
339,
327,
14076,
4573,
27673,
11348,
1901,
642,
1373,
12,
7791,
1536,
314,
5007,
11076,
14,
272,
347,
5389,
8257,
8,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
27673,
11348,
304,
288,
746,
2186,
480,
6049,
1454,
5389,
27673,
16558,
9124,
398,
340,
1163,
365,
291,
26,
221,
327,
3659,
16612,
15164,
288,
291,
14,
5628,
8,
1574,
14,
8293,
8,
1848,
430,
221,
327,
19503,
32592,
1504,
315,
282,
22965,
1865,
267,
587,
26,
288,
340,
291,
14,
78,
508,
378,
26,
355,
291,
14,
6553,
275,
1163,
14,
6553,
355,
291,
14,
77,
18,
275,
1163,
14,
77,
18,
355,
291,
14,
78,
275,
1163,
14,
78,
355,
291,
14,
988,
1110,
275,
1163,
14,
988,
1110,
355,
291,
14,
827,
1110,
275,
1163,
14,
827,
1110,
953,
916,
1163,
14,
78,
1137,
378,
26,
355,
5762,
275,
1163,
14,
6553,
446,
291,
14,
6553,
355,
340,
1163,
14,
78,
627,
1616,
665,
291,
14,
78,
26,
490,
291,
14,
6553,
275,
291,
14,
6553,
435,
334,
3136,
627,
1163,
14,
78,
9,
1182,
334,
277,
14,
78,
435,
1163,
14,
78,
9,
355,
916,
291,
14,
78,
627,
1616,
665,
1163,
14,
78,
26,
490,
291,
14,
6553,
275,
1163,
14,
6553,
446,
334,
3136,
627,
291,
14,
78,
9,
1182,
334,
277,
14,
78,
435,
1163,
14,
78,
9,
355,
587,
26,
490,
291,
14,
6553,
275,
334,
277,
14,
6553,
627,
291,
14,
78,
435,
1163,
14,
6553,
627,
1163,
14,
78,
9,
1182,
334,
277,
14,
78,
435,
1163,
14,
78,
9,
2234,
291,
14,
988,
1110,
275,
5696,
8,
277,
14,
988,
1110,
12,
1163,
14,
988,
1110,
9,
355,
291,
14,
827,
1110,
275,
7481,
8,
277,
14,
827,
1110,
12,
1163,
14,
827,
1110,
9,
2234,
291,
14,
77,
18,
847,
1163,
14,
77,
18,
435,
334,
3136,
627,
5762,
627,
291,
14,
78,
627,
1163,
14,
78,
9,
1182,
334,
277,
14,
78,
435,
1163,
14,
78,
9,
355,
291,
14,
78,
847,
1163,
14,
78,
267,
372,
291,
339,
327,
8465,
368,
642,
27673,
11348,
272,
347,
1331,
8,
277,
304,
267,
372,
1331,
14,
8293,
8,
277,
9,
339,
347,
2338,
8,
277,
304,
267,
372,
1109,
8,
277,
14,
78,
9,
339,
347,
4615,
8,
277,
304,
267,
372,
291,
14,
6553,
339,
347,
3089,
8,
277,
304,
267,
372,
291,
14,
78,
627,
291,
14,
6553,
339,
347,
1748,
8,
277,
304,
267,
372,
291,
14,
827,
1110,
339,
347,
1390,
8,
277,
304,
267,
372,
291,
14,
988,
1110,
339,
327,
1432,
314,
11773,
402,
314,
1338,
14,
272,
347,
11773,
8,
277,
304,
267,
340,
291,
14,
78,
508,
378,
26,
288,
372,
2069,
360,
4304,
358,
267,
587,
26,
288,
372,
291,
14,
77,
18,
1182,
291,
14,
78,
339,
327,
272,
327,
1432,
314,
2690,
11773,
12,
1314,
3211,
83,
367,
10671,
315,
4347,
3969,
316,
314,
11773,
701,
487,
11604,
272,
327,
701,
653,
13,
17,
3140,
402,
653,
14,
272,
327,
272,
347,
2690,
31805,
8,
277,
304,
267,
340,
291,
14,
78,
2695,
413,
26,
288,
372,
2069,
360,
4304,
358,
267,
587,
26,
288,
372,
291,
14,
77,
18,
1182,
334,
277,
14,
78,
446,
413,
9,
339,
327,
1432,
314,
4465,
18458,
402,
314,
1338,
14,
272,
347,
410,
2374,
8,
277,
304,
267,
372,
7452,
8,
277,
14,
6221,
1012,
339,
327,
272,
327,
1432,
314,
2690,
4465,
18458,
402,
314,
1338,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
yared-bezum/tweepy
|
tests/config.py
|
44
|
1093
|
import os
import vcr
from tweepy.auth import OAuthHandler
from tweepy.api import API
import six
if six.PY3:
import unittest
else:
import unittest2 as unittest
username = os.environ.get('TWITTER_USERNAME', 'tweepytest')
oauth_consumer_key = os.environ.get('CONSUMER_KEY', '')
oauth_consumer_secret = os.environ.get('CONSUMER_SECRET', '')
oauth_token = os.environ.get('ACCESS_KEY', '')
oauth_token_secret = os.environ.get('ACCESS_SECRET', '')
use_replay = os.environ.get('USE_REPLAY', False)
tape = vcr.VCR(
cassette_library_dir='cassettes',
filter_headers=['Authorization'],
serializer='json',
# Either use existing cassettes, or never use recordings:
record_mode='none' if use_replay else 'all',
)
class TweepyTestCase(unittest.TestCase):
def setUp(self):
self.auth = create_auth()
self.api = API(self.auth)
self.api.retry_count = 2
self.api.retry_delay = 5
def create_auth():
auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
auth.set_access_token(oauth_token, oauth_token_secret)
return auth
|
mit
|
[
646,
747,
199,
199,
646,
373,
1556,
199,
199,
504,
8900,
1024,
647,
14,
1178,
492,
11715,
2461,
199,
504,
8900,
1024,
647,
14,
1246,
492,
3261,
199,
199,
646,
3816,
199,
692,
3816,
14,
4521,
19,
26,
272,
492,
2882,
199,
2836,
26,
272,
492,
2882,
18,
465,
2882,
199,
199,
2473,
275,
747,
14,
2314,
14,
362,
360,
16491,
649,
1157,
63,
11958,
297,
283,
8122,
1024,
4462,
358,
199,
6126,
63,
8542,
63,
498,
275,
747,
14,
2314,
14,
362,
360,
1864,
13285,
540,
63,
3078,
297,
4074,
199,
6126,
63,
8542,
63,
4731,
275,
747,
14,
2314,
14,
362,
360,
1864,
13285,
540,
63,
12961,
297,
4074,
199,
6126,
63,
1418,
275,
747,
14,
2314,
14,
362,
360,
11074,
63,
3078,
297,
4074,
199,
6126,
63,
1418,
63,
4731,
275,
747,
14,
2314,
14,
362,
360,
11074,
63,
12961,
297,
4074,
199,
1180,
63,
19540,
275,
747,
14,
2314,
14,
362,
360,
4701,
63,
907,
11625,
297,
756,
9,
421,
199,
502,
321,
275,
373,
1556,
14,
54,
2944,
8,
272,
286,
6562,
266,
63,
4342,
63,
694,
534,
67,
6562,
744,
297,
272,
2457,
63,
2139,
2968,
11626,
995,
272,
9146,
534,
1001,
297,
272,
327,
13083,
675,
3411,
286,
6562,
744,
12,
503,
7078,
675,
2777,
780,
26,
272,
2777,
63,
632,
534,
3592,
7,
340,
675,
63,
19540,
587,
283,
452,
297,
199,
9,
421,
199,
533,
377,
25515,
647,
1746,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
1178,
275,
1218,
63,
1178,
342,
267,
291,
14,
1246,
275,
3261,
8,
277,
14,
1178,
9,
267,
291,
14,
1246,
14,
7154,
63,
835,
275,
499,
267,
291,
14,
1246,
14,
7154,
63,
5814,
275,
959,
421,
199,
318,
1218,
63,
1178,
837,
272,
1790,
275,
11715,
2461,
8,
6126,
63,
8542,
63,
498,
12,
9725,
63,
8542,
63,
4731,
9,
272,
1790,
14,
409,
63,
2732,
63,
1418,
8,
6126,
63,
1418,
12,
9725,
63,
1418,
63,
4731,
9,
272,
372,
1790,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
747,
199,
199,
646,
373,
1556,
199,
199,
504,
8900,
1024,
647,
14,
1178,
492,
11715,
2461,
199,
504,
8900,
1024,
647,
14,
1246,
492,
3261,
199,
199,
646,
3816,
199,
692,
3816,
14,
4521,
19,
26,
272,
492,
2882,
199,
2836,
26,
272,
492,
2882,
18,
465,
2882,
199,
199,
2473,
275,
747,
14,
2314,
14,
362,
360,
16491,
649,
1157,
63,
11958,
297,
283,
8122,
1024,
4462,
358,
199,
6126,
63,
8542,
63,
498,
275,
747,
14,
2314,
14,
362,
360,
1864,
13285,
540,
63,
3078,
297,
4074,
199,
6126,
63,
8542,
63,
4731,
275,
747,
14,
2314,
14,
362,
360,
1864,
13285,
540,
63,
12961,
297,
4074,
199,
6126,
63,
1418,
275,
747,
14,
2314,
14,
362,
360,
11074,
63,
3078,
297,
4074,
199,
6126,
63,
1418,
63,
4731,
275,
747,
14,
2314,
14,
362,
360,
11074,
63,
12961,
297,
4074,
199,
1180,
63,
19540,
275,
747,
14,
2314,
14,
362,
360,
4701,
63,
907,
11625,
297,
756,
9,
421,
199,
502,
321,
275,
373,
1556,
14,
54,
2944,
8,
272,
286,
6562,
266,
63,
4342,
63,
694,
534,
67,
6562,
744,
297,
272,
2457,
63,
2139,
2968,
11626,
995,
272,
9146,
534,
1001,
297,
272,
327,
13083,
675,
3411,
286,
6562,
744,
12,
503,
7078,
675,
2777,
780,
26,
272,
2777,
63,
632,
534,
3592,
7,
340,
675,
63,
19540,
587,
283,
452,
297,
199,
9,
421,
199,
533,
377,
25515,
647,
1746,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
1178,
275,
1218,
63,
1178,
342,
267,
291,
14,
1246,
275,
3261,
8,
277,
14,
1178,
9,
267,
291,
14,
1246,
14,
7154,
63,
835,
275,
499,
267,
291,
14,
1246,
14,
7154,
63,
5814,
275,
959,
421,
199,
318,
1218,
63,
1178,
837,
272,
1790,
275,
11715,
2461,
8,
6126,
63,
8542,
63,
498,
12,
9725,
63,
8542,
63,
4731,
9,
272,
1790,
14,
409,
63,
2732,
63,
1418,
8,
6126,
63,
1418,
12,
9725,
63,
1418,
63,
4731,
9,
272,
372,
1790,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
Russell-IO/ansible
|
test/units/plugins/action/test_raw.py
|
44
|
3774
|
# (c) 2016, Saran Ahluwalia <ahlusar.ahluwalia@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.errors import AnsibleActionFail
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import patch, MagicMock, Mock
from ansible.plugins.action.raw import ActionModule
from ansible.playbook.task import Task
class TestCopyResultExclude(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
# The current behavior of the raw aciton in regards to executable is currently in question;
# the test_raw_executable_is_not_empty_string verifies the current behavior (whether it is desireed or not.
# Please refer to the following for context:
# Issue: https://github.com/ansible/ansible/issues/16054
# PR: https://github.com/ansible/ansible/pull/16085
def test_raw_executable_is_not_empty_string(self):
play_context = Mock()
task = MagicMock(Task)
task.async_val = False
connection = Mock()
task.args = {'_raw_params': 'Args1'}
play_context.check_mode = False
self.mock_am = ActionModule(task, connection, play_context, loader=None, templar=None, shared_loader_obj=None)
self.mock_am._low_level_execute_command = Mock(return_value={})
self.mock_am.display = Mock()
self.mock_am.run()
self.mock_am._low_level_execute_command.assert_called_with('Args1', executable=False)
def test_raw_check_mode_is_True(self):
play_context = Mock()
task = MagicMock(Task)
task.async_val = False
connection = Mock()
task.args = {'_raw_params': 'Args1'}
play_context.check_mode = True
try:
self.mock_am = ActionModule(task, connection, play_context, loader=None, templar=None, shared_loader_obj=None)
except AnsibleActionFail:
pass
def test_raw_test_environment_is_None(self):
play_context = Mock()
task = MagicMock(Task)
task.async_val = False
connection = Mock()
task.args = {'_raw_params': 'Args1'}
task.environment = None
play_context.check_mode = False
self.mock_am = ActionModule(task, connection, play_context, loader=None, templar=None, shared_loader_obj=None)
self.mock_am._low_level_execute_command = Mock(return_value={})
self.mock_am.display = Mock()
self.assertEqual(task.environment, None)
def test_raw_task_vars_is_not_None(self):
play_context = Mock()
task = MagicMock(Task)
task.async_val = False
connection = Mock()
task.args = {'_raw_params': 'Args1'}
task.environment = None
play_context.check_mode = False
self.mock_am = ActionModule(task, connection, play_context, loader=None, templar=None, shared_loader_obj=None)
self.mock_am._low_level_execute_command = Mock(return_value={})
self.mock_am.display = Mock()
self.mock_am.run(task_vars={'a': 'b'})
self.assertEqual(task.environment, None)
|
gpl-3.0
|
[
3,
334,
67,
9,
7800,
12,
428,
285,
290,
437,
72,
10836,
87,
19221,
665,
11326,
24879,
285,
14,
11326,
10836,
87,
19221,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
2550,
492,
2622,
3310,
4874,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
504,
3242,
14,
5819,
14,
2219,
14,
1805,
492,
3371,
12,
10079,
12,
4420,
199,
504,
3242,
14,
5265,
14,
1287,
14,
1773,
492,
10033,
2377,
199,
504,
3242,
14,
14205,
14,
1765,
492,
8495,
421,
199,
533,
1379,
5116,
2889,
29448,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
986,
339,
347,
6766,
8,
277,
304,
267,
986,
339,
327,
710,
1453,
5953,
402,
314,
3066,
1066,
390,
265,
315,
1295,
5596,
370,
7286,
365,
5544,
315,
7894,
27,
272,
327,
314,
511,
63,
1773,
63,
5904,
63,
374,
63,
1397,
63,
1667,
63,
875,
22694,
314,
1453,
5953,
334,
87,
3081,
652,
365,
477,
338,
3798,
503,
440,
14,
272,
327,
7754,
10618,
370,
314,
2569,
367,
1067,
26,
272,
327,
13383,
26,
4178,
921,
5031,
14,
957,
15,
4853,
15,
4853,
15,
10115,
15,
8488,
1477,
272,
327,
12218,
26,
4178,
921,
5031,
14,
957,
15,
4853,
15,
4853,
15,
9302,
15,
975,
17494,
339,
347,
511,
63,
1773,
63,
5904,
63,
374,
63,
1397,
63,
1667,
63,
875,
8,
277,
304,
398,
5232,
63,
1100,
275,
4420,
342,
267,
2120,
275,
10079,
8,
4476,
9,
267,
2120,
14,
4146,
63,
637,
275,
756,
267,
1950,
275,
4420,
342,
398,
2120,
14,
589,
275,
32136,
1773,
63,
1162,
356,
283,
6213,
17,
936,
267,
5232,
63,
1100,
14,
1074,
63,
632,
275,
756,
398,
291,
14,
1805,
63,
455,
275,
10033,
2377,
8,
1765,
12,
1950,
12,
5232,
63,
1100,
12,
5077,
29,
403,
12,
28038,
29,
403,
12,
5709,
63,
3422,
63,
1113,
29,
403,
9,
267,
291,
14,
1805,
63,
455,
423,
674,
63,
1896,
63,
2526,
63,
1531,
275,
4420,
8,
1107,
63,
585,
21146,
267,
291,
14,
1805,
63,
455,
14,
2918,
275,
4420,
342,
398,
291,
14,
1805,
63,
455,
14,
1065,
342,
267,
291,
14,
1805,
63,
455,
423,
674,
63,
1896,
63,
2526,
63,
1531,
14,
479,
63,
3527,
63,
1045,
360,
6213,
17,
297,
7286,
29,
797,
9,
339,
347,
511,
63,
1773,
63,
1074,
63,
632,
63,
374,
63,
549,
8,
277,
304,
398,
5232,
63,
1100,
275,
4420,
342,
267,
2120,
275,
10079,
8,
4476,
9,
267,
2120,
14,
4146,
63,
637,
275,
756,
267,
1950,
275,
4420,
342,
398,
2120,
14,
589,
275,
32136,
1773,
63,
1162,
356,
283,
6213,
17,
936,
267,
5232,
63,
1100,
14,
1074,
63,
632,
275,
715,
398,
862,
26,
288,
291,
14,
1805,
63,
455,
275,
10033,
2377,
8,
1765,
12,
1950,
12,
5232,
63,
1100,
12,
5077,
29,
403,
12,
28038,
29,
403,
12,
5709,
63,
3422,
63,
1113,
29,
403,
9,
267,
871,
2622,
3310,
4874,
26,
288,
986,
339,
347,
511,
63,
1773,
63,
396,
63,
5418,
63,
374,
63,
403,
8,
277,
304,
398,
5232,
63,
1100,
275,
4420,
342,
267,
2120,
275,
10079,
8,
4476,
9,
267,
2120,
14,
4146,
63,
637,
275,
756,
267,
1950,
275,
4420,
342,
398,
2120,
14,
589,
275,
32136,
1773,
63,
1162,
356,
283,
6213,
17,
936,
267,
2120,
14,
5418,
275,
488,
267,
5232,
63,
1100,
14,
1074,
63,
632,
275,
756,
398,
291,
14,
1805,
63,
455,
275,
10033,
2377,
8,
1765,
12,
1950,
12,
5232,
63,
1100,
12,
5077,
29,
403,
12,
28038,
29,
403,
12,
5709,
63,
3422,
63,
1113,
29,
403,
9,
267,
291,
14,
1805,
63,
455,
423,
674,
63,
1896,
63,
2526,
63,
1531,
275,
4420,
8,
1107,
63,
585,
21146,
267,
291,
14,
1805,
63,
455,
14,
2918,
275,
4420,
342,
398,
291,
14,
629,
8,
1765,
14,
5418,
12,
488,
9,
339,
347,
511,
63,
1773,
63,
1765,
63,
2936,
63,
374,
63,
1397,
63,
403,
8,
277,
304,
398,
5232,
63,
1100,
275,
4420,
342,
267,
2120,
275,
10079,
8,
4476,
9,
267,
2120,
14,
4146,
63,
637,
275,
756,
267,
1950,
275,
4420,
342,
398,
2120,
14,
589,
275,
32136,
1773,
63,
1162,
356,
283,
6213,
17,
936,
267,
2120,
14,
5418,
275,
488,
267,
5232,
63,
1100,
14,
1074,
63,
632,
275,
756,
398,
291,
14,
1805,
63,
455,
275,
10033,
2377,
8,
1765,
12,
1950,
12,
5232,
63,
1100,
12,
5077,
29,
403,
12,
28038,
29,
403,
12,
5709,
63,
3422,
63,
1113,
29,
403,
9,
267,
291,
14,
1805,
63,
455,
423,
674,
63,
1896,
63,
2526,
63,
1531,
275,
4420,
8,
1107,
63,
585,
21146,
267,
291,
14,
1805,
63,
455,
14,
2918,
275,
4420,
342,
398,
291,
14,
1805,
63,
455,
14,
1065,
8,
1765,
63,
2936,
3713,
65,
356,
283,
66,
3071,
267,
291,
14,
629,
8,
1765,
14,
5418,
12,
488,
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
] |
[
334,
67,
9,
7800,
12,
428,
285,
290,
437,
72,
10836,
87,
19221,
665,
11326,
24879,
285,
14,
11326,
10836,
87,
19221,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
2550,
492,
2622,
3310,
4874,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
504,
3242,
14,
5819,
14,
2219,
14,
1805,
492,
3371,
12,
10079,
12,
4420,
199,
504,
3242,
14,
5265,
14,
1287,
14,
1773,
492,
10033,
2377,
199,
504,
3242,
14,
14205,
14,
1765,
492,
8495,
421,
199,
533,
1379,
5116,
2889,
29448,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
986,
339,
347,
6766,
8,
277,
304,
267,
986,
339,
327,
710,
1453,
5953,
402,
314,
3066,
1066,
390,
265,
315,
1295,
5596,
370,
7286,
365,
5544,
315,
7894,
27,
272,
327,
314,
511,
63,
1773,
63,
5904,
63,
374,
63,
1397,
63,
1667,
63,
875,
22694,
314,
1453,
5953,
334,
87,
3081,
652,
365,
477,
338,
3798,
503,
440,
14,
272,
327,
7754,
10618,
370,
314,
2569,
367,
1067,
26,
272,
327,
13383,
26,
4178,
921,
5031,
14,
957,
15,
4853,
15,
4853,
15,
10115,
15,
8488,
1477,
272,
327,
12218,
26,
4178,
921,
5031,
14,
957,
15,
4853,
15,
4853,
15,
9302,
15,
975,
17494,
339,
347,
511,
63,
1773,
63,
5904,
63,
374,
63,
1397,
63,
1667,
63,
875,
8,
277,
304,
398,
5232,
63,
1100,
275,
4420,
342,
267,
2120,
275,
10079,
8,
4476,
9,
267,
2120,
14,
4146,
63,
637,
275,
756,
267,
1950,
275,
4420,
342,
398,
2120,
14,
589,
275,
32136,
1773,
63,
1162,
356,
283,
6213,
17,
936,
267,
5232,
63,
1100,
14,
1074,
63,
632,
275,
756,
398,
291,
14,
1805,
63,
455,
275,
10033,
2377,
8,
1765,
12,
1950,
12,
5232,
63,
1100,
12,
5077,
29,
403,
12,
28038,
29,
403,
12,
5709,
63,
3422,
63,
1113,
29,
403,
9,
267,
291,
14,
1805,
63,
455,
423,
674,
63,
1896,
63,
2526,
63,
1531,
275,
4420,
8,
1107,
63,
585,
21146,
267,
291,
14,
1805,
63,
455,
14,
2918,
275,
4420,
342,
398,
291,
14,
1805,
63,
455,
14,
1065,
342,
267,
291,
14,
1805,
63,
455,
423,
674,
63,
1896,
63,
2526,
63,
1531,
14,
479,
63,
3527,
63,
1045,
360,
6213,
17,
297,
7286,
29,
797,
9,
339,
347,
511,
63,
1773,
63,
1074,
63,
632,
63,
374,
63,
549,
8,
277,
304,
398,
5232,
63,
1100,
275,
4420,
342,
267,
2120,
275,
10079,
8,
4476,
9,
267,
2120,
14,
4146,
63,
637,
275,
756,
267,
1950,
275,
4420,
342,
398,
2120,
14,
589,
275,
32136,
1773,
63,
1162,
356,
283,
6213,
17,
936,
267,
5232,
63,
1100,
14,
1074,
63,
632,
275,
715,
398,
862,
26,
288,
291,
14,
1805,
63,
455,
275,
10033,
2377,
8,
1765,
12,
1950,
12,
5232,
63,
1100,
12,
5077,
29,
403,
12,
28038,
29,
403,
12,
5709,
63,
3422,
63,
1113,
29,
403,
9,
267,
871,
2622,
3310,
4874,
26,
288,
986,
339,
347,
511,
63,
1773,
63,
396,
63,
5418,
63,
374,
63,
403,
8,
277,
304,
398,
5232,
63,
1100,
275,
4420,
342,
267,
2120,
275,
10079,
8,
4476,
9,
267,
2120,
14,
4146,
63,
637,
275,
756,
267,
1950,
275,
4420,
342,
398,
2120,
14,
589,
275,
32136,
1773,
63,
1162,
356,
283,
6213,
17,
936,
267,
2120,
14,
5418,
275,
488,
267,
5232,
63,
1100,
14,
1074,
63,
632,
275,
756,
398,
291,
14,
1805,
63,
455,
275,
10033,
2377,
8,
1765,
12,
1950,
12,
5232,
63,
1100,
12,
5077,
29,
403,
12,
28038,
29,
403,
12,
5709,
63,
3422,
63,
1113,
29,
403,
9,
267,
291,
14,
1805,
63,
455,
423,
674,
63,
1896,
63,
2526,
63,
1531,
275,
4420,
8,
1107,
63,
585,
21146,
267,
291,
14,
1805,
63,
455,
14,
2918,
275,
4420,
342,
398,
291,
14,
629,
8,
1765,
14,
5418,
12,
488,
9,
339,
347,
511,
63,
1773,
63,
1765,
63,
2936,
63,
374,
63,
1397,
63,
403,
8,
277,
304,
398,
5232,
63,
1100,
275,
4420,
342,
267,
2120,
275,
10079,
8,
4476,
9,
267,
2120,
14,
4146,
63,
637,
275,
756,
267,
1950,
275,
4420,
342,
398,
2120,
14,
589,
275,
32136,
1773,
63,
1162,
356,
283,
6213,
17,
936,
267,
2120,
14,
5418,
275,
488,
267,
5232,
63,
1100,
14,
1074,
63,
632,
275,
756,
398,
291,
14,
1805,
63,
455,
275,
10033,
2377,
8,
1765,
12,
1950,
12,
5232,
63,
1100,
12,
5077,
29,
403,
12,
28038,
29,
403,
12,
5709,
63,
3422,
63,
1113,
29,
403,
9,
267,
291,
14,
1805,
63,
455,
423,
674,
63,
1896,
63,
2526,
63,
1531,
275,
4420,
8,
1107,
63,
585,
21146,
267,
291,
14,
1805,
63,
455,
14,
2918,
275,
4420,
342,
398,
291,
14,
1805,
63,
455,
14,
1065,
8,
1765,
63,
2936,
3713,
65,
356,
283,
66,
3071,
267,
291,
14,
629,
8,
1765,
14,
5418,
12,
488,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jimka2001/MuseScore
|
thirdparty/freetype/src/tools/docmaker/utils.py
|
153
|
3513
|
#
# utils.py
#
# Auxiliary functions for the `docmaker' tool (library file).
#
# Copyright 2002-2015 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
# modified, and distributed under the terms of the FreeType project
# license, LICENSE.TXT. By continuing to use, modify, or distribute
# this file you indicate that you have read the license and
# understand and accept it fully.
import string, sys, os, glob, itertools
# current output directory
#
output_dir = None
# A function that generates a sorting key. We want lexicographical order
# (primary key) except that capital letters are sorted before lowercase
# ones (secondary key).
#
# The primary key is implemented by lowercasing the input. The secondary
# key is simply the original data appended, character by character. For
# example, the sort key for `FT_x' is `fFtT__xx', while the sort key for
# `ft_X' is `fftt__xX'. Since ASCII codes of uppercase letters are
# numerically smaller than the codes of lowercase letters, `fFtT__xx' gets
# sorted before `fftt__xX'.
#
def index_key( s ):
return string.join( itertools.chain( *zip( s.lower(), s ) ) )
# Sort `input_list', placing the elements of `order_list' in front.
#
def sort_order_list( input_list, order_list ):
new_list = order_list[:]
for id in input_list:
if not id in order_list:
new_list.append( id )
return new_list
# Divert standard output to a given project documentation file. Use
# `output_dir' to determine the filename location if necessary and save the
# old stdout handle in a tuple that is returned by this function.
#
def open_output( filename ):
global output_dir
if output_dir and output_dir != "":
filename = output_dir + os.sep + filename
old_stdout = sys.stdout
new_file = open( filename, "w" )
sys.stdout = new_file
return ( new_file, old_stdout )
# Close the output that was returned by `open_output'.
#
def close_output( output ):
output[0].close()
sys.stdout = output[1]
# Check output directory.
#
def check_output():
global output_dir
if output_dir:
if output_dir != "":
if not os.path.isdir( output_dir ):
sys.stderr.write( "argument"
+ " '" + output_dir + "' "
+ "is not a valid directory\n" )
sys.exit( 2 )
else:
output_dir = None
def file_exists( pathname ):
"""Check that a given file exists."""
result = 1
try:
file = open( pathname, "r" )
file.close()
except:
result = None
sys.stderr.write( pathname + " couldn't be accessed\n" )
return result
def make_file_list( args = None ):
"""Build a list of input files from command-line arguments."""
file_list = []
# sys.stderr.write( repr( sys.argv[1 :] ) + '\n' )
if not args:
args = sys.argv[1:]
for pathname in args:
if string.find( pathname, '*' ) >= 0:
newpath = glob.glob( pathname )
newpath.sort() # sort files -- this is important because
# of the order of files
else:
newpath = [pathname]
file_list.extend( newpath )
if len( file_list ) == 0:
file_list = None
else:
# now filter the file list to remove non-existing ones
file_list = filter( file_exists, file_list )
return file_list
# eof
|
gpl-2.0
|
[
3,
199,
3,
221,
3778,
14,
647,
199,
3,
199,
3,
259,
437,
2521,
20524,
3423,
367,
314,
658,
1301,
14367,
7,
4744,
334,
4342,
570,
680,
199,
3,
199,
3,
221,
1898,
14790,
13,
7806,
701,
199,
3,
221,
20232,
16147,
281,
14,
199,
3,
199,
3,
221,
961,
570,
365,
1777,
402,
314,
2868,
804,
2199,
12,
436,
1443,
1454,
506,
1202,
12,
199,
3,
221,
6042,
12,
436,
1854,
1334,
314,
2895,
402,
314,
2868,
804,
2199,
199,
3,
221,
4190,
12,
5113,
14,
17715,
14,
221,
4885,
32620,
370,
675,
12,
2811,
12,
503,
11207,
199,
3,
221,
642,
570,
1265,
6623,
626,
1265,
1172,
1586,
314,
4190,
436,
199,
3,
221,
20647,
436,
4729,
652,
9999,
14,
421,
199,
646,
1059,
12,
984,
12,
747,
12,
5739,
12,
7975,
421,
199,
3,
1453,
1072,
2082,
199,
3,
199,
1199,
63,
694,
275,
488,
421,
199,
3,
437,
805,
626,
12821,
282,
13351,
790,
14,
221,
2136,
2934,
1026,
30077,
2180,
2652,
1865,
199,
3,
334,
3327,
790,
9,
871,
626,
17094,
14435,
787,
3355,
2544,
12141,
199,
3,
7869,
334,
12371,
790,
680,
199,
3,
199,
3,
710,
5062,
790,
365,
6366,
701,
5117,
9765,
316,
314,
1324,
14,
221,
710,
13851,
199,
3,
790,
365,
9329,
314,
3379,
666,
11544,
12,
4528,
701,
4528,
14,
221,
2104,
199,
3,
2893,
12,
314,
4069,
790,
367,
658,
2161,
63,
88,
7,
365,
658,
70,
38,
84,
52,
363,
2154,
297,
1830,
314,
4069,
790,
367,
199,
3,
658,
856,
63,
56,
7,
365,
658,
556,
6215,
363,
24110,
1370,
221,
9336,
10485,
9479,
402,
22681,
14435,
787,
199,
3,
8950,
1183,
12700,
2419,
314,
9479,
402,
12141,
14435,
12,
658,
70,
38,
84,
52,
363,
2154,
7,
7545,
199,
3,
3355,
2544,
658,
556,
6215,
363,
24110,
1370,
199,
3,
199,
318,
221,
1478,
63,
498,
8,
308,
3461,
272,
372,
1059,
14,
904,
8,
7975,
14,
4429,
8,
627,
3065,
8,
308,
14,
2325,
1062,
308,
776,
776,
776,
421,
199,
3,
16722,
658,
1210,
63,
513,
297,
299,
13121,
314,
4008,
402,
658,
1648,
63,
513,
7,
315,
13738,
14,
199,
3,
199,
318,
221,
4069,
63,
1648,
63,
513,
8,
1324,
63,
513,
12,
1865,
63,
513,
3461,
272,
892,
63,
513,
275,
1865,
63,
513,
5873,
272,
367,
1305,
315,
1324,
63,
513,
26,
267,
340,
440,
1305,
315,
1865,
63,
513,
26,
288,
892,
63,
513,
14,
740,
8,
1305,
776,
272,
372,
892,
63,
513,
421,
199,
3,
3757,
1884,
4465,
1072,
370,
282,
1627,
2199,
3794,
570,
14,
221,
3645,
199,
3,
658,
1199,
63,
694,
7,
370,
6705,
314,
1788,
2909,
340,
5784,
436,
3354,
314,
199,
3,
2269,
3839,
2429,
315,
282,
2008,
626,
365,
2138,
701,
642,
805,
14,
199,
3,
199,
318,
221,
1551,
63,
1199,
8,
1788,
3461,
272,
2288,
1072,
63,
694,
339,
340,
1072,
63,
694,
436,
1072,
63,
694,
1137,
10812,
267,
1788,
275,
1072,
63,
694,
435,
747,
14,
4127,
435,
1788,
339,
2269,
63,
2703,
275,
984,
14,
2703,
272,
892,
63,
493,
257,
275,
1551,
8,
1788,
12,
298,
87,
2,
776,
272,
984,
14,
2703,
275,
892,
63,
493,
339,
372,
334,
892,
63,
493,
12,
2269,
63,
2703,
776,
421,
199,
3,
15524,
314,
1072,
626,
1990,
2138,
701,
658,
1490,
63,
1199,
1370,
199,
3,
199,
318,
221,
4002,
63,
1199,
8,
1072,
3461,
272,
1072,
59,
16,
1055,
1600,
342,
272,
984,
14,
2703,
275,
1072,
59,
17,
61,
421,
199,
3,
2670,
1072,
2082,
14,
199,
3,
199,
318,
221,
1104,
63,
1199,
837,
272,
2288,
1072,
63,
694,
272,
340,
1072,
63,
694,
26,
267,
340,
1072,
63,
694,
1137,
10812,
288,
340,
440,
747,
14,
515,
14,
6027,
8,
1072,
63,
694,
3461,
355,
984,
14,
3083,
14,
952,
8,
298,
2094,
2,
3303,
435,
298,
5522,
435,
1072,
63,
694,
435,
3546,
298,
3303,
435,
298,
374,
440,
282,
1686,
2082,
60,
78,
2,
776,
355,
984,
14,
2224,
8,
499,
776,
267,
587,
26,
288,
1072,
63,
694,
275,
488,
421,
199,
318,
221,
570,
63,
2444,
8,
11776,
3461,
272,
408,
1799,
626,
282,
1627,
570,
3495,
1041,
272,
754,
275,
413,
272,
862,
26,
267,
570,
275,
1551,
8,
11776,
12,
298,
82,
2,
776,
267,
570,
14,
1600,
342,
272,
871,
26,
267,
754,
275,
488,
267,
984,
14,
3083,
14,
952,
8,
11776,
435,
298,
21554,
1133,
506,
13810,
60,
78,
2,
776,
339,
372,
754,
421,
199,
318,
221,
1852,
63,
493,
63,
513,
8,
1249,
275,
488,
3461,
272,
408,
3425,
282,
769,
402,
1324,
1584,
687,
1414,
13,
604,
2368,
1041,
272,
570,
63,
513,
275,
942,
272,
327,
984,
14,
3083,
14,
952,
8,
4700,
8,
984,
14,
3020,
59,
17,
12228,
776,
435,
1557,
78,
7,
776,
339,
340,
440,
1249,
26,
267,
1249,
275,
984,
14,
3020,
59,
17,
2938,
339,
367,
11776,
315,
1249,
26,
267,
340,
1059,
14,
1623,
8,
11776,
12,
13626,
776,
2356,
378,
26,
288,
30965,
275,
5739,
14,
6463,
8,
11776,
776,
288,
30965,
14,
3191,
342,
221,
327,
4069,
1584,
1553,
642,
365,
11012,
2952,
1169,
327,
402,
314,
1865,
402,
1584,
267,
587,
26,
288,
30965,
275,
359,
12445,
61,
398,
570,
63,
513,
14,
2880,
8,
30965,
776,
339,
340,
822,
8,
570,
63,
513,
776,
508,
378,
26,
267,
570,
63,
513,
275,
488,
272,
587,
26,
267,
327,
3063,
2457,
314,
570,
769,
370,
2813,
2222,
13,
5952,
7869,
267,
570,
63,
513,
275,
2457,
8,
570,
63,
2444,
12,
570,
63,
513,
776,
339,
372,
570,
63,
513,
199,
199,
3,
29403,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
221,
3778,
14,
647,
199,
3,
199,
3,
259,
437,
2521,
20524,
3423,
367,
314,
658,
1301,
14367,
7,
4744,
334,
4342,
570,
680,
199,
3,
199,
3,
221,
1898,
14790,
13,
7806,
701,
199,
3,
221,
20232,
16147,
281,
14,
199,
3,
199,
3,
221,
961,
570,
365,
1777,
402,
314,
2868,
804,
2199,
12,
436,
1443,
1454,
506,
1202,
12,
199,
3,
221,
6042,
12,
436,
1854,
1334,
314,
2895,
402,
314,
2868,
804,
2199,
199,
3,
221,
4190,
12,
5113,
14,
17715,
14,
221,
4885,
32620,
370,
675,
12,
2811,
12,
503,
11207,
199,
3,
221,
642,
570,
1265,
6623,
626,
1265,
1172,
1586,
314,
4190,
436,
199,
3,
221,
20647,
436,
4729,
652,
9999,
14,
421,
199,
646,
1059,
12,
984,
12,
747,
12,
5739,
12,
7975,
421,
199,
3,
1453,
1072,
2082,
199,
3,
199,
1199,
63,
694,
275,
488,
421,
199,
3,
437,
805,
626,
12821,
282,
13351,
790,
14,
221,
2136,
2934,
1026,
30077,
2180,
2652,
1865,
199,
3,
334,
3327,
790,
9,
871,
626,
17094,
14435,
787,
3355,
2544,
12141,
199,
3,
7869,
334,
12371,
790,
680,
199,
3,
199,
3,
710,
5062,
790,
365,
6366,
701,
5117,
9765,
316,
314,
1324,
14,
221,
710,
13851,
199,
3,
790,
365,
9329,
314,
3379,
666,
11544,
12,
4528,
701,
4528,
14,
221,
2104,
199,
3,
2893,
12,
314,
4069,
790,
367,
658,
2161,
63,
88,
7,
365,
658,
70,
38,
84,
52,
363,
2154,
297,
1830,
314,
4069,
790,
367,
199,
3,
658,
856,
63,
56,
7,
365,
658,
556,
6215,
363,
24110,
1370,
221,
9336,
10485,
9479,
402,
22681,
14435,
787,
199,
3,
8950,
1183,
12700,
2419,
314,
9479,
402,
12141,
14435,
12,
658,
70,
38,
84,
52,
363,
2154,
7,
7545,
199,
3,
3355,
2544,
658,
556,
6215,
363,
24110,
1370,
199,
3,
199,
318,
221,
1478,
63,
498,
8,
308,
3461,
272,
372,
1059,
14,
904,
8,
7975,
14,
4429,
8,
627,
3065,
8,
308,
14,
2325,
1062,
308,
776,
776,
776,
421,
199,
3,
16722,
658,
1210,
63,
513,
297,
299,
13121,
314,
4008,
402,
658,
1648,
63,
513,
7,
315,
13738,
14,
199,
3,
199,
318,
221,
4069,
63,
1648,
63,
513,
8,
1324,
63,
513,
12,
1865,
63,
513,
3461,
272,
892,
63,
513,
275,
1865,
63,
513,
5873,
272,
367,
1305,
315,
1324,
63,
513,
26,
267,
340,
440,
1305,
315,
1865,
63,
513,
26,
288,
892,
63,
513,
14,
740,
8,
1305,
776,
272,
372,
892,
63,
513,
421,
199,
3,
3757,
1884,
4465,
1072,
370,
282,
1627,
2199,
3794,
570,
14,
221,
3645,
199,
3,
658,
1199,
63,
694,
7,
370,
6705,
314,
1788,
2909,
340,
5784,
436,
3354,
314,
199,
3,
2269,
3839,
2429,
315,
282,
2008,
626,
365,
2138,
701,
642,
805,
14,
199,
3,
199,
318,
221,
1551,
63,
1199,
8,
1788,
3461,
272,
2288,
1072,
63,
694,
339,
340,
1072,
63,
694,
436,
1072,
63,
694,
1137,
10812,
267,
1788,
275,
1072,
63,
694,
435,
747,
14,
4127,
435,
1788,
339,
2269,
63,
2703,
275,
984,
14,
2703,
272,
892,
63,
493,
257,
275,
1551,
8,
1788,
12,
298,
87,
2,
776,
272,
984,
14,
2703,
275,
892,
63,
493,
339,
372,
334,
892,
63,
493,
12,
2269,
63,
2703,
776,
421,
199,
3,
15524,
314,
1072,
626,
1990,
2138,
701,
658,
1490,
63,
1199,
1370,
199,
3,
199,
318,
221,
4002,
63,
1199,
8,
1072,
3461,
272,
1072,
59,
16,
1055,
1600,
342,
272,
984,
14,
2703,
275,
1072,
59,
17,
61,
421,
199,
3,
2670,
1072,
2082,
14,
199,
3,
199,
318,
221,
1104,
63,
1199,
837,
272,
2288,
1072,
63,
694,
272,
340,
1072,
63,
694,
26,
267,
340,
1072,
63,
694,
1137,
10812,
288,
340,
440,
747,
14,
515,
14,
6027,
8,
1072,
63,
694,
3461,
355,
984,
14,
3083,
14,
952,
8,
298,
2094,
2,
3303,
435,
298,
5522,
435,
1072,
63,
694,
435,
3546,
298,
3303,
435,
298,
374,
440,
282,
1686,
2082,
60,
78,
2,
776,
355,
984,
14,
2224,
8,
499,
776,
267,
587,
26,
288,
1072,
63,
694,
275,
488,
421,
199,
318,
221,
570,
63,
2444,
8,
11776,
3461,
272,
408,
1799,
626,
282,
1627,
570,
3495,
1041,
272,
754,
275,
413,
272,
862,
26,
267,
570,
275,
1551,
8,
11776,
12,
298,
82,
2,
776,
267,
570,
14,
1600,
342,
272,
871,
26,
267,
754,
275,
488,
267,
984,
14,
3083,
14,
952,
8,
11776,
435,
298,
21554,
1133,
506,
13810,
60,
78,
2,
776,
339,
372,
754,
421,
199,
318,
221,
1852,
63,
493,
63,
513,
8,
1249,
275,
488,
3461,
272,
408,
3425,
282,
769,
402,
1324,
1584,
687,
1414,
13,
604,
2368,
1041,
272,
570,
63,
513,
275,
942,
272,
327,
984,
14,
3083,
14,
952,
8,
4700,
8,
984,
14,
3020,
59,
17,
12228,
776,
435,
1557,
78,
7,
776,
339,
340,
440,
1249,
26,
267,
1249,
275,
984,
14,
3020,
59,
17,
2938,
339,
367,
11776,
315,
1249,
26,
267,
340,
1059,
14,
1623,
8,
11776,
12,
13626,
776,
2356,
378,
26,
288,
30965,
275,
5739,
14,
6463,
8,
11776,
776,
288,
30965,
14,
3191,
342,
221,
327,
4069,
1584,
1553,
642,
365,
11012,
2952,
1169,
327,
402,
314,
1865,
402,
1584,
267,
587,
26,
288,
30965,
275,
359,
12445,
61,
398,
570,
63,
513,
14,
2880,
8,
30965,
776,
339,
340,
822,
8,
570,
63,
513,
776,
508,
378,
26,
267,
570,
63,
513,
275,
488,
272,
587,
26,
267,
327,
3063,
2457,
314,
570,
769,
370,
2813,
2222,
13,
5952,
7869,
267,
570,
63,
513,
275,
2457,
8,
570,
63,
2444,
12,
570,
63,
513,
776,
339,
372,
570,
63,
513,
199,
199,
3,
29403,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
AlertaDengue/InfoDenguePredict
|
infodenguepredict/predict.py
|
2
|
2129
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This is predict script. Running it returns the prediction using the selected model
To run this script uncomment the following line in the
entry_points section in setup.cfg:
console_scripts =
predict = infodenguepredict.predict:run
"""
import argparse
import sys
import logging
from infodenguepredict import __version__
__author__ = "Flávio Codeço Coelho"
__copyright__ = "Flávio Codeço Coelho"
__license__ = "gpl3"
_logger = logging.getLogger(__name__)
def predict(model, test_data):
"""
generate prediction from existing model based on test data
:param model: Trained model saved previously
:param test_data: data from which to generate the predictions
:return:
"""
pass
def parse_args(args):
"""
Parse command line parameters
:param args: command line parameters as list of strings
:return: command line parameters as :obj:`argparse.Namespace`
"""
parser = argparse.ArgumentParser(
description="Incidence prediction tool")
parser.add_argument(
'--version',
action='version',
version='InfoDenguePredict {ver}'.format(ver=__version__))
parser.add_argument(
dest="m",
help="model file",
type=str,
metavar="INT")
parser.add_argument(
dest="d",
help="Test data file (CSV)",
type=str
)
parser.add_argument(
'-v',
'--verbose',
dest="loglevel",
help="set loglevel to INFO",
action='store_const',
const=logging.INFO)
parser.add_argument(
'-vv',
'--very-verbose',
dest="loglevel",
help="set loglevel to DEBUG",
action='store_const',
const=logging.DEBUG)
return parser.parse_args(args)
def main(args):
args = parse_args(args)
logging.basicConfig(level=args.loglevel, stream=sys.stdout)
_logger.debug("Generating predition...")
print("The predicted incidence is...")
_logger.info("Script ends here")
def run():
main(sys.argv[1:])
if __name__ == "__main__":
run()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
2765,
365,
12610,
2884,
14,
26848,
652,
2529,
314,
12044,
1808,
314,
4895,
1402,
199,
199,
1378,
1255,
642,
2884,
625,
3349,
314,
2569,
1004,
315,
314,
199,
2373,
63,
3438,
3420,
315,
3272,
14,
4128,
26,
339,
8559,
63,
6429,
275,
1362,
12610,
275,
10739,
380,
2753,
310,
6892,
14,
6892,
26,
1065,
421,
199,
624,
199,
199,
646,
7534,
199,
646,
984,
199,
646,
2050,
199,
199,
504,
10739,
380,
2753,
310,
6892,
492,
636,
1023,
363,
199,
199,
363,
2502,
363,
275,
298,
7579,
11302,
32052,
5495,
15368,
79,
1849,
352,
526,
2,
199,
363,
7307,
363,
275,
298,
7579,
11302,
32052,
5495,
15368,
79,
1849,
352,
526,
2,
199,
363,
1682,
363,
275,
298,
11692,
19,
2,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
318,
12610,
8,
1238,
12,
511,
63,
576,
304,
272,
408,
272,
3550,
12044,
687,
3411,
1402,
4079,
641,
511,
666,
272,
520,
635,
1402,
26,
12643,
1942,
1402,
6290,
10889,
272,
520,
635,
511,
63,
576,
26,
666,
687,
1314,
370,
3550,
314,
7914,
272,
520,
1107,
26,
339,
408,
272,
986,
421,
199,
318,
2198,
63,
589,
8,
589,
304,
272,
408,
272,
6077,
1414,
1004,
2633,
339,
520,
635,
1249,
26,
1414,
1004,
2633,
465,
769,
402,
3326,
272,
520,
1107,
26,
1414,
1004,
2633,
465,
520,
1113,
1705,
18978,
14,
8814,
64,
272,
408,
272,
1798,
275,
7534,
14,
10730,
8,
267,
1369,
628,
607,
559,
5606,
12044,
4744,
531,
272,
1798,
14,
525,
63,
2094,
8,
267,
2850,
1023,
297,
267,
1595,
534,
1023,
297,
267,
1015,
534,
2354,
36,
7420,
310,
28240,
469,
422,
5285,
908,
8,
422,
18971,
1023,
8964,
272,
1798,
14,
525,
63,
2094,
8,
267,
2053,
628,
77,
401,
267,
1720,
628,
1238,
570,
401,
267,
730,
29,
495,
12,
267,
8214,
628,
2919,
531,
272,
1798,
14,
525,
63,
2094,
8,
267,
2053,
628,
68,
401,
267,
1720,
628,
774,
666,
570,
334,
19018,
4186,
267,
730,
29,
495,
272,
776,
272,
1798,
14,
525,
63,
2094,
8,
267,
2475,
86,
297,
267,
2850,
3832,
297,
267,
2053,
628,
26629,
401,
267,
1720,
628,
409,
943,
1896,
370,
24008,
401,
267,
1595,
534,
1617,
63,
1297,
297,
267,
950,
29,
4806,
14,
4531,
9,
272,
1798,
14,
525,
63,
2094,
8,
267,
2475,
8958,
297,
267,
2850,
2588,
13,
3832,
297,
267,
2053,
628,
26629,
401,
267,
1720,
628,
409,
943,
1896,
370,
10990,
401,
267,
1595,
534,
1617,
63,
1297,
297,
267,
950,
29,
4806,
14,
5287,
9,
272,
372,
1798,
14,
1122,
63,
589,
8,
589,
9,
421,
199,
318,
2446,
8,
589,
304,
272,
1249,
275,
2198,
63,
589,
8,
589,
9,
272,
2050,
14,
19602,
8,
1896,
29,
589,
14,
26629,
12,
2547,
29,
1274,
14,
2703,
9,
272,
485,
2921,
14,
1757,
480,
29244,
876,
1671,
12594,
272,
870,
480,
1918,
14746,
315,
559,
5606,
365,
12594,
272,
485,
2921,
14,
815,
480,
5229,
11187,
2348,
531,
421,
199,
318,
1255,
837,
272,
2446,
8,
1274,
14,
3020,
59,
17,
5728,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
1255,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
2765,
365,
12610,
2884,
14,
26848,
652,
2529,
314,
12044,
1808,
314,
4895,
1402,
199,
199,
1378,
1255,
642,
2884,
625,
3349,
314,
2569,
1004,
315,
314,
199,
2373,
63,
3438,
3420,
315,
3272,
14,
4128,
26,
339,
8559,
63,
6429,
275,
1362,
12610,
275,
10739,
380,
2753,
310,
6892,
14,
6892,
26,
1065,
421,
199,
624,
199,
199,
646,
7534,
199,
646,
984,
199,
646,
2050,
199,
199,
504,
10739,
380,
2753,
310,
6892,
492,
636,
1023,
363,
199,
199,
363,
2502,
363,
275,
298,
7579,
11302,
32052,
5495,
15368,
79,
1849,
352,
526,
2,
199,
363,
7307,
363,
275,
298,
7579,
11302,
32052,
5495,
15368,
79,
1849,
352,
526,
2,
199,
363,
1682,
363,
275,
298,
11692,
19,
2,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
318,
12610,
8,
1238,
12,
511,
63,
576,
304,
272,
408,
272,
3550,
12044,
687,
3411,
1402,
4079,
641,
511,
666,
272,
520,
635,
1402,
26,
12643,
1942,
1402,
6290,
10889,
272,
520,
635,
511,
63,
576,
26,
666,
687,
1314,
370,
3550,
314,
7914,
272,
520,
1107,
26,
339,
408,
272,
986,
421,
199,
318,
2198,
63,
589,
8,
589,
304,
272,
408,
272,
6077,
1414,
1004,
2633,
339,
520,
635,
1249,
26,
1414,
1004,
2633,
465,
769,
402,
3326,
272,
520,
1107,
26,
1414,
1004,
2633,
465,
520,
1113,
1705,
18978,
14,
8814,
64,
272,
408,
272,
1798,
275,
7534,
14,
10730,
8,
267,
1369,
628,
607,
559,
5606,
12044,
4744,
531,
272,
1798,
14,
525,
63,
2094,
8,
267,
2850,
1023,
297,
267,
1595,
534,
1023,
297,
267,
1015,
534,
2354,
36,
7420,
310,
28240,
469,
422,
5285,
908,
8,
422,
18971,
1023,
8964,
272,
1798,
14,
525,
63,
2094,
8,
267,
2053,
628,
77,
401,
267,
1720,
628,
1238,
570,
401,
267,
730,
29,
495,
12,
267,
8214,
628,
2919,
531,
272,
1798,
14,
525,
63,
2094,
8,
267,
2053,
628,
68,
401,
267,
1720,
628,
774,
666,
570,
334,
19018,
4186,
267,
730,
29,
495,
272,
776,
272,
1798,
14,
525,
63,
2094,
8,
267,
2475,
86,
297,
267,
2850,
3832,
297,
267,
2053,
628,
26629,
401,
267,
1720,
628,
409,
943,
1896,
370,
24008,
401,
267,
1595,
534,
1617,
63,
1297,
297,
267,
950,
29,
4806,
14,
4531,
9,
272,
1798,
14,
525,
63,
2094,
8,
267,
2475,
8958,
297,
267,
2850,
2588,
13,
3832,
297,
267,
2053,
628,
26629,
401,
267,
1720,
628,
409,
943,
1896,
370,
10990,
401,
267,
1595,
534,
1617,
63,
1297,
297,
267,
950,
29,
4806,
14,
5287,
9,
272,
372,
1798,
14,
1122,
63,
589,
8,
589,
9,
421,
199,
318,
2446,
8,
589,
304,
272,
1249,
275,
2198,
63,
589,
8,
589,
9,
272,
2050,
14,
19602,
8,
1896,
29,
589,
14,
26629,
12,
2547,
29,
1274,
14,
2703,
9,
272,
485,
2921,
14,
1757,
480,
29244,
876,
1671,
12594,
272,
870,
480,
1918,
14746,
315,
559,
5606,
365,
12594,
272,
485,
2921,
14,
815,
480,
5229,
11187,
2348,
531,
421,
199,
318,
1255,
837,
272,
2446,
8,
1274,
14,
3020,
59,
17,
5728,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
1255,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
MalloyPower/parsing-python
|
front-end/testsuite-python-lib/Python-2.2/Lib/xml/sax/xmlreader.py
|
136
|
12580
|
"""An XML Reader is the SAX 2 name for an XML parser. XML Parsers
should be based on this code. """
import handler
from _exceptions import SAXNotSupportedException, SAXNotRecognizedException
# ===== XMLREADER =====
class XMLReader:
"""Interface for reading an XML document using callbacks.
XMLReader is the interface that an XML parser's SAX2 driver must
implement. This interface allows an application to set and query
features and properties in the parser, to register event handlers
for document processing, and to initiate a document parse.
All SAX interfaces are assumed to be synchronous: the parse
methods must not return until parsing is complete, and readers
must wait for an event-handler callback to return before reporting
the next event."""
def __init__(self):
self._cont_handler = handler.ContentHandler()
self._dtd_handler = handler.DTDHandler()
self._ent_handler = handler.EntityResolver()
self._err_handler = handler.ErrorHandler()
def parse(self, source):
"Parse an XML document from a system identifier or an InputSource."
raise NotImplementedError("This method must be implemented!")
def getContentHandler(self):
"Returns the current ContentHandler."
return self._cont_handler
def setContentHandler(self, handler):
"Registers a new object to receive document content events."
self._cont_handler = handler
def getDTDHandler(self):
"Returns the current DTD handler."
return self._dtd_handler
def setDTDHandler(self, handler):
"Register an object to receive basic DTD-related events."
self._dtd_handler = handler
def getEntityResolver(self):
"Returns the current EntityResolver."
return self._ent_handler
def setEntityResolver(self, resolver):
"Register an object to resolve external entities."
self._ent_handler = resolver
def getErrorHandler(self):
"Returns the current ErrorHandler."
return self._err_handler
def setErrorHandler(self, handler):
"Register an object to receive error-message events."
self._err_handler = handler
def setLocale(self, locale):
"""Allow an application to set the locale for errors and warnings.
SAX parsers are not required to provide localization for errors
and warnings; if they cannot support the requested locale,
however, they must throw a SAX exception. Applications may
request a locale change in the middle of a parse."""
raise SAXNotSupportedException("Locale support not implemented")
def getFeature(self, name):
"Looks up and returns the state of a SAX2 feature."
raise SAXNotRecognizedException("Feature '%s' not recognized" % name)
def setFeature(self, name, state):
"Sets the state of a SAX2 feature."
raise SAXNotRecognizedException("Feature '%s' not recognized" % name)
def getProperty(self, name):
"Looks up and returns the value of a SAX2 property."
raise SAXNotRecognizedException("Property '%s' not recognized" % name)
def setProperty(self, name, value):
"Sets the value of a SAX2 property."
raise SAXNotRecognizedException("Property '%s' not recognized" % name)
class IncrementalParser(XMLReader):
"""This interface adds three extra methods to the XMLReader
interface that allow XML parsers to support incremental
parsing. Support for this interface is optional, since not all
underlying XML parsers support this functionality.
When the parser is instantiated it is ready to begin accepting
data from the feed method immediately. After parsing has been
finished with a call to close the reset method must be called to
make the parser ready to accept new data, either from feed or
using the parse method.
Note that these methods must _not_ be called during parsing, that
is, after parse has been called and before it returns.
By default, the class also implements the parse method of the XMLReader
interface using the feed, close and reset methods of the
IncrementalParser interface as a convenience to SAX 2.0 driver
writers."""
def __init__(self, bufsize=2**16):
self._bufsize = bufsize
XMLReader.__init__(self)
def parse(self, source):
import saxutils
source = saxutils.prepare_input_source(source)
self.prepareParser(source)
file = source.getByteStream()
buffer = file.read(self._bufsize)
while buffer != "":
self.feed(buffer)
buffer = file.read(self._bufsize)
self.close()
def feed(self, data):
"""This method gives the raw XML data in the data parameter to
the parser and makes it parse the data, emitting the
corresponding events. It is allowed for XML constructs to be
split across several calls to feed.
feed may raise SAXException."""
raise NotImplementedError("This method must be implemented!")
def prepareParser(self, source):
"""This method is called by the parse implementation to allow
the SAX 2.0 driver to prepare itself for parsing."""
raise NotImplementedError("prepareParser must be overridden!")
def close(self):
"""This method is called when the entire XML document has been
passed to the parser through the feed method, to notify the
parser that there are no more data. This allows the parser to
do the final checks on the document and empty the internal
data buffer.
The parser will not be ready to parse another document until
the reset method has been called.
close may raise SAXException."""
raise NotImplementedError("This method must be implemented!")
def reset(self):
"""This method is called after close has been called to reset
the parser so that it is ready to parse new documents. The
results of calling parse or feed after close without calling
reset are undefined."""
raise NotImplementedError("This method must be implemented!")
# ===== LOCATOR =====
class Locator:
"""Interface for associating a SAX event with a document
location. A locator object will return valid results only during
calls to DocumentHandler methods; at any other time, the
results are unpredictable."""
def getColumnNumber(self):
"Return the column number where the current event ends."
return -1
def getLineNumber(self):
"Return the line number where the current event ends."
return -1
def getPublicId(self):
"Return the public identifier for the current event."
return None
def getSystemId(self):
"Return the system identifier for the current event."
return None
# ===== INPUTSOURCE =====
class InputSource:
"""Encapsulation of the information needed by the XMLReader to
read entities.
This class may include information about the public identifier,
system identifier, byte stream (possibly with character encoding
information) and/or the character stream of an entity.
Applications will create objects of this class for use in the
XMLReader.parse method and for returning from
EntityResolver.resolveEntity.
An InputSource belongs to the application, the XMLReader is not
allowed to modify InputSource objects passed to it from the
application, although it may make copies and modify those."""
def __init__(self, system_id = None):
self.__system_id = system_id
self.__public_id = None
self.__encoding = None
self.__bytefile = None
self.__charfile = None
def setPublicId(self, public_id):
"Sets the public identifier of this InputSource."
self.__public_id = public_id
def getPublicId(self):
"Returns the public identifier of this InputSource."
return self.__public_id
def setSystemId(self, system_id):
"Sets the system identifier of this InputSource."
self.__system_id = system_id
def getSystemId(self):
"Returns the system identifier of this InputSource."
return self.__system_id
def setEncoding(self, encoding):
"""Sets the character encoding of this InputSource.
The encoding must be a string acceptable for an XML encoding
declaration (see section 4.3.3 of the XML recommendation).
The encoding attribute of the InputSource is ignored if the
InputSource also contains a character stream."""
self.__encoding = encoding
def getEncoding(self):
"Get the character encoding of this InputSource."
return self.__encoding
def setByteStream(self, bytefile):
"""Set the byte stream (a Python file-like object which does
not perform byte-to-character conversion) for this input
source.
The SAX parser will ignore this if there is also a character
stream specified, but it will use a byte stream in preference
to opening a URI connection itself.
If the application knows the character encoding of the byte
stream, it should set it with the setEncoding method."""
self.__bytefile = bytefile
def getByteStream(self):
"""Get the byte stream for this input source.
The getEncoding method will return the character encoding for
this byte stream, or None if unknown."""
return self.__bytefile
def setCharacterStream(self, charfile):
"""Set the character stream for this input source. (The stream
must be a Python 2.0 Unicode-wrapped file-like that performs
conversion to Unicode strings.)
If there is a character stream specified, the SAX parser will
ignore any byte stream and will not attempt to open a URI
connection to the system identifier."""
self.__charfile = charfile
def getCharacterStream(self):
"Get the character stream for this input source."
return self.__charfile
# ===== ATTRIBUTESIMPL =====
class AttributesImpl:
def __init__(self, attrs):
"""Non-NS-aware implementation.
attrs should be of the form {name : value}."""
self._attrs = attrs
def getLength(self):
return len(self._attrs)
def getType(self, name):
return "CDATA"
def getValue(self, name):
return self._attrs[name]
def getValueByQName(self, name):
return self._attrs[name]
def getNameByQName(self, name):
if not self._attrs.has_key(name):
raise KeyError, name
return name
def getQNameByName(self, name):
if not self._attrs.has_key(name):
raise KeyError, name
return name
def getNames(self):
return self._attrs.keys()
def getQNames(self):
return self._attrs.keys()
def __len__(self):
return len(self._attrs)
def __getitem__(self, name):
return self._attrs[name]
def keys(self):
return self._attrs.keys()
def has_key(self, name):
return self._attrs.has_key(name)
def get(self, name, alternative=None):
return self._attrs.get(name, alternative)
def copy(self):
return self.__class__(self._attrs)
def items(self):
return self._attrs.items()
def values(self):
return self._attrs.values()
# ===== ATTRIBUTESNSIMPL =====
class AttributesNSImpl(AttributesImpl):
def __init__(self, attrs, qnames):
"""NS-aware implementation.
attrs should be of the form {(ns_uri, lname): value, ...}.
qnames of the form {(ns_uri, lname): qname, ...}."""
self._attrs = attrs
self._qnames = qnames
def getValueByQName(self, name):
for (nsname, qname) in self._qnames.items():
if qname == name:
return self._attrs[nsname]
raise KeyError, name
def getNameByQName(self, name):
for (nsname, qname) in self._qnames.items():
if qname == name:
return nsname
raise KeyError, name
def getQNameByName(self, name):
return self._qnames[name]
def getQNames(self):
return self._qnames.values()
def copy(self):
return self.__class__(self._attrs, self._qnames)
def _test():
XMLReader()
IncrementalParser()
Locator()
if __name__ == "__main__":
_test()
|
mit
|
[
624,
2493,
4692,
23099,
365,
314,
19310,
499,
536,
367,
376,
4692,
1798,
14,
4692,
10191,
83,
199,
5626,
506,
4079,
641,
642,
1233,
14,
408,
199,
199,
646,
3016,
199,
199,
504,
485,
3924,
492,
19310,
26077,
1726,
12,
19310,
1763,
497,
9659,
1726,
421,
199,
3,
9310,
4692,
5670,
540,
9310,
199,
199,
533,
4692,
5929,
26,
272,
408,
4267,
367,
7664,
376,
4692,
2213,
1808,
13484,
14,
339,
4692,
5929,
365,
314,
3217,
626,
376,
4692,
1798,
1159,
19310,
18,
5253,
1471,
272,
5669,
14,
961,
3217,
6127,
376,
4223,
370,
663,
436,
1827,
272,
4534,
436,
4382,
315,
314,
1798,
12,
370,
2274,
1566,
8297,
272,
367,
2213,
6661,
12,
436,
370,
11023,
323,
282,
2213,
2198,
14,
339,
2900,
19310,
8386,
787,
10826,
370,
506,
24248,
26,
314,
2198,
272,
3102,
1471,
440,
372,
5133,
6057,
365,
4890,
12,
436,
7002,
83,
272,
1471,
3618,
367,
376,
1566,
13,
2232,
3233,
370,
372,
2544,
17290,
272,
314,
2163,
1566,
1041,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
11096,
63,
2232,
275,
3016,
14,
2714,
2461,
342,
267,
291,
423,
15662,
63,
2232,
275,
3016,
14,
21156,
2461,
342,
267,
291,
423,
484,
63,
2232,
275,
3016,
14,
7302,
12407,
342,
267,
291,
423,
1508,
63,
2232,
275,
3016,
14,
25933,
342,
339,
347,
2198,
8,
277,
12,
1350,
304,
267,
298,
4003,
376,
4692,
2213,
687,
282,
2656,
5148,
503,
376,
6924,
2980,
2122,
267,
746,
4279,
480,
2765,
1083,
1471,
506,
6366,
9124,
339,
347,
664,
2714,
2461,
8,
277,
304,
267,
298,
3407,
314,
1453,
6646,
2461,
2122,
267,
372,
291,
423,
11096,
63,
2232,
339,
347,
663,
2714,
2461,
8,
277,
12,
3016,
304,
267,
298,
31136,
282,
892,
909,
370,
9128,
2213,
1564,
4474,
2122,
267,
291,
423,
11096,
63,
2232,
275,
3016,
339,
347,
664,
21156,
2461,
8,
277,
304,
267,
298,
3407,
314,
1453,
577,
13449,
3016,
2122,
267,
372,
291,
423,
15662,
63,
2232,
339,
347,
663,
21156,
2461,
8,
277,
12,
3016,
304,
267,
298,
7099,
376,
909,
370,
9128,
5678,
577,
13449,
13,
2407,
4474,
2122,
267,
291,
423,
15662,
63,
2232,
275,
3016,
339,
347,
664,
7302,
12407,
8,
277,
304,
267,
298,
3407,
314,
1453,
17680,
12407,
2122,
267,
372,
291,
423,
484,
63,
2232,
339,
347,
663,
7302,
12407,
8,
277,
12,
15611,
304,
267,
298,
7099,
376,
909,
370,
7512,
5957,
9045,
2122,
267,
291,
423,
484,
63,
2232,
275,
15611,
339,
347,
664,
25933,
8,
277,
304,
267,
298,
3407,
314,
1453,
4520,
2461,
2122,
267,
372,
291,
423,
1508,
63,
2232,
339,
347,
663,
25933,
8,
277,
12,
3016,
304,
267,
298,
7099,
376,
909,
370,
9128,
1125,
13,
1188,
4474,
2122,
267,
291,
423,
1508,
63,
2232,
275,
3016,
339,
347,
663,
20342,
8,
277,
12,
5867,
304,
267,
408,
7852,
376,
4223,
370,
663,
314,
5867,
367,
2552,
436,
3598,
14,
398,
19310,
21295,
787,
440,
1415,
370,
5647,
2257,
2072,
367,
2552,
267,
436,
3598,
27,
340,
2985,
3913,
2291,
314,
5839,
5867,
12,
267,
13432,
12,
2985,
1471,
7978,
282,
19310,
1919,
14,
24636,
1443,
267,
1056,
282,
5867,
1570,
315,
314,
12180,
402,
282,
2198,
1041,
267,
746,
19310,
26077,
1726,
480,
20342,
2291,
440,
6366,
531,
339,
347,
664,
5968,
8,
277,
12,
536,
304,
267,
298,
20926,
83,
1536,
436,
2529,
314,
1174,
402,
282,
19310,
18,
3878,
2122,
267,
746,
19310,
1763,
497,
9659,
1726,
480,
5968,
1543,
83,
7,
440,
18054,
2,
450,
536,
9,
339,
347,
663,
5968,
8,
277,
12,
536,
12,
1174,
304,
267,
298,
9899,
314,
1174,
402,
282,
19310,
18,
3878,
2122,
267,
746,
19310,
1763,
497,
9659,
1726,
480,
5968,
1543,
83,
7,
440,
18054,
2,
450,
536,
9,
339,
347,
664,
3697,
8,
277,
12,
536,
304,
267,
298,
20926,
83,
1536,
436,
2529,
314,
574,
402,
282,
19310,
18,
3324,
2122,
267,
746,
19310,
1763,
497,
9659,
1726,
480,
3697,
1543,
83,
7,
440,
18054,
2,
450,
536,
9,
339,
347,
663,
3697,
8,
277,
12,
536,
12,
574,
304,
267,
298,
9899,
314,
574,
402,
282,
19310,
18,
3324,
2122,
267,
746,
19310,
1763,
497,
9659,
1726,
480,
3697,
1543,
83,
7,
440,
18054,
2,
450,
536,
9,
199,
199,
533,
14684,
2842,
8,
4317,
5929,
304,
272,
408,
2765,
3217,
9584,
7795,
2402,
3102,
370,
314,
4692,
5929,
272,
3217,
626,
2040,
4692,
21295,
370,
2291,
16316,
272,
6057,
14,
12502,
367,
642,
3217,
365,
2716,
12,
3967,
440,
1006,
272,
8793,
4692,
21295,
2291,
642,
9330,
14,
339,
3979,
314,
1798,
365,
17544,
652,
365,
10144,
370,
5386,
32163,
272,
666,
687,
314,
4733,
1083,
9939,
14,
12836,
6057,
965,
2757,
272,
9158,
543,
282,
1240,
370,
4002,
314,
5305,
1083,
1471,
506,
2797,
370,
272,
1852,
314,
1798,
10144,
370,
4729,
892,
666,
12,
1902,
687,
4733,
503,
272,
1808,
314,
2198,
1083,
14,
339,
3390,
626,
3520,
3102,
1471,
485,
1397,
63,
506,
2797,
5309,
6057,
12,
626,
272,
365,
12,
2410,
2198,
965,
2757,
2797,
436,
2544,
652,
2529,
14,
339,
4885,
849,
12,
314,
1021,
2597,
9031,
314,
2198,
1083,
402,
314,
4692,
5929,
272,
3217,
1808,
314,
4733,
12,
4002,
436,
5305,
3102,
402,
314,
272,
14684,
2842,
3217,
465,
282,
16777,
370,
19310,
499,
14,
16,
5253,
272,
2211,
878,
1041,
339,
347,
636,
826,
721,
277,
12,
17080,
29,
18,
538,
975,
304,
267,
291,
423,
19146,
275,
17080,
267,
4692,
5929,
855,
826,
721,
277,
9,
339,
347,
2198,
8,
277,
12,
1350,
304,
267,
492,
308,
1219,
1208,
267,
1350,
275,
308,
1219,
1208,
14,
6726,
63,
1210,
63,
1365,
8,
1365,
9,
398,
291,
14,
6726,
2842,
8,
1365,
9,
267,
570,
275,
1350,
14,
362,
4861,
3296,
342,
267,
3335,
275,
570,
14,
739,
8,
277,
423,
19146,
9,
267,
1830,
3335,
1137,
10812,
288,
291,
14,
3871,
8,
2738,
9,
288,
3335,
275,
570,
14,
739,
8,
277,
423,
19146,
9,
267,
291,
14,
1600,
342,
339,
347,
4733,
8,
277,
12,
666,
304,
267,
408,
2765,
1083,
10557,
314,
3066,
4692,
666,
315,
314,
666,
2725,
370,
267
] |
[
2493,
4692,
23099,
365,
314,
19310,
499,
536,
367,
376,
4692,
1798,
14,
4692,
10191,
83,
199,
5626,
506,
4079,
641,
642,
1233,
14,
408,
199,
199,
646,
3016,
199,
199,
504,
485,
3924,
492,
19310,
26077,
1726,
12,
19310,
1763,
497,
9659,
1726,
421,
199,
3,
9310,
4692,
5670,
540,
9310,
199,
199,
533,
4692,
5929,
26,
272,
408,
4267,
367,
7664,
376,
4692,
2213,
1808,
13484,
14,
339,
4692,
5929,
365,
314,
3217,
626,
376,
4692,
1798,
1159,
19310,
18,
5253,
1471,
272,
5669,
14,
961,
3217,
6127,
376,
4223,
370,
663,
436,
1827,
272,
4534,
436,
4382,
315,
314,
1798,
12,
370,
2274,
1566,
8297,
272,
367,
2213,
6661,
12,
436,
370,
11023,
323,
282,
2213,
2198,
14,
339,
2900,
19310,
8386,
787,
10826,
370,
506,
24248,
26,
314,
2198,
272,
3102,
1471,
440,
372,
5133,
6057,
365,
4890,
12,
436,
7002,
83,
272,
1471,
3618,
367,
376,
1566,
13,
2232,
3233,
370,
372,
2544,
17290,
272,
314,
2163,
1566,
1041,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
11096,
63,
2232,
275,
3016,
14,
2714,
2461,
342,
267,
291,
423,
15662,
63,
2232,
275,
3016,
14,
21156,
2461,
342,
267,
291,
423,
484,
63,
2232,
275,
3016,
14,
7302,
12407,
342,
267,
291,
423,
1508,
63,
2232,
275,
3016,
14,
25933,
342,
339,
347,
2198,
8,
277,
12,
1350,
304,
267,
298,
4003,
376,
4692,
2213,
687,
282,
2656,
5148,
503,
376,
6924,
2980,
2122,
267,
746,
4279,
480,
2765,
1083,
1471,
506,
6366,
9124,
339,
347,
664,
2714,
2461,
8,
277,
304,
267,
298,
3407,
314,
1453,
6646,
2461,
2122,
267,
372,
291,
423,
11096,
63,
2232,
339,
347,
663,
2714,
2461,
8,
277,
12,
3016,
304,
267,
298,
31136,
282,
892,
909,
370,
9128,
2213,
1564,
4474,
2122,
267,
291,
423,
11096,
63,
2232,
275,
3016,
339,
347,
664,
21156,
2461,
8,
277,
304,
267,
298,
3407,
314,
1453,
577,
13449,
3016,
2122,
267,
372,
291,
423,
15662,
63,
2232,
339,
347,
663,
21156,
2461,
8,
277,
12,
3016,
304,
267,
298,
7099,
376,
909,
370,
9128,
5678,
577,
13449,
13,
2407,
4474,
2122,
267,
291,
423,
15662,
63,
2232,
275,
3016,
339,
347,
664,
7302,
12407,
8,
277,
304,
267,
298,
3407,
314,
1453,
17680,
12407,
2122,
267,
372,
291,
423,
484,
63,
2232,
339,
347,
663,
7302,
12407,
8,
277,
12,
15611,
304,
267,
298,
7099,
376,
909,
370,
7512,
5957,
9045,
2122,
267,
291,
423,
484,
63,
2232,
275,
15611,
339,
347,
664,
25933,
8,
277,
304,
267,
298,
3407,
314,
1453,
4520,
2461,
2122,
267,
372,
291,
423,
1508,
63,
2232,
339,
347,
663,
25933,
8,
277,
12,
3016,
304,
267,
298,
7099,
376,
909,
370,
9128,
1125,
13,
1188,
4474,
2122,
267,
291,
423,
1508,
63,
2232,
275,
3016,
339,
347,
663,
20342,
8,
277,
12,
5867,
304,
267,
408,
7852,
376,
4223,
370,
663,
314,
5867,
367,
2552,
436,
3598,
14,
398,
19310,
21295,
787,
440,
1415,
370,
5647,
2257,
2072,
367,
2552,
267,
436,
3598,
27,
340,
2985,
3913,
2291,
314,
5839,
5867,
12,
267,
13432,
12,
2985,
1471,
7978,
282,
19310,
1919,
14,
24636,
1443,
267,
1056,
282,
5867,
1570,
315,
314,
12180,
402,
282,
2198,
1041,
267,
746,
19310,
26077,
1726,
480,
20342,
2291,
440,
6366,
531,
339,
347,
664,
5968,
8,
277,
12,
536,
304,
267,
298,
20926,
83,
1536,
436,
2529,
314,
1174,
402,
282,
19310,
18,
3878,
2122,
267,
746,
19310,
1763,
497,
9659,
1726,
480,
5968,
1543,
83,
7,
440,
18054,
2,
450,
536,
9,
339,
347,
663,
5968,
8,
277,
12,
536,
12,
1174,
304,
267,
298,
9899,
314,
1174,
402,
282,
19310,
18,
3878,
2122,
267,
746,
19310,
1763,
497,
9659,
1726,
480,
5968,
1543,
83,
7,
440,
18054,
2,
450,
536,
9,
339,
347,
664,
3697,
8,
277,
12,
536,
304,
267,
298,
20926,
83,
1536,
436,
2529,
314,
574,
402,
282,
19310,
18,
3324,
2122,
267,
746,
19310,
1763,
497,
9659,
1726,
480,
3697,
1543,
83,
7,
440,
18054,
2,
450,
536,
9,
339,
347,
663,
3697,
8,
277,
12,
536,
12,
574,
304,
267,
298,
9899,
314,
574,
402,
282,
19310,
18,
3324,
2122,
267,
746,
19310,
1763,
497,
9659,
1726,
480,
3697,
1543,
83,
7,
440,
18054,
2,
450,
536,
9,
199,
199,
533,
14684,
2842,
8,
4317,
5929,
304,
272,
408,
2765,
3217,
9584,
7795,
2402,
3102,
370,
314,
4692,
5929,
272,
3217,
626,
2040,
4692,
21295,
370,
2291,
16316,
272,
6057,
14,
12502,
367,
642,
3217,
365,
2716,
12,
3967,
440,
1006,
272,
8793,
4692,
21295,
2291,
642,
9330,
14,
339,
3979,
314,
1798,
365,
17544,
652,
365,
10144,
370,
5386,
32163,
272,
666,
687,
314,
4733,
1083,
9939,
14,
12836,
6057,
965,
2757,
272,
9158,
543,
282,
1240,
370,
4002,
314,
5305,
1083,
1471,
506,
2797,
370,
272,
1852,
314,
1798,
10144,
370,
4729,
892,
666,
12,
1902,
687,
4733,
503,
272,
1808,
314,
2198,
1083,
14,
339,
3390,
626,
3520,
3102,
1471,
485,
1397,
63,
506,
2797,
5309,
6057,
12,
626,
272,
365,
12,
2410,
2198,
965,
2757,
2797,
436,
2544,
652,
2529,
14,
339,
4885,
849,
12,
314,
1021,
2597,
9031,
314,
2198,
1083,
402,
314,
4692,
5929,
272,
3217,
1808,
314,
4733,
12,
4002,
436,
5305,
3102,
402,
314,
272,
14684,
2842,
3217,
465,
282,
16777,
370,
19310,
499,
14,
16,
5253,
272,
2211,
878,
1041,
339,
347,
636,
826,
721,
277,
12,
17080,
29,
18,
538,
975,
304,
267,
291,
423,
19146,
275,
17080,
267,
4692,
5929,
855,
826,
721,
277,
9,
339,
347,
2198,
8,
277,
12,
1350,
304,
267,
492,
308,
1219,
1208,
267,
1350,
275,
308,
1219,
1208,
14,
6726,
63,
1210,
63,
1365,
8,
1365,
9,
398,
291,
14,
6726,
2842,
8,
1365,
9,
267,
570,
275,
1350,
14,
362,
4861,
3296,
342,
267,
3335,
275,
570,
14,
739,
8,
277,
423,
19146,
9,
267,
1830,
3335,
1137,
10812,
288,
291,
14,
3871,
8,
2738,
9,
288,
3335,
275,
570,
14,
739,
8,
277,
423,
19146,
9,
267,
291,
14,
1600,
342,
339,
347,
4733,
8,
277,
12,
666,
304,
267,
408,
2765,
1083,
10557,
314,
3066,
4692,
666,
315,
314,
666,
2725,
370,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ryfeus/lambda-packs
|
Tensorflow/source/tensorflow/python/ops/gen_linalg_ops.py
|
2
|
56706
|
"""Python wrappers around TensorFlow ops.
This file is MACHINE GENERATED! Do not edit.
Original C++ source file: linalg_ops.cc
"""
import collections as _collections
from tensorflow.python.eager import execute as _execute
from tensorflow.python.eager import context as _context
from tensorflow.python.eager import core as _core
from tensorflow.python.framework import dtypes as _dtypes
from tensorflow.python.framework import tensor_shape as _tensor_shape
from tensorflow.core.framework import op_def_pb2 as _op_def_pb2
# Needed to trigger the call to _set_call_cpp_shape_fn.
from tensorflow.python.framework import common_shapes as _common_shapes
from tensorflow.python.framework import op_def_registry as _op_def_registry
from tensorflow.python.framework import ops as _ops
from tensorflow.python.framework import op_def_library as _op_def_library
def _batch_cholesky(input, name=None):
r"""TODO: add doc.
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `input`.
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchCholesky", input=input, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"BatchCholesky", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"BatchCholesky", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def _batch_cholesky_grad(l, grad, name=None):
r"""TODO: add doc.
Args:
l: A `Tensor`. Must be one of the following types: `float32`, `float64`.
grad: A `Tensor`. Must have the same type as `l`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `l`.
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchCholeskyGrad", l=l, grad=grad, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, _inputs_T = _execute.args_to_matching_eager([l, grad], _ctx)
(l, grad) = _inputs_T
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [l, grad]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"BatchCholeskyGrad", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"BatchCholeskyGrad", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def _batch_matrix_determinant(input, name=None):
r"""TODO: add doc.
Args:
input: A `Tensor`. Must be one of the following types: `float32`, `float64`, `complex64`, `complex128`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `input`.
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchMatrixDeterminant", input=input, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"BatchMatrixDeterminant", 1,
inputs=_inputs_flat, attrs=_attrs, ctx=_ctx,
name=name)
_execute.record_gradient(
"BatchMatrixDeterminant", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def _batch_matrix_inverse(input, adjoint=False, name=None):
r"""TODO: add doc.
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`.
adjoint: An optional `bool`. Defaults to `False`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `input`.
"""
if adjoint is None:
adjoint = False
adjoint = _execute.make_bool(adjoint, "adjoint")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchMatrixInverse", input=input, adjoint=adjoint, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("adjoint", _op.get_attr("adjoint"), "T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("adjoint", adjoint, "T", _attr_T)
_result = _execute.execute(b"BatchMatrixInverse", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"BatchMatrixInverse", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def _batch_matrix_solve(matrix, rhs, adjoint=False, name=None):
r"""TODO: add doc.
Args:
matrix: A `Tensor`. Must be one of the following types: `float64`, `float32`.
rhs: A `Tensor`. Must have the same type as `matrix`.
adjoint: An optional `bool`. Defaults to `False`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `matrix`.
"""
if adjoint is None:
adjoint = False
adjoint = _execute.make_bool(adjoint, "adjoint")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchMatrixSolve", matrix=matrix, rhs=rhs, adjoint=adjoint,
name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("adjoint", _op.get_attr("adjoint"), "T", _op.get_attr("T"))
else:
_attr_T, _inputs_T = _execute.args_to_matching_eager([matrix, rhs], _ctx)
(matrix, rhs) = _inputs_T
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [matrix, rhs]
_attrs = ("adjoint", adjoint, "T", _attr_T)
_result = _execute.execute(b"BatchMatrixSolve", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"BatchMatrixSolve", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def _batch_matrix_solve_ls(matrix, rhs, l2_regularizer, fast=True, name=None):
r"""TODO: add doc.
Args:
matrix: A `Tensor`. Must be one of the following types: `float64`, `float32`.
rhs: A `Tensor`. Must have the same type as `matrix`.
l2_regularizer: A `Tensor` of type `float64`.
fast: An optional `bool`. Defaults to `True`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `matrix`.
"""
if fast is None:
fast = True
fast = _execute.make_bool(fast, "fast")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchMatrixSolveLs", matrix=matrix, rhs=rhs,
l2_regularizer=l2_regularizer, fast=fast, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"), "fast", _op.get_attr("fast"))
else:
_attr_T, _inputs_T = _execute.args_to_matching_eager([matrix, rhs], _ctx)
(matrix, rhs) = _inputs_T
_attr_T = _attr_T.as_datatype_enum
l2_regularizer = _ops.convert_to_tensor(l2_regularizer, _dtypes.float64)
_inputs_flat = [matrix, rhs, l2_regularizer]
_attrs = ("T", _attr_T, "fast", fast)
_result = _execute.execute(b"BatchMatrixSolveLs", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"BatchMatrixSolveLs", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def _batch_matrix_triangular_solve(matrix, rhs, lower=True, adjoint=False, name=None):
r"""TODO: add doc.
Args:
matrix: A `Tensor`. Must be one of the following types: `float64`, `float32`.
rhs: A `Tensor`. Must have the same type as `matrix`.
lower: An optional `bool`. Defaults to `True`.
adjoint: An optional `bool`. Defaults to `False`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `matrix`.
"""
if lower is None:
lower = True
lower = _execute.make_bool(lower, "lower")
if adjoint is None:
adjoint = False
adjoint = _execute.make_bool(adjoint, "adjoint")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchMatrixTriangularSolve", matrix=matrix, rhs=rhs, lower=lower,
adjoint=adjoint, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("lower", _op.get_attr("lower"), "adjoint",
_op.get_attr("adjoint"), "T", _op.get_attr("T"))
else:
_attr_T, _inputs_T = _execute.args_to_matching_eager([matrix, rhs], _ctx)
(matrix, rhs) = _inputs_T
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [matrix, rhs]
_attrs = ("lower", lower, "adjoint", adjoint, "T", _attr_T)
_result = _execute.execute(b"BatchMatrixTriangularSolve", 1,
inputs=_inputs_flat, attrs=_attrs, ctx=_ctx,
name=name)
_execute.record_gradient(
"BatchMatrixTriangularSolve", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def _batch_self_adjoint_eig(input, name=None):
r"""TODO: add doc.
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `input`.
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchSelfAdjointEig", input=input, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"BatchSelfAdjointEig", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"BatchSelfAdjointEig", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
__batch_self_adjoint_eig_v2_outputs = ["e", "v"]
_BatchSelfAdjointEigV2Output = _collections.namedtuple(
"BatchSelfAdjointEigV2", __batch_self_adjoint_eig_v2_outputs)
def _batch_self_adjoint_eig_v2(input, compute_v=True, name=None):
r"""TODO: add doc.
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`.
compute_v: An optional `bool`. Defaults to `True`.
name: A name for the operation (optional).
Returns:
A tuple of `Tensor` objects (e, v).
e: A `Tensor`. Has the same type as `input`.
v: A `Tensor`. Has the same type as `input`.
"""
if compute_v is None:
compute_v = True
compute_v = _execute.make_bool(compute_v, "compute_v")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchSelfAdjointEigV2", input=input, compute_v=compute_v, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("compute_v", _op.get_attr("compute_v"), "T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("compute_v", compute_v, "T", _attr_T)
_result = _execute.execute(b"BatchSelfAdjointEigV2", 2,
inputs=_inputs_flat, attrs=_attrs, ctx=_ctx,
name=name)
_execute.record_gradient(
"BatchSelfAdjointEigV2", _inputs_flat, _attrs, _result, name)
_result = _BatchSelfAdjointEigV2Output._make(_result)
return _result
__batch_svd_outputs = ["s", "u", "v"]
_BatchSvdOutput = _collections.namedtuple(
"BatchSvd", __batch_svd_outputs)
def _batch_svd(input, compute_uv=True, full_matrices=False, name=None):
r"""TODO: add doc.
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
compute_uv: An optional `bool`. Defaults to `True`.
full_matrices: An optional `bool`. Defaults to `False`.
name: A name for the operation (optional).
Returns:
A tuple of `Tensor` objects (s, u, v).
s: A `Tensor`. Has the same type as `input`.
u: A `Tensor`. Has the same type as `input`.
v: A `Tensor`. Has the same type as `input`.
"""
if compute_uv is None:
compute_uv = True
compute_uv = _execute.make_bool(compute_uv, "compute_uv")
if full_matrices is None:
full_matrices = False
full_matrices = _execute.make_bool(full_matrices, "full_matrices")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"BatchSvd", input=input, compute_uv=compute_uv,
full_matrices=full_matrices, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("compute_uv", _op.get_attr("compute_uv"), "full_matrices",
_op.get_attr("full_matrices"), "T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("compute_uv", compute_uv, "full_matrices", full_matrices, "T",
_attr_T)
_result = _execute.execute(b"BatchSvd", 3, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"BatchSvd", _inputs_flat, _attrs, _result, name)
_result = _BatchSvdOutput._make(_result)
return _result
def cholesky(input, name=None):
r"""Computes the Cholesky decomposition of one or more square matrices.
The input is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
form square matrices.
The input has to be symmetric and positive definite. Only the lower-triangular
part of the input will be used for this operation. The upper-triangular part
will not be read.
The output is a tensor of the same shape as the input
containing the Cholesky decompositions for all input submatrices `[..., :, :]`.
**Note**: The gradient computation on GPU is faster for large matrices but
not for large batch dimensions when the submatrices are small. In this
case it might be faster to use the CPU.
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
Shape is `[..., M, M]`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `input`. Shape is `[..., M, M]`.
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"Cholesky", input=input, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"Cholesky", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"Cholesky", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def cholesky_grad(l, grad, name=None):
r"""Computes the reverse mode backpropagated gradient of the Cholesky algorithm.
For an explanation see "Differentiation of the Cholesky algorithm" by
Iain Murray http://arxiv.org/abs/1602.07527.
Args:
l: A `Tensor`. Must be one of the following types: `float32`, `float64`.
Output of batch Cholesky algorithm l = cholesky(A). Shape is `[..., M, M]`.
Algorithm depends only on lower triangular part of the innermost matrices of
this tensor.
grad: A `Tensor`. Must have the same type as `l`.
df/dl where f is some scalar function. Shape is `[..., M, M]`.
Algorithm depends only on lower triangular part of the innermost matrices of
this tensor.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `l`.
Symmetrized version of df/dA . Shape is `[..., M, M]`
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"CholeskyGrad", l=l, grad=grad, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, _inputs_T = _execute.args_to_matching_eager([l, grad], _ctx)
(l, grad) = _inputs_T
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [l, grad]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"CholeskyGrad", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"CholeskyGrad", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
__log_matrix_determinant_outputs = ["sign", "log_abs_determinant"]
_LogMatrixDeterminantOutput = _collections.namedtuple(
"LogMatrixDeterminant", __log_matrix_determinant_outputs)
def _log_matrix_determinant(input, name=None):
r"""Computes the sign and the log of the absolute value of the determinant of
one or more square matrices.
The input is a tensor of shape `[N, M, M]` whose inner-most 2 dimensions
form square matrices. The outputs are two tensors containing the signs and
absolute values of the log determinants for all N input submatrices
`[..., :, :]` such that the determinant = sign*exp(log_abs_determinant).
The log_abs_determinant is computed as det(P)*sum(log(diag(LU))) where LU
is the LU decomposition of the input and P is the corresponding
permutation matrix.
Args:
input: A `Tensor`. Must be one of the following types: `float32`, `float64`, `complex64`, `complex128`.
Shape is `[N, M, M]`.
name: A name for the operation (optional).
Returns:
A tuple of `Tensor` objects (sign, log_abs_determinant).
sign: A `Tensor`. Has the same type as `input`. The signs of the log determinants of the inputs. Shape is `[N]`.
log_abs_determinant: A `Tensor`. Has the same type as `input`. The logs of the absolute values of the determinants
of the N input matrices. Shape is `[N]`.
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"LogMatrixDeterminant", input=input, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"LogMatrixDeterminant", 2,
inputs=_inputs_flat, attrs=_attrs, ctx=_ctx,
name=name)
_execute.record_gradient(
"LogMatrixDeterminant", _inputs_flat, _attrs, _result, name)
_result = _LogMatrixDeterminantOutput._make(_result)
return _result
def matrix_determinant(input, name=None):
r"""Computes the determinant of one or more square matrices.
The input is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
form square matrices. The output is a tensor containing the determinants
for all input submatrices `[..., :, :]`.
Args:
input: A `Tensor`. Must be one of the following types: `float32`, `float64`, `complex64`, `complex128`.
Shape is `[..., M, M]`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `input`. Shape is `[...]`.
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"MatrixDeterminant", input=input, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"MatrixDeterminant", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"MatrixDeterminant", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def matrix_inverse(input, adjoint=False, name=None):
r"""Computes the inverse of one or more square invertible matrices or their
adjoints (conjugate transposes).
The input is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
form square matrices. The output is a tensor of the same shape as the input
containing the inverse for all input submatrices `[..., :, :]`.
The op uses LU decomposition with partial pivoting to compute the inverses.
If a matrix is not invertible there is no guarantee what the op does. It
may detect the condition and raise an exception or it may simply return a
garbage result.
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
Shape is `[..., M, M]`.
adjoint: An optional `bool`. Defaults to `False`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `input`. Shape is `[..., M, M]`.
@compatibility(numpy)
Equivalent to np.linalg.inv
@end_compatibility
"""
if adjoint is None:
adjoint = False
adjoint = _execute.make_bool(adjoint, "adjoint")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"MatrixInverse", input=input, adjoint=adjoint, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("adjoint", _op.get_attr("adjoint"), "T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("adjoint", adjoint, "T", _attr_T)
_result = _execute.execute(b"MatrixInverse", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"MatrixInverse", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def matrix_solve(matrix, rhs, adjoint=False, name=None):
r"""Solves systems of linear equations.
`Matrix` is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
form square matrices. `Rhs` is a tensor of shape `[..., M, K]`. The `output` is
a tensor shape `[..., M, K]`. If `adjoint` is `False` then each output matrix
satisfies `matrix[..., :, :] * output[..., :, :] = rhs[..., :, :]`.
If `adjoint` is `True` then each output matrix satisfies
`adjoint(matrix[..., :, :]) * output[..., :, :] = rhs[..., :, :]`.
Args:
matrix: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
Shape is `[..., M, M]`.
rhs: A `Tensor`. Must have the same type as `matrix`.
Shape is `[..., M, K]`.
adjoint: An optional `bool`. Defaults to `False`.
Boolean indicating whether to solve with `matrix` or its (block-wise)
adjoint.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `matrix`. Shape is `[..., M, K]`.
"""
if adjoint is None:
adjoint = False
adjoint = _execute.make_bool(adjoint, "adjoint")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"MatrixSolve", matrix=matrix, rhs=rhs, adjoint=adjoint, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("adjoint", _op.get_attr("adjoint"), "T", _op.get_attr("T"))
else:
_attr_T, _inputs_T = _execute.args_to_matching_eager([matrix, rhs], _ctx)
(matrix, rhs) = _inputs_T
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [matrix, rhs]
_attrs = ("adjoint", adjoint, "T", _attr_T)
_result = _execute.execute(b"MatrixSolve", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"MatrixSolve", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def _matrix_solve_ls(matrix, rhs, l2_regularizer, fast=True, name=None):
r"""Solves one or more linear least-squares problems.
`matrix` is a tensor of shape `[..., M, N]` whose inner-most 2 dimensions
form real or complex matrices of size `[M, N]`. `Rhs` is a tensor of the same
type as `matrix` and shape `[..., M, K]`.
The output is a tensor shape `[..., N, K]` where each output matrix solves
each of the equations
`matrix[..., :, :]` * `output[..., :, :]` = `rhs[..., :, :]`
in the least squares sense.
We use the following notation for (complex) matrix and right-hand sides
in the batch:
`matrix`=\\(A \in \mathbb{C}^{m \times n}\\),
`rhs`=\\(B \in \mathbb{C}^{m \times k}\\),
`output`=\\(X \in \mathbb{C}^{n \times k}\\),
`l2_regularizer`=\\(\lambda \in \mathbb{R}\\).
If `fast` is `True`, then the solution is computed by solving the normal
equations using Cholesky decomposition. Specifically, if \\(m \ge n\\) then
\\(X = (A^H A + \lambda I)^{-1} A^H B\\), which solves the least-squares
problem \\(X = \mathrm{argmin}_{Z \in \Re^{n \times k} } ||A Z - B||_F^2 +
\lambda ||Z||_F^2\\). If \\(m \lt n\\) then `output` is computed as
\\(X = A^H (A A^H + \lambda I)^{-1} B\\), which (for \\(\lambda = 0\\)) is the
minimum-norm solution to the under-determined linear system, i.e.
\\(X = \mathrm{argmin}_{Z \in \mathbb{C}^{n \times k} } ||Z||_F^2 \\),
subject to \\(A Z = B\\). Notice that the fast path is only numerically stable
when \\(A\\) is numerically full rank and has a condition number
\\(\mathrm{cond}(A) \lt \frac{1}{\sqrt{\epsilon_{mach} } }\\) or\\(\lambda\\) is
sufficiently large.
If `fast` is `False` an algorithm based on the numerically robust complete
orthogonal decomposition is used. This computes the minimum-norm
least-squares solution, even when \\(A\\) is rank deficient. This path is
typically 6-7 times slower than the fast path. If `fast` is `False` then
`l2_regularizer` is ignored.
Args:
matrix: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
Shape is `[..., M, N]`.
rhs: A `Tensor`. Must have the same type as `matrix`.
Shape is `[..., M, K]`.
l2_regularizer: A `Tensor` of type `float64`. Scalar tensor.
@compatibility(numpy)
Equivalent to np.linalg.lstsq
@end_compatibility
fast: An optional `bool`. Defaults to `True`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `matrix`. Shape is `[..., N, K]`.
"""
if fast is None:
fast = True
fast = _execute.make_bool(fast, "fast")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"MatrixSolveLs", matrix=matrix, rhs=rhs,
l2_regularizer=l2_regularizer, fast=fast, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"), "fast", _op.get_attr("fast"))
else:
_attr_T, _inputs_T = _execute.args_to_matching_eager([matrix, rhs], _ctx)
(matrix, rhs) = _inputs_T
_attr_T = _attr_T.as_datatype_enum
l2_regularizer = _ops.convert_to_tensor(l2_regularizer, _dtypes.float64)
_inputs_flat = [matrix, rhs, l2_regularizer]
_attrs = ("T", _attr_T, "fast", fast)
_result = _execute.execute(b"MatrixSolveLs", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"MatrixSolveLs", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
def matrix_triangular_solve(matrix, rhs, lower=True, adjoint=False, name=None):
r"""Solves systems of linear equations with upper or lower triangular matrices by
backsubstitution.
`matrix` is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions form
square matrices. If `lower` is `True` then the strictly upper triangular part
of each inner-most matrix is assumed to be zero and not accessed.
If `lower` is False then the strictly lower triangular part of each inner-most
matrix is assumed to be zero and not accessed.
`rhs` is a tensor of shape `[..., M, K]`.
The output is a tensor of shape `[..., M, K]`. If `adjoint` is
`True` then the innermost matrices in `output` satisfy matrix equations
`matrix[..., :, :] * output[..., :, :] = rhs[..., :, :]`.
If `adjoint` is `False` then the strictly then the innermost matrices in
`output` satisfy matrix equations
`adjoint(matrix[..., i, k]) * output[..., k, j] = rhs[..., i, j]`.
Args:
matrix: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
Shape is `[..., M, M]`.
rhs: A `Tensor`. Must have the same type as `matrix`.
Shape is `[..., M, K]`.
lower: An optional `bool`. Defaults to `True`.
Boolean indicating whether the innermost matrices in `matrix` are
lower or upper triangular.
adjoint: An optional `bool`. Defaults to `False`.
Boolean indicating whether to solve with `matrix` or its (block-wise)
adjoint.
@compatibility(numpy)
Equivalent to np.linalg.triangular_solve
@end_compatibility
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `matrix`. Shape is `[..., M, K]`.
"""
if lower is None:
lower = True
lower = _execute.make_bool(lower, "lower")
if adjoint is None:
adjoint = False
adjoint = _execute.make_bool(adjoint, "adjoint")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"MatrixTriangularSolve", matrix=matrix, rhs=rhs, lower=lower,
adjoint=adjoint, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("lower", _op.get_attr("lower"), "adjoint",
_op.get_attr("adjoint"), "T", _op.get_attr("T"))
else:
_attr_T, _inputs_T = _execute.args_to_matching_eager([matrix, rhs], _ctx)
(matrix, rhs) = _inputs_T
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [matrix, rhs]
_attrs = ("lower", lower, "adjoint", adjoint, "T", _attr_T)
_result = _execute.execute(b"MatrixTriangularSolve", 1,
inputs=_inputs_flat, attrs=_attrs, ctx=_ctx,
name=name)
_execute.record_gradient(
"MatrixTriangularSolve", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
_qr_outputs = ["q", "r"]
_QrOutput = _collections.namedtuple(
"Qr", _qr_outputs)
def qr(input, full_matrices=False, name=None):
r"""Computes the QR decompositions of one or more matrices.
Computes the QR decomposition of each inner matrix in `tensor` such that
`tensor[..., :, :] = q[..., :, :] * r[..., :,:])`
```python
# a is a tensor.
# q is a tensor of orthonormal matrices.
# r is a tensor of upper triangular matrices.
q, r = qr(a)
q_full, r_full = qr(a, full_matrices=True)
```
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
A tensor of shape `[..., M, N]` whose inner-most 2 dimensions
form matrices of size `[M, N]`. Let `P` be the minimum of `M` and `N`.
full_matrices: An optional `bool`. Defaults to `False`.
If true, compute full-sized `q` and `r`. If false
(the default), compute only the leading `P` columns of `q`.
name: A name for the operation (optional).
Returns:
A tuple of `Tensor` objects (q, r).
q: A `Tensor`. Has the same type as `input`. Orthonormal basis for range of `a`. If `full_matrices` is `False` then
shape is `[..., M, P]`; if `full_matrices` is `True` then shape is
`[..., M, M]`.
r: A `Tensor`. Has the same type as `input`. Triangular factor. If `full_matrices` is `False` then shape is
`[..., P, N]`. If `full_matrices` is `True` then shape is `[..., M, N]`.
"""
if full_matrices is None:
full_matrices = False
full_matrices = _execute.make_bool(full_matrices, "full_matrices")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"Qr", input=input, full_matrices=full_matrices, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("full_matrices", _op.get_attr("full_matrices"), "T",
_op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("full_matrices", full_matrices, "T", _attr_T)
_result = _execute.execute(b"Qr", 2, inputs=_inputs_flat, attrs=_attrs,
ctx=_ctx, name=name)
_execute.record_gradient(
"Qr", _inputs_flat, _attrs, _result, name)
_result = _QrOutput._make(_result)
return _result
def _self_adjoint_eig(input, name=None):
r"""Computes the Eigen Decomposition of a batch of square self-adjoint matrices.
The input is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
form square matrices, with the same constraints as the single matrix
SelfAdjointEig.
The result is a [..., M+1, M] matrix with [..., 0,:] containing the
eigenvalues, and subsequent [...,1:, :] containing the eigenvectors.
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`.
Shape is `[..., M, M]`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `input`. Shape is `[..., M+1, M]`.
"""
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"SelfAdjointEig", input=input, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("T", _attr_T)
_result = _execute.execute(b"SelfAdjointEig", 1, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"SelfAdjointEig", _inputs_flat, _attrs, _result, name)
_result, = _result
return _result
__self_adjoint_eig_v2_outputs = ["e", "v"]
_SelfAdjointEigV2Output = _collections.namedtuple(
"SelfAdjointEigV2", __self_adjoint_eig_v2_outputs)
def _self_adjoint_eig_v2(input, compute_v=True, name=None):
r"""Computes the eigen decomposition of one or more square self-adjoint matrices.
Computes the eigenvalues and (optionally) eigenvectors of each inner matrix in
`input` such that `input[..., :, :] = v[..., :, :] * diag(e[..., :])`.
```python
# a is a tensor.
# e is a tensor of eigenvalues.
# v is a tensor of eigenvectors.
e, v = self_adjoint_eig(a)
e = self_adjoint_eig(a, compute_v=False)
```
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
`Tensor` input of shape `[N, N]`.
compute_v: An optional `bool`. Defaults to `True`.
If `True` then eigenvectors will be computed and returned in `v`.
Otherwise, only the eigenvalues will be computed.
name: A name for the operation (optional).
Returns:
A tuple of `Tensor` objects (e, v).
e: A `Tensor`. Has the same type as `input`. Eigenvalues. Shape is `[N]`.
v: A `Tensor`. Has the same type as `input`. Eigenvectors. Shape is `[N, N]`.
"""
if compute_v is None:
compute_v = True
compute_v = _execute.make_bool(compute_v, "compute_v")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"SelfAdjointEigV2", input=input, compute_v=compute_v, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("compute_v", _op.get_attr("compute_v"), "T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("compute_v", compute_v, "T", _attr_T)
_result = _execute.execute(b"SelfAdjointEigV2", 2, inputs=_inputs_flat,
attrs=_attrs, ctx=_ctx, name=name)
_execute.record_gradient(
"SelfAdjointEigV2", _inputs_flat, _attrs, _result, name)
_result = _SelfAdjointEigV2Output._make(_result)
return _result
__svd_outputs = ["s", "u", "v"]
_SvdOutput = _collections.namedtuple(
"Svd", __svd_outputs)
def _svd(input, compute_uv=True, full_matrices=False, name=None):
r"""Computes the singular value decompositions of one or more matrices.
Computes the SVD of each inner matrix in `input` such that
`input[..., :, :] = u[..., :, :] * diag(s[..., :, :]) * transpose(v[..., :, :])`
```python
# a is a tensor containing a batch of matrices.
# s is a tensor of singular values for each matrix.
# u is the tensor containing of left singular vectors for each matrix.
# v is the tensor containing of right singular vectors for each matrix.
s, u, v = svd(a)
s, _, _ = svd(a, compute_uv=False)
```
Args:
input: A `Tensor`. Must be one of the following types: `float64`, `float32`, `complex64`, `complex128`.
A tensor of shape `[..., M, N]` whose inner-most 2 dimensions
form matrices of size `[M, N]`. Let `P` be the minimum of `M` and `N`.
compute_uv: An optional `bool`. Defaults to `True`.
If true, left and right singular vectors will be
computed and returned in `u` and `v`, respectively.
If false, `u` and `v` are not set and should never referenced.
full_matrices: An optional `bool`. Defaults to `False`.
If true, compute full-sized `u` and `v`. If false
(the default), compute only the leading `P` singular vectors.
Ignored if `compute_uv` is `False`.
name: A name for the operation (optional).
Returns:
A tuple of `Tensor` objects (s, u, v).
s: A `Tensor`. Has the same type as `input`. Singular values. Shape is `[..., P]`.
u: A `Tensor`. Has the same type as `input`. Left singular vectors. If `full_matrices` is `False` then shape is
`[..., M, P]`; if `full_matrices` is `True` then shape is
`[..., M, M]`. Undefined if `compute_uv` is `False`.
v: A `Tensor`. Has the same type as `input`. Left singular vectors. If `full_matrices` is `False` then shape is
`[..., N, P]`. If `full_matrices` is `True` then shape is `[..., N, N]`.
Undefined if `compute_uv` is false.
"""
if compute_uv is None:
compute_uv = True
compute_uv = _execute.make_bool(compute_uv, "compute_uv")
if full_matrices is None:
full_matrices = False
full_matrices = _execute.make_bool(full_matrices, "full_matrices")
_ctx = _context.context()
if _ctx.in_graph_mode():
_, _, _op = _op_def_lib._apply_op_helper(
"Svd", input=input, compute_uv=compute_uv,
full_matrices=full_matrices, name=name)
_result = _op.outputs[:]
_inputs_flat = _op.inputs
_attrs = ("compute_uv", _op.get_attr("compute_uv"), "full_matrices",
_op.get_attr("full_matrices"), "T", _op.get_attr("T"))
else:
_attr_T, (input,) = _execute.args_to_matching_eager([input], _ctx)
_attr_T = _attr_T.as_datatype_enum
_inputs_flat = [input]
_attrs = ("compute_uv", compute_uv, "full_matrices", full_matrices, "T",
_attr_T)
_result = _execute.execute(b"Svd", 3, inputs=_inputs_flat, attrs=_attrs,
ctx=_ctx, name=name)
_execute.record_gradient(
"Svd", _inputs_flat, _attrs, _result, name)
_result = _SvdOutput._make(_result)
return _result
def _InitOpDefLibrary(op_list_proto_bytes):
op_list = _op_def_pb2.OpList()
op_list.ParseFromString(op_list_proto_bytes)
_op_def_registry.register_op_list(op_list)
op_def_lib = _op_def_library.OpDefLibrary()
op_def_lib.add_op_list(op_list)
return op_def_lib
# op {
# name: "BatchCholesky"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# }
# }
# }
# deprecation {
# version: 13
# explanation: "Use Cholesky instead."
# }
# }
# op {
# name: "BatchCholeskyGrad"
# input_arg {
# name: "l"
# type_attr: "T"
# }
# input_arg {
# name: "grad"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_FLOAT
# type: DT_DOUBLE
# }
# }
# }
# deprecation {
# version: 13
# explanation: "Use CholeskyGrad instead."
# }
# }
# op {
# name: "BatchMatrixDeterminant"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_FLOAT
# type: DT_DOUBLE
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# deprecation {
# version: 13
# explanation: "Use MatrixDeterminant instead."
# }
# }
# op {
# name: "BatchMatrixInverse"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "adjoint"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# }
# }
# }
# deprecation {
# version: 13
# explanation: "Use MatrixInverse instead."
# }
# }
# op {
# name: "BatchMatrixSolve"
# input_arg {
# name: "matrix"
# type_attr: "T"
# }
# input_arg {
# name: "rhs"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "adjoint"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# }
# }
# }
# deprecation {
# version: 13
# explanation: "Use MatrixSolve instead."
# }
# }
# op {
# name: "BatchMatrixSolveLs"
# input_arg {
# name: "matrix"
# type_attr: "T"
# }
# input_arg {
# name: "rhs"
# type_attr: "T"
# }
# input_arg {
# name: "l2_regularizer"
# type: DT_DOUBLE
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# }
# }
# }
# attr {
# name: "fast"
# type: "bool"
# default_value {
# b: true
# }
# }
# deprecation {
# version: 13
# explanation: "Use MatrixSolveLs instead."
# }
# }
# op {
# name: "BatchMatrixTriangularSolve"
# input_arg {
# name: "matrix"
# type_attr: "T"
# }
# input_arg {
# name: "rhs"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "lower"
# type: "bool"
# default_value {
# b: true
# }
# }
# attr {
# name: "adjoint"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# }
# }
# }
# deprecation {
# version: 13
# explanation: "Use MatrixTriangularSolve instead."
# }
# }
# op {
# name: "BatchSelfAdjointEig"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# }
# }
# }
# deprecation {
# version: 11
# explanation: "Use SelfAdjointEigV2 instead."
# }
# }
# op {
# name: "BatchSelfAdjointEigV2"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "e"
# type_attr: "T"
# }
# output_arg {
# name: "v"
# type_attr: "T"
# }
# attr {
# name: "compute_v"
# type: "bool"
# default_value {
# b: true
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# }
# }
# }
# deprecation {
# version: 13
# explanation: "Use SelfAdjointEigV2 instead."
# }
# }
# op {
# name: "BatchSvd"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "s"
# type_attr: "T"
# }
# output_arg {
# name: "u"
# type_attr: "T"
# }
# output_arg {
# name: "v"
# type_attr: "T"
# }
# attr {
# name: "compute_uv"
# type: "bool"
# default_value {
# b: true
# }
# }
# attr {
# name: "full_matrices"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# deprecation {
# version: 13
# explanation: "Use Svd instead."
# }
# }
# op {
# name: "Cholesky"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
# op {
# name: "CholeskyGrad"
# input_arg {
# name: "l"
# type_attr: "T"
# }
# input_arg {
# name: "grad"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_FLOAT
# type: DT_DOUBLE
# }
# }
# }
# }
# op {
# name: "LogMatrixDeterminant"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "sign"
# type_attr: "T"
# }
# output_arg {
# name: "log_abs_determinant"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_FLOAT
# type: DT_DOUBLE
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
# op {
# name: "MatrixDeterminant"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_FLOAT
# type: DT_DOUBLE
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
# op {
# name: "MatrixInverse"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "adjoint"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
# op {
# name: "MatrixSolve"
# input_arg {
# name: "matrix"
# type_attr: "T"
# }
# input_arg {
# name: "rhs"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "adjoint"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
# op {
# name: "MatrixSolveLs"
# input_arg {
# name: "matrix"
# type_attr: "T"
# }
# input_arg {
# name: "rhs"
# type_attr: "T"
# }
# input_arg {
# name: "l2_regularizer"
# type: DT_DOUBLE
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# attr {
# name: "fast"
# type: "bool"
# default_value {
# b: true
# }
# }
# }
# op {
# name: "MatrixTriangularSolve"
# input_arg {
# name: "matrix"
# type_attr: "T"
# }
# input_arg {
# name: "rhs"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "lower"
# type: "bool"
# default_value {
# b: true
# }
# }
# attr {
# name: "adjoint"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
# op {
# name: "Qr"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "q"
# type_attr: "T"
# }
# output_arg {
# name: "r"
# type_attr: "T"
# }
# attr {
# name: "full_matrices"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
# op {
# name: "SelfAdjointEig"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "output"
# type_attr: "T"
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# }
# }
# }
# deprecation {
# version: 11
# explanation: "Use SelfAdjointEigV2 instead."
# }
# }
# op {
# name: "SelfAdjointEigV2"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "e"
# type_attr: "T"
# }
# output_arg {
# name: "v"
# type_attr: "T"
# }
# attr {
# name: "compute_v"
# type: "bool"
# default_value {
# b: true
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
# op {
# name: "Svd"
# input_arg {
# name: "input"
# type_attr: "T"
# }
# output_arg {
# name: "s"
# type_attr: "T"
# }
# output_arg {
# name: "u"
# type_attr: "T"
# }
# output_arg {
# name: "v"
# type_attr: "T"
# }
# attr {
# name: "compute_uv"
# type: "bool"
# default_value {
# b: true
# }
# }
# attr {
# name: "full_matrices"
# type: "bool"
# default_value {
# b: false
# }
# }
# attr {
# name: "T"
# type: "type"
# allowed_values {
# list {
# type: DT_DOUBLE
# type: DT_FLOAT
# type: DT_COMPLEX64
# type: DT_COMPLEX128
# }
# }
# }
# }
_op_def_lib = _InitOpDefLibrary(b"\nV\n\rBatchCholesky\022\n\n\005input\"\001T\032\013\n\006output\"\001T\"\021\n\001T\022\004type:\006\n\0042\002\002\001B\031\010\r\022\025Use Cholesky instead.\ne\n\021BatchCholeskyGrad\022\006\n\001l\"\001T\022\t\n\004grad\"\001T\032\013\n\006output\"\001T\"\021\n\001T\022\004type:\006\n\0042\002\001\002B\035\010\r\022\031Use CholeskyGrad instead.\nj\n\026BatchMatrixDeterminant\022\n\n\005input\"\001T\032\013\n\006output\"\001T\"\023\n\001T\022\004type:\010\n\0062\004\001\002\010\022B\"\010\r\022\036Use MatrixDeterminant instead.\nu\n\022BatchMatrixInverse\022\n\n\005input\"\001T\032\013\n\006output\"\001T\"\023\n\007adjoint\022\004bool\032\002(\000\"\021\n\001T\022\004type:\006\n\0042\002\002\001B\036\010\r\022\032Use MatrixInverse instead.\n|\n\020BatchMatrixSolve\022\013\n\006matrix\"\001T\022\010\n\003rhs\"\001T\032\013\n\006output\"\001T\"\023\n\007adjoint\022\004bool\032\002(\000\"\021\n\001T\022\004type:\006\n\0042\002\002\001B\034\010\r\022\030Use MatrixSolve instead.\n\221\001\n\022BatchMatrixSolveLs\022\013\n\006matrix\"\001T\022\010\n\003rhs\"\001T\022\022\n\016l2_regularizer\030\002\032\013\n\006output\"\001T\"\021\n\001T\022\004type:\006\n\0042\002\002\001\"\020\n\004fast\022\004bool\032\002(\001B\036\010\r\022\032Use MatrixSolveLs instead.\n\243\001\n\032BatchMatrixTriangularSolve\022\013\n\006matrix\"\001T\022\010\n\003rhs\"\001T\032\013\n\006output\"\001T\"\021\n\005lower\022\004bool\032\002(\001\"\023\n\007adjoint\022\004bool\032\002(\000\"\021\n\001T\022\004type:\006\n\0042\002\002\001B&\010\r\022\"Use MatrixTriangularSolve instead.\nd\n\023BatchSelfAdjointEig\022\n\n\005input\"\001T\032\013\n\006output\"\001T\"\021\n\001T\022\004type:\006\n\0042\002\002\001B!\010\013\022\035Use SelfAdjointEigV2 instead.\n\200\001\n\025BatchSelfAdjointEigV2\022\n\n\005input\"\001T\032\006\n\001e\"\001T\032\006\n\001v\"\001T\"\025\n\tcompute_v\022\004bool\032\002(\001\"\021\n\001T\022\004type:\006\n\0042\002\002\001B!\010\r\022\035Use SelfAdjointEigV2 instead.\n\214\001\n\010BatchSvd\022\n\n\005input\"\001T\032\006\n\001s\"\001T\032\006\n\001u\"\001T\032\006\n\001v\"\001T\"\026\n\ncompute_uv\022\004bool\032\002(\001\"\031\n\rfull_matrices\022\004bool\032\002(\000\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022B\024\010\r\022\020Use Svd instead.\n8\n\010Cholesky\022\n\n\005input\"\001T\032\013\n\006output\"\001T\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022\nA\n\014CholeskyGrad\022\006\n\001l\"\001T\022\t\n\004grad\"\001T\032\013\n\006output\"\001T\"\021\n\001T\022\004type:\006\n\0042\002\001\002\n\\\n\024LogMatrixDeterminant\022\n\n\005input\"\001T\032\t\n\004sign\"\001T\032\030\n\023log_abs_determinant\"\001T\"\023\n\001T\022\004type:\010\n\0062\004\001\002\010\022\nA\n\021MatrixDeterminant\022\n\n\005input\"\001T\032\013\n\006output\"\001T\"\023\n\001T\022\004type:\010\n\0062\004\001\002\010\022\nR\n\rMatrixInverse\022\n\n\005input\"\001T\032\013\n\006output\"\001T\"\023\n\007adjoint\022\004bool\032\002(\000\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022\n[\n\013MatrixSolve\022\013\n\006matrix\"\001T\022\010\n\003rhs\"\001T\032\013\n\006output\"\001T\"\023\n\007adjoint\022\004bool\032\002(\000\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022\nn\n\rMatrixSolveLs\022\013\n\006matrix\"\001T\022\010\n\003rhs\"\001T\022\022\n\016l2_regularizer\030\002\032\013\n\006output\"\001T\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022\"\020\n\004fast\022\004bool\032\002(\001\nx\n\025MatrixTriangularSolve\022\013\n\006matrix\"\001T\022\010\n\003rhs\"\001T\032\013\n\006output\"\001T\"\021\n\005lower\022\004bool\032\002(\001\"\023\n\007adjoint\022\004bool\032\002(\000\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022\nP\n\002Qr\022\n\n\005input\"\001T\032\006\n\001q\"\001T\032\006\n\001r\"\001T\"\031\n\rfull_matrices\022\004bool\032\002(\000\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022\n_\n\016SelfAdjointEig\022\n\n\005input\"\001T\032\013\n\006output\"\001T\"\021\n\001T\022\004type:\006\n\0042\002\002\001B!\010\013\022\035Use SelfAdjointEigV2 instead.\nZ\n\020SelfAdjointEigV2\022\n\n\005input\"\001T\032\006\n\001e\"\001T\032\006\n\001v\"\001T\"\025\n\tcompute_v\022\004bool\032\002(\001\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022\nq\n\003Svd\022\n\n\005input\"\001T\032\006\n\001s\"\001T\032\006\n\001u\"\001T\032\006\n\001v\"\001T\"\026\n\ncompute_uv\022\004bool\032\002(\001\"\031\n\rfull_matrices\022\004bool\032\002(\000\"\023\n\001T\022\004type:\010\n\0062\004\002\001\010\022")
|
mit
|
[
624,
4718,
17995,
6818,
9134,
4156,
14,
199,
199,
2765,
570,
365,
4828,
1244,
3565,
29087,
6989,
1,
4226,
440,
5283,
14,
199,
17286,
445,
4176,
1350,
570,
26,
16727,
63,
1483,
14,
2055,
199,
624,
199,
199,
646,
5055,
465,
485,
7882,
199,
199,
504,
3228,
14,
1548,
14,
10283,
492,
5341,
465,
485,
2526,
199,
504,
3228,
14,
1548,
14,
10283,
492,
1067,
465,
485,
1100,
199,
504,
3228,
14,
1548,
14,
10283,
492,
6170,
465,
485,
1018,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
465,
485,
5717,
199,
504,
3228,
14,
1548,
14,
4857,
492,
2345,
63,
1392,
465,
485,
3128,
63,
1392,
199,
199,
504,
3228,
14,
1018,
14,
4857,
492,
1687,
63,
318,
63,
3317,
18,
465,
485,
411,
63,
318,
63,
3317,
18,
199,
3,
28196,
370,
6804,
314,
1240,
370,
485,
409,
63,
1250,
63,
5910,
63,
1392,
63,
2324,
14,
199,
504,
3228,
14,
1548,
14,
4857,
492,
2863,
63,
9069,
465,
485,
2330,
63,
9069,
199,
504,
3228,
14,
1548,
14,
4857,
492,
1687,
63,
318,
63,
5189,
465,
485,
411,
63,
318,
63,
5189,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
465,
485,
1483,
199,
504,
3228,
14,
1548,
14,
4857,
492,
1687,
63,
318,
63,
4342,
465,
485,
411,
63,
318,
63,
4342,
421,
199,
318,
485,
2912,
63,
31369,
8,
1210,
12,
536,
29,
403,
304,
523,
519,
624,
11768,
26,
1050,
1382,
14,
819,
3033,
26,
272,
1324,
26,
437,
658,
3861,
2313,
9498,
506,
1373,
402,
314,
2569,
2943,
26,
658,
1609,
772,
3559,
658,
1609,
708,
2313,
272,
536,
26,
437,
536,
367,
314,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
658,
3861,
2313,
13481,
314,
2011,
730,
465,
658,
1210,
2313,
523,
408,
523,
485,
3799,
275,
485,
1100,
14,
1100,
342,
523,
340,
485,
3799,
14,
262,
63,
2180,
63,
632,
837,
272,
5501,
5501,
485,
411,
275,
485,
411,
63,
318,
63,
773,
423,
4998,
63,
411,
63,
3676,
8,
267,
298,
8842,
6209,
19881,
401,
1324,
29,
1210,
12,
536,
29,
354,
9,
272,
485,
1099,
275,
485,
411,
14,
4467,
5873,
272,
485,
3711,
63,
7088,
275,
485,
411,
14,
3711,
272,
485,
3288,
275,
1689,
52,
401,
485,
411,
14,
362,
63,
962,
480,
52,
2237,
523,
587,
26,
272,
485,
962,
63,
52,
12,
334,
1210,
4258,
275,
485,
2526,
14,
589,
63,
475,
63,
9467,
63,
10283,
779,
1210,
467,
485,
3799,
9,
272,
485,
962,
63,
52,
275,
485,
962,
63,
52,
14,
305,
63,
14184,
63,
4869,
272,
485,
3711,
63,
7088,
275,
359,
1210,
61,
272,
485,
3288,
275,
1689,
52,
401,
485,
962,
63,
52,
9,
272,
485,
1099,
275,
485,
2526,
14,
2526,
8,
66,
2,
8842,
6209,
19881,
401,
413,
12,
4153,
3699,
3711,
63,
7088,
12,
3044,
3290,
3699,
3288,
12,
4027,
3699,
3799,
12,
536,
29,
354,
9,
523,
485,
2526,
14,
3059,
63,
7490,
8,
489,
298,
8842,
6209,
19881,
401,
485,
3711,
63,
7088,
12,
485,
3288,
12,
485,
1099,
12,
536,
9,
523,
485,
1099,
12,
275,
485,
1099,
523,
372,
485,
1099,
421,
199,
318,
485,
2912,
63,
31369,
63,
6017,
8,
76,
12,
7659,
12,
536,
29,
403,
304,
523,
519,
624,
11768,
26,
1050,
1382,
14,
819,
3033,
26,
272,
634,
26,
437,
658,
3861,
2313,
9498,
506,
1373,
402,
314,
2569,
2943,
26,
658,
1609,
708,
3559,
658,
1609,
772,
2313,
272,
7659,
26,
437,
658,
3861,
2313,
9498,
1172,
314,
2011,
730,
465,
658,
76,
2313,
272,
536,
26,
437,
536,
367,
314,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
658,
3861,
2313,
13481,
314,
2011,
730,
465,
658,
76,
2313,
523,
408,
523,
485,
3799,
275,
485,
1100,
14,
1100,
342,
523,
340,
485,
3799,
14,
262,
63,
2180,
63,
632,
837,
272,
5501,
5501,
485,
411,
275,
485,
411,
63,
318,
63,
773,
423,
4998,
63,
411,
63,
3676,
8,
267,
298,
8842,
6209,
19881,
14812,
401,
634,
29,
76,
12,
7659,
29,
6017,
12,
536,
29,
354,
9,
272,
485,
1099,
275,
485,
411,
14,
4467,
5873,
272,
485,
3711,
63,
7088,
275,
485,
411,
14,
3711,
272,
485,
3288,
275,
1689,
52,
401,
485,
411,
14,
362,
63,
962,
480,
52,
2237,
523,
587,
26,
272,
485,
962,
63,
52,
12,
485,
3711,
63,
52,
275,
485,
2526,
14,
589,
63,
475,
63,
9467,
63,
10283,
779,
76,
12,
7659,
467,
485,
3799,
9,
272,
334,
76,
12,
7659,
9,
275,
485,
3711,
63,
52,
272,
485,
962,
63,
52,
275,
485,
962,
63,
52,
14,
305,
63,
14184,
63,
4869,
272,
485,
3711,
63,
7088,
275,
359,
76,
12,
7659,
61,
272,
485,
3288,
275,
1689,
52,
401,
485,
962,
63,
52,
9,
272,
485,
1099,
275,
485,
2526,
14,
2526,
8,
66,
2,
8842,
6209,
19881,
14812,
401,
413,
12,
4153,
3699,
3711,
63,
7088,
12,
3044,
3290,
3699,
3288,
12,
4027,
3699,
3799,
12,
536,
29,
354,
9,
523,
485,
2526,
14,
3059,
63,
7490,
8,
489,
298,
8842,
6209,
19881,
14812,
401,
485,
3711,
63,
7088,
12,
485,
3288,
12,
485,
1099,
12,
536,
9,
523,
485,
1099,
12,
275,
485,
1099,
523,
372,
485,
1099,
421,
199,
318,
485,
2912,
63,
3642,
63,
17061,
867,
8,
1210,
12,
536,
29,
403,
304,
523,
519,
624,
11768,
26,
1050,
1382,
14,
819,
3033,
26,
272,
1324,
26,
437,
658,
3861,
2313,
9498,
506,
1373,
402,
314,
2569,
2943,
26,
658,
1609,
708,
3559,
658,
1609,
772,
3559,
658,
5254,
772,
3559,
658,
5254,
3933,
2313,
272,
536,
26,
437,
536,
367,
314,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
658,
3861,
2313,
13481,
314,
2011,
730,
465,
658,
1210,
2313,
523,
408,
523,
485,
3799,
275,
485,
1100,
14,
1100,
342,
523,
340,
485,
3799,
14,
262,
63,
2180,
63,
632,
837,
272,
5501,
5501,
485,
411,
275,
485,
411,
63,
318,
63,
773,
423,
4998,
63,
411,
63,
3676,
8,
267,
298,
8842,
6443,
24318,
867,
401,
1324,
29,
1210,
12,
536,
29,
354,
9,
272,
485,
1099,
275,
485,
411,
14,
4467,
5873,
272,
485
] |
[
4718,
17995,
6818,
9134,
4156,
14,
199,
199,
2765,
570,
365,
4828,
1244,
3565,
29087,
6989,
1,
4226,
440,
5283,
14,
199,
17286,
445,
4176,
1350,
570,
26,
16727,
63,
1483,
14,
2055,
199,
624,
199,
199,
646,
5055,
465,
485,
7882,
199,
199,
504,
3228,
14,
1548,
14,
10283,
492,
5341,
465,
485,
2526,
199,
504,
3228,
14,
1548,
14,
10283,
492,
1067,
465,
485,
1100,
199,
504,
3228,
14,
1548,
14,
10283,
492,
6170,
465,
485,
1018,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
465,
485,
5717,
199,
504,
3228,
14,
1548,
14,
4857,
492,
2345,
63,
1392,
465,
485,
3128,
63,
1392,
199,
199,
504,
3228,
14,
1018,
14,
4857,
492,
1687,
63,
318,
63,
3317,
18,
465,
485,
411,
63,
318,
63,
3317,
18,
199,
3,
28196,
370,
6804,
314,
1240,
370,
485,
409,
63,
1250,
63,
5910,
63,
1392,
63,
2324,
14,
199,
504,
3228,
14,
1548,
14,
4857,
492,
2863,
63,
9069,
465,
485,
2330,
63,
9069,
199,
504,
3228,
14,
1548,
14,
4857,
492,
1687,
63,
318,
63,
5189,
465,
485,
411,
63,
318,
63,
5189,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
465,
485,
1483,
199,
504,
3228,
14,
1548,
14,
4857,
492,
1687,
63,
318,
63,
4342,
465,
485,
411,
63,
318,
63,
4342,
421,
199,
318,
485,
2912,
63,
31369,
8,
1210,
12,
536,
29,
403,
304,
523,
519,
624,
11768,
26,
1050,
1382,
14,
819,
3033,
26,
272,
1324,
26,
437,
658,
3861,
2313,
9498,
506,
1373,
402,
314,
2569,
2943,
26,
658,
1609,
772,
3559,
658,
1609,
708,
2313,
272,
536,
26,
437,
536,
367,
314,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
658,
3861,
2313,
13481,
314,
2011,
730,
465,
658,
1210,
2313,
523,
408,
523,
485,
3799,
275,
485,
1100,
14,
1100,
342,
523,
340,
485,
3799,
14,
262,
63,
2180,
63,
632,
837,
272,
5501,
5501,
485,
411,
275,
485,
411,
63,
318,
63,
773,
423,
4998,
63,
411,
63,
3676,
8,
267,
298,
8842,
6209,
19881,
401,
1324,
29,
1210,
12,
536,
29,
354,
9,
272,
485,
1099,
275,
485,
411,
14,
4467,
5873,
272,
485,
3711,
63,
7088,
275,
485,
411,
14,
3711,
272,
485,
3288,
275,
1689,
52,
401,
485,
411,
14,
362,
63,
962,
480,
52,
2237,
523,
587,
26,
272,
485,
962,
63,
52,
12,
334,
1210,
4258,
275,
485,
2526,
14,
589,
63,
475,
63,
9467,
63,
10283,
779,
1210,
467,
485,
3799,
9,
272,
485,
962,
63,
52,
275,
485,
962,
63,
52,
14,
305,
63,
14184,
63,
4869,
272,
485,
3711,
63,
7088,
275,
359,
1210,
61,
272,
485,
3288,
275,
1689,
52,
401,
485,
962,
63,
52,
9,
272,
485,
1099,
275,
485,
2526,
14,
2526,
8,
66,
2,
8842,
6209,
19881,
401,
413,
12,
4153,
3699,
3711,
63,
7088,
12,
3044,
3290,
3699,
3288,
12,
4027,
3699,
3799,
12,
536,
29,
354,
9,
523,
485,
2526,
14,
3059,
63,
7490,
8,
489,
298,
8842,
6209,
19881,
401,
485,
3711,
63,
7088,
12,
485,
3288,
12,
485,
1099,
12,
536,
9,
523,
485,
1099,
12,
275,
485,
1099,
523,
372,
485,
1099,
421,
199,
318,
485,
2912,
63,
31369,
63,
6017,
8,
76,
12,
7659,
12,
536,
29,
403,
304,
523,
519,
624,
11768,
26,
1050,
1382,
14,
819,
3033,
26,
272,
634,
26,
437,
658,
3861,
2313,
9498,
506,
1373,
402,
314,
2569,
2943,
26,
658,
1609,
708,
3559,
658,
1609,
772,
2313,
272,
7659,
26,
437,
658,
3861,
2313,
9498,
1172,
314,
2011,
730,
465,
658,
76,
2313,
272,
536,
26,
437,
536,
367,
314,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
658,
3861,
2313,
13481,
314,
2011,
730,
465,
658,
76,
2313,
523,
408,
523,
485,
3799,
275,
485,
1100,
14,
1100,
342,
523,
340,
485,
3799,
14,
262,
63,
2180,
63,
632,
837,
272,
5501,
5501,
485,
411,
275,
485,
411,
63,
318,
63,
773,
423,
4998,
63,
411,
63,
3676,
8,
267,
298,
8842,
6209,
19881,
14812,
401,
634,
29,
76,
12,
7659,
29,
6017,
12,
536,
29,
354,
9,
272,
485,
1099,
275,
485,
411,
14,
4467,
5873,
272,
485,
3711,
63,
7088,
275,
485,
411,
14,
3711,
272,
485,
3288,
275,
1689,
52,
401,
485,
411,
14,
362,
63,
962,
480,
52,
2237,
523,
587,
26,
272,
485,
962,
63,
52,
12,
485,
3711,
63,
52,
275,
485,
2526,
14,
589,
63,
475,
63,
9467,
63,
10283,
779,
76,
12,
7659,
467,
485,
3799,
9,
272,
334,
76,
12,
7659,
9,
275,
485,
3711,
63,
52,
272,
485,
962,
63,
52,
275,
485,
962,
63,
52,
14,
305,
63,
14184,
63,
4869,
272,
485,
3711,
63,
7088,
275,
359,
76,
12,
7659,
61,
272,
485,
3288,
275,
1689,
52,
401,
485,
962,
63,
52,
9,
272,
485,
1099,
275,
485,
2526,
14,
2526,
8,
66,
2,
8842,
6209,
19881,
14812,
401,
413,
12,
4153,
3699,
3711,
63,
7088,
12,
3044,
3290,
3699,
3288,
12,
4027,
3699,
3799,
12,
536,
29,
354,
9,
523,
485,
2526,
14,
3059,
63,
7490,
8,
489,
298,
8842,
6209,
19881,
14812,
401,
485,
3711,
63,
7088,
12,
485,
3288,
12,
485,
1099,
12,
536,
9,
523,
485,
1099,
12,
275,
485,
1099,
523,
372,
485,
1099,
421,
199,
318,
485,
2912,
63,
3642,
63,
17061,
867,
8,
1210,
12,
536,
29,
403,
304,
523,
519,
624,
11768,
26,
1050,
1382,
14,
819,
3033,
26,
272,
1324,
26,
437,
658,
3861,
2313,
9498,
506,
1373,
402,
314,
2569,
2943,
26,
658,
1609,
708,
3559,
658,
1609,
772,
3559,
658,
5254,
772,
3559,
658,
5254,
3933,
2313,
272,
536,
26,
437,
536,
367,
314,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
658,
3861,
2313,
13481,
314,
2011,
730,
465,
658,
1210,
2313,
523,
408,
523,
485,
3799,
275,
485,
1100,
14,
1100,
342,
523,
340,
485,
3799,
14,
262,
63,
2180,
63,
632,
837,
272,
5501,
5501,
485,
411,
275,
485,
411,
63,
318,
63,
773,
423,
4998,
63,
411,
63,
3676,
8,
267,
298,
8842,
6443,
24318,
867,
401,
1324,
29,
1210,
12,
536,
29,
354,
9,
272,
485,
1099,
275,
485,
411,
14,
4467,
5873,
272,
485,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
gangadharkadam/shfr
|
frappe/test_runner.py
|
23
|
7048
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
import unittest, json
import importlib
from frappe.modules import load_doctype_module, get_module_name
from frappe.utils import cstr
def main(app=None, module=None, doctype=None, verbose=False, tests=(), force=False):
frappe.flags.print_messages = verbose
frappe.flags.in_test = True
if not frappe.db:
frappe.connect()
if not frappe.conf.get("db_name").startswith("test_"):
raise Exception, 'db_name must start with "test_"'
# workaround! since there is no separate test db
frappe.clear_cache()
if verbose:
print 'Running "before_tests" hooks'
for fn in frappe.get_hooks("before_tests", app_name=app):
frappe.get_attr(fn)()
if doctype:
ret = run_tests_for_doctype(doctype, verbose=verbose, tests=tests, force=force)
elif module:
ret = run_tests_for_module(module, verbose=verbose, tests=tests)
else:
ret = run_all_tests(app, verbose)
frappe.db.commit()
# workaround! since there is no separate test db
frappe.clear_cache()
return ret
def run_all_tests(app=None, verbose=False):
import os
apps = [app] if app else frappe.get_installed_apps()
test_suite = unittest.TestSuite()
for app in apps:
for path, folders, files in os.walk(frappe.get_pymodule_path(app)):
for dontwalk in ('locals', '.git', 'public'):
if dontwalk in folders:
folders.remove(dontwalk)
# print path
for filename in files:
filename = cstr(filename)
if filename.startswith("test_") and filename.endswith(".py"):
# print filename[:-3]
_add_test(path, filename, verbose, test_suite=test_suite)
return unittest.TextTestRunner(verbosity=1+(verbose and 1 or 0)).run(test_suite)
def run_tests_for_doctype(doctype, verbose=False, tests=(), force=False):
module = frappe.db.get_value("DocType", doctype, "module")
test_module = get_module_name(doctype, module, "test_")
if force:
for name in frappe.db.sql_list("select name from `tab%s`" % doctype):
frappe.delete_doc(doctype, name, force=True)
make_test_records(doctype, verbose=verbose, force=force)
module = frappe.get_module(test_module)
return _run_unittest(module, verbose=verbose, tests=tests)
def run_tests_for_module(module, verbose=False, tests=()):
module = importlib.import_module(module)
if hasattr(module, "test_dependencies"):
for doctype in module.test_dependencies:
make_test_records(doctype, verbose=verbose)
return _run_unittest(module=module, verbose=verbose, tests=tests)
def _run_unittest(module, verbose=False, tests=()):
test_suite = unittest.TestSuite()
module_test_cases = unittest.TestLoader().loadTestsFromModule(module)
if tests:
for each in module_test_cases:
for test_case in each.__dict__["_tests"]:
if test_case.__dict__["_testMethodName"] in tests:
test_suite.addTest(test_case)
else:
test_suite.addTest(module_test_cases)
return unittest.TextTestRunner(verbosity=1+(verbose and 1 or 0)).run(test_suite)
def _add_test(path, filename, verbose, test_suite=None):
import os, imp
if os.path.sep.join(["doctype", "doctype", "boilerplate"]) in path:
# in /doctype/doctype/boilerplate/
return
if not test_suite:
test_suite = unittest.TestSuite()
if os.path.basename(os.path.dirname(path))=="doctype":
txt_file = os.path.join(path, filename[5:].replace(".py", ".json"))
with open(txt_file, 'r') as f:
doc = json.loads(f.read())
doctype = doc["name"]
make_test_records(doctype, verbose)
module = imp.load_source(filename[:-3], os.path.join(path, filename))
test_suite.addTest(unittest.TestLoader().loadTestsFromModule(module))
def make_test_records(doctype, verbose=0, force=False):
frappe.flags.mute_emails = True
if not frappe.db:
frappe.connect()
for options in get_dependencies(doctype):
if options == "[Select]":
continue
if options not in frappe.local.test_objects:
frappe.local.test_objects[options] = []
make_test_records(options, verbose, force)
make_test_records_for_doctype(options, verbose, force)
def get_modules(doctype):
module = frappe.db.get_value("DocType", doctype, "module")
try:
test_module = load_doctype_module(doctype, module, "test_")
if test_module:
reload(test_module)
except ImportError:
test_module = None
return module, test_module
def get_dependencies(doctype):
module, test_module = get_modules(doctype)
meta = frappe.get_meta(doctype)
link_fields = meta.get_link_fields()
for df in meta.get_table_fields():
link_fields.extend(frappe.get_meta(df.options).get_link_fields())
options_list = [df.options for df in link_fields] + [doctype]
if hasattr(test_module, "test_dependencies"):
options_list += test_module.test_dependencies
options_list = list(set(options_list))
if hasattr(test_module, "test_ignore"):
for doctype_name in test_module.test_ignore:
if doctype_name in options_list:
options_list.remove(doctype_name)
return options_list
def make_test_records_for_doctype(doctype, verbose=0, force=False):
module, test_module = get_modules(doctype)
if verbose:
print "Making for " + doctype
if hasattr(test_module, "_make_test_records"):
frappe.local.test_objects[doctype] += test_module._make_test_records(verbose)
elif hasattr(test_module, "test_records"):
frappe.local.test_objects[doctype] += make_test_objects(doctype, test_module.test_records, verbose)
else:
test_records = frappe.get_test_records(doctype)
if test_records:
frappe.local.test_objects[doctype] += make_test_objects(doctype, test_records, verbose)
elif verbose:
print_mandatory_fields(doctype)
def make_test_objects(doctype, test_records, verbose=None):
records = []
if not frappe.get_meta(doctype).issingle:
existing = frappe.get_list(doctype, filters={"name":("like", "_T-" + doctype + "-%")})
if existing:
return [d.name for d in existing]
existing = frappe.get_list(doctype, filters={"name":("like", "_Test " + doctype + "%")})
if existing:
return [d.name for d in existing]
for doc in test_records:
if not doc.get("doctype"):
doc["doctype"] = doctype
d = frappe.copy_doc(doc)
if doc.get('name'):
d.name = doc.get('name')
if frappe.local.test_objects.get(d.doctype):
# do not create test records, if already exists
return []
if d.meta.get_field("naming_series"):
if not d.naming_series:
d.naming_series = "_T-" + d.doctype + "-"
# submit if docstatus is set to 1 for test record
docstatus = d.docstatus
d.docstatus = 0
try:
d.insert()
if docstatus == 1:
d.submit()
except frappe.NameError:
pass
records.append(d.name)
frappe.db.commit()
return records
def print_mandatory_fields(doctype):
print "Please setup make_test_records for: " + doctype
print "-" * 60
meta = frappe.get_meta(doctype)
print "Autoname: " + (meta.autoname or "")
print "Mandatory Fields: "
for d in meta.get("fields", {"reqd":1}):
print d.parent + ":" + d.fieldname + " | " + d.fieldtype + " | " + (d.options or "")
print
|
mit
|
[
3,
1898,
334,
67,
9,
6171,
12,
6001,
8144,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
10697,
844,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
6950,
199,
646,
2882,
12,
2022,
199,
646,
14802,
199,
504,
6950,
14,
3112,
492,
2248,
63,
6356,
63,
578,
12,
664,
63,
578,
63,
354,
199,
504,
6950,
14,
1208,
492,
286,
495,
421,
199,
318,
2446,
8,
571,
29,
403,
12,
859,
29,
403,
12,
13265,
29,
403,
12,
3376,
29,
797,
12,
2295,
16729,
3542,
29,
797,
304,
199,
198,
9098,
14,
2469,
14,
1361,
63,
3431,
275,
3376,
199,
198,
9098,
14,
2469,
14,
262,
63,
396,
275,
715,
421,
198,
692,
440,
6950,
14,
697,
26,
507,
198,
9098,
14,
2242,
342,
421,
198,
692,
440,
6950,
14,
2190,
14,
362,
480,
697,
63,
354,
3471,
2460,
480,
396,
63,
2349,
507,
198,
3730,
2186,
12,
283,
697,
63,
354,
1471,
1343,
543,
298,
396,
63,
4507,
421,
198,
3,
18092,
1,
3967,
2337,
365,
949,
7396,
511,
1592,
199,
198,
9098,
14,
3584,
63,
1637,
342,
421,
198,
692,
3376,
26,
507,
198,
1361,
283,
9602,
298,
5182,
63,
2219,
2,
12604,
7,
199,
198,
509,
4325,
315,
6950,
14,
362,
63,
7922,
480,
5182,
63,
2219,
401,
1145,
63,
354,
29,
571,
304,
507,
198,
9098,
14,
362,
63,
962,
8,
2324,
16315,
421,
198,
692,
13265,
26,
507,
198,
3292,
275,
1255,
63,
2219,
63,
509,
63,
6356,
8,
6356,
12,
3376,
29,
3832,
12,
2295,
29,
2219,
12,
3542,
29,
3990,
9,
199,
198,
4164,
859,
26,
507,
198,
3292,
275,
1255,
63,
2219,
63,
509,
63,
578,
8,
578,
12,
3376,
29,
3832,
12,
2295,
29,
2219,
9,
199,
198,
2836,
26,
507,
198,
3292,
275,
1255,
63,
452,
63,
2219,
8,
571,
12,
3376,
9,
421,
198,
9098,
14,
697,
14,
3543,
342,
421,
198,
3,
18092,
1,
3967,
2337,
365,
949,
7396,
511,
1592,
199,
198,
9098,
14,
3584,
63,
1637,
342,
421,
198,
1107,
2203,
199,
199,
318,
1255,
63,
452,
63,
2219,
8,
571,
29,
403,
12,
3376,
29,
797,
304,
199,
198,
646,
747,
421,
198,
5181,
275,
359,
571,
61,
340,
1145,
587,
6950,
14,
362,
63,
7657,
63,
5181,
342,
421,
198,
396,
63,
5768,
275,
2882,
14,
10591,
342,
199,
198,
509,
1145,
315,
8686,
26,
507,
198,
509,
931,
12,
16533,
12,
1584,
315,
747,
14,
7757,
8,
9098,
14,
362,
63,
647,
578,
63,
515,
8,
571,
2298,
686,
198,
509,
21542,
7757,
315,
661,
9350,
297,
1987,
3187,
297,
283,
3455,
735,
1585,
198,
692,
21542,
7757,
315,
16533,
26,
1871,
198,
15171,
14,
2168,
8,
18671,
7757,
9,
6319,
198,
3,
870,
931,
686,
198,
509,
1788,
315,
1584,
26,
1585,
198,
1501,
275,
286,
495,
8,
1501,
9,
1585,
198,
692,
1788,
14,
2460,
480,
396,
29443,
436,
1788,
14,
4130,
9520,
647,
2349,
1871,
198,
3,
870,
1788,
4439,
19,
61,
1871,
198,
63,
525,
63,
396,
8,
515,
12,
1788,
12,
3376,
12,
511,
63,
5768,
29,
396,
63,
5768,
9,
421,
198,
1107,
2882,
14,
24285,
8,
9833,
29,
17,
15622,
3832,
436,
413,
503,
378,
4992,
1065,
8,
396,
63,
5768,
9,
199,
199,
318,
1255,
63,
2219,
63,
509,
63,
6356,
8,
6356,
12,
3376,
29,
797,
12,
2295,
16729,
3542,
29,
797,
304,
199,
198,
578,
275,
6950,
14,
697,
14,
362,
63,
585,
480,
3768,
804,
401,
13265,
12,
298,
578,
531,
199,
198,
396,
63,
578,
275,
664,
63,
578,
63,
354,
8,
6356,
12,
859,
12,
298,
396,
29443,
199,
198,
692,
3542,
26,
507,
198,
509,
536,
315,
6950,
14,
697,
14,
3009,
63,
513,
480,
2416,
536,
687,
658,
2902,
5,
83,
64,
2,
450,
13265,
304,
686,
198,
9098,
14,
1807,
63,
1301,
8,
6356,
12,
536,
12,
3542,
29,
549,
9,
199,
198,
1875,
63,
396,
63,
6502,
8,
6356,
12,
3376,
29,
3832,
12,
3542,
29,
3990,
9,
199,
198,
578,
275,
6950,
14,
362,
63,
578,
8,
396,
63,
578,
9,
199,
198,
1107,
485,
1065,
63,
2796,
8,
578,
12,
3376,
29,
3832,
12,
2295,
29,
2219,
9,
199,
199,
318,
1255,
63,
2219,
63,
509,
63,
578,
8,
578,
12,
3376,
29,
797,
12,
2295,
23603,
199,
198,
578,
275,
14802,
14,
646,
63,
578,
8,
578,
9,
199,
198,
692,
2688,
8,
578,
12,
298,
396,
63,
5714,
2349,
507,
198,
509,
13265,
315,
859,
14,
396,
63,
5714,
26,
686,
198,
1875,
63,
396,
63,
6502,
8,
6356,
12,
3376,
29,
3832,
9,
421,
198,
1107,
485,
1065,
63,
2796,
8,
578,
29,
578,
12,
3376,
29,
3832,
12,
2295,
29,
2219,
9,
199,
199,
318,
485,
1065,
63,
2796,
8,
578,
12,
3376,
29,
797,
12,
2295,
23603,
199,
198,
396,
63,
5768,
275,
2882,
14,
10591,
342,
199,
198,
578,
63,
396,
63,
9403,
275,
2882,
14,
15824,
1252,
12861,
2377,
8,
578,
9,
199,
198,
692,
2295,
26,
507,
198,
509,
1924,
315,
859,
63,
396,
63,
9403,
26,
686,
198,
509,
511,
63,
2546,
315,
1924,
855,
807,
363,
18524,
2219,
6229,
1585,
198,
692,
511,
63,
2546,
855,
807,
363,
18524,
25008,
985,
937,
315,
2295,
26,
1871,
198,
396,
63,
5768,
14,
15714,
8,
396,
63,
2546,
9,
199,
198,
2836,
26,
507,
198,
396,
63,
5768,
14,
15714,
8,
578,
63,
396,
63,
9403,
9,
421,
198,
1107,
2882,
14,
24285,
8,
9833,
29,
17,
15622,
3832,
436,
413,
503,
378,
4992,
1065,
8,
396,
63,
5768,
9,
199,
199,
318,
485,
525,
63,
396,
8,
515,
12,
1788,
12,
3376,
12,
511,
63,
5768,
29,
403,
304,
199,
198,
646,
747,
12,
1742,
421,
198,
692,
747,
14,
515,
14,
4127,
14,
904,
5234,
6356,
401,
298,
6356,
401,
298,
656,
27025,
3135,
315,
931,
26,
507,
198,
3,
315,
1182,
6356,
15,
6356,
15,
656,
27025,
15,
507,
198,
1107,
421,
198,
692,
440,
511,
63,
5768,
26,
507,
198,
396,
63,
5768,
275,
2882,
14,
10591,
342,
421,
198,
692,
747,
14,
515,
14
] |
[
1898,
334,
67,
9,
6171,
12,
6001,
8144,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
10697,
844,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
6950,
199,
646,
2882,
12,
2022,
199,
646,
14802,
199,
504,
6950,
14,
3112,
492,
2248,
63,
6356,
63,
578,
12,
664,
63,
578,
63,
354,
199,
504,
6950,
14,
1208,
492,
286,
495,
421,
199,
318,
2446,
8,
571,
29,
403,
12,
859,
29,
403,
12,
13265,
29,
403,
12,
3376,
29,
797,
12,
2295,
16729,
3542,
29,
797,
304,
199,
198,
9098,
14,
2469,
14,
1361,
63,
3431,
275,
3376,
199,
198,
9098,
14,
2469,
14,
262,
63,
396,
275,
715,
421,
198,
692,
440,
6950,
14,
697,
26,
507,
198,
9098,
14,
2242,
342,
421,
198,
692,
440,
6950,
14,
2190,
14,
362,
480,
697,
63,
354,
3471,
2460,
480,
396,
63,
2349,
507,
198,
3730,
2186,
12,
283,
697,
63,
354,
1471,
1343,
543,
298,
396,
63,
4507,
421,
198,
3,
18092,
1,
3967,
2337,
365,
949,
7396,
511,
1592,
199,
198,
9098,
14,
3584,
63,
1637,
342,
421,
198,
692,
3376,
26,
507,
198,
1361,
283,
9602,
298,
5182,
63,
2219,
2,
12604,
7,
199,
198,
509,
4325,
315,
6950,
14,
362,
63,
7922,
480,
5182,
63,
2219,
401,
1145,
63,
354,
29,
571,
304,
507,
198,
9098,
14,
362,
63,
962,
8,
2324,
16315,
421,
198,
692,
13265,
26,
507,
198,
3292,
275,
1255,
63,
2219,
63,
509,
63,
6356,
8,
6356,
12,
3376,
29,
3832,
12,
2295,
29,
2219,
12,
3542,
29,
3990,
9,
199,
198,
4164,
859,
26,
507,
198,
3292,
275,
1255,
63,
2219,
63,
509,
63,
578,
8,
578,
12,
3376,
29,
3832,
12,
2295,
29,
2219,
9,
199,
198,
2836,
26,
507,
198,
3292,
275,
1255,
63,
452,
63,
2219,
8,
571,
12,
3376,
9,
421,
198,
9098,
14,
697,
14,
3543,
342,
421,
198,
3,
18092,
1,
3967,
2337,
365,
949,
7396,
511,
1592,
199,
198,
9098,
14,
3584,
63,
1637,
342,
421,
198,
1107,
2203,
199,
199,
318,
1255,
63,
452,
63,
2219,
8,
571,
29,
403,
12,
3376,
29,
797,
304,
199,
198,
646,
747,
421,
198,
5181,
275,
359,
571,
61,
340,
1145,
587,
6950,
14,
362,
63,
7657,
63,
5181,
342,
421,
198,
396,
63,
5768,
275,
2882,
14,
10591,
342,
199,
198,
509,
1145,
315,
8686,
26,
507,
198,
509,
931,
12,
16533,
12,
1584,
315,
747,
14,
7757,
8,
9098,
14,
362,
63,
647,
578,
63,
515,
8,
571,
2298,
686,
198,
509,
21542,
7757,
315,
661,
9350,
297,
1987,
3187,
297,
283,
3455,
735,
1585,
198,
692,
21542,
7757,
315,
16533,
26,
1871,
198,
15171,
14,
2168,
8,
18671,
7757,
9,
6319,
198,
3,
870,
931,
686,
198,
509,
1788,
315,
1584,
26,
1585,
198,
1501,
275,
286,
495,
8,
1501,
9,
1585,
198,
692,
1788,
14,
2460,
480,
396,
29443,
436,
1788,
14,
4130,
9520,
647,
2349,
1871,
198,
3,
870,
1788,
4439,
19,
61,
1871,
198,
63,
525,
63,
396,
8,
515,
12,
1788,
12,
3376,
12,
511,
63,
5768,
29,
396,
63,
5768,
9,
421,
198,
1107,
2882,
14,
24285,
8,
9833,
29,
17,
15622,
3832,
436,
413,
503,
378,
4992,
1065,
8,
396,
63,
5768,
9,
199,
199,
318,
1255,
63,
2219,
63,
509,
63,
6356,
8,
6356,
12,
3376,
29,
797,
12,
2295,
16729,
3542,
29,
797,
304,
199,
198,
578,
275,
6950,
14,
697,
14,
362,
63,
585,
480,
3768,
804,
401,
13265,
12,
298,
578,
531,
199,
198,
396,
63,
578,
275,
664,
63,
578,
63,
354,
8,
6356,
12,
859,
12,
298,
396,
29443,
199,
198,
692,
3542,
26,
507,
198,
509,
536,
315,
6950,
14,
697,
14,
3009,
63,
513,
480,
2416,
536,
687,
658,
2902,
5,
83,
64,
2,
450,
13265,
304,
686,
198,
9098,
14,
1807,
63,
1301,
8,
6356,
12,
536,
12,
3542,
29,
549,
9,
199,
198,
1875,
63,
396,
63,
6502,
8,
6356,
12,
3376,
29,
3832,
12,
3542,
29,
3990,
9,
199,
198,
578,
275,
6950,
14,
362,
63,
578,
8,
396,
63,
578,
9,
199,
198,
1107,
485,
1065,
63,
2796,
8,
578,
12,
3376,
29,
3832,
12,
2295,
29,
2219,
9,
199,
199,
318,
1255,
63,
2219,
63,
509,
63,
578,
8,
578,
12,
3376,
29,
797,
12,
2295,
23603,
199,
198,
578,
275,
14802,
14,
646,
63,
578,
8,
578,
9,
199,
198,
692,
2688,
8,
578,
12,
298,
396,
63,
5714,
2349,
507,
198,
509,
13265,
315,
859,
14,
396,
63,
5714,
26,
686,
198,
1875,
63,
396,
63,
6502,
8,
6356,
12,
3376,
29,
3832,
9,
421,
198,
1107,
485,
1065,
63,
2796,
8,
578,
29,
578,
12,
3376,
29,
3832,
12,
2295,
29,
2219,
9,
199,
199,
318,
485,
1065,
63,
2796,
8,
578,
12,
3376,
29,
797,
12,
2295,
23603,
199,
198,
396,
63,
5768,
275,
2882,
14,
10591,
342,
199,
198,
578,
63,
396,
63,
9403,
275,
2882,
14,
15824,
1252,
12861,
2377,
8,
578,
9,
199,
198,
692,
2295,
26,
507,
198,
509,
1924,
315,
859,
63,
396,
63,
9403,
26,
686,
198,
509,
511,
63,
2546,
315,
1924,
855,
807,
363,
18524,
2219,
6229,
1585,
198,
692,
511,
63,
2546,
855,
807,
363,
18524,
25008,
985,
937,
315,
2295,
26,
1871,
198,
396,
63,
5768,
14,
15714,
8,
396,
63,
2546,
9,
199,
198,
2836,
26,
507,
198,
396,
63,
5768,
14,
15714,
8,
578,
63,
396,
63,
9403,
9,
421,
198,
1107,
2882,
14,
24285,
8,
9833,
29,
17,
15622,
3832,
436,
413,
503,
378,
4992,
1065,
8,
396,
63,
5768,
9,
199,
199,
318,
485,
525,
63,
396,
8,
515,
12,
1788,
12,
3376,
12,
511,
63,
5768,
29,
403,
304,
199,
198,
646,
747,
12,
1742,
421,
198,
692,
747,
14,
515,
14,
4127,
14,
904,
5234,
6356,
401,
298,
6356,
401,
298,
656,
27025,
3135,
315,
931,
26,
507,
198,
3,
315,
1182,
6356,
15,
6356,
15,
656,
27025,
15,
507,
198,
1107,
421,
198,
692,
440,
511,
63,
5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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
] |
Dronecode/MAVProxy
|
MAVProxy/modules/mavproxy_timesync.py
|
6
|
1119
|
#!/usr/bin/env python
from __future__ import print_function
"""
Currently what I do is run a sync every second and keep the following:
time_send
time_receive
As a result the delta between GCS time and drone time is:
dtime = (time_send + time_receive) / 2 - drone_time;
And when doing that a lot the dtime will average to the correct
delta. As a result it is now possible to know exactly when a
"GLOBAL_POSITION_INT" was created in GCS time.
"""
from MAVProxy.modules.lib import mp_module
class TimeSyncModule(mp_module.MPModule):
def __init__(self, mpstate):
super(TimeSyncModule, self).__init__(mpstate, "timesync")
self.add_command('timesync', self.cmd_timesync, "timesync")
def cmd_timesync(self, args):
if (len(args) != 1):
print("Usage: timesync CURRENT_TIME")
return
self.master.mav.timesync_send(0, int(args[0]))
def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
if m.get_type() == 'TIMESYNC':
print(m)
def init(mpstate):
'''initialise module'''
return TimeSyncModule(mpstate)
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
624,
199,
31499,
4052,
473,
886,
365,
1255,
282,
7604,
4036,
3499,
436,
4215,
314,
2569,
26,
199,
521,
63,
2254,
199,
521,
63,
9391,
199,
199,
2822,
282,
754,
314,
5762,
3382,
598,
3298,
900,
436,
16642,
368,
900,
365,
26,
199,
68,
521,
275,
334,
521,
63,
2254,
435,
900,
63,
9391,
9,
1182,
499,
446,
16642,
368,
63,
521,
27,
199,
199,
3325,
1380,
9689,
626,
282,
13918,
314,
366,
521,
911,
8095,
370,
314,
3211,
199,
3136,
14,
3709,
282,
754,
652,
365,
3063,
3962,
370,
5715,
8840,
1380,
282,
199,
2,
13808,
63,
15717,
63,
2919,
2,
1990,
2737,
315,
598,
3298,
900,
14,
199,
624,
199,
199,
504,
20553,
4936,
14,
3112,
14,
773,
492,
6118,
63,
578,
421,
199,
533,
4703,
10878,
2377,
8,
311,
63,
578,
14,
1658,
2377,
304,
272,
347,
636,
826,
721,
277,
12,
6118,
929,
304,
267,
1613,
8,
1366,
10878,
2377,
12,
291,
2843,
826,
721,
311,
929,
12,
298,
4508,
1870,
531,
267,
291,
14,
525,
63,
1531,
360,
4508,
1870,
297,
291,
14,
1760,
63,
4508,
1870,
12,
298,
4508,
1870,
531,
339,
347,
2088,
63,
4508,
1870,
8,
277,
12,
1249,
304,
267,
340,
334,
552,
8,
589,
9,
1137,
413,
304,
288,
870,
480,
7692,
26,
900,
5186,
27946,
63,
4961,
531,
288,
372,
398,
291,
14,
4133,
14,
10336,
14,
4508,
1870,
63,
2254,
8,
16,
12,
1109,
8,
589,
59,
16,
2459,
339,
347,
11456,
1073,
63,
6253,
8,
277,
12,
333,
304,
267,
1449,
2479,
376,
12467,
11456,
1073,
3644,
2344,
267,
340,
333,
14,
362,
63,
466,
342,
508,
283,
11342,
654,
57,
6389,
356,
288,
870,
8,
77,
9,
421,
199,
318,
4205,
8,
311,
929,
304,
272,
1449,
2747,
572,
859,
2344,
272,
372,
4703,
10878,
2377,
8,
311,
929,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
624,
199,
31499,
4052,
473,
886,
365,
1255,
282,
7604,
4036,
3499,
436,
4215,
314,
2569,
26,
199,
521,
63,
2254,
199,
521,
63,
9391,
199,
199,
2822,
282,
754,
314,
5762,
3382,
598,
3298,
900,
436,
16642,
368,
900,
365,
26,
199,
68,
521,
275,
334,
521,
63,
2254,
435,
900,
63,
9391,
9,
1182,
499,
446,
16642,
368,
63,
521,
27,
199,
199,
3325,
1380,
9689,
626,
282,
13918,
314,
366,
521,
911,
8095,
370,
314,
3211,
199,
3136,
14,
3709,
282,
754,
652,
365,
3063,
3962,
370,
5715,
8840,
1380,
282,
199,
2,
13808,
63,
15717,
63,
2919,
2,
1990,
2737,
315,
598,
3298,
900,
14,
199,
624,
199,
199,
504,
20553,
4936,
14,
3112,
14,
773,
492,
6118,
63,
578,
421,
199,
533,
4703,
10878,
2377,
8,
311,
63,
578,
14,
1658,
2377,
304,
272,
347,
636,
826,
721,
277,
12,
6118,
929,
304,
267,
1613,
8,
1366,
10878,
2377,
12,
291,
2843,
826,
721,
311,
929,
12,
298,
4508,
1870,
531,
267,
291,
14,
525,
63,
1531,
360,
4508,
1870,
297,
291,
14,
1760,
63,
4508,
1870,
12,
298,
4508,
1870,
531,
339,
347,
2088,
63,
4508,
1870,
8,
277,
12,
1249,
304,
267,
340,
334,
552,
8,
589,
9,
1137,
413,
304,
288,
870,
480,
7692,
26,
900,
5186,
27946,
63,
4961,
531,
288,
372,
398,
291,
14,
4133,
14,
10336,
14,
4508,
1870,
63,
2254,
8,
16,
12,
1109,
8,
589,
59,
16,
2459,
339,
347,
11456,
1073,
63,
6253,
8,
277,
12,
333,
304,
267,
1449,
2479,
376,
12467,
11456,
1073,
3644,
2344,
267,
340,
333,
14,
362,
63,
466,
342,
508,
283,
11342,
654,
57,
6389,
356,
288,
870,
8,
77,
9,
421,
199,
318,
4205,
8,
311,
929,
304,
272,
1449,
2747,
572,
859,
2344,
272,
372,
4703,
10878,
2377,
8,
311,
929,
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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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
] |
pforai/easybuild-framework
|
test/framework/sandbox/easybuild/easyblocks/generic/dummyextension.py
|
9
|
1375
|
##
# Copyright 2009-2015 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en),
# the Hercules foundation (http://www.herculesstichting.be/in_English)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# http://github.com/hpcugent/easybuild
#
# EasyBuild 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 v2.
#
# EasyBuild 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 EasyBuild. If not, see <http://www.gnu.org/licenses/>.
##
"""
EasyBuild support for building and installing dummy extensions, implemented as an easyblock
@author: Kenneth Hoste (Ghent University)
"""
from easybuild.framework.extensioneasyblock import ExtensionEasyBlock
class DummyExtension(ExtensionEasyBlock):
"""Support for building/installing dummy extensions."""
|
gpl-2.0
|
[
309,
199,
3,
1898,
8937,
13,
7806,
598,
72,
484,
15904,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
30025,
12,
199,
3,
20657,
2737,
701,
314,
869,
4222,
8099,
402,
598,
72,
484,
15904,
334,
1014,
921,
1518,
484,
14,
1235,
15,
72,
2352,
15,
287,
395,
199,
3,
543,
2291,
402,
598,
72,
484,
15904,
334,
1014,
921,
1518,
484,
14,
1235,
15,
72,
2352,
395,
199,
3,
314,
481,
274,
1292,
72,
17897,
23805,
30610,
264,
334,
54,
5153,
9,
334,
2859,
921,
86,
10845,
454,
453,
14,
1235,
15,
7530,
15,
287,
395,
199,
3,
314,
18769,
67,
443,
83,
1911,
425,
334,
1014,
921,
1544,
14,
2523,
67,
443,
83,
270,
1158,
1337,
14,
1235,
15,
262,
63,
19410,
9,
199,
3,
436,
314,
1487,
12493,
402,
662,
25129,
89,
12,
27491,
436,
1010,
889,
4255,
334,
37,
18759,
9,
334,
1014,
921,
1544,
14,
546,
73,
13,
86,
416,
290,
271,
828,
14,
1235,
15,
287,
680,
199,
3,
199,
3,
1455,
921,
5031,
14,
957,
15,
72,
2352,
1518,
484,
15,
13581,
1506,
199,
3,
199,
3,
30025,
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,
373,
18,
14,
199,
3,
199,
3,
30025,
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,
30025,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
309,
199,
624,
199,
28326,
3425,
2291,
367,
10015,
436,
22200,
7283,
5478,
12,
6366,
465,
376,
8837,
1457,
199,
199,
32,
2502,
26,
1804,
287,
685,
273,
869,
736,
266,
334,
39,
72,
484,
15904,
9,
199,
624,
199,
199,
504,
8837,
1506,
14,
4857,
14,
1614,
9353,
5660,
1457,
492,
13282,
28326,
3142,
199,
199,
533,
9762,
6382,
8,
6382,
28326,
3142,
304,
272,
408,
11532,
367,
10015,
15,
3174,
316,
7283,
5478,
1041,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
1898,
8937,
13,
7806,
598,
72,
484,
15904,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
30025,
12,
199,
3,
20657,
2737,
701,
314,
869,
4222,
8099,
402,
598,
72,
484,
15904,
334,
1014,
921,
1518,
484,
14,
1235,
15,
72,
2352,
15,
287,
395,
199,
3,
543,
2291,
402,
598,
72,
484,
15904,
334,
1014,
921,
1518,
484,
14,
1235,
15,
72,
2352,
395,
199,
3,
314,
481,
274,
1292,
72,
17897,
23805,
30610,
264,
334,
54,
5153,
9,
334,
2859,
921,
86,
10845,
454,
453,
14,
1235,
15,
7530,
15,
287,
395,
199,
3,
314,
18769,
67,
443,
83,
1911,
425,
334,
1014,
921,
1544,
14,
2523,
67,
443,
83,
270,
1158,
1337,
14,
1235,
15,
262,
63,
19410,
9,
199,
3,
436,
314,
1487,
12493,
402,
662,
25129,
89,
12,
27491,
436,
1010,
889,
4255,
334,
37,
18759,
9,
334,
1014,
921,
1544,
14,
546,
73,
13,
86,
416,
290,
271,
828,
14,
1235,
15,
287,
680,
199,
3,
199,
3,
1455,
921,
5031,
14,
957,
15,
72,
2352,
1518,
484,
15,
13581,
1506,
199,
3,
199,
3,
30025,
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,
373,
18,
14,
199,
3,
199,
3,
30025,
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,
30025,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
309,
199,
624,
199,
28326,
3425,
2291,
367,
10015,
436,
22200,
7283,
5478,
12,
6366,
465,
376,
8837,
1457,
199,
199,
32,
2502,
26,
1804,
287,
685,
273,
869,
736,
266,
334,
39,
72,
484,
15904,
9,
199,
624,
199,
199,
504,
8837,
1506,
14,
4857,
14,
1614,
9353,
5660,
1457,
492,
13282,
28326,
3142,
199,
199,
533,
9762,
6382,
8,
6382,
28326,
3142,
304,
272,
408,
11532,
367,
10015,
15,
3174,
316,
7283,
5478,
1041,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
dafrito/trac-mirror
|
trac/about.py
|
7
|
3145
|
# -*- coding: utf-8 -*-
#
# Copyright (C) 2004-2009 Edgewall Software
# Copyright (C) 2004-2005 Jonas Borgström <jonas@edgewall.com>
# Copyright (C) 2004-2005 Daniel Lundin <daniel@edgewall.com>
# Copyright (C) 2005-2006 Christopher Lenz <cmlenz@gmx.de>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://trac.edgewall.org/wiki/TracLicense.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/log/.
#
# Author: Jonas Borgström <jonas@edgewall.com>
# Christopher Lenz <cmlenz@gmx.de>
import re
from genshi.builder import tag
from trac.core import *
from trac.loader import get_plugin_info
from trac.perm import IPermissionRequestor
from trac.util.translation import _
from trac.web import IRequestHandler
from trac.web.chrome import INavigationContributor
class AboutModule(Component):
""""About Trac" page provider, showing version information from
third-party packages, as well as configuration information."""
required = True
implements(INavigationContributor, IPermissionRequestor, IRequestHandler)
# INavigationContributor methods
def get_active_navigation_item(self, req):
return 'about'
def get_navigation_items(self, req):
yield ('metanav', 'about',
tag.a(_('About Trac'), href=req.href.about()))
# IPermissionRequestor methods
def get_permission_actions(self):
return ['CONFIG_VIEW']
# IRequestHandler methods
def match_request(self, req):
return re.match(r'/about(?:_trac)?(?:/.+)?$', req.path_info)
def process_request(self, req):
data = {'systeminfo': None, 'plugins': None, 'config': None}
if 'CONFIG_VIEW' in req.perm('config', 'systeminfo'):
# Collect system information
data['systeminfo'] = self.env.get_systeminfo()
if 'CONFIG_VIEW' in req.perm('config', 'plugins'):
# Collect plugin information
data['plugins'] = get_plugin_info(self.env)
if 'CONFIG_VIEW' in req.perm('config', 'ini'):
# Collect config information
defaults = self.config.defaults(self.compmgr)
sections = []
for section in self.config.sections(self.compmgr):
options = []
default_options = defaults.get(section, {})
for name, value in self.config.options(section, self.compmgr):
default = default_options.get(name) or ''
options.append({
'name': name, 'value': value,
'modified': unicode(value) != unicode(default)
})
options.sort(key=lambda o: o['name'])
sections.append({'name': section, 'options': options})
sections.sort(key=lambda s: s['name'])
data['config'] = sections
return 'about.html', data, None
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
35,
9,
8353,
13,
8664,
25155,
7567,
2290,
199,
3,
1898,
334,
35,
9,
8353,
13,
9397,
1603,
265,
305,
699,
1308,
495,
14614,
77,
665,
74,
265,
305,
32,
5173,
7567,
14,
957,
30,
199,
3,
1898,
334,
35,
9,
8353,
13,
9397,
24747,
14769,
491,
725,
262,
665,
24863,
14769,
32,
5173,
7567,
14,
957,
30,
199,
3,
1898,
334,
35,
9,
11811,
13,
7968,
2799,
322,
2379,
2523,
15757,
90,
665,
4400,
552,
90,
32,
71,
9457,
14,
271,
30,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
961,
2032,
365,
18233,
465,
11736,
315,
314,
570,
9685,
12,
1314,
199,
3,
1265,
1077,
1172,
3086,
465,
1777,
402,
642,
4084,
14,
710,
2895,
199,
3,
787,
2597,
2808,
737,
1455,
921,
23047,
14,
5173,
7567,
14,
1308,
15,
6797,
15,
2437,
67,
3761,
14,
199,
3,
199,
3,
961,
2032,
18581,
402,
5236,
638,
695,
406,
26675,
6326,
701,
5002,
199,
3,
8212,
83,
14,
2104,
314,
5835,
406,
15980,
7994,
12,
1937,
314,
6974,
199,
3,
7994,
436,
9610,
12,
2808,
737,
1455,
921,
23047,
14,
5173,
7567,
14,
1308,
15,
793,
8083,
199,
3,
199,
3,
6529,
26,
1603,
265,
305,
699,
1308,
495,
14614,
77,
665,
74,
265,
305,
32,
5173,
7567,
14,
957,
30,
199,
3,
260,
2799,
322,
2379,
2523,
15757,
90,
665,
4400,
552,
90,
32,
71,
9457,
14,
271,
30,
199,
199,
646,
295,
199,
199,
504,
3805,
19377,
14,
5649,
492,
1947,
199,
199,
504,
1468,
67,
14,
1018,
492,
627,
199,
504,
1468,
67,
14,
3422,
492,
664,
63,
2718,
63,
815,
199,
504,
1468,
67,
14,
8220,
492,
473,
7980,
2017,
269,
199,
504,
1468,
67,
14,
1974,
14,
6893,
492,
485,
199,
504,
1468,
67,
14,
2520,
492,
473,
11149,
199,
504,
1468,
67,
14,
2520,
14,
9887,
492,
1621,
7194,
5360,
714,
1925,
4139,
421,
199,
533,
25225,
2377,
8,
7004,
304,
272,
408,
2,
18816,
377,
6457,
2,
2034,
5022,
12,
21207,
1015,
2556,
687,
272,
10919,
13,
7522,
6117,
12,
465,
5521,
465,
2897,
2556,
1041,
339,
1415,
275,
715,
339,
9031,
8,
568,
7194,
5360,
714,
1925,
4139,
12,
473,
7980,
2017,
269,
12,
473,
11149,
9,
339,
327,
1621,
7194,
5360,
714,
1925,
4139,
3102,
339,
347,
664,
63,
2682,
63,
24148,
63,
1053,
8,
277,
12,
2648,
304,
267,
372,
283,
10254,
7,
339,
347,
664,
63,
24148,
63,
1744,
8,
277,
12,
2648,
304,
267,
1995,
661,
10207,
290,
1214,
297,
283,
10254,
297,
2049,
1947,
14,
65,
6723,
18816,
377,
6457,
659,
4369,
29,
2103,
14,
6399,
14,
10254,
4059,
339,
327,
473,
7980,
2017,
269,
3102,
339,
347,
664,
63,
5693,
63,
3723,
8,
277,
304,
267,
372,
788,
5569,
63,
12058,
418,
339,
327,
473,
11149,
3102,
339,
347,
1336,
63,
1069,
8,
277,
12,
2648,
304,
267,
372,
295,
14,
1431,
8,
82,
9807,
10254,
5169,
63,
23047,
5547,
5169,
15,
6977,
5547,
4268,
2648,
14,
515,
63,
815,
9,
339,
347,
2112,
63,
1069,
8,
277,
12,
2648,
304,
267,
666,
275,
791,
2253,
815,
356,
488,
12,
283,
5265,
356,
488,
12,
283,
888,
356,
488,
93,
398,
340,
283,
5569,
63,
12058,
7,
315,
2648,
14,
8220,
360,
888,
297,
283,
2253,
815,
735,
288,
327,
19649,
2656,
2556,
288,
666,
459,
2253,
815,
418,
275,
291,
14,
1813,
14,
362,
63,
2253,
815,
342,
398,
340,
283,
5569,
63,
12058,
7,
315,
2648,
14,
8220,
360,
888,
297,
283,
5265,
735,
288,
327,
19649,
3589,
2556,
288,
666,
459,
5265,
418,
275,
664,
63,
2718,
63,
815,
8,
277,
14,
1813,
9,
398,
340,
283,
5569,
63,
12058,
7,
315,
2648,
14,
8220,
360,
888,
297,
283,
2730,
735,
288,
327,
19649,
1101,
2556,
288,
4243,
275,
291,
14,
888,
14,
4322,
8,
277,
14,
863,
7755,
9,
288,
10189,
275,
942,
288,
367,
3420,
315,
291,
14,
888,
14,
7786,
8,
277,
14,
863,
7755,
304,
355,
1511,
275,
942,
355,
849,
63,
1419,
275,
4243,
14,
362,
8,
2792,
12,
5009,
355,
367,
536,
12,
574,
315,
291,
14,
888,
14,
1419,
8,
2792,
12,
291,
14,
863,
7755,
304,
490,
849,
275,
849,
63,
1419,
14,
362,
8,
354,
9,
503,
2125,
490,
1511,
14,
740,
2561,
717,
283,
354,
356,
536,
12,
283,
585,
356,
574,
12,
717,
283,
5540,
356,
2649,
8,
585,
9,
1137,
2649,
8,
885,
9,
490,
3828,
355,
1511,
14,
3191,
8,
498,
29,
2734,
312,
26,
312,
459,
354,
1105,
355,
10189,
14,
740,
3252,
354,
356,
3420,
12,
283,
1419,
356,
1511,
1552,
288,
10189,
14,
3191,
8,
498,
29,
2734,
308,
26,
308,
459,
354,
1105,
288,
666,
459,
888,
418,
275,
10189,
398,
372,
283,
10254,
14,
1360,
297,
666,
12,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
35,
9,
8353,
13,
8664,
25155,
7567,
2290,
199,
3,
1898,
334,
35,
9,
8353,
13,
9397,
1603,
265,
305,
699,
1308,
495,
14614,
77,
665,
74,
265,
305,
32,
5173,
7567,
14,
957,
30,
199,
3,
1898,
334,
35,
9,
8353,
13,
9397,
24747,
14769,
491,
725,
262,
665,
24863,
14769,
32,
5173,
7567,
14,
957,
30,
199,
3,
1898,
334,
35,
9,
11811,
13,
7968,
2799,
322,
2379,
2523,
15757,
90,
665,
4400,
552,
90,
32,
71,
9457,
14,
271,
30,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
961,
2032,
365,
18233,
465,
11736,
315,
314,
570,
9685,
12,
1314,
199,
3,
1265,
1077,
1172,
3086,
465,
1777,
402,
642,
4084,
14,
710,
2895,
199,
3,
787,
2597,
2808,
737,
1455,
921,
23047,
14,
5173,
7567,
14,
1308,
15,
6797,
15,
2437,
67,
3761,
14,
199,
3,
199,
3,
961,
2032,
18581,
402,
5236,
638,
695,
406,
26675,
6326,
701,
5002,
199,
3,
8212,
83,
14,
2104,
314,
5835,
406,
15980,
7994,
12,
1937,
314,
6974,
199,
3,
7994,
436,
9610,
12,
2808,
737,
1455,
921,
23047,
14,
5173,
7567,
14,
1308,
15,
793,
8083,
199,
3,
199,
3,
6529,
26,
1603,
265,
305,
699,
1308,
495,
14614,
77,
665,
74,
265,
305,
32,
5173,
7567,
14,
957,
30,
199,
3,
260,
2799,
322,
2379,
2523,
15757,
90,
665,
4400,
552,
90,
32,
71,
9457,
14,
271,
30,
199,
199,
646,
295,
199,
199,
504,
3805,
19377,
14,
5649,
492,
1947,
199,
199,
504,
1468,
67,
14,
1018,
492,
627,
199,
504,
1468,
67,
14,
3422,
492,
664,
63,
2718,
63,
815,
199,
504,
1468,
67,
14,
8220,
492,
473,
7980,
2017,
269,
199,
504,
1468,
67,
14,
1974,
14,
6893,
492,
485,
199,
504,
1468,
67,
14,
2520,
492,
473,
11149,
199,
504,
1468,
67,
14,
2520,
14,
9887,
492,
1621,
7194,
5360,
714,
1925,
4139,
421,
199,
533,
25225,
2377,
8,
7004,
304,
272,
408,
2,
18816,
377,
6457,
2,
2034,
5022,
12,
21207,
1015,
2556,
687,
272,
10919,
13,
7522,
6117,
12,
465,
5521,
465,
2897,
2556,
1041,
339,
1415,
275,
715,
339,
9031,
8,
568,
7194,
5360,
714,
1925,
4139,
12,
473,
7980,
2017,
269,
12,
473,
11149,
9,
339,
327,
1621,
7194,
5360,
714,
1925,
4139,
3102,
339,
347,
664,
63,
2682,
63,
24148,
63,
1053,
8,
277,
12,
2648,
304,
267,
372,
283,
10254,
7,
339,
347,
664,
63,
24148,
63,
1744,
8,
277,
12,
2648,
304,
267,
1995,
661,
10207,
290,
1214,
297,
283,
10254,
297,
2049,
1947,
14,
65,
6723,
18816,
377,
6457,
659,
4369,
29,
2103,
14,
6399,
14,
10254,
4059,
339,
327,
473,
7980,
2017,
269,
3102,
339,
347,
664,
63,
5693,
63,
3723,
8,
277,
304,
267,
372,
788,
5569,
63,
12058,
418,
339,
327,
473,
11149,
3102,
339,
347,
1336,
63,
1069,
8,
277,
12,
2648,
304,
267,
372,
295,
14,
1431,
8,
82,
9807,
10254,
5169,
63,
23047,
5547,
5169,
15,
6977,
5547,
4268,
2648,
14,
515,
63,
815,
9,
339,
347,
2112,
63,
1069,
8,
277,
12,
2648,
304,
267,
666,
275,
791,
2253,
815,
356,
488,
12,
283,
5265,
356,
488,
12,
283,
888,
356,
488,
93,
398,
340,
283,
5569,
63,
12058,
7,
315,
2648,
14,
8220,
360,
888,
297,
283,
2253,
815,
735,
288,
327,
19649,
2656,
2556,
288,
666,
459,
2253,
815,
418,
275,
291,
14,
1813,
14,
362,
63,
2253,
815,
342,
398,
340,
283,
5569,
63,
12058,
7,
315,
2648,
14,
8220,
360,
888,
297,
283,
5265,
735,
288,
327,
19649,
3589,
2556,
288,
666,
459,
5265,
418,
275,
664,
63,
2718,
63,
815,
8,
277,
14,
1813,
9,
398,
340,
283,
5569,
63,
12058,
7,
315,
2648,
14,
8220,
360,
888,
297,
283,
2730,
735,
288,
327,
19649,
1101,
2556,
288,
4243,
275,
291,
14,
888,
14,
4322,
8,
277,
14,
863,
7755,
9,
288,
10189,
275,
942,
288,
367,
3420,
315,
291,
14,
888,
14,
7786,
8,
277,
14,
863,
7755,
304,
355,
1511,
275,
942,
355,
849,
63,
1419,
275,
4243,
14,
362,
8,
2792,
12,
5009,
355,
367,
536,
12,
574,
315,
291,
14,
888,
14,
1419,
8,
2792,
12,
291,
14,
863,
7755,
304,
490,
849,
275,
849,
63,
1419,
14,
362,
8,
354,
9,
503,
2125,
490,
1511,
14,
740,
2561,
717,
283,
354,
356,
536,
12,
283,
585,
356,
574,
12,
717,
283,
5540,
356,
2649,
8,
585,
9,
1137,
2649,
8,
885,
9,
490,
3828,
355,
1511,
14,
3191,
8,
498,
29,
2734,
312,
26,
312,
459,
354,
1105,
355,
10189,
14,
740,
3252,
354,
356,
3420,
12,
283,
1419,
356,
1511,
1552,
288,
10189,
14,
3191,
8,
498,
29,
2734,
308,
26,
308,
459,
354,
1105,
288,
666,
459,
888,
418,
275,
10189,
398,
372,
283,
10254,
14,
1360,
297,
666,
12,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
yonglehou/spiderfoot
|
ext/dns/rdataset.py
|
91
|
11548
|
# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
# provided that the above copyright notice and this permission notice
# appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""DNS rdatasets (an rdataset is a set of rdatas of a given type and class)"""
import random
import StringIO
import struct
import dns.exception
import dns.rdatatype
import dns.rdataclass
import dns.rdata
import dns.set
# define SimpleSet here for backwards compatibility
SimpleSet = dns.set.Set
class DifferingCovers(dns.exception.DNSException):
"""Raised if an attempt is made to add a SIG/RRSIG whose covered type
is not the same as that of the other rdatas in the rdataset."""
pass
class IncompatibleTypes(dns.exception.DNSException):
"""Raised if an attempt is made to add rdata of an incompatible type."""
pass
class Rdataset(dns.set.Set):
"""A DNS rdataset.
@ivar rdclass: The class of the rdataset
@type rdclass: int
@ivar rdtype: The type of the rdataset
@type rdtype: int
@ivar covers: The covered type. Usually this value is
dns.rdatatype.NONE, but if the rdtype is dns.rdatatype.SIG or
dns.rdatatype.RRSIG, then the covers value will be the rdata
type the SIG/RRSIG covers. The library treats the SIG and RRSIG
types as if they were a family of
types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA). This makes RRSIGs much
easier to work with than if RRSIGs covering different rdata
types were aggregated into a single RRSIG rdataset.
@type covers: int
@ivar ttl: The DNS TTL (Time To Live) value
@type ttl: int
"""
__slots__ = ['rdclass', 'rdtype', 'covers', 'ttl']
def __init__(self, rdclass, rdtype, covers=dns.rdatatype.NONE):
"""Create a new rdataset of the specified class and type.
@see: the description of the class instance variables for the
meaning of I{rdclass} and I{rdtype}"""
super(Rdataset, self).__init__()
self.rdclass = rdclass
self.rdtype = rdtype
self.covers = covers
self.ttl = 0
def _clone(self):
obj = super(Rdataset, self)._clone()
obj.rdclass = self.rdclass
obj.rdtype = self.rdtype
obj.covers = self.covers
obj.ttl = self.ttl
return obj
def update_ttl(self, ttl):
"""Set the TTL of the rdataset to be the lesser of the set's current
TTL or the specified TTL. If the set contains no rdatas, set the TTL
to the specified TTL.
@param ttl: The TTL
@type ttl: int"""
if len(self) == 0:
self.ttl = ttl
elif ttl < self.ttl:
self.ttl = ttl
def add(self, rd, ttl=None):
"""Add the specified rdata to the rdataset.
If the optional I{ttl} parameter is supplied, then
self.update_ttl(ttl) will be called prior to adding the rdata.
@param rd: The rdata
@type rd: dns.rdata.Rdata object
@param ttl: The TTL
@type ttl: int"""
#
# If we're adding a signature, do some special handling to
# check that the signature covers the same type as the
# other rdatas in this rdataset. If this is the first rdata
# in the set, initialize the covers field.
#
if self.rdclass != rd.rdclass or self.rdtype != rd.rdtype:
raise IncompatibleTypes
if not ttl is None:
self.update_ttl(ttl)
if self.rdtype == dns.rdatatype.RRSIG or \
self.rdtype == dns.rdatatype.SIG:
covers = rd.covers()
if len(self) == 0 and self.covers == dns.rdatatype.NONE:
self.covers = covers
elif self.covers != covers:
raise DifferingCovers
if dns.rdatatype.is_singleton(rd.rdtype) and len(self) > 0:
self.clear()
super(Rdataset, self).add(rd)
def union_update(self, other):
self.update_ttl(other.ttl)
super(Rdataset, self).union_update(other)
def intersection_update(self, other):
self.update_ttl(other.ttl)
super(Rdataset, self).intersection_update(other)
def update(self, other):
"""Add all rdatas in other to self.
@param other: The rdataset from which to update
@type other: dns.rdataset.Rdataset object"""
self.update_ttl(other.ttl)
super(Rdataset, self).update(other)
def __repr__(self):
if self.covers == 0:
ctext = ''
else:
ctext = '(' + dns.rdatatype.to_text(self.covers) + ')'
return '<DNS ' + dns.rdataclass.to_text(self.rdclass) + ' ' + \
dns.rdatatype.to_text(self.rdtype) + ctext + ' rdataset>'
def __str__(self):
return self.to_text()
def __eq__(self, other):
"""Two rdatasets are equal if they have the same class, type, and
covers, and contain the same rdata.
@rtype: bool"""
if not isinstance(other, Rdataset):
return False
if self.rdclass != other.rdclass or \
self.rdtype != other.rdtype or \
self.covers != other.covers:
return False
return super(Rdataset, self).__eq__(other)
def __ne__(self, other):
return not self.__eq__(other)
def to_text(self, name=None, origin=None, relativize=True,
override_rdclass=None, **kw):
"""Convert the rdataset into DNS master file format.
@see: L{dns.name.Name.choose_relativity} for more information
on how I{origin} and I{relativize} determine the way names
are emitted.
Any additional keyword arguments are passed on to the rdata
to_text() method.
@param name: If name is not None, emit a RRs with I{name} as
the owner name.
@type name: dns.name.Name object
@param origin: The origin for relative names, or None.
@type origin: dns.name.Name object
@param relativize: True if names should names be relativized
@type relativize: bool"""
if not name is None:
name = name.choose_relativity(origin, relativize)
ntext = str(name)
pad = ' '
else:
ntext = ''
pad = ''
s = StringIO.StringIO()
if not override_rdclass is None:
rdclass = override_rdclass
else:
rdclass = self.rdclass
if len(self) == 0:
#
# Empty rdatasets are used for the question section, and in
# some dynamic updates, so we don't need to print out the TTL
# (which is meaningless anyway).
#
print >> s, '%s%s%s %s' % (ntext, pad,
dns.rdataclass.to_text(rdclass),
dns.rdatatype.to_text(self.rdtype))
else:
for rd in self:
print >> s, '%s%s%d %s %s %s' % \
(ntext, pad, self.ttl, dns.rdataclass.to_text(rdclass),
dns.rdatatype.to_text(self.rdtype),
rd.to_text(origin=origin, relativize=relativize, **kw))
#
# We strip off the final \n for the caller's convenience in printing
#
return s.getvalue()[:-1]
def to_wire(self, name, file, compress=None, origin=None,
override_rdclass=None, want_shuffle=True):
"""Convert the rdataset to wire format.
@param name: The owner name of the RRset that will be emitted
@type name: dns.name.Name object
@param file: The file to which the wire format data will be appended
@type file: file
@param compress: The compression table to use; the default is None.
@type compress: dict
@param origin: The origin to be appended to any relative names when
they are emitted. The default is None.
@returns: the number of records emitted
@rtype: int
"""
if not override_rdclass is None:
rdclass = override_rdclass
want_shuffle = False
else:
rdclass = self.rdclass
file.seek(0, 2)
if len(self) == 0:
name.to_wire(file, compress, origin)
stuff = struct.pack("!HHIH", self.rdtype, rdclass, 0, 0)
file.write(stuff)
return 1
else:
if want_shuffle:
l = list(self)
random.shuffle(l)
else:
l = self
for rd in l:
name.to_wire(file, compress, origin)
stuff = struct.pack("!HHIH", self.rdtype, rdclass,
self.ttl, 0)
file.write(stuff)
start = file.tell()
rd.to_wire(file, compress, origin)
end = file.tell()
assert end - start < 65536
file.seek(start - 2)
stuff = struct.pack("!H", end - start)
file.write(stuff)
file.seek(0, 2)
return len(self)
def match(self, rdclass, rdtype, covers):
"""Returns True if this rdataset matches the specified class, type,
and covers"""
if self.rdclass == rdclass and \
self.rdtype == rdtype and \
self.covers == covers:
return True
return False
def from_text_list(rdclass, rdtype, ttl, text_rdatas):
"""Create an rdataset with the specified class, type, and TTL, and with
the specified list of rdatas in text format.
@rtype: dns.rdataset.Rdataset object
"""
if isinstance(rdclass, (str, unicode)):
rdclass = dns.rdataclass.from_text(rdclass)
if isinstance(rdtype, (str, unicode)):
rdtype = dns.rdatatype.from_text(rdtype)
r = Rdataset(rdclass, rdtype)
r.update_ttl(ttl)
for t in text_rdatas:
rd = dns.rdata.from_text(r.rdclass, r.rdtype, t)
r.add(rd)
return r
def from_text(rdclass, rdtype, ttl, *text_rdatas):
"""Create an rdataset with the specified class, type, and TTL, and with
the specified rdatas in text format.
@rtype: dns.rdataset.Rdataset object
"""
return from_text_list(rdclass, rdtype, ttl, text_rdatas)
def from_rdata_list(ttl, rdatas):
"""Create an rdataset with the specified TTL, and with
the specified list of rdata objects.
@rtype: dns.rdataset.Rdataset object
"""
if len(rdatas) == 0:
raise ValueError("rdata list must not be empty")
r = None
for rd in rdatas:
if r is None:
r = Rdataset(rd.rdclass, rd.rdtype)
r.update_ttl(ttl)
first_time = False
r.add(rd)
return r
def from_rdata(ttl, *rdatas):
"""Create an rdataset with the specified TTL, and with
the specified rdata objects.
@rtype: dns.rdataset.Rdataset object
"""
return from_rdata_list(ttl, rdatas)
|
gpl-2.0
|
[
3,
1898,
334,
35,
9,
12521,
13,
9488,
12,
8937,
13,
8128,
653,
676,
262,
453,
12,
3277,
14,
199,
3,
199,
3,
8779,
370,
675,
12,
1331,
12,
2811,
12,
436,
11207,
642,
2032,
436,
2399,
199,
3,
3794,
367,
1263,
12016,
543,
503,
1928,
14751,
365,
11882,
10009,
12,
199,
3,
2741,
626,
314,
3432,
4248,
4245,
436,
642,
4983,
4245,
199,
3,
7468,
315,
1006,
6866,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
2,
2401,
4825,
4896,
2639,
8990,
51,
11727,
2990,
199,
3,
1663,
14142,
7816,
2296,
5749,
4141,
6931,
11727,
5292,
2990,
1634,
199,
3,
3169,
2401,
3092,
14,
1621,
4825,
6461,
7000,
4825,
4896,
2639,
6262,
7024,
2381,
199,
3,
1821,
8820,
12,
8703,
12,
9168,
12,
1549,
9110,
6736,
1549,
1821,
6736,
199,
3,
28752,
4118,
27362,
20668,
1206,
4442,
9102,
1634,
4815,
12,
7126,
1549,
9206,
12,
7061,
1621,
1261,
199,
3,
9612,
1634,
7066,
12,
9254,
1549,
5010,
7056,
25657,
9612,
12,
7043,
5738,
199,
3,
1634,
1549,
1621,
11287,
1663,
2334,
4815,
1549,
13873,
30340,
1634,
5749,
4141,
14,
199,
199,
624,
12323,
519,
12281,
334,
290,
519,
5214,
365,
282,
663,
402,
519,
11563,
402,
282,
1627,
730,
436,
1021,
9471,
199,
199,
646,
2196,
199,
646,
5228,
199,
646,
2702,
199,
199,
646,
6715,
14,
1971,
199,
646,
6715,
14,
82,
14184,
199,
646,
6715,
14,
23203,
533,
199,
646,
6715,
14,
23203,
199,
646,
6715,
14,
409,
199,
199,
3,
5627,
5870,
1084,
2348,
367,
8552,
7163,
199,
3184,
1084,
275,
6715,
14,
409,
14,
1084,
199,
199,
533,
3757,
1260,
316,
967,
14895,
8,
5797,
14,
1971,
14,
10872,
21686,
304,
272,
408,
16894,
340,
376,
7427,
365,
6326,
370,
1050,
282,
15522,
15,
13381,
7864,
7447,
24295,
730,
272,
365,
440,
314,
2011,
465,
626,
402,
314,
1163,
519,
11563,
315,
314,
519,
5214,
1041,
272,
986,
199,
199,
533,
1010,
6490,
4100,
8,
5797,
14,
1971,
14,
10872,
21686,
304,
272,
408,
16894,
340,
376,
7427,
365,
6326,
370,
1050,
27020,
402,
376,
18457,
730,
1041,
272,
986,
199,
199,
533,
820,
5214,
8,
5797,
14,
409,
14,
1084,
304,
272,
408,
33,
10237,
519,
5214,
14,
339,
768,
7725,
29320,
26,
710,
1021,
402,
314,
519,
5214,
272,
768,
466,
29320,
26,
1109,
272,
768,
7725,
22764,
26,
710,
730,
402,
314,
519,
5214,
272,
768,
466,
22764,
26,
1109,
272,
768,
7725,
25858,
26,
710,
24295,
730,
14,
221,
24612,
642,
574,
365,
272,
6715,
14,
82,
14184,
14,
9185,
12,
1325,
340,
314,
22764,
365,
6715,
14,
82,
14184,
14,
7864,
503,
272,
6715,
14,
82,
14184,
14,
13381,
7864,
12,
2066,
314,
25858,
574,
911,
506,
314,
27020,
272,
730,
314,
15522,
15,
13381,
7864,
25858,
14,
221,
710,
3555,
20991,
1956,
314,
15522,
436,
27222,
7864,
272,
2943,
465,
340,
2985,
4898,
282,
9614,
402,
272,
2943,
12,
325,
14,
71,
14,
27222,
7864,
8,
33,
395,
27222,
7864,
8,
2709,
395,
27222,
7864,
8,
4118,
33,
680,
221,
961,
7704,
27222,
7864,
83,
8298,
272,
14905,
370,
1736,
543,
2419,
340,
27222,
7864,
83,
8486,
316,
3365,
27020,
272,
2943,
4898,
26913,
1901,
282,
2849,
27222,
7864,
519,
5214,
14,
272,
768,
466,
25858,
26,
1109,
272,
768,
7725,
14856,
26,
710,
10237,
30822,
334,
1366,
4005,
24683,
9,
574,
272,
768,
466,
14856,
26,
1109,
272,
408,
339,
636,
7257,
363,
275,
788,
30186,
297,
283,
82,
2271,
297,
283,
5899,
83,
297,
283,
12130,
418,
339,
347,
636,
826,
721,
277,
12,
29320,
12,
22764,
12,
25858,
29,
5797,
14,
82,
14184,
14,
9185,
304,
267,
408,
2499,
282,
892,
519,
5214,
402,
314,
2013,
1021,
436,
730,
14,
398,
768,
3239,
26,
314,
1369,
402,
314,
1021,
1256,
2860,
367,
314,
267,
11150,
402,
473,
91,
30186,
93,
436,
473,
91,
82,
2271,
30437,
398,
1613,
8,
50,
5214,
12,
291,
2843,
826,
4533,
267,
291,
14,
30186,
275,
29320,
267,
291,
14,
82,
2271,
275,
22764,
267,
291,
14,
5899,
83,
275,
25858,
267,
291,
14,
12130,
275,
378,
339,
347,
485,
6311,
8,
277,
304,
267,
1559,
275,
1613,
8,
50,
5214,
12,
291,
10445,
6311,
342,
267,
1559,
14,
30186,
275,
291,
14,
30186,
267,
1559,
14,
82,
2271,
275,
291,
14,
82,
2271,
267,
1559,
14,
5899,
83,
275,
291,
14,
5899,
83,
267,
1559,
14,
12130,
275,
291,
14,
12130,
267,
372,
1559,
339,
347,
1678,
63,
12130,
8,
277,
12,
14856,
304,
267,
408,
1084,
314,
30822,
402,
314,
519,
5214,
370,
506,
314,
23487,
332,
402,
314,
663,
1159,
1453,
267,
30822,
503,
314,
2013,
30822,
14,
221,
982,
314,
663,
3509,
949,
519,
11563,
12,
663,
314,
30822,
267,
370,
314,
2013,
30822,
14,
267,
768,
635,
14856,
26,
710,
30822,
267,
768,
466,
14856,
26,
1109,
624,
398,
340,
822,
8,
277,
9,
508,
378,
26,
288,
291,
14,
12130,
275,
14856,
267,
916,
14856,
665,
291,
14,
12130,
26,
288,
291,
14,
12130,
275,
14856,
339,
347,
1050,
8,
277,
12,
11517,
12,
14856,
29,
403,
304,
267,
408,
1123,
314,
2013,
27020,
370,
314,
519,
5214,
14,
398,
982,
314,
2716,
473,
91,
12130,
93,
2725,
365,
6841,
12,
2066,
267,
291,
14,
873,
63,
12130,
8,
12130,
9,
911,
506,
2797,
6791,
370,
7791,
314,
27020,
14,
398,
768,
635,
11517,
26,
710,
27020,
267,
768,
466,
11517,
26,
6715,
14,
23203,
14,
50,
576,
909,
267,
768,
635,
14856,
26,
710,
30822,
267,
768,
466,
14856,
26,
1109,
624,
398,
327,
267,
327,
982,
781,
3984,
7791,
282,
4955,
12,
886,
2005,
4539,
7252,
370,
267,
327,
1104,
626,
314,
4955,
25858,
314,
2011,
730,
465,
314,
267,
327,
1163,
519,
11563,
315,
642,
519,
5214,
14,
221,
982,
642,
365,
314,
1642,
27020,
267,
327,
315,
314,
663,
12,
8265,
314,
25858,
901,
14,
267,
327,
267,
340,
291,
14,
30186,
1137,
11517,
14,
30186,
503,
291,
14,
82,
2271,
1137,
11517,
14,
82,
2271,
26,
288,
746,
1010,
6490,
4100,
267,
340,
440,
14856,
365,
488,
26,
288,
291,
14,
873,
63,
12130,
8,
12130,
9,
267,
340,
291
] |
[
1898,
334,
35,
9,
12521,
13,
9488,
12,
8937,
13,
8128,
653,
676,
262,
453,
12,
3277,
14,
199,
3,
199,
3,
8779,
370,
675,
12,
1331,
12,
2811,
12,
436,
11207,
642,
2032,
436,
2399,
199,
3,
3794,
367,
1263,
12016,
543,
503,
1928,
14751,
365,
11882,
10009,
12,
199,
3,
2741,
626,
314,
3432,
4248,
4245,
436,
642,
4983,
4245,
199,
3,
7468,
315,
1006,
6866,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
2,
2401,
4825,
4896,
2639,
8990,
51,
11727,
2990,
199,
3,
1663,
14142,
7816,
2296,
5749,
4141,
6931,
11727,
5292,
2990,
1634,
199,
3,
3169,
2401,
3092,
14,
1621,
4825,
6461,
7000,
4825,
4896,
2639,
6262,
7024,
2381,
199,
3,
1821,
8820,
12,
8703,
12,
9168,
12,
1549,
9110,
6736,
1549,
1821,
6736,
199,
3,
28752,
4118,
27362,
20668,
1206,
4442,
9102,
1634,
4815,
12,
7126,
1549,
9206,
12,
7061,
1621,
1261,
199,
3,
9612,
1634,
7066,
12,
9254,
1549,
5010,
7056,
25657,
9612,
12,
7043,
5738,
199,
3,
1634,
1549,
1621,
11287,
1663,
2334,
4815,
1549,
13873,
30340,
1634,
5749,
4141,
14,
199,
199,
624,
12323,
519,
12281,
334,
290,
519,
5214,
365,
282,
663,
402,
519,
11563,
402,
282,
1627,
730,
436,
1021,
9471,
199,
199,
646,
2196,
199,
646,
5228,
199,
646,
2702,
199,
199,
646,
6715,
14,
1971,
199,
646,
6715,
14,
82,
14184,
199,
646,
6715,
14,
23203,
533,
199,
646,
6715,
14,
23203,
199,
646,
6715,
14,
409,
199,
199,
3,
5627,
5870,
1084,
2348,
367,
8552,
7163,
199,
3184,
1084,
275,
6715,
14,
409,
14,
1084,
199,
199,
533,
3757,
1260,
316,
967,
14895,
8,
5797,
14,
1971,
14,
10872,
21686,
304,
272,
408,
16894,
340,
376,
7427,
365,
6326,
370,
1050,
282,
15522,
15,
13381,
7864,
7447,
24295,
730,
272,
365,
440,
314,
2011,
465,
626,
402,
314,
1163,
519,
11563,
315,
314,
519,
5214,
1041,
272,
986,
199,
199,
533,
1010,
6490,
4100,
8,
5797,
14,
1971,
14,
10872,
21686,
304,
272,
408,
16894,
340,
376,
7427,
365,
6326,
370,
1050,
27020,
402,
376,
18457,
730,
1041,
272,
986,
199,
199,
533,
820,
5214,
8,
5797,
14,
409,
14,
1084,
304,
272,
408,
33,
10237,
519,
5214,
14,
339,
768,
7725,
29320,
26,
710,
1021,
402,
314,
519,
5214,
272,
768,
466,
29320,
26,
1109,
272,
768,
7725,
22764,
26,
710,
730,
402,
314,
519,
5214,
272,
768,
466,
22764,
26,
1109,
272,
768,
7725,
25858,
26,
710,
24295,
730,
14,
221,
24612,
642,
574,
365,
272,
6715,
14,
82,
14184,
14,
9185,
12,
1325,
340,
314,
22764,
365,
6715,
14,
82,
14184,
14,
7864,
503,
272,
6715,
14,
82,
14184,
14,
13381,
7864,
12,
2066,
314,
25858,
574,
911,
506,
314,
27020,
272,
730,
314,
15522,
15,
13381,
7864,
25858,
14,
221,
710,
3555,
20991,
1956,
314,
15522,
436,
27222,
7864,
272,
2943,
465,
340,
2985,
4898,
282,
9614,
402,
272,
2943,
12,
325,
14,
71,
14,
27222,
7864,
8,
33,
395,
27222,
7864,
8,
2709,
395,
27222,
7864,
8,
4118,
33,
680,
221,
961,
7704,
27222,
7864,
83,
8298,
272,
14905,
370,
1736,
543,
2419,
340,
27222,
7864,
83,
8486,
316,
3365,
27020,
272,
2943,
4898,
26913,
1901,
282,
2849,
27222,
7864,
519,
5214,
14,
272,
768,
466,
25858,
26,
1109,
272,
768,
7725,
14856,
26,
710,
10237,
30822,
334,
1366,
4005,
24683,
9,
574,
272,
768,
466,
14856,
26,
1109,
272,
408,
339,
636,
7257,
363,
275,
788,
30186,
297,
283,
82,
2271,
297,
283,
5899,
83,
297,
283,
12130,
418,
339,
347,
636,
826,
721,
277,
12,
29320,
12,
22764,
12,
25858,
29,
5797,
14,
82,
14184,
14,
9185,
304,
267,
408,
2499,
282,
892,
519,
5214,
402,
314,
2013,
1021,
436,
730,
14,
398,
768,
3239,
26,
314,
1369,
402,
314,
1021,
1256,
2860,
367,
314,
267,
11150,
402,
473,
91,
30186,
93,
436,
473,
91,
82,
2271,
30437,
398,
1613,
8,
50,
5214,
12,
291,
2843,
826,
4533,
267,
291,
14,
30186,
275,
29320,
267,
291,
14,
82,
2271,
275,
22764,
267,
291,
14,
5899,
83,
275,
25858,
267,
291,
14,
12130,
275,
378,
339,
347,
485,
6311,
8,
277,
304,
267,
1559,
275,
1613,
8,
50,
5214,
12,
291,
10445,
6311,
342,
267,
1559,
14,
30186,
275,
291,
14,
30186,
267,
1559,
14,
82,
2271,
275,
291,
14,
82,
2271,
267,
1559,
14,
5899,
83,
275,
291,
14,
5899,
83,
267,
1559,
14,
12130,
275,
291,
14,
12130,
267,
372,
1559,
339,
347,
1678,
63,
12130,
8,
277,
12,
14856,
304,
267,
408,
1084,
314,
30822,
402,
314,
519,
5214,
370,
506,
314,
23487,
332,
402,
314,
663,
1159,
1453,
267,
30822,
503,
314,
2013,
30822,
14,
221,
982,
314,
663,
3509,
949,
519,
11563,
12,
663,
314,
30822,
267,
370,
314,
2013,
30822,
14,
267,
768,
635,
14856,
26,
710,
30822,
267,
768,
466,
14856,
26,
1109,
624,
398,
340,
822,
8,
277,
9,
508,
378,
26,
288,
291,
14,
12130,
275,
14856,
267,
916,
14856,
665,
291,
14,
12130,
26,
288,
291,
14,
12130,
275,
14856,
339,
347,
1050,
8,
277,
12,
11517,
12,
14856,
29,
403,
304,
267,
408,
1123,
314,
2013,
27020,
370,
314,
519,
5214,
14,
398,
982,
314,
2716,
473,
91,
12130,
93,
2725,
365,
6841,
12,
2066,
267,
291,
14,
873,
63,
12130,
8,
12130,
9,
911,
506,
2797,
6791,
370,
7791,
314,
27020,
14,
398,
768,
635,
11517,
26,
710,
27020,
267,
768,
466,
11517,
26,
6715,
14,
23203,
14,
50,
576,
909,
267,
768,
635,
14856,
26,
710,
30822,
267,
768,
466,
14856,
26,
1109,
624,
398,
327,
267,
327,
982,
781,
3984,
7791,
282,
4955,
12,
886,
2005,
4539,
7252,
370,
267,
327,
1104,
626,
314,
4955,
25858,
314,
2011,
730,
465,
314,
267,
327,
1163,
519,
11563,
315,
642,
519,
5214,
14,
221,
982,
642,
365,
314,
1642,
27020,
267,
327,
315,
314,
663,
12,
8265,
314,
25858,
901,
14,
267,
327,
267,
340,
291,
14,
30186,
1137,
11517,
14,
30186,
503,
291,
14,
82,
2271,
1137,
11517,
14,
82,
2271,
26,
288,
746,
1010,
6490,
4100,
267,
340,
440,
14856,
365,
488,
26,
288,
291,
14,
873,
63,
12130,
8,
12130,
9,
267,
340,
291,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
Mirantis/disk_perf_test_tool
|
wally/test_run_class.py
|
1
|
1980
|
from typing import List, Callable, Any, Dict, Optional, Set
from concurrent.futures import ThreadPoolExecutor
from cephlib.istorage import IStorage
from cephlib.node import NodeInfo, IRPCNode
from cephlib.ssh import ConnCreds
from cephlib.storage_selectors import DevRolesConfig
from .openstack_api import OSCreds, OSConnection
from .config import Config
from .result_classes import IWallyStorage
class TestRun:
"""Test run information"""
def __init__(self, config: Config, storage: IStorage, rstorage: IWallyStorage) -> None:
# NodesInfo list
self.nodes_info: Dict[str, NodeInfo] = {}
self.ceph_master_node: Optional[IRPCNode] = None
self.ceph_extra_args: Optional[str] = None
# Nodes list
self.nodes: List[IRPCNode] = []
self.build_meta: Dict[str,Any] = {}
self.clear_calls_stack: List[Callable[['TestRun'], None]] = []
# openstack credentials
self.os_creds: Optional[OSCreds] = None # type: ignore
self.os_connection: Optional[OSConnection] = None # type: ignore
self.rpc_code: bytes = None # type: ignore
self.default_rpc_plugins: Dict[str, bytes] = None # type: ignore
self.storage = storage
self.rstorage = rstorage
self.config = config
self.sensors_run_on: Set[str] = set()
self.os_spawned_nodes_ids: List[int] = None # type: ignore
self.devs_locator: DevRolesConfig = []
def get_pool(self):
return ThreadPoolExecutor(self.config.get('worker_pool_sz', 32))
def merge_node(self, creds: ConnCreds, roles: Set[str], **params) -> NodeInfo:
info = NodeInfo(creds, roles, params)
nid = info.node_id
if nid in self.nodes_info:
self.nodes_info[nid].roles.update(info.roles)
self.nodes_info[nid].params.update(info.params)
return self.nodes_info[nid]
else:
self.nodes_info[nid] = info
return info
|
apache-2.0
|
[
504,
14090,
492,
3820,
12,
16975,
12,
6184,
12,
7448,
12,
4879,
12,
2494,
199,
504,
23002,
14,
25513,
492,
11086,
5453,
16752,
199,
199,
504,
27316,
773,
14,
631,
2128,
492,
473,
6408,
199,
504,
27316,
773,
14,
932,
492,
5013,
2354,
12,
473,
8171,
1716,
199,
504,
27316,
773,
14,
5510,
492,
13482,
35,
10428,
199,
504,
27316,
773,
14,
3494,
63,
6662,
83,
492,
29314,
3863,
2978,
2028,
199,
199,
504,
1275,
8512,
63,
1246,
492,
4403,
35,
10428,
12,
4403,
3225,
199,
504,
1275,
888,
492,
4094,
199,
504,
1275,
1099,
63,
2888,
492,
473,
55,
1183,
6408,
421,
199,
533,
1379,
2540,
26,
272,
408,
774,
1255,
2556,
624,
272,
347,
636,
826,
721,
277,
12,
1101,
26,
4094,
12,
4887,
26,
473,
6408,
12,
519,
3494,
26,
473,
55,
1183,
6408,
9,
1035,
488,
26,
267,
327,
23836,
2354,
769,
267,
291,
14,
2415,
63,
815,
26,
7448,
59,
495,
12,
5013,
2354,
61,
275,
1052,
398,
291,
14,
20266,
63,
4133,
63,
932,
26,
4879,
59,
3927,
4222,
1716,
61,
275,
488,
267,
291,
14,
20266,
63,
2911,
63,
589,
26,
4879,
59,
495,
61,
275,
488,
398,
327,
23836,
769,
267,
291,
14,
2415,
26,
3820,
59,
3927,
4222,
1716,
61,
275,
942,
398,
291,
14,
1506,
63,
2024,
26,
7448,
59,
495,
12,
9874,
61,
275,
1052,
267,
291,
14,
3584,
63,
5352,
63,
2340,
26,
3820,
59,
16410,
59,
459,
21228,
995,
488,
2677,
275,
942,
398,
327,
13869,
6235,
267,
291,
14,
736,
63,
15226,
26,
4879,
59,
31799,
10428,
61,
275,
488,
221,
327,
730,
26,
3686,
267,
291,
14,
736,
63,
2105,
26,
4879,
59,
3100,
3225,
61,
275,
488,
221,
327,
730,
26,
3686,
267,
291,
14,
4354,
63,
600,
26,
2783,
275,
488,
221,
327,
730,
26,
3686,
267,
291,
14,
885,
63,
4354,
63,
5265,
26,
7448,
59,
495,
12,
2783,
61,
275,
488,
221,
327,
730,
26,
3686,
398,
291,
14,
3494,
275,
4887,
267,
291,
14,
82,
3494,
275,
519,
3494,
267,
291,
14,
888,
275,
1101,
267,
291,
14,
22675,
63,
1065,
63,
265,
26,
2494,
59,
495,
61,
275,
663,
342,
267,
291,
14,
736,
63,
10212,
379,
63,
2415,
63,
1580,
26,
3820,
59,
442,
61,
275,
488,
221,
327,
730,
26,
3686,
267,
291,
14,
18804,
63,
6354,
26,
29314,
3863,
2978,
2028,
275,
942,
339,
347,
664,
63,
2293,
8,
277,
304,
267,
372,
11086,
5453,
16752,
8,
277,
14,
888,
14,
362,
360,
6599,
63,
2293,
63,
11803,
297,
4337,
430,
339,
347,
5389,
63,
932,
8,
277,
12,
20023,
26,
13482,
35,
10428,
12,
11689,
26,
2494,
59,
495,
467,
1011,
1162,
9,
1035,
5013,
2354,
26,
267,
2256,
275,
5013,
2354,
8,
15226,
12,
11689,
12,
1862,
9,
267,
302,
344,
275,
2256,
14,
932,
63,
344,
398,
340,
302,
344,
315,
291,
14,
2415,
63,
815,
26,
288,
291,
14,
2415,
63,
815,
59,
30411,
1055,
8050,
14,
873,
8,
815,
14,
8050,
9,
288,
291,
14,
2415,
63,
815,
59,
30411,
1055,
1162,
14,
873,
8,
815,
14,
1162,
9,
288,
372,
291,
14,
2415,
63,
815,
59,
30411,
61,
267,
587,
26,
288,
291,
14,
2415,
63,
815,
59,
30411,
61,
275,
2256,
288,
372,
2256,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
14090,
492,
3820,
12,
16975,
12,
6184,
12,
7448,
12,
4879,
12,
2494,
199,
504,
23002,
14,
25513,
492,
11086,
5453,
16752,
199,
199,
504,
27316,
773,
14,
631,
2128,
492,
473,
6408,
199,
504,
27316,
773,
14,
932,
492,
5013,
2354,
12,
473,
8171,
1716,
199,
504,
27316,
773,
14,
5510,
492,
13482,
35,
10428,
199,
504,
27316,
773,
14,
3494,
63,
6662,
83,
492,
29314,
3863,
2978,
2028,
199,
199,
504,
1275,
8512,
63,
1246,
492,
4403,
35,
10428,
12,
4403,
3225,
199,
504,
1275,
888,
492,
4094,
199,
504,
1275,
1099,
63,
2888,
492,
473,
55,
1183,
6408,
421,
199,
533,
1379,
2540,
26,
272,
408,
774,
1255,
2556,
624,
272,
347,
636,
826,
721,
277,
12,
1101,
26,
4094,
12,
4887,
26,
473,
6408,
12,
519,
3494,
26,
473,
55,
1183,
6408,
9,
1035,
488,
26,
267,
327,
23836,
2354,
769,
267,
291,
14,
2415,
63,
815,
26,
7448,
59,
495,
12,
5013,
2354,
61,
275,
1052,
398,
291,
14,
20266,
63,
4133,
63,
932,
26,
4879,
59,
3927,
4222,
1716,
61,
275,
488,
267,
291,
14,
20266,
63,
2911,
63,
589,
26,
4879,
59,
495,
61,
275,
488,
398,
327,
23836,
769,
267,
291,
14,
2415,
26,
3820,
59,
3927,
4222,
1716,
61,
275,
942,
398,
291,
14,
1506,
63,
2024,
26,
7448,
59,
495,
12,
9874,
61,
275,
1052,
267,
291,
14,
3584,
63,
5352,
63,
2340,
26,
3820,
59,
16410,
59,
459,
21228,
995,
488,
2677,
275,
942,
398,
327,
13869,
6235,
267,
291,
14,
736,
63,
15226,
26,
4879,
59,
31799,
10428,
61,
275,
488,
221,
327,
730,
26,
3686,
267,
291,
14,
736,
63,
2105,
26,
4879,
59,
3100,
3225,
61,
275,
488,
221,
327,
730,
26,
3686,
267,
291,
14,
4354,
63,
600,
26,
2783,
275,
488,
221,
327,
730,
26,
3686,
267,
291,
14,
885,
63,
4354,
63,
5265,
26,
7448,
59,
495,
12,
2783,
61,
275,
488,
221,
327,
730,
26,
3686,
398,
291,
14,
3494,
275,
4887,
267,
291,
14,
82,
3494,
275,
519,
3494,
267,
291,
14,
888,
275,
1101,
267,
291,
14,
22675,
63,
1065,
63,
265,
26,
2494,
59,
495,
61,
275,
663,
342,
267,
291,
14,
736,
63,
10212,
379,
63,
2415,
63,
1580,
26,
3820,
59,
442,
61,
275,
488,
221,
327,
730,
26,
3686,
267,
291,
14,
18804,
63,
6354,
26,
29314,
3863,
2978,
2028,
275,
942,
339,
347,
664,
63,
2293,
8,
277,
304,
267,
372,
11086,
5453,
16752,
8,
277,
14,
888,
14,
362,
360,
6599,
63,
2293,
63,
11803,
297,
4337,
430,
339,
347,
5389,
63,
932,
8,
277,
12,
20023,
26,
13482,
35,
10428,
12,
11689,
26,
2494,
59,
495,
467,
1011,
1162,
9,
1035,
5013,
2354,
26,
267,
2256,
275,
5013,
2354,
8,
15226,
12,
11689,
12,
1862,
9,
267,
302,
344,
275,
2256,
14,
932,
63,
344,
398,
340,
302,
344,
315,
291,
14,
2415,
63,
815,
26,
288,
291,
14,
2415,
63,
815,
59,
30411,
1055,
8050,
14,
873,
8,
815,
14,
8050,
9,
288,
291,
14,
2415,
63,
815,
59,
30411,
1055,
1162,
14,
873,
8,
815,
14,
1162,
9,
288,
372,
291,
14,
2415,
63,
815,
59,
30411,
61,
267,
587,
26,
288,
291,
14,
2415,
63,
815,
59,
30411,
61,
275,
2256,
288,
372,
2256,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jessicalucci/NovaOrc
|
nova/openstack/common/plugin/callbackplugin.py
|
6
|
3401
|
# 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.
from nova.openstack.common import log as logging
from nova.openstack.common.plugin import plugin
LOG = logging.getLogger(__name__)
class _CallbackNotifier(object):
"""Manages plugin-defined notification callbacks.
For each Plugin, a CallbackNotifier will be added to the
notification driver list. Calls to notify() with appropriate
messages will be hooked and prompt callbacks.
A callback should look like this:
def callback(context, message, user_data)
"""
def __init__(self):
self._callback_dict = {}
def _add_callback(self, event_type, callback, user_data):
callback_list = self._callback_dict.get(event_type, [])
callback_list.append({'function': callback,
'user_data': user_data})
self._callback_dict[event_type] = callback_list
def _remove_callback(self, callback):
for callback_list in self._callback_dict.values():
for entry in callback_list:
if entry['function'] == callback:
callback_list.remove(entry)
def notify(self, context, message):
if message.get('event_type') not in self._callback_dict:
return
for entry in self._callback_dict[message.get('event_type')]:
entry['function'](context, message, entry.get('user_data'))
def callbacks(self):
return self._callback_dict
class CallbackPlugin(plugin.Plugin):
""" Plugin with a simple callback interface.
This class is provided as a convenience for producing a simple
plugin that only watches a couple of events. For example, here's
a subclass which prints a line the first time an instance is created.
class HookInstanceCreation(CallbackPlugin):
def __init__(self, _service_name):
super(HookInstanceCreation, self).__init__()
self._add_callback(self.magic, 'compute.instance.create.start')
def magic(self):
print "An instance was created!"
self._remove_callback(self, self.magic)
"""
def __init__(self, service_name):
super(CallbackPlugin, self).__init__(service_name)
self._callback_notifier = _CallbackNotifier()
self._add_notifier(self._callback_notifier)
def _add_callback(self, callback, event_type, user_data=None):
"""Add callback for a given event notification.
Subclasses can call this as an alternative to implementing
a fullblown notify notifier.
"""
self._callback_notifier._add_callback(event_type, callback, user_data)
def _remove_callback(self, callback):
"""Remove all notification callbacks to specified function."""
self._callback_notifier._remove_callback(callback)
|
apache-2.0
|
[
3,
1898,
6029,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
5913,
14,
8512,
14,
2330,
492,
943,
465,
2050,
199,
504,
5913,
14,
8512,
14,
2330,
14,
2718,
492,
3589,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
485,
2806,
26884,
8,
785,
304,
272,
408,
2395,
7441,
3589,
13,
4037,
6955,
13484,
14,
339,
2104,
1924,
11349,
12,
282,
17555,
26884,
911,
506,
3483,
370,
314,
272,
6955,
5253,
769,
14,
221,
28055,
370,
11705,
342,
543,
5827,
272,
3788,
911,
506,
5759,
379,
436,
8457,
13484,
14,
339,
437,
3233,
1077,
3648,
2839,
642,
26,
489,
347,
3233,
8,
1100,
12,
1245,
12,
922,
63,
576,
9,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
3058,
63,
807,
275,
1052,
339,
347,
485,
525,
63,
3058,
8,
277,
12,
1566,
63,
466,
12,
3233,
12,
922,
63,
576,
304,
267,
3233,
63,
513,
275,
291,
423,
3058,
63,
807,
14,
362,
8,
1430,
63,
466,
12,
3073,
267,
3233,
63,
513,
14,
740,
3252,
1593,
356,
3233,
12,
2892,
283,
751,
63,
576,
356,
922,
63,
576,
1552,
267,
291,
423,
3058,
63,
807,
59,
1430,
63,
466,
61,
275,
3233,
63,
513,
339,
347,
485,
2168,
63,
3058,
8,
277,
12,
3233,
304,
267,
367,
3233,
63,
513,
315,
291,
423,
3058,
63,
807,
14,
1459,
837,
288,
367,
2397,
315,
3233,
63,
513,
26,
355,
340,
2397,
459,
1593,
418,
508,
3233,
26,
490,
3233,
63,
513,
14,
2168,
8,
2373,
9,
339,
347,
11705,
8,
277,
12,
1067,
12,
1245,
304,
267,
340,
1245,
14,
362,
360,
1430,
63,
466,
358,
440,
315,
291,
423,
3058,
63,
807,
26,
288,
372,
398,
367,
2397,
315,
291,
423,
3058,
63,
807,
59,
1188,
14,
362,
360,
1430,
63,
466,
358,
2189,
288,
2397,
459,
1593,
21407,
1100,
12,
1245,
12,
2397,
14,
362,
360,
751,
63,
576,
1333,
339,
347,
13484,
8,
277,
304,
267,
372,
291,
423,
3058,
63,
807,
421,
199,
533,
17555,
5061,
8,
2718,
14,
5061,
304,
272,
408,
11349,
543,
282,
3486,
3233,
3217,
14,
339,
961,
1021,
365,
2741,
465,
282,
16777,
367,
27955,
282,
3486,
272,
3589,
626,
1454,
9626,
397,
282,
17535,
402,
4474,
14,
221,
2104,
2893,
12,
2348,
1159,
272,
282,
5516,
1314,
14767,
282,
1004,
314,
1642,
900,
376,
1256,
365,
2737,
14,
339,
1021,
24837,
3244,
13921,
8,
2806,
5061,
304,
398,
347,
636,
826,
721,
277,
12,
485,
1364,
63,
354,
304,
288,
1613,
8,
8481,
3244,
13921,
12,
291,
2843,
826,
4533,
288,
291,
423,
525,
63,
3058,
8,
277,
14,
11523,
12,
283,
3357,
14,
842,
14,
981,
14,
928,
358,
398,
347,
10628,
8,
277,
304,
288,
870,
298,
2493,
1256,
1990,
2737,
9539,
288,
291,
423,
2168,
63,
3058,
8,
277,
12,
291,
14,
11523,
9,
272,
408,
339,
347,
636,
826,
721,
277,
12,
2435,
63,
354,
304,
267,
1613,
8,
2806,
5061,
12,
291,
2843,
826,
721,
1364,
63,
354,
9,
267,
291,
423,
3058,
63,
18031,
275,
485,
2806,
26884,
342,
267,
291,
423,
525,
63,
18031,
8,
277,
423,
3058,
63,
18031,
9,
339,
347,
485,
525,
63,
3058,
8,
277,
12,
3233,
12,
1566,
63,
466,
12,
922,
63,
576,
29,
403,
304,
267,
408,
1123,
3233,
367,
282,
1627,
1566,
6955,
14,
398,
20196,
883,
1240,
642,
465,
376,
13943,
370,
18234,
267,
282,
2615,
66,
674,
78,
11705,
30154,
14,
267,
408,
267,
291,
423,
3058,
63,
18031,
423,
525,
63,
3058,
8,
1430,
63,
466,
12,
3233,
12,
922,
63,
576,
9,
339,
347,
485,
2168,
63,
3058,
8,
277,
12,
3233,
304,
267,
408,
5587,
1006,
6955,
13484,
370,
2013,
805,
1041,
267,
291,
423,
3058,
63,
18031,
423,
2168,
63,
3058,
8,
3058,
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
] |
[
1898,
6029,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
5913,
14,
8512,
14,
2330,
492,
943,
465,
2050,
199,
504,
5913,
14,
8512,
14,
2330,
14,
2718,
492,
3589,
421,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
485,
2806,
26884,
8,
785,
304,
272,
408,
2395,
7441,
3589,
13,
4037,
6955,
13484,
14,
339,
2104,
1924,
11349,
12,
282,
17555,
26884,
911,
506,
3483,
370,
314,
272,
6955,
5253,
769,
14,
221,
28055,
370,
11705,
342,
543,
5827,
272,
3788,
911,
506,
5759,
379,
436,
8457,
13484,
14,
339,
437,
3233,
1077,
3648,
2839,
642,
26,
489,
347,
3233,
8,
1100,
12,
1245,
12,
922,
63,
576,
9,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
3058,
63,
807,
275,
1052,
339,
347,
485,
525,
63,
3058,
8,
277,
12,
1566,
63,
466,
12,
3233,
12,
922,
63,
576,
304,
267,
3233,
63,
513,
275,
291,
423,
3058,
63,
807,
14,
362,
8,
1430,
63,
466,
12,
3073,
267,
3233,
63,
513,
14,
740,
3252,
1593,
356,
3233,
12,
2892,
283,
751,
63,
576,
356,
922,
63,
576,
1552,
267,
291,
423,
3058,
63,
807,
59,
1430,
63,
466,
61,
275,
3233,
63,
513,
339,
347,
485,
2168,
63,
3058,
8,
277,
12,
3233,
304,
267,
367,
3233,
63,
513,
315,
291,
423,
3058,
63,
807,
14,
1459,
837,
288,
367,
2397,
315,
3233,
63,
513,
26,
355,
340,
2397,
459,
1593,
418,
508,
3233,
26,
490,
3233,
63,
513,
14,
2168,
8,
2373,
9,
339,
347,
11705,
8,
277,
12,
1067,
12,
1245,
304,
267,
340,
1245,
14,
362,
360,
1430,
63,
466,
358,
440,
315,
291,
423,
3058,
63,
807,
26,
288,
372,
398,
367,
2397,
315,
291,
423,
3058,
63,
807,
59,
1188,
14,
362,
360,
1430,
63,
466,
358,
2189,
288,
2397,
459,
1593,
21407,
1100,
12,
1245,
12,
2397,
14,
362,
360,
751,
63,
576,
1333,
339,
347,
13484,
8,
277,
304,
267,
372,
291,
423,
3058,
63,
807,
421,
199,
533,
17555,
5061,
8,
2718,
14,
5061,
304,
272,
408,
11349,
543,
282,
3486,
3233,
3217,
14,
339,
961,
1021,
365,
2741,
465,
282,
16777,
367,
27955,
282,
3486,
272,
3589,
626,
1454,
9626,
397,
282,
17535,
402,
4474,
14,
221,
2104,
2893,
12,
2348,
1159,
272,
282,
5516,
1314,
14767,
282,
1004,
314,
1642,
900,
376,
1256,
365,
2737,
14,
339,
1021,
24837,
3244,
13921,
8,
2806,
5061,
304,
398,
347,
636,
826,
721,
277,
12,
485,
1364,
63,
354,
304,
288,
1613,
8,
8481,
3244,
13921,
12,
291,
2843,
826,
4533,
288,
291,
423,
525,
63,
3058,
8,
277,
14,
11523,
12,
283,
3357,
14,
842,
14,
981,
14,
928,
358,
398,
347,
10628,
8,
277,
304,
288,
870,
298,
2493,
1256,
1990,
2737,
9539,
288,
291,
423,
2168,
63,
3058,
8,
277,
12,
291,
14,
11523,
9,
272,
408,
339,
347,
636,
826,
721,
277,
12,
2435,
63,
354,
304,
267,
1613,
8,
2806,
5061,
12,
291,
2843,
826,
721,
1364,
63,
354,
9,
267,
291,
423,
3058,
63,
18031,
275,
485,
2806,
26884,
342,
267,
291,
423,
525,
63,
18031,
8,
277,
423,
3058,
63,
18031,
9,
339,
347,
485,
525,
63,
3058,
8,
277,
12,
3233,
12,
1566,
63,
466,
12,
922,
63,
576,
29,
403,
304,
267,
408,
1123,
3233,
367,
282,
1627,
1566,
6955,
14,
398,
20196,
883,
1240,
642,
465,
376,
13943,
370,
18234,
267,
282,
2615,
66,
674,
78,
11705,
30154,
14,
267,
408,
267,
291,
423,
3058,
63,
18031,
423,
525,
63,
3058,
8,
1430,
63,
466,
12,
3233,
12,
922,
63,
576,
9,
339,
347,
485,
2168,
63,
3058,
8,
277,
12,
3233,
304,
267,
408,
5587,
1006,
6955,
13484,
370,
2013,
805,
1041,
267,
291,
423,
3058,
63,
18031,
423,
2168,
63,
3058,
8,
3058,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
XertroV/bitcoin-python3
|
src/bitcoinrpc/data.py
|
9
|
5184
|
# Copyright (c) 2010 Witchspace <witchspace81@gmail.com>
#
# 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.
"""
Bitcoin RPC service, data objects.
"""
from bitcoinrpc.util import DStruct
class ServerInfo(DStruct):
"""
Information object returned by :func:`~bitcoinrpc.connection.BitcoinConnection.getinfo`.
- *errors* -- Number of errors.
- *blocks* -- Number of blocks.
- *paytxfee* -- Amount of transaction fee to pay.
- *keypoololdest* -- Oldest key in keypool.
- *genproclimit* -- Processor limit for generation.
- *connections* -- Number of connections to other clients.
- *difficulty* -- Current generating difficulty.
- *testnet* -- True if connected to testnet, False if on real network.
- *version* -- Bitcoin client version.
- *proxy* -- Proxy configured in client.
- *hashespersec* -- Number of hashes per second (if generation enabled).
- *balance* -- Total current server balance.
- *generate* -- True if generation enabled, False if not.
- *unlocked_until* -- Timestamp (seconds since epoch) after which the wallet
will be/was locked (if wallet encryption is enabled).
"""
class AccountInfo(DStruct):
"""
Information object returned by :func:`~bitcoinrpc.connection.BitcoinConnection.listreceivedbyaccount`.
- *account* -- The account of the receiving address.
- *amount* -- Total amount received by the address.
- *confirmations* -- Number of confirmations of the most recent transaction included.
"""
class AddressInfo(DStruct):
"""
Information object returned by :func:`~bitcoinrpc.connection.BitcoinConnection.listreceivedbyaddress`.
- *address* -- Receiving address.
- *account* -- The account of the receiving address.
- *amount* -- Total amount received by the address.
- *confirmations* -- Number of confirmations of the most recent transaction included.
"""
class TransactionInfo(DStruct):
"""
Information object returned by :func:`~bitcoinrpc.connection.BitcoinConnection.listtransactions`.
- *account* -- account name.
- *address* -- the address bitcoins were sent to, or received from.
- *category* -- will be generate, send, receive, or move.
- *amount* -- amount of transaction.
- *fee* -- Fee (if any) paid (only for send transactions).
- *confirmations* -- number of confirmations (only for generate/send/receive).
- *txid* -- transaction ID (only for generate/send/receive).
- *otheraccount* -- account funds were moved to or from (only for move).
- *message* -- message associated with transaction (only for send).
- *to* -- message-to associated with transaction (only for send).
"""
class AddressValidation(DStruct):
"""
Information object returned by :func:`~bitcoinrpc.connection.BitcoinConnection.validateaddress`.
- *isvalid* -- Validatity of address (:const:`True` or :const:`False`).
- *ismine* -- :const:`True` if the address is in the server's wallet.
- *address* -- Bitcoin address.
"""
class WorkItem(DStruct):
"""
Information object returned by :func:`~bitcoinrpc.connection.BitcoinConnection.getwork`.
- *midstate* -- Precomputed hash state after hashing the first half of the data.
- *data* -- Block data.
- *hash1* -- Formatted hash buffer for second hash.
- *target* -- Little endian hash target.
"""
class MiningInfo(DStruct):
"""
Information object returned by :func:`~bitcoinrpc.connection.BitcoinConnection.getmininginfo`.
- *blocks* -- Number of blocks.
- *currentblocksize* -- Size of current block.
- *currentblocktx* -- Number of transactions in current block.
- *difficulty* -- Current generating difficulty.
- *errors* -- Number of errors.
- *generate* -- True if generation enabled, False if not.
- *genproclimit* -- Processor limit for generation.
- *hashespersec* -- Number of hashes per second (if generation enabled).
- *pooledtx* -- Number of pooled transactions.
- *testnet* -- True if connected to testnet, False if on real network.
"""
|
mit
|
[
3,
1898,
334,
67,
9,
7129,
644,
9414,
2638,
665,
3111,
2638,
2835,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
3,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
3,
315,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
3,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
3,
6866,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
3,
13985,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
3,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
3,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
10610,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
3,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
3,
2334,
4141,
14,
199,
624,
199,
4734,
9061,
11785,
2435,
12,
666,
2251,
14,
199,
624,
199,
504,
27214,
4354,
14,
1974,
492,
577,
4836,
421,
199,
533,
7146,
2354,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
32286,
2313,
339,
446,
627,
2550,
10,
1553,
4860,
402,
2552,
14,
339,
446,
627,
4166,
10,
1553,
4860,
402,
5664,
14,
339,
446,
627,
5989,
2347,
11195,
10,
1553,
26701,
402,
6008,
14751,
370,
8633,
14,
339,
446,
627,
498,
555,
79,
320,
76,
2614,
10,
1553,
593,
76,
2614,
790,
315,
790,
2293,
14,
339,
446,
627,
2268,
496,
2764,
1147,
10,
1553,
31500,
2304,
367,
10152,
14,
339,
446,
627,
7995,
10,
1553,
4860,
402,
6947,
370,
1163,
13431,
14,
339,
446,
627,
29801,
10,
1553,
9338,
12999,
23976,
17323,
14,
339,
446,
627,
396,
846,
10,
1553,
715,
340,
8539,
370,
511,
846,
12,
756,
340,
641,
3363,
2784,
14,
339,
446,
627,
1023,
10,
1553,
21158,
1890,
1015,
14,
339,
446,
627,
3280,
10,
1553,
12373,
7526,
315,
1890,
14,
339,
446,
627,
12428,
529,
3321,
10,
1553,
4860,
402,
14647,
1126,
3499,
334,
692,
10152,
5223,
680,
339,
446,
627,
7358,
10,
1553,
19271,
1453,
1654,
14094,
14,
339,
446,
627,
4208,
10,
1553,
715,
340,
10152,
5223,
12,
756,
340,
440,
14,
339,
446,
627,
32489,
63,
8111,
10,
1553,
18267,
334,
4515,
3967,
9463,
9,
2410,
1314,
314,
20534,
2079,
911,
506,
15,
10274,
14233,
334,
692,
20534,
14396,
365,
5223,
680,
339,
408,
421,
199,
533,
9973,
2354,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
513,
30404,
2048,
2313,
339,
446,
627,
2048,
10,
1553,
710,
2933,
402,
314,
18390,
2287,
14,
339,
446,
627,
4606,
10,
1553,
19271,
5982,
3086,
701,
314,
2287,
14,
339,
446,
627,
388,
27389,
10,
1553,
4860,
402,
406,
27389,
402,
314,
4750,
8058,
6008,
5120,
14,
339,
408,
421,
199,
533,
9906,
2354,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
513,
30404,
1562,
2313,
339,
446,
627,
1562,
10,
1553,
799,
2375,
316,
2287,
14,
339,
446,
627,
2048,
10,
1553,
710,
2933,
402,
314,
18390,
2287,
14,
339,
446,
627,
4606,
10,
1553,
19271,
5982,
3086,
701,
314,
2287,
14,
339,
446,
627,
388,
27389,
10,
1553,
4860,
402,
406,
27389,
402,
314,
4750,
8058,
6008,
5120,
14,
339,
408,
421,
199,
533,
18244,
2354,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
513,
13754,
2313,
339,
446,
627,
2048,
10,
1553,
2933,
536,
14,
339,
446,
627,
1562,
10,
1553,
314,
2287,
4546,
331,
3617,
4898,
4847,
370,
12,
503,
3086,
687,
14,
2286,
446,
627,
3710,
10,
1553,
911,
506,
3550,
12,
3222,
12,
9128,
12,
503,
4057,
14,
339,
446,
627,
4606,
10,
1553,
5982,
402,
6008,
14,
339,
446,
627,
11195,
10,
1553,
481,
1024,
334,
692,
1263,
9,
30677,
334,
2118,
367,
3222,
15809,
680,
339,
446,
627,
388,
27389,
10,
1553,
1329,
402,
406,
27389,
334,
2118,
367,
3550,
15,
2254,
15,
9391,
680,
339,
446,
627,
14113,
10,
1553,
6008,
2870,
334,
2118,
367,
3550,
15,
2254,
15,
9391,
680,
339,
446,
627,
1848,
2048,
10,
1553,
2933,
27440,
83,
4898,
12155,
370,
503,
687,
334,
2118,
367,
4057,
680,
339,
446,
627,
1188,
10,
1553,
1245,
4568,
543,
6008,
334,
2118,
367,
3222,
680,
339,
446,
627,
475,
10,
1553,
1245,
13,
475,
4568,
543,
6008,
334,
2118,
367,
3222,
680,
272,
408,
421,
199,
533,
9906,
13816,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
3502,
1562,
2313,
339,
446,
627,
374,
1078,
10,
1553,
4821,
65,
1701,
402,
2287,
18479,
1297,
1705,
549,
64,
503,
520,
1297,
1705,
797,
14963,
339,
446,
627,
374,
19153,
10,
1553,
520,
1297,
1705,
549,
64,
340,
314,
2287,
365,
315,
314,
1654,
1159,
20534,
14,
339,
446,
627,
1562,
10,
1553,
21158,
2287,
14,
339,
408,
421,
199,
533,
9361,
2081,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
362,
800,
2313,
339,
446,
627,
8523,
929,
10,
1553,
5543,
14378,
2631,
1174,
2410,
25223,
314,
1642,
12995,
402,
314,
666,
14,
339,
446,
627,
576,
10,
1553,
8651,
666,
14,
339,
446,
627,
2227,
17
] |
[
1898,
334,
67,
9,
7129,
644,
9414,
2638,
665,
3111,
2638,
2835,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
3,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
3,
315,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
3,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
3,
6866,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
3,
13985,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
3,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
3,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
10610,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
3,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
3,
2334,
4141,
14,
199,
624,
199,
4734,
9061,
11785,
2435,
12,
666,
2251,
14,
199,
624,
199,
504,
27214,
4354,
14,
1974,
492,
577,
4836,
421,
199,
533,
7146,
2354,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
32286,
2313,
339,
446,
627,
2550,
10,
1553,
4860,
402,
2552,
14,
339,
446,
627,
4166,
10,
1553,
4860,
402,
5664,
14,
339,
446,
627,
5989,
2347,
11195,
10,
1553,
26701,
402,
6008,
14751,
370,
8633,
14,
339,
446,
627,
498,
555,
79,
320,
76,
2614,
10,
1553,
593,
76,
2614,
790,
315,
790,
2293,
14,
339,
446,
627,
2268,
496,
2764,
1147,
10,
1553,
31500,
2304,
367,
10152,
14,
339,
446,
627,
7995,
10,
1553,
4860,
402,
6947,
370,
1163,
13431,
14,
339,
446,
627,
29801,
10,
1553,
9338,
12999,
23976,
17323,
14,
339,
446,
627,
396,
846,
10,
1553,
715,
340,
8539,
370,
511,
846,
12,
756,
340,
641,
3363,
2784,
14,
339,
446,
627,
1023,
10,
1553,
21158,
1890,
1015,
14,
339,
446,
627,
3280,
10,
1553,
12373,
7526,
315,
1890,
14,
339,
446,
627,
12428,
529,
3321,
10,
1553,
4860,
402,
14647,
1126,
3499,
334,
692,
10152,
5223,
680,
339,
446,
627,
7358,
10,
1553,
19271,
1453,
1654,
14094,
14,
339,
446,
627,
4208,
10,
1553,
715,
340,
10152,
5223,
12,
756,
340,
440,
14,
339,
446,
627,
32489,
63,
8111,
10,
1553,
18267,
334,
4515,
3967,
9463,
9,
2410,
1314,
314,
20534,
2079,
911,
506,
15,
10274,
14233,
334,
692,
20534,
14396,
365,
5223,
680,
339,
408,
421,
199,
533,
9973,
2354,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
513,
30404,
2048,
2313,
339,
446,
627,
2048,
10,
1553,
710,
2933,
402,
314,
18390,
2287,
14,
339,
446,
627,
4606,
10,
1553,
19271,
5982,
3086,
701,
314,
2287,
14,
339,
446,
627,
388,
27389,
10,
1553,
4860,
402,
406,
27389,
402,
314,
4750,
8058,
6008,
5120,
14,
339,
408,
421,
199,
533,
9906,
2354,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
513,
30404,
1562,
2313,
339,
446,
627,
1562,
10,
1553,
799,
2375,
316,
2287,
14,
339,
446,
627,
2048,
10,
1553,
710,
2933,
402,
314,
18390,
2287,
14,
339,
446,
627,
4606,
10,
1553,
19271,
5982,
3086,
701,
314,
2287,
14,
339,
446,
627,
388,
27389,
10,
1553,
4860,
402,
406,
27389,
402,
314,
4750,
8058,
6008,
5120,
14,
339,
408,
421,
199,
533,
18244,
2354,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
513,
13754,
2313,
339,
446,
627,
2048,
10,
1553,
2933,
536,
14,
339,
446,
627,
1562,
10,
1553,
314,
2287,
4546,
331,
3617,
4898,
4847,
370,
12,
503,
3086,
687,
14,
2286,
446,
627,
3710,
10,
1553,
911,
506,
3550,
12,
3222,
12,
9128,
12,
503,
4057,
14,
339,
446,
627,
4606,
10,
1553,
5982,
402,
6008,
14,
339,
446,
627,
11195,
10,
1553,
481,
1024,
334,
692,
1263,
9,
30677,
334,
2118,
367,
3222,
15809,
680,
339,
446,
627,
388,
27389,
10,
1553,
1329,
402,
406,
27389,
334,
2118,
367,
3550,
15,
2254,
15,
9391,
680,
339,
446,
627,
14113,
10,
1553,
6008,
2870,
334,
2118,
367,
3550,
15,
2254,
15,
9391,
680,
339,
446,
627,
1848,
2048,
10,
1553,
2933,
27440,
83,
4898,
12155,
370,
503,
687,
334,
2118,
367,
4057,
680,
339,
446,
627,
1188,
10,
1553,
1245,
4568,
543,
6008,
334,
2118,
367,
3222,
680,
339,
446,
627,
475,
10,
1553,
1245,
13,
475,
4568,
543,
6008,
334,
2118,
367,
3222,
680,
272,
408,
421,
199,
533,
9906,
13816,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
3502,
1562,
2313,
339,
446,
627,
374,
1078,
10,
1553,
4821,
65,
1701,
402,
2287,
18479,
1297,
1705,
549,
64,
503,
520,
1297,
1705,
797,
14963,
339,
446,
627,
374,
19153,
10,
1553,
520,
1297,
1705,
549,
64,
340,
314,
2287,
365,
315,
314,
1654,
1159,
20534,
14,
339,
446,
627,
1562,
10,
1553,
21158,
2287,
14,
339,
408,
421,
199,
533,
9361,
2081,
8,
36,
4836,
304,
272,
408,
272,
17064,
909,
2138,
701,
520,
1532,
6054,
22816,
4354,
14,
2105,
14,
4734,
9061,
3225,
14,
362,
800,
2313,
339,
446,
627,
8523,
929,
10,
1553,
5543,
14378,
2631,
1174,
2410,
25223,
314,
1642,
12995,
402,
314,
666,
14,
339,
446,
627,
576,
10,
1553,
8651,
666,
14,
339,
446,
627,
2227,
17,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
purpleidea/macaronic-net
|
django/contrib/flatpages/admin.py
|
250
|
1089
|
from django import forms
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
from django.utils.translation import ugettext_lazy as _
class FlatpageForm(forms.ModelForm):
url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
help_text = _("Example: '/about/contact/'. Make sure to have leading"
" and trailing slashes."),
error_message = _("This value must contain only letters, numbers,"
" dots, underscores, dashes, slashes or tildes."))
class Meta:
model = FlatPage
class FlatPageAdmin(admin.ModelAdmin):
form = FlatpageForm
fieldsets = (
(None, {'fields': ('url', 'title', 'content', 'sites')}),
(_('Advanced options'), {'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name')}),
)
list_display = ('url', 'title')
list_filter = ('sites', 'enable_comments', 'registration_required')
search_fields = ('url', 'title')
admin.site.register(FlatPage, FlatPageAdmin)
|
agpl-3.0
|
[
504,
1639,
492,
4513,
199,
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
29974,
14,
992,
492,
19005,
3276,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
533,
19005,
1606,
2821,
8,
3351,
14,
15937,
304,
272,
1166,
275,
4513,
14,
5103,
792,
8,
1302,
9384,
2632,
1288,
1390,
63,
1267,
29,
1960,
12,
5163,
29,
82,
4289,
1988,
60,
87,
15,
4537,
94,
2807,
4268,
267,
1720,
63,
505,
275,
3824,
9846,
26,
1994,
10254,
15,
7811,
15,
1370,
4155,
3238,
370,
1172,
9186,
2,
1993,
298,
436,
8520,
20275,
7651,
267,
1125,
63,
1188,
275,
3824,
2765,
574,
1471,
1395,
1454,
14435,
12,
5579,
4589,
2079,
298,
21185,
12,
23998,
12,
21106,
12,
20275,
503,
221,
2270,
3424,
13853,
339,
1021,
6288,
26,
267,
1402,
275,
19005,
3276,
421,
199,
533,
19005,
3276,
4880,
8,
2113,
14,
12976,
304,
272,
1824,
275,
19005,
1606,
2821,
272,
901,
2193,
275,
334,
267,
334,
403,
12,
791,
955,
356,
661,
633,
297,
283,
1213,
297,
283,
1317,
297,
283,
8619,
358,
8688,
267,
21790,
23613,
1511,
659,
791,
2888,
356,
661,
20681,
5529,
283,
955,
356,
661,
4296,
63,
6223,
297,
283,
8054,
63,
2427,
297,
283,
1160,
63,
354,
358,
8688,
272,
776,
272,
769,
63,
2918,
275,
661,
633,
297,
283,
1213,
358,
272,
769,
63,
1541,
275,
661,
8619,
297,
283,
4296,
63,
6223,
297,
283,
8054,
63,
2427,
358,
272,
2754,
63,
955,
275,
661,
633,
297,
283,
1213,
358,
199,
199,
2113,
14,
2124,
14,
2683,
8,
17271,
3276,
12,
19005,
3276,
4880,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
492,
4513,
199,
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
29974,
14,
992,
492,
19005,
3276,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
533,
19005,
1606,
2821,
8,
3351,
14,
15937,
304,
272,
1166,
275,
4513,
14,
5103,
792,
8,
1302,
9384,
2632,
1288,
1390,
63,
1267,
29,
1960,
12,
5163,
29,
82,
4289,
1988,
60,
87,
15,
4537,
94,
2807,
4268,
267,
1720,
63,
505,
275,
3824,
9846,
26,
1994,
10254,
15,
7811,
15,
1370,
4155,
3238,
370,
1172,
9186,
2,
1993,
298,
436,
8520,
20275,
7651,
267,
1125,
63,
1188,
275,
3824,
2765,
574,
1471,
1395,
1454,
14435,
12,
5579,
4589,
2079,
298,
21185,
12,
23998,
12,
21106,
12,
20275,
503,
221,
2270,
3424,
13853,
339,
1021,
6288,
26,
267,
1402,
275,
19005,
3276,
421,
199,
533,
19005,
3276,
4880,
8,
2113,
14,
12976,
304,
272,
1824,
275,
19005,
1606,
2821,
272,
901,
2193,
275,
334,
267,
334,
403,
12,
791,
955,
356,
661,
633,
297,
283,
1213,
297,
283,
1317,
297,
283,
8619,
358,
8688,
267,
21790,
23613,
1511,
659,
791,
2888,
356,
661,
20681,
5529,
283,
955,
356,
661,
4296,
63,
6223,
297,
283,
8054,
63,
2427,
297,
283,
1160,
63,
354,
358,
8688,
272,
776,
272,
769,
63,
2918,
275,
661,
633,
297,
283,
1213,
358,
272,
769,
63,
1541,
275,
661,
8619,
297,
283,
4296,
63,
6223,
297,
283,
8054,
63,
2427,
358,
272,
2754,
63,
955,
275,
661,
633,
297,
283,
1213,
358,
199,
199,
2113,
14,
2124,
14,
2683,
8,
17271,
3276,
12,
19005,
3276,
4880,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
MSeifert04/astropy
|
astropy/units/quantity_helper/function_helpers.py
|
3
|
35300
|
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license. See LICENSE.rst except
# for parts explicitly labelled as being (largely) copies of numpy
# implementations; for those, see licenses/NUMPY_LICENSE.rst.
"""Helpers for overriding numpy functions.
We override numpy functions in `~astropy.units.Quantity.__array_function__`.
In this module, the numpy functions are split in four groups, each of
which has an associated `set` or `dict`:
1. SUBCLASS_SAFE_FUNCTIONS (set), if the numpy implementation
supports Quantity; we pass on to ndarray.__array_function__.
2. FUNCTION_HELPERS (dict), if the numpy implementation is usable
after converting quantities to arrays with suitable units,
and possibly setting units on the result.
3. DISPATCHED_FUNCTIONS (dict), if the function makes sense but
requires a Quantity-specific implementation
4. UNSUPPORTED_FUNCTIONS (set), if the function does not make sense.
For the FUNCTION_HELPERS `dict`, the value is a function that does the
unit conversion. It should take the same arguments as the numpy
function would (though one can use ``*args`` and ``**kwargs``) and
return a tuple of ``args, kwargs, unit, out``, where ``args`` and
``kwargs`` will be will be passed on to the numpy implementation,
``unit`` is a possible unit of the result (`None` if it should not be
converted to Quantity), and ``out`` is a possible output Quantity passed
in, which will be filled in-place.
For the DISPATCHED_FUNCTIONS `dict`, the value is a function that
implements the numpy functionality for Quantity input. It should
return a tuple of ``result, unit, out``, where ``result`` is generally
a plain array with the result, and ``unit`` and ``out`` are as above.
If unit is `None`, result gets returned directly, so one can also
return a Quantity directly using ``quantity_result, None, None``.
"""
import functools
import operator
import numpy as np
from astropy.units.core import (
UnitsError, UnitTypeError, dimensionless_unscaled)
from astropy.utils.compat import NUMPY_LT_1_17, NUMPY_LT_1_18
from astropy.utils import isiterable
if NUMPY_LT_1_17: # pragma: no cover
# pre 1.16, overrides.py did not exist; in 1.16, it existed, but
# __array_function__ overrides were turned off by default.
ARRAY_FUNCTION_ENABLED = (hasattr(np.core, 'overrides') and
np.core.overrides.ENABLE_ARRAY_FUNCTION)
else:
# In 1.17, overrides are enabled by default, but it is still possible to
# turn them off using an environment variable. We use getattr since it
# is planned to remove that possibility in later numpy versions.
ARRAY_FUNCTION_ENABLED = getattr(np.core.overrides,
'ENABLE_ARRAY_FUNCTION', True)
SUBCLASS_SAFE_FUNCTIONS = set()
"""Functions with implementations supporting subclasses like Quantity."""
FUNCTION_HELPERS = {}
"""Functions with implementations usable with proper unit conversion."""
DISPATCHED_FUNCTIONS = {}
"""Functions for which we provide our own implementation."""
UNSUPPORTED_FUNCTIONS = set()
"""Functions that cannot sensibly be used with quantities."""
SUBCLASS_SAFE_FUNCTIONS |= {
np.shape, np.size, np.ndim,
np.reshape, np.ravel, np.moveaxis, np.rollaxis, np.swapaxes,
np.transpose, np.atleast_1d, np.atleast_2d, np.atleast_3d,
np.expand_dims, np.squeeze, np.broadcast_to, np.broadcast_arrays,
np.flip, np.fliplr, np.flipud, np.rot90,
np.argmin, np.argmax, np.argsort, np.lexsort, np.searchsorted,
np.nonzero, np.argwhere, np.flatnonzero,
np.diag_indices_from, np.triu_indices_from, np.tril_indices_from,
np.real, np.imag, np.diagonal, np.diagflat,
np.empty_like, np.zeros_like,
np.compress, np.extract, np.delete, np.trim_zeros, np.roll, np.take,
np.put, np.fill_diagonal, np.tile, np.repeat,
np.split, np.array_split, np.hsplit, np.vsplit, np.dsplit,
np.stack, np.column_stack, np.hstack, np.vstack, np.dstack,
np.amax, np.amin, np.ptp, np.sum, np.cumsum,
np.prod, np.product, np.cumprod, np.cumproduct,
np.round, np.around,
np.fix, np.angle, np.i0, np.clip,
np.isposinf, np.isneginf, np.isreal, np.iscomplex,
np.average, np.mean, np.std, np.var, np.median, np.trace,
np.nanmax, np.nanmin, np.nanargmin, np.nanargmax, np.nanmean,
np.nanmedian, np.nansum, np.nancumsum, np.nanstd, np.nanvar,
np.nanprod, np.nancumprod,
np.einsum_path, np.trapz, np.linspace,
np.sort, np.msort, np.partition, np.meshgrid,
np.common_type, np.result_type, np.can_cast, np.min_scalar_type,
np.iscomplexobj, np.isrealobj,
np.shares_memory, np.may_share_memory,
np.apply_along_axis, np.take_along_axis, np.put_along_axis,
np.linalg.cond, np.linalg.multi_dot}
if NUMPY_LT_1_18:
SUBCLASS_SAFE_FUNCTIONS |= {np.alen}
# Implemented as methods on Quantity:
# np.ediff1d is from setops, but we support it anyway; the others
# currently return NotImplementedError.
# TODO: move latter to UNSUPPORTED? Would raise TypeError instead.
SUBCLASS_SAFE_FUNCTIONS |= {np.ediff1d}
# Nonsensical for quantities.
UNSUPPORTED_FUNCTIONS |= {
np.packbits, np.unpackbits, np.unravel_index,
np.ravel_multi_index, np.ix_, np.cov, np.corrcoef,
np.busday_count, np.busday_offset, np.datetime_as_string,
np.is_busday, np.all, np.any, np.sometrue, np.alltrue}
# Could be supported if we had a natural logarithm unit.
UNSUPPORTED_FUNCTIONS |= {np.linalg.slogdet}
# The following are not just unsupported, but so unlikely to be thought
# to be supported that we ignore them in testing. (Kept in a separate
# variable so that we can check consistency in the test routine -
# test_quantity_non_ufuncs.py)
IGNORED_FUNCTIONS = {
# Deprecated
np.asscalar,
# I/O - useless for Quantity, since no way to store the unit.
np.save, np.savez, np.savetxt, np.savez_compressed,
# Polynomials
np.poly, np.polyadd, np.polyder, np.polydiv, np.polyfit, np.polyint,
np.polymul, np.polysub, np.polyval, np.roots, np.vander,
# financial
np.fv, np.ipmt, np.irr, np.mirr, np.nper, np.npv, np.pmt, np.ppmt,
np.pv, np.rate}
if NUMPY_LT_1_18:
IGNORED_FUNCTIONS |= {np.rank}
else:
IGNORED_FUNCTIONS |= {np.alen}
UNSUPPORTED_FUNCTIONS |= IGNORED_FUNCTIONS
class FunctionAssigner:
def __init__(self, assignments):
self.assignments = assignments
def __call__(self, f=None, helps=None, module=np):
"""Add a helper to a numpy function.
Normally used as a decorator.
If ``helps`` is given, it should be the numpy function helped (or an
iterable of numpy functions helped).
If ``helps`` is not given, it is assumed the function helped is the
numpy function with the same name as the decorated function.
"""
if f is not None:
if helps is None:
helps = getattr(module, f.__name__)
if not isiterable(helps):
helps = (helps,)
for h in helps:
self.assignments[h] = f
return f
elif helps is not None or module is not np:
return functools.partial(self.__call__, helps=helps, module=module)
else: # pragma: no cover
raise ValueError("function_helper requires at least one argument.")
function_helper = FunctionAssigner(FUNCTION_HELPERS)
dispatched_function = FunctionAssigner(DISPATCHED_FUNCTIONS)
@function_helper(helps={
np.copy, np.asfarray, np.real_if_close, np.sort_complex, np.resize,
np.fft.fft, np.fft.ifft, np.fft.rfft, np.fft.irfft,
np.fft.fft2, np.fft.ifft2, np.fft.rfft2, np.fft.irfft2,
np.fft.fftn, np.fft.ifftn, np.fft.rfftn, np.fft.irfftn,
np.fft.hfft, np.fft.ihfft,
np.linalg.eigvals, np.linalg.eigvalsh})
def invariant_a_helper(a, *args, **kwargs):
return (a.view(np.ndarray),) + args, kwargs, a.unit, None
@function_helper(helps={np.tril, np.triu})
def invariant_m_helper(m, *args, **kwargs):
return (m.view(np.ndarray),) + args, kwargs, m.unit, None
@function_helper(helps={np.fft.fftshift, np.fft.ifftshift})
def invariant_x_helper(x, *args, **kwargs):
return (x.view(np.ndarray),) + args, kwargs, x.unit, None
# Note that ones_like does *not* work by default (unlike zeros_like) since if
# one creates an empty array with a unit, one cannot just fill it with unity.
# Indeed, in this respect, it is a bit of an odd function for Quantity. On the
# other hand, it matches the idea that a unit is the same as the quantity with
# that unit and value of 1. Also, it used to work without __array_function__.
@function_helper
def ones_like(a, *args, **kwargs):
subok = args[2] if len(args) > 2 else kwargs.pop('subok', True)
unit = a.unit if subok else None
return (a.view(np.ndarray),) + args, kwargs, unit, None
@function_helper
def sinc(x):
from astropy.units.si import radian
try:
x = x.to_value(radian)
except UnitsError:
raise UnitTypeError("Can only apply 'sinc' function to "
"quantities with angle units")
return (x,), {}, dimensionless_unscaled, None
@dispatched_function
def unwrap(p, discont=None, axis=-1):
from astropy.units.si import radian
if discont is None:
discont = np.pi << radian
p, discont = _as_quantities(p, discont)
result = np.unwrap.__wrapped__(p.to_value(radian),
discont.to_value(radian), axis=axis)
result = radian.to(p.unit, result)
return result, p.unit, None
@function_helper
def argpartition(a, *args, **kwargs):
return (a.view(np.ndarray),) + args, kwargs, None, None
@function_helper
def full_like(a, fill_value, *args, **kwargs):
unit = a.unit if kwargs.get('subok', True) else None
return (a.view(np.ndarray),
a._to_own_unit(fill_value)) + args, kwargs, unit, None
@function_helper
def putmask(a, mask, values):
from astropy.units import Quantity
if isinstance(a, Quantity):
return (a.view(np.ndarray), mask,
a._to_own_unit(values)), {}, a.unit, None
elif isinstance(values, Quantity):
return (a, mask,
values.to_value(dimensionless_unscaled)), {}, None, None
else:
raise NotImplementedError
@function_helper
def place(arr, mask, vals):
from astropy.units import Quantity
if isinstance(arr, Quantity):
return (arr.view(np.ndarray), mask,
arr._to_own_unit(vals)), {}, arr.unit, None
elif isinstance(vals, Quantity):
return (arr, mask,
vals.to_value(dimensionless_unscaled)), {}, None, None
else:
raise NotImplementedError
@function_helper
def copyto(dst, src, *args, **kwargs):
from astropy.units import Quantity
if isinstance(dst, Quantity):
return ((dst.view(np.ndarray), dst._to_own_unit(src)) + args,
kwargs, None, None)
elif isinstance(src, Quantity):
return ((dst, src.to_value(dimensionless_unscaled)) + args,
kwargs, None, None)
else:
raise NotImplementedError
@function_helper
def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):
nan = x._to_own_unit(nan)
if posinf is not None:
posinf = x._to_own_unit(posinf)
if neginf is not None:
neginf = x._to_own_unit(neginf)
return ((x.view(np.ndarray),),
dict(copy=True, nan=nan, posinf=posinf, neginf=neginf),
x.unit, None)
def _as_quantity(a):
"""Convert argument to a Quantity (or raise NotImplementedError)."""
from astropy.units import Quantity
try:
return Quantity(a, copy=False, subok=True)
except Exception:
# If we cannot convert to Quantity, we should just bail.
raise NotImplementedError
def _as_quantities(*args):
"""Convert arguments to Quantity (or raise NotImplentedError)."""
from astropy.units import Quantity
try:
return tuple(Quantity(a, copy=False, subok=True)
for a in args)
except Exception:
# If we cannot convert to Quantity, we should just bail.
raise NotImplementedError
def _quantities2arrays(*args, unit_from_first=False):
"""Convert to arrays in units of the first argument that has a unit.
If unit_from_first, take the unit of the first argument regardless
whether it actually defined a unit (e.g., dimensionless for arrays).
"""
# Turn first argument into a quantity.
q = _as_quantity(args[0])
if len(args) == 1:
return (q.value,), q.unit
# If we care about the unit being explicit, then check whether this
# argument actually had a unit, or was likely inferred.
if not unit_from_first and (q.unit is q._default_unit
and not hasattr(args[0], 'unit')):
# Here, the argument could still be things like [10*u.one, 11.*u.one]),
# i.e., properly dimensionless. So, we only override with anything
# that has a unit not equivalent to dimensionless (fine to ignore other
# dimensionless units pass, even if explicitly given).
for arg in args[1:]:
trial = _as_quantity(arg)
if not trial.unit.is_equivalent(q.unit):
# Use any explicit unit not equivalent to dimensionless.
q = trial
break
# We use the private _to_own_unit method here instead of just
# converting everything to quantity and then do .to_value(qs0.unit)
# as we want to allow arbitrary unit for 0, inf, and nan.
try:
arrays = tuple((q._to_own_unit(arg)) for arg in args)
except TypeError:
raise NotImplementedError
return arrays, q.unit
def _iterable_helper(*args, out=None, **kwargs):
"""Convert arguments to Quantity, and treat possible 'out'."""
from astropy.units import Quantity
if out is not None:
if isinstance(out, Quantity):
kwargs['out'] = out.view(np.ndarray)
else:
# TODO: for an ndarray output, we could in principle
# try converting all Quantity to dimensionless.
raise NotImplementedError
arrays, unit = _quantities2arrays(*args)
return arrays, kwargs, unit, out
@function_helper
def concatenate(arrays, axis=0, out=None):
# TODO: make this smarter by creating an appropriately shaped
# empty output array and just filling it.
arrays, kwargs, unit, out = _iterable_helper(*arrays, out=out, axis=axis)
return (arrays,), kwargs, unit, out
@dispatched_function
def block(arrays):
# We need to override block since the numpy implementation can take two
# different paths, one for concatenation, one for creating a large empty
# result array in which parts are set. Each assumes array input and
# cannot be used directly. Since it would be very costly to inspect all
# arrays and then turn them back into a nested list, we just copy here the
# second implementation, np.core.shape_base._block_slicing, since it is
# shortest and easiest.
(arrays, list_ndim, result_ndim,
final_size) = np.core.shape_base._block_setup(arrays)
shape, slices, arrays = np.core.shape_base._block_info_recursion(
arrays, list_ndim, result_ndim)
# Here, one line of difference!
arrays, unit = _quantities2arrays(*arrays)
# Back to _block_slicing
dtype = np.result_type(*[arr.dtype for arr in arrays])
F_order = all(arr.flags['F_CONTIGUOUS'] for arr in arrays)
C_order = all(arr.flags['C_CONTIGUOUS'] for arr in arrays)
order = 'F' if F_order and not C_order else 'C'
result = np.empty(shape=shape, dtype=dtype, order=order)
for the_slice, arr in zip(slices, arrays):
result[(Ellipsis,) + the_slice] = arr
return result, unit, None
@function_helper
def choose(a, choices, out=None, **kwargs):
choices, kwargs, unit, out = _iterable_helper(*choices, out=out, **kwargs)
return (a, choices,), kwargs, unit, out
@function_helper
def select(condlist, choicelist, default=0):
choicelist, kwargs, unit, out = _iterable_helper(*choicelist)
if default != 0:
default = (1 * unit)._to_own_unit(default)
return (condlist, choicelist, default), kwargs, unit, out
@dispatched_function
def piecewise(x, condlist, funclist, *args, **kw):
from astropy.units import Quantity
# Copied implementation from numpy.lib.function_base.piecewise,
# taking care of units of function outputs.
n2 = len(funclist)
# undocumented: single condition is promoted to a list of one condition
if np.isscalar(condlist) or (
not isinstance(condlist[0], (list, np.ndarray)) and x.ndim != 0):
condlist = [condlist]
if any(isinstance(c, Quantity) for c in condlist):
raise NotImplementedError
condlist = np.array(condlist, dtype=bool)
n = len(condlist)
if n == n2 - 1: # compute the "otherwise" condition.
condelse = ~np.any(condlist, axis=0, keepdims=True)
condlist = np.concatenate([condlist, condelse], axis=0)
n += 1
elif n != n2:
raise ValueError(
"with {} condition(s), either {} or {} functions are expected"
.format(n, n, n+1)
)
y = np.zeros(x.shape, x.dtype)
where = []
what = []
for k in range(n):
item = funclist[k]
if not callable(item):
where.append(condlist[k])
what.append(item)
else:
vals = x[condlist[k]]
if vals.size > 0:
where.append(condlist[k])
what.append(item(vals, *args, **kw))
what, unit = _quantities2arrays(*what)
for item, value in zip(where, what):
y[item] = value
return y, unit, None
@function_helper
def append(arr, values, *args, **kwargs):
arrays, unit = _quantities2arrays(arr, values, unit_from_first=True)
return arrays + args, kwargs, unit, None
@function_helper
def insert(arr, obj, values, *args, **kwargs):
from astropy.units import Quantity
if isinstance(obj, Quantity):
raise NotImplementedError
(arr, values), unit = _quantities2arrays(arr, values,
unit_from_first=True)
return (arr, obj, values) + args, kwargs, unit, None
@function_helper
def pad(array, pad_width, mode='constant', **kwargs):
# pad dispatches only on array, so that must be a Quantity.
for key in 'constant_values', 'end_values':
value = kwargs.pop(key, None)
if value is None:
continue
if not isinstance(value, tuple):
value = (value,)
new_value = []
for v in value:
new_value.append(
tuple(array._to_own_unit(_v) for _v in v)
if isinstance(v, tuple) else array._to_own_unit(v))
kwargs[key] = new_value
return (array.view(np.ndarray), pad_width, mode), kwargs, array.unit, None
@function_helper
def where(condition, *args):
from astropy.units import Quantity
if isinstance(condition, Quantity) or len(args) != 2:
raise NotImplementedError
args, unit = _quantities2arrays(*args)
return (condition,) + args, {}, unit, None
@function_helper(helps=({np.quantile, np.nanquantile}))
def quantile(a, q, *args, _q_unit=dimensionless_unscaled, **kwargs):
if len(args) >= 2:
out = args[1]
args = args[:1] + args[2:]
else:
out = kwargs.pop('out', None)
from astropy.units import Quantity
if isinstance(q, Quantity):
q = q.to_value(_q_unit)
(a,), kwargs, unit, out = _iterable_helper(a, out=out, **kwargs)
return (a, q) + args, kwargs, unit, out
@function_helper(helps={np.percentile, np.nanpercentile})
def percentile(a, q, *args, **kwargs):
from astropy.units import percent
return quantile(a, q, *args, _q_unit=percent, **kwargs)
@function_helper
def count_nonzero(a, *args, **kwargs):
return (a.value,) + args, kwargs, None, None
@function_helper(helps={np.isclose, np.allclose})
def close(a, b, rtol=1e-05, atol=1e-08, *args, **kwargs):
from astropy.units import Quantity
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
# Allow number without a unit as having the unit.
atol = Quantity(atol, unit).value
return (a, b, rtol, atol) + args, kwargs, None, None
@function_helper
def array_equal(a1, a2):
args, unit = _quantities2arrays(a1, a2)
return args, {}, None, None
@function_helper
def array_equiv(a1, a2):
args, unit = _quantities2arrays(a1, a2)
return args, {}, None, None
@function_helper(helps={np.dot, np.outer})
def dot_like(a, b, out=None):
from astropy.units import Quantity
a, b = _as_quantities(a, b)
unit = a.unit * b.unit
if out is not None:
if not isinstance(out, Quantity):
raise NotImplementedError
return tuple(x.view(np.ndarray) for x in (a, b, out)), {}, unit, out
else:
return (a.view(np.ndarray), b.view(np.ndarray)), {}, unit, None
@function_helper(helps={np.cross, np.inner, np.vdot, np.tensordot, np.kron,
np.correlate, np.convolve})
def cross_like(a, b, *args, **kwargs):
a, b = _as_quantities(a, b)
unit = a.unit * b.unit
return (a.view(np.ndarray), b.view(np.ndarray)) + args, kwargs, unit, None
@function_helper
def einsum(subscripts, *operands, out=None, **kwargs):
from astropy.units import Quantity
if not isinstance(subscripts, str):
raise ValueError('only "subscripts" string mode supported for einsum.')
if out is not None:
if not isinstance(out, Quantity):
raise NotImplementedError
else:
kwargs['out'] = out.view(np.ndarray)
qs = _as_quantities(*operands)
unit = functools.reduce(operator.mul, (q.unit for q in qs),
dimensionless_unscaled)
arrays = tuple(q.view(np.ndarray) for q in qs)
return (subscripts,) + arrays, kwargs, unit, out
@function_helper
def bincount(x, weights=None, minlength=0):
from astropy.units import Quantity
if isinstance(x, Quantity):
raise NotImplementedError
return (x, weights.value, minlength), {}, weights.unit, None
@function_helper
def digitize(x, bins, *args, **kwargs):
arrays, unit = _quantities2arrays(x, bins, unit_from_first=True)
return arrays + args, kwargs, None, None
def _check_bins(bins, unit):
from astropy.units import Quantity
check = _as_quantity(bins)
if check.ndim > 0:
return check.to_value(unit)
elif isinstance(bins, Quantity):
# bins should be an integer (or at least definitely not a Quantity).
raise NotImplementedError
else:
return bins
@function_helper
def histogram(a, bins=10, range=None, weights=None, density=None):
if weights is not None:
weights = _as_quantity(weights)
unit = weights.unit
weights = weights.value
else:
unit = None
a = _as_quantity(a)
if not isinstance(bins, str):
bins = _check_bins(bins, a.unit)
if density:
unit = (unit or 1) / a.unit
return ((a.value, bins, range), {'weights': weights, 'density': density},
(unit, a.unit), None)
@function_helper(helps=np.histogram_bin_edges)
def histogram_bin_edges(a, bins=10, range=None, weights=None):
# weights is currently unused
a = _as_quantity(a)
if not isinstance(bins, str):
bins = _check_bins(bins, a.unit)
return (a.value, bins, range, weights), {}, a.unit, None
@function_helper
def histogram2d(x, y, bins=10, range=None, weights=None, density=None):
from astropy.units import Quantity
if weights is not None:
weights = _as_quantity(weights)
unit = weights.unit
weights = weights.value
else:
unit = None
x, y = _as_quantities(x, y)
try:
n = len(bins)
except TypeError:
# bins should be an integer (or at least definitely not a Quantity).
if isinstance(bins, Quantity):
raise NotImplementedError
else:
if n == 1:
raise NotImplementedError
elif n == 2 and not isinstance(bins, Quantity):
bins = [_check_bins(b, unit)
for (b, unit) in zip(bins, (x.unit, y.unit))]
else:
bins = _check_bins(bins, x.unit)
y = y.to(x.unit)
if density:
unit = (unit or 1) / x.unit / y.unit
return ((x.value, y.value, bins, range),
{'weights': weights, 'density': density},
(unit, x.unit, y.unit), None)
@function_helper
def histogramdd(sample, bins=10, range=None, weights=None, density=None):
if weights is not None:
weights = _as_quantity(weights)
unit = weights.unit
weights = weights.value
else:
unit = None
try:
# Sample is an ND-array.
_, D = sample.shape
except (AttributeError, ValueError):
# Sample is a sequence of 1D arrays.
sample = _as_quantities(*sample)
sample_units = [s.unit for s in sample]
sample = [s.value for s in sample]
D = len(sample)
else:
sample = _as_quantity(sample)
sample_units = [sample.unit] * D
try:
M = len(bins)
except TypeError:
# bins should be an integer
from astropy.units import Quantity
if isinstance(bins, Quantity):
raise NotImplementedError
else:
if M != D:
raise ValueError(
'The dimension of bins must be equal to the dimension of the '
' sample x.')
bins = [_check_bins(b, unit)
for (b, unit) in zip(bins, sample_units)]
if density:
unit = functools.reduce(operator.truediv, sample_units, (unit or 1))
return ((sample, bins, range), {'weights': weights, 'density': density},
(unit, sample_units), None)
@function_helper
def diff(a, n=1, axis=-1, prepend=np._NoValue, append=np._NoValue):
a = _as_quantity(a)
if prepend is not np._NoValue:
prepend = _as_quantity(prepend).to_value(a.unit)
if append is not np._NoValue:
append = _as_quantity(append).to_value(a.unit)
return (a.value, n, axis, prepend, append), {}, a.unit, None
@function_helper
def gradient(f, *varargs, **kwargs):
f = _as_quantity(f)
axis = kwargs.get('axis', None)
if axis is None:
n_axis = f.ndim
elif isinstance(axis, tuple):
n_axis = len(axis)
else:
n_axis = 1
if varargs:
varargs = _as_quantities(*varargs)
if len(varargs) == 1 and n_axis > 1:
varargs = varargs * n_axis
if varargs:
units = [f.unit / q.unit for q in varargs]
varargs = tuple(q.value for q in varargs)
else:
units = [f.unit] * n_axis
if len(units) == 1:
units = units[0]
return (f.value,) + varargs, kwargs, units, None
@function_helper
def logspace(start, stop, *args, **kwargs):
from astropy.units import LogQuantity, dex
if (not isinstance(start, LogQuantity) or
not isinstance(stop, LogQuantity)):
raise NotImplementedError
# Get unit from end point as for linspace.
stop = stop.to(dex(stop.unit.physical_unit))
start = start.to(stop.unit)
unit = stop.unit.physical_unit
return (start.value, stop.value) + args, kwargs, unit, None
@function_helper
def geomspace(start, stop, *args, **kwargs):
# Get unit from end point as for linspace.
(stop, start), unit = _quantities2arrays(stop, start)
return (start, stop) + args, kwargs, unit, None
@function_helper
def interp(x, xp, fp, *args, **kwargs):
from astropy.units import Quantity
(x, xp), _ = _quantities2arrays(x, xp)
if isinstance(fp, Quantity):
unit = fp.unit
fp = fp.value
else:
unit = None
return (x, xp, fp) + args, kwargs, unit, None
@function_helper
def unique(ar, return_index=False, return_inverse=False,
return_counts=False, axis=None):
unit = ar.unit
n_index = sum(bool(i) for i in
(return_index, return_inverse, return_counts))
if n_index:
unit = [unit] + n_index * [None]
return (ar.value, return_index, return_inverse, return_counts,
axis), {}, unit, None
@function_helper
def intersect1d(ar1, ar2, assume_unique=False, return_indices=False):
(ar1, ar2), unit = _quantities2arrays(ar1, ar2)
if return_indices:
unit = [unit, None, None]
return (ar1, ar2, assume_unique, return_indices), {}, unit, None
@function_helper(helps=(np.setxor1d, np.union1d, np.setdiff1d))
def twosetop(ar1, ar2, *args, **kwargs):
(ar1, ar2), unit = _quantities2arrays(ar1, ar2)
return (ar1, ar2) + args, kwargs, unit, None
@function_helper(helps=(np.isin, np.in1d))
def setcheckop(ar1, ar2, *args, **kwargs):
# This tests whether ar1 is in ar2, so we should change the unit of
# a1 to that of a2.
(ar2, ar1), unit = _quantities2arrays(ar2, ar1)
return (ar1, ar2) + args, kwargs, None, None
@dispatched_function
def apply_over_axes(func, a, axes):
# Copied straight from numpy/lib/shape_base, just to omit its
# val = asarray(a); if only it had been asanyarray, or just not there
# since a is assumed to an an array in the next line...
# Which is what we do here - we can only get here if it is a Quantity.
val = a
N = a.ndim
if np.array(axes).ndim == 0:
axes = (axes,)
for axis in axes:
if axis < 0:
axis = N + axis
args = (val, axis)
res = func(*args)
if res.ndim == val.ndim:
val = res
else:
res = np.expand_dims(res, axis)
if res.ndim == val.ndim:
val = res
else:
raise ValueError("function is not returning "
"an array of the correct shape")
# Returning unit is None to signal nothing should happen to
# the output.
return val, None, None
@dispatched_function
def array_repr(arr, *args, **kwargs):
# TODO: The addition of "unit='...'" doesn't worry about line
# length. Could copy & adapt _array_repr_implementation from
# numpy.core.arrayprint.py
cls_name = arr.__class__.__name__
fake_name = '_' * len(cls_name)
fake_cls = type(fake_name, (np.ndarray,), {})
no_unit = np.array_repr(arr.view(fake_cls),
*args, **kwargs).replace(fake_name, cls_name)
unit_part = f"unit='{arr.unit}'"
pre, dtype, post = no_unit.rpartition('dtype')
if dtype:
return f"{pre}{unit_part}, {dtype}{post}", None, None
else:
return f"{no_unit[:-1]}, {unit_part})", None, None
@dispatched_function
def array_str(arr, *args, **kwargs):
# TODO: The addition of the unit doesn't worry about line length.
# Could copy & adapt _array_repr_implementation from
# numpy.core.arrayprint.py
no_unit = np.array_str(arr.value, *args, **kwargs)
return no_unit + arr._unitstr, None, None
@function_helper
def array2string(a, *args, **kwargs):
# array2string breaks on quantities as it tries to turn individual
# items into float, which works only for dimensionless. Since the
# defaults would not keep any unit anyway, this is rather pointless -
# we're better off just passing on the array view. However, one can
# also work around this by passing on a formatter (as is done in Angle).
# So, we do nothing if the formatter argument is present and has the
# relevant formatter for our dtype.
formatter = args[6] if len(args) >= 7 else kwargs.get('formatter', None)
if formatter is None:
a = a.value
else:
# See whether it covers our dtype.
from numpy.core.arrayprint import _get_format_function
with np.printoptions(formatter=formatter) as options:
try:
ff = _get_format_function(a.value, **options)
except Exception:
# Shouldn't happen, but possibly we're just not being smart
# enough, so let's pass things on as is.
pass
else:
# If the selected format function is that of numpy, we know
# things will fail
if 'numpy' in ff.__module__:
a = a.value
return (a,) + args, kwargs, None, None
@function_helper
def diag(v, *args, **kwargs):
# Function works for *getting* the diagonal, but not *setting*.
# So, override always.
return (v.value,) + args, kwargs, v.unit, None
@function_helper(module=np.linalg)
def svd(a, full_matrices=True, compute_uv=True, hermitian=False):
unit = a.unit
if compute_uv:
unit = (None, unit, None)
return ((a.view(np.ndarray), full_matrices, compute_uv, hermitian),
{}, unit, None)
def _interpret_tol(tol, unit):
from astropy.units import Quantity
return Quantity(tol, unit).value
@function_helper(module=np.linalg)
def matrix_rank(M, tol=None, *args, **kwargs):
if tol is not None:
tol = _interpret_tol(tol, M.unit)
return (M.view(np.ndarray), tol) + args, kwargs, None, None
@function_helper(helps={np.linalg.inv, np.linalg.tensorinv})
def inv(a, *args, **kwargs):
return (a.view(np.ndarray),)+args, kwargs, 1/a.unit, None
@function_helper(module=np.linalg)
def pinv(a, rcond=1e-15, *args, **kwargs):
rcond = _interpret_tol(rcond, a.unit)
return (a.view(np.ndarray), rcond) + args, kwargs, 1/a.unit, None
@function_helper(module=np.linalg)
def det(a):
return (a.view(np.ndarray),), {}, a.unit ** a.shape[-1], None
@function_helper(helps={np.linalg.solve, np.linalg.tensorsolve})
def solve(a, b, *args, **kwargs):
a, b = _as_quantities(a, b)
return ((a.view(np.ndarray), b.view(np.ndarray)) + args, kwargs,
b.unit / a.unit, None)
@function_helper(module=np.linalg)
def lstsq(a, b, rcond="warn"):
a, b = _as_quantities(a, b)
if rcond not in (None, "warn", -1):
rcond = _interpret_tol(rcond, a.unit)
return ((a.view(np.ndarray), b.view(np.ndarray), rcond), {},
(b.unit / a.unit, b.unit ** 2, None, a.unit), None)
@function_helper(module=np.linalg)
def norm(x, ord=None, *args, **kwargs):
if ord == 0:
from astropy.units import dimensionless_unscaled
unit = dimensionless_unscaled
else:
unit = x.unit
return (x.view(np.ndarray), ord)+args, kwargs, unit, None
@function_helper(module=np.linalg)
def matrix_power(a, n):
return (a.value, n), {}, a.unit ** n, None
@function_helper(module=np.linalg)
def cholesky(a):
return (a.value,), {}, a.unit ** 0.5, None
@function_helper(module=np.linalg)
def qr(a, mode='reduced'):
if mode.startswith('e'):
units = None
elif mode == 'r':
units = a.unit
else:
from astropy.units import dimensionless_unscaled
units = (dimensionless_unscaled, a.unit)
return (a.value, mode), {}, units, None
@function_helper(helps={np.linalg.eig, np.linalg.eigh})
def eig(a, *args, **kwargs):
from astropy.units import dimensionless_unscaled
return (a.value,)+args, kwargs, (a.unit, dimensionless_unscaled), None
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
3909,
1334,
282,
650,
13,
8501,
6289,
3449,
4190,
14,
1666,
5113,
14,
8332,
871,
199,
3,
367,
4184,
7662,
1768,
1146,
465,
3769,
334,
9629,
590,
9,
6866,
402,
2680,
199,
3,
12591,
27,
367,
5204,
12,
1937,
12378,
15,
1440,
1658,
57,
63,
3961,
14,
8332,
14,
199,
624,
4433,
83,
367,
18972,
2680,
3423,
14,
199,
199,
6004,
4278,
2680,
3423,
315,
28157,
1810,
7537,
14,
5260,
14,
19703,
855,
1144,
63,
1593,
363,
2313,
199,
607,
642,
859,
12,
314,
2680,
3423,
787,
3715,
315,
11648,
4652,
12,
1924,
402,
199,
6777,
965,
376,
4568,
658,
409,
64,
503,
658,
807,
8340,
199,
199,
17,
14,
7605,
6885,
63,
27657,
63,
29865,
334,
409,
395,
340,
314,
2680,
4514,
2043,
5171,
31951,
27,
781,
986,
641,
370,
6800,
855,
1144,
63,
1593,
4343,
199,
18,
14,
32744,
63,
17930,
3960,
334,
807,
395,
340,
314,
2680,
4514,
365,
18025,
2043,
2410,
13806,
13621,
1417,
370,
6572,
543,
11233,
6204,
12,
2043,
436,
12570,
4260,
6204,
641,
314,
754,
14,
199,
19,
14,
7587,
17073,
1149,
63,
29865,
334,
807,
395,
340,
314,
805,
7704,
12249,
1325,
2043,
5074,
282,
31951,
13,
6100,
4514,
199,
20,
14,
32708,
2160,
3657,
1149,
63,
29865,
334,
409,
395,
340,
314,
805,
1630,
440,
1852,
12249,
14,
199,
199,
1858,
314,
32744,
63,
17930,
3960,
658,
807,
3559,
314,
574,
365,
282,
805,
626,
1630,
314,
199,
3248,
8603,
14,
221,
2779,
1077,
5452,
314,
2011,
2368,
465,
314,
2680,
199,
1593,
3955,
334,
15401,
1373,
883,
675,
1124,
10,
589,
1040,
436,
1124,
538,
958,
16580,
436,
199,
1107,
282,
2008,
402,
1124,
589,
12,
2074,
12,
4137,
12,
734,
4542,
2382,
1124,
589,
1040,
436,
199,
1040,
958,
1040,
911,
506,
911,
506,
3032,
641,
370,
314,
2680,
4514,
12,
199,
1040,
3248,
1040,
365,
282,
3962,
4137,
402,
314,
754,
13493,
403,
64,
340,
652,
1077,
440,
506,
199,
22818,
370,
31951,
395,
436,
1124,
548,
1040,
365,
282,
3962,
1072,
31951,
3032,
199,
262,
12,
1314,
911,
506,
13457,
315,
13,
2778,
14,
199,
199,
1858,
314,
7587,
17073,
1149,
63,
29865,
658,
807,
3559,
314,
574,
365,
282,
805,
626,
199,
24900,
314,
2680,
9330,
367,
31951,
1324,
14,
2779,
1077,
199,
1107,
282,
2008,
402,
1124,
1099,
12,
4137,
12,
734,
4542,
2382,
1124,
1099,
1040,
365,
16711,
199,
65,
8971,
1625,
543,
314,
754,
12,
436,
1124,
3248,
1040,
436,
1124,
548,
1040,
787,
465,
3432,
14,
199,
3917,
4137,
365,
658,
403,
3559,
754,
7545,
2138,
5370,
12,
880,
1373,
883,
2597,
199,
1107,
282,
31951,
5370,
1808,
1124,
10577,
63,
1099,
12,
488,
12,
488,
4345,
199,
199,
624,
199,
199,
646,
9143,
199,
646,
4182,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
28753,
14,
5260,
14,
1018,
492,
334,
272,
1910,
1405,
547,
12,
12008,
4333,
12,
6240,
2003,
63,
324,
15120,
9,
199,
504,
28753,
14,
1208,
14,
5819,
492,
653,
22759,
57,
63,
17090,
63,
17,
63,
1196,
12,
653,
22759,
57,
63,
17090,
63,
17,
63,
1085,
199,
504,
28753,
14,
1208,
492,
284,
2124,
6842,
421,
199,
692,
653,
22759,
57,
63,
17090,
63,
17,
63,
1196,
26,
221,
327,
11942,
26,
949,
8486,
272,
327,
876,
413,
14,
975,
12,
10580,
14,
647,
8103,
440,
2187,
27,
315,
413,
14,
975,
12,
652,
30482,
12,
1325,
272,
327,
636,
1144,
63,
1593,
363,
10580,
4898,
19136,
2331,
701,
849,
14,
272,
4160,
2847,
57,
63,
15476,
63,
15704,
275,
334,
11161,
8,
1590,
14,
1018,
12,
283,
12867,
358,
436,
2892,
980,
14,
1018,
14,
12867,
14,
8898,
63,
12322,
63,
15476,
9,
199,
2836,
26,
272,
327,
1010,
413,
14,
1196,
12,
10580,
787,
5223,
701,
849,
12,
1325,
652,
365,
5139,
3962,
370,
272,
327,
7485,
3062,
2331,
1808,
376,
3734,
1750,
14,
221,
2136,
675,
2519,
3967,
652,
272,
327,
365,
1620,
9386,
370,
2813,
626,
31077,
315,
2945,
2680,
5459,
14,
272,
4160,
2847,
57,
63,
15476,
63,
15704,
275,
2519,
8,
1590,
14,
1018,
14,
12867,
12,
3660,
283,
8898,
63,
12322,
63,
15476,
297,
715,
9,
199,
6348,
6885,
63,
27657,
63,
29865,
275,
663,
342,
199,
624,
13967,
543,
12591,
21038,
9180,
2839,
31951,
1041,
199,
15476,
63,
17930,
3960,
275,
1052,
199,
624,
13967,
543,
12591,
18025,
543,
5576,
4137,
8603,
1041,
199,
32550,
1149,
63,
29865,
275,
1052,
199,
624,
13967,
367,
1314,
781,
5647,
4154,
5705,
4514,
1041,
199,
1734,
15925,
63,
29865,
275,
663,
342,
199,
624,
13967,
626,
3913,
4334,
9312,
506,
1202,
543,
13621,
1417,
1041,
199,
199,
6348,
6885,
63,
27657,
63,
29865,
8901,
469,
272,
980,
14,
1392,
12,
980,
14,
890,
12,
980,
14,
8322,
12,
272,
980,
14,
5217,
12,
980,
14,
11186,
12,
980,
14,
1185,
3127,
12,
980,
14,
8459,
416,
7291,
12,
980,
14,
24262,
387,
12908,
12,
272,
980,
14,
10483,
12,
980,
14,
22900,
63,
17,
68,
12,
980,
14,
22900,
63,
18,
68,
12,
980,
14,
22900,
63,
19,
68,
12,
272,
980,
14,
4441,
63,
5380,
12,
980,
14,
16597,
12,
980,
14,
10786,
63,
475,
12,
980,
14,
10786,
63,
10095,
12,
272,
980,
14,
16114,
12,
980,
14,
70,
317,
1168,
82,
12,
980,
14,
16114,
1181,
12,
980,
14,
4571,
2710,
12,
272,
980,
14,
26488,
12,
980,
14,
16383,
12,
980,
14,
20188,
12,
980,
14,
3113,
3191,
12,
980,
14,
31698,
12,
272,
980,
14,
10262,
12,
980,
14,
1273,
4509,
12,
980,
14,
7088,
10262,
12,
272,
980,
14,
6706,
63,
4108,
63,
504,
12,
980,
14,
599,
85,
63,
4108,
63,
504,
12,
980,
14,
32135,
63,
4108,
63,
504,
12,
272,
980,
14,
3093,
12,
980,
14,
14688,
12,
980,
14,
20057,
12,
980,
14,
6706,
7088,
12,
272,
980,
14,
1667,
63,
2930,
12,
980,
14,
4250,
63,
2930,
12,
272,
980,
14,
6447,
12,
980,
14,
5005,
12,
980,
14,
1807,
12,
980,
14,
12263,
63,
4250,
12,
980,
14,
2827,
12,
980,
14,
11066,
12,
272,
980,
14,
524,
12,
980,
14
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
3909,
1334,
282,
650,
13,
8501,
6289,
3449,
4190,
14,
1666,
5113,
14,
8332,
871,
199,
3,
367,
4184,
7662,
1768,
1146,
465,
3769,
334,
9629,
590,
9,
6866,
402,
2680,
199,
3,
12591,
27,
367,
5204,
12,
1937,
12378,
15,
1440,
1658,
57,
63,
3961,
14,
8332,
14,
199,
624,
4433,
83,
367,
18972,
2680,
3423,
14,
199,
199,
6004,
4278,
2680,
3423,
315,
28157,
1810,
7537,
14,
5260,
14,
19703,
855,
1144,
63,
1593,
363,
2313,
199,
607,
642,
859,
12,
314,
2680,
3423,
787,
3715,
315,
11648,
4652,
12,
1924,
402,
199,
6777,
965,
376,
4568,
658,
409,
64,
503,
658,
807,
8340,
199,
199,
17,
14,
7605,
6885,
63,
27657,
63,
29865,
334,
409,
395,
340,
314,
2680,
4514,
2043,
5171,
31951,
27,
781,
986,
641,
370,
6800,
855,
1144,
63,
1593,
4343,
199,
18,
14,
32744,
63,
17930,
3960,
334,
807,
395,
340,
314,
2680,
4514,
365,
18025,
2043,
2410,
13806,
13621,
1417,
370,
6572,
543,
11233,
6204,
12,
2043,
436,
12570,
4260,
6204,
641,
314,
754,
14,
199,
19,
14,
7587,
17073,
1149,
63,
29865,
334,
807,
395,
340,
314,
805,
7704,
12249,
1325,
2043,
5074,
282,
31951,
13,
6100,
4514,
199,
20,
14,
32708,
2160,
3657,
1149,
63,
29865,
334,
409,
395,
340,
314,
805,
1630,
440,
1852,
12249,
14,
199,
199,
1858,
314,
32744,
63,
17930,
3960,
658,
807,
3559,
314,
574,
365,
282,
805,
626,
1630,
314,
199,
3248,
8603,
14,
221,
2779,
1077,
5452,
314,
2011,
2368,
465,
314,
2680,
199,
1593,
3955,
334,
15401,
1373,
883,
675,
1124,
10,
589,
1040,
436,
1124,
538,
958,
16580,
436,
199,
1107,
282,
2008,
402,
1124,
589,
12,
2074,
12,
4137,
12,
734,
4542,
2382,
1124,
589,
1040,
436,
199,
1040,
958,
1040,
911,
506,
911,
506,
3032,
641,
370,
314,
2680,
4514,
12,
199,
1040,
3248,
1040,
365,
282,
3962,
4137,
402,
314,
754,
13493,
403,
64,
340,
652,
1077,
440,
506,
199,
22818,
370,
31951,
395,
436,
1124,
548,
1040,
365,
282,
3962,
1072,
31951,
3032,
199,
262,
12,
1314,
911,
506,
13457,
315,
13,
2778,
14,
199,
199,
1858,
314,
7587,
17073,
1149,
63,
29865,
658,
807,
3559,
314,
574,
365,
282,
805,
626,
199,
24900,
314,
2680,
9330,
367,
31951,
1324,
14,
2779,
1077,
199,
1107,
282,
2008,
402,
1124,
1099,
12,
4137,
12,
734,
4542,
2382,
1124,
1099,
1040,
365,
16711,
199,
65,
8971,
1625,
543,
314,
754,
12,
436,
1124,
3248,
1040,
436,
1124,
548,
1040,
787,
465,
3432,
14,
199,
3917,
4137,
365,
658,
403,
3559,
754,
7545,
2138,
5370,
12,
880,
1373,
883,
2597,
199,
1107,
282,
31951,
5370,
1808,
1124,
10577,
63,
1099,
12,
488,
12,
488,
4345,
199,
199,
624,
199,
199,
646,
9143,
199,
646,
4182,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
28753,
14,
5260,
14,
1018,
492,
334,
272,
1910,
1405,
547,
12,
12008,
4333,
12,
6240,
2003,
63,
324,
15120,
9,
199,
504,
28753,
14,
1208,
14,
5819,
492,
653,
22759,
57,
63,
17090,
63,
17,
63,
1196,
12,
653,
22759,
57,
63,
17090,
63,
17,
63,
1085,
199,
504,
28753,
14,
1208,
492,
284,
2124,
6842,
421,
199,
692,
653,
22759,
57,
63,
17090,
63,
17,
63,
1196,
26,
221,
327,
11942,
26,
949,
8486,
272,
327,
876,
413,
14,
975,
12,
10580,
14,
647,
8103,
440,
2187,
27,
315,
413,
14,
975,
12,
652,
30482,
12,
1325,
272,
327,
636,
1144,
63,
1593,
363,
10580,
4898,
19136,
2331,
701,
849,
14,
272,
4160,
2847,
57,
63,
15476,
63,
15704,
275,
334,
11161,
8,
1590,
14,
1018,
12,
283,
12867,
358,
436,
2892,
980,
14,
1018,
14,
12867,
14,
8898,
63,
12322,
63,
15476,
9,
199,
2836,
26,
272,
327,
1010,
413,
14,
1196,
12,
10580,
787,
5223,
701,
849,
12,
1325,
652,
365,
5139,
3962,
370,
272,
327,
7485,
3062,
2331,
1808,
376,
3734,
1750,
14,
221,
2136,
675,
2519,
3967,
652,
272,
327,
365,
1620,
9386,
370,
2813,
626,
31077,
315,
2945,
2680,
5459,
14,
272,
4160,
2847,
57,
63,
15476,
63,
15704,
275,
2519,
8,
1590,
14,
1018,
14,
12867,
12,
3660,
283,
8898,
63,
12322,
63,
15476,
297,
715,
9,
199,
6348,
6885,
63,
27657,
63,
29865,
275,
663,
342,
199,
624,
13967,
543,
12591,
21038,
9180,
2839,
31951,
1041,
199,
15476,
63,
17930,
3960,
275,
1052,
199,
624,
13967,
543,
12591,
18025,
543,
5576,
4137,
8603,
1041,
199,
32550,
1149,
63,
29865,
275,
1052,
199,
624,
13967,
367,
1314,
781,
5647,
4154,
5705,
4514,
1041,
199,
1734,
15925,
63,
29865,
275,
663,
342,
199,
624,
13967,
626,
3913,
4334,
9312,
506,
1202,
543,
13621,
1417,
1041,
199,
199,
6348,
6885,
63,
27657,
63,
29865,
8901,
469,
272,
980,
14,
1392,
12,
980,
14,
890,
12,
980,
14,
8322,
12,
272,
980,
14,
5217,
12,
980,
14,
11186,
12,
980,
14,
1185,
3127,
12,
980,
14,
8459,
416,
7291,
12,
980,
14,
24262,
387,
12908,
12,
272,
980,
14,
10483,
12,
980,
14,
22900,
63,
17,
68,
12,
980,
14,
22900,
63,
18,
68,
12,
980,
14,
22900,
63,
19,
68,
12,
272,
980,
14,
4441,
63,
5380,
12,
980,
14,
16597,
12,
980,
14,
10786,
63,
475,
12,
980,
14,
10786,
63,
10095,
12,
272,
980,
14,
16114,
12,
980,
14,
70,
317,
1168,
82,
12,
980,
14,
16114,
1181,
12,
980,
14,
4571,
2710,
12,
272,
980,
14,
26488,
12,
980,
14,
16383,
12,
980,
14,
20188,
12,
980,
14,
3113,
3191,
12,
980,
14,
31698,
12,
272,
980,
14,
10262,
12,
980,
14,
1273,
4509,
12,
980,
14,
7088,
10262,
12,
272,
980,
14,
6706,
63,
4108,
63,
504,
12,
980,
14,
599,
85,
63,
4108,
63,
504,
12,
980,
14,
32135,
63,
4108,
63,
504,
12,
272,
980,
14,
3093,
12,
980,
14,
14688,
12,
980,
14,
20057,
12,
980,
14,
6706,
7088,
12,
272,
980,
14,
1667,
63,
2930,
12,
980,
14,
4250,
63,
2930,
12,
272,
980,
14,
6447,
12,
980,
14,
5005,
12,
980,
14,
1807,
12,
980,
14,
12263,
63,
4250,
12,
980,
14,
2827,
12,
980,
14,
11066,
12,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,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
xflin/spark
|
examples/src/main/python/ml/onehot_encoder_example.py
|
72
|
1605
|
#
# 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 __future__ import print_function
# $example on$
from pyspark.ml.feature import OneHotEncoder, StringIndexer
# $example off$
from pyspark.sql import SparkSession
if __name__ == "__main__":
spark = SparkSession\
.builder\
.appName("OneHotEncoderExample")\
.getOrCreate()
# $example on$
df = spark.createDataFrame([
(0, "a"),
(1, "b"),
(2, "c"),
(3, "a"),
(4, "a"),
(5, "c")
], ["id", "category"])
stringIndexer = StringIndexer(inputCol="category", outputCol="categoryIndex")
model = stringIndexer.fit(df)
indexed = model.transform(df)
encoder = OneHotEncoder(inputCol="categoryIndex", outputCol="categoryVec")
encoded = encoder.transform(indexed)
encoded.show()
# $example off$
spark.stop()
|
apache-2.0
|
[
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
3,
2672,
2694,
641,
4,
199,
504,
15847,
14,
757,
14,
4445,
492,
7309,
19942,
6679,
12,
2624,
32275,
199,
3,
2672,
2694,
2331,
4,
199,
504,
15847,
14,
3009,
492,
13932,
4434,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
15442,
275,
13932,
4434,
60,
267,
1275,
5649,
60,
267,
1275,
571,
985,
480,
4395,
19942,
6679,
9846,
27681,
267,
1275,
30457,
2499,
342,
339,
327,
2672,
2694,
641,
4,
272,
4051,
275,
15442,
14,
25482,
779,
267,
334,
16,
12,
298,
65,
1288,
267,
334,
17,
12,
298,
66,
1288,
267,
334,
18,
12,
298,
67,
1288,
267,
334,
19,
12,
298,
65,
1288,
267,
334,
20,
12,
298,
65,
1288,
267,
334,
21,
12,
298,
67,
531,
272,
2156,
2097,
344,
401,
298,
3710,
3135,
339,
1059,
32275,
275,
2624,
32275,
8,
1210,
2001,
628,
3710,
401,
1072,
2001,
628,
3710,
2681,
531,
272,
1402,
275,
1059,
32275,
14,
3269,
8,
1587,
9,
272,
15235,
275,
1402,
14,
4711,
8,
1587,
9,
339,
10295,
275,
7309,
19942,
6679,
8,
1210,
2001,
628,
3710,
2681,
401,
1072,
2001,
628,
3710,
14373,
531,
272,
5737,
275,
10295,
14,
4711,
8,
16821,
9,
272,
5737,
14,
2384,
342,
272,
327,
2672,
2694,
2331,
4,
339,
15442,
14,
2379,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
3,
2672,
2694,
641,
4,
199,
504,
15847,
14,
757,
14,
4445,
492,
7309,
19942,
6679,
12,
2624,
32275,
199,
3,
2672,
2694,
2331,
4,
199,
504,
15847,
14,
3009,
492,
13932,
4434,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
15442,
275,
13932,
4434,
60,
267,
1275,
5649,
60,
267,
1275,
571,
985,
480,
4395,
19942,
6679,
9846,
27681,
267,
1275,
30457,
2499,
342,
339,
327,
2672,
2694,
641,
4,
272,
4051,
275,
15442,
14,
25482,
779,
267,
334,
16,
12,
298,
65,
1288,
267,
334,
17,
12,
298,
66,
1288,
267,
334,
18,
12,
298,
67,
1288,
267,
334,
19,
12,
298,
65,
1288,
267,
334,
20,
12,
298,
65,
1288,
267,
334,
21,
12,
298,
67,
531,
272,
2156,
2097,
344,
401,
298,
3710,
3135,
339,
1059,
32275,
275,
2624,
32275,
8,
1210,
2001,
628,
3710,
401,
1072,
2001,
628,
3710,
2681,
531,
272,
1402,
275,
1059,
32275,
14,
3269,
8,
1587,
9,
272,
15235,
275,
1402,
14,
4711,
8,
1587,
9,
339,
10295,
275,
7309,
19942,
6679,
8,
1210,
2001,
628,
3710,
2681,
401,
1072,
2001,
628,
3710,
14373,
531,
272,
5737,
275,
10295,
14,
4711,
8,
16821,
9,
272,
5737,
14,
2384,
342,
272,
327,
2672,
2694,
2331,
4,
339,
15442,
14,
2379,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
trudikampfschaf/flask-microblog
|
flask/lib/python2.7/site-packages/jinja2/utils.py
|
598
|
16165
|
# -*- coding: utf-8 -*-
"""
jinja2.utils
~~~~~~~~~~~~
Utility functions.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import re
import errno
from collections import deque
from jinja2._compat import text_type, string_types, implements_iterator, \
allocate_lock, url_quote
_word_split_re = re.compile(r'(\s+)')
_punctuation_re = re.compile(
'^(?P<lead>(?:%s)*)(?P<middle>.*?)(?P<trail>(?:%s)*)$' % (
'|'.join(map(re.escape, ('(', '<', '<'))),
'|'.join(map(re.escape, ('.', ',', ')', '>', '\n', '>')))
)
)
_simple_email_re = re.compile(r'^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$')
_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
_entity_re = re.compile(r'&([^;]+);')
_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
_digits = '0123456789'
# special singleton representing missing values for the runtime
missing = type('MissingType', (), {'__repr__': lambda x: 'missing'})()
# internal code
internal_code = set()
concat = u''.join
def contextfunction(f):
"""This decorator can be used to mark a function or method context callable.
A context callable is passed the active :class:`Context` as first argument when
called from the template. This is useful if a function wants to get access
to the context or functions provided on the context object. For example
a function that returns a sorted list of template variables the current
template exports could look like this::
@contextfunction
def get_exported_names(context):
return sorted(context.exported_vars)
"""
f.contextfunction = True
return f
def evalcontextfunction(f):
"""This decorator can be used to mark a function or method as an eval
context callable. This is similar to the :func:`contextfunction`
but instead of passing the context, an evaluation context object is
passed. For more information about the eval context, see
:ref:`eval-context`.
.. versionadded:: 2.4
"""
f.evalcontextfunction = True
return f
def environmentfunction(f):
"""This decorator can be used to mark a function or method as environment
callable. This decorator works exactly like the :func:`contextfunction`
decorator just that the first argument is the active :class:`Environment`
and not context.
"""
f.environmentfunction = True
return f
def internalcode(f):
"""Marks the function as internally used"""
internal_code.add(f.__code__)
return f
def is_undefined(obj):
"""Check if the object passed is undefined. This does nothing more than
performing an instance check against :class:`Undefined` but looks nicer.
This can be used for custom filters or tests that want to react to
undefined variables. For example a custom default filter can look like
this::
def default(var, default=''):
if is_undefined(var):
return default
return var
"""
from jinja2.runtime import Undefined
return isinstance(obj, Undefined)
def consume(iterable):
"""Consumes an iterable without doing anything with it."""
for event in iterable:
pass
def clear_caches():
"""Jinja2 keeps internal caches for environments and lexers. These are
used so that Jinja2 doesn't have to recreate environments and lexers all
the time. Normally you don't have to care about that but if you are
messuring memory consumption you may want to clean the caches.
"""
from jinja2.environment import _spontaneous_environments
from jinja2.lexer import _lexer_cache
_spontaneous_environments.clear()
_lexer_cache.clear()
def import_string(import_name, silent=False):
"""Imports an object based on a string. This is useful if you want to
use import paths as endpoints or something similar. An import path can
be specified either in dotted notation (``xml.sax.saxutils.escape``)
or with a colon as object delimiter (``xml.sax.saxutils:escape``).
If the `silent` is True the return value will be `None` if the import
fails.
:return: imported object
"""
try:
if ':' in import_name:
module, obj = import_name.split(':', 1)
elif '.' in import_name:
items = import_name.split('.')
module = '.'.join(items[:-1])
obj = items[-1]
else:
return __import__(import_name)
return getattr(__import__(module, None, None, [obj]), obj)
except (ImportError, AttributeError):
if not silent:
raise
def open_if_exists(filename, mode='rb'):
"""Returns a file descriptor for the filename if that file exists,
otherwise `None`.
"""
try:
return open(filename, mode)
except IOError as e:
if e.errno not in (errno.ENOENT, errno.EISDIR):
raise
def object_type_repr(obj):
"""Returns the name of the object's type. For some recognized
singletons the name of the object is returned instead. (For
example for `None` and `Ellipsis`).
"""
if obj is None:
return 'None'
elif obj is Ellipsis:
return 'Ellipsis'
# __builtin__ in 2.x, builtins in 3.x
if obj.__class__.__module__ in ('__builtin__', 'builtins'):
name = obj.__class__.__name__
else:
name = obj.__class__.__module__ + '.' + obj.__class__.__name__
return '%s object' % name
def pformat(obj, verbose=False):
"""Prettyprint an object. Either use the `pretty` library or the
builtin `pprint`.
"""
try:
from pretty import pretty
return pretty(obj, verbose=verbose)
except ImportError:
from pprint import pformat
return pformat(obj)
def urlize(text, trim_url_limit=None, nofollow=False):
"""Converts any URLs in text into clickable links. Works on http://,
https:// and www. links. Links can have trailing punctuation (periods,
commas, close-parens) and leading punctuation (opening parens) and
it'll still do the right thing.
If trim_url_limit is not None, the URLs in link text will be limited
to trim_url_limit characters.
If nofollow is True, the URLs in link text will get a rel="nofollow"
attribute.
"""
trim_url = lambda x, limit=trim_url_limit: limit is not None \
and (x[:limit] + (len(x) >=limit and '...'
or '')) or x
words = _word_split_re.split(text_type(escape(text)))
nofollow_attr = nofollow and ' rel="nofollow"' or ''
for i, word in enumerate(words):
match = _punctuation_re.match(word)
if match:
lead, middle, trail = match.groups()
if middle.startswith('www.') or (
'@' not in middle and
not middle.startswith('http://') and
not middle.startswith('https://') and
len(middle) > 0 and
middle[0] in _letters + _digits and (
middle.endswith('.org') or
middle.endswith('.net') or
middle.endswith('.com')
)):
middle = '<a href="http://%s"%s>%s</a>' % (middle,
nofollow_attr, trim_url(middle))
if middle.startswith('http://') or \
middle.startswith('https://'):
middle = '<a href="%s"%s>%s</a>' % (middle,
nofollow_attr, trim_url(middle))
if '@' in middle and not middle.startswith('www.') and \
not ':' in middle and _simple_email_re.match(middle):
middle = '<a href="mailto:%s">%s</a>' % (middle, middle)
if lead + middle + trail != word:
words[i] = lead + middle + trail
return u''.join(words)
def generate_lorem_ipsum(n=5, html=True, min=20, max=100):
"""Generate some lorem impsum for the template."""
from jinja2.constants import LOREM_IPSUM_WORDS
from random import choice, randrange
words = LOREM_IPSUM_WORDS.split()
result = []
for _ in range(n):
next_capitalized = True
last_comma = last_fullstop = 0
word = None
last = None
p = []
# each paragraph contains out of 20 to 100 words.
for idx, _ in enumerate(range(randrange(min, max))):
while True:
word = choice(words)
if word != last:
last = word
break
if next_capitalized:
word = word.capitalize()
next_capitalized = False
# add commas
if idx - randrange(3, 8) > last_comma:
last_comma = idx
last_fullstop += 2
word += ','
# add end of sentences
if idx - randrange(10, 20) > last_fullstop:
last_comma = last_fullstop = idx
word += '.'
next_capitalized = True
p.append(word)
# ensure that the paragraph ends with a dot.
p = u' '.join(p)
if p.endswith(','):
p = p[:-1] + '.'
elif not p.endswith('.'):
p += '.'
result.append(p)
if not html:
return u'\n\n'.join(result)
return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result))
def unicode_urlencode(obj, charset='utf-8'):
"""URL escapes a single bytestring or unicode string with the
given charset if applicable to URL safe quoting under all rules
that need to be considered under all supported Python versions.
If non strings are provided they are converted to their unicode
representation first.
"""
if not isinstance(obj, string_types):
obj = text_type(obj)
if isinstance(obj, text_type):
obj = obj.encode(charset)
return text_type(url_quote(obj))
class LRUCache(object):
"""A simple LRU Cache implementation."""
# this is fast for small capacities (something below 1000) but doesn't
# scale. But as long as it's only used as storage for templates this
# won't do any harm.
def __init__(self, capacity):
self.capacity = capacity
self._mapping = {}
self._queue = deque()
self._postinit()
def _postinit(self):
# alias all queue methods for faster lookup
self._popleft = self._queue.popleft
self._pop = self._queue.pop
self._remove = self._queue.remove
self._wlock = allocate_lock()
self._append = self._queue.append
def __getstate__(self):
return {
'capacity': self.capacity,
'_mapping': self._mapping,
'_queue': self._queue
}
def __setstate__(self, d):
self.__dict__.update(d)
self._postinit()
def __getnewargs__(self):
return (self.capacity,)
def copy(self):
"""Return a shallow copy of the instance."""
rv = self.__class__(self.capacity)
rv._mapping.update(self._mapping)
rv._queue = deque(self._queue)
return rv
def get(self, key, default=None):
"""Return an item from the cache dict or `default`"""
try:
return self[key]
except KeyError:
return default
def setdefault(self, key, default=None):
"""Set `default` if the key is not in the cache otherwise
leave unchanged. Return the value of this key.
"""
self._wlock.acquire()
try:
try:
return self[key]
except KeyError:
self[key] = default
return default
finally:
self._wlock.release()
def clear(self):
"""Clear the cache."""
self._wlock.acquire()
try:
self._mapping.clear()
self._queue.clear()
finally:
self._wlock.release()
def __contains__(self, key):
"""Check if a key exists in this cache."""
return key in self._mapping
def __len__(self):
"""Return the current size of the cache."""
return len(self._mapping)
def __repr__(self):
return '<%s %r>' % (
self.__class__.__name__,
self._mapping
)
def __getitem__(self, key):
"""Get an item from the cache. Moves the item up so that it has the
highest priority then.
Raise a `KeyError` if it does not exist.
"""
self._wlock.acquire()
try:
rv = self._mapping[key]
if self._queue[-1] != key:
try:
self._remove(key)
except ValueError:
# if something removed the key from the container
# when we read, ignore the ValueError that we would
# get otherwise.
pass
self._append(key)
return rv
finally:
self._wlock.release()
def __setitem__(self, key, value):
"""Sets the value for an item. Moves the item up so that it
has the highest priority then.
"""
self._wlock.acquire()
try:
if key in self._mapping:
self._remove(key)
elif len(self._mapping) == self.capacity:
del self._mapping[self._popleft()]
self._append(key)
self._mapping[key] = value
finally:
self._wlock.release()
def __delitem__(self, key):
"""Remove an item from the cache dict.
Raise a `KeyError` if it does not exist.
"""
self._wlock.acquire()
try:
del self._mapping[key]
try:
self._remove(key)
except ValueError:
# __getitem__ is not locked, it might happen
pass
finally:
self._wlock.release()
def items(self):
"""Return a list of items."""
result = [(key, self._mapping[key]) for key in list(self._queue)]
result.reverse()
return result
def iteritems(self):
"""Iterate over all items."""
return iter(self.items())
def values(self):
"""Return a list of all values."""
return [x[1] for x in self.items()]
def itervalue(self):
"""Iterate over all values."""
return iter(self.values())
def keys(self):
"""Return a list of all keys ordered by most recent usage."""
return list(self)
def iterkeys(self):
"""Iterate over all keys in the cache dict, ordered by
the most recent usage.
"""
return reversed(tuple(self._queue))
__iter__ = iterkeys
def __reversed__(self):
"""Iterate over the values in the cache dict, oldest items
coming first.
"""
return iter(tuple(self._queue))
__copy__ = copy
# register the LRU cache as mutable mapping if possible
try:
from collections import MutableMapping
MutableMapping.register(LRUCache)
except ImportError:
pass
@implements_iterator
class Cycler(object):
"""A cycle helper for templates."""
def __init__(self, *items):
if not items:
raise RuntimeError('at least one item has to be provided')
self.items = items
self.reset()
def reset(self):
"""Resets the cycle."""
self.pos = 0
@property
def current(self):
"""Returns the current item."""
return self.items[self.pos]
def __next__(self):
"""Goes one item ahead and returns it."""
rv = self.current
self.pos = (self.pos + 1) % len(self.items)
return rv
class Joiner(object):
"""A joining helper for templates."""
def __init__(self, sep=u', '):
self.sep = sep
self.used = False
def __call__(self):
if not self.used:
self.used = True
return u''
return self.sep
# Imported here because that's where it was in the past
from markupsafe import Markup, escape, soft_unicode
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
1208,
272,
32202,
339,
20511,
3423,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
646,
295,
199,
646,
7554,
199,
504,
5055,
492,
15782,
199,
504,
10321,
18,
423,
5819,
492,
1318,
63,
466,
12,
1059,
63,
1313,
12,
9031,
63,
5778,
12,
971,
1362,
18310,
63,
831,
12,
1166,
63,
3513,
421,
199,
63,
1027,
63,
1294,
63,
264,
275,
295,
14,
2014,
8,
82,
13445,
83,
11,
5942,
199,
63,
25181,
63,
264,
275,
295,
14,
2014,
8,
272,
14452,
2229,
48,
28,
13799,
30,
2229,
2689,
83,
3342,
18168,
48,
28,
14885,
27124,
18168,
48,
28,
15732,
30,
2229,
2689,
83,
3342,
9,
12913,
450,
334,
267,
21590,
904,
8,
1130,
8,
264,
14,
3765,
12,
661,
5102,
30243,
7673,
4116,
27,
22645,
267,
21590,
904,
8,
1130,
8,
264,
14,
3765,
12,
661,
3130,
30048,
283,
3196,
26120,
1557,
78,
297,
7673,
3308,
27,
7058,
272,
776,
199,
9,
199,
63,
4129,
63,
2123,
63,
264,
275,
295,
14,
2014,
8,
82,
15542,
51,
11,
32,
59,
65,
13,
6353,
13,
58,
16,
13,
25,
423,
20253,
27658,
65,
13,
6353,
13,
58,
16,
13,
25,
423,
20253,
9988,
199,
63,
1913,
2969,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
25273,
6697,
306,
21521,
28,
28959,
30,
5942,
199,
63,
4502,
63,
264,
275,
295,
14,
2014,
8,
82,
21840,
7059,
27,
2807,
2736,
358,
199,
63,
16415,
275,
283,
23459,
28114,
7,
199,
63,
7022,
275,
283,
11371,
7,
199,
199,
3,
4539,
19768,
6144,
4124,
1338,
367,
314,
8836,
199,
4752,
275,
730,
360,
7718,
804,
297,
11969,
791,
363,
2722,
3706,
2400,
671,
26,
283,
4752,
3071,
342,
199,
199,
3,
5007,
1233,
199,
4672,
63,
600,
275,
663,
342,
199,
199,
9419,
275,
399,
17067,
904,
421,
199,
318,
1067,
1593,
8,
70,
304,
272,
408,
2765,
7531,
883,
506,
1202,
370,
2216,
282,
805,
503,
1083,
1067,
4550,
14,
272,
437,
1067,
4550,
365,
3032,
314,
4702,
520,
533,
1705,
2998,
64,
465,
1642,
1423,
1380,
272,
2797,
687,
314,
1978,
14,
221,
961,
365,
2997,
340,
282,
805,
15061,
370,
664,
2879,
272,
370,
314,
1067,
503,
3423,
2741,
641,
314,
1067,
909,
14,
221,
2104,
2893,
272,
282,
805,
626,
2529,
282,
3355,
769,
402,
1978,
2860,
314,
1453,
272,
1978,
22609,
4293,
3648,
2839,
642,
447,
398,
768,
1100,
1593,
267,
347,
664,
63,
23028,
63,
1247,
8,
1100,
304,
288,
372,
3355,
8,
1100,
14,
23028,
63,
2936,
9,
272,
408,
272,
289,
14,
1100,
1593,
275,
715,
272,
372,
289,
421,
199,
318,
3468,
1100,
1593,
8,
70,
304,
272,
408,
2765,
7531,
883,
506,
1202,
370,
2216,
282,
805,
503,
1083,
465,
376,
3468,
272,
1067,
4550,
14,
221,
961,
365,
8545,
370,
314,
520,
1532,
1705,
1100,
1593,
64,
272,
1325,
3140,
402,
9476,
314,
1067,
12,
376,
11735,
1067,
909,
365,
272,
3032,
14,
221,
2104,
1655,
2556,
3595,
314,
3468,
1067,
12,
1937,
272,
520,
1121,
1705,
2579,
13,
1100,
2313,
339,
2508,
7445,
447,
499,
14,
20,
272,
408,
272,
289,
14,
2579,
1100,
1593,
275,
715,
272,
372,
289,
421,
199,
318,
3734,
1593,
8,
70,
304,
272,
408,
2765,
7531,
883,
506,
1202,
370,
2216,
282,
805,
503,
1083,
465,
3734,
272,
4550,
14,
221,
961,
7531,
5419,
8840,
2839,
314,
520,
1532,
1705,
1100,
1593,
64,
272,
7531,
2951,
626,
314,
1642,
1423,
365,
314,
4702,
520,
533,
1705,
8263,
64,
272,
436,
440,
1067,
14,
272,
408,
272,
289,
14,
5418,
1593,
275,
715,
272,
372,
289,
421,
199,
318,
5007,
600,
8,
70,
304,
272,
408,
6470,
83,
314,
805,
465,
14448,
1202,
624,
272,
5007,
63,
600,
14,
525,
8,
70,
855,
600,
3368,
272,
372,
289,
421,
199,
318,
365,
63,
10705,
8,
1113,
304,
272,
408,
1799,
340,
314,
909,
3032,
365,
10942,
14,
221,
961,
1630,
6548,
1655,
2419,
272,
19203,
376,
1256,
1104,
6169,
520,
533,
1705,
16283,
64,
1325,
10734,
30023,
14,
272,
961,
883,
506,
1202,
367,
3537,
4766,
503,
2295,
626,
2934,
370,
295,
2442,
370,
272,
10942,
2860,
14,
221,
2104,
2893,
282,
3537,
849,
2457,
883,
3648,
2839,
272,
642,
447,
398,
347,
849,
8,
1391,
12,
849,
9280,
288,
340,
365,
63,
10705,
8,
1391,
304,
355,
372,
849,
288,
372,
2729,
272,
408,
272,
687,
10321,
18,
14,
7726,
492,
25868,
272,
372,
1228,
8,
1113,
12,
25868,
9,
421,
199,
318,
9451,
8,
8147,
304,
272,
408,
21042,
83,
376,
6076,
1928,
9689,
7003,
543,
652,
1041,
272,
367,
1566,
315,
6076,
26,
267,
986,
421,
199,
318,
5436,
63,
17595,
837,
272,
408,
42,
4135,
18,
18578,
5007,
18014,
367,
22196,
436,
7103,
1192,
14,
221,
5723,
787,
272,
1202,
880,
626,
17300,
18,
3181,
1133,
1172,
370,
23959,
22196,
436,
7103,
1192,
1006,
272,
314,
900,
14,
221,
24573,
1265,
2793,
1133,
1172,
370,
10296,
3595,
626,
1325,
340,
1265,
787,
272,
15634,
4039,
4402,
13447,
15052,
1265,
1443,
2934,
370,
3633,
314,
18014,
14,
272,
408,
272,
687,
10321,
18,
14,
5418,
492,
485,
83,
678,
84,
13815,
63,
26411,
272,
687,
10321,
18,
14,
11729,
492,
485,
11729,
63,
1637,
272,
485,
83,
678,
84,
13815,
63,
26411,
14,
3584,
342,
272,
485,
11729,
63,
1637,
14,
3584,
342,
421,
199,
318,
492,
63,
875,
8,
646,
63,
354,
12,
10866,
29,
797,
304,
272,
408,
32447,
376,
909,
4079,
641,
282,
1059,
14,
221,
961,
365,
2997,
340,
1265,
2934,
370,
272,
675,
492,
3792,
465,
16173,
503,
6020,
8545,
14,
221,
1626,
492,
931,
883,
272,
506,
2013,
1902,
315,
18947,
15843,
15693,
1652,
14,
14338,
14,
14338,
1208,
14,
3765,
16580,
272,
503,
543,
282,
18307,
465,
909,
11172,
15693,
1652,
14,
14338,
14,
14338,
1208,
26,
3765,
20008,
339,
982,
314,
658,
14434,
64,
365,
715,
314,
372,
574,
911,
506,
658,
403,
64,
340,
314,
492,
272,
6918,
14,
339,
520
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
1208,
272,
32202,
339,
20511,
3423,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
646,
295,
199,
646,
7554,
199,
504,
5055,
492,
15782,
199,
504,
10321,
18,
423,
5819,
492,
1318,
63,
466,
12,
1059,
63,
1313,
12,
9031,
63,
5778,
12,
971,
1362,
18310,
63,
831,
12,
1166,
63,
3513,
421,
199,
63,
1027,
63,
1294,
63,
264,
275,
295,
14,
2014,
8,
82,
13445,
83,
11,
5942,
199,
63,
25181,
63,
264,
275,
295,
14,
2014,
8,
272,
14452,
2229,
48,
28,
13799,
30,
2229,
2689,
83,
3342,
18168,
48,
28,
14885,
27124,
18168,
48,
28,
15732,
30,
2229,
2689,
83,
3342,
9,
12913,
450,
334,
267,
21590,
904,
8,
1130,
8,
264,
14,
3765,
12,
661,
5102,
30243,
7673,
4116,
27,
22645,
267,
21590,
904,
8,
1130,
8,
264,
14,
3765,
12,
661,
3130,
30048,
283,
3196,
26120,
1557,
78,
297,
7673,
3308,
27,
7058,
272,
776,
199,
9,
199,
63,
4129,
63,
2123,
63,
264,
275,
295,
14,
2014,
8,
82,
15542,
51,
11,
32,
59,
65,
13,
6353,
13,
58,
16,
13,
25,
423,
20253,
27658,
65,
13,
6353,
13,
58,
16,
13,
25,
423,
20253,
9988,
199,
63,
1913,
2969,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
25273,
6697,
306,
21521,
28,
28959,
30,
5942,
199,
63,
4502,
63,
264,
275,
295,
14,
2014,
8,
82,
21840,
7059,
27,
2807,
2736,
358,
199,
63,
16415,
275,
283,
23459,
28114,
7,
199,
63,
7022,
275,
283,
11371,
7,
199,
199,
3,
4539,
19768,
6144,
4124,
1338,
367,
314,
8836,
199,
4752,
275,
730,
360,
7718,
804,
297,
11969,
791,
363,
2722,
3706,
2400,
671,
26,
283,
4752,
3071,
342,
199,
199,
3,
5007,
1233,
199,
4672,
63,
600,
275,
663,
342,
199,
199,
9419,
275,
399,
17067,
904,
421,
199,
318,
1067,
1593,
8,
70,
304,
272,
408,
2765,
7531,
883,
506,
1202,
370,
2216,
282,
805,
503,
1083,
1067,
4550,
14,
272,
437,
1067,
4550,
365,
3032,
314,
4702,
520,
533,
1705,
2998,
64,
465,
1642,
1423,
1380,
272,
2797,
687,
314,
1978,
14,
221,
961,
365,
2997,
340,
282,
805,
15061,
370,
664,
2879,
272,
370,
314,
1067,
503,
3423,
2741,
641,
314,
1067,
909,
14,
221,
2104,
2893,
272,
282,
805,
626,
2529,
282,
3355,
769,
402,
1978,
2860,
314,
1453,
272,
1978,
22609,
4293,
3648,
2839,
642,
447,
398,
768,
1100,
1593,
267,
347,
664,
63,
23028,
63,
1247,
8,
1100,
304,
288,
372,
3355,
8,
1100,
14,
23028,
63,
2936,
9,
272,
408,
272,
289,
14,
1100,
1593,
275,
715,
272,
372,
289,
421,
199,
318,
3468,
1100,
1593,
8,
70,
304,
272,
408,
2765,
7531,
883,
506,
1202,
370,
2216,
282,
805,
503,
1083,
465,
376,
3468,
272,
1067,
4550,
14,
221,
961,
365,
8545,
370,
314,
520,
1532,
1705,
1100,
1593,
64,
272,
1325,
3140,
402,
9476,
314,
1067,
12,
376,
11735,
1067,
909,
365,
272,
3032,
14,
221,
2104,
1655,
2556,
3595,
314,
3468,
1067,
12,
1937,
272,
520,
1121,
1705,
2579,
13,
1100,
2313,
339,
2508,
7445,
447,
499,
14,
20,
272,
408,
272,
289,
14,
2579,
1100,
1593,
275,
715,
272,
372,
289,
421,
199,
318,
3734,
1593,
8,
70,
304,
272,
408,
2765,
7531,
883,
506,
1202,
370,
2216,
282,
805,
503,
1083,
465,
3734,
272,
4550,
14,
221,
961,
7531,
5419,
8840,
2839,
314,
520,
1532,
1705,
1100,
1593,
64,
272,
7531,
2951,
626,
314,
1642,
1423,
365,
314,
4702,
520,
533,
1705,
8263,
64,
272,
436,
440,
1067,
14,
272,
408,
272,
289,
14,
5418,
1593,
275,
715,
272,
372,
289,
421,
199,
318,
5007,
600,
8,
70,
304,
272,
408,
6470,
83,
314,
805,
465,
14448,
1202,
624,
272,
5007,
63,
600,
14,
525,
8,
70,
855,
600,
3368,
272,
372,
289,
421,
199,
318,
365,
63,
10705,
8,
1113,
304,
272,
408,
1799,
340,
314,
909,
3032,
365,
10942,
14,
221,
961,
1630,
6548,
1655,
2419,
272,
19203,
376,
1256,
1104,
6169,
520,
533,
1705,
16283,
64,
1325,
10734,
30023,
14,
272,
961,
883,
506,
1202,
367,
3537,
4766,
503,
2295,
626,
2934,
370,
295,
2442,
370,
272,
10942,
2860,
14,
221,
2104,
2893,
282,
3537,
849,
2457,
883,
3648,
2839,
272,
642,
447,
398,
347,
849,
8,
1391,
12,
849,
9280,
288,
340,
365,
63,
10705,
8,
1391,
304,
355,
372,
849,
288,
372,
2729,
272,
408,
272,
687,
10321,
18,
14,
7726,
492,
25868,
272,
372,
1228,
8,
1113,
12,
25868,
9,
421,
199,
318,
9451,
8,
8147,
304,
272,
408,
21042,
83,
376,
6076,
1928,
9689,
7003,
543,
652,
1041,
272,
367,
1566,
315,
6076,
26,
267,
986,
421,
199,
318,
5436,
63,
17595,
837,
272,
408,
42,
4135,
18,
18578,
5007,
18014,
367,
22196,
436,
7103,
1192,
14,
221,
5723,
787,
272,
1202,
880,
626,
17300,
18,
3181,
1133,
1172,
370,
23959,
22196,
436,
7103,
1192,
1006,
272,
314,
900,
14,
221,
24573,
1265,
2793,
1133,
1172,
370,
10296,
3595,
626,
1325,
340,
1265,
787,
272,
15634,
4039,
4402,
13447,
15052,
1265,
1443,
2934,
370,
3633,
314,
18014,
14,
272,
408,
272,
687,
10321,
18,
14,
5418,
492,
485,
83,
678,
84,
13815,
63,
26411,
272,
687,
10321,
18,
14,
11729,
492,
485,
11729,
63,
1637,
272,
485,
83,
678,
84,
13815,
63,
26411,
14,
3584,
342,
272,
485,
11729,
63,
1637,
14,
3584,
342,
421,
199,
318,
492,
63,
875,
8,
646,
63,
354,
12,
10866,
29,
797,
304,
272,
408,
32447,
376,
909,
4079,
641,
282,
1059,
14,
221,
961,
365,
2997,
340,
1265,
2934,
370,
272,
675,
492,
3792,
465,
16173,
503,
6020,
8545,
14,
221,
1626,
492,
931,
883,
272,
506,
2013,
1902,
315,
18947,
15843,
15693,
1652,
14,
14338,
14,
14338,
1208,
14,
3765,
16580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